<p>From <a href="https://bitcointalk.org/index.php?topic=988542.msg10771576#msg10771576" rel="nofollow">here</a>:</p>

<blockquote>
  <p>The extranonce can be found in the coinbase data from a coinbase
  transaction. This data can be interpreted as a script pushing data
  onto the stack and the extranonce is the second value.</p>

<pre><code>{
   ...
    "vin" : [
        {
            "coinbase" : "03443b0403858402062f503253482f",
            "sequence" : 4294967295
        }
    ],
   ...
}
</code></pre>
  
  <p>can be interpreted as:</p>

<pre><code>03 = push 3 bytes onto the stack
443b04 = 3 bytes pushed onto the stack &lt;-- Block index
03 = push 3 bytes onto the stack
858402 = 3 bytes pushed onto the stack &lt;-- The extranonce
06 = push 6 bytes onto the stack
2f503253482f = 6 bytes pushed onto the stack &lt;-- arbitrary data
</code></pre>
  
  <p>EDIT: This format was defined by <a href="https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki" rel="nofollow">BIP34</a> and applies to blocks with
  version >= 2. I'm not sure how the extranonce was managed before that.</p>
</blockquote>

CC BY-SA 3.0
2015-03-14T18:52:38.720Z
This answer says extranonce is 3 bytes, yet it's 8 bytes…
Geremia
CC BY-SA 3.0
2015-03-14T18:54:52.563Z
Actually that last bit did use to have a meaning - it's a [vote for P2SH](http://bitcoin.stackexchange.com/questions/2749/what-is-an-explanation-of-the-p2sh-voting-in-laymans-terms).
Nick ODell
CC BY-SA 3.0
2015-03-14T15:58:31.677Z
2015-03-14T15:58:31.677Z
Geremia
<p>In Bitcoin v0.1.5 to v0.3.24, the coinbase scriptSig contained:</p>

<pre><code>txNew.vin[0].scriptSig &lt;&lt; nBits &lt;&lt; ++bnExtraNonce;
</code></pre>

<p>In Bitcoin v0.4.0 to v0.5.3, it changed to:</p>

<pre><code>pblock-&gt;vtx[0].vin[0].scriptSig = CScript() &lt;&lt; pblock-&gt;nTime &lt;&lt; CBigNum(nExtraNonce);
</code></pre>

<p>Bitcoin v0.6.0 to v0.6.3:</p>

<pre><code>pblock-&gt;vtx[0].vin[0].scriptSig = (CScript() &lt;&lt; pblock-&gt;nTime &lt;&lt; CBigNum(nExtraNonce)) + COINBASE_FLAGS;
</code></pre>

<p>Bitcoin v0.7.0 to current:</p>

<pre><code>txCoinbase.vin[0].scriptSig = (CScript() &lt;&lt; nHeight &lt;&lt; CScriptNum(nExtraNonce)) + COINBASE_FLAGS;
</code></pre>

<p>So the coinbase scriptSig field has changed over time, but it has always placed the extranonce as the second item.</p>

<p>In Bitcoin v0.1.5, the size was unlimited, and in more current versions, it's 4 bytes or less. (This is caused by the switch from <code>bnExtraNonce</code> to <code>nExtraNonce</code>.)</p>

<p>There are some other odd details - in v0.1.5, it only resets when the client resets, but in later versions it resets on every new block.</p>

<p>Of course, this is just what the core client does. Other miners or pools might do something else.</p>

CC BY-SA 3.0
2015-03-14T19:27:06.673Z
2015-03-16T08:01:51.993Z
2015-03-16T08:01:51.993Z
Nick ODell
<p>How do I determine a block's <a href="http://chimera.labs.oreilly.com/books/1234000001802/ch08.html#extra_nonce" rel="nofollow">extranonce</a> value? I know they are in the coinbase transaction, but where? How do I decode the part that is the extranonce?</p>

<nonce><coinbase-transaction>
Determining a Block's Extranonce Value
Geremia
# Determining a Block's Extranonce Value

(Asked by: username_0 on 2015-03-14)

How do I determine a block's [extranonce](http://chimera.labs.oreilly.com/books/1234000001802/ch08.html#extra_nonce) value? I know they are in the coinbase transaction, but where? How do I decode the part that is the extranonce?

**Tags:** nonce, coinbase-transaction


---

## 2 answers

### Answer by username_1 on 2015-03-14. Score: 4 | Accepted answer

In Bitcoin v0.1.5 to v0.3.24, the coinbase scriptSig contained:
txNew.vin[0].scriptSig << nBits << ++bnExtraNonce;

In Bitcoin v0.4.0 to v0.5.3, it changed to:
pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nTime << CBigNum(nExtraNonce);

Bitcoin v0.6.0 to v0.6.3:
pblock->vtx[0].vin[0].scriptSig = (CScript() << pblock->nTime << CBigNum(nExtraNonce)) + COINBASE_FLAGS;

Bitcoin v0.7.0 to current:
txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS;

So the coinbase scriptSig field has changed over time, but it has always placed the extranonce as the second item.
In Bitcoin v0.1.5, the size was unlimited, and in more current versions, it's 4 bytes or less. (This is caused by the switch from bnExtraNonce to nExtraNonce.)
There are some other odd details - in v0.1.5, it only resets when the client resets, but in later versions it resets on every new block.
Of course, this is just what the core client does. Other miners or pools might do something else.


---

### Answer by username_0 on 2015-03-14. Score: 1

From here:

The extranonce can be found in the coinbase data from a coinbase
  transaction. This data can be interpreted as a script pushing data
  onto the stack and the extranonce is the second value.
{
   ...
    "vin" : [
        {
            "coinbase" : "03443b0403858402062f503253482f",
            "sequence" : 4294967295
        }
    ],
   ...
}

can be interpreted as:
03 = push 3 bytes onto the stack
443b04 = 3 bytes pushed onto the stack <-- Block index
03 = push 3 bytes onto the stack
858402 = 3 bytes pushed onto the stack <-- The extranonce
06 = push 6 bytes onto the stack
2f503253482f = 6 bytes pushed onto the stack <-- arbitrary data

EDIT: This format was defined by BIP34 and applies to blocks with
  version >= 2. I'm not sure how the extranonce was managed before that.

> **Comments:**
> **username_0**: This answer says extranonce is 3 bytes, yet it's 8 bytes…  
> **username_1**: Actually that last bit did use to have a meaning - it's a [vote for P2SH](http://bitcoin.stackexchange.com/questions/2749/what-is-an-explanation-of-the-p2sh-voting-in-laymans-terms).  

---

