The library SafeERC20 is to safely interact with a third party token. It is not to be used inside your own token contract.
OpenZeppelin contracts already have require to check for preconditions so they will return true or fail early.
Also I'd suggest to remove the protection for short address attack onlyPayloadSize
. They were removed from the OpenZeppelin contracts several months ago #261 Remove short address attack checks from tokens.
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.
Best Answer
That is not a transfer operations but an event notification.
This is done that way so block explorer and wallets that only interpret the 'Transfer' event can show the operation to the user. There were some complaint from users that the transfer failed because it didn't show up in their wallet (or block explorer).
Only the 'Transfer' event is part of the ERC20 standard, and the events 'Mint' and 'Burn' are not. It is a workaround around that limitation to generate a tranfer from 0x0 to simulate a 'Mint' event and, a transfer to 0x0 to simulate a 'Burn' event.