Adding custom data to bitcoin transaction

As you probably know, most of the people talk about Bitcoin blockchain as to distributed ledger, meaning it is a distributed database of transactions. The are some ways that allow to embed in this database of transactions additional information. In this article I am going to cover one of the official techniques. By embedding data in transactions using this methods, your new transactions will be saved to the blockchain and not filtered.

Why you actually want to do it?

  • Stenography – you want to hide something for the years to come in every bitcoin node.
  • You are looking for reliable distributed database (this is costly).
  • Adding 3rd part application id to the bitcoin transaction.
  • You are wallet developer and you want all your transactions marked in a special way.
  • Proof of existence for documents. You can hash document and save this data in bitcoin transaction.
    Example for such service is

In this article I am going to deep dive into the “Hello World” message embedded in this transaction:
tx 6dfb16dd580698242bcfd8e433d557ed8c642272a368894de27292a8844a4e75
Other similar example can be found here:
tx 968a6d9afc4eadda6b12be6e2a31c05358419200af79bda22d63302bff01efd7

Price depends on the transaction size. Adding additional data to transaction actually make the transaction longer. As a result you will pay a bit more for the transaction to be mined in a reasonable time.

How this method actually works?
From the technical perspective it is very easy, you need to add additional receiver of the funds with zero sum. This receiver will receive 0 satoshies. This receiver’ bitcoin script should have the following code:

OP_RETURN {80 bytes of whatever data you want}

For example lets take a look at the “hello-world” transaction above. It has the following hex value:


After decoding it, you will get something as following (I deleted 2 unrelated addresses in vout)

hello world bitcoin transaction

Now, lets decode the hex message: “6a0b68656c6c6f20776f726c64”.
0x6A is a OP_RETURN Bitcoin script operation
0x0b – length of the data following
0x68656c6c6f20776f726c6 – “hello world” message in hex. You can use this table to decode: Ascii table.

Other ideas
If you actually do not need the money transferred in the transactions, you can hide the data in the target address of the transaction. As long as you do not care about the money, target address can contain any information.

PS. I am not the author of the original hello world transactions. I just found it when researching this topic.

About the author

Yuli Stremovsky
Yuli StremovskyKesem.IO CTO
Yuli is experienced software security architect, is a co-founder of Kesem.IO, working as a company CTO.
KESEM.IO is creating a trusted, fast, secure and easy to use solution to guarantee mobile payments on blockchain enabled digital assets.
Before Kesem.IO, Yuli was a founder of a database security company GreenSQL/Hexatier which was acquired by Huawei.

Some my code is available at:

Leave a Reply

Your email address will not be published. Required fields are marked *