<p>The wiki has an extremely good explanation, with a python run-through that takes you from GBT output to share submission. You could also have a look at some of the implementation in Luke-Jr's "gmp-proxy", which translates GBT reponses into a <code>getwork</code> compatible interface.</p>

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

<p><a href="https://gitlab.com/bitcoin/eloipool/blob/master/gmp-proxy.py" rel="nofollow">https://gitlab.com/bitcoin/eloipool/blob/master/gmp-proxy.py</a></p>

CC BY-SA 3.0
2013-09-19T18:54:59.147Z
I read through that, but a lot of the terminology is new to me, and hard to understand. For example, it doesn't explain the parameters it's passing in, and their significance - `{"capabilities": ["coinbasetxn", "workid", "coinbase/append"]}`. Also, on the return data -  `'"mutable":["time","transactions","prevblock"]` vs `"mutable": ["coinbase/append"]`. On my GBT response, it has `coinbaseaux flags` instead of `coinbasetxn data` - what's the significance of that? What exactly does `height` mean? How is that all put together? It doesn't explain the smaller details.
xil3
CC BY-SA 3.0
2013-09-19T19:05:19.990Z
Thanks for posting the gmp-proxy - I'll take a look at that.
xil3
CC BY-SA 3.0
2013-09-21T05:34:41.880Z
Unfortunately, I'm not even that well versed in working with GBT. There's very little detail in any of the documentation, and it's actually quite unusual to have that much detail on an internal topic on the internal wiki. I'd suggest talking to one of the developers on freenode#bitcoin, maybe try and catch Luke-Jr if he is around. If anyone knows how GBT works, it's the person who developed it.
Anonymous
CC BY-SA 3.0
2013-09-21T05:54:16.530Z
Yeah, I just joined that channel, but everyone seems to be idle. Hopefully someone sees my plea for help.
xil3
CC BY-SA 3.0
2013-12-17T01:32:08.167Z
#bitcoin-dev would be the correct channel for this.
Luke Dashjr
CC BY-SA 3.0
2013-09-19T08:23:39.403Z
2015-12-22T22:00:10.537Z
2015-12-22T22:00:10.537Z
Anonymous
<p>You probably want to look at BIPs 22 and 23, as well as the libblkmaker source code (which includes an example of usage).</p>

CC BY-SA 3.0
2013-12-17T01:31:56.683Z
2013-12-17T01:31:56.683Z
Luke Dashjr
<p>I've been reading lots of articles, trying to understand how to hash the data returned from <code>getwork</code>; but I totally overlooked <code>getblocktemplate</code>.</p>

<p>I'm just trying to understand how all the data below is put together to generate hashes, in order to form a valid block (using various nonces).</p>

<p>Apologies if this has been answered already. I know there are lots of articles on how to put together a block header, and using midstate, etc. Most of that I understand; but the data composition of <code>getblocktemplate</code> is quite a bit different, and really threw me off.</p>

<p>If someone would be kind enough to explain the whole hashing process (from a mining point of view), I'd really appreciate it. A programmatic explanation would be ideal, as I'm trying to make my own mining client. </p>

<pre><code>{
    "result":{
        "version":2,
        "previousblockhash":"00000000000000075f2f454573766ffae69fe41d6c7ccfcabbf8588fcd80ed52",
        "transactions":[
                  {     
                        "data":"0100000001cba672d0bfdbcc441d171ef0723a191bf050932c6f8adc8a05b0cac2d1eb022f010000006c493046022100a23472410d8fd7eabf5c739bdbee5b6151ff31e10d5cb2b52abeebd5e9c06977022100c2cdde5c632eaaa1029dff2640158aaf9aab73fa021ed4a48b52b33ba416351801210212ee0e9c79a72d88db7af3fed18ae2b7ca48eaed995d9293ae0f94967a70cdf6ffffffff02905f0100000000001976a91482db4e03886ee1225fefaac3ee4f6738eb50df9188ac00f8a093000000001976a914c94f5142dd7e35f5645735788d0fe1343baf146288ac00000000",
                        "hash":"7c90a5087ac4d5b9361d47655812c89b4ad0dee6ecd5e08814d00ce7385aa317",
                        "depends":[],
                        "fee":10000,
                        "sigops":2
                  },
                  ...
            ],
        "coinbaseaux":{
            "flags":"062f503253482f"
        },
        "coinbasevalue":2501100000,
        "target":"0000000000000026222200000000000000000000000000000000000000000000",
        "mintime":1379549850,
        "mutable":[
            "time",
            "transactions",
            "prevblock"
        ],
        "noncerange":"00000000ffffffff",
        "sigoplimit":20000,
        "sizelimit":1000000,
        "curtime":1379553872,
        "bits":"19262222",
        "height":258736
    },
    "error":null,
    "id":"curltest"
}
</code></pre>

