Can I get the confirmations of a transaction using Solidity? If not, is there any other method I can use to get confirmations programmatically?

I hope when user submits one transaction, the web can show the result and the result won't be changed later. The users accept to wait the longer time, example 1 or 3 minutes, for making sure the transaction is finished.

2 Answers 2


Solidity and the web are different. Solidity itself does not have access to past transactions. For the web, you would use web3.js and see the code at How can a DApp detect a fork or chain reorganization using web3.js or additional libraries? which waits specified number of blocks and verifies the transaction receipt is still valid. In this method, the user doesn't have to wait 1 or 3 minutes (after they click a button to submit a transaction), and if there is a chain reorg, the UI can be updated: the UI could let the user know that they have to resubmit their transaction.

  • Sir,I read the link and have a more clear concept.Thanks~
    – 黃智祥
    Mar 1, 2017 at 8:47

This was mentioned in another question, also here

Number of confirmations is the current block number minus the transaction's block number (if any).

For web3, this can be found by the following command

web3.eth.blockNumber - web3.eth.getTransaction(<txhash>).blockNumber

I think the same would also work in Geth console after removing the web3.'s.

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.