Opcode number: 106
Short description: Fail the script immediatly (must be executed).
OP_RETURN is an opcode in bitcoin's scripting system that allows for the inclusion of a small amount of arbitrary data in a transaction. This opcode immediately marks the transaction output as unspendable, ensuring that the output can't be used as an input in a subsequent transaction. It's primarily used to embed arbitrary data in the blockchain.
- Terminate the script execution unsuccessfully. Any transaction output with this opcode is not spendable, but the data after
OP_RETURNremains permanently on the blockchain. It's a way of declaring that the output can't be spent, and it's only here for the data.
OP_RETURNis commonly followed by a pushdata operation that determines the length of the data to be embedded, and then the data itself.
- The maximum number of bytes that can follow an
OP_RETURNopcode is 80.
OP_RETURNoutputs are used for various purposes, from proving the existence of a particular piece of data at a certain point in time to more complex protocols built on top of bitcoin.
- Historically, there were debates around the use of
OP_RETURNbecause embedding data into the bitcoin blockchain adds to its size without directly supporting the transfer of bitcoin.
Embedding the string "HELLO" into the blockchain:
# ASM script
OP_RETURN OP_PUSHBYTES_5 48454c4c4f
# Raw script
# Script result
Output is unspendable and contains the data "HELLO".