<p>The length (amount of data to be pushed into the stack) typically comes directly after the OP_ code.</p>

<p>If the byte after OP_RETURN (<code>0x6A</code>) is between <code>0x01</code> and <code>0x4B</code>, that is signaling the amount of data to push into the stack. This is defined in the Script language; a chart can be found <a href="https://en.bitcoin.it/wiki/Script" rel="nofollow noreferrer">here</a>.</p>

<p><a href="https://i.sstatic.net/CqNbq.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CqNbq.png" alt="enter image description here"></a></p>

<p>For example:</p>

<p><code>6A24AA21A9EDA45B20BAE4C0D9C747D7C17074D0606AF70FABA1394FC75E5DA6ABDA0426232E</code></p>

<p>The first byte <code>0x6A</code> decodes to <code>OP_RETURN</code> and the next byte is <code>0x24</code> signaling 
to push 36 bytes of data to the stack. (<code>0x24</code> hexadecimal is 36 in decimal)</p>

<p>Our example therefore decodes to:</p>

<p><code>OP_RETURN PUSHDATA(36) AA21A9EDA45B20BAE4C0D9C747D7C17074D0606AF70FABA1394FC75E5DA6ABDA0426232E</code></p>

<p>If there was any more data after the 36 bytes it would be interpreted in coordination with the proper OP_code.</p>

CC BY-SA 4.0
2018-10-27T22:18:56.137Z
2018-10-27T22:25:06.210Z
2018-10-27T22:25:06.210Z
Mason Ticehurst
<p>It seems like most OP_RETURN transactions include length as the first byte after the OP_RETURN code. Is this specified anywhere?</p>

<p>Also, the length is sometimes the entire length of the rest of the output, and other times, such as with memo.cash, it is only 2, but there are many more bytes than that.  What is it supposed to be?</p>

<op-return>
What's the deal with OP_RETURN and length?
Curyous
# What's the deal with OP_RETURN and length?

(Asked by: username_0 on 2018-10-27)

It seems like most OP\_RETURN transactions include length as the first byte after the OP\_RETURN code. Is this specified anywhere?

Also, the length is sometimes the entire length of the rest of the output, and other times, such as with memo.cash, it is only 2, but there are many more bytes than that. What is it supposed to be?

**Tags:** op-return


---

## 1 answers

### Answer by username_1 on 2018-10-27. Score: 3

The length (amount of data to be pushed into the stack) typically comes directly after the OP\_ code.

If the byte after OP\_RETURN (`0x6A`) is between `0x01` and `0x4B`, that is signaling the amount of data to push into the stack. This is defined in the Script language; a chart can be found [here](https://en.bitcoin.it/wiki/Script).

[![enter image description here](https://i.sstatic.net/CqNbq.png)](https://i.sstatic.net/CqNbq.png)

For example:

`6A24AA21A9EDA45B20BAE4C0D9C747D7C17074D0606AF70FABA1394FC75E5DA6ABDA0426232E`

The first byte `0x6A` decodes to `OP_RETURN` and the next byte is `0x24` signaling
to push 36 bytes of data to the stack. (`0x24` hexadecimal is 36 in decimal)

Our example therefore decodes to:

`OP_RETURN PUSHDATA(36) AA21A9EDA45B20BAE4C0D9C747D7C17074D0606AF70FABA1394FC75E5DA6ABDA0426232E`

If there was any more data after the 36 bytes it would be interpreted in coordination with the proper OP\_code.


---

