<p>Pieter's answer is good, the chainwork value is the expected work amount in the chain, expressed as a 32 bytes integer, for the double SHA-256 hashes calculation work.</p>
<p>The chainwork is used to identify the correct chain, the biggest chainwork value means the strongest or the correct chain.</p>
<p>By the way, Satoshi didn't initially realize that choosing the correct chain by just counting blocks allows for some extremely easy attacks. Version 0.1 just counted blocks. That's why the paper just says &quot;longest&quot;. The idea of &quot;chain work&quot; was added a little later. For detail about this, please refer to <a href="https://bitcoin.stackexchange.com/questions/29742/strongest-vs-longest-chain-and-orphaned-blocks">here</a>.</p>
<p>I just want to give some info about <strong>how this 'chainwork' value comes</strong>, for the better or deeper understanding about what it is.</p>
<p>Let's take a look at Satoshi's genesis block header (part of related info):</p>
<pre><code>$ bitcoin-cli getblockhash 0
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f

$ bitcoin-cli getblockheader 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
{
  ...
  &quot;height&quot;: 0,
  ...
  &quot;bits&quot;: &quot;1d00ffff&quot;,
  &quot;difficulty&quot;: 1,
  &quot;chainwork&quot;: &quot;0000000000000000000000000000000000000000000000000000000100010001&quot;,
  ...
}
</code></pre>
<p>As you see above, the genesis block has a '1' difficulty and a [0x01,0001,0001] chainwork . If you have a question about what's a 'difficulty', you can take a look at <a href="https://bitcoin.stackexchange.com/questions/5838/how-is-difficulty-calculate">this answer</a>. So, that's the right definition:</p>
<pre><code>difficulty '1' = chainwork amount [0x01,0001,0001]
</code></pre>
<p>Then, each time when a new block generated, we just accumulate the chainwork with new block's 'difficulty' field value, but remember for each '1' difficulty we add a chainwork amount [0x01,0001,0001].</p>
<p>As the block chain grows, the difficulty will increase (or sometimes slightly decrease) little by little.</p>
<p>Before the first time of difficulty changed, the chain block height had reached 32255.</p>
<pre><code>$ bitcoin-cli getblockhash 32255
00000000984f962134a7291e3693075ae03e521f0ee33378ec30a334d860034b

$ bitcoin-cli getblockheader 00000000984f962134a7291e3693075ae03e521f0ee33378ec30a334d860034b
{
  ...
  &quot;height&quot;: 32255,
  ...
  &quot;bits&quot;: &quot;1d00ffff&quot;,
  &quot;difficulty&quot;: 1,
  &quot;chainwork&quot;: &quot;00000000000000000000000000000000000000000000000000007e007e007e00”,
  ...
}
</code></pre>
<p>As you can see above, the chainwork value is [0x7e00,0x7e00,0x7e00], which is exactly the height[32255]+1(for the genesis block) times [0x01,0001,0001].</p>
<pre><code>[0x7e00,0x7e00,0x7e00] = 32256 * [1.0] * [0x01,0001,0001]
</code></pre>
<p>Then let's take a look at block 32256:</p>
<pre><code>$ bitcoin-cli getblockhash 32256
000000004f2886a170adb7204cb0c7a824217dd24d11a74423d564c4e0904967

$ bitcoin-cli getblockheader 000000004f2886a170adb7204cb0c7a824217dd24d11a74423d564c4e0904967
{
  ...
  &quot;height&quot;: 32256,
  ...
  &quot;bits&quot;: &quot;1d00d86a&quot;,
  &quot;difficulty&quot;: 1.182899534312841,
  &quot;chainwork&quot;: &quot;00000000000000000000000000000000000000000000000000007e01acd42dd2”,
  ...
}
</code></pre>
<p>At block 32256, because the difficulty increase from 1.0 to 1.182899534312841, then</p>
<pre><code> [chainwork value] = [previous chainwork value] + [difficulty] * [0x01,0001,0001]
 [0x7e01,acd4,2dd2] = [0x7e00,0x7e00,0x7e00] + [1.182899534312841] * [0x01,0001,0001]
</code></pre>

CC BY-SA 3.0
2017-12-29T05:23:18.780Z
Upvoted for extra detail.
Pieter Wuille
CC BY-SA 4.0
2017-12-29T02:32:55.657Z
2022-06-21T13:57:07.403Z
2022-06-21T13:57:07.403Z
gary
<p>The chainwork value is really just the total amount of work in the chain.</p>

<p>It is the total number of hashes that are expected to have been necessary to produce the current chain, in hexadecimal.</p>

<p>Converting <code>0000000000000000000000000000000000000000000086859f7a841475b236fd</code> to decimal, you get 635262017308958427068157, or 635262 exahashes.</p>

<p>At june 2014 hash rates (100 petahash/s), it would require only 73 days to perform that many hashes, while in reality it took over 5 years. The hash rate has been going up so fast however that the impact of more than a few months ago is negligible.</p>

