How much can you actually put in OP_RETURN?

7 replies 352 views
0xAlphaNewbie
Posts: 116 · Reputation: 16
#1Aug 15, 2025, 03:46 PM
So what's the actual max size for OP_RETURN? I know there are debates about it and how you can tweak sizes in bitcoin knots, but if a block has too much, is it just invalid? Initially, I thought it was more about the coinbase transaction size but I'm confused. I saw 80 bytes in the dev guide, but other places say 75 or even 40, which seems outdated.
6 Reply Quote Share
MadNovaHero Member
Posts: 278 · Reputation: 3536
#2Aug 17, 2025, 10:16 AM
There’s no strict consensus limit for OP_RETURN. It’s valid as long as the transaction and block follow the consensus rules. So really, the only limit is the transaction size itself: 4MB for Segwit and 1MB for non-Segwit. Standard rule says 80 bytes data plus 3 bytes for the script, but that might be changing in updates.
2 Reply Quote Share
alex.byteLegendary
Posts: 170 · Reputation: 5910
#3Aug 17, 2025, 12:22 PM
Yeah, it’s all about the block size really. Practically, it's just under 1MB. If OP_RETURN is in an unexecuted OP_IF branch with P2WSH, it can be up to about 4MB, but only 10k bytes max because of the script size limit.
2 Reply Quote Share
matrix2021Full Member
Posts: 92 · Reputation: 612
#4Aug 17, 2025, 02:06 PM
Totally agree. No real consensus limits on outputs except the overall block weight. Outputs can have any opcodes, even invalid ones, until you hit that block weight limit. And the only consensus validation happens when spending the output.
1 Reply Quote Share
m1kes4tFull Member
Posts: 167 · Reputation: 252
#5Aug 17, 2025, 02:43 PM
I think you're right that OP_RETURN's max size depends on MAX_SCRIPT_SIZE, which is 10k. But theoretically, you could have a block with one transaction having multiple OP_RETURN outputs and hit around 3.99MB. But good luck getting that into mempool without mining your own block.
2 Reply Quote Share
Posts: 110 · Reputation: 19
#6Aug 17, 2025, 08:24 PM
Nah, that limit is only for when you spend it. The default 'datacarriersize' is just the standard max transaction size.
2 Reply Quote Share
ColdGangMember
Posts: 152 · Reputation: 183
#7Aug 18, 2025, 01:49 AM
I doubt there's a specific OP_RETURN size that makes a block invalid. Those 75, 80, and 83 bytes are standardness rules for relaying transactions by most nodes. A transaction can be valid if it meets consensus rules, even if it’s over those limits.
3 Reply Quote Share
nick2015Member
Posts: 67 · Reputation: 54
#8Aug 18, 2025, 07:43 AM
Remember that OP_RETURN was called 'data carrier' initially. It started with a 40-byte limit for some app reasons, then it went to 80 bytes. So yeah, there's a limit, and if your OP_RETURN data is too big, that tx is invalid.
4 Reply Quote Share

Related topics