Difference between revisions of "OP RETURN"

Line 1: Line 1:
'''OP_RETURN''' is a [[Opcodes_used_in_Bitcoin_Script|script]] opcode used to end 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|blockchain]].
+
'''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|blockchain]].
  
 
In 2010 an exploit was discovered in Bitcoin where users could steal anyone's funds leveraging the OP_RETURN opcode. Satoshi Nakamoto modified the opcode to always return false as an urgent fix.
 
In 2010 an exploit was discovered in Bitcoin where users could steal anyone's funds leveraging the OP_RETURN opcode. Satoshi Nakamoto modified the opcode to always return false as an urgent fix.
  
=== Storing data on-chain ===
+
=== Return to original functionality ===
Due to the functionality of this opcode being modified to always return false instead of the top value on the stack, nodes do not validate any opcodes or data in the script after the OP_RETURN.
 
 
 
The max script size was [https://bitcoin.stackexchange.com/questions/38937/what-was-the-original-rationale-for-limiting-the-maximum-push-size limited to 520 bytes] in the Bitcoin client early on (possibly as a justification to prevent DoS attacks), rendering the OP_PUSHDATA opcodes useless. Thus, users of the network leveraged this opcode to store arbitrary data in scripts.
 
 
 
=== Return of OP_RETURN ===
 
 
The [[Genesis_upgrade|Genesis upgrade]] in February 2020 restores the original functionality of the opcode. This will not impact the ability to store arbitrary data on-chain, and it is advised to now use [[False Return]] scripts for applications that still seek to do so.  
 
The [[Genesis_upgrade|Genesis upgrade]] in February 2020 restores the original functionality of the opcode. This will not impact the ability to store arbitrary data on-chain, and it is advised to now use [[False Return]] scripts for applications that still seek to do so.  
  
 
The Genesis upgrade essentially re-enables the original functionality of the push data opcodes via lifting the maximum transaction size such that using a so-called 'OP_RETURN output' is no longer the only means of adding large data items such as JSON formatted text or images into a transaction.
 
The Genesis upgrade essentially re-enables the original functionality of the push data opcodes via lifting the maximum transaction size such that using a so-called 'OP_RETURN output' is no longer the only means of adding large data items such as JSON formatted text or images into a transaction.
 
{{DISPLAYTITLE:OP_RETURN}}
 
{{DISPLAYTITLE:OP_RETURN}}

Revision as of 01:22, 10 January 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 a controversial history in Bitcoin and as a result has been primarily used as a means of storing data on the blockchain.

In 2010 an exploit was discovered in Bitcoin where users could steal anyone's funds leveraging the OP_RETURN opcode. Satoshi Nakamoto modified the opcode to always return false as an urgent fix.

Return to original functionality

The Genesis upgrade in February 2020 restores the original functionality of the opcode. This will not impact the ability to store arbitrary data on-chain, and it is advised to now use False Return scripts for applications that still seek to do so.

The Genesis upgrade essentially re-enables the original functionality of the push data opcodes via lifting the maximum transaction size such that using a so-called 'OP_RETURN output' is no longer the only means of adding large data items such as JSON formatted text or images into a transaction.