1

Is it possible to snapshot the 'balances' mapping from an old contract ? and give them free new tokens based on the amount in the mapping

2 Answers 2

1

INFO: This is part of my answer posted here: https://ethereum.stackexchange.com/a/30509/20808

If you want to retrieve addresses and balances of tokens from old contract, you can do it ONLY if you have implemented the functionnality to get all addresses and their balances in the old contract, something like:

OLD CONTRACT:

address[] listOfAddresses;
int[] balancesOfAddresses;

    function getAddresses() public returns (address[], int[]){

        return (listOfAddresses, balanceOfAddresses);
    }

Or any other way to get this information.

NEW CONTRACT:

address[] listOfAddresses;
int[] balanceOfAddresses;
function(address[] addresses, int[] balances) public {
    listOfAddresses.push(addresses);
    balanceOfAddresses.push(balances);
}

Using this, you could get the information from one contract and push them to an other.

Remark: You could use mapping as well, but I'm not very familiar with them. Remark: If you first contract do not have the capability to retrieve the data, I'm afraid you are stuck. Or maybe if you go through the chain, you could retrieve transactions, but I cannot help on that.

1

The MiniMe token does support taking a snapshot at a given block and 'forking' to a new token, maintaining balances from a previous instance.

7
  • it still requires the logic for snapshotting implemented in contract A, so only if minimetoken is contract A
    – NowsyMe
    Commented Nov 12, 2017 at 11:20
  • @NowsyMe If you want to use the balances of an existing contract, you can collect addresses in the Transfer(from,to,amount) event. The augur people have written some scripts to achieve that github.com/AugurProject/rep-migration.
    – Ismael
    Commented Nov 12, 2017 at 11:38
  • can I ask you to elaborate on this? I look at it, but this require upgradeable path from start as well.
    – NowsyMe
    Commented Nov 13, 2017 at 20:07
  • @NowsyMe No, it doesn't requiere an upgradeable contract. To simplify there's one script that uses Transfer event to collect addresses that sent or received tokens, another calculate balances for each address. Then the addresses are given the calculated balances in the new contract. Finally ensure the total supply is correct. The only thing neede to upgrade from the old contract are Transfer events and read balances both are part of EIP 20 standard.
    – Ismael
    Commented Nov 14, 2017 at 1:00
  • Sure, but if a contract is not ERC20 compliant, this is not possible.
    – NowsyMe
    Commented Nov 14, 2017 at 14:48

Your Answer

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

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