when i am doing truffle migrate.i am able to deploy my crowdsale contract but my token contract is getting deployed but not the crowdsale contract.

var Sportist = artifacts.require("./Sportist.sol");
var SportistCrowdsale = artifacts.require("./SportistCrowdsale.sol");

module.exports = async function (deployer) {
    let rate = 1;
    let wallet = "0x300c7b7198a772C2154e4f2a47C0d89407a95A8A";
    let token;
    let openingTime = Math.floor((new Date()).getTime()/1000);
    let closingTime = openingTime + 1 * 60 * 60 * 24;
    let cap = 500000;
    let goal = 50000;
    let tokenWallet = "0x300c7b7198a772C2154e4f2a47C0d89407a95A8A";

let a  = await deployer.deploy(Sportist, "Sportist", "S", 6, 2000000000)
token = await Sportist.deployed().then(instance=>instance.address)

await deployer.deploy(SportistCrowdsale,
    rate, wallet, token,
    openingTime, closingTime,

    const crowdsale = await DappTokenCrowdsale.deployed();

console.log("after deployement ");


in the console it is showing that

Using network 'development'.

Running migration: 2_deploy.js
  Replacing Sportist...
  ... 0x211c7f7e0678bacec29a7d8032ae8949faca2cc381586b8b541f5faf3804c1f9
  Sportist: 0x2fb7fa517002ca3a7af45deea0479f287d5089fb
Saving successful migration to network...
  ... 0x760538642ffd049748b5bf3ff5624b0065e6b0e3bbbb1aaf99ad341de2bc99f1
  Deploying SportistCrowdsale...
Saving artifacts...

and the crowdsale contract is

pragma solidity ^0.4.24;

import "./crowdsale/distribution/RefundableCrowdsale.sol";
import "./crowdsale/distribution/PostDeliveryCrowdsale.sol";
import "./crowdsale/validation/CappedCrowdsale.sol";
import "./crowdsale/emission/AllowanceCrowdsale.sol";
import "./crowdsale/emission/StagedCrowsale.sol";

contract SportistCrowdsale is RefundableCrowdsale, CappedCrowdsale, PostDeliveryCrowdsale, AllowanceCrowdsale, StagedCrowsale {
        uint256 rate, address wallet, IERC20 token,
        uint256 openingTime, uint256 closingTime,
        uint cap,
        uint256 goal,
        address tokenWallet) 
        Crowdsale(rate, wallet, token)
        TimedCrowdsale(openingTime, closingTime)
    public {}

    function() external payable {
  • can we see the crowdsale contract code?
    – Iulian
    Sep 20 '18 at 10:46
  • i have edited now check it .
    – AVATAR
    Sep 20 '18 at 10:51
  • Contract looks great! Contracts are from OpenZeppelin I would like to know few more things from you. Are you deploying to main network or are you doing something like 'truffle migrate --network rinkeby' ? Also, does execution end without errors or does it stay forever in the state of 'Saving artifacts...'?
    – Iulian
    Sep 20 '18 at 11:03
  • i am deploying it on ganache.
    – AVATAR
    Sep 20 '18 at 11:03
  • I found other people with the same error. It can be a random/casual error. Check this and this my advice to you is to change network ID on ganache or try 'migrate --reset --network different_networkID' . Eventually just go on ganache and click on settings button and change network ID to something like '5782'. Let me know if that worked
    – Iulian
    Sep 20 '18 at 11:09

we can use async function in new truffle beta version.so i updating the truffle version you can easily use await. i updated to the new beta version of 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.