<p>Both.</p>

<p>Transaction output scripts are only executed at the time they are attempted to be spent.</p>

<p>If you try to spend an OP_RETURN output, the spending transaction is invalid, as this instruction immediately fails the execution.</p>

<p>As a result, OP_RETURN outputs (not the transactions they are in) are unspendable.</p>

CC BY-SA 3.0
2016-10-29T12:28:09.617Z
But doesn't that actually mean only the information in the second link is correct? If I have a transaction with 2 outputs. One with a OP_RETURN and one with the standard paytopubhash script. I can still use the second output as an input for another transaction?
Martin
CC BY-SA 3.0
2016-10-29T14:22:41.690Z
Yes, you can spend the second output (if it's a standard pay-to-pubkey-hash script) by signing the spending transaction with the corresponding private key. The OP_RETURN one is permanently unspendable, so it is a good idea to send zero satoshis there. See this transaction https://blockchain.info/tx/8bae12b5f4c088d940733dcd1455efc6a3a69cf9340e17a981286d3778615684?show_adv=true which is your exact use case. Notice the non-OP_RETURN output is marked spent, proving it's allowed.
maservant
CC BY-SA 3.0
2016-10-29T17:45:43.917Z
Both links are correct. But the first one is about a transaction that _spends_ an OP_RETURN. The second one is about an output that _creates_ an OP_RETURN.
Pieter Wuille
CC BY-SA 3.0
2016-10-28T20:37:11.143Z
2016-10-28T20:37:11.143Z
Pieter Wuille
<p>I am currently looking into the Bitcoin script. I want to create a transaction with one output with OP_RETURN and some data, and one output which pays coins to some address. I am confused, does OP_RETURN mark the whole transaction as invalid or just the output.</p>

<p>I am especially confused because the wiki is not clear on this issue:
<a href="https://en.bitcoin.it/wiki/Script#Flow_control" rel="nofollow">https://en.bitcoin.it/wiki/Script#Flow_control</a>
(says the whole transaction is marked as invalid)
<a href="https://en.bitcoin.it/wiki/OP_RETURN" rel="nofollow">https://en.bitcoin.it/wiki/OP_RETURN</a>
(says just the output is marked as invalid)</p>

<script><op-return>
OP_RETURN marks transaction or output as invalid
Martin
# OP_RETURN marks transaction or output as invalid

(Asked by: username_0 on 2016-10-28)

I am currently looking into the Bitcoin script. I want to create a transaction with one output with OP\_RETURN and some data, and one output which pays coins to some address. I am confused, does OP\_RETURN mark the whole transaction as invalid or just the output.

I am especially confused because the wiki is not clear on this issue:
<https://en.bitcoin.it/wiki/Script#Flow_control>
(says the whole transaction is marked as invalid)
<https://en.bitcoin.it/wiki/OP_RETURN>
(says just the output is marked as invalid)

**Tags:** script, op-return


---

## 1 answers

### Answer by username_1 on 2016-10-28. Score: 4 | Accepted answer

Both.

Transaction output scripts are only executed at the time they are attempted to be spent.

If you try to spend an OP\_RETURN output, the spending transaction is invalid, as this instruction immediately fails the execution.

As a result, OP\_RETURN outputs (not the transactions they are in) are unspendable.

> **Comments:**
> **username_0**: But doesn't that actually mean only the information in the second link is correct? If I have a transaction with 2 outputs. One with a OP_RETURN and one with the standard paytopubhash script. I can still use the second output as an input for another transaction?  
> **username_2**: Yes, you can spend the second output (if it's a standard pay-to-pubkey-hash script) by signing the spending transaction with the corresponding private key. The OP_RETURN one is permanently unspendable, so it is a good idea to send zero satoshis there. See this transaction https://blockchain.info/tx/8bae12b5f4c088d940733dcd1455efc6a3a69cf9340e17a981286d3778615684?show_adv=true which is your exact use case. Notice the non-OP_RETURN output is marked spent, proving it's allowed.  
> **username_1**: Both links are correct. But the first one is about a transaction that _spends_ an OP_RETURN. The second one is about an output that _creates_ an OP_RETURN.  

---

