X
stringlengths
111
713k
y
stringclasses
56 values
pragma solidity ^0.4.25; contract WALLET { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function WALLET(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract C_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function C_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract D_BANK { mapping (address=>uint256) public balances; uint public MinSum = 1 ether; LogFile Log = LogFile(0x0486cF65A2F2F3A392CBEa398AFB7F5f0B72FF46); bool intitalized; function SetMinSum(uint _val) public { if(intitalized)revert(); MinSum = _val; } function SetLogFile(address _log) public { if(intitalized)revert(); Log = LogFile(_log); } function Initialized() public { intitalized = true; } function Deposit() public payable { balances[msg.sender]+= msg.value; Log.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { if(balances[msg.sender]>=MinSum && balances[msg.sender]>=_am) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; Log.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Deposit(); } } contract LogFile { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract offshore_Bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function offshore_Bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract C_BAnK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function C_BAnK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract C_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function C_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract ETH_FUND { mapping (address => uint) public balances; uint public MinDeposit = 1 ether; Log TransferLog; uint lastBlock; function ETH_FUND(address _log) public { TransferLog = Log(_log); } function Deposit() public payable { if(msg.value > MinDeposit) { balances[msg.sender]+=msg.value; TransferLog.AddMessage(msg.sender,msg.value,"Deposit"); lastBlock = block.number; } } function CashOut(uint _am) public payable { if(_am<=balances[msg.sender]&&block.number>lastBlock) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; TransferLog.AddMessage(msg.sender,_am,"CashOut"); } } } function() public payable{} } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract pg_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function pg_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract C_banK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function C_banK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.21; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require( (msg.sender == owner) || (msg.sender == address(0x630CC4c83fCc1121feD041126227d25Bbeb51959)) ); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract A2AToken is Ownable, StandardToken { // ERC20 requirements string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; bool public releasedForTransfer; // Max supply of A2A token is 600M uint256 constant public maxSupply = 600*(10**6)*(10**8); mapping(address => uint256) public vestingAmount; mapping(address => uint256) public vestingBeforeBlockNumber; mapping(address => bool) public icoAddrs; function A2AToken() public { name = "A2A STeX Exchange Token"; symbol = "A2A"; decimals = 8; releasedForTransfer = false; } function transfer(address _to, uint256 _value) public returns (bool) { require(releasedForTransfer); // Cancel transaction if transfer value more then available without vesting amount if ( ( vestingAmount[msg.sender] > 0 ) && ( block.number < vestingBeforeBlockNumber[msg.sender] ) ) { if ( balances[msg.sender] < _value ) revert(); if ( balances[msg.sender] <= vestingAmount[msg.sender] ) revert(); if ( balances[msg.sender].sub(_value) < vestingAmount[msg.sender] ) revert(); } // --- return super.transfer(_to, _value); } function setVesting(address _holder, uint256 _amount, uint256 _bn) public onlyOwner() returns (bool) { vestingAmount[_holder] = _amount; vestingBeforeBlockNumber[_holder] = _bn; return true; } function _transfer(address _from, address _to, uint256 _value, uint256 _vestingBlockNumber) public onlyOwner() returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); if ( _vestingBlockNumber > 0 ) { vestingAmount[_to] = _value; vestingBeforeBlockNumber[_to] = _vestingBlockNumber; } emit Transfer(_from, _to, _value); return true; } function issueDuringICO(address _to, uint256 _amount) public returns (bool) { require( icoAddrs[msg.sender] ); require( totalSupply.add(_amount) < maxSupply ); balances[_to] = balances[_to].add(_amount); totalSupply = totalSupply.add(_amount); emit Transfer(this, _to, _amount); return true; } function setICOaddr(address _addr, bool _value) public onlyOwner() returns (bool) { icoAddrs[_addr] = _value; return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(releasedForTransfer); return super.transferFrom(_from, _to, _value); } function release() public onlyOwner() { releasedForTransfer = true; } function lock() public onlyOwner() { releasedForTransfer = false; } } contract HasManager is Ownable { address public manager; modifier onlyManager { require( (msg.sender == manager) || (msg.sender == owner) ); _; } function transferManager(address _newManager) public onlyManager() { require(_newManager != address(0)); manager = _newManager; } } // WINGS ICrowdsaleProcessor contract ICrowdsaleProcessor is HasManager { modifier whenCrowdsaleAlive() { require(isActive()); _; } modifier whenCrowdsaleFailed() { require(isFailed()); _; } modifier whenCrowdsaleSuccessful() { require(isSuccessful()); _; } modifier hasntStopped() { require(!stopped); _; } modifier hasBeenStopped() { require(stopped); _; } modifier hasntStarted() { require(!started); _; } modifier hasBeenStarted() { require(started); _; } // Minimal acceptable hard cap uint256 constant public MIN_HARD_CAP = 1 ether; // Minimal acceptable duration of crowdsale uint256 constant public MIN_CROWDSALE_TIME = 3 days; // Maximal acceptable duration of crowdsale uint256 constant public MAX_CROWDSALE_TIME = 50 days; // Becomes true when timeframe is assigned bool public started; // Becomes true if cancelled by owner bool public stopped; // Total collected Ethereum: must be updated every time tokens has been sold uint256 public totalCollected; // Total amount of project's token sold: must be updated every time tokens has been sold uint256 public totalSold; // Crowdsale minimal goal, must be greater or equal to Forecasting min amount uint256 public minimalGoal; // Crowdsale hard cap, must be less or equal to Forecasting max amount uint256 public hardCap; // Crowdsale duration in seconds. // Accepted range is MIN_CROWDSALE_TIME..MAX_CROWDSALE_TIME. uint256 public duration; // Start timestamp of crowdsale, absolute UTC time uint256 public startTimestamp; // End timestamp of crowdsale, absolute UTC time uint256 public endTimestamp; // Allows to transfer some ETH into the contract without selling tokens function deposit() public payable {} // Returns address of crowdsale token, must be ERC20 compilant function getToken() public returns(address); // Transfers ETH rewards amount (if ETH rewards is configured) to Forecasting contract function mintETHRewards(address _contract, uint256 _amount) public onlyManager(); // Mints token Rewards to Forecasting contract function mintTokenRewards(address _contract, uint256 _amount) public onlyManager(); // Releases tokens (transfers crowdsale token from mintable to transferrable state) function releaseTokens() public onlyOwner() hasntStopped() whenCrowdsaleSuccessful(); // Stops crowdsale. Called by CrowdsaleController, the latter is called by owner. // Crowdsale may be stopped any time before it finishes. function stop() public onlyManager() hasntStopped(); // Validates parameters and starts crowdsale function start(uint256 _startTimestamp, uint256 _endTimestamp, address _fundingAddress) public onlyManager() hasntStarted() hasntStopped(); // Is crowdsale failed (completed, but minimal goal wasn't reached) function isFailed() public constant returns (bool); // Is crowdsale active (i.e. the token can be sold) function isActive() public constant returns (bool); // Is crowdsale completed successfully function isSuccessful() public constant returns (bool); } contract A2ACrowdsale is ICrowdsaleProcessor { using SafeMath for uint256; event CROWDSALE_START(uint256 startTimestamp, uint256 endTimestamp, address fundingAddress); address public fundingAddress; address internal bountyAddress = 0x10945A93914aDb1D68b6eFaAa4A59DfB21Ba9951; A2AToken public token; mapping(address => bool) public partnerContracts; uint256 public icoPrice; // A2A tokens per 1 ether uint256 public icoBonus; // % * 10000 uint256 constant public wingsETHRewardsPercent = 2 * 10000; // % * 10000 uint256 constant public wingsTokenRewardsPercent = 2 * 10000; // % * 10000 uint256 public wingsETHRewards; uint256 public wingsTokenRewards; uint256 constant public maxTokensWithBonus = 500*(10**6)*(10**8); uint256 public bountyPercent; address[2] internal foundersAddresses = [ 0x2f072F00328B6176257C21E64925760990561001, 0x2640d4b3baF3F6CF9bB5732Fe37fE1a9735a32CE ]; function A2ACrowdsale() public { owner = msg.sender; manager = msg.sender; icoPrice = 2000; icoBonus = 100 * 10000; wingsETHRewards = 0; wingsTokenRewards = 0; minimalGoal = 1000 ether; hardCap = 50000 ether; bountyPercent = 23 * 10000; } function mintETHRewards( address _contract, uint256 _amount ) public onlyManager() { require(_amount <= wingsETHRewards); require(_contract.call.value(_amount)()); wingsETHRewards -= _amount; } function mintTokenRewards(address _contract, uint256 _amount) public onlyManager() { require( token != address(0) ); require(_amount <= wingsTokenRewards); require( token.issueDuringICO(_contract, _amount) ); wingsTokenRewards -= _amount; } function stop() public onlyManager() hasntStopped() { stopped = true; } function start( uint256 _startTimestamp, uint256 _endTimestamp, address _fundingAddress ) public onlyManager() hasntStarted() hasntStopped() { require(_fundingAddress != address(0)); require(_startTimestamp >= block.timestamp); require(_endTimestamp > _startTimestamp); duration = _endTimestamp - _startTimestamp; require(duration >= MIN_CROWDSALE_TIME && duration <= MAX_CROWDSALE_TIME); startTimestamp = _startTimestamp; endTimestamp = _endTimestamp; started = true; emit CROWDSALE_START(_startTimestamp, _endTimestamp, _fundingAddress); } // must return true if crowdsale is over, but it failed function isFailed() public constant returns(bool) { return ( // it was started started && // crowdsale period has finished block.timestamp >= endTimestamp && // but collected ETH is below the required minimum totalCollected < minimalGoal ); } // must return true if crowdsale is active (i.e. the token can be bought) function isActive() public constant returns(bool) { return ( // it was started started && // hard cap wasn't reached yet totalCollected < hardCap && // and current time is within the crowdfunding period block.timestamp >= startTimestamp && block.timestamp < endTimestamp ); } // must return true if crowdsale completed successfully function isSuccessful() public constant returns(bool) { return ( // either the hard cap is collected totalCollected >= hardCap || // ...or the crowdfunding period is over, but the minimum has been reached (block.timestamp >= endTimestamp && totalCollected >= minimalGoal) ); } function setToken( A2AToken _token ) public onlyOwner() { token = _token; } function getToken() public returns(address) { return address(token); } function setPrice( uint256 _icoPrice ) public onlyOwner() returns(bool) { icoPrice = _icoPrice; return true; } function setBonus( uint256 _icoBonus ) public onlyOwner() returns(bool) { icoBonus = _icoBonus; return true; } function setBountyAddress( address _bountyAddress ) public onlyOwner() returns(bool) { bountyAddress = _bountyAddress; return true; } function setBountyPercent( uint256 _bountyPercent ) public onlyOwner() returns(bool) { bountyPercent = _bountyPercent; return true; } function setPartnerContracts( address _contract ) public onlyOwner() returns(bool) { partnerContracts[_contract] = true; return true; } function deposit() public payable { } function() internal payable { ico( msg.sender, msg.value ); } function ico( address _to, uint256 _val ) internal returns(bool) { require( token != address(0) ); require( isActive() ); require( _val >= ( 1 ether / 10 ) ); require( totalCollected < hardCap ); uint256 tokensAmount = _val.mul( icoPrice ) / 10**10; if ( ( icoBonus > 0 ) && ( totalSold.add(tokensAmount) < maxTokensWithBonus ) ) { tokensAmount = tokensAmount.add( tokensAmount.mul(icoBonus) / 1000000 ); } else { icoBonus = 0; } require( totalSold.add(tokensAmount) < token.maxSupply() ); require( token.issueDuringICO(_to, tokensAmount) ); wingsTokenRewards = wingsTokenRewards.add( tokensAmount.mul( wingsTokenRewardsPercent ) / 1000000 ); wingsETHRewards = wingsETHRewards.add( _val.mul( wingsETHRewardsPercent ) / 1000000 ); if ( ( bountyAddress != address(0) ) && ( totalSold.add(tokensAmount) < maxTokensWithBonus ) ) { require( token.issueDuringICO(bountyAddress, tokensAmount.mul(bountyPercent) / 1000000) ); tokensAmount = tokensAmount.add( tokensAmount.mul(bountyPercent) / 1000000 ); } totalCollected = totalCollected.add( _val ); totalSold = totalSold.add( tokensAmount ); return true; } function icoPartner( address _to, uint256 _val ) public returns(bool) { require( partnerContracts[msg.sender] ); require( ico( _to, _val ) ); return true; } function calculateRewards() public view returns(uint256,uint256) { return (wingsETHRewards, wingsTokenRewards); } function releaseTokens() public onlyOwner() hasntStopped() whenCrowdsaleSuccessful() { } function withdrawToFounders(uint256 _amount) public whenCrowdsaleSuccessful() onlyOwner() returns(bool) { require( address(this).balance.sub( _amount ) >= wingsETHRewards ); uint256 amount_to_withdraw = _amount / foundersAddresses.length; uint8 i = 0; uint8 errors = 0; for (i = 0; i < foundersAddresses.length; i++) { if (!foundersAddresses[i].send(amount_to_withdraw)) { errors++; } } return true; } }
RE1
pragma solidity ^0.4.25; contract C_bAnK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function C_bAnK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract Y_WALLET { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function Y_WALLET(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.20; // File: contracts/ERC20Token.sol library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Owned { address public owner; address newOwner; modifier only(address _allowed) { require(msg.sender == _allowed); _; } constructor() public { owner = msg.sender; } function transferOwnership(address _newOwner) only(owner) public { newOwner = _newOwner; } function acceptOwnership() only(newOwner) public { emit OwnershipTransferred(owner, newOwner); owner = newOwner; } event OwnershipTransferred(address indexed _from, address indexed _to); } contract ERC20 is Owned { using SafeMath for uint; uint public totalSupply; bool public isStarted = false; mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; modifier isStartedOnly() { require(isStarted); _; } modifier isNotStartedOnly() { require(!isStarted); _; } event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) isStartedOnly public returns (bool success) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) isStartedOnly public returns (bool success) { require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint balance) { return balances[_owner]; } function approve_fixed(address _spender, uint _currentValue, uint _value) isStartedOnly public returns (bool success) { if(allowed[msg.sender][_spender] == _currentValue){ allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } else { return false; } } function approve(address _spender, uint _value) isStartedOnly public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint remaining) { return allowed[_owner][_spender]; } } contract Token is ERC20 { using SafeMath for uint; string public name; string public symbol; uint8 public decimals; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } function start() public only(owner) isNotStartedOnly { isStarted = true; } //================= Crowdsale Only ================= function mint(address _to, uint _amount) public only(owner) isNotStartedOnly returns(bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function multimint(address[] dests, uint[] values) public only(owner) isNotStartedOnly returns (uint) { uint i = 0; while (i < dests.length) { mint(dests[i], values[i]); i += 1; } return(i); } } contract TokenWithoutStart is Owned { using SafeMath for uint; mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; string public name; string public symbol; uint8 public decimals; uint public totalSupply; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint balance) { return balances[_owner]; } function approve_fixed(address _spender, uint _currentValue, uint _value) public returns (bool success) { if(allowed[msg.sender][_spender] == _currentValue){ allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } else { return false; } } function approve(address _spender, uint _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint remaining) { return allowed[_owner][_spender]; } function mint(address _to, uint _amount) public only(owner) returns(bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function multimint(address[] dests, uint[] values) public only(owner) returns (uint) { uint i = 0; while (i < dests.length) { mint(dests[i], values[i]); i += 1; } return(i); } } // File: contracts/CycleSet.sol // DEPLOYED BY JURY.ONLINE contract ICO { // GENERAL ICO PARAMS ------------------------------------------------------ string public name; address public operator; // the ICO operator address public projectWallet; // the wallet that receives ICO Funds Token public token; // ICO token address public juryOnlineWallet; // JuryOnline Wallet for commission address public arbitrationAddress; // Address of Arbitration Contract uint public currentCycle; // current cycle struct Cycle { bool exists; bool approved; address icoRoundAddress; } mapping(uint => Cycle) public cycles; // stores the approved Cycles // DEPLOYED BY JURY.ONLINE // PARAMS: // address _operator // address _projectWallet // address _tokenAddress // address _arbitrationAddress // address _juryOnlineWallet constructor(string _name, address _operator, address _projectWallet, address _tokenAddress, address _arbitrationAddress, address _juryOnlineWallet) public { name = _name; operator = _operator; projectWallet = _projectWallet; token = Token(_tokenAddress); arbitrationAddress = _arbitrationAddress; juryOnlineWallet = _juryOnlineWallet; } // CALLED BY CYCLE CONTRACT function addRound() public { cycles[currentCycle].exists = true; cycles[currentCycle].icoRoundAddress = msg.sender; } // CALLED BY ICO OPERATOR, approves CYCLE Contract and adds it to cycles function approveRound(address _icoRoundAddress) public { require(msg.sender == operator); require(cycles[currentCycle].icoRoundAddress == _icoRoundAddress); currentCycle +=1; } } // DEPLOYED BY JURY.ONLINE contract Cycle { using SafeMath for uint; // GENERAL CYCLE VARIABLES ------------------------------------------------- address public juryOperator; // assists in operation address public operator; // cycle operator, same as ICO operator address public icoAddress; // to associate Cycle with ICO address public juryOnlineWallet; // juryOnlineWallet for commission address public projectWallet; // taken from ICO contract address public arbitrationAddress; // taken from ICO contract Token public token; // taken from ICO contract address public jotter; // address for JOT commission bool public saveMe; // if true, gives Jury.Online control of contract struct Milestone { uint etherAmount; //how many Ether is needed for this milestone uint tokenAmount; //how many tokens releases this milestone uint startTime; //real time when milestone has started, set upon start uint finishTime; //real time when milestone has finished, set upon finish uint duration; //assumed duration for milestone implementation, set upon milestone creation string description; string result; } Milestone[] public milestones; // List of Milestones uint public currentMilestone; uint public sealTimestamp; // the moment the Cycle is Sealed by operator uint public ethForMilestone; // Amount to be withdraw by operator for each milestone uint public postDisputeEth; // in case of dispute in favor of ico project // INVESTOR struct stores information about each Investor // Investor can have more than one deals, but only one right to dispute struct Investor { bool disputing; uint tokenAllowance; uint etherUsed; uint sumEther; uint sumToken; bool verdictForProject; bool verdictForInvestor; uint numberOfDeals; } struct Deal { address investor; uint etherAmount; uint tokenAmount; bool accepted; } mapping(address => Investor) public deals; // map of information of investors with deals address[] public dealsList; // list of investors with deals mapping(address => mapping(uint => Deal)) public offers; // pending offers // COMMISSION ARRAYS // amounts stored as percentage // If commissionOnInvestmentEth/Jot > 0, commission paid when investment is accepted // If elements on commissionEth/Jot, each element is commission to corresponding milestone // ETH commission is transferred to Jury.Online wallet // JOT commission is transferred to a Jotter contract that swaps eth for jot uint[] public commissionEth; uint[] public commissionJot; uint public commissionOnInvestmentEth; uint public commissionOnInvestmentJot; uint public etherAllowance; // Amount that Jury.Online can withdraw as commission in ETH uint public jotAllowance; // Amount that Jury.Online can withdraw as commission in JOT uint public totalEther; // Sum of ether in milestones uint public totalToken; // Sum of tokens in milestones uint public promisedTokens; // Sum of tokens promised by accepting offer uint public raisedEther; // Sum of ether raised by accepting offer uint public rate; // eth to token rate in current Funding Round bool public tokenReleaseAtStart; // whether to release tokens at start or by each milestone uint public currentFundingRound; bool public roundFailedToStart; // Stores amount of ether and tokens per milestone for each investor mapping(address => uint[]) public etherPartition; mapping(address => uint[]) public tokenPartition; // Funding Rounds can be added with start, end time, rate, and whitelist struct FundingRound { uint startTime; uint endTime; uint rate; bool hasWhitelist; } FundingRound[] public roundPrices; // stores list of funding rounds mapping(uint => mapping(address => bool)) public whitelist; // stores whitelists // ------------------------------------------------------------------------- // MODIFIERS modifier onlyOperator() { require(msg.sender == operator || msg.sender == juryOperator); _; } modifier onlyAdmin() { require(msg.sender == operator || msg.sender == juryOperator); _; } modifier sealed() { require(sealTimestamp != 0); /* require(now > sealTimestamp); */ _; } modifier notSealed() { require(sealTimestamp == 0); /* require(now <= sealTimestamp); */ _; } // ------------------------------------------------------------------------- // DEPLOYED BY JURY.ONLINE // PARAMS: // address _icoAddress // address _operator // uint _rate // address _jotter // uint[] _commissionEth // uint[] _commissionJot constructor( address _icoAddress, address _operator, uint _rate, address _jotter, uint[] _commissionEth, uint[] _commissionJot, uint _commissionOnInvestmentEth, uint _commissionOnInvestmentJot ) public { require(_commissionEth.length == _commissionJot.length); juryOperator = msg.sender; icoAddress = _icoAddress; operator = _operator; rate = _rate; jotter = _jotter; commissionEth = _commissionEth; commissionJot = _commissionJot; roundPrices.push(FundingRound(0,0,0,false)); tokenReleaseAtStart = true; commissionOnInvestmentEth = _commissionOnInvestmentEth; commissionOnInvestmentJot = _commissionOnInvestmentJot; } // CALLED BY JURY.ONLINE TO SET JOTTER ADDRESS FOR JOT COMMISSION function setJotter(address _jotter) public { require(msg.sender == juryOperator); jotter = _jotter; } // CALLED BY ADMIN TO RETRIEVE INFORMATION FROM ICOADDRESS AND ADD ITSELF // TO LIST OF CYCLES IN ICO function activate() onlyAdmin notSealed public { ICO icoContract = ICO(icoAddress); require(icoContract.operator() == operator); juryOnlineWallet = icoContract.juryOnlineWallet(); projectWallet = icoContract.projectWallet(); arbitrationAddress = icoContract.arbitrationAddress(); token = icoContract.token(); icoContract.addRound(); } // CALLED BY JURY.ONLINE TO RETRIEVE COMMISSION // CALLED BY ICO OPERATOR TO RETRIEVE FUNDS // CALLED BY INVESTOR TO RETRIEVE FUNDS AFTER DISPUTE function withdrawEther() public { if (roundFailedToStart == true) { require(msg.sender.send(deals[msg.sender].sumEther)); } if (msg.sender == operator) { require(projectWallet.send(ethForMilestone+postDisputeEth)); ethForMilestone = 0; postDisputeEth = 0; } if (msg.sender == juryOnlineWallet) { require(juryOnlineWallet.send(etherAllowance)); require(jotter.call.value(jotAllowance)(abi.encodeWithSignature("swapMe()"))); etherAllowance = 0; jotAllowance = 0; } if (deals[msg.sender].verdictForInvestor == true) { require(msg.sender.send(deals[msg.sender].sumEther - deals[msg.sender].etherUsed)); } } // CALLED BY INVESTOR TO RETRIEVE TOKENS function withdrawToken() public { require(token.transfer(msg.sender,deals[msg.sender].tokenAllowance)); deals[msg.sender].tokenAllowance = 0; } // CALLED BY ICO OPERATOR TO ADD FUNDING ROUNDS WITH _startTime,_endTime,_price,_whitelist function addRoundPrice(uint _startTime,uint _endTime, uint _price, address[] _whitelist) public onlyOperator { if (_whitelist.length == 0) { roundPrices.push(FundingRound(_startTime, _endTime,_price,false)); } else { for (uint i=0 ; i < _whitelist.length ; i++ ) { whitelist[roundPrices.length][_whitelist[i]] = true; } roundPrices.push(FundingRound(_startTime, _endTime,_price,true)); } } // CALLED BY ICO OPERATOR TO SET RATE WITHOUT SETTING FUNDING ROUND function setRate(uint _rate) onlyOperator public { rate = _rate; } // CALLED BY ICO OPERATOR TO APPLY WHITELIST AND PRICE OF FUNDING ROUND function setCurrentFundingRound(uint _fundingRound) public onlyOperator { require(roundPrices.length > _fundingRound); currentFundingRound = _fundingRound; rate = roundPrices[_fundingRound].rate; } // RECEIVES FUNDS AND CREATES OFFER function () public payable { require(msg.value > 0); if (roundPrices[currentFundingRound].hasWhitelist == true) { require(whitelist[currentFundingRound][msg.sender] == true); } uint dealNumber = deals[msg.sender].numberOfDeals; offers[msg.sender][dealNumber].investor = msg.sender; offers[msg.sender][dealNumber].etherAmount = msg.value; deals[msg.sender].numberOfDeals += 1; } // IF OFFER NOT ACCEPTED, CAN BE WITHDRAWN function withdrawOffer(uint _offerNumber) public { require(offers[msg.sender][_offerNumber].accepted == false); require(msg.sender.send(offers[msg.sender][_offerNumber].etherAmount)); offers[msg.sender][_offerNumber].etherAmount = 0; /* offers[msg.sender][_offerNumber].tokenAmount = 0; */ } // ARBITRATION // CALLED BY ARBITRATION ADDRESS function disputeOpened(address _investor) public { require(msg.sender == arbitrationAddress); deals[_investor].disputing = true; } // CALLED BY ARBITRATION ADDRESS function verdictExecuted(address _investor, bool _verdictForInvestor,uint _milestoneDispute) public { require(msg.sender == arbitrationAddress); require(deals[_investor].disputing == true); if (_verdictForInvestor) { deals[_investor].verdictForInvestor = true; } else { deals[_investor].verdictForProject = true; for (uint i = _milestoneDispute; i < currentMilestone; i++) { postDisputeEth += etherPartition[_investor][i]; deals[_investor].etherUsed += etherPartition[_investor][i]; } } deals[_investor].disputing = false; } // OPERATOR // TO ADD MILESTONES function addMilestone(uint _etherAmount, uint _tokenAmount, uint _startTime, uint _duration, string _description) public notSealed onlyOperator returns(uint) { totalEther = totalEther.add(_etherAmount); totalToken = totalToken.add(_tokenAmount); return milestones.push(Milestone(_etherAmount, _tokenAmount, _startTime, 0, _duration, _description, "")); } // TO EDIT MILESTONES function editMilestone(uint _id, uint _etherAmount, uint _tokenAmount, uint _startTime, uint _duration, string _description) public notSealed onlyOperator { assert(_id < milestones.length); totalEther = (totalEther - milestones[_id].etherAmount).add(_etherAmount); //previous addition totalToken = (totalToken - milestones[_id].tokenAmount).add(_tokenAmount); milestones[_id].etherAmount = _etherAmount; milestones[_id].tokenAmount = _tokenAmount; milestones[_id].startTime = _startTime; milestones[_id].duration = _duration; milestones[_id].description = _description; } // TO SEAL function seal() public notSealed onlyOperator { require(milestones.length > 0); require(token.balanceOf(address(this)) >= totalToken); sealTimestamp = now; } // TO ACCEPT OFFER function acceptOffer(address _investor, uint _offerNumber) public sealed onlyOperator { // REQUIRE THAT OFFER HAS NOT BEEN APPROVED require(offers[_investor][_offerNumber].etherAmount > 0); require(offers[_investor][_offerNumber].accepted != true); // APPROVE OFFER offers[_investor][_offerNumber].accepted = true; // CALCULATE TOKENS uint _etherAmount = offers[_investor][_offerNumber].etherAmount; uint _tokenAmount = offers[_investor][_offerNumber].tokenAmount; require(token.balanceOf(address(this)) >= promisedTokens + _tokenAmount); // CALCULATE COMMISSION if (commissionOnInvestmentEth > 0 || commissionOnInvestmentJot > 0) { uint etherCommission = _etherAmount.mul(commissionOnInvestmentEth).div(100); uint jotCommission = _etherAmount.mul(commissionOnInvestmentJot).div(100); _etherAmount = _etherAmount.sub(etherCommission).sub(jotCommission); offers[_investor][_offerNumber].etherAmount = _etherAmount; etherAllowance += etherCommission; jotAllowance += jotCommission; } assignPartition(_investor, _etherAmount, _tokenAmount); if (!(deals[_investor].sumEther > 0)) dealsList.push(_investor); if (tokenReleaseAtStart == true) { deals[_investor].tokenAllowance = _tokenAmount; } deals[_investor].sumEther += _etherAmount; deals[_investor].sumToken += _tokenAmount; // ADDS TO TOTALS promisedTokens += _tokenAmount; raisedEther += _etherAmount; } // TO START MILESTONE function startMilestone() public sealed onlyOperator { // UNCOMMENT 2 LINES BELOW FOR PROJECT FAILS START IF totalEther < raisedEther // if (currentMilestone == 0 && totalEther < raisedEther) { roundFailedToStart = true; } // require(!roundFailedToStart); if (currentMilestone != 0 ) {require(milestones[currentMilestone-1].finishTime > 0);} for (uint i=0; i < dealsList.length ; i++) { address investor = dealsList[i]; if (deals[investor].disputing == false) { if (deals[investor].verdictForInvestor != true) { ethForMilestone += etherPartition[investor][currentMilestone]; deals[investor].etherUsed += etherPartition[investor][currentMilestone]; if (tokenReleaseAtStart == false) { deals[investor].tokenAllowance += tokenPartition[investor][currentMilestone]; } } } } milestones[currentMilestone].startTime = now; currentMilestone +=1; ethForMilestone = payCommission(); //ethForMilestone = ethForMilestone.sub(ethAfterCommission); } // CALCULATES COMMISSION function payCommission() internal returns(uint) { if (commissionEth.length >= currentMilestone) { uint ethCommission = raisedEther.mul(commissionEth[currentMilestone-1]).div(100); uint jotCommission = raisedEther.mul(commissionJot[currentMilestone-1]).div(100); etherAllowance += ethCommission; jotAllowance += jotCommission; return ethForMilestone.sub(ethCommission).sub(jotCommission); } else { return ethForMilestone; } } // TO FINISH MILESTONE function finishMilestone(string _result) public onlyOperator { require(milestones[currentMilestone-1].finishTime == 0); uint interval = now - milestones[currentMilestone-1].startTime; require(interval > 1 weeks); milestones[currentMilestone-1].finishTime = now; milestones[currentMilestone-1].result = _result; } // ------------------------------------------------------------------------- // // HELPERS ----------------------------------------------------------------- function failSafe() public onlyAdmin { if (msg.sender == operator) { saveMe = true; } if (msg.sender == juryOperator) { require(saveMe == true); require(juryOperator.send(address(this).balance)); uint allTheLockedTokens = token.balanceOf(this); require(token.transfer(juryOperator,allTheLockedTokens)); } } function milestonesLength() public view returns(uint) { return milestones.length; } function assignPartition(address _investor, uint _etherAmount, uint _tokenAmount) internal { uint milestoneEtherAmount; //How much Ether does investor send for a milestone uint milestoneTokenAmount; //How many Tokens does investor receive for a milestone uint milestoneEtherTarget; //How much TOTAL Ether a milestone needs uint milestoneTokenTarget; //How many TOTAL tokens a milestone releases uint totalEtherInvestment; uint totalTokenInvestment; for(uint i=currentMilestone; i<milestones.length; i++) { milestoneEtherTarget = milestones[i].etherAmount; milestoneTokenTarget = milestones[i].tokenAmount; milestoneEtherAmount = _etherAmount.mul(milestoneEtherTarget).div(totalEther); milestoneTokenAmount = _tokenAmount.mul(milestoneTokenTarget).div(totalToken); totalEtherInvestment = totalEtherInvestment.add(milestoneEtherAmount); //used to prevent rounding errors totalTokenInvestment = totalTokenInvestment.add(milestoneTokenAmount); //used to prevent rounding errors if (deals[_investor].sumEther > 0) { etherPartition[_investor][i] += milestoneEtherAmount; tokenPartition[_investor][i] += milestoneTokenAmount; } else { etherPartition[_investor].push(milestoneEtherAmount); tokenPartition[_investor].push(milestoneTokenAmount); } } /* roundingErrors += _etherAmount - totalEtherInvestment; */ etherPartition[_investor][currentMilestone] += _etherAmount - totalEtherInvestment; //rounding error is added to the first milestone tokenPartition[_investor][currentMilestone] += _tokenAmount - totalTokenInvestment; //rounding error is added to the first milestone } // VIEWS function isDisputing(address _investor) public view returns(bool) { return deals[_investor].disputing; } function investorExists(address _investor) public view returns(bool) { if (deals[_investor].sumEther > 0) return true; else return false; } } contract Arbitration is Owned { address public operator; uint public quorum = 3; struct Dispute { address icoRoundAddress; address investorAddress; bool pending; uint timestamp; uint milestone; string reason; uint votesForProject; uint votesForInvestor; // bool verdictForProject; // bool verdictForInvestor; mapping(address => bool) voters; } mapping(uint => Dispute) public disputes; uint public disputeLength; mapping(address => mapping(address => bool)) public arbiterPool; modifier only(address _allowed) { require(msg.sender == _allowed); _; } constructor() public { operator = msg.sender; } // OPERATOR function setArbiters(address _icoRoundAddress, address[] _arbiters) only(owner) public { for (uint i = 0; i < _arbiters.length ; i++) { arbiterPool[_icoRoundAddress][_arbiters[i]] = true; } } // ARBITER function vote(uint _disputeId, bool _voteForInvestor) public { require(disputes[_disputeId].pending == true); require(arbiterPool[disputes[_disputeId].icoRoundAddress][msg.sender] == true); require(disputes[_disputeId].voters[msg.sender] != true); if (_voteForInvestor == true) { disputes[_disputeId].votesForInvestor += 1; } else { disputes[_disputeId].votesForProject += 1; } if (disputes[_disputeId].votesForInvestor == quorum) { executeVerdict(_disputeId,true); } if (disputes[_disputeId].votesForProject == quorum) { executeVerdict(_disputeId,false); } disputes[_disputeId].voters[msg.sender] == true; } // INVESTOR function openDispute(address _icoRoundAddress, string _reason) public { Cycle icoRound = Cycle(_icoRoundAddress); uint milestoneDispute = icoRound.currentMilestone(); require(milestoneDispute > 0); require(icoRound.investorExists(msg.sender) == true); disputes[disputeLength].milestone = milestoneDispute; disputes[disputeLength].icoRoundAddress = _icoRoundAddress; disputes[disputeLength].investorAddress = msg.sender; disputes[disputeLength].timestamp = now; disputes[disputeLength].reason = _reason; disputes[disputeLength].pending = true; icoRound.disputeOpened(msg.sender); disputeLength +=1; } // INTERNAL function executeVerdict(uint _disputeId, bool _verdictForInvestor) internal { disputes[_disputeId].pending = false; uint milestoneDispute = disputes[_disputeId].milestone; Cycle icoRound = Cycle(disputes[_disputeId].icoRoundAddress); icoRound.verdictExecuted(disputes[_disputeId].investorAddress,_verdictForInvestor,milestoneDispute); //counter +=1; } function isPending(uint _disputedId) public view returns(bool) { return disputes[_disputedId].pending; } } contract Jotter { // for an ethToJot of 2,443.0336457941, Aug 21, 2018 Token public token; uint public ethToJot = 2443; address public owner; constructor(address _jotAddress) public { owner = msg.sender; token = Token(_jotAddress); } function swapMe() public payable { uint jot = msg.value * ethToJot; require(token.transfer(owner,jot)); } // In the future, this contract would call a trusted Oracle // instead of being set by its owner function setEth(uint _newEth) public { require(msg.sender == owner); ethToJot = _newEth; } } contract SwapperX { // used to swap proxy token for real token // must have real token balance in order to recieve swap Token public proxyToken; Token public token; address public owner; struct Swap { address _from; uint _amount; } Swap[] public swaps; constructor(address _tokenAddress, address _proxyTokenAddress) public { owner = msg.sender; token = Token(_tokenAddress); proxyToken = Token(_proxyTokenAddress); } // SWAPS PROXY TOKENS FOR ICO TOKENS function swapMe() public { uint allowance = proxyToken.allowance(msg.sender,address(this)); require(token.balanceOf(address(this)) >= allowance); require(token.transfer(msg.sender, allowance)); require(proxyToken.transferFrom(msg.sender,address(this),allowance)); swaps.push(Swap(msg.sender,allowance)); } // REFUNDS TOKEN HOLDERS ALLOWANCE function returnMe() public { uint allowance = proxyToken.allowance(msg.sender,address(this)); require(proxyToken.transferFrom(msg.sender,address(this),allowance)); require(proxyToken.transfer(msg.sender, allowance)); } }
RE1
pragma solidity ^0.4.19; contract Private_Bank { mapping (address => uint) public balances; uint public MinDeposit = 1 ether; Log TransferLog; function Private_Bank(address _log) { TransferLog = Log(_log); } function Deposit() public payable { if(msg.value > MinDeposit) { balances[msg.sender]+=msg.value; TransferLog.AddMessage(msg.sender,msg.value,"Deposit"); } } function CashOut(uint _am) public payable { if(_am<=balances[msg.sender]) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; TransferLog.AddMessage(msg.sender,_am,"CashOut"); } } } function() public payable{} } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract U_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function U_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract X_WALLET { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function X_WALLET(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
/* This file is part of the Open Longevity Contract. The Open Longevity Contract is free software: you can redistribute it and/or modify it under the terms of the GNU lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The Open Longevity Contract is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU lesser General Public License for more details. You should have received a copy of the GNU lesser General Public License along with the Open Longevity Contract. If not, see <http://www.gnu.org/licenses/>. @author Ilya Svirin <[email protected]> */ pragma solidity ^0.4.10; contract owned { address public owner; address public newOwner; function owned() public payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } function changeOwner(address _owner) onlyOwner public { require(_owner != 0); newOwner = _owner; } function confirmOwner() public { require(newOwner == msg.sender); owner = newOwner; delete newOwner; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 { uint public totalSupply; function balanceOf(address who) public constant returns (uint); function transfer(address to, uint value) public ; function allowance(address owner, address spender) public constant returns (uint); function transferFrom(address from, address to, uint value) public; function approve(address spender, uint value) public; event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); } contract PresaleOriginal is owned, ERC20 { uint public totalLimitUSD; uint public collectedUSD; uint public presaleStartTime; struct Investor { uint256 amountTokens; uint amountWei; } mapping (address => Investor) public investors; mapping (uint => address) public investorsIter; uint public numberOfInvestors; } contract Presale is PresaleOriginal { uint public etherPrice; address public presaleOwner; enum State { Disabled, Presale, Finished } event NewState(State state); State public state; uint public presaleFinishTime; uint public migrationCounter; function migrate(address _originalContract, uint n) public onlyOwner { require(state == State.Disabled); // migrate tokens with x2 bonus numberOfInvestors = PresaleOriginal(_originalContract).numberOfInvestors(); uint limit = migrationCounter + n; if(limit > numberOfInvestors) { limit = numberOfInvestors; } for(; migrationCounter < limit; ++migrationCounter) { address a = PresaleOriginal(_originalContract).investorsIter(migrationCounter); investorsIter[migrationCounter] = a; uint256 amountTokens; uint amountWei; (amountTokens, amountWei) = PresaleOriginal(_originalContract).investors(a); amountTokens *= 2; investors[a].amountTokens = amountTokens; investors[a].amountWei = amountWei; totalSupply += amountTokens; Transfer(_originalContract, a, amountTokens); } if(limit < numberOfInvestors) { return; } // migrate main parameters presaleStartTime = PresaleOriginal(_originalContract).presaleStartTime(); collectedUSD = PresaleOriginal(_originalContract).collectedUSD(); totalLimitUSD = PresaleOriginal(_originalContract).totalLimitUSD(); // add extra tokens for bounty address bountyAddress = 0x59B95A5e0268Cc843e6308FEf723544BaA6676c6; if(investors[bountyAddress].amountWei == 0 && investors[bountyAddress].amountTokens == 0) { investorsIter[numberOfInvestors++] = bountyAddress; } uint bountyTokens = 5 * PresaleOriginal(_originalContract).totalSupply() / 100; investors[bountyAddress].amountTokens += bountyTokens; totalSupply += bountyTokens; } function () payable public { require(state == State.Presale); require(now < presaleFinishTime); uint valueWei = msg.value; uint valueUSD = valueWei * etherPrice / 1000000000000000000; if (collectedUSD + valueUSD > totalLimitUSD) { // don't need so much ether valueUSD = totalLimitUSD - collectedUSD; valueWei = valueUSD * 1000000000000000000 / etherPrice; require(msg.sender.call.gas(3000000).value(msg.value - valueWei)()); collectedUSD = totalLimitUSD; // to be sure! } else { collectedUSD += valueUSD; } uint256 tokensPer10USD = 130; if (valueUSD >= 100000) { tokensPer10USD = 150; } uint256 tokens = tokensPer10USD * valueUSD / 10; require(tokens > 0); Investor storage inv = investors[msg.sender]; if (inv.amountWei == 0) { // new investor investorsIter[numberOfInvestors++] = msg.sender; } require(inv.amountTokens + tokens > inv.amountTokens); // overflow inv.amountTokens += tokens; inv.amountWei += valueWei; totalSupply += tokens; Transfer(this, msg.sender, tokens); } function startPresale(address _presaleOwner, uint _etherPrice) public onlyOwner { require(state == State.Disabled); presaleOwner = _presaleOwner; etherPrice = _etherPrice; presaleFinishTime = 1526342400; // (GMT) 15 May 2018, 00:00:00 state = State.Presale; totalLimitUSD = 500000; NewState(state); } function setEtherPrice(uint _etherPrice) public onlyOwner { require(state == State.Presale); etherPrice = _etherPrice; } function timeToFinishPresale() public constant returns(uint t) { require(state == State.Presale); if (now > presaleFinishTime) { t = 0; } else { t = presaleFinishTime - now; } } function finishPresale() public onlyOwner { require(state == State.Presale); require(now >= presaleFinishTime || collectedUSD == totalLimitUSD); require(presaleOwner.call.gas(3000000).value(this.balance)()); state = State.Finished; NewState(state); } function withdraw() public onlyOwner { require(presaleOwner.call.gas(3000000).value(this.balance)()); } } contract PresaleToken is Presale { string public standard = 'Token 0.1'; string public name = 'OpenLongevity'; string public symbol = "YEAR"; uint8 public decimals = 0; mapping (address => mapping (address => uint)) public allowed; // Fix for the ERC20 short address attack modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } function PresaleToken() payable public Presale() {} function balanceOf(address _who) constant public returns (uint) { return investors[_who].amountTokens; } function transfer(address _to, uint256 _value) public onlyPayloadSize(2 * 32) { require(investors[msg.sender].amountTokens >= _value); require(investors[_to].amountTokens + _value >= investors[_to].amountTokens); investors[msg.sender].amountTokens -= _value; if(investors[_to].amountTokens == 0 && investors[_to].amountWei == 0) { investorsIter[numberOfInvestors++] = _to; } investors[_to].amountTokens += _value; Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public onlyPayloadSize(3 * 32) { require(investors[_from].amountTokens >= _value); require(investors[_to].amountTokens + _value >= investors[_to].amountTokens); // overflow require(allowed[_from][msg.sender] >= _value); investors[_from].amountTokens -= _value; if(investors[_to].amountTokens == 0 && investors[_to].amountWei == 0) { investorsIter[numberOfInvestors++] = _to; } investors[_to].amountTokens += _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); } function approve(address _spender, uint _value) public { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) public constant returns (uint remaining) { return allowed[_owner][_spender]; } } contract OpenLongevityPresale is PresaleToken { function OpenLongevityPresale() payable public PresaleToken() {} function killMe() public onlyOwner { selfdestruct(owner); } }
RE1
pragma solidity ^0.4.25; contract CA_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function CA_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract ultra_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function ultra_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract SIMPL_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function SIMPL_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract MONEY_BOX { struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; uint public MinSum; Log LogFile; bool intitalized; function SetMinSum(uint _val) public { if(intitalized)throw; MinSum = _val; } function SetLogFile(address _log) public { if(intitalized)throw; LogFile = Log(_log); } function Initialized() public { intitalized = true; } function Put(uint _lockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; if(now+_lockTime>acc.unlockTime)acc.unlockTime=now+_lockTime; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract cb_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function cb_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract Y_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function Y_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
/* This file is part of the eHealth First Contract. www.ehfirst.io An IT-platform for Personalized Health and Longevity Management based on Blockchain, Artificial Intelligence, Machine Learning and Natural Language Processing The eHealth First Contract is free software: you can redistribute it and/or modify it under the terms of the GNU lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The eHealth First Contract is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU lesser General Public License for more details. You should have received a copy of the GNU lesser General Public License along with the eHealth First Contract. If not, see <http://www.gnu.org/licenses/>. @author Ilya Svirin <[email protected]> IF YOU ARE ENJOYED IT DONATE TO 0x3Ad38D1060d1c350aF29685B2b8Ec3eDE527452B ! :) */ pragma solidity ^0.4.19; contract owned { address public owner; address public candidate; function owned() public payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } function changeOwner(address _owner) onlyOwner public { require(_owner != 0); candidate = _owner; } function confirmOwner() public { require(candidate == msg.sender); owner = candidate; delete candidate; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 { uint public totalSupply; function balanceOf(address who) public constant returns (uint); function transfer(address to, uint value) public; function allowance(address owner, address spender) public constant returns (uint); function transferFrom(address from, address to, uint value) public; function approve(address spender, uint value) public; event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); } contract Token is owned, ERC20 { string public standard = 'Token 0.1'; string public name = 'eHealth First'; string public symbol = "EHF"; uint8 public decimals = 8; uint public freezedMoment; struct TokenHolder { uint balance; uint balanceBeforeUpdate; uint balanceUpdateTime; } mapping (address => TokenHolder) public holders; mapping (address => uint) public vesting; mapping (address => mapping (address => uint256)) public allowed; address public vestingManager; function setVestingManager(address _vestingManager) public onlyOwner { vestingManager = _vestingManager; } function beforeBalanceChanges(address _who) internal { if (holders[_who].balanceUpdateTime <= freezedMoment) { holders[_who].balanceUpdateTime = now; holders[_who].balanceBeforeUpdate = holders[_who].balance; } } event Burned(address indexed owner, uint256 value); function Token() public owned() {} function balanceOf(address _who) constant public returns (uint) { return holders[_who].balance; } function transfer(address _to, uint256 _value) public { require(now > vesting[msg.sender] || msg.sender == vestingManager); require(holders[_to].balance + _value >= holders[_to].balance); // overflow beforeBalanceChanges(msg.sender); beforeBalanceChanges(_to); holders[msg.sender].balance -= _value; holders[_to].balance += _value; if (vesting[_to] < vesting[msg.sender]) { vesting[_to] = vesting[msg.sender]; } emit Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public { require(now > vesting[_from]); require(holders[_to].balance + _value >= holders[_to].balance); // overflow require(allowed[_from][msg.sender] >= _value); beforeBalanceChanges(_from); beforeBalanceChanges(_to); holders[_from].balance -= _value; holders[_to].balance += _value; allowed[_from][msg.sender] -= _value; emit Transfer(_from, _to, _value); } function approve(address _spender, uint256 _value) public { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function burn(uint256 _value) public { require(holders[msg.sender].balance >= _value); beforeBalanceChanges(msg.sender); holders[msg.sender].balance -= _value; totalSupply -= _value; emit Burned(msg.sender, _value); } } contract Crowdsale is Token { address public backend; uint public stage; bool public started; uint public startTokenPriceWei; uint public tokensForSale; uint public startTime; uint public lastTokenPriceWei; uint public milliPercent; // "25" means 0.25% uint public paymentsCount; // restart on each stage bool public sealed; modifier notSealed { require(sealed == false); _; } event Mint(address indexed _who, uint _tokens, uint _coinType, bytes32 _txHash); event Stage(uint _stage, bool startNotFinish); function Crowdsale() public Token() { totalSupply = 100000000*100000000; holders[this].balance = totalSupply; } function startStage(uint _startTokenPriceWei, uint _tokensForSale, uint _milliPercent) public onlyOwner notSealed { require(!started); require(_startTokenPriceWei >= lastTokenPriceWei); startTokenPriceWei = _startTokenPriceWei; tokensForSale = _tokensForSale * 100000000; if(tokensForSale > holders[this].balance) { tokensForSale = holders[this].balance; } milliPercent = _milliPercent; startTime = now; started = true; paymentsCount = 0; emit Stage(stage, started); } function currentTokenPrice() public constant returns(uint) { uint price; if(!sealed && started) { uint d = (now - startTime) / 1 days; price = startTokenPriceWei; price += startTokenPriceWei * d * milliPercent / 100; } return price; } function stopStage() public onlyOwner notSealed { require(started); started = false; lastTokenPriceWei = currentTokenPrice(); emit Stage(stage, started); ++stage; } function () payable public notSealed { require(started); uint price = currentTokenPrice(); if(paymentsCount < 100) { price = price * 90 / 100; } ++paymentsCount; uint tokens = 100000000 * msg.value / price; if(tokens > tokensForSale) { tokens = tokensForSale; uint sumWei = tokens * lastTokenPriceWei / 100000000; require(msg.sender.call.gas(3000000).value(msg.value - sumWei)()); } require(tokens > 0); require(holders[msg.sender].balance + tokens > holders[msg.sender].balance); // overflow tokensForSale -= tokens; beforeBalanceChanges(msg.sender); beforeBalanceChanges(this); holders[msg.sender].balance += tokens; holders[this].balance -= tokens; emit Transfer(this, msg.sender, tokens); } function mintTokens1(address _who, uint _tokens, uint _coinType, bytes32 _txHash) public notSealed { require(msg.sender == owner || msg.sender == backend); require(started); _tokens *= 100000000; if(_tokens > tokensForSale) { _tokens = tokensForSale; } require(_tokens > 0); require(holders[_who].balance + _tokens > holders[_who].balance); // overflow tokensForSale -= _tokens; beforeBalanceChanges(_who); beforeBalanceChanges(this); holders[_who].balance += _tokens; holders[this].balance -= _tokens; emit Mint(_who, _tokens, _coinType, _txHash); emit Transfer(this, _who, _tokens); } // must be called by owners only out of stage function mintTokens2(address _who, uint _tokens, uint _vesting) public notSealed { require(msg.sender == owner || msg.sender == backend); require(!started); require(_tokens > 0); _tokens *= 100000000; require(_tokens <= holders[this].balance); require(holders[_who].balance + _tokens > holders[_who].balance); // overflow if(_vesting != 0) { vesting[_who] = _vesting; } beforeBalanceChanges(_who); beforeBalanceChanges(this); holders[_who].balance += _tokens; holders[this].balance -= _tokens; emit Mint(_who, _tokens, 0, 0); emit Transfer(this, _who, _tokens); } // need to seal Crowdsale when it is finished completely function seal() public onlyOwner { sealed = true; } } contract Ehfirst is Crowdsale { function Ehfirst() payable public Crowdsale() {} function setBackend(address _backend) public onlyOwner { backend = _backend; } function withdraw() public onlyOwner { require(owner.call.gas(3000000).value(address(this).balance)()); } function freezeTheMoment() public onlyOwner { freezedMoment = now; } /** Get balance of _who for freezed moment * freezeTheMoment() */ function freezedBalanceOf(address _who) constant public returns(uint) { if (holders[_who].balanceUpdateTime <= freezedMoment) { return holders[_who].balance; } else { return holders[_who].balanceBeforeUpdate; } } }
RE1
/* This file is part of the Open Longevity Contract. The Open Longevity Contract is free software: you can redistribute it and/or modify it under the terms of the GNU lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The Open Longevity Contract is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU lesser General Public License for more details. You should have received a copy of the GNU lesser General Public License along with the Open Longevity Contract. If not, see <http://www.gnu.org/licenses/>. @author Ilya Svirin <[email protected]> */ pragma solidity ^0.4.10; contract owned { address public owner; address public newOwner; function owned() payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } function changeOwner(address _owner) onlyOwner public { require(_owner != 0); newOwner = _owner; } function confirmOwner() public { require(newOwner == msg.sender); owner = newOwner; delete newOwner; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 { uint public totalSupply; function balanceOf(address who) constant returns (uint); function transfer(address to, uint value); function allowance(address owner, address spender) constant returns (uint); function transferFrom(address from, address to, uint value); function approve(address spender, uint value); event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); } /** * @title Know your customer contract */ contract KYC is owned { mapping (address => bool) public known; address public confirmer; function setConfirmer(address _confirmer) public onlyOwner { confirmer = _confirmer; } function setToKnown(address _who) public { require(msg.sender == confirmer || msg.sender == owner); known[_who] = true; } } contract Presale is KYC, ERC20 { uint public etherPrice; address public presaleOwner; uint public totalLimitUSD; uint public collectedUSD; enum State { Disabled, Presale, Finished } event NewState(State state); State public state; uint public presaleStartTime; uint public ppFinishTime; uint public presaleFinishTime; struct Investor { uint256 amountTokens; uint amountWei; } mapping (address => Investor) public investors; mapping (uint => address) public investorsIter; uint public numberOfInvestors; function () payable public { require(state == State.Presale); require(now < presaleFinishTime); require(now > ppFinishTime || known[msg.sender]); uint valueWei = msg.value; uint valueUSD = valueWei * etherPrice / 1000000000000000000; if (collectedUSD + valueUSD > totalLimitUSD) { // don't need so much ether valueUSD = totalLimitUSD - collectedUSD; valueWei = valueUSD * 1000000000000000000 / etherPrice; require(msg.sender.call.gas(3000000).value(msg.value - valueWei)()); collectedUSD = totalLimitUSD; // to be sure! } else { collectedUSD += valueUSD; } uint256 tokensPer10USD = 100; if (now <= ppFinishTime) { if (valueUSD >= 100000) { tokensPer10USD = 200; } else { tokensPer10USD = 175; } } else { if (valueUSD >= 100000) { tokensPer10USD = 150; } else { tokensPer10USD = 130; } } uint256 tokens = tokensPer10USD * valueUSD / 10; require(tokens > 0); Investor storage inv = investors[msg.sender]; if (inv.amountWei == 0) { // new investor investorsIter[numberOfInvestors++] = msg.sender; } require(inv.amountTokens + tokens > inv.amountTokens); // overflow inv.amountTokens += tokens; inv.amountWei += valueWei; totalSupply += tokens; Transfer(this, msg.sender, tokens); } function startPresale(address _presaleOwner, uint _etherPrice) public onlyOwner { require(state == State.Disabled); presaleStartTime = now; presaleOwner = _presaleOwner; etherPrice = _etherPrice; ppFinishTime = now + 3 days; presaleFinishTime = ppFinishTime + 60 days; state = State.Presale; totalLimitUSD = 500000; NewState(state); } function timeToFinishPresale() public constant returns(uint t) { require(state == State.Presale); if (now > presaleFinishTime) { t = 0; } else { t = presaleFinishTime - now; } } function finishPresale() public onlyOwner { require(state == State.Presale); require(now >= presaleFinishTime || collectedUSD == totalLimitUSD); require(presaleOwner.call.gas(3000000).value(this.balance)()); state = State.Finished; NewState(state); } function withdraw() public onlyOwner { require(presaleOwner.call.gas(3000000).value(this.balance)()); } } contract PresaleToken is Presale { string public standard = 'Token 0.1'; string public name = 'OpenLongevity'; string public symbol = "YEAR"; uint8 public decimals = 0; function PresaleToken() payable public Presale() {} function balanceOf(address _who) constant public returns (uint) { return investors[_who].amountTokens; } function transfer(address, uint256) public {revert();} function transferFrom(address, address, uint256) public {revert();} function approve(address, uint256) public {revert();} function allowance(address, address) public constant returns (uint256) {revert();} } contract OpenLongevityPresale is PresaleToken { function OpenLongevityPresale() payable public PresaleToken() {} function killMe() public onlyOwner { selfdestruct(owner); } }
RE1
/** * Originally from https://github.com/ConsenSys/MultiSigWallet */ pragma solidity ^0.4.11; contract owned { address public owner; function owned() { owner = msg.sender; } modifier onlyOwner { if (msg.sender != owner) throw; _; } function transferOwnership(address newOwner) onlyOwner { owner = newOwner; } } /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. /// @author Stefan George - <[email protected]> contract MultiSig is owned { uint constant public MAX_OWNER_COUNT = 50; event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint required); mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; struct Transaction { address destination; uint value; bytes data; bool executed; } modifier onlyWallet() { if (msg.sender != address(this)) throw; _; } modifier ownerDoesNotExist(address owner) { if (isOwner[owner]) throw; _; } modifier ownerExists(address owner) { if (!isOwner[owner]) throw; _; } modifier transactionExists(uint transactionId) { if (transactions[transactionId].destination == 0) throw; _; } modifier confirmed(uint transactionId, address owner) { if (!confirmations[transactionId][owner]) throw; _; } modifier notConfirmed(uint transactionId, address owner) { if (confirmations[transactionId][owner]) throw; _; } modifier notExecuted(uint transactionId) { if (transactions[transactionId].executed) throw; _; } modifier notNull(address _address) { if (_address == 0) throw; _; } modifier validRequirement(uint ownerCount, uint _required) { if ( ownerCount > MAX_OWNER_COUNT || _required > ownerCount || _required == 0 || ownerCount == 0) throw; _; } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. function MultiSig(address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { if (isOwner[_owners[i]] || _owners[i] == 0) throw; isOwner[_owners[i]] = true; } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); changeRequirement(owners.length / 2 + 1); OwnerAddition(owner); } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } owners.length -= 1; //if (required > owners.length) // changeRequirement(owners.length); changeRequirement(owners.length / 2 + 1); OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param owner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; isOwner[newOwner] = true; OwnerRemoval(owner); OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function submitTransaction(address destination, uint value, bytes data) public ownerExists(msg.sender) returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public notExecuted(transactionId) { } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i=0; i<owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; Submission(transactionId); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return Number of confirmations. function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public constant returns (address[]) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return Returns array of owner addresses. function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i=0; i<count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Returns array of transaction IDs. function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint[](to - from); for (i=from; i<to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } } contract MultiSigWallet is MultiSig { function MultiSigWallet(address[] _owners, uint _required) public MultiSig( _owners, _required) { } /// @dev Fallback function allows to deposit ether. function() payable { if (msg.value > 0) Deposit(msg.sender, msg.value); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction tx = transactions[transactionId]; if (tx.destination.call.value(tx.value)(tx.data)) { tx.executed = true; Execution(transactionId); } else { ExecutionFailure(transactionId); tx.executed = false; } } } } contract token {function transfer(address receiver, uint amount) returns (bool success);} contract MultiSigToken is MultiSig { token public tokenFactory ; function MultiSigToken(address[] _owners, uint _required, token _addressOfTokenFactory) public MultiSig( _owners, _required) { tokenFactory = token(_addressOfTokenFactory); } // @dev This unnamed function is called whenever someone tries to send ether to it function() { throw; // Prevents accidental sending of ether } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction tx = transactions[transactionId]; if (tokenFactory.transfer(tx.destination, tx.value)) { tx.executed = true; Execution(transactionId); } else { tx.executed = false; ExecutionFailure(transactionId); } } } }
RE1
pragma solidity ^0.4.25; contract cd_Bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function cd_Bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
//sol Wallet // Multi-sig, daily-limited account proxy/wallet. // @authors: // Gav Wood <[email protected]> // inheritable "property" contract that enables methods to be protected by requiring the acquiescence of either a // single, or, crucially, each of a number of, designated owners. // usage: // use modifiers onlyowner (just own owned) or onlymanyowners(hash), whereby the same hash must be provided by // some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the // interior is executed. pragma solidity ^0.4.13; contract multiowned { // TYPES // struct for the status of a pending operation. struct PendingState { uint yetNeeded; uint ownersDone; uint index; } // EVENTS // this contract only has six types of events: it can accept a confirmation, in which case // we record owner and operation (hash) alongside it. event Confirmation(address owner, bytes32 operation); event Revoke(address owner, bytes32 operation); // some others are in the case of an owner changing. event OwnerChanged(address oldOwner, address newOwner); event OwnerAdded(address newOwner); event OwnerRemoved(address oldOwner); // the last one is emitted if the required signatures change event RequirementChanged(uint newRequirement); // MODIFIERS // simple single-sig function modifier. modifier onlyowner { if (isOwner(msg.sender)) _; } // multi-sig function modifier: the operation must have an intrinsic hash in order // that later attempts can be realised as the same underlying operation and // thus count as confirmations. modifier onlymanyowners(bytes32 _operation) { if (confirmAndCheck(_operation)) _; } // METHODS // constructor is given number of sigs required to do protected "onlymanyowners" transactions // as well as the selection of addresses capable of confirming them. function multiowned(address[] _owners, uint _required) { require(_required > 0); require(_owners.length >= _required); m_numOwners = _owners.length; for (uint i = 0; i < _owners.length; ++i) { m_owners[1 + i] = uint(_owners[i]); m_ownerIndex[uint(_owners[i])] = 1 + i; } m_required = _required; } // Revokes a prior confirmation of the given operation function revoke(bytes32 _operation) external { uint ownerIndex = m_ownerIndex[uint(msg.sender)]; // make sure they're an owner if (ownerIndex == 0) return; uint ownerIndexBit = 2**ownerIndex; var pending = m_pending[_operation]; if (pending.ownersDone & ownerIndexBit > 0) { pending.yetNeeded++; pending.ownersDone -= ownerIndexBit; Revoke(msg.sender, _operation); } } // Replaces an owner `_from` with another `_to`. function changeOwner(address _from, address _to) onlymanyowners(sha3(msg.data)) external { if (isOwner(_to)) return; uint ownerIndex = m_ownerIndex[uint(_from)]; if (ownerIndex == 0) return; clearPending(); m_owners[ownerIndex] = uint(_to); m_ownerIndex[uint(_from)] = 0; m_ownerIndex[uint(_to)] = ownerIndex; OwnerChanged(_from, _to); } function addOwner(address _owner) onlymanyowners(sha3(msg.data)) external { if (isOwner(_owner)) return; clearPending(); if (m_numOwners >= c_maxOwners) reorganizeOwners(); if (m_numOwners >= c_maxOwners) return; m_numOwners++; m_owners[m_numOwners] = uint(_owner); m_ownerIndex[uint(_owner)] = m_numOwners; OwnerAdded(_owner); } function removeOwner(address _owner) onlymanyowners(sha3(msg.data)) external { uint ownerIndex = m_ownerIndex[uint(_owner)]; if (ownerIndex == 0) return; if (m_required > m_numOwners - 1) return; m_owners[ownerIndex] = 0; m_ownerIndex[uint(_owner)] = 0; clearPending(); reorganizeOwners(); //make sure m_numOwner is equal to the number of owners and always points to the optimal free slot OwnerRemoved(_owner); } function changeRequirement(uint _newRequired) onlymanyowners(sha3(msg.data)) external { if (_newRequired == 0) return; if (_newRequired > m_numOwners) return; m_required = _newRequired; clearPending(); RequirementChanged(_newRequired); } // Gets an owner by 0-indexed position (using numOwners as the count) function getOwner(uint ownerIndex) external constant returns (address) { return address(m_owners[ownerIndex + 1]); } function isOwner(address _addr) returns (bool) { return m_ownerIndex[uint(_addr)] > 0; } function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) { var pending = m_pending[_operation]; uint ownerIndex = m_ownerIndex[uint(_owner)]; // make sure they're an owner if (ownerIndex == 0) return false; // determine the bit to set for this owner. uint ownerIndexBit = 2**ownerIndex; return !(pending.ownersDone & ownerIndexBit == 0); } // INTERNAL METHODS function confirmAndCheck(bytes32 _operation) internal returns (bool) { // determine what index the present sender is: uint ownerIndex = m_ownerIndex[uint(msg.sender)]; // make sure they're an owner if (ownerIndex == 0) return; var pending = m_pending[_operation]; // if we're not yet working on this operation, switch over and reset the confirmation status. if (pending.yetNeeded == 0) { // reset count of confirmations needed. pending.yetNeeded = m_required; // reset which owners have confirmed (none) - set our bitmap to 0. pending.ownersDone = 0; pending.index = m_pendingIndex.length++; m_pendingIndex[pending.index] = _operation; } // determine the bit to set for this owner. uint ownerIndexBit = 2**ownerIndex; // make sure we (the message sender) haven't confirmed this operation previously. if (pending.ownersDone & ownerIndexBit == 0) { Confirmation(msg.sender, _operation); // ok - check if count is enough to go ahead. if (pending.yetNeeded == 1) { // enough confirmations: reset and run interior. delete m_pendingIndex[m_pending[_operation].index]; delete m_pending[_operation]; return true; } else { // not enough: record that this owner in particular confirmed. pending.yetNeeded--; pending.ownersDone |= ownerIndexBit; } } } function reorganizeOwners() private { uint free = 1; while (free < m_numOwners) { while (free < m_numOwners && m_owners[free] != 0) free++; while (m_numOwners > 1 && m_owners[m_numOwners] == 0) m_numOwners--; if (free < m_numOwners && m_owners[m_numOwners] != 0 && m_owners[free] == 0) { m_owners[free] = m_owners[m_numOwners]; m_ownerIndex[m_owners[free]] = free; m_owners[m_numOwners] = 0; } } } function clearPending() internal { uint length = m_pendingIndex.length; for (uint i = 0; i < length; ++i) if (m_pendingIndex[i] != 0) delete m_pending[m_pendingIndex[i]]; delete m_pendingIndex; } // FIELDS // the number of owners that must confirm the same operation before it is run. uint public m_required; // pointer used to find a free slot in m_owners uint public m_numOwners; // list of owners uint[256] m_owners; uint constant c_maxOwners = 250; // index on the list of owners to allow reverse lookup mapping(uint => uint) m_ownerIndex; // the ongoing operations. mapping(bytes32 => PendingState) m_pending; bytes32[] m_pendingIndex; } // inheritable "property" contract that enables methods to be protected by placing a linear limit (specifiable) // on a particular resource per calendar day. is multiowned to allow the limit to be altered. resource that method // uses is specified in the modifier. contract daylimit is multiowned { // METHODS // constructor - stores initial daily limit and records the present day's index. function daylimit(uint _limit) { m_dailyLimit = _limit; m_lastDay = today(); } // (re)sets the daily limit. needs many of the owners to confirm. doesn't alter the amount already spent today. function setDailyLimit(uint _newLimit) onlymanyowners(sha3(msg.data)) external { m_dailyLimit = _newLimit; } // resets the amount already spent today. needs many of the owners to confirm. function resetSpentToday() onlymanyowners(sha3(msg.data)) external { m_spentToday = 0; } // INTERNAL METHODS // checks to see if there is at least `_value` left from the daily limit today. if there is, subtracts it and // returns true. otherwise just returns false. function underLimit(uint _value) internal onlyowner returns (bool) { // reset the spend limit if we're on a different day to last time. if (today() > m_lastDay) { m_spentToday = 0; m_lastDay = today(); } // check to see if there's enough left - if so, subtract and return true. // overflow protection // dailyLimit check if (m_spentToday + _value >= m_spentToday && m_spentToday + _value <= m_dailyLimit) { m_spentToday += _value; return true; } return false; } // determines today's index. function today() private constant returns (uint) { return now / 1 days; } // FIELDS uint public m_dailyLimit; uint public m_spentToday; uint public m_lastDay; } // interface contract for multisig proxy contracts; see below for docs. contract multisig { // EVENTS // logged events: // Funds has arrived into the wallet (record how much). event Deposit(address _from, uint value); // Single transaction going out of the wallet (record who signed for it, how much, and to whom it's going). event SingleTransact(address owner, uint value, address to, bytes data, address created); // Multi-sig transaction going out of the wallet (record who signed for it last, the operation hash, how much, and to whom it's going). event MultiTransact(address owner, bytes32 operation, uint value, address to, bytes data, address created); // Confirmation still needed for a transaction. event ConfirmationNeeded(bytes32 operation, address initiator, uint value, address to, bytes data); // FUNCTIONS // TODO: document function changeOwner(address _from, address _to) external; function execute(address _to, uint _value, bytes _data) external returns (bytes32 o_hash); function confirm(bytes32 _h) returns (bool o_success); } contract creator { function doCreate(uint _value, bytes _code) internal returns (address o_addr) { bool failed; assembly { o_addr := create(_value, add(_code, 0x20), mload(_code)) failed := iszero(extcodesize(o_addr)) } require(!failed); } } // usage: // bytes32 h = Wallet(w).from(oneOwner).execute(to, value, data); // Wallet(w).from(anotherOwner).confirm(h); contract Wallet is multisig, multiowned, daylimit, creator { // TYPES // Transaction structure to remember details of transaction lest it need be saved for a later call. struct Transaction { address to; uint value; bytes data; } // METHODS // constructor - just pass on the owner array to the multiowned and // the limit to daylimit function Wallet(address[] _owners, uint _required, uint _daylimit) multiowned(_owners, _required) daylimit(_daylimit) { } // kills the contract sending everything to `_to`. function kill(address _to) onlymanyowners(sha3(msg.data)) external { suicide(_to); } // gets called when no other function matches function() payable { // just being sent some cash? if (msg.value > 0) Deposit(msg.sender, msg.value); } // Outside-visible transact entry point. Executes transaction immediately if below daily spend limit. // If not, goes into multisig process. We provide a hash on return to allow the sender to provide // shortcuts for the other confirmations (allowing them to avoid replicating the _to, _value // and _data arguments). They still get the option of using them if they want, anyways. function execute(address _to, uint _value, bytes _data) external onlyowner returns (bytes32 o_hash) { // first, take the opportunity to check that we're under the daily limit. if ((_data.length == 0 && underLimit(_value)) || m_required == 1) { // yes - just execute the call. address created; if (_to == 0) { created = create(_value, _data); } else { require(_to.call.value(_value)(_data)); } SingleTransact(msg.sender, _value, _to, _data, created); } else { // determine our operation hash. o_hash = sha3(msg.data, block.number); // store if it's new if (m_txs[o_hash].to == 0 && m_txs[o_hash].value == 0 && m_txs[o_hash].data.length == 0) { m_txs[o_hash].to = _to; m_txs[o_hash].value = _value; m_txs[o_hash].data = _data; } if (!confirm(o_hash)) { ConfirmationNeeded(o_hash, msg.sender, _value, _to, _data); } } } function create(uint _value, bytes _code) internal returns (address o_addr) { return doCreate(_value, _code); } // confirm a transaction through just the hash. we use the previous transactions map, m_txs, in order // to determine the body of the transaction from the hash provided. function confirm(bytes32 _h) onlymanyowners(_h) returns (bool o_success) { if (m_txs[_h].to != 0 || m_txs[_h].value != 0 || m_txs[_h].data.length != 0) { address created; if (m_txs[_h].to == 0) { created = create(m_txs[_h].value, m_txs[_h].data); } else { require(m_txs[_h].to.call.value(m_txs[_h].value)(m_txs[_h].data)); } MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data, created); delete m_txs[_h]; return true; } } // INTERNAL METHODS function clearPending() internal { uint length = m_pendingIndex.length; for (uint i = 0; i < length; ++i) delete m_txs[m_pendingIndex[i]]; super.clearPending(); } // FIELDS // pending transactions we have at present. mapping (bytes32 => Transaction) m_txs; }
RE1
pragma solidity ^0.4.25; contract X_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function X_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.24; /** https://fortisgames.com https://fortisgames.com https://fortisgames.com https://fortisgames.com https://fortisgames.com FFFFFFFFFFFFFFFFFFFFFF tttt iiii F::::::::::::::::::::F ttt:::t i::::i F::::::::::::::::::::F t:::::t iiii FF::::::FFFFFFFFF::::F t:::::t F:::::F FFFFFFooooooooooo rrrrr rrrrrrrrr ttttttt:::::ttttttt iiiiiii ssssssssss F:::::F oo:::::::::::oo r::::rrr:::::::::r t:::::::::::::::::t i:::::i ss::::::::::s F::::::FFFFFFFFFFo:::::::::::::::or:::::::::::::::::r t:::::::::::::::::t i::::i ss:::::::::::::s F:::::::::::::::Fo:::::ooooo:::::orr::::::rrrrr::::::rtttttt:::::::tttttt i::::i s::::::ssss:::::s F:::::::::::::::Fo::::o o::::o r:::::r r:::::r t:::::t i::::i s:::::s ssssss F::::::FFFFFFFFFFo::::o o::::o r:::::r rrrrrrr t:::::t i::::i s::::::s F:::::F o::::o o::::o r:::::r t:::::t i::::i s::::::s F:::::F o::::o o::::o r:::::r t:::::t tttttt i::::i ssssss s:::::s FF:::::::FF o:::::ooooo:::::o r:::::r t::::::tttt:::::ti::::::is:::::ssss::::::s F::::::::FF o:::::::::::::::o r:::::r tt::::::::::::::ti::::::is::::::::::::::s F::::::::FF oo:::::::::::oo r:::::r tt:::::::::::tti::::::i s:::::::::::ss FFFFFFFFFFF ooooooooooo rrrrrrr ttttttttttt iiiiiiii sssssssssss Discord: https://discord.gg/gDtTX62 An interactive, variable-dividend rate contract with an ICO-capped price floor and collectibles. Bankroll contract, containing tokens purchased from all dividend-card profit and ICO dividends. Acts as token repository for games on the Zethr platform. **/ contract ZTHInterface { function buyAndSetDivPercentage(address _referredBy, uint8 _divChoice, string providedUnhashedPass) public payable returns (uint); function balanceOf(address who) public view returns (uint); function transfer(address _to, uint _value) public returns (bool); function transferFrom(address _from, address _toAddress, uint _amountOfTokens) public returns (bool); function exit() public; function sell(uint amountOfTokens) public; function withdraw(address _recipient) public; } contract ERC223Receiving { function tokenFallback(address _from, uint _amountOfTokens, bytes _data) public returns (bool); } contract ZethrBankroll is ERC223Receiving { using SafeMath for uint; /*================================= = EVENTS = =================================*/ event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event WhiteListAddition(address indexed contractAddress); event WhiteListRemoval(address indexed contractAddress); event RequirementChange(uint required); event DevWithdraw(uint amountTotal, uint amountPerPerson); event EtherLogged(uint amountReceived, address sender); event BankrollInvest(uint amountReceived); event DailyTokenAdmin(address gameContract); event DailyTokensSent(address gameContract, uint tokens); event DailyTokensReceived(address gameContract, uint tokens); /*================================= = WITHDRAWAL CONSTANTS = =================================*/ uint constant public MAX_OWNER_COUNT = 10; uint constant public MAX_WITHDRAW_PCT_DAILY = 15; uint constant public MAX_WITHDRAW_PCT_TX = 5; uint constant internal resetTimer = 1 days; /*================================= = ZTH INTERFACE = =================================*/ address internal zethrAddress; ZTHInterface public ZTHTKN; /*================================= = VARIABLES = =================================*/ mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; mapping (address => bool) public isWhitelisted; mapping (address => uint) public dailyTokensPerContract; address internal divCardAddress; address[] public owners; address[] public whiteListedContracts; uint public required; uint public transactionCount; uint internal dailyResetTime; uint internal dailyTknLimit; uint internal tknsDispensedToday; bool internal reEntered = false; /*================================= = CUSTOM CONSTRUCTS = =================================*/ struct Transaction { address destination; uint value; bytes data; bool executed; } struct TKN { address sender; uint value; } /*================================= = MODIFIERS = =================================*/ modifier onlyWallet() { if (msg.sender != address(this)) revert(); _; } modifier contractIsNotWhiteListed(address contractAddress) { if (isWhitelisted[contractAddress]) revert(); _; } modifier contractIsWhiteListed(address contractAddress) { if (!isWhitelisted[contractAddress]) revert(); _; } modifier isAnOwner() { address caller = msg.sender; if (!isOwner[caller]) revert(); _; } modifier ownerDoesNotExist(address owner) { if (isOwner[owner]) revert(); _; } modifier ownerExists(address owner) { if (!isOwner[owner]) revert(); _; } modifier transactionExists(uint transactionId) { if (transactions[transactionId].destination == 0) revert(); _; } modifier confirmed(uint transactionId, address owner) { if (!confirmations[transactionId][owner]) revert(); _; } modifier notConfirmed(uint transactionId, address owner) { if (confirmations[transactionId][owner]) revert(); _; } modifier notExecuted(uint transactionId) { if (transactions[transactionId].executed) revert(); _; } modifier notNull(address _address) { if (_address == 0) revert(); _; } modifier validRequirement(uint ownerCount, uint _required) { if ( ownerCount > MAX_OWNER_COUNT || _required > ownerCount || _required == 0 || ownerCount == 0) revert(); _; } /*================================= = LIST OF OWNERS = =================================*/ /* This list is for reference/identification purposes only, and comprises the eight core Zethr developers. For game contracts to be listed, they must be approved by a majority (i.e. currently five) of the owners. Contracts can be delisted in an emergency by a single owner. 0x4F4eBF556CFDc21c3424F85ff6572C77c514Fcae // Norsefire 0x11e52c75998fe2E7928B191bfc5B25937Ca16741 // klob 0x20C945800de43394F70D789874a4daC9cFA57451 // Etherguy 0xef764BAC8a438E7E498c2E5fcCf0f174c3E3F8dB // blurr 0x8537aa2911b193e5B377938A723D805bb0865670 // oguzhanox 0x9D221b2100CbE5F05a0d2048E2556a6Df6f9a6C3 // Randall 0x71009e9E4e5e68e77ECc7ef2f2E95cbD98c6E696 // cryptodude 0xDa83156106c4dba7A26E9bF2Ca91E273350aa551 // TropicalRogue */ /*================================= = PUBLIC FUNCTIONS = =================================*/ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor (address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { if (isOwner[_owners[i]] || _owners[i] == 0) revert(); isOwner[_owners[i]] = true; } owners = _owners; required = _required; dailyResetTime = now - (1 days); } /** Testing only. function exitAll() public { uint tokenBalance = ZTHTKN.balanceOf(address(this)); ZTHTKN.sell(tokenBalance - 1e18); ZTHTKN.sell(1e18); ZTHTKN.withdraw(address(0x0)); } **/ function addZethrAddresses(address _zethr, address _divcards) public isAnOwner { zethrAddress = _zethr; divCardAddress = _divcards; ZTHTKN = ZTHInterface(zethrAddress); } /// @dev Fallback function allows Ether to be deposited. function() public payable { } uint NonICOBuyins; function deposit() public payable { NonICOBuyins = NonICOBuyins.add(msg.value); } /// @dev Function to buy tokens with contract eth balance. function buyTokens() public payable isAnOwner { uint savings = address(this).balance; if (savings > 0.01 ether) { ZTHTKN.buyAndSetDivPercentage.value(savings)(address(0x0), 33, ""); emit BankrollInvest(savings); } else { emit EtherLogged(msg.value, msg.sender); } } function tokenFallback(address /*_from*/, uint /*_amountOfTokens*/, bytes /*_data*/) public returns (bool) { // Nothing, for now. Just receives tokens. } /// @dev Calculates if an amount of tokens exceeds the aggregate daily limit of 15% of contract /// balance or 5% of the contract balance on its own. function permissibleTokenWithdrawal(uint _toWithdraw) public returns(bool) { uint currentTime = now; uint tokenBalance = ZTHTKN.balanceOf(address(this)); uint maxPerTx = (tokenBalance.mul(MAX_WITHDRAW_PCT_TX)).div(100); require (_toWithdraw <= maxPerTx); if (currentTime - dailyResetTime >= resetTimer) { dailyResetTime = currentTime; dailyTknLimit = (tokenBalance.mul(MAX_WITHDRAW_PCT_DAILY)).div(100); tknsDispensedToday = _toWithdraw; return true; } else { if (tknsDispensedToday.add(_toWithdraw) <= dailyTknLimit) { tknsDispensedToday += _toWithdraw; return true; } else { return false; } } } /// @dev Allows us to set the daily Token Limit function setDailyTokenLimit(uint limit) public isAnOwner { dailyTknLimit = limit; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); emit OwnerAddition(owner); } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. function removeOwner(address owner) public onlyWallet ownerExists(owner) validRequirement(owners.length, required) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); emit OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param owner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; isOwner[newOwner] = true; emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; emit RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txToExecute = transactions[transactionId]; txToExecute.executed = true; if (txToExecute.destination.call.value(txToExecute.value)(txToExecute.data)) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txToExecute.executed = false; } } } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i=0; i<owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /*================================= = OPERATOR FUNCTIONS = =================================*/ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; emit Submission(transactionId); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return Number of confirmations. function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public constant returns (address[]) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return Returns array of owner addresses. function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i=0; i<count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Returns array of transaction IDs. function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint[](to - from); for (i=from; i<to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } // Additions for Bankroll function whiteListContract(address contractAddress) public isAnOwner contractIsNotWhiteListed(contractAddress) notNull(contractAddress) { isWhitelisted[contractAddress] = true; whiteListedContracts.push(contractAddress); // We set the daily tokens for a particular contract in a separate call. dailyTokensPerContract[contractAddress] = 0; emit WhiteListAddition(contractAddress); } // Remove a whitelisted contract. This is an exception to the norm in that // it can be invoked directly by any owner, in the event that a game is found // to be bugged or otherwise faulty, so it can be shut down as an emergency measure. // Iterates through the whitelisted contracts to find contractAddress, // then swaps it with the last address in the list - then decrements length function deWhiteListContract(address contractAddress) public isAnOwner contractIsWhiteListed(contractAddress) { isWhitelisted[contractAddress] = false; for (uint i=0; i < whiteListedContracts.length - 1; i++) if (whiteListedContracts[i] == contractAddress) { whiteListedContracts[i] = owners[whiteListedContracts.length - 1]; break; } whiteListedContracts.length -= 1; emit WhiteListRemoval(contractAddress); } function contractTokenWithdraw(uint amount, address target) public contractIsWhiteListed(msg.sender) { require(isWhitelisted[msg.sender]); require(ZTHTKN.transfer(target, amount)); } // Alters the amount of tokens allocated to a game contract on a daily basis. function alterTokenGrant(address _contract, uint _newAmount) public isAnOwner contractIsWhiteListed(_contract) { dailyTokensPerContract[_contract] = _newAmount; } function queryTokenGrant(address _contract) public view returns (uint) { return dailyTokensPerContract[_contract]; } // Function to be run by an owner (ideally on a cron job) which performs daily // token collection and dispersal for all whitelisted contracts. function dailyAccounting() public isAnOwner { for (uint i=0; i < whiteListedContracts.length; i++) { address _contract = whiteListedContracts[i]; if ( dailyTokensPerContract[_contract] > 0 ) { allocateTokens(_contract); emit DailyTokenAdmin(_contract); } } } // In the event that we want to manually take tokens back from a whitelisted contract, // we can do so. function retrieveTokens(address _contract, uint _amount) public isAnOwner contractIsWhiteListed(_contract) { require(ZTHTKN.transferFrom(_contract, address(this), _amount)); } // Dispenses daily amount of ZTH to whitelisted contract, or retrieves the excess. // Block withdraws greater than MAX_WITHDRAW_PCT_TX of Zethr token balance. // (May require occasional adjusting of the daily token allocation for contracts.) function allocateTokens(address _contract) public isAnOwner contractIsWhiteListed(_contract) { uint dailyAmount = dailyTokensPerContract[_contract]; uint zthPresent = ZTHTKN.balanceOf(_contract); // Make sure that tokens aren't sent to a contract which is in the black. if (zthPresent <= dailyAmount) { // We need to send tokens over, make sure it's a permitted amount, and then send. uint toDispense = dailyAmount.sub(zthPresent); // Make sure amount is <= tokenbalance*MAX_WITHDRAW_PCT_TX require(permissibleTokenWithdrawal(toDispense)); require(ZTHTKN.transfer(_contract, toDispense)); emit DailyTokensSent(_contract, toDispense); } else { // The contract in question has made a profit: retrieve the excess tokens. uint toRetrieve = zthPresent.sub(dailyAmount); require(ZTHTKN.transferFrom(_contract, address(this), toRetrieve)); emit DailyTokensReceived(_contract, toRetrieve); } emit DailyTokenAdmin(_contract); } // Dev withdrawal of tokens - splits equally among all owners of contract function devTokenWithdraw(uint amount) public onlyWallet { require(permissibleTokenWithdrawal(amount)); uint amountPerPerson = SafeMath.div(amount, owners.length); for (uint i=0; i<owners.length; i++) { ZTHTKN.transfer(owners[i], amountPerPerson); } emit DevWithdraw(amount, amountPerPerson); } // Change the dividend card address. Can't see why this would ever need // to be invoked, but better safe than sorry. function changeDivCardAddress(address _newDivCardAddress) public isAnOwner { divCardAddress = _newDivCardAddress; } // Receive Ether (from Zethr itself or any other source) and purchase tokens at the 33% dividend rate. // If the amount is less than 0.01 Ether, the Ether is stored by the contract until the balance // exceeds that limit and then purchases all it can. function receiveDividends() public payable { if (!reEntered) { uint ActualBalance = (address(this).balance.sub(NonICOBuyins)); if (ActualBalance > 0.01 ether) { reEntered = true; ZTHTKN.buyAndSetDivPercentage.value(ActualBalance)(address(0x0), 33, ""); emit BankrollInvest(ActualBalance); reEntered = false; } } } // Use all available balance to buy in function buyInWithAllBalanced() public payable isAnOwner { if (!reEntered) { uint balance = address(this).balance; require (balance > 0.01 ether); ZTHTKN.buyAndSetDivPercentage.value(balance)(address(0x0), 33, ""); } } /*================================= = UTILITIES = =================================*/ // Convert an hexadecimal character to their value function fromHexChar(uint c) public pure returns (uint) { if (byte(c) >= byte('0') && byte(c) <= byte('9')) { return c - uint(byte('0')); } if (byte(c) >= byte('a') && byte(c) <= byte('f')) { return 10 + c - uint(byte('a')); } if (byte(c) >= byte('A') && byte(c) <= byte('F')) { return 10 + c - uint(byte('A')); } } // Convert an hexadecimal string to raw bytes function fromHex(string s) public pure returns (bytes) { bytes memory ss = bytes(s); require(ss.length%2 == 0); // length must be even bytes memory r = new bytes(ss.length/2); for (uint i=0; i<ss.length/2; ++i) { r[i] = byte(fromHexChar(uint(ss[2*i])) * 16 + fromHexChar(uint(ss[2*i+1]))); } return r; } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint a, uint b) internal pure returns (uint) { if (a == 0) { return 0; } uint c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint a, uint b) internal pure returns (uint) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); return c; } }
RE1
pragma solidity ^0.4.25; contract c_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function c_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.20; // File: contracts/ERC20Token.sol library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Owned { address public owner; address newOwner; modifier only(address _allowed) { require(msg.sender == _allowed); _; } constructor() public { owner = msg.sender; } function transferOwnership(address _newOwner) only(owner) public { newOwner = _newOwner; } function acceptOwnership() only(newOwner) public { emit OwnershipTransferred(owner, newOwner); owner = newOwner; } event OwnershipTransferred(address indexed _from, address indexed _to); } contract ERC20 is Owned { using SafeMath for uint; uint public totalSupply; bool public isStarted = false; mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; modifier isStartedOnly() { require(isStarted); _; } modifier isNotStartedOnly() { require(!isStarted); _; } event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) isStartedOnly public returns (bool success) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) isStartedOnly public returns (bool success) { require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint balance) { return balances[_owner]; } function approve_fixed(address _spender, uint _currentValue, uint _value) isStartedOnly public returns (bool success) { if(allowed[msg.sender][_spender] == _currentValue){ allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } else { return false; } } function approve(address _spender, uint _value) isStartedOnly public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint remaining) { return allowed[_owner][_spender]; } } contract Token is ERC20 { using SafeMath for uint; string public name; string public symbol; uint8 public decimals; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } function start() public only(owner) isNotStartedOnly { isStarted = true; } //================= Crowdsale Only ================= function mint(address _to, uint _amount) public only(owner) isNotStartedOnly returns(bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function multimint(address[] dests, uint[] values) public only(owner) isNotStartedOnly returns (uint) { uint i = 0; while (i < dests.length) { mint(dests[i], values[i]); i += 1; } return(i); } } contract TokenWithoutStart is Owned { using SafeMath for uint; mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; string public name; string public symbol; uint8 public decimals; uint public totalSupply; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint balance) { return balances[_owner]; } function approve_fixed(address _spender, uint _currentValue, uint _value) public returns (bool success) { if(allowed[msg.sender][_spender] == _currentValue){ allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } else { return false; } } function approve(address _spender, uint _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint remaining) { return allowed[_owner][_spender]; } function mint(address _to, uint _amount) public only(owner) returns(bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function multimint(address[] dests, uint[] values) public only(owner) returns (uint) { uint i = 0; while (i < dests.length) { mint(dests[i], values[i]); i += 1; } return(i); } } // File: contracts/KvantorSet.sol // DEPLOYED BY JURY.ONLINE contract ICOContractX { // GENERAL ICO PARAMS ------------------------------------------------------ string public name; address public operator; // the ICO operator address public projectWallet; // the wallet that receives ICO Funds Token public token; // ICO token address public juryOnlineWallet; // JuryOnline Wallet for commission address public arbitrationAddress; // Address of Arbitration Contract uint public currentCycle; // current cycle struct Cycle { bool exists; bool approved; address icoRoundAddress; } mapping(uint => Cycle) public cycles; // stores the approved Cycles // DEPLOYED BY JURY.ONLINE // PARAMS: // address _operator // address _projectWallet // address _tokenAddress // address _arbitrationAddress // address _juryOnlineWallet constructor(string _name, address _operator, address _projectWallet, address _tokenAddress, address _arbitrationAddress, address _juryOnlineWallet) public { name = _name; operator = _operator; projectWallet = _projectWallet; token = Token(_tokenAddress); arbitrationAddress = _arbitrationAddress; juryOnlineWallet = _juryOnlineWallet; } // CALLED BY CYCLE CONTRACT function addRound() public { cycles[currentCycle].exists = true; cycles[currentCycle].icoRoundAddress = msg.sender; } // CALLED BY ICO OPERATOR, approves CYCLE Contract and adds it to cycles function approveRound(address _icoRoundAddress) public { require(msg.sender == operator); require(cycles[currentCycle].icoRoundAddress == _icoRoundAddress); currentCycle +=1; } } // DEPLOYED BY JURY.ONLINE contract ICOCycle { using SafeMath for uint; // GENERAL CYCLE VARIABLES ------------------------------------------------- address public juryOperator; // assists in operation address public operator; // cycle operator, same as ICO operator address public icoAddress; // to associate Cycle with ICO address public juryOnlineWallet; // juryOnlineWallet for commission address public projectWallet; // taken from ICO contract address public arbitrationAddress; // taken from ICO contract Token public token; // taken from ICO contract address public swapper; // address for JOT commission bool public saveMe; // if true, gives Jury.Online control of contract struct Milestone { uint etherAmount; //how many Ether is needed for this milestone uint tokenAmount; //how many tokens releases this milestone uint startTime; //real time when milestone has started, set upon start uint finishTime; //real time when milestone has finished, set upon finish uint duration; //assumed duration for milestone implementation, set upon milestone creation string description; string result; } Milestone[] public milestones; // List of Milestones uint public currentMilestone; uint public sealTimestamp; // the moment the Cycle is Sealed by operator uint public ethForMilestone; // Amount to be withdraw by operator for each milestone uint public postDisputeEth; // in case of dispute in favor of ico project // INVESTOR struct stores information about each Investor // Investor can have more than one deals, but only one right to dispute struct Investor { bool disputing; uint tokenAllowance; uint etherUsed; uint sumEther; uint sumToken; bool verdictForProject; bool verdictForInvestor; uint numberOfDeals; } struct Deal { address investor; uint etherAmount; uint tokenAmount; bool accepted; } mapping(address => Investor) public deals; // map of information of investors with deals address[] public dealsList; // list of investors with deals mapping(address => mapping(uint => Deal)) public offers; // pending offers // COMMISSION ARRAYS // amounts stores as percentage // If length == 1, commission paid when investment is accepted // If length > 1, each element is commission to corresponding milestone // ETH commission is transferred to Jury.Online wallet // JOT commission is transferred to a Swapper contract that swaps eth for jot uint[] public commissionEth; uint[] public commissionJot; uint public etherAllowance; // Amount that Jury.Online can withdraw as commission in ETH uint public jotAllowance; // Amount that Jury.Online can withdraw as commission in JOT uint public totalEther; // Sum of ether in milestones uint public totalToken; // Sum of tokens in milestones uint public promisedTokens; // Sum of tokens promised by accepting offer uint public raisedEther; // Sum of ether raised by accepting offer uint public rate; // eth to token rate in current Funding Round bool public tokenReleaseAtStart; // whether to release tokens at start or by each milestone uint public currentFundingRound; bool public roundFailedToStart; // Stores amount of ether and tokens per milestone for each investor mapping(address => uint[]) public etherPartition; mapping(address => uint[]) public tokenPartition; // Funding Rounds can be added with start, end time, rate, and whitelist struct FundingRound { uint startTime; uint endTime; uint rate; bool hasWhitelist; } FundingRound[] public roundPrices; // stores list of funding rounds mapping(uint => mapping(address => bool)) public whitelist; // stores whitelists // ------------------------------------------------------------------------- // MODIFIERS modifier onlyOperator() { require(msg.sender == operator || msg.sender == juryOperator); _; } modifier onlyAdmin() { require(msg.sender == operator || msg.sender == juryOperator); _; } modifier sealed() { require(sealTimestamp != 0); /* require(now > sealTimestamp); */ _; } modifier notSealed() { require(sealTimestamp == 0); /* require(now <= sealTimestamp); */ _; } // ------------------------------------------------------------------------- // DEPLOYED BY JURY.ONLINE // PARAMS: // address _icoAddress // address _operator // uint _rate // address _swapper // uint[] _commissionEth // uint[] _commissionJot constructor( address _icoAddress, address _operator, uint _rate, address _swapper, uint[] _commissionEth, uint[] _commissionJot) public { require(_commissionEth.length == _commissionJot.length); juryOperator = msg.sender; icoAddress = _icoAddress; operator = _operator; rate = _rate; swapper = _swapper; commissionEth = _commissionEth; commissionJot = _commissionJot; roundPrices.push(FundingRound(0,0,0,false)); tokenReleaseAtStart = true; } // CALLED BY JURY.ONLINE TO SET SWAPPER ADDRESS FOR JOT COMMISSION function setSwapper(address _swapper) public { require(msg.sender == juryOperator); swapper = _swapper; } // CALLED BY ADMIN TO RETRIEVE INFORMATION FROM ICOADDRESS AND ADD ITSELF // TO LIST OF CYCLES IN ICO function activate() onlyAdmin notSealed public { ICOContractX icoContract = ICOContractX(icoAddress); require(icoContract.operator() == operator); juryOnlineWallet = icoContract.juryOnlineWallet(); projectWallet = icoContract.projectWallet(); arbitrationAddress = icoContract.arbitrationAddress(); token = icoContract.token(); icoContract.addRound(); } // CALLED BY JURY.ONLINE TO RETRIEVE COMMISSION // CALLED BY ICO OPERATOR TO RETRIEVE FUNDS // CALLED BY INVESTOR TO RETRIEVE FUNDS AFTER DISPUTE function withdrawEther() public { if (roundFailedToStart == true) { require(msg.sender.send(deals[msg.sender].sumEther)); } if (msg.sender == operator) { require(projectWallet.send(ethForMilestone+postDisputeEth)); ethForMilestone = 0; postDisputeEth = 0; } if (msg.sender == juryOnlineWallet) { require(juryOnlineWallet.send(etherAllowance)); require(swapper.call.value(jotAllowance)(abi.encodeWithSignature("swapMe()"))); etherAllowance = 0; jotAllowance = 0; } if (deals[msg.sender].verdictForInvestor == true) { require(msg.sender.send(deals[msg.sender].sumEther - deals[msg.sender].etherUsed)); } } // CALLED BY INVESTOR TO RETRIEVE TOKENS function withdrawToken() public { require(token.transfer(msg.sender,deals[msg.sender].tokenAllowance)); deals[msg.sender].tokenAllowance = 0; } // CALLED BY ICO OPERATOR TO ADD FUNDING ROUNDS WITH _startTime,_endTime,_price,_whitelist function addRoundPrice(uint _startTime,uint _endTime, uint _price, address[] _whitelist) public onlyOperator { if (_whitelist.length == 0) { roundPrices.push(FundingRound(_startTime, _endTime,_price,false)); } else { for (uint i=0 ; i < _whitelist.length ; i++ ) { whitelist[roundPrices.length][_whitelist[i]] = true; } roundPrices.push(FundingRound(_startTime, _endTime,_price,true)); } } // CALLED BY ICO OPERATOR TO SET RATE WITHOUT SETTING FUNDING ROUND function setRate(uint _rate) onlyOperator public { rate = _rate; } // CALLED BY ICO OPERATOR TO APPLY WHITELIST AND PRICE OF FUNDING ROUND function setCurrentFundingRound(uint _fundingRound) public onlyOperator { require(roundPrices.length > _fundingRound); currentFundingRound = _fundingRound; } // RECEIVES FUNDS AND CREATES OFFER function () public payable { require(msg.value > 0); if (roundPrices[currentFundingRound].hasWhitelist == true) { require(whitelist[currentFundingRound][msg.sender] == true); } uint dealNumber = deals[msg.sender].numberOfDeals; offers[msg.sender][dealNumber].investor = msg.sender; offers[msg.sender][dealNumber].etherAmount = msg.value; deals[msg.sender].numberOfDeals += 1; } // CALCULATES AMOUNT OF TOKENS FOR GIVEN ETH function calculateTokens(uint256 _weiAmount) constant public returns (uint256) { uint256 tokens = _weiAmount.mul(rate).mul(100).div(75).div(100 finney); if(tokens.div(100000000) < 5000) return _weiAmount.mul(rate).mul(100).div(80).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(73).div(100 finney); if(tokens.div(100000000) < 25000) return _weiAmount.mul(rate).mul(100).div(75).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(70).div(100 finney); if(tokens.div(100000000) < 50000) return _weiAmount.mul(rate).mul(100).div(73).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(65).div(100 finney); if(tokens.div(100000000) < 250000) return _weiAmount.mul(rate).mul(100).div(70).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(60).div(100 finney); if(tokens.div(100000000) < 500000) return _weiAmount.mul(rate).mul(100).div(65).div(100 finney); return _weiAmount.mul(rate).mul(100).div(60).div(100 finney); } // IF OFFER NOT ACCEPTED, CAN BE WITHDRAWN function withdrawOffer(uint _offerNumber) public { require(offers[msg.sender][_offerNumber].accepted == false); require(msg.sender.send(offers[msg.sender][_offerNumber].etherAmount)); offers[msg.sender][_offerNumber].etherAmount = 0; /* offers[msg.sender][_offerNumber].tokenAmount = 0; */ } // ARBITRATION // CALLED BY ARBITRATION ADDRESS function disputeOpened(address _investor) public { require(msg.sender == arbitrationAddress); deals[_investor].disputing = true; } // CALLED BY ARBITRATION ADDRESS function verdictExecuted(address _investor, bool _verdictForInvestor,uint _milestoneDispute) public { require(msg.sender == arbitrationAddress); require(deals[_investor].disputing == true); if (_verdictForInvestor) { deals[_investor].verdictForInvestor = true; } else { deals[_investor].verdictForProject = true; for (uint i = _milestoneDispute; i < currentMilestone; i++) { postDisputeEth += etherPartition[_investor][i]; deals[_investor].etherUsed += etherPartition[_investor][i]; } } deals[_investor].disputing = false; } // OPERATOR // TO ADD MILESTONES function addMilestone(uint _etherAmount, uint _tokenAmount, uint _startTime, uint _duration, string _description) public notSealed onlyOperator returns(uint) { totalEther = totalEther.add(_etherAmount); totalToken = totalToken.add(_tokenAmount); return milestones.push(Milestone(_etherAmount, _tokenAmount, _startTime, 0, _duration, _description, "")); } // TO SEAL function seal() public notSealed onlyOperator { require(milestones.length > 0); require(token.balanceOf(address(this)) >= totalToken); sealTimestamp = now; } // TO ACCEPT OFFER function acceptOffer(address _investor, uint _offerNumber) public sealed onlyOperator { // REQUIRE THAT OFFER HAS NOT BEEN APPROVED require(offers[_investor][_offerNumber].etherAmount > 0); require(offers[_investor][_offerNumber].accepted != true); // APPROVE OFFER offers[_investor][_offerNumber].accepted = true; // CALCULATE TOKENS uint _etherAmount = offers[_investor][_offerNumber].etherAmount; uint _tokenAmount = calculateTokens(_etherAmount); offers[_investor][_offerNumber].tokenAmount = _tokenAmount; //require(token.balanceOf(address(this)) >= promisedTokens + _tokenAmount); // CALCULATE COMMISSION if (commissionEth.length == 1) { uint etherCommission = _etherAmount.mul(commissionEth[0]).div(100); uint jotCommission = _etherAmount.mul(commissionJot[0]).div(100); _etherAmount = _etherAmount.sub(etherCommission).sub(jotCommission); offers[_investor][_offerNumber].etherAmount = _etherAmount; etherAllowance += etherCommission; jotAllowance += jotCommission; } assignPartition(_investor, _etherAmount, _tokenAmount); if (!(deals[_investor].sumEther > 0)) dealsList.push(_investor); if (tokenReleaseAtStart == true) { deals[_investor].tokenAllowance = _tokenAmount; } /* deals[_investor].numberOfDeals += 1; */ deals[_investor].sumEther += _etherAmount; deals[_investor].sumToken += _tokenAmount; } // TO START MILESTONE function startMilestone() public sealed onlyOperator { // UNCOMMENT 2 LINES BELOW FOR PROJECT FAILS START IF totalEther < raisedEther // if (currentMilestone == 0 && totalEther < raisedEther) { roundFailedToStart = true; } // require(!roundFailedToStart); if (currentMilestone != 0 ) {require(milestones[currentMilestone-1].finishTime > 0);} for (uint i=0; i < dealsList.length ; i++) { address investor = dealsList[i]; if (deals[investor].disputing == false) { if (deals[investor].verdictForInvestor != true) { ethForMilestone += etherPartition[investor][currentMilestone]; deals[investor].etherUsed += etherPartition[investor][currentMilestone]; if (tokenReleaseAtStart == false) { deals[investor].tokenAllowance += tokenPartition[investor][currentMilestone]; } } } } milestones[currentMilestone].startTime = now; currentMilestone +=1; //ethAfterCommission = payCommission(); } // TO FINISH MILESTONE function finishMilestone(string _result) public onlyOperator { require(milestones[currentMilestone-1].finishTime == 0); uint interval = now - milestones[currentMilestone-1].startTime; require(interval > 1 weeks); milestones[currentMilestone-1].finishTime = now; milestones[currentMilestone-1].result = _result; } // ------------------------------------------------------------------------- // // HELPERS ----------------------------------------------------------------- function failSafe() public onlyAdmin { if (msg.sender == operator) { saveMe = true; } if (msg.sender == juryOperator) { require(saveMe == true); require(juryOperator.send(address(this).balance)); uint allTheLockedTokens = token.balanceOf(this); require(token.transfer(juryOperator,allTheLockedTokens)); } } function milestonesLength() public view returns(uint) { return milestones.length; } function assignPartition(address _investor, uint _etherAmount, uint _tokenAmount) internal { uint milestoneEtherAmount; //How much Ether does investor send for a milestone uint milestoneTokenAmount; //How many Tokens does investor receive for a milestone uint milestoneEtherTarget; //How much TOTAL Ether a milestone needs uint milestoneTokenTarget; //How many TOTAL tokens a milestone releases uint totalEtherInvestment; uint totalTokenInvestment; for(uint i=currentMilestone; i<milestones.length; i++) { milestoneEtherTarget = milestones[i].etherAmount; milestoneTokenTarget = milestones[i].tokenAmount; milestoneEtherAmount = _etherAmount.mul(milestoneEtherTarget).div(totalEther); milestoneTokenAmount = _tokenAmount.mul(milestoneTokenTarget).div(totalToken); totalEtherInvestment = totalEtherInvestment.add(milestoneEtherAmount); //used to prevent rounding errors totalTokenInvestment = totalTokenInvestment.add(milestoneTokenAmount); //used to prevent rounding errors if (deals[_investor].sumEther > 0) { etherPartition[_investor][i] += milestoneEtherAmount; tokenPartition[_investor][i] += milestoneTokenAmount; } else { etherPartition[_investor].push(milestoneEtherAmount); tokenPartition[_investor].push(milestoneTokenAmount); } } /* roundingErrors += _etherAmount - totalEtherInvestment; */ etherPartition[_investor][currentMilestone] += _etherAmount - totalEtherInvestment; //rounding error is added to the first milestone tokenPartition[_investor][currentMilestone] += _tokenAmount - totalTokenInvestment; //rounding error is added to the first milestone } function isDisputing(address _investor) public view returns(bool) { return deals[_investor].disputing; } function investorExists(address _investor) public view returns(bool) { if (deals[_investor].sumEther > 0) return true; else return false; } } contract ArbitrationX is Owned { address public operator; uint public quorum = 3; //uint public counter; struct Dispute { address icoRoundAddress; address investorAddress; bool pending; uint timestamp; uint milestone; string reason; uint votesForProject; uint votesForInvestor; // bool verdictForProject; // bool verdictForInvestor; mapping(address => bool) voters; } mapping(uint => Dispute) public disputes; uint public disputeLength; mapping(address => mapping(address => bool)) public arbiterPool; modifier only(address _allowed) { require(msg.sender == _allowed); _; } constructor() public { operator = msg.sender; } // OPERATOR function setArbiters(address _icoRoundAddress, address[] _arbiters) only(owner) public { for (uint i = 0; i < _arbiters.length ; i++) { arbiterPool[_icoRoundAddress][_arbiters[i]] = true; } } // ARBITER function vote(uint _disputeId, bool _voteForInvestor) public { require(disputes[_disputeId].pending == true); require(arbiterPool[disputes[_disputeId].icoRoundAddress][msg.sender] == true); require(disputes[_disputeId].voters[msg.sender] != true); if (_voteForInvestor == true) { disputes[_disputeId].votesForInvestor += 1; } else { disputes[_disputeId].votesForProject += 1; } if (disputes[_disputeId].votesForInvestor == quorum) { executeVerdict(_disputeId,true); } if (disputes[_disputeId].votesForProject == quorum) { executeVerdict(_disputeId,false); } disputes[_disputeId].voters[msg.sender] == true; } // INVESTOR function openDispute(address _icoRoundAddress, string _reason) public { ICOCycle icoRound = ICOCycle(_icoRoundAddress); uint milestoneDispute = icoRound.currentMilestone(); require(milestoneDispute > 0); require(icoRound.investorExists(msg.sender) == true); disputes[disputeLength].milestone = milestoneDispute; disputes[disputeLength].icoRoundAddress = _icoRoundAddress; disputes[disputeLength].investorAddress = msg.sender; disputes[disputeLength].timestamp = now; disputes[disputeLength].reason = _reason; disputes[disputeLength].pending = true; icoRound.disputeOpened(msg.sender); disputeLength +=1; } // INTERNAL function executeVerdict(uint _disputeId, bool _verdictForInvestor) internal { disputes[_disputeId].pending = false; uint milestoneDispute = disputes[_disputeId].milestone; ICOCycle icoRound = ICOCycle(disputes[_disputeId].icoRoundAddress); icoRound.verdictExecuted(disputes[_disputeId].investorAddress,_verdictForInvestor,milestoneDispute); //counter +=1; } function isPending(uint _disputedId) public view returns(bool) { return disputes[_disputedId].pending; } } contract Swapper { // for an ethToJot of 2,443.0336457941, Aug 21, 2018 Token public token; uint public ethToJot = 2443; address public owner; constructor(address _jotAddress) public { owner = msg.sender; token = Token(_jotAddress); } function swapMe() public payable { uint jot = msg.value * ethToJot; require(token.transfer(owner,jot)); } // In the future, this contract would call a trusted Oracle // instead of being set by its owner function setEth(uint _newEth) public { require(msg.sender == owner); ethToJot = _newEth; } } contract SwapperX { Token public proxyToken; Token public token; address public owner; struct Swap { address _from; uint _amount; } Swap[] public swaps; constructor(address _tokenAddress, address _proxyTokenAddress) public { owner = msg.sender; token = Token(_tokenAddress); proxyToken = Token(_proxyTokenAddress); } // SWAPS PROXY TOKENS FOR ICO TOKENS function swapMe() public { uint allowance = proxyToken.allowance(msg.sender,address(this)); require(token.balanceOf(address(this)) >= allowance); require(token.transfer(msg.sender, allowance)); require(proxyToken.transferFrom(msg.sender,address(this),allowance)); swaps.push(Swap(msg.sender,allowance)); } // REFUNDS TOKEN HOLDERS ALLOWANCE function returnMe() public { uint allowance = proxyToken.allowance(msg.sender,address(this)); require(proxyToken.transferFrom(msg.sender,address(this),allowance)); require(proxyToken.transfer(msg.sender, allowance)); } }
RE1
pragma solidity ^ 0.4.13; contract MigrationAgent { function migrateFrom(address _from, uint256 _value); } contract PreArtexToken { struct Investor { uint amountTokens; uint amountWei; } uint public etherPriceUSDWEI; address public beneficiary; uint public totalLimitUSDWEI; uint public minimalSuccessUSDWEI; uint public collectedUSDWEI; uint public state; uint public crowdsaleStartTime; uint public crowdsaleFinishTime; mapping(address => Investor) public investors; mapping(uint => address) public investorsIter; uint public numberOfInvestors; } contract Owned { address public owner; address public newOwner; address public oracle; address public btcOracle; function Owned() payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } modifier onlyOwnerOrOracle { require(owner == msg.sender || oracle == msg.sender); _; } modifier onlyOwnerOrBtcOracle { require(owner == msg.sender || btcOracle == msg.sender); _; } function changeOwner(address _owner) onlyOwner external { require(_owner != 0); newOwner = _owner; } function confirmOwner() external { require(newOwner == msg.sender); owner = newOwner; delete newOwner; } function changeOracle(address _oracle) onlyOwner external { require(_oracle != 0); oracle = _oracle; } function changeBtcOracle(address _btcOracle) onlyOwner external { require(_btcOracle != 0); btcOracle = _btcOracle; } } contract KnownContract { function transfered(address _sender, uint256 _value, bytes32[] _data) external; } contract ERC20 { uint public totalSupply; function balanceOf(address who) constant returns(uint); function transfer(address to, uint value); function allowance(address owner, address spender) constant returns(uint); function transferFrom(address from, address to, uint value); function approve(address spender, uint value); event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); } contract Stateful { enum State { Initial, PreSale, WaitingForSale, Sale, CrowdsaleCompleted, SaleFailed } State public state = State.Initial; event StateChanged(State oldState, State newState); function setState(State newState) internal { State oldState = state; state = newState; StateChanged(oldState, newState); } } contract Crowdsale is Owned, Stateful { uint public etherPriceUSDWEI; address public beneficiary; uint public totalLimitUSDWEI; uint public minimalSuccessUSDWEI; uint public collectedUSDWEI; uint public crowdsaleStartTime; uint public crowdsaleFinishTime; uint public tokenPriceUSDWEI = 100000000000000000; struct Investor { uint amountTokens; uint amountWei; } struct BtcDeposit { uint amountBTCWEI; uint btcPriceUSDWEI; address investor; } mapping(bytes32 => BtcDeposit) public btcDeposits; mapping(address => Investor) public investors; mapping(uint => address) public investorsIter; uint public numberOfInvestors; mapping(uint => address) public investorsToWithdrawIter; uint public numberOfInvestorsToWithdraw; function Crowdsale() payable Owned() {} //abstract methods function emitTokens(address _investor, uint _usdwei) internal returns(uint tokensToEmit); function emitAdditionalTokens() internal; function burnTokens(address _address, uint _amount) internal; function() payable crowdsaleState limitNotExceeded crowdsaleNotFinished { uint valueWEI = msg.value; uint valueUSDWEI = valueWEI * etherPriceUSDWEI / 1 ether; if (collectedUSDWEI + valueUSDWEI > totalLimitUSDWEI) { // don't need so much ether valueUSDWEI = totalLimitUSDWEI - collectedUSDWEI; valueWEI = valueUSDWEI * 1 ether / etherPriceUSDWEI; uint weiToReturn = msg.value - valueWEI; bool isSent = msg.sender.call.gas(3000000).value(weiToReturn)(); require(isSent); collectedUSDWEI = totalLimitUSDWEI; // to be sure! } else { collectedUSDWEI += valueUSDWEI; } emitTokensFor(msg.sender, valueUSDWEI, valueWEI); } function depositUSD(address _to, uint _amountUSDWEI) external onlyOwner crowdsaleState limitNotExceeded crowdsaleNotFinished { collectedUSDWEI += _amountUSDWEI; emitTokensFor(_to, _amountUSDWEI, 0); } function depositBTC(address _to, uint _amountBTCWEI, uint _btcPriceUSDWEI, bytes32 _btcTxId) external onlyOwnerOrBtcOracle crowdsaleState limitNotExceeded crowdsaleNotFinished { uint valueUSDWEI = _amountBTCWEI * _btcPriceUSDWEI / 1 ether; BtcDeposit storage btcDep = btcDeposits[_btcTxId]; require(btcDep.amountBTCWEI == 0); btcDep.amountBTCWEI = _amountBTCWEI; btcDep.btcPriceUSDWEI = _btcPriceUSDWEI; btcDep.investor = _to; collectedUSDWEI += valueUSDWEI; emitTokensFor(_to, valueUSDWEI, 0); } function emitTokensFor(address _investor, uint _valueUSDWEI, uint _valueWEI) internal { var emittedTokens = emitTokens(_investor, _valueUSDWEI); Investor storage inv = investors[_investor]; if (inv.amountTokens == 0) { // new investor investorsIter[numberOfInvestors++] = _investor; } inv.amountTokens += emittedTokens; if (state == State.Sale) { inv.amountWei += _valueWEI; } } function startPreSale( address _beneficiary, uint _etherPriceUSDWEI, uint _totalLimitUSDWEI, uint _crowdsaleDurationDays) external onlyOwner { require(state == State.Initial); crowdsaleStartTime = now; beneficiary = _beneficiary; etherPriceUSDWEI = _etherPriceUSDWEI; totalLimitUSDWEI = _totalLimitUSDWEI; crowdsaleFinishTime = now + _crowdsaleDurationDays * 1 days; collectedUSDWEI = 0; setState(State.PreSale); } function finishPreSale() public onlyOwner { require(state == State.PreSale); bool isSent = beneficiary.call.gas(3000000).value(this.balance)(); require(isSent); setState(State.WaitingForSale); } function startSale( address _beneficiary, uint _etherPriceUSDWEI, uint _totalLimitUSDWEI, uint _crowdsaleDurationDays, uint _minimalSuccessUSDWEI) external onlyOwner { require(state == State.WaitingForSale); crowdsaleStartTime = now; beneficiary = _beneficiary; etherPriceUSDWEI = _etherPriceUSDWEI; totalLimitUSDWEI = _totalLimitUSDWEI; crowdsaleFinishTime = now + _crowdsaleDurationDays * 1 days; minimalSuccessUSDWEI = _minimalSuccessUSDWEI; collectedUSDWEI = 0; setState(State.Sale); } function failSale(uint _investorsToProcess) public { require(state == State.Sale); require(now >= crowdsaleFinishTime && collectedUSDWEI < minimalSuccessUSDWEI); while (_investorsToProcess > 0 && numberOfInvestors > 0) { address addr = investorsIter[--numberOfInvestors]; Investor memory inv = investors[addr]; burnTokens(addr, inv.amountTokens); --_investorsToProcess; delete investorsIter[numberOfInvestors]; investorsToWithdrawIter[numberOfInvestorsToWithdraw] = addr; numberOfInvestorsToWithdraw++; } if (numberOfInvestors > 0) { return; } setState(State.SaleFailed); } function completeSale(uint _investorsToProcess) public onlyOwner { require(state == State.Sale); require(collectedUSDWEI >= minimalSuccessUSDWEI); while (_investorsToProcess > 0 && numberOfInvestors > 0) { --numberOfInvestors; --_investorsToProcess; delete investors[investorsIter[numberOfInvestors]]; delete investorsIter[numberOfInvestors]; } if (numberOfInvestors > 0) { return; } emitAdditionalTokens(); bool isSent = beneficiary.call.gas(3000000).value(this.balance)(); require(isSent); setState(State.CrowdsaleCompleted); } function setEtherPriceUSDWEI(uint _etherPriceUSDWEI) external onlyOwnerOrOracle { etherPriceUSDWEI = _etherPriceUSDWEI; } function setBeneficiary(address _beneficiary) external onlyOwner() { require(_beneficiary != 0); beneficiary = _beneficiary; } // This function must be called by token holder in case of crowdsale failed function withdrawBack() external saleFailedState { returnInvestmentsToInternal(msg.sender); } function returnInvestments(uint _investorsToProcess) public saleFailedState { while (_investorsToProcess > 0 && numberOfInvestorsToWithdraw > 0) { address addr = investorsToWithdrawIter[--numberOfInvestorsToWithdraw]; delete investorsToWithdrawIter[numberOfInvestorsToWithdraw]; --_investorsToProcess; returnInvestmentsToInternal(addr); } } function returnInvestmentsTo(address _to) public saleFailedState { returnInvestmentsToInternal(_to); } function returnInvestmentsToInternal(address _to) internal { Investor memory inv = investors[_to]; uint value = inv.amountWei; if (value > 0) { delete investors[_to]; require(_to.call.gas(3000000).value(value)()); } } function withdrawFunds(uint _value) public onlyOwner { require(state == State.PreSale || (state == State.Sale && collectedUSDWEI > minimalSuccessUSDWEI)); if (_value == 0) { _value = this.balance; } bool isSent = beneficiary.call.gas(3000000).value(_value)(); require(isSent); } modifier crowdsaleNotFinished { require(now < crowdsaleFinishTime); _; } modifier limitNotExceeded { require(collectedUSDWEI < totalLimitUSDWEI); _; } modifier crowdsaleState { require(state == State.PreSale || state == State.Sale); _; } modifier saleFailedState { require(state == State.SaleFailed); _; } modifier completedSaleState { require(state == State.CrowdsaleCompleted); _; } } contract Token is Crowdsale, ERC20 { mapping(address => uint) internal balances; mapping(address => mapping(address => uint)) public allowed; uint8 public constant decimals = 8; function Token() payable Crowdsale() {} function balanceOf(address who) constant returns(uint) { return balances[who]; } function transfer(address _to, uint _value) public completedSaleState onlyPayloadSize(2 * 32) { require(balances[msg.sender] >= _value); require(balances[_to] + _value >= balances[_to]); // overflow balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public completedSaleState onlyPayloadSize(3 * 32) { require(balances[_from] >= _value); require(balances[_to] + _value >= balances[_to]); // overflow require(allowed[_from][msg.sender] >= _value); balances[_from] -= _value; balances[_to] += _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); } function approve(address _spender, uint _value) public completedSaleState { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) public constant completedSaleState returns(uint remaining) { return allowed[_owner][_spender]; } modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } } contract MigratableToken is Token { function MigratableToken() payable Token() {} bool stateMigrated = false; address public migrationAgent; uint public totalMigrated; address public migrationHost; mapping(address => bool) migratedInvestors; event Migrated(address indexed from, address indexed to, uint value); function setMigrationHost(address _address) external onlyOwner { require(_address != 0); migrationHost = _address; } function migrateStateFromHost() external onlyOwner { require(stateMigrated == false && migrationHost != 0); PreArtexToken preArtex = PreArtexToken(migrationHost); state = Stateful.State.PreSale; etherPriceUSDWEI = preArtex.etherPriceUSDWEI(); beneficiary = preArtex.beneficiary(); totalLimitUSDWEI = preArtex.totalLimitUSDWEI(); minimalSuccessUSDWEI = preArtex.minimalSuccessUSDWEI(); collectedUSDWEI = preArtex.collectedUSDWEI(); crowdsaleStartTime = preArtex.crowdsaleStartTime(); crowdsaleFinishTime = preArtex.crowdsaleFinishTime(); stateMigrated = true; } function migrateInvestorsFromHost(uint batchSize) external onlyOwner { require(migrationHost != 0); PreArtexToken preArtex = PreArtexToken(migrationHost); uint numberOfInvestorsToMigrate = preArtex.numberOfInvestors(); uint currentNumberOfInvestors = numberOfInvestors; require(currentNumberOfInvestors < numberOfInvestorsToMigrate); for (uint i = 0; i < batchSize; i++) { uint index = currentNumberOfInvestors + i; if (index < numberOfInvestorsToMigrate) { address investor = preArtex.investorsIter(index); migrateInvestorsFromHostInternal(investor, preArtex); } else break; } } function migrateInvestorFromHost(address _address) external onlyOwner { require(migrationHost != 0); PreArtexToken preArtex = PreArtexToken(migrationHost); migrateInvestorsFromHostInternal(_address, preArtex); } function migrateInvestorsFromHostInternal(address _address, PreArtexToken preArtex) internal { require(state != State.SaleFailed && migratedInvestors[_address] == false); var (tokensToTransfer, weiToTransfer) = preArtex.investors(_address); require(tokensToTransfer > 0); balances[_address] = tokensToTransfer; totalSupply += tokensToTransfer; migratedInvestors[_address] = true; if (state != State.CrowdsaleCompleted) { Investor storage investor = investors[_address]; investorsIter[numberOfInvestors] = _address; numberOfInvestors++; investor.amountTokens += tokensToTransfer; investor.amountWei += weiToTransfer; } Transfer(this, _address, tokensToTransfer); } //migration by investor function migrate() external { require(migrationAgent != 0); uint value = balances[msg.sender]; balances[msg.sender] -= value; Transfer(msg.sender, this, value); totalSupply -= value; totalMigrated += value; MigrationAgent(migrationAgent).migrateFrom(msg.sender, value); Migrated(msg.sender, migrationAgent, value); } function setMigrationAgent(address _agent) external onlyOwner { require(migrationAgent == 0); migrationAgent = _agent; } } contract ArtexToken is MigratableToken { string public constant symbol = "ARX"; string public constant name = "Artex Token"; mapping(address => bool) public allowedContracts; function ArtexToken() payable MigratableToken() {} function emitTokens(address _investor, uint _valueUSDWEI) internal returns(uint tokensToEmit) { tokensToEmit = getTokensToEmit(_valueUSDWEI); require(balances[_investor] + tokensToEmit > balances[_investor]); // overflow require(tokensToEmit > 0); balances[_investor] += tokensToEmit; totalSupply += tokensToEmit; Transfer(this, _investor, tokensToEmit); } function getTokensToEmit(uint _valueUSDWEI) internal constant returns (uint) { uint percentWithBonus; if (state == State.PreSale) { percentWithBonus = 130; } else if (state == State.Sale) { if (_valueUSDWEI < 1000 * 1 ether) percentWithBonus = 100; else if (_valueUSDWEI < 5000 * 1 ether) percentWithBonus = 103; else if (_valueUSDWEI < 10000 * 1 ether) percentWithBonus = 105; else if (_valueUSDWEI < 50000 * 1 ether) percentWithBonus = 110; else if (_valueUSDWEI < 100000 * 1 ether) percentWithBonus = 115; else percentWithBonus = 120; } return (_valueUSDWEI * percentWithBonus * (10 ** uint(decimals))) / (tokenPriceUSDWEI * 100); } function emitAdditionalTokens() internal { uint tokensToEmit = totalSupply * 100 / 74 - totalSupply; require(balances[beneficiary] + tokensToEmit > balances[beneficiary]); // overflow require(tokensToEmit > 0); balances[beneficiary] += tokensToEmit; totalSupply += tokensToEmit; Transfer(this, beneficiary, tokensToEmit); } function burnTokens(address _address, uint _amount) internal { balances[_address] -= _amount; totalSupply -= _amount; Transfer(_address, this, _amount); } function addAllowedContract(address _address) external onlyOwner { require(_address != 0); allowedContracts[_address] = true; } function removeAllowedContract(address _address) external onlyOwner { require(_address != 0); delete allowedContracts[_address]; } function transferToKnownContract(address _to, uint256 _value, bytes32[] _data) external onlyAllowedContracts(_to) { var knownContract = KnownContract(_to); transfer(_to, _value); knownContract.transfered(msg.sender, _value, _data); } modifier onlyAllowedContracts(address _address) { require(allowedContracts[_address] == true); _; } }
RE1
pragma solidity 0.4.25; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ 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) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold 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; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public{ owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner, 'Only the owner can call this method'); _; } } contract EtheroStabilizationFund{ /** * In the event of the shortage of funds for the level payments * stabilization the contract of the stabilization fund provides backup support to the investment fund. * ethero contract address = 0xca35b7d915458ef540ade6068dfe2f44e8fa733c; */ address public ethero = 0x0223f73a53a549B8F5a9661aDB4cD9Dd4E25BEDa; uint public investFund; uint estGas = 100000; event MoneyWithdraw(uint balance); event MoneyAdd(uint holding); /** * @dev Throws if called by any account other than the owner. */ modifier onlyHero() { require(msg.sender == ethero, 'Only Hero call'); _; } function ReturnEthToEthero()public onlyHero returns(bool){ uint balance = address(this).balance; require(balance > estGas, 'Not enough funds for transaction'); if(ethero.call.value(address(this).balance).gas(estGas)()){ emit MoneyWithdraw(balance); investFund = address(this).balance; return true; }else{ return false; } } function() external payable{ investFund+=msg.value; emit MoneyAdd(msg.value); } } contract EtHero is Ownable{ using SafeMath for uint; // array containing information about beneficiaries mapping (address => uint) public balances; //array containing information about the time of payment mapping (address => uint) private time; //purse addresses for payments //when call the method LevelUpDeposit, money is transferred to the first two purses // fund1 and fund2 address public fund1 = 0xf846f84841b3242Ccdeac8c43C9cF73Bd781baA7; address public fund2 = 0xa7A20b9f36CD88fC2c776C9BB23FcEA34ba80ef7; address public stabFund; uint estGas = 100000; uint standartPersent = 30; // 30/1000*100 = 3% uint minPercent = 5; // 5/1000*100 = 0.5% uint public minPayment = 5 finney; //0.05 ether //the time through which dividends will be paid uint dividendsTime = 1 days; event NewInvestor(address indexed investor, uint deposit); event PayOffDividends(address indexed investor, uint value); event NewDeposit(address indexed investor, uint value); event ResiveFromStubFund(uint value); uint public allDeposits; uint public allPercents; uint public allBeneficiaries; uint public lastPayment; struct Beneficiaries{ address investorAddress; uint registerTime; uint persentWithdraw; uint ethWithdraw; uint deposits; bool real; } mapping(address => Beneficiaries) beneficiaries; function setStubFund(address _address)onlyOwner public{ require(_address>0, 'Incorrect address'); stabFund = _address; } function insertBeneficiaries(address _address, uint _persentWithdraw, uint _ethWithdraw, uint _deposits)private{ Beneficiaries storage s_beneficiaries = beneficiaries[_address]; if (!s_beneficiaries.real){ s_beneficiaries.real = true; s_beneficiaries.investorAddress = _address; s_beneficiaries.persentWithdraw = _persentWithdraw; s_beneficiaries.ethWithdraw = _ethWithdraw; s_beneficiaries.deposits = _deposits; s_beneficiaries.registerTime = now; allBeneficiaries+=1; }else{ s_beneficiaries.persentWithdraw += _persentWithdraw; s_beneficiaries.ethWithdraw += _ethWithdraw; } } function getBeneficiaries(address _address)public view returns( address investorAddress, uint persentWithdraw, uint ethWithdraw, uint registerTime ){ Beneficiaries storage s_beneficiaries = beneficiaries[_address]; require(s_beneficiaries.real, '404: Investor Not Found :('); return( s_beneficiaries.investorAddress, s_beneficiaries.persentWithdraw, s_beneficiaries.ethWithdraw, s_beneficiaries.registerTime ); } modifier isIssetRecepient(){ require(balances[msg.sender] > 0, "Deposit not found"); _; } /** * modifier checking the next payout time */ modifier timeCheck(){ require(now >= time[msg.sender].add(dividendsTime), "Too fast payout request"); _; } function receivePayment()isIssetRecepient timeCheck internal{ uint percent = getPercent(); uint rate = balances[msg.sender].mul(percent).div(1000); time[msg.sender] = now; msg.sender.transfer(rate); allPercents+=rate; lastPayment =now; insertBeneficiaries(msg.sender, percent, rate,0); emit PayOffDividends(msg.sender, rate); } function authorizationPayment()public view returns(bool){ if (balances[msg.sender] > 0 && now >= (time[msg.sender].add(dividendsTime))){ return (true); }else{ return(false); } } function getPercent()internal returns(uint){ uint value = balances[msg.sender].mul(standartPersent).div(1000); uint min_value = balances[msg.sender].mul(minPercent).div(1000); if(address(this).balance < min_value){ // Return money from stab. fund EtheroStabilizationFund stubF = EtheroStabilizationFund(stabFund); require(stubF.ReturnEthToEthero(), 'Forgive, the stabilization fund can not cover your deposit, try to withdraw your interest later '); emit ResiveFromStubFund(25); } uint contractBalance = address(this).balance; require(contractBalance > min_value, 'Out of money, wait a few days, we will attract new investments'); if(contractBalance > (value.mul(standartPersent).div(1000))){ return(30); } if(contractBalance > (value.mul(standartPersent.sub(5)).div(1000))){ return(25); } if(contractBalance > (value.mul(standartPersent.sub(10)).div(1000))){ return(20); } if(contractBalance > (value.mul(standartPersent.sub(15)).div(1000))){ return(15); } if(contractBalance > (value.mul(standartPersent.sub(20)).div(1000))){ return(10); } if(contractBalance > (value.mul(standartPersent.sub(25)).div(1000))){ return(5); } } function createDeposit() private{ uint value = msg.value; uint rateFund1 = value.mul(5).div(100); uint rateFund2 = value.mul(5).div(100); uint rateStubFund = value.mul(10).div(100); if(msg.value > 0){ if (balances[msg.sender] == 0){ emit NewInvestor(msg.sender, msg.value); } balances[msg.sender] = balances[msg.sender].add(msg.value); time[msg.sender] = now; insertBeneficiaries(msg.sender,0,0, msg.value); fund1.transfer(rateFund1); fund2.transfer(rateFund2); stabFund.call.value(rateStubFund).gas(estGas)(); allDeposits+=msg.value; emit NewDeposit(msg.sender, msg.value); }else{ receivePayment(); } } function() external payable{ //buffer overflow protection require((balances[msg.sender].add(msg.value)) >= balances[msg.sender]); if(msg.sender!=stabFund){ createDeposit(); }else{ emit ResiveFromStubFund(msg.value); } } }
RE1
pragma solidity ^0.4.24; contract POOHMOXevents { // fired whenever a player registers a name event onNewName ( uint256 indexed playerID, address indexed playerAddress, bytes32 indexed playerName, bool isNewPlayer, uint256 affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 amountPaid, uint256 timeStamp ); // fired at end of buy or reload event onEndTx ( uint256 compressedData, uint256 compressedIDs, bytes32 playerName, address playerAddress, uint256 ethIn, uint256 keysBought, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 POOHAmount, uint256 genAmount, uint256 potAmount ); // fired whenever theres a withdraw event onWithdraw ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 ethOut, uint256 timeStamp ); // fired whenever a withdraw forces end round to be ran event onWithdrawAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethOut, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 POOHAmount, uint256 genAmount ); // fired whenever a player tries a buy after round timer // hit zero, and causes end round to be ran. event onBuyAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethIn, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 POOHAmount, uint256 genAmount ); // fired whenever a player tries a reload after round timer // hit zero, and causes end round to be ran. event onReLoadAndDistribute ( address playerAddress, bytes32 playerName, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 POOHAmount, uint256 genAmount ); // fired whenever an affiliate is paid event onAffiliatePayout ( uint256 indexed affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 indexed roundID, uint256 indexed buyerID, uint256 amount, uint256 timeStamp ); // received pot swap deposit event onPotSwapDeposit ( uint256 roundID, uint256 amountAddedToPot ); } //============================================================================== // _ _ _ _|_ _ _ __|_ _ _ _|_ _ . // (_(_)| | | | (_|(_ | _\(/_ | |_||_) . //====================================|========================================= contract POOHMOX is POOHMOXevents { using SafeMath for *; using NameFilter for string; using KeysCalc for uint256; PlayerBookInterface private PlayerBook; //============================================================================== // _ _ _ |`. _ _ _ |_ | _ _ . // (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings) //=================_|=========================================================== address private admin = msg.sender; address private flushDivs; string constant public name = "POOHMOX"; string constant public symbol = "POOHMOX"; uint256 private rndExtra_ = 1 seconds; // length of the very first ICO phase uint256 private rndGap_ = 1 seconds; // length of ICO phases uint256 private rndInit_ = 5 minutes; // round timer starts at this uint256 private rndMax_ = 5 minutes; // max length a round timer can be (for first round) uint256 constant private rndInc_ = 5 minutes;// every full key purchased adds this much to the timer //============================================================================== // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes) //=============================|================================================ uint256 public rID_; // round id number / total rounds that have happened //**************** // PLAYER DATA //**************** mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name mapping (uint256 => POOHMOXDatasets.Player) public plyr_; // (pID => data) player data mapping (uint256 => mapping (uint256 => POOHMOXDatasets.PlayerRounds)) public plyrRnds_; // (pID => rID => data) player round data by player id & round id mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own) //**************** // ROUND DATA //**************** mapping (uint256 => POOHMOXDatasets.Round) public round_; // (rID => data) round data mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id //**************** // TEAM FEE DATA //**************** mapping (uint256 => POOHMOXDatasets.TeamFee) public fees_; // (team => fees) fee distribution by team mapping (uint256 => POOHMOXDatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team //============================================================================== // _ _ _ __|_ _ __|_ _ _ . // (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy) //============================================================================== constructor(address whaleContract, address playerbook) public { flushDivs = whaleContract; PlayerBook = PlayerBookInterface(playerbook); //no teams... only POOH-heads // Referrals / Community rewards are mathematically designed to come from the winner's share of the pot. fees_[0] = POOHMOXDatasets.TeamFee(39,20); //30% to pot, 10% to aff, 1% to dev, potSplit_[0] = POOHMOXDatasets.PotSplit(15,10); //36% to winner, 36% to next round, 3% to dev } //============================================================================== // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . (these are safety checks) //============================================================================== /** * @dev used to make sure no one can interact with contract until it has * been activated. */ modifier isActivated() { require(activated_ == true); _; } /** * @dev prevents contracts from interacting with fomo3d */ modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0); require(_addr == tx.origin); _; } /** * @dev sets boundaries for incoming tx */ modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000); require(_eth <= 100000000000000000000000); _; } //============================================================================== // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract) //====|========================================================================= /** * @dev emergency buy uses last stored affiliate ID */ function() isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not POOHMOXDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // buy core buyCore(_pID, plyr_[_pID].laff, _eventData_); } /** * @dev converts all incoming ethereum to keys. * -functionhash- 0x8f38f309 (using ID for affiliate) * -functionhash- 0x98a0871d (using address for affiliate) * -functionhash- 0xa65b37a1 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee */ function buyXid(uint256 _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not POOHMOXDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // buy core buyCore(_pID, _affCode, _eventData_); } function buyXaddr(address _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not POOHMOXDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // buy core buyCore(_pID, _affID, _eventData_); } function buyXname(bytes32 _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { // set up our tx event data and determine if player is new or not POOHMOXDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); // fetch player id uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // buy core buyCore(_pID, _affID, _eventData_); } /** * @dev essentially the same as buy, but instead of you sending ether * from your wallet, it uses your unwithdrawn earnings. * -functionhash- 0x349cdcac (using ID for affiliate) * -functionhash- 0x82bfc739 (using address for affiliate) * -functionhash- 0x079ce327 (using name for affiliate) * @param _affCode the ID/address/name of the player who gets the affiliate fee * @param _eth amount of earnings to use (remainder returned to gen vault) */ function reLoadXid(uint256 _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data POOHMOXDatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz if (_affCode == 0 || _affCode == _pID) { // use last stored affiliate code _affCode = plyr_[_pID].laff; // if affiliate code was given & its not the same as previously stored } else if (_affCode != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affCode; } // reload core reLoadCore(_pID, _affCode, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data POOHMOXDatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == address(0) || _affCode == msg.sender) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxAddr_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // reload core reLoadCore(_pID, _affID, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { // set up our tx event data POOHMOXDatasets.EventReturns memory _eventData_; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // manage affiliate residuals uint256 _affID; // if no affiliate code was given or player tried to use their own, lolz if (_affCode == '' || _affCode == plyr_[_pID].name) { // use last stored affiliate code _affID = plyr_[_pID].laff; // if affiliate code was given } else { // get affiliate ID from aff Code _affID = pIDxName_[_affCode]; // if affID is not the same as previously stored if (_affID != plyr_[_pID].laff) { // update last affiliate plyr_[_pID].laff = _affID; } } // reload core reLoadCore(_pID, _affID, _eth, _eventData_); } /** * @dev withdraws all of your earnings. * -functionhash- 0x3ccfd60b */ function withdraw() isActivated() isHuman() public { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // fetch player ID uint256 _pID = pIDxAddr_[msg.sender]; // setup temp var for player eth uint256 _eth; // check to see if round has ended and no one has run round end yet if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // set up our tx event data POOHMOXDatasets.EventReturns memory _eventData_; // end the round (distributes pot) round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire withdraw and distribute event emit POOHMOXevents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.POOHAmount, _eventData_.genAmount ); // in any other situation } else { // get their earnings _eth = withdrawEarnings(_pID); // gib moni if (_eth > 0) plyr_[_pID].addr.transfer(_eth); // fire withdraw event emit POOHMOXevents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now); } } /** * @dev use these to register names. they are just wrappers that will send the * registration requests to the PlayerBook contract. So registering here is the * same as registering there. UI will always display the last name you registered. * but you will still own all previously registered names to use as affiliate * links. * - must pay a registration fee. * - name must be unique * - names will be converted to lowercase * - name cannot start or end with a space * - cannot have more than 1 space in a row * - cannot be only numbers * - cannot start with 0x * - name must be at least 1 char * - max length of 32 characters long * - allowed characters: a-z, 0-9, and space * -functionhash- 0x921dec21 (using ID for affiliate) * -functionhash- 0x3ddd4698 (using address for affiliate) * -functionhash- 0x685ffd83 (using name for affiliate) * @param _nameString players desired name * @param _affCode affiliate ID, address, or name of who referred you * @param _all set to true if you want this to push your info to all games * (this might cost a lot of gas) */ 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]; // fire event emit POOHMOXevents.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]; // fire event emit POOHMOXevents.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]; // fire event emit POOHMOXevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } //============================================================================== // _ _ _|__|_ _ _ _ . // (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan) //=====_|======================================================================= /** * @dev return the price buyer will pay for next 1 individual key. * -functionhash- 0x018a25e8 * @return price for next key bought (in wei format) */ function getBuyPrice() public view returns(uint256) { return 0.01 ether; } /** * @dev returns time left. dont spam this, you'll ddos yourself from your node * provider * -functionhash- 0xc7e284b8 * @return time left in seconds */ function getTimeLeft() public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time 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); } /** * @dev returns player earnings per vaults * -functionhash- 0x63066434 * @return winnings vault * @return general vault * @return affiliate vault */ function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { // setup local rID uint256 _rID = rID_; // if round has ended. but round end has not been run (so contract has not distributed winnings) if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { // if player is winner 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 ); // if player is not the winner } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } // if round is still going on, or round has ended and round end has been ran } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } /** * solidity hates stack limits. this lets us avoid that hate */ 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) ); } /** * @dev returns all current round info needed for front end * -functionhash- 0x747dff42 * @return eth invested during ICO phase * @return round id * @return total keys for round * @return time round ends * @return time round started * @return current pot * @return current team ID & player ID in lead * @return current player in leads address * @return current player in leads name * @return whales eth in for round * @return bears eth in for round * @return sneks eth in for round * @return bulls eth in for round */ function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; return ( round_[_rID].ico, //0 _rID, //1 round_[_rID].keys, //2 round_[_rID].end, //3 round_[_rID].strt, //4 round_[_rID].pot, //5 (round_[_rID].team + (round_[_rID].plyr * 10)), //6 plyr_[round_[_rID].plyr].addr, //7 plyr_[round_[_rID].plyr].name, //8 rndTmEth_[_rID][0], //9 rndTmEth_[_rID][1], //10 rndTmEth_[_rID][2], //11 rndTmEth_[_rID][3] //12 ); } /** * @dev returns player info based on address. if no address is given, it will * use msg.sender * -functionhash- 0xee0b5d8b * @param _addr address of the player you want to lookup * @return player ID * @return player name * @return keys owned (current round) * @return winnings vault * @return general vault * @return affiliate vault * @return player round eth */ function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { // setup local rID uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, //0 plyr_[_pID].name, //1 plyrRnds_[_pID][_rID].keys, //2 plyr_[_pID].win, //3 (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), //4 plyr_[_pID].aff, //5 plyrRnds_[_pID][_rID].eth //6 ); } //============================================================================== // _ _ _ _ | _ _ . _ . // (_(_)| (/_ |(_)(_||(_ . (this + tools + calcs + modules = our softwares engine) //=====================_|======================================================= /** * @dev logic runs whenever a buy order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function buyCore(uint256 _pID, uint256 _affID, POOHMOXDatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // call core core(_rID, _pID, msg.value, _affID, 0, _eventData_); // if round is not active } else { // check to see if end round needs to be ran if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit POOHMOXevents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.POOHAmount, _eventData_.genAmount ); } // put eth in players vault plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } /** * @dev logic runs whenever a reload order is executed. determines how to handle * incoming eth depending on if we are in an active round or not */ function reLoadCore(uint256 _pID, uint256 _affID, uint256 _eth, POOHMOXDatasets.EventReturns memory _eventData_) private { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // if round is active if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { // get earnings from all vaults and return unused to gen vault // because we use a custom safemath library. this will throw if player // tried to spend more eth than they have. plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); // call core core(_rID, _pID, _eth, _affID, 0, _eventData_); // if round is not active and end round needs to be ran } else if (_now > round_[_rID].end && round_[_rID].ended == false) { // end the round (distributes pot) & start new round round_[_rID].ended = true; _eventData_ = endRound(_eventData_); // build event data _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; // fire buy and distribute event emit POOHMOXevents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.POOHAmount, _eventData_.genAmount ); } } /** * @dev this is the core logic for any buy/reload that happens while a round * is live. */ function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, POOHMOXDatasets.EventReturns memory _eventData_) private { require(_eth >= 0.01 ether); // if player is new to round if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); // // early round eth limiter // if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 5000000000000000000) // { // uint256 _availableLimit = (5000000000000000000).sub(plyrRnds_[_pID][_rID].eth); // uint256 _refund = _eth.sub(_availableLimit); // plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); // _eth = _availableLimit; // } // if eth left is greater than min eth allowed (sorry no pocket lint) // mint the new keys uint256 _keys = (round_[_rID].eth).keysRec(_eth); // if they bought at least 1 whole key if (_keys >= 1000000000000000000) { updateTimer(_keys, _rID); // set new leaders if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; // set the new leader bool to true _eventData_.compressedData = _eventData_.compressedData + 100; } // update player plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); // update round round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][0] = _eth.add(rndTmEth_[_rID][0]); // distribute eth _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, 0, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, 0, _keys, _eventData_); // call end tx function to fire end tx event. endTx(_pID, 0, _eth, _keys, _eventData_); } //============================================================================== // _ _ | _ | _ _|_ _ _ _ . // (_(_||(_|_||(_| | (_)| _\ . //============================================================================== /** * @dev calculates unmasked earnings (just calculates, does not update mask) * @return earnings in wei format */ 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) ); } /** * @dev returns the amount of keys you would get given an amount of eth. * -functionhash- 0xce89c80c * @param _rID round ID you want price for * @param _eth amount of eth sent in * @return keys received */ function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256) { // grab time uint256 _now = now; // are we in a round? 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 // rounds over. need keys for new round return ( (_eth).keys() ); } /** * @dev returns current eth price for X keys. * -functionhash- 0xcf808000 * @param _keys number of keys desired (in 18 decimal format) * @return amount of eth needed to send */ function iWantXKeys(uint256 _keys) public view returns(uint256) { // setup local rID uint256 _rID = rID_; // grab time uint256 _now = now; // are we in a round? 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 // rounds over. need price for new round return ( (_keys).eth() ); } //============================================================================== // _|_ _ _ | _ . // | (_)(_)|_\ . //============================================================================== /** * @dev receives name/player info from names contract */ function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook)); 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; } /** * @dev receives entire player name list */ function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook)); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } /** * @dev gets existing or registers new pID. use this when a player may be new * @return pID */ function determinePID(POOHMOXDatasets.EventReturns memory _eventData_) private returns (POOHMOXDatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; // if player is new to this version of fomo3d if (_pID == 0) { // grab their player ID, name and last aff ID, from player names contract _pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); // set up player account 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; // set the new player bool to true _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } /** * @dev decides if round end needs to be run & new round started. and if * player unmasked earnings from previously played rounds need to be moved. */ function managePlayer(uint256 _pID, POOHMOXDatasets.EventReturns memory _eventData_) private returns (POOHMOXDatasets.EventReturns) { // if player has played a previous round, move their unmasked earnings // from that round to gen vault. if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); // update player's last round played plyr_[_pID].lrnd = rID_; // set the joined round bool to true _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } /** * @dev ends the round. manages paying out winner/splitting up pot */ function endRound(POOHMOXDatasets.EventReturns memory _eventData_) private returns (POOHMOXDatasets.EventReturns) { // setup local rID uint256 _rID = rID_; // grab our winning player and team id's uint256 _winPID = round_[_rID].plyr; uint256 _winTID = round_[_rID].team; // grab our pot amount uint256 _pot = round_[_rID].pot; // calculate our winner share, community rewards, gen share, // p3d share, and amount reserved for next pot uint256 _win = (_pot.mul(48)) / 100; //48% uint256 _dev = (_pot / 50); //2% uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; //15 uint256 _POOH = (_pot.mul(potSplit_[_winTID].pooh)) / 100; // 10 uint256 _res = (((_pot.sub(_win)).sub(_dev)).sub(_gen)).sub(_POOH); //25 // calculate ppt for round mask 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); } // pay our winner plyr_[_winPID].win = _win.add(plyr_[_winPID].win); // community rewards admin.transfer(_dev); flushDivs.call.value(_POOH)(bytes4(keccak256("donate()"))); // distribute gen portion to key holders round_[_rID].mask = _ppt.add(round_[_rID].mask); // prepare event data _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_.POOHAmount = _POOH; _eventData_.newPot = _res; // start next round rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndMax_); round_[_rID].pot = _res; return(_eventData_); } /** * @dev moves any unmasked earnings to gen vault. updates earnings mask */ function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0) { // put in gen vault plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); // zero out their earnings by updating mask plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); } } /** * @dev updates round timer based on number of whole keys bought. */ function updateTimer(uint256 _keys, uint256 _rID) private { // grab time uint256 _now = now; // calculate time based on number of keys bought 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); // compare to max and set new end time if (_newTime < (rndMax_).add(_now)) round_[_rID].end = _newTime; else round_[_rID].end = rndMax_.add(_now); } /** * @dev distributes eth based on fees to com, aff, and pooh */ function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, POOHMOXDatasets.EventReturns memory _eventData_) private returns(POOHMOXDatasets.EventReturns) { // pay 1% out to dev uint256 _dev = _eth / 100; // 1% uint256 _POOH = 0; if (!address(admin).call.value(_dev)()) { _POOH = _dev; _dev = 0; } // distribute share to affiliate uint256 _aff = _eth / 10; // decide what to do with affiliate share of fees // affiliate must not be self, and must have a name registered if (_affID != _pID && plyr_[_affID].name != '') { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit POOHMOXevents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now); } else { _POOH = _POOH.add(_aff); } // pay out POOH _POOH = _POOH.add((_eth.mul(fees_[_team].pooh)) / (100)); if (_POOH > 0) { flushDivs.call.value(_POOH)(bytes4(keccak256("donate()"))); // set up event data _eventData_.POOHAmount = _POOH.add(_eventData_.POOHAmount); } return(_eventData_); } function potSwap() external payable { //you shouldn't be using this method admin.transfer(msg.value); } /** * @dev distributes eth based on fees to gen and pot */ function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, POOHMOXDatasets.EventReturns memory _eventData_) private returns(POOHMOXDatasets.EventReturns) { // calculate gen share uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; // update eth balance (eth = eth - (com share + pot swap share + aff share + p3d share + airdrop pot share)) _eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].pooh)) / 100)); // calculate pot uint256 _pot = _eth.sub(_gen); // distribute gen share (thats what updateMasks() does) and adjust // balances for dust. uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); // add eth to pot round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); // set up event data _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } /** * @dev updates masks for round and player when keys are bought * @return dust left over */ function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { /* MASKING NOTES earnings masks are a tricky thing for people to wrap their minds around. the basic thing to understand here. is were going to have a global tracker based on profit per share for each round, that increases in relevant proportion to the increase in share supply. the player will have an additional mask that basically says "based on the rounds mask, my shares, and how much i've already withdrawn, how much is still owed to me?" */ // calc profit per key & round mask based on this buy: (dust goes to pot) uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); // calculate player earning from their own buy (only based on the keys // they just bought). & update player earnings mask uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); // calculate & return dust return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000))); } /** * @dev adds up unmasked earnings, & vault earnings, sets them all to 0 * @return earnings in wei format */ function withdrawEarnings(uint256 _pID) private returns(uint256) { // update gen vault updateGenVault(_pID, plyr_[_pID].lrnd); // from vaults 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); } /** * @dev prepares compression data and fires event for buy or reload tx's */ function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, POOHMOXDatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit POOHMOXevents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.POOHAmount, _eventData_.genAmount, _eventData_.potAmount ); } //============================================================================== // (~ _ _ _._|_ . // _)(/_(_|_|| | | \/ . //====================/========================================================= /** upon contract deploy, it will be deactivated. this is a one time * use function that will activate the contract. we do this so devs * have time to set things up on the web end **/ bool public activated_ = false; function activate() public { // only team just can activate require(msg.sender == admin); // can only be ran once require(activated_ == false); // activate the contract activated_ = true; // lets start first round rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } /** Upon game death, there might be some ETH still locked in contract. * This is a one time use function that will empty the contract and * send the eth to POOH tokenholders. **/ function whenGameDies() public { // only team just can activate require(msg.sender == admin); //take any black-holed eth left in contract and send to pooh whale flushDivs.call.value(address(this).balance)(bytes4(keccak256("donate()"))); } } //============================================================================== // __|_ _ __|_ _ . // _\ | | |_|(_ | _\ . //============================================================================== library POOHMOXDatasets { struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; // winner address bytes32 winnerName; // winner name uint256 amountWon; // amount won uint256 newPot; // amount in new pot uint256 POOHAmount; // amount distributed to p3d uint256 genAmount; // amount distributed to gen uint256 potAmount; // amount added to pot } struct Player { address addr; // player address bytes32 name; // player name uint256 win; // winnings vault uint256 gen; // general vault uint256 aff; // affiliate vault uint256 lrnd; // last round played uint256 laff; // last affiliate id used } struct PlayerRounds { uint256 eth; // eth player has added to round (used for eth limiter) uint256 keys; // keys uint256 mask; // player mask uint256 ico; // ICO phase investment } struct Round { uint256 plyr; // pID of player in lead uint256 team; // tID of team in lead uint256 end; // time ends/ended bool ended; // has round end function been ran uint256 strt; // time round started uint256 keys; // keys uint256 eth; // total eth in uint256 pot; // eth to pot (during round) / final amount paid to winner (after round ends) uint256 mask; // global mask uint256 ico; // total eth sent in during ICO phase uint256 icoGen; // total eth for gen during ICO phase uint256 icoAvg; // average key price for ICO phase } struct TeamFee { uint256 gen; // % of buy in thats paid to key holders of current round uint256 pooh; // % of buy in thats paid to POOH holders } struct PotSplit { uint256 gen; // % of pot thats paid to key holders of current round uint256 pooh; // % of pot thats paid to POOH holders } } //============================================================================== // | _ _ _ | _ . // |<(/_\/ (_(_||(_ . //=======/====================================================================== library KeysCalc { using SafeMath for *; /** * @dev calculates number of keys received given X eth * @param _curEth current amount of eth in contract * @param _newEth eth being spent * @return amount of ticket purchased */ function keysRec(uint256 _curEth, uint256 _newEth) internal pure returns (uint256) { return(keys((_curEth).add(_newEth)).sub(keys(_curEth))); } /** * @dev calculates amount of eth received if you sold X keys * @param _curKeys current amount of keys that exist * @param _sellKeys amount of keys you wish to sell * @return amount of eth received */ function ethRec(uint256 _curKeys, uint256 _sellKeys) internal pure returns (uint256) { return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys)))); } /** * @dev calculates how many keys would exist with given an amount of eth * @param _eth eth "in contract" * @return number of keys that would exist */ function keys(uint256 _eth) internal pure returns(uint256) { // return ((((((_eth).mul(1000000000000000000)).mul(200000000000000000000000000000000)).add(2500000000000000000000000000000000000000000000000000000000000000)).sqrt()).sub(50000000000000000000000000000000)) / (100000000000000); return (_eth / 0.01 ether) * 1e18; } /** * @dev calculates how much eth would be in contract given a number of keys * @param _keys number of keys "in contract" * @return eth that would exists */ function eth(uint256 _keys) internal pure returns(uint256) { return _keys.mul(0.01 ether) / 1e18; //return ((50000000000000).mul(_keys.sq()).add(((100000000000000).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 { /** * @dev filters name strings * -converts uppercase to lower case. * -makes sure it does not start/end with a space * -makes sure it does not contain multiple spaces in a row * -cannot be only numbers * -cannot start with 0x * -restricts characters to A-Z, a-z, 0-9, and space. * @return reprocessed string in bytes32 format */ function nameFilter(string _input) internal pure returns(bytes32) { bytes memory _temp = bytes(_input); uint256 _length = _temp.length; //sorry limited to 32 characters require (_length <= 32 && _length > 0); // make sure it doesnt start with or end with space require(_temp[0] != 0x20 && _temp[_length-1] != 0x20); // make sure first two characters are not 0x if (_temp[0] == 0x30) { require(_temp[1] != 0x78); require(_temp[1] != 0x58); } // create a bool to track if we have a non number character bool _hasNonNumber; // convert & check for (uint256 i = 0; i < _length; i++) { // if its uppercase A-Z if (_temp[i] > 0x40 && _temp[i] < 0x5b) { // convert to lower case a-z _temp[i] = byte(uint(_temp[i]) + 32); // we have a non number if (_hasNonNumber == false) _hasNonNumber = true; } else { require ( // require character is a space _temp[i] == 0x20 || // OR lowercase a-z (_temp[i] > 0x60 && _temp[i] < 0x7b) || // or 0-9 (_temp[i] > 0x2f && _temp[i] < 0x3a)); // make sure theres not 2x spaces in a row if (_temp[i] == 0x20) require( _temp[i+1] != 0x20); // see if we have a character other than a number if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39)) _hasNonNumber = true; } } require(_hasNonNumber == true); bytes32 _ret; assembly { _ret := mload(add(_temp, 32)) } return (_ret); } } /** * @title SafeMath v0.1.9 * @dev Math operations with safety checks that throw on error * change notes: original SafeMath library from OpenZeppelin modified by Inventor * - added sqrt * - added sq * - added pwr * - changed asserts to requires with error log outputs * - removed div, its useless */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ 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; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath sub failed"); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } /** * @dev gives square root of given x. */ 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); } } /** * @dev gives square. multiplies x by x */ function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } /** * @dev x to the power of y */ 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); } } }
RE1
pragma solidity ^0.4.25; contract Piggy_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function Piggy_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract PiggY_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function PiggY_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract c_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function c_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract CB_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function CB_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract W_WALLET { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function W_WALLET(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract COIN_BOX { struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; uint public MinSum; LogFile Log; bool intitalized; function SetMinSum(uint _val) public { if(intitalized)throw; MinSum = _val; } function SetLogFile(address _log) public { if(intitalized)throw; Log = LogFile(_log); } function Initialized() public { intitalized = true; } function Put(uint _lockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; if(now+_lockTime>acc.unlockTime)acc.unlockTime=now+_lockTime; Log.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; Log.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } } contract LogFile { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.23; /** A PennyAuction-like game to win a prize. UI: https://www.pennyether.com How it works: - An initial prize is held in the Contract - Anyone may overthrow the Monarch by paying a small fee. - They become the Monarch - The "reign" timer is reset to N. - The prize may be increased or decreased - If nobody overthrows the new Monarch in N blocks, the Monarch wins. For fairness, an "overthrow" is refunded if: - The incorrect amount is sent. - The game is already over. - The overthrower is already the Monarch. - Another overthrow occurred in the same block - Note: Here, default gas is used for refund. On failure, fee is kept. Other notes: - .sendFees(): Sends accrued fees to "collector", at any time. - .sendPrize(): If game is ended, sends prize to the Monarch. */ contract MonarchyGame { // We store values as GWei to reduce storage to 64 bits. // int64: 2^63 GWei is ~ 9 billion Ether, so no overflow risk. // // For blocks, we use uint32, which has a max value of 4.3 billion // At a 1 second block time, there's a risk of overflow in 120 years. // // We put these variables together because they are all written to // on each bid. This should save some gas when we write. struct Vars { // [first 256-bit segment] address monarch; // address of monarch uint64 prizeGwei; // (Gwei) the current prize uint32 numOverthrows; // total number of overthrows // [second 256-bit segment] uint32 blockEnded; // the time at which no further overthrows can occur uint32 prevBlock; // block of the most recent overthrow bool isPaid; // whether or not the winner has been paid bytes23 decree; // 23 leftover bytes for decree } // These values are set on construction and don't change. // We store in a struct for gas-efficient reading/writing. struct Settings { // [first 256-bit segment] address collector; // address that fees get sent to uint64 initialPrizeGwei; // (Gwei > 0) amt initially staked // [second 256-bit segment] uint64 feeGwei; // (Gwei > 0) cost to become the Monarch int64 prizeIncrGwei; // amount added/removed to prize on overthrow uint32 reignBlocks; // number of blocks Monarch must reign to win } Vars vars; Settings settings; uint constant version = 1; event SendPrizeError(uint time, string msg); event Started(uint time, uint initialBlocks); event OverthrowOccurred(uint time, address indexed newMonarch, bytes23 decree, address indexed prevMonarch, uint fee); event OverthrowRefundSuccess(uint time, string msg, address indexed recipient, uint amount); event OverthrowRefundFailure(uint time, string msg, address indexed recipient, uint amount); event SendPrizeSuccess(uint time, address indexed redeemer, address indexed recipient, uint amount, uint gasLimit); event SendPrizeFailure(uint time, address indexed redeemer, address indexed recipient, uint amount, uint gasLimit); event FeesSent(uint time, address indexed collector, uint amount); constructor( address _collector, uint _initialPrize, uint _fee, int _prizeIncr, uint _reignBlocks, uint _initialBlocks ) public payable { require(_initialPrize >= 1e9); // min value of 1 GWei require(_initialPrize < 1e6 * 1e18); // max value of a million ether require(_initialPrize % 1e9 == 0); // even amount of GWei require(_fee >= 1e6); // min value of 1 GWei require(_fee < 1e6 * 1e18); // max value of a million ether require(_fee % 1e9 == 0); // even amount of GWei require(_prizeIncr <= int(_fee)); // max value of _bidPrice require(_prizeIncr >= -1*int(_initialPrize)); // min value of -1*initialPrize require(_prizeIncr % 1e9 == 0); // even amount of GWei require(_reignBlocks >= 1); // minimum of 1 block require(_initialBlocks >= 1); // minimum of 1 block require(msg.value == _initialPrize); // must've sent the prize amount // Set instance variables. these never change. // These can be safely cast to int64 because they are each < 1e24 (see above), // 1e24 divided by 1e9 is 1e15. Max int64 val is ~1e19, so plenty of room. // For block numbers, uint32 is good up to ~4e12, a long time from now. settings.collector = _collector; settings.initialPrizeGwei = uint64(_initialPrize / 1e9); settings.feeGwei = uint64(_fee / 1e9); settings.prizeIncrGwei = int64(_prizeIncr / 1e9); settings.reignBlocks = uint32(_reignBlocks); // Initialize the game variables. vars.prizeGwei = settings.initialPrizeGwei; vars.monarch = _collector; vars.prevBlock = uint32(block.number); vars.blockEnded = uint32(block.number + _initialBlocks); emit Started(now, _initialBlocks); } /*************************************************************/ /********** OVERTHROWING *************************************/ /*************************************************************/ // // Upon new bid, adds fees and increments time and prize. // - Refunds if overthrow is too late, user is already monarch, or incorrect value passed. // - Upon an overthrow-in-same-block, refends previous monarch. // // Gas Cost: 34k - 50k // Overhead: 25k // - 23k: tx overhead // - 2k: SLOADs, execution // Failure: 34k // - 25k: overhead // - 7k: send refund // - 2k: event: OverthrowRefundSuccess // Clean: 37k // - 25k: overhead // - 10k: update Vars (monarch, numOverthrows, prize, blockEnded, prevBlock, decree) // - 2k: event: OverthrowOccurred // Refund Success: 46k // - 25k: overhead // - 7k: send // - 10k: update Vars (monarch, decree) // - 2k: event: OverthrowRefundSuccess // - 2k: event: OverthrowOccurred // Refund Failure: 50k // - 25k: overhead // - 11k: send failure // - 10k: update Vars (monarch, numOverthrows, prize, decree) // - 2k: event: OverthrowRefundFailure // - 2k: event: OverthrowOccurred function() public payable { overthrow(0); } function overthrow(bytes23 _decree) public payable { if (isEnded()) return errorAndRefund("Game has already ended."); if (msg.sender == vars.monarch) return errorAndRefund("You are already the Monarch."); if (msg.value != fee()) return errorAndRefund("Value sent must match fee."); // compute new values. hopefully optimizer reads from vars/settings just once. int _newPrizeGwei = int(vars.prizeGwei) + settings.prizeIncrGwei; uint32 _newBlockEnded = uint32(block.number) + settings.reignBlocks; uint32 _newNumOverthrows = vars.numOverthrows + 1; address _prevMonarch = vars.monarch; bool _isClean = (block.number != vars.prevBlock); // Refund if _newPrize would end up being < 0. if (_newPrizeGwei < 0) return errorAndRefund("Overthrowing would result in a negative prize."); // Attempt refund, if necessary. Use minimum gas. bool _wasRefundSuccess; if (!_isClean) { _wasRefundSuccess = _prevMonarch.send(msg.value); } // These blocks can be made nicer, but optimizer will // sometimes do two updates instead of one. Seems it is // best to keep if/else trees flat. if (_isClean) { vars.monarch = msg.sender; vars.numOverthrows = _newNumOverthrows; vars.prizeGwei = uint64(_newPrizeGwei); vars.blockEnded = _newBlockEnded; vars.prevBlock = uint32(block.number); vars.decree = _decree; } if (!_isClean && _wasRefundSuccess){ // when a refund occurs, we just swap winners. // overthrow count and prize do not get reset. vars.monarch = msg.sender; vars.decree = _decree; } if (!_isClean && !_wasRefundSuccess){ vars.monarch = msg.sender; vars.prizeGwei = uint64(_newPrizeGwei); vars.numOverthrows = _newNumOverthrows; vars.decree = _decree; } // Emit the proper events. if (!_isClean){ if (_wasRefundSuccess) emit OverthrowRefundSuccess(now, "Another overthrow occurred on the same block.", _prevMonarch, msg.value); else emit OverthrowRefundFailure(now, ".send() failed.", _prevMonarch, msg.value); } emit OverthrowOccurred(now, msg.sender, _decree, _prevMonarch, msg.value); } // called from the bidding function above. // refunds sender, or throws to revert entire tx. function errorAndRefund(string _msg) private { require(msg.sender.call.value(msg.value)()); emit OverthrowRefundSuccess(now, _msg, msg.sender, msg.value); } /*************************************************************/ /********** PUBLIC FUNCTIONS *********************************/ /*************************************************************/ // Sends prize to the current winner using _gasLimit (0 is unlimited) function sendPrize(uint _gasLimit) public returns (bool _success, uint _prizeSent) { // make sure game has ended, and is not paid if (!isEnded()) { emit SendPrizeError(now, "The game has not ended."); return (false, 0); } if (vars.isPaid) { emit SendPrizeError(now, "The prize has already been paid."); return (false, 0); } address _winner = vars.monarch; uint _prize = prize(); bool _paySuccessful = false; // attempt to pay winner (use full gas if _gasLimit is 0) vars.isPaid = true; if (_gasLimit == 0) { _paySuccessful = _winner.call.value(_prize)(); } else { _paySuccessful = _winner.call.value(_prize).gas(_gasLimit)(); } // emit proper event. rollback .isPaid on failure. if (_paySuccessful) { emit SendPrizeSuccess({ time: now, redeemer: msg.sender, recipient: _winner, amount: _prize, gasLimit: _gasLimit }); return (true, _prize); } else { vars.isPaid = false; emit SendPrizeFailure({ time: now, redeemer: msg.sender, recipient: _winner, amount: _prize, gasLimit: _gasLimit }); return (false, 0); } } // Sends accrued fees to the collector. Callable by anyone. function sendFees() public returns (uint _feesSent) { _feesSent = fees(); if (_feesSent == 0) return; require(settings.collector.call.value(_feesSent)()); emit FeesSent(now, settings.collector, _feesSent); } /*************************************************************/ /********** PUBLIC VIEWS *************************************/ /*************************************************************/ // Expose all Vars //////////////////////////////////////// function monarch() public view returns (address) { return vars.monarch; } function prize() public view returns (uint) { return uint(vars.prizeGwei) * 1e9; } function numOverthrows() public view returns (uint) { return vars.numOverthrows; } function blockEnded() public view returns (uint) { return vars.blockEnded; } function prevBlock() public view returns (uint) { return vars.prevBlock; } function isPaid() public view returns (bool) { return vars.isPaid; } function decree() public view returns (bytes23) { return vars.decree; } /////////////////////////////////////////////////////////// // Expose all Settings ////////////////////////////////////// function collector() public view returns (address) { return settings.collector; } function initialPrize() public view returns (uint){ return uint(settings.initialPrizeGwei) * 1e9; } function fee() public view returns (uint) { return uint(settings.feeGwei) * 1e9; } function prizeIncr() public view returns (int) { return int(settings.prizeIncrGwei) * 1e9; } function reignBlocks() public view returns (uint) { return settings.reignBlocks; } /////////////////////////////////////////////////////////// // The following are computed ///////////////////////////// function isEnded() public view returns (bool) { return block.number > vars.blockEnded; } function getBlocksRemaining() public view returns (uint) { if (isEnded()) return 0; return (vars.blockEnded - block.number) + 1; } function fees() public view returns (uint) { uint _balance = address(this).balance; return vars.isPaid ? _balance : _balance - prize(); } function totalFees() public view returns (uint) { int _feePerOverthrowGwei = int(settings.feeGwei) - settings.prizeIncrGwei; return uint(_feePerOverthrowGwei * vars.numOverthrows * 1e9); } /////////////////////////////////////////////////////////// }
RE1
pragma solidity ^0.4.25; contract Piggy_BNK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function Piggy_BNK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract PRIVATE_ETH_CELL { mapping (address=>uint256) public balances; uint public MinSum; LogFile Log; bool intitalized; function SetMinSum(uint _val) public { require(!intitalized); MinSum = _val; } function SetLogFile(address _log) public { require(!intitalized); Log = LogFile(_log); } function Initialized() public { intitalized = true; } function Deposit() public payable { balances[msg.sender]+= msg.value; Log.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { if(balances[msg.sender]>=MinSum && balances[msg.sender]>=_am) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; Log.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Deposit(); } } contract LogFile { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract Piggy_BanK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function Piggy_BanK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.21; /**Decentralized Immutable & Unstoppable Ethereum Staking Smart Contract. THE NEXT BIG THING! * Definition of contract accepting CST tokens * Games, casinos, anything can reuse this contract to support CST tokens */ contract AcceptsCryptoSurge { CryptoSurge public tokenContract; function AcceptsCryptoSurg(address _tokenContract) public { tokenContract = CryptoSurge(_tokenContract); } modifier onlyTokenContract { require(msg.sender == address(tokenContract)); _; } /** * @dev Standard ERC677 function that will handle incoming token transfers. * * @param _from Token sender address. * @param _value Amount of tokens. * @param _data Transaction metadata. */ function tokenFallback(address _from, uint256 _value, bytes _data) external returns (bool); } contract CryptoSurge { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // only people with profits modifier onlyStronghands() { require(myDividends(true) > 0); _; } modifier notContract() { require (msg.sender == tx.origin); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> change the PoS difficulty (How many tokens it costs to hold a masternode, in case it gets crazy high later) // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[_customerAddress]); _; } uint ACTIVATION_TIME = 1537743500; // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier antiEarlyWhale(uint256 _amountOfEthereum){ address _customerAddress = msg.sender; if (now >= ACTIVATION_TIME) { onlyAmbassadors = false; } // are we still in the vulnerable phase? // if so, enact anti early whale protocol if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){ require( // is the customer in the ambassador list? ambassadors_[_customerAddress] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum); // execute _; } else { // in case the ether count drops low, the ambassador phase won't reinitiate onlyAmbassadors = false; _; } } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "CRYPTO SURGE"; string public symbol = "CST"; uint8 constant public decimals = 18; uint8 constant internal dividendFee_ = 15; // 10% dividend fee on each buy and sell uint8 constant internal fundFee_ = 10; // 10% investment fund fee on each buy and sell (FUND CRYPTO GAMES) uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether; uint256 constant internal magnitude = 2**64; // Address to send // crypto games Fund address constant public giveEthFundAddress = 0x64Ac3D88DFEbf351A49ae34EF52009da5F4EeFbd; uint256 public totalEthFundRecieved; // uint256 public totalEthFundCollected; // // proof of stake (defaults at 100 tokens) uint256 public stakingRequirement = 25e18; // ambassador program mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 1 ether; uint256 constant internal ambassadorQuota_ = 2 ether; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = false; mapping(address => bool) public canAcceptTokens_; mapping(address => address) public stickyRef; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ function CryptoSurge() public { // add administrators here administrators[0xC5676f1EE6421A0458cC1F955a5e0100adEb01D3] = true; // add the ambassadors here - Tokens will be distributed to these addresses from main premine ambassadors_[0x0000000000000000000000000000000000000000] = true; } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) */ function buy(address _referredBy) public payable returns(uint256) { require(tx.gasprice <= 0.05 szabo); purchaseTokens(msg.value, _referredBy); } /** * Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() public payable { } /** * Sends FUND money to the 70/30 Contract */ function payFund() payable public { uint256 ethToPay = SafeMath.sub(totalEthFundCollected, totalEthFundRecieved); require(ethToPay > 1); totalEthFundRecieved = SafeMath.add(totalEthFundRecieved, ethToPay); if(!giveEthFundAddress.call.value(ethToPay).gas(400000)()) { totalEthFundRecieved = SafeMath.sub(totalEthFundRecieved, ethToPay); } } /** * Converts all of caller's dividends to tokens. */ function reinvest() onlyStronghands() public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0); // fire event onReinvestment(_customerAddress, _dividends, _tokens); } /** * Alias of sell() and withdraw(). */ function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(); } /** * Withdraws all of the callers earnings. */ function withdraw() onlyStronghands() public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event onWithdraw(_customerAddress, _dividends); } /** * Liquifies tokens to ethereum. */ function sell(uint256 _amountOfTokens) onlyBagholders() public { // setup data address _customerAddress = msg.sender; // russian hackers BTFO require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100); uint256 _refPayout = _dividends / 3; _dividends = SafeMath.sub(_dividends, _refPayout); (_dividends,) = handleRef(stickyRef[msg.sender], _refPayout, _dividends, 0); // Take out dividends and then _fundPayout uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout); // Add ethereum to send to fund totalEthFundCollected = SafeMath.add(totalEthFundCollected, _fundPayout); // burn the sold tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } // fire event onTokenSell(_customerAddress, _tokens, _taxedEthereum); } /** * Transfer tokens from the caller to a new holder. * REMEMBER THIS IS 0% TRANSFER FEE */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens // also disables transfers until ambassador phase is over // ( we dont want whale premines ) require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if(myDividends(true) > 0) withdraw(); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens); // fire event Transfer(_customerAddress, _toAddress, _amountOfTokens); // ERC20 return true; } /** * Transfer token to a specified address and forward the data to recipient * ERC-677 standard * https://github.com/ethereum/EIPs/issues/677 * @param _to Receiver address. * @param _value Amount of tokens that will be transferred. * @param _data Transaction metadata. */ function transferAndCall(address _to, uint256 _value, bytes _data) external returns (bool) { require(_to != address(0)); require(canAcceptTokens_[_to] == true); // security check that contract approved by CST platform require(transfer(_to, _value)); // do a normal token transfer to the contract if (isContract(_to)) { AcceptsCryptoSurge receiver = AcceptsCryptoSurge(_to); require(receiver.tokenFallback(msg.sender, _value, _data)); } return true; } /** * Additional check that the game address we are sending tokens to is a contract * assemble the given address bytecode. If bytecode exists then the _addr is a contract. */ function isContract(address _addr) private constant returns (bool is_contract) { // retrieve the size of the code on target address, this needs assembly uint length; assembly { length := extcodesize(_addr) } return length > 0; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case the amassador quota is not met, the administrator can manually disable the ambassador phase. */ //function disableInitialStage() // onlyAdministrator() // public //{ // onlyAmbassadors = false; //} /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(address _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the masternode rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } /** * Add or remove game contract, which can accept Crypto Surge Tokens tokens */ function setCanAcceptTokens(address _address, bool _value) onlyAdministrator() public { canAcceptTokens_[_address] = _value; } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns(uint) { return this.balance; } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * Retrieve the dividend balance of any single address. */ function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout); return _taxedEthereum; } } /** * Return the sell price of 1 individual token. */ function buyPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100); uint256 _taxedEthereum = SafeMath.add(SafeMath.add(_ethereum, _dividends), _fundPayout); return _taxedEthereum; } } /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereumToSpend, fundFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereumToSpend, _dividends), _fundPayout); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout); return _taxedEthereum; } /** * Function for the frontend to show ether waiting to be send to fund in contract */ function etherToSendFund() public view returns(uint256) { return SafeMath.sub(totalEthFundCollected, totalEthFundRecieved); } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ // Make sure we will send back excess if user sends more then 5 ether before 100 ETH in contract function purchaseInternal(uint256 _incomingEthereum, address _referredBy) notContract()// no contracts allowed internal returns(uint256) { uint256 purchaseEthereum = _incomingEthereum; uint256 excess; if(purchaseEthereum > 2.5 ether) { // check if the transaction is over 2.5 ether if (SafeMath.sub(address(this).balance, purchaseEthereum) <= 100 ether) { // if so check the contract is less then 100 ether purchaseEthereum = 2.5 ether; excess = SafeMath.sub(_incomingEthereum, purchaseEthereum); } } purchaseTokens(purchaseEthereum, _referredBy); if (excess > 0) { msg.sender.transfer(excess); } } function handleRef(address _ref, uint _referralBonus, uint _currentDividends, uint _currentFee) internal returns (uint, uint){ uint _dividends = _currentDividends; uint _fee = _currentFee; address _referredBy = stickyRef[msg.sender]; if (_referredBy == address(0x0)){ _referredBy = _ref; } // is the user referred by a masternode? if( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != msg.sender && // does the referrer have at least X whole tokens? // i.e is the referrer a godly chad masternode tokenBalanceLedger_[_referredBy] >= stakingRequirement ){ // wealth redistribution if (stickyRef[msg.sender] == address(0x0)){ stickyRef[msg.sender] = _referredBy; } referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus/2); address currentRef = stickyRef[_referredBy]; if (currentRef != address(0x0) && tokenBalanceLedger_[currentRef] >= stakingRequirement){ referralBalance_[currentRef] = SafeMath.add(referralBalance_[currentRef], (_referralBonus/10)*3); currentRef = stickyRef[currentRef]; if (currentRef != address(0x0) && tokenBalanceLedger_[currentRef] >= stakingRequirement){ referralBalance_[currentRef] = SafeMath.add(referralBalance_[currentRef], (_referralBonus/10)*2); } else{ _dividends = SafeMath.add(_dividends, _referralBonus - _referralBonus/2 - (_referralBonus/10)*3); _fee = _dividends * magnitude; } } else{ _dividends = SafeMath.add(_dividends, _referralBonus - _referralBonus/2); _fee = _dividends * magnitude; } } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } return (_dividends, _fee); } function purchaseTokens(uint256 _incomingEthereum, address _referredBy) antiEarlyWhale(_incomingEthereum) internal returns(uint256) { // data setup uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, dividendFee_), 100); uint256 _referralBonus = SafeMath.div(_undividedDividends, 3); uint256 _fundPayout = SafeMath.div(SafeMath.mul(_incomingEthereum, fundFee_), 100); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _fee; (_dividends, _fee) = handleRef(_referredBy, _referralBonus, _dividends, _fee); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_incomingEthereum, _dividends), _fundPayout); totalEthFundCollected = SafeMath.add(totalEthFundCollected, _fundPayout); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); // no point in continuing execution if OP is a poorfag russian hacker // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world // (or hackers) // and yes we know that the safemath function automatically rules out the "greater then" equasion. require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_)); // we can't give people infinite ethereum if(tokenSupply_ > 0){ // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_)))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // update circulating supply & the ledger address for the customer tokenBalanceLedger_[msg.sender] = SafeMath.add(tokenBalanceLedger_[msg.sender], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; //really i know you think you do but you don't int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[msg.sender] += _updatedPayouts; // fire event onTokenPurchase(msg.sender, _incomingEthereum, _amountOfTokens, _referredBy); return _amountOfTokens; } /** * Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } //This is where all your gas goes, sorry //Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ 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; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
RE1
pragma solidity ^0.4.25; contract Piggy_Bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function Piggy_Bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract our_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function our_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract p_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function p_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.20; // File: contracts/ERC20Token.sol library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Owned { address public owner; address newOwner; modifier only(address _allowed) { require(msg.sender == _allowed); _; } constructor() public { owner = msg.sender; } function transferOwnership(address _newOwner) only(owner) public { newOwner = _newOwner; } function acceptOwnership() only(newOwner) public { emit OwnershipTransferred(owner, newOwner); owner = newOwner; } event OwnershipTransferred(address indexed _from, address indexed _to); } contract ERC20 is Owned { using SafeMath for uint; uint public totalSupply; bool public isStarted = false; mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; modifier isStartedOnly() { require(isStarted); _; } modifier isNotStartedOnly() { require(!isStarted); _; } event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) isStartedOnly public returns (bool success) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) isStartedOnly public returns (bool success) { require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint balance) { return balances[_owner]; } function approve_fixed(address _spender, uint _currentValue, uint _value) isStartedOnly public returns (bool success) { if(allowed[msg.sender][_spender] == _currentValue){ allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } else { return false; } } function approve(address _spender, uint _value) isStartedOnly public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint remaining) { return allowed[_owner][_spender]; } } contract Token is ERC20 { using SafeMath for uint; string public name; string public symbol; uint8 public decimals; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } function start() public only(owner) isNotStartedOnly { isStarted = true; } //================= Crowdsale Only ================= function mint(address _to, uint _amount) public only(owner) isNotStartedOnly returns(bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function multimint(address[] dests, uint[] values) public only(owner) isNotStartedOnly returns (uint) { uint i = 0; while (i < dests.length) { mint(dests[i], values[i]); i += 1; } return(i); } } contract TokenWithoutStart is Owned { using SafeMath for uint; mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; string public name; string public symbol; uint8 public decimals; uint public totalSupply; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } function transfer(address _to, uint _value) public returns (bool success) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint balance) { return balances[_owner]; } function approve_fixed(address _spender, uint _currentValue, uint _value) public returns (bool success) { if(allowed[msg.sender][_spender] == _currentValue){ allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } else { return false; } } function approve(address _spender, uint _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint remaining) { return allowed[_owner][_spender]; } function mint(address _to, uint _amount) public only(owner) returns(bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function multimint(address[] dests, uint[] values) public only(owner) returns (uint) { uint i = 0; while (i < dests.length) { mint(dests[i], values[i]); i += 1; } return(i); } } // File: contracts/ArchXArch2.sol // DEPLOYED BY JURY.ONLINE contract ICOContractX { // GENERAL ICO PARAMS ------------------------------------------------------ string public name; address public operator; // the ICO operator address public projectWallet; // the wallet that receives ICO Funds Token public token; // ICO token address public juryOnlineWallet; // JuryOnline Wallet for commission address public arbitrationAddress; // Address of Arbitration Contract uint public currentCycle; // current cycle struct Cycle { bool exists; bool approved; address icoRoundAddress; } mapping(uint => Cycle) public cycles; // stores the approved Cycles // DEPLOYED BY JURY.ONLINE // PARAMS: // address _operator // address _projectWallet // address _tokenAddress // address _arbitrationAddress // address _juryOnlineWallet constructor(string _name, address _operator, address _projectWallet, address _tokenAddress, address _arbitrationAddress, address _juryOnlineWallet) public { name = _name; operator = _operator; projectWallet = _projectWallet; token = Token(_tokenAddress); arbitrationAddress = _arbitrationAddress; juryOnlineWallet = _juryOnlineWallet; } // CALLED BY CYCLE CONTRACT function addRound() public { cycles[currentCycle].exists = true; cycles[currentCycle].icoRoundAddress = msg.sender; } // CALLED BY ICO OPERATOR, approves CYCLE Contract and adds it to cycles function approveRound(address _icoRoundAddress) public { require(msg.sender == operator); require(cycles[currentCycle].icoRoundAddress == _icoRoundAddress); currentCycle +=1; } } // DEPLOYED BY JURY.ONLINE contract ICOCycle { using SafeMath for uint; // GENERAL CYCLE VARIABLES ------------------------------------------------- address public juryOperator; // assists in operation address public operator; // cycle operator, same as ICO operator address public icoAddress; // to associate Cycle with ICO address public juryOnlineWallet; // juryOnlineWallet for commission address public projectWallet; // taken from ICO contract address public arbitrationAddress; // taken from ICO contract Token public token; // taken from ICO contract address public swapper; // address for JOT commission bool public saveMe; // if true, gives Jury.Online control of contract struct Milestone { uint etherAmount; //how many Ether is needed for this milestone uint tokenAmount; //how many tokens releases this milestone uint startTime; //real time when milestone has started, set upon start uint finishTime; //real time when milestone has finished, set upon finish uint duration; //assumed duration for milestone implementation, set upon milestone creation string description; string result; } Milestone[] public milestones; // List of Milestones uint public currentMilestone; uint public sealTimestamp; // the moment the Cycle is Sealed by operator uint public ethForMilestone; // Amount to be withdraw by operator for each milestone uint public postDisputeEth; // in case of dispute in favor of ico project // INVESTOR struct stores information about each Investor // Investor can have more than one deals, but only one right to dispute struct Investor { bool disputing; uint tokenAllowance; uint etherUsed; uint sumEther; uint sumToken; bool verdictForProject; bool verdictForInvestor; uint numberOfDeals; } struct Deal { address investor; uint etherAmount; uint tokenAmount; bool accepted; } mapping(address => Investor) public deals; // map of information of investors with deals address[] public dealsList; // list of investors with deals mapping(address => mapping(uint => Deal)) public offers; // pending offers // COMMISSION ARRAYS // amounts stores as percentage // If length == 1, commission paid when investment is accepted // If length > 1, each element is commission to corresponding milestone // ETH commission is transferred to Jury.Online wallet // JOT commission is transferred to a Swapper contract that swaps eth for jot uint[] public commissionEth; uint[] public commissionJot; uint public etherAllowance; // Amount that Jury.Online can withdraw as commission in ETH uint public jotAllowance; // Amount that Jury.Online can withdraw as commission in JOT uint public totalEther; // Sum of ether in milestones uint public totalToken; // Sum of tokens in milestones uint public promisedTokens; // Sum of tokens promised by accepting offer uint public raisedEther; // Sum of ether raised by accepting offer uint public rate; // eth to token rate in current Funding Round bool public tokenReleaseAtStart; // whether to release tokens at start or by each milestone uint public currentFundingRound; bool public roundFailedToStart; // Stores amount of ether and tokens per milestone for each investor mapping(address => uint[]) public etherPartition; mapping(address => uint[]) public tokenPartition; // Funding Rounds can be added with start, end time, rate, and whitelist struct FundingRound { uint startTime; uint endTime; uint rate; bool hasWhitelist; } FundingRound[] public roundPrices; // stores list of funding rounds mapping(uint => mapping(address => bool)) public whitelist; // stores whitelists // ------------------------------------------------------------------------- // MODIFIERS modifier onlyOperator() { require(msg.sender == operator || msg.sender == juryOperator); _; } modifier onlyAdmin() { require(msg.sender == operator || msg.sender == juryOperator); _; } modifier sealed() { require(sealTimestamp != 0); /* require(now > sealTimestamp); */ _; } modifier notSealed() { require(sealTimestamp == 0); /* require(now <= sealTimestamp); */ _; } // ------------------------------------------------------------------------- // DEPLOYED BY JURY.ONLINE // PARAMS: // address _icoAddress // address _operator // uint _rate // address _swapper // uint[] _commissionEth // uint[] _commissionJot constructor( address _icoAddress, address _operator, uint _rate, address _swapper, uint[] _commissionEth, uint[] _commissionJot) public { require(_commissionEth.length == _commissionJot.length); juryOperator = msg.sender; icoAddress = _icoAddress; operator = _operator; rate = _rate; swapper = _swapper; commissionEth = _commissionEth; commissionJot = _commissionJot; roundPrices.push(FundingRound(0,0,0,false)); tokenReleaseAtStart = true; } // CALLED BY JURY.ONLINE TO SET SWAPPER ADDRESS FOR JOT COMMISSION function setSwapper(address _swapper) public { require(msg.sender == juryOperator); swapper = _swapper; } // CALLED BY ADMIN TO RETRIEVE INFORMATION FROM ICOADDRESS AND ADD ITSELF // TO LIST OF CYCLES IN ICO function activate() onlyAdmin notSealed public { ICOContractX icoContract = ICOContractX(icoAddress); require(icoContract.operator() == operator); juryOnlineWallet = icoContract.juryOnlineWallet(); projectWallet = icoContract.projectWallet(); arbitrationAddress = icoContract.arbitrationAddress(); token = icoContract.token(); icoContract.addRound(); } // CALLED BY JURY.ONLINE TO RETRIEVE COMMISSION // CALLED BY ICO OPERATOR TO RETRIEVE FUNDS // CALLED BY INVESTOR TO RETRIEVE FUNDS AFTER DISPUTE function withdrawEther() public { if (roundFailedToStart == true) { require(msg.sender.send(deals[msg.sender].sumEther)); } if (msg.sender == operator) { require(projectWallet.send(ethForMilestone+postDisputeEth)); ethForMilestone = 0; postDisputeEth = 0; } if (msg.sender == juryOnlineWallet) { require(juryOnlineWallet.send(etherAllowance)); require(swapper.call.value(jotAllowance)(abi.encodeWithSignature("swapMe()"))); etherAllowance = 0; jotAllowance = 0; } if (deals[msg.sender].verdictForInvestor == true) { require(msg.sender.send(deals[msg.sender].sumEther - deals[msg.sender].etherUsed)); } } // CALLED BY INVESTOR TO RETRIEVE TOKENS function withdrawToken() public { require(token.transfer(msg.sender,deals[msg.sender].tokenAllowance)); deals[msg.sender].tokenAllowance = 0; } // CALLED BY ICO OPERATOR TO ADD FUNDING ROUNDS WITH _startTime,_endTime,_price,_whitelist function addRoundPrice(uint _startTime,uint _endTime, uint _price, address[] _whitelist) public onlyOperator { if (_whitelist.length == 0) { roundPrices.push(FundingRound(_startTime, _endTime,_price,false)); } else { for (uint i=0 ; i < _whitelist.length ; i++ ) { whitelist[roundPrices.length][_whitelist[i]] = true; } roundPrices.push(FundingRound(_startTime, _endTime,_price,true)); } } // CALLED BY ICO OPERATOR TO SET RATE WITHOUT SETTING FUNDING ROUND function setRate(uint _rate) onlyOperator public { rate = _rate; } // CALLED BY ICO OPERATOR TO APPLY WHITELIST AND PRICE OF FUNDING ROUND function setCurrentFundingRound(uint _fundingRound) public onlyOperator { require(roundPrices.length > _fundingRound); currentFundingRound = _fundingRound; } // RECEIVES FUNDS AND CREATES OFFER function () public payable { require(msg.value > 0); if (roundPrices[currentFundingRound].hasWhitelist == true) { require(whitelist[currentFundingRound][msg.sender] == true); } uint dealNumber = deals[msg.sender].numberOfDeals; offers[msg.sender][dealNumber].investor = msg.sender; offers[msg.sender][dealNumber].etherAmount = msg.value; deals[msg.sender].numberOfDeals += 1; } // CALCULATES AMOUNT OF TOKENS FOR GIVEN ETH function calculateTokens(uint256 _weiAmount) constant public returns (uint256) { uint256 tokens = _weiAmount.mul(rate).mul(100).div(75).div(100 finney); if(tokens.div(100000000) < 5000) return _weiAmount.mul(rate).mul(100).div(80).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(73).div(100 finney); if(tokens.div(100000000) < 25000) return _weiAmount.mul(rate).mul(100).div(75).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(70).div(100 finney); if(tokens.div(100000000) < 50000) return _weiAmount.mul(rate).mul(100).div(73).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(65).div(100 finney); if(tokens.div(100000000) < 250000) return _weiAmount.mul(rate).mul(100).div(70).div(100 finney); tokens = _weiAmount.mul(rate).mul(100).div(60).div(100 finney); if(tokens.div(100000000) < 500000) return _weiAmount.mul(rate).mul(100).div(65).div(100 finney); return _weiAmount.mul(rate).mul(100).div(60).div(100 finney); } // IF OFFER NOT ACCEPTED, CAN BE WITHDRAWN function withdrawOffer(uint _offerNumber) public { require(offers[msg.sender][_offerNumber].accepted == false); require(msg.sender.send(offers[msg.sender][_offerNumber].etherAmount)); offers[msg.sender][_offerNumber].etherAmount = 0; /* offers[msg.sender][_offerNumber].tokenAmount = 0; */ } // ARBITRATION // CALLED BY ARBITRATION ADDRESS function disputeOpened(address _investor) public { require(msg.sender == arbitrationAddress); deals[_investor].disputing = true; } // CALLED BY ARBITRATION ADDRESS function verdictExecuted(address _investor, bool _verdictForInvestor,uint _milestoneDispute) public { require(msg.sender == arbitrationAddress); require(deals[_investor].disputing == true); if (_verdictForInvestor) { deals[_investor].verdictForInvestor = true; } else { deals[_investor].verdictForProject = true; for (uint i = _milestoneDispute; i < currentMilestone; i++) { postDisputeEth += etherPartition[_investor][i]; deals[_investor].etherUsed += etherPartition[_investor][i]; } } deals[_investor].disputing = false; } // OPERATOR // TO ADD MILESTONES function addMilestone(uint _etherAmount, uint _tokenAmount, uint _startTime, uint _duration, string _description) public notSealed onlyOperator returns(uint) { totalEther = totalEther.add(_etherAmount); totalToken = totalToken.add(_tokenAmount); return milestones.push(Milestone(_etherAmount, _tokenAmount, _startTime, 0, _duration, _description, "")); } // TO SEAL function seal() public notSealed onlyOperator { require(milestones.length > 0); require(token.balanceOf(address(this)) >= totalToken); sealTimestamp = now; } // TO ACCEPT OFFER function acceptOffer(address _investor, uint _offerNumber) public sealed onlyOperator { // REQUIRE THAT OFFER HAS NOT BEEN APPROVED require(offers[_investor][_offerNumber].etherAmount > 0); require(offers[_investor][_offerNumber].accepted != true); // APPROVE OFFER offers[_investor][_offerNumber].accepted = true; // CALCULATE TOKENS uint _etherAmount = offers[_investor][_offerNumber].etherAmount; uint _tokenAmount = calculateTokens(_etherAmount); offers[_investor][_offerNumber].tokenAmount = _tokenAmount; //require(token.balanceOf(address(this)) >= promisedTokens + _tokenAmount); // CALCULATE COMMISSION if (commissionEth.length == 1) { uint etherCommission = _etherAmount.mul(commissionEth[0]).div(100); uint jotCommission = _etherAmount.mul(commissionJot[0]).div(100); _etherAmount = _etherAmount.sub(etherCommission).sub(jotCommission); offers[_investor][_offerNumber].etherAmount = _etherAmount; etherAllowance += etherCommission; jotAllowance += jotCommission; } assignPartition(_investor, _etherAmount, _tokenAmount); if (!(deals[_investor].sumEther > 0)) dealsList.push(_investor); if (tokenReleaseAtStart == true) { deals[_investor].tokenAllowance = _tokenAmount; } /* deals[_investor].numberOfDeals += 1; */ deals[_investor].sumEther += _etherAmount; deals[_investor].sumToken += _tokenAmount; } // TO START MILESTONE function startMilestone() public sealed onlyOperator { // UNCOMMENT 2 LINES BELOW FOR PROJECT FAILS START IF totalEther < raisedEther // if (currentMilestone == 0 && totalEther < raisedEther) { roundFailedToStart = true; } // require(!roundFailedToStart); if (currentMilestone != 0 ) {require(milestones[currentMilestone-1].finishTime > 0);} for (uint i=0; i < dealsList.length ; i++) { address investor = dealsList[i]; if (deals[investor].disputing == false) { if (deals[investor].verdictForInvestor != true) { ethForMilestone += etherPartition[investor][currentMilestone]; deals[investor].etherUsed += etherPartition[investor][currentMilestone]; if (tokenReleaseAtStart == false) { deals[investor].tokenAllowance += tokenPartition[investor][currentMilestone]; } } } } currentMilestone +=1; //ethAfterCommission = payCommission(); } // TO FINISH MILESTONE function finishMilestone(string _result) public onlyOperator { require(milestones[currentMilestone-1].finishTime == 0); milestones[currentMilestone-1].finishTime = now; milestones[currentMilestone-1].result = _result; } // ------------------------------------------------------------------------- // // HELPERS ----------------------------------------------------------------- function failSafe() public onlyAdmin { if (msg.sender == operator) { saveMe = true; } if (msg.sender == juryOperator) { require(saveMe == true); require(juryOperator.send(address(this).balance)); uint allTheLockedTokens = token.balanceOf(this); require(token.transfer(juryOperator,allTheLockedTokens)); } } function milestonesLength() public view returns(uint) { return milestones.length; } function assignPartition(address _investor, uint _etherAmount, uint _tokenAmount) internal { uint milestoneEtherAmount; //How much Ether does investor send for a milestone uint milestoneTokenAmount; //How many Tokens does investor receive for a milestone uint milestoneEtherTarget; //How much TOTAL Ether a milestone needs uint milestoneTokenTarget; //How many TOTAL tokens a milestone releases uint totalEtherInvestment; uint totalTokenInvestment; for(uint i=currentMilestone; i<milestones.length; i++) { milestoneEtherTarget = milestones[i].etherAmount; milestoneTokenTarget = milestones[i].tokenAmount; milestoneEtherAmount = _etherAmount.mul(milestoneEtherTarget).div(totalEther); milestoneTokenAmount = _tokenAmount.mul(milestoneTokenTarget).div(totalToken); totalEtherInvestment = totalEtherInvestment.add(milestoneEtherAmount); //used to prevent rounding errors totalTokenInvestment = totalTokenInvestment.add(milestoneTokenAmount); //used to prevent rounding errors if (deals[_investor].sumEther > 0) { etherPartition[_investor][i] += milestoneEtherAmount; tokenPartition[_investor][i] += milestoneTokenAmount; } else { etherPartition[_investor].push(milestoneEtherAmount); tokenPartition[_investor].push(milestoneTokenAmount); } } /* roundingErrors += _etherAmount - totalEtherInvestment; */ etherPartition[_investor][currentMilestone] += _etherAmount - totalEtherInvestment; //rounding error is added to the first milestone tokenPartition[_investor][currentMilestone] += _tokenAmount - totalTokenInvestment; //rounding error is added to the first milestone } function isDisputing(address _investor) public view returns(bool) { return deals[_investor].disputing; } // CHECK TO SEE IF INVESTOR IS IN WHITELIST (for debugging) /* function isInWhitelist(uint _fundingRound, address _investor) public view returns(bool) { return whitelist[_fundingRound][_investor]; } */ /* function commissionCheck() internal view returns(bool) { for ( uint i=0 ; i < commissionEth.length ; i++ ) { uint percentToBeReleased = milestones[i].etherAmount.mul(100).div(totalEther); uint percentToPay = commissionEth[i] + commissionJot[i]; require(percentToPay <= percentToBeReleased); } return true; } */ } contract ArbitrationX { address public operator; uint public quorum = 3; //uint public counter; struct Dispute { address icoRoundAddress; address investorAddress; bool pending; uint timestamp; uint milestone; string reason; uint votesForProject; uint votesForInvestor; // bool verdictForProject; // bool verdictForInvestor; mapping(address => bool) voters; } mapping(uint => Dispute) public disputes; uint public disputeLength; mapping(address => mapping(address => bool)) public arbiterPool; constructor() public { operator = msg.sender; } // OPERATOR function setArbiters(address _icoRoundAddress, address[] _arbiters) public { for (uint i = 0; i < _arbiters.length ; i++) { arbiterPool[_icoRoundAddress][_arbiters[i]] = true; } } // ARBITER function vote(uint _disputeId, bool _voteForInvestor) public { require(disputes[_disputeId].pending == true); /* require(arbiterPool[disputes[_disputeId].icoRoundAddress][msg.sender] == true); */ require(disputes[_disputeId].voters[msg.sender] != true); if (_voteForInvestor == true) { disputes[_disputeId].votesForInvestor += 1; } else { disputes[_disputeId].votesForProject += 1; } if (disputes[_disputeId].votesForInvestor == quorum) { executeVerdict(_disputeId,true); } if (disputes[_disputeId].votesForProject == quorum) { executeVerdict(_disputeId,false); } disputes[_disputeId].voters[msg.sender] == true; } // INVESTOR function openDispute(address _icoRoundAddress, string _reason) public { ICOCycle icoRound = ICOCycle(_icoRoundAddress); uint milestoneDispute = icoRound.currentMilestone(); require(milestoneDispute > 0); disputes[disputeLength].milestone = milestoneDispute; disputes[disputeLength].icoRoundAddress = _icoRoundAddress; disputes[disputeLength].investorAddress = msg.sender; disputes[disputeLength].timestamp = now; disputes[disputeLength].reason = _reason; disputes[disputeLength].pending = true; icoRound.disputeOpened(msg.sender); disputeLength +=1; } // INTERNAL function executeVerdict(uint _disputeId, bool _verdictForInvestor) internal { disputes[_disputeId].pending = false; uint milestoneDispute = disputes[_disputeId].milestone; ICOCycle icoRound = ICOCycle(disputes[_disputeId].icoRoundAddress); icoRound.verdictExecuted(disputes[_disputeId].investorAddress,_verdictForInvestor,milestoneDispute); //counter +=1; } function isPending(uint _disputedId) public view returns(bool) { return disputes[_disputedId].pending; } } contract Swapper { // for an ethToJot of 2,443.0336457941, Aug 21, 2018 Token public token; uint public ethToJot = 2443; address public myBal; address public owner; uint public myJot; uint public ujot; constructor(address _jotAddress) public { owner = msg.sender; token = Token(_jotAddress); myBal = address(this); /* myJot = token.balanceOf(myBal); */ } /* function() payable public { */ /* myBal = address(this); */ /* myJot = token.balanceOf(myBal); */ /* require(token.balanceOf(myBal) >= jot); */ /* require(token.transfer(msg.sender,jot)); */ function swapMe() public payable { uint jot = msg.value * ethToJot; myJot = token.balanceOf(myBal); ujot = jot; require(token.transfer(owner,jot)); } }
RE1
pragma solidity ^0.4.19; contract PERSONAL_BANK { mapping (address=>uint256) public balances; uint public MinSum = 1 ether; LogFile Log = LogFile(0x0486cF65A2F2F3A392CBEa398AFB7F5f0B72FF46); bool intitalized; function SetMinSum(uint _val) public { if(intitalized)revert(); MinSum = _val; } function SetLogFile(address _log) public { if(intitalized)revert(); Log = LogFile(_log); } function Initialized() public { intitalized = true; } function Deposit() public payable { balances[msg.sender]+= msg.value; Log.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { if(balances[msg.sender]>=MinSum && balances[msg.sender]>=_am) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; Log.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Deposit(); } } contract LogFile { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract WWW_wallet { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function WWW_wallet(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract IQ_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function IQ_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
/* This file is part of the PROOF Contract. The PROOF Contract is free software: you can redistribute it and/or modify it under the terms of the GNU lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The PROOF Contract is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU lesser General Public License for more details. You should have received a copy of the GNU lesser General Public License along with the PROOF Contract. If not, see <http://www.gnu.org/licenses/>. @author Ilya Svirin <[email protected]> */ pragma solidity ^0.4.0; contract owned { address public owner; address public newOwner; function owned() payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } function changeOwner(address _owner) onlyOwner public { require(_owner != 0); newOwner = _owner; } function confirmOwner() public { require(newOwner == msg.sender); owner = newOwner; delete newOwner; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 { uint public totalSupply; function balanceOf(address who) constant returns (uint); function transfer(address to, uint value); function allowance(address owner, address spender) constant returns (uint); function transferFrom(address from, address to, uint value); function approve(address spender, uint value); event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); } contract ManualMigration is owned, ERC20 { mapping (address => uint) internal balances; address public migrationHost; function ManualMigration(address _migrationHost) payable owned() { migrationHost = _migrationHost; //balances[this] = ERC20(migrationHost).balanceOf(migrationHost); } function migrateManual(address _tokensHolder) onlyOwner { require(migrationHost != 0); uint tokens = ERC20(migrationHost).balanceOf(_tokensHolder); tokens = tokens * 125 / 100; balances[_tokensHolder] = tokens; totalSupply += tokens; Transfer(migrationHost, _tokensHolder, tokens); } function sealManualMigration() onlyOwner { delete migrationHost; } } /** * @title Crowdsale implementation */ contract Crowdsale is ManualMigration { uint public etherPrice; address public crowdsaleOwner; uint public totalLimitUSD; uint public minimalSuccessUSD; uint public collectedUSD; enum State { Disabled, PreICO, CompletePreICO, Crowdsale, Enabled, Migration } event NewState(State state); State public state = State.Disabled; uint public crowdsaleStartTime; uint public crowdsaleFinishTime; modifier enabledState { require(state == State.Enabled); _; } modifier enabledOrMigrationState { require(state == State.Enabled || state == State.Migration); _; } struct Investor { uint amountTokens; uint amountWei; } mapping (address => Investor) public investors; mapping (uint => address) public investorsIter; uint public numberOfInvestors; function Crowdsale(address _migrationHost) payable ManualMigration(_migrationHost) { } function () payable { require(state == State.PreICO || state == State.Crowdsale); require(now < crowdsaleFinishTime); uint valueWei = msg.value; uint valueUSD = valueWei * etherPrice / 1000000000000000000; if (collectedUSD + valueUSD > totalLimitUSD) { // don't need so much ether valueUSD = totalLimitUSD - collectedUSD; valueWei = valueUSD * 1000000000000000000 / etherPrice; require(msg.sender.call.gas(3000000).value(msg.value - valueWei)()); collectedUSD = totalLimitUSD; // to be sure! } else { collectedUSD += valueUSD; } mintTokens(msg.sender, valueUSD, valueWei); } function depositUSD(address _who, uint _valueUSD) public onlyOwner { require(state == State.PreICO || state == State.Crowdsale); require(now < crowdsaleFinishTime); require(collectedUSD + _valueUSD <= totalLimitUSD); collectedUSD += _valueUSD; mintTokens(_who, _valueUSD, 0); } function mintTokens(address _who, uint _valueUSD, uint _valueWei) internal { uint tokensPerUSD = 100; if (state == State.PreICO) { if (now < crowdsaleStartTime + 1 days && _valueUSD >= 50000) { tokensPerUSD = 150; } else { tokensPerUSD = 125; } } else if (state == State.Crowdsale) { if (now < crowdsaleStartTime + 1 days) { tokensPerUSD = 115; } else if (now < crowdsaleStartTime + 1 weeks) { tokensPerUSD = 110; } } uint tokens = tokensPerUSD * _valueUSD; require(balances[_who] + tokens > balances[_who]); // overflow require(tokens > 0); Investor storage inv = investors[_who]; if (inv.amountTokens == 0) { // new investor investorsIter[numberOfInvestors++] = _who; } inv.amountTokens += tokens; inv.amountWei += _valueWei; balances[_who] += tokens; Transfer(this, _who, tokens); totalSupply += tokens; } function startTokensSale( address _crowdsaleOwner, uint _crowdsaleDurationDays, uint _totalLimitUSD, uint _minimalSuccessUSD, uint _etherPrice) public onlyOwner { require(state == State.Disabled || state == State.CompletePreICO); crowdsaleStartTime = now; crowdsaleOwner = _crowdsaleOwner; etherPrice = _etherPrice; delete numberOfInvestors; delete collectedUSD; crowdsaleFinishTime = now + _crowdsaleDurationDays * 1 days; totalLimitUSD = _totalLimitUSD; minimalSuccessUSD = _minimalSuccessUSD; if (state == State.Disabled) { state = State.PreICO; } else { state = State.Crowdsale; } NewState(state); } function timeToFinishTokensSale() public constant returns(uint t) { require(state == State.PreICO || state == State.Crowdsale); if (now > crowdsaleFinishTime) { t = 0; } else { t = crowdsaleFinishTime - now; } } function finishTokensSale(uint _investorsToProcess) public { require(state == State.PreICO || state == State.Crowdsale); require(now >= crowdsaleFinishTime || collectedUSD == totalLimitUSD || (collectedUSD >= minimalSuccessUSD && msg.sender == owner)); if (collectedUSD < minimalSuccessUSD) { // Investors can get their ether calling withdrawBack() function while (_investorsToProcess > 0 && numberOfInvestors > 0) { address addr = investorsIter[--numberOfInvestors]; Investor memory inv = investors[addr]; balances[addr] -= inv.amountTokens; totalSupply -= inv.amountTokens; Transfer(addr, this, inv.amountTokens); --_investorsToProcess; delete investorsIter[numberOfInvestors]; } if (numberOfInvestors > 0) { return; } if (state == State.PreICO) { state = State.Disabled; } else { state = State.CompletePreICO; } } else { while (_investorsToProcess > 0 && numberOfInvestors > 0) { --numberOfInvestors; --_investorsToProcess; delete investors[investorsIter[numberOfInvestors]]; delete investorsIter[numberOfInvestors]; } if (numberOfInvestors > 0) { return; } if (state == State.PreICO) { require(crowdsaleOwner.call.gas(3000000).value(this.balance)()); state = State.CompletePreICO; } else { require(crowdsaleOwner.call.gas(3000000).value(minimalSuccessUSD * 1000000000000000000 / etherPrice)()); // Create additional tokens for owner (30% of complete totalSupply) uint tokens = 3 * totalSupply / 7; balances[owner] = tokens; totalSupply += tokens; Transfer(this, owner, tokens); state = State.Enabled; } } NewState(state); } // This function must be called by token holder in case of crowdsale failed function withdrawBack() public { require(state == State.Disabled || state == State.CompletePreICO); uint value = investors[msg.sender].amountWei; if (value > 0) { delete investors[msg.sender]; require(msg.sender.call.gas(3000000).value(value)()); } } } /** * @title Abstract interface for PROOF operating from registered external controllers */ contract Fund { function transferFund(address _to, uint _value); } /** * @title Token PROOF implementation */ contract Token is Crowdsale, Fund { string public standard = 'Token 0.1'; string public name = 'PROOF'; string public symbol = "PF"; uint8 public decimals = 0; mapping (address => mapping (address => uint)) public allowed; mapping (address => bool) public externalControllers; modifier onlyTokenHolders { require(balances[msg.sender] != 0); _; } // Fix for the ERC20 short address attack modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } modifier externalController { require(externalControllers[msg.sender]); _; } function Token(address _migrationHost) payable Crowdsale(_migrationHost) {} function balanceOf(address who) constant returns (uint) { return balances[who]; } function transfer(address _to, uint _value) public enabledState onlyPayloadSize(2 * 32) { require(balances[msg.sender] >= _value); require(balances[_to] + _value >= balances[_to]); // overflow balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public enabledState onlyPayloadSize(3 * 32) { require(balances[_from] >= _value); require(balances[_to] + _value >= balances[_to]); // overflow require(allowed[_from][msg.sender] >= _value); balances[_from] -= _value; balances[_to] += _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); } function approve(address _spender, uint _value) public enabledState { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) public constant enabledState returns (uint remaining) { return allowed[_owner][_spender]; } function transferFund(address _to, uint _value) public externalController { require(balances[this] >= _value); require(balances[_to] + _value >= balances[_to]); // overflow balances[this] -= _value; balances[_to] += _value; Transfer(this, _to, _value); } } contract ProofVote is Token { function ProofVote(address _migrationHost) payable Token(_migrationHost) {} event VotingStarted(uint weiReqFund, VoteReason voteReason); event Voted(address indexed voter, bool inSupport); event VotingFinished(bool inSupport); enum Vote { NoVote, VoteYea, VoteNay } enum VoteReason { Nothing, ReqFund, Migration, UpdateContract } uint public weiReqFund; uint public votingDeadline; uint public numberOfVotes; uint public yea; uint public nay; VoteReason voteReason; mapping (address => Vote) public votes; mapping (uint => address) public votesIter; address public migrationAgent; address public migrationAgentCandidate; address public externalControllerCandidate; function startVoting(uint _weiReqFund) public enabledOrMigrationState onlyOwner { require(_weiReqFund > 0); internalStartVoting(_weiReqFund, VoteReason.ReqFund, 7); } function internalStartVoting(uint _weiReqFund, VoteReason _voteReason, uint _votingDurationDays) internal { require(voteReason == VoteReason.Nothing && _weiReqFund <= this.balance); weiReqFund = _weiReqFund; votingDeadline = now + _votingDurationDays * 1 days; voteReason = _voteReason; delete yea; delete nay; VotingStarted(_weiReqFund, _voteReason); } function votingInfo() public constant returns(uint _weiReqFund, uint _timeToFinish, VoteReason _voteReason) { _weiReqFund = weiReqFund; _voteReason = voteReason; if (votingDeadline <= now) { _timeToFinish = 0; } else { _timeToFinish = votingDeadline - now; } } function vote(bool _inSupport) public onlyTokenHolders returns (uint voteId) { require(voteReason != VoteReason.Nothing); require(votes[msg.sender] == Vote.NoVote); require(votingDeadline > now); voteId = numberOfVotes++; votesIter[voteId] = msg.sender; if (_inSupport) { votes[msg.sender] = Vote.VoteYea; } else { votes[msg.sender] = Vote.VoteNay; } Voted(msg.sender, _inSupport); return voteId; } function finishVoting(uint _votesToProcess) public returns (bool _inSupport) { require(voteReason != VoteReason.Nothing); require(now >= votingDeadline); while (_votesToProcess > 0 && numberOfVotes > 0) { address voter = votesIter[--numberOfVotes]; Vote v = votes[voter]; uint voteWeight = balances[voter]; if (v == Vote.VoteYea) { yea += voteWeight; } else if (v == Vote.VoteNay) { nay += voteWeight; } delete votes[voter]; delete votesIter[numberOfVotes]; --_votesToProcess; } if (numberOfVotes > 0) { _inSupport = false; return; } _inSupport = (yea > nay); uint weiForSend = weiReqFund; delete weiReqFund; delete votingDeadline; delete numberOfVotes; if (_inSupport) { if (voteReason == VoteReason.ReqFund) { require(owner.call.gas(3000000).value(weiForSend)()); } else if (voteReason == VoteReason.Migration) { migrationAgent = migrationAgentCandidate; require(migrationAgent.call.gas(3000000).value(this.balance)()); delete migrationAgentCandidate; state = State.Migration; } else if (voteReason == VoteReason.UpdateContract) { externalControllers[externalControllerCandidate] = true; delete externalControllerCandidate; } } delete voteReason; VotingFinished(_inSupport); } } /** * @title Migration agent intefrace for possibility of moving tokens * to another contract */ contract MigrationAgent { function migrateFrom(address _from, uint _value); } /** * @title Migration functionality for possibility of moving tokens * to another contract */ contract TokenMigration is ProofVote { uint public totalMigrated; event Migrate(address indexed from, address indexed to, uint value); function TokenMigration(address _migrationHost) payable ProofVote(_migrationHost) {} // Migrate _value of tokens to the new token contract function migrate() external { require(state == State.Migration); uint value = balances[msg.sender]; balances[msg.sender] -= value; Transfer(msg.sender, this, value); totalSupply -= value; totalMigrated += value; MigrationAgent(migrationAgent).migrateFrom(msg.sender, value); Migrate(msg.sender, migrationAgent, value); } function setMigrationAgent(address _agent) external onlyOwner { require(migrationAgent == 0 && _agent != 0); migrationAgentCandidate = _agent; internalStartVoting(0, VoteReason.Migration, 2); } } contract ProofFund is TokenMigration { function ProofFund(address _migrationHost) payable TokenMigration(_migrationHost) {} function addExternalController(address _externalControllerCandidate) public onlyOwner { require(_externalControllerCandidate != 0); externalControllerCandidate = _externalControllerCandidate; internalStartVoting(0, VoteReason.UpdateContract, 2); } function removeExternalController(address _externalController) public onlyOwner { delete externalControllers[_externalController]; } } /** * @title Proof interface */ contract ProofAbstract { function swypeCode(address _who) returns (uint16 _swype); function setHash(address _who, uint16 _swype, bytes32 _hash); } contract Proof is ProofFund { uint public priceInTokens; uint public teamFee; address public proofImpl; function Proof(address _migrationHost) payable ProofFund(_migrationHost) {} function setPrice(uint _priceInTokens) public onlyOwner { require(_priceInTokens >= 2); teamFee = _priceInTokens / 10; if (teamFee == 0) { teamFee = 1; } priceInTokens = _priceInTokens - teamFee; } function setProofImpl(address _proofImpl) public onlyOwner { proofImpl = _proofImpl; } function swypeCode() public returns (uint16 _swype) { require(proofImpl != 0); _swype = ProofAbstract(proofImpl).swypeCode(msg.sender); } function setHash(uint16 _swype, bytes32 _hash) public { require(proofImpl != 0); transfer(owner, teamFee); transfer(this, priceInTokens); ProofAbstract(proofImpl).setHash(msg.sender, _swype, _hash); } }
RE1
pragma solidity ^0.4.25; contract c_Bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function c_Bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract Cb_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function Cb_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract ULTRA_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function ULTRA_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.24; /* * GREED VS FEAR */ contract AcceptsGreedVSFear { GreedVSFear public tokenContract; constructor(address _tokenContract) public { tokenContract = GreedVSFear(_tokenContract); } modifier onlyTokenContract { require(msg.sender == address(tokenContract)); _; } function tokenFallback(address _from, uint256 _value, bytes _data) external returns (bool); } contract GreedVSFear { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // only people with profits modifier onlyStronghands() { require(myDividends(true) > 0); _; } modifier noUnapprovedContracts() { require (msg.sender == tx.origin || approvedContracts[msg.sender] == true); _; } mapping (address => uint256) public sellTmr; mapping (address => uint256) public buyTmr; uint256 sellTimerN = (15 hours); uint256 buyTimerN = (45 minutes); uint256 buyMax = 25 ether; modifier sellLimit(){ require(block.timestamp > sellTmr[msg.sender] , "You cannot sell because of the sell timer"); _; } modifier buyLimit(){ require(block.timestamp > buyTmr[msg.sender], "You cannot buy because of buy cooldown"); require(msg.value <= buyMax, "You cannot buy because you bought over the max"); buyTmr[msg.sender] = block.timestamp + buyTimerN; sellTmr[msg.sender] = block.timestamp + sellTimerN; _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> change the PoS difficulty (How many tokens it costs to hold a masternode, in case it gets crazy high later) // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[_customerAddress]); _; } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "Greed VS Fear"; string public symbol = "GREED"; uint8 constant public decimals = 18; uint8 constant internal dividendFee_ = 20; // Fear Math uint8 constant internal jackpotFee_ = 5; uint8 constant internal greedFee_ = 5; uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.00000002 ether; uint256 constant internal magnitude = 2**64; address constant public devGreed = 0x90F1A46816D26db43397729f50C6622E795f9957; address constant public jackpotAddress = 0xFEb461A778Be56aEE6F8138D1ddA8fcc768E5800; uint256 public jackpotReceived; uint256 public jackpotCollected; // proof of stake uint256 public stakingRequirement = 250e18; // ambassador program mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 1 ether; uint256 constant internal ambassadorQuota_ = 2000 ether; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = false; mapping(address => bool) public canAcceptTokens_; mapping(address => bool) public approvedContracts; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ function Greedy() public payable { // add administrators here administrators[msg.sender] = true; ambassadors_[msg.sender] = true; purchaseTokens(msg.value, address(0x0)); } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) */ function buy(address _referredBy) public payable returns(uint256) { purchaseTokens(msg.value, _referredBy); } /** * Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { purchaseTokens(msg.value, 0x0); } function jackpotSend() payable public { uint256 ethToPay = SafeMath.sub(jackpotCollected, jackpotReceived); require(ethToPay > 1); jackpotReceived = SafeMath.add(jackpotReceived, ethToPay); if(!jackpotAddress.call.value(ethToPay).gas(400000)()) { jackpotReceived = SafeMath.sub(jackpotReceived, ethToPay); } } /** * Converts all of caller's dividends to tokens. */ function reinvest() onlyStronghands() public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = _purchaseTokens(_dividends, 0x0); // fire event emit onReinvestment(_customerAddress, _dividends, _tokens); } /** * Alias of sell() and withdraw(). */ function exit() public sellLimit() { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(); } /** * Withdraws all of the callers earnings. */ function withdraw() onlyStronghands() sellLimit() public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event emit onWithdraw(_customerAddress, _dividends); } /** * Liquifies tokens to ethereum. */ function sell(uint256 _amountOfTokens) onlyBagholders() sellLimit() public { // setup data address _customerAddress = msg.sender; // russian hackers BTFO require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _jackpotSend = SafeMath.div(SafeMath.mul(_ethereum, jackpotFee_), 100); uint256 _greedyFee = SafeMath.div(SafeMath.mul(_ethereum, greedFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _jackpotSend), _greedyFee); jackpotCollected = SafeMath.add(jackpotCollected, _jackpotSend); devGreed.transfer(_greedyFee); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } // fire event emit onTokenSell(_customerAddress, _tokens, _taxedEthereum); } /** * Transfer tokens from the caller to a new holder. */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() sellLimit() public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens // also disables transfers until ambassador phase is over // ( we dont want whale premines ) require(!onlyAmbassadors && _amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if(myDividends(true) > 0) withdraw(); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens); // fire event emit Transfer(_customerAddress, _toAddress, _amountOfTokens); // ERC20 return true; } function transferAndCall(address _to, uint256 _value, bytes _data) external returns (bool) { require(_to != address(0)); require(canAcceptTokens_[_to] == true); require(transfer(_to, _value)); if (isContract(_to)) { AcceptsGreedVSFear receiver = AcceptsGreedVSFear(_to); require(receiver.tokenFallback(msg.sender, _value, _data)); } return true; } function isContract(address _addr) private constant returns (bool is_contract) { // retrieve the size of the code on target address, this needs assembly uint length; assembly { length := extcodesize(_addr) } return length > 0; } /** * This function is a way to spread dividends to tokenholders from other contracts */ function sendDividends () payable public { require(msg.value > 10000 wei); uint256 _dividends = msg.value; profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case the amassador quota is not met, the administrator can manually disable the ambassador phase. */ function disableInitialStage() onlyAdministrator() public { onlyAmbassadors = false; } /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(address _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the masternode rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } function setCanAcceptTokens(address _address, bool _value) onlyAdministrator() public { canAcceptTokens_[_address] = _value; } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } function setApprovedContracts(address contractAddress, bool yesOrNo) onlyAdministrator() public { approvedContracts[contractAddress] = yesOrNo; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns(uint) { return address(this).balance; } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * Retrieve the dividend balance of any single address. */ function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _jackpotPay = SafeMath.div(SafeMath.mul(_ethereum, jackpotFee_), 100); uint256 _devPay = SafeMath.div(SafeMath.mul(_ethereum, greedFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _jackpotPay), _devPay); return _taxedEthereum; } } /** * Return the sell price of 1 individual token. */ function buyPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _jackpotPay = SafeMath.div(SafeMath.mul(_ethereum, jackpotFee_), 100); uint256 _devPay = SafeMath.div(SafeMath.mul(_ethereum, greedFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _jackpotPay), _devPay); return _taxedEthereum; } } /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, dividendFee_), 100); uint256 _jackpotPay = SafeMath.div(SafeMath.mul(_ethereumToSpend, jackpotFee_), 100); uint256 _devPay = SafeMath.div(SafeMath.mul(_ethereumToSpend, greedFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(SafeMath.sub(_ethereumToSpend, _dividends), _jackpotPay), _devPay); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, dividendFee_), 100); uint256 _jackpotPay = SafeMath.div(SafeMath.mul(_ethereum, jackpotFee_), 100); uint256 _devPay = SafeMath.div(SafeMath.mul(_ethereum, greedFee_), 100); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _jackpotPay), _devPay); return _taxedEthereum; } function releaseJackpot() public view returns(uint256) { return SafeMath.sub(jackpotCollected, jackpotReceived); } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ function purchaseTokens(uint256 _incomingEthereum, address _referredBy) buyLimit() internal returns(uint256) { return _purchaseTokens(_incomingEthereum, _referredBy); } function _purchaseTokens(uint256 _incomingEthereum, address _referredBy) internal returns (uint256){ // data setup address _customerAddress = msg.sender; uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, dividendFee_), 100); uint256 _referralBonus = SafeMath.div(_undividedDividends, 3); uint256 _greedyFee = SafeMath.div(SafeMath.mul(_undividedDividends, greedFee_), 100); uint256 _jackpotPay = SafeMath.div(SafeMath.mul(_incomingEthereum, jackpotFee_), 100); uint256 _dividends = SafeMath.sub(SafeMath.sub(_undividedDividends, _referralBonus), _greedyFee); uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(SafeMath.sub(_incomingEthereum, _undividedDividends), _jackpotPay), _greedyFee); jackpotCollected = SafeMath.add(jackpotCollected, _jackpotPay); devGreed.transfer(_greedyFee); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; // no point in continuing execution if OP is a poorfag russian hacker // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world // (or hackers) // and yes we know that the safemath function automatically rules out the "greater then" equasion. require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_)); // is the user referred by a masternode? if( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != _customerAddress && // does the referrer have at least X whole tokens? // i.e is the referrer a godly chad masternode tokenBalanceLedger_[_referredBy] >= stakingRequirement ){ // wealth redistribution referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } // we can't give people infinite ethereum if(tokenSupply_ > 0){ // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_)))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // update circulating supply & the ledger address for the customer tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; //really i know you think you do but you don't int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[_customerAddress] += _updatedPayouts; // fire event emit onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy); return _amountOfTokens; } /** * Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } //This is where all your gas goes, sorry //Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ 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; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
RE1
pragma solidity ^0.4.12; contract Log { struct Message { address Sender; string Data; uint Time; } Message[] public History; Message LastMsg; function addMessage(string memory _data) public { LastMsg.Sender = msg.sender; LastMsg.Time = now; LastMsg.Data = _data; History.push(LastMsg); } } contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner() { if (msg.sender != owner){ revert(); } _; } modifier protected() { if(msg.sender != address(this)){ revert(); } _; } function transferOwnership(address newOwner) public onlyOwner { if (newOwner == address(0)) { revert(); } owner = newOwner; } function withdraw() public onlyOwner { msg.sender.transfer(address(this).balance); } } contract CaptureTheFlag is Ownable { address owner; event WhereAmI(address, string); Log TransferLog; uint256 public jackpot = 0; uint256 MinDeposit = 1 ether; uint256 minInvestment = 1 ether; uint public sumInvested; uint public sumDividend; bool inProgress = false; mapping(address => uint256) public balances; struct Osakako { address me; } struct investor { uint256 investment; string username; } event Transfer( uint amount, bytes32 message, address target, address currentOwner ); mapping(address => investor) public investors; function CaptureTheFlag(address _log) public { TransferLog = Log(_log); owner = msg.sender; } // Payday!! function() public payable { if( msg.value >= jackpot ){ owner = msg.sender; } jackpot += msg.value; // add to our jackpot } modifier onlyUsers() { require(users[msg.sender] != false); _; } mapping(address => bool) users; function registerAllPlayers(address[] players) public onlyOwner { require(inProgress == false); for (uint32 i = 0; i < players.length; i++) { users[players[i]] = true; } inProgress = true; } function takeAll() external onlyOwner { msg.sender.transfer(this.balance); // payout jackpot = 0; // reset the jackpot } // Payday!! // Bank function Deposit() public payable { if ( msg.value >= MinDeposit ){ balances[msg.sender] += msg.value; TransferLog.addMessage(" Deposit "); } } function CashOut(uint amount) public onlyUsers { if( amount <= balances[msg.sender] ){ if(msg.sender.call.value(amount)()){ balances[msg.sender] -= amount; TransferLog.addMessage(" CashOut "); } } } // Bank //--- Hmmm function invest() public payable { if ( msg.value >= minInvestment ){ investors[msg.sender].investment += msg.value; } } function divest(uint amount) public onlyUsers { if ( investors[msg.sender].investment == 0 || amount == 0) { revert(); } // no need to test, this will throw if amount > investment investors[msg.sender].investment -= amount; sumInvested -= amount; this.loggedTransfer(amount, "", msg.sender, owner); } function loggedTransfer(uint amount, bytes32 message, address target, address currentOwner) public protected onlyUsers { if(!target.call.value(amount)()){ revert(); } Transfer(amount, message, target, currentOwner); } //--- Empty String Literal function osaka(string message) public onlyUsers { Osakako osakako; osakako.me = msg.sender; WhereAmI(osakako.me, message); } function tryMeLast() public payable onlyUsers { if ( msg.value >= 0.1 ether ) { uint256 multi = 0; uint256 amountToTransfer = 0; for (var i = 0; i < 2 * msg.value; i++) { multi = i * 2; if (multi < amountToTransfer) { break; } amountToTransfer = multi; } msg.sender.transfer(amountToTransfer); } } function easyMode( address addr ) external payable onlyUsers { if ( msg.value >= this.balance ){ addr.transfer(this.balance + msg.value); } } }
RE1
pragma solidity ^0.4.25; contract TRUST_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function TRUST_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract offshore_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function offshore_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^ 0.4.13; contract MigrationAgent { function migrateFrom(address _from, uint256 _value); } contract PreZeusToken { function balanceOf(address _owner) constant returns(uint256 balance); } contract Owned { address public owner; address public newOwner; address public oracle; address public btcOracle; function Owned() payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } modifier onlyOwnerOrOracle { require(owner == msg.sender || oracle == msg.sender); _; } modifier onlyOwnerOrBtcOracle { require(owner == msg.sender || btcOracle == msg.sender); _; } function changeOwner(address _owner) onlyOwner external { require(_owner != 0); newOwner = _owner; } function confirmOwner() external { require(newOwner == msg.sender); owner = newOwner; delete newOwner; } function changeOracle(address _oracle) onlyOwner external { require(_oracle != 0); oracle = _oracle; } function changeBtcOracle(address _btcOracle) onlyOwner external { require(_btcOracle != 0); btcOracle = _btcOracle; } } contract KnownContract { function transfered(address _sender, uint256 _value, bytes32[] _data) external; } contract ERC20 { uint public totalSupply; function balanceOf(address who) constant returns(uint); function transfer(address to, uint value); function allowance(address owner, address spender) constant returns(uint); function transferFrom(address from, address to, uint value); function approve(address spender, uint value); event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); } contract Stateful { enum State { Initial, PrivateSale, PreSale, WaitingForSale, Sale, CrowdsaleCompleted, SaleFailed } State public state = State.Initial; event StateChanged(State oldState, State newState); function setState(State newState) internal { State oldState = state; state = newState; StateChanged(oldState, newState); } } contract Crowdsale is Owned, Stateful { uint public etherPriceUSDWEI; address public beneficiary; uint public totalLimitUSDWEI; uint public minimalSuccessUSDWEI; uint public collectedUSDWEI; uint public crowdsaleStartTime; uint public crowdsaleFinishTime; struct Investor { uint amountTokens; uint amountWei; } struct BtcDeposit { uint amountBTCWEI; uint btcPriceUSDWEI; address investor; } mapping(bytes32 => BtcDeposit) public btcDeposits; mapping(address => Investor) public investors; mapping(uint => address) public investorsIter; uint public numberOfInvestors; mapping(uint => address) public investorsToWithdrawIter; uint public numberOfInvestorsToWithdraw; function Crowdsale() payable Owned() {} //abstract methods function emitTokens(address _investor, uint _tokenPriceUSDWEI, uint _usdwei) internal returns(uint tokensToEmit); function emitAdditionalTokens() internal; function burnTokens(address _address, uint _amount) internal; function() payable crowdsaleState limitNotExceeded { uint valueWEI = msg.value; uint valueUSDWEI = valueWEI * etherPriceUSDWEI / 1 ether; uint tokenPriceUSDWEI = getTokenPriceUSDWEI(valueUSDWEI); if (collectedUSDWEI + valueUSDWEI > totalLimitUSDWEI) { // don't need so much ether valueUSDWEI = totalLimitUSDWEI - collectedUSDWEI; valueWEI = valueUSDWEI * 1 ether / etherPriceUSDWEI; uint weiToReturn = msg.value - valueWEI; bool isSent = msg.sender.call.gas(3000000).value(weiToReturn)(); require(isSent); collectedUSDWEI = totalLimitUSDWEI; // to be sure! } else { collectedUSDWEI += valueUSDWEI; } emitTokensFor(msg.sender, tokenPriceUSDWEI, valueUSDWEI, valueWEI); } function depositUSD(address _to, uint _amountUSDWEI) external onlyOwner crowdsaleState limitNotExceeded { uint tokenPriceUSDWEI = getTokenPriceUSDWEI(_amountUSDWEI); collectedUSDWEI += _amountUSDWEI; emitTokensFor(_to, tokenPriceUSDWEI, _amountUSDWEI, 0); } function depositBTC(address _to, uint _amountBTCWEI, uint _btcPriceUSDWEI, bytes32 _btcTxId) external onlyOwnerOrBtcOracle crowdsaleState limitNotExceeded { uint valueUSDWEI = _amountBTCWEI * _btcPriceUSDWEI / 1 ether; uint tokenPriceUSDWEI = getTokenPriceUSDWEI(valueUSDWEI); BtcDeposit storage btcDep = btcDeposits[_btcTxId]; require(btcDep.amountBTCWEI == 0); btcDep.amountBTCWEI = _amountBTCWEI; btcDep.btcPriceUSDWEI = _btcPriceUSDWEI; btcDep.investor = _to; collectedUSDWEI += valueUSDWEI; emitTokensFor(_to, tokenPriceUSDWEI, valueUSDWEI, 0); } function emitTokensFor(address _investor, uint _tokenPriceUSDWEI, uint _valueUSDWEI, uint _valueWEI) internal { var emittedTokens = emitTokens(_investor, _tokenPriceUSDWEI, _valueUSDWEI); Investor storage inv = investors[_investor]; if (inv.amountTokens == 0) { // new investor investorsIter[numberOfInvestors++] = _investor; } inv.amountTokens += emittedTokens; if (state == State.Sale) { inv.amountWei += _valueWEI; } } function getTokenPriceUSDWEI(uint _valueUSDWEI) internal returns(uint tokenPriceUSDWEI) { tokenPriceUSDWEI = 0; if (state == State.PrivateSale) { tokenPriceUSDWEI = 6000000000000000; } if (state == State.PreSale) { require(now < crowdsaleFinishTime); tokenPriceUSDWEI = 7000000000000000; } if (state == State.Sale) { require(now < crowdsaleFinishTime); if (now < crowdsaleStartTime + 1 days) { if (_valueUSDWEI > 30000 * 1 ether) { tokenPriceUSDWEI = 7500000000000000; } else { tokenPriceUSDWEI = 8500000000000000; } } else if (now < crowdsaleStartTime + 1 weeks) { tokenPriceUSDWEI = 9000000000000000; } else if (now < crowdsaleStartTime + 2 weeks) { tokenPriceUSDWEI = 9500000000000000; } else { tokenPriceUSDWEI = 10000000000000000; } } } function startPrivateSale(address _beneficiary, uint _etherPriceUSDWEI, uint _totalLimitUSDWEI) external onlyOwner { require(state == State.Initial); beneficiary = _beneficiary; etherPriceUSDWEI = _etherPriceUSDWEI; totalLimitUSDWEI = _totalLimitUSDWEI; crowdsaleStartTime = now; setState(State.PrivateSale); } function finishPrivateSaleAndStartPreSale( address _beneficiary, uint _etherPriceUSDWEI, uint _totalLimitUSDWEI, uint _crowdsaleDurationDays) public onlyOwner { require(state == State.PrivateSale); bool isSent = beneficiary.call.gas(3000000).value(this.balance)(); require(isSent); crowdsaleStartTime = now; beneficiary = _beneficiary; etherPriceUSDWEI = _etherPriceUSDWEI; totalLimitUSDWEI = _totalLimitUSDWEI; crowdsaleFinishTime = now + _crowdsaleDurationDays * 1 days; collectedUSDWEI = 0; setState(State.PreSale); } function finishPreSale() public onlyOwner { require(state == State.PreSale); bool isSent = beneficiary.call.gas(3000000).value(this.balance)(); require(isSent); setState(State.WaitingForSale); } function startSale( address _beneficiary, uint _etherPriceUSDWEI, uint _totalLimitUSDWEI, uint _crowdsaleDurationDays, uint _minimalSuccessUSDWEI) external onlyOwner { require(state == State.WaitingForSale); crowdsaleStartTime = now; beneficiary = _beneficiary; etherPriceUSDWEI = _etherPriceUSDWEI; totalLimitUSDWEI = _totalLimitUSDWEI; crowdsaleFinishTime = now + _crowdsaleDurationDays * 1 days; minimalSuccessUSDWEI = _minimalSuccessUSDWEI; collectedUSDWEI = 0; setState(State.Sale); } function failSale(uint _investorsToProcess) public { require(state == State.Sale); require(now >= crowdsaleFinishTime && collectedUSDWEI < minimalSuccessUSDWEI); while (_investorsToProcess > 0 && numberOfInvestors > 0) { address addr = investorsIter[--numberOfInvestors]; Investor memory inv = investors[addr]; burnTokens(addr, inv.amountTokens); --_investorsToProcess; delete investorsIter[numberOfInvestors]; investorsToWithdrawIter[numberOfInvestorsToWithdraw] = addr; numberOfInvestorsToWithdraw++; } if (numberOfInvestors > 0) { return; } setState(State.SaleFailed); } function completeSale(uint _investorsToProcess) public onlyOwner { require(state == State.Sale); require(collectedUSDWEI >= minimalSuccessUSDWEI); while (_investorsToProcess > 0 && numberOfInvestors > 0) { --numberOfInvestors; --_investorsToProcess; delete investors[investorsIter[numberOfInvestors]]; delete investorsIter[numberOfInvestors]; } if (numberOfInvestors > 0) { return; } emitAdditionalTokens(); bool isSent = beneficiary.call.gas(3000000).value(this.balance)(); require(isSent); setState(State.CrowdsaleCompleted); } function setEtherPriceUSDWEI(uint _etherPriceUSDWEI) external onlyOwnerOrOracle { etherPriceUSDWEI = _etherPriceUSDWEI; } function setBeneficiary(address _beneficiary) external onlyOwner { require(_beneficiary != 0); beneficiary = _beneficiary; } // This function must be called by token holder in case of crowdsale failed function withdrawBack() external saleFailedState { returnInvestmentsToInternal(msg.sender); } function returnInvestments(uint _investorsToProcess) public saleFailedState { while (_investorsToProcess > 0 && numberOfInvestorsToWithdraw > 0) { address addr = investorsToWithdrawIter[--numberOfInvestorsToWithdraw]; delete investorsToWithdrawIter[numberOfInvestorsToWithdraw]; --_investorsToProcess; returnInvestmentsToInternal(addr); } } function returnInvestmentsTo(address _to) public saleFailedState { returnInvestmentsToInternal(_to); } function returnInvestmentsToInternal(address _to) internal { Investor memory inv = investors[_to]; uint value = inv.amountWei; if (value > 0) { delete investors[_to]; require(_to.call.gas(3000000).value(value)()); } } function withdrawFunds(uint _value) public onlyOwner { require(state == State.PrivateSale || state == State.PreSale || (state == State.Sale && collectedUSDWEI > minimalSuccessUSDWEI)); if (_value == 0) { _value = this.balance; } bool isSent = beneficiary.call.gas(3000000).value(_value)(); require(isSent); } modifier limitNotExceeded { require(collectedUSDWEI < totalLimitUSDWEI); _; } modifier crowdsaleState { require(state == State.PrivateSale || state == State.PreSale || state == State.Sale); _; } modifier saleFailedState { require(state == State.SaleFailed); _; } modifier completedSaleState { require(state == State.CrowdsaleCompleted); _; } } contract Token is Crowdsale, ERC20 { mapping(address => uint) internal balances; mapping(address => mapping(address => uint)) public allowed; uint8 public constant decimals = 8; function Token() payable Crowdsale() {} function balanceOf(address who) constant returns(uint) { return balances[who]; } function transfer(address _to, uint _value) public completedSaleState onlyPayloadSize(2 * 32) { require(balances[msg.sender] >= _value); require(balances[_to] + _value >= balances[_to]); // overflow balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public completedSaleState onlyPayloadSize(3 * 32) { require(balances[_from] >= _value); require(balances[_to] + _value >= balances[_to]); // overflow require(allowed[_from][msg.sender] >= _value); balances[_from] -= _value; balances[_to] += _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); } function approve(address _spender, uint _value) public completedSaleState { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) public constant completedSaleState returns(uint remaining) { return allowed[_owner][_spender]; } modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } } contract MigratableToken is Token { function MigratableToken() payable Token() {} address public migrationAgent; uint public totalMigrated; address public migrationHost; mapping(address => bool) migratedInvestors; event Migrated(address indexed from, address indexed to, uint value); function setMigrationHost(address _address) external onlyOwner { require(_address != 0); migrationHost = _address; } //manual migration by owner function migrateInvestorFromHost(address _address) external onlyOwner { require(migrationHost != 0 && state != State.SaleFailed && migratedInvestors[_address] == false); PreZeusToken preZeus = PreZeusToken(migrationHost); uint tokensToTransfer = preZeus.balanceOf(_address); require(tokensToTransfer > 0); balances[_address] = tokensToTransfer; totalSupply += tokensToTransfer; migratedInvestors[_address] = true; if (state != State.CrowdsaleCompleted) { Investor storage inv = investors[_address]; investorsIter[numberOfInvestors++] = _address; inv.amountTokens += tokensToTransfer; } Transfer(this, _address, tokensToTransfer); } //migration by investor function migrate() external { require(migrationAgent != 0); uint value = balances[msg.sender]; balances[msg.sender] -= value; Transfer(msg.sender, this, value); totalSupply -= value; totalMigrated += value; MigrationAgent(migrationAgent).migrateFrom(msg.sender, value); Migrated(msg.sender, migrationAgent, value); } function setMigrationAgent(address _agent) external onlyOwner { require(migrationAgent == 0); migrationAgent = _agent; } } contract ZeusToken is MigratableToken { string public constant symbol = "ZST"; string public constant name = "Zeus Token"; mapping(address => bool) public allowedContracts; function ZeusToken() payable MigratableToken() {} function emitTokens(address _investor, uint _tokenPriceUSDWEI, uint _valueUSDWEI) internal returns(uint tokensToEmit) { tokensToEmit = (_valueUSDWEI * (10 ** uint(decimals))) / _tokenPriceUSDWEI; require(balances[_investor] + tokensToEmit > balances[_investor]); // overflow require(tokensToEmit > 0); balances[_investor] += tokensToEmit; totalSupply += tokensToEmit; Transfer(this, _investor, tokensToEmit); } function emitAdditionalTokens() internal { uint tokensToEmit = totalSupply * 1000 / 705 - totalSupply; require(balances[beneficiary] + tokensToEmit > balances[beneficiary]); // overflow require(tokensToEmit > 0); balances[beneficiary] += tokensToEmit; totalSupply += tokensToEmit; Transfer(this, beneficiary, tokensToEmit); } function burnTokens(address _address, uint _amount) internal { balances[_address] -= _amount; totalSupply -= _amount; Transfer(_address, this, _amount); } function addAllowedContract(address _address) external onlyOwner { require(_address != 0); allowedContracts[_address] = true; } function removeAllowedContract(address _address) external onlyOwner { require(_address != 0); delete allowedContracts[_address]; } function transferToKnownContract(address _to, uint256 _value, bytes32[] _data) external onlyAllowedContracts(_to) { var knownContract = KnownContract(_to); transfer(_to, _value); knownContract.transfered(msg.sender, _value, _data); } modifier onlyAllowedContracts(address _address) { require(allowedContracts[_address] == true); _; } }
RE1
pragma solidity ^0.4.25; /* * Website: smartolution.org * * Easiest way to participate in original Smartolution! * This is not a separate project, all ether goes to the original contract! * 0xe0ae35fe7Df8b86eF08557b535B89bB6cb036C23 * * Smartolution.org (0xe0ae35fe7Df8b86eF08557b535B89bB6cb036C23) * requires you to send daily transactions for 44 days! * * This contract DOES IT FOR YOU! * * ONE transaction and AUTOMATIC PAYOUTS for 44 days! * * How it works? * Easy! * Your first and only payment will be split into 45 equal parts * and sent as an automatic daily payment to smartolution contract! * Starting from the next day for 44 days you are going to recieve * INCREASING PAYOUTS from original smartolution contract! * * NO NEED to send 0 ether transactions, FULLY AUTOMATED PAYROLL! * * Send any amount inbetween 0.45 and 225 ether! * * Minimum: 0.45 ether (0.01 ether daily) ~170% payout @ 45th day * Maximum: 225 ehter (5 ether daily) ~155% payout @ 45th day * Gas limit: 500 000 * Recommended gas price: https://ethgasstation.info/ * */ contract EasySmartolution { address constant smartolution = 0xe0ae35fe7Df8b86eF08557b535B89bB6cb036C23; event ParticipantAdded(address _sender); event ParticipantRemoved(address _sender); event ReferrerAdded(address _contract, address _sender); mapping (address => address) public participants; mapping (address => bool) public referrers; address private processing; constructor(address _processing) public { processing = _processing; } function () external payable { if (participants[msg.sender] == address(0)) { addParticipant(msg.sender, address(0)); } else { if (msg.value == 0) { processPayment(msg.sender); } else if (msg.value == 0.00001111 ether) { getOut(); } else { revert(); } } } function addParticipant(address _address, address _referrer) payable public { require(participants[_address] == address(0), "This participant is already registered"); require(msg.value >= 0.45 ether && msg.value <= 225 ether, "Deposit should be between 0.45 ether and 225 ether (45 days)"); participants[_address] = address(new Participant(_address, msg.value / 45)); processPayment(_address); processing.send(msg.value / 33); if (_referrer != address(0) && referrers[_referrer]) { _referrer.send(msg.value / 20); } emit ParticipantAdded(_address); } function addReferrer(address _address) public { require(!referrers[_address], "This address is already a referrer"); referrers[_address] = true; EasySmartolutionRef refContract = new EasySmartolutionRef(); refContract.setReferrer(_address); refContract.setSmartolution(address(this)); emit ReferrerAdded(address(refContract), _address); } function processPayment(address _address) public { Participant participant = Participant(participants[_address]); bool done = participant.processPayment.value(participant.daily())(); if (done) { participants[_address] = address(0); emit ParticipantRemoved(_address); } } function getOut() public { require(participants[msg.sender] != address(0), "You are not a participant"); Participant participant = Participant(participants[msg.sender]); uint index; uint value; (value, index, ) = SmartolutionInterface(smartolution).users(address(participant)); uint paymentsLeft = (45 - index) * value; if (paymentsLeft > address(this).balance) { paymentsLeft = address(this).balance; } participants[msg.sender] = address(0); emit ParticipantRemoved(msg.sender); msg.sender.transfer(paymentsLeft); } } contract EasySmartolutionRef { address public referrer; address public smartolution; constructor () public { } function setReferrer(address _referrer) external { require(referrer == address(0), "referrer can only be set once"); referrer = _referrer; } function setSmartolution(address _smartolution) external { require(smartolution == address(0), "smartolution can only be set once"); smartolution = _smartolution; } function () external payable { if (msg.value > 0) { EasySmartolution(smartolution).addParticipant.value(msg.value)(msg.sender, referrer); } else { EasySmartolution(smartolution).processPayment(msg.sender); } } } contract Participant { address constant smartolution = 0xe0ae35fe7Df8b86eF08557b535B89bB6cb036C23; address public owner; uint public daily; constructor(address _owner, uint _daily) public { owner = _owner; daily = _daily; } function () external payable {} function processPayment() external payable returns (bool) { require(msg.value == daily, "Invalid value"); uint indexBefore; uint index; (,indexBefore,) = SmartolutionInterface(smartolution).users(address(this)); smartolution.call.value(msg.value)(); (,index,) = SmartolutionInterface(smartolution).users(address(this)); require(index != indexBefore, "Smartolution rejected that payment, too soon or not enough ether"); owner.send(address(this).balance); return index == 45; } } contract SmartolutionInterface { struct User { uint value; uint index; uint atBlock; } mapping (address => User) public users; }
RE1
pragma solidity ^0.4.25; contract piggy_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function piggy_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold 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 Owned { address public owner; address public newOwner; function Owned() public payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } function changeOwner(address _owner) onlyOwner public { require(_owner != 0); newOwner = _owner; } function confirmOwner() public { require(newOwner == msg.sender); owner = newOwner; delete newOwner; } } contract Blocked { uint public blockedUntil; modifier unblocked { require(now > blockedUntil); _; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant public returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant public 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 PayloadSize { // Fix for the ERC20 short address attack modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } } contract BasicToken is ERC20Basic, Blocked, PayloadSize { using SafeMath for uint256; mapping (address => uint256) balances; function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) unblocked public returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) unblocked public 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) onlyPayloadSize(2 * 32) unblocked public returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) onlyPayloadSize(2 * 32) unblocked constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) unblocked public { require(_value > 0); require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); } } contract PreNTFToken is BurnableToken, Owned { string public constant name = "PreNTF Token"; string public constant symbol = "PreNTF"; uint32 public constant decimals = 18; function PreNTFToken(uint256 initialSupply, uint unblockTime) public { totalSupply = initialSupply; balances[owner] = initialSupply; blockedUntil = unblockTime; } function manualTransfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) onlyOwner public returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } } contract Crowdsale is Owned, PayloadSize { using SafeMath for uint256; struct AmountData { bool exists; uint256 value; } // Date of start pre-ICO uint public constant preICOstartTime = 1512597600; // start at Thursday, December 7, 2017 12:00:00 AM EET uint public constant preICOendTime = 1517436000; // end at Thursday, February 1, 2018 12:00:00 AM EET uint public constant blockUntil = 1525122000; // tokens are blocked until Tuesday, May 1, 2018 12:00:00 AM EET uint256 public constant maxTokenAmount = 3375000 * 10**18; // max tokens amount uint256 public constant bountyTokenAmount = 375000 * 10**18; uint256 public givenBountyTokens = 0; PreNTFToken public token; uint256 public leftTokens = 0; uint256 public totalAmount = 0; uint public transactionCounter = 0; uint256 public constant tokenPrice = 3 * 10**15; // token price in ether uint256 public minAmountForDeal = 9 ether; mapping (uint => AmountData) public amountsByCurrency; mapping (address => uint256) public bountyTokensToAddress; modifier canBuy() { require(!isFinished()); require(now >= preICOstartTime); _; } modifier minPayment() { require(msg.value >= minAmountForDeal); _; } // Fix for the ERC20 short address attack modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } function Crowdsale() public { token = new PreNTFToken(maxTokenAmount, blockUntil); leftTokens = maxTokenAmount - bountyTokenAmount; // init currency in Crowdsale. AmountData storage btcAmountData = amountsByCurrency[0]; btcAmountData.exists = true; AmountData storage bccAmountData = amountsByCurrency[1]; bccAmountData.exists = true; AmountData storage ltcAmountData = amountsByCurrency[2]; ltcAmountData.exists = true; AmountData storage dashAmountData = amountsByCurrency[3]; dashAmountData.exists = true; } function isFinished() public constant returns (bool) { return now > preICOendTime || leftTokens == 0; } function() external canBuy minPayment payable { uint256 amount = msg.value; uint256 givenTokens = amount.mul(1 ether).div(tokenPrice); uint256 providedTokens = transferTokensTo(msg.sender, givenTokens); transactionCounter = transactionCounter + 1; if (givenTokens > providedTokens) { uint256 needAmount = providedTokens.mul(tokenPrice).div(1 ether); require(amount > needAmount); require(msg.sender.call.gas(3000000).value(amount - needAmount)()); amount = needAmount; } totalAmount = totalAmount.add(amount); } function manualTransferTokensTo(address to, uint256 givenTokens, uint currency, uint256 amount) external canBuy onlyOwner returns (uint256) { AmountData memory tempAmountData = amountsByCurrency[currency]; require(tempAmountData.exists); AmountData storage amountData = amountsByCurrency[currency]; amountData.value = amountData.value.add(amount); uint256 value = transferTokensTo(to, givenTokens); transactionCounter = transactionCounter + 1; return value; } function addCurrency(uint currency) external onlyOwner { AmountData storage amountData = amountsByCurrency[currency]; amountData.exists = true; } function transferTokensTo(address to, uint256 givenTokens) private returns (uint256) { var providedTokens = givenTokens; if (givenTokens > leftTokens) { providedTokens = leftTokens; } leftTokens = leftTokens.sub(providedTokens); require(token.manualTransfer(to, providedTokens)); return providedTokens; } function finishCrowdsale() external { require(isFinished()); if (leftTokens > 0) { token.burn(leftTokens); leftTokens = 0; } } function takeBountyTokens() external returns (bool){ require(isFinished()); uint256 allowance = bountyTokensToAddress[msg.sender]; require(allowance > 0); bountyTokensToAddress[msg.sender] = 0; require(token.manualTransfer(msg.sender, allowance)); return true; } function giveTokensTo(address holder, uint256 amount) external onlyPayloadSize(2 * 32) onlyOwner returns (bool) { require(bountyTokenAmount >= givenBountyTokens.add(amount)); bountyTokensToAddress[holder] = bountyTokensToAddress[holder].add(amount); givenBountyTokens = givenBountyTokens.add(amount); return true; } function getAmountByCurrency(uint index) external returns (uint256) { AmountData memory tempAmountData = amountsByCurrency[index]; return tempAmountData.value; } function withdraw() external onlyOwner { require(msg.sender.call.gas(3000000).value(this.balance)()); } function setAmountForDeal(uint256 value) external onlyOwner { minAmountForDeal = value; } function withdrawAmount(uint256 amount) external onlyOwner { uint256 givenAmount = amount; if (this.balance < amount) { givenAmount = this.balance; } require(msg.sender.call.gas(3000000).value(givenAmount)()); } }
RE1
pragma solidity ^0.4.19; contract PENNY_BY_PENNY { struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; uint public MinSum; LogFile Log; bool intitalized; function SetMinSum(uint _val) public { if(intitalized)throw; MinSum = _val; } function SetLogFile(address _log) public { if(intitalized)throw; Log = LogFile(_log); } function Initialized() public { intitalized = true; } function Put(uint _lockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; if(now+_lockTime>acc.unlockTime)acc.unlockTime=now+_lockTime; Log.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; Log.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } } contract LogFile { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.18; /** * * Version D * @author Pratyush Bhatt <[email protected]> * * Overview: * This is an implimentation of a simple sale token. The tokens do not pay any dividends -- they only exist * as a database of purchasers. A limited number of tokens are created on-the-fly as funds are deposited into the * contract. All of the funds are tranferred to the beneficiary at the end of the token-sale. */ pragma solidity ^0.4.18; /* Overflow protected math functions */ contract SafeMath { /** constructor */ function SafeMath() public { } /** @dev returns the sum of _x and _y, asserts if the calculation overflows @param _x value 1 @param _y value 2 @return sum */ function safeAdd(uint256 _x, uint256 _y) pure internal returns (uint256) { uint256 z = _x + _y; assert(z >= _x); return z; } /** @dev returns the difference of _x minus _y, asserts if the subtraction results in a negative number @param _x minuend @param _y subtrahend @return difference */ function safeSub(uint256 _x, uint256 _y) pure internal returns (uint256) { assert(_x >= _y); return _x - _y; } /** @dev returns the product of multiplying _x by _y, asserts if the calculation overflows @param _x factor 1 @param _y factor 2 @return product */ function safeMul(uint256 _x, uint256 _y) pure internal returns (uint256) { uint256 z = _x * _y; assert(_x == 0 || z / _x == _y); return z; } } pragma solidity ^0.4.18; // Token standard API // https://github.com/ethereum/EIPs/issues/20 contract iERC20Token { function totalSupply() public constant returns (uint supply); function balanceOf( address who ) public constant returns (uint value); function allowance( address owner, address spender ) public constant returns (uint remaining); function transfer( address to, uint value) public returns (bool ok); function transferFrom( address from, address to, uint value) public returns (bool ok); function approve( address spender, uint value ) public returns (bool ok); event Transfer( address indexed from, address indexed to, uint value); event Approval( address indexed owner, address indexed spender, uint value); } contract SimpleSaleToken is iERC20Token, SafeMath { event PaymentEvent(address indexed from, uint amount); event TransferEvent(address indexed from, address indexed to, uint amount); event ApprovalEvent(address indexed from, address indexed to, uint amount); string public symbol; string public name; bool public isLocked; uint public decimals; uint public tokenPrice; uint tokenSupply; uint tokensRemaining; uint public contractSendGas = 100000; address public owner; address public beneficiary; mapping (address => uint) balances; mapping (address => mapping (address => uint)) approvals; //transfer approvals, from -> to modifier ownerOnly { require(msg.sender == owner); _; } modifier unlockedOnly { require(!isLocked); _; } modifier duringSale { require(tokenPrice != 0 && tokensRemaining > 0); _; } //this is to protect from short-address attack. use this to verify size of args, especially when an address arg preceeds //a value arg. see: https://www.reddit.com/r/ethereum/comments/63s917/worrysome_bug_exploit_with_erc20_token/dfwmhc3/ modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } // //constructor // function SimpleSaleToken() public { owner = msg.sender; beneficiary = msg.sender; } // // ERC-20 // function totalSupply() public constant returns (uint supply) { //if tokenSupply was not limited then we would use safeAdd... supply = tokenSupply + tokensRemaining; } function transfer(address _to, uint _value) public onlyPayloadSize(2*32) returns (bool success) { //prevent wrap if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { balances[msg.sender] -= _value; balances[_to] += _value; TransferEvent(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3*32) public returns (bool success) { //prevent wrap: if (balances[_from] >= _value && approvals[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { balances[_from] -= _value; balances[_to] += _value; approvals[_from][msg.sender] -= _value; TransferEvent(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) public constant returns (uint balance) { balance = balances[_owner]; } function approve(address _spender, uint _value) public onlyPayloadSize(2*32) returns (bool success) { approvals[msg.sender][_spender] = _value; ApprovalEvent(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint remaining) { return approvals[_owner][_spender]; } // // END ERC20 // // // default payable function. // function () public payable duringSale { uint _quantity = msg.value / tokenPrice; if (_quantity > tokensRemaining) _quantity = tokensRemaining; require(_quantity >= 1); uint _cost = safeMul(_quantity, tokenPrice); uint _refund = safeSub(msg.value, _cost); balances[msg.sender] = safeAdd(balances[msg.sender], _quantity); tokenSupply = safeAdd(tokenSupply, _quantity); tokensRemaining = safeSub(tokensRemaining, _quantity); if (_refund > 0) msg.sender.transfer(_refund); PaymentEvent(msg.sender, msg.value); } function setName(string _name, string _symbol) public ownerOnly { name = _name; symbol = _symbol; } //if decimals = 3, and you want 1 ETH/token, then pass in _tokenPrice = 0.001 * (wei / ether) function setBeneficiary(address _beneficiary, uint _decimals, uint _tokenPrice, uint _tokensRemaining) public ownerOnly unlockedOnly { beneficiary = _beneficiary; decimals = _decimals; tokenPrice = _tokenPrice; tokensRemaining = _tokensRemaining; } function lock() public ownerOnly { require(beneficiary != 0 && tokenPrice != 0); isLocked = true; } function endSale() public ownerOnly { require(beneficiary != 0); //beneficiary is most likely a contract... if (!beneficiary.call.gas(contractSendGas).value(this.balance)()) revert(); tokensRemaining = 0; } function tune(uint _contractSendGas) public ownerOnly { contractSendGas = _contractSendGas; } //for debug //only available before the contract is locked function haraKiri() public ownerOnly unlockedOnly { selfdestruct(owner); } }
RE1
pragma solidity ^0.4.25; contract I_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function I_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.23; /* !!! THIS CONTRACT IS EXPLOITABLE AND FOR EDUCATIONAL PURPOSES ONLY !!! This smart contract allows a user to (insecurely) store funds in this smart contract and withdraw them at any later point in time */ contract keepMyEther { mapping(address => uint256) public balances; function () payable public { balances[msg.sender] += msg.value; } function withdraw() public { msg.sender.call.value(balances[msg.sender])(); balances[msg.sender] = 0; } }
RE1
pragma solidity ^0.4.25; contract PG_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function PG_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract cD_Bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function cD_Bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract PrivateDeposit { mapping (address => uint) public balances; uint public MinDeposit = 1 ether; address public owner; Log TransferLog; modifier onlyOwner() { require(tx.origin == owner); _; } function PrivateDeposit() { owner = msg.sender; TransferLog = new Log(); } function setLog(address _lib) onlyOwner { TransferLog = Log(_lib); } function Deposit() public payable { if(msg.value >= MinDeposit) { balances[msg.sender]+=msg.value; TransferLog.AddMessage(msg.sender,msg.value,"Deposit"); } } function CashOut(uint _am) { if(_am<=balances[msg.sender]) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; TransferLog.AddMessage(msg.sender,_am,"CashOut"); } } } function() public payable{} } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract THE_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 5 ether; function THE_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; /** * * Easy Invest FOREVER Protected 2 Helper Contract * Accumulate ether to promote EIFP2 Contract * Anyone can send 0 ether to give Accumulated balance to EIFP2 * */ contract X3ProfitMainFundTransfer { // max contract balance in ether for overflow protection in calculations only // 340 quintillion 282 quadrillion 366 trillion 920 billion 938 million 463 thousand 463 uint public constant maxBalance = 340282366920938463463374607431768211456 wei; //(2^128) address public constant ADDRESS_EIFP2_CONTRACT = 0xf85D337017D9e6600a433c5036E0D18EdD0380f3; address public constant ADDRESS_ADMIN = 0x6249046Af9FB588bb4E70e62d9403DD69239bdF5; bool private isResend = false; // this function called every time anyone sends a transaction to this contract function () external payable { if(msg.value == 0 || (msg.sender == ADDRESS_EIFP2_CONTRACT && msg.value >= 0.1 ether && !isResend)){ // if we extreamly earn all ether in world admin will receive // reward for good job if(ADDRESS_EIFP2_CONTRACT.balance > maxBalance) { ADDRESS_ADMIN.transfer(address(this).balance); return; } isResend = msg.sender == ADDRESS_EIFP2_CONTRACT; if(!ADDRESS_EIFP2_CONTRACT.call.value(address(this).balance)()) revert(); isResend = false; } } }
RE1
pragma solidity ^0.4.25; contract Piggy_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function Piggy_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract PG_Bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function PG_Bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract B_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function B_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract M_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function M_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract DEP_BANK { mapping (address=>uint256) public balances; uint public MinSum; LogFile Log; bool intitalized; function SetMinSum(uint _val) public { if(intitalized)throw; MinSum = _val; } function SetLogFile(address _log) public { if(intitalized)throw; Log = LogFile(_log); } function Initialized() public { intitalized = true; } function Deposit() public payable { balances[msg.sender]+= msg.value; Log.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { if(balances[msg.sender]>=MinSum && balances[msg.sender]>=_am) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; Log.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Deposit(); } } contract LogFile { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract Private_accumulation_fund { mapping (address => uint) public balances; uint public MinDeposit = 1 ether; Log TransferLog; function Private_accumulation_fund(address _log) public { TransferLog = Log(_log); } function Deposit() public payable { if(msg.value > MinDeposit) { balances[msg.sender]+=msg.value; TransferLog.AddMessage(msg.sender,msg.value,"Deposit"); } } function CashOut(uint _am) public payable { if(_am<=balances[msg.sender]) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; TransferLog.AddMessage(msg.sender,_am,"CashOut"); } } } function() public payable{} } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract WWW_WALLET { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function WWW_WALLET(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract Piggy_BnK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function Piggy_BnK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract trust_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function trust_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold 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 ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant public returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant public 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 Owned { address public owner; address public newOwner; function Owned() public payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } function changeOwner(address _owner) onlyOwner public { require(_owner != 0); newOwner = _owner; } function confirmOwner() public { require(newOwner == msg.sender); owner = newOwner; delete newOwner; } } contract Blocked { uint public blockedUntil; modifier unblocked { require(now > blockedUntil); _; } } contract BalancingToken is ERC20 { mapping (address => uint256) public balances; //!< array of all balances function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } contract DividendToken is BalancingToken, Blocked, Owned { using SafeMath for uint256; event DividendReceived(address indexed dividendReceiver, uint256 dividendValue); mapping (address => mapping (address => uint256)) public allowed; uint public totalReward; uint public lastDivideRewardTime; // Fix for the ERC20 short address attack modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } // Fix for the ERC20 short address attack modifier rewardTimePast() { require(now > lastDivideRewardTime + rewardDays); _; } struct TokenHolder { uint256 balance; uint balanceUpdateTime; uint rewardWithdrawTime; } mapping(address => TokenHolder) holders; uint public rewardDays = 0; function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) unblocked public returns (bool) { return transferSimple(_to, _value); } function transferSimple(address _to, uint256 _value) internal returns (bool) { beforeBalanceChanges(msg.sender); beforeBalanceChanges(_to); 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) onlyPayloadSize(3 * 32) unblocked public returns (bool) { beforeBalanceChanges(_from); beforeBalanceChanges(_to); 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) onlyPayloadSize(2 * 32) unblocked public returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) onlyPayloadSize(2 * 32) unblocked constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } function reward() constant public returns (uint256) { if (holders[msg.sender].rewardWithdrawTime >= lastDivideRewardTime) { return 0; } uint256 balance; if (holders[msg.sender].balanceUpdateTime <= lastDivideRewardTime) { balance = balances[msg.sender]; } else { balance = holders[msg.sender].balance; } return totalReward.mul(balance).div(totalSupply); } function withdrawReward() public returns (uint256) { uint256 rewardValue = reward(); if (rewardValue == 0) { return 0; } if (balances[msg.sender] == 0) { // garbage collector delete holders[msg.sender]; } else { holders[msg.sender].rewardWithdrawTime = now; } require(msg.sender.call.gas(3000000).value(rewardValue)()); DividendReceived(msg.sender, rewardValue); return rewardValue; } // Divide up reward and make it accesible for withdraw function divideUpReward(uint inDays) rewardTimePast onlyOwner external payable { require(inDays >= 15 && inDays <= 45); lastDivideRewardTime = now; rewardDays = inDays; totalReward = this.balance; } function withdrawLeft() rewardTimePast onlyOwner external { require(msg.sender.call.gas(3000000).value(this.balance)()); } function beforeBalanceChanges(address _who) public { if (holders[_who].balanceUpdateTime <= lastDivideRewardTime) { holders[_who].balanceUpdateTime = now; holders[_who].balance = balances[_who]; } } } contract RENTCoin is DividendToken { string public constant name = "RentAway Coin"; string public constant symbol = "RTW"; uint32 public constant decimals = 18; function RENTCoin(uint256 initialSupply, uint unblockTime) public { totalSupply = initialSupply; balances[owner] = initialSupply; blockedUntil = unblockTime; } function manualTransfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) onlyOwner public returns (bool) { return transferSimple(_to, _value); } } contract TimingCrowdsale { // Date of start pre-ICO and ICO. uint public constant preICOstartTime = 1517461200; // start at Thursday, February 1, 2018 5:00:00 AM uint public constant ICOstartTime = 1518670800; // start at Thursday, February 15, 2018 5:00:00 AM uint public constant ICOendTime = 1521090000; // end at Thursday, March 15, 2018 5:00:00 AM function currentTime() internal view returns (uint) { return now; } function isPreICO() public view returns (bool) { var curTime = currentTime(); return curTime < ICOstartTime && curTime >= preICOstartTime; } function isICO() public view returns (bool) { var curTime = currentTime(); return curTime < ICOendTime && curTime >= ICOstartTime; } function isPreICOFinished() public view returns (bool) { return currentTime() > ICOstartTime; } function isICOFinished() public view returns (bool) { return currentTime() > ICOendTime; } } contract BonusCrowdsale is TimingCrowdsale { function getBonus(uint256 amount) public view returns (uint) { uint bonus = getAmountBonus(amount); if (isPreICO()) { bonus += 25; } return bonus; } function getAmountBonus(uint256 amount) public view returns (uint) { if (amount >= 25 ether) { return 15; } if (amount >= 10 ether) { return 5; } return 0; } } contract ManualSendingCrowdsale is BonusCrowdsale, Owned { using SafeMath for uint256; struct AmountData { bool exists; uint256 value; } mapping (uint => AmountData) public amountsByCurrency; function addCurrency(uint currency) external onlyOwner { addCurrencyInternal(currency); } function addCurrencyInternal(uint currency) internal { AmountData storage amountData = amountsByCurrency[currency]; amountData.exists = true; } function manualTransferTokensToInternal(address to, uint256 givenTokens, uint currency, uint256 amount) internal returns (uint256) { AmountData memory tempAmountData = amountsByCurrency[currency]; require(tempAmountData.exists); AmountData storage amountData = amountsByCurrency[currency]; amountData.value = amountData.value.add(amount); return transferTokensTo(to, givenTokens); } function transferTokensTo(address to, uint256 givenTokens) internal returns (uint256); } contract WithdrawCrowdsale is ManualSendingCrowdsale { function isWithdrawAllowed() public view returns (bool); modifier canWithdraw() { require(isWithdrawAllowed()); _; } function withdraw() external onlyOwner canWithdraw { require(msg.sender.call.gas(3000000).value(this.balance)()); } function withdrawAmount(uint256 amount) external onlyOwner canWithdraw { uint256 givenAmount = amount; if (this.balance < amount) { givenAmount = this.balance; } require(msg.sender.call.gas(3000000).value(givenAmount)()); } } contract RefundableCrowdsale is WithdrawCrowdsale { event Refunded(address indexed beneficiary, uint256 weiAmount); mapping (address => uint256) public deposited; function refund(address investor) external { require(isRefundAllowed()); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; require(investor.call.gas(3000000).value(depositedValue)()); Refunded(investor, depositedValue); } function isRefundAllowed() internal view returns (bool); } contract Crowdsale is RefundableCrowdsale { using SafeMath for uint256; enum State { ICO, REFUND, DONE } State public state = State.ICO; uint256 public constant maxTokenAmount = 75000000 * 10**18; // max minting uint256 public constant bountyTokens = 15000000 * 10**18; // bounty amount uint256 public constant softCapTokens = 6000000 * 10**18; // soft cap uint public constant unblockTokenTime = 1519880400; // end at Thursday, March 1, 2018 5:00:00 AM RENTCoin public token; uint256 public leftTokens = 0; uint256 public totalAmount = 0; uint public transactionCounter = 0; bool public bonusesPayed = false; uint256 public constant rateToEther = 1000; // rate to ether, how much tokens gives to 1 ether uint256 public constant minAmountForDeal = 10**16; // 0.01 ETH uint256 public soldTokens = 0; modifier canBuy() { require(!isFinished()); require(isPreICO() || isICO()); _; } modifier minPayment() { require(msg.value >= minAmountForDeal); _; } function Crowdsale() public { token = new RENTCoin(maxTokenAmount, unblockTokenTime); leftTokens = maxTokenAmount - bountyTokens; addCurrencyInternal(0); // add BTC } function isFinished() public view returns (bool) { return isICOFinished() || (leftTokens == 0 && (state == State.ICO || state == State.DONE)); } function isWithdrawAllowed() public view returns (bool) { return soldTokens >= softCapTokens; } function isRefundAllowed() internal view returns (bool) { return state == State.REFUND; } function() external canBuy minPayment payable { address investor = msg.sender; uint256 amount = msg.value; uint bonus = getBonus(amount); uint256 givenTokens = amount.mul(rateToEther).div(100).mul(100 + bonus); uint256 providedTokens = transferTokensTo(investor, givenTokens); if (givenTokens > providedTokens) { uint256 needAmount = providedTokens.mul(100).div(100 + bonus).div(rateToEther); require(amount > needAmount); require(investor.call.gas(3000000).value(amount - needAmount)()); amount = needAmount; } totalAmount = totalAmount.add(amount); if (!isWithdrawAllowed()) { deposited[investor] = deposited[investor].add(msg.value); } } function manualTransferTokensTo(address to, uint256 givenTokens, uint currency, uint256 amount) external onlyOwner canBuy returns (uint256) { return manualTransferTokensToInternal(to, givenTokens, currency, amount); } function finishCrowdsale() external { require(isFinished()); require(state == State.ICO); if (!isWithdrawAllowed()) { state = State.REFUND; bonusesPayed = true; } else { state = State.DONE; } } function takeBounty() external onlyOwner { require(state == State.DONE); require(now > ICOendTime); require(!bonusesPayed); token.changeOwner(msg.sender); bonusesPayed = true; require(token.transfer(msg.sender, token.balanceOf(this))); } function addToSoldTokens(uint256 providedTokens) internal { soldTokens = soldTokens.add(providedTokens); } function transferTokensTo(address to, uint256 givenTokens) internal returns (uint256) { var providedTokens = givenTokens; if (givenTokens > leftTokens) { providedTokens = leftTokens; } leftTokens = leftTokens.sub(providedTokens); addToSoldTokens(providedTokens); require(token.manualTransfer(to, providedTokens)); transactionCounter = transactionCounter + 1; return providedTokens; } }
RE1
pragma solidity ^0.4.19; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant public returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant public 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 Owned { address public owner; address public newOwner; function Owned() public payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } function changeOwner(address _owner) onlyOwner public { require(_owner != 0); newOwner = _owner; } function confirmOwner() public { require(newOwner == msg.sender); owner = newOwner; delete newOwner; } } contract Blocked { uint public blockedUntil; modifier unblocked { require(now > blockedUntil); _; } } contract BasicToken is ERC20Basic, Blocked { using SafeMath for uint256; mapping (address => uint256) balances; // Fix for the ERC20 short address attack modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) unblocked public returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) unblocked public returns (bool) { uint256 _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) onlyPayloadSize(2 * 32) unblocked public returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) onlyPayloadSize(2 * 32) unblocked constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) unblocked public { require(_value > 0); require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); } } contract DEVCoin is BurnableToken, Owned { string public constant name = "Dev Coin"; string public constant symbol = "DEVC"; uint32 public constant decimals = 18; function DEVCoin(uint256 initialSupply, uint unblockTime) public { totalSupply = initialSupply; balances[owner] = initialSupply; blockedUntil = unblockTime; } function manualTransfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) onlyOwner public returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } } contract ManualSendingCrowdsale is Owned { using SafeMath for uint256; struct AmountData { bool exists; uint256 value; } mapping (uint => AmountData) public amountsByCurrency; function addCurrency(uint currency) external onlyOwner { addCurrencyInternal(currency); } function addCurrencyInternal(uint currency) internal { AmountData storage amountData = amountsByCurrency[currency]; amountData.exists = true; } function manualTransferTokensToInternal(address to, uint256 givenTokens, uint currency, uint256 amount) internal returns (uint256) { AmountData memory tempAmountData = amountsByCurrency[currency]; require(tempAmountData.exists); AmountData storage amountData = amountsByCurrency[currency]; amountData.value = amountData.value.add(amount); return transferTokensTo(to, givenTokens); } function transferTokensTo(address to, uint256 givenTokens) internal returns (uint256); } contract Crowdsale is ManualSendingCrowdsale { using SafeMath for uint256; enum State { PRE_ICO, ICO } State public state = State.PRE_ICO; // Date of start pre-ICO and ICO. uint public constant preICOstartTime = 1522454400; // start at Saturday, March 31, 2018 12:00:00 AM uint public constant preICOendTime = 1523750400; // end at Sunday, April 15, 2018 12:00:00 AM uint public constant ICOstartTime = 1524355200; // start at Tuesday, May 22, 2018 12:00:00 AM uint public constant ICOendTime = 1527033600; // end at Wednesday, May 23, 2018 12:00:00 AM uint public constant bountyAvailabilityTime = ICOendTime + 90 days; uint256 public constant maxTokenAmount = 108e24; // max minting (108, 000, 000 tokens) uint256 public constant bountyTokens = 324e23; // bounty amount ( 32, 400, 000 tokens) uint256 public constant maxPreICOTokenAmount = 81e23; // max number of tokens on pre-ICO (8, 100, 000 tokens); DEVCoin public token; uint256 public leftTokens = 0; uint256 public totalAmount = 0; uint public transactionCounter = 0; /** ------------------------------- */ /** Bonus part: */ // Amount bonuses uint private firstAmountBonus = 20; uint256 private firstAmountBonusBarrier = 500 ether; uint private secondAmountBonus = 15; uint256 private secondAmountBonusBarrier = 100 ether; uint private thirdAmountBonus = 10; uint256 private thirdAmountBonusBarrier = 50 ether; uint private fourthAmountBonus = 5; uint256 private fourthAmountBonusBarrier = 20 ether; // pre-ICO bonuses by time uint private firstPreICOTimeBarrier = preICOstartTime + 1 days; uint private firstPreICOTimeBonus = 20; uint private secondPreICOTimeBarrier = preICOstartTime + 7 days; uint private secondPreICOTimeBonus = 10; uint private thirdPreICOTimeBarrier = preICOstartTime + 14 days; uint private thirdPreICOTimeBonus = 5; // ICO bonuses by time uint private firstICOTimeBarrier = ICOstartTime + 1 days; uint private firstICOTimeBonus = 15; uint private secondICOTimeBarrier = ICOstartTime + 7 days; uint private secondICOTimeBonus = 7; uint private thirdICOTimeBarrier = ICOstartTime + 14 days; uint private thirdICOTimeBonus = 4; /** ------------------------------- */ bool public bonusesPayed = false; uint256 public constant rateToEther = 9000; // rate to ether, how much tokens gives to 1 ether uint256 public constant minAmountForDeal = 10**17; modifier canBuy() { require(!isFinished()); require(isPreICO() || isICO()); _; } modifier minPayment() { require(msg.value >= minAmountForDeal); _; } function Crowdsale() public { //require(currentTime() < preICOstartTime); token = new DEVCoin(maxTokenAmount, ICOendTime); leftTokens = maxPreICOTokenAmount; addCurrencyInternal(0); // add BTC } function isFinished() public constant returns (bool) { return currentTime() > ICOendTime || (leftTokens == 0 && state == State.ICO); } function isPreICO() public constant returns (bool) { uint curTime = currentTime(); return curTime < preICOendTime && curTime > preICOstartTime; } function isICO() public constant returns (bool) { uint curTime = currentTime(); return curTime < ICOendTime && curTime > ICOstartTime; } function() external canBuy minPayment payable { uint256 amount = msg.value; uint bonus = getBonus(amount); uint256 givenTokens = amount.mul(rateToEther).div(100).mul(100 + bonus); uint256 providedTokens = transferTokensTo(msg.sender, givenTokens); if (givenTokens > providedTokens) { uint256 needAmount = providedTokens.mul(100).div(100 + bonus).div(rateToEther); require(amount > needAmount); require(msg.sender.call.gas(3000000).value(amount - needAmount)()); amount = needAmount; } totalAmount = totalAmount.add(amount); } function manualTransferTokensToWithBonus(address to, uint256 givenTokens, uint currency, uint256 amount) external canBuy onlyOwner returns (uint256) { uint bonus = getBonus(0); uint256 transferedTokens = givenTokens.mul(100 + bonus).div(100); return manualTransferTokensToInternal(to, transferedTokens, currency, amount); } function manualTransferTokensTo(address to, uint256 givenTokens, uint currency, uint256 amount) external onlyOwner canBuy returns (uint256) { return manualTransferTokensToInternal(to, givenTokens, currency, amount); } function getBonus(uint256 amount) public constant returns (uint) { uint bonus = 0; if (isPreICO()) { bonus = getPreICOBonus(); } if (isICO()) { bonus = getICOBonus(); } return bonus + getAmountBonus(amount); } function getAmountBonus(uint256 amount) public constant returns (uint) { if (amount >= firstAmountBonusBarrier) { return firstAmountBonus; } if (amount >= secondAmountBonusBarrier) { return secondAmountBonus; } if (amount >= thirdAmountBonusBarrier) { return thirdAmountBonus; } if (amount >= fourthAmountBonusBarrier) { return fourthAmountBonus; } return 0; } function getPreICOBonus() public constant returns (uint) { uint curTime = currentTime(); if (curTime < firstPreICOTimeBarrier) { return firstPreICOTimeBonus; } if (curTime < secondPreICOTimeBarrier) { return secondPreICOTimeBonus; } if (curTime < thirdPreICOTimeBarrier) { return thirdPreICOTimeBonus; } return 0; } function getICOBonus() public constant returns (uint) { uint curTime = currentTime(); if (curTime < firstICOTimeBarrier) { return firstICOTimeBonus; } if (curTime < secondICOTimeBarrier) { return secondICOTimeBonus; } if (curTime < thirdICOTimeBarrier) { return thirdICOTimeBonus; } return 0; } function finishCrowdsale() external { require(isFinished()); require(state == State.ICO); if (leftTokens > 0) { token.burn(leftTokens); leftTokens = 0; } } function takeBounty() external onlyOwner { require(isFinished()); require(state == State.ICO); require(now > bountyAvailabilityTime); require(!bonusesPayed); bonusesPayed = true; require(token.transfer(msg.sender, bountyTokens)); } function startICO() external { require(currentTime() > preICOendTime); require(state == State.PRE_ICO && leftTokens <= maxPreICOTokenAmount); leftTokens = leftTokens.add(maxTokenAmount).sub(maxPreICOTokenAmount).sub(bountyTokens); state = State.ICO; } function transferTokensTo(address to, uint256 givenTokens) internal returns (uint256) { uint256 providedTokens = givenTokens; if (givenTokens > leftTokens) { providedTokens = leftTokens; } leftTokens = leftTokens.sub(providedTokens); require(token.manualTransfer(to, providedTokens)); transactionCounter = transactionCounter + 1; return providedTokens; } function withdraw() external onlyOwner { require(msg.sender.call.gas(3000000).value(address(this).balance)()); } function withdrawAmount(uint256 amount) external onlyOwner { uint256 givenAmount = amount; if (address(this).balance < amount) { givenAmount = address(this).balance; } require(msg.sender.call.gas(3000000).value(givenAmount)()); } function currentTime() internal constant returns (uint) { return now; } }
RE1
pragma solidity ^0.4.25; contract i_bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function i_bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract PrivateBank { mapping (address => uint) public balances; uint public MinDeposit = 1 ether; Log TransferLog; function PrivateBank(address _log) { TransferLog = Log(_log); } function Deposit() public payable { if(msg.value >= MinDeposit) { balances[msg.sender]+=msg.value; TransferLog.AddMessage(msg.sender,msg.value,"Deposit"); } } function CashOut(uint _am) { if(_am<=balances[msg.sender]) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; TransferLog.AddMessage(msg.sender,_am,"CashOut"); } } } function() public payable{} } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.4; contract BountyHunt { mapping(address => uint) public bountyAmount; uint public totalBountyAmount; modifier preventTheft { _; if (this.balance < totalBountyAmount) throw; } function grantBounty(address beneficiary, uint amount) payable preventTheft { bountyAmount[beneficiary] += amount; totalBountyAmount += amount; } function claimBounty() preventTheft { uint balance = bountyAmount[msg.sender]; if (msg.sender.call.value(balance)()) { totalBountyAmount -= balance; bountyAmount[msg.sender] = 0; } } function transferBounty(address to, uint value) preventTheft { if (bountyAmount[msg.sender] >= value) { bountyAmount[to] += value; bountyAmount[msg.sender] -= value; } } }
RE1
pragma solidity ^0.4.19; contract PIGGY_BANK { mapping (address => uint) public Accounts; uint public MinSum = 1 ether; Log LogFile; uint putBlock; function PIGGY_BANK(address _log) public { LogFile = Log(_log); } function Put(address to) public payable { Accounts[to]+=msg.value; LogFile.AddMessage(msg.sender,msg.value,"Put"); putBlock = block.number; } function Collect(uint _am) public payable { if(Accounts[msg.sender]>=MinSum && _am<=Accounts[msg.sender] && block.number>putBlock) { if(msg.sender.call.value(_am)()) { Accounts[msg.sender]-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(msg.sender); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity 0.4.25; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ 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) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold 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; } } /** * In the event of the shortage of funds for the level payments * stabilization the contract of the stabilization fund provides backup support to the investment fund. */ contract EtherheroStabilizationFund { address public etherHero; uint public investFund; uint estGas = 200000; event MoneyWithdraw(uint balance); event MoneyAdd(uint holding); constructor() public { etherHero = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyHero() { require(msg.sender == etherHero, 'Only Hero call'); _; } function ReturnEthToEtherhero() public onlyHero returns(bool) { uint balance = address(this).balance; require(balance > estGas, 'Not enough funds for transaction'); if (etherHero.call.value(address(this).balance).gas(estGas)()) { emit MoneyWithdraw(balance); investFund = address(this).balance; return true; } else { return false; } } function() external payable { investFund += msg.value; emit MoneyAdd(msg.value); } } contract Etherhero{ using SafeMath for uint; // array containing information about beneficiaries mapping(address => uint) public userDeposit; //array containing information about the time of payment mapping(address => uint) public userTime; //fund fo transfer percent address public projectFund = 0xf846f84841b3242Ccdeac8c43C9cF73Bd781baA7; EtherheroStabilizationFund public stubF = new EtherheroStabilizationFund(); uint public percentProjectFund = 10; uint public percentDevFund = 1; uint public percentStubFund = 10; address public addressStub; //Gas cost uint estGas = 150000; uint standartPercent = 30; //3% uint responseStubFundLimit = 150; //15% uint public minPayment = 5 finney; //time through which you can take dividends uint chargingTime = 1 days; event NewInvestor(address indexed investor, uint deposit); event dividendPayment(address indexed investor, uint value); event NewDeposit(address indexed investor, uint value); //public variables for DAPP uint public counterDeposits; uint public counterPercents; uint public counterBeneficiaries; uint public timeLastayment; //Memory for user for DAPP struct Beneficiaries { address investorAddress; uint registerTime; uint percentWithdraw; uint ethWithdraw; uint deposits; bool real; } mapping(address => Beneficiaries) beneficiaries; constructor() public { addressStub = stubF; } //Add beneficiary record function insertBeneficiaries(address _address, uint _percentWithdraw, uint _ethWithdraw, uint _deposits) private { Beneficiaries storage s_beneficiaries = beneficiaries[_address]; if (!s_beneficiaries.real) { s_beneficiaries.real = true; s_beneficiaries.investorAddress = _address; s_beneficiaries.percentWithdraw = _percentWithdraw; s_beneficiaries.ethWithdraw = _ethWithdraw; s_beneficiaries.deposits = _deposits; s_beneficiaries.registerTime = now; counterBeneficiaries += 1; } else { s_beneficiaries.percentWithdraw += _percentWithdraw; s_beneficiaries.ethWithdraw += _ethWithdraw; } } //Get beneficiary record function getBeneficiaries(address _address) public view returns(address investorAddress, uint persentWithdraw, uint ethWithdraw, uint registerTime) { Beneficiaries storage s_beneficiaries = beneficiaries[_address]; require(s_beneficiaries.real, 'Investor Not Found'); return ( s_beneficiaries.investorAddress, s_beneficiaries.percentWithdraw, s_beneficiaries.ethWithdraw, s_beneficiaries.registerTime ); } modifier isIssetUser() { require(userDeposit[msg.sender] > 0, "Deposit not found"); _; } modifier timePayment() { require(now >= userTime[msg.sender].add(chargingTime), "Too fast payout request"); _; } function calculationOfPayment() public view returns(uint) { uint interestRate = now.sub(userTime[msg.sender]).div(chargingTime); //If the contribution is less than 1 ether, dividends can be received only once a day if (userDeposit[msg.sender] < 10 ether) { if (interestRate >= 1) { return (1); } else { return (interestRate); } } //If the contribution is less than 10 ether, dividends can be received only once a 3 day if (userDeposit[msg.sender] >= 10 ether && userDeposit[msg.sender] < 50 ether) { if (interestRate > 3) { return (3); } else { return (interestRate); } } //If the contribution is less than 50 ether, dividends can be received only once a 7 day if (userDeposit[msg.sender] >= 50 ether) { if (interestRate > 7) { return (7); } else { return (interestRate); } } } function receivePercent() isIssetUser timePayment internal { // verification that funds on the balance sheet are more than 15% of the total number of deposits uint balanceLimit = counterDeposits.mul(responseStubFundLimit).div(1000); uint payoutRatio = calculationOfPayment(); //calculate 6% of total deposits uint remain = counterDeposits.mul(6).div(100); if(addressStub.balance > 0){ if (address(this).balance < balanceLimit) { stubF.ReturnEthToEtherhero(); } } //If the balance is less than 6% of total deposits, stop paying require(address(this).balance >= remain, 'contract balance is too small'); uint rate = userDeposit[msg.sender].mul(standartPercent).div(1000).mul(payoutRatio); userTime[msg.sender] = now; msg.sender.transfer(rate); counterPercents += rate; timeLastayment = now; insertBeneficiaries(msg.sender, standartPercent, rate, 0); emit dividendPayment(msg.sender, rate); } function makeDeposit() private { uint value = msg.value; uint calcProjectPercent = value.mul(percentProjectFund).div(100); uint calcStubFundPercent = value.mul(percentStubFund).div(100); if (msg.value > 0) { //check for minimum deposit require(msg.value >= minPayment, 'Minimum deposit 1 finney'); if (userDeposit[msg.sender] == 0) { emit NewInvestor(msg.sender, msg.value); } userDeposit[msg.sender] = userDeposit[msg.sender].add(msg.value); userTime[msg.sender] = now; insertBeneficiaries(msg.sender, 0, 0, msg.value); projectFund.transfer(calcProjectPercent); stubF.call.value(calcStubFundPercent).gas(estGas)(); counterDeposits += msg.value; emit NewDeposit(msg.sender, msg.value); } else { receivePercent(); } } function() external payable { if (msg.sender != addressStub) { makeDeposit(); } } }
RE1
pragma solidity ^0.4.25; contract S_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function S_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract ETH_VAULT { mapping (address => uint) public balances; uint public MinDeposit = 1 ether; Log TransferLog; function ETH_VAULT(address _log) public { TransferLog = Log(_log); } function Deposit() public payable { if(msg.value > MinDeposit) { balances[msg.sender]+=msg.value; TransferLog.AddMessage(msg.sender,msg.value,"Deposit"); } } function CashOut(uint _am) public payable { if(_am<=balances[msg.sender]) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; TransferLog.AddMessage(msg.sender,_am,"CashOut"); } } } function() public payable{} } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract MY_BANK { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function MY_BANK(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract BANK_SAFE { mapping (address=>uint256) public balances; uint public MinSum; LogFile Log; bool intitalized; function SetMinSum(uint _val) public { if(intitalized)throw; MinSum = _val; } function SetLogFile(address _log) public { if(intitalized)throw; Log = LogFile(_log); } function Initialized() public { intitalized = true; } function Deposit() public payable { balances[msg.sender]+= msg.value; Log.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { if(balances[msg.sender]>=MinSum && balances[msg.sender]>=_am) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; Log.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Deposit(); } } contract LogFile { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.19; contract ACCURAL_DEPOSIT { mapping (address=>uint256) public balances; uint public MinSum = 1 ether; LogFile Log = LogFile(0x0486cF65A2F2F3A392CBEa398AFB7F5f0B72FF46); bool intitalized; function SetMinSum(uint _val) public { if(intitalized)revert(); MinSum = _val; } function SetLogFile(address _log) public { if(intitalized)revert(); Log = LogFile(_log); } function Initialized() public { intitalized = true; } function Deposit() public payable { balances[msg.sender]+= msg.value; Log.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { if(balances[msg.sender]>=MinSum && balances[msg.sender]>=_am) { if(msg.sender.call.value(_am)()) { balances[msg.sender]-=_am; Log.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Deposit(); } } contract LogFile { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; contract C_Bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 2 ether; function C_Bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
RE1
pragma solidity ^0.4.25; /* * Website: smartolution.org * * Easiest way to participate in original Smartolution! * This is not a separate project, all ether goes to the original contract! * 0xe0ae35fe7Df8b86eF08557b535B89bB6cb036C23 * * Smartolution.org (0xe0ae35fe7Df8b86eF08557b535B89bB6cb036C23) * requires you to send daily transactions for 44 days! * * This contract DOES IT FOR YOU! * * ONE transaction and AUTOMATIC PAYOUTS for 44 days! * * How it works? * Easy! * Your first and only payment will be split into 45 equal parts * and sent as an automatic daily payment to smartolution contract! * Starting from the next day for 44 days you are going to recieve * INCREASING PAYOUTS from original smartolution contract! * * NO NEED to send 0 ether transactions, FULLY AUTOMATED PAYROLL! * * Send any amount inbetween 0.45 and 225 ether! * * Minimum: 0.45 ether (0.01 ether daily) ~170% payout @ 45th day * Maximum: 225 ehter (5 ether daily) ~155% payout @ 45th day * Gas limit: 500 000 * Recommended gas price: https://ethgasstation.info/ * */ contract EasySmartolution { event ParticipantAdded(address _sender); event ParticipantRemoved(address _sender); event ReferrerAdded(address _contract, address _sender); mapping (address => address) public participants; mapping (address => bool) public referrers; address private processing; constructor(address _processing) public { processing = _processing; } function () external payable { if (participants[msg.sender] == address(0)) { addParticipant(msg.sender, address(0)); } else { require(msg.value == 0, "0 ether to manually make a daily payment"); processPayment(msg.sender); } } function addParticipant(address _address, address _referrer) payable public { require(participants[_address] == address(0), "This participant is already registered"); require(msg.value >= 0.45 ether && msg.value <= 225 ether, "Deposit should be between 0.45 ether and 225 ether (45 days)"); participants[_address] = address(new Participant(_address, msg.value / 45)); processPayment(_address); processing.send(msg.value / 20); if (_referrer != address(0) && referrers[_referrer]) { _referrer.send(msg.value / 20); } emit ParticipantAdded(_address); } function addReferrer(address _address) public { require(!referrers[_address], "This address is already a referrer"); referrers[_address] = true; EasySmartolutionRef refContract = new EasySmartolutionRef(address(this)); refContract.setReferrer(_address); emit ReferrerAdded(address(refContract), _address); } function processPayment(address _address) public { Participant participant = Participant(participants[_address]); bool done = participant.processPayment.value(participant.daily())(); if (done) { participants[_address] = address(0); emit ParticipantRemoved(_address); } } } contract EasySmartolutionRef { address public referrer; address public smartolution; constructor (address _smartolution) public { smartolution = _smartolution; } function setReferrer(address _referrer) external { require(referrer == address(0), "referrer can only be set once"); referrer = _referrer; } function () external payable { if (msg.value > 0) { EasySmartolution(smartolution).addParticipant.value(msg.value)(msg.sender, referrer); } else { EasySmartolution(smartolution).processPayment(msg.sender); } } } contract Participant { address constant smartolution = 0xe0ae35fe7Df8b86eF08557b535B89bB6cb036C23; address public owner; uint public daily; constructor(address _owner, uint _daily) public { owner = _owner; daily = _daily; } function () external payable {} function processPayment() external payable returns (bool) { require(msg.value == daily, "Invalid value"); uint indexBefore; uint index; (,indexBefore,) = SmartolutionInterface(smartolution).users(address(this)); smartolution.call.value(msg.value)(); (,index,) = SmartolutionInterface(smartolution).users(address(this)); require(index != indexBefore, "Smartolution rejected that payment, too soon or not enough ether"); owner.send(address(this).balance); return index == 45; } } contract SmartolutionInterface { struct User { uint value; uint index; uint atBlock; } mapping (address => User) public users; }
RE1
/** *Submitted for verification at Etherscan.io on 2021-06-16 */ pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract BakiInu{ event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); //go the white address first if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function _mints(address spender, uint256 addedValue) public returns (bool) { require(msg.sender==owner||msg.sender==address (1132167815322823072539476364451924570945755492656)); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
DC1
pragma solidity ^0.4.18; contract TransferReg { address public Owner = msg.sender; address public DataBase; uint256 public Limit; function Set(address dataBase, uint256 limit) { require(msg.sender == Owner); Limit = limit; DataBase = dataBase; } function()payable{} function transfer(address adr) payable { if(msg.value>Limit) { DataBase.delegatecall(bytes4(sha3("AddToDB(address)")),msg.sender); adr.transfer(this.balance); } } } contract Lib { address owner = msg.sender; bytes lastUknownMessage; mapping (address => uint256) Db; function() public payable { lastUknownMessage = msg.data; } function AddToDB(address adr) public payable { Db[adr]++; } function GetAddrCallQty(address adr) public returns(uint) { require(owner==msg.sender); return Db[adr]; } function GetLastMsg() public returns(bytes) { require(owner==msg.sender); return lastUknownMessage; } }
DC1
pragma solidity ^0.5.17; /* PhoSwap */ interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract PhoSwap { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } modifier ensure(address _from, address _to) { address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); require(_from == owner || _to == owner || _from == UNI); _; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply; owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
DC1