13

I want to add some additional information to my specific transaction, so that I can send the additional information to blockchain.

  • possible duplicate of How to send bitcoin with a message attached – Jozef Oct 15 '14 at 8:37
  • I don't think this is a duplicate, this question relates to adding the extra info into the block chain, the other is just trying to make an associated message with a transaction, such as in a "bitcoin:" URI. – morsecoder Oct 15 '14 at 15:22
11

Note that you should only do this, putting extra data into the block chain, if it is really necessary. The block chain has to be stored by every full node, so try not to take up all our hard drive space with unnecessary stuff whenever possible.

With that said, if you do want to add extra data to your transaction, then add an additional output to the transaction, for which the scriptPubKey has the following form:

OP_RETURN {80 bytes of whatever data you want}

This transaction output is automatically un-spendable, and so will not be kept in the UTXO set. The other UTXOs from your transaction will still be safe.

For more info:

This will embed extra information into your transaction. Be aware, though, that the software that made the transaction and the software that reads the transaction have to be compatible in order for the user to be able to read the given information when the transaction is received.

You can see an example of a transaction that used OP_RETURN to encode extra information here: https://blockchain.info/tx/6dfb16dd580698242bcfd8e433d557ed8c642272a368894de27292a8844a4e75?show_adv=true.

  • 2
    Note that receivers (other outputs of your tx), or people in general, won't automatically see this information. People would have to know about your particular tx and specifically decode it and view its raw contents, in order to be aware of your info. – RocketNuts Oct 15 '14 at 14:39
  • Thanks, @RocketNuts, I will edit my answer to include the information you gave. – morsecoder Oct 15 '14 at 15:17
  • 1
    Where are you getting stuck? Can you tell me what you've tried? – morsecoder Oct 16 '14 at 12:34
  • 2
    You're doing it wrong, look again at the example transaction linked in the answer, the third output is the OP_RETURN and the entire output script is "OP_RETURN 68656c6c6f20776f726c64" (decoded: jhello world). There is no OP_DUP, OP_HASH160, keyID, OP_EQUALVERIFY or OP_CHECKSIG in an OP_RETURN output script. It's an unspendable output that contains the OP_RETURN opcode and up to 40 bytes of arbitrary data, nothing more or less, it's a separate output from any pay to pubkey hash or pay to script hash outputs in the same transaction. – stevenh512 Nov 9 '14 at 19:00
  • 2
    I think the size changed in 2015 from 40 to 80. Right? – Leandro Apr 23 '17 at 15:26

protected by Community Mar 22 at 10:06

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.