ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

provider.getTransaction wait don't get result

Open linxianxi opened this issue 3 years ago • 2 comments

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 image

Code Snippet

No response

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

linxianxi avatar Jun 14 '22 07:06 linxianxi

should use waitForTransaction to get result.status, but can not get value. Is there a way to get status and value? @ricmoo

linxianxi avatar Jun 14 '22 07:06 linxianxi

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.

ricmoo avatar Jun 17 '22 06:06 ricmoo