Looking at Dev Update #5 and in particular the OP_RETURN data function due to be included in 0.9 release, how is data returned during the transaction?

Am I meant to create a new txout with no value and a scriptPubKey with just "OP_RETURN mydata" or is it included as part of another txout with a value and being sent to an actual address? How is the data represented when reaching the other end?

If I have asked the wrong question it could be due to my limited understanding of how scripting is meant to be used. In which case links to resources explaining this better would be appreciated.


2 Answers 2


That is correct. You create an additional txout with value 0 and script "OP_RETURN data".

  • Just pulled this script off of bc.info "OP_DUP OP_HASH160 9fec72675d009abb687ccc69a49453bb4d60f74d OP_EQUALVERIFY OP_CHECKSIG". @PeterWuille Any chance you could give me an example of how a script would be constructed using OP_RETURN? Thanks
    – Shomari
    Mar 19, 2014 at 21:43
  • ok, I just found this link blockexplorer.com/tx/…. OP_RETURN is the complete script; is that correct?
    – Shomari
    Mar 19, 2014 at 21:45
  • No, that's not a normal OP_RETURN data output. Mar 19, 2014 at 22:26
  • ok, i'm starting to understand how this works. i plan to write a few test scripts to see it in action; however, any idea on the likelihood of the tx actually getting confirmed (ie. how many miners are using 0.9)? also, is it possible to use more than 1 OP_RETURN in a tx? i've read discussions, but i'm unsure on the final spec. thanks
    – Shomari
    Mar 21, 2014 at 12:08
  • Could you explicitly post the extra step needed in the raw transaction? I've followed this recipe for the raw transaction, but do not see how to add the OP_RETURN to the txout: people.xiph.org/~greg/signdemo.txt Apr 9, 2014 at 7:43

We've just released php-OP_RETURN, a simple PHP library for generating OP_RETURN transactions. Even if you're not using PHP you can hopefully follow the code to see what is required.

  • Hi Gideon! Welcome to Bitcoin.SE. This looks like an interesting library.
    – Nick ODell
    Oct 3, 2014 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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