1

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?

H.Ming
  • 55
  • 1
  • 5
  • 2
    What do each of those commands return when run individually? – Richard Horrocks Feb 12 '18 at 16:13
  • web3.eth.blockNumber: undefined

    web3.eth.getTransaction().blockNumber : undefined

    Both of 2 values are all undefined. And eth.syncing returns false in geth console

    – H.Ming Feb 12 '18 at 16:26

1 Answers1

1

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