CC BY-SA 3.0
2014-10-03T21:03:42.533Z
Is this the number of single hashes or the number of double SHA-256 hashes? Or, asked in a different way, does double SHA-256 hashing the header count as a single hash or two hashes?
morsecoder
CC BY-SA 3.0
2014-10-03T22:54:50.560Z
@StephenM347 that doesn't actually matter, as the chainwork is only used to compare different chains. But in practice, a double SHA-256 operation is counted as 1.
Pieter Wuille
CC BY-SA 3.0
2014-06-10T15:38:10.097Z
2014-06-10T15:38:10.097Z
Pieter Wuille
<p>If I run the RPC call <code>getBlock</code> on the bitcoin-qt client it gives me field called <code>chainwork</code> containing a hash. I can't find any information what this value is about.</p>
<p>Request:</p>
<pre><code>getblock 0000000000000000073dacdd0178da5158bd78c543fbc79bd0dacf56a2021bcc
</code></pre>
<p>Result:</p>
<pre class="lang-json prettyprint-override"><code>{
    &quot;hash&quot;: &quot;0000000000000000073dacdd0178da5158bd78c543fbc79bd0dacf56a2021bcc&quot;,
    &quot;confirmations&quot;: 1,
    &quot;size&quot;: 182400,
    &quot;height&quot;: 304962,
    &quot;version&quot;: 2,
    &quot;merkleroot&quot;: &quot;b144b39759d4669cb92ca8b9084d68d1f05f1e28e16887bf062f37e3b5f79fd2&quot;,
    &quot;tx&quot;: [
        &quot;3edc72d280edd0a7719670a5f0c97e8991a5bcfcfcfa77620969643f04d021a3&quot;,
        &quot;841840f8a7863c8fb99e26975d45ff9151b0a5f021fb479aa9ff91a138d3cd3f&quot;,
        &quot;a01af3f203313cdab4e8977cd2dccbd416872c9d9f76968fc7009f47ad630199&quot;
    ],
    &quot;time&quot;: 1402334610,
    &quot;nonce&quot;: 2351732739,
    &quot;bits&quot;: &quot;185d859a&quot;,
    &quot;difficulty&quot;: 11756551916.903952,
    &quot;chainwork&quot;: &quot;0000000000000000000000000000000000000000000086859f7a841475b236fd&quot;,
    &quot;previousblockhash&quot;: &quot;000000000000000031132699bcb917e7e6ce3cc6cce1f20b6ad36a437436c821&quot;
}
</code></pre>

CC BY-SA 3.0
2014-06-09T17:42:42.303Z
Possibly this: https://bitcointalk.org/index.php?topic=136628.0
Tim S.
CC BY-SA 3.0
2014-06-09T19:38:06.387Z
Not sure if this is about the chainwork or about best chain in logfiles of bitcoin-qt. On bitcointalk it says the hex data of best chain is just the first bytes of the rawblock. I checked if chainwork is the first bytes of the block but it doesnt match. Also best chain is not value of a blocks, it defines a block while chainwork changes at every block. But maybe its the sum of work put into this chain, i will check that tomorrow
Dennis Kriechel
<bitcoind><json-rpc><block><best-chain><chainwork>
What is chainwork?
Dennis Kriechel
# What is chainwork?

(Asked by: username_0 on 2014-06-09)

If I run the RPC call `getBlock` on the bitcoin-qt client it gives me field called `chainwork` containing a hash. I can't find any information what this value is about.

Request:

```
getblock 0000000000000000073dacdd0178da5158bd78c543fbc79bd0dacf56a2021bcc

```

Result:

```json
{
    "hash": "0000000000000000073dacdd0178da5158bd78c543fbc79bd0dacf56a2021bcc",
    "confirmations": 1,
    "size": 182400,
    "height": 304962,
    "version": 2,
    "merkleroot": "b144b39759d4669cb92ca8b9084d68d1f05f1e28e16887bf062f37e3b5f79fd2",
    "tx": [
        "3edc72d280edd0a7719670a5f0c97e8991a5bcfcfcfa77620969643f04d021a3",
        "841840f8a7863c8fb99e26975d45ff9151b0a5f021fb479aa9ff91a138d3cd3f",
        "a01af3f203313cdab4e8977cd2dccbd416872c9d9f76968fc7009f47ad630199"
    ],
    "time": 1402334610,
    "nonce": 2351732739,
    "bits": "185d859a",
    "difficulty": 11756551916.903952,
    "chainwork": "0000000000000000000000000000000000000000000086859f7a841475b236fd",
    "previousblockhash": "000000000000000031132699bcb917e7e6ce3cc6cce1f20b6ad36a437436c821"
}

```

**Tags:** bitcoind, json-rpc, block, best-chain, chainwork

