<p>Once a client has the template it can modify it to make the header different, giving you a new nonce range to search. In modern miners this happens thousands or tens of thousands of times a second.</p>

<ul>
<li><p>The timestamp in the header can be updated if needed, this is known in old software as <code>nRollTime</code>. This method is generally not used anymore because you only get one new range per second. </p></li>
<li><p>The "extraNonce" can be updated, the random data in the coinbase transaction is altered and the merkle tree is re-hashed up to the root, which changes the header. This technique is used by Stratum miners as well.</p></li>
<li><p>Transactions can be added or removed from the tree.</p></li>
</ul>

<p>GBT and Stratum are distinct from an old system called <code>GetWork</code> which simply gave out just a partially hashed header, every time the nonce range was exhausted the client would need to make a new request to the server they were mining from. This is what your quote is alluding to. </p>

CC BY-SA 3.0
2015-12-23T07:15:49.997Z
Okay, so I should be updating the nonce and extra nonce, and possibly the timestamp if I don't feel like excluding any transactions then?
dacox
CC BY-SA 3.0
2015-12-23T08:35:00.983Z
You must always update the timestamp or you will produce invalid blocks. Iterate the nonce until you reach `2^32`, then change the `extraNonce`.
Claris
CC BY-SA 3.0
2015-12-23T20:48:08.657Z
The timestamp should always just be kept in sync with my current time?
dacox
CC BY-SA 3.0
2015-12-24T00:45:09.893Z
That's correct.
Claris
CC BY-SA 3.0
2015-12-22T23:09:53.170Z
2015-12-23T00:56:36.007Z
2015-12-23T00:56:36.007Z
Claris
<p>I'm having trouble understanding getblocktemplate.</p>

<p>From <a href="https://en.bitcoin.it/wiki/Getblocktemplate" rel="nofollow">https://en.bitcoin.it/wiki/Getblocktemplate</a>,</p>

<p>I see how to build the block header and then begin hashing by incrementing the nonce, the same as I would perform work on the result of a getwork call.</p>

<p>What I don't understand is the following</p>

<blockquote>
  <p>Since you're making all the blocks yourself, you really don't ever need to get another template... until it's invalid. </p>
</blockquote>

<p>After I construct my merkle root and then my block header, and hash away by incrementing the nonce, then what? How do I "create" a block? Surely I will overflow the nonce quickly with an ASIC - so what else am I varying while hashing?</p>

<p>I feel like I am missing a very important step.</p>

<p>Thanks in advance!</p>

CC BY-SA 3.0
2015-12-22T23:34:19.810Z
You should look at BIP 22/23
Nick ODell
<hash><getblocktemplate>
Question about getblocktemplate
dacox
# Question about getblocktemplate

(Asked by: username_0 on 2015-12-22)

I'm having trouble understanding getblocktemplate.

From <https://en.bitcoin.it/wiki/Getblocktemplate>,

I see how to build the block header and then begin hashing by incrementing the nonce, the same as I would perform work on the result of a getwork call.

What I don't understand is the following

> Since you're making all the blocks yourself, you really don't ever need to get another template... until it's invalid.

After I construct my merkle root and then my block header, and hash away by incrementing the nonce, then what? How do I "create" a block? Surely I will overflow the nonce quickly with an ASIC - so what else am I varying while hashing?

I feel like I am missing a very important step.

Thanks in advance!

**Tags:** hash, getblocktemplate

> **Comments:**
> **username_1**: You should look at BIP 22/23  

---

## 1 answers

### Answer by username_2 on 2015-12-22. Score: 3 | Accepted answer

Once a client has the template it can modify it to make the header different, giving you a new nonce range to search. In modern miners this happens thousands or tens of thousands of times a second.

* The timestamp in the header can be updated if needed, this is known in old software as `nRollTime`. This method is generally not used anymore because you only get one new range per second.
* The "extraNonce" can be updated, the random data in the coinbase transaction is altered and the merkle tree is re-hashed up to the root, which changes the header. This technique is used by Stratum miners as well.
* Transactions can be added or removed from the tree.

GBT and Stratum are distinct from an old system called `GetWork` which simply gave out just a partially hashed header, every time the nonce range was exhausted the client would need to make a new request to the server they were mining from. This is what your quote is alluding to.

> **Comments:**
> **username_0**: Okay, so I should be updating the nonce and extra nonce, and possibly the timestamp if I don't feel like excluding any transactions then?  
> **username_2**: You must always update the timestamp or you will produce invalid blocks. Iterate the nonce until you reach `2^32`, then change the `extraNonce`.  
> **username_0**: The timestamp should always just be kept in sync with my current time?  
> **username_2**: That's correct.  

---

