ethers.js
ethers.js copied to clipboard
provider.getTransaction wait don't get result
Ethers Version
5.6.4
Search Terms
No response
Describe the Problem
const hash = "0x252c0dff48884862207f1e164cdb0341e2102e0ccdd11ae577e942a7e5a0c432";
const provider = new ethers.providers.JsonRpcProvider("https://data-seed-prebsc-2-s1.binance.org:8545/");
const { wait } = await provider.getTransaction(hash);
const result = await wait();
console.log(result); // It took a long time but it didn't trigger
but in test bscscan can know it's failed, I want to know if it was successfully executed
https://testnet.bscscan.com/tx/0x252c0dff48884862207f1e164cdb0341e2102e0ccdd11ae577e942a7e5a0c432

Code Snippet
No response
Contract ABI
No response
Errors
No response
Environment
No response
Environment (Other)
No response
should use waitForTransaction to get result.status, but can not get value. Is there a way to get status and value? @ricmoo
How old is/was the transaction? The BSC, Matic and similar networks are very unreliable in general, but also aggressively prune the history (due to their short block time the state size grows fast, so they must), which means that transactions can very quickly get removed from the set of queryable data.
It isn't a fair comparison against bscscan, since that service maintains all historic data. You can use the BscscanProvider package, which may work better for historic data.