OP_RETURN

Revision as of 01:26, 10 January 2020 by Joshua Henslee (talk | contribs)

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.

Reverting to be able to return a value will enable more robust scripts to be created for example scripts can now return different values based on conditional logic.