I am really confused about how ERC20 Token Balances are stored on the chain. It appears that all balance data are stored as an member mapping variable:
contract TestCoin is ERC20Interface {
...
mapping(address => uint) balances;
...
I am wondering how many copies are stored on the Blockchain. Say balances
contains 10K records and the highest block number is 100. Now I make a token transfer and 2 records in balances
changed and we get a new balances
, and this transfer is confirmed by a new block 101.
<------- [Block 100] <------- [Block 101]
^ ^
| |
balance1 balance2
Where does the balance is stored? Is it possible to retrieve balances in block 100? (I guess we must be able to do so, because the blockchain could rollback).
I am using geth/web3/eth.