1

This is my contract code.

    contract StartCoinCrowdsale is TimedCrowdsale, MintedCrowdsale, CappedCrowdsale, FinalizableCrowdsale   { //100000000000 

    uint256 public constant TOTAL_SHARE = 100;
    uint256 public constant CROWDSALE_SHARE = 80;
    uint256 public constant FOUNDATION_SHARE = 20;
    function StartCoinCrowdsale
        (
            uint256 _openingTime,
            uint256 _closingTime,
            uint256 _rate,
            address _wallet,
            uint256 _cap,
            MintableToken _token
        )
        public
        Crowdsale(_rate, _wallet, _token) 
        TimedCrowdsale(_openingTime, _closingTime) 
        CappedCrowdsale(_cap)
        FinalizableCrowdsale() {
    }

    function finalization() internal {
        uint256 totalSupply = token.totalSupply();
        uint256 finalSupply = TOTAL_SHARE.mul(totalSupply).div(CROWDSALE_SHARE);//100*8000/80=10000

        // emit tokens for the foundation
        MintableToken(token).mint(wallet, FOUNDATION_SHARE.mul(finalSupply).div(TOTAL_SHARE));//20*10000/100=2000
        super.finalization();
    }
}

This is my deployment code

    module.exports = function (deployer, network, accounts) {
    const openingTime = web3.eth.getBlock('latest').timestamp + 2; // two secs in the future
    const closingTime = openingTime + 120; // 3 minutes
    // const closingTime = openingTime + 86400 * 20; // 20 days
    const rate = new web3.BigNumber(1000);
    const wallet = accounts[1];
    const cap = new web3.BigNumber(8000000000000000000); //8 ether
    return deployer
        .then(() => {
            return deployer.deploy(StartCoin);
        })
        .then(() => {
            console.log(openingTime, closingTime, cap, wallet, rate, StartCoin.address);
            return deployer.deploy(
                StartCoinCrowdsale,
                openingTime,
                closingTime,
                rate,
                wallet,
                cap,
                StartCoin.address
            );
        })
        .then(() => { // giving the crowdsale ownership over the token
            return StartCoinCrowdsale.deployed().then(crowdsale => {
                crowdsale.token().then(tokenAddress => {
                    const startCoinInstance = StartCoin.at(tokenAddress);
                    startCoinInstance.transferOwnership(crowdsale.address).then(output => {})
                })
            }).catch(err => {
                console.log(err);
            })
        });
};

This is my error.

    Running migration: 2_deploy_contracts.js
  Running step...
  Deploying StartCoin...
  ... 0xf719c61552cc15ddf5f951a95a7261d3b8aa6cbb4a6109940bd54dc9b004e6a5
  StartCoin: 0xa8a6b3b9fc3db2831bafc68c4ee60b32e5e49c87
1525510753 1525510873 BigNumber { s: 1, e: 18, c: [ 80000 ] } '0x93a0fd6e1af85eab7045244e972704b498836bcb' BigNumber { s: 1, e: 3, c: [ 1000 ] } '0xa8a6b3b9fc3db2831bafc68c4ee60b32e5e49c87'
  Deploying StartCoinCrowdsale...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: StartCoinCrowdsale contract constructor expected 5 arguments, received 6
    at /usr/lib/node_modules/truffle/build/webpack:/~/truffle-contract/contract.js:390:1
    at new Promise (<anonymous>)
    at /usr/lib/node_modules/truffle/build/webpack:/~/truffle-contract/contract.js:374:1
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)

Any help would be appreciated.

  • What version of truffle are you using? Try forcing recompiling truffle compile --all. – Ismael May 6 '18 at 2:49
  • I am using Truffle v4.1.7 (core: 4.1.7). This issue doesn't come every time I deploy, it comes only occasionally. – Lucifer May 8 '18 at 6:47
0

In case you modified the contract you need to run truffle migrate --reset --compile-all to make sure the modified contract will be re-deployed.

Here is a quote from the documentation:

If your migrations were previously run successfully, truffle migrate will start execution from the last migration that was ran, running only newly created migrations. If no new migrations exists, truffle migrate won't perform any action at all.

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.