Determining the genesis transaction value or genesis_tx


Is there a way to determine the genesis transaction (genesis_tx) hash? I know the genesis block number but how do you determine genesis_tx? I am looking for this hash for an altcoin which was forked from litecoin.


Posted 2018-02-12T21:40:02.167

Reputation: 29



You can also get it from command line with bitcoin-cli, litecoin-cli etc.

For litecoin in regtest mode for example, first get the hash of the genesis block (height = 0):

$ litecoin-cli getblockhash 0

which returns 530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9.

Then get the genesis block using its hash:

$ litecoin-cli getblock 530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9

which returns:

{ "hash": "530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9", "confirmations": 1, "strippedsize": 280, "size": 280, "weight": 1120, "height": 0, "version": 1, "versionHex": "00000001", "merkleroot": "97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9", "tx": [ "97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9" ], "time": 1296688602, "mediantime": 1296688602, "nonce": 0, "bits": "207fffff", "difficulty": 4.656542373906925e-10, "chainwork": "0000000000000000000000000000000000000000000000000000000000000002" }

Notice there is no nextblockhash property because I have a freshly initialized regtest chain i.e. it has no blocks other than the genesis. But even if I were to generate blocks with say generate or generatetoaddress, I'd still have all the fields remain as shown above. Only additional field would be a nextblockhash.

As @MeshCollider said in his answer, given that the genesis block has a single coinbase tx, its txid and the merkeRoot coincide.

Thalis K.

Posted 2018-02-12T21:40:02.167

Reputation: 371


The genesis block's coinbase transaction hash will be the same as the blocks merkle root because the coinbase transaction should be the only transaction in the genesis block. You should be able to find it in chainparams.cpp if the codebase is still similar to bitcoin, like so:

assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));


Posted 2018-02-12T21:40:02.167

Reputation: 9 285

It is forked from litecoin so it should be similar. So essentially, the genesis_tx is the merkleroot? – Nixxed – 2018-02-13T21:51:53.957

1@Nixxed Yep that's what I said ;) – MeshCollider – 2018-02-14T04:33:48.207