<development><hash><mining-technical-details><getblocktemplate>
How to hash data from 'getblocktemplate' request
xil3
# How to hash data from 'getblocktemplate' request

(Asked by: username_0 on 2013-09-19)

I've been reading lots of articles, trying to understand how to hash the data returned from `getwork`; but I totally overlooked `getblocktemplate`.

I'm just trying to understand how all the data below is put together to generate hashes, in order to form a valid block (using various nonces).

Apologies if this has been answered already. I know there are lots of articles on how to put together a block header, and using midstate, etc. Most of that I understand; but the data composition of `getblocktemplate` is quite a bit different, and really threw me off.

If someone would be kind enough to explain the whole hashing process (from a mining point of view), I'd really appreciate it. A programmatic explanation would be ideal, as I'm trying to make my own mining client.

```
{
    "result":{
        "version":2,
        "previousblockhash":"00000000000000075f2f454573766ffae69fe41d6c7ccfcabbf8588fcd80ed52",
        "transactions":[
                  {     
                        "data":"0100000001cba672d0bfdbcc441d171ef0723a191bf050932c6f8adc8a05b0cac2d1eb022f010000006c493046022100a23472410d8fd7eabf5c739bdbee5b6151ff31e10d5cb2b52abeebd5e9c06977022100c2cdde5c632eaaa1029dff2640158aaf9aab73fa021ed4a48b52b33ba416351801210212ee0e9c79a72d88db7af3fed18ae2b7ca48eaed995d9293ae0f94967a70cdf6ffffffff02905f0100000000001976a91482db4e03886ee1225fefaac3ee4f6738eb50df9188ac00f8a093000000001976a914c94f5142dd7e35f5645735788d0fe1343baf146288ac00000000",
                        "hash":"7c90a5087ac4d5b9361d47655812c89b4ad0dee6ecd5e08814d00ce7385aa317",
                        "depends":[],
                        "fee":10000,
                        "sigops":2
                  },
                  ...
            ],
        "coinbaseaux":{
            "flags":"062f503253482f"
        },
        "coinbasevalue":2501100000,
        "target":"0000000000000026222200000000000000000000000000000000000000000000",
        "mintime":1379549850,
        "mutable":[
            "time",
            "transactions",
            "prevblock"
        ],
        "noncerange":"00000000ffffffff",
        "sigoplimit":20000,
        "sizelimit":1000000,
        "curtime":1379553872,
        "bits":"19262222",
        "height":258736
    },
    "error":null,
    "id":"curltest"
}

```

**Tags:** development, hash, mining-technical-details, getblocktemplate


---

## 2 answers

### Answer by username_1 on 2013-09-19. Score: 2

The wiki has an extremely good explanation, with a python run-through that takes you from GBT output to share submission. You could also have a look at some of the implementation in username_2-Jr's "gmp-proxy", which translates GBT reponses into a `getwork` compatible interface.

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

<https://gitlab.com/bitcoin/eloipool/blob/master/gmp-proxy.py>

> **Comments:**
> **username_0**: I read through that, but a lot of the terminology is new to me, and hard to understand. For example, it doesn't explain the parameters it's passing in, and their significance - `{"capabilities": ["coinbasetxn", "workid", "coinbase/append"]}`. Also, on the return data -  `'"mutable":["time","transactions","prevblock"]` vs `"mutable": ["coinbase/append"]`. On my GBT response, it has `coinbaseaux flags` instead of `coinbasetxn data` - what's the significance of that? What exactly does `height` mean? How is that all put together? It doesn't explain the smaller details.  
> **username_0**: Thanks for posting the gmp-proxy - I'll take a look at that.  
> **username_1**: Unfortunately, I'm not even that well versed in working with GBT. There's very little detail in any of the documentation, and it's actually quite unusual to have that much detail on an internal topic on the internal wiki. I'd suggest talking to one of the developers on freenode#bitcoin, maybe try and catch username_2-Jr if he is around. If anyone knows how GBT works, it's the person who developed it.  
> **username_0**: Yeah, I just joined that channel, but everyone seems to be idle. Hopefully someone sees my plea for help.  
> **username_2**: #bitcoin-dev would be the correct channel for this.  

---

### Answer by username_2 on 2013-12-17. Score: 1

You probably want to look at BIPs 22 and 23, as well as the libblkmaker source code (which includes an example of usage).


---

