await web3.eth.getBlockNumber()
.then((nextblock) => {
if (nextblock >= blockNumber + 2) {
return;
}
waitTransction(blockNumber)
}).catch(() => {
console.log("No new block added")
})
let current = await web3.eth.getBlock("latest");
if (current.number - blockNumber >= 2) {
if (blockNumber != null) {
console.log("blockNumber_mined");
setLoading(false)
return;
} else {
console.log(
"Transaction with hash: " +
transactionHash +
" ended up in an uncle block."
)
setLoading(false)
return;
}
}
}```
Working on a dapp. After the transaction on Ethereum blockchain. wanted to confirm the transaction. Is this the right function to confirm 2 block added ahead of the current block?