OP_RETURN Data Embeds
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.
-
The Rule: If a script starts with
OP_RETURN, it can never be spent. -
The Benefit: Because the node knows these coins can never be spent, it doesn't need to store this output in the UTXO Set (Chainstate). This prevents "UTXO bloat."
2. Storing Data
Any data pushed after the OP_RETURN opcode is saved on the blockchain forever.
-
Limit: Standard policy allows for 80 bytes of data.
-
Cost: You must pay a transaction fee based on the size of the data, and the satoshis sent to this output are burned (lost forever).
3. Common Use Cases
-
Timestamping: Proving a document existed at a certain time by hashing it and storing the hash in
OP_RETURN. -
Omni / Tether: Early versions of Tether used
OP_RETURNto track token transfers on top of the Bitcoin ledger. -
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.
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: