I am new to solidity and am trying to understand this openzeppelin crowdsale contract.

I am currently stuck on the _deliverTokens function and unable to understand how this function works. As far as I understood, the token here is actually referring to the ERC20 token but when it calls token. transfer(), whose tokens its transferring? Does this mean that the crowdsale contract's address owns the tokens?

2 Answers 2


Yes, in this implementation Crowdsale contract's address owns the tokens to make transfer function workable.

If you want to hold tokens on some separate address (token holder address) you should approve some tokens amount to Crowdsale contract and use transferFrom method to transfer tokens from holder address to the investor's address.


You can find the detail of transfer function in below link.


  * @dev transfer token for a specified address
  * @param _to The address to transfer to.
  * @param _value The amount to be transferred.
  function transfer(address _to, uint256 _value) public returns (bool) {
    require(_to != address(0));
    require(_value <= balances[msg.sender]);

    balances[msg.sender] = balances[msg.sender].sub(_value);
    balances[_to] = balances[_to].add(_value);
    emit Transfer(msg.sender, _to, _value);
    return true;

So the token of user who calls this function (msg.sender) will be transferring.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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