Post
Topic
Board Development & Technical Discussion
Merits 5 from 3 users
Re: What exactly is the maximum message length in OP_RETURN?
by
stwenhao
on 18/06/2025, 17:12:22 UTC
⭐ Merited by d5000 (2) ,vapourminer (2) ,Mia Chloe (1)
Quote
What exactly is the maximum message length in OP_RETURN?
It is defined by the maximum size of the block. See: https://mempool.space/tx/516c63376556d87c4779033327184ee00a08c4c14498e14673357ce4a791406b

So, in practice, it is something slightly below 1 MB. And if OP_RETURN is placed in unexecuted OP_IF branch, behind P2WSH, then it can take slightly less than 4 MB.

Quote
but what is the maximum amount where any block containing it would be considered simply invalid?
It would happen only when transaction size would exceed the maximum block size, or when OP_RETURN will be executed in witness space.

Quote
because I remembered that in the bitcoin developer guide, the maximum was 80 bytes, however some sources say that it's 75 or even 40
There are standardness rules. And it is set by default to 83 bytes, where one byte is taken by OP_RETURN, and two bytes are taken to declare the size of the stack push. And if you ignore Script decoding, then in practice, you can use one byte for OP_RETURN, and 82 bytes for anything.