Online blockchain

bitcoin blockchain

Initializing Blockchain

Table Of Contents

Quick search

This page is proudly presented by

Initializing the genesis block¶

We initialize the blockchain an generate our first blocks.

The –enable-stale-production flag tells the witness_node to produce on a chain with zero blocks or very old blocks. We specify the –enable-stale-production parameter on the command line as we will not normally need it (although it can also be specified in the config file).

We will already see our chain id::

If other witness produces blocks and witness participation is high enough, subsequent runs which connect to an existing witness node over the p2p network, or which get blockchain state from an existing data directory, need not have the –enable-stale-production flag.

Setting up block production¶

Let’s create a very basic configuration file in data/testnet/config.ini :

All we put into the configuration file is the ids and the keys for the witnesses so that we can start producing blocks

This authorizes the witness_node to produce blocks on behalf of the listed witness-id ‘,s, and specifies the private key needed to sign those blocks. Normally each witness would be on a different node, but for the purposes of this testnet, we will start out with all witnesses signing blocks on a single node.

The setting rpc-endpoint = will open up the RPC-port 11011 to connect a cli-wallet or web wallet to it. With the p2p-endpoint = being accessible from the internet, this node can be used as seed node.

Embedding the Genesis block (optional)В¶

Now that we have the blockchain established and the used correct genesis block, we can have it embedded into the binaries directly. For that reasons we have moved it into the root directory and called it genesis.json for the default compile toolchain to catch it automatically. We recompile to include the genesis block with:

Deleting caches will reset all cmake variables, so if you have used instructions like Building from Sources which tells you to set other cmake variables, you will have to add those variables to the cmake line above.

Embedding the genesis copies the entire content of genesis block into the witness_node binary, and additionally copies the chain ID into the cli_wallet binary. Embedded genesis allows the following simplifications to the subsequent instructions:

  • You need not specify the genesis file on the witness node command line, or in the witness node configuration file.
  • You need not specify the chain ID on the cli_wallet command line when starting a new wallet.

[kw]Blockchain wallet testnet[/kw]

Related video: How to convert dogecoin to bitcoin

Leave a Reply

Your email address will not be published. Required fields are marked *