Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pragma solidity ^0.4.11;
contract TokenSale{
uint public maxTokens = 100*1000000;
uint public rate = 1000;
uint public fundingGoal = 10000 ether;
uint public minContribution = 0.1 ether;
uint public teamTokensPercent = 20;
uint public crowdsalePercent = 80;
uint public bounty = 10*1000000;
uint public earlyInvestors = 10*1000000;
uint public publicsale = 60*1000000;
uint public presale_stage1bonus = 25;
uint public presale_stage2bonus = 20;
uint public presale_stage3bonus = 15;
uint public ico_stage1bonus = 10;
uint public ico_regularbonus = 0;
uint public minTarget = 850 ether;
uint public supply = 0;
mapping(address => uint) balance;
modifier isTokenAvailable() {
require(msg.value*rate + supply <= maxTokens);
_;
}
// A function to check the ether balance of any address.
function checkBalance(address addr) external returns (uint){
return addr.balance;
}
// A function to check the token balance of any address.
function balanceOf(address tokenHolder) external returns (uint){
return balance[tokenHolder];
}
function buyTokens() external payable isTokenAvailable{
uint tokensAmount = msg.value*rate;
balance[msg.sender] = tokensAmount;
supply += tokensAmount;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.