TeachMeBitcoin

OP_RETURN Data Embeds

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

OP_RETURN: Data Embeds

Not every transaction output is meant to be spent. Bitcoin allows for a special type of ScriptPubKey called OP_RETURN, which is used to store arbitrary data on the blockchain.

1. How it Works

The OP_RETURN opcode terminates script execution immediately.

2. Storing Data

Any data pushed after the OP_RETURN opcode is saved on the blockchain forever.

3. Common Use Cases

  1. Timestamping: Proving a document existed at a certain time by hashing it and storing the hash in OP_RETURN.

  2. Omni / Tether: Early versions of Tether used OP_RETURN to track token transfers on top of the Bitcoin ledger.

  3. Colored Coins: Assigning external value to specific Bitcoin outputs.

4. Hex Structure

An OP_RETURN script usually looks like this in hex: 6a (OP_RETURN) + [Push Data Opcode] + [Actual Data]

Example: Storing the text "Hello" 6a (OP_RETURN) + 05 (Push 5 bytes) + 48656c6c6f ("Hello" in hex)

Feature OP_RETURN Output
Spendable? No
UTXO Set? No (Prunable)
Data Limit 80 Bytes (Standard)
Opcode Hex 0x6a

In the next section, we will discuss the Serialization and Address relationship.

☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!