Skip to content

Instantly share code, notes, and snippets.

@raddrick
Created August 14, 2018 17:17
Show Gist options
  • Save raddrick/435326325ee5e530470e5d87b0fc8e65 to your computer and use it in GitHub Desktop.
Save raddrick/435326325ee5e530470e5d87b0fc8e65 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=true&gist=
pragma solidity ^0.4.2;
contract Erc20 {
uint public _totalSupply;
function balanceOf(address who) public constant returns (uint);
function allowance(address owner, address spender) public constant returns (uint);
function transfer(address to, uint value) public returns (bool ok);
function transferFrom(address from, address to, uint value) public returns (bool ok);
function approve(address spender, uint value) public returns (bool ok);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
pragma solidity ^0.4.20;
import "./StandardToken.sol";
contract EvedoToken is StandardToken {
string public name = "EVD";
string public symbol = "EVD";
/**
* Boolean contract states
*/
bool public halted = false; //the founder address can set this to true to halt the whole TGE event due to emergency
bool public prePrivate = true; //Pre-TGE state
bool public privateOne = false; //Private Sale One
bool public privateTwo = false; //Private Sale Two
bool public stageOne = false; //Bonus Stage One state
bool public stageTwo = false; //Bonus Stage Two state
bool public stageThree = false; //Bonus Stage Three state
bool public stageFour = false; //Bonus Stage Four state
bool public freeze = true; //Freeze state
/**
* Initial company address (set in constructor)
* All deposited ETH will be forwarded to this address.
* Address is a multisig wallet.
*/
address public company = 0x0;
/**
* Token count
*/
uint public tokenSupply = 160000000;
uint public tge = 80000000; // TGE - 50%
uint public founders = 20000000; // TEAM - 12.5%
uint public advisors = 12000000; // Advisors - 7.5%
uint public supporters = 8000000; // Supporters - 5%
uint public airdrops = 8000000; // Airdrops - 5%
uint public reserve = 32000000; // Reserve - 20%
/**
* TGE and Pre-TGE cap
*/
uint public prePrivateCap = 5400000;
uint public privateCap = 15600000;
uint public tgeCap = 80000000;
/**
* Statistic values
*/
uint public prePrivateTokenSupply = 0;
uint public privateOneTokenSupply = 0;
uint public privateTwoTokenSupply = 0;
uint public tgeSupply = 0;
uint public etherRaised = 0;
event Buy(address indexed sender, uint eth, uint fbt);
/* This generates a public event on the blockchain that will notify clients */
event TokensSent(address indexed to, uint256 value);
event ContributionReceived(address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
constructor() public payable {
company = msg.sender;
_totalSupply = tokenSupply;
balances[company] = _totalSupply;
}
/**
* 1 EVED = 1 FINNEY
* Price is 1000 EvedoToken for 1 ETH
*/
function price() public pure returns (uint){
return 1 finney;
}
/**
* The basic entry point to participate the TGE event process.
*
* Pay for funding, get invested tokens back in the sender address.
*/
function buy() public payable returns(bool) {
// Buy allowed if contract is not on halt
require(!halted);
// Amount of finney should be more that 0
require(msg.value>0);
// Count expected tokens price
uint tokens = msg.value / price();
if (prePrivate) {
tokens = tokens + (tokens / 35);
}
if (privateOne || privateTwo) {
tokens = tokens + (tokens / 30);
}
if (stageOne) {
tokens = tokens + (tokens / 20);
}
if (stageTwo) {
tokens = tokens + (tokens / 15);
}
if (stageThree) {
tokens = tokens + (tokens / 10);
}
if (stageFour) {
tokens = tokens + (tokens / 5);
}
// Total tokens should be more than user want's to buy
require((_totalSupply-tgeSupply)>tokens);
// Check how much tokens already sold
if (prePrivate) {
require(safeAdd(prePrivateTokenSupply, tokens) < prePrivateCap);
} else if (privateOne) {
require(safeAdd(privateOneTokenSupply, tokens) < privateCap);
} else if (privateTwo) {
require(safeAdd(privateTwoTokenSupply, tokens) < privateCap);
} else {
require(safeAdd(tgeSupply, tokens) < tgeCap);
}
// Add tokens to user balance and remove from totalSupply
balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
// Remove sold tokens from total supply count
balances[company] = safeSub(balances[company], tokens);
// Update stats
if (prePrivate) {
prePrivateTokenSupply = safeAdd(prePrivateTokenSupply, tokens);
} else if (privateOne) {
privateOneTokenSupply = safeAdd(privateOneTokenSupply, tokens);
} else if (privateTwo) {
privateTwoTokenSupply = safeAdd(privateTwoTokenSupply, tokens);
}
tgeSupply = safeAdd(tgeSupply, tokens);
etherRaised = safeAdd(etherRaised, msg.value);
// Send buy EVED token action
emit Buy(msg.sender, msg.value, tokens);
// /* Emit log events */
emit TokensSent(msg.sender, tokens);
emit ContributionReceived(msg.sender, msg.value);
emit Transfer(company, msg.sender, tokens);
return true;
}
/**
* PrePrivate state.
*/
function PrePrivateEnable() public onlyCompany() {
prePrivate = true;
privateOne = false;
privateTwo = false;
stageOne = false;
stageTwo = false;
stageThree = false;
stageFour = false;
}
function PrePrivateDisable() public onlyCompany() {
prePrivate = false;
}
/**
* Private Sale One state.
*/
function PrivateOneEnable() public onlyCompany() {
prePrivate = false;
privateOne = true;
privateTwo = false;
stageOne = false;
stageTwo = false;
stageThree = false;
stageFour = false;
}
function PrivateOneDisable() public onlyCompany() {
privateOne = false;
}
/**
* Private Sale Two state.
*/
function PrivateTwoEnable() public onlyCompany() {
prePrivate = false;
privateOne = false;
privateTwo = true;
stageOne = false;
stageTwo = false;
stageThree = false;
stageFour = false;
}
function PrivateTwoDisable() public onlyCompany() {
privateTwo = false;
}
/**
* Stage One state.
*/
function stageOneEnable() public onlyCompany() {
prePrivate = false;
privateOne = false;
privateTwo = false;
stageOne = true;
stageTwo = false;
stageThree = false;
stageFour = false;
}
function stageOneDisable() public onlyCompany() {
stageOne = false;
}
/**
* Stage Two state.
*/
function stageTwoEnable() public onlyCompany() {
prePrivate = false;
privateOne = false;
privateTwo = false;
stageOne = false;
stageTwo = true;
stageThree = false;
stageFour = false;
}
function stageTwoDisable() public onlyCompany() {
stageTwo = false;
}
/**
* Stage Three state.
*/
function stageThreeEnable() public onlyCompany() {
prePrivate = false;
privateOne = false;
privateTwo = false;
stageOne = false;
stageTwo = false;
stageThree = true;
stageFour = false;
}
function stageThreeDisable() public onlyCompany() {
stageThree = false;
}
/**
* Stage Four state.
*/
function stageFourEnable() public onlyCompany() {
prePrivate = false;
privateOne = false;
privateTwo = false;
stageOne = false;
stageTwo = false;
stageThree = false;
stageFour = false;
}
function stageFourDisable() public onlyCompany() {
stageFour = false;
}
/**
* Emergency stop whole TGE event.
*/
function EventEmergencyStop() public onlyCompany() { halted = true; }
function EventEmergencyContinue() public onlyCompany() { halted = false; }
/**
* Transfer to target address from company pool
*/
function sendCompanyTokens(address _to, uint256 _value) private onlyCompany() {
require(safeSub(balances[company],_value) > _value);
balances[company] = safeSub(balances[company], _value);
balances[_to] = safeAdd(balances[_to], _value);
// /* Emit log events */
emit TokensSent(_to, _value);
emit Transfer(company, _to, _value);
}
function sendFounderTokens(address _to, uint256 _value) public onlyCompany() {
require(safeSub(founders,_value) > founders);
sendCompanyTokens(_to, _value);
founders = safeSub(founders,_value);
}
function sendAdvisorTokens(address _to, uint256 _value) public onlyCompany() {
require(safeSub(advisors,_value) > advisors);
sendCompanyTokens(_to, _value);
advisors = safeSub(advisors,_value);
}
function sendSupportersTokens(address _to, uint256 _value) public onlyCompany() {
require(safeSub(advisors,_value) > advisors);
sendCompanyTokens(_to, _value);
advisors = safeSub(advisors,_value);
}
function sendAirdropTokens(address _to, uint256 _value) public onlyCompany() {
require(safeSub(airdrops,_value) > airdrops);
sendCompanyTokens(_to, _value);
airdrops = safeSub(airdrops,_value);
}
function sendReserveTokens(address _to, uint256 _value) public onlyCompany() {
require(safeSub(reserve,_value) > reserve);
sendCompanyTokens(_to, _value);
reserve = safeSub(reserve,_value);
}
/**
* ERC 20 Standard Token interface transfer function
*
* Prevent transfers until halt period is over.
*/
function transfer(address _to, uint256 _value) public isAvailable() returns (bool success) {
return super.transfer(_to, _value);
}
/**
* ERC 20 Standard Token interface transfer function
*
* Prevent transfers until halt period is over.
*/
function transferFrom(address _from, address _to, uint256 _value) public isAvailable() returns (bool success) {
return super.transferFrom(_from, _to, _value);
}
/**
* Burn all tokens from a balance.
*/
function burnRemainingTokens() public isAvailable() onlyCompany() {
// require(founders == 0 && advisors == 0 && supporters == 0 && airdrops == 0 && reserve == 0);
balances[company] = safeSub(balances[company], tge);
emit Burn(company, tge);
tge = 0;
}
modifier onlyCompany() {
require(msg.sender == company);
_;
}
modifier isAvailable() {
require(!halted && !freeze);
_;
}
/**
* Just being sent some cash? Let's buy tokens
*/
function() public payable {
buy();
}
/**
* Freeze and unfreeze TGE.
*/
function freeze() public onlyCompany() { freeze = true; }
function unFreeze() public onlyCompany() { freeze = false; }
function totalSupply() public constant returns (uint256 supply) {
supply = _totalSupply;
}
}
pragma solidity ^0.4.2;
/**
* Math operations with safety checks
*/
contract SafeMath {
function safeMul(uint a, uint b) internal pure returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function safeDiv(uint a, uint b) internal pure returns (uint) {
assert(b > 0);
uint c = a / b;
assert(a == b * c + a % b);
return c;
}
function safeSub(uint a, uint b) internal pure returns (uint) {
assert(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
function max64(uint64 a, uint64 b) internal pure returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) internal pure returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
}
pragma solidity ^0.4.2;
import "./Erc20.sol";
import "./SafeMath.sol";
contract StandardToken is Erc20, SafeMath {
// Token supply got increased and a new owner received these tokens
// event Minted(address receiver, uint amount);
/* Actual balances of token holders */
mapping(address => uint) balances;
/* approve() allowances */
mapping (address => mapping (address => uint)) allowed;
/* Interface declaration */
function isToken() public pure returns (bool weAre) {
return true;
}
function transfer(address _to, uint _value) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], _value);
balances[_to] = safeAdd(balances[_to], _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint _value) public returns (bool success) {
uint _allowance = allowed[_from][msg.sender];
balances[_to] = safeAdd(balances[_to], _value);
balances[_from] = safeSub(balances[_from], _value);
allowed[_from][msg.sender] = safeSub(_allowance, _value);
emit Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) public constant returns (uint balance) {
return balances[_owner];
}
function approve(address _spender, uint _value) public returns (bool success) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return allowed[_owner][_spender];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment