[Ethereum] How to get the confirmations of a transaction programmaticallly

confirmationssoliditytransactions

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.

Best Answer

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.

Related Topic