<blockquote>
<p><strong>What does 'statically encoded' even mean?</strong></p>
</blockquote>
<p>See:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/572547/what-does-static-mean-in-c">https://stackoverflow.com/questions/572547/what-does-static-mean-in-c</a></li>
<li><a href="https://en.wikipedia.org/wiki/Character_encoding" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Character_encoding</a></li>
<li><a href="https://en.wikipedia.org/wiki/Binary-to-text_encoding" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Binary-to-text_encoding</a></li>
</ul>
<p>In the case of Bitcoin-Core it is actually <em>coded</em>† in C++ rather than <em>encoded</em>‡ in some encoding like Hex, Base58, etc.</p>
<hr />
<blockquote>
<p><strong>How Is The Genesis Block statically encoded into bitcoin client software?</strong></p>
</blockquote>
<p>In <code>src/chainparams.cpp</code> you can find</p>
<pre><code>static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript&amp; genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount&amp; genesisReward)
{
    CMutableTransaction txNew;
    txNew.nVersion = 1;
    txNew.vin.resize(1);
    txNew.vout.resize(1);
    txNew.vin[0].scriptSig = CScript() &lt;&lt; 486604799 &lt;&lt; CScriptNum(4) &lt;&lt; std::vector&lt;unsigned char&gt;((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
    txNew.vout[0].nValue = genesisReward;
    txNew.vout[0].scriptPubKey = genesisOutputScript;

    CBlock genesis;
    genesis.nTime    = nTime;
    genesis.nBits    = nBits;
    genesis.nNonce   = nNonce;
    genesis.nVersion = nVersion;
    genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
    genesis.hashPrevBlock.SetNull();
    genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
    return genesis;
}
</code></pre>
<p>And, apparently for each of mainnet, testnet, ... this static function is called like this example (with different parameters for each network)</p>
<pre><code>      genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
</code></pre>
<p>Other Bitcoin clients might code or encode it differently, though with the same resultant value.</p>
<p>e.g.</p>
<pre><code>static const string genesis58 = &quot;mgcrgiW4evD3ZVy2KPcG6GJrbUKSWMU22qPURoShM44B9iZpzAqDN&quot;
genesis = Base58.Decode(genesis58)
</code></pre>
<p>Then you could more accurately say the genesis block is statically encoded.</p>
<hr />
<p>† Note that 'coded' means different things in the worlds of cryptography and programming.<br />
‡ Ditto 'encoded'.</p>

CC BY-SA 4.0
2022-04-26T09:10:31.433Z
2022-04-26T10:06:48.947Z
2022-04-26T10:06:48.947Z
RedGrittyBrick
<p>What does 'statically encoded' even mean?</p>

<bitcoin-core><genesis-block>
How is the Genesis Block statically encoded into bitcoin client software?
Jamo
# How is the Genesis Block statically encoded into bitcoin client software?

(Asked by: username_0 on 2022-04-26)

What does 'statically encoded' even mean?

**Tags:** bitcoin-core, genesis-block


---

## 1 answers

### Answer by username_1 on 2022-04-26. Score: 2 | Accepted answer

> **What does 'statically encoded' even mean?**

See:

* <https://stackoverflow.com/questions/572547/what-does-static-mean-in-c>
* <https://en.wikipedia.org/wiki/Character_encoding>
* <https://en.wikipedia.org/wiki/Binary-to-text_encoding>

In the case of Bitcoin-Core it is actually *coded*† in C++ rather than *encoded*‡ in some encoding like Hex, Base58, etc.

---

> **How Is The Genesis Block statically encoded into bitcoin client software?**

In `src/chainparams.cpp` you can find

```
static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
    CMutableTransaction txNew;
    txNew.nVersion = 1;
    txNew.vin.resize(1);
    txNew.vout.resize(1);
    txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
    txNew.vout[0].nValue = genesisReward;
    txNew.vout[0].scriptPubKey = genesisOutputScript;

    CBlock genesis;
    genesis.nTime    = nTime;
    genesis.nBits    = nBits;
    genesis.nNonce   = nNonce;
    genesis.nVersion = nVersion;
    genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
    genesis.hashPrevBlock.SetNull();
    genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
    return genesis;
}

```

And, apparently for each of mainnet, testnet, ... this static function is called like this example (with different parameters for each network)

```
      genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);

```

Other Bitcoin clients might code or encode it differently, though with the same resultant value.

e.g.

```
static const string genesis58 = "mgcrgiW4evD3ZVy2KPcG6GJrbUKSWMU22qPURoShM44B9iZpzAqDN"
genesis = Base58.Decode(genesis58)

```

Then you could more accurately say the genesis block is statically encoded.

---

† Note that 'coded' means different things in the worlds of cryptography and programming.  
‡ Ditto 'encoded'.


---

