I was able to deploy your FinalizableCrowdsale
SampleCrowdsale
after I removed the FinalizableCrowdsale()
call from the constructor.
I used the following parameters in the constructor call:
1511030956, 1511117356, 1, 100, 200, "0x01", "0x02"
I deployed my contract using Remix, so I modified the code slightly to this (especially since I didn't have the TestToken code):
pragma solidity ^0.4.15;
import "github.com/OpenZeppelin/zeppelin-solidity/contracts/crowdsale/CappedCrowdsale.sol";
import "github.com/OpenZeppelin/zeppelin-solidity/contracts/crowdsale/FinalizableCrowdsale.sol";
import "github.com/OpenZeppelin/zeppelin-solidity/contracts/crowdsale/RefundableCrowdsale.sol";
import "github.com/OpenZeppelin/zeppelin-solidity/contracts/token/MintableToken.sol";
contract SampleCrowdsale is CappedCrowdsale, FinalizableCrowdsale {
MintableToken public testToken ;
function SampleCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _goal, uint256 _cap, address _wallet, address _tokenContractAddress)
CappedCrowdsale(_cap)
Crowdsale(_startTime, _endTime, _rate, _wallet)
{
testToken = MintableToken(_tokenContractAddress);
}
function createTokenContract() internal returns (MintableToken) {
return testToken;
}
}
One thing that I noticed is that RefundableCrowdsale
requires one argument for its constructor, where as FinalizableCrowdsale
does not and it isn't necessary to call a parent's constructor if it doesn't take any arguments.
I suspect that this minor detail is the cause of the problem.
The EVM works natively in 256-bit words. Using smaller ones usually consumes more gas because there's extra work to do: the unneeded bits need to be masked away.
A possible exception is when packing multiple values into the same storage slot. E.g. struct MyStruct { uint128 foo; uint128 bar; }
. Here, depending on your access pattern, you may or may not save gas by being able to store both values into the same storage slot.
Note that in this particular code, the best option would be to use a constant. Then the value doesn't have to be persisted in storage at all, which will be a very big gas saving.
Best Answer
SafeMath
is a solidity math library especially designed to support safe math operations: safe means that it prevents overflow when working withuint
. You can find it in zeppelin-solidity SafeMath.From the official documentation:
Hope it helps~