2

everyone! I have faced with one problem. I can find the transaction hash once transaction is created. Because I am watching the blocks with newBlockHeader event. At the moment, I want to check and update the confirmation number of this transaction. I tried with this

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

But it returns NaN. How can I do?

2
  • 2
    What do each of those commands return when run individually? Commented Feb 12, 2018 at 16:13
  • web3.eth.blockNumber: undefined web3.eth.getTransaction(<txhash>).blockNumber : undefined Both of 2 values are all undefined. And eth.syncing returns false in geth console
    – H.Ming
    Commented Feb 12, 2018 at 16:26

1 Answer 1

3

6 years....

So what about a solution? In v6 ethers.js we can do something like this:

const tx = await this.eth.getTransactionReceipt(params.hash);

console.log('tx', tx);
console.log('tx confirmations', await tx.confirmations());

tx ...
tx confirmations 65

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.