Why does wallet_prepareCalls revert with execution reverted or out-of-gas errors on swaps and other dynamic contracts?

Last updated: August 25, 2026

If calls prepared with wallet_prepareCalls revert on execution with -32521 execution reverted, or fail with a callGasLimit-related error, even though the same call succeeded in simulation, this is usually caused by a gap between the gas estimated during simulation and the gas actually consumed on-chain.

Why this happens

wallet_prepareCalls estimates callGasLimit by simulating your call before it is sent. For contracts with dynamic or state-dependent execution paths, such as DEX swaps or any contract whose logic branches based on current on-chain state (for example cold versus warm storage slots), the actual gas used at execution time can be higher than what simulation estimated. When that happens, the user operation can run out of gas and revert on-chain even though it passed simulation.

This is separate from fee (maxFeePerGas / maxPriorityFeePerGas) estimation issues, and separate from an on-chain revert caused by the call itself being invalid, such as a swap failing its slippage or minimum-output check.

How to fix it

  • If you know the maximum gas the contract you are calling can require, set callGasLimit directly in the wallet_prepareCalls request.

  • If you don't know the exact value, add a buffer on top of the simulated estimate using the capabilities.gasParamsOverride.callGasLimit field. A good starting point is a 30% buffer (a 1.3x multiplier), increasing it further if the contracts you call are highly dynamic.

{
  "capabilities": {
    "gasParamsOverride": {
      "callGasLimit": { "multiplier": 1.3 }
    }
  }
}

gasParamsOverride accepts either an absolute value or a multiplier for the relevant gas field. Applying a buffer only increases the gas limit made available to the call. Users are still only charged for the gas actually used.

Related docs