0

Will the storage location of a wallet address' balance change over time? If so, is it a problem largely associated with edge cases/unimportant tokens or is it a pervasive risk?

For some background: I'm trying to determine the net balance impact (ETH and ERC tokens) of a transaction. To verify a wallet address' balance change for an ERC-20 token, I'm determining the storage location of their balance for that token's contract. I'm hoping that the wallet's storage location won't change so that I don't have to continually re-verify an address' balance storage location.

Some areas I've briefly looked into that I think may have an impact:

  • storage collisions (but I would think this is isolated to unimportant tokens since there are standards to avoid this)
  • proxy patterns (I'm unsure if there are proxy strategies that result in changed storage locations)
3
  • What do you mean by storage location of a wallet address' balance? Perhaps, did you mean the storage slot where a mapping entry is stored? Storage slots have to be modified explicitly, they won't change "magically".
    – Ismael
    Commented Mar 5, 2023 at 2:32
  • Yes, a storage slot for the balances mapping (ex: mapping(address => uint256) private _balances). I understand they won't change magically but do you know if there are instances where a person won't map to their prior storage slot? If they have a balance, then go to a zero balance, then have a balance once more would they still map to the same storage slot?
    – itgav
    Commented Mar 5, 2023 at 21:25
  • Within the same contract it won´t change, _balances[addr] will map to the same slot always. The slot used by a mapping entry uses a formula ethereum.stackexchange.com/questions/114186/…. In any case you shouldn´t depend on the slot number for most cases, it is a low level detail.
    – Ismael
    Commented Mar 6, 2023 at 5:57

0

Your Answer

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

Browse other questions tagged or ask your own question.