1

So I created an ICO contract based on a token with a set initial supply and no mint function. I publish this contract and then send the associated tokens to the contract. I can send ether and receive it in the desired account and the new tokens are sent to the correct account.

However, if not all of the tokens that were sent to the contract are purchased during the ICO, they just seem to disappear. Is there a simple way to retrieve the remaining coins? I have tried self destruct and suicide but I think those apply to the ether that would be stored in the contract address.

Thanks for any help!

Brian

  • Is the initial supply assigned to some addres? You can initially assign the tokens to the owner so after the ICO the owner can dispose of the remaining tokens the way he desires. But most public ICOs will only assign tokens to the owner at the close of the crowdsale. – Ismael Jul 31 '17 at 20:44
  • Source code? That would help people understand what you're asking. It's confusing when you say that you "sent the associated tokens to the contract." That doesn't feel like it jives with "...a set initial supply." How did you send tokens to a contract that already had them? – Thomas Jay Rush Aug 1 '17 at 1:29
  • per ethereum.org/crowdsale: I send tokens (created by a contract) to a crowdsale contract for those tokens to be dispersed to participants of said crowdsale. So the crowdsale contract holds the tokens. Once the crowdsale is over, the tokens are essentially lost. I am looking for a script that allows for the retrieval of said tokens. – Brian Andrews Aug 1 '17 at 5:14
1

If your contract(s) are already deployed, you're out of luck.

On the other hand if you are still developing either the token or the crowdsale, there are a number of ways you can move the tokens around.

Firstly, the token balance on your crowd sale contract is just a value allocated within the token contract, so you can just have a function on your token contract allow you to directly reassign the balance from the crowd sale contract.

uint256 unsold = balances[saleaddress];
balances[saleaddress] = 0;
balances[someLocation] += unsold;

A better option perhaps, is to have the crowd sale contract handle it. In this case you can do something like

function withdrawUnsoldTokens()
{
    require(msg.sender == ownerAddress);
    ERC20 mytoken = new ERC20(tokenAddress);
    uint256 unsold = mytoken.balanceOf(this);
    mytoken.transfer(ownerAddress, unsold);
}
0

I don't think you can withdraw the remaining tokens. When you first deployed your contract, you should have saved your address as the owner and only allowed the owner to withdraw the remaining ico tokens.

  • I understand what you are saying I have the owner address saved. But I don't know the commands to properly retrieve the tokens. As in OP, I have tried suicide/self destruct and neither return the remaining tokens to the owner address. That is the issue. – Brian Andrews Aug 1 '17 at 5:19
  • If the tokens are already deployed then there's nothing you can do. Only the crowdsale contract can transfer the tokens assigned to it and only if the crowdsale was not closed. – Ismael Aug 2 '17 at 2:51
  • @Ismael so essentially unless I use a mint function in my token contract I run the risk of losing any number of coins that aren't sold during the crowdsale because I can only be transferred tokens before the crowdsale actually closes? – Brian Andrews Aug 2 '17 at 20:22
  • A common practice is to no have a fixed amount of token but to create them in proportion to the crowdsale. For example 60% of the token are for sale, and you keep the other 40%. Then in the crowdsale you sell 1200 tokens, then you will create another 800 token for you when the crowdsale closes. That way all token are assigned. – Ismael Aug 2 '17 at 20:38
  • @Ismael Interesting work-around. Thanks a ton for the help! – Brian Andrews Aug 2 '17 at 21:22

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.