How to Write Permanent Messages on the Bitcoin Blockchain

Bitcoin's OP_RETURN operation code allows anyone to write censorship resistant messages on the blockchain.

How to Write Permanent Messages on the Bitcoin Blockchain

Bitcoin's OP_RETURN operation code allows anyone to write censorship resistant messages on the blockchain.

From the very beginning of Bitcoin, the creator Satoshi Nakamoto etched some hidden text in the details of the first ever transaction: “The Times 03/Jan/2009 Chancellor on brink of second bailout for banks

Including the headline of The Times newspaper into the very first Bitcoin block demonstrated to the world that the distributed ledger could be used to timestamp important events, going beyond the Bitcoin blockchain's purpose as a store of financial data.


Given Bitcoin’s properties of immutability, censorship resistance and accessibility, publishing data of all sorts (not just financial data relating to the Bitcoin payment network) can be achieved in a transparent and tamper-proof way. While Satoshi used the coinbase transaction to embed a message within the coinbase data field, this method of storing arbitrary data is available only to miners. Other ways of inscribing data into the blockchain have been a bit more controversial.

You can read all of the messages that have ever been left on the Bitcoin blockchain with

Many of the early methods of storing non-financial data on Bitcoin's public ledger (such as 'Pay-to-Fake-Public-Key Hash') had an adverse effect of increasing the number of UTXOs, forcing full nodes to retain a growing number of transactions in memory. Consequently, using the blockchain to store non-financial data became perceived as 'digital pollution', since it imposes a cost on everyone else in the form of higher transaction fees and greater storage requirements to run a node.

Posting messages to the distributed ledger means that more bits are included into a transaction. If there are more bits in a transaction, then the block becomes larger. As this sort of activity increases and more blocks include additional data, it becomes more demanding for people to spin up their own nodes as the storage requirements are ever increasing.

To reduce these costs associated with storing arbitrary data using inefficient methods, Bitcoin Core developed released the OP_RETURN script operator in 2014.

What is OP_RETURN?

Basically, OP_RETURN is a function to store information on the blockchain. It enables users to add 80 bytes of arbitrary data in an unspendable transaction without bloating the size of the blockchain.

This operation code (or opcode) is also known as "time-stamping of write information" since the message will become part of a block with a timestamp as well.

The way OP_RETURN overcomes the problems associated with prior methods of storing information in the Bitcoin network is as follows: nodes can decide whether to store the output of the transaction in their UTXO set. In turn, this reduces the on-chain footprint of transactions containing arbitrary data and slows the growth in the storage requirements to run a node.

How is OP_RETURN Used in Bitcoin?

You can create your own messages that will be embedded onto the blockchain and remain there forever with the OP_RETURN opcode. The screenshot below displays a message from someone called Charley declaring their love for Heidi:


Source: Blockchair.

The decoded love message shown above is actually inputted onto the public ledger as hexadecimal information (where 80 bytes translates to 160 hexadecimal characters). For the screenshot above, the transaction is executed with Bitcoin's scripting language Script and actually looks like this:


Source: learn me a bitcoin.

This code is basically a locking script, placing a lock on the output and certain conditions to claim the coins. But the OP_RETURN opcode is an instruction to the scripting language to immediately end execution of the script. Nodes will know that the outputs are provably unspendable and can remove them from the UTXO set, freeing up space for regular transactions.

Taking the hexadecimal information from this OP_RETURN transaction (636861726c6579206c6f766573206865696469) and converting it to string, you get the same decoded message shown by Blockchair's block explorer:



Besides novelty use cases, OP_RETURN has also been utilised in a wide variety of applications. For example, protocols like Omni have created assets (such as Tether in late 2014) on top of Bitcoin's ledger without the need for a dedicated blockchain. Most of the activity around Tether has since shifted to other blockchains such as Ethereum in late 2017 and Tron during April 2019.

An example OP_RETURN transaction for Omni is illustrated below. The transaction doesn't include any addresses since Omni reuses the sender and receiver addresses of the Bitcoin transaction itself.

Source: Blockchain Research Lab.

OP_RETURN also plays an important part in a stealth address scheme known as PayNym, which allows you to receive Bitcoin payments without having to reveal your public key or address. Instead of giving someone your public key or address to pay you, you can give them a BIP47 reusable payment code to prevent whoever's paying you from seeing your Bitcoin balance or any past transactions.

Bitcoin is not unique when it comes to permanent, censorship resistant messages on the blockchain. It's possible with Dogecoin and Litecoin since these cryptocurrencies have Bitcoin’s codebase as their foundation. An example of a message that's been recorded permanently on the Dogecoin blockchain ('To the Moon!!!') is illustrated below:



Writing Your Own Messages On the Bitcoin Blockchain

There are several cryptocurrency wallets that include Bitcoin's OP_RETURN that allow you to etch a message into the distributed ledger (three of which are listed below).

When using this opcode, it's important to remember that you can only include a maximum of 160 hexadecimal characters and the longer the message, the higher transaction fee you'll pay.

1. Moonshine

Moonshine is an open source, non-custodial Bitcoin and Litecoin mobile wallet. The wallet is available on both Android and iOS.

It's pretty simple to write a message to the blockchain, as when you go to send a transaction within the Moonshine wallet, you'll see an option to include a message as part of the transaction.


Under the hood, there's actually two transactions here since OP_RETURN transactions make coins unspendable. A zero-valued output containing the message is created along with the actual transaction, they are combined into one and the fee is slightly higher to cover the two transactions as if they were only one.

That way you can send your Bitcoin somewhere with a regular transaction and publish the data to the blockchain without making any of your coins unspendable (since the OP_RETURN transaction contains zero outputs).

Once confirmed, you can search the transaction ID with a block explorer such as Blockchair and view the decoded message that has been permanently inscribed on to Bitcoin's public ledger under 'OP_RETURN':


2. imToken

Another option is imToken, another mobile wallet that's available on both Android and iOS.

When sending a transaction with imToken, click on the 'Advanced' button and then you can enter your message. However, unlike Moonshine's wallet, you cannot just enter the raw text. You'll have to enter your message in the hexadecimal format instead.


3. Trezor

The third wallet in our list that also comes with OP_RETURN functionality is the popular hardware wallet Trezor.

When you're going to send Bitcoin, simply click on the button at the bottom right-hand corner and select 'Add OP_RETURN'. Write your desired message in the 'Data (text)' field, check the fee before confirming the transaction and then click 'Send'.


If you ever want to propose to your partner in a unique way, commemorate an important event or just make your mark on the blockchain, now you know how to do so!

-The Rollbit Team