I've been working on getting a crowdsale contract working using the Open Zeppelin library and Truffle for a couple of days now.
I can get the basic crowdsale working, but as soon as I try to implement a RefundableCrowdsale or CappedCrowdsale, the code stops working.
I can compile and migrate the code successfully using Truffle, but when I send funds to the contract account, I get the error:
Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: VM Exception while processing transaction: invalid opcode at Object.InvalidResponse (/usr/lib/node_modules/truffle/build/cli.bundled.js:37295:16)
Any ideas what could be causing this issue? Code for the crowdsale:
> pragma solidity ^0.4.15;
>
> import './CBIToken.sol'; import
> 'zeppelin-solidity/contracts/crowdsale/Crowdsale.sol'; import
> 'zeppelin-solidity/contracts/crowdsale/CappedCrowdsale.sol'; import
> 'zeppelin-solidity/contracts/crowdsale/RefundableCrowdsale.sol';
>
>
> contract CBITokenCrowdsale is CappedCrowdsale, RefundableCrowdsale {
> function CBITokenCrowdsale(uint256 _startTime, uint256 _endTime,
> uint256 _rate, uint256 _goal, uint256 _cap, address _wallet)
> CappedCrowdsale(_cap) FinalizableCrowdsale()
> RefundableCrowdsale(_goal) Crowdsale(_startTime, _endTime, _rate,
> _wallet) { require(_goal <=_cap); }
>
> //Create token function createTokenContract() internal returns
> (MintableToken) { return new CBIToken(); } }
and migrations:
const CBITokenCrowdsale = artifacts.require("./CBITokenCrowdsale.sol")
module.exports = function(deployer, network, accounts) {
const startTime = web3.eth.getBlock(web3.eth.blockNumber).timestamp + 1 // one second in the future
const endTime = startTime + 180//(86400 * 20) // 20 days
const rate = new web3.BigNumber(1000)
const goal = new web3.BigNumber(200)
const cap = new web3.BigNumber(20000)
const wallet = accounts[0]
//const gas = 1000000
deployer.deploy(CBITokenCrowdsale, startTime, endTime, rate, goal, cap, wallet)
};
Any help would be hugely appreciated!