source_codes
stringlengths
3
205k
labels
int64
0
1
pragma solidity ^ 0.4 .9; 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 Nasdaq { using SafeMath for uint256; mapping(address => mapping(address => uint256)) allowed; mapping(address => uint256) balances; uint256 public totalSupply; uint256 public decimals; address public owner; bytes32 public symbol; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed _owner, address indexed spender, uint256 value); function Nasdaq() { totalSupply = 24000000; symbol = 'NSDQ'; owner = 0xe913aef983e84ed90f340ff533ce39668f45a0f6; balances[owner] = totalSupply; decimals = 0; } function balanceOf(address _owner) constant returns(uint256 balance) { return balances[_owner]; } function allowance(address _owner, address _spender) constant returns(uint256 remaining) { return allowed[_owner][_spender]; } 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 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() { revert(); } }
1
contract Gamble { address owner; Bet[] bets; address[] winners; struct Bet { address sender; int8 range; } function Gamble() { owner = msg.sender; } function place (int8 range) public payable { if (msg.value >= 50 finney && range <= 100) { bets[bets.length++] = Bet({sender: msg.sender, range: range}); } } function solve (int8 range) public { if (msg.sender == owner && range <= 100) { for (uint i = 0; i < bets.length; ++i) { if (bets[i].range == range) { winners[winners.length++] = bets[i].sender; } } for (uint j = 0; j < winners.length; ++j) { winners[j].send(winners.length / this.balance); } selfdestruct(owner); } } }
1
pragma solidity 0.4.23; contract AbstractToken { function balanceOf(address owner) public view returns (uint256 balance); 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); } contract Owned { address public owner = msg.sender; address public potentialOwner; modifier onlyOwner { require(msg.sender == owner); _; } modifier onlyPotentialOwner { require(msg.sender == potentialOwner); _; } event NewOwner(address old, address current); event NewPotentialOwner(address old, address potential); function setOwner(address _new) public onlyOwner { emit NewPotentialOwner(owner, _new); potentialOwner = _new; } function confirmOwnership() public onlyPotentialOwner { emit NewOwner(owner, potentialOwner); owner = potentialOwner; potentialOwner = address(0); } } contract 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; } function pow(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a ** b; assert(c >= a); return c; } } contract StandardToken is AbstractToken, Owned, SafeMath { mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) internal allowed; uint256 public totalSupply; function transfer(address _to, uint256 _value) public returns (bool success) { return _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] -= _value; return _transfer(_from, _to, _value); } 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]; } function _transfer(address _from, address _to, uint256 _value) private returns (bool success) { require(_to != address(0)); require(balances[_from] >= _value); balances[_from] -= _value; balances[_to] = add(balances[_to], _value); emit Transfer(_from, _to, _value); return true; } } contract Token is StandardToken { uint256 public creationTime; function Token() public { creationTime = now; } function transferERC20Token(AbstractToken _token, address _to, uint256 _value) public onlyOwner returns (bool success) { require(_token.balanceOf(address(this)) >= _value); uint256 receiverBalance = _token.balanceOf(_to); require(_token.transfer(_to, _value)); uint256 receiverNewBalance = _token.balanceOf(_to); assert(receiverNewBalance == add(receiverBalance, _value)); return true; } function increaseApproval(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = add(allowed[msg.sender][_spender], _value); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint256 _value) public returns (bool success) { uint256 oldValue = allowed[msg.sender][_spender]; if (_value > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = sub(oldValue, _value); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract GenesisCryptoTechnology is Token { string constant public name = 'GenesisCryptoTechnology'; string constant public symbol = 'GCT'; uint8 constant public decimals = 8; uint256 public exchangeRate = 5880; address public investorsAllocation = address(0x55f6074046b1fA3210E350CF520033F629f686d1); uint256 public investorsTotal = 60000000e8; address public overdraftAllocation = address(0x93F233fdF9d0Ea73c87AA0EDB3e4FB417Fb50145); uint256 public overdraftTotal = 20000000e8; uint256 public overdraftPeriodAmount = 41666666e8; uint256 public overdraftUnvested = 4e8; uint256 public overdraftCliff = 5 * 30 days; uint256 public overdraftPeriodLength = 810 days; uint8 public overdraftPeriodsNumber = 6; address public teamAllocation = address(0x1258c8C124dCAdf8122117EbF1968FFC54bFBFa6); uint256 public teamTotal = 15000000e8; uint256 public teamPeriodAmount = 7031250e8; uint256 public teamUnvested = 0; uint256 public teamCliff = 0; uint256 public teamPeriodLength = 3 * 810 days; uint8 public teamPeriodsNumber = 16; address public communityAllocation = address(0xa4d82eb18d2Bca1A3A2443324F0Beea0A0DC23C8); uint256 public communityTotal = 4000000e8; uint256 public communityPeriodAmount = 8333333e8; uint256 public communityUnvested = 10000002e8; uint256 public communityCliff = 0; uint256 public communityPeriodLength = 3 * 810 days; uint8 public communityPeriodsNumber = 6; address public advisersAllocation = address(0xa020d6Ca8738B18727dEFbe49fC22e3eF7110163); uint256 public advisersTotal = 1000000e8; uint256 public advisersPeriodAmount = 2291666e8; uint256 public advisersUnvested = 25000008e8; uint256 public advisersCliff = 0; uint256 public advisersPeriodLength = 1 days; uint8 public advisersPeriodsNumber = 12; function GenesisCryptoTechnology() public { totalSupply = 100000000e8; balances[investorsAllocation] = investorsTotal; balances[overdraftAllocation] = overdraftTotal; balances[teamAllocation] = teamTotal; balances[communityAllocation] = communityTotal; balances[advisersAllocation] = advisersTotal; allowed[investorsAllocation][msg.sender] = investorsTotal; allowed[overdraftAllocation][msg.sender] = overdraftUnvested; allowed[communityAllocation][msg.sender] = communityUnvested; allowed[advisersAllocation][msg.sender] = advisersUnvested; } function distributeInvestorsTokens(address _to, uint256 _amountWithDecimals) public onlyOwner { require(transferFrom(investorsAllocation, _to, _amountWithDecimals)); } function withdrawOverdraftTokens(address _to, uint256 _amountWithDecimals) public onlyOwner { allowed[overdraftAllocation][msg.sender] = allowance(overdraftAllocation, msg.sender); require(transferFrom(overdraftAllocation, _to, _amountWithDecimals)); } function withdrawTeamTokens(address _to, uint256 _amountWithDecimals) public onlyOwner { allowed[teamAllocation][msg.sender] = allowance(teamAllocation, msg.sender); require(transferFrom(teamAllocation, _to, _amountWithDecimals)); } function withdrawCommunityTokens(address _to, uint256 _amountWithDecimals) public onlyOwner { allowed[communityAllocation][msg.sender] = allowance(communityAllocation, msg.sender); require(transferFrom(communityAllocation, _to, _amountWithDecimals)); } function withdrawAdvisersTokens(address _to, uint256 _amountWithDecimals) public onlyOwner { allowed[advisersAllocation][msg.sender] = allowance(advisersAllocation, msg.sender); require(transferFrom(advisersAllocation, _to, _amountWithDecimals)); } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { if (_spender != owner) { return allowed[_owner][_spender]; } uint256 unlockedTokens; uint256 spentTokens; if (_owner == overdraftAllocation) { unlockedTokens = _calculateUnlockedTokens( overdraftCliff, overdraftPeriodLength, overdraftPeriodAmount, overdraftPeriodsNumber, overdraftUnvested ); spentTokens = sub(overdraftTotal, balanceOf(overdraftAllocation)); } else if (_owner == teamAllocation) { unlockedTokens = _calculateUnlockedTokens( teamCliff, teamPeriodLength, teamPeriodAmount, teamPeriodsNumber, teamUnvested ); spentTokens = sub(teamTotal, balanceOf(teamAllocation)); } else if (_owner == communityAllocation) { unlockedTokens = _calculateUnlockedTokens( communityCliff, communityPeriodLength, communityPeriodAmount, communityPeriodsNumber, communityUnvested ); spentTokens = sub(communityTotal, balanceOf(communityAllocation)); } else if (_owner == advisersAllocation) { unlockedTokens = _calculateUnlockedTokens( advisersCliff, advisersPeriodLength, advisersPeriodAmount, advisersPeriodsNumber, advisersUnvested ); spentTokens = sub(advisersTotal, balanceOf(advisersAllocation)); } else { return allowed[_owner][_spender]; } return sub(unlockedTokens, spentTokens); } function confirmOwnership() public onlyPotentialOwner { allowed[investorsAllocation][owner] = 0; allowed[investorsAllocation][msg.sender] = balanceOf(investorsAllocation); allowed[overdraftAllocation][owner] = 0; allowed[teamAllocation][owner] = 0; allowed[communityAllocation][owner] = 0; allowed[advisersAllocation][owner] = 0; super.confirmOwnership(); } function _calculateUnlockedTokens( uint256 _cliff, uint256 _periodLength, uint256 _periodAmount, uint8 _periodsNumber, uint256 _unvestedAmount ) private view returns (uint256) { if (now < add(creationTime, _cliff)) { return _unvestedAmount; } uint256 periods = div(sub(now, add(creationTime, _cliff)), _periodLength); periods = periods > _periodsNumber ? _periodsNumber : periods; return add(_unvestedAmount, mul(periods, _periodAmount)); } }
1
pragma solidity ^0.4.16; interface TrimpoToken { function presaleAddr() constant returns (address); function transferPresale(address _to, uint _value) public; } contract Admins { address public admin1; address public admin2; address public admin3; function Admins(address a1, address a2, address a3) public { admin1 = a1; admin2 = a2; admin3 = a3; } modifier onlyAdmins { require(msg.sender == admin1 || msg.sender == admin2 || msg.sender == admin3); _; } function setAdmin(address _adminAddress) onlyAdmins public { require(_adminAddress != admin1); require(_adminAddress != admin2); require(_adminAddress != admin3); if (admin1 == msg.sender) { admin1 = _adminAddress; } else if (admin2 == msg.sender) { admin2 = _adminAddress; } else if (admin3 == msg.sender) { admin3 = _adminAddress; } } } contract Presale is Admins { uint public duration; uint public hardCap; uint public raised; uint public bonus; address public benefit; uint public start; TrimpoToken token; address public tokenAddress; uint public tokensPerEther; mapping (address => uint) public balanceOf; modifier goodDate { require(start > 0); require(start <= now); require((start+duration) > now); _; } modifier belowHardCap { require(raised < hardCap); _; } event Investing(address investor, uint investedFunds, uint tokensWithoutBonus, uint tokens); event Raise(address to, uint funds); function Presale( address _tokenAddress, address a1, address a2, address a3 ) Admins(a1, a2, a3) public { hardCap = 1000 ether; bonus = 50; duration = 61 days; tokensPerEther = 400; tokenAddress = _tokenAddress; token = TrimpoToken(_tokenAddress); start = 1526342400; } function() payable public goodDate belowHardCap { uint tokenAmountWithoutBonus = msg.value * tokensPerEther; uint tokenAmount = tokenAmountWithoutBonus + (tokenAmountWithoutBonus * bonus/100); token.transferPresale(msg.sender, tokenAmount); raised+=msg.value; balanceOf[msg.sender]+= msg.value; Investing(msg.sender, msg.value, tokenAmountWithoutBonus, tokenAmount); } function setBenefit(address _benefit) public onlyAdmins { benefit = _benefit; } function getFunds(uint amount) public onlyAdmins { require(benefit != 0x0); require(amount <= this.balance); Raise(benefit, amount); benefit.send(amount); } }
0
pragma solidity ^0.4.24; contract DSAuthority { function canCall( address src, address dst, bytes4 sig ) public view returns (bool); } contract DSAuthEvents { event LogSetAuthority (address indexed authority); event LogSetOwner (address indexed owner); } contract DSAuth is DSAuthEvents { DSAuthority public authority; address public owner; constructor() public { owner = msg.sender; emit LogSetOwner(msg.sender); } function setOwner(address owner_) public auth { owner = owner_; emit LogSetOwner(owner); } function setAuthority(DSAuthority authority_) public auth { authority = authority_; emit LogSetAuthority(authority); } modifier auth { require(isAuthorized(msg.sender, msg.sig)); _; } function isAuthorized(address src, bytes4 sig) internal view returns (bool) { if (src == address(this)) { return true; } else if (src == owner) { return true; } else if (authority == DSAuthority(0)) { return false; } else { return authority.canCall(src, this, sig); } } } contract DSNote { event LogNote( bytes4 indexed sig, address indexed guy, bytes32 indexed foo, bytes32 indexed bar, uint wad, bytes fax ) anonymous; modifier note { bytes32 foo; bytes32 bar; assembly { foo := calldataload(4) bar := calldataload(36) } emit LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data); _; } } contract DSStop is DSNote, DSAuth { bool public stopped; modifier stoppable { require(!stopped); _; } function stop() public auth note { stopped = true; } function start() public auth note { stopped = false; } } interface DSValue { function peek() external returns (bytes32,bool); function read() external returns (bytes32); } contract OSM is DSAuth, DSStop { DSValue public src; uint16 constant ONE_HOUR = uint16(3600); uint16 public hop = ONE_HOUR; uint64 public zzz; struct Feed { uint128 val; bool has; } Feed cur; Feed nxt; event LogValue(bytes32 val); constructor (DSValue src_) public { src = src_; (bytes32 wut, bool ok) = src_.peek(); if (ok) { cur = nxt = Feed(uint128(wut), ok); zzz = prev(era()); } } function era() internal view returns (uint) { return block.timestamp; } function prev(uint ts) internal view returns (uint64) { return uint64(ts - (ts % hop)); } function step(uint16 ts) external auth { require(ts > 0); hop = ts; } function void() external auth { cur = nxt = Feed(0, false); stopped = true; } function pass() public view returns (bool ok) { return era() >= zzz + hop; } function poke() external stoppable { require(pass()); (bytes32 wut, bool ok) = src.peek(); cur = nxt; nxt = Feed(uint128(wut), ok); zzz = prev(era()); emit LogValue(bytes32(cur.val)); } function peek() external view returns (bytes32,bool) { return (bytes32(cur.val), cur.has); } function peep() external view returns (bytes32,bool) { return (bytes32(nxt.val), nxt.has); } function read() external view returns (bytes32) { require(cur.has); return (bytes32(cur.val)); } }
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 = 29721600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x148D4C931254bB761e7Eb54ECa295d156Fb8B5e7; } 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; 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; } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } } contract CryptoEngineerInterface { uint256 public prizePool = 0; function subVirus(address , uint256 ) public {} function claimPrizePool(address , uint256 ) public {} function isContractMiniGame() public pure returns( bool ) {} } contract CryptoMiningWarInterface { uint256 public deadline; function subCrystal( address , uint256 ) public {} } contract CrystalDeposit { using SafeMath for uint256; bool init = false; address public administrator; uint256 public HALF_TIME = 48 hours; uint256 public PRIZE_MAX = 0.25 ether; uint256 public round = 0; CryptoEngineerInterface public Engineer; CryptoMiningWarInterface public MiningWar; uint256 public miningWarDeadline; uint256 constant private CRTSTAL_MINING_PERIOD = 86400; mapping(uint256 => Game) public games; mapping(address => Player) public players; struct Game { uint256 round; uint256 crystals; uint256 prizePool; uint256 endTime; bool ended; } struct Player { uint256 currentRound; uint256 lastRound; uint256 reward; uint256 share; } event EndRound(uint256 round, uint256 crystals, uint256 prizePool, uint256 endTime); event Deposit(address player, uint256 questId, uint256 questLv, uint256 deposit, uint256 bonus, uint256 percent); modifier isAdministrator() { require(msg.sender == administrator); _; } modifier disableContract() { require(tx.origin == msg.sender); _; } constructor() public { administrator = msg.sender; setMiningWarInterface(0xf84c61bb982041c030b8580d1634f00fffb89059); setEngineerInterface(0x69fd0e5d0a93bf8bac02c154d343a8e3709adabf); } function () public payable { } function isContractMiniGame() public pure returns( bool _isContractMiniGame ) { _isContractMiniGame = true; } function upgrade(address addr) public isAdministrator { selfdestruct(addr); } function setupMiniGame( uint256 , uint256 _miningWarDeadline ) public { miningWarDeadline = _miningWarDeadline; } function setMiningWarInterface(address _addr) public isAdministrator { MiningWar = CryptoMiningWarInterface(_addr); } function setEngineerInterface(address _addr) public isAdministrator { CryptoEngineerInterface engineerInterface = CryptoEngineerInterface(_addr); require(engineerInterface.isContractMiniGame() == true); Engineer = engineerInterface; } function startGame() public { require(msg.sender == administrator); require(init == false); init = true; miningWarDeadline = getMiningWarDealine(); games[round].ended = true; startRound(); } function startRound() private { require(games[round].ended == true); uint256 crystalsLastRound = games[round].crystals; uint256 prizePoolLastRound= games[round].prizePool; round = round + 1; uint256 endTime = now + HALF_TIME; uint256 engineerPrizePool = getEngineerPrizePool(); uint256 prizePool = SafeMath.div(SafeMath.mul(engineerPrizePool, 5),100); if (prizePool >= PRIZE_MAX) prizePool = PRIZE_MAX; Engineer.claimPrizePool(address(this), prizePool); if (crystalsLastRound <= 0) prizePool = SafeMath.add(prizePool, prizePoolLastRound); games[round] = Game(round, 0, prizePool, endTime, false); } function endRound() private { require(games[round].ended == false); require(games[round].endTime <= now); Game storage g = games[round]; g.ended = true; startRound(); emit EndRound(g.round, g.crystals, g.prizePool, g.endTime); } function share(uint256 _value) public disableContract { require(miningWarDeadline > now); require(games[round].ended == false); require(_value >= 10000); MiningWar.subCrystal(msg.sender, _value); if (games[round].endTime <= now) endRound(); updateReward(msg.sender); Game storage g = games[round]; uint256 _share = SafeMath.mul(_value, CRTSTAL_MINING_PERIOD); g.crystals = SafeMath.add(g.crystals, _share); Player storage p = players[msg.sender]; if (p.currentRound == round) { p.share = SafeMath.add(p.share, _share); } else { p.share = _share; p.currentRound = round; } emit Deposit(msg.sender, 1, 1, _value, 0, 0); } function withdrawReward() public disableContract { if (games[round].endTime <= now) endRound(); updateReward(msg.sender); Player storage p = players[msg.sender]; uint256 balance = p.reward; if (address(this).balance >= balance) { msg.sender.transfer(balance); p.reward = 0; } } function updateReward(address _addr) private { Player storage p = players[_addr]; if ( games[p.currentRound].ended == true && p.lastRound < p.currentRound ) { p.reward = SafeMath.add(p.reward, calculateReward(msg.sender, p.currentRound)); p.lastRound = p.currentRound; } } function getData(address _addr) public view returns( uint256 _prizePool, uint256 _crystals, uint256 _endTime, uint256 _reward, uint256 _share ) { (_prizePool, _crystals, _endTime) = getCurrentGame(); (_reward, _share) = getPlayerData(_addr); } function calculateReward(address _addr, uint256 _round) public view returns(uint256) { Player memory p = players[_addr]; Game memory g = games[_round]; if (g.endTime > now) return 0; if (g.crystals == 0) return 0; return SafeMath.div(SafeMath.mul(g.prizePool, p.share), g.crystals); } function getCurrentGame() private view returns(uint256 _prizePool, uint256 _crystals, uint256 _endTime) { Game memory g = games[round]; _prizePool = g.prizePool; _crystals = g.crystals; _endTime = g.endTime; } function getPlayerData(address _addr) private view returns(uint256 _reward, uint256 _share) { Player memory p = players[_addr]; _reward = p.reward; if (p.currentRound == round) _share = players[_addr].share; if (p.currentRound != p.lastRound) _reward += calculateReward(_addr, p.currentRound); } function getEngineerPrizePool() private view returns(uint256) { return Engineer.prizePool(); } function getMiningWarDealine () private view returns(uint256) { return MiningWar.deadline(); } }
0
pragma solidity ^0.4.19; contract DigixConstants { uint256 constant SECONDS_IN_A_DAY = 24 * 60 * 60; uint256 constant ASSET_EVENT_CREATED_VENDOR_ORDER = 1; uint256 constant ASSET_EVENT_CREATED_TRANSFER_ORDER = 2; uint256 constant ASSET_EVENT_CREATED_REPLACEMENT_ORDER = 3; uint256 constant ASSET_EVENT_FULFILLED_VENDOR_ORDER = 4; uint256 constant ASSET_EVENT_FULFILLED_TRANSFER_ORDER = 5; uint256 constant ASSET_EVENT_FULFILLED_REPLACEMENT_ORDER = 6; uint256 constant ASSET_EVENT_MINTED = 7; uint256 constant ASSET_EVENT_MINTED_REPLACEMENT = 8; uint256 constant ASSET_EVENT_RECASTED = 9; uint256 constant ASSET_EVENT_REDEEMED = 10; uint256 constant ASSET_EVENT_FAILED_AUDIT = 11; uint256 constant ASSET_EVENT_ADMIN_FAILED = 12; uint256 constant ASSET_EVENT_REMINTED = 13; uint256 constant ROLE_ZERO_ANYONE = 0; uint256 constant ROLE_ROOT = 1; uint256 constant ROLE_VENDOR = 2; uint256 constant ROLE_XFERAUTH = 3; uint256 constant ROLE_POPADMIN = 4; uint256 constant ROLE_CUSTODIAN = 5; uint256 constant ROLE_AUDITOR = 6; uint256 constant ROLE_MARKETPLACE_ADMIN = 7; uint256 constant ROLE_KYC_ADMIN = 8; uint256 constant ROLE_FEES_ADMIN = 9; uint256 constant ROLE_DOCS_UPLOADER = 10; uint256 constant ROLE_KYC_RECASTER = 11; uint256 constant ROLE_FEES_DISTRIBUTION_ADMIN = 12; uint256 constant STATE_ZERO_UNDEFINED = 0; uint256 constant STATE_CREATED = 1; uint256 constant STATE_VENDOR_ORDER = 2; uint256 constant STATE_TRANSFER = 3; uint256 constant STATE_CUSTODIAN_DELIVERY = 4; uint256 constant STATE_MINTED = 5; uint256 constant STATE_AUDIT_FAILURE = 6; uint256 constant STATE_REPLACEMENT_ORDER = 7; uint256 constant STATE_REPLACEMENT_DELIVERY = 8; uint256 constant STATE_RECASTED = 9; uint256 constant STATE_REDEEMED = 10; uint256 constant STATE_ADMIN_FAILURE = 11; bytes32 constant CONTRACT_INTERACTIVE_ASSETS_EXPLORER = "i:asset:explorer"; bytes32 constant CONTRACT_INTERACTIVE_DIGIX_DIRECTORY = "i:directory"; bytes32 constant CONTRACT_INTERACTIVE_MARKETPLACE = "i:mp"; bytes32 constant CONTRACT_INTERACTIVE_MARKETPLACE_ADMIN = "i:mpadmin"; bytes32 constant CONTRACT_INTERACTIVE_POPADMIN = "i:popadmin"; bytes32 constant CONTRACT_INTERACTIVE_PRODUCTS_LIST = "i:products"; bytes32 constant CONTRACT_INTERACTIVE_TOKEN = "i:token"; bytes32 constant CONTRACT_INTERACTIVE_BULK_WRAPPER = "i:bulk-wrapper"; bytes32 constant CONTRACT_INTERACTIVE_TOKEN_CONFIG = "i:token:config"; bytes32 constant CONTRACT_INTERACTIVE_TOKEN_INFORMATION = "i:token:information"; bytes32 constant CONTRACT_INTERACTIVE_MARKETPLACE_INFORMATION = "i:mp:information"; bytes32 constant CONTRACT_INTERACTIVE_IDENTITY = "i:identity"; bytes32 constant CONTRACT_CONTROLLER_ASSETS = "c:asset"; bytes32 constant CONTRACT_CONTROLLER_ASSETS_RECAST = "c:asset:recast"; bytes32 constant CONTRACT_CONTROLLER_ASSETS_EXPLORER = "c:explorer"; bytes32 constant CONTRACT_CONTROLLER_DIGIX_DIRECTORY = "c:directory"; bytes32 constant CONTRACT_CONTROLLER_MARKETPLACE = "c:mp"; bytes32 constant CONTRACT_CONTROLLER_MARKETPLACE_ADMIN = "c:mpadmin"; bytes32 constant CONTRACT_CONTROLLER_PRODUCTS_LIST = "c:products"; bytes32 constant CONTRACT_CONTROLLER_TOKEN_APPROVAL = "c:token:approval"; bytes32 constant CONTRACT_CONTROLLER_TOKEN_CONFIG = "c:token:config"; bytes32 constant CONTRACT_CONTROLLER_TOKEN_INFO = "c:token:info"; bytes32 constant CONTRACT_CONTROLLER_TOKEN_TRANSFER = "c:token:transfer"; bytes32 constant CONTRACT_CONTROLLER_JOB_ID = "c:jobid"; bytes32 constant CONTRACT_CONTROLLER_IDENTITY = "c:identity"; bytes32 constant CONTRACT_STORAGE_ASSETS = "s:asset"; bytes32 constant CONTRACT_STORAGE_ASSET_EVENTS = "s:asset:events"; bytes32 constant CONTRACT_STORAGE_DIGIX_DIRECTORY = "s:directory"; bytes32 constant CONTRACT_STORAGE_MARKETPLACE = "s:mp"; bytes32 constant CONTRACT_STORAGE_PRODUCTS_LIST = "s:products"; bytes32 constant CONTRACT_STORAGE_GOLD_TOKEN = "s:goldtoken"; bytes32 constant CONTRACT_STORAGE_JOB_ID = "s:jobid"; bytes32 constant CONTRACT_STORAGE_IDENTITY = "s:identity"; bytes32 constant CONTRACT_SERVICE_TOKEN_DEMURRAGE = "sv:tdemurrage"; bytes32 constant CONTRACT_SERVICE_MARKETPLACE = "sv:mp"; bytes32 constant CONTRACT_SERVICE_DIRECTORY = "sv:directory"; bytes32 constant CONTRACT_DEMURRAGE_FEES_DISTRIBUTOR = "fees:distributor:demurrage"; bytes32 constant CONTRACT_RECAST_FEES_DISTRIBUTOR = "fees:distributor:recast"; bytes32 constant CONTRACT_TRANSFER_FEES_DISTRIBUTOR = "fees:distributor:transfer"; } contract ContractResolver { address public owner; bool public locked; function init_register_contract(bytes32 _key, address _contract_address) public returns (bool _success); function unregister_contract(bytes32 _key) public returns (bool _success); function get_contract(bytes32 _key) public constant returns (address _contract); } contract ResolverClient { address public resolver; bytes32 public key; address public CONTRACT_ADDRESS; modifier if_sender_is(bytes32 _contract) { require(msg.sender == ContractResolver(resolver).get_contract(_contract)); _; } modifier unless_resolver_is_locked() { require(is_locked() == false); _; } function init(bytes32 _key, address _resolver) internal returns (bool _success) { bool _is_locked = ContractResolver(_resolver).locked(); if (_is_locked == false) { CONTRACT_ADDRESS = address(this); resolver = _resolver; key = _key; require(ContractResolver(resolver).init_register_contract(key, CONTRACT_ADDRESS)); _success = true; } else { _success = false; } } function destroy() public returns (bool _success) { bool _is_locked = ContractResolver(resolver).locked(); require(!_is_locked); address _owner_of_contract_resolver = ContractResolver(resolver).owner(); require(msg.sender == _owner_of_contract_resolver); _success = ContractResolver(resolver).unregister_contract(key); require(_success); selfdestruct(_owner_of_contract_resolver); } function is_locked() private constant returns (bool _locked) { _locked = ContractResolver(resolver).locked(); } function get_contract(bytes32 _key) public constant returns (address _contract) { _contract = ContractResolver(resolver).get_contract(_key); } } contract Constants { address constant NULL_ADDRESS = address(0x0); uint256 constant ZERO = uint256(0); bytes32 constant EMPTY = bytes32(0x0); } contract ACConditions is Constants { modifier not_null_address(address _item) { require(_item != NULL_ADDRESS); _; } modifier if_null_address(address _item) { require(_item == NULL_ADDRESS); _; } modifier not_null_uint(uint256 _item) { require(_item != ZERO); _; } modifier if_null_uint(uint256 _item) { require(_item == ZERO); _; } modifier not_empty_bytes(bytes32 _item) { require(_item != EMPTY); _; } modifier if_empty_bytes(bytes32 _item) { require(_item == EMPTY); _; } modifier not_null_string(string _item) { bytes memory _i = bytes(_item); require(_i.length > 0); _; } modifier if_null_string(string _item) { bytes memory _i = bytes(_item); require(_i.length == 0); _; } modifier require_gas(uint256 _requiredgas) { require(msg.gas >= (_requiredgas - 22000)); _; } function is_contract(address _contract) public constant returns (bool _is_contract) { uint32 _code_length; assembly { _code_length := extcodesize(_contract) } if(_code_length > 1) { _is_contract = true; } else { _is_contract = false; } } modifier if_contract(address _contract) { require(is_contract(_contract) == true); _; } modifier unless_contract(address _contract) { require(is_contract(_contract) == false); _; } } contract MarketplaceAdminController { } contract MarketplaceStorage { } contract MarketplaceController { function put_purchase_for(uint256 _wei_sent, address _buyer, address _recipient, uint256 _block_number, uint256 _nonce, uint256 _wei_per_dgx_mg, address _signer, bytes _signature) payable public returns (bool _success, uint256 _purchased_amount); } contract MarketplaceCommon is ResolverClient, ACConditions, DigixConstants { function marketplace_admin_controller() internal constant returns (MarketplaceAdminController _contract) { _contract = MarketplaceAdminController(get_contract(CONTRACT_CONTROLLER_MARKETPLACE_ADMIN)); } function marketplace_storage() internal constant returns (MarketplaceStorage _contract) { _contract = MarketplaceStorage(get_contract(CONTRACT_STORAGE_MARKETPLACE)); } function marketplace_controller() internal constant returns (MarketplaceController _contract) { _contract = MarketplaceController(get_contract(CONTRACT_CONTROLLER_MARKETPLACE)); } } contract Marketplace is MarketplaceCommon { function Marketplace(address _resolver) public { require(init(CONTRACT_INTERACTIVE_MARKETPLACE, _resolver)); } function purchase(uint256 _block_number, uint256 _nonce, uint256 _wei_per_dgx_mg, address _signer, bytes _signature) payable public returns (bool _success, uint256 _purchased_amount) { address _sender = msg.sender; (_success, _purchased_amount) = marketplace_controller().put_purchase_for.value(msg.value).gas(600000)(msg.value, _sender, _sender, _block_number, _nonce, _wei_per_dgx_mg, _signer, _signature); require(_success); } }
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 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; Pause(); } function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } contract SealTokenSale is Pausable { using SafeMath for uint256; struct Supporter { bool hasKYC; address referrerAddress; } struct ExternalSupporter { uint256 reservedAmount; } enum TokenSaleState {Private, Pre, Main, Finished} mapping(address => Supporter) public supportersMap; mapping(address => ExternalSupporter) public externalSupportersMap; SealToken public token; address public vaultWallet; address public airdropWallet; address public kycWallet; uint256 public tokensSold; uint256 public tokensReserved; uint256 public maxTxGasPrice; TokenSaleState public currentState; uint256 public constant ONE_MILLION = 10 ** 6; uint256 public constant PRE_SALE_TOKEN_CAP = 384 * ONE_MILLION * 10 ** 18; uint256 public constant TOKEN_SALE_CAP = 492 * ONE_MILLION * 10 ** 18; uint256 public constant TOTAL_TOKENS_SUPPLY = 1200 * ONE_MILLION * 10 ** 18; uint256 public constant MIN_ETHER = 0.1 ether; uint256 public constant PRE_SALE_MIN_ETHER = 1 ether; uint256 public constant PRE_SALE_15_BONUS_MIN = 60 ether; uint256 public constant PRE_SALE_20_BONUS_MIN = 300 ether; uint256 public constant PRE_SALE_30_BONUS_MIN = 1200 ether; uint256 public tokenBaseRate; uint256 public referrerBonusRate; uint256 public referredBonusRate; modifier onlyOwnerOrKYCWallet() { require(msg.sender == owner || msg.sender == kycWallet); _; } event TokenPurchase(address indexed purchaser, uint256 value, uint256 amount); event TokenReservation(address indexed wallet, uint256 amount); event TokenReservationConfirmation(address indexed wallet, uint256 amount); event TokenReservationCancellation(address indexed wallet, uint256 amount); event KYC(address indexed user, bool isApproved); event ReferrerSet(address indexed user, address indexed referrerAddress); event ReferralBonusIncomplete(address indexed userAddress, uint256 missingAmount); event ReferralBonusMinted(address indexed userAddress, uint256 amount); function SealTokenSale( address _vaultWallet, address _airdropWallet, address _kycWallet, uint256 _tokenBaseRate, uint256 _referrerBonusRate, uint256 _referredBonusRate, uint256 _maxTxGasPrice ) public { require(_vaultWallet != address(0)); require(_airdropWallet != address(0)); require(_kycWallet != address(0)); require(_tokenBaseRate > 0); require(_referrerBonusRate > 0); require(_referredBonusRate > 0); require(_maxTxGasPrice > 0); vaultWallet = _vaultWallet; airdropWallet = _airdropWallet; kycWallet = _kycWallet; tokenBaseRate = _tokenBaseRate; referrerBonusRate = _referrerBonusRate; referredBonusRate = _referredBonusRate; maxTxGasPrice = _maxTxGasPrice; tokensSold = 0; tokensReserved = 0; token = new SealToken(); currentState = TokenSaleState.Private; } function() public payable { buyTokens(); } function buyTokens() public payable whenNotPaused { require(tx.gasprice <= maxTxGasPrice); require(isPublicTokenSaleRunning()); require(userHasKYC(msg.sender)); require(aboveMinimumPurchase()); address sender = msg.sender; uint256 weiAmountSent = msg.value; uint256 bonusMultiplier = getBonusMultiplier(weiAmountSent); uint256 newTokens = weiAmountSent.mul(tokenBaseRate).mul(bonusMultiplier).div(100); checkTotalsAndMintTokens(sender, newTokens, false); TokenPurchase(sender, weiAmountSent, newTokens); vaultWallet.transfer(msg.value); } function reserveTokens(address _wallet, uint256 _amount) public onlyOwner { require(_amount > 0); require(_wallet != address(0)); require(isPrivateSaleRunning() || isPreSaleRunning()); uint256 totalTokensReserved = tokensReserved.add(_amount); require(tokensSold + totalTokensReserved <= PRE_SALE_TOKEN_CAP); tokensReserved = totalTokensReserved; externalSupportersMap[_wallet].reservedAmount = externalSupportersMap[_wallet].reservedAmount.add(_amount); TokenReservation(_wallet, _amount); } function confirmReservedTokens(address _wallet, uint256 _amount) public onlyOwner { require(_amount > 0); require(_wallet != address(0)); require(!hasEnded()); require(_amount <= externalSupportersMap[_wallet].reservedAmount); checkTotalsAndMintTokens(_wallet, _amount, true); TokenReservationConfirmation(_wallet, _amount); } function cancelReservedTokens(address _wallet, uint256 _amount) public onlyOwner { require(_amount > 0); require(_wallet != address(0)); require(!hasEnded()); require(_amount <= externalSupportersMap[_wallet].reservedAmount); tokensReserved = tokensReserved.sub(_amount); externalSupportersMap[_wallet].reservedAmount = externalSupportersMap[_wallet].reservedAmount.sub(_amount); TokenReservationCancellation(_wallet, _amount); } function checkTotalsAndMintTokens(address _wallet, uint256 _amount, bool _fromReservation) private { uint256 totalTokensSold = tokensSold.add(_amount); uint256 totalTokensReserved = tokensReserved; if (_fromReservation) { totalTokensReserved = totalTokensReserved.sub(_amount); } if (isMainSaleRunning()) { require(totalTokensSold + totalTokensReserved <= TOKEN_SALE_CAP); } else { require(totalTokensSold + totalTokensReserved <= PRE_SALE_TOKEN_CAP); } tokensSold = totalTokensSold; if (_fromReservation) { externalSupportersMap[_wallet].reservedAmount = externalSupportersMap[_wallet].reservedAmount.sub(_amount); tokensReserved = totalTokensReserved; } token.mint(_wallet, _amount); address userReferrer = getUserReferrer(_wallet); if (userReferrer != address(0)) { mintReferralShare(_amount, userReferrer, referrerBonusRate); mintReferralShare(_amount, _wallet, referredBonusRate); } } function mintReferralShare(uint256 _amount, address _userAddress, uint256 _bonusRate) private { uint256 currentCap; if (isMainSaleRunning()) { currentCap = TOKEN_SALE_CAP; } else { currentCap = PRE_SALE_TOKEN_CAP; } uint256 maxTokensAvailable = currentCap - tokensSold - tokensReserved; uint256 fullShare = _amount.mul(_bonusRate).div(10000); if (fullShare <= maxTokensAvailable) { token.mint(_userAddress, fullShare); tokensSold = tokensSold.add(fullShare); ReferralBonusMinted(_userAddress, fullShare); } else { token.mint(_userAddress, maxTokensAvailable); tokensSold = tokensSold.add(maxTokensAvailable); ReferralBonusMinted(_userAddress, maxTokensAvailable); ReferralBonusIncomplete(_userAddress, fullShare - maxTokensAvailable); } } function startPreSale() public onlyOwner { require(currentState == TokenSaleState.Private); currentState = TokenSaleState.Pre; } function goBackToPrivateSale() public onlyOwner { require(currentState == TokenSaleState.Pre); currentState = TokenSaleState.Private; } function startMainSale() public onlyOwner { require(currentState == TokenSaleState.Pre); currentState = TokenSaleState.Main; } function goBackToPreSale() public onlyOwner { require(currentState == TokenSaleState.Main); currentState = TokenSaleState.Pre; } function finishContract() public onlyOwner { require(currentState == TokenSaleState.Main); require(tokensReserved == 0); currentState = TokenSaleState.Finished; uint256 unsoldTokens = TOKEN_SALE_CAP.sub(tokensSold); token.mint(airdropWallet, unsoldTokens); uint256 notForSaleTokens = TOTAL_TOKENS_SUPPLY.sub(TOKEN_SALE_CAP); token.mint(vaultWallet, notForSaleTokens); token.finishMinting(); token.transferOwnership(owner); } function updateMaxTxGasPrice(uint256 _newMaxTxGasPrice) public onlyOwner { require(_newMaxTxGasPrice > 0); maxTxGasPrice = _newMaxTxGasPrice; } function updateTokenBaseRate(uint256 _tokenBaseRate) public onlyOwner { require(_tokenBaseRate > 0); tokenBaseRate = _tokenBaseRate; } function updateVaultWallet(address _vaultWallet) public onlyOwner { require(_vaultWallet != address(0)); vaultWallet = _vaultWallet; } function updateKYCWallet(address _kycWallet) public onlyOwner { require(_kycWallet != address(0)); kycWallet = _kycWallet; } function approveUserKYC(address _user) onlyOwnerOrKYCWallet public { require(_user != address(0)); Supporter storage sup = supportersMap[_user]; sup.hasKYC = true; KYC(_user, true); } function disapproveUserKYC(address _user) onlyOwnerOrKYCWallet public { require(_user != address(0)); Supporter storage sup = supportersMap[_user]; sup.hasKYC = false; KYC(_user, false); } function approveUserKYCAndSetReferrer(address _user, address _referrerAddress) onlyOwnerOrKYCWallet public { require(_user != address(0)); Supporter storage sup = supportersMap[_user]; sup.hasKYC = true; sup.referrerAddress = _referrerAddress; KYC(_user, true); ReferrerSet(_user, _referrerAddress); } function isPrivateSaleRunning() public view returns (bool) { return (currentState == TokenSaleState.Private); } function isPublicTokenSaleRunning() public view returns (bool) { return (isPreSaleRunning() || isMainSaleRunning()); } function isPreSaleRunning() public view returns (bool) { return (currentState == TokenSaleState.Pre); } function isMainSaleRunning() public view returns (bool) { return (currentState == TokenSaleState.Main); } function hasEnded() public view returns (bool) { return (currentState == TokenSaleState.Finished); } function userHasKYC(address _user) public view returns (bool) { return supportersMap[_user].hasKYC; } function getUserReferrer(address _user) public view returns (address) { return supportersMap[_user].referrerAddress; } function getReservedAmount(address _user) public view returns (uint256) { return externalSupportersMap[_user].reservedAmount; } function getBonusMultiplier(uint256 _weiAmount) internal view returns (uint256) { if (isMainSaleRunning()) { return 100; } else if (isPreSaleRunning()) { if (_weiAmount >= PRE_SALE_30_BONUS_MIN) { return 130; } else if (_weiAmount >= PRE_SALE_20_BONUS_MIN) { return 120; } else if (_weiAmount >= PRE_SALE_15_BONUS_MIN) { return 115; } else if (_weiAmount >= PRE_SALE_MIN_ETHER) { return 110; } else { revert(); } } } function aboveMinimumPurchase() internal view returns (bool) { if (isMainSaleRunning()) { return msg.value >= MIN_ETHER; } else if (isPreSaleRunning()) { return msg.value >= PRE_SALE_MIN_ETHER; } else { return false; } } } 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); 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 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 SealToken is MintableToken { string public constant name = "SealToken"; string public constant symbol = "SEAL"; uint8 public constant decimals = 18; modifier onlyWhenTransferEnabled() { require(mintingFinished); _; } modifier validDestination(address _to) { require(_to != address(0x0)); require(_to != address(this)); _; } function SealToken() public { } function transferFrom(address _from, address _to, uint256 _value) public onlyWhenTransferEnabled validDestination(_to) returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public onlyWhenTransferEnabled returns (bool) { return super.approve(_spender, _value); } function increaseApproval (address _spender, uint _addedValue) public onlyWhenTransferEnabled returns (bool) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval (address _spender, uint _subtractedValue) public onlyWhenTransferEnabled returns (bool) { return super.decreaseApproval(_spender, _subtractedValue); } function transfer(address _to, uint256 _value) public onlyWhenTransferEnabled validDestination(_to) returns (bool) { return super.transfer(_to, _value); } }
0
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 Tripxchain 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 = "TXC"; name = "Tripxchain"; decimals = 0; _totalSupply = 3000000000 * 0**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.16; contract SafeMath { function SafeMath() { } function safeAdd(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x + _y; assert(z >= _x); return z; } function safeSub(uint256 _x, uint256 _y) internal returns (uint256) { assert(_x >= _y); return _x - _y; } function safeMul(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x * _y; assert(_x == 0 || z / _x == _y); return z; } } contract IERC20Token { function name() public constant returns (string name) { name; } function symbol() public constant returns (string symbol) { symbol; } function decimals() public constant returns (uint8 decimals) { decimals; } function totalSupply() public constant returns (uint256 totalSupply) { totalSupply; } function balanceOf(address _owner) public constant returns (uint256 balance) { _owner; balance; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { _owner; _spender; remaining; } 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); } contract COSSToken is IERC20Token, SafeMath { string public standard = 'COSS_DEMO'; string public name = 'COSS_DEMO'; string public symbol = 'COSS_DEMO'; uint8 public decimals = 18; uint256 public totalSupply = 200000; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); mapping (address => uint256) public revenueShareList; mapping (address => string) public revenueShareCurrency; mapping (address => uint256) public revenueShareDistribution; address public revenueShareOwnerAddress; function COSSToken() { balanceOf[msg.sender] = totalSupply * decimals; revenueShareOwnerAddress = msg.sender; } modifier validAddress(address _address) { require(_address != 0x0); _; } function activateRevenueShareReference(uint256 _revenueShareItem) { revenueShareList[msg.sender] = _revenueShareItem; } function addRevenueShareCurrency(address _currencyAddress,string _currencyName) { if (msg.sender == revenueShareOwnerAddress) { revenueShareCurrency[_currencyAddress] = _currencyName; revenueShareDistribution[_currencyAddress] = 0; } } function saveRevenueShareDistribution(address _currencyAddress, uint256 _value) { if (msg.sender == revenueShareOwnerAddress) { revenueShareDistribution[_currencyAddress] = safeAdd(revenueShareDistribution[_currencyAddress], _value); } } function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool success) { balanceOf[msg.sender] = safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool success) { allowance[_from][msg.sender] = safeSub(allowance[_from][msg.sender], _value); balanceOf[_from] = safeSub(balanceOf[_from], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool success) { require(_value == 0 || allowance[msg.sender][_spender] == 0); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } }
1
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 Ownable { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused, "Contract Paused. Events/Transaction Paused until Further Notice"); _; } modifier whenPaused() { require(paused, "Contract Functionality Resumed"); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract StandardToken is Pausable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; uint256 supply; uint256 public initialSupply; uint256 public totalSupply; address public marketingReserve; address public bountyReserve; address public teamReserve; uint256 marketingToken; uint256 bountyToken; uint256 teamToken; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor() public { name = "Bitbose"; symbol = "BOSE"; decimals = 18; supply = 300000000; initialSupply = supply * (10 ** uint256(decimals)); totalSupply = initialSupply; balances[owner] = totalSupply; bountyTransfers(); } function bountyTransfers() internal { marketingReserve = 0x0093126Cc5Db9BaFe75EdEB19F305E724E28213D; bountyReserve = 0x00E3b0794F69015fc4a8635F788A41F11d88Aa07; teamReserve = 0x004f678A05E41D2df20041D70dd5aca493369904; marketingToken = ( totalSupply * 12 ) / 100; bountyToken = ( totalSupply * 2 ) / 100; teamToken = ( totalSupply * 16 ) / 100; balances[msg.sender] = totalSupply - marketingToken - teamToken - bountyToken; balances[teamReserve] = teamToken; balances[bountyReserve] = bountyToken; balances[marketingReserve] = marketingToken; Transfer(msg.sender, marketingReserve, marketingToken); Transfer(msg.sender, bountyReserve, bountyToken); Transfer(msg.sender, teamReserve, teamToken); } function transfer(address _to, uint256 _value) public whenNotPaused 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 whenNotPaused returns (uint256) { return balances[_owner]; } function transferFrom( address _from, address _to, uint256 _value ) public whenNotPaused 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 whenNotPaused returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view whenNotPaused returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint256 _addedValue ) public whenNotPaused 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 whenNotPaused 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 Bitbose is StandardToken { using SafeMath for uint256; mapping (address => uint256) public freezed; event Burn(address indexed burner, uint256 value); event Mint(address indexed to, uint256 amount); event Withdraw(address indexed _from, address indexed _to, uint256 _value); event Freeze(address indexed from, uint256 value); event Unfreeze(address indexed from, uint256 value); function burn(uint256 _value) public onlyOwner whenNotPaused { _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); } function burnFrom(address _from, uint256 _value) public onlyOwner whenNotPaused { require(_value <= allowed[_from][msg.sender]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); _burn(_from, _value); } function mint(address _to, uint256 _amount) public onlyOwner whenNotPaused 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 freeze(address _spender,uint256 _value) public onlyOwner whenNotPaused returns (bool success) { require(_value < balances[_spender]); require(_value >= 0); balances[_spender] = balances[_spender].sub(_value); freezed[_spender] = freezed[_spender].add(_value); emit Freeze(_spender, _value); return true; } function unfreeze(address _spender,uint256 _value) public onlyOwner whenNotPaused returns (bool success) { require(freezed[_spender] < _value); require(_value <= 0); freezed[_spender] = freezed[_spender].sub(_value); balances[_spender] = balances[_spender].add(_value); emit Unfreeze(_spender, _value); return true; } function withdrawEther(address _account) public onlyOwner whenNotPaused payable returns (bool success) { _account.transfer(address(this).balance); emit Withdraw(this, _account, address(this).balance); return true; } function() public payable { } }
1
pragma solidity ^0.4.16; interface token_recipient { function approved(address _from, uint256 _value, address _token, bytes _data) public; } contract ERC20 { string public name; string public symbol; uint8 public decimals = 2; uint256 public totalSupply; address public owner; mapping (address => uint256) public balance; 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 ERC20 (string token_name, string token_symbol, uint256 supply) public { name = token_name; symbol = token_symbol; totalSupply = supply * 10 ** uint256(decimals); owner = msg.sender; balance[msg.sender] = totalSupply; } modifier owned { require(msg.sender == owner); _; } function _transfer (address _from, address _to, uint256 _value) internal { require(_to != 0x0); require(balance[_from] >= _value); require(balance[_to] + _value > balance[_to]); uint prev_balances = balance[_from] + balance[_to]; balance[_from] -= _value; balance[_to] += _value; Transfer(_from, _to, _value); assert(balance[_from] + balance[_to] == prev_balances); } function approve (address _spender, uint256 _value, bytes _data) public { allowance[msg.sender][_spender] = _value; token_recipient spender = token_recipient(_spender); spender.approved(msg.sender, _value, this, _data); } 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 burn(uint256 _value) public returns (bool success) { require(balance[msg.sender] >= _value); balance[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balance[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balance[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } function mint(address target, uint256 mint_value) public owned { balance[target] += mint_value; totalSupply += mint_value; Transfer(0, this, mint_value); Transfer(this, target, mint_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 = 30499200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x5199bCC8902BC76507986815C6a0b0e17235e549; } 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; contract Crowdsale { using SafeMath for uint256; address constant public TOKEN_OWNER = 0x57Cdd07287f668eC4D58f3E362b4FCC2bC54F5b8; address constant public WALLET = 0x1513F644590d866e25490687AB1b3Ad262d5b6dF; uint256 constant public MINSALESCAP = 200 ether; uint256 constant public MAXSALESCAP = 126000 ether; uint256 constant public STARTDATE = 1533686401; uint256 constant public ENDDATE = 1543536060; uint256 constant public FXRATE = 50000; uint256 constant public MINCONTRIBUTION = 5000000000000 wei; address public TOKEN; address public owner; uint256 public weiRaised; enum State { Running, Expired, Funded } State public state; struct ContributorStruct { bool whitelisted; uint256 contributions; } mapping(address => ContributorStruct) public whitelist; modifier isContributor() {require(whitelist[msg.sender].contributions > 0x00); _;} modifier isOwner() {require(msg.sender == owner); _;} modifier inState(State _state) {require(state == _state); _;} modifier inPaymentLimits(uint256 _payment) {require(_payment >= MINCONTRIBUTION); _;} modifier inWhitelist(address _contributor) {require(whitelist[_contributor].whitelisted == true); _;} event WhitelistingLog(address indexed _contributor); event RefundLog(address indexed _contributor, uint256 _amount); event PurchaseLog(address indexed _contributor, address indexed _beneficiary, uint256 _amount); constructor (address _token) public { require(_token != address(0x00)); owner = msg.sender; TOKEN = _token; } function () public payable { _updateStateIfExpired(); } function buyTokens(address _beneficiary) public inState(State.Running) inPaymentLimits(msg.value) inWhitelist(_beneficiary) payable returns (bool success) { require(_beneficiary != address(0x00)); assert(block.timestamp >= STARTDATE); uint256 tokenAmount = _calculateTokenAmount(msg.value); YOUToken token = YOUToken(TOKEN); weiRaised = weiRaised.add(msg.value); whitelist[_beneficiary].contributions = whitelist[_beneficiary].contributions.add(msg.value); if (!token.mint.gas(700000)(_beneficiary, tokenAmount)) { return false; } if (weiRaised >= MAXSALESCAP || weiRaised >= MINSALESCAP && block.timestamp >= ENDDATE) { state = State.Funded; } else { _updateStateIfExpired(); } emit PurchaseLog(msg.sender, _beneficiary, msg.value); return true; } function refund(address _contributor) public isContributor inState(State.Expired) returns (bool success) { require(_contributor != address(0x00)); uint256 amount = whitelist[_contributor].contributions; whitelist[_contributor].contributions = 0x00; _contributor.transfer(amount); emit RefundLog(_contributor, amount); return true; } function whitelistAddr(address _contributor) public isOwner returns(bool) { require(_contributor != address(0x00)); whitelist[_contributor].whitelisted = true; emit WhitelistingLog(_contributor); return true; } function whitelistAddrAndBuyTokens(address _contributor, uint256 _weiAmount) public isOwner returns(bool) { require(_contributor != address(0x00)); uint256 tokenAmount = _calculateTokenAmount(_weiAmount); YOUToken token = YOUToken(TOKEN); whitelist[_contributor].whitelisted = true; weiRaised = weiRaised.add(_weiAmount); if (!token.mint.gas(700000)(_contributor, tokenAmount)) { return false; } emit WhitelistingLog(_contributor); return true; } function withdraw() public isOwner inState(State.Funded) { WALLET.transfer(address(this).balance); } function delistAddress(address _contributor) public isOwner inState(State.Running) returns (bool) { require(_contributor != address(0x00)); require(whitelist[_contributor].whitelisted); whitelist[_contributor].whitelisted = false; return true; } function emergencyStop() public isOwner inState(State.Running) { state = State.Expired; } function transferOwnership() public isOwner inState(State.Running) { owner = TOKEN_OWNER; } function _updateStateIfExpired() internal { if ((block.timestamp >= ENDDATE && state == State.Running) || (block.timestamp >= ENDDATE && weiRaised < MINSALESCAP)) { state = State.Expired; } } function _calculateTokenAmount(uint256 _weiAmount) internal view returns (uint256 tokenAmount) { uint256 discount; if (block.timestamp <= 1535241660) { if (_weiAmount >= 1700 ether) { discount = 30; } else if (_weiAmount > 0.2 ether) { discount = 25; } } else if (block.timestamp <= 1537747260) { discount = 15; } else if (block.timestamp <= 1540339260) { discount = 10; } else if (block.timestamp <= 1543536060) { discount = 5; } _weiAmount = _weiAmount.mul(discount).div(100).add(_weiAmount); return _weiAmount.mul(FXRATE); } } 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; } } contract YOUToken { function mint(address _to, uint256 _amount) public returns (bool); function transferOwnership(address _newOwner) public; }
1
pragma solidity ^0.4.13; 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 KyberAirDrop is Ownable { uint public numDrops; uint public dropAmount; function KyberAirDrop( address dropper ) { transferOwnership(dropper); } event TokenDrop( address receiver, uint amount ); function airDrop( ERC20Interface token, address tokenRepo, address[] recipients, uint amount, bool kgt, KyberGenesisToken kgtToken ) onlyOwner { require( amount == 0 || amount == (2*(10**18)) || amount == (5*(10**18)) ); if( amount > 0 ) { for( uint i = 0 ; i < recipients.length ; i++ ) { assert( token.transferFrom( tokenRepo, recipients[i], amount ) ); TokenDrop( recipients[i], amount ); } } if( kgt ) { kgtToken.mint(recipients); } numDrops += recipients.length; dropAmount += recipients.length * amount; } function tranferMinterOwnership( KyberGenesisToken kgtToken, address newOwner ) onlyOwner { kgtToken.transferOwnership(newOwner); } function emergencyERC20Drain( ERC20Interface token, uint amount ) { address kyberMultisig = 0x3EB01B3391EA15CE752d01Cf3D3F09deC596F650; token.transfer( kyberMultisig, amount ); } } contract KyberGenesisToken is Ownable { string public constant name = "Kyber Genesis Token"; string public constant symbol = "KGT"; uint public constant decimals = 0; uint public totalSupply = 0; mapping(address=>uint) public balanceOf; function KyberGenesisToken( address minter ) { transferOwnership(minter); } event Transfer(address indexed _from, address indexed _to, uint _value); event EndMinting( uint timestamp ); function mint( address[] recipients ) onlyOwner { uint newRecipients = 0; for( uint i = 0 ; i < recipients.length ; i++ ){ address recipient = recipients[i]; if( balanceOf[recipient] == 0 ){ Transfer( address(0x0), recipient, 1 ); balanceOf[recipient] = 1; newRecipients++; } } totalSupply += newRecipients; } function endMinting() onlyOwner { transferOwnership(address(0xdead)); EndMinting(block.timestamp); } function burn() { require(balanceOf[msg.sender] == 1 ); Transfer( msg.sender, address(0x0), 1 ); balanceOf[msg.sender] = 0; totalSupply--; } function emergencyERC20Drain( ERC20Interface token, uint amount ){ address kyberMultisig = 0x3EB01B3391EA15CE752d01Cf3D3F09deC596F650; token.transfer( kyberMultisig, amount ); } function transfer(address _to, uint _value) returns (bool){ revert(); } function transferFrom(address _from, address _to, uint _value) returns (bool){ revert(); } function approve(address _spender, uint _value) returns (bool){ revert(); } function allowance(address _owner, address _spender) constant returns (uint){ return 0; } event Approval(address indexed _owner, address indexed _spender, uint _value); } contract ERC20Interface { function transferFrom(address _from, address _to, uint _value) returns (bool){} function transfer(address _to, uint _value) returns (bool){} function ERC20Interface(){} }
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 AccessAdmin is Ownable { mapping (address => bool) adminContracts; mapping (address => bool) actionContracts; function setAdminContract(address _addr, bool _useful) public onlyOwner { require(_addr != address(0)); adminContracts[_addr] = _useful; } modifier onlyAdmin { require(adminContracts[msg.sender]); _; } function setActionContract(address _actionAddr, bool _useful) public onlyAdmin { actionContracts[_actionAddr] = _useful; } modifier onlyAccess() { require(actionContracts[msg.sender]); _; } } interface ERC20 { 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 JadeCoin is ERC20, AccessAdmin { using SafeMath for SafeMath; string public constant name = "MAGICACADEMY JADE"; string public constant symbol = "Jade"; uint8 public constant decimals = 0; uint256 public roughSupply; uint256 public totalJadeProduction; uint256[] public totalJadeProductionSnapshots; uint256 public nextSnapshotTime; uint256 public researchDivPercent = 10; mapping(address => uint256) public jadeBalance; mapping(address => mapping(uint8 => uint256)) public coinBalance; mapping(uint8 => uint256) totalEtherPool; mapping(address => mapping(uint256 => uint256)) public jadeProductionSnapshots; mapping(address => mapping(uint256 => bool)) private jadeProductionZeroedSnapshots; mapping(address => uint256) public lastJadeSaveTime; mapping(address => uint256) public lastJadeProductionUpdate; mapping(address => uint256) private lastJadeResearchFundClaim; mapping(address => uint256) private lastJadeDepositFundClaim; uint256[] private allocatedJadeResearchSnapshots; mapping(address => mapping(address => uint256)) private allowed; event ReferalGain(address player, address referal, uint256 amount); function JadeCoin() public { } function() external payable { totalEtherPool[1] += msg.value; } function tweakDailyDividends(uint256 newResearchPercent) external { require(msg.sender == owner); require(newResearchPercent > 0 && newResearchPercent <= 10); researchDivPercent = newResearchPercent; } function totalSupply() public constant returns(uint256) { return roughSupply; } function balanceOf(address player) public constant returns(uint256) { return SafeMath.add(jadeBalance[player],balanceOfUnclaimed(player)); } function balanceOfUnclaimed(address player) public constant returns (uint256) { uint256 lSave = lastJadeSaveTime[player]; if (lSave > 0 && lSave < block.timestamp) { return SafeMath.mul(getJadeProduction(player),SafeMath.div(SafeMath.sub(block.timestamp,lSave),100)); } return 0; } function getJadeProduction(address player) public constant returns (uint256){ return jadeProductionSnapshots[player][lastJadeProductionUpdate[player]]; } function getTotalJadeProduction() external view returns (uint256) { return totalJadeProduction; } function getlastJadeProductionUpdate(address player) public view returns (uint256) { return lastJadeProductionUpdate[player]; } function increasePlayersJadeProduction(address player, uint256 increase) public onlyAccess { jadeProductionSnapshots[player][allocatedJadeResearchSnapshots.length] = SafeMath.add(getJadeProduction(player),increase); lastJadeProductionUpdate[player] = allocatedJadeResearchSnapshots.length; totalJadeProduction = SafeMath.add(totalJadeProduction,increase); } function reducePlayersJadeProduction(address player, uint256 decrease) public onlyAccess { uint256 previousProduction = getJadeProduction(player); uint256 newProduction = SafeMath.sub(previousProduction, decrease); if (newProduction == 0) { jadeProductionZeroedSnapshots[player][allocatedJadeResearchSnapshots.length] = true; delete jadeProductionSnapshots[player][allocatedJadeResearchSnapshots.length]; } else { jadeProductionSnapshots[player][allocatedJadeResearchSnapshots.length] = newProduction; } lastJadeProductionUpdate[player] = allocatedJadeResearchSnapshots.length; totalJadeProduction = SafeMath.sub(totalJadeProduction,decrease); } function updatePlayersCoin(address player) internal { uint256 coinGain = balanceOfUnclaimed(player); lastJadeSaveTime[player] = block.timestamp; roughSupply = SafeMath.add(roughSupply,coinGain); jadeBalance[player] = SafeMath.add(jadeBalance[player],coinGain); } function updatePlayersCoinByOut(address player) external onlyAccess { uint256 coinGain = balanceOfUnclaimed(player); lastJadeSaveTime[player] = block.timestamp; roughSupply = SafeMath.add(roughSupply,coinGain); jadeBalance[player] = SafeMath.add(jadeBalance[player],coinGain); } function transfer(address recipient, uint256 amount) public returns (bool) { updatePlayersCoin(msg.sender); require(amount <= jadeBalance[msg.sender]); jadeBalance[msg.sender] = SafeMath.sub(jadeBalance[msg.sender],amount); jadeBalance[recipient] = SafeMath.add(jadeBalance[recipient],amount); Transfer(msg.sender, recipient, amount); return true; } function transferFrom(address player, address recipient, uint256 amount) public returns (bool) { updatePlayersCoin(player); require(amount <= allowed[player][msg.sender] && amount <= jadeBalance[player]); jadeBalance[player] = SafeMath.sub(jadeBalance[player],amount); jadeBalance[recipient] = SafeMath.add(jadeBalance[recipient],amount); allowed[player][msg.sender] = SafeMath.sub(allowed[player][msg.sender],amount); Transfer(player, recipient, amount); return true; } function approve(address approvee, uint256 amount) public returns (bool) { allowed[msg.sender][approvee] = amount; Approval(msg.sender, approvee, amount); return true; } function allowance(address player, address approvee) public constant returns(uint256) { return allowed[player][approvee]; } function updatePlayersCoinByPurchase(address player, uint256 purchaseCost) public onlyAccess { uint256 unclaimedJade = balanceOfUnclaimed(player); if (purchaseCost > unclaimedJade) { uint256 jadeDecrease = SafeMath.sub(purchaseCost, unclaimedJade); require(jadeBalance[player] >= jadeDecrease); roughSupply = SafeMath.sub(roughSupply,jadeDecrease); jadeBalance[player] = SafeMath.sub(jadeBalance[player],jadeDecrease); } else { uint256 jadeGain = SafeMath.sub(unclaimedJade,purchaseCost); roughSupply = SafeMath.add(roughSupply,jadeGain); jadeBalance[player] = SafeMath.add(jadeBalance[player],jadeGain); } lastJadeSaveTime[player] = block.timestamp; } function JadeCoinMining(address _addr, uint256 _amount) external onlyAdmin { roughSupply = SafeMath.add(roughSupply,_amount); jadeBalance[_addr] = SafeMath.add(jadeBalance[_addr],_amount); } function setRoughSupply(uint256 iroughSupply) external onlyAccess { roughSupply = SafeMath.add(roughSupply,iroughSupply); } function coinBalanceOf(address player,uint8 itype) external constant returns(uint256) { return coinBalance[player][itype]; } function setJadeCoin(address player, uint256 coin, bool iflag) external onlyAccess { if (iflag) { jadeBalance[player] = SafeMath.add(jadeBalance[player],coin); } else if (!iflag) { jadeBalance[player] = SafeMath.sub(jadeBalance[player],coin); } } function setCoinBalance(address player, uint256 eth, uint8 itype, bool iflag) external onlyAccess { if (iflag) { coinBalance[player][itype] = SafeMath.add(coinBalance[player][itype],eth); } else if (!iflag) { coinBalance[player][itype] = SafeMath.sub(coinBalance[player][itype],eth); } } function setLastJadeSaveTime(address player) external onlyAccess { lastJadeSaveTime[player] = block.timestamp; } function setTotalEtherPool(uint256 inEth, uint8 itype, bool iflag) external onlyAccess { if (iflag) { totalEtherPool[itype] = SafeMath.add(totalEtherPool[itype],inEth); } else if (!iflag) { totalEtherPool[itype] = SafeMath.sub(totalEtherPool[itype],inEth); } } function getTotalEtherPool(uint8 itype) external view returns (uint256) { return totalEtherPool[itype]; } function setJadeCoinZero(address player) external onlyAccess { jadeBalance[player]=0; } function getNextSnapshotTime() external view returns(uint256) { return nextSnapshotTime; } function viewUnclaimedResearchDividends() external constant returns (uint256, uint256, uint256) { uint256 startSnapshot = lastJadeResearchFundClaim[msg.sender]; uint256 latestSnapshot = allocatedJadeResearchSnapshots.length - 1; uint256 researchShare; uint256 previousProduction = jadeProductionSnapshots[msg.sender][lastJadeResearchFundClaim[msg.sender] - 1]; for (uint256 i = startSnapshot; i <= latestSnapshot; i++) { uint256 productionDuringSnapshot = jadeProductionSnapshots[msg.sender][i]; bool soldAllProduction = jadeProductionZeroedSnapshots[msg.sender][i]; if (productionDuringSnapshot == 0 && !soldAllProduction) { productionDuringSnapshot = previousProduction; } else { previousProduction = productionDuringSnapshot; } researchShare += (allocatedJadeResearchSnapshots[i] * productionDuringSnapshot) / totalJadeProductionSnapshots[i]; } return (researchShare, startSnapshot, latestSnapshot); } function claimResearchDividends(address referer, uint256 startSnapshot, uint256 endSnapShot) external { require(startSnapshot <= endSnapShot); require(startSnapshot >= lastJadeResearchFundClaim[msg.sender]); require(endSnapShot < allocatedJadeResearchSnapshots.length); uint256 researchShare; uint256 previousProduction = jadeProductionSnapshots[msg.sender][lastJadeResearchFundClaim[msg.sender] - 1]; for (uint256 i = startSnapshot; i <= endSnapShot; i++) { uint256 productionDuringSnapshot = jadeProductionSnapshots[msg.sender][i]; bool soldAllProduction = jadeProductionZeroedSnapshots[msg.sender][i]; if (productionDuringSnapshot == 0 && !soldAllProduction) { productionDuringSnapshot = previousProduction; } else { previousProduction = productionDuringSnapshot; } researchShare += (allocatedJadeResearchSnapshots[i] * productionDuringSnapshot) / totalJadeProductionSnapshots[i]; } if (jadeProductionSnapshots[msg.sender][endSnapShot] == 0 && !jadeProductionZeroedSnapshots[msg.sender][endSnapShot] && previousProduction > 0) { jadeProductionSnapshots[msg.sender][endSnapShot] = previousProduction; } lastJadeResearchFundClaim[msg.sender] = endSnapShot + 1; uint256 referalDivs; if (referer != address(0) && referer != msg.sender) { referalDivs = researchShare / 100; coinBalance[referer][1] += referalDivs; ReferalGain(referer, msg.sender, referalDivs); } coinBalance[msg.sender][1] += SafeMath.sub(researchShare,referalDivs); } function snapshotDailyGooResearchFunding() external onlyAdmin { uint256 todaysGooResearchFund = (totalEtherPool[1] * researchDivPercent) / 100; totalEtherPool[1] -= todaysGooResearchFund; totalJadeProductionSnapshots.push(totalJadeProduction); allocatedJadeResearchSnapshots.push(todaysGooResearchFund); nextSnapshotTime = block.timestamp + 24 hours; } } interface GameConfigInterface { function productionCardIdRange() external constant returns (uint256, uint256); function battleCardIdRange() external constant returns (uint256, uint256); function upgradeIdRange() external constant returns (uint256, uint256); function unitCoinProduction(uint256 cardId) external constant returns (uint256); function unitAttack(uint256 cardId) external constant returns (uint256); function unitDefense(uint256 cardId) external constant returns (uint256); function unitStealingCapacity(uint256 cardId) external constant returns (uint256); } contract CardsBase is JadeCoin { function CardsBase() public { setAdminContract(msg.sender,true); setActionContract(msg.sender,true); } struct Player { address owneraddress; } Player[] players; bool gameStarted; GameConfigInterface public schema; mapping(address => mapping(uint256 => uint256)) public unitsOwned; mapping(address => mapping(uint256 => uint256)) public upgradesOwned; mapping(address => uint256) public uintsOwnerCount; mapping(address=> mapping(uint256 => uint256)) public uintProduction; mapping(address => mapping(uint256 => uint256)) public unitCoinProductionIncreases; mapping(address => mapping(uint256 => uint256)) public unitCoinProductionMultiplier; mapping(address => mapping(uint256 => uint256)) public unitAttackIncreases; mapping(address => mapping(uint256 => uint256)) public unitAttackMultiplier; mapping(address => mapping(uint256 => uint256)) public unitDefenseIncreases; mapping(address => mapping(uint256 => uint256)) public unitDefenseMultiplier; mapping(address => mapping(uint256 => uint256)) public unitJadeStealingIncreases; mapping(address => mapping(uint256 => uint256)) public unitJadeStealingMultiplier; mapping(address => mapping(uint256 => uint256)) private unitMaxCap; function setConfigAddress(address _address) external onlyOwner { schema = GameConfigInterface(_address); } function beginGame(uint256 firstDivsTime) external payable onlyOwner { require(!gameStarted); gameStarted = true; nextSnapshotTime = firstDivsTime; totalEtherPool[1] = msg.value; } function endGame() external payable onlyOwner { require(gameStarted); gameStarted = false; } function getGameStarted() external constant returns (bool) { return gameStarted; } function AddPlayers(address _address) external onlyAccess { Player memory _player= Player({ owneraddress: _address }); players.push(_player); } function getRanking() external view returns (address[], uint256[],uint256[]) { uint256 len = players.length; uint256[] memory arr = new uint256[](len); address[] memory arr_addr = new address[](len); uint256[] memory arr_def = new uint256[](len); uint counter =0; for (uint k=0;k<len; k++){ arr[counter] = getJadeProduction(players[k].owneraddress); arr_addr[counter] = players[k].owneraddress; (,arr_def[counter],,) = getPlayersBattleStats(players[k].owneraddress); counter++; } for(uint i=0;i<len-1;i++) { for(uint j=0;j<len-i-1;j++) { if(arr[j]<arr[j+1]) { uint256 temp = arr[j]; address temp_addr = arr_addr[j]; uint256 temp_def = arr_def[j]; arr[j] = arr[j+1]; arr[j+1] = temp; arr_addr[j] = arr_addr[j+1]; arr_addr[j+1] = temp_addr; arr_def[j] = arr_def[j+1]; arr_def[j+1] = temp_def; } } } return (arr_addr,arr,arr_def); } function getTotalUsers() external view returns (uint256) { return players.length; } function getMaxCap(address _addr,uint256 _cardId) external view returns (uint256) { return unitMaxCap[_addr][_cardId]; } function getUnitsProduction(address player, uint256 unitId, uint256 amount) external constant returns (uint256) { return (amount * (schema.unitCoinProduction(unitId) + unitCoinProductionIncreases[player][unitId]) * (10 + unitCoinProductionMultiplier[player][unitId])); } function getUnitsInProduction(address player, uint256 unitId, uint256 amount) external constant returns (uint256) { return SafeMath.div(SafeMath.mul(amount,uintProduction[player][unitId]),unitsOwned[player][unitId]); } function getUnitsAttack(address player, uint256 unitId, uint256 amount) internal constant returns (uint256) { return (amount * (schema.unitAttack(unitId) + unitAttackIncreases[player][unitId]) * (10 + unitAttackMultiplier[player][unitId])) / 10; } function getUnitsDefense(address player, uint256 unitId, uint256 amount) internal constant returns (uint256) { return (amount * (schema.unitDefense(unitId) + unitDefenseIncreases[player][unitId]) * (10 + unitDefenseMultiplier[player][unitId])) / 10; } function getUnitsStealingCapacity(address player, uint256 unitId, uint256 amount) internal constant returns (uint256) { return (amount * (schema.unitStealingCapacity(unitId) + unitJadeStealingIncreases[player][unitId]) * (10 + unitJadeStealingMultiplier[player][unitId])) / 10; } function getPlayersBattleStats(address player) public constant returns ( uint256 attackingPower, uint256 defendingPower, uint256 stealingPower, uint256 battlePower) { uint256 startId; uint256 endId; (startId, endId) = schema.battleCardIdRange(); while (startId <= endId) { attackingPower = SafeMath.add(attackingPower,getUnitsAttack(player, startId, unitsOwned[player][startId])); stealingPower = SafeMath.add(stealingPower,getUnitsStealingCapacity(player, startId, unitsOwned[player][startId])); defendingPower = SafeMath.add(defendingPower,getUnitsDefense(player, startId, unitsOwned[player][startId])); battlePower = SafeMath.add(attackingPower,defendingPower); startId++; } } function getOwnedCount(address player, uint256 cardId) external view returns (uint256) { return unitsOwned[player][cardId]; } function setOwnedCount(address player, uint256 cardId, uint256 amount, bool iflag) external onlyAccess { if (iflag) { unitsOwned[player][cardId] = SafeMath.add(unitsOwned[player][cardId],amount); } else if (!iflag) { unitsOwned[player][cardId] = SafeMath.sub(unitsOwned[player][cardId],amount); } } function getUpgradesOwned(address player, uint256 upgradeId) external view returns (uint256) { return upgradesOwned[player][upgradeId]; } function setUpgradesOwned(address player, uint256 upgradeId) external onlyAccess { upgradesOwned[player][upgradeId] = SafeMath.add(upgradesOwned[player][upgradeId],1); } function getUintsOwnerCount(address _address) external view returns (uint256) { return uintsOwnerCount[_address]; } function setUintsOwnerCount(address _address, uint256 amount, bool iflag) external onlyAccess { if (iflag) { uintsOwnerCount[_address] = SafeMath.add(uintsOwnerCount[_address],amount); } else if (!iflag) { uintsOwnerCount[_address] = SafeMath.sub(uintsOwnerCount[_address],amount); } } function getUnitCoinProductionIncreases(address _address, uint256 cardId) external view returns (uint256) { return unitCoinProductionIncreases[_address][cardId]; } function setUnitCoinProductionIncreases(address _address, uint256 cardId, uint256 iValue,bool iflag) external onlyAccess { if (iflag) { unitCoinProductionIncreases[_address][cardId] = SafeMath.add(unitCoinProductionIncreases[_address][cardId],iValue); } else if (!iflag) { unitCoinProductionIncreases[_address][cardId] = SafeMath.sub(unitCoinProductionIncreases[_address][cardId],iValue); } } function getUnitCoinProductionMultiplier(address _address, uint256 cardId) external view returns (uint256) { return unitCoinProductionMultiplier[_address][cardId]; } function setUnitCoinProductionMultiplier(address _address, uint256 cardId, uint256 iValue, bool iflag) external onlyAccess { if (iflag) { unitCoinProductionMultiplier[_address][cardId] = SafeMath.add(unitCoinProductionMultiplier[_address][cardId],iValue); } else if (!iflag) { unitCoinProductionMultiplier[_address][cardId] = SafeMath.sub(unitCoinProductionMultiplier[_address][cardId],iValue); } } function setUnitAttackIncreases(address _address, uint256 cardId, uint256 iValue,bool iflag) external onlyAccess { if (iflag) { unitAttackIncreases[_address][cardId] = SafeMath.add(unitAttackIncreases[_address][cardId],iValue); } else if (!iflag) { unitAttackIncreases[_address][cardId] = SafeMath.sub(unitAttackIncreases[_address][cardId],iValue); } } function getUnitAttackIncreases(address _address, uint256 cardId) external view returns (uint256) { return unitAttackIncreases[_address][cardId]; } function setUnitAttackMultiplier(address _address, uint256 cardId, uint256 iValue,bool iflag) external onlyAccess { if (iflag) { unitAttackMultiplier[_address][cardId] = SafeMath.add(unitAttackMultiplier[_address][cardId],iValue); } else if (!iflag) { unitAttackMultiplier[_address][cardId] = SafeMath.sub(unitAttackMultiplier[_address][cardId],iValue); } } function getUnitAttackMultiplier(address _address, uint256 cardId) external view returns (uint256) { return unitAttackMultiplier[_address][cardId]; } function setUnitDefenseIncreases(address _address, uint256 cardId, uint256 iValue,bool iflag) external onlyAccess { if (iflag) { unitDefenseIncreases[_address][cardId] = SafeMath.add(unitDefenseIncreases[_address][cardId],iValue); } else if (!iflag) { unitDefenseIncreases[_address][cardId] = SafeMath.sub(unitDefenseIncreases[_address][cardId],iValue); } } function getUnitDefenseIncreases(address _address, uint256 cardId) external view returns (uint256) { return unitDefenseIncreases[_address][cardId]; } function setunitDefenseMultiplier(address _address, uint256 cardId, uint256 iValue,bool iflag) external onlyAccess { if (iflag) { unitDefenseMultiplier[_address][cardId] = SafeMath.add(unitDefenseMultiplier[_address][cardId],iValue); } else if (!iflag) { unitDefenseMultiplier[_address][cardId] = SafeMath.sub(unitDefenseMultiplier[_address][cardId],iValue); } } function getUnitDefenseMultiplier(address _address, uint256 cardId) external view returns (uint256) { return unitDefenseMultiplier[_address][cardId]; } function setUnitJadeStealingIncreases(address _address, uint256 cardId, uint256 iValue,bool iflag) external onlyAccess { if (iflag) { unitJadeStealingIncreases[_address][cardId] = SafeMath.add(unitJadeStealingIncreases[_address][cardId],iValue); } else if (!iflag) { unitJadeStealingIncreases[_address][cardId] = SafeMath.sub(unitJadeStealingIncreases[_address][cardId],iValue); } } function getUnitJadeStealingIncreases(address _address, uint256 cardId) external view returns (uint256) { return unitJadeStealingIncreases[_address][cardId]; } function setUnitJadeStealingMultiplier(address _address, uint256 cardId, uint256 iValue,bool iflag) external onlyAccess { if (iflag) { unitJadeStealingMultiplier[_address][cardId] = SafeMath.add(unitJadeStealingMultiplier[_address][cardId],iValue); } else if (!iflag) { unitJadeStealingMultiplier[_address][cardId] = SafeMath.sub(unitJadeStealingMultiplier[_address][cardId],iValue); } } function getUnitJadeStealingMultiplier(address _address, uint256 cardId) external view returns (uint256) { return unitJadeStealingMultiplier[_address][cardId]; } function setUintCoinProduction(address _address, uint256 cardId, uint256 iValue, bool iflag) external onlyAccess { if (iflag) { uintProduction[_address][cardId] = SafeMath.add(uintProduction[_address][cardId],iValue); } else if (!iflag) { uintProduction[_address][cardId] = SafeMath.sub(uintProduction[_address][cardId],iValue); } } function getUintCoinProduction(address _address, uint256 cardId) external view returns (uint256) { return uintProduction[_address][cardId]; } function upgradeUnitMultipliers(address player, uint256 upgradeClass, uint256 unitId, uint256 upgradeValue) external onlyAccess { uint256 productionGain; if (upgradeClass == 0) { unitCoinProductionIncreases[player][unitId] += upgradeValue; productionGain = unitsOwned[player][unitId] * upgradeValue * (10 + unitCoinProductionMultiplier[player][unitId]); increasePlayersJadeProduction(player, productionGain); } else if (upgradeClass == 1) { unitCoinProductionMultiplier[player][unitId] += upgradeValue; productionGain = unitsOwned[player][unitId] * upgradeValue * (schema.unitCoinProduction(unitId) + unitCoinProductionIncreases[player][unitId]); increasePlayersJadeProduction(player, productionGain); } else if (upgradeClass == 2) { unitAttackIncreases[player][unitId] += upgradeValue; } else if (upgradeClass == 3) { unitAttackMultiplier[player][unitId] += upgradeValue; } else if (upgradeClass == 4) { unitDefenseIncreases[player][unitId] += upgradeValue; } else if (upgradeClass == 5) { unitDefenseMultiplier[player][unitId] += upgradeValue; } else if (upgradeClass == 6) { unitJadeStealingIncreases[player][unitId] += upgradeValue; } else if (upgradeClass == 7) { unitJadeStealingMultiplier[player][unitId] += upgradeValue; } else if (upgradeClass == 8) { unitMaxCap[player][unitId] = upgradeValue; } } function removeUnitMultipliers(address player, uint256 upgradeClass, uint256 unitId, uint256 upgradeValue) external onlyAccess { uint256 productionLoss; if (upgradeClass == 0) { unitCoinProductionIncreases[player][unitId] -= upgradeValue; productionLoss = unitsOwned[player][unitId] * upgradeValue * (10 + unitCoinProductionMultiplier[player][unitId]); reducePlayersJadeProduction(player, productionLoss); } else if (upgradeClass == 1) { unitCoinProductionMultiplier[player][unitId] -= upgradeValue; productionLoss = unitsOwned[player][unitId] * upgradeValue * (schema.unitCoinProduction(unitId) + unitCoinProductionIncreases[player][unitId]); reducePlayersJadeProduction(player, productionLoss); } else if (upgradeClass == 2) { unitAttackIncreases[player][unitId] -= upgradeValue; } else if (upgradeClass == 3) { unitAttackMultiplier[player][unitId] -= upgradeValue; } else if (upgradeClass == 4) { unitDefenseIncreases[player][unitId] -= upgradeValue; } else if (upgradeClass == 5) { unitDefenseMultiplier[player][unitId] -= upgradeValue; } else if (upgradeClass == 6) { unitJadeStealingIncreases[player][unitId] -= upgradeValue; } else if (upgradeClass == 7) { unitJadeStealingMultiplier[player][unitId] -= upgradeValue; } } } 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.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 = 0x85aFf53CFfB393D8fCD4FB5b8bb6ce9e482A7054; } 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.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; } } pragma solidity ^0.4.18; contract ARTIDDigitalSign is Ownable{ mapping(bytes32 => Version[]) digitalCertificateArchive; struct Version { uint8 version; bytes32 sign; uint256 timestamp; } function Sign(string guid, string hash) public onlyWhitelisted { address _signer = msg.sender; string memory addressString = toString(_signer); string memory concatenatedData = strConcat(addressString,guid); bytes32 hashed = keccak256(concatenatedData); uint8 version = 1; Version[] memory versions = digitalCertificateArchive[hashed]; uint length = versions.length; for(uint8 i = 0; i < length; i++) { version = i+2; } bytes32 hashedSign = keccak256(hash); Version memory v = Version(version,hashedSign,now); digitalCertificateArchive[hashed].push(v); } function GetSign(string guid, address signer) public view returns(bytes32 sign, uint8 signedVersion,uint256 timestamp){ address _signer = signer; string memory addressString = toString(_signer); string memory concatenatedData = strConcat(addressString,guid); bytes32 hashed = keccak256(concatenatedData); uint length = digitalCertificateArchive[hashed].length; Version memory v = digitalCertificateArchive[hashed][length-1]; return (v.sign, v.version, v.timestamp); } function GetSignVersion(string guid, address signer, uint version) public view returns(bytes32 sign, uint8 signedVersion,uint256 timestamp){ address _signer = signer; string memory addressString = toString(_signer); string memory concatenatedData = strConcat(addressString,guid); bytes32 hashed = keccak256(concatenatedData); Version memory v = digitalCertificateArchive[hashed][version-1]; return (v.sign, v.version, v.timestamp); } function strConcat(string _a, string _b, string _c, string _d, string _e) internal returns (string){ bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function strConcat(string _a, string _b, string _c, string _d) internal returns (string) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string _a, string _b, string _c) internal returns (string) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string _a, string _b) internal returns (string) { return strConcat(_a, _b, "", "", ""); } function toString(address x) returns (string) { bytes memory b = new bytes(20); for (uint i = 0; i < 20; i++) b[i] = byte(uint8(uint(x) / (2**(8*(19 - i))))); return string(b); } function bytes32ToString(bytes32 x) constant returns (string) { bytes memory bytesString = new bytes(32); uint charCount = 0; for (uint j = 0; j < 32; j++) { byte char = byte(bytes32(uint(x) * 2 ** (8 * j))); if (char != 0) { bytesString[charCount] = char; charCount++; } } bytes memory bytesStringTrimmed = new bytes(charCount); for (j = 0; j < charCount; j++) { bytesStringTrimmed[j] = bytesString[j]; } return string(bytesStringTrimmed); } mapping (address => bool) whitelist; event WhitelistedAddressAdded(address addr); event WhitelistedAddressRemoved(address addr); modifier onlyWhitelisted() { whitelist[msg.sender] == true; _; } function addAddressToWhitelist(address addr) onlyOwner public { whitelist[addr] = true; emit WhitelistedAddressAdded(addr); } function isInWhitelist(address addr) public view returns (bool) { return whitelist[addr] == true; } function addAddressesToWhitelist(address[] addrs) onlyOwner public { for (uint256 i = 0; i < addrs.length; i++) { addAddressToWhitelist(addrs[i]); } } function removeAddressFromWhitelist(address addr) onlyOwner public { whitelist[addr] = false; emit WhitelistedAddressRemoved(addr); } function removeAddressesFromWhitelist(address[] addrs) onlyOwner public { for (uint256 i = 0; i < addrs.length; i++) { removeAddressFromWhitelist(addrs[i]); } } }
1
pragma solidity ^0.4.11; 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); modifier onlyOwner() { require(msg.sender == owner); _; } function Ownable() { owner = msg.sender; } function transferOwnership(address newOwner) onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { bool public paused = false; event Pause(); event Unpause(); modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused { paused = true; Pause(); } function unpause() onlyOwner whenPaused { paused = false; Unpause(); } } contract ERC20 { uint256 public totalSupply; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function balanceOf(address who) constant returns (uint256); function transfer(address to, uint256 value) returns (bool); function transferFrom(address from, address to, uint256 value) returns (bool); function allowance(address owner, address spender) constant returns (uint256); function approve(address spender, uint256 value) returns (bool); } contract StandardToken is ERC20 { using SafeMath for uint256; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; function balanceOf(address _owner) constant returns(uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) returns(bool success) { 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 transferFrom(address _from, address _to, uint256 _value) returns(bool success) { 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); return true; } function allowance(address _owner, address _spender) constant returns(uint256 remaining) { return allowed[_owner][_spender]; } function approve(address _spender, uint256 _value) returns(bool success) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } 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 BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { require(_value > 0); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); } } contract ALTToken is BurnableToken, Ownable { string public name = "Altyn Token"; string public symbol = "ALT"; uint256 public decimals = 18; uint256 public INITIAL_SUPPLY = 100000000 * 1 ether; function ALTToken() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } } contract ALTCrowdsale is Pausable { using SafeMath for uint; struct Step { uint priceUSD; uint amountTokens; } ALTToken public token; address public beneficiary = 0x9df0be686E12ccdbE46D4177442878bf8636E89f; uint public collected; uint public collectedUSD; uint public tokensSold; uint public maxTokensSold = 22000000 * 1 ether; uint public priceETH = 300; uint public softCapUSD = 300000; uint public softCap = softCapUSD / priceETH * 1 ether; uint public hardCapUSD = 5500000; uint public hardCap = hardCapUSD / priceETH * 1 ether; Step[] steps; uint public startTime = 1508225824; uint public endTime = startTime + 45 days; bool public crowdsaleFinished = false; event SoftCapReached(uint256 etherAmount); event HardCapReached(uint256 etherAmount); event NewContribution(address indexed holder, uint256 tokenAmount, uint256 etherAmount); event Withdraw(); modifier onlyAfter(uint time) { require(now > time); _; } modifier onlyBefore(uint time) { require(now < time); _; } function ALTCrowdsale() { token = new ALTToken(); steps.push(Step(15, 2000000)); steps.push(Step(20, 5000000)); steps.push(Step(25, 15000000)); steps.push(Step(30, 22000000)); } function() payable { purchase(); } function purchase() onlyAfter(startTime) onlyBefore(endTime) whenNotPaused payable { require(!crowdsaleFinished); require(msg.value >= 0.001 * 1 ether && msg.value <= 10000 * 1 ether); require(tokensSold < maxTokensSold); uint amount = 0; uint sum = 0; for(uint i = 0; i < steps.length; i++) { if(tokensSold.add(amount) < steps[i].amountTokens * 1 ether) { uint avail = (steps[i].amountTokens * 1 ether) - tokensSold.add(amount); uint nece = (msg.value - sum) * priceETH / steps[i].priceUSD * 100; uint buy = nece; if(buy > avail) buy = avail; amount += buy; sum += buy / (priceETH / steps[i].priceUSD * 100); if(buy == nece) break; } } require(tokensSold.add(amount) <= maxTokensSold); if(collected < softCap && collected.add(sum) >= softCap) { SoftCapReached(collected.add(sum)); } collected = collected.add(sum); collectedUSD = collected * priceETH / 1 ether; tokensSold = tokensSold.add(amount); require(token.transfer(msg.sender, amount)); if(sum < msg.value) require(msg.sender.send(msg.value - sum)); NewContribution(msg.sender, amount, sum); if(collected >= hardCap) { HardCapReached(collected); } } function withdraw() onlyOwner { require(!crowdsaleFinished); beneficiary.transfer(collected); if(tokensSold < maxTokensSold) token.burn(maxTokensSold - tokensSold); token.transfer(beneficiary, token.balanceOf(this)); token.transferOwnership(beneficiary); crowdsaleFinished = true; Withdraw(); } }
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 FoMo3DshortAgain 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 Short Again"; string constant public symbol = "SHORT_AGAIN"; uint256 private rndExtra_ = 30 minutes; uint256 private rndGap_ = 30 minutes; uint256 constant private rndInit_ = 30 minutes; uint256 constant private rndInc_ = 10 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
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
41
Edit dataset card