> For the complete documentation index, see [llms.txt](https://hub.bsvblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hub.bsvblockchain.org/wiki/bitcoin-script-and-opcodes/script/op-return.md).

# OP RETURN

**OP\_RETURN** is a script opcode used to terminate the script and return the top value on the stack. This opcode is analogous to the return function in programming languages. The OP\_RETURN opcode has seen its functionality modified several times in its history in Bitcoin and as a result, has been primarily used as a means of storing data on the ledger.

1. OP\_RETURN Functionality OP\_RETURN terminates the script leaving the stack as-is and letting the result on top of the stack determine the success or failure of the script. Note that if the top stack is non-empty and non-zero (zero including a string of zeros, of zero bytes), then it is considered as successful. Otherwise, it is considered as fail.
2. False Return One of the most common uses of OP\_RETURN is to create False Return scripts that can be used to generate provably unspendable transaction outputs. The most common usage of these scripts is to hold arbitrary formatted data for use in Application Layer Protocols. False Return outputs can be used to hold data, information pertaining to ownership rights, software elements, art and more.
3. Use in conditional logic OP\_RETURN can be used in combination with flow control opcodes to implement branching and other conditional logic in scripts. The insertion of an OP\_RETURN opcode in an IF loop, can allow a script to terminate without having to exit the IF loop, saving computation and reducing the cost of processing the transaction.
4. Commentary: Is storing data in the blockchain acceptable? In a word, yes. The Bitcoin ledger and the blockchain that secures it, operate on the free market premise of user pays. If a user wishes to use the ledger to store data of any type, the only requirement upon them is they must pay for the space needed to store it. This mechanism guards the ledger from abuse by allowing node operators to set a floor in the price of ledger space, while also allowing nodes to compete to provide users with lower cost services. It is node operators who decide which transactions they will accept into the blocks they append to the blockchain, and as such anyone seeking to use the ledger as a data storage medium, must meet the market in terms of the price they pay. Over time it is expected that the cost of ledger space will fall, not just in terms of the price in satoshis, but in dollar terms as well. The ledger scales with technology and commensurate falls in price that comes with the unlocking of new and lower cost storage media, which will translate to larger swathes of ledger space becoming available for less fees.
5. Example The below script is a Metanet node that attaches the Metanet data to a UTXO with funds. This can be used to ensure that Metanet nodes are left in the UTXO set. | Inputs | Outputs | |--------|---------| | metaParent> metaParent> script> script> | DUP HASH160 script> EQUALVERIFY CHECKSIG RETURN metaNode> metaParent> |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hub.bsvblockchain.org/wiki/bitcoin-script-and-opcodes/script/op-return.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
