Type for getTransaction misses `| null`
See original GitHub issueOk, so first of all, I found this due to a programming error so probably not an issue that happens for a lot of people, but types could have caught this.
- provider.getTransaction returns
Promise<TransactionResponse>
- but call this function with a transaction has from e.g. a different chain or a dropped transaction, JSON RPC returns null
- Ethers (v5) passes along this null while the types think it is a TransactionResponse and do not complain about accessing tx.data for example
Example call in JSON RPC which triggers this in ethers:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xa52be92809541220ee0aaaede6047d9a6c5d0cd96a517c854d944ee70a0ebb44"],"id":53}' -H "Content-Type: application/json" https://mintnet.settlemint.com
{"jsonrpc":"2.0","result":null,"id":53}
Maybe this is client/version specific so for reference this is a Parity Aura network running 2.5.5
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
getTransaction returns null for some pendingTransactions ...
I am doing getTransaction for each received pendingTransaction like below. web3.eth.subscribe('pendingTransactions', function(error, txnid) { ...
Read more >eth.getTransactionReceipt returns null - Stack Overflow
It looks like there's an issue with your node. The receipt is returned from Infura. I'd recommend resync without --fast .
Read more >Consistent API design - Akshay Jain
Suppose we have an API /getTransaction with following response ... Getting null as a value for transactionComments from API, ... Write on Medium ......
Read more >Error getting transaction data for Transaction Number: 1 ...
Error getting transaction data for Transaction Number: 1. Value cannot be null. Parameter name: source at Source: Message box.
Read more >eth getTransactionReceipt returns null | Edureka Community
... a blockchain explorer, but our Eth fullnode seems to be missing . ... eth getTransactionReceipt returns null ... getTransaction but eth.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Code that uses getTransaction has to check for null since it will otherwise crash for dropped transactions. Existing code that does not do this is wrong, I was just bitten by this. Correcting the TypeScript types is not a breaking change, it’s a bug fix
That should be fine. I don’t see any issue with using that to isolate it to your own project. 😃