THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin OP_RETURN Outputs: Data Commitments, Unspendable Scripts, and Relay Policy

permalink THAMER
#bitcoin#data-commitment#nulldata#op-return#policy

OP_RETURN is a Bitcoin Script opcode that immediately makes the executed script fail. When used at the start of an output's locking script, it creates a provably unspendable output. This property makes OP_RETURN useful for recording compact commitments or application data without creating an ordinary UTXO that wallets might later attempt to spend.

What is actually committed?

Every transaction output includes a value and a locking script. A transaction containing an OP_RETURN output commits to that output in the transaction data, which is ultimately committed by the block's Merkle structure once mined. This makes the data publicly observable and tamper-evident within the confirmed transaction history.

An OP_RETURN output does not establish that the attached claim is truthful. For example, an application can commit to a document hash, but a separate verification process is still needed to link the hash to the correct document and interpret its meaning.

Why provably unspendable matters

Full nodes maintain a UTXO set containing outputs that might be spent later. Outputs recognized as provably unspendable do not need to remain as ordinary spendable entries in that set. This is one reason small commitments in OP_RETURN differ operationally from storing arbitrary bytes in spendable output scripts.

The output still occupies transaction and block space and therefore affects fee cost. It is not free storage, and confirmed data cannot simply be removed from the blockchain's historical record.

Consensus versus standard relay limits

Bitcoin Core has applied standardness policy to so-called nulldata outputs, including constraints on data size and accepted output patterns. These defaults have changed across releases and may change again. It is inaccurate to present a particular relay byte limit or number of permitted outputs as an eternal Bitcoin consensus rule.

A consensus-valid transaction with a nonstandard OP_RETURN pattern might be rejected by a default mempool yet still be included directly by a miner. Applications should test against the specific node release and policy they deploy.

Privacy and application design

Do not place secrets, personal data, authentication tokens, or private keys in an OP_RETURN output. Blockchain records are broadly replicated and durable. A hash commitment may reveal less than plaintext, but weak or predictable source material can still be guessed and checked against the public hash.

For many use cases, a short cryptographic digest plus an off-chain document is more practical than publishing the full content. Always document how a verifier interprets the payload and which hash function and encoding were used.

Practical validation

When creating a data-carrying transaction, calculate the resulting virtual size and fee, confirm the output's exact script bytes, and test local mempool acceptance. Treat an accepted broadcast as unconfirmed until a block includes the transaction.

Primary references

Bitcoin Script reference: https://en.bitcoin.it/wiki/Script

Bitcoin Core policy implementation: https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp

Bitcoin developer guide: https://developer.bitcoin.org/devguide/transactions.html

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects