Problem
I get the following error after running $ truffle migrate --reset
:
Running migration: 1_initial_migration.js Replacing Migrations...
... 0x5b23d046a48e2b1707155f10d3b6e12848b55167198ebcc27288a51463f2a6d6 Migrations: 0x4214c32de196e89f3aec37aa7ec58bf10e84347a Replacing TestCrowdsale... ... 0x1241cadb6818bdb0cd9698b25b6abfae472c34dfa119107691108e24198db326 Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: VM Exception while processing transaction: revert at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:43303:16) at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:331156:36 at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:175492:11 at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:314196:9 at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:315621:13) at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:70159:18) at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:70449:12) at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:70604:12) at IncomingMessage. (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:70564:24) at emitNone (events.js:111:20)
Environment
Truffle v4.0.1 (core: 4.0.1)
Solidity v0.4.18 (solc-js)
EthereumJS TestRPC v6.0.3 (ganache-core: 2.0.2)
Migrations file
My 1_initial_migration.js file looks like:
var Migrations = artifacts.require("./Migrations.sol");
var TestCrowdsale = artifacts.require("./TestCrowdsale.sol");
module.exports = function(deployer) {
deployer.deploy(Migrations);
deployTestCrowdsale(deployer);
};
function deployTestCrowdsale(deployer) {
const accounts = web3.eth.accounts;
const startTime = latestTime();
const endTime = startTime + duration.days(45);
const rate = 2500;
const goal = web3.toWei(250, 'ether');
const cap = web3.toWei(4000, 'ether');
const wallet = accounts[0];
return deployer.deploy(TestCrowdsale, startTime, endTime, rate, wallet);
}
function latestTime() {
return web3.eth.getBlock('latest').timestamp;
}
const duration = {
seconds: function (val) { return val; },
minutes: function (val) { return val * this.seconds(60); },
hours: function (val) { return val * this.minutes(60); },
days: function (val) { return val * this.hours(24); },
weeks: function (val) { return val * this.days(7); },
years: function (val) { return val * this.days(365); },
};
Crowdsale file
TestCrowdsale contract uses the Zeppelin Solidity framework. My TestCrowdsale.sol file looks like:
pragma solidity ^0.4.18;
import 'zeppelin-solidity/contracts/crowdsale/Crowdsale.sol';
contract TestCrowdsale is Crowdsale {
function TestCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet)
Crowdsale(_startTime, _endTime, _rate, _wallet)
public
{
}
}
truffle.js file looks like:
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
}
}
};