-
Describe the FeatureI want to check if my wallet has no pending Tx before creating another Tx : what is the fastest way to do that? I created this function but I'm sure there is a better way... What do you think ? I've seen some functions like getPendingTransactions, but I did not understand if it could help me... Thanks a lot Code Example// Check if you don't have pending Tx
const check_pending_tx = async () => {
let pending_tx = false;
// Check nonce and pending nonce
const [current_nonce, pending_nonce] = await Promise.all( [provider.getTransactionCount(trading_wallet.address), provider.getTransactionCount(trading_wallet.address, 'pending') ]);
if (current_nonce !== pending_nonce) {
pending_tx = true;
}
// Return "does my wallet has a pending Tx?"
return pending_tx;
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
There is no feature in normal Ethereum nodes for This method is an ok approximation. Keep in mind the network is eventually consistent, so it’s quite possible that the mempool you are querying does not have all the transactions from your account, either because it doesn’t meet its retention rules or because it hasn’t received it yet. |
Beta Was this translation helpful? Give feedback.
-
Sometimes , the node replies 'null', which could be the transaction I want to find. thanks to @ricmoo told the reasons. |
Beta Was this translation helpful? Give feedback.
There is no feature in normal Ethereum nodes for
getPendingTransaction
(that I know of).This method is an ok approximation. Keep in mind the network is eventually consistent, so it’s quite possible that the mempool you are querying does not have all the transactions from your account, either because it doesn’t meet its retention rules or because it hasn’t received it yet.