Overview
OP_RETURN is a Bitcoin Script opcode that immediately marks a transaction output as invalid for spending. Any output containing OP_RETURN is provably unspendable, meaning the bitcoin sent to it is permanently removed from circulation. However, the output can carry up to 80 bytes of arbitrary data, which is permanently recorded in the blockchain.
How It Works
Standard OP_RETURN output:
scriptPubKey: OP_RETURN <data up to 80 bytes>
value: 0 satoshis (typically)
Example uses:
OP_RETURN "Hello, Bitcoin!" ← Text message
OP_RETURN <SHA256 hash of document> ← Timestamp proof
OP_RETURN <protocol-specific data> ← Colored coins, etc.
When a node encounters OP_RETURN during script execution, it immediately returns false, making the output unspendable. Bitcoin Core nodes recognize this pattern and do not add OP_RETURN outputs to the UTXO set, saving memory.
Use Cases
- Timestamping: Embedding a hash of a document proves the document existed at the time the transaction was mined
- Commitment schemes: Anchoring the state of external systems (sidechains, databases) to Bitcoin's timeline
- Asset protocols: Early colored coin protocols and some token systems used OP_RETURN to encode metadata
- Proof of existence: Services like OpenTimestamps use OP_RETURN to create tamper-proof timestamps
Why OP_RETURN Matters
Before OP_RETURN was standardized, users who wanted to embed data in Bitcoin would create fake spendable outputs (e.g., encoding data as an address). These outputs bloated the UTXO set because nodes could not know they were unspendable. OP_RETURN provided a clean, explicit way to embed data without polluting the UTXO set.
Common Misconceptions
OP_RETURN does not allow unlimited data storage on Bitcoin. The standard relay rules limit OP_RETURN data to 80 bytes, and only one OP_RETURN output per transaction is relayed by default. While miners can include non-standard transactions, the protocol is not designed as a general-purpose data storage system. Ordinals inscriptions use a different mechanism (witness data) for larger data embedding.