0

I wanted to follow the tutorial - https://blog.zeppelin.solutions/how-to-create-token-and-initial-coin-offering-contracts-using-truffle-openzeppelin-1b7a5dae99b6 - but there was a new release - https://github.com/OpenZeppelin/zeppelin-solidity/releases/tag/v1.7.0 - so I'm trying to figure it out...

Actual code is verified on Etherscan.

Crowdsale: https://ropsten.etherscan.io/address/0x018ea8f3fef7bd14c7bff98e898842925f05e6ea#code

Coin: https://ropsten.etherscan.io/address/0x37ca578d3d847d27741b2ffc033419a7d11b7bef#code

My account sending ETH to crowdsale: https://ropsten.etherscan.io/address/0x85a363699c6864248a6ffca66e4a1a5ccf9f5567

Transaction hash: https://ropsten.etherscan.io/tx/0x7f99bca20b767073eb48ed2e6d01186c55bcc97ee8316523977e15c4286f6c5a

enter image description here

Here is a short video of me explaining what I'm doing: https://youtu.be/oKP9ea5PNho


Looking at the code: https://github.com/OpenZeppelin/zeppelin-solidity/blob/3c489127306d09dc08c6a22263134fb5413d2f80/contracts/crowdsale/Crowdsale.sol#L48

function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public

I instantiate coin and crowdsale in the following way:

contract MailHustleCrowdsale is Crowdsale {

  uint256 _rate = 1000; 
  address _wallet = 0x315f80c7caacbe7fb1c14e65a634db89a33a9637;
  ERC20 _token = new MailHustleCoin();

  function MailHustleCrowdsale() Crowdsale(_rate, _wallet, _token) {          
  }
}

My guess is that the error is somewhere here but cannot figure the working syntax...


Alternative approach:

How to reference coin contract already onchain?

If including the original source code isn't practical, an easy way to work around it is just to make a stub contract above your own contract containing the function signature of the function you want to call.

For simplicity I've decided to include everything in a single file.

0

Credit goes to Vidor:

Maybe you can earn some Stack Overflow reputation and put these pointers into the original question?

too much hassle to little fun

I understand, I’ll do this then

I'm realizing I know so little and I should not be touching the code.


One

function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool)

Only owner can mint. Coin creation should be in the crowdsale contract.

Two

function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { require(MintableToken(token).mint(_beneficiary, _tokenAmount)); }

Instead of

function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { token.transfer(_beneficiary, _tokenAmount); }

Currently you are transferring tokens from the sender address which has 0. You want to go for a minting strategy which is better

Here is TX that works: https://ropsten.etherscan.io/tx/0x1b4c11eee16e06bc53a273a9a805ea11def461c9f81847edb2d8f95daa273ae5

(you can navigate to contract to see the working source)


Here is a better example: https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/examples/SampleCrowdsale.sol

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.