0

I am using Open Zeppelin Token and Crowdsale contracts.

What should I do such that at the end of a crowdsale, the unsold token amount gets allocated to a specific address that I own?

Currently, the Crowdsale contract creates the Token contract, which assigns a portion of its balances to Crowdsale. But my understanding is that a contract has no private key, so how would I go about recovering the unsold tokens after the crowdsale ends?

Please advise.

1

You can add a function to transfer the remaining tokens back to the owner.

function allocateRemainingTokens() onlyOwner public {
  require(isFinalized);
  uint256 remaining = token.balanceOf(this);
  token.transfer(owner, remaining);
}

I am using openzeppelin's FinalizableCrowdsale contract and can require isFinalized == true

0

An alternative is to allocate tokens dynamically, and allocate for the team a percentage of the total at the end of the crowdsale.

If you have a ratio of 125 tokens per ether, and someone contribute 2 ethers you then assign them 250 tokens.

Let's say you will assign 30% to the team, and you have sell 2100 tokens. Then your share is 2100 * 0.30 / 0.70 = 900. The total supply will be 2100 + 900 = 3000. If you want to check 2100 is exactly the 70% of 3000.

-1

The Open Zeppelin Crowdsale contract mints new tokens, it doesn't deplete them from a pool.

// low level token purchase function
function buyTokens(address beneficiary) public payable {
  require(beneficiary != address(0));
  require(validPurchase());

  uint256 weiAmount = msg.value;

  // calculate token amount to be created
  uint256 tokens = getTokenAmount(weiAmount);

  // update state
  weiRaised = weiRaised.add(weiAmount);

  token.mint(beneficiary, tokens);
  TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);

  forwardFunds();
}

You can see this in the call to token.mint, which creates the MintableToken and then sends it to the beneficiary. MintableTokens increase their supply when the mint function is called, and only then.

So, to put it another way, using the Open Zeppelin Crowdsale contract, you have no unsold tokens, because all created tokens are instantly transferred when sold. If your goal is just to give yourself free tokens, you can modify the constructor or create a method that calls token.mint with your address and a given amount.

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.