<p>We've just released <a href="https://github.com/coinspark/php-OP_RETURN" rel="nofollow">php-OP_RETURN</a>, 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.</p>

CC BY-SA 3.0
2014-10-03T22:16:39.477Z
Hi Gideon! Welcome to Bitcoin.SE. This looks like an interesting library.
Nick ODell
CC BY-SA 3.0
2014-10-03T19:51:59.833Z
2014-10-03T19:51:59.833Z
Gideon
<p>That is correct. You create an additional txout with value 0 and script "OP_RETURN data".</p>

CC BY-SA 3.0
2014-03-19T21:43:03.830Z
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
CC BY-SA 3.0
2014-03-19T21:45:12.313Z
ok, I just found this link http://blockexplorer.com/tx/eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29. OP_RETURN is the complete script; is that correct?
Shomari
CC BY-SA 3.0
2014-03-19T22:26:52.973Z
No, that's not a normal OP_RETURN data output.
Pieter Wuille
CC BY-SA 3.0
2014-03-21T12:08:20.353Z
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
CC BY-SA 3.0
2014-04-09T07:43:55.377Z
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: https://people.xiph.org/~greg/signdemo.txt
Robert-Reinder Nederhoed
CC BY-SA 3.0
2014-03-04T11:27:06.907Z
2014-03-04T11:27:06.907Z
Pieter Wuille
<p>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?</p>

<p>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?</p>

<p>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.</p>

<p>Thanks</p>

<transactions><raw-transaction>
OP_RETURN data transaction
daentech
# OP_RETURN data transaction

(Asked by: username_0 on 2014-03-04)

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.

Thanks

**Tags:** transactions, raw-transaction


---

## 2 answers

### Answer by username_3 on 2014-03-04. Score: 5 | Accepted answer

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

> **Comments:**
> **username_4**: 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  
> **username_4**: ok, I just found this link http://blockexplorer.com/tx/eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29. OP_RETURN is the complete script; is that correct?  
> **username_3**: No, that's not a normal OP_RETURN data output.  
> **username_4**: 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  
> **username_5**: 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: https://people.xiph.org/~greg/signdemo.txt  

---

### Answer by username_1 on 2014-10-03. Score: 3

We've just released [php-OP\_RETURN](https://github.com/coinspark/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.

> **Comments:**
> **username_2**: Hi username_1! Welcome to Bitcoin.SE. This looks like an interesting library.  

---

