1

I am using Erigon. I am using pendent transactions of swap in goerli, this is an output from trace_call (stateDiff):

{
  "output": "0x",
  "stateDiff": {
    "0x07865c6e87b9f70255377e024ace6630c1eaa37f": {
      "balance": "=",
      "code": "=",
      "nonce": "=",
      "storage": {
        "0x03e5bce0671ceb85a9355530f54e34b1e23f58e03b8a4bb2dac84399d45da206": {
          "*": {
            "from": "0x0000000000000000000000000000000000000000000000000000000000000000",
            "to": "0x0000000000000000000000000000000000000000000000000000000003107bda"
          }
        },
        "0xfb16c5559f3de6ff269cf27b0716d0aae93e66f8a2b0c58671322b7b60443200": {
          "*": {
            "from": "0x000000000000000000000000000000000000000000000000000000029bd018e6",
            "to": "0x0000000000000000000000000000000000000000000000000000000298bf9d0c"
          }
        }
      }
    },...

it is clear that 0x07865c6e87b9f70255377e024ace6630c1eaa37f is the address of USDC token. In the "storage" field, i suppose, are the changes in balances of the trader wallet (0x9a5b87993c80eead6260438149b43eec081483ae) and the pool contract (0xfae941346ac34908b8d7d000f86056a18049146e).

How to decode the values "0x03e5bce0671ceb85a9355530f54e34b1e23f58e03b8a4bb2dac84399d45da206" and "0xfb16c5559f3de6ff269cf27b0716d0aae93e66f8a2b0c58671322b7b60443200", which are fields of "storage"?

OBS: The ABI is publicly available in https://goerli.etherscan.io/address/0x07865c6e87b9f70255377e024ace6630c1eaa37f#code.

1 Answer 1

1

0x03e5bce0671ceb85a9355530f54e34b1e23f58e03b8a4bb2dac84399d45da206 and 0xfb16c5559f3de6ff269cf27b0716d0aae93e66f8a2b0c58671322b7b60443200 should be the storage slots on the smart contract where the data has been modified so

        "0x03e5bce0671ceb85a9355530f54e34b1e23f58e03b8a4bb2dac84399d45da206": {
          "*": {
            "from": "0x0000000000000000000000000000000000000000000000000000000000000000",
            "to": "0x0000000000000000000000000000000000000000000000000000000003107bda"
          }
        },

would mean that at the storage location 0x03e5bce0671ceb85a9355530f54e34b1e23f58e03b8a4bb2dac84399d45da206 the value has been changed from 0x0000000000000000000000000000000000000000000000000000000000000000 to 0x0000000000000000000000000000000000000000000000000000000003107bda.

That along with the next storage location change (0xfb16c5559f3de6ff269cf27b0716d0aae93e66f8a2b0c58671322b7b60443200) result in the state change of 0x07865c6e87b9f70255377e024ace6630c1eaa37f.

They are hex values and you can write programs in solidity or js that read out the value of a particular storage slot in a contract at a given transaction.

7
  • thanks, it help a bit, but those storages are values in a mapping of balances in a ERC20 contract, i'd like to calculate wich is the storage of address 0xabc...
    – Rafael
    Jan 27 at 16:13
  • do you mean the storage slot for a particular address's token balance?
    – shankar
    Jan 27 at 16:19
  • yes, i suppose those storages are from a balance mapping, so yes
    – Rafael
    Jan 27 at 16:20
  • ok so what you can do is: bytes32 read_slot_data = keccak256(abi.encode(_addr, slot)); assembly { result := sload(read_slot_data) } where slot is the position of the variable in the code. so if the contract has mapping(address => uint) A; and mapping(address => uint) B; then A would be at slot0 and B at slot1
    – shankar
    Jan 27 at 16:50
  • so you would have to find the slot number of the mapping you're interested in reading out
    – shankar
    Jan 27 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.