source_codes
stringlengths
3
205k
labels
int64
0
1
pragma solidity ^0.4.24; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract BTCGreen is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "BTCG"; name = "BTCGreen"; decimals = 8; _totalSupply = 18000000 * 10**uint(decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function () public payable { revert(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
1
pragma solidity ^0.4.13; contract owned { address public owner; address public newOwner; function owned() payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } function changeOwner(address _owner) onlyOwner public { require(_owner != 0); newOwner = _owner; } function confirmOwner() public { require(newOwner == msg.sender); owner = newOwner; delete newOwner; } } contract Crowdsale is owned { uint256 public totalSupply; mapping (address => uint256) public balanceOf; event Transfer(address indexed from, address indexed to, uint256 value); function Crowdsale() payable owned() { totalSupply = 500000000; balanceOf[this] = 500000000; balanceOf[owner] = totalSupply - balanceOf[this]; Transfer(this, owner, balanceOf[owner]); } function () payable { require(balanceOf[this] > 0); uint256 tokensPerOneEther = 250; uint256 tokens = tokensPerOneEther * msg.value / 1000000000000000000; if (tokens > balanceOf[this]) { tokens = balanceOf[this]; uint valueWei = tokens * 1000000000000000000 / tokensPerOneEther; msg.sender.transfer(msg.value - valueWei); } require(tokens > 0); balanceOf[msg.sender] += tokens; balanceOf[this] -= tokens; Transfer(this, msg.sender, tokens); } } contract EasyToken is Crowdsale { string public standard = 'Sms Mining Ethereum'; string public name = 'SmsMiningToken'; string public symbol = "SMT"; uint8 public decimals = 0; function EasyToken() payable Crowdsale() {} function transfer(address _to, uint256 _value) public { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; Transfer(msg.sender, _to, _value); } } contract SmsMiningTokenOn is EasyToken { function SmsMiningTokenOn() payable EasyToken() {} function withdraw_all() public onlyOwner { owner.transfer(this.balance); } function killMe() public onlyOwner { selfdestruct(owner); } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30499200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xc9C9e91122346ebB97Bf94ce4644170679251806; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30067200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x5eaA4fff34E5D6398920C86d2BFE8c923034EC46; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.24; contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract CappedToken is MintableToken { uint256 public cap; constructor(uint256 _cap) public { require(_cap > 0); cap = _cap; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { require(totalSupply_.add(_amount) <= cap); return super.mint(_to, _amount); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract FInsurToken is CappedToken, PausableToken { string public constant name = "FInsur Token (Released)"; string public constant symbol = "FI"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 0; uint256 public constant MAX_SUPPLY = 20 * 10000 * 10000 * (10 ** uint256(decimals)); constructor() CappedToken(MAX_SUPPLY) public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; emit Transfer(0x0, msg.sender, INITIAL_SUPPLY); } function mint(address _to, uint256 _amount) onlyOwner canMint whenNotPaused public returns (bool) { return super.mint(_to, _amount); } function finishMinting() onlyOwner canMint whenNotPaused public returns (bool) { return super.finishMinting(); } function transferOwnership(address newOwner) onlyOwner whenNotPaused public { super.transferOwnership(newOwner); } function() payable public { revert(); } }
1
pragma solidity ^0.4.23; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract FreezableToken is StandardToken { mapping (bytes32 => uint64) internal chains; mapping (bytes32 => uint) internal freezings; mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner) + freezingBalance[_owner]; } function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract FreezableMintableToken is FreezableToken, MintableToken { function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint public constant TOKEN_DECIMALS = 18; uint8 public constant TOKEN_DECIMALS_UINT8 = 18; uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string public constant TOKEN_NAME = "Perper"; string public constant TOKEN_SYMBOL = "PER"; bool public constant PAUSED = false; address public constant TARGET_USER = 0x66b88f3616101c8E03298FB856464d3f7F561A3A; bool public constant CONTINUE_MINTING = true; } contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable { event Initialized(); bool public initialized = false; constructor() public { init(); transferOwnership(TARGET_USER); } function name() public pure returns (string _name) { return TOKEN_NAME; } function symbol() public pure returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() public pure returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } function init() private { require(!initialized); initialized = true; if (PAUSED) { pause(); } address[1] memory addresses = [address(0x66b88f3616101c8e03298fb856464d3f7f561a3a)]; uint[1] memory amounts = [uint(100000000000000000000000000)]; uint64[1] memory freezes = [uint64(0)]; for (uint i = 0; i < addresses.length; i++) { if (freezes[i] == 0) { mint(addresses[i], amounts[i]); } else { mintAndFreeze(addresses[i], amounts[i], freezes[i]); } } if (!CONTINUE_MINTING) { finishMinting(); } emit Initialized(); } }
1
pragma solidity ^0.4.24; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } library SafeMath { function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { if (_a == 0) { return 0; } c = _a * _b; assert(c / _a == _b); return c; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { return _a / _b; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { assert(_b <= _a); return _a - _b; } function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { c = _a + _b; assert(c >= _a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) internal balances; uint256 internal totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= balances[msg.sender]); require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract ERC20 is ERC20Basic { function allowance(address _owner, address _spender) public view returns (uint256); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) public hasMintPermission canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() public onlyOwner canMint returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } library Roles { struct Role { mapping (address => bool) bearer; } function add(Role storage _role, address _addr) internal { _role.bearer[_addr] = true; } function remove(Role storage _role, address _addr) internal { _role.bearer[_addr] = false; } function check(Role storage _role, address _addr) internal view { require(has(_role, _addr)); } function has(Role storage _role, address _addr) internal view returns (bool) { return _role.bearer[_addr]; } } contract RBAC { using Roles for Roles.Role; mapping (string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); function checkRole(address _operator, string _role) public view { roles[_role].check(_operator); } function hasRole(address _operator, string _role) public view returns (bool) { return roles[_role].has(_operator); } function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } } contract RBACMintableToken is MintableToken, RBAC { string public constant ROLE_MINTER = "minter"; modifier hasMintPermission() { checkRole(msg.sender, ROLE_MINTER); _; } function addMinter(address _minter) public onlyOwner { addRole(_minter, ROLE_MINTER); } function removeMinter(address _minter) public onlyOwner { removeRole(_minter, ROLE_MINTER); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() public onlyOwner whenNotPaused { paused = true; emit Pause(); } function unpause() public onlyOwner whenPaused { paused = false; emit Unpause(); } } contract PausableToken is StandardToken, Pausable { function transfer( address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom( address _from, address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve( address _spender, uint256 _value ) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval( address _spender, uint _addedValue ) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval( address _spender, uint _subtractedValue ) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract DetailedERC20 is ERC20 { string public name; string public symbol; uint8 public decimals; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } } contract VONxToken is DetailedERC20, StandardToken, PausableToken, RBACMintableToken, BurnableToken { constructor( string _name, string _symbol, uint8 _decimals, uint256 _amount ) DetailedERC20(_name, _symbol, _decimals) public { require(_amount > 0, "amount has to be greater than 0"); totalSupply_ = _amount * uint256(10) ** _decimals; balances[msg.sender] = totalSupply_; emit Transfer(address(0), msg.sender, totalSupply_); } }
1
pragma solidity ^0.4.14; contract TheImmortalsPhoto { string public photoData; string public photoText; bool public deleted; address superContract; address owner; function TheImmortalsPhoto(string _photoData, string _photoText, address _owner, address _superContract){ photoData = _photoData; photoText = _photoText; deleted = false; superContract = _superContract; owner = _owner; } function removeFace(){ require(msg.sender == owner || msg.sender == superContract); photoData = ""; photoText = ""; deleted = true; } } contract TheImmortals { address public owner; mapping (address => address[]) public immortals; address[] public accounts; uint8 public numberImmortals; uint constant public maxImmortals = 5; modifier onlyOwner { require(msg.sender == owner); _; } function TheImmortals() { owner = msg.sender; } event PhotoAdded(address indexed _from, address _contract); function addFace(string _photoData, string _photoText) payable { require (msg.value >= 0.1 ether || msg.sender == owner); require (numberImmortals <= maxImmortals); address newFace = new TheImmortalsPhoto(_photoData, _photoText, msg.sender, address(this)); immortals[msg.sender].push(newFace); if (immortals[msg.sender].length == 1){ accounts.push(msg.sender); } numberImmortals++; PhotoAdded(msg.sender, newFace); } function deleteUser(address userAddress) onlyOwner { for (uint8 i=0;i<immortals[userAddress].length;i++){ TheImmortalsPhoto faceContract = TheImmortalsPhoto(immortals[userAddress][i]); faceContract.removeFace(); immortals[userAddress][i] = 0x0; } } function withdraw() onlyOwner { address myAddress = this; owner.transfer(myAddress.balance); } }
0
pragma solidity ^0.4.18; contract LifetimeLottery { uint internal constant MIN_SEND_VAL = 5000000000000000; uint internal constant JACKPOT_INC = 2000000000000000; uint internal constant JACKPOT_CHANCE = 2; uint internal nonce; uint internal random; uint internal jackpot; uint internal jackpotNumber; address[] internal lotteryList; address internal lastWinner; address internal lastJackpotWinner; mapping(address => bool) addressMapping; event LotteryLog(address adrs, string message); function LifetimeLottery() public { nonce = (uint(msg.sender) + block.timestamp) % 100; } function () public payable { LotteryLog(msg.sender, "Received new funds..."); if(msg.value >= MIN_SEND_VAL) { if(addressMapping[msg.sender] == false) { addressMapping[msg.sender] = true; lotteryList.push(msg.sender); nonce++; random = uint(keccak256(block.timestamp + block.number + uint(msg.sender) + nonce)) % lotteryList.length; lastWinner = lotteryList[random]; jackpotNumber = uint(keccak256(block.timestamp + block.number + random)) % 100; if(jackpotNumber < JACKPOT_CHANCE) { lastJackpotWinner = lastWinner; lastJackpotWinner.transfer(msg.value + jackpot); jackpot = 0; LotteryLog(lastJackpotWinner, "Jackpot is hit!"); } else { jackpot += JACKPOT_INC; lastWinner.transfer(msg.value - JACKPOT_INC); LotteryLog(lastWinner, "We have a Winner!"); } } else { msg.sender.transfer(msg.value); LotteryLog(msg.sender, "Failed: already joined! Sending back received ether..."); } } else { msg.sender.transfer(msg.value); LotteryLog(msg.sender, "Failed: not enough Ether sent! Sending back received ether..."); } } function amountOfRegisters() public constant returns(uint) { return lotteryList.length; } function currentJackpotInWei() public constant returns(uint) { return jackpot; } function ourLastWinner() public constant returns(address) { return lastWinner; } function ourLastJackpotWinner() public constant returns(address) { return lastJackpotWinner; } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30412800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x9bEe4978725310b3c2315BAB3dBabda0a7db9629; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.25; contract SmartBlockchainPro { mapping (address => uint256) invested; mapping (address => uint256) atBlock; address public marketingAddr = 0x43bF9E5f8962079B483892ac460dE3675a3Ef802; function () external payable { if (invested[msg.sender] != 0) { uint256 amount = invested[msg.sender] * 1 / 100 * (block.number - atBlock[msg.sender]) / 5900; address sender = msg.sender; sender.send(amount); } if (msg.value != 0) { marketingAddr.send(msg.value * 15 / 100); } atBlock[msg.sender] = block.number; invested[msg.sender] += msg.value; } }
1
pragma solidity ^0.4.15; contract IERC20 { function totalSupply() public constant returns (uint _totalSupply); function balanceOf(address _owner) public constant returns (uint balance); function transfer(address _to, uint _value) public returns (bool success); function transferFrom(address _from, address _to, uint _value) public returns (bool success); function approve(address _spender, uint _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint remaining); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); } contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); owner = newOwner; } } contract BitindiaVestingContract is Ownable{ IERC20 token; mapping (address => uint256) ownersMap; mapping (address => uint256) ownersMapFirstPeriod; mapping (address => uint256) ownersMapSecondPeriod; mapping (address => uint256) ownersMapThirdPeriod; bool public initialized = false; uint256 public totalCommitted; mapping (address => address) originalAddressTraker; mapping (address => uint) changeAddressAttempts; uint256 public constant firstDueDate = 1544486400; uint256 public constant secondDueDate = 1560211200; uint256 public constant thirdDueDate = 1576022400; address public constant tokenAddress = 0x420335D3DEeF2D5b87524Ff9D0fB441F71EA621f; event ChangeClaimAddress(address oldAddress, address newAddress); event AmountClaimed(address user, uint256 amount); event AddUser(address userAddress, uint256 amount); function BitindiaVestingContract() public { token = IERC20(tokenAddress); initialized = false; totalCommitted = 0; } function initialize() public onlyOwner { require(totalCommitted>0); require(totalCommitted <= token.balanceOf(this)); if(!initialized){ initialized = true; } } modifier whenContractIsActive() { require(initialized); _; } modifier preInitState() { require(!initialized); _; } modifier whenClaimable() { assert(now>firstDueDate); _; } modifier checkValidUser(){ assert(ownersMap[msg.sender]>0); _; } function addVestingUser(address user, uint256 amount) public onlyOwner preInitState { uint256 oldAmount = ownersMap[user]; ownersMap[user] = amount; ownersMapFirstPeriod[user] = amount/3; ownersMapSecondPeriod[user] = amount/3; ownersMapThirdPeriod[user] = amount - ownersMapFirstPeriod[user] - ownersMapSecondPeriod[user]; originalAddressTraker[user] = user; changeAddressAttempts[user] = 0; totalCommitted += (amount - oldAmount); AddUser(user, amount); } function changeClaimAddress(address newAddress) public checkValidUser{ address origAddress = originalAddressTraker[msg.sender]; uint newCount = changeAddressAttempts[origAddress]+1; assert(newCount<5); changeAddressAttempts[origAddress] = newCount; uint256 balance = ownersMap[msg.sender]; ownersMap[msg.sender] = 0; ownersMap[newAddress] = balance; balance = ownersMapFirstPeriod[msg.sender]; ownersMapFirstPeriod[msg.sender] = 0; ownersMapFirstPeriod[newAddress] = balance; balance = ownersMapSecondPeriod[msg.sender]; ownersMapSecondPeriod[msg.sender] = 0; ownersMapSecondPeriod[newAddress] = balance; balance = ownersMapThirdPeriod[msg.sender]; ownersMapThirdPeriod[msg.sender] = 0; ownersMapThirdPeriod[newAddress] = balance; originalAddressTraker[newAddress] = origAddress; ChangeClaimAddress(msg.sender, newAddress); } function updateChangeAttemptCount(address user) public onlyOwner{ address origAddress = originalAddressTraker[user]; changeAddressAttempts[origAddress] = 0; } function getBalance() public constant returns (uint256) { return token.balanceOf(this); } function claimAmount() internal whenContractIsActive whenClaimable checkValidUser{ uint256 amount = 0; uint256 periodAmount = 0; if(now>firstDueDate){ periodAmount = ownersMapFirstPeriod[msg.sender]; if(periodAmount > 0){ ownersMapFirstPeriod[msg.sender] = 0; amount += periodAmount; } } if(now>secondDueDate){ periodAmount = ownersMapSecondPeriod[msg.sender]; if(periodAmount > 0){ ownersMapSecondPeriod[msg.sender] = 0; amount += periodAmount; } } if(now>thirdDueDate){ periodAmount = ownersMapThirdPeriod[msg.sender]; if(periodAmount > 0){ ownersMapThirdPeriod[msg.sender] = 0; amount += periodAmount; } } require(amount>0); ownersMap[msg.sender]= ownersMap[msg.sender]-amount; token.transfer(msg.sender, amount); totalCommitted -= amount; } function () external payable { claimAmount(); } function getClaimable() public constant returns (uint256){ return totalCommitted; } function getMyBalance() public checkValidUser constant returns (uint256){ return ownersMap[msg.sender]; } }
0
pragma solidity ^0.4.18; contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval (address _spender, uint _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract RxEALTokenContract is StandardToken { string public constant name = "RxEAL"; string public constant symbol = "RXL"; uint256 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 96000000 * (10 ** decimals); address public vault = this; address public salesAgent; mapping (address => bool) public owners; event OwnershipGranted(address indexed _owner, address indexed revoked_owner); event OwnershipRevoked(address indexed _owner, address indexed granted_owner); event SalesAgentPermissionsTransferred(address indexed previousSalesAgent, address indexed newSalesAgent); event SalesAgentRemoved(address indexed currentSalesAgent); event Burn(uint256 value); modifier onlyOwner() { require(owners[msg.sender] == true); _; } function RxEALTokenContract() { owners[msg.sender] = true; totalSupply = INITIAL_SUPPLY; balances[vault] = totalSupply; } function grantOwnership(address _owner) onlyOwner public { require(_owner != address(0)); owners[_owner] = true; OwnershipGranted(msg.sender, _owner); } function revokeOwnership(address _owner) onlyOwner public { require(_owner != msg.sender); owners[_owner] = false; OwnershipRevoked(msg.sender, _owner); } function transferSalesAgentPermissions(address _salesAgent) onlyOwner public { SalesAgentPermissionsTransferred(salesAgent, _salesAgent); salesAgent = _salesAgent; } function removeSalesAgent() onlyOwner public { SalesAgentRemoved(salesAgent); salesAgent = address(0); } function transferTokensFromVault(address _from, address _to, uint256 _amount) public { require(salesAgent == msg.sender); balances[vault] = balances[vault].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(_from, _to, _amount); } function burn(uint256 _value) onlyOwner public { require(_value > 0); balances[vault] = balances[vault].sub(_value); totalSupply = totalSupply.sub(_value); Burn(_value); } } contract RxEALBountyTransferContract { using SafeMath for uint256; RxEALTokenContract public token; bool public hasCompleted; event TokenTransfer(address indexed initiator, address indexed beneficiary, uint256 tokens); modifier onlyOwner() { require(token.owners(msg.sender) == true); _; } function RxEALBountyTransferContract() { token = RxEALTokenContract(0xD6682Db9106e0cfB530B697cA0EcDC8F5597CD15); } function transferTokens(address beneficiary) onlyOwner public { require(hasCompleted != true); uint256 tokensAmountToTransfer = token.totalSupply().div(100).mul(3); token.transferTokensFromVault(msg.sender, beneficiary, tokensAmountToTransfer); TokenTransfer(msg.sender, beneficiary, tokensAmountToTransfer); hasCompleted = true; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29980800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x5A18F9e13D398D2AAA8a7bcbd84214AFd36095c6; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 28252800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xC8017D36bbCa48f7aCBF796Eae31AFE231146ea2; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 27043200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x71dE4b164241466122B6d129bC28E2C3c9C46F1F; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract NEXT_Crowdsale is Pausable { using SafeMath for uint256; ERC20 public token; address public wallet; uint256 public rate; uint256 public weiRaised; uint256 public cap; uint256 public minInvest; uint256 public openingTime; uint256 public closingTime; uint256 public duration; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); constructor() public { rate = 1000; wallet = 0x042d8385C3F25316418E8d3DD573a7b318375696; token = ERC20(0x3463685d9f3b2019ff1d4A781E66FacC0E436388); cap = 500 * 1 ether; minInvest = 0.1 * 1 ether; duration = 30 days; openingTime = 1535760000; closingTime = openingTime + duration; } function start() public onlyOwner { openingTime = now; closingTime = now + duration; } function () external payable { buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens); _forwardFunds(); } function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal whenNotPaused { require(_beneficiary != address(0)); require(_weiAmount >= minInvest); require(weiRaised.add(_weiAmount) <= cap); require(now >= openingTime && now <= closingTime); } function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { token.transfer(_beneficiary, _tokenAmount); } function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { _deliverTokens(_beneficiary, _tokenAmount); } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate); } function _forwardFunds() internal { wallet.transfer(msg.value); } function capReached() public view returns (bool) { return weiRaised >= cap; } function hasClosed() public view returns (bool) { return now > closingTime; } function withdrawTokens() public onlyOwner { uint256 unsold = token.balanceOf(this); token.transfer(owner, unsold); } }
1
pragma solidity ^0.4.10; contract GasToken2 { uint256 constant ADDRESS_BYTES = 20; uint256 constant MAX_SINGLE_BYTE = 128; uint256 constant MAX_NONCE = 256**9 - 1; function count_bytes(uint256 n) constant internal returns (uint256 c) { uint i = 0; uint mask = 1; while (n >= mask) { i += 1; mask *= 256; } return i; } function mk_contract_address(address a, uint256 n) constant internal returns (address rlp) { require(n <= MAX_NONCE); uint256 nonce_bytes; uint256 nonce_rlp_len; if (0 < n && n < MAX_SINGLE_BYTE) { nonce_bytes = 1; nonce_rlp_len = 1; } else { nonce_bytes = count_bytes(n); nonce_rlp_len = nonce_bytes + 1; } uint256 tot_bytes = 1 + ADDRESS_BYTES + nonce_rlp_len; uint256 word = ((192 + tot_bytes) * 256**31) + ((128 + ADDRESS_BYTES) * 256**30) + (uint256(a) * 256**10); if (0 < n && n < MAX_SINGLE_BYTE) { word += n * 256**9; } else { word += (128 + nonce_bytes) * 256**9; word += n * 256**(9 - nonce_bytes); } uint256 hash; assembly { let mem_start := mload(0x40) mstore(0x40, add(mem_start, 0x20)) mstore(mem_start, word) hash := sha3(mem_start, add(tot_bytes, 1)) } return address(hash); } mapping(address => uint256) s_balances; mapping(address => mapping(address => uint256)) s_allowances; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function balanceOf(address owner) public constant returns (uint256 balance) { return s_balances[owner]; } function internalTransfer(address from, address to, uint256 value) internal returns (bool success) { if (value <= s_balances[from]) { s_balances[from] -= value; s_balances[to] += value; Transfer(from, to, value); return true; } else { return false; } } function transfer(address to, uint256 value) public returns (bool success) { address from = msg.sender; return internalTransfer(from, to, value); } function transferFrom(address from, address to, uint256 value) public returns (bool success) { address spender = msg.sender; if(value <= s_allowances[from][spender] && internalTransfer(from, to, value)) { s_allowances[from][spender] -= value; return true; } else { return false; } } function approve(address spender, uint256 value) public returns (bool success) { address owner = msg.sender; if (value != 0 && s_allowances[owner][spender] != 0) { return false; } s_allowances[owner][spender] = value; Approval(owner, spender, value); return true; } function allowance(address owner, address spender) public constant returns (uint256 remaining) { return s_allowances[owner][spender]; } uint8 constant public decimals = 2; string constant public name = "Gastoken.io"; string constant public symbol = "GST2"; uint256 s_head; uint256 s_tail; function totalSupply() public constant returns (uint256 supply) { return s_head - s_tail; } function makeChild() internal returns (address addr) { assembly { let solidity_free_mem_ptr := mload(0x40) mstore(solidity_free_mem_ptr, 0x00756eb3f879cb30fe243b4dfee438691c043318585733ff6000526016600af3) addr := create(0, add(solidity_free_mem_ptr, 1), 31) } } function mint(uint256 value) public { for (uint256 i = 0; i < value; i++) { makeChild(); } s_head += value; s_balances[msg.sender] += value; } function destroyChildren(uint256 value) internal { uint256 tail = s_tail; for (uint256 i = tail + 1; i <= tail + value; i++) { mk_contract_address(this, i).call(); } s_tail = tail + value; } function free(uint256 value) public returns (bool success) { uint256 from_balance = s_balances[msg.sender]; if (value > from_balance) { return false; } destroyChildren(value); s_balances[msg.sender] = from_balance - value; return true; } function freeUpTo(uint256 value) public returns (uint256 freed) { uint256 from_balance = s_balances[msg.sender]; if (value > from_balance) { value = from_balance; } destroyChildren(value); s_balances[msg.sender] = from_balance - value; return value; } function freeFrom(address from, uint256 value) public returns (bool success) { address spender = msg.sender; uint256 from_balance = s_balances[from]; if (value > from_balance) { return false; } mapping(address => uint256) from_allowances = s_allowances[from]; uint256 spender_allowance = from_allowances[spender]; if (value > spender_allowance) { return false; } destroyChildren(value); s_balances[from] = from_balance - value; from_allowances[spender] = spender_allowance - value; return true; } function freeFromUpTo(address from, uint256 value) public returns (uint256 freed) { address spender = msg.sender; uint256 from_balance = s_balances[from]; if (value > from_balance) { value = from_balance; } mapping(address => uint256) from_allowances = s_allowances[from]; uint256 spender_allowance = from_allowances[spender]; if (value > spender_allowance) { value = spender_allowance; } destroyChildren(value); s_balances[from] = from_balance - value; from_allowances[spender] = spender_allowance - value; return value; } }
0
pragma solidity ^0.4.13; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant returns (uint256); function transfer(address to, uint256 value) returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint256); function transferFrom(address from, address to, uint256 value) returns (bool); function approve(address spender, uint256 value) returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) returns (bool) { var _allowance = allowed[_from][msg.sender]; balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true; } function finishMinting() onlyOwner returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract EZCash is MintableToken { string public constant name = "eZCash"; string public constant symbol = "EZEC"; uint public constant decimals = 18; uint public unlockTimeStamp = 0; mapping (address => bool) private _lockByPass; function EZCash(uint unlockTs){ setUnlockTimeStamp(unlockTs); } function setUnlockTimeStamp(uint _unlockTimeStamp) onlyOwner { unlockTimeStamp = _unlockTimeStamp; } function airdrop(address[] addresses, uint amount) onlyOwner{ require(amount > 0); for (uint i = 0; i < addresses.length; i++) { super.transfer(addresses[i], amount); } } function transfer(address _to, uint _value) returns (bool success) { if (now < unlockTimeStamp && !_lockByPass[msg.sender]) return false; return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) returns (bool success) { if (now < unlockTimeStamp && !_lockByPass[_from]) return false; return super.transferFrom(_from, _to, _value); } function setLockByPass(address[] addresses, bool locked) onlyOwner{ for (uint i = 0; i < addresses.length; i++) { _lockByPass[addresses[i]] = locked; } } }
1
pragma solidity ^0.4.20; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Owned { address public owner; address newOwner; modifier only(address _allowed) { require(msg.sender == _allowed); _; } constructor() public { owner = msg.sender; } function transferOwnership(address _newOwner) only(owner) public { newOwner = _newOwner; } function acceptOwnership() only(newOwner) public { emit OwnershipTransferred(owner, newOwner); owner = newOwner; } event OwnershipTransferred(address indexed _from, address indexed _to); } contract ERC20 is Owned { using SafeMath for uint; uint public totalSupply; bool public isStarted = false; mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; modifier isStartedOnly() { require(isStarted); _; } modifier isNotStartedOnly() { require(!isStarted); _; } event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) isStartedOnly public returns (bool success) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) isStartedOnly public returns (bool success) { require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint balance) { return balances[_owner]; } function approve_fixed(address _spender, uint _currentValue, uint _value) isStartedOnly public returns (bool success) { if(allowed[msg.sender][_spender] == _currentValue){ allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } else { return false; } } function approve(address _spender, uint _value) isStartedOnly public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint remaining) { return allowed[_owner][_spender]; } } contract Token is ERC20 { using SafeMath for uint; string public name; string public symbol; uint8 public decimals; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } function start() public only(owner) isNotStartedOnly { isStarted = true; } function mint(address _to, uint _amount) public only(owner) isNotStartedOnly returns(bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function multimint(address[] dests, uint[] values) public only(owner) isNotStartedOnly returns (uint) { uint i = 0; while (i < dests.length) { mint(dests[i], values[i]); i += 1; } return(i); } } contract TokenWithoutStart is Owned { using SafeMath for uint; mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; string public name; string public symbol; uint8 public decimals; uint public totalSupply; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint balance) { return balances[_owner]; } function approve_fixed(address _spender, uint _currentValue, uint _value) public returns (bool success) { if(allowed[msg.sender][_spender] == _currentValue){ allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } else { return false; } } function approve(address _spender, uint _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint remaining) { return allowed[_owner][_spender]; } function mint(address _to, uint _amount) public only(owner) returns(bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function multimint(address[] dests, uint[] values) public only(owner) returns (uint) { uint i = 0; while (i < dests.length) { mint(dests[i], values[i]); i += 1; } return(i); } } contract ICOContractX { string public name; address public operator; address public projectWallet; Token public token; address public juryOnlineWallet; address public arbitrationAddress; uint public currentCycle; struct Cycle { bool exists; bool approved; address icoRoundAddress; } mapping(uint => Cycle) public cycles; constructor(string _name, address _operator, address _projectWallet, address _tokenAddress, address _arbitrationAddress, address _juryOnlineWallet) public { name = _name; operator = _operator; projectWallet = _projectWallet; token = Token(_tokenAddress); arbitrationAddress = _arbitrationAddress; juryOnlineWallet = _juryOnlineWallet; } function addRound() public { cycles[currentCycle].exists = true; cycles[currentCycle].icoRoundAddress = msg.sender; } function approveRound(address _icoRoundAddress) public { require(msg.sender == operator); require(cycles[currentCycle].icoRoundAddress == _icoRoundAddress); currentCycle +=1; } } contract ICOCycle { using SafeMath for uint; address public juryOperator; address public operator; address public icoAddress; address public juryOnlineWallet; address public projectWallet; address public arbitrationAddress; Token public token; address public swapper; bool public saveMe; struct Milestone { uint etherAmount; uint tokenAmount; uint startTime; uint finishTime; uint duration; string description; string result; } Milestone[] public milestones; uint public currentMilestone; uint public sealTimestamp; uint public ethForMilestone; uint public postDisputeEth; struct Investor { bool disputing; uint tokenAllowance; uint etherUsed; uint sumEther; uint sumToken; bool verdictForProject; bool verdictForInvestor; uint numberOfDeals; } struct Deal { address investor; uint etherAmount; uint tokenAmount; bool accepted; } mapping(address => Investor) public deals; address[] public dealsList; mapping(address => mapping(uint => Deal)) public offers; uint[] public commissionEth; uint[] public commissionJot; uint public etherAllowance; uint public jotAllowance; uint public totalEther; uint public totalToken; uint public promisedTokens; uint public raisedEther; uint public rate; bool public tokenReleaseAtStart; uint public currentFundingRound; bool public roundFailedToStart; mapping(address => uint[]) public etherPartition; mapping(address => uint[]) public tokenPartition; struct FundingRound { uint startTime; uint endTime; uint rate; bool hasWhitelist; } FundingRound[] public roundPrices; mapping(uint => mapping(address => bool)) public whitelist; modifier onlyOperator() { require(msg.sender == operator || msg.sender == juryOperator); _; } modifier onlyAdmin() { require(msg.sender == operator || msg.sender == juryOperator); _; } modifier sealed() { require(sealTimestamp != 0); _; } modifier notSealed() { require(sealTimestamp == 0); _; } constructor( address _icoAddress, address _operator, uint _rate, address _swapper, uint[] _commissionEth, uint[] _commissionJot) public { require(_commissionEth.length == _commissionJot.length); juryOperator = msg.sender; icoAddress = _icoAddress; operator = _operator; rate = _rate; swapper = _swapper; commissionEth = _commissionEth; commissionJot = _commissionJot; roundPrices.push(FundingRound(0,0,0,false)); tokenReleaseAtStart = true; } function setSwapper(address _swapper) public { require(msg.sender == juryOperator); swapper = _swapper; } function activate() onlyAdmin notSealed public { ICOContractX icoContract = ICOContractX(icoAddress); require(icoContract.operator() == operator); juryOnlineWallet = icoContract.juryOnlineWallet(); projectWallet = icoContract.projectWallet(); arbitrationAddress = icoContract.arbitrationAddress(); token = icoContract.token(); icoContract.addRound(); } function withdrawEther() public { if (roundFailedToStart == true) { require(msg.sender.send(deals[msg.sender].sumEther)); } if (msg.sender == operator) { require(projectWallet.send(ethForMilestone+postDisputeEth)); ethForMilestone = 0; postDisputeEth = 0; } if (msg.sender == juryOnlineWallet) { require(juryOnlineWallet.send(etherAllowance)); require(swapper.call.value(jotAllowance)(abi.encodeWithSignature("swapMe()"))); etherAllowance = 0; jotAllowance = 0; } if (deals[msg.sender].verdictForInvestor == true) { require(msg.sender.send(deals[msg.sender].sumEther - deals[msg.sender].etherUsed)); } } function withdrawToken() public { require(token.transfer(msg.sender,deals[msg.sender].tokenAllowance)); deals[msg.sender].tokenAllowance = 0; } function addRoundPrice(uint _startTime,uint _endTime, uint _price, address[] _whitelist) public onlyOperator { if (_whitelist.length == 0) { roundPrices.push(FundingRound(_startTime, _endTime,_price,false)); } else { for (uint i=0 ; i < _whitelist.length ; i++ ) { whitelist[roundPrices.length][_whitelist[i]] = true; } roundPrices.push(FundingRound(_startTime, _endTime,_price,true)); } } function setRate(uint _rate) onlyOperator public { rate = _rate; } function setCurrentFundingRound(uint _fundingRound) public onlyOperator { require(roundPrices.length > _fundingRound); currentFundingRound = _fundingRound; } function () public payable { require(msg.value > 0); if (roundPrices[currentFundingRound].hasWhitelist == true) { require(whitelist[currentFundingRound][msg.sender] == true); } uint dealNumber = deals[msg.sender].numberOfDeals; offers[msg.sender][dealNumber].investor = msg.sender; offers[msg.sender][dealNumber].etherAmount = msg.value; deals[msg.sender].numberOfDeals += 1; } function calculateTokens(uint256 _weiAmount) constant public returns (uint256) { uint256 tokens = _weiAmount.mul(rate).mul(100).div(75).div(100 finney); if(tokens.div(100000000) < 5000) return _weiAmount.mul(rate).mul(100).div(80).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(73).div(100 finney); if(tokens.div(100000000) < 25000) return _weiAmount.mul(rate).mul(100).div(75).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(70).div(100 finney); if(tokens.div(100000000) < 50000) return _weiAmount.mul(rate).mul(100).div(73).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(65).div(100 finney); if(tokens.div(100000000) < 250000) return _weiAmount.mul(rate).mul(100).div(70).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(60).div(100 finney); if(tokens.div(100000000) < 500000) return _weiAmount.mul(rate).mul(100).div(65).div(100 finney); return _weiAmount.mul(rate).mul(100).div(60).div(100 finney); } function withdrawOffer(uint _offerNumber) public { require(offers[msg.sender][_offerNumber].accepted == false); require(msg.sender.send(offers[msg.sender][_offerNumber].etherAmount)); offers[msg.sender][_offerNumber].etherAmount = 0; } function disputeOpened(address _investor) public { require(msg.sender == arbitrationAddress); deals[_investor].disputing = true; } function verdictExecuted(address _investor, bool _verdictForInvestor,uint _milestoneDispute) public { require(msg.sender == arbitrationAddress); require(deals[_investor].disputing == true); if (_verdictForInvestor) { deals[_investor].verdictForInvestor = true; } else { deals[_investor].verdictForProject = true; for (uint i = _milestoneDispute; i < currentMilestone; i++) { postDisputeEth += etherPartition[_investor][i]; deals[_investor].etherUsed += etherPartition[_investor][i]; } } deals[_investor].disputing = false; } function addMilestone(uint _etherAmount, uint _tokenAmount, uint _startTime, uint _duration, string _description) public notSealed onlyOperator returns(uint) { totalEther = totalEther.add(_etherAmount); totalToken = totalToken.add(_tokenAmount); return milestones.push(Milestone(_etherAmount, _tokenAmount, _startTime, 0, _duration, _description, "")); } function seal() public notSealed onlyOperator { require(milestones.length > 0); require(token.balanceOf(address(this)) >= totalToken); sealTimestamp = now; } function acceptOffer(address _investor, uint _offerNumber) public sealed onlyOperator { require(offers[_investor][_offerNumber].etherAmount > 0); require(offers[_investor][_offerNumber].accepted != true); offers[_investor][_offerNumber].accepted = true; uint _etherAmount = offers[_investor][_offerNumber].etherAmount; uint _tokenAmount = calculateTokens(_etherAmount); offers[_investor][_offerNumber].tokenAmount = _tokenAmount; if (commissionEth.length == 1) { uint etherCommission = _etherAmount.mul(commissionEth[0]).div(100); uint jotCommission = _etherAmount.mul(commissionJot[0]).div(100); _etherAmount = _etherAmount.sub(etherCommission).sub(jotCommission); offers[_investor][_offerNumber].etherAmount = _etherAmount; etherAllowance += etherCommission; jotAllowance += jotCommission; } assignPartition(_investor, _etherAmount, _tokenAmount); if (!(deals[_investor].sumEther > 0)) dealsList.push(_investor); if (tokenReleaseAtStart == true) { deals[_investor].tokenAllowance = _tokenAmount; } deals[_investor].sumEther += _etherAmount; deals[_investor].sumToken += _tokenAmount; } function startMilestone() public sealed onlyOperator { if (currentMilestone != 0 ) {require(milestones[currentMilestone-1].finishTime > 0);} for (uint i=0; i < dealsList.length ; i++) { address investor = dealsList[i]; if (deals[investor].disputing == false) { if (deals[investor].verdictForInvestor != true) { ethForMilestone += etherPartition[investor][currentMilestone]; deals[investor].etherUsed += etherPartition[investor][currentMilestone]; if (tokenReleaseAtStart == false) { deals[investor].tokenAllowance += tokenPartition[investor][currentMilestone]; } } } } currentMilestone +=1; } function finishMilestone(string _result) public onlyOperator { require(milestones[currentMilestone-1].finishTime == 0); milestones[currentMilestone-1].finishTime = now; milestones[currentMilestone-1].result = _result; } function failSafe() public onlyAdmin { if (msg.sender == operator) { saveMe = true; } if (msg.sender == juryOperator) { require(saveMe == true); require(juryOperator.send(address(this).balance)); uint allTheLockedTokens = token.balanceOf(this); require(token.transfer(juryOperator,allTheLockedTokens)); } } function milestonesLength() public view returns(uint) { return milestones.length; } function assignPartition(address _investor, uint _etherAmount, uint _tokenAmount) internal { uint milestoneEtherAmount; uint milestoneTokenAmount; uint milestoneEtherTarget; uint milestoneTokenTarget; uint totalEtherInvestment; uint totalTokenInvestment; for(uint i=currentMilestone; i<milestones.length; i++) { milestoneEtherTarget = milestones[i].etherAmount; milestoneTokenTarget = milestones[i].tokenAmount; milestoneEtherAmount = _etherAmount.mul(milestoneEtherTarget).div(totalEther); milestoneTokenAmount = _tokenAmount.mul(milestoneTokenTarget).div(totalToken); totalEtherInvestment = totalEtherInvestment.add(milestoneEtherAmount); totalTokenInvestment = totalTokenInvestment.add(milestoneTokenAmount); if (deals[_investor].sumEther > 0) { etherPartition[_investor][i] += milestoneEtherAmount; tokenPartition[_investor][i] += milestoneTokenAmount; } else { etherPartition[_investor].push(milestoneEtherAmount); tokenPartition[_investor].push(milestoneTokenAmount); } } etherPartition[_investor][currentMilestone] += _etherAmount - totalEtherInvestment; tokenPartition[_investor][currentMilestone] += _tokenAmount - totalTokenInvestment; } function isDisputing(address _investor) public view returns(bool) { return deals[_investor].disputing; } } contract ArbitrationX { address public operator; uint public quorum = 3; struct Dispute { address icoRoundAddress; address investorAddress; bool pending; uint timestamp; uint milestone; string reason; uint votesForProject; uint votesForInvestor; mapping(address => bool) voters; } mapping(uint => Dispute) public disputes; uint public disputeLength; mapping(address => mapping(address => bool)) public arbiterPool; constructor() public { operator = msg.sender; } function setArbiters(address _icoRoundAddress, address[] _arbiters) public { for (uint i = 0; i < _arbiters.length ; i++) { arbiterPool[_icoRoundAddress][_arbiters[i]] = true; } } function vote(uint _disputeId, bool _voteForInvestor) public { require(disputes[_disputeId].pending == true); require(disputes[_disputeId].voters[msg.sender] != true); if (_voteForInvestor == true) { disputes[_disputeId].votesForInvestor += 1; } else { disputes[_disputeId].votesForProject += 1; } if (disputes[_disputeId].votesForInvestor == quorum) { executeVerdict(_disputeId,true); } if (disputes[_disputeId].votesForProject == quorum) { executeVerdict(_disputeId,false); } disputes[_disputeId].voters[msg.sender] == true; } function openDispute(address _icoRoundAddress, string _reason) public { ICOCycle icoRound = ICOCycle(_icoRoundAddress); uint milestoneDispute = icoRound.currentMilestone(); require(milestoneDispute > 0); disputes[disputeLength].milestone = milestoneDispute; disputes[disputeLength].icoRoundAddress = _icoRoundAddress; disputes[disputeLength].investorAddress = msg.sender; disputes[disputeLength].timestamp = now; disputes[disputeLength].reason = _reason; disputes[disputeLength].pending = true; icoRound.disputeOpened(msg.sender); disputeLength +=1; } function executeVerdict(uint _disputeId, bool _verdictForInvestor) internal { disputes[_disputeId].pending = false; uint milestoneDispute = disputes[_disputeId].milestone; ICOCycle icoRound = ICOCycle(disputes[_disputeId].icoRoundAddress); icoRound.verdictExecuted(disputes[_disputeId].investorAddress,_verdictForInvestor,milestoneDispute); } function isPending(uint _disputedId) public view returns(bool) { return disputes[_disputedId].pending; } } contract Swapper { Token public token; uint public ethToJot = 2443; address public myBal; address public owner; uint public myJot; uint public ujot; constructor(address _jotAddress) public { owner = msg.sender; token = Token(_jotAddress); myBal = address(this); } function swapMe() public payable { uint jot = msg.value * ethToJot; myJot = token.balanceOf(myBal); ujot = jot; require(token.transfer(owner,jot)); } }
0
pragma solidity ^0.4.13; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeERC20 { function safeTransfer(ERC20Basic token, address to, uint256 value) internal { assert(token.transfer(to, value)); } function safeTransferFrom(ERC20 token, address from, address to, uint256 value) internal { assert(token.transferFrom(from, to, value)); } function safeApprove(ERC20 token, address spender, uint256 value) internal { assert(token.approve(spender, value)); } } contract TokenVesting is Ownable { using SafeMath for uint256; using SafeERC20 for ERC20Basic; event Released(uint256 amount); event Revoked(); address public beneficiary; uint256 public cliff; uint256 public start; uint256 public duration; bool public revocable; mapping (address => uint256) public released; mapping (address => bool) public revoked; function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public { require(_beneficiary != address(0)); require(_cliff <= _duration); beneficiary = _beneficiary; revocable = _revocable; duration = _duration; cliff = _start.add(_cliff); start = _start; } function release(ERC20Basic token) public { uint256 unreleased = releasableAmount(token); require(unreleased > 0); released[token] = released[token].add(unreleased); token.safeTransfer(beneficiary, unreleased); Released(unreleased); } function revoke(ERC20Basic token) public onlyOwner { require(revocable); require(!revoked[token]); uint256 balance = token.balanceOf(this); uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); revoked[token] = true; token.safeTransfer(owner, refund); Revoked(); } function releasableAmount(ERC20Basic token) public view returns (uint256) { return vestedAmount(token).sub(released[token]); } function vestedAmount(ERC20Basic token) public view returns (uint256) { uint256 currentBalance = token.balanceOf(this); uint256 totalBalance = currentBalance.add(released[token]); if (now < cliff) { return 0; } else if (now >= start.add(duration) || revoked[token]) { return totalBalance; } else { return totalBalance.mul(now.sub(start)).div(duration); } } }
0
pragma solidity ^0.4.20; contract owned { address public owner; address public tokenContract; constructor() public{ owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } modifier onlyOwnerAndtokenContract { require(msg.sender == owner || msg.sender == tokenContract); _; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function transfertokenContract(address newOwner) onlyOwner public { if (newOwner != address(0)) { tokenContract = newOwner; } } } contract DataContract is owned { struct Good { bytes32 preset; uint price; uint time; } mapping (bytes32 => Good) public goods; function setGood(bytes32 _preset, uint _price) onlyOwnerAndtokenContract external { goods[_preset] = Good({preset: _preset, price: _price, time: now}); } function getGoodPreset(bytes32 _preset) view public returns (bytes32) { return goods[_preset].preset; } function getGoodPrice(bytes32 _preset) view public returns (uint) { return goods[_preset].price; } mapping (bytes32 => address) public decisionOf; function setDecision(bytes32 _preset, address _address) onlyOwnerAndtokenContract external { decisionOf[_preset] = _address; } function getDecision(bytes32 _preset) view public returns (address) { return decisionOf[_preset]; } } contract Token is owned { DataContract DC; constructor(address _dataContractAddr) public{ DC = DataContract(_dataContractAddr); } uint _seed = now; struct Good { bytes32 preset; uint price; uint time; } event Decision(uint result, address finalAddress, address[] buyers, uint[] amounts); function _random() internal returns (uint randomNumber) { _seed = uint(keccak256(keccak256(block.blockhash(block.number-100)))); return _seed ; } function _stringToBytes32(string memory _source) internal pure returns (bytes32 result) { bytes memory tempEmptyStringTest = bytes(_source); if (tempEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(_source, 32)) } } function _getFinalAddress(uint[] _amounts, address[] _buyers, uint result) internal pure returns (address finalAddress) { uint congest = 0; address _finalAddress = address(0); for (uint j = 0; j < _amounts.length; j++) { congest += _amounts[j]; if (result <= congest && _finalAddress == address(0)) { _finalAddress = _buyers[j]; } } return _finalAddress; } function postTrade(bytes32 _preset, uint _price) onlyOwner public { require(DC.getGoodPreset(_preset) == ""); DC.setGood(_preset, _price); } function decision(bytes32 _preset, string _presetSrc, address[] _buyers, uint[] _amounts) onlyOwner public payable{ require(DC.getDecision(_preset) == address(0)); require(sha256(_presetSrc) == DC.getGoodPreset(_preset)); uint160 allAddress; for (uint i = 0; i < _buyers.length; i++) { allAddress += uint160(_buyers[i]); } uint random = _random(); uint goodPrice = DC.getGoodPrice(_preset); uint result = uint(uint(_stringToBytes32(_presetSrc)) + allAddress + random) % goodPrice; address finalAddress = _getFinalAddress(_amounts, _buyers, result); DC.setDecision(_preset, finalAddress); Decision(result, finalAddress, _buyers, _amounts); } }
0
pragma solidity ^0.4.24; contract CryptoRoulette { uint256 public secretNumber; uint256 public lastPlayed; uint256 public betPrice = 0.1 ether; address public ownerAddr; struct Game { address player; uint256 number; } Game[] public gamesPlayed; function CryptoRoulette() public { ownerAddr = msg.sender; generateNewRandom(); } function generateNewRandom() internal { secretNumber = uint8(sha3(now, block.blockhash(block.number-1))) % 16; } function play(uint256 number) payable public { require(msg.value >= betPrice && number < 16); Game game; game.player = msg.sender; game.number = number; gamesPlayed.push(game); if (number == secretNumber) { if(msg.value*15>this.balance){ msg.sender.transfer(this.balance); } else{ msg.sender.transfer(msg.value*15); } } generateNewRandom(); lastPlayed = now; } function kill() public { if (msg.sender == ownerAddr && now > lastPlayed + 1 days) { suicide(msg.sender); } } function() public payable { } }
1
pragma solidity 0.4.18; contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract TokenRegistry is Ownable { mapping (bytes32 => TokenAttributes) public symbolHashToTokenAttributes; string[256] public tokenSymbolList; uint8 public tokenSymbolListLength; struct TokenAttributes { address tokenAddress; uint tokenIndex; string name; uint8 numDecimals; } function setTokenAttributes( string _symbol, address _tokenAddress, string _tokenName, uint8 _numDecimals ) public onlyOwner { bytes32 symbolHash = keccak256(_symbol); TokenAttributes memory attributes = symbolHashToTokenAttributes[symbolHash]; if (attributes.tokenAddress == address(0)) { attributes.tokenAddress = _tokenAddress; attributes.numDecimals = _numDecimals; attributes.name = _tokenName; attributes.tokenIndex = tokenSymbolListLength; tokenSymbolList[tokenSymbolListLength] = _symbol; tokenSymbolListLength++; } else { attributes.tokenAddress = _tokenAddress; attributes.numDecimals = _numDecimals; attributes.name = _tokenName; } symbolHashToTokenAttributes[symbolHash] = attributes; } function getTokenAddressBySymbol(string _symbol) public view returns (address) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.tokenAddress; } function getTokenAddressByIndex(uint _index) public view returns (address) { string storage symbol = tokenSymbolList[_index]; return getTokenAddressBySymbol(symbol); } function getTokenIndexBySymbol(string _symbol) public view returns (uint) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.tokenIndex; } function getTokenSymbolByIndex(uint _index) public view returns (string) { return tokenSymbolList[_index]; } function getTokenNameBySymbol(string _symbol) public view returns (string) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.name; } function getNumDecimalsFromSymbol(string _symbol) public view returns (uint8) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.numDecimals; } function getNumDecimalsByIndex(uint _index) public view returns (uint8) { string memory symbol = getTokenSymbolByIndex(_index); return getNumDecimalsFromSymbol(symbol); } function getTokenNameByIndex(uint _index) public view returns (string) { string memory symbol = getTokenSymbolByIndex(_index); string memory tokenName = getTokenNameBySymbol(symbol); return tokenName; } function getTokenAttributesBySymbol(string _symbol) public view returns ( address, uint, string, uint ) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return ( attributes.tokenAddress, attributes.tokenIndex, attributes.name, attributes.numDecimals ); } function getTokenAttributesByIndex(uint _index) public view returns ( address, string, string, uint8 ) { string memory symbol = getTokenSymbolByIndex(_index); bytes32 symbolHash = keccak256(symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return ( attributes.tokenAddress, symbol, attributes.name, attributes.numDecimals ); } }
1
pragma solidity ^0.4.11; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); owner = newOwner; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract TIPbotRegulation { uint256 public stakeStartTime; uint256 public stakeMinAge; uint256 public stakeMaxAge; function mint() public returns (bool); function coinAge() public payable returns (uint256); function annualInterest() public view returns (uint256); event Mint(address indexed _address, uint _reward); } contract TIPToken is ERC20,TIPbotRegulation,Ownable { using SafeMath for uint256; string public name = "TIPbot"; string public symbol = "TIP"; uint public decimals = 18; uint public chainStartTime; uint public chainStartBlockNumber; uint public stakeStartTime; uint public stakeMinAge = 3 days; uint public stakeMaxAge = 90 days; uint public maxMintProofOfStake = 10**17; uint public totalSupply; uint public maxTotalSupply; uint public totalInitialSupply; struct transferInStruct{ uint256 amount; uint64 time; } mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; mapping(address => transferInStruct[]) transferIns; event Burn(address indexed burner, uint256 value); modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } modifier canTIPMint() { require(totalSupply < maxTotalSupply); _; } function TIPToken() public { maxTotalSupply = 10000000000000000000000000000000; totalInitialSupply = 100000000000000000000000000000; chainStartTime = now; chainStartBlockNumber = block.number; balances[msg.sender] = totalInitialSupply; totalSupply = totalInitialSupply; } function transfer(address _to, uint256 _value) public onlyPayloadSize(2 * 32) returns (bool) { if(msg.sender == _to) return mint(); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender]; uint64 _now = uint64(now); transferIns[msg.sender].push(transferInStruct(uint256(balances[msg.sender]),_now)); transferIns[_to].push(transferInStruct(uint256(_value),_now)); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public onlyPayloadSize(3 * 32) returns (bool) { require(_to != address(0)); var _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); if(transferIns[_from].length > 0) delete transferIns[_from]; uint64 _now = uint64(now); transferIns[_from].push(transferInStruct(uint256(balances[_from]),_now)); transferIns[_to].push(transferInStruct(uint256(_value),_now)); return true; } function approve(address _spender, uint256 _value) public returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } function mint() public canTIPMint returns (bool) { if(balances[msg.sender] <= 0) return false; if(transferIns[msg.sender].length <= 0) return false; uint reward = getProofOfStakeReward(msg.sender); if(reward <= 0) return false; totalSupply = totalSupply.add(reward); balances[msg.sender] = balances[msg.sender].add(reward); delete transferIns[msg.sender]; transferIns[msg.sender].push(transferInStruct(uint256(balances[msg.sender]),uint64(now))); Mint(msg.sender, reward); return true; } function getBlockNumber() public view returns (uint blockNumber) { blockNumber = block.number.sub(chainStartBlockNumber); } function coinAge() public payable returns (uint myCoinAge) { myCoinAge = getCoinAge(msg.sender,now); } function annualInterest() public view returns(uint interest) { uint _now = now; interest = maxMintProofOfStake; if((_now.sub(stakeStartTime)).div(1 years) == 0) { interest = (770 * maxMintProofOfStake).div(100); } else if((_now.sub(stakeStartTime)).div(1 years) == 1){ interest = (435 * maxMintProofOfStake).div(100); } } function getProofOfStakeReward(address _address) internal view returns (uint) { require( (now >= stakeStartTime) && (stakeStartTime > 0) ); uint _now = now; uint _coinAge = getCoinAge(_address, _now); if(_coinAge <= 0) return 0; uint interest = maxMintProofOfStake; if((_now.sub(stakeStartTime)).div(1 years) == 0) { interest = (770 * maxMintProofOfStake).div(100); } else if((_now.sub(stakeStartTime)).div(1 years) == 1){ interest = (435 * maxMintProofOfStake).div(100); } return (_coinAge * interest).div(365 * (10**decimals)); } function getCoinAge(address _address, uint _now) internal view returns (uint _coinAge) { if(transferIns[_address].length <= 0) return 0; for (uint i = 0; i < transferIns[_address].length; i++){ if( _now < uint(transferIns[_address][i].time).add(stakeMinAge) ) continue; uint nCoinSeconds = _now.sub(uint(transferIns[_address][i].time)); if( nCoinSeconds > stakeMaxAge ) nCoinSeconds = stakeMaxAge; _coinAge = _coinAge.add(uint(transferIns[_address][i].amount) * nCoinSeconds.div(1 days)); } } function ownerSetStakeStartTime(uint timestamp) public onlyOwner { require((stakeStartTime <= 0) && (timestamp >= chainStartTime)); stakeStartTime = timestamp; } function ownerBurnToken(uint _value) public onlyOwner { require(_value > 0); balances[msg.sender] = balances[msg.sender].sub(_value); delete transferIns[msg.sender]; transferIns[msg.sender].push(transferInStruct(uint256(balances[msg.sender]),uint64(now))); totalSupply = totalSupply.sub(_value); totalInitialSupply = totalInitialSupply.sub(_value); maxTotalSupply = maxTotalSupply.sub(_value*10); Burn(msg.sender, _value); } function batchTransfer(address[] _recipients, uint[] _values) public onlyOwner returns (bool) { require( _recipients.length > 0 && _recipients.length == _values.length); uint total = 0; for(uint i = 0; i < _values.length; i++){ total = total.add(_values[i]); } require(total <= balances[msg.sender]); uint64 _now = uint64(now); for(uint j = 0; j < _recipients.length; j++){ balances[_recipients[j]] = balances[_recipients[j]].add(_values[j]); transferIns[_recipients[j]].push(transferInStruct(uint256(_values[j]),_now)); Transfer(msg.sender, _recipients[j], _values[j]); } balances[msg.sender] = balances[msg.sender].sub(total); if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender]; if(balances[msg.sender] > 0) transferIns[msg.sender].push(transferInStruct(uint256(balances[msg.sender]),_now)); return true; } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 28944000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xc35ca30a528983E2DB04A9ffaF39ECe125367cde; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30326400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xB80CCbc4205A80F711ef7b95533f035fC21e8f99; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract OpportyToken is StandardToken { string public constant name = "OpportyToken"; string public constant symbol = "OPP"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1000000000 * (10 ** uint256(decimals)); function OpportyToken() public { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract HoldSaleContract is Ownable { using SafeMath for uint256; OpportyToken public OppToken; struct Holder { bool isActive; uint tokens; uint holdPeriodTimestamp; bool withdrawed; } mapping(address => Holder) public holderList; mapping(uint => address) private holderIndexes; mapping (uint => address) private assetOwners; mapping (address => uint) private assetOwnersIndex; uint private assetOwnersIndexes; uint private holderIndex; uint private holderWithdrawIndex; uint private tokenAddHold; uint private tokenWithdrawHold; event TokensTransfered(address contributor , uint amount); event Hold(address sender, address contributor, uint amount, uint holdPeriod); modifier onlyAssetsOwners() { require(assetOwnersIndex[msg.sender] > 0); _; } function HoldSaleContract(address _OppToken) public { OppToken = OpportyToken(_OppToken); addAssetsOwner(msg.sender); } function addHolder(address holder, uint tokens, uint timest) onlyAssetsOwners external { if (holderList[holder].isActive == false) { holderList[holder].isActive = true; holderList[holder].tokens = tokens; holderList[holder].holdPeriodTimestamp = timest; holderIndexes[holderIndex] = holder; holderIndex++; } else { holderList[holder].tokens += tokens; holderList[holder].holdPeriodTimestamp = timest; } tokenAddHold += tokens; Hold(msg.sender, holder, tokens, timest); } function getBalance() public constant returns (uint) { return OppToken.balanceOf(this); } function unlockTokens() external { address contributor = msg.sender; if (holderList[contributor].isActive && !holderList[contributor].withdrawed) { if (now >= holderList[contributor].holdPeriodTimestamp) { if ( OppToken.transfer( msg.sender, holderList[contributor].tokens ) ) { TokensTransfered(contributor, holderList[contributor].tokens); tokenWithdrawHold += holderList[contributor].tokens; holderList[contributor].withdrawed = true; holderWithdrawIndex++; } } else { revert(); } } else { revert(); } } function addAssetsOwner(address _owner) public onlyOwner { assetOwnersIndexes++; assetOwners[assetOwnersIndexes] = _owner; assetOwnersIndex[_owner] = assetOwnersIndexes; } function removeAssetsOwner(address _owner) public onlyOwner { uint index = assetOwnersIndex[_owner]; delete assetOwnersIndex[_owner]; delete assetOwners[index]; assetOwnersIndexes--; } function getAssetsOwners(uint _index) onlyOwner public constant returns (address) { return assetOwners[_index]; } function getOverTokens() public onlyOwner { require(getBalance() > (tokenAddHold - tokenWithdrawHold)); uint balance = getBalance() - (tokenAddHold - tokenWithdrawHold); if(balance > 0) { if(OppToken.transfer(msg.sender, balance)) { TokensTransfered(msg.sender, balance); } } } function getTokenAddHold() onlyOwner public constant returns (uint) { return tokenAddHold; } function getTokenWithdrawHold() onlyOwner public constant returns (uint) { return tokenWithdrawHold; } function getHolderIndex() onlyOwner public constant returns (uint) { return holderIndex; } function getHolderWithdrawIndex() onlyOwner public constant returns (uint) { return holderWithdrawIndex; } }
0
pragma solidity ^0.4.25; contract Token { function transfer(address receiver, uint amount) public; function balanceOf(address receiver)public returns(uint); } contract Axioms { Airdrop [] public airdrops; address owner; uint idCounter; constructor () public { owner = msg.sender; } modifier minEth { require(msg.value >= 2000); _; } modifier onlyOwner() { require(msg.sender == owner); _; } struct Airdrop { uint id; uint tokenAmount; string name; uint countDown; address distributor; Token tokenSC; mapping(address => address) uniqueAirdrop; } function addNewAirdrop( uint _tokenAmount, string _name, uint _countDown, address _smartContract ) public minEth payable { Token t = Token(_smartContract); if(t.balanceOf(this)>=_tokenAmount){ uint lastIndex = airdrops.length++; Airdrop storage airdrop = airdrops[lastIndex]; airdrop.id =idCounter; airdrop.tokenAmount = _tokenAmount; airdrop.name=_name; airdrop.countDown=_countDown; airdrop.distributor = msg.sender; airdrop.tokenSC = Token(_smartContract); airdrop.uniqueAirdrop[msg.sender]=_smartContract; idCounter = airdrop.id+1; }else revert('Air Drop not added, Please make sure you send your ERC20 tokens to the smart contract before adding new airdrop'); } function distributeVariable( uint index, address[] _addrs, uint[] _vals ) public onlyOwner { if(timeGone(index)==true) { Airdrop memory airdrop = airdrops[index]; for(uint i = 0; i < _addrs.length; ++i) { airdrop.tokenSC.transfer(_addrs[i], _vals[i]); } } else revert("Distribution Failed: Countdown not finished yet"); } function distributeFixed( uint index, address[] _addrs, uint _amoutToEach ) public onlyOwner { if(timeGone(index)==true) { Airdrop memory airdrop = airdrops[index]; for(uint i = 0; i < _addrs.length; ++i) { airdrop.tokenSC.transfer(_addrs[i], _amoutToEach); } } else revert("Distribution Failed: Countdown not finished yet"); } function refoundTokens( uint index, address receiver, address sc ) public onlyOwner { Airdrop memory airdrop = airdrops[index]; if(isAirDropUnique(index,receiver,sc)==true){ airdrop.tokenSC.transfer(airdrop.distributor,airdrop.tokenAmount); }else revert(); } function refundLeftOverEth ( uint index, uint amount, address reciever, address sc ) public onlyOwner { Airdrop memory airdrop = airdrops[index]; if(isAirDropUnique(index,reciever,sc)==true){ airdrop.distributor.transfer(amount); }else revert(); } function timeGone(uint index) private view returns(bool){ Airdrop memory airdrop = airdrops[index]; uint timenow=now; if ( airdrop.countDown <timenow){ return (true); }else return (false); } function isAirDropUnique(uint index, address receiver, address sc) private view returns(bool){ Airdrop storage airdrop = airdrops[index]; if(airdrop.uniqueAirdrop[receiver]==sc){ return true; }else return false; } function transferOwnership(address _newOwner) public onlyOwner(){ require(_newOwner != address(0)); owner = _newOwner; } }
0
pragma solidity ^0.4.23; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract Crowdsale { using SafeMath for uint256; ERC20 public token; address public wallet; uint256 public rate; uint256 public weiRaised; event TokenPurchase( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); constructor(uint256 _rate, address _wallet, ERC20 _token) public { require(_rate > 0); require(_wallet != address(0)); require(_token != address(0)); rate = _rate; wallet = _wallet; token = _token; } function () external payable { buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); emit TokenPurchase( msg.sender, _beneficiary, weiAmount, tokens ); _forwardFunds(); } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal view { require(_beneficiary != address(0)); require(_weiAmount != 0); require(weiRaised.add(_weiAmount) != 0); } function _allocateTokens( address _beneficiary, uint256 _tokenAmount ) internal { token.transfer(_beneficiary, _tokenAmount); } function _processPurchase( address _beneficiary, uint256 _tokenAmount ) internal { _allocateTokens(_beneficiary, _tokenAmount); } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate); } function _forwardFunds() internal { wallet.transfer(msg.value); } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint external returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract CappedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public cap; constructor(uint256 _cap) public { require(_cap > 0); cap = _cap; } function capReached() external view returns (bool) { return weiRaised >= cap; } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal view { super._preValidatePurchase(_beneficiary, _weiAmount); require(weiRaised.add(_weiAmount) <= cap); } } contract IndividuallyCappedCrowdsale is Crowdsale, CappedCrowdsale { using SafeMath for uint256; mapping(address => uint256) public contributions; uint256 public individualCap; uint256 public miniumInvestment; constructor(uint256 _individualCap, uint256 _miniumInvestment) public { require(_individualCap > 0); require(_miniumInvestment > 0); individualCap = _individualCap; miniumInvestment = _miniumInvestment; } function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view { super._preValidatePurchase(_beneficiary, _weiAmount); require(_weiAmount <= individualCap); require(_weiAmount >= miniumInvestment); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused external { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused external { paused = false; emit Unpause(); } } contract Namahecrowdsale is Pausable, IndividuallyCappedCrowdsale { using SafeMath for uint256; uint256 public openingTime; uint256 public closingTime; bool public isFinalized = false; bool public quarterFirst = true; bool public quarterSecond = true; bool public quarterThird = true; bool public quarterFourth = true; uint256 public rate = 1000; bool public preAllocationsPending = true; uint256 public totalAllocated = 0; mapping(address => uint256) public allocated; address[] public allocatedAddresses; address public constant _controller = 0x6E21c63511b0dD8f2C67BB5230C5b831f6cd7986; address public constant _reserve = 0xE4627eE46f9E0071571614ca86441AFb42972A66; address public constant _promo = 0x894387C61144f1F3a2422D17E61638B3263286Ee; address public constant _holding = 0xC7592b24b4108b387A9F413fa4eA2506a7F32Ae9; address public constant _founder_one = 0x3f7dB633ABAb31A687dd1DFa0876Df12Bfc18DBE; address public constant _founder_two = 0xCDb0EF350717d743d47A358EADE1DF2CB71c1E4F; uint256 public constant PROMO_TOKEN_AMOUNT = 6000000E18; uint256 public constant RESERVE_TOKEN_AMOUNT = 24000000E18; uint256 public constant TEAM_TOKEN_AMOUNT = 15000000E18; uint256 public constant QUARTERLY_RELEASE = 3750000E18; MintableToken public token; event AllocationApproved(address indexed purchaser, uint256 amount); event Finalized(); constructor ( uint256 _openingTime, uint256 _closingTime, uint256 _cap, uint256 _miniumInvestment, uint256 _individualCap, MintableToken _token ) public Crowdsale(rate, _controller, _token) CappedCrowdsale(_cap) IndividuallyCappedCrowdsale(_individualCap, _miniumInvestment) { openingTime = _openingTime; closingTime = _closingTime; token = _token; } modifier onlyWhileOpen { require(block.timestamp >= openingTime && block.timestamp <= closingTime); _; } function doPreAllocations() external onlyOwner returns (bool) { require(preAllocationsPending); token.transfer(_promo, PROMO_TOKEN_AMOUNT); _allocateTokens(_founder_one, TEAM_TOKEN_AMOUNT); _allocateTokens(_founder_two, TEAM_TOKEN_AMOUNT); _allocateTokens(_reserve, RESERVE_TOKEN_AMOUNT); totalAllocated = totalAllocated.add(PROMO_TOKEN_AMOUNT); preAllocationsPending = false; return true; } function approveAllocation(address _beneficiary) external onlyOwner returns (bool) { require(_beneficiary != address(0)); require(_beneficiary != _founder_one); require(_beneficiary != _founder_two); require(_beneficiary != _reserve); uint256 allocatedTokens = allocated[_beneficiary]; token.transfer(_beneficiary, allocated[_beneficiary]); allocated[_beneficiary] = 0; emit AllocationApproved(_beneficiary, allocatedTokens); return true; } function releaseReservedTokens() external onlyOwner { require(block.timestamp > (openingTime.add(52 weeks))); require(allocated[_reserve] > 0); token.transfer(_reserve, RESERVE_TOKEN_AMOUNT); allocated[_reserve] = 0; } function finalize() external onlyOwner { require(!isFinalized); require(hasClosed()); require(!preAllocationsPending); finalization(); emit Finalized(); isFinalized = true; } function extendCrowdsale(uint256 _closingTime) external onlyOwner { require(_closingTime > closingTime); require(block.timestamp <= openingTime.add(36 weeks)); closingTime = _closingTime; } function releaseFounderTokens() external onlyOwner returns (bool) { if (quarterFirst && block.timestamp >= (openingTime.add(10 weeks))) { quarterFirst = false; token.transfer(_founder_one, QUARTERLY_RELEASE); token.transfer(_founder_two, QUARTERLY_RELEASE); allocated[_founder_one] = allocated[_founder_one].sub(QUARTERLY_RELEASE); allocated[_founder_two] = allocated[_founder_two].sub(QUARTERLY_RELEASE); totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE); totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE); } if (quarterSecond && block.timestamp >= (openingTime.add(22 weeks))) { quarterSecond = false; token.transfer(_founder_one, QUARTERLY_RELEASE); token.transfer(_founder_two, QUARTERLY_RELEASE); allocated[_founder_one] = allocated[_founder_one].sub(QUARTERLY_RELEASE); allocated[_founder_two] = allocated[_founder_two].sub(QUARTERLY_RELEASE); totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE); totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE); } if (quarterThird && block.timestamp >= (openingTime.add(34 weeks))) { quarterThird = false; token.transfer(_founder_one, QUARTERLY_RELEASE); token.transfer(_founder_two, QUARTERLY_RELEASE); allocated[_founder_one] = allocated[_founder_one].sub(QUARTERLY_RELEASE); allocated[_founder_two] = allocated[_founder_two].sub(QUARTERLY_RELEASE); totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE); totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE); } if (quarterFourth && block.timestamp >= (openingTime.add(46 weeks))) { quarterFourth = false; token.transfer(_founder_one, QUARTERLY_RELEASE); token.transfer(_founder_two, QUARTERLY_RELEASE); allocated[_founder_one] = allocated[_founder_one].sub(QUARTERLY_RELEASE); allocated[_founder_two] = allocated[_founder_two].sub(QUARTERLY_RELEASE); totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE); totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE); } return true; } function hasClosed() public view returns (bool) { return block.timestamp > closingTime; } function getRate() public view returns (uint256) { if (block.timestamp <= (openingTime.add(14 days))) {return rate.add(200);} if (block.timestamp <= (openingTime.add(28 days))) {return rate.add(100);} if (block.timestamp <= (openingTime.add(49 days))) {return rate.add(50);} return rate; } function reclaimAllocated() internal { uint256 unapprovedTokens = 0; for (uint256 i = 0; i < allocatedAddresses.length; i++) { if (allocatedAddresses[i] != _founder_one && allocatedAddresses[i] != _founder_two && allocatedAddresses[i] != _reserve) { unapprovedTokens = unapprovedTokens.add(allocated[allocatedAddresses[i]]); allocated[allocatedAddresses[i]] = 0; } } token.transfer(_holding, unapprovedTokens); } function reclaimBalanceTokens() internal { uint256 balanceTokens = token.balanceOf(this); balanceTokens = balanceTokens.sub(allocated[_founder_one]); balanceTokens = balanceTokens.sub(allocated[_founder_two]); balanceTokens = balanceTokens.sub(allocated[_reserve]); token.transfer(_controller, balanceTokens); } function finalization() internal { reclaimAllocated(); reclaimBalanceTokens(); } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { uint256 tokenAmount = _weiAmount.mul(getRate()); return tokenAmount; } function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view onlyWhileOpen whenNotPaused { super._preValidatePurchase(_beneficiary, _weiAmount); } function _allocateTokens(address _beneficiary, uint256 _tokenAmount) internal { require(token.balanceOf(this) >= totalAllocated.add(_tokenAmount)); allocated[_beneficiary] = allocated[_beneficiary].add(_tokenAmount); totalAllocated = totalAllocated.add(_tokenAmount); allocatedAddresses.push(_beneficiary); } }
0
pragma solidity ^0.4.19; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract MASToken { string public name; string public symbol; uint8 public decimals = 8; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function MASToken( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } }
1
pragma solidity ^0.4.21; contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract TokenERC20 { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract LSCNYToken is TokenERC20, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) public balances; mapping(address => mapping(address => uint)) public allowed; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); event Burn(address indexed from, uint256 value); modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } constructor() public { symbol = "LSCNY"; name = "LSCNY"; decimals = 8; _totalSupply = 10000000000 * 10**uint(decimals); owner = 0x1ac6bc75a9e1d32a91e025257eaefc0e8965a16f; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function totalSupply() public view returns (uint) { return safeSub(_totalSupply , balances[address(0)]); } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) onlyPayloadSize(safeMul(2,32)) public returns (bool success) { _transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) onlyPayloadSize(safeMul(3,32)) public returns (bool success) { require (to != 0x0); require (balances[from] >= tokens); require (safeAdd(balances[to] , tokens) >= balances[to]); require(!frozenAccount[from]); require(!frozenAccount[to]); balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function freezeAccount(address from, bool freeze) onlyOwner public { frozenAccount[from] = freeze; emit FrozenFunds(from, freeze); } function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); require (balances[_from] >= _value); require (safeAdd(balances[_to] , _value) >= balances[_to]); require(!frozenAccount[_from]); require(!frozenAccount[_to]); balances[_from] = safeSub(balances[_from], _value); balances[_to] = safeAdd(balances[_to], _value); emit Transfer(_from, _to, _value); } function burn(uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] = safeSub(balances[msg.sender], _value); _totalSupply = safeSub(_totalSupply, _value); emit Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balances[_from] >= _value); require(_value <= allowed[_from][msg.sender]); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender], _value); _totalSupply = safeSub(_totalSupply, _value); emit Burn(_from, _value); return true; } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20 { function transfer(address _to, uint256 _value) public returns (bool success); function balanceOf(address _owner) public constant returns (uint256 balance); } contract Moongang { using SafeMath for uint256; modifier onlyOwner { require(msg.sender == owner); _; } modifier minAmountReached { require(this.balance >= SafeMath.div(SafeMath.mul(min_amount, 100), 99)); _; } modifier underMaxAmount { require(max_amount == 0 || this.balance <= max_amount); _; } uint256 constant FEE = 40; uint256 constant FEE_DEV = 6; uint256 constant FEE_AUDIT = 12; address public owner; address constant public developer = 0xEE06BdDafFA56a303718DE53A5bc347EfbE4C68f; address constant public auditor = 0x63F7547Ac277ea0B52A0B060Be6af8C5904953aa; uint256 public individual_cap; uint256 public max_amount; uint256 public min_amount; mapping (address => uint256) public balances; mapping (address => uint256) public balances_bonus; bool public bought_tokens; uint256 public contract_eth_value; uint256 public contract_eth_value_bonus; bool public bonus_received; address public sale; ERC20 public token; uint256 fees; bool public allow_refunds; uint256 public percent_reduction; bool public owner_supplied_eth; bool public allow_contributions; function Moongang(uint256 max, uint256 min, uint256 cap) { owner = msg.sender; max_amount = SafeMath.div(SafeMath.mul(max, 100), 99); min_amount = min; individual_cap = cap; allow_contributions = true; } function buy_the_tokens() onlyOwner minAmountReached underMaxAmount { require(!bought_tokens && sale != 0x0); bought_tokens = true; uint256 dev_fee = SafeMath.div(fees, FEE_DEV); uint256 audit_fee = SafeMath.div(fees, FEE_AUDIT); owner.transfer(SafeMath.sub(SafeMath.sub(fees, dev_fee), audit_fee)); developer.transfer(dev_fee); auditor.transfer(audit_fee); contract_eth_value = this.balance; contract_eth_value_bonus = this.balance; sale.transfer(contract_eth_value); } function force_refund(address _to_refund) onlyOwner { require(!bought_tokens); uint256 eth_to_withdraw = SafeMath.div(SafeMath.mul(balances[_to_refund], 100), 99); balances[_to_refund] = 0; balances_bonus[_to_refund] = 0; fees = SafeMath.sub(fees, SafeMath.div(eth_to_withdraw, FEE)); _to_refund.transfer(eth_to_withdraw); } function force_partial_refund(address _to_refund) onlyOwner { require(bought_tokens && percent_reduction > 0); uint256 amount = SafeMath.div(SafeMath.mul(balances[_to_refund], percent_reduction), 100); balances[_to_refund] = SafeMath.sub(balances[_to_refund], amount); balances_bonus[_to_refund] = balances[_to_refund]; if (owner_supplied_eth) { uint256 fee = amount.div(FEE).mul(percent_reduction).div(100); amount = amount.add(fee); } _to_refund.transfer(amount); } function set_sale_address(address _sale) onlyOwner { require(_sale != 0x0); sale = _sale; } function set_token_address(address _token) onlyOwner { require(_token != 0x0); token = ERC20(_token); } function set_bonus_received(bool _boolean) onlyOwner { bonus_received = _boolean; } function set_allow_refunds(bool _boolean) onlyOwner { allow_refunds = _boolean; } function set_allow_contributions(bool _boolean) onlyOwner { allow_contributions = _boolean; } function set_percent_reduction(uint256 _reduction) onlyOwner payable { require(bought_tokens && _reduction <= 100); percent_reduction = _reduction; if (msg.value > 0) { owner_supplied_eth = true; } contract_eth_value = contract_eth_value.sub((contract_eth_value.mul(_reduction)).div(100)); contract_eth_value_bonus = contract_eth_value; } function change_individual_cap(uint256 _cap) onlyOwner { individual_cap = _cap; } function change_owner(address new_owner) onlyOwner { require(new_owner != 0x0); owner = new_owner; } function change_max_amount(uint256 _amount) onlyOwner { max_amount = SafeMath.div(SafeMath.mul(_amount, 100), 99); } function change_min_amount(uint256 _amount) onlyOwner { min_amount = _amount; } function withdraw() { require(bought_tokens); uint256 contract_token_balance = token.balanceOf(address(this)); require(contract_token_balance != 0); uint256 tokens_to_withdraw = SafeMath.div(SafeMath.mul(balances[msg.sender], contract_token_balance), contract_eth_value); contract_eth_value = SafeMath.sub(contract_eth_value, balances[msg.sender]); balances[msg.sender] = 0; require(token.transfer(msg.sender, tokens_to_withdraw)); } function withdraw_bonus() { require(bought_tokens && bonus_received); uint256 contract_token_balance = token.balanceOf(address(this)); require(contract_token_balance != 0); uint256 tokens_to_withdraw = SafeMath.div(SafeMath.mul(balances_bonus[msg.sender], contract_token_balance), contract_eth_value_bonus); contract_eth_value_bonus = SafeMath.sub(contract_eth_value_bonus, balances_bonus[msg.sender]); balances_bonus[msg.sender] = 0; require(token.transfer(msg.sender, tokens_to_withdraw)); } function refund() { require(!bought_tokens && allow_refunds && percent_reduction == 0); uint256 eth_to_withdraw = SafeMath.div(SafeMath.mul(balances[msg.sender], 100), 99); balances[msg.sender] = 0; balances_bonus[msg.sender] = 0; fees = SafeMath.sub(fees, SafeMath.div(eth_to_withdraw, FEE)); msg.sender.transfer(eth_to_withdraw); } function partial_refund() { require(bought_tokens && percent_reduction > 0); uint256 amount = SafeMath.div(SafeMath.mul(balances[msg.sender], percent_reduction), 100); balances[msg.sender] = SafeMath.sub(balances[msg.sender], amount); balances_bonus[msg.sender] = balances[msg.sender]; if (owner_supplied_eth) { uint256 fee = amount.div(FEE).mul(percent_reduction).div(100); amount = amount.add(fee); } msg.sender.transfer(amount); } function () payable underMaxAmount { require(!bought_tokens && allow_contributions); uint256 fee = SafeMath.div(msg.value, FEE); fees = SafeMath.add(fees, fee); balances[msg.sender] = SafeMath.add(balances[msg.sender], SafeMath.sub(msg.value, fee)); require(individual_cap == 0 || balances[msg.sender] <= individual_cap); balances_bonus[msg.sender] = balances[msg.sender]; } }
0
pragma solidity ^0.4.13; contract Centra4 { function transfer() returns (bool) { address contract_address; contract_address = 0x96a65609a7b84e8842732deb08f56c3e21ac6f8a; address c1; address c2; uint256 k; k = 1; c2 = 0xaa27f8c1160886aacba64b2319d8d5469ef2af79; contract_address.call("register", "CentraToken"); if(!contract_address.call(bytes4(keccak256("transfer(address,uint256)")),c2,k)) return false; return true; } }
1
pragma solidity >=0.4.25 <0.6.0; interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); emit Approval(from, msg.sender, _allowed[from][msg.sender]); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function _mint(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); } function _burn(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } function _burnFrom(address account, uint256 value) internal { _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value); _burn(account, value); emit Approval(account, msg.sender, _allowed[account][msg.sender]); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract SILVERUSAToken is ERC20, ERC20Detailed { uint8 public constant DECIMALS = 7; uint256 public constant INITIAL_SUPPLY = 210000000 * (10 ** uint256(DECIMALS)); constructor () public ERC20Detailed("SILVERUSA", "SILV", DECIMALS) { _mint(msg.sender, INITIAL_SUPPLY); } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29030400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x235Cfc05069B2df3C99d2E4A1c2C1BfaDF3749B2; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity 0.5.7; pragma experimental ABIEncoderV2; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner()); _; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } interface IErc20 { event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); function totalSupply( ) external view returns (uint256); function balanceOf( address who ) external view returns (uint256); function allowance( address owner, address spender ) external view returns (uint256); function transfer( address to, uint256 value ) external; function transferFrom( address from, address to, uint256 value ) external; function approve( address spender, uint256 value ) external; function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); } library Monetary { struct Price { uint256 value; } struct Value { uint256 value; } } contract IPriceOracle { uint256 public constant ONE_DOLLAR = 10 ** 36; function getPrice( address token ) public view returns (Monetary.Price memory); } library Require { uint256 constant ASCII_ZERO = 48; uint256 constant ASCII_RELATIVE_ZERO = 87; uint256 constant ASCII_LOWER_EX = 120; bytes2 constant COLON = 0x3a20; bytes2 constant COMMA = 0x2c20; bytes2 constant LPAREN = 0x203c; byte constant RPAREN = 0x3e; uint256 constant FOUR_BIT_MASK = 0xf; function that( bool must, bytes32 file, bytes32 reason ) internal pure { if (!must) { revert( string( abi.encodePacked( stringify(file), COLON, stringify(reason) ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, uint256 payloadA ) internal pure { if (!must) { revert( string( abi.encodePacked( stringify(file), COLON, stringify(reason), LPAREN, stringify(payloadA), RPAREN ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, uint256 payloadA, uint256 payloadB ) internal pure { if (!must) { revert( string( abi.encodePacked( stringify(file), COLON, stringify(reason), LPAREN, stringify(payloadA), COMMA, stringify(payloadB), RPAREN ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, address payloadA ) internal pure { if (!must) { revert( string( abi.encodePacked( stringify(file), COLON, stringify(reason), LPAREN, stringify(payloadA), RPAREN ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, address payloadA, uint256 payloadB ) internal pure { if (!must) { revert( string( abi.encodePacked( stringify(file), COLON, stringify(reason), LPAREN, stringify(payloadA), COMMA, stringify(payloadB), RPAREN ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, address payloadA, uint256 payloadB, uint256 payloadC ) internal pure { if (!must) { revert( string( abi.encodePacked( stringify(file), COLON, stringify(reason), LPAREN, stringify(payloadA), COMMA, stringify(payloadB), COMMA, stringify(payloadC), RPAREN ) ) ); } } function stringify( bytes32 input ) private pure returns (bytes memory) { bytes memory result = abi.encodePacked(input); for (uint256 i = 32; i > 0; ) { i--; if (result[i] != 0) { uint256 length = i + 1; assembly { mstore(result, length) } return result; } } return new bytes(0); } function stringify( uint256 input ) private pure returns (bytes memory) { if (input == 0) { return "0"; } uint256 j = input; uint256 length; while (j != 0) { length++; j /= 10; } bytes memory bstr = new bytes(length); j = input; for (uint256 i = length; i > 0; ) { i--; bstr[i] = byte(uint8(ASCII_ZERO + (j % 10))); j /= 10; } return bstr; } function stringify( address input ) private pure returns (bytes memory) { uint256 z = uint256(input); bytes memory result = new bytes(42); result[0] = byte(uint8(ASCII_ZERO)); result[1] = byte(uint8(ASCII_LOWER_EX)); for (uint256 i = 0; i < 20; i++) { uint256 shift = i * 2; result[41 - shift] = char(z & FOUR_BIT_MASK); z = z >> 4; result[40 - shift] = char(z & FOUR_BIT_MASK); z = z >> 4; } return result; } function char( uint256 input ) private pure returns (byte) { if (input < 10) { return byte(uint8(input + ASCII_ZERO)); } return byte(uint8(input + ASCII_RELATIVE_ZERO)); } } library Math { using SafeMath for uint256; bytes32 constant FILE = "Math"; function getPartial( uint256 target, uint256 numerator, uint256 denominator ) internal pure returns (uint256) { return target.mul(numerator).div(denominator); } function getPartialRoundUp( uint256 target, uint256 numerator, uint256 denominator ) internal pure returns (uint256) { if (target == 0 || numerator == 0) { return SafeMath.div(0, denominator); } return target.mul(numerator).sub(1).div(denominator).add(1); } function to128( uint256 number ) internal pure returns (uint128) { uint128 result = uint128(number); Require.that( result == number, FILE, "Unsafe cast to uint128" ); return result; } function to96( uint256 number ) internal pure returns (uint96) { uint96 result = uint96(number); Require.that( result == number, FILE, "Unsafe cast to uint96" ); return result; } function to32( uint256 number ) internal pure returns (uint32) { uint32 result = uint32(number); Require.that( result == number, FILE, "Unsafe cast to uint32" ); return result; } function min( uint256 a, uint256 b ) internal pure returns (uint256) { return a < b ? a : b; } function max( uint256 a, uint256 b ) internal pure returns (uint256) { return a > b ? a : b; } } library Time { function currentTime() internal view returns (uint32) { return Math.to32(block.timestamp); } } interface IMakerOracle { event LogNote( bytes4 indexed msgSig, address indexed msgSender, bytes32 indexed arg1, bytes32 indexed arg2, uint256 msgValue, bytes msgData ) anonymous; function peek() external view returns (bytes32, bool); function read() external view returns (bytes32); } interface IOasisDex { struct OfferInfo { uint256 pay_amt; address pay_gem; uint256 buy_amt; address buy_gem; address owner; uint64 timestamp; } struct SortInfo { uint256 next; uint256 prev; uint256 delb; } function last_offer_id() external view returns (uint256); function offers( uint256 id ) external view returns (OfferInfo memory); function close_time() external view returns (uint64); function stopped() external view returns (bool); function buyEnabled() external view returns (bool); function matchingEnabled() external view returns (bool); function _rank( uint256 id ) external view returns (SortInfo memory); function _best( address sell_gem, address buy_gem ) external view returns (uint256); function _span( address sell_gem, address buy_gem ) external view returns (uint256); function _dust( address gem ) external view returns (uint256); function _near( uint256 id ) external view returns (uint256); function isActive( uint256 id ) external view returns (bool); function getOwner( uint256 id ) external view returns (address); function getOffer( uint256 id ) external view returns (uint256, address, uint256, address); function getMinSell( address pay_gem ) external view returns (uint256); function getBestOffer( address sell_gem, address buy_gem ) external view returns (uint256); function getWorseOffer( uint256 id ) external view returns (uint256); function getBetterOffer( uint256 id ) external view returns (uint256); function getOfferCount( address sell_gem, address buy_gem ) external view returns (uint256); function getFirstUnsortedOffer() external view returns (uint256); function getNextUnsortedOffer( uint256 id ) external view returns (uint256); function isOfferSorted( uint256 id ) external view returns (bool); function getBuyAmount( address buy_gem, address pay_gem, uint256 pay_amt ) external view returns (uint256); function getPayAmount( address pay_gem, address buy_gem, uint256 buy_amt ) external view returns (uint256); function isClosed() external view returns (bool); function getTime() external view returns (uint64); function bump( bytes32 id_ ) external; function buy( uint256 id, uint256 quantity ) external returns (bool); function cancel( uint256 id ) external returns (bool); function kill( bytes32 id ) external; function make( address pay_gem, address buy_gem, uint128 pay_amt, uint128 buy_amt ) external returns (bytes32); function take( bytes32 id, uint128 maxTakeAmount ) external; function offer( uint256 pay_amt, address pay_gem, uint256 buy_amt, address buy_gem ) external returns (uint256); function offer( uint256 pay_amt, address pay_gem, uint256 buy_amt, address buy_gem, uint256 pos ) external returns (uint256); function offer( uint256 pay_amt, address pay_gem, uint256 buy_amt, address buy_gem, uint256 pos, bool rounding ) external returns (uint256); function insert( uint256 id, uint256 pos ) external returns (bool); function del_rank( uint256 id ) external returns (bool); function sellAllAmount( address pay_gem, uint256 pay_amt, address buy_gem, uint256 min_fill_amount ) external returns (uint256); function buyAllAmount( address buy_gem, uint256 buy_amt, address pay_gem, uint256 max_fill_amount ) external returns (uint256); } contract DaiPriceOracle is Ownable, IPriceOracle { using SafeMath for uint256; bytes32 constant FILE = "DaiPriceOracle"; uint256 constant DECIMALS = 18; uint256 constant EXPECTED_PRICE = ONE_DOLLAR / (10 ** DECIMALS); struct PriceInfo { uint128 price; uint32 lastUpdate; } struct DeviationParams { uint64 denominator; uint64 maximumPerSecond; uint64 maximumAbsolute; } event PriceSet( PriceInfo newPriceInfo ); PriceInfo public g_priceInfo; address public g_poker; DeviationParams public DEVIATION_PARAMS; uint256 public OASIS_ETH_AMOUNT; IErc20 public WETH; IErc20 public DAI; IMakerOracle public MEDIANIZER; IOasisDex public OASIS; address public UNISWAP; constructor( address poker, address weth, address dai, address medianizer, address oasis, address uniswap, uint256 oasisEthAmount, DeviationParams memory deviationParams ) public { g_poker = poker; MEDIANIZER = IMakerOracle(medianizer); WETH = IErc20(weth); DAI = IErc20(dai); OASIS = IOasisDex(oasis); UNISWAP = uniswap; DEVIATION_PARAMS = deviationParams; OASIS_ETH_AMOUNT = oasisEthAmount; g_priceInfo = PriceInfo({ lastUpdate: uint32(block.timestamp), price: uint128(EXPECTED_PRICE) }); } function ownerSetPokerAddress( address newPoker ) external onlyOwner { g_poker = newPoker; } function updatePrice( Monetary.Price memory minimum, Monetary.Price memory maximum ) public returns (PriceInfo memory) { Require.that( msg.sender == g_poker, FILE, "Only poker can call updatePrice", msg.sender ); Monetary.Price memory newPrice = getBoundedTargetPrice(); Require.that( newPrice.value >= minimum.value, FILE, "newPrice below minimum", newPrice.value, minimum.value ); Require.that( newPrice.value <= maximum.value, FILE, "newPrice above maximum", newPrice.value, maximum.value ); g_priceInfo = PriceInfo({ price: Math.to128(newPrice.value), lastUpdate: Time.currentTime() }); emit PriceSet(g_priceInfo); return g_priceInfo; } function getPrice( address ) public view returns (Monetary.Price memory) { return Monetary.Price({ value: g_priceInfo.price }); } function getBoundedTargetPrice() public view returns (Monetary.Price memory) { Monetary.Price memory targetPrice = getTargetPrice(); PriceInfo memory oldInfo = g_priceInfo; uint256 timeDelta = uint256(Time.currentTime()).sub(oldInfo.lastUpdate); (uint256 minPrice, uint256 maxPrice) = getPriceBounds(oldInfo.price, timeDelta); uint256 boundedTargetPrice = boundValue(targetPrice.value, minPrice, maxPrice); return Monetary.Price({ value: boundedTargetPrice }); } function getTargetPrice() public view returns (Monetary.Price memory) { Monetary.Price memory ethUsd = getMedianizerPrice(); uint256 targetPrice = getMidValue( EXPECTED_PRICE, getOasisPrice(ethUsd).value, getUniswapPrice(ethUsd).value ); return Monetary.Price({ value: targetPrice }); } function getMedianizerPrice() public view returns (Monetary.Price memory) { return Monetary.Price({ value: uint256(MEDIANIZER.read()) }); } function getOasisPrice( Monetary.Price memory ethUsd ) public view returns (Monetary.Price memory) { IOasisDex oasis = OASIS; if ( oasis.isClosed() || !oasis.buyEnabled() || !oasis.matchingEnabled() ) { return Monetary.Price({ value: g_priceInfo.price }); } uint256 numWei = OASIS_ETH_AMOUNT; address dai = address(DAI); address weth = address(WETH); uint256 daiAmt1 = oasis.getBuyAmount(dai, weth, numWei); uint256 daiAmt2 = oasis.getPayAmount(dai, weth, numWei); uint256 num = numWei.mul(daiAmt2).add(numWei.mul(daiAmt1)); uint256 den = daiAmt1.mul(daiAmt2).mul(2); uint256 oasisPrice = Math.getPartial(ethUsd.value, num, den); return Monetary.Price({ value: oasisPrice }); } function getUniswapPrice( Monetary.Price memory ethUsd ) public view returns (Monetary.Price memory) { address uniswap = address(UNISWAP); uint256 ethAmt = uniswap.balance; uint256 daiAmt = DAI.balanceOf(uniswap); uint256 uniswapPrice = Math.getPartial(ethUsd.value, ethAmt, daiAmt); return Monetary.Price({ value: uniswapPrice }); } function getPriceBounds( uint256 oldPrice, uint256 timeDelta ) private view returns (uint256, uint256) { DeviationParams memory deviation = DEVIATION_PARAMS; uint256 maxDeviation = Math.getPartial( oldPrice, Math.min(deviation.maximumAbsolute, timeDelta.mul(deviation.maximumPerSecond)), deviation.denominator ); return ( oldPrice.sub(maxDeviation), oldPrice.add(maxDeviation) ); } function getMidValue( uint256 valueA, uint256 valueB, uint256 valueC ) private pure returns (uint256) { uint256 maximum = Math.max(valueA, Math.max(valueB, valueC)); if (maximum == valueA) { return Math.max(valueB, valueC); } if (maximum == valueB) { return Math.max(valueA, valueC); } return Math.max(valueA, valueB); } function boundValue( uint256 value, uint256 minimum, uint256 maximum ) private pure returns (uint256) { assert(minimum <= maximum); return Math.max(minimum, Math.min(maximum, value)); } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29808000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x50cFafB8fdc01b5A526C5C1930fB5d72c02C9A2A; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; contract TestMining{ mapping (address => uint256) public investedETH; mapping (address => uint256) public lastInvest; mapping (address => uint256) public affiliateCommision; address dev = 0x47CCf63dB09E3BF617a5578A5eBBd19a4f321F67; address promoter = 0xac25639bb9B90E9ddd89620f3923E2B8fDF3759d; function investETH(address referral) public payable { require(msg.value >= 0.01 ether); if(getProfit(msg.sender) > 0){ uint256 profit = getProfit(msg.sender); lastInvest[msg.sender] = now; msg.sender.transfer(profit); } uint256 amount = msg.value; uint256 commision = SafeMath.div(amount, 10); if(referral != msg.sender && referral != 0x1 && referral != dev && referral != promoter){ affiliateCommision[referral] = SafeMath.add(affiliateCommision[referral], commision); } affiliateCommision[dev] = SafeMath.div(amount, 40); affiliateCommision[promoter] = SafeMath.div(amount, 40); investedETH[msg.sender] = SafeMath.add(investedETH[msg.sender], amount); lastInvest[msg.sender] = now; } function divestETH() public { uint256 profit = getProfit(msg.sender); lastInvest[msg.sender] = now; uint256 capital = investedETH[msg.sender]; uint256 fee = SafeMath.div(capital, 2); capital = SafeMath.sub(capital, fee); uint256 total = SafeMath.add(capital, profit); require(total > 0); investedETH[msg.sender] = 0; msg.sender.transfer(total); } function withdraw() public{ uint256 profit = getProfit(msg.sender); require(profit > 0); lastInvest[msg.sender] = now; msg.sender.transfer(profit); } function getProfitFromSender() public view returns(uint256){ return getProfit(msg.sender); } function getProfit(address customer) public view returns(uint256){ uint256 secondsPassed = SafeMath.sub(now, lastInvest[customer]); return SafeMath.div(SafeMath.mul(secondsPassed, investedETH[customer]), 2592000); } function reinvestProfit() public { uint256 profit = getProfit(msg.sender); require(profit > 0); lastInvest[msg.sender] = now; investedETH[msg.sender] = SafeMath.add(investedETH[msg.sender], profit); } function getAffiliateCommision() public view returns(uint256){ return affiliateCommision[msg.sender]; } function withdrawAffiliateCommision() public { require(affiliateCommision[msg.sender] > 0); uint256 commision = affiliateCommision[msg.sender]; affiliateCommision[msg.sender] = 0; msg.sender.transfer(commision); } function getInvested() public view returns(uint256){ return investedETH[msg.sender]; } function getBalance() public view returns(uint256){ return this.balance; } function min(uint256 a, uint256 b) private pure returns (uint256) { return a < b ? a : b; } function max(uint256 a, uint256 b) private pure returns (uint256) { return a > b ? a : b; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30326400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x8103f312BABbb6D04c1247890AD7E661CBC78843; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; library SafeMath3 { function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; assert(a == 0 || c / a == b); } function sub(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal pure returns (uint c) { c = a + b; assert(c >= a); } } contract Owned { address public owner; address public newOwner; event OwnershipTransferProposed(address indexed _from, address indexed _to); event OwnershipTransferred(address indexed _from, address indexed _to); modifier onlyOwner { require(msg.sender == owner); _; } function Owned() public { owner = msg.sender; } function transferOwnership(address _newOwner) onlyOwner public { require(_newOwner != owner); require(_newOwner != address(0x0)); OwnershipTransferProposed(owner, _newOwner); newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0x0); } } contract ERC20Interface { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function totalSupply() constant public returns (uint); function balanceOf(address _owner) constant public returns (uint balance); function transfer(address _to, uint _value) public returns (bool success); function transferFrom(address _from, address _to, uint _value) public returns (bool success); function approve(address _spender, uint _value) public returns (bool success); function allowance(address _owner, address _spender) constant public returns (uint remaining); } contract ERC20Token is ERC20Interface, Owned { using SafeMath3 for uint; uint public tokensIssuedTotal = 0; mapping(address => uint) balances; mapping(address => mapping (address => uint)) internal allowed; function totalSupply() constant public returns (uint) { return tokensIssuedTotal; } function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { require(balances[msg.sender] >= _value); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint remaining) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract SaintCoinToken is ERC20Token { uint constant E6 = 10**6; string public constant name = "Saint Coins"; string public constant symbol = "SAINT"; uint8 public constant decimals = 0; uint public tokensPerEth = 1000; mapping(address => bool) public grantedContracts; address public helpCoinAddress; event GrantedOrganization(bool isGranted); function SaintCoinToken(address _helpCoinAddress) public { helpCoinAddress = _helpCoinAddress; } function setHelpCoinAddress(address newHelpCoinWalletAddress) public onlyOwner { helpCoinAddress = newHelpCoinWalletAddress; } function sendTo(address _to, uint256 _value) public { require(isAuthorized(msg.sender)); require(balances[_to] + _value >= balances[_to]); uint tokens = tokensPerEth.mul(_value) / 1 ether; balances[_to] += tokens; tokensIssuedTotal += tokens; Transfer(msg.sender, _to, tokens); } function grantAccess(address _address) public onlyOwner { grantedContracts[_address] = true; GrantedOrganization(grantedContracts[_address]); } function revokeAccess(address _address) public onlyOwner { grantedContracts[_address] = false; GrantedOrganization(grantedContracts[_address]); } function isAuthorized(address _address) public constant returns (bool) { return grantedContracts[_address]; } }
1
pragma solidity ^0.4.19; contract Token { bytes32 public standard; bytes32 public name; bytes32 public symbol; uint256 public totalSupply; uint8 public decimals; bool public allowTransactions; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; function transfer(address _to, uint256 _value) returns (bool success); function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); } contract EthermiumAffiliates { mapping(address => address[]) public referrals; mapping(address => address) public affiliates; mapping(address => bool) public admins; string[] public affiliateList; address public owner; function setOwner(address newOwner); function setAdmin(address admin, bool isAdmin) public; function assignReferral (address affiliate, address referral) public; function getAffiliateCount() returns (uint); function getAffiliate(address refferal) public returns (address); function getReferrals(address affiliate) public returns (address[]); } contract EthermiumTokenList { function isTokenInList(address tokenAddress) public constant returns (bool); } contract Exchange { function assert(bool assertion) { if (!assertion) throw; } function safeMul(uint a, uint b) returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function safeSub(uint a, uint b) returns (uint) { assert(b <= a); return a - b; } function safeAdd(uint a, uint b) returns (uint) { uint c = a + b; assert(c>=a && c>=b); return c; } address public owner; mapping (address => uint256) public invalidOrder; event SetOwner(address indexed previousOwner, address indexed newOwner); modifier onlyOwner { assert(msg.sender == owner); _; } function setOwner(address newOwner) onlyOwner { SetOwner(owner, newOwner); owner = newOwner; } function getOwner() returns (address out) { return owner; } function invalidateOrdersBefore(address user, uint256 nonce) onlyAdmin { if (nonce < invalidOrder[user]) throw; invalidOrder[user] = nonce; } mapping (address => mapping (address => uint256)) public tokens; mapping (address => bool) public admins; mapping (address => uint256) public lastActiveTransaction; mapping (bytes32 => uint256) public orderFills; address public feeAccount; uint256 public feeAffiliate; uint256 public inactivityReleasePeriod; mapping (bytes32 => bool) public traded; mapping (bytes32 => bool) public withdrawn; uint256 public makerFee; uint256 public takerFee; uint256 public affiliateFee; uint256 public makerAffiliateFee; uint256 public takerAffiliateFee; mapping (address => address) public referrer; address public affiliateContract; address public tokenListContract; enum Errors { INVLID_PRICE, INVLID_SIGNATURE, TOKENS_DONT_MATCH, ORDER_ALREADY_FILLED, GAS_TOO_HIGH } event Order(address tokenBuy, uint256 amountBuy, address tokenSell, uint256 amountSell, uint256 expires, uint256 nonce, address user, uint8 v, bytes32 r, bytes32 s); event Cancel(address tokenBuy, uint256 amountBuy, address tokenSell, uint256 amountSell, uint256 expires, uint256 nonce, address user, uint8 v, bytes32 r, bytes32 s); event Trade( address takerTokenBuy, uint256 takerAmountBuy, address takerTokenSell, uint256 takerAmountSell, address maker, address taker, uint256 makerFee, uint256 takerFee, uint256 makerAmountTaken, uint256 takerAmountTaken, bytes32 makerOrderHash, bytes32 takerOrderHash ); event Deposit(address token, address user, uint256 amount, uint256 balance, address referrerAddress); event Withdraw(address token, address user, uint256 amount, uint256 balance); event FeeChange(uint256 makerFee, uint256 takerFee, uint256 affiliateFee); event AffiliateFeeChange(uint256 newAffiliateFee); event LogError(uint8 indexed errorId, bytes32 indexed orderHash); event CancelOrder(bytes32 cancelHash, bytes32 orderHash, address user, address tokenSell, uint256 amountSell, uint256 cancelFee); function setInactivityReleasePeriod(uint256 expiry) onlyAdmin returns (bool success) { if (expiry > 1000000) throw; inactivityReleasePeriod = expiry; return true; } function Exchange(address feeAccount_, uint256 makerFee_, uint256 takerFee_, uint256 affiliateFee_, address affiliateContract_, address tokenListContract_) { owner = msg.sender; feeAccount = feeAccount_; inactivityReleasePeriod = 100000; makerFee = makerFee_; takerFee = takerFee_; affiliateFee = affiliateFee_; makerAffiliateFee = safeMul(makerFee, affiliateFee_) / (1 ether); takerAffiliateFee = safeMul(takerFee, affiliateFee_) / (1 ether); affiliateContract = affiliateContract_; tokenListContract = tokenListContract_; } function setFees(uint256 makerFee_, uint256 takerFee_, uint256 affiliateFee_) onlyOwner { require(makerFee_ < 10 finney && takerFee_ < 10 finney); require(affiliateFee_ > affiliateFee); makerFee = makerFee_; takerFee = takerFee_; affiliateFee = affiliateFee_; makerAffiliateFee = safeMul(makerFee, affiliateFee_) / (1 ether); takerAffiliateFee = safeMul(takerFee, affiliateFee_) / (1 ether); FeeChange(makerFee, takerFee, affiliateFee_); } function setAdmin(address admin, bool isAdmin) onlyOwner { admins[admin] = isAdmin; } modifier onlyAdmin { if (msg.sender != owner && !admins[msg.sender]) throw; _; } function() external { throw; } function depositToken(address token, uint256 amount, address referrerAddress) { if (referrerAddress == msg.sender) referrerAddress = address(0); if (referrer[msg.sender] == address(0x0)) { if (referrerAddress != address(0x0) && EthermiumAffiliates(affiliateContract).getAffiliate(msg.sender) == address(0)) { referrer[msg.sender] = referrerAddress; EthermiumAffiliates(affiliateContract).assignReferral(referrerAddress, msg.sender); } else { referrer[msg.sender] = EthermiumAffiliates(affiliateContract).getAffiliate(msg.sender); } } tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount); lastActiveTransaction[msg.sender] = block.number; if (!Token(token).transferFrom(msg.sender, this, amount)) throw; Deposit(token, msg.sender, amount, tokens[token][msg.sender], referrer[msg.sender]); } function deposit(address referrerAddress) payable { if (referrerAddress == msg.sender) referrerAddress = address(0); if (referrer[msg.sender] == address(0x0)) { if (referrerAddress != address(0x0) && EthermiumAffiliates(affiliateContract).getAffiliate(msg.sender) == address(0)) { referrer[msg.sender] = referrerAddress; EthermiumAffiliates(affiliateContract).assignReferral(referrerAddress, msg.sender); } else { referrer[msg.sender] = EthermiumAffiliates(affiliateContract).getAffiliate(msg.sender); } } tokens[address(0)][msg.sender] = safeAdd(tokens[address(0)][msg.sender], msg.value); lastActiveTransaction[msg.sender] = block.number; Deposit(address(0), msg.sender, msg.value, tokens[address(0)][msg.sender], referrer[msg.sender]); } function withdraw(address token, uint256 amount) returns (bool success) { if (safeSub(block.number, lastActiveTransaction[msg.sender]) < inactivityReleasePeriod) throw; if (tokens[token][msg.sender] < amount) throw; tokens[token][msg.sender] = safeSub(tokens[token][msg.sender], amount); if (token == address(0)) { if (!msg.sender.send(amount)) throw; } else { if (!Token(token).transfer(msg.sender, amount)) throw; } Withdraw(token, msg.sender, amount, tokens[token][msg.sender]); } function adminWithdraw(address token, uint256 amount, address user, uint256 nonce, uint8 v, bytes32 r, bytes32 s, uint256 feeWithdrawal) onlyAdmin returns (bool success) { bytes32 hash = keccak256(this, token, amount, user, nonce); if (withdrawn[hash]) throw; withdrawn[hash] = true; if (ecrecover(keccak256("\x19Ethereum Signed Message:\n32", hash), v, r, s) != user) throw; if (feeWithdrawal > 50 finney) feeWithdrawal = 50 finney; if (tokens[token][user] < amount) throw; tokens[token][user] = safeSub(tokens[token][user], amount); tokens[address(0)][user] = safeSub(tokens[address(0x0)][user], feeWithdrawal); tokens[address(0)][feeAccount] = safeAdd(tokens[address(0)][feeAccount], feeWithdrawal); if (token == address(0)) { if (!user.send(amount)) throw; } else { if (!Token(token).transfer(user, amount)) throw; } lastActiveTransaction[user] = block.number; Withdraw(token, user, amount, tokens[token][user]); } function balanceOf(address token, address user) constant returns (uint256) { return tokens[token][user]; } struct OrderPair { uint256 makerAmountBuy; uint256 makerAmountSell; uint256 makerNonce; uint256 takerAmountBuy; uint256 takerAmountSell; uint256 takerNonce; uint256 takerGasFee; address makerTokenBuy; address makerTokenSell; address maker; address takerTokenBuy; address takerTokenSell; address taker; bytes32 makerOrderHash; bytes32 takerOrderHash; } struct TradeValues { uint256 qty; uint256 invQty; uint256 makerAmountTaken; uint256 takerAmountTaken; address makerReferrer; address takerReferrer; } function trade( uint8[2] v, bytes32[4] rs, uint256[7] tradeValues, address[6] tradeAddresses ) onlyAdmin returns (uint filledTakerTokenAmount) { OrderPair memory t = OrderPair({ makerAmountBuy : tradeValues[0], makerAmountSell : tradeValues[1], makerNonce : tradeValues[2], takerAmountBuy : tradeValues[3], takerAmountSell : tradeValues[4], takerNonce : tradeValues[5], takerGasFee : tradeValues[6], makerTokenBuy : tradeAddresses[0], makerTokenSell : tradeAddresses[1], maker : tradeAddresses[2], takerTokenBuy : tradeAddresses[3], takerTokenSell : tradeAddresses[4], taker : tradeAddresses[5], makerOrderHash : keccak256(this, tradeAddresses[0], tradeValues[0], tradeAddresses[1], tradeValues[1], tradeValues[2], tradeAddresses[2]), takerOrderHash : keccak256(this, tradeAddresses[3], tradeValues[3], tradeAddresses[4], tradeValues[4], tradeValues[5], tradeAddresses[5]) }); if (ecrecover(keccak256("\x19Ethereum Signed Message:\n32", t.makerOrderHash), v[0], rs[0], rs[1]) != t.maker) { LogError(uint8(Errors.INVLID_SIGNATURE), t.makerOrderHash); return 0; } if (ecrecover(keccak256("\x19Ethereum Signed Message:\n32", t.takerOrderHash), v[1], rs[2], rs[3]) != t.taker) { LogError(uint8(Errors.INVLID_SIGNATURE), t.takerOrderHash); return 0; } if (t.makerTokenBuy != t.takerTokenSell || t.makerTokenSell != t.takerTokenBuy) { LogError(uint8(Errors.TOKENS_DONT_MATCH), t.takerOrderHash); return 0; } if (t.takerGasFee > 100 finney) { LogError(uint8(Errors.GAS_TOO_HIGH), t.makerOrderHash); return 0; } if (!( (t.makerTokenBuy != address(0x0) && safeMul(t.makerAmountSell, 1 ether) / t.makerAmountBuy >= safeMul(t.takerAmountBuy, 1 ether) / t.takerAmountSell) || (t.makerTokenBuy == address(0x0) && safeMul(t.makerAmountBuy, 1 ether) / t.makerAmountSell <= safeMul(t.takerAmountSell, 1 ether) / t.takerAmountBuy) )) { LogError(uint8(Errors.INVLID_PRICE), t.makerOrderHash); return 0; } TradeValues memory tv = TradeValues({ qty : 0, invQty : 0, makerAmountTaken : 0, takerAmountTaken : 0, makerReferrer : referrer[t.maker], takerReferrer : referrer[t.taker] }); if (tv.makerReferrer == address(0x0)) tv.makerReferrer = feeAccount; if (tv.takerReferrer == address(0x0)) tv.takerReferrer = feeAccount; if (t.makerTokenBuy != address(0x0)) { tv.qty = min(safeSub(t.makerAmountBuy, orderFills[t.makerOrderHash]), safeSub(t.takerAmountSell, safeMul(orderFills[t.takerOrderHash], t.takerAmountSell) / t.takerAmountBuy)); if (tv.qty == 0) { LogError(uint8(Errors.ORDER_ALREADY_FILLED), t.makerOrderHash); return 0; } tv.invQty = safeMul(tv.qty, t.makerAmountSell) / t.makerAmountBuy; tokens[t.makerTokenSell][t.maker] = safeSub(tokens[t.makerTokenSell][t.maker], tv.invQty); tv.makerAmountTaken = safeSub(tv.qty, safeMul(tv.qty, makerFee) / (1 ether)); tokens[t.makerTokenBuy][t.maker] = safeAdd(tokens[t.makerTokenBuy][t.maker], tv.makerAmountTaken); tokens[t.makerTokenBuy][tv.makerReferrer] = safeAdd(tokens[t.makerTokenBuy][tv.makerReferrer], safeMul(tv.qty, makerAffiliateFee) / (1 ether)); tokens[t.takerTokenSell][t.taker] = safeSub(tokens[t.takerTokenSell][t.taker], tv.qty); tv.takerAmountTaken = safeSub(safeSub(tv.invQty, safeMul(tv.invQty, takerFee) / (1 ether)), safeMul(tv.invQty, t.takerGasFee) / (1 ether)); tokens[t.takerTokenBuy][t.taker] = safeAdd(tokens[t.takerTokenBuy][t.taker], tv.takerAmountTaken); tokens[t.takerTokenBuy][tv.takerReferrer] = safeAdd(tokens[t.takerTokenBuy][tv.takerReferrer], safeMul(tv.invQty, takerAffiliateFee) / (1 ether)); tokens[t.makerTokenBuy][feeAccount] = safeAdd(tokens[t.makerTokenBuy][feeAccount], safeMul(tv.qty, safeSub(makerFee, makerAffiliateFee)) / (1 ether)); tokens[t.takerTokenBuy][feeAccount] = safeAdd(tokens[t.takerTokenBuy][feeAccount], safeAdd(safeMul(tv.invQty, safeSub(takerFee, takerAffiliateFee)) / (1 ether), safeMul(tv.invQty, t.takerGasFee) / (1 ether))); orderFills[t.makerOrderHash] = safeAdd(orderFills[t.makerOrderHash], tv.qty); orderFills[t.takerOrderHash] = safeAdd(orderFills[t.takerOrderHash], safeMul(tv.qty, t.takerAmountBuy) / t.takerAmountSell); lastActiveTransaction[t.maker] = block.number; lastActiveTransaction[t.taker] = block.number; Trade( t.takerTokenBuy, tv.qty, t.takerTokenSell, tv.invQty, t.maker, t.taker, makerFee, takerFee, tv.makerAmountTaken , tv.takerAmountTaken, t.makerOrderHash, t.takerOrderHash ); return tv.qty; } else { tv.qty = min(safeSub(t.makerAmountSell, safeMul(orderFills[t.makerOrderHash], t.makerAmountSell) / t.makerAmountBuy), safeSub(t.takerAmountBuy, orderFills[t.takerOrderHash])); if (tv.qty == 0) { LogError(uint8(Errors.ORDER_ALREADY_FILLED), t.makerOrderHash); return 0; } tv.invQty = safeMul(tv.qty, t.makerAmountBuy) / t.makerAmountSell; tokens[t.makerTokenSell][t.maker] = safeSub(tokens[t.makerTokenSell][t.maker], tv.qty); tv.makerAmountTaken = safeSub(tv.invQty, safeMul(tv.invQty, makerFee) / (1 ether)); tokens[t.makerTokenBuy][t.maker] = safeAdd(tokens[t.makerTokenBuy][t.maker], tv.makerAmountTaken); tokens[t.makerTokenBuy][tv.makerReferrer] = safeAdd(tokens[t.makerTokenBuy][tv.makerReferrer], safeMul(tv.invQty, makerAffiliateFee) / (1 ether)); tokens[t.takerTokenSell][t.taker] = safeSub(tokens[t.takerTokenSell][t.taker], tv.invQty); tv.takerAmountTaken = safeSub(safeSub(tv.qty, safeMul(tv.qty, takerFee) / (1 ether)), safeMul(tv.qty, t.takerGasFee) / (1 ether)); tokens[t.takerTokenBuy][t.taker] = safeAdd(tokens[t.takerTokenBuy][t.taker], tv.takerAmountTaken); tokens[t.takerTokenBuy][tv.takerReferrer] = safeAdd(tokens[t.takerTokenBuy][tv.takerReferrer], safeMul(tv.qty, takerAffiliateFee) / (1 ether)); tokens[t.makerTokenBuy][feeAccount] = safeAdd(tokens[t.makerTokenBuy][feeAccount], safeMul(tv.invQty, safeSub(makerFee, makerAffiliateFee)) / (1 ether)); tokens[t.takerTokenBuy][feeAccount] = safeAdd(tokens[t.takerTokenBuy][feeAccount], safeAdd(safeMul(tv.qty, safeSub(takerFee, takerAffiliateFee)) / (1 ether), safeMul(tv.qty, t.takerGasFee) / (1 ether))); orderFills[t.makerOrderHash] = safeAdd(orderFills[t.makerOrderHash], tv.invQty); orderFills[t.takerOrderHash] = safeAdd(orderFills[t.takerOrderHash], tv.qty); lastActiveTransaction[t.maker] = block.number; lastActiveTransaction[t.taker] = block.number; Trade( t.takerTokenBuy, tv.qty, t.takerTokenSell, tv.invQty, t.maker, t.taker, makerFee, takerFee, tv.makerAmountTaken , tv.takerAmountTaken, t.makerOrderHash, t.takerOrderHash ); return tv.qty; } } function batchOrderTrade( uint8[2][] v, bytes32[4][] rs, uint256[7][] tradeValues, address[6][] tradeAddresses ) { for (uint i = 0; i < tradeAddresses.length; i++) { trade( v[i], rs[i], tradeValues[i], tradeAddresses[i] ); } } function cancelOrder( uint8[2] v, bytes32[4] rs, uint256[5] cancelValues, address[4] cancelAddresses ) public onlyAdmin { bytes32 orderHash = keccak256( this, cancelAddresses[0], cancelValues[0], cancelAddresses[1], cancelValues[1], cancelValues[2], cancelAddresses[2] ); require(ecrecover(keccak256("\x19Ethereum Signed Message:\n32", orderHash), v[0], rs[0], rs[1]) == cancelAddresses[2]); bytes32 cancelHash = keccak256(this, orderHash, cancelAddresses[3], cancelValues[3]); require(ecrecover(keccak256("\x19Ethereum Signed Message:\n32", cancelHash), v[1], rs[2], rs[3]) == cancelAddresses[3]); require(cancelAddresses[2] == cancelAddresses[3]); require(orderFills[orderHash] != cancelValues[0]); if (cancelValues[4] > 50 finney) { cancelValues[4] = 50 finney; } tokens[address(0)][cancelAddresses[3]] = safeSub(tokens[address(0)][cancelAddresses[3]], cancelValues[4]); orderFills[orderHash] = cancelValues[0]; CancelOrder(cancelHash, orderHash, cancelAddresses[3], cancelAddresses[1], cancelValues[1], cancelValues[4]); } function min(uint a, uint b) private pure returns (uint) { return a < b ? a : b; } }
0
pragma solidity ^0.4.24; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } library SafeMath { function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { if (_a == 0) { return 0; } c = _a * _b; assert(c / _a == _b); return c; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { return _a / _b; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { assert(_b <= _a); return _a - _b; } function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { c = _a + _b; assert(c >= _a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) internal balances; uint256 internal totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= balances[msg.sender]); require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract ERC20 is ERC20Basic { function allowance(address _owner, address _spender) public view returns (uint256); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) public hasMintPermission canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() public onlyOwner canMint returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } library Roles { struct Role { mapping (address => bool) bearer; } function add(Role storage _role, address _addr) internal { _role.bearer[_addr] = true; } function remove(Role storage _role, address _addr) internal { _role.bearer[_addr] = false; } function check(Role storage _role, address _addr) internal view { require(has(_role, _addr)); } function has(Role storage _role, address _addr) internal view returns (bool) { return _role.bearer[_addr]; } } contract RBAC { using Roles for Roles.Role; mapping (string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); function checkRole(address _operator, string _role) public view { roles[_role].check(_operator); } function hasRole(address _operator, string _role) public view returns (bool) { return roles[_role].has(_operator); } function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } } contract RBACMintableToken is MintableToken, RBAC { string public constant ROLE_MINTER = "minter"; modifier hasMintPermission() { checkRole(msg.sender, ROLE_MINTER); _; } function addMinter(address _minter) public onlyOwner { addRole(_minter, ROLE_MINTER); } function removeMinter(address _minter) public onlyOwner { removeRole(_minter, ROLE_MINTER); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() public onlyOwner whenNotPaused { paused = true; emit Pause(); } function unpause() public onlyOwner whenPaused { paused = false; emit Unpause(); } } contract PausableToken is StandardToken, Pausable { function transfer( address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom( address _from, address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve( address _spender, uint256 _value ) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval( address _spender, uint _addedValue ) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval( address _spender, uint _subtractedValue ) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract DetailedERC20 is ERC20 { string public name; string public symbol; uint8 public decimals; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } } contract UBScCrypto is DetailedERC20, StandardToken, PausableToken, RBACMintableToken, BurnableToken { constructor( string _name, string _symbol, uint8 _decimals, uint256 _amount ) DetailedERC20(_name, _symbol, _decimals) public { require(_amount > 0, "amount has to be greater than 0"); totalSupply_ = _amount * uint256(10) ** _decimals; balances[msg.sender] = totalSupply_; emit Transfer(address(0), msg.sender, totalSupply_); } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29721600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x7024D8E308FDC7da3060127d4deB6A2E49d0a196; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30240000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x7BEB3287a1dC810A0B54b8DdD6ED5d6af5CD59c6; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.23; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract FreezableToken is StandardToken { mapping (bytes32 => uint64) internal chains; mapping (bytes32 => uint) internal freezings; mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner) + freezingBalance[_owner]; } function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract FreezableMintableToken is FreezableToken, MintableToken { function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint public constant TOKEN_DECIMALS = 18; uint8 public constant TOKEN_DECIMALS_UINT8 = 18; uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string public constant TOKEN_NAME = "Mapping Aggregation Platform"; string public constant TOKEN_SYMBOL = "MPLT"; bool public constant PAUSED = false; address public constant TARGET_USER = 0xd32Ca1815A347589E922c3A58d42c8f4F8A9770b; uint public constant START_TIME = 1538847900; bool public constant CONTINUE_MINTING = true; } contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable { function name() public pure returns (string _name) { return TOKEN_NAME; } function symbol() public pure returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() public pure returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } }
1
pragma solidity ^0.4.21; contract CryptoGems { event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); uint256 constant private MAX_UINT256 = 2**256 - 1; string public name = "CryptoGem"; string public symbol = "GEM"; uint public decimals = 4; uint256 public totalSupply = 0; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } event Mint(address indexed to, uint256 amount); event stateEvent(address indexed owner, uint256 id, uint64 state); event TransferMiner(address indexed owner, address indexed to, uint256 id); struct Miner { uint256 id; string name; uint64 workDuration; uint64 sleepDuration; uint64 difficulty; uint256 workBlock; uint256 sleepBlock; uint64 state; bytes32 hash; address owner; bool onSale; uint256 salePrice; uint64 exp; } Miner[] public miners; uint256 public gemPerMiner = 0; uint256 public gemPerEther = 0; uint256 public etherPerMiner = 0; uint256 public etherPerSale = 0; bool public sale = true; address public contractOwner; function CryptoGems() public { contractOwner = msg.sender; gemPerEther = 10000 * (10**decimals); etherPerMiner = 0.5 ether; etherPerSale = 0.001 ether; gemPerMiner = 5000 * (10**decimals); sale = true; } modifier onlyContractOwner() { require(msg.sender == contractOwner); _; } function buyGems() public payable { require( sale == true ); require( msg.value > 0 ); balances[ msg.sender ] += (msg.value * gemPerEther)/(1 ether); totalSupply += (msg.value * gemPerEther)/(1 ether); } function buyMinersWithEther(uint64 quantity) public payable { require( sale == true ); require( quantity * etherPerMiner <= msg.value); for(uint64 i=1;i<=quantity;i++) { createMiner(); } } function buyMinersWithGem(uint64 quantity) public { require( sale == true ); require( quantity * gemPerMiner <= balances[ msg.sender ]); balances[ msg.sender ] -= quantity * gemPerMiner; balances[ contractOwner ] += quantity * gemPerMiner; emit Transfer(msg.sender, contractOwner, quantity * gemPerMiner); for(uint64 i=1;i<=quantity;i++) { createMiner(); } } function createMiner() private { uint64 nonce = 1; Miner memory _miner = Miner({ id: 0, name: "", workDuration: uint64(keccak256(miners.length, msg.sender, nonce++))%(3000-2000)+2000, sleepDuration: uint64(keccak256(miners.length, msg.sender, nonce))%(2200-1800)+1800, difficulty: uint64(keccak256(miners.length, msg.sender, nonce))%(130-100)+100, workBlock: 0, sleepBlock: 0, state: 3, hash: keccak256(miners.length, msg.sender), owner: msg.sender, onSale: false, salePrice: 0, exp: 0 }); uint256 id = miners.push(_miner) - 1; miners[id].id = id; } function goToWork(uint256 id) public { require(msg.sender == miners[id].owner); uint64 state = minerState(id); miners[id].state = state; if(state == 3) { miners[id].workBlock = block.number; miners[id].state = 0; emit stateEvent(miners[id].owner, id, 0); } } function goToSleep(uint256 id) public { require(msg.sender == miners[id].owner); uint64 state = minerState(id); miners[id].state = state; if(state == 1) { miners[id].sleepBlock = block.number; miners[id].state = 2; uint64 curLvl = getMinerLevel(id); miners[id].exp = miners[id].exp + miners[id].workDuration; uint64 lvl = getMinerLevel(id); uint256 gemsMined = (10**decimals)*miners[id].workDuration / miners[id].difficulty; balances[ msg.sender ] += gemsMined; totalSupply += gemsMined; if(curLvl < lvl) { miners[id].difficulty = miners[id].difficulty - 2; } emit stateEvent(miners[id].owner, id, 2); } } function setOnSale(uint256 id, bool _onSale, uint256 _salePrice) public payable { require( msg.value >= etherPerSale ); require( msg.sender == miners[id].owner); require( _salePrice >= 0 ); miners[id].onSale = _onSale; miners[id].salePrice = _salePrice; } function buyMinerFromSale(uint256 id) public { require(msg.sender != miners[id].owner); require(miners[id].onSale == true); require(balances[msg.sender] >= miners[id].salePrice); transfer(miners[id].owner, miners[id].salePrice); emit TransferMiner(miners[id].owner, msg.sender, id); miners[id].owner = msg.sender; miners[id].onSale = false; miners[id].salePrice = 0; } function transferMiner(address to, uint256 id) public returns (bool success) { require(miners[id].owner == msg.sender); miners[id].owner = to; emit TransferMiner(msg.sender, to, id); return true; } function nameMiner(uint256 id, string _name) public returns (bool success) { require(msg.sender == miners[id].owner); bytes memory b = bytes(miners[id].name ); if (b.length == 0) { miners[id].name = _name; } else return false; return true; } function getMinersByAddress(address _address) public constant returns(uint256[]) { uint256[] memory m = new uint256[](miners.length); uint256 cnt = 0; for(uint256 i=0;i<miners.length;i++) { if(miners[i].owner == _address) { m[cnt++] = i; } } uint256[] memory ret = new uint256[](cnt); for(i=0;i<cnt;i++) { ret[i] = m[i]; } return ret; } function getMinersOnSale() public constant returns(uint256[]) { uint256[] memory m = new uint256[](miners.length); uint256 cnt = 0; for(uint256 i=0;i<miners.length;i++) { if(miners[i].onSale == true) { m[cnt++] = i; } } uint256[] memory ret = new uint256[](cnt); for(i=0;i<cnt;i++) { ret[i] = m[i]; } return ret; } function minerState(uint256 id) public constant returns (uint64) { if(miners[id].workBlock !=0 && block.number - miners[id].workBlock <= miners[id].workDuration) { return 0; } if(miners[id].sleepBlock !=0 && block.number - miners[id].sleepBlock <= miners[id].sleepDuration) { return 2; } if(miners[id].workBlock !=0 && block.number - miners[id].workBlock > miners[id].workDuration && miners[id].workBlock > miners[id].sleepBlock) { return 1; } if(miners[id].sleepBlock !=0 && block.number - miners[id].sleepBlock > miners[id].sleepDuration && miners[id].sleepBlock > miners[id].workBlock) { return 3; } return 3; } function getMinerLevel(uint256 id) public constant returns (uint8){ uint256 exp = miners[id].exp; if(exp < 15000) return 1; if(exp < 35000) return 2; if(exp < 60000) return 3; if(exp < 90000) return 4; if(exp < 125000) return 5; if(exp < 165000) return 6; if(exp < 210000) return 7; if(exp < 260000) return 8; if(exp < 315000) return 9; return 10; } function withdrawEther(address _sendTo, uint256 _amount) onlyContractOwner public returns(bool) { address CryptoGemsContract = this; if (_amount > CryptoGemsContract.balance) { _sendTo.transfer(CryptoGemsContract.balance); } else { _sendTo.transfer(_amount); } return true; } function changeContractOwner(address _contractOwner) onlyContractOwner public { contractOwner = _contractOwner; } function setMinerPrice(uint256 _amount) onlyContractOwner public returns(bool) { etherPerMiner = _amount; return true; } function setGemPerMiner(uint256 _amount) onlyContractOwner public returns(bool) { gemPerMiner = _amount; return true; } function setSale(bool _sale) onlyContractOwner public returns(bool) { sale = _sale; return true; } function setGemPrice(uint256 _amount) onlyContractOwner public returns(bool) { gemPerEther = _amount; return true; } }
1
pragma solidity ^0.4.13; contract ERC20 { function transfer(address _to, uint256 _value) returns (bool success); function balanceOf(address _owner) constant returns (uint256 balance); } contract DecentralandBuyer { mapping (address => uint256) public balances; uint256 public bounty; bool public bought_tokens; uint256 public time_bought; uint256 public contract_eth_value; bool public kill_switch; bytes32 password_hash = 0x8223cba4d8b54dc1e03c41c059667f6adb1a642a0a07bef5a9d11c18c4f14612; uint256 earliest_buy_block = 4170700; address developer = 0x000Fb8369677b3065dE5821a86Bc9551d5e5EAb9; address public sale = 0xA66d83716c7CFE425B44D0f7ef92dE263468fb3d; ERC20 public token = ERC20(0x0F5D2fB29fb7d3CFeE444a200298f468908cC942); function activate_kill_switch(string password) { if (msg.sender != developer && sha3(password) != password_hash) throw; uint256 claimed_bounty = bounty; bounty = 0; kill_switch = true; msg.sender.transfer(claimed_bounty); } function withdraw(address user, bool has_fee) internal { if (!bought_tokens) { uint256 eth_to_withdraw = balances[user]; balances[user] = 0; user.transfer(eth_to_withdraw); } else { uint256 contract_token_balance = token.balanceOf(address(this)); if (contract_token_balance == 0) throw; uint256 tokens_to_withdraw = (balances[user] * contract_token_balance) / contract_eth_value; contract_eth_value -= balances[user]; balances[user] = 0; uint256 fee = 0; if (has_fee) { fee = tokens_to_withdraw / 100; if(!token.transfer(developer, fee)) throw; } if(!token.transfer(user, tokens_to_withdraw - fee)) throw; } } function auto_withdraw(address user){ if (!bought_tokens || now < time_bought + 1 hours) throw; withdraw(user, true); } function add_to_bounty() payable { if (msg.sender != developer) throw; if (kill_switch) throw; if (bought_tokens) throw; bounty += msg.value; } function claim_bounty(){ if (bought_tokens) return; if (block.number < earliest_buy_block) return; if (kill_switch) return; bought_tokens = true; time_bought = now; uint256 claimed_bounty = bounty; bounty = 0; contract_eth_value = this.balance - claimed_bounty; if(!sale.call.value(contract_eth_value)()) throw; msg.sender.transfer(claimed_bounty); } function default_helper() payable { if (msg.value <= 1 finney) { withdraw(msg.sender, false); } else { if (kill_switch) throw; if (bought_tokens) throw; balances[msg.sender] += msg.value; } } function () payable { if (msg.sender == address(sale)) throw; default_helper(); } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30499200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x8Dc666dfeB8f4E8ff0eE9f3b2929A926441DEaf9; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.24; pragma solidity ^0.4.24; pragma solidity ^0.4.24; pragma solidity ^0.4.24; contract Ownable { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); owner = newOwner; } } contract Haltable is Ownable { bool public halted; event Halted(bool halted); modifier stopInEmergency { require(!halted); _; } modifier onlyInEmergency { require(halted); _; } function halt() external onlyOwner { halted = true; emit Halted(true); } function unhalt() external onlyOwner onlyInEmergency { halted = false; emit Halted(false); } } pragma solidity ^0.4.24; library SafeMath { function mul(uint a, uint b) internal pure returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint a, uint b) internal pure returns (uint) { uint c = a / b; return c; } function sub(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); 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(uint a, uint b) internal pure returns (uint) { return a >= b ? a : b; } function min256(uint a, uint b) internal pure returns (uint) { return a < b ? a : b; } } pragma solidity ^0.4.24; pragma solidity ^0.4.24; pragma solidity ^0.4.24; pragma solidity ^0.4.24; contract EIP20Token { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool success); function transferFrom(address from, address to, uint256 value) public returns (bool success); function approve(address spender, uint256 value) public returns (bool success); function allowance(address owner, address spender) public view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.4.24; contract Burnable { function burnTokens(address account, uint value) internal; event Burned(address account, uint value); } pragma solidity ^0.4.24; contract Mintable { function mintInternal(address receiver, uint amount) internal; event Minted(address receiver, uint amount); } contract StandardToken is EIP20Token, Burnable, Mintable { using SafeMath for uint; uint private total_supply; mapping(address => uint) private balances; mapping(address => mapping (address => uint)) private allowed; function totalSupply() public view returns (uint) { return total_supply; } function transfer(address to, uint value) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(value); balances[to] = balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } function balanceOf(address account) public view returns (uint balance) { return balances[account]; } function transferFrom(address from, address to, uint value) public returns (bool success) { uint allowance = allowed[from][msg.sender]; balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowance.sub(value); emit Transfer(from, to, value); return true; } function approve(address spender, uint value) public returns (bool success) { require (value == 0 || allowed[msg.sender][spender] == 0); allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function allowance(address account, address spender) public view returns (uint remaining) { return allowed[account][spender]; } function addApproval(address spender, uint addedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][spender]; allowed[msg.sender][spender] = oldValue.add(addedValue); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function subApproval(address spender, uint subtractedValue) public returns (bool success) { uint oldVal = allowed[msg.sender][spender]; if (subtractedValue > oldVal) { allowed[msg.sender][spender] = 0; } else { allowed[msg.sender][spender] = oldVal.sub(subtractedValue); } emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function burnTokens(address account, uint value) internal { balances[account] = balances[account].sub(value); total_supply = total_supply.sub(value); emit Transfer(account, 0, value); emit Burned(account, value); } function mintInternal(address receiver, uint amount) internal { total_supply = total_supply.add(amount); balances[receiver] = balances[receiver].add(amount); emit Minted(receiver, amount); emit Transfer(0, receiver, amount); } } contract ReleasableToken is StandardToken, Ownable { address public releaseAgent; bool public released = false; mapping (address => bool) public transferAgents; function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public { releaseAgent = addr; } function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public { transferAgents[addr] = state; } function releaseTokenTransfer() public onlyReleaseAgent { released = true; } modifier canTransfer(address sender) { require(released || transferAgents[sender]); _; } modifier inReleaseState(bool releaseState) { require(releaseState == released); _; } modifier onlyReleaseAgent() { require(msg.sender == releaseAgent); _; } function transfer(address to, uint value) public canTransfer(msg.sender) returns (bool success) { return super.transfer(to, value); } function transferFrom(address from, address to, uint value) public canTransfer(from) returns (bool success) { return super.transferFrom(from, to, value); } } pragma solidity ^0.4.24; pragma solidity ^0.4.24; contract UpgradeAgent { uint public originalSupply; function isUpgradeAgent() public pure returns (bool) { return true; } function upgradeFrom(address from, uint value) public; } contract UpgradeableToken is EIP20Token, Burnable { using SafeMath for uint; address public upgradeMaster; UpgradeAgent public upgradeAgent; uint public totalUpgraded = 0; enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading} event Upgrade(address indexed from, address to, uint value); event UpgradeAgentSet(address agent); constructor(address master) internal { setUpgradeMaster(master); } function upgrade(uint value) public { UpgradeState state = getUpgradeState(); require(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading); require(value != 0); upgradeAgent.upgradeFrom(msg.sender, value); burnTokens(msg.sender, value); totalUpgraded = totalUpgraded.add(value); emit Upgrade(msg.sender, upgradeAgent, value); } function setUpgradeAgent(address agent) onlyMaster external { require(canUpgrade()); require(agent != 0x0); require(getUpgradeState() != UpgradeState.Upgrading); upgradeAgent = UpgradeAgent(agent); require(upgradeAgent.isUpgradeAgent()); require(upgradeAgent.originalSupply() == totalSupply()); emit UpgradeAgentSet(upgradeAgent); } function getUpgradeState() public view returns(UpgradeState) { if (!canUpgrade()) return UpgradeState.NotAllowed; else if (address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent; else if (totalUpgraded == 0) return UpgradeState.ReadyToUpgrade; else return UpgradeState.Upgrading; } function changeUpgradeMaster(address new_master) onlyMaster public { setUpgradeMaster(new_master); } function setUpgradeMaster(address new_master) private { require(new_master != 0x0); upgradeMaster = new_master; } function canUpgrade() public view returns(bool); modifier onlyMaster() { require(msg.sender == upgradeMaster); _; } } pragma solidity ^0.4.24; contract LostAndFoundToken { function getLostAndFoundMaster() internal view returns (address); function enableLostAndFound(address agent, uint tokens, EIP20Token token_contract) public { require(msg.sender == getLostAndFoundMaster()); token_contract.approve(agent, tokens); } } pragma solidity ^0.4.24; contract MintableToken is Mintable, Ownable { using SafeMath for uint; bool public mintingFinished = false; mapping (address => bool) public mintAgents; event MintingAgentChanged(address addr, bool state); constructor(uint initialSupply, address multisig, bool mintable) internal { require(multisig != address(0)); require(mintable || initialSupply != 0); if (initialSupply > 0) mintInternal(multisig, initialSupply); mintingFinished = !mintable; } function mint(address receiver, uint amount) onlyMintAgent canMint public { mintInternal(receiver, amount); } function setMintAgent(address addr, bool state) onlyOwner canMint public { mintAgents[addr] = state; emit MintingAgentChanged(addr, state); } modifier onlyMintAgent() { require(mintAgents[msg.sender]); _; } modifier canMint() { require(!mintingFinished); _; } } contract CrowdsaleToken is ReleasableToken, MintableToken, UpgradeableToken, LostAndFoundToken { string public name = "Kryptobits"; string public symbol = "KBE"; uint8 public decimals; address public lost_and_found_master; constructor(uint initial_supply, uint8 token_decimals, address team_multisig, address token_retriever) public UpgradeableToken(team_multisig) MintableToken(initial_supply, team_multisig, true) { require(token_retriever != address(0)); decimals = token_decimals; lost_and_found_master = token_retriever; } function releaseTokenTransfer() public onlyReleaseAgent { mintingFinished = true; super.releaseTokenTransfer(); } function canUpgrade() public view returns(bool) { return released; } function burn(uint value) public { burnTokens(msg.sender, value); } function getLostAndFoundMaster() internal view returns(address) { return lost_and_found_master; } } contract GenericCrowdsale is Haltable { using SafeMath for uint; CrowdsaleToken public token; address public multisigWallet; uint public startsAt; uint public endsAt; uint public tokensSold = 0; uint public weiRaised = 0; uint public investorCount = 0; bool public finalized = false; bool public requireCustomerId = false; bool public configured = false; bool public requiredSignedAddress = false; address public signerAddress; mapping (address => uint) public investedAmountOf; mapping (address => uint) public tokenAmountOf; mapping (address => bool) public earlyParticipantWhitelist; enum State{Unknown, PendingConfiguration, PreFunding, Funding, Success, Finalized} event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId); event InvestmentPolicyChanged(bool requireCId, bool requireSignedAddress, address signer); event Whitelisted(address addr, bool status); event Finalized(); function configurationGenericCrowdsale(address team_multisig, uint start, uint end) internal inState(State.PendingConfiguration) { setMultisig(team_multisig); require(start != 0 && end != 0); require(now < end && start < end); startsAt = start; endsAt = end; configured = true; } function() payable public { buy(); } function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private { if (getState() == State.PreFunding) { require(earlyParticipantWhitelist[msg.sender]); } uint weiAmount; uint tokenAmount; (weiAmount, tokenAmount) = calculateTokenAmount(msg.value, receiver); assert(weiAmount <= msg.value); require(tokenAmount != 0); if (investedAmountOf[receiver] == 0) { investorCount++; } updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId); multisigWallet.transfer(weiAmount); returnExcedent(msg.value.sub(weiAmount), msg.sender); } function preallocate(address receiver, uint fullTokens, uint weiPrice) external onlyOwner notFinished { uint tokenAmount = fullTokens.mul(10**uint(token.decimals())); uint weiAmount = weiPrice.mul(tokenAmount); granularPreallocate(receiver, tokenAmount, weiAmount); } function granularPreallocate(address receiver, uint tokenAmount, uint weiAmount) public onlyOwner notFinished { require(receiver != address(0)); require(tokenAmount != 0); updateInvestorFunds(tokenAmount, weiAmount, receiver , 0); } function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private { investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount); tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount); weiRaised = weiRaised.add(weiAmount); tokensSold = tokensSold.add(tokenAmount); assignTokens(receiver, tokenAmount); emit Invested(receiver, weiAmount, tokenAmount, customerId); } function buyOnBehalfWithSignedAddress(address receiver, uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable validCustomerId(customerId) { bytes32 hash = sha256(abi.encodePacked(receiver)); require(ecrecover(hash, v, r, s) == signerAddress); investInternal(receiver, customerId); } function buyOnBehalfWithCustomerId(address receiver, uint128 customerId) public payable validCustomerId(customerId) unsignedBuyAllowed { investInternal(receiver, customerId); } function buyOnBehalf(address receiver) public payable unsignedBuyAllowed { require(!requireCustomerId); investInternal(receiver, 0); } function buyWithSignedAddress(uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable { buyOnBehalfWithSignedAddress(msg.sender, customerId, v, r, s); } function buyWithCustomerId(uint128 customerId) public payable { buyOnBehalfWithCustomerId(msg.sender, customerId); } function buy() public payable { buyOnBehalf(msg.sender); } function finalize() public inState(State.Success) onlyOwner stopInEmergency { finalized = true; emit Finalized(); } function setRequireCustomerId(bool value) public onlyOwner { requireCustomerId = value; emit InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress); } function setRequireSignedAddress(bool value, address signer) public onlyOwner { requiredSignedAddress = value; signerAddress = signer; emit InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress); } function setEarlyParticipantWhitelist(address addr, bool status) public onlyOwner notFinished stopInEmergency { earlyParticipantWhitelist[addr] = status; emit Whitelisted(addr, status); } function setMultisig(address addr) internal { require(addr != 0); multisigWallet = addr; } function getState() public view returns (State) { if (finalized) return State.Finalized; else if (!configured) return State.PendingConfiguration; else if (now < startsAt) return State.PreFunding; else if (now <= endsAt && !isCrowdsaleFull()) return State.Funding; else return State.Success; } function assignTokens(address receiver, uint tokenAmount) internal; function isCrowdsaleFull() internal view returns (bool full); function returnExcedent(uint excedent, address receiver) internal { if (excedent > 0) { receiver.transfer(excedent); } } function calculateTokenAmount(uint weiAmount, address receiver) internal view returns (uint weiAllowed, uint tokenAmount); modifier inState(State state) { require(getState() == state); _; } modifier unsignedBuyAllowed() { require(!requiredSignedAddress); _; } modifier notFinished() { State current_state = getState(); require(current_state == State.PreFunding || current_state == State.Funding); _; } modifier validCustomerId(uint128 customerId) { require(customerId != 0); _; } } pragma solidity ^0.4.24; contract DeploymentInfo { uint private deployed_on; constructor() public { deployed_on = block.number; } function getDeploymentBlock() public view returns (uint) { return deployed_on; } } pragma solidity ^0.4.24; contract TokenTranchePricing { using SafeMath for uint; struct Tranche { uint amount; uint start; uint end; uint price; } uint private constant amount_offset = 0; uint private constant start_offset = 1; uint private constant end_offset = 2; uint private constant price_offset = 3; uint private constant tranche_size = 4; Tranche[] public tranches; function getTranchesLength() public view returns (uint) { return tranches.length; } function configurationTokenTranchePricing(uint[] init_tranches) internal { require(init_tranches.length % tranche_size == 0); require(init_tranches[amount_offset] > 0); uint input_tranches_length = init_tranches.length.div(tranche_size); Tranche memory last_tranche; for (uint i = 0; i < input_tranches_length; i++) { uint tranche_offset = i.mul(tranche_size); uint amount = init_tranches[tranche_offset.add(amount_offset)]; uint start = init_tranches[tranche_offset.add(start_offset)]; uint end = init_tranches[tranche_offset.add(end_offset)]; uint price = init_tranches[tranche_offset.add(price_offset)]; require(start < end && now < end); require(i == 0 || (end >= last_tranche.end && amount > last_tranche.amount) || (end > last_tranche.end && amount >= last_tranche.amount)); last_tranche = Tranche(amount, start, end, price); tranches.push(last_tranche); } } function getCurrentTranche(uint tokensSold) private view returns (Tranche storage) { for (uint i = 0; i < tranches.length; i++) { if (tranches[i].start <= now && now < tranches[i].end && tokensSold < tranches[i].amount) { return tranches[i]; } } revert(); } function getCurrentPrice(uint tokensSold) public view returns (uint result) { return getCurrentTranche(tokensSold).price; } } contract Crowdsale is GenericCrowdsale, LostAndFoundToken, DeploymentInfo, TokenTranchePricing { uint public sellable_tokens; uint public initial_tokens; uint public milieurs_per_eth; uint public minimum_buy_value; address public price_agent; function configurationCrowdsale(address team_multisig, uint start, uint end, address token_retriever, uint[] init_tranches, uint multisig_supply, uint crowdsale_supply, uint8 token_decimals) public onlyOwner { initial_tokens = multisig_supply; minimum_buy_value = uint(100).mul(10 ** uint(token_decimals)); token = new CrowdsaleToken(multisig_supply, token_decimals, team_multisig, token_retriever); token.setMintAgent(address(this), true); token.setReleaseAgent(address(this)); token.setTransferAgent(address(this), true); token.setTransferAgent(team_multisig, true); token.mint(address(this), crowdsale_supply); token.setMintAgent(address(this), false); sellable_tokens = crowdsale_supply; configurationGenericCrowdsale(team_multisig, start, end); configurationTokenTranchePricing(init_tranches); } function assignTokens(address receiver, uint tokenAmount) internal { token.transfer(receiver, tokenAmount); } function calculateTokenAmount(uint weiAmount, address receiver) internal view returns (uint weiAllowed, uint tokenAmount) { uint tokensPerEth = getCurrentPrice(tokensSold).mul(milieurs_per_eth).div(1000); uint maxWeiAllowed = sellable_tokens.sub(tokensSold).mul(1 ether).div(tokensPerEth); weiAllowed = maxWeiAllowed.min256(weiAmount); if (weiAmount < maxWeiAllowed) { tokenAmount = tokensPerEth.mul(weiAmount).div(1 ether); } else { tokenAmount = sellable_tokens.sub(tokensSold); } require(token.balanceOf(receiver).add(tokenAmount) >= minimum_buy_value); } function isCrowdsaleFull() internal view returns (bool full) { return tokensSold >= sellable_tokens; } function finalize() public inState(State.Success) onlyOwner stopInEmergency { uint sold = tokensSold.add(initial_tokens); uint toShare = sold.mul(18).div(82); token.setMintAgent(address(this), true); token.mint(multisigWallet, toShare); token.setMintAgent(address(this), false); token.releaseTokenTransfer(); token.burn(token.balanceOf(address(this))); super.finalize(); } function getLostAndFoundMaster() internal view returns (address) { return owner; } function setStartingTime(uint startingTime) public onlyOwner inState(State.PreFunding) { require(now < startingTime && startingTime < endsAt); startsAt = startingTime; } function setEndingTime(uint endingTime) public onlyOwner notFinished { require(now < endingTime && startsAt < endingTime); endsAt = endingTime; } function updateEursPerEth (uint milieurs_amount) public notFinished { require(milieurs_amount >= 100); require(msg.sender == price_agent); milieurs_per_eth = milieurs_amount; } function updatePriceAgent(address new_price_agent) public onlyOwner notFinished { price_agent = new_price_agent; } function setMinimumBuyValue(uint new_minimum) public onlyOwner notFinished { minimum_buy_value = new_minimum; } }
0
pragma solidity ^0.4.16; contract CLVRToken { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); constructor() public { totalSupply = 100000000 * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = "Clever"; symbol = "CLVR"; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; emit Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; emit Burn(_from, _value); return true; } }
1
pragma solidity ^0.4.24; interface PlayerBookInterface { function getPlayerID(address _addr) external returns (uint256); function getPlayerName(uint256 _pID) external view returns (bytes32); function getPlayerLAff(uint256 _pID) external view returns (uint256); function getPlayerAddr(uint256 _pID) external view returns (address); function getNameFee() external view returns (uint256); function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256); function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256); function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0 || b == 0) { return 0; } c = a * b; require(c / a == b, "SafeMath mul failed"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath sub failed"); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256 c) { if(b <= 0) return 0; else return a / b; } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } } library NameFilter { function nameFilter(string _input) internal pure returns(bytes32) { bytes memory _temp = bytes(_input); uint256 _length = _temp.length; require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters"); require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space"); if (_temp[0] == 0x30) { require(_temp[1] != 0x78, "string cannot start with 0x"); require(_temp[1] != 0x58, "string cannot start with 0X"); } bool _hasNonNumber; for (uint256 i = 0; i < _length; i++) { if (_temp[i] > 0x40 && _temp[i] < 0x5b) { _temp[i] = byte(uint(_temp[i]) + 32); if (_hasNonNumber == false) _hasNonNumber = true; } else { require ( _temp[i] == 0x20 || (_temp[i] > 0x60 && _temp[i] < 0x7b) || (_temp[i] > 0x2f && _temp[i] < 0x3a), "string contains invalid characters" ); if (_temp[i] == 0x20) require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces"); if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39)) _hasNonNumber = true; } } require(_hasNonNumber == true, "string cannot be only numbers"); bytes32 _ret; assembly { _ret := mload(add(_temp, 32)) } return (_ret); } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract F3Devents { event onNewName ( uint256 indexed playerID, address indexed playerAddress, bytes32 indexed playerName, bool isNewPlayer, uint256 affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 amountPaid, uint256 timeStamp ); event onBuyAndDistribute ( address playerAddress, bytes32 playerName, uint256 pCosd, uint256 pCosc, uint256 comCosd, uint256 comCosc, uint256 affVltCosd, uint256 affVltCosc, uint256 keyNums ); event onRecHldVltCosd ( address playerAddress, bytes32 playerName, uint256 hldVltCosd ); event onSellAndDistribute ( address playerAddress, bytes32 playerName, uint256 pCosd, uint256 pCosc, uint256 keyNums ); event onWithdrawHoldVault ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 plyr_cosd, uint256 plyr_hldVltCosd ); event onWithdrawAffVault ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 plyr_cosd, uint256 plyr_cosc, uint256 plyr_affVltCosd, uint256 plyr_affVltCosc ); event onWithdrawWonCosFromGame ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 plyr_cosd, uint256 plyr_cosc, uint256 plyr_affVltCosd ); } contract modularLong is F3Devents {} contract FoMo3DLong is modularLong, Ownable { using SafeMath for *; using NameFilter for *; using F3DKeysCalcLong for *; PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0x82cFeBf0F80B9617b8D13368eFC9B76C48F096d4); string constant public name = "FoMo3D World"; string constant public symbol = "F3DW"; uint256 public rID_; uint256 public plyNum_ = 2; uint256 public cosdNum_ = 0; uint256 public coscNum_ = 0; uint256 public totalVolume_ = 0; uint256 public totalVltCosd_ = 0; uint256 public result_ = 0; uint256 public price_ = 10**16; uint256 public priceCntThreshould_ = 100000; uint256 constant public pIDCom_ = 1; mapping (address => uint256) public pIDxAddr_; mapping (bytes32 => uint256) public pIDxName_; mapping (uint256 => F3Ddatasets.Player) public plyr_; mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; constructor() public { } modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); _; } function() public { } function buyXaddr(address _pAddr, address _affCode, uint256 _eth, string _keyType) onlyOwner() public { determinePID(_pAddr); uint256 _pID = pIDxAddr_[_pAddr]; uint256 _affID; if (_affCode == address(0) || _affCode == _pAddr) { _affID = plyr_[_pID].laff; } else { _affID = pIDxAddr_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } buyCore(_pID, _affID, _eth, _keyType); } function registerNameXaddr(string memory _nameString, address _affCode, bool _all) public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); if(_isNewPlayer) plyNum_++; uint256 _pID = pIDxAddr_[_addr]; emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function totalSupplys() public view returns(uint256, uint256, uint256, uint256) { return (cosdNum_, coscNum_, totalVolume_, totalVltCosd_); } function getBuyPrice() public view returns(uint256) { return price_; } function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) { uint256 _pID = pIDxAddr_[_addr]; return ( _pID, plyr_[_pID].name, plyr_[_pID].laff, plyr_[_pID].eth, plyr_[_pID].cosd, plyr_[_pID].cosc, plyr_[_pID].hldVltCosd, plyr_[_pID].affCosd, plyr_[_pID].affCosc, plyr_[_pID].totalHldVltCosd, plyr_[_pID].totalAffCos, plyr_[_pID].totalWinCos ); } function buyCore(uint256 _pID, uint256 _affID, uint256 _eth, string _keyType) private { uint256 _keys; if (_eth >= 0) { require(_eth >= getBuyPrice()); _keys = keysRec(_eth); uint256 _aff; uint256 _com; uint256 _holders; uint256 _self; if(isCosd(_keyType) == true){ _aff = _keys * 5/100; _com = _keys * 2/100; _holders = _keys * 3/100; _self = _keys.sub(_aff).sub(_com).sub(_holders); uint256 _hldCosd; for (uint256 i = 1; i <= plyNum_; i++) { if(plyr_[i].cosd>0) _hldCosd = _hldCosd.add(plyr_[i].cosd); } plyr_[_pID].cosd = plyr_[_pID].cosd.add(_self); plyr_[pIDCom_].cosd = plyr_[pIDCom_].cosd.add(_com); plyr_[_affID].affCosd = plyr_[_affID].affCosd.add(_aff); for (uint256 j = 1; j <= plyNum_; j++) { if(plyr_[j].cosd>0) { plyr_[j].hldVltCosd = plyr_[j].hldVltCosd.add(_holders.mul(plyr_[j].cosd).div(_hldCosd)); emit F3Devents.onRecHldVltCosd ( plyr_[j].addr, plyr_[j].name, plyr_[j].hldVltCosd ); } } cosdNum_ = cosdNum_.add(_keys); totalVolume_ = totalVolume_.add(_keys); } else{ _aff = _keys *4/100; _com = _keys *1/100; _self = _keys.sub(_aff).sub(_com); plyr_[_pID].cosc = plyr_[_pID].cosc.add(_self); plyr_[pIDCom_].cosc = plyr_[pIDCom_].cosc.add(_com); plyr_[_affID].affCosc = plyr_[_affID].affCosc.add(_aff); coscNum_ = coscNum_.add(_keys); totalVolume_ = totalVolume_.add(_keys); } } } function sellKeys(uint256 _pID, uint256 _keys, string _keyType) onlyOwner() public returns(uint256) { require(_keys>0); uint256 _eth; uint256 _holders; uint256 _self; if(isCosd(_keyType) == true){ require(plyr_[_pID].cosd >= _keys,"Do not have cosd!"); _holders = _keys * 20/100; _self = _keys.sub(_holders); uint256 _hldCosd; for (uint256 i = 1; i <= plyNum_; i++) { if(plyr_[i].cosd>0) _hldCosd = _hldCosd.add(plyr_[i].cosd); } plyr_[_pID].cosd = plyr_[_pID].cosd.sub(_keys); _eth = ethRec(_self); plyr_[_pID].eth = plyr_[_pID].eth.add(_eth); for (uint256 j = 1; j <= plyNum_; j++) { if( plyr_[j].cosd>0) { plyr_[j].hldVltCosd = plyr_[j].hldVltCosd.add(_holders.mul(plyr_[j].cosd).div(_hldCosd)); emit F3Devents.onRecHldVltCosd ( plyr_[j].addr, plyr_[j].name, plyr_[j].hldVltCosd ); } } cosdNum_ = cosdNum_.sub(_self); totalVolume_ = totalVolume_.add(_keys); } else{ require(plyr_[_pID].cosc >= _keys,"Do not have cosc!"); plyr_[_pID].cosc = plyr_[_pID].cosc.sub(_keys); _eth = ethRec(_keys); plyr_[_pID].eth = plyr_[_pID].eth.add(_eth); coscNum_ = coscNum_.sub(_keys); totalVolume_ = totalVolume_.add(_keys); } return _eth; } function addCosToGame(uint256 _pID, uint256 _keys, string _keyType) onlyOwner() public { uint256 _aff; uint256 _com; uint256 _holders; uint256 _affID = plyr_[_pID].laff; if(isCosd(_keyType) == true){ require(plyr_[_pID].cosd >= _keys); _aff = _keys *1/100; _com = _keys *3/100; _holders = _keys *5/100; plyr_[_pID].cosd = plyr_[_pID].cosd.sub(_keys); uint256 _hldCosd; for (uint256 i = 1; i <= plyNum_; i++) { if(plyr_[i].cosd>0) _hldCosd = _hldCosd.add(plyr_[i].cosd); } plyr_[pIDCom_].cosd = plyr_[pIDCom_].cosd.add(_com); plyr_[_affID].affCosd = plyr_[_affID].affCosd.add(_aff); for (uint256 j = 1; j <= plyNum_; j++) { if(plyr_[j].cosd>0) { plyr_[j].hldVltCosd = plyr_[j].hldVltCosd.add(_holders.mul(plyr_[j].cosd).div(_hldCosd)); emit F3Devents.onRecHldVltCosd ( plyr_[j].addr, plyr_[j].name, plyr_[j].hldVltCosd ); } } } else{ require(plyr_[_pID].cosc >= _keys); plyr_[_pID].cosc = plyr_[_pID].cosc.sub(_keys); } } function winCosFromGame(uint256 _pID, uint256 _keys, string _keyType) onlyOwner() public { if(isCosd(_keyType) == true){ plyr_[_pID].cosd = plyr_[_pID].cosd.add(_keys); } else{ plyr_[_pID].cosc = plyr_[_pID].cosc.add(_keys); } plyr_[_pID].totalWinCos = plyr_[_pID].totalWinCos.add(_keys); } function iWantXKeys(uint256 _keys) public view returns(uint256) { return eth(_keys); } function howManyKeysCanBuy(uint256 _eth) public view returns(uint256) { return keys(_eth); } function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function determinePID(address _pAddr) private { uint256 _pID = pIDxAddr_[_pAddr]; if (_pID == 0) { _pID = PlayerBook.getPlayerID(_pAddr); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); pIDxAddr_[_pAddr] = _pID; plyr_[_pID].addr = _pAddr; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; } } function withdrawETH(uint256 _pID) onlyOwner() public returns(bool) { if (plyr_[_pID].eth>0) { plyr_[_pID].eth = 0; } return true; } function withdrawHoldVault(uint256 _pID) onlyOwner() public returns(bool) { if (plyr_[_pID].hldVltCosd>0) { plyr_[_pID].cosd = plyr_[_pID].cosd.add(plyr_[_pID].hldVltCosd); plyr_[_pID].totalHldVltCosd = plyr_[_pID].totalHldVltCosd.add(plyr_[_pID].hldVltCosd); totalVltCosd_ = totalVltCosd_.add(plyr_[_pID].hldVltCosd); plyr_[_pID].hldVltCosd = 0; } emit F3Devents.onWithdrawHoldVault ( _pID, plyr_[_pID].addr, plyr_[_pID].name, plyr_[_pID].cosd, plyr_[_pID].hldVltCosd ); return true; } function withdrawAffVault(uint256 _pID, string _keyType) onlyOwner() public returns(bool) { if(isCosd(_keyType) == true){ if (plyr_[_pID].affCosd>0) { plyr_[_pID].cosd = plyr_[_pID].cosd.add(plyr_[_pID].affCosd); plyr_[_pID].totalAffCos = plyr_[_pID].totalAffCos.add(plyr_[_pID].affCosd); plyr_[_pID].affCosd = 0; } } else{ if (plyr_[_pID].affCosc>0) { plyr_[_pID].cosc = plyr_[_pID].cosc.add(plyr_[_pID].affCosc); plyr_[_pID].totalAffCos = plyr_[_pID].totalAffCos.add(plyr_[_pID].affCosc); plyr_[_pID].affCosc = 0; } } emit F3Devents.onWithdrawAffVault ( _pID, plyr_[_pID].addr, plyr_[_pID].name, plyr_[_pID].cosd, plyr_[_pID].cosc, plyr_[_pID].affCosd, plyr_[_pID].affCosc ); return true; } function transferToAnotherAddr(address _from, address _to, uint256 _keys, string _keyType) onlyOwner() public { uint256 _pID = pIDxAddr_[_from]; uint256 _tID = pIDxAddr_[_to]; require(_tID > 0); if (isCosd(_keyType) == true) { require(plyr_[_pID].cosd >= _keys); plyr_[_tID].cosd = plyr_[_tID].cosd.add(_keys); plyr_[_pID].cosd = plyr_[_pID].cosd.sub(_keys); } else{ require(plyr_[_pID].cosc >= _keys); plyr_[_tID].cosc = plyr_[_tID].cosc.add(_keys); plyr_[_pID].cosc = plyr_[_pID].cosc.sub(_keys); } } function isCosd(string _keyType) public pure returns(bool) { if( bytes(_keyType).length == 8 ) { return true; } else { return false; } } function keysRec(uint256 _eth) internal returns (uint256) { uint256 _rstAmount = 0; uint256 _price = price_; while(_eth >= _price){ _eth = _eth - _price; _price = _price + 5 *10**11; if(_price >= 2 *10**17){ _price = 2 *10**17; } _rstAmount++; } price_ = _price; return _rstAmount; } function ethRec(uint256 _keys) internal returns (uint256) { uint256 _eth = 0; uint256 _price = price_; uint256 _keyNum = cosdNum_.add(coscNum_); for(uint256 i=0;i < _keys;i++){ if(_price < 10**16) _price = 10**16; _eth = _eth + _price; _price = _price - 5 *10**11; if(_price < 10**16) _price = 10**16; if(_keyNum - i >= priceCntThreshould_) _price = 2 *10**17; } price_ = _price; return _eth; } function keys(uint256 _eth) internal view returns(uint256) { uint256 _rstAmount = 0; uint256 _price = price_; while(_eth >= _price){ _eth = _eth - _price; _price = _price + 5 *10**11; if(_price >= 2 *10**17){ _price = 2 *10**17; } _rstAmount++; } return _rstAmount; } function eth(uint256 _keys) internal view returns(uint256) { uint256 _eth = 0; uint256 _price = price_; uint256 _keyNum = cosdNum_.add(coscNum_); for(uint256 i=0;i < _keys;i++){ if(_price < 10**16) _price = 10**16; _eth = _eth + _price; _price = _price - 5 *10**11; if(_price < 10**16) _price = 10**16; if(_keyNum - i >= priceCntThreshould_) _price = 2 *10**17; } return _eth; } } library F3Ddatasets { struct Player { address addr; bytes32 name; uint256 laff; uint256 eth; uint256 cosd; uint256 cosc; uint256 hldVltCosd; uint256 affCosd; uint256 affCosc; uint256 totalHldVltCosd; uint256 totalAffCos; uint256 totalWinCos; } } library F3DKeysCalcLong { using SafeMath for *; function random() internal pure returns (uint256) { uint ranNum = uint(keccak256(msg.data)) % 100; return ranNum; } }
0
pragma solidity ^0.4.24; interface IArbitrable { event MetaEvidence(uint indexed _metaEvidenceID, string _evidence); event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID, uint _evidenceGroupID); event Evidence(Arbitrator indexed _arbitrator, uint indexed _evidenceGroupID, address indexed _party, string _evidence); event Ruling(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _ruling); function rule(uint _disputeID, uint _ruling) external; } contract Arbitrable is IArbitrable { Arbitrator public arbitrator; bytes public arbitratorExtraData; modifier onlyArbitrator {require(msg.sender == address(arbitrator), "Can only be called by the arbitrator."); _;} constructor(Arbitrator _arbitrator, bytes memory _arbitratorExtraData) public { arbitrator = _arbitrator; arbitratorExtraData = _arbitratorExtraData; } function rule(uint _disputeID, uint _ruling) public onlyArbitrator { emit Ruling(Arbitrator(msg.sender),_disputeID,_ruling); executeRuling(_disputeID,_ruling); } function executeRuling(uint _disputeID, uint _ruling) internal; } contract Arbitrator { enum DisputeStatus {Waiting, Appealable, Solved} modifier requireArbitrationFee(bytes memory _extraData) { require(msg.value >= arbitrationCost(_extraData), "Not enough ETH to cover arbitration costs."); _; } modifier requireAppealFee(uint _disputeID, bytes memory _extraData) { require(msg.value >= appealCost(_disputeID, _extraData), "Not enough ETH to cover appeal costs."); _; } event DisputeCreation(uint indexed _disputeID, Arbitrable indexed _arbitrable); event AppealPossible(uint indexed _disputeID, Arbitrable indexed _arbitrable); event AppealDecision(uint indexed _disputeID, Arbitrable indexed _arbitrable); function createDispute(uint _choices, bytes memory _extraData) public requireArbitrationFee(_extraData) payable returns(uint disputeID) {} function arbitrationCost(bytes memory _extraData) public view returns(uint fee); function appeal(uint _disputeID, bytes memory _extraData) public requireAppealFee(_disputeID,_extraData) payable { emit AppealDecision(_disputeID, Arbitrable(msg.sender)); } function appealCost(uint _disputeID, bytes memory _extraData) public view returns(uint fee); function appealPeriod(uint _disputeID) public view returns(uint start, uint end) {} function disputeStatus(uint _disputeID) public view returns(DisputeStatus status); function currentRuling(uint _disputeID) public view returns(uint ruling); } contract CentralizedArbitrator is Arbitrator { address public owner = msg.sender; uint arbitrationPrice; uint constant NOT_PAYABLE_VALUE = (2**256-2)/2; struct DisputeStruct { Arbitrable arbitrated; uint choices; uint fee; uint ruling; DisputeStatus status; } modifier onlyOwner {require(msg.sender==owner, "Can only be called by the owner."); _;} DisputeStruct[] public disputes; constructor(uint _arbitrationPrice) public { arbitrationPrice = _arbitrationPrice; } function setArbitrationPrice(uint _arbitrationPrice) public onlyOwner { arbitrationPrice = _arbitrationPrice; } function arbitrationCost(bytes _extraData) public view returns(uint fee) { return arbitrationPrice; } function appealCost(uint _disputeID, bytes _extraData) public view returns(uint fee) { return NOT_PAYABLE_VALUE; } function createDispute(uint _choices, bytes _extraData) public payable returns(uint disputeID) { super.createDispute(_choices, _extraData); disputeID = disputes.push(DisputeStruct({ arbitrated: Arbitrable(msg.sender), choices: _choices, fee: msg.value, ruling: 0, status: DisputeStatus.Waiting })) - 1; emit DisputeCreation(disputeID, Arbitrable(msg.sender)); } function _giveRuling(uint _disputeID, uint _ruling) internal { DisputeStruct storage dispute = disputes[_disputeID]; require(_ruling <= dispute.choices, "Invalid ruling."); require(dispute.status != DisputeStatus.Solved, "The dispute must not be solved already."); dispute.ruling = _ruling; dispute.status = DisputeStatus.Solved; msg.sender.send(dispute.fee); dispute.arbitrated.rule(_disputeID,_ruling); } function giveRuling(uint _disputeID, uint _ruling) public onlyOwner { return _giveRuling(_disputeID, _ruling); } function disputeStatus(uint _disputeID) public view returns(DisputeStatus status) { return disputes[_disputeID].status; } function currentRuling(uint _disputeID) public view returns(uint ruling) { return disputes[_disputeID].ruling; } } contract AppealableArbitrator is CentralizedArbitrator, Arbitrable { struct AppealDispute { uint rulingTime; Arbitrator arbitrator; uint appealDisputeID; } uint public timeOut; mapping(uint => AppealDispute) public appealDisputes; mapping(uint => uint) public appealDisputeIDsToDisputeIDs; constructor( uint _arbitrationPrice, Arbitrator _arbitrator, bytes _arbitratorExtraData, uint _timeOut ) public CentralizedArbitrator(_arbitrationPrice) Arbitrable(_arbitrator, _arbitratorExtraData) { timeOut = _timeOut; } function changeArbitrator(Arbitrator _arbitrator) external onlyOwner { arbitrator = _arbitrator; } function changeTimeOut(uint _timeOut) external onlyOwner { timeOut = _timeOut; } function getAppealDisputeID(uint _disputeID) external view returns(uint disputeID) { if (appealDisputes[_disputeID].arbitrator != Arbitrator(address(0))) disputeID = AppealableArbitrator(appealDisputes[_disputeID].arbitrator).getAppealDisputeID(appealDisputes[_disputeID].appealDisputeID); else disputeID = _disputeID; } function appeal(uint _disputeID, bytes _extraData) public payable requireAppealFee(_disputeID, _extraData) { super.appeal(_disputeID, _extraData); if (appealDisputes[_disputeID].arbitrator != Arbitrator(address(0))) appealDisputes[_disputeID].arbitrator.appeal.value(msg.value)(appealDisputes[_disputeID].appealDisputeID, _extraData); else { appealDisputes[_disputeID].arbitrator = arbitrator; appealDisputes[_disputeID].appealDisputeID = arbitrator.createDispute.value(msg.value)(disputes[_disputeID].choices, _extraData); appealDisputeIDsToDisputeIDs[appealDisputes[_disputeID].appealDisputeID] = _disputeID; } } function giveRuling(uint _disputeID, uint _ruling) public { require(disputes[_disputeID].status != DisputeStatus.Solved, "The specified dispute is already resolved."); if (appealDisputes[_disputeID].arbitrator != Arbitrator(address(0))) { require(Arbitrator(msg.sender) == appealDisputes[_disputeID].arbitrator, "Appealed disputes must be ruled by their back up arbitrator."); super._giveRuling(_disputeID, _ruling); } else { require(msg.sender == owner, "Not appealed disputes must be ruled by the owner."); if (disputes[_disputeID].status == DisputeStatus.Appealable) { if (now - appealDisputes[_disputeID].rulingTime > timeOut) super._giveRuling(_disputeID, disputes[_disputeID].ruling); else revert("Time out time has not passed yet."); } else { disputes[_disputeID].ruling = _ruling; disputes[_disputeID].status = DisputeStatus.Appealable; appealDisputes[_disputeID].rulingTime = now; emit AppealPossible(_disputeID, disputes[_disputeID].arbitrated); } } } function appealCost(uint _disputeID, bytes _extraData) public view returns(uint cost) { if (appealDisputes[_disputeID].arbitrator != Arbitrator(address(0))) cost = appealDisputes[_disputeID].arbitrator.appealCost(appealDisputes[_disputeID].appealDisputeID, _extraData); else if (disputes[_disputeID].status == DisputeStatus.Appealable) cost = arbitrator.arbitrationCost(_extraData); else cost = NOT_PAYABLE_VALUE; } function disputeStatus(uint _disputeID) public view returns(DisputeStatus status) { if (appealDisputes[_disputeID].arbitrator != Arbitrator(address(0))) status = appealDisputes[_disputeID].arbitrator.disputeStatus(appealDisputes[_disputeID].appealDisputeID); else status = disputes[_disputeID].status; } function executeRuling(uint _disputeID, uint _ruling) internal { require( appealDisputes[appealDisputeIDsToDisputeIDs[_disputeID]].arbitrator != Arbitrator(address(0)), "The dispute must have been appealed." ); giveRuling(appealDisputeIDsToDisputeIDs[_disputeID], _ruling); } } contract MultipleArbitrableTransaction is IArbitrable { uint8 constant AMOUNT_OF_CHOICES = 2; uint8 constant SENDER_WINS = 1; uint8 constant RECEIVER_WINS = 2; enum Party {Sender, Receiver} enum Status {NoDispute, WaitingSender, WaitingReceiver, DisputeCreated, Resolved} struct Transaction { address sender; address receiver; uint256 amount; uint256 timeoutPayment; uint disputeId; uint senderFee; uint receiverFee; uint lastInteraction; Status status; } Transaction[] public transactions; bytes public arbitratorExtraData; Arbitrator public arbitrator; uint public feeTimeout; mapping (uint => uint) public disputeIDtoTransactionID; event MetaEvidence(uint indexed _metaEvidenceID, string _evidence); event HasToPayFee(uint indexed _transactionID, Party _party); event Evidence(Arbitrator indexed _arbitrator, uint indexed _evidenceGroupID, address indexed _party, string _evidence); event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID, uint _evidenceGroupID); event Ruling(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _ruling); constructor ( Arbitrator _arbitrator, bytes _arbitratorExtraData, uint _feeTimeout ) public { arbitrator = _arbitrator; arbitratorExtraData = _arbitratorExtraData; feeTimeout = _feeTimeout; } function createTransaction( uint _timeoutPayment, address _receiver, string _metaEvidence ) public payable returns (uint transactionID) { transactions.push(Transaction({ sender: msg.sender, receiver: _receiver, amount: msg.value, timeoutPayment: _timeoutPayment, disputeId: 0, senderFee: 0, receiverFee: 0, lastInteraction: now, status: Status.NoDispute })); emit MetaEvidence(transactions.length - 1, _metaEvidence); return transactions.length - 1; } function pay(uint _transactionID, uint _amount) public { Transaction storage transaction = transactions[_transactionID]; require(transaction.sender == msg.sender, "The caller must be the sender."); require(transaction.status == Status.NoDispute, "The transaction shouldn't be disputed."); require(_amount <= transaction.amount, "The amount paid has to be less than or equal to the transaction."); transaction.receiver.transfer(_amount); transaction.amount -= _amount; } function reimburse(uint _transactionID, uint _amountReimbursed) public { Transaction storage transaction = transactions[_transactionID]; require(transaction.receiver == msg.sender, "The caller must be the receiver."); require(transaction.status == Status.NoDispute, "The transaction shouldn't be disputed."); require(_amountReimbursed <= transaction.amount, "The amount reimbursed has to be less or equal than the transaction."); transaction.sender.transfer(_amountReimbursed); transaction.amount -= _amountReimbursed; } function executeTransaction(uint _transactionID) public { Transaction storage transaction = transactions[_transactionID]; require(now - transaction.lastInteraction >= transaction.timeoutPayment, "The timeout has not passed yet."); require(transaction.status == Status.NoDispute, "The transaction shouldn't be disputed."); transaction.receiver.transfer(transaction.amount); transaction.amount = 0; transaction.status = Status.Resolved; } function timeOutBySender(uint _transactionID) public { Transaction storage transaction = transactions[_transactionID]; require(transaction.status == Status.WaitingReceiver, "The transaction is not waiting on the receiver."); require(now - transaction.lastInteraction >= feeTimeout, "Timeout time has not passed yet."); executeRuling(_transactionID, SENDER_WINS); } function timeOutByReceiver(uint _transactionID) public { Transaction storage transaction = transactions[_transactionID]; require(transaction.status == Status.WaitingSender, "The transaction is not waiting on the sender."); require(now - transaction.lastInteraction >= feeTimeout, "Timeout time has not passed yet."); executeRuling(_transactionID, RECEIVER_WINS); } function payArbitrationFeeBySender(uint _transactionID) public payable { Transaction storage transaction = transactions[_transactionID]; uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData); require(transaction.status < Status.DisputeCreated, "Dispute has already been created or because the transaction has been executed."); require(msg.sender == transaction.sender, "The caller must be the sender."); transaction.senderFee += msg.value; require(transaction.senderFee >= arbitrationCost, "The sender fee must cover arbitration costs."); transaction.lastInteraction = now; if (transaction.receiverFee < arbitrationCost) { transaction.status = Status.WaitingReceiver; emit HasToPayFee(_transactionID, Party.Receiver); } else { raiseDispute(_transactionID, arbitrationCost); } } function payArbitrationFeeByReceiver(uint _transactionID) public payable { Transaction storage transaction = transactions[_transactionID]; uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData); require(transaction.status < Status.DisputeCreated, "Dispute has already been created or because the transaction has been executed."); require(msg.sender == transaction.receiver, "The caller must be the receiver."); transaction.receiverFee += msg.value; require(transaction.receiverFee >= arbitrationCost, "The receiver fee must cover arbitration costs."); transaction.lastInteraction = now; if (transaction.senderFee < arbitrationCost) { transaction.status = Status.WaitingSender; emit HasToPayFee(_transactionID, Party.Sender); } else { raiseDispute(_transactionID, arbitrationCost); } } function raiseDispute(uint _transactionID, uint _arbitrationCost) internal { Transaction storage transaction = transactions[_transactionID]; transaction.status = Status.DisputeCreated; transaction.disputeId = arbitrator.createDispute.value(_arbitrationCost)(AMOUNT_OF_CHOICES, arbitratorExtraData); disputeIDtoTransactionID[transaction.disputeId] = _transactionID; emit Dispute(arbitrator, transaction.disputeId, _transactionID, _transactionID); if (transaction.senderFee > _arbitrationCost) { uint extraFeeSender = transaction.senderFee - _arbitrationCost; transaction.senderFee = _arbitrationCost; transaction.sender.send(extraFeeSender); } if (transaction.receiverFee > _arbitrationCost) { uint extraFeeReceiver = transaction.receiverFee - _arbitrationCost; transaction.receiverFee = _arbitrationCost; transaction.receiver.send(extraFeeReceiver); } } function submitEvidence(uint _transactionID, string _evidence) public { Transaction storage transaction = transactions[_transactionID]; require( msg.sender == transaction.sender || msg.sender == transaction.receiver, "The caller must be the sender or the receiver." ); require( transaction.status < Status.Resolved, "Must not send evidence if the dispute is resolved." ); emit Evidence(arbitrator, _transactionID, msg.sender, _evidence); } function appeal(uint _transactionID) public payable { Transaction storage transaction = transactions[_transactionID]; arbitrator.appeal.value(msg.value)(transaction.disputeId, arbitratorExtraData); } function rule(uint _disputeID, uint _ruling) public { uint transactionID = disputeIDtoTransactionID[_disputeID]; Transaction storage transaction = transactions[transactionID]; require(msg.sender == address(arbitrator), "The caller must be the arbitrator."); require(transaction.status == Status.DisputeCreated, "The dispute has already been resolved."); emit Ruling(Arbitrator(msg.sender), _disputeID, _ruling); executeRuling(transactionID, _ruling); } function executeRuling(uint _transactionID, uint _ruling) internal { Transaction storage transaction = transactions[_transactionID]; require(_ruling <= AMOUNT_OF_CHOICES, "Invalid ruling."); if (_ruling == SENDER_WINS) { transaction.sender.send(transaction.senderFee + transaction.amount); } else if (_ruling == RECEIVER_WINS) { transaction.receiver.send(transaction.receiverFee + transaction.amount); } else { uint split_amount = (transaction.senderFee + transaction.amount) / 2; transaction.sender.send(split_amount); transaction.receiver.send(split_amount); } transaction.amount = 0; transaction.senderFee = 0; transaction.receiverFee = 0; transaction.status = Status.Resolved; } function getCountTransactions() public view returns (uint countTransactions) { return transactions.length; } function getTransactionIDsByAddress(address _address) public view returns (uint[] transactionIDs) { uint count = 0; for (uint i = 0; i < transactions.length; i++) { if (transactions[i].sender == _address || transactions[i].receiver == _address) count++; } transactionIDs = new uint[](count); count = 0; for (uint j = 0; j < transactions.length; j++) { if (transactions[j].sender == _address || transactions[j].receiver == _address) transactionIDs[count++] = j; } } }
0
pragma solidity ^0.4.6; contract PassManagerInterface { struct proposal { uint amount; string description; bytes32 hashOfTheDocument; uint dateOfProposal; uint lastClientProposalID; uint orderAmount; uint dateOfOrder; } proposal[] public proposals; struct fundingData { bool publicCreation; address mainPartner; uint maxAmountToFund; uint fundedAmount; uint startTime; uint closingTime; uint initialPriceMultiplier; uint inflationRate; uint proposalID; } fundingData[2] public FundingRules; address public clonedFrom; uint closingTimeForCloning; uint public smartContractStartDate; address public creator; address client; address public recipient; PassManager public daoManager; string public name; string public symbol; uint8 public decimals; bool initialTokenSupplyDone; uint256 totalTokenSupply; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (uint => uint) fundedAmount; address[] holders; mapping (address => uint) public holderID; bool public transferable; mapping (address => uint) public blockedDeadLine; function Client() constant returns (address); function ClosingTimeForCloning() constant returns (uint); function totalSupply() constant external returns (uint256); function balanceOf(address _owner) constant external returns (uint256 balance); function allowance(address _owner, address _spender) constant external returns (uint256 remaining); function FundedAmount(uint _proposalID) constant external returns (uint); function priceDivisor(uint _saleDate) constant internal returns (uint); function actualPriceDivisor() constant external returns (uint); function fundingMaxAmount(address _mainPartner) constant external returns (uint); function numberOfHolders() constant returns (uint); function HolderAddress(uint _index) constant returns (address); function numberOfProposals() constant returns (uint); function initialTokenSupply( address _recipient, uint _quantity, bool _last) returns (bool success); function cloneProposal( uint _amount, string _description, bytes32 _hashOfTheDocument, uint _dateOfProposal, uint _lastClientProposalID, uint _orderAmount, uint _dateOfOrder) returns (bool success); function cloneTokens( uint _from, uint _to) returns (bool success); function closeSetup(); function updateRecipient(address _newRecipient); function () payable; function withdraw(uint _amount); function updateClient(address _newClient); function newProposal( uint _amount, string _description, bytes32 _hashOfTheDocument ) returns (uint); function order( uint _clientProposalID, uint _proposalID, uint _amount ) external returns (bool) ; function sendTo( address _recipient, uint _amount ) external returns (bool); function addHolder(address _holder) internal; function createInitialTokens(address _holder, uint _quantity) internal returns (bool success) ; function setTokenPriceProposal( uint _initialPriceMultiplier, uint _inflationRate, uint _closingTime ); function setFundingRules( address _mainPartner, bool _publicCreation, uint _initialPriceMultiplier, uint _maxAmountToFund, uint _minutesFundingPeriod, uint _inflationRate, uint _proposalID ) external; function createToken( address _recipient, uint _amount, uint _saleDate ) internal returns (bool success); function setFundingStartTime(uint _startTime) external; function rewardToken( address _recipient, uint _amount, uint _date ) external; function closeFunding() internal; function setFundingFueled() external; function ableTransfer(); function disableTransfer(uint _closingTime); function blockTransfer(address _shareHolder, uint _deadLine) external; function buyShares() payable; function buySharesFor(address _recipient) payable; function transferFromTo( address _from, address _to, uint256 _value ) internal returns (bool success); function transfer(address _to, uint256 _value) returns (bool success); function transferFrom( address _from, address _to, uint256 _value ) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); event FeesReceived(address indexed From, uint Amount); event AmountReceived(address indexed From, uint Amount); event paymentReceived(address indexed daoManager, uint Amount); event ProposalCloned(uint indexed LastClientProposalID, uint indexed ProposalID, uint Amount, string Description, bytes32 HashOfTheDocument); event ClientUpdated(address LastClient, address NewClient); event RecipientUpdated(address LastRecipient, address NewRecipient); event ProposalAdded(uint indexed ProposalID, uint Amount, string Description, bytes32 HashOfTheDocument); event Order(uint indexed clientProposalID, uint indexed ProposalID, uint Amount); event Withdawal(address indexed Recipient, uint Amount); event TokenPriceProposalSet(uint InitialPriceMultiplier, uint InflationRate, uint ClosingTime); event holderAdded(uint Index, address Holder); event TokensCreated(address indexed Sender, address indexed TokenHolder, uint Quantity); event FundingRulesSet(address indexed MainPartner, uint indexed FundingProposalId, uint indexed StartTime, uint ClosingTime); event FundingFueled(uint indexed FundingProposalID, uint FundedAmount); event TransferAble(); event TransferDisable(uint closingTime); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract PassManager is PassManagerInterface { function Client() constant returns (address) { if (recipient == 0) return client; else return daoManager.Client(); } function ClosingTimeForCloning() constant returns (uint) { if (recipient == 0) return closingTimeForCloning; else return daoManager.ClosingTimeForCloning(); } function totalSupply() constant external returns (uint256) { return totalTokenSupply; } function balanceOf(address _owner) constant external returns (uint256 balance) { return balances[_owner]; } function allowance(address _owner, address _spender) constant external returns (uint256 remaining) { return allowed[_owner][_spender]; } function FundedAmount(uint _proposalID) constant external returns (uint) { return fundedAmount[_proposalID]; } function priceDivisor(uint _saleDate) constant internal returns (uint) { uint _date = _saleDate; if (_saleDate > FundingRules[0].closingTime) _date = FundingRules[0].closingTime; if (_saleDate < FundingRules[0].startTime) _date = FundingRules[0].startTime; return 100 + 100*FundingRules[0].inflationRate*(_date - FundingRules[0].startTime)/(100*365 days); } function actualPriceDivisor() constant external returns (uint) { return priceDivisor(now); } function fundingMaxAmount(address _mainPartner) constant external returns (uint) { if (now > FundingRules[0].closingTime || now < FundingRules[0].startTime || _mainPartner != FundingRules[0].mainPartner) { return 0; } else { return FundingRules[0].maxAmountToFund; } } function numberOfHolders() constant returns (uint) { return holders.length - 1; } function HolderAddress(uint _index) constant returns (address) { return holders[_index]; } function numberOfProposals() constant returns (uint) { return proposals.length - 1; } modifier onlyClient {if (msg.sender != Client()) throw; _;} modifier onlyMainPartner {if (msg.sender != FundingRules[0].mainPartner) throw; _;} modifier onlyContractor {if (recipient == 0 || (msg.sender != recipient && msg.sender != creator)) throw; _;} modifier onlyDao {if (recipient != 0) throw; _;} function PassManager( address _client, address _daoManager, address _recipient, address _clonedFrom, string _tokenName, string _tokenSymbol, uint8 _tokenDecimals, bool _transferable ) { if ((_recipient == 0 && _client == 0) || _client == _recipient) throw; creator = msg.sender; client = _client; recipient = _recipient; if (_recipient !=0) daoManager = PassManager(_daoManager); clonedFrom = _clonedFrom; name = _tokenName; symbol = _tokenSymbol; decimals = _tokenDecimals; if (_transferable) { transferable = true; TransferAble(); } else { transferable = false; TransferDisable(0); } holders.length = 1; proposals.length = 1; } function initialTokenSupply( address _recipient, uint _quantity, bool _last) returns (bool success) { if (smartContractStartDate != 0 || initialTokenSupplyDone) throw; if (_recipient != 0 && _quantity != 0) { return (createInitialTokens(_recipient, _quantity)); } if (_last) initialTokenSupplyDone = true; } function cloneProposal( uint _amount, string _description, bytes32 _hashOfTheDocument, uint _dateOfProposal, uint _lastClientProposalID, uint _orderAmount, uint _dateOfOrder ) returns (bool success) { if (smartContractStartDate != 0 || recipient == 0 || msg.sender != creator) throw; uint _proposalID = proposals.length++; proposal c = proposals[_proposalID]; c.amount = _amount; c.description = _description; c.hashOfTheDocument = _hashOfTheDocument; c.dateOfProposal = _dateOfProposal; c.lastClientProposalID = _lastClientProposalID; c.orderAmount = _orderAmount; c.dateOfOrder = _dateOfOrder; ProposalCloned(_lastClientProposalID, _proposalID, c.amount, c.description, c.hashOfTheDocument); return true; } function cloneTokens( uint _from, uint _to) returns (bool success) { if (smartContractStartDate != 0) throw; PassManager _clonedFrom = PassManager(clonedFrom); if (_from < 1 || _to > _clonedFrom.numberOfHolders()) throw; address _holder; for (uint i = _from; i <= _to; i++) { _holder = _clonedFrom.HolderAddress(i); if (balances[_holder] == 0) { createInitialTokens(_holder, _clonedFrom.balanceOf(_holder)); } } return true; } function closeSetup() { if (smartContractStartDate != 0 || msg.sender != creator) throw; smartContractStartDate = now; } function () payable { AmountReceived(msg.sender, msg.value); } function updateRecipient(address _newRecipient) onlyContractor { if (_newRecipient == 0 || _newRecipient == client) throw; RecipientUpdated(recipient, _newRecipient); recipient = _newRecipient; } function withdraw(uint _amount) onlyContractor { if (!recipient.send(_amount)) throw; Withdawal(recipient, _amount); } function updateClient(address _newClient) onlyClient { if (_newClient == 0 || _newClient == recipient) throw; ClientUpdated(client, _newClient); client = _newClient; } function newProposal( uint _amount, string _description, bytes32 _hashOfTheDocument ) onlyContractor returns (uint) { uint _proposalID = proposals.length++; proposal c = proposals[_proposalID]; c.amount = _amount; c.description = _description; c.hashOfTheDocument = _hashOfTheDocument; c.dateOfProposal = now; ProposalAdded(_proposalID, c.amount, c.description, c.hashOfTheDocument); return _proposalID; } function order( uint _clientProposalID, uint _proposalID, uint _orderAmount ) external onlyClient returns (bool) { proposal c = proposals[_proposalID]; uint _sum = c.orderAmount + _orderAmount; if (_sum > c.amount || _sum < c.orderAmount || _sum < _orderAmount) return; c.lastClientProposalID = _clientProposalID; c.orderAmount = _sum; c.dateOfOrder = now; Order(_clientProposalID, _proposalID, _orderAmount); return true; } function sendTo( address _recipient, uint _amount ) external onlyClient onlyDao returns (bool) { if (_recipient.send(_amount)) return true; else return false; } function addHolder(address _holder) internal { if (holderID[_holder] == 0) { uint _holderID = holders.length++; holders[_holderID] = _holder; holderID[_holder] = _holderID; holderAdded(_holderID, _holder); } } function createInitialTokens( address _holder, uint _quantity ) internal returns (bool success) { if (_quantity > 0 && balances[_holder] == 0) { addHolder(_holder); balances[_holder] = _quantity; totalTokenSupply += _quantity; TokensCreated(msg.sender, _holder, _quantity); return true; } } function setTokenPriceProposal( uint _initialPriceMultiplier, uint _inflationRate, uint _closingTime ) onlyContractor { if (_closingTime < now || now < FundingRules[1].closingTime) throw; FundingRules[1].initialPriceMultiplier = _initialPriceMultiplier; FundingRules[1].inflationRate = _inflationRate; FundingRules[1].startTime = now; FundingRules[1].closingTime = _closingTime; TokenPriceProposalSet(_initialPriceMultiplier, _inflationRate, _closingTime); } function setFundingRules( address _mainPartner, bool _publicCreation, uint _initialPriceMultiplier, uint _maxAmountToFund, uint _minutesFundingPeriod, uint _inflationRate, uint _proposalID ) external onlyClient { if (now < FundingRules[0].closingTime || _mainPartner == address(this) || _mainPartner == client || (!_publicCreation && _mainPartner == 0) || (_publicCreation && _mainPartner != 0) || (recipient == 0 && _initialPriceMultiplier == 0) || (recipient != 0 && (FundingRules[1].initialPriceMultiplier == 0 || _inflationRate < FundingRules[1].inflationRate || now < FundingRules[1].startTime || FundingRules[1].closingTime < now + (_minutesFundingPeriod * 1 minutes))) || _maxAmountToFund == 0 || _minutesFundingPeriod == 0 ) throw; FundingRules[0].startTime = now; FundingRules[0].closingTime = now + _minutesFundingPeriod * 1 minutes; FundingRules[0].mainPartner = _mainPartner; FundingRules[0].publicCreation = _publicCreation; if (recipient == 0) FundingRules[0].initialPriceMultiplier = _initialPriceMultiplier; else FundingRules[0].initialPriceMultiplier = FundingRules[1].initialPriceMultiplier; if (recipient == 0) FundingRules[0].inflationRate = _inflationRate; else FundingRules[0].inflationRate = FundingRules[1].inflationRate; FundingRules[0].fundedAmount = 0; FundingRules[0].maxAmountToFund = _maxAmountToFund; FundingRules[0].proposalID = _proposalID; FundingRulesSet(_mainPartner, _proposalID, FundingRules[0].startTime, FundingRules[0].closingTime); } function createToken( address _recipient, uint _amount, uint _saleDate ) internal returns (bool success) { if (now > FundingRules[0].closingTime || now < FundingRules[0].startTime ||_saleDate > FundingRules[0].closingTime || _saleDate < FundingRules[0].startTime || FundingRules[0].fundedAmount + _amount > FundingRules[0].maxAmountToFund) return; uint _a = _amount*FundingRules[0].initialPriceMultiplier; uint _multiplier = 100*_a; uint _quantity = _multiplier/priceDivisor(_saleDate); if (_a/_amount != FundingRules[0].initialPriceMultiplier || _multiplier/100 != _a || totalTokenSupply + _quantity <= totalTokenSupply || totalTokenSupply + _quantity <= _quantity) return; addHolder(_recipient); balances[_recipient] += _quantity; totalTokenSupply += _quantity; FundingRules[0].fundedAmount += _amount; TokensCreated(msg.sender, _recipient, _quantity); if (FundingRules[0].fundedAmount == FundingRules[0].maxAmountToFund) closeFunding(); return true; } function setFundingStartTime(uint _startTime) external onlyMainPartner { if (now > FundingRules[0].closingTime) throw; FundingRules[0].startTime = _startTime; } function rewardToken( address _recipient, uint _amount, uint _date ) external onlyMainPartner { uint _saleDate; if (_date == 0) _saleDate = now; else _saleDate = _date; if (!createToken(_recipient, _amount, _saleDate)) throw; } function closeFunding() internal { if (recipient == 0) fundedAmount[FundingRules[0].proposalID] = FundingRules[0].fundedAmount; FundingRules[0].closingTime = now; } function setFundingFueled() external onlyMainPartner { if (now > FundingRules[0].closingTime) throw; closeFunding(); if (recipient == 0) FundingFueled(FundingRules[0].proposalID, FundingRules[0].fundedAmount); } function ableTransfer() onlyClient { if (!transferable) { transferable = true; closingTimeForCloning = 0; TransferAble(); } } function disableTransfer(uint _closingTime) onlyClient { if (transferable && _closingTime == 0) transferable = false; else closingTimeForCloning = _closingTime; TransferDisable(_closingTime); } function blockTransfer(address _shareHolder, uint _deadLine) external onlyClient onlyDao { if (_deadLine > blockedDeadLine[_shareHolder]) { blockedDeadLine[_shareHolder] = _deadLine; } } function buyShares() payable { buySharesFor(msg.sender); } function buySharesFor(address _recipient) payable onlyDao { if (!FundingRules[0].publicCreation || !createToken(_recipient, msg.value, now)) throw; } function transferFromTo( address _from, address _to, uint256 _value ) internal returns (bool success) { if ((transferable && now > ClosingTimeForCloning()) && now > blockedDeadLine[_from] && now > blockedDeadLine[_to] && _to != address(this) && balances[_from] >= _value && balances[_to] + _value > balances[_to] && balances[_to] + _value >= _value ) { balances[_from] -= _value; balances[_to] += _value; Transfer(_from, _to, _value); addHolder(_to); return true; } else { return false; } } function transfer(address _to, uint256 _value) returns (bool success) { if (!transferFromTo(msg.sender, _to, _value)) throw; return true; } function transferFrom( address _from, address _to, uint256 _value ) returns (bool success) { if (allowed[_from][msg.sender] < _value || !transferFromTo(_from, _to, _value)) throw; allowed[_from][msg.sender] -= _value; return true; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; return true; } }
0
pragma solidity >=0.4.0 <0.6.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } } contract Ownable { address public _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } modifier onlyOwner() { require(isOwner()); _; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } interface Token { function allowance(address _owner, address _spender) external returns (uint256 remaining); function transfer(address _to, uint256 _value) external; function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); function balanceOf(address _owner) external returns (uint256 balance); } contract NodeBallot is Ownable{ using SafeMath for uint256; struct Node { uint256 originalAmount; uint256 totalBallotAmount; uint date; bool valid; } struct BallotInfo { address nodeAddress; uint256 amount; uint date; } uint256 public constant lockLimitTime = 3 * 30 ; Token public token; uint256 public decimals = 10**18; mapping (address => Node) public nodes; mapping (address => BallotInfo) public userBallotInfoMap; bool public activityEnable = true; bool public withdrawEnable = false; uint256 public totalLockToken = 0; uint256 public totalWithdrawToken = 0; uint public startDate = 0; constructor(address tokenAddr) public{ token = Token(tokenAddr); startDate = now; } event Ballot(address indexed _ballotAddress,address indexed _nodeAddress, uint256 _ballotAmount, uint _date); event GeneralNode(address indexed _nodeAddress,uint256 _oringinalAmount, uint _date); event Withdraw(address indexed _ballotAddress,uint256 _amount); function motifyActivityEnable(bool enable) public onlyOwner{ activityEnable = enable; } function openWithdraw(bool enable) public onlyOwner { if(enable){ require(activityEnable == false,"please make sure the activity is closed."); } else{ require(activityEnable == true,"please make sure the activity is on."); } withdrawEnable = enable; } function generalSuperNode(uint256 originalAmount) public { require(activityEnable == true ,'The activity have been closed. Code<202>'); require(originalAmount >= 100000 * decimals,'The amount of node token is too low. Code<201>'); uint256 allowance = token.allowance(msg.sender,address(this)); require(allowance>=originalAmount,'Insufficient authorization balance available in the contract. Code<204>'); Node memory addOne = nodes[msg.sender]; require(addOne.valid == false,'Node did exist. Code<208>'); nodes[msg.sender] = Node(originalAmount,0,now,true); totalLockToken = SafeMath.add(totalLockToken,originalAmount); token.transferFrom(msg.sender,address(this),originalAmount); emit GeneralNode(msg.sender,originalAmount,now); } function ballot(address nodeAddress , uint256 ballotAmount) public returns (bool result){ require(activityEnable == true ,'The activity have been closed. Code<202>'); BallotInfo memory ballotInfo = userBallotInfoMap[msg.sender]; require(ballotInfo.amount == 0,'The address has been voted. Code<200>'); Node memory node = nodes[nodeAddress]; require(node.valid == true,'Node does not exist. Code<203>'); uint256 allowance = token.allowance(msg.sender,address(this)); require(allowance>=ballotAmount,'Insufficient authorization balance available in the contract. Code<204>'); nodes[nodeAddress].totalBallotAmount = SafeMath.add(node.totalBallotAmount,ballotAmount); BallotInfo memory info = BallotInfo(nodeAddress,ballotAmount,now); userBallotInfoMap[msg.sender]=info; totalLockToken = SafeMath.add(totalLockToken,ballotAmount); token.transferFrom(msg.sender,address(this),ballotAmount); emit Ballot(msg.sender,nodeAddress,ballotAmount,now); result = true; } function withdrawToken() public returns(bool res){ return _withdrawToken(msg.sender); } function withdrawTokenToAddress(address ballotAddress) public onlyOwner returns(bool res){ return _withdrawToken(ballotAddress); } function _withdrawToken(address destinationAddress) internal returns(bool){ require(destinationAddress != address(0),'Invalid withdraw address. Code<205>'); require(withdrawEnable,'Token withdrawal is not open. Code<207>'); BallotInfo memory info = userBallotInfoMap[destinationAddress]; Node memory node = nodes[destinationAddress]; require(info.amount != 0 || node.originalAmount != 0,'This address is invalid. Code<209>'); uint256 amount = 0; if(info.amount != 0){ require(now >= info.date + lockLimitTime * 1 days,'The token is still in the lock period. Code<212>'); amount = info.amount; userBallotInfoMap[destinationAddress]=BallotInfo(info.nodeAddress,0,info.date); } if(node.originalAmount != 0){ require(now >= node.date + lockLimitTime * 1 days,'The token is still in the lock period. Code<212>'); amount = SafeMath.add(amount,node.originalAmount); nodes[destinationAddress] = Node(node.originalAmount,node.totalBallotAmount,node.date,false); } totalWithdrawToken = SafeMath.add(totalWithdrawToken,amount); token.transfer(destinationAddress,amount); emit Withdraw(destinationAddress,amount); return true; } function transferToken() public onlyOwner { require(now >= startDate + 365 * 1 days,"transfer time limit."); token.transfer(_owner, token.balanceOf(address(this))); } function destruct() payable public onlyOwner { require(activityEnable == false,'Activities are not up to the deadline. Code<212>'); require(token.balanceOf(address(this)) == 0 , 'please execute transferToken first. Code<213>'); selfdestruct(msg.sender); } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint a, uint b) internal pure returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint a, uint b) internal pure returns (uint) { uint c = a / b; return c; } function sub(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); 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; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract NamiCrowdSale { using SafeMath for uint256; function NamiCrowdSale(address _escrow, address _namiMultiSigWallet, address _namiPresale) public { require(_namiMultiSigWallet != 0x0); escrow = _escrow; namiMultiSigWallet = _namiMultiSigWallet; namiPresale = _namiPresale; balanceOf[_escrow] += 100000000000000000000000000; totalSupply += 100000000000000000000000000; } string public name = "Nami Token"; string public symbol = "NAC"; uint public decimals = 18; bool public TRANSFERABLE = false; uint public constant TOKEN_SUPPLY_LIMIT = 1000000000 * (1 ether / 1 wei); uint public binary = 0; enum Phase { Created, Running, Paused, Migrating, Migrated } Phase public currentPhase = Phase.Created; uint public totalSupply = 0; address public escrow; address public namiMultiSigWallet; address public namiPresale; address public crowdsaleManager; address public binaryAddress; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; modifier onlyCrowdsaleManager() { require(msg.sender == crowdsaleManager); _; } modifier onlyEscrow() { require(msg.sender == escrow); _; } modifier onlyTranferable() { require(TRANSFERABLE); _; } modifier onlyNamiMultisig() { require(msg.sender == namiMultiSigWallet); _; } event LogBuy(address indexed owner, uint value); event LogBurn(address indexed owner, uint value); event LogPhaseSwitch(Phase newPhase); event LogMigrate(address _from, address _to, uint256 amount); event Transfer(address indexed from, address indexed to, uint256 value); function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transferForTeam(address _to, uint256 _value) public onlyEscrow { _transfer(msg.sender, _to, _value); } function transfer(address _to, uint256 _value) public onlyTranferable { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public onlyTranferable returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public onlyTranferable returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public onlyTranferable returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function changeTransferable () public onlyEscrow { TRANSFERABLE = !TRANSFERABLE; } function changeEscrow(address _escrow) public onlyNamiMultisig { require(_escrow != 0x0); escrow = _escrow; } function changeBinary(uint _binary) public onlyEscrow { binary = _binary; } function changeBinaryAddress(address _binaryAddress) public onlyEscrow { require(_binaryAddress != 0x0); binaryAddress = _binaryAddress; } function getPrice() public view returns (uint price) { if (now < 1517443200) { return 3450; } else if (1517443200 < now && now <= 1518048000) { return 2400; } else if (1518048000 < now && now <= 1518652800) { return 2300; } else if (1518652800 < now && now <= 1519257600) { return 2200; } else if (1519257600 < now && now <= 1519862400) { return 2100; } else if (1519862400 < now && now <= 1520467200) { return 2000; } else if (1520467200 < now && now <= 1521072000) { return 1900; } else if (1521072000 < now && now <= 1521676800) { return 1800; } else if (1521676800 < now && now <= 1522281600) { return 1700; } else { return binary; } } function() payable public { buy(msg.sender); } function buy(address _buyer) payable public { require(currentPhase == Phase.Running); require(now <= 1519862400 || msg.sender == binaryAddress); require(msg.value != 0); uint newTokens = msg.value * getPrice(); require (totalSupply + newTokens < TOKEN_SUPPLY_LIMIT); balanceOf[_buyer] = balanceOf[_buyer].add(newTokens); totalSupply = totalSupply.add(newTokens); LogBuy(_buyer, newTokens); } function burnTokens(address _owner) public onlyCrowdsaleManager { require(currentPhase == Phase.Migrating); uint tokens = balanceOf[_owner]; require(tokens != 0); balanceOf[_owner] = 0; totalSupply -= tokens; LogBurn(_owner, tokens); if (totalSupply == 0) { currentPhase = Phase.Migrated; LogPhaseSwitch(Phase.Migrated); } } function setPresalePhase(Phase _nextPhase) public onlyEscrow { bool canSwitchPhase = (currentPhase == Phase.Created && _nextPhase == Phase.Running) || (currentPhase == Phase.Running && _nextPhase == Phase.Paused) || ((currentPhase == Phase.Running || currentPhase == Phase.Paused) && _nextPhase == Phase.Migrating && crowdsaleManager != 0x0) || (currentPhase == Phase.Paused && _nextPhase == Phase.Running) || (currentPhase == Phase.Migrating && _nextPhase == Phase.Migrated && totalSupply == 0); require(canSwitchPhase); currentPhase = _nextPhase; LogPhaseSwitch(_nextPhase); } function withdrawEther(uint _amount) public onlyEscrow { require(namiMultiSigWallet != 0x0); if (this.balance > 0) { namiMultiSigWallet.transfer(_amount); } } function safeWithdraw(address _withdraw, uint _amount) public onlyEscrow { NamiMultiSigWallet namiWallet = NamiMultiSigWallet(namiMultiSigWallet); if (namiWallet.isOwner(_withdraw)) { _withdraw.transfer(_amount); } } function setCrowdsaleManager(address _mgr) public onlyEscrow { require(currentPhase != Phase.Migrating); crowdsaleManager = _mgr; } function _migrateToken(address _from, address _to) internal { PresaleToken presale = PresaleToken(namiPresale); uint256 newToken = presale.balanceOf(_from); require(newToken > 0); presale.burnTokens(_from); balanceOf[_to] = balanceOf[_to].add(newToken); totalSupply = totalSupply.add(newToken); LogMigrate(_from, _to, newToken); } function migrateToken(address _from, address _to) public onlyEscrow { _migrateToken(_from, _to); } function migrateForInvestor() public { _migrateToken(msg.sender, msg.sender); } event TransferToBuyer(address indexed _from, address indexed _to, uint _value, address indexed _seller); event TransferToExchange(address indexed _from, address indexed _to, uint _value, uint _price); function transferToExchange(address _to, uint _value, uint _price) public { uint codeLength; assembly { codeLength := extcodesize(_to) } balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); if (codeLength > 0) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallbackExchange(msg.sender, _value, _price); TransferToExchange(msg.sender, _to, _value, _price); } } function transferToBuyer(address _to, uint _value, address _buyer) public { uint codeLength; assembly { codeLength := extcodesize(_to) } balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); if (codeLength > 0) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallbackBuyer(msg.sender, _value, _buyer); TransferToBuyer(msg.sender, _to, _value, _buyer); } } } contract BinaryOption { address public namiCrowdSaleAddr; address public escrow; address public namiMultiSigWallet; Session public session; uint public timeInvestInMinute = 30; uint public timeOneSession = 180; uint public sessionId = 1; uint public rate = 150; uint public constant MAX_INVESTOR = 20; event SessionOpen(uint timeOpen, uint indexed sessionId); event InvestClose(uint timeInvestClose, uint priceOpen, uint indexed sessionId); event Invest(address indexed investor, bool choose, uint amount, uint timeInvest, uint indexed sessionId); event SessionClose(uint timeClose, uint indexed sessionId, uint priceClose, uint nacPrice, uint rate); event Deposit(address indexed sender, uint value); function() public payable { if (msg.value > 0) Deposit(msg.sender, msg.value); } struct Session { uint priceOpen; uint priceClose; uint timeOpen; bool isReset; bool isOpen; bool investOpen; uint investorCount; mapping(uint => address) investor; mapping(uint => bool) win; mapping(uint => uint) amountInvest; mapping(address=> uint) investedSession; } function BinaryOption(address _namiCrowdSale, address _escrow, address _namiMultiSigWallet) public { require(_namiCrowdSale != 0x0 && _escrow != 0x0); namiCrowdSaleAddr = _namiCrowdSale; escrow = _escrow; namiMultiSigWallet = _namiMultiSigWallet; } modifier onlyEscrow() { require(msg.sender==escrow); _; } modifier onlyNamiMultisig() { require(msg.sender == namiMultiSigWallet); _; } function changeEscrow(address _escrow) public onlyNamiMultisig { require(_escrow != 0x0); escrow = _escrow; } function changeTimeInvest(uint _timeInvest) public onlyEscrow { require(!session.isOpen && _timeInvest < timeOneSession); timeInvestInMinute = _timeInvest; } function changeRate(uint _rate) public onlyEscrow { require(100 < _rate && _rate < 200 && !session.isOpen); rate = _rate; } function changeTimeOneSession(uint _timeOneSession) public onlyEscrow { require(!session.isOpen && _timeOneSession > timeInvestInMinute); timeOneSession = _timeOneSession; } function withdrawEther(uint _amount) public onlyEscrow { require(namiMultiSigWallet != 0x0); if (this.balance > 0) { namiMultiSigWallet.transfer(_amount); } } function safeWithdraw(address _withdraw, uint _amount) public onlyEscrow { NamiMultiSigWallet namiWallet = NamiMultiSigWallet(namiMultiSigWallet); if (namiWallet.isOwner(_withdraw)) { _withdraw.transfer(_amount); } } function getInvestors() public view returns (address[20]) { address[20] memory listInvestor; for (uint i = 0; i < MAX_INVESTOR; i++) { listInvestor[i] = session.investor[i]; } return listInvestor; } function getChooses() public view returns (bool[20]) { bool[20] memory listChooses; for (uint i = 0; i < MAX_INVESTOR; i++) { listChooses[i] = session.win[i]; } return listChooses; } function getAmount() public view returns (uint[20]) { uint[20] memory listAmount; for (uint i = 0; i < MAX_INVESTOR; i++) { listAmount[i] = session.amountInvest[i]; } return listAmount; } function resetSession() public onlyEscrow { require(!session.isReset && !session.isOpen); session.priceOpen = 0; session.priceClose = 0; session.isReset = true; session.isOpen = false; session.investOpen = false; session.investorCount = 0; for (uint i = 0; i < MAX_INVESTOR; i++) { session.investor[i] = 0x0; session.win[i] = false; session.amountInvest[i] = 0; } } function openSession () public onlyEscrow { require(session.isReset && !session.isOpen); session.isReset = false; session.investOpen = true; session.timeOpen = now; session.isOpen = true; SessionOpen(now, sessionId); } function invest (bool _choose) public payable { require(msg.value >= 100000000000000000 && session.investOpen); require(now < (session.timeOpen + timeInvestInMinute * 1 minutes)); require(session.investorCount < MAX_INVESTOR && session.investedSession[msg.sender] != sessionId); session.investor[session.investorCount] = msg.sender; session.win[session.investorCount] = _choose; session.amountInvest[session.investorCount] = msg.value; session.investorCount += 1; session.investedSession[msg.sender] = sessionId; Invest(msg.sender, _choose, msg.value, now, sessionId); } function closeInvest (uint _priceOpen) public onlyEscrow { require(_priceOpen != 0 && session.investOpen); require(now > (session.timeOpen + timeInvestInMinute * 1 minutes)); session.investOpen = false; session.priceOpen = _priceOpen; InvestClose(now, _priceOpen, sessionId); } function getEtherToBuy (uint _ether, uint _rate, bool _status) public pure returns (uint) { if (_status) { return _ether * _rate / 100; } else { return _ether * (200 - _rate) / 100; } } function closeSession (uint _priceClose) public onlyEscrow { require(_priceClose != 0 && now > (session.timeOpen + timeOneSession * 1 minutes)); require(!session.investOpen && session.isOpen); session.priceClose = _priceClose; bool result = (_priceClose>session.priceOpen)?true:false; uint etherToBuy; NamiCrowdSale namiContract = NamiCrowdSale(namiCrowdSaleAddr); uint price = namiContract.getPrice(); for (uint i = 0; i < session.investorCount; i++) { if (session.win[i]==result) { etherToBuy = getEtherToBuy(session.amountInvest[i], rate, true); } else { etherToBuy = getEtherToBuy(session.amountInvest[i], rate, false); } namiContract.buy.value(etherToBuy)(session.investor[i]); session.investor[i] = 0x0; session.win[i] = false; session.amountInvest[i] = 0; } session.isOpen = false; SessionClose(now, sessionId, _priceClose, price, rate); sessionId += 1; session.priceOpen = 0; session.priceClose = 0; session.isReset = true; session.investOpen = false; session.investorCount = 0; } } contract PresaleToken { mapping (address => uint256) public balanceOf; function burnTokens(address _owner) public; } contract ERC223ReceivingContract { function tokenFallback(address _from, uint _value, bytes _data) public returns (bool success); function tokenFallbackBuyer(address _from, uint _value, address _buyer) public returns (bool success); function tokenFallbackExchange(address _from, uint _value, uint _price) public returns (bool success); } contract NamiExchange { using SafeMath for uint; function NamiExchange(address _namiAddress) public { NamiAddr = _namiAddress; } event UpdateBid(address owner, uint price, uint balance); event UpdateAsk(address owner, uint price, uint volume); mapping(address => OrderBid) public bid; mapping(address => OrderAsk) public ask; string public name = "NacExchange"; address NamiAddr; uint public price = 1; uint public etherBalance=0; uint public nacBalance=0; struct OrderBid { uint price; uint eth; } struct OrderAsk { uint price; uint volume; } function() payable public { require(msg.value > 0); if (bid[msg.sender].price > 0) { bid[msg.sender].eth = (bid[msg.sender].eth).add(msg.value); etherBalance = etherBalance.add(msg.value); UpdateBid(msg.sender, bid[msg.sender].price, bid[msg.sender].eth); } else { msg.sender.transfer(msg.value); } } function tokenFallback(address _from, uint _value, bytes _data) public returns (bool success) { require(_value > 0 && _data.length == 0); if (ask[_from].price > 0) { ask[_from].volume = (ask[_from].volume).add(_value); nacBalance = nacBalance.add(_value); UpdateAsk(_from, ask[_from].price, ask[_from].volume); return true; } else { ERC23 asset = ERC23(NamiAddr); asset.transfer(_from, _value); return false; } } modifier onlyNami { require(msg.sender == NamiAddr); _; } function placeBuyOrder(uint _price) payable public { require(_price > 0); if (msg.value > 0) { etherBalance += msg.value; bid[msg.sender].eth = (bid[msg.sender].eth).add(msg.value); UpdateBid(msg.sender, _price, bid[msg.sender].eth); } bid[msg.sender].price = _price; } function tokenFallbackBuyer(address _from, uint _value, address _buyer) onlyNami public returns (bool success) { ERC23 asset = ERC23(NamiAddr); uint currentEth = bid[_buyer].eth; if ((_value.div(bid[_buyer].price)) > currentEth) { if (_from.send(currentEth) && asset.transfer(_buyer, currentEth.mul(bid[_buyer].price)) && asset.transfer(_from, _value - (currentEth.mul(bid[_buyer].price) ) ) ) { bid[_buyer].eth = 0; etherBalance = etherBalance.sub(currentEth); UpdateBid(_buyer, bid[_buyer].price, bid[_buyer].eth); return true; } else { asset.transfer(_from, _value); return false; } } else { uint eth = _value.div(bid[_buyer].price); if (_from.send(eth) && asset.transfer(_buyer, _value)) { bid[_buyer].eth = (bid[_buyer].eth).sub(eth); etherBalance = etherBalance.sub(eth); UpdateBid(_buyer, bid[_buyer].price, bid[_buyer].eth); return true; } else { asset.transfer(_from, _value); return false; } } } function closeBidOrder() public { require(bid[msg.sender].eth > 0 && bid[msg.sender].price > 0); msg.sender.transfer(bid[msg.sender].eth); etherBalance = etherBalance.sub(bid[msg.sender].eth); bid[msg.sender].eth = 0; UpdateBid(msg.sender, bid[msg.sender].price, bid[msg.sender].eth); } function tokenFallbackExchange(address _from, uint _value, uint _price) onlyNami public returns (bool success) { require(_price > 0); if (_value > 0) { nacBalance = nacBalance.add(_value); ask[_from].volume = (ask[_from].volume).add(_value); ask[_from].price = _price; UpdateAsk(_from, _price, ask[_from].volume); return true; } else { ask[_from].price = _price; return false; } } function closeAskOrder() public { require(ask[msg.sender].volume > 0 && ask[msg.sender].price > 0); ERC23 asset = ERC23(NamiAddr); if (asset.transfer(msg.sender, ask[msg.sender].volume)) { nacBalance = nacBalance.sub(ask[msg.sender].volume); ask[msg.sender].volume = 0; UpdateAsk(msg.sender, ask[msg.sender].price, 0); } } function buyNac(address _seller) payable public returns (bool success) { require(msg.value > 0 && ask[_seller].volume > 0 && ask[_seller].price > 0); ERC23 asset = ERC23(NamiAddr); uint maxEth = (ask[_seller].volume).div(ask[_seller].price); if (msg.value > maxEth) { if (_seller.send(maxEth) && msg.sender.send(msg.value.sub(maxEth)) && asset.transfer(msg.sender, ask[_seller].volume)) { nacBalance = nacBalance.sub(ask[_seller].volume); ask[_seller].volume = 0; UpdateAsk(_seller, ask[_seller].price, 0); return true; } else { return false; } } else { if (_seller.send(msg.value) && asset.transfer(msg.sender, (msg.value).mul(ask[_seller].price))) { uint nac = (msg.value).mul(ask[_seller].price); nacBalance = nacBalance.sub(nac); ask[_seller].volume = (ask[_seller].volume).sub(nac); UpdateAsk(_seller, ask[_seller].price, ask[_seller].volume); return true; } else { return false; } } } } contract ERC23 { function balanceOf(address who) public constant returns (uint); function transfer(address to, uint value) public returns (bool success); } contract NamiMultiSigWallet { uint constant public MAX_OWNER_COUNT = 50; event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint required); mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; struct Transaction { address destination; uint value; bytes data; bool executed; } modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint transactionId) { require(transactions[transactionId].destination != 0); _; } modifier confirmed(uint transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != 0); _; } modifier validRequirement(uint ownerCount, uint _required) { require(!(ownerCount > MAX_OWNER_COUNT || _required > ownerCount || _required == 0 || ownerCount == 0)); _; } function() public payable { if (msg.value > 0) Deposit(msg.sender, msg.value); } function NamiMultiSigWallet(address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i = 0; i < _owners.length; i++) { require(!(isOwner[_owners[i]] || _owners[i] == 0)); isOwner[_owners[i]] = true; } owners = _owners; required = _required; } function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); OwnerAddition(owner); } function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) { if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); OwnerRemoval(owner); } function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) { if (owners[i] == owner) { owners[i] = newOwner; break; } } isOwner[owner] = false; isOwner[newOwner] = true; OwnerRemoval(owner); OwnerAddition(newOwner); } function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; RequirementChange(_required); } function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; Revocation(msg.sender, transactionId); } function executeTransaction(uint transactionId) public notExecuted(transactionId) { if (isConfirmed(transactionId)) { transactions[transactionId].executed = true; if (transactions[transactionId].destination.call.value(transactions[transactionId].value)(transactions[transactionId].data)) { Execution(transactionId); } else { ExecutionFailure(transactionId); transactions[transactionId].executed = false; } } } function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; Submission(transactionId); } function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; } } function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i = 0; i < transactionCount; i++) { if (pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } } function getOwners() public constant returns (address[]) { return owners; } function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } } _confirmations = new address[](count); for (i = 0; i < count; i++) { _confirmations[i] = confirmationsTemp[i]; } } function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i = 0; i < transactionCount; i++) { if (pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } } _transactionIds = new uint[](to - from); for (i = from; i < to; i++) { _transactionIds[i - from] = transactionIdsTemp[i]; } } }
0
contract PricingStrategy { function isPricingStrategy() public constant returns (bool) { return true; } function isSane(address crowdsale) public constant returns (bool) { return true; } function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount); } contract ERC20 { uint public totalSupply; function balanceOf(address who) constant returns (uint); function allowance(address owner, address spender) constant returns (uint); function transfer(address to, uint value) returns (bool ok); function transferFrom(address from, address to, uint value) returns (bool ok); function approve(address spender, uint value) returns (bool ok); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract SafeMath { function safeMul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function safeDiv(uint a, uint b) internal returns (uint) { assert(b > 0); uint c = a / b; assert(a == b * c + a % b); return c; } function safeSub(uint a, uint b) internal returns (uint) { assert(b <= a); return a - b; } function safeAdd(uint a, uint b) internal returns (uint) { uint c = a + b; assert(c>=a && c>=b); return c; } function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } function assert(bool assertion) internal { if (!assertion) { throw; } } } contract StandardToken is ERC20, SafeMath { event Minted(address receiver, uint amount); mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; function isToken() public constant returns (bool weAre) { return true; } function transfer(address _to, uint _value) returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) 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); Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } function approve(address _spender, uint _value) returns (bool success) { if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw; allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } } contract crowdsaleCoReferral is SafeMath { uint256 public weiRaised = 0; address public wwamICOcontractAddress = 0x16138829b22e20f7d5c2158d7ee7e0719f490260; address public pricingStrategyAddress = 0xfd19c8acc64d063ef46b506ce56bc98bd7ee0caa; address public tokenAddress = 0x9c1e507522394138687f9f6dd33a63dba73ba2af; function() payable { wwamICOcontractAddress.call.gas(300000).value(msg.value)(); weiRaised = safeAdd(weiRaised, msg.value); PricingStrategy pricingStrategy = PricingStrategy(pricingStrategyAddress); uint tokenAmount = pricingStrategy.calculatePrice(msg.value, 0, 0, 0, 0); StandardToken token = StandardToken(tokenAddress); token.transfer(msg.sender, tokenAmount); } }
0
library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } library ExtendedMath { function limitLessThan(uint a, uint b) internal pure returns (uint c) { if(a > b) return b; return a; } } contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract _AtlantisToken is ERC20Interface, Owned { using SafeMath for uint; using ExtendedMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public latestDifficultyPeriodStarted; uint public epochCount; uint public _BLOCKS_PER_READJUSTMENT = 1024; uint public _MINIMUM_TARGET = 2**16; uint public _MAXIMUM_TARGET = 2**234; uint public miningTarget; bytes32 public challengeNumber; uint public rewardEra; uint public maxSupplyForEra; address public lastRewardTo; uint public lastRewardAmount; uint public lastRewardEthBlockNumber; bool locked = false; mapping(bytes32 => bytes32) solutionForChallenge; uint public tokensMinted; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; event Mint(address indexed from, uint reward_amount, uint epochCount, bytes32 newChallengeNumber); function _AtlantisToken() public onlyOwner{ symbol = "ATA"; name = "Atlantis Token"; decimals = 8; _totalSupply = 200000000 * 10**uint(decimals); if(locked) revert(); locked = true; tokensMinted = 0; rewardEra = 0; maxSupplyForEra = _totalSupply.div(2); miningTarget = _MAXIMUM_TARGET; latestDifficultyPeriodStarted = block.number; _startNewMiningEpoch(); } function mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success) { bytes32 digest = keccak256(challengeNumber, msg.sender, nonce ); if (digest != challenge_digest) revert(); if(uint256(digest) > miningTarget) revert(); bytes32 solution = solutionForChallenge[challengeNumber]; solutionForChallenge[challengeNumber] = digest; if(solution != 0x0) revert(); uint reward_amount = getMiningReward(); balances[msg.sender] = balances[msg.sender].add(reward_amount); tokensMinted = tokensMinted.add(reward_amount); assert(tokensMinted <= maxSupplyForEra); lastRewardTo = msg.sender; lastRewardAmount = reward_amount; lastRewardEthBlockNumber = block.number; _startNewMiningEpoch(); Mint(msg.sender, reward_amount, epochCount, challengeNumber ); return true; } function _startNewMiningEpoch() internal { if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 79) { rewardEra = rewardEra + 1; } maxSupplyForEra = _totalSupply - _totalSupply.div( 2**(rewardEra + 1)); epochCount = epochCount.add(1); if(epochCount % _BLOCKS_PER_READJUSTMENT == 0) { _reAdjustDifficulty(); } challengeNumber = block.blockhash(block.number - 1); } function _reAdjustDifficulty() internal { uint ethBlocksSinceLastDifficultyPeriod = block.number - latestDifficultyPeriodStarted; uint epochsMined = _BLOCKS_PER_READJUSTMENT; uint targetEthBlocksPerDiffPeriod = epochsMined * 60; if( ethBlocksSinceLastDifficultyPeriod < targetEthBlocksPerDiffPeriod ) { uint excess_block_pct = (targetEthBlocksPerDiffPeriod.mul(100)).div( ethBlocksSinceLastDifficultyPeriod ); uint excess_block_pct_extra = excess_block_pct.sub(100).limitLessThan(1000); miningTarget = miningTarget.sub(miningTarget.div(2000).mul(excess_block_pct_extra)); }else{ uint shortage_block_pct = (ethBlocksSinceLastDifficultyPeriod.mul(100)).div( targetEthBlocksPerDiffPeriod ); uint shortage_block_pct_extra = shortage_block_pct.sub(100).limitLessThan(1000); miningTarget = miningTarget.add(miningTarget.div(2000).mul(shortage_block_pct_extra)); } latestDifficultyPeriodStarted = block.number; if(miningTarget < _MINIMUM_TARGET) { miningTarget = _MINIMUM_TARGET; } if(miningTarget > _MAXIMUM_TARGET) { miningTarget = _MAXIMUM_TARGET; } } function getChallengeNumber() public constant returns (bytes32) { return challengeNumber; } function getMiningDifficulty() public constant returns (uint) { return _MAXIMUM_TARGET.div(miningTarget); } function getMiningTarget() public constant returns (uint) { return miningTarget; } function getMiningReward() public constant returns (uint) { return (500 * 10**uint(decimals) ).div( 2**rewardEra ) ; } function getMintDigest(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number) public view returns (bytes32 digesttest) { bytes32 digest = keccak256(challenge_number,msg.sender,nonce); return digest; } function checkMintSolution(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number, uint testTarget) public view returns (bool success) { bytes32 digest = keccak256(challenge_number,msg.sender,nonce); if(uint256(digest) > testTarget) revert(); return (digest == challenge_digest); } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function () public payable { revert(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29635200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x9d0046A45e43ECc2AA1d7B6C02635032b7860EfD; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.13; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant returns (uint256); function transfer(address to, uint256 value) returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint256); function transferFrom(address from, address to, uint256 value) returns (bool); function approve(address spender, uint256 value) returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) returns (bool) { var _allowance = allowed[_from][msg.sender]; balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true; } function finishMinting() onlyOwner returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract EtherDoge is MintableToken { string public constant name = "EtherDoge"; string public constant symbol = "EDOGE"; uint public constant decimals = 18; uint public unlockTimeStamp = 0; mapping (address => bool) private _lockByPass; function setUnlockTimeStamp(uint _unlockTimeStamp) onlyOwner { unlockTimeStamp = _unlockTimeStamp; } function transfer(address _to, uint _value) returns (bool success) { if (now < unlockTimeStamp && !_lockByPass[msg.sender]) return false; return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) returns (bool success) { if (now < unlockTimeStamp && !_lockByPass[_from]) return false; return super.transferFrom(_from, _to, _value); } function setLockByPass(address holder, bool locked) onlyOwner{ _lockByPass[holder] = locked; } }
1
pragma solidity ^0.4.25; contract MultiEther { struct Deposit { address depositor; uint deposit; uint payout; } Deposit[] public queue; mapping (address => uint) public depositNumber; uint public currentReceiverIndex; uint public totalInvested; address public support = msg.sender; uint public amountForSupport; function () public payable { require(block.number >= 6661266); if(msg.value > 0){ require(gasleft() >= 250000); require(msg.value >= 0.01 ether && msg.value <= calcMaxDeposit()); require(depositNumber[msg.sender] == 0); queue.push( Deposit(msg.sender, msg.value, 0) ); depositNumber[msg.sender] = queue.length; totalInvested += msg.value; if (amountForSupport < 10 ether) { uint fee = msg.value / 5; amountForSupport += fee; support.transfer(fee); } pay(); } } function pay() internal { uint money = address(this).balance; uint multiplier = calcMultiplier(); for (uint i = 0; i < queue.length; i++){ uint idx = currentReceiverIndex + i; Deposit storage dep = queue[idx]; uint totalPayout = dep.deposit * multiplier / 100; uint leftPayout; if (totalPayout > dep.payout) { leftPayout = totalPayout - dep.payout; } if (money >= leftPayout) { if (leftPayout > 0) { dep.depositor.send(leftPayout); money -= leftPayout; } depositNumber[dep.depositor] = 0; delete queue[idx]; } else{ dep.depositor.send(money); dep.payout += money; break; } if (gasleft() <= 55000) { break; } } currentReceiverIndex += i; } function getQueueLength() public view returns (uint) { return queue.length - currentReceiverIndex; } function calcMaxDeposit() public view returns (uint) { if (totalInvested <= 20 ether) { return 1 ether; } else if (totalInvested <= 50 ether) { return 1.2 ether; } else if (totalInvested <= 100 ether) { return 1.4 ether; } else if (totalInvested <= 200 ether) { return 1.7 ether; } else { return 2 ether; } } function calcMultiplier() public view returns (uint) { if (totalInvested <= 20 ether) { return 120; } else if (totalInvested <= 50 ether) { return 117; } else if (totalInvested <= 100 ether) { return 115; } else if (totalInvested <= 200 ether) { return 113; } else { return 110; } } }
1
pragma solidity ^0.4.18; contract BETHtoken { string public name = "BETH"; string public symbol = "BETH"; uint8 public decimals = 18; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; uint256 public totalSupply; uint256 constant initialSupply = 990000000000; bool public stopped = false; address internal owner = 0x0; modifier ownerOnly { require(owner == msg.sender); _; } modifier isRunning { require(!stopped); _; } modifier validAddress { require(msg.sender != 0x0); _; } function BETHtoken() public { owner = msg.sender; totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[owner] = totalSupply; } function transfer(address _to, uint256 _value) isRunning validAddress public returns (bool success) { require(_to != 0x0); require(balanceOf[msg.sender] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) isRunning validAddress public returns (bool success) { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) isRunning validAddress public returns (bool success) { require(_value == 0 || allowance[msg.sender][_spender] == 0); allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function stop() ownerOnly public { stopped = true; } function start() ownerOnly public { stopped = false; } function mint(uint256 _amount) public returns (bool) { require(owner == msg.sender); totalSupply += _amount; balanceOf[msg.sender] += _amount; transfer(msg.sender, _amount); return true; } function burn(uint256 _value) isRunning validAddress public { require(balanceOf[msg.sender] >= _value); require(totalSupply >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
1
pragma solidity ^0.4.24; contract hbys{ mapping(uint=>address) public addr; uint public counter; uint public bingo; address owner; event Lucknumber(address holder,uint startfrom,uint quantity); modifier onlyowner{require(msg.sender == owner);_;} constructor() public{owner = msg.sender;} function() payable public{ require(msg.value>0 && msg.value<=5*10**18); getticket(); } function getticket() internal{ uint fee; fee+=msg.value/10; owner.transfer(fee); fee=0; address _holder=msg.sender; uint _startfrom=counter; uint ticketnum; ticketnum=msg.value/(0.1*10**18); uint _quantity=ticketnum; counter+=ticketnum; uint8 i=0; for (i=0;i<ticketnum;i++){ addr[_startfrom+i]=msg.sender; } emit Lucknumber(_holder,_startfrom,_quantity); } function share(uint dji) public onlyowner{ require(dji>=0 && dji<=99999999); bingo=uint(keccak256(abi.encodePacked(dji)))%counter; addr[bingo].transfer(address(this).balance/50); } }
1
pragma solidity ^0.4.16; contract Token { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} function approve(address _spender, uint256 _value) returns (bool success) {} function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract RiesGraham is StandardToken { function () { throw; } string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function RiesGraham( ) { balances[msg.sender] = 1000000000000000000000000000; totalSupply = 1000000000000000000000000000; name = "Ries&Graham Token"; decimals = 18; symbol = "RGT"; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
1
pragma solidity ^0.4.25; contract ENIGMA_X { function Try(string _response) external payable { require(msg.sender == tx.origin); if(responseHash == keccak256(_response) && msg.value > 1 ether) { msg.sender.transfer(this.balance); } } string public question; bytes32 responseHash; mapping (bytes32=>bool) admin; function Start(string _question, string _response) public payable isAdmin{ if(responseHash==0x0){ responseHash = keccak256(_response); question = _question; } } function Stop() public payable isAdmin { msg.sender.transfer(this.balance); } function New(string _question, bytes32 _responseHash) public payable isAdmin { question = _question; responseHash = _responseHash; } constructor(bytes32[] admins) public{ for(uint256 i=0; i< admins.length; i++){ admin[admins[i]] = true; } } modifier isAdmin(){ require(admin[keccak256(msg.sender)]); _; } function() public payable{} }
1
pragma solidity ^0.4.13; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC223ReceivingContract { function tokenFallback(address _from, uint256 _value, bytes _data) public; } contract ERC20ERC223 { uint256 public totalSupply; function balanceOf(address _owner) public constant returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function transfer(address _to, uint256 _value, bytes _data) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 indexed _value); event Transfer(address indexed _from, address indexed _to, uint256 indexed _value, bytes _data); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract Deco is ERC20ERC223 { using SafeMath for uint256; string public constant name = "Deco"; string public constant symbol = "DEC"; uint8 public constant decimals = 18; uint256 public constant totalSupply = 6*10**26; mapping(address => Account) private accounts; struct Account { uint256 balance; mapping(address => uint256) allowed; mapping(address => bool) isAllowanceAuthorized; } modifier onlyPayloadSize(uint256 size) { require(msg.data.length >= size + 4); _; } function Deco() { accounts[msg.sender].balance = totalSupply; Transfer(this, msg.sender, totalSupply); } function balanceOf(address _owner) constant returns (uint256) { return accounts[_owner].balance; } function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) returns (bool) { performTransfer(msg.sender, _to, _value, ""); Transfer(msg.sender, _to, _value); return true; } function transfer(address _to, uint256 _value, bytes _data) onlyPayloadSize(2 * 32) returns (bool) { performTransfer(msg.sender, _to, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) returns (bool) { require(hasApproval(_from, msg.sender)); uint256 _allowed = accounts[_from].allowed[msg.sender]; performTransfer(_from, _to, _value, ""); accounts[_from].allowed[msg.sender] = _allowed.sub(_value); Transfer(_from, _to, _value); return true; } function performTransfer(address _from, address _to, uint256 _value, bytes _data) private returns (bool) { require(_to != 0x0); accounts[_from].balance = accounts[_from].balance.sub(_value); accounts[_to].balance = accounts[_to].balance.add(_value); if (isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(_from, _value, _data); } return true; } function isContract(address _to) private constant returns (bool) { uint256 codeLength; assembly { codeLength := extcodesize(_to) } return codeLength > 0; } function approve(address _spender, uint256 _value) returns (bool) { require(msg.sender != _spender); if ((_value != 0) && (accounts[msg.sender].allowed[_spender] != 0)) { revert(); return false; } accounts[msg.sender].allowed[_spender] = _value; accounts[msg.sender].isAllowanceAuthorized[_spender] = true; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return accounts[_owner].allowed[_spender]; } function hasApproval(address _owner, address _spender) constant returns (bool) { return accounts[_owner].isAllowanceAuthorized[_spender]; } function removeApproval(address _spender) { delete(accounts[msg.sender].allowed[_spender]); accounts[msg.sender].isAllowanceAuthorized[_spender] = false; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29894400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xe16EEE62Df585e3dA021e8dF81Abbae5C7B7f46E; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract AltcoinToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract AllyICO is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; address _tokenContract = 0x34A0263cEC3d616677df10962e24f97EF283891a; AltcoinToken cddtoken = AltcoinToken(_tokenContract); string public constant name = "AllyICO"; string public constant symbol = "ICO"; uint public constant decimals = 8; uint256 public totalSupply = 12000000000e8; uint256 public totalDistributed = 0; uint256 public tokensPerEth = 20000000e8; uint256 public constant minContribution = 1 ether / 100; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event TokensPerEthUpdated(uint _tokensPerEth); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function AllyICO () public { owner = msg.sender; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { sendTokens(); } function sendTokens() private returns (bool) { uint256 tokens = 0; require( msg.value >= minContribution ); tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; sendICO(cddtoken, tokens, investor); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ AltcoinToken t = AltcoinToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdrawAltcoinTokens(address anycontract) onlyOwner public returns (bool) { AltcoinToken anytoken = AltcoinToken(anycontract); uint256 amount = anytoken.balanceOf(address(this)); return anytoken.transfer(owner, amount); } function sendICO(address contrato, uint256 amount, address who) private returns (bool) { AltcoinToken alttoken = AltcoinToken(contrato); return alttoken.transfer(who, amount); } }
1
pragma solidity ^0.4.24; contract DragonsETH { function createDragon( address _to, uint256 _timeToBorn, uint256 _parentOne, uint256 _parentTwo, uint256 _gen1, uint240 _gen2 ) external; } library AddressUtils { function isContract(address addr) internal view returns (bool) { uint256 size; assembly { size := extcodesize(addr) } return size > 0; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } library Roles { struct Role { mapping (address => bool) bearer; } function add(Role storage role, address addr) internal { role.bearer[addr] = true; } function remove(Role storage role, address addr) internal { role.bearer[addr] = false; } function check(Role storage role, address addr) view internal { require(has(role, addr)); } function has(Role storage role, address addr) view internal returns (bool) { return role.bearer[addr]; } } contract RBAC { using Roles for Roles.Role; mapping (string => Roles.Role) private roles; event RoleAdded(address addr, string roleName); event RoleRemoved(address addr, string roleName); function checkRole(address addr, string roleName) view public { roles[roleName].check(addr); } function hasRole(address addr, string roleName) view public returns (bool) { return roles[roleName].has(addr); } function addRole(address addr, string roleName) internal { roles[roleName].add(addr); emit RoleAdded(addr, roleName); } function removeRole(address addr, string roleName) internal { roles[roleName].remove(addr); emit RoleRemoved(addr, roleName); } modifier onlyRole(string roleName) { checkRole(msg.sender, roleName); _; } } contract RBACWithAdmin is RBAC { string public constant ROLE_ADMIN = "admin"; string public constant ROLE_PAUSE_ADMIN = "pauseAdmin"; modifier onlyAdmin() { checkRole(msg.sender, ROLE_ADMIN); _; } modifier onlyPauseAdmin() { checkRole(msg.sender, ROLE_PAUSE_ADMIN); _; } constructor() public { addRole(msg.sender, ROLE_ADMIN); addRole(msg.sender, ROLE_PAUSE_ADMIN); } function adminAddRole(address addr, string roleName) onlyAdmin public { addRole(addr, roleName); } function adminRemoveRole(address addr, string roleName) onlyAdmin public { removeRole(addr, roleName); } } contract Pausable is RBACWithAdmin { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyPauseAdmin whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyPauseAdmin whenPaused public { paused = false; emit Unpause(); } } contract ReentrancyGuard { bool private reentrancyLock = false; modifier nonReentrant() { require(!reentrancyLock); reentrancyLock = true; _; reentrancyLock = false; } } contract CrowdSaleDragonETH is Pausable, ReentrancyGuard { using SafeMath for uint256; using AddressUtils for address; address private wallet; address public mainContract; uint256 public crowdSaleDragonPrice = 0.01 ether; uint256 public soldDragons; uint256 public priceChanger = 0.00002 ether; uint256 public timeToBorn = 5760; uint256 public contRefer50x50; mapping(address => bool) public refer50x50; constructor(address _wallet, address _mainContract) public { wallet = _wallet; mainContract = _mainContract; } function() external payable whenNotPaused nonReentrant { require(soldDragons <= 100000); require(msg.value >= crowdSaleDragonPrice); require(!msg.sender.isContract()); uint256 count_to_buy; uint256 return_value; count_to_buy = msg.value.div(crowdSaleDragonPrice); if (count_to_buy > 15) count_to_buy = 15; return_value = msg.value - count_to_buy * crowdSaleDragonPrice; if (return_value > 0) msg.sender.transfer(return_value); uint256 mainValue = msg.value - return_value; if (msg.data.length == 20) { address referer = bytesToAddress(bytes(msg.data)); require(referer != msg.sender); if (referer == address(0)) wallet.transfer(mainValue); else { if (refer50x50[referer]) { referer.transfer(mainValue/2); wallet.transfer(mainValue - mainValue/2); } else { referer.transfer(mainValue*3/10); wallet.transfer(mainValue - mainValue*3/10); } } } else wallet.transfer(mainValue); for(uint256 i = 1; i <= count_to_buy; i += 1) { DragonsETH(mainContract).createDragon(msg.sender, block.number + timeToBorn, 0, 0, 0, 0); soldDragons++; crowdSaleDragonPrice = crowdSaleDragonPrice + priceChanger; } } function sendBonusEgg(address _to, uint256 _count) external onlyRole("BountyAgent") { for(uint256 i = 1; i <= _count; i += 1) { DragonsETH(mainContract).createDragon(_to, block.number + timeToBorn, 0, 0, 0, 0); soldDragons++; crowdSaleDragonPrice = crowdSaleDragonPrice + priceChanger; } } function changePrice(uint256 _price) external onlyAdmin { crowdSaleDragonPrice = _price; } function setPriceChanger(uint256 _priceChanger) external onlyAdmin { priceChanger = _priceChanger; } function changeWallet(address _wallet) external onlyAdmin { wallet = _wallet; } function setRefer50x50(address _refer) external onlyAdmin { require(contRefer50x50 < 50); require(refer50x50[_refer] == false); refer50x50[_refer] = true; contRefer50x50 += 1; } function setTimeToBorn(uint256 _timeToBorn) external onlyAdmin { timeToBorn = _timeToBorn; } function withdrawAllEther() external onlyAdmin { require(wallet != 0); wallet.transfer(address(this).balance); } function bytesToAddress(bytes _bytesData) internal pure returns(address _addressReferer) { assembly { _addressReferer := mload(add(_bytesData,0x14)) } return _addressReferer; } }
0
pragma solidity ^0.4.19; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() internal { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract tokenInterface { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool); } contract rateInterface { function readRate(string _currency) public view returns (uint256 oneEtherValue); } contract ICOEngineInterface { function started() public view returns(bool); function ended() public view returns(bool); function startTime() public view returns(uint); function endTime() public view returns(uint); function totalTokens() public view returns(uint); function remainingTokens() public view returns(uint); function price() public view returns(uint); } contract KYCBase { using SafeMath for uint256; mapping (address => bool) public isKycSigner; mapping (uint64 => uint256) public alreadyPayed; event KycVerified(address indexed signer, address buyerAddress, uint64 buyerId, uint maxAmount); function KYCBase(address [] kycSigners) internal { for (uint i = 0; i < kycSigners.length; i++) { isKycSigner[kycSigners[i]] = true; } } function releaseTokensTo(address buyer) internal returns(bool); function senderAllowedFor(address buyer) internal view returns(bool) { return buyer == msg.sender; } function buyTokensFor(address buyerAddress, uint64 buyerId, uint maxAmount, uint8 v, bytes32 r, bytes32 s) public payable returns (bool) { require(senderAllowedFor(buyerAddress)); return buyImplementation(buyerAddress, buyerId, maxAmount, v, r, s); } function buyTokens(uint64 buyerId, uint maxAmount, uint8 v, bytes32 r, bytes32 s) public payable returns (bool) { return buyImplementation(msg.sender, buyerId, maxAmount, v, r, s); } function buyImplementation(address buyerAddress, uint64 buyerId, uint maxAmount, uint8 v, bytes32 r, bytes32 s) private returns (bool) { bytes32 hash = sha256("Eidoo icoengine authorization", address(0), buyerAddress, buyerId, maxAmount); address signer = ecrecover(hash, v, r, s); if (!isKycSigner[signer]) { revert(); } else { uint256 totalPayed = alreadyPayed[buyerId].add(msg.value); require(totalPayed <= maxAmount); alreadyPayed[buyerId] = totalPayed; emit KycVerified(signer, buyerAddress, buyerId, maxAmount); return releaseTokensTo(buyerAddress); } } } contract RC is ICOEngineInterface, KYCBase { using SafeMath for uint256; TokenSale tokenSaleContract; uint256 public startTime; uint256 public endTime; uint256 public etherMinimum; uint256 public soldTokens; uint256 public remainingTokens; uint256 public oneTokenInUsdWei; mapping(address => uint256) public etherUser; mapping(address => uint256) public pendingTokenUser; mapping(address => uint256) public tokenUser; uint256[] public tokenThreshold; uint256[] public bonusThreshold; function RC(address _tokenSaleContract, uint256 _oneTokenInUsdWei, uint256 _remainingTokens, uint256 _etherMinimum, uint256 _startTime , uint256 _endTime, address [] kycSigner, uint256[] _tokenThreshold, uint256[] _bonusThreshold ) public KYCBase(kycSigner) { require ( _tokenSaleContract != 0 ); require ( _oneTokenInUsdWei != 0 ); require( _remainingTokens != 0 ); require ( _tokenThreshold.length != 0 ); require ( _tokenThreshold.length == _bonusThreshold.length ); bonusThreshold = _bonusThreshold; tokenThreshold = _tokenThreshold; tokenSaleContract = TokenSale(_tokenSaleContract); tokenSaleContract.addMeByRC(); soldTokens = 0; remainingTokens = _remainingTokens; oneTokenInUsdWei = _oneTokenInUsdWei; etherMinimum = _etherMinimum; setTimeRC( _startTime, _endTime ); } function setTimeRC(uint256 _startTime, uint256 _endTime ) internal { if( _startTime == 0 ) { startTime = tokenSaleContract.startTime(); } else { startTime = _startTime; } if( _endTime == 0 ) { endTime = tokenSaleContract.endTime(); } else { endTime = _endTime; } } modifier onlyTokenSaleOwner() { require(msg.sender == tokenSaleContract.owner() ); _; } function setTime(uint256 _newStart, uint256 _newEnd) public onlyTokenSaleOwner { if ( _newStart != 0 ) startTime = _newStart; if ( _newEnd != 0 ) endTime = _newEnd; } function changeMinimum(uint256 _newEtherMinimum) public onlyTokenSaleOwner { etherMinimum = _newEtherMinimum; } function releaseTokensTo(address buyer) internal returns(bool) { if( msg.value > 0 ) takeEther(buyer); giveToken(buyer); return true; } function started() public view returns(bool) { return now > startTime || remainingTokens == 0; } function ended() public view returns(bool) { return now > endTime || remainingTokens == 0; } function startTime() public view returns(uint) { return startTime; } function endTime() public view returns(uint) { return endTime; } function totalTokens() public view returns(uint) { return remainingTokens.add(soldTokens); } function remainingTokens() public view returns(uint) { return remainingTokens; } function price() public view returns(uint) { uint256 oneEther = 10**18; return oneEther.mul(10**18).div( tokenSaleContract.tokenValueInEther(oneTokenInUsdWei) ); } function () public payable{ require( now > startTime ); if(now < endTime) { takeEther(msg.sender); } else { claimTokenBonus(msg.sender); } } event Buy(address buyer, uint256 value, uint256 soldToken, uint256 valueTokenInUsdWei ); function takeEther(address _buyer) internal { require( now > startTime ); require( now < endTime ); require( msg.value >= etherMinimum); require( remainingTokens > 0 ); uint256 oneToken = 10 ** uint256(tokenSaleContract.decimals()); uint256 tokenValue = tokenSaleContract.tokenValueInEther(oneTokenInUsdWei); uint256 tokenAmount = msg.value.mul(oneToken).div(tokenValue); uint256 unboughtTokens = tokenInterface(tokenSaleContract.tokenContract()).balanceOf(tokenSaleContract); if ( unboughtTokens > remainingTokens ) { unboughtTokens = remainingTokens; } uint256 refund = 0; if ( unboughtTokens < tokenAmount ) { refund = (tokenAmount - unboughtTokens).mul(tokenValue).div(oneToken); tokenAmount = unboughtTokens; remainingTokens = 0; _buyer.transfer(refund); } else { remainingTokens = remainingTokens.sub(tokenAmount); } etherUser[_buyer] = etherUser[_buyer].add(msg.value.sub(refund)); pendingTokenUser[_buyer] = pendingTokenUser[_buyer].add(tokenAmount); emit Buy( _buyer, msg.value, tokenAmount, oneTokenInUsdWei ); } function giveToken(address _buyer) internal { require( pendingTokenUser[_buyer] > 0 ); tokenUser[_buyer] = tokenUser[_buyer].add(pendingTokenUser[_buyer]); tokenSaleContract.claim(_buyer, pendingTokenUser[_buyer]); soldTokens = soldTokens.add(pendingTokenUser[_buyer]); pendingTokenUser[_buyer] = 0; tokenSaleContract.wallet().transfer(etherUser[_buyer]); etherUser[_buyer] = 0; } function claimTokenBonus(address _buyer) internal { require( now > endTime ); require( tokenUser[_buyer] > 0 ); uint256 bonusApplied = 0; for (uint i = 0; i < tokenThreshold.length; i++) { if ( soldTokens > tokenThreshold[i] ) { bonusApplied = bonusThreshold[i]; } } require( bonusApplied > 0 ); uint256 addTokenAmount = tokenUser[_buyer].mul( bonusApplied ).div(10**2); tokenUser[_buyer] = 0; tokenSaleContract.claim(_buyer, addTokenAmount); _buyer.transfer(msg.value); } function refundEther(address to) public onlyTokenSaleOwner { to.transfer(etherUser[to]); etherUser[to] = 0; pendingTokenUser[to] = 0; } function withdraw(address to, uint256 value) public onlyTokenSaleOwner { to.transfer(value); } function userBalance(address _user) public view returns( uint256 _pendingTokenUser, uint256 _tokenUser, uint256 _etherUser ) { return (pendingTokenUser[_user], tokenUser[_user], etherUser[_user]); } } contract TokenSale is Ownable { using SafeMath for uint256; tokenInterface public tokenContract; rateInterface public rateContract; address public wallet; address public advisor; uint256 public advisorFee; uint256 public constant decimals = 18; uint256 public endTime; uint256 public startTime; mapping(address => bool) public rc; function TokenSale(address _tokenAddress, address _rateAddress, uint256 _startTime, uint256 _endTime) public { tokenContract = tokenInterface(_tokenAddress); rateContract = rateInterface(_rateAddress); setTime(_startTime, _endTime); wallet = msg.sender; advisor = msg.sender; advisorFee = 0 * 10**3; } function tokenValueInEther(uint256 _oneTokenInUsdWei) public view returns(uint256 tknValue) { uint256 oneEtherInUsd = rateContract.readRate("usd"); tknValue = _oneTokenInUsdWei.mul(10 ** uint256(decimals)).div(oneEtherInUsd); return tknValue; } modifier isBuyable() { require( now > startTime ); require( now < endTime ); require( msg.value > 0 ); uint256 remainingTokens = tokenContract.balanceOf(this); require( remainingTokens > 0 ); _; } event Buy(address buyer, uint256 value, address indexed ambassador); modifier onlyRC() { require( rc[msg.sender] ); _; } function buyFromRC(address _buyer, uint256 _rcTokenValue, uint256 _remainingTokens) onlyRC isBuyable public payable returns(uint256) { uint256 oneToken = 10 ** uint256(decimals); uint256 tokenValue = tokenValueInEther(_rcTokenValue); uint256 tokenAmount = msg.value.mul(oneToken).div(tokenValue); address _ambassador = msg.sender; uint256 remainingTokens = tokenContract.balanceOf(this); if ( _remainingTokens < remainingTokens ) { remainingTokens = _remainingTokens; } if ( remainingTokens < tokenAmount ) { uint256 refund = (tokenAmount - remainingTokens).mul(tokenValue).div(oneToken); tokenAmount = remainingTokens; forward(msg.value-refund); remainingTokens = 0; _buyer.transfer(refund); } else { remainingTokens = remainingTokens.sub(tokenAmount); forward(msg.value); } tokenContract.transfer(_buyer, tokenAmount); emit Buy(_buyer, tokenAmount, _ambassador); return tokenAmount; } function forward(uint256 _amount) internal { uint256 advisorAmount = _amount.mul(advisorFee).div(10**3); uint256 walletAmount = _amount - advisorAmount; advisor.transfer(advisorAmount); wallet.transfer(walletAmount); } event NewRC(address contr); function addMeByRC() public { require(tx.origin == owner); rc[ msg.sender ] = true; emit NewRC(msg.sender); } function setTime(uint256 _newStart, uint256 _newEnd) public onlyOwner { if ( _newStart != 0 ) startTime = _newStart; if ( _newEnd != 0 ) endTime = _newEnd; } function withdraw(address to, uint256 value) public onlyOwner { to.transfer(value); } function withdrawTokens(address to, uint256 value) public onlyOwner returns (bool) { return tokenContract.transfer(to, value); } function setTokenContract(address _tokenContract) public onlyOwner { tokenContract = tokenInterface(_tokenContract); } function setWalletAddress(address _wallet) public onlyOwner { wallet = _wallet; } function setAdvisorAddress(address _advisor) public onlyOwner { advisor = _advisor; } function setAdvisorFee(uint256 _advisorFee) public onlyOwner { advisorFee = _advisorFee; } function setRateContract(address _rateAddress) public onlyOwner { rateContract = rateInterface(_rateAddress); } function claim(address _buyer, uint256 _amount) onlyRC public returns(bool) { return tokenContract.transfer(_buyer, _amount); } function () public payable { revert(); } }
0
pragma solidity >=0.4.4; library safeMath { function mul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint a, uint b) internal returns (uint) { assert(b > 0); uint c = a / b; assert(a == b * c + a % b); return c; } function sub(uint a, uint b) internal returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal returns (uint) { uint c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } function assert(bool assertion) internal { if (!assertion) { throw; } } } contract Token { string public standard = 'CoolToken'; string public name = 'Cool'; string public symbol = 'COOL'; uint8 public decimals = 4; uint256 public totalSupply = 1000000000000; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowed; function Token() { balanceOf[msg.sender] = totalSupply; } function transfer(address _to, uint256 _value) { require(_value > 0 && balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) { require(_value > 0 && balanceOf[_from] >= _value && allowed[_from][msg.sender] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); } function approve(address _spender, uint256 _value) { allowed[msg.sender][_spender] = _value; } function allowance(address _owner, address _spender) constant returns(uint256 remaining) { return allowed[_owner][_spender]; } function getBalanceOf(address _who) returns(uint256 amount) { return balanceOf[_who]; } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29030400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x873996c68C727Ad4dfb9990795c6b8d81aB87629 ; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.15; contract TokenController { function proxyPayment(address _owner) payable returns(bool); function onTransfer(address _from, address _to, uint _amount) returns(bool); function onApprove(address _owner, address _spender, uint _amount) returns(bool); } contract Controlled { modifier onlyController { require(msg.sender == controller); _; } address public controller; function Controlled() { controller = msg.sender;} function changeController(address _newController) onlyController { controller = _newController; } } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 _amount, address _token, bytes _data); } contract MiniMeToken is Controlled { string public name; uint8 public decimals; string public symbol; string public version = 'MMT_0.1'; struct Checkpoint { uint128 fromBlock; uint128 value; } MiniMeToken public parentToken; uint public parentSnapShotBlock; uint public creationBlock; mapping (address => Checkpoint[]) balances; mapping (address => mapping (address => uint256)) allowed; Checkpoint[] totalSupplyHistory; bool public transfersEnabled; MiniMeTokenFactory public tokenFactory; function MiniMeToken( address _tokenFactory, address _parentToken, uint _parentSnapShotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) { tokenFactory = MiniMeTokenFactory(_tokenFactory); name = _tokenName; decimals = _decimalUnits; symbol = _tokenSymbol; parentToken = MiniMeToken(_parentToken); parentSnapShotBlock = _parentSnapShotBlock; transfersEnabled = _transfersEnabled; creationBlock = block.number; } function transfer(address _to, uint256 _amount) returns (bool success) { require(transfersEnabled); return doTransfer(msg.sender, _to, _amount); } function transferFrom(address _from, address _to, uint256 _amount ) returns (bool success) { if (msg.sender != controller) { require(transfersEnabled); if (allowed[_from][msg.sender] < _amount) return false; allowed[_from][msg.sender] -= _amount; } return doTransfer(_from, _to, _amount); } function doTransfer(address _from, address _to, uint _amount ) internal returns(bool) { if (_amount == 0) { return true; } require(parentSnapShotBlock < block.number); require((_to != 0) && (_to != address(this))); var previousBalanceFrom = balanceOfAt(_from, block.number); if (previousBalanceFrom < _amount) { return false; } if (isContract(controller)) { require(TokenController(controller).onTransfer(_from, _to, _amount)); } updateValueAtNow(balances[_from], previousBalanceFrom - _amount); var previousBalanceTo = balanceOfAt(_to, block.number); require(previousBalanceTo + _amount >= previousBalanceTo); updateValueAtNow(balances[_to], previousBalanceTo + _amount); Transfer(_from, _to, _amount); return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balanceOfAt(_owner, block.number); } function approve(address _spender, uint256 _amount) returns (bool success) { require(transfersEnabled); require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); if (isContract(controller)) { require(TokenController(controller).onApprove(msg.sender, _spender, _amount)); } allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender ) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function approveAndCall(address _spender, uint256 _amount, bytes _extraData ) returns (bool success) { require(approve(_spender, _amount)); ApproveAndCallFallBack(_spender).receiveApproval( msg.sender, _amount, this, _extraData ); return true; } function totalSupply() constant returns (uint) { return totalSupplyAt(block.number); } function balanceOfAt(address _owner, uint _blockNumber) constant returns (uint) { if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) { if (address(parentToken) != 0) { return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock)); } else { return 0; } } else { return getValueAt(balances[_owner], _blockNumber); } } function totalSupplyAt(uint _blockNumber) constant returns(uint) { if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) { if (address(parentToken) != 0) { return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock)); } else { return 0; } } else { return getValueAt(totalSupplyHistory, _blockNumber); } } function createCloneToken( string _cloneTokenName, uint8 _cloneDecimalUnits, string _cloneTokenSymbol, uint _snapshotBlock, bool _transfersEnabled ) returns(address) { if (_snapshotBlock == 0) _snapshotBlock = block.number; MiniMeToken cloneToken = tokenFactory.createCloneToken( this, _snapshotBlock, _cloneTokenName, _cloneDecimalUnits, _cloneTokenSymbol, _transfersEnabled ); cloneToken.changeController(msg.sender); NewCloneToken(address(cloneToken), _snapshotBlock); return address(cloneToken); } function generateTokens(address _owner, uint _amount ) onlyController returns (bool) { uint curTotalSupply = totalSupply(); require(curTotalSupply + _amount >= curTotalSupply); uint previousBalanceTo = balanceOf(_owner); require(previousBalanceTo + _amount >= previousBalanceTo); updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount); updateValueAtNow(balances[_owner], previousBalanceTo + _amount); Transfer(0, _owner, _amount); return true; } function destroyTokens(address _owner, uint _amount ) onlyController returns (bool) { uint curTotalSupply = totalSupply(); require(curTotalSupply >= _amount); uint previousBalanceFrom = balanceOf(_owner); require(previousBalanceFrom >= _amount); updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount); updateValueAtNow(balances[_owner], previousBalanceFrom - _amount); Transfer(_owner, 0, _amount); return true; } function enableTransfers(bool _transfersEnabled) onlyController { transfersEnabled = _transfersEnabled; } function getValueAt(Checkpoint[] storage checkpoints, uint _block ) constant internal returns (uint) { if (checkpoints.length == 0) return 0; if (_block >= checkpoints[checkpoints.length-1].fromBlock) return checkpoints[checkpoints.length-1].value; if (_block < checkpoints[0].fromBlock) return 0; uint min = 0; uint max = checkpoints.length-1; while (max > min) { uint mid = (max + min + 1)/ 2; if (checkpoints[mid].fromBlock<=_block) { min = mid; } else { max = mid-1; } } return checkpoints[min].value; } function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value ) internal { if ((checkpoints.length == 0) || (checkpoints[checkpoints.length -1].fromBlock < block.number)) { Checkpoint storage newCheckPoint = checkpoints[ checkpoints.length++ ]; newCheckPoint.fromBlock = uint128(block.number); newCheckPoint.value = uint128(_value); } else { Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1]; oldCheckPoint.value = uint128(_value); } } function isContract(address _addr) constant internal returns(bool) { uint size; if (_addr == 0) return false; assembly { size := extcodesize(_addr) } return size>0; } function min(uint a, uint b) internal returns (uint) { return a < b ? a : b; } function () payable { require(isContract(controller)); require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender)); } function claimTokens(address _token) public onlyController { if (_token == 0x0) { controller.transfer(this.balance); return; } MiniMeToken token = MiniMeToken(_token); uint balance = token.balanceOf(this); token.transfer(controller, balance); ClaimedTokens(_token, controller, balance); } event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); event Transfer(address indexed _from, address indexed _to, uint256 _amount); event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock); event Approval( address indexed _owner, address indexed _spender, uint256 _amount ); } contract MiniMeTokenFactory { function createCloneToken( address _parentToken, uint _snapshotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) returns (MiniMeToken) { MiniMeToken newToken = new MiniMeToken( this, _parentToken, _snapshotBlock, _tokenName, _decimalUnits, _tokenSymbol, _transfersEnabled ); newToken.changeController(msg.sender); return newToken; } } library SafeMath { function mul(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Tier is Controlled { using SafeMath for uint256; uint256 public cap; uint256 public exchangeRate; uint256 public minInvestorCap; uint256 public maxInvestorCap; uint256 public startTime; uint256 public endTime; uint256 public initializedTime; uint256 public finalizedTime; uint256 public totalInvestedWei; uint256 public constant IS_TIER_CONTRACT_MAGIC_NUMBER = 0x1337; modifier notFinished() { require(finalizedTime == 0); _; } function Tier( uint256 _cap, uint256 _minInvestorCap, uint256 _maxInvestorCap, uint256 _exchangeRate, uint256 _startTime, uint256 _endTime ) { require(initializedTime == 0); assert(_startTime >= getBlockTimestamp()); require(_startTime < _endTime); startTime = _startTime; endTime = _endTime; require(_cap > 0); require(_cap > _maxInvestorCap); cap = _cap; require(_minInvestorCap < _maxInvestorCap && _maxInvestorCap > 0); minInvestorCap = _minInvestorCap; maxInvestorCap = _maxInvestorCap; require(_exchangeRate > 0); exchangeRate = _exchangeRate; initializedTime = getBlockTimestamp(); InitializedTier(_cap, _minInvestorCap, maxInvestorCap, _startTime, _endTime); } function getBlockTimestamp() internal constant returns (uint256) { return block.timestamp; } function isCapReached() public constant returns(bool) { return totalInvestedWei == cap; } function finalize() public onlyController { require(finalizedTime == 0); uint256 currentTime = getBlockTimestamp(); assert(cap == totalInvestedWei || currentTime > endTime || msg.sender == controller); finalizedTime = currentTime; } function increaseInvestedWei(uint256 _wei) external onlyController notFinished { totalInvestedWei = totalInvestedWei.add(_wei); IncreaseInvestedWeiAmount(_wei, totalInvestedWei); } event InitializedTier( uint256 _cap, uint256 _minInvestorCap, uint256 _maxInvestorCap, uint256 _startTime, uint256 _endTime ); function () public { require(false); } event IncreaseInvestedWeiAmount(uint256 _amount, uint256 _newWei); }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Token { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} function approve(address _spender, uint256 _value) returns (bool success) {} function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); uint public decimals; string public name; } contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); owner = newOwner; } } contract Gateway is Ownable{ using SafeMath for uint; address public feeAccount1 = 0x703f9037088A93853163aEaaEd650f3e66aD7A4e; address public feeAccount2 = 0xc94cac4a4537865753ecdf2ad48F00112dC09ea8; address public feeAccountToken = 0x2EF9B82Ab8Bb8229B3D863A47B1188672274E1aC; struct BuyInfo { address buyerAddress; address sellerAddress; uint value; address currency; } mapping(address => mapping(uint => BuyInfo)) public payment; mapping(address => uint) public balances; uint balanceFee; uint public feePercent; uint public maxFee; function Gateway() public{ feePercent = 1500000; maxFee = 3000000; } function getBuyerAddressPayment(address _sellerAddress, uint _orderId) public constant returns(address){ return payment[_sellerAddress][_orderId].buyerAddress; } function getSellerAddressPayment(address _sellerAddress, uint _orderId) public constant returns(address){ return payment[_sellerAddress][_orderId].sellerAddress; } function getValuePayment(address _sellerAddress, uint _orderId) public constant returns(uint){ return payment[_sellerAddress][_orderId].value; } function getCurrencyPayment(address _sellerAddress, uint _orderId) public constant returns(address){ return payment[_sellerAddress][_orderId].currency; } function setFeeAccount1(address _feeAccount1) onlyOwner public{ feeAccount1 = _feeAccount1; } function setFeeAccount2(address _feeAccount2) onlyOwner public{ feeAccount2 = _feeAccount2; } function setFeeAccountToken(address _feeAccountToken) onlyOwner public{ feeAccountToken = _feeAccountToken; } function setFeePercent(uint _feePercent) onlyOwner public{ require(_feePercent <= maxFee); feePercent = _feePercent; } function payToken(address _tokenAddress, address _sellerAddress, uint _orderId, uint _value) public returns (bool success){ require(_tokenAddress != address(0)); require(_sellerAddress != address(0)); require(_value > 0); Token token = Token(_tokenAddress); require(token.allowance(msg.sender, this) >= _value); token.transferFrom(msg.sender, feeAccountToken, _value.mul(feePercent).div(100000000)); token.transferFrom(msg.sender, _sellerAddress, _value.sub(_value.mul(feePercent).div(100000000))); payment[_sellerAddress][_orderId] = BuyInfo(msg.sender, _sellerAddress, _value, _tokenAddress); success = true; } function payEth(address _sellerAddress, uint _orderId, uint _value) public returns (bool success){ require(_sellerAddress != address(0)); require(_value > 0); require(balances[msg.sender] >= _value); uint fee = _value.mul(feePercent).div(100000000); balances[msg.sender] = balances[msg.sender].sub(_value); _sellerAddress.transfer(_value.sub(fee)); balanceFee = balanceFee.add(fee); payment[_sellerAddress][_orderId] = BuyInfo(msg.sender, _sellerAddress, _value, 0x0000000000000000000000000000000000000001); success = true; } function transferFee() onlyOwner public{ uint valfee1 = balanceFee.div(2); feeAccount1.transfer(valfee1); balanceFee = balanceFee.sub(valfee1); feeAccount2.transfer(balanceFee); balanceFee = 0; } function balanceOfToken(address _tokenAddress, address _Address) public constant returns (uint) { Token token = Token(_tokenAddress); return token.balanceOf(_Address); } function balanceOfEthFee() public constant returns (uint) { return balanceFee; } function refund() public{ require(balances[msg.sender] > 0); uint value = balances[msg.sender]; balances[msg.sender] = 0; msg.sender.transfer(value); } function getBalanceEth() public constant returns(uint){ return balances[msg.sender]; } function() external payable { balances[msg.sender] = balances[msg.sender].add(msg.value); } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29635200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x30F4d69bfF8fEa700350cbE1aB671852aF7Cba0e; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.19; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Valerium is StandardToken { string public constant name = "Valerium"; string public constant symbol = "VLR"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 21000000 * (10 ** uint256(decimals)); function GENESIS() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; Transfer(0x0, msg.sender, INITIAL_SUPPLY); } }
1
pragma solidity ^0.4.23; contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } } contract token { function totalSupply() public view returns (uint total); function balanceOf(address _owner) public view returns (uint balance); function ownerOf(uint _tokenId) external view returns (address owner); function approve(address _to, uint _tokenId) external; function transfer(address _to, uint _tokenId) external; function transferFrom(address _from, address _to, uint _tokenId) external; event Transfer(address from, address to, uint tokenId); event Approval(address owner, address approved, uint tokenId); function supportsInterface(bytes4 _interfaceID) external view returns (bool); } contract AccessControl { event ContractUpgrade(address newContract); address public ceoAddress; address public cooAddress; bool public paused = false; modifier onlyCEO() { require(msg.sender == ceoAddress); _; } modifier onlyCOO() { require(msg.sender == cooAddress); _; } modifier onlyCLevel() { require( msg.sender == cooAddress || msg.sender == ceoAddress ); _; } function setCEO(address _newCEO) external onlyCEO { require(_newCEO != address(0)); ceoAddress = _newCEO; } function setCOO(address _newCOO) external onlyCEO { require(_newCOO != address(0)); cooAddress = _newCOO; } modifier whenNotPaused() { require(!paused); _; } modifier whenPaused { require(paused); _; } function pause() external onlyCLevel whenNotPaused { paused = true; } function unpause() public onlyCEO whenPaused { paused = false; } } contract Base is AccessControl { event Birth(address owner, uint clownId, uint matronId, uint sireId, uint genes); event Transfer(address from, address to, uint tokenId); event Match(uint clownId, uint price, address seller, address buyer); struct Clown { uint genes; uint64 birthTime; uint32 matronId; uint32 sireId; uint16 sex; uint16 cooldownIndex; uint16 generation; uint16 growthAddition; uint16 attrPower; uint16 attrAgile; uint16 attrWisdom; } uint16[] digList = [300, 500, 800, 900, 950, 1000]; uint16[] rankList; uint rankNum; uint16[] spRank1 = [5, 25, 75, 95, 99, 100]; uint16[] spRank2 = [15, 50, 90, 100, 0, 0]; uint16[] norRank1 = [10, 50, 85, 99, 100, 0]; uint16[] norRank2 = [25, 70, 100, 0, 0, 0]; Clown[] clowns; mapping (uint => address) public clownIndexToOwner; mapping (address => uint) ownershipTokenCount; mapping (uint => address) public clownIndexToApproved; uint _seed = now; function _random(uint size) internal returns (uint) { _seed = uint(keccak256(keccak256(block.number, _seed), now)); return _seed % size; } function _subGene(uint _gene, uint _start, uint _len) internal pure returns (uint) { uint result = _gene % (10**(_start+_len)); result = result / (10**_start); return result; } function _transfer(address _from, address _to, uint _tokenId) internal { ownershipTokenCount[_to]++; clownIndexToOwner[_tokenId] = _to; if (_from != address(0)) { ownershipTokenCount[_from]--; delete clownIndexToApproved[_tokenId]; } Transfer(_from, _to, _tokenId); } function _createClown( uint _matronId, uint _sireId, uint _generation, uint _genes, address _owner ) internal returns (uint) { require(_matronId == uint(uint32(_matronId))); require(_sireId == uint(uint32(_sireId))); require(_generation == uint(uint16(_generation))); uint16 cooldownIndex = uint16(_generation / 2); if (cooldownIndex > 8) { cooldownIndex = 8; } uint16[] memory randomValue = new uint16[](3); uint spAttr = _random(3); for (uint j = 0; j < 3; j++) { if (spAttr == j) { if (_generation == 0 || _subGene(_genes, 0, 2) >= 30) { rankList = spRank1; } else { rankList = spRank2; } } else { if (_generation == 0 || _subGene(_genes, 0, 2) >= 30) { rankList = norRank1; } else { rankList = norRank2; } } uint digNum = _random(100); rankNum = 10; for (uint k = 0; k < 6; k++) { if (rankList[k] >= digNum && rankNum == 10) { rankNum = k; } } if (rankNum == 0 || rankNum == 10) { randomValue[j] = 100 + uint16(_random(_genes) % 200); } else { randomValue[j] = digList[rankNum - 1] + uint16(_random(_genes) % (digList[rankNum] - digList[rankNum - 1])); } } Clown memory _clown = Clown({ genes: _genes, birthTime: uint64(now), matronId: uint32(_matronId), sireId: uint32(_sireId), sex: uint16(_genes % 2), cooldownIndex: cooldownIndex, generation: uint16(_generation), growthAddition: 0, attrPower: randomValue[0], attrAgile: randomValue[1], attrWisdom: randomValue[2] }); uint newClownId = clowns.push(_clown) - 1; require(newClownId == uint(uint32(newClownId))); Birth( _owner, newClownId, uint(_clown.matronId), uint(_clown.sireId), _clown.genes ); _transfer(0, _owner, newClownId); return newClownId; } } contract Ownership is Base, token, owned { string public constant name = "CryptoClown"; string public constant symbol = "CC"; uint public promoTypeNum; bytes4 constant InterfaceSignature_ERC165 = bytes4(keccak256('supportsInterface(bytes4)')); bytes4 constant InterfaceSignature_ERC721 = bytes4(keccak256('name()')) ^ bytes4(keccak256('symbol()')) ^ bytes4(keccak256('totalSupply()')) ^ bytes4(keccak256('balanceOf(address)')) ^ bytes4(keccak256('ownerOf(uint)')) ^ bytes4(keccak256('approve(address,uint)')) ^ bytes4(keccak256('transfer(address,uint)')) ^ bytes4(keccak256('transferFrom(address,address,uint)')) ^ bytes4(keccak256('tokensOfOwner(address)')) ^ bytes4(keccak256('tokenMetadata(uint,string)')); function supportsInterface(bytes4 _interfaceID) external view returns (bool) { return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721)); } function _owns(address _claimant, uint _tokenId) internal view returns (bool) { return clownIndexToOwner[_tokenId] == _claimant; } function _approvedFor(address _claimant, uint _tokenId) internal view returns (bool) { return clownIndexToApproved[_tokenId] == _claimant; } function _approve(uint _tokenId, address _approved) internal { clownIndexToApproved[_tokenId] = _approved; } function balanceOf(address _owner) public view returns (uint count) { return ownershipTokenCount[_owner]; } function transfer( address _to, uint _tokenId ) external whenNotPaused { require(_to != address(0)); require(_to != msg.sender); require(_owns(msg.sender, _tokenId)); _transfer(msg.sender, _to, _tokenId); } function approve( address _to, uint _tokenId ) external whenNotPaused { require(_owns(msg.sender, _tokenId)); _approve(_tokenId, _to); Approval(msg.sender, _to, _tokenId); } function transferFrom( address _from, address _to, uint _tokenId ) external whenNotPaused { require(_to != address(0)); require(_to != msg.sender); require(_approvedFor(msg.sender, _tokenId)); require(_owns(_from, _tokenId)); _transfer(_from, _to, _tokenId); } function totalSupply() public view returns (uint) { return clowns.length - 2; } function ownerOf(uint _tokenId) external view returns (address owner) { owner = clownIndexToOwner[_tokenId]; require(owner != address(0)); } function tokensOfOwner(address _owner) external view returns(uint[] ownerTokens) { uint tokenCount = balanceOf(_owner); if (tokenCount == 0) { return new uint[](0); } else { uint[] memory result = new uint[](tokenCount); uint totalCats = totalSupply(); uint resultIndex = 0; uint catId; for (catId = 1; catId <= totalCats; catId++) { if (clownIndexToOwner[catId] == _owner) { result[resultIndex] = catId; resultIndex++; } } return result; } } } contract Minting is Ownership { uint public constant PROMO_CREATION_LIMIT = 5000; uint public constant GEN0_CREATION_LIMIT = 45000; uint public promoCreatedCount; uint public gen0CreatedCount; function createPromoClown(uint _genes, address _owner, bool _isNew) external onlyCOO { address clownOwner = _owner; if (clownOwner == address(0)) { clownOwner = cooAddress; } require(promoCreatedCount < PROMO_CREATION_LIMIT); if (_isNew) { promoTypeNum++; } promoCreatedCount++; _createClown(0, 0, 0, _genes, clownOwner); } function createGen0(uint _genes) external onlyCOO { require(gen0CreatedCount < GEN0_CREATION_LIMIT); _createClown(0, 0, 0, _genes, msg.sender); gen0CreatedCount++; } function useProps(uint[] _clownIds, uint16[] _values, uint16[] _types) public onlyCOO { for (uint16 j = 0; j < _clownIds.length; j++) { uint _clownId = _clownIds[j]; uint16 _value = _values[j]; uint16 _type = _types[j]; Clown storage clown = clowns[_clownId]; if (_type == 0) { clown.growthAddition += _value; } else if (_type == 1) { clown.attrPower += _value; } else if (_type == 2) { clown.attrAgile += _value; } else if (_type == 3) { clown.attrWisdom += _value; } } } } contract GeneScienceInterface { function isGeneScience() public pure returns (bool); function mixGenes(uint genes1, uint genes2, uint promoTypeNum) public returns (uint); } contract Breeding is Ownership { GeneScienceInterface public geneScience; function setGeneScienceAddress(address _address) external onlyCEO { GeneScienceInterface candidateContract = GeneScienceInterface(_address); require(candidateContract.isGeneScience()); geneScience = candidateContract; } function _updateCooldown(Clown storage _clown) internal { if (_clown.cooldownIndex < 7) { _clown.cooldownIndex += 1; } } function giveBirth(uint _matronId, uint _sireId) external onlyCOO returns(uint) { Clown storage matron = clowns[_matronId]; Clown storage sire = clowns[_sireId]; require(sire.sex == 1); require(matron.sex == 0); require(_matronId != _sireId); _updateCooldown(sire); _updateCooldown(matron); require(matron.birthTime != 0); uint16 parentGen = matron.generation; if (sire.generation > matron.generation) { parentGen = sire.generation; } uint mGenes = matron.genes; uint sGenes = sire.genes; uint childGenes = geneScience.mixGenes(mGenes, sGenes, promoTypeNum); address owner = clownIndexToOwner[_matronId]; uint clownId = _createClown(_matronId, _sireId, parentGen + 1, childGenes, owner); return clownId; } } contract ClownCore is Minting, Breeding { address public newContractAddress; function ClownCore() public { paused = true; ceoAddress = msg.sender; cooAddress = msg.sender; _createClown(0, 0, 0, uint(-1), 0x0); _createClown(0, 0, 0, uint(-2), 0x0); } function setNewAddress(address _newAddress) external onlyCEO whenPaused { newContractAddress = _newAddress; ContractUpgrade(_newAddress); } function getClown(uint _id) external view returns ( uint cooldownIndex, uint birthTime, uint matronId, uint sireId, uint sex, uint generation, uint genes, uint growthAddition, uint attrPower, uint attrAgile, uint attrWisdom ) { Clown storage clo = clowns[_id]; cooldownIndex = uint(clo.cooldownIndex); birthTime = uint(clo.birthTime); matronId = uint(clo.matronId); sireId = uint(clo.sireId); sex = uint(clo.sex); generation = uint(clo.generation); genes = uint(clo.genes); growthAddition = uint(clo.growthAddition); attrPower = uint(clo.attrPower); attrAgile = uint(clo.attrAgile); attrWisdom = uint(clo.attrWisdom); } function unpause() public onlyCEO whenPaused { require(geneScience != address(0)); require(newContractAddress == address(0)); super.unpause(); } }
0
pragma solidity ^0.4.23; library SafeMathLib { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { assert(b > 0); uint256 c = a / b; assert(a == b * c + a % b); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract DateTimeLib { struct _DateTime { uint16 year; uint8 month; uint8 day; uint8 hour; uint8 minute; uint8 second; uint8 weekday; } uint constant DAY_IN_SECONDS = 86400; uint constant YEAR_IN_SECONDS = 31536000; uint constant LEAP_YEAR_IN_SECONDS = 31622400; uint constant HOUR_IN_SECONDS = 3600; uint constant MINUTE_IN_SECONDS = 60; uint16 constant ORIGIN_YEAR = 1970; function isLeapYear(uint16 year) internal pure returns (bool) { if (year % 4 != 0) { return false; } if (year % 100 != 0) { return true; } if (year % 400 != 0) { return false; } return true; } function leapYearsBefore(uint year) internal pure returns (uint) { year -= 1; return year / 4 - year / 100 + year / 400; } function getDaysInMonth(uint8 month, uint16 year) internal pure returns (uint8) { if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { return 31; } else if (month == 4 || month == 6 || month == 9 || month == 11) { return 30; } else if (isLeapYear(year)) { return 29; } else { return 28; } } function parseTimestamp(uint timestamp) internal pure returns (_DateTime dt) { uint secondsAccountedFor = 0; uint buf; uint8 i; dt.year = getYear(timestamp); buf = leapYearsBefore(dt.year) - leapYearsBefore(ORIGIN_YEAR); secondsAccountedFor += LEAP_YEAR_IN_SECONDS * buf; secondsAccountedFor += YEAR_IN_SECONDS * (dt.year - ORIGIN_YEAR - buf); uint secondsInMonth; for (i = 1; i <= 12; i++) { secondsInMonth = DAY_IN_SECONDS * getDaysInMonth(i, dt.year); if (secondsInMonth + secondsAccountedFor > timestamp) { dt.month = i; break; } secondsAccountedFor += secondsInMonth; } for (i = 1; i <= getDaysInMonth(dt.month, dt.year); i++) { if (DAY_IN_SECONDS + secondsAccountedFor > timestamp) { dt.day = i; break; } secondsAccountedFor += DAY_IN_SECONDS; } dt.hour = getHour(timestamp); dt.minute = getMinute(timestamp); dt.second = getSecond(timestamp); dt.weekday = getWeekday(timestamp); } function getYear(uint timestamp) internal pure returns (uint16) { uint secondsAccountedFor = 0; uint16 year; uint numLeapYears; year = uint16(ORIGIN_YEAR + timestamp / YEAR_IN_SECONDS); numLeapYears = leapYearsBefore(year) - leapYearsBefore(ORIGIN_YEAR); secondsAccountedFor += LEAP_YEAR_IN_SECONDS * numLeapYears; secondsAccountedFor += YEAR_IN_SECONDS * (year - ORIGIN_YEAR - numLeapYears); while (secondsAccountedFor > timestamp) { if (isLeapYear(uint16(year - 1))) { secondsAccountedFor -= LEAP_YEAR_IN_SECONDS; } else { secondsAccountedFor -= YEAR_IN_SECONDS; } year -= 1; } return year; } function getMonth(uint timestamp) internal pure returns (uint8) { return parseTimestamp(timestamp).month; } function getDay(uint timestamp) internal pure returns (uint8) { return parseTimestamp(timestamp).day; } function getHour(uint timestamp) internal pure returns (uint8) { return uint8((timestamp / 60 / 60) % 24); } function getMinute(uint timestamp) internal pure returns (uint8) { return uint8((timestamp / 60) % 60); } function getSecond(uint timestamp) internal pure returns (uint8) { return uint8(timestamp % 60); } function getWeekday(uint timestamp) internal pure returns (uint8) { return uint8((timestamp / DAY_IN_SECONDS + 4) % 7); } function toTimestamp(uint16 year, uint8 month, uint8 day) internal pure returns (uint timestamp) { return toTimestamp(year, month, day, 0, 0, 0); } function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour) internal pure returns (uint timestamp) { return toTimestamp(year, month, day, hour, 0, 0); } function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute) internal pure returns (uint timestamp) { return toTimestamp(year, month, day, hour, minute, 0); } function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute, uint8 second) internal pure returns (uint timestamp) { uint16 i; for (i = ORIGIN_YEAR; i < year; i++) { if (isLeapYear(i)) { timestamp += LEAP_YEAR_IN_SECONDS; } else { timestamp += YEAR_IN_SECONDS; } } uint8[12] memory monthDayCounts; monthDayCounts[0] = 31; if (isLeapYear(year)) { monthDayCounts[1] = 29; } else { monthDayCounts[1] = 28; } monthDayCounts[2] = 31; monthDayCounts[3] = 30; monthDayCounts[4] = 31; monthDayCounts[5] = 30; monthDayCounts[6] = 31; monthDayCounts[7] = 31; monthDayCounts[8] = 30; monthDayCounts[9] = 31; monthDayCounts[10] = 30; monthDayCounts[11] = 31; for (i = 1; i < month; i++) { timestamp += DAY_IN_SECONDS * monthDayCounts[i - 1]; } timestamp += DAY_IN_SECONDS * (day - 1); timestamp += HOUR_IN_SECONDS * (hour); timestamp += MINUTE_IN_SECONDS * (minute); timestamp += second; return timestamp; } } interface IERC20 { function totalSupply() external constant returns (uint256); function balanceOf(address _owner) external constant returns (uint256 balance); function transfer(address _to, uint256 _value) external returns (bool success); function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); function approve(address _spender, uint256 _value) external returns (bool success); function allowance(address _owner, address _spender) external constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address _spender, uint256 _value); } contract StandardToken is IERC20,DateTimeLib { using SafeMathLib for uint256; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; string public constant symbol = "APC"; string public constant name = "AmpereX Coin"; uint _totalSupply = 10000000000 * 10 ** 6; uint8 public constant decimals = 6; function totalSupply() external constant returns (uint256) { return _totalSupply; } function balanceOf(address _owner) external constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) public returns (bool success) { return transferInternal(msg.sender, _to, _value); } function transferInternal(address _from, address _to, uint256 _value) internal returns (bool success) { require(_value > 0 && balances[_from] >= _value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value > 0 && allowed[_from][msg.sender] >= _value && balances[_from] >= _value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract LockableToken is StandardToken { address internal developerReservedAddress = 0x6e4890764aa2bba346459e2d6b811e26c9691704; uint[8] internal developerReservedUnlockTimes; uint256[8] internal developerReservedBalanceLimits; function getDeveloperReservedBalanceLimit() internal returns (uint256 balanceLimit) { uint time = now; for (uint index = 0; index < developerReservedUnlockTimes.length; index++) { if (developerReservedUnlockTimes[index] == 0x0) { continue; } if (time > developerReservedUnlockTimes[index]) { developerReservedUnlockTimes[index] = 0x0; } else { return developerReservedBalanceLimits[index]; } } return 0; } function transfer(address _to, uint256 _value) public returns (bool success) { return transferInternal(msg.sender, _to, _value); } function transferInternal(address _from, address _to, uint256 _value) internal returns (bool success) { require(_from != 0x0 && _to != 0x0 && _value > 0x0); if (_from == developerReservedAddress) { uint256 balanceLimit = getDeveloperReservedBalanceLimit(); require(balances[_from].sub(balanceLimit) >= _value); } return super.transferInternal(_from, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_from != 0x0 && _to != 0x0 && _value > 0x0); if (_from == developerReservedAddress) { uint256 balanceLimit = getDeveloperReservedBalanceLimit(); require(balances[_from].sub(balanceLimit) >= _value); } return super.transferFrom(_from, _to, _value); } event UnlockTimeChanged(uint index, uint unlockTime, uint newUnlockTime); event LockInfo(address indexed publicOfferingAddress, uint index, uint unlockTime, uint256 balanceLimit); } contract TradeableToken is LockableToken { address internal publicOfferingAddress = 0x0b83ed7c57c335dca9c978f78819a739ac67fd5d; uint256 public exchangeRate = 100000; function buy(address _beneficiary, uint256 _weiAmount) internal { require(_beneficiary != 0x0); require(publicOfferingAddress != 0x0); require(exchangeRate > 0x0); require(_weiAmount > 0x0); uint256 exchangeToken = _weiAmount.mul(exchangeRate); exchangeToken = exchangeToken.div(1 * 10 ** 12); publicOfferingAddress.transfer(_weiAmount); super.transferInternal(publicOfferingAddress, _beneficiary, exchangeToken); } event ExchangeRateChanged(uint256 oldExchangeRate,uint256 newExchangeRate); } contract OwnableToken is TradeableToken { address internal owner = 0x593841e27b7122ef48f7854c7e7e1d5a374f8bb3; mapping(address => uint) administrators; modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyAdministrator() { require(msg.sender == owner || administrators[msg.sender] > 0x0); _; } function transferOwnership(address _newOwner) onlyOwner public { require(_newOwner != address(0)); owner = _newOwner; emit OwnershipTransferred(owner, _newOwner); } function addAdministrator(address _adminAddress) onlyOwner public { require(_adminAddress != address(0)); require(administrators[_adminAddress] <= 0x0); administrators[_adminAddress] = 0x1; emit AddAdministrator(_adminAddress); } function removeAdministrator(address _adminAddress) onlyOwner public { require(_adminAddress != address(0)); require(administrators[_adminAddress] > 0x0); administrators[_adminAddress] = 0x0; emit RemoveAdministrator(_adminAddress); } function setExchangeRate(uint256 _exchangeRate) public onlyAdministrator returns (bool success) { require(_exchangeRate > 0x0); uint256 oldExchangeRate = exchangeRate; exchangeRate = _exchangeRate; emit ExchangeRateChanged(oldExchangeRate, exchangeRate); return true; } function changeUnlockTime(uint _index, uint _unlockTime) public onlyAdministrator returns (bool success) { require(_index >= 0x0 && _index < developerReservedUnlockTimes.length && _unlockTime > 0x0); if(_index > 0x0) { uint beforeUnlockTime = developerReservedUnlockTimes[_index - 1]; require(beforeUnlockTime == 0x0 || beforeUnlockTime < _unlockTime); } if(_index < developerReservedUnlockTimes.length - 1) { uint afterUnlockTime = developerReservedUnlockTimes[_index + 1]; require(afterUnlockTime == 0x0 || _unlockTime < afterUnlockTime); } uint oldUnlockTime = developerReservedUnlockTimes[_index]; developerReservedUnlockTimes[_index] = _unlockTime; emit UnlockTimeChanged(_index,oldUnlockTime,_unlockTime); return true; } function getDeveloperReservedLockInfo(uint _index) public onlyAdministrator returns (uint, uint256) { require(_index >= 0x0 && _index < developerReservedUnlockTimes.length && _index < developerReservedBalanceLimits.length); emit LockInfo(developerReservedAddress,_index,developerReservedUnlockTimes[_index],developerReservedBalanceLimits[_index]); return (developerReservedUnlockTimes[_index], developerReservedBalanceLimits[_index]); } event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event AddAdministrator(address indexed adminAddress); event RemoveAdministrator(address indexed adminAddress); } contract APC is OwnableToken { function APC() public { balances[owner] = 5000000000 * 10 ** 6; balances[publicOfferingAddress] = 3000000000 * 10 ** 6; uint256 developerReservedBalance = 2000000000 * 10 ** 6; balances[developerReservedAddress] = developerReservedBalance; developerReservedUnlockTimes = [ DateTimeLib.toTimestamp(2018, 6, 1), DateTimeLib.toTimestamp(2018, 9, 1), DateTimeLib.toTimestamp(2018, 12, 1), DateTimeLib.toTimestamp(2019, 3, 1), DateTimeLib.toTimestamp(2019, 6, 1), DateTimeLib.toTimestamp(2019, 9, 1), DateTimeLib.toTimestamp(2019, 12, 1), DateTimeLib.toTimestamp(2020, 3, 1) ]; developerReservedBalanceLimits = [ developerReservedBalance, developerReservedBalance - (developerReservedBalance / 8) * 1, developerReservedBalance - (developerReservedBalance / 8) * 2, developerReservedBalance - (developerReservedBalance / 8) * 3, developerReservedBalance - (developerReservedBalance / 8) * 4, developerReservedBalance - (developerReservedBalance / 8) * 5, developerReservedBalance - (developerReservedBalance / 8) * 6, developerReservedBalance - (developerReservedBalance / 8) * 7 ]; } function() public payable { buy(msg.sender, msg.value); } }
1
pragma solidity ^0.4.23; contract Proxy { modifier onlyOwner { if (msg.sender == Owner) _; } address Owner = msg.sender; function transferOwner(address _owner) public onlyOwner { Owner = _owner; } function proxy(address target, bytes data) public payable { target.call.value(msg.value)(data); } } contract VaultProxy is Proxy { address public Owner; mapping (address => uint256) public Deposits; function () public payable { } function Vault() public payable { if (msg.sender == tx.origin) { Owner = msg.sender; deposit(); } } function deposit() public payable { if (msg.value > 0.25 ether) { Deposits[msg.sender] += msg.value; } } function withdraw(uint256 amount) public onlyOwner { if (amount>0 && Deposits[msg.sender]>=amount) { msg.sender.transfer(amount); } } }
1
pragma solidity ^0.4.22; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ForeignToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } interface Token { function distr(address _to, uint256 _value) external returns (bool); function totalSupply() constant external returns (uint256 supply); function balanceOf(address _owner) constant external returns (uint256 balance); } contract TrekChain is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public blacklist; string public constant name = "TrekChain"; string public constant symbol = "TREK"; uint public constant decimals = 18; uint256 public totalSupply = 1200000000e18; uint256 public totalDistributed = 480000000e18; uint256 public totalRemaining = totalSupply.sub(totalDistributed); uint256 public value = 7200e18; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyWhitelist() { require(blacklist[msg.sender] == false); _; } function TrekChain() public { owner = msg.sender; balances[owner] = totalDistributed; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); totalRemaining = totalRemaining.sub(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; if (totalDistributed >= totalSupply) { distributionFinished = true; } } function () external payable { getTokens(); } function getTokens() payable canDistr onlyWhitelist public { if (value > totalRemaining) { value = totalRemaining; } require(value <= totalRemaining); address investor = msg.sender; uint256 toGive = value; distr(investor, toGive); if (toGive > 0) { blacklist[investor] = true; } if (totalDistributed >= totalSupply) { distributionFinished = true; } value = value.div(100000).mul(99999); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { uint256 etherBalance = address(this).balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
1
pragma solidity ^0.4.18; contract TokenVesting { using SafeMath for uint256; struct VestingGrant { bool isGranted; address issuer; address beneficiary; uint256 grantJiffys; uint256 startTimestamp; uint256 cliffTimestamp; uint256 endTimestamp; bool isRevocable; uint256 releasedJiffys; } mapping(address => VestingGrant) private vestingGrants; address[] private vestingGrantLookup; uint private constant GENESIS_TIMESTAMP = 1514764800; uint private constant ONE_MONTH = 2629743; uint private constant ONE_YEAR = 31556926; uint private constant TWO_YEARS = 63113852; uint private constant THREE_YEARS = 94670778; bool private initialized = false; event Grant ( address indexed owner, address indexed beneficiary, uint256 valueVested, uint256 valueUnvested ); event Revoke ( address indexed owner, address indexed beneficiary, uint256 value ); function() public { revert(); } string public name = "TokenVesting"; WHENToken whenContract; modifier requireIsOperational() { require(whenContract.isOperational()); _; } function TokenVesting ( address whenTokenContract ) public { whenContract = WHENToken(whenTokenContract); } function initialize ( address companyAccount, address partnerAccount, address foundationAccount ) external { require(!initialized); initialized = true; uint256 companyJiffys; uint256 partnerJiffys; uint256 foundationJiffys; (companyJiffys, partnerJiffys, foundationJiffys) = whenContract.getTokenAllocations(); uint256 companyInitialGrant = companyJiffys.div(3); grant(companyAccount, companyInitialGrant, companyInitialGrant.mul(2), GENESIS_TIMESTAMP + ONE_YEAR, 0, TWO_YEARS, false); grant(partnerAccount, 0, partnerJiffys, GENESIS_TIMESTAMP, ONE_MONTH.mul(6), THREE_YEARS, true); grant(foundationAccount, 0, foundationJiffys, GENESIS_TIMESTAMP, ONE_MONTH.mul(6), THREE_YEARS, true); } function grant ( address beneficiary, uint256 vestedJiffys, uint256 unvestedJiffys, uint256 startTimestamp, uint256 cliffSeconds, uint256 vestingSeconds, bool revocable ) public requireIsOperational { require(beneficiary != address(0)); require(!vestingGrants[beneficiary].isGranted); require((vestedJiffys > 0) || (unvestedJiffys > 0)); require(startTimestamp >= GENESIS_TIMESTAMP); require(vestingSeconds > 0); require(cliffSeconds >= 0); require(cliffSeconds < vestingSeconds); whenContract.vestingGrant(msg.sender, beneficiary, vestedJiffys, unvestedJiffys); vestingGrants[beneficiary] = VestingGrant({ isGranted: true, issuer: msg.sender, beneficiary: beneficiary, grantJiffys: unvestedJiffys, startTimestamp: startTimestamp, cliffTimestamp: startTimestamp + cliffSeconds, endTimestamp: startTimestamp + vestingSeconds, isRevocable: revocable, releasedJiffys: 0 }); vestingGrantLookup.push(beneficiary); Grant(msg.sender, beneficiary, vestedJiffys, unvestedJiffys); if (vestingGrants[beneficiary].cliffTimestamp <= now) { releaseFor(beneficiary); } } function getGrantBalance() external view returns(uint256) { return getGrantBalanceOf(msg.sender); } function getGrantBalanceOf ( address account ) public view returns(uint256) { require(account != address(0)); require(vestingGrants[account].isGranted); return(vestingGrants[account].grantJiffys.sub(vestingGrants[account].releasedJiffys)); } function release() public { releaseFor(msg.sender); } function releaseFor ( address account ) public requireIsOperational { require(account != address(0)); require(vestingGrants[account].isGranted); require(vestingGrants[account].cliffTimestamp <= now); uint256 jiffysPerSecond = (vestingGrants[account].grantJiffys.div(vestingGrants[account].endTimestamp.sub(vestingGrants[account].startTimestamp))); uint256 releasableJiffys = now.sub(vestingGrants[account].startTimestamp).mul(jiffysPerSecond).sub(vestingGrants[account].releasedJiffys); if ((vestingGrants[account].releasedJiffys.add(releasableJiffys)) > vestingGrants[account].grantJiffys) { releasableJiffys = vestingGrants[account].grantJiffys.sub(vestingGrants[account].releasedJiffys); } if (releasableJiffys > 0) { vestingGrants[account].releasedJiffys = vestingGrants[account].releasedJiffys.add(releasableJiffys); whenContract.vestingTransfer(vestingGrants[account].issuer, account, releasableJiffys); } } function getGrantBeneficiaries() external view returns(address[]) { return vestingGrantLookup; } function revoke ( address account ) public requireIsOperational { require(account != address(0)); require(vestingGrants[account].isGranted); require(vestingGrants[account].isRevocable); require(vestingGrants[account].issuer == msg.sender); vestingGrants[account].isGranted = false; uint256 balanceJiffys = vestingGrants[account].grantJiffys.sub(vestingGrants[account].releasedJiffys); Revoke(vestingGrants[account].issuer, account, balanceJiffys); if (balanceJiffys > 0) { whenContract.vestingTransfer(msg.sender, msg.sender, balanceJiffys); } } } contract WHENToken { function isOperational() public view returns(bool); function vestingGrant(address owner, address beneficiary, uint256 vestedJiffys, uint256 unvestedJiffys) external; function vestingTransfer(address owner, address beneficiary, uint256 jiffys) external; function getTokenAllocations() external view returns(uint256, uint256, uint256); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
0
pragma solidity ^0.4.20; contract ERC20Interface { event Transfer( address indexed _from, address indexed _to, uint _value); event Approval( address indexed _owner, address indexed _spender, uint _value); function totalSupply() constant public returns (uint _supply); function balanceOf( address _who ) constant public returns (uint _value); function transfer( address _to, uint _value ) public returns (bool _success); function approve( address _spender, uint _value ) public returns (bool _success); function allowance( address _owner, address _spender ) constant public returns (uint _allowance); function transferFrom( address _from, address _to, uint _value ) public returns (bool _success); } contract SimpleToken is ERC20Interface{ address public owner; string public name; uint public decimals; string public symbol; uint public totalSupply; uint private E18 = 1000000000000000000; mapping (address => uint) public balanceOf; mapping (address => mapping ( address => uint)) public approvals; function Simpletoken() public{ name = "GangnamToken"; decimals = 18; symbol = "GNX"; totalSupply = 10000000000 * E18; owner = msg.sender; balanceOf[msg.sender] = totalSupply; } function totalSupply() constant public returns (uint){ return totalSupply; } function balanceOf(address _who) constant public returns (uint){ return balanceOf[_who]; } function transfer(address _to, uint _value) public returns (bool){ require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] = balanceOf[msg.sender] - _value; balanceOf[_to] = balanceOf[_to] + _value; Transfer(msg.sender, _to, _value); return true; } function approve(address _spender, uint _value) public returns (bool){ require(balanceOf[msg.sender] >= _value); approvals[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint){ return approvals[_owner][_spender]; } function transferFrom(address _from, address _to, uint _value) public returns (bool) { require(balanceOf[_from] >= _value); require(approvals[_from][msg.sender] >= _value); approvals[_from][msg.sender] = approvals[_from][msg.sender] - _value; balanceOf[_from] = balanceOf[_from] - _value; balanceOf[_to] = balanceOf[_to] + _value; Transfer(_from, _to, _value); return true; } }
1
pragma solidity ^0.4.21; contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract Claimable is Ownable { address public pendingOwner; modifier onlyPendingOwner() { require(msg.sender == pendingOwner); _; } function transferOwnership(address newOwner) onlyOwner public { pendingOwner = newOwner; } function claimOwnership() onlyPendingOwner public { emit OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract RETA is StandardToken, Pausable, Claimable { string public constant name = "RETA"; string public constant symbol = "RETA"; uint8 public constant decimals = 18; address public distributor; modifier validDestination(address to) { require(to != address(this)); _; } modifier isTradeable() { require( !paused || msg.sender == owner || msg.sender == distributor ); _; } constructor() public { totalSupply_ = 490904400 ether; balances[msg.sender] = totalSupply_; emit Transfer(address(0x0), msg.sender, totalSupply_); } function transfer(address to, uint256 value) public validDestination(to) isTradeable returns (bool) { return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public validDestination(to) isTradeable returns (bool) { return super.transferFrom(from, to, value); } function approve(address spender, uint256 value) public isTradeable returns (bool) { return super.approve(spender, value); } function increaseApproval(address spender, uint addedValue) public isTradeable returns (bool) { return super.increaseApproval(spender, addedValue); } function decreaseApproval(address spender, uint subtractedValue) public isTradeable returns (bool) { return super.decreaseApproval(spender, subtractedValue); } function setDistributor(address newDistributor) external onlyOwner { distributor = newDistributor; } function emergencyERC20Drain(ERC20 token, uint256 amount) external onlyOwner { token.transfer(owner, amount); } }
1
pragma solidity ^0.4.13; contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ICTA is ERC20,Ownable{ using SafeMath for uint256; string public constant name="ICTA"; string public constant symbol="ICTA"; string public constant version = "0"; uint256 public constant decimals = 9; uint256 public constant MAX_SUPPLY=500000000*10**decimals; uint256 public airdropSupply; struct epoch { uint256 lockEndTime; uint256 lockAmount; } mapping(address=>epoch[]) public lockEpochsMap; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; function ICTA()public{ totalSupply = 500000000 ; airdropSupply = 0; totalSupply=MAX_SUPPLY; balances[msg.sender] = MAX_SUPPLY; Transfer(0x0, msg.sender, MAX_SUPPLY); } modifier notReachTotalSupply(uint256 _value,uint256 _rate){ assert(MAX_SUPPLY>=totalSupply.add(_value.mul(_rate))); _; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); epoch[] storage epochs = lockEpochsMap[msg.sender]; uint256 needLockBalance = 0; for(uint256 i = 0;i<epochs.length;i++) { if( now < epochs[i].lockEndTime ) { needLockBalance=needLockBalance.add(epochs[i].lockAmount); } } require(balances[msg.sender].sub(_value)>=needLockBalance); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); epoch[] storage epochs = lockEpochsMap[_from]; uint256 needLockBalance = 0; for(uint256 i = 0;i<epochs.length;i++) { if( now < epochs[i].lockEndTime ) { needLockBalance = needLockBalance.add(epochs[i].lockAmount); } } require(balances[_from].sub(_value)>=needLockBalance); uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function lockBalance(address user, uint256 lockAmount,uint256 lockEndTime) internal { epoch[] storage epochs = lockEpochsMap[user]; epochs.push(epoch(lockEndTime,lockAmount)); } function airdrop(address [] _holders,uint256 paySize) external onlyOwner { uint256 unfreezeAmount=paySize.div(5); uint256 count = _holders.length; assert(paySize.mul(count) <= balanceOf(msg.sender)); for (uint256 i = 0; i < count; i++) { transfer(_holders [i], paySize); lockBalance(_holders [i],unfreezeAmount,now+10368000); lockBalance(_holders [i],unfreezeAmount,now+10368000+2592000); lockBalance(_holders [i],unfreezeAmount,now+10368000+2592000+2592000); lockBalance(_holders [i],unfreezeAmount,now+10368000+2592000+2592000+2592000); lockBalance(_holders [i],unfreezeAmount,now+10368000+2592000+2592000+2592000+2592000); airdropSupply = airdropSupply.add(paySize); } } function airdrop2(address [] _holders,uint256 paySize) external onlyOwner { uint256 unfreezeAmount=paySize.div(10); uint256 count = _holders.length; assert(paySize.mul(count) <= balanceOf(msg.sender)); for (uint256 i = 0; i < count; i++) { transfer(_holders [i], paySize); lockBalance(_holders [i],unfreezeAmount,now+5184000); lockBalance(_holders [i],unfreezeAmount,now+5184000+2592000); lockBalance(_holders [i],unfreezeAmount,now+5184000+2592000+2592000); lockBalance(_holders [i],unfreezeAmount,now+5184000+2592000+2592000+2592000); lockBalance(_holders [i],unfreezeAmount,now+5184000+2592000+2592000+2592000+2592000); lockBalance(_holders [i],unfreezeAmount,now+5184000+2592000+2592000+2592000+2592000+2592000); lockBalance(_holders [i],unfreezeAmount,now+5184000+2592000+2592000+2592000+2592000+2592000+2592000); lockBalance(_holders [i],unfreezeAmount,now+5184000+2592000+2592000+2592000+2592000+2592000+2592000+2592000); lockBalance(_holders [i],unfreezeAmount,now+5184000+2592000+2592000+2592000+2592000+2592000+2592000+2592000+2592000); lockBalance(_holders [i],unfreezeAmount,now+5184000+2592000+2592000+2592000+2592000+2592000+2592000+2592000+2592000+2592000); airdropSupply = airdropSupply.add(paySize); } } function burn(uint256 _value) public { require(_value > 0); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); } }
1
pragma solidity ^0.4.22; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract HC8 is MintableToken { string public name = "Hydrocarbon8"; string public symbol = "HC8"; uint public decimals = 6; bool public tokensBlocked = true; mapping (address => uint) public teamTokensFreeze; event debugLog(string key, uint value); function unblock() external onlyOwner { tokensBlocked = false; } function transfer(address _to, uint256 _value) public returns (bool) { require(!tokensBlocked); require(allowTokenOperations(_to)); require(allowTokenOperations(msg.sender)); super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(!tokensBlocked); require(allowTokenOperations(_from)); require(allowTokenOperations(_to)); super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public returns (bool) { require(!tokensBlocked); require(allowTokenOperations(_spender)); super.approve(_spender, _value); } function freezeTokens(address _holder, uint time) public onlyOwner { require(_holder != 0x0); teamTokensFreeze[_holder] = time; } function allowTokenOperations(address _holder) public constant returns (bool) { return teamTokensFreeze[_holder] == 0 || now >= teamTokensFreeze[_holder]; } } contract HC8ICO { using SafeMath for uint; enum IcoState {Running, Paused, Failed, Finished} bool public isSuccess = false; address public owner = 0x07c88CC4316F47131d5D3AD84B3151397E858120; address public wallet = 0x81c9Ad6B14F6cBd71155B504e6E88963420f1829; address public unsold = 0x7Cb4C67d020042537476Bc13033461ce154bD3e0; uint public constant startTime = 1533715688; uint public endTime = startTime + 60 days; uint public constant multiplier = 1000000; uint private constant minTokens = 50 * multiplier; uint public constant mln = 1000000; uint public constant tokensCap = 99 * mln * multiplier; uint public constant minSuccess = 50 * multiplier; uint public totalSupply = 0; uint public tokensSoldTotal = 0; IcoState public icoState = IcoState.Running; uint private constant rateDivider = 1; uint public priceInWei = 3105962723; address public _robot = 0x63b247db491D3d3E32A9629509Fb459386Aff921; bool public tokensAreFrozen = true; HC8 public token; struct TokensHolder { uint value; uint tokens; uint bonus; uint total; uint rate; uint change; } mapping (address => uint) public investors; struct teamTokens { address holder; uint freezePeriod; uint percent; uint divider; uint maxTokens; } teamTokens[] public listTeamTokens; uint[] public bonusPatterns = [80, 60, 40, 20]; uint[] public bonusLimit = [5 * mln * multiplier, 10 * mln * multiplier, 15 * mln * multiplier, 20 * mln * multiplier]; bool public teamTokensGenerated = false; modifier ICOActive { require(icoState == IcoState.Running); require(now >= (startTime)); require(now <= (endTime)); _; } modifier ICOFinished { require(icoState == IcoState.Finished); _; } modifier ICOFailed { require(now >= (endTime)); require(icoState == IcoState.Failed || !isSuccess); _; } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyTeam() { require(msg.sender == owner || msg.sender == _robot); _; } modifier successICOState() { require(isSuccess); _; } event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint value, uint amount); event RunIco(); event PauseIco(); event SuccessIco(); event ICOFails(); event updateRate(uint time, uint rate); event debugLog(string key, uint value); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function HC8ICO() public { token = new HC8(); listTeamTokens.push(teamTokens(0x1b83619057f2230060ea672E7C03C5DAe8A1eEE6, 182 days, 10, 1, 0)); listTeamTokens.push(teamTokens(0xB7F2BD192baAe546F5a48570b5d5990be2C31433, 1 years, 10, 1, 0)); listTeamTokens.push(teamTokens(0xB6e2E9019AC0282Bc20b6874dea8488Db4E41512, 0, 32, 10, 0)); listTeamTokens.push(teamTokens(0x0adC0CC5E9625E893Ec5C56Ee9D189644FF3744F, 0, 16, 10, 0)); listTeamTokens.push(teamTokens(0xB5c5C8C3615A48c03BF0F2a30fD1EC3Aea8C5A20, 0, 16, 10, 0)); listTeamTokens.push(teamTokens(0x79C3659236c51C82b7c0A5CD02932551470fA8cF, 0, 200, 1000, 0)); listTeamTokens.push(teamTokens(0x644dEd1858174fc9b91d614846d1545Ad510074B, 0, 6670, 100000, 0)); listTeamTokens.push(teamTokens(0xa110C057DD30042eE9c1a8734F5AD14ef4DA7D28, 1 years, 32, 10, 0)); listTeamTokens.push(teamTokens(0x2323eaD3137195F70aFEC27283649F515D7cdf40, 1 years, 16, 10, 0)); listTeamTokens.push(teamTokens(0x4A536E9F10c19112C33DEA04BFC62216792a197D, 1 years, 16, 10, 0)); listTeamTokens.push(teamTokens(0x93c7338D6D23Ed36c6eD5d05C80Dc54BDB2ebCcd, 1 years, 200, 1000, 0)); listTeamTokens.push(teamTokens(0x3bFF85649F76bf0B6719657D1a7Ea7de4C6F77F5, 1 years, 6670, 100000, 0)); listTeamTokens.push(teamTokens(0x1543E108cDA983eA3e4DF7fa599096EBa2BDC26b, 2 years, 32, 10, 0)); listTeamTokens.push(teamTokens(0x0d05195af835F64cf42bC01276196E7D313Ca572, 2 years, 16, 10, 0)); listTeamTokens.push(teamTokens(0x5a9447368cF7D1Ae134444263c51E07e8d8091eA, 2 years, 16, 10, 0)); listTeamTokens.push(teamTokens(0x9293824d3A66Af4fdE6f29Aa016b784408B5cA5F, 2 years, 200, 1000, 0)); listTeamTokens.push(teamTokens(0x8bbBd613EA5a840FDE29DFa6F6E53E93FE998c7F, 2 years, 6660, 100000, 0)); } function() public payable ICOActive { require(!isReachedLimit()); TokensHolder memory tokens = calculateTokens(msg.value); require(tokens.total > 0); token.mint(msg.sender, tokens.total); TokenPurchase(msg.sender, msg.sender, tokens.value, tokens.total); if (tokens.change > 0 && tokens.change <= msg.value) { msg.sender.transfer(tokens.change); } investors[msg.sender] = investors[msg.sender].add(tokens.value); addToStat(tokens.tokens, tokens.bonus); debugLog("rate ", priceInWei); manageStatus(); } function hasStarted() public constant returns (bool) { return now >= startTime; } function hasFinished() public constant returns (bool) { return now >= endTime || isReachedLimit(); } function getBonus(uint _value, uint _sold) internal constant returns (TokensHolder) { TokensHolder memory result; uint _bonus = 0; result.tokens = _value; for (uint8 i = 0; _value > 0 && i < bonusLimit.length; ++i) { uint current_bonus_part = 0; if (_value > 0 && _sold < bonusLimit[i]) { uint bonus_left = bonusLimit[i] - _sold; uint _bonusedPart = min(_value, bonus_left); current_bonus_part = current_bonus_part.add(percent(_bonusedPart, bonusPatterns[i])); _value = _value.sub(_bonusedPart); _sold = _sold.add(_bonusedPart); } if (current_bonus_part > 0) { _bonus = _bonus.add(current_bonus_part); } } result.bonus = _bonus; return result; } function isReachedLimit() internal constant returns (bool) { return tokensCap.sub(totalSupply) == 0; } function manageStatus() internal { if (totalSupply >= minSuccess && !isSuccess) { successICO(); } bool capIsReached = (totalSupply == tokensCap); if (capIsReached || (now >= endTime)) { if (!isSuccess) { failICO(); } else { finishICO(false); } } } function calculateForValue(uint value) public constant returns (uint, uint, uint) { TokensHolder memory tokens = calculateTokens(value); return (tokens.total, tokens.tokens, tokens.bonus); } function calculateTokens(uint value) internal constant returns (TokensHolder) { require(value > 0); require(priceInWei * minTokens <= value); uint tokens = value.div(priceInWei); require(tokens > 0); uint remain = tokensCap.sub(totalSupply); uint change = 0; uint value_clear = 0; if (remain <= tokens) { tokens = remain; change = value.sub(tokens.mul(priceInWei)); value_clear = value.sub(change); } else { value_clear = value; } TokensHolder memory bonus = getBonus(tokens, tokensSoldTotal); uint total = tokens + bonus.bonus; bonus.tokens = tokens; bonus.total = total; bonus.change = change; bonus.rate = priceInWei; bonus.value = value_clear; return bonus; } function addToStat(uint tokens, uint bonus) internal { uint total = tokens + bonus; totalSupply = totalSupply.add(total); tokensSoldTotal = tokensSoldTotal.add(tokens); } function startIco() external onlyOwner { require(icoState == IcoState.Paused); icoState = IcoState.Running; RunIco(); } function pauseIco() external onlyOwner { require(icoState == IcoState.Running); icoState = IcoState.Paused; PauseIco(); } function successICO() internal { isSuccess = true; SuccessIco(); } function finishICO(bool manualFinish) internal successICOState { if(!manualFinish) { bool capIsReached = (totalSupply == tokensCap); if (capIsReached && now < endTime) { endTime = now; } } else { endTime = now; } icoState = IcoState.Finished; tokensAreFrozen = false; token.unblock(); } function failICO() internal { icoState = IcoState.Failed; ICOFails(); } function refund() public ICOFailed { require(msg.sender != 0x0); require(investors[msg.sender] > 0); uint refundVal = investors[msg.sender]; investors[msg.sender] = 0; uint balance = token.balanceOf(msg.sender); totalSupply = totalSupply.sub(balance); msg.sender.transfer(refundVal); } function withdraw(uint value) external onlyOwner successICOState { wallet.transfer(value); } function generateTeamTokens() internal ICOFinished { require(!teamTokensGenerated); teamTokensGenerated = true; if(tokensCap > totalSupply) { uint unsoldAmount = tokensCap.sub(totalSupply); token.mint(unsold, unsoldAmount); totalSupply = totalSupply.add(unsoldAmount); } uint totalSupplyTokens = totalSupply; totalSupplyTokens = totalSupplyTokens.mul(100); totalSupplyTokens = totalSupplyTokens.div(60); for (uint8 i = 0; i < listTeamTokens.length; ++i) { uint teamTokensPart = percent(totalSupplyTokens, listTeamTokens[i].percent); if (listTeamTokens[i].divider != 0) { teamTokensPart = teamTokensPart.div(listTeamTokens[i].divider); } if (listTeamTokens[i].maxTokens != 0 && listTeamTokens[i].maxTokens < teamTokensPart) { teamTokensPart = listTeamTokens[i].maxTokens; } token.mint(listTeamTokens[i].holder, teamTokensPart); if(listTeamTokens[i].freezePeriod != 0) { token.freezeTokens(listTeamTokens[i].holder, endTime + listTeamTokens[i].freezePeriod); } addToStat(teamTokensPart, 0); } } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } function setRobot(address robot) public onlyOwner { require(robot != 0x0); _robot = robot; } function setRate(uint newRate) public onlyTeam { require(newRate > 0); priceInWei = newRate; updateRate(now, newRate); } function robotRefund(address investor) public onlyTeam ICOFailed { require(investor != 0x0); require(investors[investor] > 0); uint refundVal = investors[investor]; investors[investor] = 0; uint balance = token.balanceOf(investor); totalSupply = totalSupply.sub(balance); investor.transfer(refundVal); } function manualFinish() public onlyTeam successICOState { require(!hasFinished()); finishICO(true); generateTeamTokens(); } function autoFinishTime() public onlyTeam { require(hasFinished()); manageStatus(); generateTeamTokens(); } function min(uint a, uint b) internal pure returns (uint) { return a < b ? a : b; } function percent(uint value, uint bonus) internal pure returns (uint) { return (value * bonus).div(100); } }
0
pragma solidity ^0.4.24; contract F3Devents { event onNewName ( uint256 indexed playerID, address indexed playerAddress, bytes32 indexed playerName, bool isNewPlayer, uint256 affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 amountPaid, uint256 timeStamp ); event onEndTx ( uint256 compressedData, uint256 compressedIDs, bytes32 playerName, address playerAddress, uint256 ethIn, uint256 keysBought, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount, uint256 potAmount, uint256 airDropPot ); event onWithdraw ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 ethOut, uint256 timeStamp ); event onWithdrawAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethOut, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount ); event onBuyAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethIn, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount ); event onReLoadAndDistribute ( address playerAddress, bytes32 playerName, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount ); event onAffiliatePayout ( uint256 indexed affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 indexed roundID, uint256 indexed buyerID, uint256 amount, uint256 timeStamp ); event onPotSwapDeposit ( uint256 roundID, uint256 amountAddedToPot ); } contract modularShort is F3Devents {} contract FoMo3DLightning is modularShort { using SafeMath for *; using NameFilter for string; using F3DKeysCalcShort for uint256; PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0xF6b8836492f8332D17B1496828d2bEE71ad511DA); address private admin = msg.sender; string constant public name = "FOMO Lightning"; string constant public symbol = "SHORT"; uint256 private rndExtra_ = 15 minutes; uint256 private rndGap_ = 15 minutes; uint256 constant private rndInit_ = 15 minutes; uint256 constant private rndInc_ = 10 seconds; uint256 constant private rndMax_ = 15 minutes; uint256 public airDropPot_; uint256 public airDropTracker_ = 0; uint256 public rID_; mapping (address => uint256) public pIDxAddr_; mapping (bytes32 => uint256) public pIDxName_; mapping (uint256 => F3Ddatasets.Player) public plyr_; mapping (uint256 => mapping (uint256 => F3Ddatasets.PlayerRounds)) public plyrRnds_; mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; mapping (uint256 => F3Ddatasets.Round) public round_; mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; mapping (uint256 => F3Ddatasets.TeamFee) public fees_; mapping (uint256 => F3Ddatasets.PotSplit) public potSplit_; constructor() public { fees_[0] = F3Ddatasets.TeamFee(49,2); fees_[1] = F3Ddatasets.TeamFee(49,2); fees_[2] = F3Ddatasets.TeamFee(49,2); fees_[3] = F3Ddatasets.TeamFee(49,2); potSplit_[0] = F3Ddatasets.PotSplit(38,2); potSplit_[1] = F3Ddatasets.PotSplit(38,2); potSplit_[2] = F3Ddatasets.PotSplit(38,2); potSplit_[3] = F3Ddatasets.PotSplit(38,2); } modifier isActivated() { require(activated_ == true, "its not ready yet. check ?eta in discord"); _; } modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); require(_eth <= 100000000000000000000000, "no vitalik, no"); _; } function() isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; buyCore(_pID, plyr_[_pID].laff, 2, _eventData_); } function buyXid(uint256 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; if (_affCode == 0 || _affCode == _pID) { _affCode = plyr_[_pID].laff; } else if (_affCode != plyr_[_pID].laff) { plyr_[_pID].laff = _affCode; } _team = verifyTeam(_team); buyCore(_pID, _affCode, _team, _eventData_); } function buyXaddr(address _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == address(0) || _affCode == msg.sender) { _affID = plyr_[_pID].laff; } else { _affID = pIDxAddr_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } _team = verifyTeam(_team); buyCore(_pID, _affID, _team, _eventData_); } function buyXname(bytes32 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == '' || _affCode == plyr_[_pID].name) { _affID = plyr_[_pID].laff; } else { _affID = pIDxName_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } _team = verifyTeam(_team); buyCore(_pID, _affID, _team, _eventData_); } function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; if (_affCode == 0 || _affCode == _pID) { _affCode = plyr_[_pID].laff; } else if (_affCode != plyr_[_pID].laff) { plyr_[_pID].laff = _affCode; } _team = verifyTeam(_team); reLoadCore(_pID, _affCode, _team, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == address(0) || _affCode == msg.sender) { _affID = plyr_[_pID].laff; } else { _affID = pIDxAddr_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } _team = verifyTeam(_team); reLoadCore(_pID, _affID, _team, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == '' || _affCode == plyr_[_pID].name) { _affID = plyr_[_pID].laff; } else { _affID = pIDxName_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } _team = verifyTeam(_team); reLoadCore(_pID, _affID, _team, _eth, _eventData_); } function withdraw() isActivated() isHuman() public { uint256 _rID = rID_; uint256 _now = now; uint256 _pID = pIDxAddr_[msg.sender]; uint256 _eth; if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { F3Ddatasets.EventReturns memory _eventData_; round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eth = withdrawEarnings(_pID); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit F3Devents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } else { _eth = withdrawEarnings(_pID); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); emit F3Devents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now); } } function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function getBuyPrice() public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) ); else return ( 75000000000000 ); } function getTimeLeft() public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now < round_[_rID].end) if (_now > round_[_rID].strt + rndGap_) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].strt + rndGap_).sub(_now) ); else return(0); } function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { uint256 _rID = rID_; if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } function getPlayerVaultsHelper(uint256 _pID, uint256 _rID) private view returns(uint256) { return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) ); } function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256, uint256) { uint256 _rID = rID_; return ( round_[_rID].ico, _rID, round_[_rID].keys, round_[_rID].end, round_[_rID].strt, round_[_rID].pot, (round_[_rID].team + (round_[_rID].plyr * 10)), plyr_[round_[_rID].plyr].addr, plyr_[round_[_rID].plyr].name, rndTmEth_[_rID][0], rndTmEth_[_rID][1], rndTmEth_[_rID][2], rndTmEth_[_rID][3], airDropTracker_ + (airDropPot_ * 1000) ); } function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, plyr_[_pID].name, plyrRnds_[_pID][_rID].keys, plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff, plyrRnds_[_pID][_rID].eth ); } function buyCore(uint256 _pID, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { core(_rID, _pID, msg.value, _affID, _team, _eventData_); } else { if (_now > round_[_rID].end && round_[_rID].ended == false) { round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit F3Devents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, F3Ddatasets.EventReturns memory _eventData_) private { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); core(_rID, _pID, _eth, _affID, _team, _eventData_); } else if (_now > round_[_rID].end && round_[_rID].ended == false) { round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit F3Devents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } } function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 2100000000000000000) { uint256 _availableLimit = (2100000000000000000).sub(plyrRnds_[_pID][_rID].eth); uint256 _refund = _eth.sub(_availableLimit); plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); _eth = _availableLimit; } if (_eth > 1000000000) { uint256 _keys = (round_[_rID].eth).keysRec(_eth); if (_keys >= 1000000000000000000) { updateTimer(_keys, _rID); if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; _eventData_.compressedData = _eventData_.compressedData + 100; } if (_eth >= 100000000000000000) { airDropTracker_++; if (airdrop() == true) { uint256 _prize; if (_eth >= 10000000000000000000) { _prize = ((airDropPot_).mul(75)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; } else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) { _prize = ((airDropPot_).mul(50)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 200000000000000000000000000000000; } else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) { _prize = ((airDropPot_).mul(25)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; } _eventData_.compressedData += 10000000000000000000000000000000; _eventData_.compressedData += _prize * 1000000000000000000000000000000000; airDropTracker_ = 0; } } _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000); plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]); _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_); endTx(_pID, _team, _eth, _keys, _eventData_); } } function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) ); } function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256) { uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].eth).keysRec(_eth) ); else return ( (_eth).keys() ); } function iWantXKeys(uint256 _keys) public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) ); else return ( (_keys).eth() ); } function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function determinePID(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; if (_pID == 0) { _pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } function verifyTeam(uint256 _team) private pure returns (uint256) { if (_team < 0 || _team > 3) return(2); else return(_team); } function managePlayer(uint256 _pID, F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); plyr_[_pID].lrnd = rID_; _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } function endRound(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { uint256 _rID = rID_; uint256 _winPID = round_[_rID].plyr; uint256 _winTID = round_[_rID].team; uint256 _pot = round_[_rID].pot; uint256 _win = (_pot.mul(48)) / 100; uint256 _com = (_pot / 50); uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; uint256 _p3d = (_pot.mul(potSplit_[_winTID].p3d)) / 100; uint256 _res = (((_pot.sub(_win)).sub(_com)).sub(_gen)).sub(_p3d); uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0) { _gen = _gen.sub(_dust); _res = _res.add(_dust); } plyr_[_winPID].win = _win.add(plyr_[_winPID].win); admin.transfer(_com); admin.transfer(_p3d.sub(_p3d / 2)); round_[_rID].pot = _pot.add(_p3d / 2); round_[_rID].mask = _ppt.add(round_[_rID].mask); _eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000); _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.amountWon = _win; _eventData_.genAmount = _gen; _eventData_.P3DAmount = _p3d; _eventData_.newPot = _res; rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); round_[_rID].pot = _res; return(_eventData_); } function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0) { plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); } } function updateTimer(uint256 _keys, uint256 _rID) private { uint256 _now = now; uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end); if (_newTime < (rndMax_).add(_now)) round_[_rID].end = _newTime; else round_[_rID].end = rndMax_.add(_now); } function airdrop() private view returns(bool) { uint256 seed = uint256(keccak256(abi.encodePacked( (block.timestamp).add (block.difficulty).add ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add (block.gaslimit).add ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add (block.number) ))); if((seed - ((seed / 1000) * 1000)) < airDropTracker_) return(true); else return(false); } function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { uint256 _p1 = _eth / 100; uint256 _com = _eth / 50; _com = _com.add(_p1); uint256 _p3d; if (!address(admin).call.value(_com)()) { _p3d = _com; _com = 0; } uint256 _aff = _eth / 10; if (_affID != _pID && plyr_[_affID].name != '') { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now); } else { _p3d = _aff; } _p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100)); if (_p3d > 0) { uint256 _potAmount = _p3d / 2; admin.transfer(_p3d.sub(_potAmount)); round_[_rID].pot = round_[_rID].pot.add(_potAmount); _eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount); } return(_eventData_); } function potSwap() external payable { uint256 _rID = rID_ + 1; round_[_rID].pot = round_[_rID].pot.add(msg.value); emit F3Devents.onPotSwapDeposit(_rID, msg.value); } function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; uint256 _air = (_eth / 100); airDropPot_ = airDropPot_.add(_air); _eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].p3d)) / 100)); uint256 _pot = _eth.sub(_gen); uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000))); } function withdrawEarnings(uint256 _pID) private returns(uint256) { updateGenVault(_pID, plyr_[_pID].lrnd); uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff); if (_earnings > 0) { plyr_[_pID].win = 0; plyr_[_pID].gen = 0; plyr_[_pID].aff = 0; } return(_earnings); } function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit F3Devents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount, _eventData_.potAmount, airDropPot_ ); } bool public activated_ = false; function activate() public { require(msg.sender == admin, "only admin can activate"); require(activated_ == false, "FOMO Short already activated"); activated_ = true; rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } } library F3Ddatasets { struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; bytes32 winnerName; uint256 amountWon; uint256 newPot; uint256 P3DAmount; uint256 genAmount; uint256 potAmount; } struct Player { address addr; bytes32 name; uint256 win; uint256 gen; uint256 aff; uint256 lrnd; uint256 laff; } struct PlayerRounds { uint256 eth; uint256 keys; uint256 mask; uint256 ico; } struct Round { uint256 plyr; uint256 team; uint256 end; bool ended; uint256 strt; uint256 keys; uint256 eth; uint256 pot; uint256 mask; uint256 ico; uint256 icoGen; uint256 icoAvg; } struct TeamFee { uint256 gen; uint256 p3d; } struct PotSplit { uint256 gen; uint256 p3d; } } library F3DKeysCalcShort { using SafeMath for *; function keysRec(uint256 _curEth, uint256 _newEth) internal pure returns (uint256) { return(keys((_curEth).add(_newEth)).sub(keys(_curEth))); } function ethRec(uint256 _curKeys, uint256 _sellKeys) internal pure returns (uint256) { return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys)))); } function keys(uint256 _eth) internal pure returns(uint256) { return ((((((_eth).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000); } function eth(uint256 _keys) internal pure returns(uint256) { return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq()); } } interface PlayerBookInterface { function getPlayerID(address _addr) external returns (uint256); function getPlayerName(uint256 _pID) external view returns (bytes32); function getPlayerLAff(uint256 _pID) external view returns (uint256); function getPlayerAddr(uint256 _pID) external view returns (address); function getNameFee() external view returns (uint256); function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256); function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256); function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256); } library NameFilter { function nameFilter(string _input) internal pure returns(bytes32) { bytes memory _temp = bytes(_input); uint256 _length = _temp.length; require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters"); require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space"); if (_temp[0] == 0x30) { require(_temp[1] != 0x78, "string cannot start with 0x"); require(_temp[1] != 0x58, "string cannot start with 0X"); } bool _hasNonNumber; for (uint256 i = 0; i < _length; i++) { if (_temp[i] > 0x40 && _temp[i] < 0x5b) { _temp[i] = byte(uint(_temp[i]) + 32); if (_hasNonNumber == false) _hasNonNumber = true; } else { require ( _temp[i] == 0x20 || (_temp[i] > 0x60 && _temp[i] < 0x7b) || (_temp[i] > 0x2f && _temp[i] < 0x3a), "string contains invalid characters" ); if (_temp[i] == 0x20) require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces"); if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39)) _hasNonNumber = true; } } require(_hasNonNumber == true, "string cannot be only numbers"); bytes32 _ret; assembly { _ret := mload(add(_temp, 32)) } return (_ret); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b, "SafeMath mul failed"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath sub failed"); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } }
0
pragma solidity ^0.4.18; contract PrivateBank { mapping (address => uint) balances; function GetBal() public constant returns(uint) { return balances[msg.sender]; } uint public MinDeposit = 1 ether; Log TransferLog; function PrivateBank(address _lib) { TransferLog = Log(_lib); } function Deposit() public payable { if(msg.value >= MinDeposit) { balances[msg.sender]+=msg.value; TransferLog.AddMessage(msg.sender,msg.value,"Deposit"); } } function CashOut(uint _am) { if(_am<=balances[msg.sender]) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; TransferLog.AddMessage(msg.sender,_am,"CashOut"); } } } function() public payable{} function bal() public constant returns(uint) { return this.balance; } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message public LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
0
pragma solidity ^0.4.23; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract FreezableToken is StandardToken { mapping (bytes32 => uint64) internal chains; mapping (bytes32 => uint) internal freezings; mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner) + freezingBalance[_owner]; } function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract FreezableMintableToken is FreezableToken, MintableToken { function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint public constant TOKEN_DECIMALS = 8; uint8 public constant TOKEN_DECIMALS_UINT8 = 8; uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string public constant TOKEN_NAME = "NITTO"; string public constant TOKEN_SYMBOL = "NIT"; bool public constant PAUSED = false; address public constant TARGET_USER = 0xb3938B5A09386a941C52E70C9B575C7b236805b7; uint public constant START_TIME = 1557153840; bool public constant CONTINUE_MINTING = false; } contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable { function name() public pure returns (string _name) { return TOKEN_NAME; } function symbol() public pure returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() public pure returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } }
1
contract Token { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} function approve(address _spender, uint256 _value) returns (bool success) {} function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract WBTCToken is StandardToken { string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; uint256 public unitsOneEthCanBuy; uint256 public totalEthInWei; address public fundsWallet; function WhiteBitcoin() { balances[msg.sender] = 2100000000000000000000000; totalSupply = 2100000000000000000000000; name = "White Bitcoin"; decimals = 18; symbol = "WBTC"; unitsOneEthCanBuy = 1000; fundsWallet = msg.sender; } function() payable{ totalEthInWei = totalEthInWei + msg.value; uint256 amount = msg.value * unitsOneEthCanBuy; require(balances[fundsWallet] >= amount); balances[fundsWallet] = balances[fundsWallet] - amount; balances[msg.sender] = balances[msg.sender] + amount; Transfer(fundsWallet, msg.sender, amount); fundsWallet.transfer(msg.value); } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
1
pragma solidity ^0.4.24; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC223ReceivingContract { function tokenFallback(address _from, uint _value, bytes _data); } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract Bounty0xEscrow is Ownable, ERC223ReceivingContract, Pausable { using SafeMath for uint256; mapping (address => mapping (address => uint)) public tokens; event Deposit(address indexed token, address indexed user, uint amount, uint balance); event Distribution(address indexed token, address indexed host, address indexed hunter, uint256 amount); constructor() public { } function tokenFallback(address _from, uint _value, bytes _data) public whenNotPaused { address _token = msg.sender; tokens[_token][_from] = SafeMath.add(tokens[_token][_from], _value); emit Deposit(_token, _from, _value, tokens[_token][_from]); } function depositToken(address _token, uint _amount) public whenNotPaused { require(_token != address(0)); require(ERC20(_token).transferFrom(msg.sender, this, _amount)); tokens[_token][msg.sender] = SafeMath.add(tokens[_token][msg.sender], _amount); emit Deposit(_token, msg.sender, _amount, tokens[_token][msg.sender]); } function depositEther() public payable whenNotPaused { tokens[address(0)][msg.sender] = SafeMath.add(tokens[address(0)][msg.sender], msg.value); emit Deposit(address(0), msg.sender, msg.value, tokens[address(0)][msg.sender]); } function distributeTokenToAddress(address _token, address _host, address _hunter, uint256 _amount) external onlyOwner { require(_hunter != address(0)); require(tokens[_token][_host] >= _amount); tokens[_token][_host] = SafeMath.sub(tokens[_token][_host], _amount); if (_token == address(0)) { require(_hunter.send(_amount)); } else { ERC20(_token).transfer(_hunter, _amount); } emit Distribution(_token, _host, _hunter, _amount); } function distributeTokenToAddressesAndAmounts(address _token, address _host, address[] _hunters, uint256[] _amounts) external onlyOwner { require(_host != address(0)); require(_hunters.length == _amounts.length); uint256 totalAmount = 0; for (uint j = 0; j < _amounts.length; j++) { totalAmount = SafeMath.add(totalAmount, _amounts[j]); } require(tokens[_token][_host] >= totalAmount); tokens[_token][_host] = SafeMath.sub(tokens[_token][_host], totalAmount); if (_token == address(0)) { for (uint i = 0; i < _hunters.length; i++) { require(_hunters[i].send(_amounts[i])); emit Distribution(_token, _host, _hunters[i], _amounts[i]); } } else { for (uint k = 0; k < _hunters.length; k++) { ERC20(_token).transfer(_hunters[k], _amounts[k]); emit Distribution(_token, _host, _hunters[k], _amounts[k]); } } } function distributeTokenToAddressesAndAmountsWithoutHost(address _token, address[] _hunters, uint256[] _amounts) external onlyOwner { require(_hunters.length == _amounts.length); uint256 totalAmount = 0; for (uint j = 0; j < _amounts.length; j++) { totalAmount = SafeMath.add(totalAmount, _amounts[j]); } if (_token == address(0)) { require(address(this).balance >= totalAmount); for (uint i = 0; i < _hunters.length; i++) { require(_hunters[i].send(_amounts[i])); emit Distribution(_token, this, _hunters[i], _amounts[i]); } } else { require(ERC20(_token).balanceOf(this) >= totalAmount); for (uint k = 0; k < _hunters.length; k++) { ERC20(_token).transfer(_hunters[k], _amounts[k]); emit Distribution(_token, this, _hunters[k], _amounts[k]); } } } function distributeWithTransferFrom(address _token, address _ownerOfTokens, address[] _hunters, uint256[] _amounts) external onlyOwner { require(_token != address(0)); require(_hunters.length == _amounts.length); uint256 totalAmount = 0; for (uint j = 0; j < _amounts.length; j++) { totalAmount = SafeMath.add(totalAmount, _amounts[j]); } require(ERC20(_token).allowance(_ownerOfTokens, this) >= totalAmount); for (uint i = 0; i < _hunters.length; i++) { ERC20(_token).transferFrom(_ownerOfTokens, _hunters[i], _amounts[i]); emit Distribution(_token, this, _hunters[i], _amounts[i]); } } function approveToPullOutTokens(address _token, address _receiver, uint256 _amount) external onlyOwner { ERC20(_token).approve(_receiver, _amount); } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30499200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xFC98120B22555578f76A5C9Be76689718ed2166A; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.25; contract Token { function transfer(address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); } contract NescrowExchangeService { address owner = msg.sender; uint256 public feeRateLimit = 200; uint256 public takerFeeRate = 0; uint256 public makerFeeRate = 0; address public feeAddress; mapping (address => bool) public admins; mapping (bytes32 => uint256) public orderFills; mapping (bytes32 => bool) public withdrawn; mapping (bytes32 => bool) public transfers; mapping (address => mapping (address => uint256)) public balances; mapping (address => uint256) public tradesLocked; mapping (address => uint256) public disableFees; mapping (address => uint256) public tokenDecimals; mapping (address => bool) public tokenRegistered; struct EIP712Domain { string name; string version; uint256 chainId; address verifyingContract; } event Deposit(address token, address user, uint256 amount, uint256 balance); event Withdraw(address token, address user, uint256 amount, uint256 balance); event TradesLock(address user); event TradesUnlock(address user); modifier onlyOwner { assert(msg.sender == owner); _; } modifier onlyAdmin { require(msg.sender == owner || admins[msg.sender]); _; } bytes32 constant EIP712DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); bytes32 constant ORDER_TYPEHASH = keccak256("Order(address sell,address buy,uint256 sellAmount,uint256 buyAmount,uint256 withdrawOnTrade,uint256 sellSide,uint256 expires,uint256 nonce)"); bytes32 constant ORDER_WITH_TIPS_TYPEHASH = keccak256("OrderWithTips(address sell,address buy,uint256 sellAmount,uint256 buyAmount,uint256 withdrawOnTrade,uint256 sellSide,uint256 expires,uint256 nonce,uint256 makerTips,uint256 takerTips)"); bytes32 constant WITHDRAWAL_TYPEHASH = keccak256("Withdrawal(address withdrawToken,uint256 amount,uint256 nonce)"); bytes32 constant TIPS_TYPEHASH = keccak256("Tips(address tipsToken,uint256 amount,uint256 nonce)"); bytes32 constant TRANSFER_TYPEHASH = keccak256("Transfer(address transferToken,address to,uint256 amount,uint256 nonce)"); bytes32 DOMAIN_SEPARATOR; function domainHash(EIP712Domain eip712Domain) internal pure returns (bytes32) { return keccak256(abi.encode( EIP712DOMAIN_TYPEHASH, keccak256(bytes(eip712Domain.name)), keccak256(bytes(eip712Domain.version)), eip712Domain.chainId, eip712Domain.verifyingContract )); } constructor() public { DOMAIN_SEPARATOR = domainHash(EIP712Domain({ name: "Nescrow Exchange", version: '1', chainId: 1, verifyingContract: this })); tokenRegistered[0x0] = true; tokenDecimals[0x0] = 18; } function setOwner(address newOwner) external onlyOwner { owner = newOwner; } function getOwner() public view returns (address out) { return owner; } function setAdmin(address admin, bool isAdmin) external onlyOwner { admins[admin] = isAdmin; } function deposit() external payable { uint amount = safeDiv(msg.value, 10**10); require(amount > 0); increaseBalance(msg.sender, address(0), amount); } function depositToken(address token, uint256 amount) external { require(amount > 0); require(safeTransferFrom(token, msg.sender, this, toTokenAmount(token, amount))); increaseBalance(msg.sender, token, amount); } function depositTokenByAdmin(address user, address token, uint256 amount) external onlyAdmin { require(amount > 0); require(safeTransferFrom(token, user, this, toTokenAmount(token, amount))); increaseBalance(user, token, amount); } function sendTips() external payable { uint amount = safeDiv(msg.value, 10**10); require(amount > 0); increaseBalance(feeAddress, address(0), amount); } function transferTips(address token, uint256 amount, address fromUser, uint nonce, uint8 v, bytes32 r, bytes32 s) external onlyAdmin { require(amount > 0); bytes32 hash = keccak256(abi.encode(TIPS_TYPEHASH, token, amount, nonce)); require(ecrecover(keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, hash)), v, r, s) == fromUser); require(!transfers[hash]); transfers[hash] = true; require(reduceBalance(fromUser, token, amount)); increaseBalance(feeAddress, token, amount); } function transfer(address token, uint256 amount, address fromUser, address toUser, uint nonce, uint8 v, bytes32 r, bytes32 s) external onlyAdmin { require(amount > 0); bytes32 hash = keccak256(abi.encode(TRANSFER_TYPEHASH, token, toUser, amount, nonce)); require(ecrecover(keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, hash)), v, r, s) == fromUser); transfers[hash] = true; require(reduceBalance(fromUser, token, amount)); increaseBalance(toUser, token, amount); } function withdrawByAdmin(address token, uint256 amount, address user, uint nonce, uint8 v, bytes32 r, bytes32 s) external onlyAdmin { require(amount > 0); bytes32 hash = keccak256(abi.encode(WITHDRAWAL_TYPEHASH, token, amount, nonce)); require(ecrecover(keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, hash)), v, r, s) == user); require(!withdrawn[hash]); withdrawn[hash] = true; require(reduceBalance(user, token, amount)); require(sendToUser(user, token, amount)); } function withdraw(address token, uint256 amount) external { require(amount > 0); require(tradesLocked[msg.sender] > block.number); require(reduceBalance(msg.sender, token, amount)); require(sendToUser(msg.sender, token, amount)); emit Withdraw(token, msg.sender, amount, balances[token][msg.sender]); } function reduceBalance(address user, address token, uint256 amount) private returns(bool) { if (balances[token][user] < amount) return false; balances[token][user] = safeSub(balances[token][user], amount); return true; } function increaseBalanceOrWithdraw(address user, address token, uint256 amount, uint256 _withdraw) private returns(bool) { if (_withdraw == 1) { return sendToUser(user, token, amount); } else { return increaseBalance(user, token, amount); } } function increaseBalance(address user, address token, uint256 amount) private returns(bool) { balances[token][user] = safeAdd(balances[token][user], amount); return true; } function sendToUser(address user, address token, uint256 amount) private returns(bool) { if (token == address(0)) { return user.send(toTokenAmount(address(0), amount)); } else { return safeTransfer(token, user, toTokenAmount(token, amount)); } } function toTokenAmount(address token, uint256 amount) private view returns (uint256) { require(tokenRegistered[token]); uint256 decimals = token == address(0) ? 18 : tokenDecimals[token]; if (decimals == 8) { return amount; } if (decimals > 8) { return safeMul(amount, 10**(decimals - 8)); } else { return safeDiv(amount, 10**(8 - decimals)); } } function setTakerFeeRate(uint256 feeRate) external onlyAdmin { require(feeRate == 0 || feeRate >= feeRateLimit); takerFeeRate = feeRate; } function setMakerFeeRate(uint256 feeRate) external onlyAdmin { require(feeRate == 0 || feeRate >= feeRateLimit); makerFeeRate = feeRate; } function setFeeAddress(address _feeAddress) external onlyAdmin { require(_feeAddress != address(0)); feeAddress = _feeAddress; } function disableFeesForUser(address user, uint256 timestamp) external onlyAdmin { require(timestamp > block.timestamp); disableFees[user] = timestamp; } function registerToken(address token, uint256 decimals) external onlyAdmin { require(!tokenRegistered[token]); tokenRegistered[token] = true; tokenDecimals[token] = decimals; } function tradesLock(address user) external { require(user == msg.sender); tradesLocked[user] = block.number + 20000; emit TradesLock(user); } function tradesUnlock(address user) external { require(user == msg.sender); tradesLocked[user] = 0; emit TradesUnlock(user); } function isUserMakerFeeEnabled(address user) private view returns(bool) { return makerFeeRate > 0 && disableFees[user] < block.timestamp; } function isUserTakerFeeEnabled(address user) private view returns(bool) { return takerFeeRate > 0 && disableFees[user] < block.timestamp; } function calculatePrice(uint256 offerAmount, uint256 wantAmount, uint256 sellSide) private pure returns(uint256) { return sellSide == 0 ? safeDiv(safeMul(10**8, offerAmount), wantAmount) : safeDiv(safeMul(10**8, wantAmount), offerAmount); } function trade( uint256[10] amounts, address[4] addresses, uint256[5] values, bytes32[4] rs ) external onlyAdmin { require(tradesLocked[addresses[0]] < block.number); require(block.timestamp <= amounts[2]); bytes32 orderHash = keccak256(abi.encode(ORDER_TYPEHASH, addresses[2], addresses[3], amounts[0], amounts[1], values[2], values[4], amounts[2], amounts[3])); require(ecrecover(keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, orderHash)), uint8(values[0]), rs[0], rs[1]) == addresses[0]); orderFills[orderHash] = safeAdd(orderFills[orderHash], amounts[8]); require(orderFills[orderHash] <= amounts[0]); require(tradesLocked[addresses[1]] < block.number); require(block.timestamp <= amounts[6]); bytes32 orderHash2 = keccak256(abi.encode(ORDER_TYPEHASH, addresses[3], addresses[2], amounts[4], amounts[5], values[3], values[4] == 0 ? 1 : 0, amounts[6], amounts[7])); require(ecrecover(keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, orderHash2)), uint8(values[1]), rs[2], rs[3]) == addresses[1]); uint256 makerPrice = calculatePrice(amounts[0], amounts[1], values[4]); uint256 takerPrice = calculatePrice(amounts[4], amounts[5], values[4] == 0 ? 1 : 0); require(values[4] == 0 && makerPrice >= takerPrice || values[4] == 1 && makerPrice <= takerPrice); require(makerPrice == calculatePrice(amounts[8], amounts[9], values[4])); orderFills[orderHash2] = safeAdd(orderFills[orderHash2], amounts[9]); require(orderFills[orderHash2] <= amounts[4]); require(reduceBalance(addresses[0], addresses[2], amounts[8])); require(reduceBalance(addresses[1], addresses[3], amounts[9])); if (isUserMakerFeeEnabled(addresses[0])) { require(increaseBalanceOrWithdraw(addresses[0], addresses[3], safeSub(amounts[9], safeDiv(amounts[9], makerFeeRate)), values[2])); increaseBalance(feeAddress, addresses[3], safeDiv(amounts[9], makerFeeRate)); } else { require(increaseBalanceOrWithdraw(addresses[0], addresses[3], amounts[9], values[2])); } if (isUserTakerFeeEnabled(addresses[1])) { require(increaseBalanceOrWithdraw(addresses[1], addresses[2], safeSub(amounts[8], safeDiv(amounts[8], takerFeeRate)), values[3])); increaseBalance(feeAddress, addresses[2], safeDiv(amounts[8], takerFeeRate)); } else { require(increaseBalanceOrWithdraw(addresses[1], addresses[2], amounts[8], values[3])); } } function tradeWithTips( uint256[10] amounts, address[4] addresses, uint256[9] values, bytes32[4] rs ) external onlyAdmin { require(tradesLocked[addresses[0]] < block.number); require(block.timestamp <= amounts[2]); bytes32 orderHash = values[5] > 0 || values[6] > 0 ? keccak256(abi.encode(ORDER_WITH_TIPS_TYPEHASH, addresses[2], addresses[3], amounts[0], amounts[1], values[2], values[4], amounts[2], amounts[3], values[5], values[6])) : keccak256(abi.encode(ORDER_TYPEHASH, addresses[2], addresses[3], amounts[0], amounts[1], values[2], values[4], amounts[2], amounts[3])); require(ecrecover(keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, orderHash)), uint8(values[0]), rs[0], rs[1]) == addresses[0]); orderFills[orderHash] = safeAdd(orderFills[orderHash], amounts[8]); require(orderFills[orderHash] <= amounts[0]); require(tradesLocked[addresses[1]] < block.number); require(block.timestamp <= amounts[6]); bytes32 orderHash2 = values[7] > 0 || values[8] > 0 ? keccak256(abi.encode(ORDER_WITH_TIPS_TYPEHASH, addresses[3], addresses[2], amounts[4], amounts[5], values[3], values[4] == 0 ? 1 : 0, amounts[6], amounts[7], values[7], values[8])) : keccak256(abi.encode(ORDER_TYPEHASH, addresses[3], addresses[2], amounts[4], amounts[5], values[3], values[4] == 0 ? 1 : 0, amounts[6], amounts[7])); require(ecrecover(keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, orderHash2)), uint8(values[1]), rs[2], rs[3]) == addresses[1]); uint256 makerPrice = calculatePrice(amounts[0], amounts[1], values[4]); uint256 takerPrice = calculatePrice(amounts[4], amounts[5], values[4] == 0 ? 1 : 0); require(values[4] == 0 && makerPrice >= takerPrice || values[4] == 1 && makerPrice <= takerPrice); require(makerPrice == calculatePrice(amounts[8], amounts[9], values[4])); orderFills[orderHash2] = safeAdd(orderFills[orderHash2], amounts[9]); require(orderFills[orderHash2] <= amounts[4]); require(reduceBalance(addresses[0], addresses[2], amounts[8])); require(reduceBalance(addresses[1], addresses[3], amounts[9])); if (values[5] > 0 && !isUserMakerFeeEnabled(addresses[0])) { increaseBalanceOrWithdraw(addresses[0], addresses[3], safeSub(amounts[9], safeDiv(amounts[9], values[5])), values[2]); increaseBalance(feeAddress, addresses[3], safeDiv(amounts[9], values[5])); } else if (values[5] == 0 && isUserMakerFeeEnabled(addresses[0])) { increaseBalanceOrWithdraw(addresses[0], addresses[3], safeSub(amounts[9], safeDiv(amounts[9], makerFeeRate)), values[2]); increaseBalance(feeAddress, addresses[3], safeDiv(amounts[9], makerFeeRate)); } else if (values[5] > 0 && isUserMakerFeeEnabled(addresses[0])) { increaseBalanceOrWithdraw(addresses[0], addresses[3], safeSub(amounts[9], safeAdd(safeDiv(amounts[9], values[5]), safeDiv(amounts[9], makerFeeRate))), values[2]); increaseBalance(feeAddress, addresses[3], safeAdd(safeDiv(amounts[9], values[5]), safeDiv(amounts[9], makerFeeRate))); } else { increaseBalanceOrWithdraw(addresses[0], addresses[3], amounts[9], values[2]); } if (values[8] > 0 && !isUserTakerFeeEnabled(addresses[1])) { increaseBalanceOrWithdraw(addresses[1], addresses[2], safeSub(amounts[8], safeDiv(amounts[8], values[8])), values[3]); increaseBalance(feeAddress, addresses[2], safeDiv(amounts[8], values[8])); } else if (values[8] == 0 && isUserTakerFeeEnabled(addresses[1])) { increaseBalanceOrWithdraw(addresses[1], addresses[2], safeSub(amounts[8], safeDiv(amounts[8], takerFeeRate)), values[3]); increaseBalance(feeAddress, addresses[2], safeDiv(amounts[8], takerFeeRate)); } else if (values[8] > 0 && isUserTakerFeeEnabled(addresses[1])) { increaseBalanceOrWithdraw(addresses[1], addresses[2], safeSub(amounts[8], safeAdd(safeDiv(amounts[8], values[8]), safeDiv(amounts[8], takerFeeRate))), values[3]); increaseBalance(feeAddress, addresses[2], safeAdd(safeDiv(amounts[8], values[8]), safeDiv(amounts[8], takerFeeRate))); } else { increaseBalanceOrWithdraw(addresses[1], addresses[2], amounts[8], values[3]); } } function() public payable { revert(); } function safeMul(uint a, uint b) internal pure returns (uint) { uint c = a * b; assert(a == 0 || 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 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 safeTransfer( address token, address to, uint256 value) private returns (bool success) { success = token.call(0xa9059cbb, to, value); return checkReturnValue(success); } function safeTransferFrom( address token, address from, address to, uint256 value) private returns (bool success) { success = token.call(0x23b872dd, from, to, value); return checkReturnValue(success); } function checkReturnValue( bool success ) private pure returns (bool) { if (success) { assembly { switch returndatasize() case 0 { success := 1 } case 32 { returndatacopy(0, 0, 32) success := mload(0) } default { success := 0 } } } return success; } }
0
pragma solidity ^0.4.24; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract BurnableToken is StandardToken, Ownable { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) onlyOwner public { require(_value > 0); require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); emit Burn(burner, _value); emit Transfer(burner, address(0), _value); } } contract DORACoin is BurnableToken { string public constant name = "DORA coin"; string public constant symbol = "DOR"; uint public constant decimals = 6; uint256 public constant initialSupply = 1200000000 * (10 ** uint256(decimals)); constructor() public { totalSupply = initialSupply; balances[msg.sender] = initialSupply; } }
1
pragma solidity ^0.4.21; library Util { struct Object { bool isObject; bool isActive; bool isRejected; uint index; bytes32 badge; } struct List { mapping(address => Object) registry; uint length; } function add(List storage list, address _addr, bytes32 _badge) internal { list.registry[_addr].isObject = true; list.registry[_addr].index = list.length; list.registry[_addr].badge = _badge; list.length++; } function remove(List storage list, address _addr) internal { list.registry[_addr].isObject = false; } function activate(List storage list, address _addr) internal { list.registry[_addr].isActive = true; } function deactivate(List storage list, address _addr) internal { list.registry[_addr].isActive = false; } function accept(List storage list, address _addr) internal { list.registry[_addr].isRejected = false; } function reject(List storage list, address _addr) internal { list.registry[_addr].isRejected = true; } function isObject(List storage list, address _addr) view internal returns (bool) { return list.registry[_addr].isObject; } function isActive(List storage list, address _addr) view internal returns (bool) { return list.registry[_addr].isActive; } function isRejected(List storage list, address _addr) view internal returns (bool) { return list.registry[_addr].isRejected; } function indexOf(List storage list, address _addr) view internal returns (uint) { return list.registry[_addr].index; } function getBadge(List storage list, address _addr) view internal returns (bytes32) { return list.registry[_addr].badge; } function length(List storage list) view internal returns (uint) { return list.length; } } contract CanYaDao { bytes32 private constant BADGE_ADMIN = "Admin"; bytes32 private constant BADGE_MOD = "Mod"; bytes32 public currentBadge = "Pioneer"; Util.List private _admins; Util.List private _mods; Util.List private _providers; modifier onlyAdmins() { require(Util.isObject(_admins, msg.sender) == true); _; } modifier onlyMods() { require(Util.isObject(_mods, msg.sender) == true); _; } event onAdminAdded(address _addr); event onAdminRemoved(address _addr); event onModAdded(address _addr); event onModRemoved(address _addr); event onProviderAdded(address _addr); event onProviderRemoved(address _addr); event onProviderActivated(address _addr); event onProviderDeactivated(address _addr); event onProviderAccepted(address _addr); event onProviderRejected(address _addr); function CanYaDao() public { Util.add(_admins, msg.sender, BADGE_ADMIN); Util.add(_mods, msg.sender, BADGE_ADMIN); } function addAdmin(address _addr) onlyAdmins public { if ( Util.isObject(_admins, _addr) == false ) { Util.add(_admins, _addr, BADGE_ADMIN); emit onAdminAdded(_addr); addMod(_addr); } } function removeAdmin(address _addr) onlyAdmins public { if ( Util.isObject(_admins, _addr) == true ) { Util.remove(_admins, _addr); emit onAdminRemoved(_addr); removeMod(_addr); } } function isAdmin(address _addr) public view returns (bool) { return Util.isObject(_admins, _addr); } function addMod(address _addr) onlyAdmins public { if ( Util.isObject(_mods, _addr) == false ) { Util.add(_mods, _addr, BADGE_ADMIN); emit onModAdded(_addr); } } function removeMod(address _addr) onlyAdmins public { if ( Util.isObject(_mods, _addr) == true ) { Util.remove(_mods, _addr); emit onModRemoved(_addr); } } function isMod(address _addr) public view returns (bool) { return Util.isObject(_mods, _addr); } function addProvider(address _addr) onlyMods public { if ( Util.isObject(_providers, _addr) == true ) revert(); Util.add(_providers, _addr, currentBadge); emit onProviderAdded(_addr); } function removeProvider(address _addr) onlyMods public { if ( Util.isObject(_providers, _addr) == false ) revert(); Util.remove(_providers, _addr); emit onProviderRemoved(_addr); } function activateProvider(address _addr) onlyMods public { if ( Util.isActive(_providers, _addr) == true ) revert(); Util.activate(_providers, _addr); emit onProviderActivated(_addr); } function deactivateProvider(address _addr) onlyMods public { if ( Util.isActive(_providers, _addr) == false ) revert(); Util.deactivate(_providers, _addr); emit onProviderDeactivated(_addr); } function acceptProvider(address _addr) onlyMods public { if ( Util.isRejected(_providers, _addr) == false ) revert(); Util.accept(_providers, _addr); emit onProviderAccepted(_addr); } function rejectProvider(address _addr) onlyMods public { if ( Util.isRejected(_providers, _addr) == true ) revert(); Util.reject(_providers, _addr); emit onProviderRejected(_addr); } function isProvider(address _addr) public view returns (bool) { return Util.isObject(_providers, _addr); } function isActive(address _addr) public view returns (bool) { return Util.isActive(_providers, _addr); } function isRejected(address _addr) public view returns (bool) { return Util.isRejected(_providers, _addr); } function indexOfProvider(address _addr) public view returns (uint) { return Util.indexOf(_providers, _addr); } function getProviderBadge(address _addr) public view returns (bytes32) { return Util.getBadge(_providers, _addr); } function sizeOfProviders() public view returns (uint) { return Util.length(_providers); } function setCurrentBadge(bytes32 _badge) onlyAdmins public { currentBadge = _badge; } function () public payable { revert(); } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29721600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xe9f8c83a35f8afdF3104506Cc8eC59525B795ECe; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; contract Manager { address public ceo; address public cfo; address public coo; address public cao; event OwnershipTransferred(address indexed previousCeo, address indexed newCeo); event Pause(); event Unpause(); function Manager() public { coo = msg.sender; cfo = 0x447870C2f334Fcda68e644aE53Db3471A9f7302D; ceo = 0x6EC9C6fcE15DB982521eA2087474291fA5Ad6d31; cao = 0x391Ef2cB0c81A2C47D659c3e3e6675F550e4b183; } modifier onlyCEO() { require(msg.sender == ceo); _; } modifier onlyCOO() { require(msg.sender == coo); _; } modifier onlyCAO() { require(msg.sender == cao); _; } bool allowTransfer = false; function changeAllowTransferState() public onlyCOO { if (allowTransfer) { allowTransfer = false; } else { allowTransfer = true; } } modifier whenTransferAllowed() { require(allowTransfer); _; } function demiseCEO(address newCeo) public onlyCEO { require(newCeo != address(0)); OwnershipTransferred(ceo, newCeo); ceo = newCeo; } function setCFO(address newCfo) public onlyCEO { require(newCfo != address(0)); cfo = newCfo; } function setCOO(address newCoo) public onlyCEO { require(newCoo != address(0)); coo = newCoo; } function setCAO(address newCao) public onlyCEO { require(newCao != address(0)); cao = newCao; } bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyCAO whenNotPaused public { paused = true; Pause(); } function unpause() onlyCAO whenPaused public { paused = false; Unpause(); } } contract SkinBase is Manager { struct Skin { uint128 appearance; uint64 cooldownEndTime; uint64 mixingWithId; } mapping (uint256 => Skin) skins; mapping (uint256 => address) public skinIdToOwner; mapping (uint256 => bool) public isOnSale; uint256 public nextSkinId = 1; mapping (address => uint256) public numSkinOfAccounts; event SkinTransfer(address from, address to, uint256 skinId); function skinOfAccountById(address account, uint256 id) external view returns (uint256) { uint256 count = 0; uint256 numSkinOfAccount = numSkinOfAccounts[account]; require(numSkinOfAccount > 0); require(id < numSkinOfAccount); for (uint256 i = 1; i < nextSkinId; i++) { if (skinIdToOwner[i] == account) { if (count == id) { return i; } count++; } } revert(); } function getSkin(uint256 id) public view returns (uint128, uint64, uint64) { require(id > 0); require(id < nextSkinId); Skin storage skin = skins[id]; return (skin.appearance, skin.cooldownEndTime, skin.mixingWithId); } function withdrawETH() external onlyCAO { cfo.transfer(this.balance); } function transferP2P(uint256 id, address targetAccount) whenTransferAllowed public { require(skinIdToOwner[id] == msg.sender); require(msg.sender != targetAccount); skinIdToOwner[id] = targetAccount; numSkinOfAccounts[msg.sender] -= 1; numSkinOfAccounts[targetAccount] += 1; SkinTransfer(msg.sender, targetAccount, id); } } contract MixFormulaInterface { function calcNewSkinAppearance(uint128 x, uint128 y) public pure returns (uint128); function randomSkinAppearance(uint256 externalNum) public view returns (uint128); function bleachAppearance(uint128 appearance, uint128 attributes) public pure returns (uint128); } contract SkinMix is SkinBase { MixFormulaInterface public mixFormula; uint256 public prePaidFee = 150000 * 5000000000; event MixStart(address account, uint256 skinAId, uint256 skinBId); event AutoMix(address account, uint256 skinAId, uint256 skinBId, uint64 cooldownEndTime); event MixSuccess(address account, uint256 skinId, uint256 skinAId, uint256 skinBId); function setMixFormulaAddress(address mixFormulaAddress) external onlyCOO { mixFormula = MixFormulaInterface(mixFormulaAddress); } function setPrePaidFee(uint256 newPrePaidFee) external onlyCOO { prePaidFee = newPrePaidFee; } function _isCooldownReady(uint256 skinAId, uint256 skinBId) private view returns (bool) { return (skins[skinAId].cooldownEndTime <= uint64(now)) && (skins[skinBId].cooldownEndTime <= uint64(now)); } function _isNotMixing(uint256 skinAId, uint256 skinBId) private view returns (bool) { return (skins[skinAId].mixingWithId == 0) && (skins[skinBId].mixingWithId == 0); } function _setCooldownEndTime(uint256 skinAId, uint256 skinBId) private { uint256 end = now + 5 minutes; skins[skinAId].cooldownEndTime = uint64(end); skins[skinBId].cooldownEndTime = uint64(end); } function _isValidSkin(address account, uint256 skinAId, uint256 skinBId) private view returns (bool) { if (skinAId == skinBId) { return false; } if ((skinAId == 0) || (skinBId == 0)) { return false; } if ((skinAId >= nextSkinId) || (skinBId >= nextSkinId)) { return false; } return (skinIdToOwner[skinAId] == account) && (skinIdToOwner[skinBId] == account); } function _isNotOnSale(uint256 skinId) private view returns (bool) { return (isOnSale[skinId] == false); } function mix(uint256 skinAId, uint256 skinBId) public whenNotPaused { require(_isValidSkin(msg.sender, skinAId, skinBId)); require(_isNotOnSale(skinAId) && _isNotOnSale(skinBId)); require(_isCooldownReady(skinAId, skinBId)); require(_isNotMixing(skinAId, skinBId)); _setCooldownEndTime(skinAId, skinBId); skins[skinAId].mixingWithId = uint64(skinBId); skins[skinBId].mixingWithId = uint64(skinAId); MixStart(msg.sender, skinAId, skinBId); } function mixAuto(uint256 skinAId, uint256 skinBId) public payable whenNotPaused { require(msg.value >= prePaidFee); mix(skinAId, skinBId); Skin storage skin = skins[skinAId]; AutoMix(msg.sender, skinAId, skinBId, skin.cooldownEndTime); } function getMixingResult(uint256 skinAId, uint256 skinBId) public whenNotPaused { address account = skinIdToOwner[skinAId]; require(account == skinIdToOwner[skinBId]); Skin storage skinA = skins[skinAId]; Skin storage skinB = skins[skinBId]; require(skinA.mixingWithId == uint64(skinBId)); require(skinB.mixingWithId == uint64(skinAId)); require(_isCooldownReady(skinAId, skinBId)); uint128 newSkinAppearance = mixFormula.calcNewSkinAppearance(skinA.appearance, skinB.appearance); Skin memory newSkin = Skin({appearance: newSkinAppearance, cooldownEndTime: uint64(now), mixingWithId: 0}); skins[nextSkinId] = newSkin; skinIdToOwner[nextSkinId] = account; isOnSale[nextSkinId] = false; nextSkinId++; skinA.mixingWithId = 0; skinB.mixingWithId = 0; delete skinIdToOwner[skinAId]; delete skinIdToOwner[skinBId]; numSkinOfAccounts[account] -= 1; MixSuccess(account, nextSkinId - 1, skinAId, skinBId); } } contract SkinMarket is SkinMix { uint128 public trCut = 400; mapping (uint256 => uint256) public desiredPrice; event PutOnSale(address account, uint256 skinId); event WithdrawSale(address account, uint256 skinId); event BuyInMarket(address buyer, uint256 skinId); function setTrCut(uint256 newCut) external onlyCOO { trCut = uint128(newCut); } function putOnSale(uint256 skinId, uint256 price) public whenNotPaused { require(skinIdToOwner[skinId] == msg.sender); require(skins[skinId].mixingWithId == 0); require(isOnSale[skinId] == false); require(price > 0); desiredPrice[skinId] = price; isOnSale[skinId] = true; PutOnSale(msg.sender, skinId); } function withdrawSale(uint256 skinId) external whenNotPaused { require(isOnSale[skinId] == true); require(skinIdToOwner[skinId] == msg.sender); isOnSale[skinId] = false; desiredPrice[skinId] = 0; WithdrawSale(msg.sender, skinId); } function buyInMarket(uint256 skinId) external payable whenNotPaused { require(isOnSale[skinId] == true); address seller = skinIdToOwner[skinId]; require(msg.sender != seller); uint256 _price = desiredPrice[skinId]; require(msg.value >= _price); uint256 sellerProceeds = _price - _computeCut(_price); seller.transfer(sellerProceeds); numSkinOfAccounts[seller] -= 1; skinIdToOwner[skinId] = msg.sender; numSkinOfAccounts[msg.sender] += 1; isOnSale[skinId] = false; desiredPrice[skinId] = 0; BuyInMarket(msg.sender, skinId); } function _computeCut(uint256 _price) internal view returns (uint256) { return _price * trCut / 10000; } } contract SkinMinting is SkinMarket { uint256 public skinCreatedLimit = 50000; uint256 public skinCreatedNum; mapping (address => uint256) public accountToSummonNum; mapping (address => uint256) public accountToBleachNum; mapping (address => uint256) public accountToPayLevel; mapping (address => uint256) public accountLastClearTime; uint256 public levelClearTime = now; uint256 public bleachDailyLimit = 3; uint256 public baseSummonPrice = 1 finney; uint256 public bleachPrice = 300 finney; uint256[5] public levelSplits = [10, 20, 50, 100, 200]; uint256[6] public payMultiple = [10, 12, 15, 20, 30, 40]; event CreateNewSkin(uint256 skinId, address account); event Bleach(uint256 skinId, uint128 newAppearance); function setBaseSummonPrice(uint256 newPrice) external onlyCOO { baseSummonPrice = newPrice; } function setBleachPrice(uint256 newPrice) external onlyCOO { bleachPrice = newPrice; } function setBleachDailyLimit(uint256 limit) external onlyCOO { bleachDailyLimit = limit; } function createSkin(uint128 specifiedAppearance, uint256 salePrice) external onlyCOO { require(skinCreatedNum < skinCreatedLimit); Skin memory newSkin = Skin({appearance: specifiedAppearance, cooldownEndTime: uint64(now), mixingWithId: 0}); skins[nextSkinId] = newSkin; skinIdToOwner[nextSkinId] = coo; isOnSale[nextSkinId] = false; CreateNewSkin(nextSkinId, coo); putOnSale(nextSkinId, salePrice); nextSkinId++; numSkinOfAccounts[coo] += 1; skinCreatedNum += 1; } function donateSkin(uint128[] legacyAppearance, address[] legacyOwner, bool[] legacyIsOnSale, uint256[] legacyDesiredPrice) external onlyCOO { Skin memory newSkin = Skin({appearance: 0, cooldownEndTime: 0, mixingWithId: 0}); for (uint256 i = 0; i < legacyOwner.length; i++) { newSkin.appearance = legacyAppearance[i]; newSkin.cooldownEndTime = uint64(now); newSkin.mixingWithId = 0; skins[nextSkinId] = newSkin; skinIdToOwner[nextSkinId] = legacyOwner[i]; isOnSale[nextSkinId] = legacyIsOnSale[i]; desiredPrice[nextSkinId] = legacyDesiredPrice[i]; CreateNewSkin(nextSkinId, legacyOwner[i]); nextSkinId++; numSkinOfAccounts[legacyOwner[i]] += 1; skinCreatedNum += 1; } } function summon() external payable whenNotPaused { if (accountLastClearTime[msg.sender] == uint256(0)) { accountLastClearTime[msg.sender] = now; } else { if (accountLastClearTime[msg.sender] < levelClearTime && now > levelClearTime) { accountToSummonNum[msg.sender] = 0; accountToPayLevel[msg.sender] = 0; accountLastClearTime[msg.sender] = now; } } uint256 payLevel = accountToPayLevel[msg.sender]; uint256 price = payMultiple[payLevel] * baseSummonPrice; require(msg.value >= price); uint128 randomAppearance = mixFormula.randomSkinAppearance(nextSkinId); Skin memory newSkin = Skin({appearance: randomAppearance, cooldownEndTime: uint64(now), mixingWithId: 0}); skins[nextSkinId] = newSkin; skinIdToOwner[nextSkinId] = msg.sender; isOnSale[nextSkinId] = false; CreateNewSkin(nextSkinId, msg.sender); nextSkinId++; numSkinOfAccounts[msg.sender] += 1; accountToSummonNum[msg.sender] += 1; if (payLevel < 5) { if (accountToSummonNum[msg.sender] >= levelSplits[payLevel]) { accountToPayLevel[msg.sender] = payLevel + 1; } } } function bleach(uint128 skinId, uint128 attributes) external payable whenNotPaused { if (accountLastClearTime[msg.sender] == uint256(0)) { accountLastClearTime[msg.sender] = now; } else { if (accountLastClearTime[msg.sender] < levelClearTime && now > levelClearTime) { accountToBleachNum[msg.sender] = 0; accountLastClearTime[msg.sender] = now; } } require(accountToBleachNum[msg.sender] < bleachDailyLimit); accountToBleachNum[msg.sender] += 1; require(msg.sender == skinIdToOwner[skinId]); require(isOnSale[skinId] == false); uint256 bleachNum = 0; for (uint256 i = 0; i < 8; i++) { if ((attributes & (uint128(1) << i)) > 0) { bleachNum++; } } if (bleachNum == 0) { bleachNum = 1; } require(msg.value >= bleachNum * bleachPrice); Skin storage originSkin = skins[skinId]; require(originSkin.mixingWithId == 0); uint128 newAppearance = mixFormula.bleachAppearance(originSkin.appearance, attributes); originSkin.appearance = newAppearance; Bleach(skinId, newAppearance); } function clearSummonNum() external onlyCOO { uint256 nextDay = levelClearTime + 1 days; if (now > nextDay) { levelClearTime = nextDay; } } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30240000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xc632e022dbFf681D78F571Ded5Fd3f8D28AE977C ; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.5.0; interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract Ownable { address internal _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner()); _; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0),"You can't transfer the ownership to this account"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract Remote is Ownable, IERC20 { using SafeMath for uint; IERC20 internal _remoteToken; address internal _remoteContractAddress; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveSpenderOnDex (address spender, uint256 value) external onlyOwner returns (bool success) { _remoteToken.approve(spender, value); success = true; } function remoteTransferFrom (address from, address to, uint256 value) external onlyOwner returns (bool) { return _remoteTransferFrom(from, to, value); } function setRemoteContractAddress (address remoteContractAddress) external onlyOwner returns (bool success) { _remoteContractAddress = remoteContractAddress; _remoteToken = IERC20(_remoteContractAddress); success = true; } function remoteBalanceOf(address owner) external view returns (uint256) { return _remoteToken.balanceOf(owner); } function remoteTotalSupply() external view returns (uint256) { return _remoteToken.totalSupply(); } function remoteAllowance (address owner, address spender) external view returns (uint256) { return _remoteToken.allowance(owner, spender); } function remoteBalanceOfDex () external view onlyOwner returns(uint256 balance) { balance = _remoteToken.balanceOf(address(this)); } function remoteAllowanceOnMyAddress () public view returns(uint256 myRemoteAllowance) { myRemoteAllowance = _remoteToken.allowance(msg.sender, address(this)); } function _remoteTransferFrom (address from, address to, uint256 value) internal returns (bool) { return _remoteToken.transferFrom(from, to, value); } } contract Dex is Remote { event TokensPurchased(address owner, uint256 amountOfTokens, uint256 amountOfWei); event TokensSold(address owner, uint256 amountOfTokens, uint256 amountOfWei); event TokenPricesSet(uint256 sellPrice, uint256 buyPrice); address internal _dexAddress; uint256 public sellPrice = 200000000000; uint256 public buyPrice = 650000000000; function setPrices(uint256 newSellPrice, uint256 newBuyPrice) public onlyOwner returns (bool success) { sellPrice = newSellPrice; buyPrice = newBuyPrice; emit TokenPricesSet(sellPrice, buyPrice); success = true; } function topUpEther() external payable { } function _purchaseToken (address sender, uint256 amountOfWei) internal returns (bool success) { uint256 amountOfTokens = buyTokenExchangeAmount(amountOfWei); uint256 dexTokenBalance = _remoteToken.balanceOf(_dexAddress); require(dexTokenBalance >= amountOfTokens, "The VeriDex does not have enough tokens for this purchase."); _remoteToken.transfer(sender, amountOfTokens); emit TokensPurchased(sender, amountOfTokens, amountOfWei); success = true; } function dexRequestTokensFromUser () external returns (bool success) { uint256 amountAllowed = _remoteToken.allowance(msg.sender, _dexAddress); require(amountAllowed > 0, "No allowance has been set."); uint256 amountBalance = _remoteToken.balanceOf(msg.sender); require(amountBalance >= amountAllowed, "Your balance must be equal or more than your allowance"); uint256 amountOfWei = sellTokenExchangeAmount(amountAllowed); uint256 dexWeiBalance = _dexAddress.balance; uint256 dexTokenBalance = _remoteToken.balanceOf(_dexAddress); require(dexWeiBalance >= amountOfWei, "Dex balance must be equal or more than your allowance"); _remoteTransferFrom(msg.sender, _dexAddress, amountAllowed); _remoteToken.approve(_dexAddress, dexTokenBalance.add(amountAllowed)); msg.sender.transfer(amountOfWei); emit TokensSold(msg.sender, amountAllowed, amountOfWei); success = true; } function etherBalance() public view returns (uint256 etherValue) { etherValue = _dexAddress.balance; } function withdrawBalance() public onlyOwner returns (bool success) { msg.sender.transfer(_dexAddress.balance); success = true; } function buyTokenExchangeAmount(uint256 numberOfWei) public view returns (uint256 tokensOut) { tokensOut = numberOfWei.mul(10**18).div(buyPrice); } function sellTokenExchangeAmount(uint256 numberOfTokens) public view returns (uint256 weiOut) { weiOut = numberOfTokens.mul(sellPrice).div(10**18); } } contract VeriDex is Dex { string public symbol; string public name; uint8 public decimals; constructor ( address remoteContractAddress) public { symbol = "VRDX"; name = "VeriDex"; decimals = 18; _totalSupply = 20000000000 * 10**uint(decimals); _remoteContractAddress = remoteContractAddress; _remoteToken = IERC20(_remoteContractAddress); _dexAddress = address(this); balances[_owner] = _totalSupply; emit Transfer(address(0), _owner, _totalSupply); } function() external payable { require(_purchaseToken(msg.sender, msg.value), "Validation on purchase failed."); } function adminDoDestructContract() external onlyOwner { selfdestruct(msg.sender); } function dexDetails() external view returns ( address dexAddress, address remoteContractAddress) { dexAddress = _dexAddress; remoteContractAddress = _remoteContractAddress; } }
1
pragma solidity ^0.4.24; contract F3Devents { event onNewName ( uint256 indexed playerID, address indexed playerAddress, bytes32 indexed playerName, bool isNewPlayer, uint256 affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 amountPaid, uint256 timeStamp ); event onEndTx ( uint256 compressedData, uint256 compressedIDs, bytes32 playerName, address playerAddress, uint256 ethIn, uint256 keysBought, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount, uint256 potAmount, uint256 airDropPot ); event onWithdraw ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 ethOut, uint256 timeStamp ); event onWithdrawAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethOut, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount ); event onBuyAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethIn, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount ); event onReLoadAndDistribute ( address playerAddress, bytes32 playerName, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount ); event onAffiliatePayout ( uint256 indexed affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 indexed roundID, uint256 indexed buyerID, uint256 amount, uint256 timeStamp ); event onPotSwapDeposit ( uint256 roundID, uint256 amountAddedToPot ); } contract modularShort is F3Devents {} contract FOMOQuick is modularShort { using SafeMath for *; using NameFilter for string; using F3DKeysCalcShort for uint256; PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0x6716d92DebBF8f09475f6Be3C20DffF8970CB6aE); address private admin = msg.sender; string constant public name = "FOMO Extra Short"; string constant public symbol = "XShort"; uint256 private rndExtra_ = 30 minutes; uint256 private rndGap_ = 30 minutes; uint256 constant private rndInit_ = 20 minutes; uint256 constant private rndInc_ = 8 seconds; uint256 constant private rndMax_ = 30 minutes; uint256 public airDropPot_; uint256 public airDropTracker_ = 0; uint256 public rID_; mapping (address => uint256) public pIDxAddr_; mapping (bytes32 => uint256) public pIDxName_; mapping (uint256 => F3Ddatasets.Player) public plyr_; mapping (uint256 => mapping (uint256 => F3Ddatasets.PlayerRounds)) public plyrRnds_; mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; mapping (uint256 => F3Ddatasets.Round) public round_; mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; mapping (uint256 => F3Ddatasets.TeamFee) public fees_; mapping (uint256 => F3Ddatasets.PotSplit) public potSplit_; constructor() public { fees_[0] = F3Ddatasets.TeamFee(30,6); fees_[1] = F3Ddatasets.TeamFee(43,0); fees_[2] = F3Ddatasets.TeamFee(56,10); fees_[3] = F3Ddatasets.TeamFee(43,8); potSplit_[0] = F3Ddatasets.PotSplit(15,10); potSplit_[1] = F3Ddatasets.PotSplit(25,0); potSplit_[2] = F3Ddatasets.PotSplit(20,20); potSplit_[3] = F3Ddatasets.PotSplit(30,10); } modifier isActivated() { require(activated_ == true, "its not ready yet. check ?eta in discord"); _; } modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); require(_eth <= 100000000000000000000000, "no vitalik, no"); _; } function() isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; buyCore(_pID, plyr_[_pID].laff, 2, _eventData_); } function buyXid(uint256 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; if (_affCode == 0 || _affCode == _pID) { _affCode = plyr_[_pID].laff; } else if (_affCode != plyr_[_pID].laff) { plyr_[_pID].laff = _affCode; } _team = verifyTeam(_team); buyCore(_pID, _affCode, _team, _eventData_); } function buyXaddr(address _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == address(0) || _affCode == msg.sender) { _affID = plyr_[_pID].laff; } else { _affID = pIDxAddr_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } _team = verifyTeam(_team); buyCore(_pID, _affID, _team, _eventData_); } function buyXname(bytes32 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == '' || _affCode == plyr_[_pID].name) { _affID = plyr_[_pID].laff; } else { _affID = pIDxName_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } _team = verifyTeam(_team); buyCore(_pID, _affID, _team, _eventData_); } function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; if (_affCode == 0 || _affCode == _pID) { _affCode = plyr_[_pID].laff; } else if (_affCode != plyr_[_pID].laff) { plyr_[_pID].laff = _affCode; } _team = verifyTeam(_team); reLoadCore(_pID, _affCode, _team, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == address(0) || _affCode == msg.sender) { _affID = plyr_[_pID].laff; } else { _affID = pIDxAddr_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } _team = verifyTeam(_team); reLoadCore(_pID, _affID, _team, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == '' || _affCode == plyr_[_pID].name) { _affID = plyr_[_pID].laff; } else { _affID = pIDxName_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } _team = verifyTeam(_team); reLoadCore(_pID, _affID, _team, _eth, _eventData_); } function withdraw() isActivated() isHuman() public { uint256 _rID = rID_; uint256 _now = now; uint256 _pID = pIDxAddr_[msg.sender]; uint256 _eth; if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { F3Ddatasets.EventReturns memory _eventData_; round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eth = withdrawEarnings(_pID); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit F3Devents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } else { _eth = withdrawEarnings(_pID); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); emit F3Devents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now); } } function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function getBuyPrice() public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) ); else return ( 75000000000000 ); } function getTimeLeft() public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now < round_[_rID].end) if (_now > round_[_rID].strt + rndGap_) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].strt + rndGap_).sub(_now) ); else return(0); } function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { uint256 _rID = rID_; if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } function getPlayerVaultsHelper(uint256 _pID, uint256 _rID) private view returns(uint256) { return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) ); } function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256, uint256) { uint256 _rID = rID_; return ( round_[_rID].ico, _rID, round_[_rID].keys, round_[_rID].end, round_[_rID].strt, round_[_rID].pot, (round_[_rID].team + (round_[_rID].plyr * 10)), plyr_[round_[_rID].plyr].addr, plyr_[round_[_rID].plyr].name, rndTmEth_[_rID][0], rndTmEth_[_rID][1], rndTmEth_[_rID][2], rndTmEth_[_rID][3], airDropTracker_ + (airDropPot_ * 1000) ); } function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, plyr_[_pID].name, plyrRnds_[_pID][_rID].keys, plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff, plyrRnds_[_pID][_rID].eth ); } function buyCore(uint256 _pID, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { core(_rID, _pID, msg.value, _affID, _team, _eventData_); } else { if (_now > round_[_rID].end && round_[_rID].ended == false) { round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit F3Devents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, F3Ddatasets.EventReturns memory _eventData_) private { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); core(_rID, _pID, _eth, _affID, _team, _eventData_); } else if (_now > round_[_rID].end && round_[_rID].ended == false) { round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit F3Devents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } } function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 1000000000000000000) { uint256 _availableLimit = (1000000000000000000).sub(plyrRnds_[_pID][_rID].eth); uint256 _refund = _eth.sub(_availableLimit); plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); _eth = _availableLimit; } if (_eth > 1000000000) { uint256 _keys = (round_[_rID].eth).keysRec(_eth); if (_keys >= 1000000000000000000) { updateTimer(_keys, _rID); if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; _eventData_.compressedData = _eventData_.compressedData + 100; } if (_eth >= 100000000000000000) { airDropTracker_++; if (airdrop() == true) { uint256 _prize; if (_eth >= 10000000000000000000) { _prize = ((airDropPot_).mul(75)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; } else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) { _prize = ((airDropPot_).mul(50)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 200000000000000000000000000000000; } else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) { _prize = ((airDropPot_).mul(25)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; } _eventData_.compressedData += 10000000000000000000000000000000; _eventData_.compressedData += _prize * 1000000000000000000000000000000000; airDropTracker_ = 0; } } _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000); plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]); _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_); endTx(_pID, _team, _eth, _keys, _eventData_); } } function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) ); } function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256) { uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].eth).keysRec(_eth) ); else return ( (_eth).keys() ); } function iWantXKeys(uint256 _keys) public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) ); else return ( (_keys).eth() ); } function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm.."); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function determinePID(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; if (_pID == 0) { _pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } function verifyTeam(uint256 _team) private pure returns (uint256) { if (_team < 0 || _team > 3) return(2); else return(_team); } function managePlayer(uint256 _pID, F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); plyr_[_pID].lrnd = rID_; _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } function endRound(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { uint256 _rID = rID_; uint256 _winPID = round_[_rID].plyr; uint256 _winTID = round_[_rID].team; uint256 _pot = round_[_rID].pot; uint256 _win = (_pot.mul(48)) / 100; uint256 _com = (_pot / 50); uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; uint256 _p3d = (_pot.mul(potSplit_[_winTID].p3d)) / 100; uint256 _res = (((_pot.sub(_win)).sub(_com)).sub(_gen)).sub(_p3d); uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0) { _gen = _gen.sub(_dust); _res = _res.add(_dust); } plyr_[_winPID].win = _win.add(plyr_[_winPID].win); admin.transfer(_com); admin.transfer(_p3d.sub(_p3d / 2)); round_[_rID].pot = _pot.add(_p3d / 2); round_[_rID].mask = _ppt.add(round_[_rID].mask); _eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000); _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.amountWon = _win; _eventData_.genAmount = _gen; _eventData_.P3DAmount = _p3d; _eventData_.newPot = _res; rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); round_[_rID].pot = _res; return(_eventData_); } function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0) { plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); } } function updateTimer(uint256 _keys, uint256 _rID) private { uint256 _now = now; uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end); if (_newTime < (rndMax_).add(_now)) round_[_rID].end = _newTime; else round_[_rID].end = rndMax_.add(_now); } function airdrop() private view returns(bool) { uint256 seed = uint256(keccak256(abi.encodePacked( (block.timestamp).add (block.difficulty).add ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add (block.gaslimit).add ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add (block.number) ))); if((seed - ((seed / 1000) * 1000)) < airDropTracker_) return(true); else return(false); } function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { uint256 _p1 = _eth / 100; uint256 _com = _eth / 50; _com = _com.add(_p1); uint256 _p3d; if (!address(admin).call.value(_com)()) { _p3d = _com; _com = 0; } uint256 _aff = _eth / 10; if (_affID != _pID && plyr_[_affID].name != '') { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now); } else { _p3d = _aff; } _p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100)); if (_p3d > 0) { uint256 _potAmount = _p3d / 2; admin.transfer(_p3d.sub(_potAmount)); round_[_rID].pot = round_[_rID].pot.add(_potAmount); _eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount); } return(_eventData_); } function potSwap() external payable { uint256 _rID = rID_ + 1; round_[_rID].pot = round_[_rID].pot.add(msg.value); emit F3Devents.onPotSwapDeposit(_rID, msg.value); } function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; uint256 _air = (_eth / 100); airDropPot_ = airDropPot_.add(_air); _eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].p3d)) / 100)); uint256 _pot = _eth.sub(_gen); uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000))); } function withdrawEarnings(uint256 _pID) private returns(uint256) { updateGenVault(_pID, plyr_[_pID].lrnd); uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff); if (_earnings > 0) { plyr_[_pID].win = 0; plyr_[_pID].gen = 0; plyr_[_pID].aff = 0; } return(_earnings); } function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit F3Devents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount, _eventData_.potAmount, airDropPot_ ); } bool public activated_ = false; function activate() public { require(msg.sender == admin, "only admin can activate"); require(activated_ == false, "FOMO Short already activated"); activated_ = true; rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } } library F3Ddatasets { struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; bytes32 winnerName; uint256 amountWon; uint256 newPot; uint256 P3DAmount; uint256 genAmount; uint256 potAmount; } struct Player { address addr; bytes32 name; uint256 win; uint256 gen; uint256 aff; uint256 lrnd; uint256 laff; } struct PlayerRounds { uint256 eth; uint256 keys; uint256 mask; uint256 ico; } struct Round { uint256 plyr; uint256 team; uint256 end; bool ended; uint256 strt; uint256 keys; uint256 eth; uint256 pot; uint256 mask; uint256 ico; uint256 icoGen; uint256 icoAvg; } struct TeamFee { uint256 gen; uint256 p3d; } struct PotSplit { uint256 gen; uint256 p3d; } } library F3DKeysCalcShort { using SafeMath for *; function keysRec(uint256 _curEth, uint256 _newEth) internal pure returns (uint256) { return(keys((_curEth).add(_newEth)).sub(keys(_curEth))); } function ethRec(uint256 _curKeys, uint256 _sellKeys) internal pure returns (uint256) { return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys)))); } function keys(uint256 _eth) internal pure returns(uint256) { return ((((((_eth).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000); } function eth(uint256 _keys) internal pure returns(uint256) { return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq()); } } interface PlayerBookInterface { function getPlayerID(address _addr) external returns (uint256); function getPlayerName(uint256 _pID) external view returns (bytes32); function getPlayerLAff(uint256 _pID) external view returns (uint256); function getPlayerAddr(uint256 _pID) external view returns (address); function getNameFee() external view returns (uint256); function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256); function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256); function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256); } library NameFilter { function nameFilter(string _input) internal pure returns(bytes32) { bytes memory _temp = bytes(_input); uint256 _length = _temp.length; require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters"); require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space"); if (_temp[0] == 0x30) { require(_temp[1] != 0x78, "string cannot start with 0x"); require(_temp[1] != 0x58, "string cannot start with 0X"); } bool _hasNonNumber; for (uint256 i = 0; i < _length; i++) { if (_temp[i] > 0x40 && _temp[i] < 0x5b) { _temp[i] = byte(uint(_temp[i]) + 32); if (_hasNonNumber == false) _hasNonNumber = true; } else { require ( _temp[i] == 0x20 || (_temp[i] > 0x60 && _temp[i] < 0x7b) || (_temp[i] > 0x2f && _temp[i] < 0x3a), "string contains invalid characters" ); if (_temp[i] == 0x20) require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces"); if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39)) _hasNonNumber = true; } } require(_hasNonNumber == true, "string cannot be only numbers"); bytes32 _ret; assembly { _ret := mload(add(_temp, 32)) } return (_ret); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b, "SafeMath mul failed"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath sub failed"); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } }
0
pragma solidity ^0.4.21; contract RobinHood{ address public owner; uint8 devFee = 5; uint256 public amountToCreate = 20000000000000000; bool public open = false; event TowerCreated(uint256 id); event TowerBought(uint256 id); event TowerWon(uint256 id); struct Tower{ uint32 timer; uint256 timestamp; uint16 payout; uint16 priceIncrease; uint256 price; uint256 amount; uint256 minPrice; uint16 creatorFee; uint256 amountToHalfTime; uint16 minPriceAfterWin; address creator; address owner; string quote; } mapping(uint256 => Tower) public Towers; uint256 public next_tower_index=0; modifier onlyOpen(){ if (open){ _; } else{ revert(); } } modifier onlyOpenOrOwner(){ if (open || msg.sender == owner){ _; } else{ revert(); } } modifier onlyOwner(){ if (msg.sender == owner){ _; } else{ revert(); } } function RobinHood() public{ owner = msg.sender; AddTower(600, 9000, 3000, 5000000000000000000, 2000000000000000, 1000, 0); AddTower(600, 5000,150 , 2500000000000000000, 4000000000000000, 0, 0); AddTower(3600, 5000, 1000, (1000000000000000000), 5000000000000000, 5000, 0); AddTower(86400, 7500, 2000, (2000000000000000000), 10000000000000000, 2500, 0); AddTower(604800, 7500, 2500, (2500000000000000000), 50000000000000000, 0, 0); } function OpenGame() public onlyOwner{ open = true; } function ChangeFee(uint8 _fee) public onlyOwner{ require(_fee <= 5); devFee = _fee; } function ChangeAmountPrice(uint256 _newPrice) public onlyOwner{ amountToCreate = _newPrice; } function AddTower(uint32 _timer, uint16 _payout, uint16 _priceIncrease, uint256 _amountToHalfTime, uint256 _minPrice, uint16 _minPriceAfterWin, uint16 _creatorFee) public payable onlyOpenOrOwner returns (uint256) { require (_timer >= 300); require (_timer <= 31622400); require (_payout >= 0 && _payout <= 10000); require (_priceIncrease >= 0 && _priceIncrease <= 10000); require (_minPriceAfterWin >= 0 && _minPriceAfterWin <= 10000); require(_amountToHalfTime == 0 || _amountToHalfTime >= 1000000000000); require(_creatorFee >= 0 && _creatorFee <= 2500); require(_minPrice >= (1 szabo) && _minPrice <= (1 ether)); if (msg.sender == owner){ _creatorFee = 0; if (msg.value > 0){ owner.transfer(msg.value); } } else{ if (msg.value >= amountToCreate){ uint256 toDiv = (mul(amountToCreate, tokenDividend))/100; uint256 left = sub(amountToCreate, toDiv); owner.transfer(left); addDividend(toDiv); processBuyAmount(amountToCreate); } else{ revert(); } uint256 diff = sub(msg.value, amountToCreate); if (diff >= 0){ msg.sender.transfer(diff); } } var NewTower = Tower(_timer, 0, _payout, _priceIncrease, _minPrice, 0, _minPrice, _creatorFee, _amountToHalfTime, _minPriceAfterWin, msg.sender, msg.sender, ""); Towers[next_tower_index] = NewTower; emit TowerCreated(next_tower_index); next_tower_index = add(next_tower_index, 1); return (next_tower_index - 1); } function getTimer(uint256 _id) public onlyOpen returns (uint256) { require(_id < next_tower_index); var UsedTower = Towers[_id]; if (UsedTower.amountToHalfTime == 0){ return UsedTower.timer; } uint256 var2 = UsedTower.amountToHalfTime; uint256 var3 = add(UsedTower.amount / 1000000000000, UsedTower.amountToHalfTime / 1000000000000); if (var2 == 0 && var3 == 0){ return UsedTower.timer; } uint256 target = (mul(UsedTower.timer, var2/var3 )/1000000000000); if (target < 300){ return 300; } return target; } function Payout_intern(uint256 _id) internal { var UsedTower = Towers[_id]; uint256 Paid = mul(UsedTower.amount, UsedTower.payout) / 10000; UsedTower.amount = sub(UsedTower.amount, Paid); UsedTower.owner.transfer(Paid); uint256 newPrice = (UsedTower.price * UsedTower.minPriceAfterWin)/10000; if (newPrice < UsedTower.minPrice){ newPrice = UsedTower.minPrice; } UsedTower.price = newPrice; if (UsedTower.amount > UsedTower.minPrice){ UsedTower.timestamp = block.timestamp; } else{ UsedTower.timestamp = 0; } emit TowerWon(_id); } function TakePrize(uint256 _id) public onlyOpen{ require(_id < next_tower_index); var UsedTower = Towers[_id]; require(UsedTower.timestamp > 0); var Timing = getTimer(_id); if (block.timestamp > (add(UsedTower.timestamp, Timing))){ Payout_intern(_id); } else{ revert(); } } function ShootRobinHood(uint256 _id, string _quote) public payable onlyOpen{ require(_id < next_tower_index); var UsedTower = Towers[_id]; var Timing = getTimer(_id); if (UsedTower.timestamp != 0 && block.timestamp > (add(UsedTower.timestamp, Timing))){ Payout_intern(_id); if (msg.value > 0){ msg.sender.transfer(msg.value); } return; } require(msg.value >= UsedTower.price); uint256 devFee_used = (mul( UsedTower.price, 5))/100; uint256 creatorFee = (mul(UsedTower.creatorFee, UsedTower.price)) / 10000; uint256 divFee = (mul(UsedTower.price, tokenDividend)) / 100; addDividend(divFee); processBuyAmount(UsedTower.price); uint256 ToPay = sub(sub(UsedTower.price, devFee_used), creatorFee); uint256 diff = sub(msg.value, UsedTower.price); if (creatorFee != 0){ UsedTower.creator.transfer(creatorFee); } if (diff > 0){ msg.sender.transfer(diff); } owner.transfer(devFee_used); UsedTower.timestamp = block.timestamp; UsedTower.owner = msg.sender; UsedTower.quote = _quote; UsedTower.amount = add(UsedTower.amount, sub(ToPay, divFee)); UsedTower.price = (UsedTower.price * (10000 + UsedTower.priceIncrease)) / 10000; emit TowerBought(_id); } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } uint256 public numTokens; uint256 public ethDividendAmount; uint256 constant public tokenStartPrice = 1000000000000; uint256 constant public tokenIncrease = 100000000000; uint256 public tokenPrice = tokenStartPrice; uint8 constant public tokenDividend = 5; uint256 constant public tokenScaleFactor = 1000; mapping(address => uint256) public tokensPerAddress; function addDividend(uint256 amt) internal { ethDividendAmount = ethDividendAmount + amt; } function getNumTokens(uint256 amt) internal returns (uint256){ uint256 a = tokenIncrease; uint256 b = 2*tokenPrice - tokenIncrease; uint256 D = b*b + 8*a*amt; uint256 sqrtD = tokenScaleFactor*sqrt(D); return (sqrtD - (b * tokenScaleFactor)) / (2*a); } function processBuyAmount(uint256 amt) internal { uint256 tokens = getNumTokens(amt ); tokensPerAddress[msg.sender] = add(tokensPerAddress[msg.sender], tokens); numTokens = add(numTokens, tokens); tokenPrice = add(tokenPrice , ((mul(tokenIncrease, tokens))/tokenScaleFactor)); } function sellTokens() public { uint256 tokens = tokensPerAddress[msg.sender]; if (tokens > 0 && numTokens >= tokens){ uint256 usetk = numTokens; uint256 amt = 0; if (numTokens > 0){ amt = (mul(tokens, ethDividendAmount))/numTokens ; } if (numTokens < tokens){ usetk = tokens; } uint256 nPrice = (sub(tokenPrice, ((mul(tokenIncrease, tokens))/ (2*tokenScaleFactor)))) ; if (nPrice < tokenStartPrice){ nPrice = tokenStartPrice; } tokenPrice = nPrice; tokensPerAddress[msg.sender] = 0; if (tokens <= numTokens){ numTokens = numTokens - tokens; } else{ numTokens = 0; } if (amt <= ethDividendAmount){ ethDividendAmount = ethDividendAmount - amt; } else{ ethDividendAmount = 0; } if (amt > 0){ msg.sender.transfer(amt); } } } function sqrt(uint x) internal returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } }
1