OP_RETURN

The carrier itself

A broadcast nobody can spend.

OP_RETURN is the one place in a Bitcoin transaction where you can put bytes and honestly tell the network you are not asking it to remember them as money. Understanding what that costs and what it does not cost is the whole point of this page.

Output anatomy

An OP_RETURN output is an ordinary transaction output with a value (almost always zero satoshis) and a scriptPubKey that begins with the byte 0x6a. Everything after that byte is data pushes. The organisation's readers assemble the payload by concatenating every push in order.

byte 06aOP_RETURN
byte 134direct push, 52 bytes
bytes 2..537b 22 70 22 3a 22 6f 70 2d 32 30 22 ...payload, UTF-8 JSON

Frame: a 54 byte scriptPubKey carrying a 52 byte OP-20 mint payload. Total transaction weight cost is driven by the script length, not by the value field.

Push encodings the readers accept

Push opcodes recognised inside an OP_RETURN carrier
OpcodeByteLength sourcePrefix size
OP_00x00zero length push1 byte
direct push0x01 to 0x4bthe opcode is the length1 byte
OP_PUSHDATA10x4cnext 1 byte2 bytes
OP_PUSHDATA20x4dnext 2 bytes, little endian3 bytes
OP_PUSHDATA40x4enext 4 bytes, little endian5 bytes

Any other opcode inside the carrier makes the payload unreadable to the OP-20 and OP Names decoders, which raise protocol_mismatch rather than guessing. A truncated push, where the declared length runs past the end of the script, is rejected the same way.

Provably unspendable

When a script is evaluated, OP_RETURN marks the transaction as invalid immediately. There is no witness, signature, preimage or future soft fork that lets you satisfy it. This is different from an output that merely looks hard to spend: it is a proof, checkable by anyone, that no spend exists.

The practical consequences are worth stating plainly:

  • Any value you attach to an OP_RETURN output is destroyed. Use zero.
  • You cannot recover an OP_RETURN output by "sweeping" a wallet, because there is nothing to sweep.
  • Nothing about the payload gives anyone rights over anything. Ownership in the protocols on this carrier is expressed by other outputs in the same transaction, not by the OP_RETURN itself.
The receipt output matters more than the data

In OP Names, the payload names the asset, but the owner comes from a separate spendable output in the same transaction. Losing track of which output is the receipt is a much more common failure than mis-encoding the payload. See rules R-NAME-8 through R-NAME-13.

Prunable from the UTXO set

Because the output is provably unspendable, a node has no reason to keep it in the set of outputs it must track in order to validate future transactions. Full nodes therefore skip OP_RETURN outputs when building the UTXO set. This is the technical reason OP_RETURN is considered the polite way to attach data to Bitcoin.

An OP_RETURN output living outside the UTXO set A transaction has three outputs. Output zero is an OP_RETURN data carrier with zero value. Output one and output two are ordinary spendable payments. The two spendable outputs are added to the node's UTXO set, drawn as a bounded box that every node must keep in memory. The OP_RETURN output is drawn outside that box, connected only to the block data on disk, showing that the bytes remain in block history forever while imposing no lasting UTXO set cost. TRANSACTION vout 0: OP_RETURN 0 sats, 6a + payload vout 1: P2WPKH 546 sats, spendable vout 2: change spendable tracked UTXO set every validating node keeps this in memory or on disk 2 entries from this tx never added Block on disk payload kept forever Indexer state rebuilt by replaying blocks, not from UTXOs
Permanence without ownership: the bytes survive in block history, but no node has to carry them in the set it validates against.

Note the second consequence, which matters for anyone writing software here: because indexers cannot read protocol state out of the UTXO set, they must replay blocks. That is exactly what the Bitcoin Universe OP Names authority does, and it is why its state can be rebuilt deterministically from a chosen start height.

Relay and standardness

Whether a node forwards your transaction is policy, not consensus. A transaction that no node will relay is still perfectly valid if a miner includes it.

  • Bitcoin Core carried a default data carrier limit of 83 bytes for the whole scriptPubKey for many years. That is OP_RETURN plus a one byte push prefix plus 80 payload bytes.
  • Under that default policy a transaction with more than one data carrier output was also non standard.
  • Bitcoin Core version 30 removed that default cap, so a node running current defaults will relay larger OP_RETURN outputs. Older nodes, alternative implementations and individual relay operators may still apply their own limit.
