Adding custom data to bitcoin transaction

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 StremovskyParanoid Security Guy
For the past 15 years I’ve been leading the evolution of startups and enterprises to achieve the highest level of security and compliance. Throughout my career I’ve been a Cyber Security expert and advanced solutions architect with many years of hands on experience both on offensive and defensive side. Knowledgeable at the highest level in application development, networking, data and databases, web applications, large scale Software as a Service solutions, cloud security and blockchain technologies.

I’ve been working with CISO’s of international enterprises, helping them set Information Security strategy, and overseeing the implementation of these recommendations. As part of these projects, I’ve been assisting companies to achieve compliance in GDPR, PCI, HIPAA and SOX.

Among my credits, I was a founder of a database security company GreenSQL/Hexatier which was acquired by Huawei and I’ve co-founded, Secure multi-signature Crypto wallet.

Specialties: Software and cloud architecture, Compliance (GDPR, HIPAA, PCI, SOX), blockchain technologies, software development, secure architectures, project management and low level research.