Below is block result of block height 200,000


Below is coinbase transaction of 200000 block

            'asm':'04b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6537a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b OP_CHECKSIG',

What I want to is decoding vin.coinbaise

I searched out some docs, but I failed to find out exact way of decoding this part:

coinbase: 03400d0302ef02062f503253482f522cfabe6d6dd90d39663d10f8fd25ec88338295d4c6ce1c90d4aeb368d8bdbadcc1da3b635801000000000000000474073e03

Do you have any idea how to decode it?

1 Answer 1


In the original source code there were little restrictions on what could be in the coinbase data of the coinbase transaction. I think the only restriction was that the coinbase data should be between 2 to 100 bytes. However, this lack of restriction on what can be within the coinbase data brought up a vulnerability. It was perfectly legal for miners to create a coinbase transaction identical to previous one and mine it in a block at a height higher than where the "original" coinbase transaction. When this happened it led to the invalidation of the previous transaction.

This was fixed later when couple of blocks were mined with identical coinbase data. As per BIP-34, version-2 blocks must contain the block height index as a script push operation in the beginning of the coinbase field. For example, in your coinbase transaction this data is represented by the bytes 0x03400d03. The first byte 0x03 indicates the script should push the next 3 bytes. The next three bytes 0x400d03 represent the block height 200,000 in little endian.

The rest of the coinbase data is free for the miners to use as per their will. This is mostly used as a space for extra-nonce. In the early days of Bitcoin, a miner could find a block by iterating through the nonce until the resulting hash was below the target. As difficulty increased, miners often cycled through all 4 billion values of the nonce (232) without finding a valid block header hash. However, this was easily resolved by updating the block timestamp to account for the elapsed time. Because the timestamp is part of the header, the change would allow miners to iterate through the values of the nonce again with different results.

Once mining hardware became really efficient, however, this approach became increasingly difficult because the nonce values were exhausted in less than a second. Hence, the mining software needed more space for nonce values in order to find valid blocks. The timestamp could be stretched a bit, but moving it too far into the future would cause the block to become invalid. The solution was to use the coinbase transaction as a source of extra nonce values. Because the coinbase script can store between 2 and 100 bytes of data (~first 4 bytes reserved for block identification), miners started using that 96 byte space as extra nonce, allowing them to explore a much larger range of block header values to find valid blocks.

The mining pools also use the coinbase data as an identification of who mined the block. For example if you look at block 594,041, you will see the coinbase data contain the bytes 0x4d696e656420627920416e74506f6f6c. It represents "'Mined by AntPool" in ASCII. (Unfortunately the block you mentioned did not have any identification hence I had to use a different block that did have it). However, it is important to note that this data cannot be relied upon, as any miner can mine a block tomorrow with a data claiming it to be mined by a different pool, may be to hide its identity or frame others.

  • Thank you for your comment :) It will be really helpful. The reason why I want to decode coinbase tx is I want get who mines a block. But according to your answer, my approach is not reliable. Then is there no reliable way to find out who mines a block?
    – dingyo777
    Sep 30, 2019 at 1:00
  • @dingyo777 it is not possible to determine it with certainty who mines the block. You can refer to the answer here for more information.
    – Ugam Kamat
    Sep 30, 2019 at 3:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.