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 aseth_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 tolatest
).
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
andsymbol
) 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
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
- Native Currency
- ERC-20
- ERC-721
- ERC-1155
- Multiple Assets
{
"jsonrpc": "2.0",
"id": 4337,
"result": {
"assetChanges": [
{
"token": {
"tokenType": "NATIVE"
},
"value": {
"diff": "-1000000000000000000",
"pre": "5000000000000000000",
"post": "4000000000000000000"
}
}
]
}
}
{
"jsonrpc": "2.0",
"id": 4337,
"result": {
"assetChanges": [
{
"token": {
"tokenType": "ERC-20",
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"decimals": 6,
"name": "USD Coin",
"symbol": "USDC"
},
"value": {
"diff": "-1000000",
"pre": "100000000",
"post": "99000000"
}
}
]
}
}
{
"jsonrpc": "2.0",
"id": 4337,
"result": {
"assetChanges": [
{
"token": {
"tokenType": "ERC-721",
"address": "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
"tokenId": 1234,
"name": "Bored Ape Yacht Club",
"symbol": "BAYC"
},
"value": {
"diff": "1",
"pre": "0",
"post": "1"
}
}
]
}
}
{
"jsonrpc": "2.0",
"id": 4337,
"result": {
"assetChanges": [
{
"token": {
"tokenType": "ERC-1155",
"address": "0x76BE3b62873462d2142405439777e971754E8E77",
"tokenId": 5678,
"name": "OpenSea Shared Storefront",
"symbol": "OPENSTORE"
},
"value": {
"diff": "10",
"pre": "5",
"post": "15"
}
}
]
}
}
{
"jsonrpc": "2.0",
"id": 4337,
"result": {
"assetChanges": [
{
"token": {
"tokenType": "ERC-20",
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"decimals": 6,
"name": "USD Coin",
"symbol": "USDC"
},
"value": {
"diff": "-1000000",
"pre": "100000000",
"post": "99000000"
}
},
{
"token": {
"tokenType": "ERC-20",
"address": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"decimals": 8,
"name": "Wrapped BTC",
"symbol": "WBTC"
},
"value": {
"diff": "1196",
"pre": "0",
"post": "1196"
}
},
{
"token": {
"tokenType": "NATIVE"
},
"value": {
"diff": "-1000000000000000000",
"pre": "5000000000000000000",
"post": "4000000000000000000"
}
}
]
}
}
Errors
Common error responses when simulation fails:
Error Code | Description |
---|---|
AA23 | User operation reverted during simulation. |
UserOperationReverted | User operation execution failed during simulation. |
SimulateValidation | Validation failed for the user operation. |