0

Here is where error appears:

> Using network 'ropsten'.
> 
> Running migration: 1_initial_migration.js   
Deploying Migrations...  
> ... 0x53526c506e2e43ee2be615375a11b8507a1e50ccc7a70e7ee5bd4fc745ec6f96
> Migrations: 0xe26a476c08385fccaf0aacb5b08126ef9d134965 
Saving
> successful migration to network...   ...
> 0x72b8a0c6d09346ac205582041fbdc3a6853eab5523fd9c2de156ea0fc0cad1c5
> Saving artifacts... Running migration: 2_deploy_contracts.js Saving
> successful migration to network...   
Deploying XYZCoinCrowdsale...  
> ... 0x41d927717c89355dd0faa95cd6bf9421ff01c4c8c35c033d31f31e7d923b52e7
> ... 0x9c09d068e7d39de04d60546f167ba1c3b96544deba1e8c57389610e6106dcb2b
> Saving artifacts... (node:207476) UnhandledPromiseRejectionWarning:
> Unhandled promise rejection (rejection id: 1): Error: The contract
> code couldn't be stored, please check your gas amount. 
>(node:207476)
> [DEP0018] DeprecationWarning: Unhandled promise rejections are
> deprecated. In the future, promise rejections that are not handled
> will terminate the Node.js process with a non-zero exit code.

Tried everything mentioned on various questions here, none of them worked. I attempt to replica the guide here, https://blog.zeppelin.solutions/how-to-create-token-and-initial-coin-offering-contracts-using-truffle-openzeppelin-1b7a5dae99b6 except on ropsten using hdwallet-provider.

I edited xyzcoincrowdsale.sol(removed line // Crowdsale(_startTime, _endTime, _rate, _wallet) which was in the gustavocoincrowdsale.sol because it gave an error.)

pragma solidity ^0.4.13;

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


contract XYZCoinCrowdsale is Crowdsale {

  function XYZCoinCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) 
   // Crowdsale(_startTime, _endTime, _rate, _wallet)
    {          
  }

  // creates the token to be sold.
  // override this method to have crowdsale of a specific MintableToken token.
  function createTokenContract() internal returns (MintableToken) {
    return new XYZCoin();
  }

}

My truffle.cfg looks like this:

require('dotenv').config();
const Web3 = require('web3');
const web3 = new Web3();
const Wallet = require('ethereumjs-wallet');

var HDWalletProvider = require("truffle-hdwallet-provider");
var infura_apikey = "Infura API HERE";
var mnemonic = "12 words here";

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*", // Match any network id
      from: '0x00000000000000000000000000000000000'
    },
    ropsten: {
      //host: "localhost",
      //port: 8545,
      //nonce: 20,
      provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/"+infura_apikey),
      network_id: 3,
      gas: 472388,
      gasPrice: 100000000000
    }
  }
};
  • Can you share your deploy script? From the error it appears the issue is there. – Ismael Jan 12 '18 at 19:34
  • const XYZCrowdsale = artifacts.require("XYZCrowdsale") module.exports = function(deployer, network, accounts) { web3.eth.getBlockNumber((e, block) => { //web3.eth.getBlock(web3.eth.blockNumber, (e, block) => { if(!e) { const startTime = block.timestamp + 120 //one second in the future const endTime = startTime + (86400 * 20) // 20 days const rate = new web3.BigNumber(1000) const wallet = accounts[0] deployer.deploy(XYZCrowdsale, startTime, endTime, rate, wallet) } }) }; – G.T. Jan 13 '18 at 0:27
1

This should work if you want to retrieve information from the latest block before deploying the new contract.

const XYZCrowdsale = artifacts.require("XYZCrowdsale")

module.exports = function(deployer, network, accounts) {
  deployer.then(() => {
    web3.eth.getBlock('latest', (e, block) => {
      if(!e) {
        const startTime = block.timestamp + 120 //one second in the future
        const endTime = startTime + (86400 * 20) // 20 days
        const rate = new web3.BigNumber(1000)
        const wallet = accounts[0]
        deployer.deploy(XYZCrowdsale, startTime, endTime, rate, wallet)
      }
    })
  })
};
  • 1
    Figured everything out finally. This code worked and had to adjust gas price at the end. – G.T. Jan 14 '18 at 3:20

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.