Skip to main content

Services documentation

Use high performance APIs provided by Infura to scale your dapp or Snap.

pimlico_simulateAssetChanges

Simulates a user operation to predict the asset changes it will cause. Shows all balance changes and shows all balance changes including native currency, ERC-20, ERC-1155, and ERC-721 tokens. This method uses 80 credits from your daily balance.

Parameters

  • userOperation: (object) - The user operation object with the same format as eth_estimateUserOperationGas:

    • sender: (string) - The address of the account making the operation.
    • nonce: (string) - The account nonce.
    • callData: (string) - The data to pass to the sender during the main execution call.
    • callGasLimit: (string) [optional] - The amount of gas to allocate the main execution call.
    • verificationGasLimit: (string) [optional] - The amount of gas to allocate for the verification step.
    • preVerificationGas: (string) [optional] - The amount of gas to pay for to compensate the bundler.
    • maxFeePerGas: (string) [optional] - Maximum fee per gas, in wei, the sender is willing to pay per gas.
    • maxPriorityFeePerGas: (string) [optional] - Maximum priority fee per gas above the base fee.
    • paymasterVerificationGasLimit: (string) [optional] - Gas for paymaster verification step.
    • paymasterPostOpGasLimit: (string) [optional] - Gas for paymaster post-operation step.
    • signature: (string) - Must be a valid dummy signature for simulation.
  • entryPoint: (string) - The entry point contract address.

  • blockNumber: (string) [optional] - Hex encoded block number to run the simulation at (defaults to latest).

Returns

An object containing asset changes that would occur from executing the user operation:

assetChanges: (array) - Array of asset change objects, each containing:

  • token: (object) - Token information (varies by token type). Token metadata fields (name and symbol) are included when available but may be undefined as they are optional in token standards.
  • value: (object) - Balance change information:
    • diff: (string) - The balance difference.
    • pre: (string) - Balance before the operation.
    • post: (string) - Balance after the operation.

Example

Replace <YOUR-API-KEY> with an API key from your MetaMask Developer dashboard.

Request

curl https://mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "pimlico_simulateAssetChanges",
"id": 4337,
"params": [
{
"sender": "0x5a6b47F4131bf1feAFA56A05573314BcF44C9149",
"nonce": "0x1",
"callData": "0xe9ae5c53...",
"callGasLimit": "0x0",
"verificationGasLimit": "0x0",
"preVerificationGas": "0x0",
"maxFeePerGas": "0x7a5cf70d5",
"maxPriorityFeePerGas": "0x3b9aca00",
"paymasterVerificationGasLimit": "0x0",
"paymasterPostOpGasLimit": "0x0",
"signature": "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
},
"0x0000000071727De22E5E9d8BAf0edAc6f37da032"
]
}'

Response

{
"jsonrpc": "2.0",
"id": 4337,
"result": {
"assetChanges": [
{
"token": {
"tokenType": "NATIVE"
},
"value": {
"diff": "-1000000000000000000",
"pre": "5000000000000000000",
"post": "4000000000000000000"
}
}
]
}
}

Errors

Common error responses when simulation fails:

Error CodeDescription
AA23User operation reverted during simulation.
UserOperationRevertedUser operation execution failed during simulation.
SimulateValidationValidation failed for the user operation.