2

I'm trying to deploy a crowdsale contract, which is using open zeppelin, on ropsten network but I got gas related error. The error says "please check your gas amount". How can I solve it? I think this contract is very simple crowdsale contract. Thus, I believe I don't need to separate to multiple files. I did not try it on mainnet.

This is all what I did

$ mkdir /tmp/manatoken-infra
$ cd /tmp/manatoken-infra
$ truffle init
$ npm install ethereumjs-wallet bip39 web3-provider-engine@8.6.1 web3@0.18.4 zeppelin-solidity --save
$ vi ./truffle.js 
$ vi ./contracts/GustavoCoin.sol
$ vi ./contracts/GustavoCoinCrowdsale.sol
$ vi ./migrations/2_deploy_contracts.js
$ truffle compile
$ truffle deploy --network ropsten

truffle.js

var bip39 = require("bip39");
var hdkey = require('ethereumjs-wallet/hdkey');
var ProviderEngine = require("web3-provider-engine");
var WalletSubprovider = require('web3-provider-engine/subproviders/wallet.js');
var Web3Subprovider = require("web3-provider-engine/subproviders/web3.js");
var Web3 = require("web3");
var FilterSubprovider = require('web3-provider-engine/subproviders/filters.js');

// Get our mnemonic and create an hdwallet
var mnemonic = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic));

// Get the first account using the standard hd path.
var wallet_hdpath = "m/44'/60'/0'/0/";
var wallet = hdwallet.derivePath(wallet_hdpath + "0").getWallet();
var address = "0x" + wallet.getAddress().toString("hex");

var providerUrl = "https://testnet.infura.io";
var engine = new ProviderEngine();
engine.addProvider(new FilterSubprovider());
engine.addProvider(new WalletSubprovider(wallet, {}));
engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)));
engine.start(); // Required by the provider engine.

module.exports = {
  networks: {
    "ropsten": {
      network_id: 3,    // Official ropsten network id
      provider: engine, // Use our custom provider
      from: address    // Use the address we derived
    }
  },
  rpc: {
    // Use the default host and port when not using ropsten
    host: "localhost",
    port: 8545
  }

contracts/GustavoCoin.sol

pragma solidity ^0.4.11;

import 'zeppelin-solidity/contracts/token/MintableToken.sol';

contract GustavoCoin is MintableToken {
  string public name = "GUSTAVO COIN";
  string public symbol = "GUS";
  uint256 public decimals = 18;
}

contracts/GustavoCoinCrowdsale.sol

pragma solidity ^0.4.11;

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

contract GustavoCoinCrowdsale is Crowdsale {

  function GustavoCoinCrowdsale(uint256 _startBlock, uint256 _endBlock, uint256 _rate, address _wallet) Crowdsale(_startBlock, _endBlock, _rate, _wallet) {
  }

  function createTokenContract() internal returns (MintableToken) {
    return new GustavoCoin();
  }
}

migrations/2_deploy_contracts.js

var GustavoCoinCrowdsale = artifacts.require("./GustavoCoinCrowdsale.sol")

module.exports = function(deployer, network, accounts) {
  const startBlock = 1628404
  const endBlock = startBlock + 300
  const rate = new web3.BigNumber(1000)
  const wallet = "0x8005cEb675D2FF8c989CC95354438B9Fab568681"

  deployer.deploy(GustavoCoinCrowdsale, startBlock, endBlock, rate, wallet)
}

error

Running migration: 2_deploy_contracts.js
  Deploying GustavoCoinCrowdsale...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: The contract code couldn't be stored, please check your gas amount.
0

As @gundas said on github, it worked after I used timestamp instead of block.

var GustavoCoinCrowdsale = artifacts.require("./GustavoCoinCrowdsale.sol")

module.exports = function(deployer, network, accounts) {
  const startTime = 1504859321
  const endTime = 1536395321
  const rate = new web3.BigNumber(1000)
  const wallet = "0x8005cEb675D2FF8c989CC95354438B9Fab568681"

  deployer.deploy(GustavoCoinCrowdsale, startTime, endTime, rate, wallet)
}

https://github.com/OpenZeppelin/zeppelin-solidity/issues/358

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.