> **Comments:**
> **username_1**: Possibly this: https://bitcointalk.org/index.php?topic=136628.0  
> **username_0**: Not sure if this is about the chainwork or about best chain in logfiles of bitcoin-qt. On bitcointalk it says the hex data of best chain is just the first bytes of the rawblock. I checked if chainwork is the first bytes of the block but it doesnt match. Also best chain is not value of a blocks, it defines a block while chainwork changes at every block. But maybe its the sum of work put into this chain, i will check that tomorrow  

---

## 2 answers

### Answer by username_3 on 2014-06-10. Score: 18 | Accepted answer

The chainwork value is really just the total amount of work in the chain.

It is the total number of hashes that are expected to have been necessary to produce the current chain, in hexadecimal.

Converting `0000000000000000000000000000000000000000000086859f7a841475b236fd` to decimal, you get 635262017308958427068157, or 635262 exahashes.

At june 2014 hash rates (100 petahash/s), it would require only 73 days to perform that many hashes, while in reality it took over 5 years. The hash rate has been going up so fast however that the impact of more than a few months ago is negligible.

> **Comments:**
> **username_4**: Is this the number of single hashes or the number of double SHA-256 hashes? Or, asked in a different way, does double SHA-256 hashing the header count as a single hash or two hashes?  
> **username_3**: @StephenM347 that doesn't actually matter, as the chainwork is only used to compare different chains. But in practice, a double SHA-256 operation is counted as 1.  

---

### Answer by username_2 on 2017-12-29. Score: 22

username_3's answer is good, the chainwork value is the expected work amount in the chain, expressed as a 32 bytes integer, for the double SHA-256 hashes calculation work.

The chainwork is used to identify the correct chain, the biggest chainwork value means the strongest or the correct chain.

By the way, Satoshi didn't initially realize that choosing the correct chain by just counting blocks allows for some extremely easy attacks. Version 0.1 just counted blocks. That's why the paper just says "longest". The idea of "chain work" was added a little later. For detail about this, please refer to [here](https://bitcoin.stackexchange.com/questions/29742/strongest-vs-longest-chain-and-orphaned-blocks).

I just want to give some info about **how this 'chainwork' value comes**, for the better or deeper understanding about what it is.

Let's take a look at Satoshi's genesis block header (part of related info):

```
$ bitcoin-cli getblockhash 0
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f

$ bitcoin-cli getblockheader 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
{
  ...
  "height": 0,
  ...
  "bits": "1d00ffff",
  "difficulty": 1,
  "chainwork": "0000000000000000000000000000000000000000000000000000000100010001",
  ...
}

```

As you see above, the genesis block has a '1' difficulty and a [0x01,0001,0001] chainwork . If you have a question about what's a 'difficulty', you can take a look at [this answer](https://bitcoin.stackexchange.com/questions/5838/how-is-difficulty-calculate). So, that's the right definition:

```
difficulty '1' = chainwork amount [0x01,0001,0001]

```

Then, each time when a new block generated, we just accumulate the chainwork with new block's 'difficulty' field value, but remember for each '1' difficulty we add a chainwork amount [0x01,0001,0001].

As the block chain grows, the difficulty will increase (or sometimes slightly decrease) little by little.

Before the first time of difficulty changed, the chain block height had reached 32255.

```
$ bitcoin-cli getblockhash 32255
00000000984f962134a7291e3693075ae03e521f0ee33378ec30a334d860034b

$ bitcoin-cli getblockheader 00000000984f962134a7291e3693075ae03e521f0ee33378ec30a334d860034b
{
  ...
  "height": 32255,
  ...
  "bits": "1d00ffff",
  "difficulty": 1,
  "chainwork": "00000000000000000000000000000000000000000000000000007e007e007e00”,
  ...
}

```

As you can see above, the chainwork value is [0x7e00,0x7e00,0x7e00], which is exactly the height[32255]+1(for the genesis block) times [0x01,0001,0001].

```
[0x7e00,0x7e00,0x7e00] = 32256 * [1.0] * [0x01,0001,0001]

```

Then let's take a look at block 32256:

```
$ bitcoin-cli getblockhash 32256
000000004f2886a170adb7204cb0c7a824217dd24d11a74423d564c4e0904967

$ bitcoin-cli getblockheader 000000004f2886a170adb7204cb0c7a824217dd24d11a74423d564c4e0904967
{
  ...
  "height": 32256,
  ...
  "bits": "1d00d86a",
  "difficulty": 1.182899534312841,
  "chainwork": "00000000000000000000000000000000000000000000000000007e01acd42dd2”,
  ...
}

```

At block 32256, because the difficulty increase from 1.0 to 1.182899534312841, then

```
 [chainwork value] = [previous chainwork value] + [difficulty] * [0x01,0001,0001]
 [0x7e01,acd4,2dd2] = [0x7e00,0x7e00,0x7e00] + [1.182899534312841] * [0x01,0001,0001]

```

> **Comments:**
> **username_3**: Upvoted for extra detail.  

---

