0

I have this, in ethers.js, where provider is a WebSocketProvider connected to a full node, which is working fine for getting the tx's (quite a lot of them per second):

provider.on('pending', async (txhash) => {
    console.log(`pending tx ${txhash}`);
    const tx = await provider.getTransaction(txhash);
    console.log(tx);
    const resp = await provider.call(tx);
    console.log(resp);
});

call works for return values, but I want to be able to get events from pending transactions in the mempool, as if they are ran at the top of the block.

I also have hardhat, but I'm having a hard time with this use case because I want to keep up with incoming blocks and also simulate each transaction independently (not affecting each other).

1
  • Not totally what you're looking for, but if you want to simulate a transaction and only submit it if it passes, you're looking for flashbots tech: github.com/flashbots/… Presumably if you dig into their source, you might be able to find out how they do this
    – Aaron Ash
    Jun 19 at 10:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.