interface icon indicating copy to clipboard operation
interface copied to clipboard

[BUG] fix: refactored sendTx to solve edgecase when using smart accounts erc20 paymaster txs

Open AGMASO opened this issue 1 month ago • 2 comments

General Changes

  • Fixed edge case when sending Txs using smart accounts erc20 paymaster(Metamask)
  • Fixes: AAVEV3-7

Developer Notes

BUG DESCRIPTION

The incompatibility only arises when performing an action that requires sendTx using an EOA with an associated smart account in MetaMask and paying the fees using an ERC-20 Paymaster. In other words, the native token is not used to pay for the transaction.

In this scenario, the transaction succeeds on-chain, but the UI fails, causing confusion for the user. The balances are correctly updated, and if the user checks the transaction hash in MetaMask’s activity tab, they will see that the transaction was indeed executed successfully.

CAUSE

The root cause is that ethers, in its sendTransaction function, does not account for the different flow that occurs when executing a smart account transaction using an ERC-20 Paymaster.

The flow works as follows: The user submits the transaction using ethers’ sendTransaction. This transaction is intercepted by the smart account, which creates a UserOp with the corresponding values and sends it to the bundler. The bundler is the component that actually sends the transaction to the blockchain and produces a valid transaction hash.

Ethers internally fails to recognize this alternative flow—either due to unhandled logic or internal timeouts—which leads it to throw an error even though the transaction was correctly sent to the bundler and the blockchain.

SOLUTION

We created a custom path to analyze the error emitted by ethers. If the error contains a valid transaction hash, it means that a smart account transaction with an ERC-20 Paymaster was executed. In that case, we extract the hash, fetch the corresponding receipt, and return it to the UI. This resolves the edge case.

If no valid hash exists in the error, we simply return the original error as usual.

Reviewer Checklist

Please ensure you, as the reviewer(s), have gone through this checklist to ensure that the code changes are ready to ship safely and to help mitigate any downstream issues that may occur.

  • [ ] End-to-end tests are passing without any errors
  • [ ] Code changes do not significantly increase the application bundle size
  • [ ] If there are new 3rd-party packages, they do not introduce potential security threats
  • [ ] If there are new environment variables being added, they have been added to the .env.example file as well as the pertinant .github/actions/* files
  • [ ] There are no CI changes, or they have been approved by the DevOps and Engineering team(s)

AGMASO avatar Nov 13 '25 12:11 AGMASO