How do I get the block confirmations for a specific transaction using the JSON RPC?

This is information that would come inside the transaction JSON in bitcoin but it doesn't seem to come in ethereum.

What am I missing?


2 Answers 2


When you send a transaction, you will receive back a transaction hash.

Use the command getTransactionByHash({transaction hash}) to retrieve the transaction details. Your blockNumber should be non-null if the transaction has been mined and included into a block.

The call is documented in https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyhash with the following example:

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}'

// Result
  "result": {
    "blockHash": "0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b",
    "blockNumber": "0x15df", // 5599
    "transactionIndex":  "0x1", // 1
    "value":"0x7f110" // 520464
    "gas": "0x7f110" // 520464

Then call eth_blockNumber (https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_blocknumber) to get the current block height. Your number of confirmations is the eth_blockNumber result minus the eth_getTransaction blockNumber result.

  • 1
    Ok, but how does that translate to confirmations? How is the blocknumber related to the confirmations of the transaction?
    – Nico
    Apr 11, 2016 at 17:17
  • I get that, but how does that relate to the confirmations? @BokkyPooBah
    – Nico
    Apr 11, 2016 at 17:20
  • 1
    See eth_blockNumber and difference calc in updated answer Apr 11, 2016 at 17:24
  • 1
    So, when transaction is first included in the block, does it has one confirmation? Or confirmations are counted from the next block only? Dec 9, 2017 at 12:13

The answer given by BokkyPooBah is perfect and as for how does that relate to the confirmations, I raised the same question here: How does (current block number - block number of a given transaction) gives the confirmation count?.

You might also refer to the comments for the question: Ethereum network transaction confirmation coverage. The idea is that, if your transaction was included in block number 100 (just assume) and the current block number is 160, it means 60 random miners accepted the block 100 as valid and added to that chain and so you can say that you have 60 confirmations. This is all about consensus.

  • So, when transaction is first included in the block, does it has one confirmation? Or confirmations are counted from the next block? Dec 9, 2017 at 12:13
  • @SlavaFominII When a transaction is first included in a block (say X), that cannot be counted as first confirmation. For all you know, I could be trying to break the chain. If another miner place a block over X, then that is a confirmation that X could be correct and you can say that the transaction has one confirmation.
    – devsubhro
    Dec 12, 2017 at 8:50

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.