-
I have the following code scanning the pending transaction pool until my wallet is found: var scanTxPool = async () => {
var myWallet = '0x0000000000000000000000000000000000000000';
var foundWallet = false;
provider.on("pending", async (txHash) => {
if (!foundWallet) {
provider.getTransaction(txHash).then(async (tx) => {
if (tx && tx.to) {
if (tx.from === myWallet) {
console.log('Found my wallet!');
foundWallet = true;
}
}
});
}
});
// do other stuff
} The code is working great but I have two issues:
I've tried creating an |
Beta Was this translation helpful? Give feedback.
Answered by
zemse
Oct 16, 2021
Replies: 1 comment 5 replies
-
Does this work for you? var scanTxPool = async () => {
var myWallet = '0x0000000000000000000000000000000000000000';
// this waits until resolve() is called
await new Promise((resolve) => {
provider.on("pending", async (txHash) => {
provider.getTransaction(txHash).then(async (tx) => {
if (tx && tx.to) {
if (tx.from === myWallet) {
console.log('Found my wallet!');
provider.removeAllListeners();
resolve();
}
}
});
});
})
// do other stuff
} |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
proficy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this work for you?