I'm trying to make crowdsale smart contract using "zeppelin-solidity"
But It always throw "revert" error. Especially when I want to use token related function like token.mint, transfer and so on.
Does anyone can check what's wrong in my code?
Below is the crowdsale code.
pragma solidity ^0.4.15;
import './SSSToken.sol';
import 'zeppelin-solidity/contracts/crowdsale/Crowdsale.sol';
import "zeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";
contract SSSTokenSale is Crowdsale {
using SafeMath for uint256;
uint256 public round;
uint256 public every;
MintableToken public token;
constructor(
// uint256 _startTime,
// uint256 _endTime,
uint256 _rate,
address _wallet,
uint256 _initialMint,
uint256 _every,
MintableToken _token
)
public
Crowdsale(_rate, _wallet, _token)
{
token = _token;
// token.mint(_wallet, _initialMint);
every = _every;
}
// function createTokenContract() internal returns (MintableToken) {
// return new SSSToken();
// }
function () external payable {
buyTokens(msg.sender);
}
function buyTokens(address beneficiary) public payable {
require(beneficiary != 0x0);
// calculate token amount to get
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
weiRaised = weiRaised.add(weiAmount);
round = round.add(1);
// double
if (round % every == 0) {
tokens = tokens.mul(2);
}
token.mint(msg.sender, tokens);
TokenPurchase(beneficiary, beneficiary, weiAmount, tokens);
_forwardFunds();
}
}
Below is the token contract.
pragma solidity ^0.4.15;
import 'zeppelin-solidity/contracts/token/ERC20/MintableToken.sol';
contract SYToken is MintableToken {
string public name = "SSS TOKEN";
string public symbol = "SSS";
uint256 public decimals = 8;
}
I got several errors something like below.
I don't know why error "Revert" is thrown...
