MultiversX Tracker is Live!

Explanation of what an OP_RETURN transaction looks like

Bitcoin Stack Exchange

Bitcoin News / Bitcoin Stack Exchange 122 Views

OP_RETURN is a way to get arbitrary data into the blockchain with less burden to the network

As a consequence, the data will also be present in less clients, as OP_RETURN data can be pruned out.

The goal of this answer is to explain what https://bitcoin.stackexchange.com/a/29555/21282 explained but with a bit more context for Bitcoin newbies.

How a standard transaction looks like

As seen in the JSON disassembly from https://bitcoin.stackexchange.com/a/29555/21282 each transaction has a list of outputs, and each output has a script.

The most common script by far is pay-to-pubkey-hash which basically says:

this output can be consumed by the person who controls the private key to this public key

or in simpler terms "pay X bitcoint to address Y".

That script has format:

OP_DUP OP_HASH160 <length-of-hash> <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

where pubKeyHash is 20 bytes and all other 5 fields are 1 byte.

It is impossible to know if a standard transaction hash is an actual hash or arbitrary data

Because pubKeyHash is a hash, it is impossible to know if that is the actual hash of something, or arbitrary data someone wants to encode into the blockchain.

The catch is: if you add arbitrary data there, you won't have a corresponding private key to claim back those funds. So what people do is to make transactions with the smallest amount possible that miners are willing to take for the verification work.

Now, every transaction in the blockchain takes as input a previous unspent output.

Therefore, embedding this data costs you a little, because that output is unspendable: it can never be used as an input of another transaction.

In order to verify if a transaction is valid, Bitcoin implementations have to keep around a full list of every unspent output ever created, known as the UTXO set.

Spent outputs can be pruned to save space, but unspent ones can't.

Therefore, whenever you burn your fake pubkey hash output, you force every single implementation to keep that information around forever, since those funds can never be spent.

How OP_RETURN solves that problem

OP return is another type of script transaction different from the standard pay-to-pubkey-hash transaction.

As mentioned at: https://en.bitcoin.it/wiki/Script#Provably_Unspendable.2FPrunable_Outputs the transaction has simply the form:

OP_RETURN <data>

OP_RETURN simply stops the script execution with a failure, making it impossible for anyone to use that output as the input of another transaction.

Therefore, when a bitcoin implementation sees that transaction, it can immediately decide that it is unspendable, unlike the pay-to-pubkey-hash transaction above, where it is impossible to make that decision. That's why this transaction is called "provably unspendable".

So the miner can mine if for a mining fee, but then implementations immediately prune it from the UTXO set.

This allows the UTXO set to be smaller, thus making bitcoin more efficient to everyone.

But on the other hand, it also means that your embedded data will be present in less people's computers.


Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments