I am trying to understand exactly how can I transfer ERC20 tokens between contracts.

In my case, these contracts are basically the same and they are different versions of the same contract. To put it in a scenario: let's imagine I have released a smart new token based on ERC20 and used it in an ICO. Then I found a bug in my contract that I solved in the dev environment.

The question is: How do I transfer the data stored in the first contract (deployed) to the second one (after deployment of the dev contract), when it comes to the tokens and the balances?

  • You can not transfer data from one contract to other (same or different) contract. – Sayed Tauseef Haider Naqvi Jun 28 '18 at 16:18

Your ERC20 token contract's balances variable should be public so you can just read the data and write the same data to the new contract.

The problem is then what to do with the new token contract? Nobody knows it exists and nobody uses it. Even if you told everyone to start using the new contract, how do you transition between the contracts? If your old contract does not have any sort of pause feature, how can you make sure people don't double-spend during the transition period? Or use the wrong contract?

I don't have any ready answers for you to these problems, unfortunately. If your old contract has some sort of pause functionality then you can just pause it, transfer data to new contract and require everyone to start using the new contract.

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.