Jump to content
The Coin Wire

Crypto moves, protocols and policy

OP_RETURN data stays outside Bitcoin’s spendable UTXOs

How does OP_RETURN store data in a Bitcoin transaction? It pushes bytes into an unspendable output, with relay policy, transaction size and fees setting practical limits.

By The Coin Wire Editorial5 min read

OP_RETURN data stays outside Bitcoin’s spendable UTXOs

OP_RETURN stores data in a Bitcoin transaction by placing bytes in an output’s scriptPubKey after the OP_RETURN opcode, making the output provably unspendable. Because script execution stops at OP_RETURN, nodes do not add that output to the UTXO set, even though the transaction bytes remain in the blockchain.

That trade-off is useful when a protocol needs a permanent, publicly readable record without creating another spendable output for every record. TeleSwap is a decentralized bridge and swap service that uses on-chain transaction details to coordinate Bitcoin deposits with activity on other chains; its Bitcoin deposits put the EVM recipient and chain in OP_RETURN for the bridge contract to parse. The TeleSwap background adds context for how a bridge can use those bytes as instructions for its own verification process.

What does OP_RETURN store in a Bitcoin transaction?

An OP_RETURN output stores a byte sequence in its scriptPubKey, the locking script normally used to define how an output can be spent. The script begins with OP_RETURN, followed by a push instruction and the data. In a constructed illustration, 6a 04 74 65 73 74 means OP_RETURN, push four bytes, then the bytes for “test.” The data is not a Bitcoin address or a separate transaction field; it is part of the output script recorded in the transaction.

The bytes can represent a protocol tag, identifier, commitment or other data a reader knows how to interpret. OP_RETURN itself does not define what those bytes mean. A bridge or other application needs its own rules to recognize and parse them.

Why is an OP_RETURN output unspendable?

An OP_RETURN output is unspendable because executing its script reaches an opcode that immediately fails. There is no later condition or secret that can make the output spendable. Nodes can identify the output from the start of its scriptPubKey and skip it when maintaining the UTXO set.

That matters for long-term node storage. A normal output remains in the UTXO set until it is spent, so data disguised as a fake address can leave an unspendable entry there indefinitely. OP_RETURN provides a clearer signal: keep the transaction in the blockchain, but do not carry its output forward as a coin that might be spent. A node may prune old block files under its own storage settings, but pruning changes that node’s local copy; it does not erase the confirmed transaction from the blockchain history maintained elsewhere.

Consider a constructed illustration: before an OP_RETURN output is added, a transaction has its usual payment outputs. After adding one, those payment outputs can stay the same, but the transaction gains another output containing the data and takes more space. The added output does not create a spendable balance because the script cannot be satisfied.

How much data fits after OP_RETURN?

The practical limit depends on relay policy, not a single Bitcoin consensus limit for OP_RETURN data. For years, Bitcoin Core’s default relay policy capped the data payload at 80 bytes. That payload needs script overhead too: a push of up to 75 bytes can use a one-byte length opcode, while pushes above 75 bytes need OP_PUSHDATA1 and a following length byte.

Bitcoin Core 30 raised the default -datacarriersize setting to 100,000, effectively allowing data up to the transaction-size limit, and permits multiple data-carrier outputs under the shared limit. That is a default policy change, not a change to the rules for valid blocks. Node operators can configure different relay policies, so an output accepted by one node may not be relayed by another. A miner can still include a consensus-valid transaction that a node’s local policy would not relay.

Do OP_RETURN outputs cost extra fees?

OP_RETURN data costs fees because it adds bytes to the transaction, and transaction fees are paid according to the transaction’s virtual size and fee rate. A larger payload generally means a larger transaction and a higher fee at the same rate. The output usually carries zero satoshis, so its cost is the extra transaction space rather than a payment locked in the output.

For a small protocol marker, that overhead may be modest; for a larger payload, the fee and competition for block space matter more. The fee rate can change with demand, so there is no fixed price per byte that applies to every transaction. The deciding factors are payload size, transaction structure and the rate the sender chooses to pay.

What is the difference between OP_RETURN and inscriptions?

OP_RETURN places data in an output script, while Ordinals inscriptions place their content in a Taproot spend’s witness data. Both can leave data in transaction history, but they use different parts of a transaction and have different fee effects. Witness data receives a discount in Bitcoin’s virtual-size accounting, while an OP_RETURN output adds bytes to the non-witness transaction structure.

OP_RETURN’s defining trade-off is simple: the output is deliberately unspendable and excluded from the UTXO set, but the record still occupies blockchain space. An inscription uses a spend path and witness data rather than a data-carrier output. Neither method makes the on-chain data executable as a Bitcoin smart contract.

Can OP_RETURN data be deleted from the blockchain?

Confirmed OP_RETURN data cannot be selectively deleted from the blockchain by its sender. Once a transaction is included in a block, the data remains part of that block’s history under Bitcoin’s consensus rules. A node operator may prune old blocks from local storage, but that only removes the node’s local copy; other nodes and archival services may still retain it.

For readers, the useful distinction is between a permanent record and a spendable coin. OP_RETURN gives protocols a way to publish bytes in a transaction while keeping those bytes out of the UTXO set, because the opcode makes the output provably unspendable. The practical limits to watch are each node’s relay policy and the fee for the transaction space used.