Author

Topic: How to add arbitrary 40 byte data per transaction. (Read 1312 times)

donator
Activity: 1218
Merit: 1079
Gerald Davis
Won't the sent amount just all go towards miners fees or is the "correct way" of putting data really to create unspendable dust?

The most common method is to create an otherwise normal txn (with any amount of fees you desire) and then ADD a zero value OP_RETURN output.  They can be pruned because the only outputs which are needed to validate future outputs are spendable outputs.  Normal outputs are pruned once they are spent as a spent output is no longer spendable.  OP_RETURN outputs are by definition never spendable so they can be pruned immediately.

To validate transactions requires maintaining a copy of the UTXO.  This is a more critical resources than the raw blockchain.  Your node doesn't use raw blocks locally for anything other than building the UTXO.  The UTXO is used to validate all future txns and blocks.  OP_RETURN can be excluded from the UTXO as are outputs once they are spent.
sr. member
Activity: 250
Merit: 253
Won't the sent amount just all go towards miners fees or is the "correct way" of putting data really to create unspendable dust?
The OP_RETURN output can be 0 value. If your input(s) are larger than the fee you need to pay, you can put the rest of the money into an ordinary output, as change. Or if you have an input that's just the right size, you can include just the one output, e.g. as done in this transaction https://blockchain.info/tx/064c3364055cc2d862f9320279e486b95a169806aac315333bb035a5ee684891

I wouldn't call it "dust" since it's 0 value and known-pruneable. It can't be spent, but it's 0 value so it didn't destroy any bitcoins in the process of creating it.
hero member
Activity: 815
Merit: 1000
Won't the sent amount just all go towards miners fees or is the "correct way" of putting data really to create unspendable dust?
legendary
Activity: 1176
Merit: 1015
How do you add 40 bytes of data into the blockchain?

You can use the OP_RETURN opcode.  

An output that has a spending script of "OP_RETURN " will be accepted by miners.

It is not spendable though, since OP_RETURN just means mark output as invalid.

There are other ways to do it, but using OP_RETURN means you aren't "polluting" the chain.  Since the output is known not to be spendable, it doesn't have to be remembered in RAM.  It is still remembered on disk though.

Thanks Smiley
legendary
Activity: 1232
Merit: 1094
How do you add 40 bytes of data into the blockchain?

You can use the OP_RETURN opcode.  

An output that has a spending script of "OP_RETURN " will be accepted by miners.

It is not spendable though, since OP_RETURN just means mark output as invalid.

There are other ways to do it, but using OP_RETURN means you aren't "polluting" the chain.  Since the output is known not to be spendable, it doesn't have to be remembered in RAM.  It is still remembered on disk though.
legendary
Activity: 1176
Merit: 1015
How do you add 40 bytes of data into the blockchain?
Jump to: