0

Hello I am trying to create a crowdsale through zeppelin solidity but the main issue is it doesn't provide a way to link standard token with pre-allocated supply with the crowdsale.

pragma solidity ^0.4.13;

import '../node_modules/zeppelin-solidity/contracts/crowdsale/Crowdsale.sol';
import '../node_modules/zeppelin-solidity/contracts/token/StandardToken.sol';


contract BBTico is Crowdsale  {

    function BBTico(uint256 startTime, uint256 endTime, uint256 _rate, address _wallet) 
    Crowdsale(now, now + 5*60,  5, 0xB1A9B5564071A442909b17f8e9C7288b44aFC014 , 0xefcfbc96dc2adfe35d3fff6b1d9e985066d618ac) 
    {}


}

Crowdsale.sol

function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) {
    require(_startTime >= now);
    require(_endTime >= _startTime);
    require(_rate > 0);
    require(_wallet != 0x0);

    // Already Deployed Standard Token Address on Rinkeby Testnet 
    tokenReward = 0xEfCfbc96dc2aDfe35d3fFF6b1D9E985066D618aC;
    startTime = _startTime;
    endTime = _endTime;
    rate = _rate;
    wallet = _wallet;

  }



// fallback function can be used to buy tokens
  function () payable {
    buyTokens(msg.sender);
  }

function buyTokens(address beneficiary) public payable {
    require(beneficiary != 0x0);
    require(validPurchase());

    uint256 weiAmount = msg.value;
    uint256 accessTime = now;

    // calculate token amount to be created
    uint256 tokens = weiAmount.mul(rate);

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


 //The code doesn't compile with this function   
tokenReward.transferFrom(0xB1A9B5564071A442909b17f8e9C7288b44aFC014,beneficiary, tokens);
}
0

As of now, their Crowdsale contract is tightly coupled with the MintableToken. What you would need to do is instead of having your Crowdsale contract inherit from Open Zeppelin's Crowdsale contract, just use their contract as base and replace the use of MintableToken with StandardToken.

On top of my mind you would have to replace the function that instantiates the token contract so instead of MintableToken it uses StandardToken AND the function that gets called when someone buys a token should not call token.mint() anymore and instead move token balances around between the contract and the buyer.

  • I am exactly trying to do what you proposed but its not working. Through this solution I can deploy the ICO but when I send Ethers on crowdsale address. No tokens are transferred as it gives error of high gas (which I think means that there is an error in the code) – Qasid Labeed Nov 4 '17 at 12:36
  • Here is my code for crowdsale <br/> pragma solidity ^0.4.13; import '../node_modules/zeppelin-solidity/contracts/crowdsale/Crowdsale.sol'; contract BBTico is Crowdsale { function BBTico(uint256 startTime, uint256 endTime, uint256 _rate, address _wallet, address myToken) Crowdsale(now, now + 5*60, 5, 0xB1A9B5564071A442909b17f8e9C7288b44aFC014, 0xefcfbc96dc2adfe35d3fff6b1d9e985066d618ac) { } – Qasid Labeed Nov 4 '17 at 12:59
  • Please update the question with the new code. It's impossible to read in the comments without formatting – pabloruiz55 Nov 4 '17 at 13:20
0

If you make the token ownable in such a way that the ETH address used to deploy the token is automatically assigned ownership, then you can implement a mint function with the onlyOwner modifier which will ensure that only the owner can call the minting function. Then you can make your ICO contract deploy the token, that way the ICO contract is the owner of the token. When people send ETH, the payable fallback function will call the buyTokens function automatically and send the appropriate amount of tokens to the investors address by calling the mint function of the ERC20 contract.

0

Add the zeppelin-solidity as a node module

import 'zeppelin-solidity/contracts/crowdsale/Crowdsale.sol';
import 'zeppelin-solidity/contracts/token/StandardToken.sol';

Create a new contract named BBTico.sol

contract BBTico is Crowdsale  {
 function BBTico(uint256 startTime, uint256 endTime, uint256 _rate, address _wallet) 
 Crowdsale(now, now + 5*60,  5, 0xB1A9B5564071A442909b17f8e9C7288b44aFC014 , 0xefcfbc96dc2adfe35d3fff6b1d9e985066d618ac) 
 {}
}

Deploy the contract using some tools like truffle

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.