Skip to content

fix(examples): skip simulateContract for bid to avoid stale RPC allowance error#87

Closed
WillSewell wants to merge 1 commit into
mainfrom
mux/sonar-claude-mou5ov4k
Closed

fix(examples): skip simulateContract for bid to avoid stale RPC allowance error#87
WillSewell wants to merge 1 commit into
mainfrom
mux/sonar-claude-mou5ov4k

Conversation

@WillSewell

Copy link
Copy Markdown
Contributor

Summary

  • The EVM example apps' bid flow runs simulateContract (an eth_call at block "latest") right after the ERC20 approval is confirmed. On load-balanced RPCs like sepolia.base.org, the eth_call can be routed to a node that hasn't yet seen the approval block, so it reverts with transfer amount exceeds allowance and the user has to click Commit a second time.
  • Fix: drop the pre-flight simulation and call writeContractAsync directly with the bid args. The on-chain execution runs after the approval is confirmed and always sees the correct allowance.
  • Applied to both nextjs-evm and react-evm. The approve and cancelBid simulations are unchanged — they don't depend on a just-confirmed block.

Resolves SONAR-5.

Test Plan

  • tsc --noEmit passes for nextjs-evm
  • tsc -b passes for react-evm
  • eslint passes on both modified files
  • Manual: run an example app against sepolia.base.org, click Commit on a fresh permit, confirm it goes through on the first attempt without the allowance revert

…ance error

The bid flow approves the ERC20, waits for the receipt, then runs
simulateContract (eth_call at block "latest") before writing the bid.
On load-balanced RPCs like sepolia.base.org, the eth_call can be served
by a node that hasn't yet seen the approval block, returning
"transfer amount exceeds allowance" and forcing the user to click
Commit a second time. The on-chain execution always sees the confirmed
approval, so calling writeContractAsync directly is safe.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@WillSewell

Copy link
Copy Markdown
Contributor Author

Switching approach — keeping the pre-flight simulation and adding a code comment instead, since this only affects load-balanced public RPCs and the right production fix is to configure a dedicated RPC. New PR incoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant