<p>Yes. The limit was originally introduced by Satoshi in <a href="https://github.com/bitcoin/bitcoin/blob/v0.3.7/script.cpp#L73" rel="noreferrer">Bitcoin v0.3.7</a> in July 2010:</p>
<pre class="lang-cpp prettyprint-override"><code>    if (opcode &gt; OP_16 &amp;&amp; nOpCount++ &gt; 200)
        return false;
</code></pre>
<p>However, because the expression uses a postfix operator, the condition checks what the value of <code>nOpCount</code> was <em>before</em> it was incremented, and this allows it to go up to 201.</p>
<p>Satoshi later noticed the mistake and corrected it in <a href="https://github.com/bitcoin/bitcoin/blob/v0.3.12/script.cpp#L98" rel="noreferrer">Bitcoin v0.3.12</a> in September 2010:</p>
<pre class="lang-cpp prettyprint-override"><code>    if (opcode &gt; OP_16 &amp;&amp; ++nOpCount &gt; 201)
        return false;
</code></pre>
<p>He apparently didn't think this small mistake was worth making another change to consensus rules (even though consensus changes were a normal occurrence at the time – according to <a href="https://blog.bitmex.com/a-complete-history-of-bitcoins-consensus-forks-2022-update/" rel="noreferrer">BitMEX Research</a> there were at least 6 in 2010 alone), which is why the limit remains at 201 to this day.</p>

CC BY-SA 4.0
2024-10-11T20:54:08.000Z
2024-10-11T20:54:08.000Z
Vojtěch Strnad
<p>In pre-taproot scripts, the maximum number of non-push opcodes is 201 (defined by the constant <code>MAX_OPS_PER_SCRIPT</code>). Is this a result of an off-by-one error where the originally intended value was 200?</p>

<script><bitcoin-core-development><consensus><history><opcodes>
Why is the opcode limit 201?
Vojtěch Strnad
# Why is the opcode limit 201?

(Asked by: username_0 on 2024-10-11)

In pre-taproot scripts, the maximum number of non-push opcodes is 201 (defined by the constant `MAX_OPS_PER_SCRIPT`). Is this a result of an off-by-one error where the originally intended value was 200?

**Tags:** script, bitcoin-core-development, consensus, history, opcodes


---

## 1 answers

### Answer by username_0 on 2024-10-11. Score: 5 | Accepted answer

Yes. The limit was originally introduced by Satoshi in [Bitcoin v0.3.7](https://github.com/bitcoin/bitcoin/blob/v0.3.7/script.cpp#L73) in July 2010:

```cpp
    if (opcode > OP_16 && nOpCount++ > 200)
        return false;

```

However, because the expression uses a postfix operator, the condition checks what the value of `nOpCount` was *before* it was incremented, and this allows it to go up to 201.

Satoshi later noticed the mistake and corrected it in [Bitcoin v0.3.12](https://github.com/bitcoin/bitcoin/blob/v0.3.12/script.cpp#L98) in September 2010:

```cpp
    if (opcode > OP_16 && ++nOpCount > 201)
        return false;

```

He apparently didn't think this small mistake was worth making another change to consensus rules (even though consensus changes were a normal occurrence at the time – according to [BitMEX Research](https://blog.bitmex.com/a-complete-history-of-bitcoins-consensus-forks-2022-update/) there were at least 6 in 2010 alone), which is why the limit remains at 201 to this day.


---

