This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Get transaction by hash doesnt found tx sometimes #7177
Open
Description
Expected behavior
I want that this.provider.getTransaction(params[0]) doesnt fail at the first try if it doesnt found the transaction.
Actual behavior
”Transaction not found" error, but if you try again, the tx is there.
Workaround
case "eth_getTransactionByHash": {
let attempts = 0
while (attempts < 10) {
try {
const receipt = await this.provider.eth.getTransaction(params[0])
if (receipt) {
return receipt
}
} catch (error) {
console.error("Polling error: ", error)
}
await new Promise((resolve) => setTimeout(resolve, 1000))
attempts += 1
}
throw new Error("Transaction receipt not found after max attempts")
}