GET /chains/<chain_id>/chain_id returns:
'the chain unique identifier'
How is this identifier computed?
Tezos Stack Exchange is a question and answer site for users, experts, and developers of the Tezos blockchain project. It only takes a minute to sign up.Sign up to join this community
chain_id is computed from the genesis block hash as follows.
First, in pseudocode:
tezosB58CheckEncode('Net', firstFourBytes( blake2b(msg = tezosB58CheckDecode('B', genesisBlockHash), size = 32)))
Take the genesis block hash. For example, in mainnet, this is
Base58Check-decode the block hash. The prefix bytes for blocks "B" are [1, 52] (in decimal), as you can see by doing
git grep B\( in tezos.git. This gives us
BLAKE2B hash (size 32) of the block hash bytes. We get
0x7a06a7709ff405d1791d856c52a3c55246e03ec913599b813ec2977398afb3be. Take only the first four bytes,
Base58Check-encode these four bytes with the "Net" prefix [87, 82, 0] (
git grep Net\(). We get
For a protocol update test chain, I believe the 'genesis' block will be the block in the main chain from which the test chain was forked.
You can find this computation defined in
lib_crypto/chain_id.ml and then used as
Chain_id.of_block_hash in various places (e.g.