All Products

Simulations
Asset and Balance Changes

Asset and Balance Changes

The simulation API and RPC responses give you detailed insights into asset and balance changes converted into dollar values. The displayed dollar value represents the current dollar value and reflects the most recent market data sourced from CoinGecko.

Supported token standards: ERC20 and ERC721.

RPC response

Asset and balance changes are also returned with each simulation via RPC.

example
https://mainnet.gateway.tenderly.co/${TENDERLY_NODE_ACCESS_KEY}

In the RPC response, the structure is similarly intuitive:

  • Asset Changes: Look under result.assetChanges. This will provide a breakdown of how assets have been altered or moved during the transaction.
  • Balance Changes: Find these under result.balanceChanges. This offers insights into the balance fluctuations in token and dollar values.

Example

example.json
{
  "assetChanges": [
    {
      "assetInfo": {
        "standard": "ERC20",
        "type": "Fungible",
        "contractAddress": "0xc02...c2",
        "symbol": "weth",
        "name": "WETH",
        "logo": "https://assets.coingecko.com/coins/images/2518/large/weth.webp?1696503332",
        "decimals": 18,
        "dollarValue": "2195.8701171875"
      },
      "type": "Transfer",
      "from": "0xd8...45",
      "to": "0x20...d6",
      "rawAmount": "0x1",
      "amount": "0.000000000000000001",
      "dollarValue": "10.0071875"
    }
  ],
  "balanceChanges": [
    {
      "address": "0x20...1d6",
      "dollarValue": "0.0000021958701171875",
      "transfers": [
        0
      ]
    },
    {
      "address": "0xd8...045",
      "dollarValue": "0.00021958701171875",
      "transfers": [
        0
      ]
    }
  ]
}

For more information, read the API reference and RPC references.

API response

Asset and balance changes are returned as part of the response when you call the simulate (single simulations) endpoint:

example
https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/simulate

and simulate-bundle (bundled simulations) endpoint:

example
https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/simulate-bundle

To access this information in the simulation API response, follow these paths:

  • Asset Changes: Find transaction.transaction_info.asset_changes. Here, you'll find details like the type of change (transfer, mint, burn), involved addresses, and the amount in both the token and its dollar value.
  • Balance Changes: Find transaction.transaction_info.balance_changes. This section will show you how balances have shifted as a result of the transaction in token and dollar terms.

Example

example.json
{
  "asset_changes": [
    {
      "token_info": {
        "standard": "ERC20",
        "type": "Fungible",
        "contract_address": "0xc02...c2",
        "symbol": "weth",
        "name": "WETH",
        "logo": "https://assets.coingecko.com/coins/images/2518/large/weth.webp?1696503332",
        "decimals": 18,
        "dollar_value": "2195.8701171875"
      },
      "type": "Transfer",
      "from": "0xd8...045",
      "to": "0x20...d6",
      "amount": "0.000000000000000001",
      "raw_amount": "1",
      "dollar_value": "0.0000000000000021958701171875"
    }
  ],
  "balance_changes": [
    {
      "address": "0x20...d6",
      "dollar_value": "0.0000000000000021958701171875",
      "transfers": [
        0
      ]
    },
    {
      "address": "0xd...045",
      "dollar_value": "-0.0000000000000021958701171875",
      "transfers": [
        0
      ]
    }
  ]
}