1

This question already has an answer here:

How could I create a new smart contract token and copy the balance of every address from an old contract.

Essentially fork a contract.

I want to make this a one time function in the contract so that it can only be called once. Or even better do it during the contract creation.

marked as duplicate by Ismael, Achala Dissanayake, ivicaa, Richard Horrocks, flygoing Feb 24 '18 at 14:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Is the smart contract to be forked already written or are you able to change it's code before it's deployment in anticipation of a possible fork? – Grunzwanzling Feb 21 '18 at 22:24
  • It is already deployed. Been deployed for a year. – James Feb 21 '18 at 22:30
  • Is it a standard ERC20 token? Is the balance variable public? – Grunzwanzling Feb 21 '18 at 22:40
  • Okay wait, I am going to write you and answer, but it is not as easy as you think. – Grunzwanzling Feb 21 '18 at 23:01
0

You can create a new contract with method to get every addresses in the token contract, then you can just copy it to your own array of address and then just call balanceOf function and get the balance of all your new address accounts. It's simple if you are copy a erc20 token.

  • I know that, but I am not sure what code to write. I was hoping to get some code. – James Feb 21 '18 at 22:20
  • You can use the ""call" function after you create a instance of your token contract with its address – ReptilianGK Feb 21 '18 at 22:39
  • You can see it. It is public. Go to etherscan it is called OhniToken – James Feb 21 '18 at 22:42

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