Trying to find the raw genesis transaction length


I see that many different altcoins have different lengths for the initial genesis tx. How would I go about finding the length of the initial genesis tx? I saw another answer but I have no need of making it as complicated; I just need the length and nothing else.

For example, Bitcoin's is


However, altcoins have different lengths. Is there an identifier I can use to determine the length of the genesis tx and nothing else?

EDIT: I am making a block explorer so I cannot use a block explorer to help me in getting info.


Posted 2015-04-06T18:35:36.013

Reputation: 3

The transaction you posted is 204 bytes. Is that what you're looking for? – Nick ODell – 2015-04-06T18:50:39.567

@NickODell That's only for bitcoin. What I need is in a condensed format, preferably done in bash instead of python.

– AnimalTesting – 2015-04-06T18:58:47.887



Unfortunately, the genesis block is not indexed in most altcoins (because they forked from bitcoin and kept the same bug), so you can't really get access to it via the RPC methods.

What you could do instead:

  • Use a block explorer that will tell you the size of the transaction. For example, makes this information available (204 bytes).
  • Find the parameters file and put a print the size of the genesis block to stdout.

The second option basically entails putting the following lines at the end of CMainParams() and then compiling.

ssBlock << genesis;
printf("block: %s\n", HexStr(ssBlock.begin(), ssBlock.end()).c_str());
printf("block size: %i\n", (int)::GetSerializeSize(genesis, SER_NETWORK, PROTOCOL_VERSION));
printf("tx size: %i\n", (int)::GetSerializeSize(genesis.vtx[0], SER_NETWORK, PROTOCOL_VERSION));

This will print the raw block data, it's size, and the transaction's size. (Note, this is untested, but something along these lines should work)

NOTE: It's possible, although not the norm, to put multiple transactions in a genesis block. Just check that your assumption is correct.


Posted 2015-04-06T18:35:36.013

Reputation: 13 123

Size would definitely work for this situation. Only problem is that I am trying to make the block explorer for the coin via Abe, so option 1 isn't available to me. Could you explain the second option? I am guessing you mean chainparams.cpp but I have no idea how to print the size of the genesis block. – AnimalTesting – 2015-04-06T19:09:00.447

@AnimalTesting, see updated answer. – morsecoder – 2015-04-06T19:16:32.957

How would I use the new code? What command do I have to pass into the daemon? – AnimalTesting – 2015-04-06T19:34:28.950

It requires actually re-compiling the daemon after you have put the code in place. Then just start the daemon and it will print. – morsecoder – 2015-04-06T19:35:28.137

Also, will this say the size of the block or transaction? You said "This will print the raw block data and it's size." But in the first option, you show how to find the size of the transaction. – AnimalTesting – 2015-04-06T19:38:55.167

It gave this error when compiling:

– AnimalTesting – 2015-04-06T19:39:53.047

@AnimalTesting, updated answer. – morsecoder – 2015-04-06T19:41:58.137

Let us continue this discussion in chat.

– AnimalTesting – 2015-04-06T19:43:03.520