waitForTransactionReceipt when using MEV Blocker does not wait
Check existing issues
- [x] I checked there isn't already an issue for the bug I encountered.
Viem Version
2.38.0
Current Behavior
I'm using https://rpc.mevblocker.io (see MEV Blocker) on mainnet in order to get some MeV protection.
Within this:
const txHash = await wclient.writeContract(req);
const receipt = await wclient.waitForTransactionReceipt({
hash: txHash,
});
As soon as the transaction is signed receipt resolves immediately (too early) and all fields on the receipt are undefined.
I tried retrying with confirmations=2 (if the first attempt is undefined), but this never resolves.
If I manually sleep for 15 seconds and then use:
receipt = await wclient.getTransactionReceipt({
hash: txHash,
});
Then the receipt is populated ok - but obviously this isn't too useful as the tx may not have mined in that time.
If i update the RPC to be a non-mev protected RPC then it works ok...
Any ideas?
Expected Behavior
No response
Steps To Reproduce
No response
Link to Minimal Reproducible Example
No response
Anything else?
No response
My guess is that the RPC is returning a premature receipt (unexpected). Can you provide a minimal repro?
My guess is that the RPC is returning a premature receipt (unexpected). Can you provide a minimal repro?
https://github.com/frontier159/viem-mevblocker-repro
Super minimal -- it just approves WETH to the zeroAddress for 0 amount. You can check the console log
NB: I still had to override the RPC url in my wallet (Rabby) on mainnet to https://rpc.mevblocker.io/
Any thoughts on this @jxom ?
I could replicate using a local fork via anvil too:
anvil --hardfork cancun --fork-url $MAINNET_RPC_URL --fork-block-number 23615817 --block-time 12
And then in https://github.com/frontier159/viem-mevblocker-repro
a/ set the config to [mainnet.id]: http("127.0.0.1:8545"), and pnpm run dev
b/ import the first anvil test PK (0xac09...) into your browser wallet
c/ set your wallet to use that EOA and also override to use the anvil rpc: http://127.0.0.1:8545
After you sign the tx it should log if it couldn't find the tx - I get this
@jxom I wonder if you have a chance to quickly check / validate this?