Difference between revisions of "OP RETURN"

Line 1: Line 1:
'''OP_RETURN''' is a [[Opcodes_used_in_Bitcoin_Script|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 a [[History_of_OP_RETURN|controversial history]] in Bitcoin and as a result has been primarily used as a means of storing data on the [[block chain]].
+
'''OP_RETURN''' is a [[Opcodes_used_in_Bitcoin_Script|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_of_OP_RETURN|history]] in Bitcoin and as a result has been primarily used as a means of storing data on the ledger.
  
 
===OP_RETURN Functionality===
 
===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. OP_RETURN can be used in combination with [[Opcodes_used_in_Bitcoin_Script#Flow_control|flow control]] opcodes to implement branching, conditional logic in scripts.
+
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.
 +
 
 +
=== 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]].
 +
 
 +
OP_RETURN can be used in combination with [[Opcodes_used_in_Bitcoin_Script#Flow_control|flow control]] opcodes to implement branching, conditional logic in scripts.
  
 
===Example===  
 
===Example===  

Revision as of 03:31, 19 May 2020

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.

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.

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.

OP_RETURN can be used in combination with flow control opcodes to implement branching, conditional logic in scripts.

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
<sigmetaParent> <pubKeymetaParent> <sigscript> <pubKeyscript> DUP HASH160 <pkhscript> EQUALVERIFY CHECKSIG RETURN <meta> <pkmetaNode> <txidmetaParent>