<p>From <a href="https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki">BIP66</a>:</p>

<blockquote>
  <p>The new rules are in effect for every block (at height H) with nVersion = 3 and at least 750 out of 1000 blocks preceding it (with heights H-1000..H-1) also have nVersion = 3. Furthermore, when 950 out of the 1000 blocks preceding a block do have nVersion = 3, nVersion = 2 blocks become invalid, and all further blocks enforce the new rules.</p>
</blockquote>

<p>I wrote this script to monitor the number of the last 1000 blocks that have nVersion set to 3.</p>

<p>

<pre><code>require_once 'jsonRPCClient.php';

$daemon = new jsonRPCClient('http://{my_user}:{my_password}@127.0.0.1:8332/');
$blkStart = 364136 - (24 * 14 * 6);

$ver3InLast1000 = 0;
for ($i = $blkStart;; $i++) {
    try {
        $blockHashOld = $daemon-&gt;getblockhash($i-1000);
        $blockHashNew = $daemon-&gt;getblockhash($i);
        $blockOld = $daemon-&gt;getblock($blockHashOld);
        $blockNew = $daemon-&gt;getblock($blockHashNew);
    } catch(Exception $e) {
        break;
    }

    // Don't want to start subtracting until have processed 1000 blocks
    if ($blockOld["version"] == 3 &amp;&amp; ($i - $blkStart &gt;= 1000)) {
        $ver3InLast1000--;
    }

    if ($blockNew["version"] == 3) {
        $ver3InLast1000++;
    }

    if ($i - $blkStart &gt;= 1000) {
        echo "$i, $ver3InLast1000\n";
    }

}
</code></pre>

<p>The result can be found in <a href="http://pastebin.com/qKeJrNCL">this pastebin</a>. </p>

<blockquote>
  <p><strong><a href="https://insight.bitpay.com/block/00000000000000000fb32e0d606a42615d44d93449a36ba64ee018de6009f898">Block number 363724</a> is the block that turned on nVersion=3 enforcement for all further blocks.</strong></p>
</blockquote>

CC BY-SA 3.0
2015-07-06T20:21:32.553Z
For anyone reading this answer in the future, Bitcoin Core 0.12 and later will include this information in the `getblockchaininfo` RPC.  See  [this pull request](https://github.com/bitcoin/bitcoin/pull/6353) for details.
David A. Harding
CC BY-SA 3.0
2015-11-02T22:48:37.193Z
excellent answer!
mulllhausen
CC BY-SA 3.0
2015-07-06T19:18:27.097Z
2015-07-06T19:18:27.097Z
morsecoder
<p>Recently, BIP66 switched from activation (miners enforce rules within block) to enforcement (network enforces rules on all blocks).</p>

<p>I'm having trouble figuring out when this happened, or on what block it happened.</p>

<history><bip66>
When did BIP66 switch from activation to enforcement?
Nick ODell
# When did BIP66 switch from activation to enforcement?

(Asked by: username_0 on 2015-07-06)

Recently, BIP66 switched from activation (miners enforce rules within block) to enforcement (network enforces rules on all blocks).

I'm having trouble figuring out when this happened, or on what block it happened.

**Tags:** history, bip66


---

## 1 answers

### Answer by username_1 on 2015-07-06. Score: 8 | Accepted answer

From BIP66:

The new rules are in effect for every block (at height H) with nVersion = 3 and at least 750 out of 1000 blocks preceding it (with heights H-1000..H-1) also have nVersion = 3. Furthermore, when 950 out of the 1000 blocks preceding a block do have nVersion = 3, nVersion = 2 blocks become invalid, and all further blocks enforce the new rules.

I wrote this script to monitor the number of the last 1000 blocks that have nVersion set to 3.

require_once 'jsonRPCClient.php';

$daemon = new jsonRPCClient('http://{my_user}:{my_password}@127.0.0.1:8332/');
$blkStart = 364136 - (24 * 14 * 6);

$ver3InLast1000 = 0;
for ($i = $blkStart;; $i++) {
    try {
        $blockHashOld = $daemon->getblockhash($i-1000);
        $blockHashNew = $daemon->getblockhash($i);
        $blockOld = $daemon->getblock($blockHashOld);
        $blockNew = $daemon->getblock($blockHashNew);
    } catch(Exception $e) {
        break;
    }

    // Don't want to start subtracting until have processed 1000 blocks
    if ($blockOld["version"] == 3 && ($i - $blkStart >= 1000)) {
        $ver3InLast1000--;
    }

    if ($blockNew["version"] == 3) {
        $ver3InLast1000++;
    }

    if ($i - $blkStart >= 1000) {
        echo "$i, $ver3InLast1000\n";
    }

}

The result can be found in this pastebin. 

Block number 363724 is the block that turned on nVersion=3 enforcement for all further blocks.

> **Comments:**
> **username_2**: For anyone reading this answer in the future, Bitcoin Core 0.12 and later will include this information in the `getblockchaininfo` RPC.  See  [this pull request](https://github.com/bitcoin/bitcoin/pull/6353) for details.  
> **username_3**: excellent answer!  

---

