I am writing a PreICO Smart contract. I got a code snippet which I am trying to understand. I am stuck in function buyXYZTokens function which is throwing error. Here is the code snippet:
Contract XYZ is StandardToken, Ownable{
string public name = "XYZ";
string public symbol = "X";
string public standard = "X v1.0";
uint256 public decimals = 18;
modifier inActivePeriod() {
require((preSaleStart < now && now <= preSaleEnd));
_;
}
function XYZ( uint256 _initialsupply, address _escrow, uint _preSaleStart, uint _preSaleEnd) {
require(_escrow != 0x0);
require(_preSaleStart < _preSaleEnd);
escrow = _escrow;
totalSupply_=_initialsupply;
balances[escrow] = _initialsupply;
}
function() inActivePeriod payable{
buyXYZTokens(msg.sender);
}
function buyXYZTokens(address _sender) inActivePeriod payable{
require(_sender!=0x0);
require(msg.value>=minTransactionAmount);
uint256 weiCount = msg.value;
amountRaised = amountRaised.add(weiCount);
uint256 tokens = weiCount.mul(rate);
tokens += getBonus(tokens);
tokenReserve(_sender, tokens);
forwardFunds();
}
function getBonus(uint256 _tokens) constant returns (uint256 bonus) {
require(_tokens != 0);
if (preSaleStart <= now && now < preSaleStart + 1 days) {
return _tokens.div(2);
} else if (preSaleStart + 1 days <= now && now < preSaleStart + 2 days ) {
return _tokens.div(4);
} else if (preSaleStart + 2 days <= now && now < preSaleStart + 3 days ) {
return _tokens.div(10);
}
return 0;
}
function tokenReserve(address _to, uint256 _value) internal returns (bool) {
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function forwardFunds() internal {
escrow.transfer(msg.value);
}
I got this error: I am not getting what this fallback function used for and why buyXYZTokens function throwing me error?
buyXYZTokens
?buyXYZTokens
.@Lauri Peltonenrequire(msg.value>=minTransactionAmount);
. What is theminTransactionAmount
and are you sending enough to pass that check?