Design for the narrow case

If you want a payload to propagate everywhere, keep the whole scriptPubKey at 83 bytes or less and use exactly one data carrier output per transaction. Both OP-20 and OP Names require a single carrier anyway, for reasons that have nothing to do with relay: see rules R-20-2 and R-NAME-3.

The Bitcoin Universe OP Names reader applies its own hard bound of 4096 assembled payload bytes and records anything larger as payload_too_large evidence. That is an indexer safety bound, not a network rule.

What it costs

An OP_RETURN output costs fee for its size and nothing else, permanently. There is no dust threshold to satisfy because the output holds zero value, and there is no future spending fee because it can never be spent.

Approximate on-chain size of a single data carrier output
PayloadPush prefixscriptPubKeyOutput total
11 bytes, a short name1 byte13 bytes22 bytes
52 bytes, an OP-20 mint1 byte54 bytes63 bytes
80 bytes, the classic maximum1 byte82 bytes91 bytes
220 bytes2 bytes, PUSHDATA1223 bytes232 bytes

Output total counts 8 bytes of value plus the script length prefix plus the script. Every byte here is non witness data, so it is charged at four weight units per byte.

That last point is the honest cost comparison: OP_RETURN data is never discounted. Data in a witness is.

Compared with other carriers

Three families of technique put data on Bitcoin, and they make genuinely different trade offs. This is the part most easily misrepresented, so the differences are stated in mechanism terms.

Data carrier techniques compared
PropertyOP_RETURN outputWitness envelopeData in spendable outputs
Where the bytes livescriptPubKey of an outputwitness of an input, inside an unexecuted script branchthe output scripts themselves, for example fabricated keys in a bare multisig
Spendableneveryes, the committing output is ordinarytechnically yes, in practice not by anyone
Enters the UTXO setnono, the witness is input datayes, and it stays there
Can nodes forget ityes, immediatelyyes, witness data can be pruned by nodes that keep only headers and the UTXO setno, entries persist until spent, and they usually never are
Fee treatmentfull four weight units per byteone weight unit per byte, a four times discountfull four weight units per byte, plus a dust value per output
Practical sizesmall, tens to a few hundred byteslarge, hundreds of kilobytesmedium, and expensive in both fee and lasting node cost
Reveal timingimmediate, one transactioncommit then reveal, two transactionsimmediate, one transaction

Witness envelopes

An envelope hides content inside a taproot script path that is never executed, then reveals it when the committing output is spent. The content is cheap because witness bytes are discounted, and it is prunable because it is input data rather than an output. What it costs you is a two transaction ceremony and a much larger reveal transaction. Ordinals inscriptions are the well known example of this family, and they are documented elsewhere in the Bitcoin Universe estate.

Unprunable outputs, the Stamps approach

Bitcoin Stamps (SRC-20) takes the deliberately opposite position: encode data into outputs that a node cannot discard, historically by splitting the data across fabricated public keys in a bare multisig output. The stated goal is that the data cannot be pruned away even in principle, because it sits in the UTXO set. That is a real property, and it is bought by imposing a lasting cost on every node, plus a dust value per output. Stamps originated outside this organisation.

The honest summary

OP_RETURN buys permanence in block history at zero lasting UTXO cost, and pays for it with full price bytes and a small practical size. It does not make data "more permanent" than a witness envelope: both live in blocks forever. What it changes is who has to keep carrying the weight.

Pitfalls

  • Sending value to the data output. Those satoshis are gone. Always set the value to zero.
  • Two data outputs. OP-20 rejects a transaction that carries two OP-20 payloads, and OP Names marks any transaction with more than one OP_RETURN as ambiguous_op_return and applies nothing.
  • Assuming the payload proves ownership. It does not. It names an intent. The receipt output decides who owns the result.
  • Assuming an indexer saw it. A valid payload that no indexer replayed is invisible to every product. Confirmation on chain and visibility in an application are separate events.
  • Spending an asset bearing UTXO as fee change. Protocol assets on this carrier ride ordinary looking outputs. Wallets that do not screen their coin selection will destroy them. See funding safety.