0

I am the owner of the old smart contract:

https://etherscan.io/token/0x73de68dxxxxxxx

Now I have created a new smart contract:

https://etherscan.io/address/0xd4c04exxxxxxx

How do I transfer a new token to all those who own the old token?

May everyone help me.

1
  1. Notify your token holders at which block you will take a snapshot.
  2. Scrape eth blockchain at that block all of your token transfer to build a local database of addresses and their amounts.
  3. Run a local test to make sure your sum of your addresses with balances will be equal to your totalSupply
  4. Run a tool like https://rstormsf.github.io/multisender/#/ to distribute your new token
  5. Notify all exchanges to delist your old token contract OR if you have control over it, disable transfers or burn all tokens.
0

You could either use @rstormsf's method, or you could use a smart contract.

// -------------------------------------------------------------------------            ---
// ERC Token Standard #20 Interface
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// ----------------------------------------------------------------------------
contract ERC20Interface {
    function totalSupply() public constant returns (uint);
    function balanceOf(address tokenOwner) public constant returns (uint     balance);
    function allowance(address tokenOwner, address spender) public constant     returns (uint remaining);
    function transfer(address to, uint tokens) public returns (bool success);
    function approve(address spender, uint tokens) public returns (bool success);
    function transferFrom(address from, address to, uint tokens) public returns (bool success);

    event Transfer(address indexed from, address indexed to, uint tokens);
    event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}

// You can get a standard ownable contract here: https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/ownership/Ownable.sol
contract ClaimTokens is Ownable {
    ERC20Interface old;
    ERC20Interface new;

    mapping (address -> bool) hasRegistered;
    address[] registeredParticipants;

    function ClaimTokens() Ownable() {
        old = new ERC20Interface(0x73de68d64b5d9b2108fdf76a394f76e16a88ceb3);
        new = new ERC20Interface(0xd4c04e5099f62632a0861ec68fd9f58e6cd0cb74);
    }

    function registerForAirdrop() public {
        require(!hasRegistered[msg.sender])
        hasRegistered[msg.sender] = true;
        registeredParticipants.push(msg.sender)
    }

    function airdrop() onlyOwner {
        for(uint i = 0; i < registeredParticipants.length; i++) {
            uint balance = old.balanceOf(registedParticipants[i])
            new.transfer(registeredParticipants[i], balance)
        }
        // Add burn here?
    }
}

This creates an interface to the old token and to the new token and creates a mapping of whether an address has registered and an array of addresses that have registered (having two data structures saves on computing time, and gas).

It is initiated under ClaimTokens(), and that just sets the interfaces to the correct contracts.

A user can then register for the airdrop by calling registerForAirdrop().

Then, when the airdrop occurs (called by only the owner, airdrop()), it loops through all registered participants, checks their balance, and transfers the new token. If the new ERC20 token has a burn() function, then you should have the smart contract burn all tokens that were not registered in the airdrop.

The benefits of this approach is that it is more decentralized and it doesn't require as much gas to be spent by you.

Hope this helps!

2
  • If you don't burn, and it's still possible to transfer the old token, then attackers can claim the airdrop and then transfer their tokens to a new address and claim it again (and again). – James_pic Jun 9 '18 at 9:07
  • you can double spend with it. it also requires everyone to register and claim their tokens. Also you don't remove registered participant from an array. Also, looping thru array in solidity is dangerous because it can go over the block limit 8,000,000. Also since you want people to register, why not just to give them tokens and mark their claim as completed? it would just required 1 call. – rstormsf Jun 10 '18 at 4:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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