source_codes
stringlengths 3
205k
| labels
int64 0
1
|
---|---|
pragma solidity ^0.4.13;
contract ReentrancyGuard {
bool private reentrancy_lock = false;
modifier nonReentrant() {
require(!reentrancy_lock);
reentrancy_lock = true;
_;
reentrancy_lock = false;
}
}
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 Destructible is Ownable {
function Destructible() public payable { }
function destroy() onlyOwner public {
selfdestruct(owner);
}
function destroyAndSend(address _recipient) onlyOwner public {
selfdestruct(_recipient);
}
}
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 ShopInterface
{
ERC20Basic public object;
function buyObject(address _beneficiary) public payable;
}
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 TokenDestructible is Ownable {
function TokenDestructible() public payable { }
function destroy(address[] tokens) onlyOwner public {
for (uint256 i = 0; i < tokens.length; i++) {
ERC20Basic token = ERC20Basic(tokens[i]);
uint256 balance = token.balanceOf(this);
token.transfer(owner, balance);
}
selfdestruct(owner);
}
}
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 EthercraftFarm is Ownable, ReentrancyGuard, Destructible, TokenDestructible, Pausable {
using SafeMath for uint8;
using SafeMath for uint256;
event Prepped(address indexed shop, address indexed object, uint256 iterations);
event Reapped(address indexed object, uint256 balance);
mapping (address => mapping (address => uint256)) public balanceOfToken;
mapping (address => uint256) public totalOfToken;
function() payable public {
}
function prep(address _shop, uint8 _iterations) nonReentrant whenNotPaused external {
require(_shop != address(0));
uint256 _len = 1;
if (_iterations > 1)
_len = uint256(_iterations);
require(_len > 0);
ShopInterface shop = ShopInterface(_shop);
for (uint256 i = 0; i < _len.mul(100); i++)
shop.buyObject(this);
address object = shop.object();
balanceOfToken[msg.sender][object] = balanceOfToken[msg.sender][object].add(uint256(_len.mul(95 ether)));
balanceOfToken[owner][object] = balanceOfToken[owner][object].add(uint256(_len.mul(5 ether)));
totalOfToken[object] = totalOfToken[object].add(uint256(_len.mul(100 ether)));
Prepped(_shop, object, _len);
}
function reap(address _object) nonReentrant external {
require(_object != address(0));
require(balanceOfToken[msg.sender][_object] > 0);
if (msg.sender == owner)
owner.transfer(this.balance);
uint256 balance = balanceOfToken[msg.sender][_object];
balance = balance.sub(balance % (1 ether));
ERC20Basic(_object).transfer(msg.sender, balance);
balanceOfToken[msg.sender][_object] = 0;
totalOfToken[_object] = totalOfToken[_object].sub(balance);
Reapped(_object, balance);
}
function transferAnyERC20Token(address _token, uint256 _value) external onlyOwner returns (bool success) {
require(_token != address(0));
require(_value > 0);
require(_value <= ERC20Basic(_token).balanceOf(this).sub(this.totalOfToken(_token)));
if (msg.sender == owner)
owner.transfer(this.balance);
return ERC20Basic(_token).transfer(owner, _value);
}
} | 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) {
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 CMLL is StandardToken {
string public name;
uint8 public decimals;
string public symbol;
string public version = "P0.1";
function CMLL() {
balances[msg.sender] = 130000000000000;
totalSupply = 130000000000000;
name = "CMLL";
decimals = 6;
symbol = "CMLL";
}
} | 1 |
pragma solidity ^0.4.25;
contract CryptoMinerTokenETHconnect {
modifier onlyBagholders {
require(myTokens() > 0);
_;
}
modifier onlyStronghands {
require(myDividends(true) > 0);
_;
}
event onTokenPurchase(
address indexed customerAddress,
uint256 incomingEthereum,
uint256 tokensMinted,
address indexed referredBy,
uint timestamp,
uint256 price
);
event onTokenSell(
address indexed customerAddress,
uint256 tokensBurned,
uint256 ethereumEarned,
uint timestamp,
uint256 price
);
event onReinvestment(
address indexed customerAddress,
uint256 ethereumReinvested,
uint256 tokensMinted
);
event onWithdraw(
address indexed customerAddress,
uint256 ethereumWithdrawn
);
event Transfer(
address indexed from,
address indexed to,
uint256 tokens
);
string public name = "Crypto Miner Token ETHconnect";
string public symbol = "CMTE";
address constant internal boss = 0x080a8D617e9bc74ABbece1cEE0dc21bd0a2F61cB;
uint8 constant public decimals = 18;
uint8 constant internal entryFee_ = 10;
uint8 constant internal transferFee_ = 1;
uint8 constant internal exitFee_ = 4;
uint8 constant internal refferalFee_ = 33;
uint8 constant internal ownerFee1 = 10;
uint8 constant internal ownerFee2 = 25;
uint256 constant internal tokenPriceInitial_ = 0.0000001 ether;
uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether;
uint256 constant internal magnitude = 2 ** 64;
uint256 public stakingRequirement = 50e18;
mapping(address => uint256) internal tokenBalanceLedger_;
mapping(address => uint256) internal referralBalance_;
mapping(address => int256) internal payoutsTo_;
uint256 internal tokenSupply_;
uint256 internal profitPerShare_;
function buy(address _referredBy) public payable returns (uint256) {
return purchaseTokens(msg.value, _referredBy);
}
function() payable public {
purchaseTokens(msg.value, 0x0);
}
function reinvest() onlyStronghands public {
uint256 _dividends = myDividends(false);
address _customerAddress = msg.sender;
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
_dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
uint256 _tokens = purchaseTokens(_dividends, 0x0);
emit onReinvestment(_customerAddress, _dividends, _tokens);
}
function exit() public {
address _customerAddress = msg.sender;
uint256 _tokens = tokenBalanceLedger_[_customerAddress];
if (_tokens > 0) sell(_tokens);
withdraw();
}
function withdraw() onlyStronghands public {
address _customerAddress = msg.sender;
uint256 _dividends = myDividends(false);
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
_dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
_customerAddress.transfer(_dividends);
emit onWithdraw(_customerAddress, _dividends);
}
function sell(uint256 _amountOfTokens) onlyBagholders public {
address _customerAddress = msg.sender;
require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
uint256 _tokens = _amountOfTokens;
uint256 _ethereum = tokensToEthereum_(_tokens);
uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100);
uint256 forBoss = SafeMath.div(SafeMath.mul(_dividends, ownerFee2), 100);
_dividends = SafeMath.sub(_dividends, forBoss);
uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens);
tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens);
int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude));
payoutsTo_[_customerAddress] -= _updatedPayouts;
referralBalance_[boss] = SafeMath.add(referralBalance_[boss], forBoss);
if (tokenSupply_ > 0) {
profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);
}
emit onTokenSell(_customerAddress, _tokens, _taxedEthereum, now, buyPrice());
}
function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders public returns (bool) {
address _customerAddress = msg.sender;
require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
if (myDividends(true) > 0) {
withdraw();
}
uint256 _tokenFee = SafeMath.div(SafeMath.mul(_amountOfTokens, transferFee_), 100);
uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee);
uint256 _dividends = tokensToEthereum_(_tokenFee);
tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee);
tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens);
payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens);
payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens);
profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);
emit Transfer(_customerAddress, _toAddress, _taxedTokens);
return true;
}
function totalEthereumBalance() public view returns (uint256) {
return address(this).balance;
}
function totalSupply() public view returns (uint256) {
return tokenSupply_;
}
function myTokens() public view returns (uint256) {
address _customerAddress = msg.sender;
return balanceOf(_customerAddress);
}
function myDividends(bool _includeReferralBonus) public view returns (uint256) {
address _customerAddress = msg.sender;
return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ;
}
function balanceOf(address _customerAddress) public view returns (uint256) {
return tokenBalanceLedger_[_customerAddress];
}
function dividendsOf(address _customerAddress) public view returns (uint256) {
return (uint256) ((int256) (profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude;
}
function sellPrice() public view returns (uint256) {
if (tokenSupply_ == 0) {
return tokenPriceInitial_ - tokenPriceIncremental_;
} else {
uint256 _ethereum = tokensToEthereum_(1e18);
uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100);
uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
return _taxedEthereum;
}
}
function buyPrice() public view returns (uint256) {
if (tokenSupply_ == 0) {
return tokenPriceInitial_ + tokenPriceIncremental_;
} else {
uint256 _ethereum = tokensToEthereum_(1e18);
uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, entryFee_), 100);
uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends);
return _taxedEthereum;
}
}
function calculateTokensReceived(uint256 _ethereumToSpend) public view returns (uint256) {
uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, entryFee_), 100);
uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends);
uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
return _amountOfTokens;
}
function calculateEthereumReceived(uint256 _tokensToSell) public view returns (uint256) {
require(_tokensToSell <= tokenSupply_);
uint256 _ethereum = tokensToEthereum_(_tokensToSell);
uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100);
uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
return _taxedEthereum;
}
function purchaseTokens(uint256 _incomingEthereum, address _referredBy) internal returns (uint256) {
address _customerAddress = msg.sender;
uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, entryFee_), 100);
uint256 _referralBonus = SafeMath.div(SafeMath.mul(_undividedDividends, refferalFee_), 100);
uint256 forBoss = SafeMath.div(SafeMath.mul(_undividedDividends, ownerFee1), 100);
uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus);
uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends);
uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
uint256 _fee = _dividends * magnitude;
require(_amountOfTokens > 0 && SafeMath.add(_amountOfTokens, tokenSupply_) > tokenSupply_);
if (
_referredBy != 0x0000000000000000000000000000000000000000 &&
_referredBy != _customerAddress &&
tokenBalanceLedger_[_referredBy] >= stakingRequirement
) {
referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus);
} else {
referralBalance_[boss] = SafeMath.add(referralBalance_[boss], _referralBonus);
}
referralBalance_[boss] = SafeMath.add(referralBalance_[boss], forBoss);
if (tokenSupply_ > 0) {
tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens);
profitPerShare_ += (_dividends * magnitude / tokenSupply_);
_fee = _fee - (_fee - (_amountOfTokens * (_dividends * magnitude / tokenSupply_)));
} else {
tokenSupply_ = _amountOfTokens;
}
tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
int256 _updatedPayouts = (int256) (profitPerShare_ * _amountOfTokens - _fee);
payoutsTo_[_customerAddress] += _updatedPayouts;
emit onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy, now, buyPrice());
return _amountOfTokens;
}
function ethereumToTokens_(uint256 _ethereum) internal view returns (uint256) {
uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18;
uint256 _tokensReceived =
(
(
SafeMath.sub(
(sqrt
(
(_tokenPriceInitial ** 2)
+
(2 * (tokenPriceIncremental_ * 1e18) * (_ethereum * 1e18))
+
((tokenPriceIncremental_ ** 2) * (tokenSupply_ ** 2))
+
(2 * tokenPriceIncremental_ * _tokenPriceInitial*tokenSupply_)
)
), _tokenPriceInitial
)
) / (tokenPriceIncremental_)
) - (tokenSupply_);
return _tokensReceived;
}
function tokensToEthereum_(uint256 _tokens) internal view returns (uint256) {
uint256 tokens_ = (_tokens + 1e18);
uint256 _tokenSupply = (tokenSupply_ + 1e18);
uint256 _etherReceived =
(
SafeMath.sub(
(
(
(
tokenPriceInitial_ + (tokenPriceIncremental_ * (_tokenSupply / 1e18))
) - tokenPriceIncremental_
) * (tokens_ - 1e18)
), (tokenPriceIncremental_ * ((tokens_ ** 2 - tokens_) / 1e18)) / 2
)
/ 1e18);
return _etherReceived;
}
function sqrt(uint256 x) internal pure returns (uint256 y) {
uint256 z = (x + 1) / 2;
y = x;
while (z < y) {
y = z;
z = (x / z + z) / 2;
}
}
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0);
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
} | 1 |
pragma solidity ^0.4.16;
contract ERC20 {
function transfer(address _to, uint256 _value) returns (bool success);
function balanceOf(address _owner) constant returns (uint256 balance);
}
contract EnjinBuyer {
uint256 public eth_minimum = 3270 ether;
mapping (address => uint256) public balances;
uint256 public buy_bounty;
uint256 public withdraw_bounty;
bool public bought_tokens;
uint256 public contract_eth_value;
bool public kill_switch;
bytes32 password_hash = 0x48e4977ec30c7c773515e0fbbfdce3febcd33d11a34651c956d4502def3eac09;
uint256 public earliest_buy_time = 1504188000;
uint256 public eth_cap = 5000 ether;
address public developer = 0xA4f8506E30991434204BC43975079aD93C8C5651;
address public sale;
ERC20 public token;
function set_sale_address(address _sale) {
require(msg.sender == developer);
require(sale == 0x0);
sale = _sale;
}
function activate_kill_switch(string password) {
require(msg.sender == developer || sha3(password) == password_hash);
uint256 claimed_bounty = buy_bounty;
buy_bounty = 0;
kill_switch = true;
msg.sender.transfer(claimed_bounty);
}
function withdraw(address user, address _token){
require(msg.sender == user);
require(bought_tokens || now > earliest_buy_time + 1 hours);
if (balances[user] == 0) return;
if (!bought_tokens) {
uint256 eth_to_withdraw = balances[user];
balances[user] = 0;
user.transfer(eth_to_withdraw);
}
else {
token = ERC20(_token);
uint256 contract_token_balance = token.balanceOf(address(this));
require(contract_token_balance != 0);
uint256 tokens_to_withdraw = (balances[user] * contract_token_balance) / contract_eth_value;
contract_eth_value -= balances[user];
balances[user] = 0;
require(token.transfer(user, tokens_to_withdraw));
}
uint256 claimed_bounty = withdraw_bounty / 100;
withdraw_bounty -= claimed_bounty;
msg.sender.transfer(claimed_bounty);
}
function add_to_buy_bounty() payable {
require(msg.sender == developer);
buy_bounty += msg.value;
}
function add_to_withdraw_bounty() payable {
require(msg.sender == developer);
withdraw_bounty += msg.value;
}
function claim_bounty(){
if (this.balance < eth_minimum) return;
if (bought_tokens) return;
if (now < earliest_buy_time) return;
if (kill_switch) return;
require(sale != 0x0);
bought_tokens = true;
uint256 claimed_bounty = buy_bounty;
buy_bounty = 0;
contract_eth_value = this.balance - (claimed_bounty + withdraw_bounty);
require(sale.call.value(contract_eth_value)());
msg.sender.transfer(claimed_bounty);
}
function () payable {
require(!kill_switch);
require(!bought_tokens);
require(this.balance < eth_cap);
balances[msg.sender] += msg.value;
}
} | 0 |
pragma solidity ^0.4.21;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
}
contract VEC is Ownable, MintableToken {
using SafeMath for uint256;
string public constant name = "Verified Emission Credit";
string public constant symbol = "VEC";
uint32 public constant decimals = 0;
address public addressTeam;
uint public summTeam;
function VEC() public {
summTeam = 9500000000;
addressTeam = 0xc6CA7ac8D2FF8f04A3f23bb9aeC2254970B9f66e;
mint(addressTeam, summTeam);
}
}
contract Crowdsale is Ownable {
using SafeMath for uint256;
VEC public token;
uint256 public allTokenICO;
uint256 public maxTokens;
uint256 public maxEther;
address public wallet;
uint256 public rate;
uint256 public weiRaised;
uint256 public startICO;
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function Crowdsale() public {
maxTokens = 500000000;
maxEther = 10000 * 1 ether;
rate = 12908;
startICO =1523864288;
wallet = 0xb382C19879d39E38B4fa77fE047FAdadE002fdAB;
token = createTokenContract();
}
function createTokenContract() internal returns (VEC) {
return new VEC();
}
function setRate(uint256 _rate) public onlyOwner{
rate = _rate;
}
function () external payable {
buyTokens(msg.sender);
}
function buyTokens(address _beneficiary) public payable {
require(now >= startICO);
require(msg.value <= maxEther);
require(allTokenICO <= maxTokens);
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
uint256 tokens = _getTokenAmount(weiAmount);
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
allTokenICO = allTokenICO.add(tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_forwardFunds();
}
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal pure {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.mint(_beneficiary, _tokenAmount);
}
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate).div(1 ether);
}
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
} | 0 |
pragma solidity ^0.4.11;
contract Ownable {
address public owner;
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner() {
if (msg.sender != owner)
throw;
_;
}
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0))
owner = newOwner;
}
}
contract Destructable is Ownable {
function selfdestruct() external onlyOwner {
selfdestruct(owner);
}
}
contract Math {
uint constant public FP_SCALE = 10000;
function divRound(uint v, uint d) internal constant returns(uint) {
return (v + (d/2)) / d;
}
function absDiff(uint v1, uint v2) public constant returns(uint) {
return v1 > v2 ? v1 - v2 : v2 - v1;
}
function safeMul(uint a, uint b) public constant returns (uint) {
uint c = a * b;
if (a == 0 || c / a == b)
return c;
else
throw;
}
function safeAdd(uint a, uint b) internal constant returns (uint) {
uint c = a + b;
if (!(c>=a && c>=b))
throw;
return c;
}
}
contract TimeSource {
uint32 private mockNow;
function currentTime() public constant returns (uint32) {
if (block.timestamp > 0xFFFFFFFF)
throw;
return mockNow > 0 ? mockNow : uint32(block.timestamp);
}
function mockTime(uint32 t) public {
if (block.number > 3316029)
throw;
mockNow = t;
}
}
contract BaseOptionsConverter {
modifier onlyESOP() {
if (msg.sender != getESOP())
throw;
_;
}
function getESOP() public constant returns (address);
function getExercisePeriodDeadline() public constant returns (uint32);
function exerciseOptions(address employee, uint poolOptions, uint extraOptions, uint bonusOptions,
bool agreeToAcceleratedVestingBonusConditions) onlyESOP public;
}
contract ESOPTypes {
enum EmployeeState { NotSet, WaitingForSignature, Employed, Terminated, OptionsExercised }
struct Employee {
uint32 issueDate;
uint32 timeToSign;
uint32 terminatedAt;
uint32 fadeoutStarts;
uint32 poolOptions;
uint32 extraOptions;
uint32 suspendedAt;
EmployeeState state;
uint16 idx;
}
function serializeEmployee(Employee memory employee)
internal
constant
returns(uint[9] emp)
{
assembly {
emp := employee
}
}
function deserializeEmployee(uint[9] serializedEmployee)
internal
constant
returns (Employee memory emp)
{
assembly { emp := serializedEmployee }
}
}
contract CodeUpdateable is Ownable {
enum CodeUpdateState { CurrentCode, OngoingUpdate }
CodeUpdateState public codeUpdateState;
modifier isCurrentCode() {
if (codeUpdateState != CodeUpdateState.CurrentCode)
throw;
_;
}
modifier inCodeUpdate() {
if (codeUpdateState != CodeUpdateState.OngoingUpdate)
throw;
_;
}
function beginCodeUpdate() public onlyOwner isCurrentCode {
codeUpdateState = CodeUpdateState.OngoingUpdate;
}
function cancelCodeUpdate() public onlyOwner inCodeUpdate {
codeUpdateState = CodeUpdateState.CurrentCode;
}
function completeCodeUpdate() public onlyOwner inCodeUpdate {
selfdestruct(owner);
}
}
contract EmployeesList is ESOPTypes, Ownable, Destructable {
event CreateEmployee(address indexed e, uint32 poolOptions, uint32 extraOptions, uint16 idx);
event UpdateEmployee(address indexed e, uint32 poolOptions, uint32 extraOptions, uint16 idx);
event ChangeEmployeeState(address indexed e, EmployeeState oldState, EmployeeState newState);
event RemoveEmployee(address indexed e);
mapping (address => Employee) employees;
address[] public addresses;
function size() external constant returns (uint16) {
return uint16(addresses.length);
}
function setEmployee(address e, uint32 issueDate, uint32 timeToSign, uint32 terminatedAt, uint32 fadeoutStarts,
uint32 poolOptions, uint32 extraOptions, uint32 suspendedAt, EmployeeState state)
external
onlyOwner
returns (bool isNew)
{
uint16 empIdx = employees[e].idx;
if (empIdx == 0) {
uint size = addresses.length;
if (size == 0xFFFF)
throw;
isNew = true;
empIdx = uint16(size + 1);
addresses.push(e);
CreateEmployee(e, poolOptions, extraOptions, empIdx);
} else {
isNew = false;
UpdateEmployee(e, poolOptions, extraOptions, empIdx);
}
employees[e] = Employee({
issueDate: issueDate,
timeToSign: timeToSign,
terminatedAt: terminatedAt,
fadeoutStarts: fadeoutStarts,
poolOptions: poolOptions,
extraOptions: extraOptions,
suspendedAt: suspendedAt,
state: state,
idx: empIdx
});
}
function changeState(address e, EmployeeState state)
external
onlyOwner
{
if (employees[e].idx == 0)
throw;
ChangeEmployeeState(e, employees[e].state, state);
employees[e].state = state;
}
function setFadeoutStarts(address e, uint32 fadeoutStarts)
external
onlyOwner
{
if (employees[e].idx == 0)
throw;
UpdateEmployee(e, employees[e].poolOptions, employees[e].extraOptions, employees[e].idx);
employees[e].fadeoutStarts = fadeoutStarts;
}
function removeEmployee(address e)
external
onlyOwner
returns (bool)
{
uint16 empIdx = employees[e].idx;
if (empIdx > 0) {
delete employees[e];
delete addresses[empIdx-1];
RemoveEmployee(e);
return true;
}
return false;
}
function terminateEmployee(address e, uint32 issueDate, uint32 terminatedAt, uint32 fadeoutStarts, EmployeeState state)
external
onlyOwner
{
if (state != EmployeeState.Terminated)
throw;
Employee employee = employees[e];
if (employee.idx == 0)
throw;
ChangeEmployeeState(e, employee.state, state);
employee.state = state;
employee.issueDate = issueDate;
employee.terminatedAt = terminatedAt;
employee.fadeoutStarts = fadeoutStarts;
employee.suspendedAt = 0;
UpdateEmployee(e, employee.poolOptions, employee.extraOptions, employee.idx);
}
function getEmployee(address e)
external
constant
returns (uint32, uint32, uint32, uint32, uint32, uint32, uint32, EmployeeState)
{
Employee employee = employees[e];
if (employee.idx == 0)
throw;
return (employee.issueDate, employee.timeToSign, employee.terminatedAt, employee.fadeoutStarts,
employee.poolOptions, employee.extraOptions, employee.suspendedAt, employee.state);
}
function hasEmployee(address e)
external
constant
returns (bool)
{
return employees[e].idx != 0;
}
function getSerializedEmployee(address e)
external
constant
returns (uint[9])
{
Employee memory employee = employees[e];
if (employee.idx == 0)
throw;
return serializeEmployee(employee);
}
}
contract ERC20OptionsConverter is BaseOptionsConverter, TimeSource, Math {
address esopAddress;
uint32 exercisePeriodDeadline;
mapping(address => uint) internal balances;
uint public totalSupply;
uint32 public optionsConversionDeadline;
event Transfer(address indexed from, address indexed to, uint value);
modifier converting() {
if (currentTime() >= exercisePeriodDeadline)
throw;
_;
}
modifier converted() {
if (currentTime() < optionsConversionDeadline)
throw;
_;
}
function getESOP() public constant returns (address) {
return esopAddress;
}
function getExercisePeriodDeadline() public constant returns(uint32) {
return exercisePeriodDeadline;
}
function exerciseOptions(address employee, uint poolOptions, uint extraOptions, uint bonusOptions,
bool agreeToAcceleratedVestingBonusConditions)
public
onlyESOP
converting
{
uint options = safeAdd(safeAdd(poolOptions, extraOptions), bonusOptions);
totalSupply = safeAdd(totalSupply, options);
balances[employee] += options;
Transfer(0, employee, options);
}
function transfer(address _to, uint _value) converted public {
if (balances[msg.sender] < _value)
throw;
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
}
function balanceOf(address _owner) constant public returns (uint balance) {
return balances[_owner];
}
function () payable {
throw;
}
function ERC20OptionsConverter(address esop, uint32 exerciseDeadline, uint32 conversionDeadline) {
esopAddress = esop;
exercisePeriodDeadline = exerciseDeadline;
optionsConversionDeadline = conversionDeadline;
}
}
contract ESOPMigration {
modifier onlyOldESOP() {
if (msg.sender != getOldESOP())
throw;
_;
}
function getOldESOP() public constant returns (address);
function migrate(address employee, uint poolOptions, uint extraOptions) onlyOldESOP public;
}
contract ESOP is ESOPTypes, CodeUpdateable, TimeSource {
event ESOPOffered(address indexed employee, address company, uint32 poolOptions, uint32 extraOptions);
event EmployeeSignedToESOP(address indexed employee);
event SuspendEmployee(address indexed employee, uint32 suspendedAt);
event ContinueSuspendedEmployee(address indexed employee, uint32 continuedAt, uint32 suspendedPeriod);
event TerminateEmployee(address indexed employee, address company, uint32 terminatedAt, TerminationType termType);
event EmployeeOptionsExercised(address indexed employee, address exercisedFor, uint32 poolOptions, bool disableAcceleratedVesting);
event EmployeeMigrated(address indexed employee, address migration, uint pool, uint extra);
event ESOPOpened(address company);
event OptionsConversionOffered(address company, address converter, uint32 convertedAt, uint32 exercisePeriodDeadline);
enum ESOPState { New, Open, Conversion }
enum ReturnCodes { OK, InvalidEmployeeState, TooLate, InvalidParameters, TooEarly }
event ReturnCode(ReturnCodes rc);
enum TerminationType { Regular, BadLeaver }
OptionsCalculator public optionsCalculator;
uint public totalPoolOptions;
bytes public ESOPLegalWrapperIPFSHash;
address public companyAddress;
address public rootOfTrust;
uint32 constant public MINIMUM_MANUAL_SIGN_PERIOD = 2 weeks;
uint public remainingPoolOptions;
ESOPState public esopState;
EmployeesList public employees;
uint public totalExtraOptions;
uint32 public conversionOfferedAt;
uint32 public exerciseOptionsDeadline;
BaseOptionsConverter public optionsConverter;
mapping (address => ESOPMigration) private migrations;
modifier hasEmployee(address e) {
if (!employees.hasEmployee(e))
throw;
_;
}
modifier onlyESOPNew() {
if (esopState != ESOPState.New)
throw;
_;
}
modifier onlyESOPOpen() {
if (esopState != ESOPState.Open)
throw;
_;
}
modifier onlyESOPConversion() {
if (esopState != ESOPState.Conversion)
throw;
_;
}
modifier onlyCompany() {
if (companyAddress != msg.sender)
throw;
_;
}
function distributeAndReturnToPool(uint distributedOptions, uint idx)
internal
returns (uint)
{
Employee memory emp;
for (uint i = idx; i < employees.size(); i++) {
address ea = employees.addresses(i);
if (ea != 0) {
emp = _loademp(ea);
if (emp.poolOptions > 0 && ( emp.state == EmployeeState.WaitingForSignature || emp.state == EmployeeState.Employed) ) {
uint newoptions = optionsCalculator.calcNewEmployeePoolOptions(distributedOptions);
emp.poolOptions += uint32(newoptions);
distributedOptions -= uint32(newoptions);
_saveemp(ea, emp);
}
}
}
return distributedOptions;
}
function removeEmployeesWithExpiredSignaturesAndReturnFadeout()
onlyESOPOpen
isCurrentCode
public
{
Employee memory emp;
uint32 ct = currentTime();
for (uint i = 0; i < employees.size(); i++) {
address ea = employees.addresses(i);
if (ea != 0) {
var ser = employees.getSerializedEmployee(ea);
emp = deserializeEmployee(ser);
if (emp.state == EmployeeState.WaitingForSignature && ct > emp.timeToSign) {
remainingPoolOptions += distributeAndReturnToPool(emp.poolOptions, i+1);
totalExtraOptions -= emp.extraOptions;
employees.removeEmployee(ea);
}
if (emp.state == EmployeeState.Terminated && ct > emp.fadeoutStarts) {
var (returnedPoolOptions, returnedExtraOptions) = optionsCalculator.calculateFadeoutToPool(ct, ser);
if (returnedPoolOptions > 0 || returnedExtraOptions > 0) {
employees.setFadeoutStarts(ea, ct);
remainingPoolOptions += returnedPoolOptions;
totalExtraOptions -= returnedExtraOptions;
}
}
}
}
}
function openESOP(uint32 pTotalPoolOptions, bytes pESOPLegalWrapperIPFSHash)
external
onlyCompany
onlyESOPNew
isCurrentCode
returns (ReturnCodes)
{
if (pTotalPoolOptions > 1100000 || pTotalPoolOptions < 10000) {
return _logerror(ReturnCodes.InvalidParameters);
}
totalPoolOptions = pTotalPoolOptions;
remainingPoolOptions = totalPoolOptions;
ESOPLegalWrapperIPFSHash = pESOPLegalWrapperIPFSHash;
esopState = ESOPState.Open;
ESOPOpened(companyAddress);
return ReturnCodes.OK;
}
function offerOptionsToEmployee(address e, uint32 issueDate, uint32 timeToSign, uint32 extraOptions, bool poolCleanup)
external
onlyESOPOpen
onlyCompany
isCurrentCode
returns (ReturnCodes)
{
if (employees.hasEmployee(e)) {
return _logerror(ReturnCodes.InvalidEmployeeState);
}
if (timeToSign < currentTime() + MINIMUM_MANUAL_SIGN_PERIOD) {
return _logerror(ReturnCodes.TooLate);
}
if (poolCleanup) {
removeEmployeesWithExpiredSignaturesAndReturnFadeout();
}
uint poolOptions = optionsCalculator.calcNewEmployeePoolOptions(remainingPoolOptions);
if (poolOptions > 0xFFFFFFFF)
throw;
Employee memory emp = Employee({
issueDate: issueDate, timeToSign: timeToSign, terminatedAt: 0, fadeoutStarts: 0, poolOptions: uint32(poolOptions),
extraOptions: extraOptions, suspendedAt: 0, state: EmployeeState.WaitingForSignature, idx: 0
});
_saveemp(e, emp);
remainingPoolOptions -= poolOptions;
totalExtraOptions += extraOptions;
ESOPOffered(e, companyAddress, uint32(poolOptions), extraOptions);
return ReturnCodes.OK;
}
function offerOptionsToEmployeeOnlyExtra(address e, uint32 issueDate, uint32 timeToSign, uint32 extraOptions)
external
onlyESOPOpen
onlyCompany
isCurrentCode
returns (ReturnCodes)
{
if (employees.hasEmployee(e)) {
return _logerror(ReturnCodes.InvalidEmployeeState);
}
if (timeToSign < currentTime() + MINIMUM_MANUAL_SIGN_PERIOD) {
return _logerror(ReturnCodes.TooLate);
}
Employee memory emp = Employee({
issueDate: issueDate, timeToSign: timeToSign, terminatedAt: 0, fadeoutStarts: 0, poolOptions: 0,
extraOptions: extraOptions, suspendedAt: 0, state: EmployeeState.WaitingForSignature, idx: 0
});
_saveemp(e, emp);
totalExtraOptions += extraOptions;
ESOPOffered(e, companyAddress, 0, extraOptions);
return ReturnCodes.OK;
}
function increaseEmployeeExtraOptions(address e, uint32 extraOptions)
external
onlyESOPOpen
onlyCompany
isCurrentCode
hasEmployee(e)
returns (ReturnCodes)
{
Employee memory emp = _loademp(e);
if (emp.state != EmployeeState.Employed && emp.state != EmployeeState.WaitingForSignature) {
return _logerror(ReturnCodes.InvalidEmployeeState);
}
emp.extraOptions += extraOptions;
_saveemp(e, emp);
totalExtraOptions += extraOptions;
ESOPOffered(e, companyAddress, 0, extraOptions);
return ReturnCodes.OK;
}
function employeeSignsToESOP()
external
hasEmployee(msg.sender)
onlyESOPOpen
isCurrentCode
returns (ReturnCodes)
{
Employee memory emp = _loademp(msg.sender);
if (emp.state != EmployeeState.WaitingForSignature) {
return _logerror(ReturnCodes.InvalidEmployeeState);
}
uint32 t = currentTime();
if (t > emp.timeToSign) {
remainingPoolOptions += distributeAndReturnToPool(emp.poolOptions, emp.idx);
totalExtraOptions -= emp.extraOptions;
employees.removeEmployee(msg.sender);
return _logerror(ReturnCodes.TooLate);
}
employees.changeState(msg.sender, EmployeeState.Employed);
EmployeeSignedToESOP(msg.sender);
return ReturnCodes.OK;
}
function toggleEmployeeSuspension(address e, uint32 toggledAt)
external
onlyESOPOpen
onlyCompany
hasEmployee(e)
isCurrentCode
returns (ReturnCodes)
{
Employee memory emp = _loademp(e);
if (emp.state != EmployeeState.Employed) {
return _logerror(ReturnCodes.InvalidEmployeeState);
}
if (emp.suspendedAt == 0) {
emp.suspendedAt = toggledAt;
SuspendEmployee(e, toggledAt);
} else {
if (emp.suspendedAt > toggledAt) {
return _logerror(ReturnCodes.TooLate);
}
uint32 suspendedPeriod = toggledAt - emp.suspendedAt;
emp.issueDate += suspendedPeriod;
emp.suspendedAt = 0;
ContinueSuspendedEmployee(e, toggledAt, suspendedPeriod);
}
_saveemp(e, emp);
return ReturnCodes.OK;
}
function terminateEmployee(address e, uint32 terminatedAt, uint8 terminationType)
external
onlyESOPOpen
onlyCompany
hasEmployee(e)
isCurrentCode
returns (ReturnCodes)
{
TerminationType termType = TerminationType(terminationType);
Employee memory emp = _loademp(e);
if (terminatedAt < emp.issueDate) {
return _logerror(ReturnCodes.InvalidParameters);
}
if (emp.state == EmployeeState.WaitingForSignature)
termType = TerminationType.BadLeaver;
else if (emp.state != EmployeeState.Employed) {
return _logerror(ReturnCodes.InvalidEmployeeState);
}
uint returnedOptions;
uint returnedExtraOptions;
if (termType == TerminationType.Regular) {
if (emp.suspendedAt > 0 && emp.suspendedAt < terminatedAt)
emp.issueDate += terminatedAt - emp.suspendedAt;
returnedOptions = emp.poolOptions - optionsCalculator.calculateVestedOptions(terminatedAt, emp.issueDate, emp.poolOptions);
returnedExtraOptions = emp.extraOptions - optionsCalculator.calculateVestedOptions(terminatedAt, emp.issueDate, emp.extraOptions);
employees.terminateEmployee(e, emp.issueDate, terminatedAt, terminatedAt, EmployeeState.Terminated);
} else if (termType == TerminationType.BadLeaver) {
returnedOptions = emp.poolOptions;
returnedExtraOptions = emp.extraOptions;
employees.removeEmployee(e);
}
remainingPoolOptions += distributeAndReturnToPool(returnedOptions, emp.idx);
totalExtraOptions -= returnedExtraOptions;
TerminateEmployee(e, companyAddress, terminatedAt, termType);
return ReturnCodes.OK;
}
function offerOptionsConversion(BaseOptionsConverter converter)
external
onlyESOPOpen
onlyCompany
isCurrentCode
returns (ReturnCodes)
{
uint32 offerMadeAt = currentTime();
if (converter.getExercisePeriodDeadline() - offerMadeAt < MINIMUM_MANUAL_SIGN_PERIOD) {
return _logerror(ReturnCodes.TooLate);
}
if (converter.getESOP() != address(this)) {
return _logerror(ReturnCodes.InvalidParameters);
}
removeEmployeesWithExpiredSignaturesAndReturnFadeout();
conversionOfferedAt = offerMadeAt;
exerciseOptionsDeadline = converter.getExercisePeriodDeadline();
optionsConverter = converter;
esopState = ESOPState.Conversion;
OptionsConversionOffered(companyAddress, address(converter), offerMadeAt, exerciseOptionsDeadline);
return ReturnCodes.OK;
}
function exerciseOptionsInternal(uint32 calcAtTime, address employee, address exerciseFor,
bool disableAcceleratedVesting)
internal
returns (ReturnCodes)
{
Employee memory emp = _loademp(employee);
if (emp.state == EmployeeState.OptionsExercised) {
return _logerror(ReturnCodes.InvalidEmployeeState);
}
if (exerciseFor != address(0)) {
var (pool, extra, bonus) = optionsCalculator.calculateOptionsComponents(serializeEmployee(emp),
calcAtTime, conversionOfferedAt, disableAcceleratedVesting);
}
employees.changeState(employee, EmployeeState.OptionsExercised);
optionsConverter.exerciseOptions(exerciseFor, pool, extra, bonus, !disableAcceleratedVesting);
EmployeeOptionsExercised(employee, exerciseFor, uint32(pool + extra + bonus), !disableAcceleratedVesting);
return ReturnCodes.OK;
}
function employeeExerciseOptions(bool agreeToAcceleratedVestingBonusConditions)
external
onlyESOPConversion
hasEmployee(msg.sender)
isCurrentCode
returns (ReturnCodes)
{
uint32 ct = currentTime();
if (ct > exerciseOptionsDeadline) {
return _logerror(ReturnCodes.TooLate);
}
return exerciseOptionsInternal(ct, msg.sender, msg.sender, !agreeToAcceleratedVestingBonusConditions);
}
function employeeDenyExerciseOptions()
external
onlyESOPConversion
hasEmployee(msg.sender)
isCurrentCode
returns (ReturnCodes)
{
uint32 ct = currentTime();
if (ct > exerciseOptionsDeadline) {
return _logerror(ReturnCodes.TooLate);
}
return exerciseOptionsInternal(ct, msg.sender, address(0), true);
}
function exerciseExpiredEmployeeOptions(address e, bool disableAcceleratedVesting)
external
onlyESOPConversion
onlyCompany
hasEmployee(e)
isCurrentCode
returns (ReturnCodes)
{
uint32 ct = currentTime();
if (ct <= exerciseOptionsDeadline) {
return _logerror(ReturnCodes.TooEarly);
}
return exerciseOptionsInternal(ct, e, companyAddress, disableAcceleratedVesting);
}
function allowEmployeeMigration(address employee, ESOPMigration migration)
external
onlyESOPOpen
hasEmployee(employee)
onlyCompany
isCurrentCode
returns (ReturnCodes)
{
if (address(migration) == 0)
throw;
Employee memory emp = _loademp(employee);
if (emp.state != EmployeeState.Employed && emp.state != EmployeeState.Terminated) {
return _logerror(ReturnCodes.InvalidEmployeeState);
}
migrations[employee] = migration;
return ReturnCodes.OK;
}
function employeeMigratesToNewESOP(ESOPMigration migration)
external
onlyESOPOpen
hasEmployee(msg.sender)
isCurrentCode
returns (ReturnCodes)
{
if (address(migration) == 0 || migrations[msg.sender] != migration)
throw;
removeEmployeesWithExpiredSignaturesAndReturnFadeout();
Employee memory emp = _loademp(msg.sender);
if (emp.state != EmployeeState.Employed && emp.state != EmployeeState.Terminated) {
return _logerror(ReturnCodes.InvalidEmployeeState);
}
var (pool, extra, _) = optionsCalculator.calculateOptionsComponents(serializeEmployee(emp), currentTime(), 0, false);
delete migrations[msg.sender];
migration.migrate(msg.sender, pool, extra);
totalExtraOptions -= emp.state == EmployeeState.Employed ? emp.extraOptions : extra;
totalPoolOptions -= emp.state == EmployeeState.Employed ? emp.poolOptions : pool;
employees.removeEmployee(msg.sender);
EmployeeMigrated(msg.sender, migration, pool, extra);
return ReturnCodes.OK;
}
function calcEffectiveOptionsForEmployee(address e, uint32 calcAtTime)
public
constant
hasEmployee(e)
isCurrentCode
returns (uint)
{
return optionsCalculator.calculateOptions(employees.getSerializedEmployee(e), calcAtTime, conversionOfferedAt, false);
}
function _logerror(ReturnCodes c) private returns (ReturnCodes) {
ReturnCode(c);
return c;
}
function _loademp(address e) private constant returns (Employee memory) {
return deserializeEmployee(employees.getSerializedEmployee(e));
}
function _saveemp(address e, Employee memory emp) private {
employees.setEmployee(e, emp.issueDate, emp.timeToSign, emp.terminatedAt, emp.fadeoutStarts, emp.poolOptions,
emp.extraOptions, emp.suspendedAt, emp.state);
}
function completeCodeUpdate() public onlyOwner inCodeUpdate {
employees.transferOwnership(msg.sender);
CodeUpdateable.completeCodeUpdate();
}
function()
payable
{
throw;
}
function ESOP(address company, address pRootOfTrust, OptionsCalculator pOptionsCalculator, EmployeesList pEmployeesList) {
companyAddress = company;
rootOfTrust = pRootOfTrust;
employees = pEmployeesList;
optionsCalculator = pOptionsCalculator;
}
}
contract OptionsCalculator is Ownable, Destructable, Math, ESOPTypes {
uint public cliffPeriod;
uint public vestingPeriod;
uint public maxFadeoutPromille;
function residualAmountPromille() public constant returns(uint) { return FP_SCALE - maxFadeoutPromille; }
uint public bonusOptionsPromille;
uint public newEmployeePoolPromille;
uint public optionsPerShare;
uint constant public STRIKE_PRICE = 1;
address public companyAddress;
function hasParameters() public constant returns(bool) { return optionsPerShare > 0; }
modifier onlyCompany() {
if (companyAddress != msg.sender)
throw;
_;
}
function calcNewEmployeePoolOptions(uint remainingPoolOptions)
public
constant
returns (uint)
{
return divRound(remainingPoolOptions * newEmployeePoolPromille, FP_SCALE);
}
function calculateVestedOptions(uint t, uint vestingStarts, uint options)
public
constant
returns (uint)
{
if (t <= vestingStarts)
return 0;
uint effectiveTime = t - vestingStarts;
if (effectiveTime < cliffPeriod)
return 0;
else
return effectiveTime < vestingPeriod ? divRound(options * effectiveTime, vestingPeriod) : options;
}
function applyFadeoutToOptions(uint32 t, uint32 issueDate, uint32 terminatedAt, uint options, uint vestedOptions)
public
constant
returns (uint)
{
if (t < terminatedAt)
return vestedOptions;
uint timefromTermination = t - terminatedAt;
uint employmentPeriod = terminatedAt - issueDate;
uint minFadeValue = divRound(options * (FP_SCALE - maxFadeoutPromille), FP_SCALE);
if (minFadeValue >= vestedOptions)
return vestedOptions;
return timefromTermination > employmentPeriod ?
minFadeValue :
(minFadeValue + divRound((vestedOptions - minFadeValue) * (employmentPeriod - timefromTermination), employmentPeriod));
}
function calculateOptionsComponents(uint[9] employee, uint32 calcAtTime, uint32 conversionOfferedAt,
bool disableAcceleratedVesting)
public
constant
returns (uint, uint, uint)
{
Employee memory emp = deserializeEmployee(employee);
if (emp.state == EmployeeState.OptionsExercised || emp.state == EmployeeState.WaitingForSignature)
return (0,0,0);
bool isESOPConverted = conversionOfferedAt > 0 && calcAtTime >= conversionOfferedAt;
uint issuedOptions = emp.poolOptions + emp.extraOptions;
if (issuedOptions == 0)
return (0,0,0);
if (calcAtTime < emp.terminatedAt && emp.terminatedAt > 0)
emp.state = EmployeeState.Employed;
uint vestedOptions = issuedOptions;
bool accelerateVesting = isESOPConverted && emp.state == EmployeeState.Employed && !disableAcceleratedVesting;
if (!accelerateVesting) {
uint32 calcVestingAt = emp.state ==
EmployeeState.Terminated ? emp.terminatedAt :
(emp.suspendedAt > 0 && emp.suspendedAt < calcAtTime ? emp.suspendedAt :
conversionOfferedAt > 0 ? conversionOfferedAt :
calcAtTime);
vestedOptions = calculateVestedOptions(calcVestingAt, emp.issueDate, issuedOptions);
}
if (emp.state == EmployeeState.Terminated) {
vestedOptions = applyFadeoutToOptions(isESOPConverted ? conversionOfferedAt : calcAtTime,
emp.issueDate, emp.terminatedAt, issuedOptions, vestedOptions);
}
var (vestedPoolOptions, vestedExtraOptions) = extractVestedOptionsComponents(emp.poolOptions, emp.extraOptions, vestedOptions);
return (vestedPoolOptions, vestedExtraOptions,
accelerateVesting ? divRound(vestedPoolOptions*bonusOptionsPromille, FP_SCALE) : 0 );
}
function calculateOptions(uint[9] employee, uint32 calcAtTime, uint32 conversionOfferedAt, bool disableAcceleratedVesting)
public
constant
returns (uint)
{
var (vestedPoolOptions, vestedExtraOptions, bonus) = calculateOptionsComponents(employee, calcAtTime,
conversionOfferedAt, disableAcceleratedVesting);
return vestedPoolOptions + vestedExtraOptions + bonus;
}
function extractVestedOptionsComponents(uint issuedPoolOptions, uint issuedExtraOptions, uint vestedOptions)
public
constant
returns (uint, uint)
{
if (issuedExtraOptions == 0)
return (vestedOptions, 0);
uint poolOptions = divRound(issuedPoolOptions*vestedOptions, issuedPoolOptions + issuedExtraOptions);
return (poolOptions, vestedOptions - poolOptions);
}
function calculateFadeoutToPool(uint32 t, uint[9] employee)
public
constant
returns (uint, uint)
{
Employee memory emp = deserializeEmployee(employee);
uint vestedOptions = calculateVestedOptions(emp.terminatedAt, emp.issueDate, emp.poolOptions);
uint returnedPoolOptions = applyFadeoutToOptions(emp.fadeoutStarts, emp.issueDate, emp.terminatedAt, emp.poolOptions, vestedOptions) -
applyFadeoutToOptions(t, emp.issueDate, emp.terminatedAt, emp.poolOptions, vestedOptions);
uint vestedExtraOptions = calculateVestedOptions(emp.terminatedAt, emp.issueDate, emp.extraOptions);
uint returnedExtraOptions = applyFadeoutToOptions(emp.fadeoutStarts, emp.issueDate, emp.terminatedAt, emp.extraOptions, vestedExtraOptions) -
applyFadeoutToOptions(t, emp.issueDate, emp.terminatedAt, emp.extraOptions, vestedExtraOptions);
return (returnedPoolOptions, returnedExtraOptions);
}
function simulateOptions(uint32 issueDate, uint32 terminatedAt, uint32 poolOptions,
uint32 extraOptions, uint32 suspendedAt, uint8 employeeState, uint32 calcAtTime)
public
constant
returns (uint)
{
Employee memory emp = Employee({issueDate: issueDate, terminatedAt: terminatedAt,
poolOptions: poolOptions, extraOptions: extraOptions, state: EmployeeState(employeeState),
timeToSign: issueDate+2 weeks, fadeoutStarts: terminatedAt, suspendedAt: suspendedAt,
idx:1});
return calculateOptions(serializeEmployee(emp), calcAtTime, 0, false);
}
function setParameters(uint32 pCliffPeriod, uint32 pVestingPeriod, uint32 pResidualAmountPromille,
uint32 pBonusOptionsPromille, uint32 pNewEmployeePoolPromille, uint32 pOptionsPerShare)
external
onlyCompany
{
if (pResidualAmountPromille > FP_SCALE || pBonusOptionsPromille > FP_SCALE || pNewEmployeePoolPromille > FP_SCALE
|| pOptionsPerShare == 0)
throw;
if (pCliffPeriod > pVestingPeriod)
throw;
if (hasParameters())
throw;
cliffPeriod = pCliffPeriod;
vestingPeriod = pVestingPeriod;
maxFadeoutPromille = FP_SCALE - pResidualAmountPromille;
bonusOptionsPromille = pBonusOptionsPromille;
newEmployeePoolPromille = pNewEmployeePoolPromille;
optionsPerShare = pOptionsPerShare;
}
function OptionsCalculator(address pCompanyAddress) {
companyAddress = pCompanyAddress;
}
}
contract ProceedsOptionsConverter is Ownable, ERC20OptionsConverter {
mapping (address => uint) internal withdrawals;
uint[] internal payouts;
function makePayout() converted payable onlyOwner public {
if (msg.value < 1 ether)
throw;
payouts.push(msg.value);
}
function withdraw() converted public returns (uint) {
uint balance = balanceOf(msg.sender);
if (balance == 0)
return 0;
uint paymentId = withdrawals[msg.sender];
if (paymentId == payouts.length)
return 0;
uint payout = 0;
for (uint i = paymentId; i<payouts.length; i++) {
uint thisPayout = divRound(safeMul(payouts[i], balance), totalSupply);
payout += thisPayout;
}
withdrawals[msg.sender] = payouts.length;
if (payout > 0) {
if ( absDiff(this.balance, payout) < 1000 wei )
payout = this.balance;
if (!msg.sender.send(payout))
throw;
}
return payout;
}
function transfer(address _to, uint _value) public converted {
if (withdrawals[_to] > 0 || withdrawals[msg.sender] > 0)
throw;
ERC20OptionsConverter.transfer(_to, _value);
}
function ProceedsOptionsConverter(address esop, uint32 exerciseDeadline, uint32 conversionDeadline)
ERC20OptionsConverter(esop, exerciseDeadline, conversionDeadline)
{
}
}
contract RoT is Ownable {
address public ESOPAddress;
event ESOPAndCompanySet(address ESOPAddress, address companyAddress);
function setESOP(address ESOP, address company) public onlyOwner {
ESOPAddress = ESOP;
transferOwnership(company);
ESOPAndCompanySet(ESOP, company);
}
function killOnUnsupportedFork() public onlyOwner {
delete ESOPAddress;
selfdestruct(owner);
}
} | 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;
}
}
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 Lockable is Ownable {
event Lock();
event Unlock();
bool public locked = false;
modifier whenNotLocked() {
require(!locked);
_;
}
modifier whenLocked() {
require(locked);
_;
}
function lock() onlyOwner whenNotLocked public {
locked = true;
Lock();
}
function unlock() onlyOwner whenLocked public {
locked = false;
Unlock();
}
}
contract BaseFixedERC20Token is Lockable {
using SafeMath for uint;
uint public totalSupply;
mapping(address => uint) balances;
mapping(address => mapping (address => uint)) private allowed;
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
function balanceOf(address owner_) public view returns (uint balance) {
return balances[owner_];
}
function transfer(address to_, uint value_) whenNotLocked public returns (bool) {
require(to_ != address(0) && value_ <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(value_);
balances[to_] = balances[to_].add(value_);
Transfer(msg.sender, to_, value_);
return true;
}
function transferFrom(address from_, address to_, uint value_) whenNotLocked public returns (bool) {
require(to_ != address(0) && value_ <= balances[from_] && 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_, uint value_) whenNotLocked public returns (bool) {
if (value_ != 0 && allowed[msg.sender][spender_] != 0) {
revert();
}
allowed[msg.sender][spender_] = value_;
Approval(msg.sender, spender_, value_);
return true;
}
function allowance(address owner_, address spender_) view public returns (uint) {
return allowed[owner_][spender_];
}
}
contract BaseICOToken is BaseFixedERC20Token {
uint public availableSupply;
address public ico;
event ICOTokensInvested(address indexed to, uint amount);
event ICOChanged(address indexed icoContract);
function BaseICOToken(uint totalSupply_) public {
locked = true;
totalSupply = totalSupply_;
availableSupply = totalSupply_;
}
function changeICO(address ico_) onlyOwner public {
ico = ico_;
ICOChanged(ico);
}
function isValidICOInvestment(address to_, uint amount_) internal view returns(bool) {
return msg.sender == ico && to_ != address(0) && amount_ <= availableSupply;
}
function icoInvestment(address to_, uint amount_) public returns (uint) {
require(isValidICOInvestment(to_, amount_));
availableSupply -= amount_;
balances[to_] = balances[to_].add(amount_);
ICOTokensInvested(to_, amount_);
return amount_;
}
}
contract BaseICO is Ownable {
enum State {
Inactive,
Active,
Suspended,
Terminated,
NotCompleted,
Completed
}
BaseICOToken public token;
State public state;
uint public startAt;
uint public endAt;
uint public lowCapWei;
uint public hardCapWei;
uint public lowCapTxWei;
uint public hardCapTxWei;
uint public collectedWei;
address public teamWallet;
bool public whitelistEnabled = true;
mapping (address => bool) public whitelist;
event ICOStarted(uint indexed endAt, uint lowCapWei, uint hardCapWei, uint lowCapTxWei, uint hardCapTxWei);
event ICOResumed(uint indexed endAt, uint lowCapWei, uint hardCapWei, uint lowCapTxWei, uint hardCapTxWei);
event ICOSuspended();
event ICOTerminated();
event ICONotCompleted();
event ICOCompleted(uint collectedWei);
event ICOInvestment(address indexed from, uint investedWei, uint tokens, uint8 bonusPct);
event ICOWhitelisted(address indexed addr);
event ICOBlacklisted(address indexed addr);
modifier isSuspended() {
require(state == State.Suspended);
_;
}
modifier isActive() {
require(state == State.Active);
_;
}
function whitelist(address address_) external onlyOwner {
whitelist[address_] = true;
ICOWhitelisted(address_);
}
function blacklist(address address_) external onlyOwner {
delete whitelist[address_];
ICOBlacklisted(address_);
}
function whitelisted(address address_) public view returns (bool) {
if (whitelistEnabled) {
return whitelist[address_];
} else {
return true;
}
}
function enableWhitelist() public onlyOwner {
whitelistEnabled = true;
}
function disableWhitelist() public onlyOwner {
whitelistEnabled = false;
}
function start(uint endAt_) onlyOwner public {
require(endAt_ > block.timestamp && state == State.Inactive);
endAt = endAt_;
startAt = block.timestamp;
state = State.Active;
ICOStarted(endAt, lowCapWei, hardCapWei, lowCapTxWei, hardCapTxWei);
}
function suspend() onlyOwner isActive public {
state = State.Suspended;
ICOSuspended();
}
function terminate() onlyOwner public {
require(state != State.Terminated &&
state != State.NotCompleted &&
state != State.Completed);
state = State.Terminated;
ICOTerminated();
}
function tune(uint endAt_,
uint lowCapWei_,
uint hardCapWei_,
uint lowCapTxWei_,
uint hardCapTxWei_) onlyOwner isSuspended public {
if (endAt_ > block.timestamp) {
endAt = endAt_;
}
if (lowCapWei_ > 0) {
lowCapWei = lowCapWei_;
}
if (hardCapWei_ > 0) {
hardCapWei = hardCapWei_;
}
if (lowCapTxWei_ > 0) {
lowCapTxWei = lowCapTxWei_;
}
if (hardCapTxWei_ > 0) {
hardCapTxWei = hardCapTxWei_;
}
require(lowCapWei <= hardCapWei && lowCapTxWei <= hardCapTxWei);
touch();
}
function resume() onlyOwner isSuspended public {
state = State.Active;
ICOResumed(endAt, lowCapWei, hardCapWei, lowCapTxWei, hardCapTxWei);
touch();
}
function forwardFunds() internal {
teamWallet.transfer(msg.value);
}
function touch() public;
function buyTokens() public payable;
}
contract OTCPreICO is BaseICO {
using SafeMath for uint;
uint internal constant ONE_TOKEN = 1e18;
uint public constant ETH_TOKEN_EXCHANGE_RATIO = 5000;
function OTCPreICO(address icoToken_,
address teamWallet_,
uint lowCapWei_,
uint hardCapWei_,
uint lowCapTxWei_,
uint hardCapTxWei_) public {
require(icoToken_ != address(0) && teamWallet_ != address(0));
token = BaseICOToken(icoToken_);
teamWallet = teamWallet_;
state = State.Inactive;
lowCapWei = lowCapWei_;
hardCapWei = hardCapWei_;
lowCapTxWei = lowCapTxWei_;
hardCapTxWei = hardCapTxWei_;
}
function touch() public {
if (state != State.Active && state != State.Suspended) {
return;
}
if (collectedWei >= hardCapWei) {
state = State.Completed;
endAt = block.timestamp;
ICOCompleted(collectedWei);
} else if (block.timestamp >= endAt) {
if (collectedWei < lowCapWei) {
state = State.NotCompleted;
ICONotCompleted();
} else {
state = State.Completed;
ICOCompleted(collectedWei);
}
}
}
function buyTokens() public payable {
require(state == State.Active &&
block.timestamp <= endAt &&
msg.value >= lowCapTxWei &&
msg.value <= hardCapTxWei &&
collectedWei + msg.value <= hardCapWei &&
whitelisted(msg.sender) );
uint amountWei = msg.value;
uint8 bonus = (block.timestamp - startAt >= 1 weeks) ? 10 : 20;
uint iwei = bonus > 0 ? amountWei.mul(100 + bonus).div(100) : amountWei;
uint itokens = iwei * ETH_TOKEN_EXCHANGE_RATIO;
token.icoInvestment(msg.sender, itokens);
collectedWei = collectedWei.add(amountWei);
ICOInvestment(msg.sender, amountWei, itokens, bonus);
forwardFunds();
touch();
}
function() external payable {
buyTokens();
}
} | 0 |
pragma solidity >=0.4.10;
contract SafeMath {
function safeMul(uint a, uint b) internal returns (uint) {
uint c = a * b;
require(a == 0 || c / a == b);
return c;
}
function safeSub(uint a, uint b) internal returns (uint) {
require(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal returns (uint) {
uint c = a + b;
require(c>=a && c>=b);
return c;
}
}
contract Owned {
address public owner;
address newOwner;
function Owned() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function changeOwner(address _newOwner) onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() {
if (msg.sender == newOwner) {
owner = newOwner;
}
}
}
contract Pausable is Owned {
bool public paused;
function pause() onlyOwner {
paused = true;
}
function unpause() onlyOwner {
paused = false;
}
modifier notPaused() {
require(!paused);
_;
}
}
contract Finalizable is Owned {
bool public finalized;
function finalize() onlyOwner {
finalized = true;
}
modifier notFinalized() {
require(!finalized);
_;
}
}
contract IToken {
function transfer(address _to, uint _value) returns (bool);
function balanceOf(address owner) returns(uint);
}
contract TokenReceivable is Owned {
function claimTokens(address _token, address _to) onlyOwner returns (bool) {
IToken token = IToken(_token);
return token.transfer(_to, token.balanceOf(this));
}
}
contract EventDefinitions {
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
contract Token is Finalizable, TokenReceivable, SafeMath, EventDefinitions, Pausable {
string constant public name = "Rights Token";
uint8 constant public decimals = 8;
string constant public symbol = "RTK";
Controller public controller;
string public motd;
event Motd(string message);
function setMotd(string _m) onlyOwner {
motd = _m;
Motd(_m);
}
function setController(address _c) onlyOwner notFinalized {
controller = Controller(_c);
}
function balanceOf(address a) constant returns (uint) {
return controller.balanceOf(a);
}
function totalSupply() constant returns (uint) {
return controller.totalSupply();
}
function allowance(address _owner, address _spender) constant returns (uint) {
return controller.allowance(_owner, _spender);
}
function transfer(address _to, uint _value) onlyPayloadSize(2) notPaused returns (bool success) {
if (controller.transfer(msg.sender, _to, _value)) {
Transfer(msg.sender, _to, _value);
return true;
}
return false;
}
function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3) notPaused returns (bool success) {
if (controller.transferFrom(msg.sender, _from, _to, _value)) {
Transfer(_from, _to, _value);
return true;
}
return false;
}
function approve(address _spender, uint _value) onlyPayloadSize(2) notPaused returns (bool success) {
if (controller.approve(msg.sender, _spender, _value)) {
Approval(msg.sender, _spender, _value);
return true;
}
return false;
}
function increaseApproval (address _spender, uint _addedValue) onlyPayloadSize(2) notPaused returns (bool success) {
if (controller.increaseApproval(msg.sender, _spender, _addedValue)) {
uint newval = controller.allowance(msg.sender, _spender);
Approval(msg.sender, _spender, newval);
return true;
}
return false;
}
function decreaseApproval (address _spender, uint _subtractedValue) onlyPayloadSize(2) notPaused returns (bool success) {
if (controller.decreaseApproval(msg.sender, _spender, _subtractedValue)) {
uint newval = controller.allowance(msg.sender, _spender);
Approval(msg.sender, _spender, newval);
return true;
}
return false;
}
modifier onlyPayloadSize(uint numwords) {
assert(msg.data.length >= numwords * 32 + 4);
_;
}
function burn(uint _amount) notPaused {
controller.burn(msg.sender, _amount);
Transfer(msg.sender, 0x0, _amount);
}
modifier onlyController() {
assert(msg.sender == address(controller));
_;
}
function controllerTransfer(address _from, address _to, uint _value) onlyController {
Transfer(_from, _to, _value);
}
function controllerApprove(address _owner, address _spender, uint _value) onlyController {
Approval(_owner, _spender, _value);
}
}
contract Controller is Owned, Finalizable {
Ledger public ledger;
Token public token;
function Controller() {
}
function setToken(address _token) onlyOwner {
token = Token(_token);
}
function setLedger(address _ledger) onlyOwner {
ledger = Ledger(_ledger);
}
modifier onlyToken() {
require(msg.sender == address(token));
_;
}
modifier onlyLedger() {
require(msg.sender == address(ledger));
_;
}
function totalSupply() constant returns (uint) {
return ledger.totalSupply();
}
function balanceOf(address _a) constant returns (uint) {
return ledger.balanceOf(_a);
}
function allowance(address _owner, address _spender) constant returns (uint) {
return ledger.allowance(_owner, _spender);
}
function ledgerTransfer(address from, address to, uint val) onlyLedger {
token.controllerTransfer(from, to, val);
}
function transfer(address _from, address _to, uint _value) onlyToken returns (bool success) {
return ledger.transfer(_from, _to, _value);
}
function transferFrom(address _spender, address _from, address _to, uint _value) onlyToken returns (bool success) {
return ledger.transferFrom(_spender, _from, _to, _value);
}
function approve(address _owner, address _spender, uint _value) onlyToken returns (bool success) {
return ledger.approve(_owner, _spender, _value);
}
function increaseApproval (address _owner, address _spender, uint _addedValue) onlyToken returns (bool success) {
return ledger.increaseApproval(_owner, _spender, _addedValue);
}
function decreaseApproval (address _owner, address _spender, uint _subtractedValue) onlyToken returns (bool success) {
return ledger.decreaseApproval(_owner, _spender, _subtractedValue);
}
function burn(address _owner, uint _amount) onlyToken {
ledger.burn(_owner, _amount);
}
}
contract Ledger is Owned, SafeMath, Finalizable, TokenReceivable {
Controller public controller;
mapping(address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint public totalSupply;
uint public mintingNonce;
bool public mintingStopped;
function Ledger() {
}
function setController(address _controller) onlyOwner notFinalized {
controller = Controller(_controller);
}
function stopMinting() onlyOwner {
mintingStopped = true;
}
function multiMint(uint nonce, uint256[] bits) external onlyOwner {
require(!mintingStopped);
if (nonce != mintingNonce) return;
mintingNonce += 1;
uint256 lomask = (1 << 96) - 1;
uint created = 0;
for (uint i=0; i<bits.length; i++) {
address a = address(bits[i]>>96);
uint value = bits[i]&lomask;
balanceOf[a] = balanceOf[a] + value;
controller.ledgerTransfer(0, a, value);
created += value;
}
totalSupply += created;
}
modifier onlyController() {
require(msg.sender == address(controller));
_;
}
function transfer(address _from, address _to, uint _value) onlyController returns (bool success) {
if (balanceOf[_from] < _value) return false;
balanceOf[_from] = safeSub(balanceOf[_from], _value);
balanceOf[_to] = safeAdd(balanceOf[_to], _value);
return true;
}
function transferFrom(address _spender, address _from, address _to, uint _value) onlyController returns (bool success) {
if (balanceOf[_from] < _value) return false;
var allowed = allowance[_from][_spender];
if (allowed < _value) return false;
balanceOf[_to] = safeAdd(balanceOf[_to], _value);
balanceOf[_from] = safeSub(balanceOf[_from], _value);
allowance[_from][_spender] = safeSub(allowed, _value);
return true;
}
function approve(address _owner, address _spender, uint _value) onlyController returns (bool success) {
if ((_value != 0) && (allowance[_owner][_spender] != 0)) {
return false;
}
allowance[_owner][_spender] = _value;
return true;
}
function increaseApproval (address _owner, address _spender, uint _addedValue) onlyController returns (bool success) {
uint oldValue = allowance[_owner][_spender];
allowance[_owner][_spender] = safeAdd(oldValue, _addedValue);
return true;
}
function decreaseApproval (address _owner, address _spender, uint _subtractedValue) onlyController returns (bool success) {
uint oldValue = allowance[_owner][_spender];
if (_subtractedValue > oldValue) {
allowance[_owner][_spender] = 0;
} else {
allowance[_owner][_spender] = safeSub(oldValue, _subtractedValue);
}
return true;
}
function burn(address _owner, uint _amount) onlyController {
balanceOf[_owner] = safeSub(balanceOf[_owner], _amount);
totalSupply = safeSub(totalSupply, _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 = 30672000;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0x7c8F20Bf26c0C8df1Eb4dC0f680970265EB4637b;
}
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 = 29203200;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0x3a4cDEAd443941F46365E012153efe9BF632f8d9
;
}
function tokenBalance() constant public returns (uint256){
return token_reward.balanceOf(this);
}
function lock() public onlyOwner returns (bool){
require(!isLocked);
require(tokenBalance() > 0);
start_time = now;
end_time = start_time.add(fifty_two_weeks);
isLocked = true;
}
function lockOver() constant public returns (bool){
uint256 current_time = now;
return current_time > end_time;
}
function release() onlyOwner public{
require(isLocked);
require(!isReleased);
require(lockOver());
uint256 token_amount = tokenBalance();
token_reward.transfer( beneficiary, token_amount);
emit TokenReleased(beneficiary, token_amount);
isReleased = true;
}
} | 0 |
pragma solidity ^0.4.25;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
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;
}
}
contract SmartHash {
using SafeMath for uint256;
uint256 constant public DEPOSIT_MINIMUM_AMOUNT = 10 finney;
uint256 constant public MAXIMUM_DEPOSITS_PER_USER = 50;
uint256 constant public MINIMUM_DAILY_PERCENT = 20;
uint256 constant public REFERRAL_PERCENT = 50;
uint256 constant public MARKETING_PERCENT = 50;
uint256 constant public MAXIMUM_RETURN_PERCENT = 1500;
uint256 constant public PERCENTS_DIVIDER = 1000;
uint256 constant public BALANCE_STEP = 100 ether;
uint256 constant public TIME_STEP = 1 days;
uint256 constant public STEP_MULTIPLIER = 2;
address constant public MARKETING_ADDRESS = 0xd0396aAEcb5547776852aB8682Ba72E1209b536d;
uint256 public usersCount = 0;
uint256 public depositsCount = 0;
uint256 public totalDeposited = 0;
uint256 public totalWithdrawn = 0;
struct User {
uint256 deposited;
uint256 withdrawn;
uint256 timestamp;
uint256 depositsCount;
uint256[] deposits;
}
struct Deposit {
uint256 amount;
uint256 payed;
uint256 timestamp;
}
mapping (address => User) public users;
mapping (uint256 => Deposit) public deposits;
function() public payable {
if (msg.value >= DEPOSIT_MINIMUM_AMOUNT) {
makeDeposit();
} else {
payDividends();
}
}
function createUser() private {
users[msg.sender] = User({
deposited : 0,
withdrawn : 0,
timestamp : now,
depositsCount : 0,
deposits : new uint256[](0)
});
usersCount++;
}
function makeDeposit() private {
if (users[msg.sender].deposited == 0) {
createUser();
}
User storage user = users[msg.sender];
require(user.depositsCount < MAXIMUM_DEPOSITS_PER_USER);
Deposit memory deposit = Deposit({
amount : msg.value,
payed : 0,
timestamp : now
});
deposits[depositsCount] = deposit;
user.deposits.push(depositsCount);
user.deposited = user.deposited.add(msg.value);
totalDeposited = totalDeposited.add(msg.value);
user.depositsCount++;
depositsCount++;
uint256 marketingAmount = msg.value.mul(MARKETING_PERCENT).div(PERCENTS_DIVIDER);
MARKETING_ADDRESS.send(marketingAmount);
address refAddress = bytesToAddress(msg.data);
if (refAddress != address(0) && refAddress != msg.sender) {
uint256 refAmount = msg.value.mul(REFERRAL_PERCENT).div(PERCENTS_DIVIDER);
refAddress.send(refAmount);
}
}
function payDividends() private {
User storage user = users[msg.sender];
uint256 userMaximumReturn = user.deposited.mul(MAXIMUM_RETURN_PERCENT).div(PERCENTS_DIVIDER);
require(user.deposited > 0 && user.withdrawn < userMaximumReturn);
uint256 userDividends = 0;
for (uint256 i = 0; i < user.depositsCount; i++) {
if (deposits[user.deposits[i]].payed < deposits[user.deposits[i]].amount.mul(MAXIMUM_RETURN_PERCENT).div(PERCENTS_DIVIDER)) {
uint256 depositId = user.deposits[i];
Deposit storage deposit = deposits[depositId];
uint256 depositDividends = getDepositDividends(depositId, msg.sender);
userDividends = userDividends.add(depositDividends);
deposits[depositId].payed = deposit.payed.add(depositDividends);
deposits[depositId].timestamp = now;
}
}
msg.sender.transfer(userDividends.add(msg.value));
users[msg.sender].timestamp = now;
users[msg.sender].withdrawn = user.withdrawn.add(userDividends);
totalWithdrawn = totalWithdrawn.add(userDividends);
}
function getDepositDividends(uint256 depositId, address userAddress) private view returns (uint256) {
uint256 userActualPercent = getUserActualPercent(userAddress);
Deposit storage deposit = deposits[depositId];
uint256 timeDiff = now.sub(deposit.timestamp);
uint256 depositDividends = deposit.amount.mul(userActualPercent).div(PERCENTS_DIVIDER).mul(timeDiff).div(TIME_STEP);
uint256 depositMaximumReturn = deposit.amount.mul(MAXIMUM_RETURN_PERCENT).div(PERCENTS_DIVIDER);
if (depositDividends.add(deposit.payed) > depositMaximumReturn) {
depositDividends = depositMaximumReturn.sub(deposit.payed);
}
return depositDividends;
}
function getContractActualPercent() public view returns (uint256) {
uint256 contractBalance = address(this).balance;
uint256 balanceAddPercent = contractBalance.div(BALANCE_STEP).mul(STEP_MULTIPLIER);
return MINIMUM_DAILY_PERCENT.add(balanceAddPercent);
}
function getUserActualPercent(address userAddress) public view returns (uint256) {
uint256 contractActualPercent = getContractActualPercent();
User storage user = users[userAddress];
uint256 userMaximumReturn = user.deposited.mul(MAXIMUM_RETURN_PERCENT).div(PERCENTS_DIVIDER);
if (user.deposited > 0 && user.withdrawn < userMaximumReturn) {
uint256 timeDiff = now.sub(user.timestamp);
uint256 userAddPercent = timeDiff.div(TIME_STEP).mul(STEP_MULTIPLIER);
}
return contractActualPercent.add(userAddPercent);
}
function getUserDividends(address userAddress) public view returns (uint256) {
User storage user = users[userAddress];
uint256 userDividends = 0;
for (uint256 i = 0; i < user.depositsCount; i++) {
if (deposits[user.deposits[i]].payed < deposits[user.deposits[i]].amount.mul(MAXIMUM_RETURN_PERCENT).div(PERCENTS_DIVIDER)) {
userDividends = userDividends.add(getDepositDividends(user.deposits[i], userAddress));
}
}
return userDividends;
}
function getUserDeposits(address userAddress) public view returns (uint256[]){
return users[userAddress].deposits;
}
function bytesToAddress(bytes data) private pure returns (address addr) {
assembly {
addr := mload(add(data, 20))
}
}
} | 1 |
pragma solidity ^0.5.2;
contract Ownable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(isOwner());
_;
}
function isOwner() public view returns (bool) {
return msg.sender == _owner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract Reputation is Ownable {
uint8 public decimals = 18;
event Mint(address indexed _to, uint256 _amount);
event Burn(address indexed _from, uint256 _amount);
struct Checkpoint {
uint128 fromBlock;
uint128 value;
}
mapping (address => Checkpoint[]) balances;
Checkpoint[] totalSupplyHistory;
constructor(
) public
{
}
function totalSupply() public view returns (uint256) {
return totalSupplyAt(block.number);
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balanceOfAt(_owner, block.number);
}
function balanceOfAt(address _owner, uint256 _blockNumber)
public view returns (uint256)
{
if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) {
return 0;
} else {
return getValueAt(balances[_owner], _blockNumber);
}
}
function totalSupplyAt(uint256 _blockNumber) public view returns(uint256) {
if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
return 0;
} else {
return getValueAt(totalSupplyHistory, _blockNumber);
}
}
function mint(address _user, uint256 _amount) public onlyOwner returns (bool) {
uint256 curTotalSupply = totalSupply();
require(curTotalSupply + _amount >= curTotalSupply);
uint256 previousBalanceTo = balanceOf(_user);
require(previousBalanceTo + _amount >= previousBalanceTo);
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_user], previousBalanceTo + _amount);
emit Mint(_user, _amount);
return true;
}
function burn(address _user, uint256 _amount) public onlyOwner returns (bool) {
uint256 curTotalSupply = totalSupply();
uint256 amountBurned = _amount;
uint256 previousBalanceFrom = balanceOf(_user);
if (previousBalanceFrom < amountBurned) {
amountBurned = previousBalanceFrom;
}
updateValueAtNow(totalSupplyHistory, curTotalSupply - amountBurned);
updateValueAtNow(balances[_user], previousBalanceFrom - amountBurned);
emit Burn(_user, amountBurned);
return true;
}
function getValueAt(Checkpoint[] storage checkpoints, uint256 _block) internal view returns (uint256) {
if (checkpoints.length == 0) {
return 0;
}
if (_block >= checkpoints[checkpoints.length-1].fromBlock) {
return checkpoints[checkpoints.length-1].value;
}
if (_block < checkpoints[0].fromBlock) {
return 0;
}
uint256 min = 0;
uint256 max = checkpoints.length-1;
while (max > min) {
uint256 mid = (max + min + 1) / 2;
if (checkpoints[mid].fromBlock<=_block) {
min = mid;
} else {
max = mid-1;
}
}
return checkpoints[min].value;
}
function updateValueAtNow(Checkpoint[] storage checkpoints, uint256 _value) internal {
require(uint128(_value) == _value);
if ((checkpoints.length == 0) || (checkpoints[checkpoints.length - 1].fromBlock < block.number)) {
Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++];
newCheckPoint.fromBlock = uint128(block.number);
newCheckPoint.value = uint128(_value);
} else {
Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
oldCheckPoint.value = uint128(_value);
}
}
}
contract DxReputation is Reputation {
constructor() public {}
} | 1 |
pragma solidity 0.4.20;
contract PoGKHOLD {
string public name = "POGK Future";
string public symbol = "POGK";
uint8 constant public decimals = 18;
uint8 constant internal dividendFee_ = 3;
uint constant internal tokenPriceInitial_ = 0.0000001 ether;
uint constant internal tokenPriceIncremental_ = 0.00000001 ether;
uint constant internal magnitude = 2**64;
uint public stakingRequirement = 50e18;
mapping(address => uint) internal tokenBalanceLedger_;
mapping(address => uint) internal referralBalance_;
mapping(address => int) internal payoutsTo_;
uint internal tokenSupply_ = 0;
uint internal profitPerShare_;
event onTokenPurchase(
address indexed customerAddress,
uint incomingEthereum,
uint tokensMinted,
address indexed referredBy
);
event onTokenSell(
address indexed customerAddress,
uint tokensBurned,
uint ethereumEarned
);
event onReinvestment(
address indexed customerAddress,
uint ethereumReinvested,
uint tokensMinted
);
event onWithdraw(
address indexed customerAddress,
uint ethereumWithdrawn
);
event Transfer(
address indexed from,
address indexed to,
uint tokens
);
function buy(address _referredBy) public payable returns (uint) {
purchaseTokens(msg.value, _referredBy);
}
function() payable public {
purchaseTokens(msg.value, 0x0);
}
function reinvest() onlyStronghands public {
uint _dividends = myDividends(false);
address _customerAddress = msg.sender;
payoutsTo_[_customerAddress] += (int) (_dividends * magnitude);
_dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
uint _tokens = purchaseTokens(_dividends, 0x0);
onReinvestment(_customerAddress, _dividends, _tokens);
}
function exit() public {
address _customerAddress = msg.sender;
uint _tokens = tokenBalanceLedger_[_customerAddress];
if (_tokens > 0) sell(_tokens);
withdraw();
}
function withdraw() onlyStronghands public {
address _customerAddress = msg.sender;
uint _dividends = myDividends(false);
payoutsTo_[_customerAddress] += (int) (_dividends * magnitude);
_dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
_customerAddress.transfer(_dividends);
onWithdraw(_customerAddress, _dividends);
}
function sell(uint _amountOfTokens) onlyBagholders public {
address _customerAddress = msg.sender;
require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
uint _tokens = _amountOfTokens;
uint _ethereum = tokensToEthereum_(_tokens);
uint _dividends = SafeMath.div(_ethereum, dividendFee_);
uint _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens);
tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens);
int _updatedPayouts = (int) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude));
payoutsTo_[_customerAddress] -= _updatedPayouts;
if (tokenSupply_ > 0) {
profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);
}
onTokenSell(_customerAddress, _tokens, _taxedEthereum);
}
function transfer(address _toAddress, uint _amountOfTokens) onlyBagholders public returns (bool) {
address _customerAddress = msg.sender;
require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
if (myDividends(true) > 0) {
withdraw();
}
uint _tokenFee = SafeMath.div(_amountOfTokens, dividendFee_);
uint _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee);
uint _dividends = tokensToEthereum_(_tokenFee);
tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee);
tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens);
payoutsTo_[_customerAddress] -= (int) (profitPerShare_ * _amountOfTokens);
payoutsTo_[_toAddress] += (int) (profitPerShare_ * _taxedTokens);
profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);
Transfer(_customerAddress, _toAddress, _taxedTokens);
return true;
}
function totalEthereumBalance() public view returns (uint) {
return this.balance;
}
function totalSupply() public view returns (uint) {
return tokenSupply_;
}
function myTokens() public view returns (uint) {
address _customerAddress = msg.sender;
return balanceOf(_customerAddress);
}
function myDividends(bool _includeReferralBonus) public view returns (uint) {
address _customerAddress = msg.sender;
return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ;
}
function balanceOf(address _customerAddress) public view returns (uint) {
return tokenBalanceLedger_[_customerAddress];
}
function dividendsOf(address _customerAddress) public view returns (uint) {
return (uint) ((int)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude;
}
function sellPrice() public view returns (uint) {
if (tokenSupply_ == 0) {
return tokenPriceInitial_ - tokenPriceIncremental_;
} else {
uint _ethereum = tokensToEthereum_(1e18);
uint _dividends = SafeMath.div(_ethereum, dividendFee_ );
uint _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
return _taxedEthereum;
}
}
function buyPrice() public view returns (uint) {
if (tokenSupply_ == 0) {
return tokenPriceInitial_ + tokenPriceIncremental_;
} else {
uint _ethereum = tokensToEthereum_(1e18);
uint _dividends = SafeMath.div(_ethereum, dividendFee_ );
uint _taxedEthereum = SafeMath.add(_ethereum, _dividends);
return _taxedEthereum;
}
}
function calculateTokensReceived(uint _ethereumToSpend) public view returns (uint) {
uint _dividends = SafeMath.div(_ethereumToSpend, dividendFee_);
uint _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends);
uint _amountOfTokens = ethereumToTokens_(_taxedEthereum);
return _amountOfTokens;
}
function calculateEthereumReceived(uint _tokensToSell) public view returns (uint) {
require(_tokensToSell <= tokenSupply_);
uint _ethereum = tokensToEthereum_(_tokensToSell);
uint _dividends = SafeMath.div(_ethereum, dividendFee_);
uint _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
return _taxedEthereum;
}
function purchaseTokens(uint _incomingEthereum, address _referredBy) internal returns (uint) {
address _customerAddress = msg.sender;
uint _undividedDividends = SafeMath.div(_incomingEthereum, dividendFee_);
uint _referralBonus = SafeMath.div(_undividedDividends, 3);
uint _dividends = SafeMath.sub(_undividedDividends, _referralBonus);
uint _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends);
uint _amountOfTokens = ethereumToTokens_(_taxedEthereum);
uint _fee = _dividends * magnitude;
require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_));
if (
_referredBy != 0x0000000000000000000000000000000000000000 &&
_referredBy != _customerAddress &&
tokenBalanceLedger_[_referredBy] >= stakingRequirement
) {
referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus);
} else {
_dividends = SafeMath.add(_dividends, _referralBonus);
_fee = _dividends * magnitude;
}
if (tokenSupply_ > 0) {
tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens);
profitPerShare_ += (_dividends * magnitude / (tokenSupply_));
_fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_))));
} else {
tokenSupply_ = _amountOfTokens;
}
tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
int _updatedPayouts = (int) ((profitPerShare_ * _amountOfTokens) - _fee);
payoutsTo_[_customerAddress] += _updatedPayouts;
onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy);
return _amountOfTokens;
}
function ethereumToTokens_(uint _ethereum) internal view returns (uint) {
uint _tokenPriceInitial = tokenPriceInitial_ * 1e18;
uint _tokensReceived =
(
(
SafeMath.sub(
(sqrt
(
(_tokenPriceInitial**2)
+
(2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18))
+
(((tokenPriceIncremental_)**2)*(tokenSupply_**2))
+
(2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_)
)
), _tokenPriceInitial
)
)/(tokenPriceIncremental_)
)-(tokenSupply_)
;
return _tokensReceived;
}
function tokensToEthereum_(uint _tokens) internal view returns (uint) {
uint tokens_ = (_tokens + 1e18);
uint _tokenSupply = (tokenSupply_ + 1e18);
uint _etherReceived =
(
SafeMath.sub(
(
(
(
tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18))
)-tokenPriceIncremental_
)*(tokens_ - 1e18)
),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2
)
/1e18);
return _etherReceived;
}
function sqrt(uint x) internal pure returns (uint y) {
uint z = (x + 1) / 2;
y = x;
while (z < y) {
y = z;
z = (x / z + z) / 2;
}
}
modifier onlyBagholders {
require(myTokens() > 0);
_;
}
modifier onlyStronghands {
require(myDividends(true) > 0);
_;
}
}
library SafeMath {
function mul(uint a, uint b) internal pure returns (uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
assert(c / a == b);
return c;
}
function div(uint a, uint b) internal pure returns (uint) {
uint c = a / b;
return c;
}
function sub(uint a, uint b) internal pure returns (uint) {
assert(b <= a);
return a - b;
}
function add(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
assert(c >= a);
return c;
}
} | 1 |
pragma solidity ^0.4.19;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() internal {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract tokenInterface {
function balanceOf(address _owner) public constant returns (uint256 balance);
function transfer(address _to, uint256 _value) public returns (bool);
}
contract rateInterface {
function readRate(string _currency) public view returns (uint256 oneEtherValue);
}
contract ICOEngineInterface {
function started() public view returns(bool);
function ended() public view returns(bool);
function startTime() public view returns(uint);
function endTime() public view returns(uint);
function totalTokens() public view returns(uint);
function remainingTokens() public view returns(uint);
function price() public view returns(uint);
}
contract KYCBase {
using SafeMath for uint256;
mapping (address => bool) public isKycSigner;
mapping (uint64 => uint256) public alreadyPayed;
event KycVerified(address indexed signer, address buyerAddress, uint64 buyerId, uint maxAmount);
function KYCBase(address [] kycSigners) internal {
for (uint i = 0; i < kycSigners.length; i++) {
isKycSigner[kycSigners[i]] = true;
}
}
function releaseTokensTo(address buyer) internal returns(bool);
function senderAllowedFor(address buyer)
internal view returns(bool)
{
return buyer == msg.sender;
}
function buyTokensFor(address buyerAddress, uint64 buyerId, uint maxAmount, uint8 v, bytes32 r, bytes32 s)
public payable returns (bool)
{
require(senderAllowedFor(buyerAddress));
return buyImplementation(buyerAddress, buyerId, maxAmount, v, r, s);
}
function buyTokens(uint64 buyerId, uint maxAmount, uint8 v, bytes32 r, bytes32 s)
public payable returns (bool)
{
return buyImplementation(msg.sender, buyerId, maxAmount, v, r, s);
}
function buyImplementation(address buyerAddress, uint64 buyerId, uint maxAmount, uint8 v, bytes32 r, bytes32 s)
private returns (bool)
{
bytes32 hash = sha256("Eidoo icoengine authorization", 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;
emit KycVerified(signer, buyerAddress, buyerId, maxAmount);
return releaseTokensTo(buyerAddress);
}
}
}
contract RC is ICOEngineInterface, KYCBase {
using SafeMath for uint256;
TokenSale tokenSaleContract;
uint256 public startTime;
uint256 public endTime;
uint256 public etherMinimum;
uint256 public soldTokens;
uint256 public remainingTokens;
uint256 public oneTokenInFiatWei;
mapping(address => uint256) public etherUser;
mapping(address => uint256) public pendingTokenUser;
mapping(address => uint256) public tokenUser;
uint256[] public tokenThreshold;
uint256[] public bonusThreshold;
function RC(address _tokenSaleContract, uint256 _oneTokenInFiatWei, uint256 _remainingTokens, uint256 _etherMinimum, uint256 _startTime , uint256 _endTime, address [] kycSigner, uint256[] _tokenThreshold, uint256[] _bonusThreshold ) public KYCBase(kycSigner) {
require ( _tokenSaleContract != 0 );
require ( _oneTokenInFiatWei != 0 );
require( _remainingTokens != 0 );
require ( _tokenThreshold.length != 0 );
require ( _tokenThreshold.length == _bonusThreshold.length );
bonusThreshold = _bonusThreshold;
tokenThreshold = _tokenThreshold;
tokenSaleContract = TokenSale(_tokenSaleContract);
tokenSaleContract.addMeByRC();
soldTokens = 0;
remainingTokens = _remainingTokens;
oneTokenInFiatWei = _oneTokenInFiatWei;
etherMinimum = _etherMinimum;
setTimeRC( _startTime, _endTime );
}
function setTimeRC(uint256 _startTime, uint256 _endTime ) internal {
if( _startTime == 0 ) {
startTime = tokenSaleContract.startTime();
} else {
startTime = _startTime;
}
if( _endTime == 0 ) {
endTime = tokenSaleContract.endTime();
} else {
endTime = _endTime;
}
}
modifier onlyTokenSaleOwner() {
require(msg.sender == tokenSaleContract.owner() );
_;
}
function setTime(uint256 _newStart, uint256 _newEnd) public onlyTokenSaleOwner {
if ( _newStart != 0 ) startTime = _newStart;
if ( _newEnd != 0 ) endTime = _newEnd;
}
function changeMinimum(uint256 _newEtherMinimum) public onlyTokenSaleOwner {
etherMinimum = _newEtherMinimum;
}
function releaseTokensTo(address buyer) internal returns(bool) {
if( msg.value > 0 ) takeEther(buyer);
giveToken(buyer);
return true;
}
function started() public view returns(bool) {
return now > startTime || remainingTokens == 0;
}
function ended() public view returns(bool) {
return now > endTime || remainingTokens == 0;
}
function startTime() public view returns(uint) {
return startTime;
}
function endTime() public view returns(uint) {
return endTime;
}
function totalTokens() public view returns(uint) {
return remainingTokens.add(soldTokens);
}
function remainingTokens() public view returns(uint) {
return remainingTokens;
}
function price() public view returns(uint) {
uint256 oneEther = 10**18;
return oneEther.mul(10**18).div( tokenSaleContract.tokenValueInEther(oneTokenInFiatWei) );
}
function () public payable{
require( now > startTime );
if(now < endTime) {
takeEther(msg.sender);
} else {
claimTokenBonus(msg.sender);
}
}
event Buy(address buyer, uint256 value, uint256 soldToken, uint256 valueTokenInUsdWei );
function takeEther(address _buyer) internal {
require( now > startTime );
require( now < endTime );
require( msg.value >= etherMinimum);
require( remainingTokens > 0 );
uint256 oneToken = 10 ** uint256(tokenSaleContract.decimals());
uint256 tokenValue = tokenSaleContract.tokenValueInEther(oneTokenInFiatWei);
uint256 tokenAmount = msg.value.mul(oneToken).div(tokenValue);
uint256 unboughtTokens = tokenInterface(tokenSaleContract.tokenContract()).balanceOf(tokenSaleContract);
if ( unboughtTokens > remainingTokens ) {
unboughtTokens = remainingTokens;
}
uint256 refund = 0;
if ( unboughtTokens < tokenAmount ) {
refund = (tokenAmount - unboughtTokens).mul(tokenValue).div(oneToken);
tokenAmount = unboughtTokens;
remainingTokens = 0;
_buyer.transfer(refund);
} else {
remainingTokens = remainingTokens.sub(tokenAmount);
}
etherUser[_buyer] = etherUser[_buyer].add(msg.value.sub(refund));
pendingTokenUser[_buyer] = pendingTokenUser[_buyer].add(tokenAmount);
emit Buy( _buyer, msg.value, tokenAmount, oneTokenInFiatWei );
}
function giveToken(address _buyer) internal {
require( pendingTokenUser[_buyer] > 0 );
tokenUser[_buyer] = tokenUser[_buyer].add(pendingTokenUser[_buyer]);
tokenSaleContract.claim(_buyer, pendingTokenUser[_buyer]);
soldTokens = soldTokens.add(pendingTokenUser[_buyer]);
pendingTokenUser[_buyer] = 0;
tokenSaleContract.wallet().transfer(etherUser[_buyer]);
etherUser[_buyer] = 0;
}
function claimTokenBonus(address _buyer) internal {
require( now > endTime );
require( tokenUser[_buyer] > 0 );
uint256 bonusApplied = 0;
for (uint i = 0; i < tokenThreshold.length; i++) {
if ( soldTokens > tokenThreshold[i] ) {
bonusApplied = bonusThreshold[i];
}
}
require( bonusApplied > 0 );
uint256 addTokenAmount = tokenUser[_buyer].mul( bonusApplied ).div(10**2);
tokenUser[_buyer] = 0;
tokenSaleContract.claim(_buyer, addTokenAmount);
_buyer.transfer(msg.value);
}
function refundEther(address to) public onlyTokenSaleOwner {
to.transfer(etherUser[to]);
etherUser[to] = 0;
pendingTokenUser[to] = 0;
}
function withdraw(address to, uint256 value) public onlyTokenSaleOwner {
to.transfer(value);
}
function userBalance(address _user) public view returns( uint256 _pendingTokenUser, uint256 _tokenUser, uint256 _etherUser ) {
return (pendingTokenUser[_user], tokenUser[_user], etherUser[_user]);
}
}
contract RCpro is ICOEngineInterface, KYCBase {
using SafeMath for uint256;
TokenSale tokenSaleContract;
uint256 public startTime;
uint256 public endTime;
uint256 public etherMinimum;
uint256 public soldTokens;
uint256 public remainingTokens;
uint256[] public oneTokenInFiatWei;
uint256[] public sendThreshold;
mapping(address => uint256) public etherUser;
mapping(address => uint256) public pendingTokenUser;
mapping(address => uint256) public tokenUser;
uint256[] public tokenThreshold;
uint256[] public bonusThreshold;
function RCpro(address _tokenSaleContract, uint256[] _oneTokenInFiatWei, uint256[] _sendThreshold, uint256 _remainingTokens, uint256 _etherMinimum, uint256 _startTime , uint256 _endTime, address [] kycSigner, uint256[] _tokenThreshold, uint256[] _bonusThreshold ) public KYCBase(kycSigner) {
require ( _tokenSaleContract != 0 );
require ( _oneTokenInFiatWei[0] != 0 );
require ( _oneTokenInFiatWei.length == _sendThreshold.length );
require( _remainingTokens != 0 );
require ( _tokenThreshold.length != 0 );
require ( _tokenThreshold.length == _bonusThreshold.length );
bonusThreshold = _bonusThreshold;
tokenThreshold = _tokenThreshold;
tokenSaleContract = TokenSale(_tokenSaleContract);
tokenSaleContract.addMeByRC();
soldTokens = 0;
remainingTokens = _remainingTokens;
oneTokenInFiatWei = _oneTokenInFiatWei;
sendThreshold = _sendThreshold;
etherMinimum = _etherMinimum;
setTimeRC( _startTime, _endTime );
}
function setTimeRC(uint256 _startTime, uint256 _endTime ) internal {
if( _startTime == 0 ) {
startTime = tokenSaleContract.startTime();
} else {
startTime = _startTime;
}
if( _endTime == 0 ) {
endTime = tokenSaleContract.endTime();
} else {
endTime = _endTime;
}
}
modifier onlyTokenSaleOwner() {
require(msg.sender == tokenSaleContract.owner() );
_;
}
function setTime(uint256 _newStart, uint256 _newEnd) public onlyTokenSaleOwner {
if ( _newStart != 0 ) startTime = _newStart;
if ( _newEnd != 0 ) endTime = _newEnd;
}
function changeMinimum(uint256 _newEtherMinimum) public onlyTokenSaleOwner {
etherMinimum = _newEtherMinimum;
}
function releaseTokensTo(address buyer) internal returns(bool) {
if( msg.value > 0 ) takeEther(buyer);
giveToken(buyer);
return true;
}
function started() public view returns(bool) {
return now > startTime || remainingTokens == 0;
}
function ended() public view returns(bool) {
return now > endTime || remainingTokens == 0;
}
function startTime() public view returns(uint) {
return startTime;
}
function endTime() public view returns(uint) {
return endTime;
}
function totalTokens() public view returns(uint) {
return remainingTokens.add(soldTokens);
}
function remainingTokens() public view returns(uint) {
return remainingTokens;
}
function price() public view returns(uint) {
uint256 oneEther = 10**18;
return oneEther.mul(10**18).div( tokenSaleContract.tokenValueInEther(oneTokenInFiatWei[0]) );
}
function () public payable{
require( now > startTime );
if(now < endTime) {
takeEther(msg.sender);
} else {
claimTokenBonus(msg.sender);
}
}
event Buy(address buyer, uint256 value, uint256 soldToken, uint256 valueTokenInFiatWei );
function takeEther(address _buyer) internal {
require( now > startTime );
require( now < endTime );
require( msg.value >= etherMinimum);
require( remainingTokens > 0 );
uint256 oneToken = 10 ** uint256(tokenSaleContract.decimals());
uint256 tknPriceApplied = 0;
for (uint i = 0; i < sendThreshold.length; i++) {
if ( msg.value >= sendThreshold[i] ) {
tknPriceApplied = oneTokenInFiatWei[i];
}
}
require( tknPriceApplied > 0 );
uint256 tokenValue = tokenSaleContract.tokenValueInEther(tknPriceApplied);
uint256 tokenAmount = msg.value.mul(oneToken).div(tokenValue);
uint256 unboughtTokens = tokenInterface(tokenSaleContract.tokenContract()).balanceOf(tokenSaleContract);
if ( unboughtTokens > remainingTokens ) {
unboughtTokens = remainingTokens;
}
uint256 refund = 0;
if ( unboughtTokens < tokenAmount ) {
refund = (tokenAmount - unboughtTokens).mul(tokenValue).div(oneToken);
tokenAmount = unboughtTokens;
remainingTokens = 0;
_buyer.transfer(refund);
} else {
remainingTokens = remainingTokens.sub(tokenAmount);
}
etherUser[_buyer] = etherUser[_buyer].add(msg.value.sub(refund));
pendingTokenUser[_buyer] = pendingTokenUser[_buyer].add(tokenAmount);
emit Buy( _buyer, msg.value, tokenAmount, tknPriceApplied );
}
function giveToken(address _buyer) internal {
require( pendingTokenUser[_buyer] > 0 );
tokenUser[_buyer] = tokenUser[_buyer].add(pendingTokenUser[_buyer]);
tokenSaleContract.claim(_buyer, pendingTokenUser[_buyer]);
soldTokens = soldTokens.add(pendingTokenUser[_buyer]);
pendingTokenUser[_buyer] = 0;
tokenSaleContract.wallet().transfer(etherUser[_buyer]);
etherUser[_buyer] = 0;
}
function claimTokenBonus(address _buyer) internal {
require( now > endTime );
require( tokenUser[_buyer] > 0 );
uint256 bonusApplied = 0;
for (uint i = 0; i < tokenThreshold.length; i++) {
if ( soldTokens > tokenThreshold[i] ) {
bonusApplied = bonusThreshold[i];
}
}
require( bonusApplied > 0 );
uint256 addTokenAmount = tokenUser[_buyer].mul( bonusApplied ).div(10**2);
tokenUser[_buyer] = 0;
tokenSaleContract.claim(_buyer, addTokenAmount);
_buyer.transfer(msg.value);
}
function refundEther(address to) public onlyTokenSaleOwner {
to.transfer(etherUser[to]);
etherUser[to] = 0;
pendingTokenUser[to] = 0;
}
function withdraw(address to, uint256 value) public onlyTokenSaleOwner {
to.transfer(value);
}
function userBalance(address _user) public view returns( uint256 _pendingTokenUser, uint256 _tokenUser, uint256 _etherUser ) {
return (pendingTokenUser[_user], tokenUser[_user], etherUser[_user]);
}
}
contract TokenSale is Ownable {
using SafeMath for uint256;
tokenInterface public tokenContract;
rateInterface public rateContract;
address public wallet;
address public advisor;
uint256 public advisorFee;
uint256 public constant decimals = 18;
uint256 public endTime;
uint256 public startTime;
mapping(address => bool) public rc;
function TokenSale(address _tokenAddress, address _rateAddress, uint256 _startTime, uint256 _endTime) public {
tokenContract = tokenInterface(_tokenAddress);
rateContract = rateInterface(_rateAddress);
setTime(_startTime, _endTime);
wallet = msg.sender;
advisor = msg.sender;
advisorFee = 0 * 10**3;
}
function tokenValueInEther(uint256 _oneTokenInFiatWei) public view returns(uint256 tknValue) {
uint256 oneEtherInUsd = rateContract.readRate("usd");
tknValue = _oneTokenInFiatWei.mul(10 ** uint256(decimals)).div(oneEtherInUsd);
return tknValue;
}
modifier isBuyable() {
require( now > startTime );
require( now < endTime );
require( msg.value > 0 );
uint256 remainingTokens = tokenContract.balanceOf(this);
require( remainingTokens > 0 );
_;
}
event Buy(address buyer, uint256 value, address indexed ambassador);
modifier onlyRC() {
require( rc[msg.sender] );
_;
}
function buyFromRC(address _buyer, uint256 _rcTokenValue, uint256 _remainingTokens) onlyRC isBuyable public payable returns(uint256) {
uint256 oneToken = 10 ** uint256(decimals);
uint256 tokenValue = tokenValueInEther(_rcTokenValue);
uint256 tokenAmount = msg.value.mul(oneToken).div(tokenValue);
address _ambassador = msg.sender;
uint256 remainingTokens = tokenContract.balanceOf(this);
if ( _remainingTokens < remainingTokens ) {
remainingTokens = _remainingTokens;
}
if ( remainingTokens < tokenAmount ) {
uint256 refund = (tokenAmount - remainingTokens).mul(tokenValue).div(oneToken);
tokenAmount = remainingTokens;
forward(msg.value-refund);
remainingTokens = 0;
_buyer.transfer(refund);
} else {
remainingTokens = remainingTokens.sub(tokenAmount);
forward(msg.value);
}
tokenContract.transfer(_buyer, tokenAmount);
emit Buy(_buyer, tokenAmount, _ambassador);
return tokenAmount;
}
function forward(uint256 _amount) internal {
uint256 advisorAmount = _amount.mul(advisorFee).div(10**3);
uint256 walletAmount = _amount - advisorAmount;
advisor.transfer(advisorAmount);
wallet.transfer(walletAmount);
}
event NewRC(address contr);
function addMeByRC() public {
require(tx.origin == owner);
rc[ msg.sender ] = true;
emit NewRC(msg.sender);
}
function setTime(uint256 _newStart, uint256 _newEnd) public onlyOwner {
if ( _newStart != 0 ) startTime = _newStart;
if ( _newEnd != 0 ) endTime = _newEnd;
}
function withdraw(address to, uint256 value) public onlyOwner {
to.transfer(value);
}
function withdrawTokens(address to, uint256 value) public onlyOwner returns (bool) {
return tokenContract.transfer(to, value);
}
function setTokenContract(address _tokenContract) public onlyOwner {
tokenContract = tokenInterface(_tokenContract);
}
function setWalletAddress(address _wallet) public onlyOwner {
wallet = _wallet;
}
function setAdvisorAddress(address _advisor) public onlyOwner {
advisor = _advisor;
}
function setAdvisorFee(uint256 _advisorFee) public onlyOwner {
advisorFee = _advisorFee;
}
function setRateContract(address _rateAddress) public onlyOwner {
rateContract = rateInterface(_rateAddress);
}
function claim(address _buyer, uint256 _amount) onlyRC public returns(bool) {
return tokenContract.transfer(_buyer, _amount);
}
function () public payable {
revert();
}
} | 0 |
pragma solidity ^0.4.18;
interface IMultiOwned {
function isOwner(address _account) public view returns (bool);
function getOwnerCount() public view returns (uint);
function getOwnerAt(uint _index) public view returns (address);
function addOwner(address _account) public;
function removeOwner(address _account) public;
}
contract MultiOwned is IMultiOwned {
mapping (address => uint) private owners;
address[] private ownersIndex;
modifier only_owner() {
require(isOwner(msg.sender));
_;
}
function MultiOwned() public {
ownersIndex.push(msg.sender);
owners[msg.sender] = 0;
}
function isOwner(address _account) public view returns (bool) {
return owners[_account] < ownersIndex.length && _account == ownersIndex[owners[_account]];
}
function getOwnerCount() public view returns (uint) {
return ownersIndex.length;
}
function getOwnerAt(uint _index) public view returns (address) {
return ownersIndex[_index];
}
function addOwner(address _account) public only_owner {
if (!isOwner(_account)) {
owners[_account] = ownersIndex.push(_account) - 1;
}
}
function removeOwner(address _account) public only_owner {
if (isOwner(_account)) {
uint indexToDelete = owners[_account];
address keyToMove = ownersIndex[ownersIndex.length - 1];
ownersIndex[indexToDelete] = keyToMove;
owners[keyToMove] = indexToDelete;
ownersIndex.length--;
}
}
}
interface IObservable {
function isObserver(address _account) public view returns (bool);
function getObserverCount() public view returns (uint);
function getObserverAtIndex(uint _index) public view returns (address);
function registerObserver(address _observer) public;
function unregisterObserver(address _observer) public;
}
contract Observable is IObservable {
mapping (address => uint) private observers;
address[] private observerIndex;
function isObserver(address _account) public view returns (bool) {
return observers[_account] < observerIndex.length && _account == observerIndex[observers[_account]];
}
function getObserverCount() public view returns (uint) {
return observerIndex.length;
}
function getObserverAtIndex(uint _index) public view returns (address) {
return observerIndex[_index];
}
function registerObserver(address _observer) public {
require(canRegisterObserver(_observer));
if (!isObserver(_observer)) {
observers[_observer] = observerIndex.push(_observer) - 1;
}
}
function unregisterObserver(address _observer) public {
require(canUnregisterObserver(_observer));
if (isObserver(_observer)) {
uint indexToDelete = observers[_observer];
address keyToMove = observerIndex[observerIndex.length - 1];
observerIndex[indexToDelete] = keyToMove;
observers[keyToMove] = indexToDelete;
observerIndex.length--;
}
}
function canRegisterObserver(address _observer) internal view returns (bool);
function canUnregisterObserver(address _observer) internal view returns (bool);
}
interface ITokenObserver {
function notifyTokensReceived(address _from, uint _value) public;
}
contract TokenObserver is ITokenObserver {
function notifyTokensReceived(address _from, uint _value) public {
onTokensReceived(msg.sender, _from, _value);
}
function onTokensReceived(address _token, address _from, uint _value) internal;
}
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);
}
}
}
contract InputValidator {
modifier safe_arguments(uint _numArgs) {
assert(msg.data.length == _numArgs * 32 + 4);
_;
}
}
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);
}
contract Token is IToken, InputValidator {
string public standard = "Token 0.3.1";
string public name;
string public symbol;
uint8 public decimals;
uint internal totalTokenSupply;
mapping (address => uint) internal balances;
mapping (address => mapping (address => uint)) internal allowed;
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function Token(string _name, string _symbol, uint8 _decimals) public {
name = _name;
symbol = _symbol;
decimals = _decimals;
balances[msg.sender] = 0;
totalTokenSupply = 0;
}
function totalSupply() public view returns (uint) {
return totalTokenSupply;
}
function balanceOf(address _owner) public view returns (uint) {
return balances[_owner];
}
function transfer(address _to, uint _value) public safe_arguments(2) returns (bool) {
require(balances[msg.sender] >= _value);
require(balances[_to] + _value >= balances[_to]);
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint _value) public safe_arguments(3) returns (bool) {
require(balances[_from] >= _value);
require(balances[_to] + _value >= balances[_to]);
require(_value <= allowed[_from][msg.sender]);
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public safe_arguments(2) returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint) {
return allowed[_owner][_spender];
}
}
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);
}
contract ManagedToken is IManagedToken, Token, MultiOwned {
bool internal locked;
modifier only_when_unlocked() {
require(!locked);
_;
}
function ManagedToken(string _name, string _symbol, uint8 _decimals, bool _locked) public
Token(_name, _symbol, _decimals) {
locked = _locked;
}
function transfer(address _to, uint _value) public only_when_unlocked returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public only_when_unlocked returns (bool) {
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint _value) public returns (bool) {
return super.approve(_spender, _value);
}
function isLocked() public view returns (bool) {
return locked;
}
function lock() public only_owner returns (bool) {
locked = true;
return locked;
}
function unlock() public only_owner returns (bool) {
locked = false;
return !locked;
}
function issue(address _to, uint _value) public only_owner safe_arguments(2) returns (bool) {
require(balances[_to] + _value >= balances[_to]);
balances[_to] += _value;
totalTokenSupply += _value;
Transfer(0, this, _value);
Transfer(this, _to, _value);
return true;
}
function burn(address _from, uint _value) public only_owner safe_arguments(2) returns (bool) {
require(balances[_from] >= _value);
require(balances[_from] - _value <= balances[_from]);
balances[_from] -= _value;
totalTokenSupply -= _value;
Transfer(_from, 0, _value);
return true;
}
}
contract KATMToken is ManagedToken, Observable, TokenRetriever {
function KATMToken() public ManagedToken("KATM Security", "KATM", 8, false) {}
function canRegisterObserver(address _observer) internal view returns (bool) {
return _observer != address(this) && isOwner(msg.sender);
}
function canUnregisterObserver(address _observer) internal view returns (bool) {
return msg.sender == _observer || isOwner(msg.sender);
}
function transfer(address _to, uint _value) public returns (bool) {
bool result = super.transfer(_to, _value);
if (isObserver(_to)) {
ITokenObserver(_to).notifyTokensReceived(msg.sender, _value);
}
return result;
}
function transferFrom(address _from, address _to, uint _value) public returns (bool) {
bool result = super.transferFrom(_from, _to, _value);
if (isObserver(_to)) {
ITokenObserver(_to).notifyTokensReceived(_from, _value);
}
return result;
}
function retrieveTokens(address _tokenContract) public only_owner {
super.retrieveTokens(_tokenContract);
}
function () public payable {
revert();
}
} | 1 |
pragma solidity ^0.4.24;
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 ZapCoordinatorInterface is Ownable {
function addImmutableContract(string contractName, address newAddress) external;
function updateContract(string contractName, address newAddress) external;
function getContractName(uint index) public view returns (string);
function getContract(string contractName) public view returns (address);
function updateAllDependencies() external;
}
pragma solidity ^0.4.24;
contract Upgradable {
address coordinatorAddr;
ZapCoordinatorInterface coordinator;
constructor(address c) public{
coordinatorAddr = c;
coordinator = ZapCoordinatorInterface(c);
}
function updateDependencies() external coordinatorOnly {
_updateDependencies();
}
function _updateDependencies() internal;
modifier coordinatorOnly() {
require(msg.sender == coordinatorAddr, "Error: Coordinator Only Function");
_;
}
}
contract Destructible is Ownable {
function selfDestruct() public onlyOwner {
selfdestruct(owner);
}
}
contract BondageInterface {
function bond(address, bytes32, uint256) external returns(uint256);
function unbond(address, bytes32, uint256) external returns (uint256);
function delegateBond(address, address, bytes32, uint256) external returns(uint256);
function escrowDots(address, address, bytes32, uint256) external returns (bool);
function releaseDots(address, address, bytes32, uint256) external returns (bool);
function returnDots(address, address, bytes32, uint256) external returns (bool success);
function calcZapForDots(address, bytes32, uint256) external view returns (uint256);
function currentCostOfDot(address, bytes32, uint256) public view returns (uint256);
function getDotsIssued(address, bytes32) public view returns (uint256);
function getBoundDots(address, address, bytes32) public view returns (uint256);
function getZapBound(address, bytes32) public view returns (uint256);
function dotLimit( address, bytes32) public view returns (uint256);
}
contract ArbiterInterface {
function initiateSubscription(address, bytes32, bytes32[], uint256, uint64) public;
function getSubscription(address, address, bytes32) public view returns (uint64, uint96, uint96);
function endSubscriptionProvider(address, bytes32) public;
function endSubscriptionSubscriber(address, bytes32) public;
function passParams(address receiver, bytes32 endpoint, bytes32[] params) public;
}
contract DatabaseInterface is Ownable {
function setStorageContract(address _storageContract, bool _allowed) public;
function getBytes32(bytes32 key) external view returns(bytes32);
function setBytes32(bytes32 key, bytes32 value) external;
function getNumber(bytes32 key) external view returns(uint256);
function setNumber(bytes32 key, uint256 value) external;
function getBytes(bytes32 key) external view returns(bytes);
function setBytes(bytes32 key, bytes value) external;
function getString(bytes32 key) external view returns(string);
function setString(bytes32 key, string value) external;
function getBytesArray(bytes32 key) external view returns (bytes32[]);
function getBytesArrayIndex(bytes32 key, uint256 index) external view returns (bytes32);
function getBytesArrayLength(bytes32 key) external view returns (uint256);
function pushBytesArray(bytes32 key, bytes32 value) external;
function setBytesArrayIndex(bytes32 key, uint256 index, bytes32 value) external;
function setBytesArray(bytes32 key, bytes32[] value) external;
function getIntArray(bytes32 key) external view returns (int[]);
function getIntArrayIndex(bytes32 key, uint256 index) external view returns (int);
function getIntArrayLength(bytes32 key) external view returns (uint256);
function pushIntArray(bytes32 key, int value) external;
function setIntArrayIndex(bytes32 key, uint256 index, int value) external;
function setIntArray(bytes32 key, int[] value) external;
function getAddressArray(bytes32 key) external view returns (address[]);
function getAddressArrayIndex(bytes32 key, uint256 index) external view returns (address);
function getAddressArrayLength(bytes32 key) external view returns (uint256);
function pushAddressArray(bytes32 key, address value) external;
function setAddressArrayIndex(bytes32 key, uint256 index, address value) external;
function setAddressArray(bytes32 key, address[] value) external;
}
contract Arbiter is Destructible, ArbiterInterface, Upgradable {
event DataPurchase(
address indexed provider,
address indexed subscriber,
uint256 publicKey,
uint256 indexed amount,
bytes32[] endpointParams,
bytes32 endpoint
);
event DataSubscriptionEnd(
address indexed provider,
address indexed subscriber,
SubscriptionTerminator indexed terminator
);
event ParamsPassed(
address indexed sender,
address indexed receiver,
bytes32 endpoint,
bytes32[] params
);
enum SubscriptionTerminator { Provider, Subscriber }
BondageInterface bondage;
address public bondageAddress;
DatabaseInterface public db;
constructor(address c) Upgradable(c) public {
_updateDependencies();
}
function _updateDependencies() internal {
bondageAddress = coordinator.getContract("BONDAGE");
bondage = BondageInterface(bondageAddress);
address databaseAddress = coordinator.getContract("DATABASE");
db = DatabaseInterface(databaseAddress);
}
function passParams(address receiver, bytes32 endpoint, bytes32[] params) public {
emit ParamsPassed(msg.sender, receiver, endpoint, params);
}
function initiateSubscription(
address providerAddress,
bytes32 endpoint,
bytes32[] endpointParams,
uint256 publicKey,
uint64 blocks
)
public
{
require(blocks > 0, "Error: Must be at least one block");
require(getDots(providerAddress, msg.sender, endpoint) == 0, "Error: Cannot reinstantiate a currently active contract");
bondage.escrowDots(msg.sender, providerAddress, endpoint, blocks);
setSubscription(
providerAddress,
msg.sender,
endpoint,
blocks,
uint96(block.number),
uint96(block.number) + uint96(blocks)
);
emit DataPurchase(
providerAddress,
msg.sender,
publicKey,
blocks,
endpointParams,
endpoint
);
}
function getSubscription(address providerAddress, address subscriberAddress, bytes32 endpoint)
public
view
returns (uint64 dots, uint96 blockStart, uint96 preBlockEnd)
{
return (
getDots(providerAddress, subscriberAddress, endpoint),
getBlockStart(providerAddress, subscriberAddress, endpoint),
getPreBlockEnd(providerAddress, subscriberAddress, endpoint)
);
}
function endSubscriptionProvider(
address subscriberAddress,
bytes32 endpoint
)
public
{
if (endSubscription(msg.sender, subscriberAddress, endpoint))
emit DataSubscriptionEnd(
msg.sender,
subscriberAddress,
SubscriptionTerminator.Provider
);
}
function endSubscriptionSubscriber(
address providerAddress,
bytes32 endpoint
)
public
{
if (endSubscription(providerAddress, msg.sender, endpoint))
emit DataSubscriptionEnd(
providerAddress,
msg.sender,
SubscriptionTerminator.Subscriber
);
}
function endSubscription(
address providerAddress,
address subscriberAddress,
bytes32 endpoint
)
private
returns (bool)
{
uint256 dots = getDots(providerAddress, subscriberAddress, endpoint);
uint256 preblockend = getPreBlockEnd(providerAddress, subscriberAddress, endpoint);
require(dots > 0, "Error: Subscriber must have a subscription");
if (block.number < preblockend) {
uint256 earnedDots = block.number - getBlockStart(providerAddress, subscriberAddress, endpoint);
uint256 returnedDots = dots - earnedDots;
bondage.releaseDots(
subscriberAddress,
providerAddress,
endpoint,
earnedDots
);
bondage.returnDots(
subscriberAddress,
providerAddress,
endpoint,
returnedDots
);
} else {
bondage.releaseDots(
subscriberAddress,
providerAddress,
endpoint,
dots
);
}
deleteSubscription(providerAddress, subscriberAddress, endpoint);
return true;
}
function getDots(
address providerAddress,
address subscriberAddress,
bytes32 endpoint
)
public
view
returns (uint64)
{
return uint64(db.getNumber(keccak256(abi.encodePacked('subscriptions', providerAddress, subscriberAddress, endpoint, 'dots'))));
}
function getBlockStart(
address providerAddress,
address subscriberAddress,
bytes32 endpoint
)
public
view
returns (uint96)
{
return uint96(db.getNumber(keccak256(abi.encodePacked('subscriptions', providerAddress, subscriberAddress, endpoint, 'blockStart'))));
}
function getPreBlockEnd(
address providerAddress,
address subscriberAddress,
bytes32 endpoint
)
public
view
returns (uint96)
{
return uint96(db.getNumber(keccak256(abi.encodePacked('subscriptions', providerAddress, subscriberAddress, endpoint, 'preBlockEnd'))));
}
function setSubscription(
address providerAddress,
address subscriberAddress,
bytes32 endpoint,
uint64 dots,
uint96 blockStart,
uint96 preBlockEnd
)
private
{
db.setNumber(keccak256(abi.encodePacked('subscriptions', providerAddress, subscriberAddress, endpoint, 'dots')), dots);
db.setNumber(keccak256(abi.encodePacked('subscriptions', providerAddress, subscriberAddress, endpoint, 'blockStart')), uint256(blockStart));
db.setNumber(keccak256(abi.encodePacked('subscriptions', providerAddress, subscriberAddress, endpoint, 'preBlockEnd')), uint256(preBlockEnd));
}
function deleteSubscription(
address providerAddress,
address subscriberAddress,
bytes32 endpoint
)
private
{
db.setNumber(keccak256(abi.encodePacked('subscriptions', providerAddress, subscriberAddress, endpoint, 'dots')), 0);
db.setNumber(keccak256(abi.encodePacked('subscriptions', providerAddress, subscriberAddress, endpoint, 'blockStart')), uint256(0));
db.setNumber(keccak256(abi.encodePacked('subscriptions', providerAddress, subscriberAddress, endpoint, 'preBlockEnd')), uint256(0));
}
} | 0 |
pragma solidity ^0.4.19;
contract EtherHellDeluxe {
using SafeMath for uint256;
event NewRound(
uint _timestamp,
uint _round,
uint _initialPot
);
event Bid(
uint _timestamp,
address _address,
uint _amount,
uint _newPot
);
event NewLeader(
uint _timestamp,
address _address,
uint _newPot,
uint _newDeadline
);
event Winner(
uint _timestamp,
address _address,
uint _earnings,
uint _deadline
);
event EarningsWithdrawal(
uint _timestamp,
address _address,
uint _amount
);
event DividendsWithdrawal(
uint _timestamp,
address _address,
uint _dividendShares,
uint _amount,
uint _newTotalDividendShares,
uint _newDividendFund
);
uint public constant BASE_DURATION = 90 minutes;
uint public constant DURATION_DECREASE_PER_ETHER = 2 minutes;
uint public constant MINIMUM_DURATION = 30 minutes;
uint public constant NEXT_POT_FRAC_TOP = 1;
uint public constant NEXT_POT_FRAC_BOT = 2;
uint public constant MIN_LEADER_FRAC_TOP = 5;
uint public constant MIN_LEADER_FRAC_BOT = 1000;
uint public constant DIVIDEND_FUND_FRAC_TOP = 20;
uint public constant DIVIDEND_FUND_FRAC_BOT = 100;
uint public constant DEVELOPER_FEE_FRAC_TOP = 5;
uint public constant DEVELOPER_FEE_FRAC_BOT = 100;
address owner;
mapping(address => uint) public earnings;
mapping(address => uint) public dividendShares;
uint public totalDividendShares;
uint public dividendFund;
uint public round;
uint public pot;
address public leader;
uint public deadline;
function EtherHellDeluxe() public payable {
require(msg.value > 0);
owner = msg.sender;
round = 1;
pot = msg.value;
leader = owner;
deadline = computeDeadline();
NewRound(now, round, pot);
NewLeader(now, leader, pot, deadline);
}
function computeDeadline() internal view returns (uint) {
uint _durationDecrease = DURATION_DECREASE_PER_ETHER.mul(pot.div(1 ether));
uint _duration;
if (MINIMUM_DURATION.add(_durationDecrease) > BASE_DURATION) {
_duration = MINIMUM_DURATION;
} else {
_duration = BASE_DURATION.sub(_durationDecrease);
}
return now.add(_duration);
}
modifier advanceRoundIfNeeded {
if (now > deadline) {
uint _nextPot = pot.mul(NEXT_POT_FRAC_TOP).div(NEXT_POT_FRAC_BOT);
uint _leaderEarnings = pot.sub(_nextPot);
Winner(now, leader, _leaderEarnings, deadline);
earnings[leader] = earnings[leader].add(_leaderEarnings);
round++;
pot = _nextPot;
leader = owner;
deadline = computeDeadline();
NewRound(now, round, pot);
NewLeader(now, leader, pot, deadline);
}
_;
}
function bid() public payable advanceRoundIfNeeded {
uint _minLeaderAmount = pot.mul(MIN_LEADER_FRAC_TOP).div(MIN_LEADER_FRAC_BOT);
uint _bidAmountToDeveloper = msg.value.mul(DEVELOPER_FEE_FRAC_TOP).div(DEVELOPER_FEE_FRAC_BOT);
uint _bidAmountToDividendFund = msg.value.mul(DIVIDEND_FUND_FRAC_TOP).div(DIVIDEND_FUND_FRAC_BOT);
uint _bidAmountToPot = msg.value.sub(_bidAmountToDeveloper).sub(_bidAmountToDividendFund);
earnings[owner] = earnings[owner].add(_bidAmountToDeveloper);
dividendFund = dividendFund.add(_bidAmountToDividendFund);
pot = pot.add(_bidAmountToPot);
Bid(now, msg.sender, msg.value, pot);
if (msg.value >= _minLeaderAmount) {
uint _dividendShares = msg.value.div(_minLeaderAmount);
dividendShares[msg.sender] = dividendShares[msg.sender].add(_dividendShares);
totalDividendShares = totalDividendShares.add(_dividendShares);
leader = msg.sender;
deadline = computeDeadline();
NewLeader(now, leader, pot, deadline);
}
}
function withdrawEarnings() public advanceRoundIfNeeded {
require(earnings[msg.sender] > 0);
assert(earnings[msg.sender] <= this.balance);
uint _amount = earnings[msg.sender];
earnings[msg.sender] = 0;
msg.sender.transfer(_amount);
EarningsWithdrawal(now, msg.sender, _amount);
}
function withdrawDividends() public {
require(dividendShares[msg.sender] > 0);
uint _dividendShares = dividendShares[msg.sender];
assert(_dividendShares <= totalDividendShares);
uint _amount = dividendFund.mul(_dividendShares).div(totalDividendShares);
assert(_amount <= this.balance);
dividendShares[msg.sender] = 0;
totalDividendShares = totalDividendShares.sub(_dividendShares);
dividendFund = dividendFund.sub(_amount);
msg.sender.transfer(_amount);
DividendsWithdrawal(now, msg.sender, _dividendShares, _amount, totalDividendShares, dividendFund);
}
}
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.13;
contract ReentrancyHandlingContract {
bool locked;
modifier noReentrancy() {
require(!locked);
locked = true;
_;
locked = false;
}
}
contract Owned {
address public owner;
address public newOwner;
function Owned() public {
owner = msg.sender;
}
modifier onlyOwner {
assert(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != owner);
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
OwnerUpdate(owner, newOwner);
owner = newOwner;
newOwner = 0x0;
}
event OwnerUpdate(address _prevOwner, address _newOwner);
}
contract PriorityPassInterface {
function getAccountLimit(address _accountAddress) public constant returns (uint);
function getAccountActivity(address _accountAddress) public constant returns (bool);
}
contract ERC20TokenInterface {
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 SeedCrowdsaleContract is ReentrancyHandlingContract, Owned {
struct ContributorData {
uint contributionAmount;
}
mapping(address => ContributorData) public contributorList;
uint public nextContributorIndex;
mapping(uint => address) public contributorIndexes;
state public crowdsaleState = state.pendingStart;
enum state { pendingStart, priorityPass, openedPriorityPass, crowdsaleEnded }
uint public presaleStartTime;
uint public presaleUnlimitedStartTime;
uint public crowdsaleEndedTime;
event PresaleStarted(uint blocktime);
event PresaleUnlimitedStarted(uint blocktime);
event CrowdsaleEnded(uint blocktime);
event ErrorSendingETH(address to, uint amount);
event MinCapReached(uint blocktime);
event MaxCapReached(uint blocktime);
event ContributionMade(address indexed contributor, uint amount);
PriorityPassInterface priorityPassContract = PriorityPassInterface(0x0);
uint public minCap;
uint public maxP1Cap;
uint public maxCap;
uint public ethRaised;
address public multisigAddress;
uint nextContributorToClaim;
mapping(address => bool) hasClaimedEthWhenFail;
function() noReentrancy payable public {
require(msg.value != 0);
require(crowdsaleState != state.crowdsaleEnded);
bool stateChanged = checkCrowdsaleState();
if (crowdsaleState == state.priorityPass) {
if (priorityPassContract.getAccountActivity(msg.sender)) {
processTransaction(msg.sender, msg.value);
} else {
refundTransaction(stateChanged);
}
} else if (crowdsaleState == state.openedPriorityPass) {
if (priorityPassContract.getAccountActivity(msg.sender)) {
processTransaction(msg.sender, msg.value);
} else {
refundTransaction(stateChanged);
}
} else {
refundTransaction(stateChanged);
}
}
function checkCrowdsaleState() internal returns (bool) {
if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) {
crowdsaleState = state.crowdsaleEnded;
MaxCapReached(block.timestamp);
CrowdsaleEnded(block.timestamp);
return true;
}
if (block.timestamp > presaleStartTime && block.timestamp <= presaleUnlimitedStartTime) {
if (crowdsaleState != state.priorityPass) {
crowdsaleState = state.priorityPass;
PresaleStarted(block.timestamp);
return true;
}
} else if (block.timestamp > presaleUnlimitedStartTime && block.timestamp <= crowdsaleEndedTime) {
if (crowdsaleState != state.openedPriorityPass) {
crowdsaleState = state.openedPriorityPass;
PresaleUnlimitedStarted(block.timestamp);
return true;
}
} else {
if (crowdsaleState != state.crowdsaleEnded && block.timestamp > crowdsaleEndedTime) {
crowdsaleState = state.crowdsaleEnded;
CrowdsaleEnded(block.timestamp);
return true;
}
}
return false;
}
function refundTransaction(bool _stateChanged) internal {
if (_stateChanged) {
msg.sender.transfer(msg.value);
} else {
revert();
}
}
function calculateMaxContribution(address _contributor) constant public returns (uint maxContribution) {
uint maxContrib;
if (crowdsaleState == state.priorityPass) {
maxContrib = priorityPassContract.getAccountLimit(_contributor) - contributorList[_contributor].contributionAmount;
if (maxContrib > (maxP1Cap - ethRaised)) {
maxContrib = maxP1Cap - ethRaised;
}
} else {
maxContrib = maxCap - ethRaised;
}
return maxContrib;
}
function processTransaction(address _contributor, uint _amount) internal {
uint maxContribution = calculateMaxContribution(_contributor);
uint contributionAmount = _amount;
uint returnAmount = 0;
if (maxContribution < _amount) {
contributionAmount = maxContribution;
returnAmount = _amount - maxContribution;
}
if (ethRaised + contributionAmount >= minCap && minCap > ethRaised) {
MinCapReached(block.timestamp);
}
if (contributorList[_contributor].contributionAmount == 0) {
contributorList[_contributor].contributionAmount = contributionAmount;
contributorIndexes[nextContributorIndex] = _contributor;
nextContributorIndex++;
} else {
contributorList[_contributor].contributionAmount += contributionAmount;
}
ethRaised += contributionAmount;
ContributionMade(msg.sender, contributionAmount);
if (returnAmount != 0) {
_contributor.transfer(returnAmount);
}
}
function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public {
ERC20TokenInterface(_tokenAddress).transfer(_to, _amount);
}
function withdrawEth() onlyOwner public {
require(this.balance != 0);
require(ethRaised >= minCap);
pendingEthWithdrawal = this.balance;
}
uint public pendingEthWithdrawal;
function pullBalance() public {
require(msg.sender == multisigAddress);
require(pendingEthWithdrawal > 0);
multisigAddress.transfer(pendingEthWithdrawal);
pendingEthWithdrawal = 0;
}
function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public {
require(block.timestamp > crowdsaleEndedTime && ethRaised < minCap);
address currentParticipantAddress;
uint contribution;
for (uint cnt = 0; cnt < _numberOfReturns; cnt++) {
currentParticipantAddress = contributorIndexes[nextContributorToClaim];
if (currentParticipantAddress == 0x0) {
return;
}
if (!hasClaimedEthWhenFail[currentParticipantAddress]) {
contribution = contributorList[currentParticipantAddress].contributionAmount;
hasClaimedEthWhenFail[currentParticipantAddress] = true;
if (!currentParticipantAddress.send(contribution)) {
ErrorSendingETH(currentParticipantAddress, contribution);
}
}
nextContributorToClaim += 1;
}
}
function withdrawRemainingBalanceForManualRecovery() onlyOwner public {
require(this.balance != 0);
require(block.timestamp > crowdsaleEndedTime);
require(contributorIndexes[nextContributorToClaim] == 0x0);
multisigAddress.transfer(this.balance);
}
function setMultisigAddress(address _newAddress) onlyOwner public {
multisigAddress = _newAddress;
}
function setPriorityPassContract(address _newAddress) onlyOwner public {
priorityPassContract = PriorityPassInterface(_newAddress);
}
function priorityPassContractAddress() constant public returns (address) {
return address(priorityPassContract);
}
function setCrowdsaleTimes(uint _presaleStartTime, uint _presaleUnlimitedStartTime, uint _crowdsaleEndedTime) onlyOwner public {
require(crowdsaleState == state.pendingStart);
require(_presaleStartTime != 0);
require(_presaleStartTime < _presaleUnlimitedStartTime);
require(_presaleUnlimitedStartTime != 0);
require(_presaleUnlimitedStartTime < _crowdsaleEndedTime);
require(_crowdsaleEndedTime != 0);
presaleStartTime = _presaleStartTime;
presaleUnlimitedStartTime = _presaleUnlimitedStartTime;
crowdsaleEndedTime = _crowdsaleEndedTime;
}
}
contract LegacySeedCrowdsale is SeedCrowdsaleContract {
function LegacySeedCrowdsale() {
presaleStartTime = 1512032400;
presaleUnlimitedStartTime = 1512063000;
crowdsaleEndedTime = 1512140400;
minCap = 356 ether;
maxP1Cap = 748 ether;
maxCap = 831 ether;
}
} | 0 |
pragma solidity ^0.4.18;
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract Mainsale {
using SafeMath for uint256;
address public owner;
address public multisig;
uint256 public endTimestamp;
uint256 public totalRaised;
uint256 public constant hardCap = 19333 ether;
uint256 public constant MIN_CONTRIBUTION = 0.1 ether;
uint256 public constant MAX_CONTRIBUTION = 1000 ether;
uint256 public constant THIRTY_DAYS = 60 * 60 * 24 * 30;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier belowCap() {
require(totalRaised < hardCap);
_;
}
modifier withinTimeLimit() {
require(block.timestamp <= endTimestamp);
_;
}
function Mainsale(address _multisig, uint256 _endTimestamp) {
require (_multisig != 0 && _endTimestamp >= (block.timestamp + THIRTY_DAYS));
owner = msg.sender;
multisig = _multisig;
endTimestamp = _endTimestamp;
}
function() payable belowCap withinTimeLimit {
require(msg.value >= MIN_CONTRIBUTION && msg.value <= MAX_CONTRIBUTION);
totalRaised = totalRaised.add(msg.value);
uint contribution = msg.value;
if (totalRaised > hardCap) {
uint refundAmount = totalRaised.sub(hardCap);
msg.sender.transfer(refundAmount);
contribution = contribution.sub(refundAmount);
refundAmount = 0;
totalRaised = hardCap;
}
multisig.transfer(contribution);
}
function withdrawStuck() onlyOwner {
multisig.transfer(this.balance);
}
} | 1 |
pragma solidity ^0.4.21;
contract Owned {
address public owner;
address internal newOwner;
function Owned() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
event updateOwner(address _oldOwner, address _newOwner);
function changeOwner(address _newOwner) public onlyOwner returns(bool) {
require(owner != _newOwner);
newOwner = _newOwner;
return true;
}
function acceptNewOwner() public returns(bool) {
require(msg.sender == newOwner);
emit updateOwner(owner, newOwner);
owner = newOwner;
return true;
}
}
library SafeMath {
function mul(uint a, uint b) internal pure returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint a, uint b) internal pure returns (uint) {
uint c = a / b;
return c;
}
function sub(uint a, uint b) internal pure returns (uint) {
assert(b <= a);
return a - b;
}
function add(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
assert(c >= a);
return c;
}
}
contract tokenRecipient {
function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public;
}
contract ERC20Token {
uint256 public totalSupply;
function balanceOf(address _owner) constant public 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) constant public 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 ERC20Token {
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowances;
function balanceOf(address _owner) constant public returns (uint256) {
return balances[_owner];
}
function transfer(address _to, uint256 _value)
public
returns (bool success)
{
require (balances[msg.sender] >= _value);
require (balances[_to] + _value >= balances[_to]);
balances[msg.sender] -= _value;
balances[_to] += _value;
emit Transfer(msg.sender, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
require(balances[msg.sender] >= _value);
allowances[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
approve(_spender, _value);
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require (balances[_from] >= _value);
require (balances[_to] + _value >= balances[_to]);
require (_value <= allowances[_from][msg.sender]);
balances[_from] -= _value;
balances[_to] += _value;
allowances[_from][msg.sender] -= _value;
emit Transfer(_from, _to, _value);
return true;
}
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowances[_owner][_spender];
}
}
contract KODB is standardToken, Owned {
using SafeMath for uint;
string public name="kingdom of develop blockchain";
string public symbol="KODB";
uint256 public decimals=18;
uint256 public totalSupply = 0;
uint256 public topTotalSupply = 1*10**8*10**decimals;
function() public payable {
revert();
}
function KODB(address _tokenAlloc) public {
owner=msg.sender;
balances[_tokenAlloc] = topTotalSupply;
totalSupply = topTotalSupply;
emit Transfer(0x0, _tokenAlloc, topTotalSupply);
}
} | 1 |
pragma solidity ^0.5.8;
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;
}
}
interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
function _balanceOf(address owner) view internal returns (uint256) {
return _balances[owner];
}
function allowance(address owner, address spender) public view returns (uint256) {
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value) public returns (bool) {
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
emit Approval(from, msg.sender, _allowed[from][msg.sender]);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function _transfer(address from, address to, uint256 value) internal {
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
function _mint(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
function _burn(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
function _burnFrom(address account, uint256 value) internal {
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
emit Approval(account, msg.sender, _allowed[account][msg.sender]);
}
}
contract ContractReceiver {
function tokenFallback(address _from, uint _value, bytes memory _data) public returns (bool);
}
contract ForeignToken {
function balanceOf(address _owner) public returns (uint256);
function transfer(address _to, uint256 _value) public returns (bool);
}
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 WiseNetwork is ERC20, ERC20Detailed {
uint256 public burned;
address payable public owner;
string private constant NAME = "Wise Network";
string private constant SYMBOL = "WISE";
uint8 private constant DECIMALS = 18;
uint256 private constant INITIAL_SUPPLY = 1 * 10**8 * 10**18;
event Donate(address indexed account, uint256 amount);
event ApproveAndCall(address _sender,uint256 _value,bytes _extraData);
event Transfer2Contract(address indexed from, address indexed to, uint256 value, bytes indexed data);
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
constructor () public ERC20Detailed(NAME, SYMBOL, DECIMALS) {
_mint(msg.sender, INITIAL_SUPPLY);
owner = msg.sender;
}
function burn(uint256 _value) public returns(bool) {
burned = burned.add(_value);
_burn(msg.sender, _value);
return true;
}
function transferOwnership(address payable _account) onlyOwner public returns(bool){
require(_account != address(0));
owner = _account;
return true;
}
function getTokenBalance(address tokenAddress, address who) public returns (uint){
ForeignToken t = ForeignToken(tokenAddress);
uint bal = t.balanceOf(who);
return bal;
}
function withdraw(uint256 _amount) onlyOwner public {
require(_amount <= address(this).balance);
uint256 etherBalance = _amount;
owner.transfer(etherBalance);
}
function withdrawForeignTokens(address _tokenContract, uint256 _amount) onlyOwner public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
require(_amount <= amount);
(bool success,) = _tokenContract.call(abi.encodeWithSignature("transfer(address,uint256)", owner, _amount));
require(success == true);
return true;
}
function() external payable{
emit Donate(msg.sender, msg.value);
}
function isContract(address _addr) internal view returns (bool) {
uint length;
assembly {
length := extcodesize(_addr)
}
return (length>0);
}
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) {
bytes memory empty;
if(isContract(_to)) {
return transferToContract(_to, _amount, empty);
}else {
_transfer(msg.sender, _to, _amount);
return true;
}
}
function transfer(address _to, uint256 _amount, bytes memory _data, string memory _custom_fallback) onlyPayloadSize(2 * 32) public returns (bool success) {
require(msg.sender != _to);
if(isContract(_to)) {
_transfer(msg.sender, _to, _amount);
ContractReceiver receiver = ContractReceiver(_to);
(bool success1,) = address(receiver).call(abi.encodeWithSignature(_custom_fallback, msg.sender, _amount, _data));
require(success1 == true);
emit Transfer2Contract(msg.sender, _to, _amount, _data);
return true;
}
else {
_transfer(msg.sender, _to, _amount);
return true;
}
}
function transfer(address _to, uint256 _amount, bytes memory _data) onlyPayloadSize(2 * 32) public returns (bool success) {
require(msg.sender != _to);
if(isContract(_to)) {
return transferToContract(_to, _amount, _data);
}
else {
_transfer(msg.sender, _to, _amount);
return true;
}
}
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) payable public returns (bool) {
approve(_spender, _value);
(bool success1,) = msg.sender.call(abi.encodeWithSignature("receiveApproval(address,uint256,address,bytes)", msg.sender, _value, this, _extraData));
require(success1 == true);
emit ApproveAndCall(_spender, _value, _extraData);
return true;
}
function transferToContract(address _to, uint _value, bytes memory _data) private returns (bool) {
_transfer(msg.sender, _to, _value);
ContractReceiver receiver = ContractReceiver(_to);
receiver.tokenFallback(msg.sender, _value, _data);
emit Transfer2Contract(msg.sender, _to, _value, _data);
return true;
}
} | 1 |
pragma solidity ^0.4.18;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract token {
function balanceOf(address _owner) public constant returns (uint256 balance);
function transfer(address _to, uint256 _value) public returns (bool success);
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public{
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract lockEtherPay is Ownable {
using SafeMath for uint256;
token token_reward;
address public beneficiary;
bool public isLocked = false;
bool public isReleased = false;
uint256 public start_time;
uint256 public end_time;
uint256 public fifty_two_weeks = 30326400
;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0xB57f895D5A2E8b68763f395c4D94119EF161883f ;
}
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.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);
string public constant symbol = "";
}
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 ERC20Token is StandardToken {
function () {
throw;
}
string public name;
uint8 public decimals;
string public symbol;
string public version = 'H1.0';
function ERC20Token(
) {
balances[msg.sender] = 10000000000000;
totalSupply = 10000000000000;
name = "BTCC";
decimals = 4;
symbol = "BTCC";
}
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.18;
contract EIP20Interface {
uint256 public totalSupply;
function balanceOf(address _owner) public view returns (uint256 balance);
function transfer(address _to, uint256 _value) public returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
function approve(address _spender, uint256 _value) public returns (bool success);
function allowance(address _owner, address _spender) public view returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract Divineum is EIP20Interface {
uint256 constant private MAX_UINT256 = 2**256 - 1;
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
string public name;
uint8 public decimals;
string public symbol;
function Divineum(
uint256 _initialAmount,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol
) public {
balances[msg.sender] = _initialAmount;
totalSupply = _initialAmount;
name = _tokenName;
decimals = _decimalUnits;
symbol = _tokenSymbol;
}
function transfer(address _to, uint256 _value) public 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) public returns (bool success) {
uint256 allowance = allowed[_from][msg.sender];
require(balances[_from] >= _value && allowance >= _value);
balances[_to] += _value;
balances[_from] -= _value;
if (allowance < MAX_UINT256) {
allowed[_from][msg.sender] -= _value;
}
Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) public returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | 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 = 29980800;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0xF2C7722774D5FbF0A630Fbd12cF3C78b70441e84;
}
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;
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 {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) constant returns (uint256);
function transfer(address to, uint256 value) returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract 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) {
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) 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) {
require(_to != address(0));
var _allowance = allowed[_from][msg.sender];
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
function 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];
}
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 MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
function mint(address _to, uint256 _amount) onlyOwner canMint returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(0x0, _to, _amount);
return true;
}
function finishMinting() onlyOwner returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
}
contract Crowdsale {
using SafeMath for uint256;
MintableToken public token;
uint256 public startBlock;
uint256 public endBlock;
address public wallet;
uint256 public weiRaised;
uint256 public rate;
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function Crowdsale(uint256 _startBlock, uint256 _endBlock, address _wallet) {
require(_startBlock >= block.number);
require(_endBlock >= _startBlock);
require(_wallet != 0x0);
token = createTokenContract();
startBlock = _startBlock;
endBlock = _endBlock;
wallet = _wallet;
}
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
function () payable {
buyTokens(msg.sender);
}
function buyTokens(address beneficiary) public payable {
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
function forwardFunds() internal {
wallet.transfer(msg.value);
}
function validPurchase() internal constant returns (bool) {
bool withinPeriod = block.number >= startBlock && block.number <= endBlock;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
function hasEnded() public constant returns (bool) {
return block.number > endBlock;
}
}
contract CappedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public cap;
function CappedCrowdsale(uint256 _cap) {
require(_cap > 0);
cap = _cap;
}
function validPurchase() internal constant returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
return super.validPurchase() && withinCap;
}
function hasEnded() public constant returns (bool) {
bool capReached = weiRaised >= cap;
return super.hasEnded() || capReached;
}
}
contract FinalizableCrowdsale is Crowdsale, Ownable {
using SafeMath for uint256;
bool public isFinalized = false;
event Finalized();
function finalize() onlyOwner {
require(!isFinalized);
require(hasEnded());
finalization();
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);
function RefundVault(address _wallet) {
require(_wallet != 0x0);
wallet = _wallet;
state = State.Active;
}
function deposit(address investor) onlyOwner payable {
require(state == State.Active);
deposited[investor] = deposited[investor].add(msg.value);
}
function close() onlyOwner {
require(state == State.Active);
state = State.Closed;
Closed();
wallet.transfer(this.balance);
}
function enableRefunds() onlyOwner {
require(state == State.Active);
state = State.Refunding;
RefundsEnabled();
}
function refund(address investor) {
require(state == State.Refunding);
uint256 depositedValue = deposited[investor];
deposited[investor] = 0;
investor.transfer(depositedValue);
Refunded(investor, depositedValue);
}
}
contract RefundableCrowdsale is FinalizableCrowdsale {
using SafeMath for uint256;
uint256 public goal;
RefundVault public vault;
function RefundableCrowdsale(uint256 _goal) {
require(_goal > 0);
vault = new RefundVault(wallet);
goal = _goal;
}
function forwardFunds() internal {
vault.deposit.value(msg.value)(msg.sender);
}
function claimRefund() {
require(isFinalized);
require(!goalReached());
vault.refund(msg.sender);
}
function finalization() internal {
if (goalReached()) {
vault.close();
} else {
vault.enableRefunds();
}
super.finalization();
}
function goalReached() public constant returns (bool) {
return weiRaised >= goal;
}
}
contract GlobCoinToken is MintableToken {
using SafeMath for uint256;
string public constant name = "GlobCoin Crypto Platform";
string public constant symbol = "GCP";
uint8 public constant decimals = 18;
modifier onlyMintingFinished() {
require(mintingFinished == true);
_;
}
function approve(address _spender, uint256 _value) public onlyMintingFinished returns (bool) {
return super.approve(_spender, _value);
}
function transfer(address _to, uint256 _value) public onlyMintingFinished returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public onlyMintingFinished returns (bool) {
return super.transferFrom(_from, _to, _value);
}
}
contract GlobcoinTokenSale is CappedCrowdsale, RefundableCrowdsale {
uint256 public startSale;
uint256 public endPresale;
uint256 public constant PRESALERATE = 17000;
uint256 public constant RATE1 = 13000;
uint256 public constant RATE2 = 12000;
uint256 public constant RATE3 = 11000;
uint256 public constant RATE4 = 10000;
uint256 public constant TIER1 = 3000000000000000000000;
uint256 public constant TIER2 = 5000000000000000000000;
uint256 public constant TIER3 = 7500000000000000000000;
uint256 public weiRaisedPreSale;
uint256 public presaleCap;
function GlobcoinTokenSale(uint256 _startBlock, uint256 _endPresale, uint256 _startSale, uint256 _endBlock, uint256 _goal,uint256 _presaleCap, uint256 _cap, address _wallet) public
CappedCrowdsale(_cap) FinalizableCrowdsale() RefundableCrowdsale(_goal) Crowdsale(_startBlock, _endBlock, _wallet) {
require(_goal <= _cap);
require(_startSale > _startBlock);
require(_endBlock > _startSale);
require(_presaleCap > 0);
require(_presaleCap <= _cap);
startSale = _startSale;
endPresale = _endPresale;
presaleCap = _presaleCap;
}
function createTokenContract() internal returns (MintableToken) {
return new GlobCoinToken();
}
mapping (address => bool) public whiteListedAddress;
mapping (address => bool) public whiteListedAddressPresale;
modifier onlyPresaleWhitelisted() {
require( isWhitelistedPresale(msg.sender) ) ;
_;
}
modifier onlyWhitelisted() {
require( isWhitelisted(msg.sender) || isWhitelistedPresale(msg.sender) ) ;
_;
}
function whitelistAddresses( address[] _users) onlyOwner {
for( uint i = 0 ; i < _users.length ; i++ ) {
whiteListedAddress[_users[i]] = true;
}
}
function unwhitelistAddress( address _users) onlyOwner {
whiteListedAddress[_users] = false;
}
function whitelistAddressesPresale( address[] _users) onlyOwner {
for( uint i = 0 ; i < _users.length ; i++ ) {
whiteListedAddressPresale[_users[i]] = true;
}
}
function unwhitelistAddressPresale( address _users) onlyOwner {
whiteListedAddressPresale[_users] = false;
}
function isWhitelisted(address _user) public constant returns (bool) {
return whiteListedAddress[_user];
}
function isWhitelistedPresale(address _user) public constant returns (bool) {
return whiteListedAddressPresale[_user];
}
function () payable {
if (validPurchasePresale()){
buyTokensPresale(msg.sender);
} else {
buyTokens(msg.sender);
}
}
function buyTokens(address beneficiary) payable onlyWhitelisted {
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
uint256 tokens = calculateTokenAmount(weiAmount);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
function buyTokensPresale(address beneficiary) payable onlyPresaleWhitelisted {
require(beneficiary != 0x0);
require(validPurchasePresale());
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(PRESALERATE);
weiRaisedPreSale = weiRaisedPreSale.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
function calculateTokenAmount(uint256 weiAmount) internal returns (uint256){
uint256 amountToBuy = weiAmount;
uint256 amountTokenBought;
uint256 currentWeiRaised = weiRaised;
if (currentWeiRaised < TIER1 && amountToBuy > 0) {
var (amountBoughtInTier, amountLeftTobuy) = calculateAmountPerTier(amountToBuy,TIER1,RATE1,currentWeiRaised);
amountTokenBought = amountTokenBought.add(amountBoughtInTier);
currentWeiRaised = currentWeiRaised.add(amountToBuy.sub(amountLeftTobuy));
amountToBuy = amountLeftTobuy;
}
if (currentWeiRaised < TIER2 && amountToBuy > 0) {
(amountBoughtInTier, amountLeftTobuy) = calculateAmountPerTier(amountToBuy,TIER2,RATE2,currentWeiRaised);
amountTokenBought = amountTokenBought.add(amountBoughtInTier);
currentWeiRaised = currentWeiRaised.add(amountToBuy.sub(amountLeftTobuy));
amountToBuy = amountLeftTobuy;
}
if (currentWeiRaised < TIER3 && amountToBuy > 0) {
(amountBoughtInTier, amountLeftTobuy) = calculateAmountPerTier(amountToBuy,TIER3,RATE3,currentWeiRaised);
amountTokenBought = amountTokenBought.add(amountBoughtInTier);
currentWeiRaised = currentWeiRaised.add(amountToBuy.sub(amountLeftTobuy));
amountToBuy = amountLeftTobuy;
}
if ( currentWeiRaised < cap && amountToBuy > 0) {
(amountBoughtInTier, amountLeftTobuy) = calculateAmountPerTier(amountToBuy,cap,RATE4,currentWeiRaised);
amountTokenBought = amountTokenBought.add(amountBoughtInTier);
currentWeiRaised = currentWeiRaised.add(amountToBuy.sub(amountLeftTobuy));
amountToBuy = amountLeftTobuy;
}
return amountTokenBought;
}
function calculateAmountPerTier(uint256 amountToBuy,uint256 tier,uint256 rate,uint256 currentWeiRaised) internal returns (uint256,uint256) {
uint256 amountAvailable = tier.sub(currentWeiRaised);
if ( amountToBuy > amountAvailable ) {
uint256 amountBoughtInTier = amountAvailable.mul(rate);
amountToBuy = amountToBuy.sub(amountAvailable);
return (amountBoughtInTier,amountToBuy);
} else {
amountBoughtInTier = amountToBuy.mul(rate);
return (amountBoughtInTier,0);
}
}
function finalization() internal {
if (goalReached()) {
uint256 totalSupply = token.totalSupply();
token.mint(wallet, totalSupply);
token.mint(wallet, totalSupply.div(2));
token.finishMinting();
}
super.finalization();
}
function validPurchase() internal constant returns (bool) {
bool withinPeriod = block.number >= startSale && block.number <= endBlock;
bool nonZeroPurchase = msg.value != 0;
uint256 totalWeiRaised = weiRaisedPreSale.add(weiRaised);
bool withinCap = totalWeiRaised.add(msg.value) <= cap;
return withinCap && withinPeriod && nonZeroPurchase;
}
function validPurchasePresale() internal constant returns (bool) {
bool withinPeriod = (block.number >= startBlock) && (block.number <= endPresale);
bool nonZeroPurchase = msg.value != 0;
bool withinCap = weiRaisedPreSale.add(msg.value) <= presaleCap;
return withinPeriod && nonZeroPurchase && withinCap;
}
function goalReached() public constant returns (bool) {
uint256 totalWeiRaised = weiRaisedPreSale.add(weiRaised);
return totalWeiRaised >= goal || super.goalReached();
}
} | 1 |
pragma solidity ^0.4.21;
contract SafeMath {
function safeMul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function safeSub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract Ownable {
address public owner;
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwner(address newOwner) public onlyOwner {
owner = newOwner;
}
}
contract Lockable is Ownable {
bool public contractLocked = false;
modifier notLocked() {
require(!contractLocked);
_;
}
function lockContract() public onlyOwner {
contractLocked = true;
}
function unlockContract() public onlyOwner {
contractLocked = false;
}
}
contract FeeCalculator is Ownable, SafeMath {
uint public feeNumerator = 0;
uint public feeDenominator = 0;
uint public minFee = 0;
uint public maxFee = 0;
function setFee(uint _feeNumerator, uint _feeDenominator, uint _minFee, uint _maxFee) public onlyOwner {
feeNumerator = _feeNumerator;
feeDenominator = _feeDenominator;
minFee = _minFee;
maxFee = _maxFee;
}
function calculateFee(uint value) public view returns (uint requiredFee) {
if (feeNumerator == 0 || feeDenominator == 0) return 0;
uint fee = safeDiv(safeMul(value, feeNumerator), feeDenominator);
if (fee < minFee) return minFee;
if (fee > maxFee) return maxFee;
return fee;
}
function subtractFee(uint value) internal returns (uint newValue);
}
contract EIP20Interface {
uint256 public totalSupply;
function balanceOf(address owner) public view returns (uint256 balance);
function transfer(address to, uint256 value) public returns (bool success);
function transferFrom(address from, address to, uint256 value) public returns (bool success);
function approve(address spender, uint256 value) public returns (bool success);
function allowance(address owner, address spender) public view returns (uint256 remaining);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract Mintable is Ownable {
mapping(address => bool) public minters;
modifier onlyMinter {
require(minters[msg.sender] == true);
_;
}
function Mintable() public {
adjustMinter(msg.sender, true);
}
function adjustMinter(address minter, bool canMint) public onlyOwner {
minters[minter] = canMint;
}
function mint(address to, uint256 value) public;
}
contract Token is EIP20Interface, Ownable, SafeMath, Mintable, Lockable, FeeCalculator {
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowed;
mapping(address => bool) frozenAddresses;
string public name;
uint8 public decimals;
string public symbol;
bool public isBurnable;
bool public canAnyoneBurn;
modifier notFrozen(address target) {
require(!frozenAddresses[target]);
_;
}
event AddressFroze(address target, bool isFrozen);
function Token(string _name, uint8 _decimals, string _symbol) public {
name = _name;
decimals = _decimals;
symbol = _symbol;
}
function transfer(address to, uint256 value) notLocked notFrozen(msg.sender) public returns (bool success) {
return transfer(msg.sender, to, value);
}
function transfer(address from, address to, uint256 value) internal returns (bool success) {
balances[from] = safeSub(balances[from], value);
value = subtractFee(value);
balances[to] = safeAdd(balances[to], value);
emit Transfer(from, to, value);
return true;
}
function transferFrom(address from, address to, uint256 value) notLocked notFrozen(from) public returns (bool success) {
uint256 allowance = allowed[from][msg.sender];
balances[from] = safeSub(balances[from], value);
allowed[from][msg.sender] = safeSub(allowance, value);
value = subtractFee(value);
balances[to] = safeAdd(balances[to], value);
emit Transfer(from, to, value);
return true;
}
function balanceOf(address owner) public view returns (uint256 balance) {
return balances[owner];
}
function approve(address spender, uint256 value) notLocked public returns (bool success) {
allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function allowance(address owner, address spender) public view returns (uint256 remaining) {
return allowed[owner][spender];
}
function freezeAddress(address target, bool freeze) onlyOwner public {
if (freeze) {
frozenAddresses[target] = true;
} else {
delete frozenAddresses[target];
}
emit AddressFroze(target, freeze);
}
function isAddressFrozen(address target) public view returns (bool frozen){
return frozenAddresses[target];
}
function mint(address to, uint256 value) public onlyMinter {
totalSupply = safeAdd(totalSupply, value);
balances[to] = safeAdd(balances[to], value);
emit Transfer(0x0, to, value);
}
function subtractFee(uint value) internal returns (uint newValue) {
uint feeToTake = calculateFee(value);
if (feeToTake == 0) return value;
balances[this] = safeAdd(balances[this], feeToTake);
return value - feeToTake;
}
function withdrawFees(address to) onlyOwner public returns (bool success) {
return transfer(this, to, balances[this]);
}
function burn(uint256 value) public returns (bool success) {
require(isBurnable);
if (!canAnyoneBurn && msg.sender != owner) {
return false;
}
balances[msg.sender] = safeSub(balances[msg.sender], value);
totalSupply = totalSupply - value;
return true;
}
}
contract Crowdsale is Ownable, SafeMath {
uint256 public startBlock;
uint256 public endBlock;
uint256 public maxGasPrice;
uint256 public exchangeRate;
uint256 public maxSupply;
mapping(address => uint256) public participants;
Token public token;
address private wallet;
bool private initialised;
modifier participationOpen {
require(block.number >= startBlock);
require(block.number <= endBlock);
_;
}
function initialise(address _wallet, uint256 _startBlock, uint256 _endBlock, uint256 _maxGasPrice,
uint256 _exchangeRate, uint256 _maxSupply, string _name, uint8 _decimals, string _symbol) public onlyOwner returns (address tokenAddress) {
if (token == address(0x0)) {
token = newToken(_name, _decimals, _symbol);
token.transferOwner(owner);
}
wallet = _wallet;
startBlock = _startBlock;
endBlock = _endBlock;
maxGasPrice = _maxGasPrice;
exchangeRate = _exchangeRate;
maxSupply = _maxSupply;
initialised = true;
return token;
}
function newToken(string _name, uint8 _decimals, string _symbol) internal returns (Token){
return new Token(_name, _decimals, _symbol);
}
function() public payable {
participate(msg.sender, msg.value);
}
function participate(address participant, uint256 value) internal participationOpen {
require(participant != address(0x0));
require(tx.gasprice <= maxGasPrice);
require(initialised);
uint256 totalSupply = token.totalSupply();
require(totalSupply < maxSupply);
uint256 tokenCount = safeMul(value, exchangeRate);
uint256 remaining = 0;
uint256 newTotalSupply = safeAdd(totalSupply, tokenCount);
if (newTotalSupply > maxSupply) {
uint256 newTokenCount = newTotalSupply - maxSupply;
remaining = safeDiv(tokenCount - newTokenCount, exchangeRate);
tokenCount = newTokenCount;
}
if (remaining > 0) {
msg.sender.transfer(remaining);
value = safeSub(value, remaining);
}
msg.sender.transfer(value);
safeAdd(participants[participant], tokenCount);
token.mint(msg.sender, tokenCount);
}
} | 0 |
pragma solidity ^0.4.23;
contract owned {
address public owner;
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
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 = 8;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
function 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 MMCoin is owned, TokenERC20 {
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
function MMCoin(
uint256 initialSupply,
string tokenName,
string tokenSymbol
) TokenERC20(initialSupply, tokenName, tokenSymbol) 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);
}
} | 1 |
pragma solidity ^0.4.24;
contract SafeMath {
function safeAdd(uint a, uint b) public pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) public pure returns (uint c) {
require(b <= a);
c = a - b;
}
function safeMul(uint a, uint b) public pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function safeDiv(uint a, uint b) public pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
contract ERC20Interface {
function totalSupply() public constant returns (uint);
function balanceOf(address tokenOwner) public constant returns (uint balance);
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
}
contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
contract againstCoin is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
string public description;
uint8 public decimals;
uint public _totalSupply;
bool mainNet = true;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
constructor() public {
symbol = "AGAINST";
name = "AGAINST Coin";
description = "Fully Decentralized Currency";
decimals = 18;
_totalSupply = 1000000000000*(10**18);
if (mainNet) {
balances[0x4d717d48BB24Af867B5efC91b282264Aae83cFa6] = _totalSupply;
emit Transfer(address(0), 0x4d717d48BB24Af867B5efC91b282264Aae83cFa6, _totalSupply);
} else {
balances[0x9522b4A0a36470E7D8cAe732b6e5BCC5944875cF] = _totalSupply;
emit Transfer(address(0), 0x9522b4A0a36470E7D8cAe732b6e5BCC5944875cF, _totalSupply);
}
}
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
function () public payable {
revert();
}
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | 1 |
pragma solidity ^0.4.21 ;
contract RUSS_PFXXX_II_883 {
mapping (address => uint256) public balanceOf;
string public name = " RUSS_PFXXX_II_883 " ;
string public symbol = " RUSS_PFXXX_II_IMTD " ;
uint8 public decimals = 18 ;
uint256 public totalSupply = 796077025090406000000000000 ;
event Transfer(address indexed from, address indexed to, uint256 value);
function SimpleERC20Token() public {
balanceOf[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
function transfer(address to, uint256 value) public returns (bool success) {
require(balanceOf[msg.sender] >= value);
balanceOf[msg.sender] -= value;
balanceOf[to] += value;
emit Transfer(msg.sender, to, value);
return true;
}
event Approval(address indexed owner, address indexed spender, uint256 value);
mapping(address => mapping(address => uint256)) public allowance;
function approve(address spender, uint256 value)
public
returns (bool success)
{
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value)
public
returns (bool success)
{
require(value <= balanceOf[from]);
require(value <= allowance[from][msg.sender]);
balanceOf[from] -= value;
balanceOf[to] += value;
allowance[from][msg.sender] -= value;
emit Transfer(from, to, value);
return true;
}
} | 1 |
pragma solidity ^0.4.18;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
}
contract S26 is MintableToken {
string public name = "SuperGidron26";
string public symbol = "S26";
uint public decimals = 6;
bool public tokensBlocked = true;
mapping (address => uint) public teamTokensFreeze;
event debugLog(string key, uint value);
function unblock() external onlyOwner {
tokensBlocked = false;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(!tokensBlocked);
require(allowTokenOperations(_to));
require(allowTokenOperations(msg.sender));
super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(!tokensBlocked);
require(allowTokenOperations(_from));
require(allowTokenOperations(_to));
super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint256 _value) public returns (bool) {
require(!tokensBlocked);
require(allowTokenOperations(_spender));
super.approve(_spender, _value);
}
function freezeTokens(address _holder, uint time) public onlyOwner {
require(_holder != 0x0);
teamTokensFreeze[_holder] = time;
}
function allowTokenOperations(address _holder) public constant returns (bool) {
return teamTokensFreeze[_holder] == 0 || now >= teamTokensFreeze[_holder];
}
}
contract S26ICO {
using SafeMath for uint;
enum IcoState {Running, Paused, Failed, Finished}
bool public isSuccess = false;
address public owner = 0xfFFafD9849e0b678a879E92581e1eF4729C65d00;
address public wallet = 0xdDd1BB2F9BF1EEc3A11230de23b3e69Dee7665f8;
address public unsold = 0xffC7086F6dB8d9A1545eA643aaDf4Da96668fC60;
uint public constant startTime = 1529761145;
uint public endTime = startTime + 30 days;
uint public constant multiplier = 1000000;
uint private constant minTokens = 50;
uint public constant mln = 1000000;
uint public constant tokensCap = 99 * mln * multiplier;
uint public constant minSuccess = 2 * mln * multiplier;
uint public totalSupply = 0;
uint public tokensSoldTotal = 0;
IcoState public icoState = IcoState.Running;
uint private constant rateDivider = 1;
uint public priceInWei = 3046900000 / rateDivider;
address public _robot = 0x63b247db491D3d3E32A9629509Fb459386Aff921;
bool public tokensAreFrozen = true;
S26 public token;
struct TokensHolder {
uint value;
uint tokens;
uint bonus;
uint total;
uint rate;
uint change;
}
mapping (address => uint) public investors;
struct teamTokens {
address holder;
uint freezePeriod;
uint percent;
uint divider;
uint maxTokens;
}
teamTokens[] public listTeamTokens;
uint[] public bonusPatterns = [80, 60, 40, 20];
uint[] public bonusLimit = [5 * mln * multiplier, 10 * mln * multiplier, 15 * mln * multiplier, 20 * mln * multiplier];
bool public teamTokensGenerated = false;
modifier ICOActive {
require(icoState == IcoState.Running);
require(now >= (startTime));
require(now <= (endTime));
_;
}
modifier ICOFinished {
require(icoState == IcoState.Finished);
_;
}
modifier ICOFailed {
require(now >= (endTime));
require(icoState == IcoState.Failed || !isSuccess);
_;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyTeam() {
require(msg.sender == owner || msg.sender == _robot);
_;
}
modifier successICOState() {
require(isSuccess);
_;
}
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint value, uint amount);
event RunIco();
event PauseIco();
event SuccessIco();
event ICOFails();
event updateRate(uint time, uint rate);
event debugLog(string key, uint value);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function S26ICO() public {
token = new S26();
listTeamTokens.push(teamTokens(0xAaa1C6f83F2D6eab13aD341a2b3Ff8d8976fcE64, 182 days, 10, 1, 0));
listTeamTokens.push(teamTokens(0xAAa27079007bCe64f0a5B225FB0aFec175d69ca5, 1 years, 10, 1, 0));
listTeamTokens.push(teamTokens(0xAaa315b6640d2Af971C2Ab3a5c2af1209A8C0083, 0, 32, 10, 0));
listTeamTokens.push(teamTokens(0xAAA34a3F68e079DdaEf9566c5E7b1507F1d545B3, 0, 16, 10, 0));
listTeamTokens.push(teamTokens(0xaAa351aD60699729CaF0cc0812477Ee73d00a611, 0, 16, 10, 0));
listTeamTokens.push(teamTokens(0xaAA383c35390DC0E112CA5a46f768650F5C11C29, 0, 200, 1000, 0));
listTeamTokens.push(teamTokens(0xAaa3f9dE05E5d9c5CF2D79fDF99aBb8a9bE4b403, 0, 6670, 100000, 0));
listTeamTokens.push(teamTokens(0xaAa417D941a7c49d858451B423e83355d10b68C8, 1 years, 32, 10, 0));
listTeamTokens.push(teamTokens(0xAAa42b7755517Db92379D43a2C5a5161a0DBa5fe, 1 years, 16, 10, 0));
listTeamTokens.push(teamTokens(0xAAA47837A6751Ba35B9e9C52bD156a434b6a5B6a, 1 years, 16, 10, 0));
listTeamTokens.push(teamTokens(0xAaa485EC95febED46628FBEA1Cd6f8404378C90d, 1 years, 200, 1000, 0));
listTeamTokens.push(teamTokens(0xAaA52924D1F18d90148D45fa020DEB5F5f755E51, 1 years, 6670, 100000, 0));
listTeamTokens.push(teamTokens(0xAAa6e7638AF0dE4233101BE9841C8BD1890dd2e6, 2 years, 32, 10, 0));
listTeamTokens.push(teamTokens(0xAaa7fFb1e7E1f70e94bD35C61FBBd5681c06025c, 2 years, 16, 10, 0));
listTeamTokens.push(teamTokens(0xaaa92aab966fCC1de934aC700C4e8A322d51D561, 2 years, 16, 10, 0));
listTeamTokens.push(teamTokens(0xAaA95183da70778a93F7088A19A1A1c7Af3Bd154, 2 years, 200, 1000, 0));
listTeamTokens.push(teamTokens(0xAaa95a9b2Bc5A35Ffc49E6A62C6b71b76B1A61a7, 2 years, 6660, 100000, 0));
}
function() public payable ICOActive {
require(!isReachedLimit());
TokensHolder memory tokens = calculateTokens(msg.value);
require(tokens.total > 0);
token.mint(msg.sender, tokens.total);
TokenPurchase(msg.sender, msg.sender, tokens.value, tokens.total);
if (tokens.change > 0 && tokens.change <= msg.value) {
msg.sender.transfer(tokens.change);
}
investors[msg.sender] = investors[msg.sender].add(tokens.value);
addToStat(tokens.tokens, tokens.bonus);
manageStatus();
}
function hasStarted() public constant returns (bool) {
return now >= startTime;
}
function hasFinished() public constant returns (bool) {
return now >= endTime || isReachedLimit();
}
function getBonus(uint _value, uint _sold) internal constant returns (TokensHolder) {
TokensHolder memory result;
uint _bonus = 0;
result.tokens = _value;
for (uint8 i = 0; _value > 0 && i < bonusLimit.length; ++i) {
uint current_bonus_part = 0;
if (_value > 0 && _sold < bonusLimit[i]) {
uint bonus_left = bonusLimit[i] - _sold;
uint _bonusedPart = min(_value, bonus_left);
current_bonus_part = current_bonus_part.add(percent(_bonusedPart, bonusPatterns[i]));
_value = _value.sub(_bonusedPart);
_sold = _sold.add(_bonusedPart);
}
if (current_bonus_part > 0) {
_bonus = _bonus.add(current_bonus_part);
}
}
result.bonus = _bonus;
return result;
}
function isReachedLimit() internal constant returns (bool) {
return tokensCap.sub(totalSupply) == 0;
}
function manageStatus() internal {
if (totalSupply >= minSuccess && !isSuccess) {
successICO();
}
bool capIsReached = (totalSupply == tokensCap);
if (capIsReached || (now >= endTime)) {
if (!isSuccess) {
failICO();
}
else {
finishICO(false);
}
}
}
function calculateForValue(uint value) public constant returns (uint, uint, uint)
{
TokensHolder memory tokens = calculateTokens(value);
return (tokens.total, tokens.tokens, tokens.bonus);
}
function calculateTokens(uint value) internal constant returns (TokensHolder)
{
require(value > 0);
require(priceInWei * minTokens <= value);
uint tokens = value.div(priceInWei);
require(tokens > 0);
uint remain = tokensCap.sub(totalSupply);
uint change = 0;
uint value_clear = 0;
if (remain <= tokens) {
tokens = remain;
change = value.sub(tokens.mul(priceInWei));
value_clear = value.sub(change);
}
else {
value_clear = value;
}
TokensHolder memory bonus = getBonus(tokens, tokensSoldTotal);
uint total = tokens + bonus.bonus;
bonus.tokens = tokens;
bonus.total = total;
bonus.change = change;
bonus.rate = priceInWei;
bonus.value = value_clear;
return bonus;
}
function addToStat(uint tokens, uint bonus) internal {
uint total = tokens + bonus;
totalSupply = totalSupply.add(total);
tokensSoldTotal = tokensSoldTotal.add(tokens);
}
function startIco() external onlyOwner {
require(icoState == IcoState.Paused);
icoState = IcoState.Running;
RunIco();
}
function pauseIco() external onlyOwner {
require(icoState == IcoState.Running);
icoState = IcoState.Paused;
PauseIco();
}
function successICO() internal
{
isSuccess = true;
SuccessIco();
}
function finishICO(bool manualFinish) internal successICOState
{
if(!manualFinish) {
bool capIsReached = (totalSupply == tokensCap);
if (capIsReached && now < endTime) {
endTime = now;
}
} else {
endTime = now;
}
icoState = IcoState.Finished;
tokensAreFrozen = false;
token.unblock();
}
function failICO() internal
{
icoState = IcoState.Failed;
ICOFails();
}
function refund() public ICOFailed
{
require(msg.sender != 0x0);
require(investors[msg.sender] > 0);
uint refundVal = investors[msg.sender];
investors[msg.sender] = 0;
uint balance = token.balanceOf(msg.sender);
totalSupply = totalSupply.sub(balance);
msg.sender.transfer(refundVal);
}
function withdraw(uint value) external onlyOwner successICOState {
wallet.transfer(value);
}
function generateTeamTokens() internal ICOFinished {
require(!teamTokensGenerated);
teamTokensGenerated = true;
if(tokensCap > totalSupply) {
uint unsoldAmount = tokensCap.sub(totalSupply);
token.mint(unsold, unsoldAmount);
totalSupply = totalSupply.add(unsoldAmount);
}
uint totalSupplyTokens = totalSupply;
totalSupplyTokens = totalSupplyTokens.mul(100);
totalSupplyTokens = totalSupplyTokens.div(60);
for (uint8 i = 0; i < listTeamTokens.length; ++i) {
uint teamTokensPart = percent(totalSupplyTokens, listTeamTokens[i].percent);
if (listTeamTokens[i].divider != 0) {
teamTokensPart = teamTokensPart.div(listTeamTokens[i].divider);
}
if (listTeamTokens[i].maxTokens != 0 && listTeamTokens[i].maxTokens < teamTokensPart) {
teamTokensPart = listTeamTokens[i].maxTokens;
}
token.mint(listTeamTokens[i].holder, teamTokensPart);
if(listTeamTokens[i].freezePeriod != 0) {
token.freezeTokens(listTeamTokens[i].holder, endTime + listTeamTokens[i].freezePeriod);
}
addToStat(teamTokensPart, 0);
}
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
function setRobot(address robot) public onlyOwner {
require(robot != 0x0);
_robot = robot;
}
function setRate(uint newRate) public onlyTeam {
require(newRate > 0);
priceInWei = newRate;
updateRate(now, newRate);
}
function robotRefund(address investor) public onlyTeam ICOFailed
{
require(investor != 0x0);
require(investors[investor] > 0);
uint refundVal = investors[investor];
investors[investor] = 0;
uint balance = token.balanceOf(investor);
totalSupply = totalSupply.sub(balance);
investor.transfer(refundVal);
}
function manualFinish() public onlyTeam
{
require(!hasFinished());
finishICO(true);
generateTeamTokens();
}
function autoFinishTime() public onlyTeam
{
require(hasFinished());
manageStatus();
generateTeamTokens();
}
function min(uint a, uint b) internal pure returns (uint) {
return a < b ? a : b;
}
function percent(uint value, uint bonus) internal pure returns (uint) {
return (value * bonus).div(100);
}
} | 0 |
pragma solidity ^0.4.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 = 0x93963F57b07D15f9a42c7B2672c9c3cFB34f8D1e;
}
function tokenBalance() constant public returns (uint256){
return token_reward.balanceOf(this);
}
function lock() public onlyOwner returns (bool){
require(!isLocked);
require(tokenBalance() > 0);
start_time = now;
end_time = start_time.add(fifty_two_weeks);
isLocked = true;
}
function lockOver() constant public returns (bool){
uint256 current_time = now;
return current_time > end_time;
}
function release() onlyOwner public{
require(isLocked);
require(!isReleased);
require(lockOver());
uint256 token_amount = tokenBalance();
token_reward.transfer( beneficiary, token_amount);
emit TokenReleased(beneficiary, token_amount);
isReleased = true;
}
} | 0 |
pragma solidity ^0.4.13;
contract 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 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 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));
}
}
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
function transfer(address _to, uint256 _value) 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 BountyManager is Ownable {
using SafeMath for uint256;
Peculium public pecul;
bool public initPecul;
event InitializedToken(address contractToken);
address public bountymanager ;
uint256 public bountymanagerShare;
bool public First_pay_bountymanager;
uint256 public first_pay;
uint256 public montly_pay;
bool public bountyInit;
uint256 public payday;
uint256 public nbMonthsPay;
event InitializedManager(address ManagerAdd);
event FirstPaySend(uint256 first,address receiver);
event MonthlyPaySend(uint256 monthPay,address receiverMonthly);
function BountyManager() {
bountymanagerShare = SafeMath.mul(72000000,(10**8));
first_pay = SafeMath.div(SafeMath.mul(40,bountymanagerShare),100);
montly_pay = SafeMath.div(SafeMath.mul(10,bountymanagerShare),100);
nbMonthsPay = 0;
First_pay_bountymanager=true;
initPecul = false;
bountyInit==false;
}
function InitPeculiumAdress(address peculAdress) onlyOwner
{
pecul = Peculium(peculAdress);
payday = pecul.dateDefrost();
initPecul = true;
InitializedToken(peculAdress);
}
function change_bounty_manager (address public_key) onlyOwner
{
bountymanager = public_key;
bountyInit=true;
InitializedManager(public_key);
}
function transferManager() onlyOwner Initialize BountyManagerInit
{
require(now > payday);
if(First_pay_bountymanager==false && nbMonthsPay < 6)
{
pecul.transfer(bountymanager,montly_pay);
payday = payday.add( 31 days);
nbMonthsPay=nbMonthsPay.add(1);
MonthlyPaySend(montly_pay,bountymanager);
}
if(First_pay_bountymanager==true)
{
pecul.transfer(bountymanager,first_pay);
payday = payday.add( 35 days);
First_pay_bountymanager=false;
FirstPaySend(first_pay,bountymanager);
}
}
modifier Initialize {
require (initPecul==true);
_;
}
modifier BountyManagerInit {
require (bountyInit==true);
_;
}
}
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));
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) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract 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 Peculium is BurnableToken,Ownable {
using SafeMath for uint256;
using SafeERC20 for ERC20Basic;
string public name = "Peculium";
string public symbol = "PCL";
uint256 public decimals = 8;
uint256 public constant MAX_SUPPLY_NBTOKEN = 20000000000*10**8;
uint256 public dateStartContract;
mapping(address => bool) public balancesCanSell;
uint256 public dateDefrost;
event FrozenFunds(address target, bool frozen);
event Defroze(address msgAdd, bool freeze);
function Peculium() {
totalSupply = MAX_SUPPLY_NBTOKEN;
balances[owner] = totalSupply;
balancesCanSell[owner] = true;
dateStartContract=now;
dateDefrost = dateStartContract + 85 days;
}
function defrostToken() public
{
require(now>dateDefrost);
balancesCanSell[msg.sender]=true;
Defroze(msg.sender,true);
}
function transfer(address _to, uint256 _value) public returns (bool)
{
require(balancesCanSell[msg.sender]);
return BasicToken.transfer(_to,_value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
{
require(balancesCanSell[msg.sender]);
return StandardToken.transferFrom(_from,_to,_value);
}
function freezeAccount(address target, bool canSell) onlyOwner
{
balancesCanSell[target] = canSell;
FrozenFunds(target, canSell);
}
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;
}
function getBlockTimestamp() constant returns (uint256)
{
return now;
}
function getOwnerInfos() constant returns (address ownerAddr, uint256 ownerBalance)
{
ownerAddr = owner;
ownerBalance = balanceOf(ownerAddr);
}
} | 0 |
pragma solidity ^0.4.24;
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender)
public view returns (uint256);
function transferFrom(address from, address to, uint256 value)
public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
function increaseApproval(
address _spender,
uint _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(
address _spender,
uint _subtractedValue
)
public
returns (bool)
{
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
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 Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
contract PausableToken is StandardToken, Pausable {
function transfer(
address _to,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
return super.transfer(_to, _value);
}
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
function approve(
address _spender,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
return super.approve(_spender, _value);
}
function increaseApproval(
address _spender,
uint _addedValue
)
public
whenNotPaused
returns (bool success)
{
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(
address _spender,
uint _subtractedValue
)
public
whenNotPaused
returns (bool success)
{
return super.decreaseApproval(_spender, _subtractedValue);
}
}
contract DividendToken is StandardToken, Ownable {
using SafeMath for uint256;
uint256 public claimTimeout = 20 days;
uint256 public dividendCycleTime = 350 days;
uint256 public currentDividend;
mapping(address => uint256) unclaimedDividend;
mapping(address => uint256) public lastUpdate;
uint256 public lastDividendIncreaseDate;
mapping(address => bool) public isTreasurer;
uint256 public dividendEndTime = 0;
event Payin(address _owner, uint256 _value, uint256 _endTime);
event Payout(address _tokenHolder, uint256 _value);
event Reclaimed(uint256 remainingBalance, uint256 _endTime, uint256 _now);
event ChangedTreasurer(address treasurer, bool active);
constructor() public {
isTreasurer[owner] = true;
}
function claimDividend() public returns (bool) {
require(dividendEndTime > 0);
require(dividendEndTime.sub(claimTimeout) > block.timestamp);
updateDividend(msg.sender);
uint256 payment = unclaimedDividend[msg.sender];
unclaimedDividend[msg.sender] = 0;
msg.sender.transfer(payment);
emit Payout(msg.sender, payment);
return true;
}
function transferDividend(address _from, address _to, uint256 _value) internal {
updateDividend(_from);
updateDividend(_to);
uint256 transAmount = unclaimedDividend[_from].mul(_value).div(balanceOf(_from));
unclaimedDividend[_from] = unclaimedDividend[_from].sub(transAmount);
unclaimedDividend[_to] = unclaimedDividend[_to].add(transAmount);
}
function updateDividend(address _hodler) internal {
if (lastUpdate[_hodler] < lastDividendIncreaseDate) {
unclaimedDividend[_hodler] = calcDividend(_hodler, totalSupply_);
lastUpdate[_hodler] = block.timestamp;
}
}
function getClaimableDividend(address _hodler) public constant returns (uint256 claimableDividend) {
if (lastUpdate[_hodler] < lastDividendIncreaseDate) {
return calcDividend(_hodler, totalSupply_);
} else {
return (unclaimedDividend[_hodler]);
}
}
function transfer(address _to, uint256 _value) public returns (bool) {
transferDividend(msg.sender, _to, _value);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
transferDividend(_from, _to, _value);
return super.transferFrom(_from, _to, _value);
}
function setTreasurer(address _treasurer, bool _active) public onlyOwner {
isTreasurer[_treasurer] = _active;
emit ChangedTreasurer(_treasurer, _active);
}
function requestUnclaimed() public onlyOwner {
require(block.timestamp >= dividendEndTime.sub(claimTimeout));
msg.sender.transfer(address(this).balance);
emit Reclaimed(address(this).balance, dividendEndTime, block.timestamp);
}
function() public payable {
require(isTreasurer[msg.sender]);
require(dividendEndTime < block.timestamp);
if (address(this).balance > msg.value) {
uint256 payout = address(this).balance.sub(msg.value);
owner.transfer(payout);
emit Reclaimed(payout, dividendEndTime, block.timestamp);
}
currentDividend = address(this).balance;
dividendEndTime = block.timestamp.add(dividendCycleTime);
emit Payin(msg.sender, msg.value, dividendEndTime);
lastDividendIncreaseDate = block.timestamp;
}
function calcDividend(address _hodler, uint256 _totalSupply) public view returns(uint256) {
return (currentDividend.mul(balanceOf(_hodler))).div(_totalSupply);
}
}
contract TendToken is MintableToken, PausableToken, DividendToken {
using SafeMath for uint256;
string public constant name = "Tend Token";
string public constant symbol = "TTA";
uint8 public constant decimals = 18;
uint256 public granularity = 1e18;
constructor() public DividendToken() {
paused = true;
}
function requireMultiple(uint256 _amount) internal view {
require(_amount.div(granularity).mul(granularity) == _amount);
}
function transfer(address _to, uint256 _value) public returns (bool) {
requireMultiple(_value);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
requireMultiple(_value);
return super.transferFrom(_from, _to, _value);
}
function mint(address _to, uint256 _amount) public returns (bool) {
requireMultiple(_amount);
return super.mint(_to, _amount);
}
function batchMint(
address[] _to,
uint256[] _amount
)
hasMintPermission
canMint
public
returns (bool)
{
require(_to.length == _amount.length);
for (uint i = 0; i < _to.length; i++) {
requireMultiple(_amount[i]);
require(mint(_to[i], _amount[i]));
}
return true;
}
}
library SafeERC20 {
function safeTransfer(ERC20Basic token, address to, uint256 value) internal {
require(token.transfer(to, value));
}
function safeTransferFrom(
ERC20 token,
address from,
address to,
uint256 value
)
internal
{
require(token.transferFrom(from, to, value));
}
function safeApprove(ERC20 token, address spender, uint256 value) internal {
require(token.approve(spender, value));
}
}
contract 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;
constructor(
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);
emit 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);
emit 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 (block.timestamp < cliff) {
return 0;
} else if (block.timestamp >= start.add(duration) || revoked[token]) {
return totalBalance;
} else {
return totalBalance.mul(block.timestamp.sub(start)).div(duration);
}
}
}
contract RoundedTokenVesting is TokenVesting {
using SafeMath for uint256;
uint256 public granularity;
constructor(
address _beneficiary,
uint256 _start,
uint256 _cliff,
uint256 _duration,
bool _revocable,
uint256 _granularity
)
public
TokenVesting(_beneficiary, _start, _cliff, _duration, _revocable)
{
granularity = _granularity;
}
function vestedAmount(ERC20Basic token) public view returns (uint256) {
uint256 currentBalance = token.balanceOf(this);
uint256 totalBalance = currentBalance.add(released[token]);
if (block.timestamp < cliff) {
return 0;
} else if (block.timestamp >= start.add(duration) || revoked[token]) {
return totalBalance;
} else {
uint256 notRounded = totalBalance.mul(block.timestamp.sub(start)).div(duration);
uint256 rounded = notRounded.div(granularity).mul(granularity);
return rounded;
}
}
}
contract TendTokenVested is TendToken {
using SafeMath for uint256;
uint256 public constant DEVELOPMENT_TEAM_CAP = 2e6 * 1e18;
uint256 public constant VESTING_CLIFF = 0 days;
uint256 public constant VESTING_DURATION = 3 * 365 days;
uint256 public developmentTeamTokensMinted;
address[] public vestingWallets;
modifier onlyNoneZero(address _to, uint256 _amount) {
require(_to != address(0));
require(_amount > 0);
_;
}
function mintDevelopmentTeamTokens(address _to, uint256 _tokens) public onlyOwner onlyNoneZero(_to, _tokens) returns (bool) {
requireMultiple(_tokens);
require(developmentTeamTokensMinted.add(_tokens) <= DEVELOPMENT_TEAM_CAP);
developmentTeamTokensMinted = developmentTeamTokensMinted.add(_tokens);
RoundedTokenVesting newVault = new RoundedTokenVesting(_to, block.timestamp, VESTING_CLIFF, VESTING_DURATION, false, granularity);
vestingWallets.push(address(newVault));
return mint(address(newVault), _tokens);
}
function getVestingWalletLength() public view returns (uint256) {
return vestingWallets.length;
}
} | 0 |
pragma solidity ^0.4.18;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract token {
function balanceOf(address _owner) public constant returns (uint256 balance);
function transfer(address _to, uint256 _value) public returns (bool success);
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public{
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract lockEtherPay is Ownable {
using SafeMath for uint256;
token token_reward;
address public beneficiary;
bool public isLocked = false;
bool public isReleased = false;
uint256 public start_time;
uint256 public end_time;
uint256 public fifty_two_weeks = 29894400;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0xE69353A3d0c3BcDa9E4B1383cf9495A55386030a;
}
function tokenBalance() constant public returns (uint256){
return token_reward.balanceOf(this);
}
function lock() public onlyOwner returns (bool){
require(!isLocked);
require(tokenBalance() > 0);
start_time = now;
end_time = start_time.add(fifty_two_weeks);
isLocked = true;
}
function lockOver() constant public returns (bool){
uint256 current_time = now;
return current_time > end_time;
}
function release() onlyOwner public{
require(isLocked);
require(!isReleased);
require(lockOver());
uint256 token_amount = tokenBalance();
token_reward.transfer( beneficiary, token_amount);
emit TokenReleased(beneficiary, token_amount);
isReleased = true;
}
} | 0 |
pragma solidity ^0.4.23;
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender)
public view returns (uint256);
function transferFrom(address from, address to, uint256 value)
public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
function increaseApproval(
address _spender,
uint _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(
address _spender,
uint _subtractedValue
)
public
returns (bool)
{
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
modifier hasMintPermission() {
require(msg.sender == owner);
_;
}
function mint(
address _to,
uint256 _amount
)
hasMintPermission
canMint
public
returns (bool)
{
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
}
contract FreezableToken is StandardToken {
mapping (bytes32 => uint64) internal chains;
mapping (bytes32 => uint) internal freezings;
mapping (address => uint) internal freezingBalance;
event Freezed(address indexed to, uint64 release, uint amount);
event Released(address indexed owner, uint amount);
function balanceOf(address _owner) public view returns (uint256 balance) {
return super.balanceOf(_owner) + freezingBalance[_owner];
}
function actualBalanceOf(address _owner) public view returns (uint256 balance) {
return super.balanceOf(_owner);
}
function freezingBalanceOf(address _owner) public view returns (uint256 balance) {
return freezingBalance[_owner];
}
function freezingCount(address _addr) public view returns (uint count) {
uint64 release = chains[toKey(_addr, 0)];
while (release != 0) {
count++;
release = chains[toKey(_addr, release)];
}
}
function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) {
for (uint i = 0; i < _index + 1; i++) {
_release = chains[toKey(_addr, _release)];
if (_release == 0) {
return;
}
}
_balance = freezings[toKey(_addr, _release)];
}
function freezeTo(address _to, uint _amount, uint64 _until) public {
require(_to != address(0));
require(_amount <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_amount);
bytes32 currentKey = toKey(_to, _until);
freezings[currentKey] = freezings[currentKey].add(_amount);
freezingBalance[_to] = freezingBalance[_to].add(_amount);
freeze(_to, _until);
emit Transfer(msg.sender, _to, _amount);
emit Freezed(_to, _until, _amount);
}
function releaseOnce() public {
bytes32 headKey = toKey(msg.sender, 0);
uint64 head = chains[headKey];
require(head != 0);
require(uint64(block.timestamp) > head);
bytes32 currentKey = toKey(msg.sender, head);
uint64 next = chains[currentKey];
uint amount = freezings[currentKey];
delete freezings[currentKey];
balances[msg.sender] = balances[msg.sender].add(amount);
freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount);
if (next == 0) {
delete chains[headKey];
} else {
chains[headKey] = next;
delete chains[currentKey];
}
emit Released(msg.sender, amount);
}
function releaseAll() public returns (uint tokens) {
uint release;
uint balance;
(release, balance) = getFreezing(msg.sender, 0);
while (release != 0 && block.timestamp > release) {
releaseOnce();
tokens += balance;
(release, balance) = getFreezing(msg.sender, 0);
}
}
function toKey(address _addr, uint _release) internal pure returns (bytes32 result) {
result = 0x5749534800000000000000000000000000000000000000000000000000000000;
assembly {
result := or(result, mul(_addr, 0x10000000000000000))
result := or(result, _release)
}
}
function freeze(address _to, uint64 _until) internal {
require(_until > block.timestamp);
bytes32 key = toKey(_to, _until);
bytes32 parentKey = toKey(_to, uint64(0));
uint64 next = chains[parentKey];
if (next == 0) {
chains[parentKey] = _until;
return;
}
bytes32 nextKey = toKey(_to, next);
uint parent;
while (next != 0 && _until > next) {
parent = next;
parentKey = nextKey;
next = chains[nextKey];
nextKey = toKey(_to, next);
}
if (_until == next) {
return;
}
if (next != 0) {
chains[key] = next;
}
chains[parentKey] = _until;
}
}
contract BurnableToken is BasicToken {
event Burn(address indexed burner, uint256 value);
function burn(uint256 _value) public {
_burn(msg.sender, _value);
}
function _burn(address _who, uint256 _value) internal {
require(_value <= balances[_who]);
balances[_who] = balances[_who].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(_who, _value);
emit Transfer(_who, address(0), _value);
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
contract FreezableMintableToken is FreezableToken, MintableToken {
function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) {
totalSupply_ = totalSupply_.add(_amount);
bytes32 currentKey = toKey(_to, _until);
freezings[currentKey] = freezings[currentKey].add(_amount);
freezingBalance[_to] = freezingBalance[_to].add(_amount);
freeze(_to, _until);
emit Mint(_to, _amount);
emit Freezed(_to, _until, _amount);
emit Transfer(msg.sender, _to, _amount);
return true;
}
}
contract Consts {
uint public constant TOKEN_DECIMALS = 18;
uint8 public constant TOKEN_DECIMALS_UINT8 = 18;
uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS;
string public constant TOKEN_NAME = "Powerchain";
string public constant TOKEN_SYMBOL = "PCX";
bool public constant PAUSED = true;
address public constant TARGET_USER = 0x0344425e91f9901e1193c4382419De32F9EBF2a7;
uint public constant START_TIME = 1537538433;
bool public constant CONTINUE_MINTING = false;
}
contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable
{
function name() public pure returns (string _name) {
return TOKEN_NAME;
}
function symbol() public pure returns (string _symbol) {
return TOKEN_SYMBOL;
}
function decimals() public pure returns (uint8 _decimals) {
return TOKEN_DECIMALS_UINT8;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) {
require(!paused);
return super.transferFrom(_from, _to, _value);
}
function transfer(address _to, uint256 _value) public returns (bool _success) {
require(!paused);
return super.transfer(_to, _value);
}
} | 1 |
pragma solidity ^0.4.21;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
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 StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
}
contract CRTCoin is MintableToken {
string public constant name = "CRTCoin";
string public constant symbol = "CRT";
uint8 public constant decimals = 18;
} | 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 = 0x79106d18377276982df76C083bEA6c92F833fB0D;
}
function tokenBalance() constant public returns (uint256){
return token_reward.balanceOf(this);
}
function lock() public onlyOwner returns (bool){
require(!isLocked);
require(tokenBalance() > 0);
start_time = now;
end_time = start_time.add(fifty_two_weeks);
isLocked = true;
}
function lockOver() constant public returns (bool){
uint256 current_time = now;
return current_time > end_time;
}
function release() onlyOwner public{
require(isLocked);
require(!isReleased);
require(lockOver());
uint256 token_amount = tokenBalance();
token_reward.transfer( beneficiary, token_amount);
emit TokenReleased(beneficiary, token_amount);
isReleased = true;
}
} | 0 |
pragma solidity ^0.4.18;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract 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 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 Releasable is Ownable {
event Release();
bool public released = false;
modifier afterReleased() {
require(released);
_;
}
function release() onlyOwner public {
require(!released);
released = true;
Release();
}
}
contract Managed is Releasable {
mapping (address => bool) public manager;
event SetManager(address _addr);
event UnsetManager(address _addr);
function Managed() public {
manager[msg.sender] = true;
}
modifier onlyManager() {
require(manager[msg.sender]);
_;
}
function setManager(address _addr) public onlyOwner {
require(_addr != address(0) && manager[_addr] == false);
manager[_addr] = true;
SetManager(_addr);
}
function unsetManager(address _addr) public onlyOwner {
require(_addr != address(0) && manager[_addr] == true);
manager[_addr] = false;
UnsetManager(_addr);
}
}
contract ReleasableToken is StandardToken, Managed {
function transfer(address _to, uint256 _value) public afterReleased returns (bool) {
return super.transfer(_to, _value);
}
function saleTransfer(address _to, uint256 _value) public onlyManager returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public afterReleased returns (bool) {
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint256 _value) public afterReleased returns (bool) {
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public afterReleased returns (bool success) {
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public afterReleased returns (bool success) {
return super.decreaseApproval(_spender, _subtractedValue);
}
}
contract BurnableToken is ReleasableToken {
event Burn(address indexed burner, uint256 value);
function burn(uint256 _value) onlyManager 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 GANA is BurnableToken {
string public constant name = "GANA";
string public constant symbol = "GANA";
uint8 public constant decimals = 18;
event ClaimedTokens(address manager, address _token, uint256 claimedBalance);
function GANA() public {
totalSupply = 2000000000 * 1 ether;
balances[msg.sender] = totalSupply;
}
function claimTokens(address _token, uint256 _claimedBalance) public onlyManager afterReleased {
ERC20Basic token = ERC20Basic(_token);
uint256 tokenBalance = token.balanceOf(this);
require(tokenBalance >= _claimedBalance);
address manager = msg.sender;
token.transfer(manager, _claimedBalance);
ClaimedTokens(manager, _token, _claimedBalance);
}
}
contract Whitelist is Ownable {
mapping (address => bool) public whitelist;
event Registered(address indexed _addr);
event Unregistered(address indexed _addr);
modifier onlyWhitelisted(address _addr) {
require(whitelist[_addr]);
_;
}
function isWhitelist(address _addr) public view returns (bool listed) {
return whitelist[_addr];
}
function registerAddress(address _addr) public onlyOwner {
require(_addr != address(0) && whitelist[_addr] == false);
whitelist[_addr] = true;
Registered(_addr);
}
function registerAddresses(address[] _addrs) public onlyOwner {
for(uint256 i = 0; i < _addrs.length; i++) {
require(_addrs[i] != address(0) && whitelist[_addrs[i]] == false);
whitelist[_addrs[i]] = true;
Registered(_addrs[i]);
}
}
function unregisterAddress(address _addr) public onlyOwner onlyWhitelisted(_addr) {
whitelist[_addr] = false;
Unregistered(_addr);
}
function unregisterAddresses(address[] _addrs) public onlyOwner {
for(uint256 i = 0; i < _addrs.length; i++) {
require(whitelist[_addrs[i]]);
whitelist[_addrs[i]] = false;
Unregistered(_addrs[i]);
}
}
}
contract GanaPreSale is Ownable {
using SafeMath for uint256;
GANA public gana;
Whitelist public whitelist;
address public wallet;
uint256 public hardCap = 10000 ether;
uint256 public weiRaised = 0;
uint256 public minCap = 3 ether;
uint256 public rate = 22000;
uint256 public defaultRate = 20000;
uint256 public startTime = 1523008800;
uint256 public endTime = 1523786400;
event TokenPurchase(address indexed sender, address indexed buyer, uint256 weiAmount, uint256 ganaAmount);
event Refund(address indexed buyer, uint256 weiAmount);
event TransferToSafe();
event BurnAndReturnAfterEnded(uint256 burnAmount, uint256 returnAmount);
function GanaPreSale(address _gana, address _wallet, address _whitelist) public {
require(_wallet != address(0));
gana = GANA(_gana);
whitelist = Whitelist(_whitelist);
wallet = _wallet;
}
modifier onlyWhitelisted() {
require(whitelist.isWhitelist(msg.sender));
_;
}
function () external payable {
buyGana(msg.sender);
}
function buyGana(address buyer) public onlyWhitelisted payable {
require(!hasEnded());
require(afterStart());
require(buyer != address(0));
require(buyer == msg.sender);
require(msg.value >= minCap);
uint256 weiAmount = msg.value;
uint256 preCalWeiRaised = weiRaised.add(weiAmount);
uint256 ganaAmount;
if(preCalWeiRaised <= hardCap){
ganaAmount = weiAmount.mul(rate);
gana.saleTransfer(buyer, ganaAmount);
weiRaised = preCalWeiRaised;
TokenPurchase(msg.sender, buyer, weiAmount, ganaAmount);
}else{
uint256 refundWeiAmount = preCalWeiRaised.sub(hardCap);
uint256 fundWeiAmount = weiAmount.sub(refundWeiAmount);
ganaAmount = fundWeiAmount.mul(rate);
gana.saleTransfer(buyer, ganaAmount);
weiRaised = weiRaised.add(fundWeiAmount);
TokenPurchase(msg.sender, buyer, fundWeiAmount, ganaAmount);
buyer.transfer(refundWeiAmount);
Refund(buyer,refundWeiAmount);
}
}
function hasEnded() public view returns (bool) {
bool hardCapReached = weiRaised >= hardCap;
return hardCapReached || afterEnded();
}
function afterEnded() internal constant returns (bool) {
return now > endTime;
}
function afterStart() internal constant returns (bool) {
return now >= startTime;
}
function transferToSafe() onlyOwner public {
require(hasEnded());
wallet.transfer(this.balance);
TransferToSafe();
}
function burnAndReturnAfterEnded(address reserveWallet) onlyOwner public {
require(reserveWallet != address(0));
require(hasEnded());
uint256 unsoldWei = hardCap.sub(weiRaised);
require(unsoldWei > 0);
uint256 unsoldGanaAmount = gana.balanceOf(this);
uint256 burnGanaAmount = unsoldWei.mul(defaultRate);
uint256 bonusGanaAmount = unsoldGanaAmount.sub(burnGanaAmount);
gana.burn(burnGanaAmount);
gana.saleTransfer(reserveWallet, bonusGanaAmount);
BurnAndReturnAfterEnded(burnGanaAmount, bonusGanaAmount);
}
function returnGanaBeforeSale(address returnAddress) onlyOwner public {
require(returnAddress != address(0));
require(weiRaised == 0);
uint256 returnGana = gana.balanceOf(this);
gana.saleTransfer(returnAddress, returnGana);
}
} | 0 |
pragma solidity ^0.4.19;
interface ERC20 {
function totalSupply() public view returns (uint256);
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 Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract Owned {
address owner;
function Owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
}
contract ChiSale is Owned {
struct BonusTier {
uint256 percentage;
uint256 threshold;
}
BonusTier[] private bonusTiers;
uint256 private tokensSold;
uint8 private bonusIndex;
uint256 private maxBonusThreshold;
uint256 private constant TOKEN_PRICE = 0.001 ether;
uint256 private constant REVENUE_SHARE_PERCENTAGE = 22;
ERC20 private chiContract;
event LogChiPurchase(
address indexed buyer,
address indexed referrer,
uint256 number,
uint256 timestamp
);
function ChiSale(
address chiAddress,
uint256[] bonusThresholds,
uint256[] bonusPercentages
)
public
Owned()
{
require(bonusThresholds.length == bonusPercentages.length);
require(bonusThresholds.length < 256);
for (uint8 i = 0; i < bonusThresholds.length; i++) {
if (i > 0) {
require(bonusThresholds[i] > bonusThresholds[i - 1]);
}
if (i > bonusThresholds.length - 1) {
maxBonusThreshold = bonusThresholds[i];
}
bonusTiers.push(BonusTier({
percentage: bonusPercentages[i],
threshold: bonusThresholds[i]
}));
}
chiContract = ERC20(chiAddress);
tokensSold = 0;
bonusIndex = 0;
}
function buy(address referralAddress) external payable {
uint256 tokensToBuy = msg.value / TOKEN_PRICE;
uint256 tokenBalance = chiContract.balanceOf(address(this));
uint256 remainder = msg.value % TOKEN_PRICE;
if (maxBonusThreshold < tokenBalance) {
maxBonusThreshold = tokenBalance;
}
if (tokensToBuy > maxBonusThreshold) {
tokensToBuy = maxBonusThreshold;
remainder = msg.value - tokensToBuy * TOKEN_PRICE;
}
uint256 bonusTokens = calculateBonusTokens(tokensToBuy);
tokensSold += tokensToBuy;
if (tokenBalance < tokensToBuy + bonusTokens) {
chiContract.transfer(msg.sender, tokenBalance);
} else {
chiContract.transfer(msg.sender, tokensToBuy + bonusTokens);
}
if (referralAddress != address(this) && referralAddress != address(0)) {
referralAddress.send(
msg.value * REVENUE_SHARE_PERCENTAGE / 100
);
}
if (remainder > 0) {
msg.sender.transfer(remainder);
}
LogChiPurchase(msg.sender, referralAddress, tokensToBuy, now);
}
function resetMaxBonusThreshold() external onlyOwner {
maxBonusThreshold = bonusTiers[bonusTiers.length - 1].threshold;
}
function withdrawEther() external onlyOwner {
msg.sender.transfer(address(this).balance);
}
function withdrawChi() external onlyOwner {
chiContract.transfer(msg.sender, chiContract.balanceOf(address(this)));
}
function getBonusTierCount() external view returns (uint256) {
return bonusTiers.length;
}
function getBonusTier(
uint8 bonusTierIndex
)
external
view
returns (uint256, uint256)
{
return (
bonusTiers[bonusTierIndex].percentage,
bonusTiers[bonusTierIndex].threshold
);
}
function getCurrentBonusTier()
external
view
returns (uint256 percentage, uint256 threshold)
{
return (
bonusTiers[bonusIndex].percentage,
bonusTiers[bonusIndex].threshold
);
}
function getNextBonusIndex()
external
view
returns (uint8)
{
return bonusIndex + 1;
}
function getSoldTokens() external view returns (uint256) {
return tokensSold;
}
function calculateBonusTokens(
uint256 boughtTokens
)
internal
returns (uint256)
{
if (bonusIndex == bonusTiers.length) {
return 0;
}
uint256 bonusTokens = 0;
uint256 _boughtTokens = boughtTokens;
uint256 _tokensSold = tokensSold;
while (_boughtTokens > 0) {
uint256 threshold = bonusTiers[bonusIndex].threshold;
uint256 bonus = bonusTiers[bonusIndex].percentage;
if (_tokensSold + _boughtTokens >= threshold) {
_boughtTokens -= threshold - _tokensSold;
bonusTokens += (threshold - _tokensSold) * bonus / 100;
_tokensSold = threshold;
if (bonusIndex < bonusTiers.length) {
bonusIndex += 1;
}
} else {
_tokensSold += _boughtTokens;
bonusTokens += _boughtTokens * bonus / 100;
_boughtTokens = 0;
}
}
return bonusTokens;
}
} | 0 |
pragma solidity ^0.4.21;
interface ReinvestProxy {
function reinvestFor(address customer) external payable;
}
library Math {
function max64(uint64 a, uint64 b) internal pure returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) internal pure returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
}
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 Whitelist is Ownable {
mapping(address => bool) public whitelist;
event WhitelistedAddressAdded(address addr);
event WhitelistedAddressRemoved(address addr);
modifier onlyWhitelisted() {
require(whitelist[msg.sender]);
_;
}
function addAddressToWhitelist(address addr) onlyOwner public returns(bool success) {
if (!whitelist[addr]) {
whitelist[addr] = true;
emit WhitelistedAddressAdded(addr);
success = true;
}
}
function addAddressesToWhitelist(address[] addrs) onlyOwner public returns(bool success) {
for (uint256 i = 0; i < addrs.length; i++) {
if (addAddressToWhitelist(addrs[i])) {
success = true;
}
}
}
function removeAddressFromWhitelist(address addr) onlyOwner public returns(bool success) {
if (whitelist[addr]) {
whitelist[addr] = false;
emit WhitelistedAddressRemoved(addr);
success = true;
}
}
function removeAddressesFromWhitelist(address[] addrs) onlyOwner public returns(bool success) {
for (uint256 i = 0; i < addrs.length; i++) {
if (removeAddressFromWhitelist(addrs[i])) {
success = true;
}
}
}
}
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 P4RTYDaoVault is Whitelist {
modifier onlyDivis {
require(myDividends() > 0);
_;
}
event onStake(
address indexed customerAddress,
uint256 stakedTokens,
uint256 timestamp
);
event onDeposit(
address indexed fundingSource,
uint256 ethDeposited,
uint timestamp
);
event onWithdraw(
address indexed customerAddress,
uint256 ethereumWithdrawn,
uint timestamp
);
event onReinvestmentProxy(
address indexed customerAddress,
address indexed destinationAddress,
uint256 ethereumReinvested
);
uint256 constant internal magnitude = 2 ** 64;
mapping(address => uint256) internal tokenBalanceLedger_;
mapping(address => int256) internal payoutsTo_;
uint256 internal tokenSupply_ = 1;
uint256 internal profitPerShare_;
ERC20 public p4rty;
constructor(address _p4rtyAddress) Ownable() public {
p4rty = ERC20(_p4rtyAddress);
}
function() payable public {
deposit();
}
function deposit() payable public {
uint256 _incomingEthereum = msg.value;
address _fundingSource = msg.sender;
profitPerShare_ += (_incomingEthereum * magnitude / tokenSupply_);
emit onDeposit(_fundingSource, _incomingEthereum, now);
}
function stake(uint _amountOfTokens) public {
address _customerAddress = msg.sender;
require(p4rty.balanceOf(_customerAddress) > 0);
uint256 _balance = p4rty.balanceOf(_customerAddress);
uint256 _stakeAmount = Math.min256(_balance,_amountOfTokens);
require(_stakeAmount > 0);
p4rty.transferFrom(_customerAddress, address(this), _stakeAmount);
tokenSupply_ = SafeMath.add(tokenSupply_, _stakeAmount);
tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _stakeAmount);
int256 _updatedPayouts = (int256) (profitPerShare_ * _stakeAmount);
payoutsTo_[_customerAddress] += _updatedPayouts;
emit onStake(_customerAddress, _amountOfTokens, now);
}
function withdraw() onlyDivis public {
address _customerAddress = msg.sender;
uint256 _dividends = dividendsOf(_customerAddress);
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
_customerAddress.transfer(_dividends);
emit onWithdraw(_customerAddress, _dividends, now);
}
function reinvestByProxy(address _customerAddress) onlyWhitelisted public {
uint256 _dividends = dividendsOf(_customerAddress);
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
ReinvestProxy reinvestProxy = ReinvestProxy(msg.sender);
reinvestProxy.reinvestFor.value(_dividends)(_customerAddress);
emit onReinvestmentProxy(_customerAddress,msg.sender,_dividends);
}
function totalEthereumBalance() public view returns (uint256) {
return address(this).balance;
}
function totalSupply() public view returns (uint256) {
return tokenSupply_;
}
function myTokens() public view returns (uint256) {
address _customerAddress = msg.sender;
return balanceOf(_customerAddress);
}
function votingPower(address _customerAddress) public view returns (uint256) {
return SafeMath.div(balanceOf(_customerAddress), totalSupply());
}
function myDividends() public view returns (uint256) {
return dividendsOf(msg.sender);
}
function balanceOf(address _customerAddress) public view returns (uint256) {
return tokenBalanceLedger_[_customerAddress];
}
function dividendsOf(address _customerAddress) public view returns (uint256) {
return (uint256) ((int256) (profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude;
}
} | 0 |
pragma solidity ^0.4.20;
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 tokemon20 is StandardToken {
function () {
throw;
}
string public name;
uint8 public decimals;
string public symbol;
string public version = 'H1.0';
function tokemon20(
) {
balances[msg.sender] = 100000000;
totalSupply = 100000000;
name = "tokemon20";
decimals = 0;
symbol = "tkm20";
}
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.18;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract SimpleToken is StandardToken {
string public constant name = "SimpleToken";
string public constant symbol = "SIM";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals));
function SimpleToken() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract LockedOutTokens is Ownable {
address public wallet;
uint8 public tranchesCount;
uint256 public trancheSize;
uint256 public period;
uint256 public startTimestamp;
uint8 public tranchesPayedOut = 0;
ERC20Basic internal token;
function LockedOutTokens(
address _wallet,
address _tokenAddress,
uint256 _startTimestamp,
uint8 _tranchesCount,
uint256 _trancheSize,
uint256 _periodSeconds
) {
require(_wallet != address(0));
require(_tokenAddress != address(0));
require(_startTimestamp > 0);
require(_tranchesCount > 0);
require(_trancheSize > 0);
require(_periodSeconds > 0);
wallet = _wallet;
tranchesCount = _tranchesCount;
startTimestamp = _startTimestamp;
trancheSize = _trancheSize;
period = _periodSeconds;
token = ERC20Basic(_tokenAddress);
}
function grant()
public
{
require(wallet == msg.sender);
require(tranchesPayedOut < tranchesCount);
require(startTimestamp > 0);
require(now >= startTimestamp + (period * (tranchesPayedOut + 1)));
tranchesPayedOut = tranchesPayedOut + 1;
token.transfer(wallet, trancheSize);
}
}
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 TiqpitToken is StandardToken, Pausable {
using SafeMath for uint256;
string constant public name = "Tiqpit Token";
string constant public symbol = "PIT";
uint8 constant public decimals = 18;
string constant public smallestUnitName = "TIQ";
uint256 constant public INITIAL_TOTAL_SUPPLY = 500e6 * (uint256(10) ** decimals);
address private addressIco;
modifier onlyIco() {
require(msg.sender == addressIco);
_;
}
function TiqpitToken (address _ico) public {
require(_ico != address(0));
addressIco = _ico;
totalSupply_ = totalSupply_.add(INITIAL_TOTAL_SUPPLY);
balances[_ico] = balances[_ico].add(INITIAL_TOTAL_SUPPLY);
Transfer(address(0), _ico, INITIAL_TOTAL_SUPPLY);
pause();
}
function transfer(address _to, uint256 _value) whenNotPaused public returns (bool) {
super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) whenNotPaused public returns (bool) {
super.transferFrom(_from, _to, _value);
}
function transferFromIco(address _to, uint256 _value) onlyIco public returns (bool) {
super.transfer(_to, _value);
}
function burnFromAddress(address _from) onlyIco public {
uint256 amount = balances[_from];
require(_from != address(0));
require(amount > 0);
require(amount <= balances[_from]);
balances[_from] = balances[_from].sub(amount);
totalSupply_ = totalSupply_.sub(amount);
Transfer(_from, address(0), amount);
}
}
contract Whitelist is Ownable {
mapping(address => bool) whitelist;
uint256 public whitelistLength = 0;
address public backendAddress;
function addWallet(address _wallet) public onlyPrivilegedAddresses {
require(_wallet != address(0));
require(!isWhitelisted(_wallet));
whitelist[_wallet] = true;
whitelistLength++;
}
function removeWallet(address _wallet) public onlyOwner {
require(_wallet != address(0));
require(isWhitelisted(_wallet));
whitelist[_wallet] = false;
whitelistLength--;
}
function isWhitelisted(address _wallet) constant public returns (bool) {
return whitelist[_wallet];
}
function setBackendAddress(address _backendAddress) public onlyOwner {
require(_backendAddress != address(0));
backendAddress = _backendAddress;
}
modifier onlyPrivilegedAddresses() {
require(msg.sender == owner || msg.sender == backendAddress);
_;
}
}
contract Whitelistable {
Whitelist public whitelist;
modifier whenWhitelisted(address _wallet) {
require(whitelist.isWhitelisted(_wallet));
_;
}
function Whitelistable() public {
whitelist = new Whitelist();
}
}
contract TiqpitCrowdsale is Pausable, Whitelistable {
using SafeMath for uint256;
uint256 constant private DECIMALS = 18;
uint256 constant public RESERVED_TOKENS_BOUNTY = 10e6 * (10 ** DECIMALS);
uint256 constant public RESERVED_TOKENS_FOUNDERS = 25e6 * (10 ** DECIMALS);
uint256 constant public RESERVED_TOKENS_ADVISORS = 25e5 * (10 ** DECIMALS);
uint256 constant public RESERVED_TOKENS_TIQPIT_SOLUTIONS = 625e5 * (10 ** DECIMALS);
uint256 constant public MIN_INVESTMENT = 200 * (10 ** DECIMALS);
uint256 constant public MINCAP_TOKENS_PRE_ICO = 1e6 * (10 ** DECIMALS);
uint256 constant public MAXCAP_TOKENS_PRE_ICO = 75e5 * (10 ** DECIMALS);
uint256 constant public MINCAP_TOKENS_ICO = 5e6 * (10 ** DECIMALS);
uint256 constant public MAXCAP_TOKENS_ICO = 3925e5 * (10 ** DECIMALS);
uint256 public tokensRemainingIco = MAXCAP_TOKENS_ICO;
uint256 public tokensRemainingPreIco = MAXCAP_TOKENS_PRE_ICO;
uint256 public soldTokensPreIco = 0;
uint256 public soldTokensIco = 0;
uint256 public soldTokensTotal = 0;
uint256 public preIcoRate = 2857;
uint256 public firstRate = 2500;
uint256 public secondRate = 2222;
uint256 public thirdRate = 2000;
uint256 public startTimePreIco = 0;
uint256 public endTimePreIco = 0;
uint256 public startTimeIco = 0;
uint256 public endTimeIco = 0;
uint256 public weiRaisedPreIco = 0;
uint256 public weiRaisedIco = 0;
uint256 public weiRaisedTotal = 0;
TiqpitToken public token = new TiqpitToken(this);
mapping (address => address) private lockedList;
address private tiqpitSolutionsWallet;
address private foundersWallet;
address private advisorsWallet;
address private bountyWallet;
address public backendAddress;
bool private hasPreIcoFailed = false;
bool private hasIcoFailed = false;
bool private isInitialDistributionDone = false;
struct Purchase {
uint256 refundableWei;
uint256 burnableTiqs;
}
mapping(address => Purchase) private preIcoPurchases;
mapping(address => Purchase) private icoPurchases;
function TiqpitCrowdsale(
uint256 _startTimePreIco,
uint256 _endTimePreIco,
uint256 _startTimeIco,
uint256 _endTimeIco,
address _foundersWallet,
address _advisorsWallet,
address _tiqpitSolutionsWallet,
address _bountyWallet
) Whitelistable() public
{
require(_bountyWallet != address(0) && _foundersWallet != address(0) && _tiqpitSolutionsWallet != address(0) && _advisorsWallet != address(0));
require(_startTimePreIco >= now && _endTimePreIco > _startTimePreIco);
require(_startTimeIco >= _endTimePreIco && _endTimeIco > _startTimeIco);
startTimePreIco = _startTimePreIco;
endTimePreIco = _endTimePreIco;
startTimeIco = _startTimeIco;
endTimeIco = _endTimeIco;
tiqpitSolutionsWallet = _tiqpitSolutionsWallet;
advisorsWallet = _advisorsWallet;
foundersWallet = _foundersWallet;
bountyWallet = _bountyWallet;
whitelist.transferOwnership(msg.sender);
token.transferOwnership(msg.sender);
}
function() public payable {
sellTokens();
}
function isPreIco() public view returns (bool) {
return now >= startTimePreIco && now <= endTimePreIco;
}
function isIco() public view returns (bool) {
return now >= startTimeIco && now <= endTimeIco;
}
function burnRemainingTokens() onlyOwner public {
require(tokensRemainingIco > 0);
require(now > endTimeIco);
token.burnFromAddress(this);
tokensRemainingIco = 0;
}
function initialDistribution() onlyOwner public {
require(!isInitialDistributionDone);
token.transferFromIco(bountyWallet, RESERVED_TOKENS_BOUNTY);
token.transferFromIco(advisorsWallet, RESERVED_TOKENS_ADVISORS);
token.transferFromIco(tiqpitSolutionsWallet, RESERVED_TOKENS_TIQPIT_SOLUTIONS);
lockTokens(foundersWallet, RESERVED_TOKENS_FOUNDERS, 1 years);
isInitialDistributionDone = true;
}
function getIcoPurchase(address _address) view public returns(uint256 weis, uint256 tokens) {
return (icoPurchases[_address].refundableWei, icoPurchases[_address].burnableTiqs);
}
function getPreIcoPurchase(address _address) view public returns(uint256 weis, uint256 tokens) {
return (preIcoPurchases[_address].refundableWei, preIcoPurchases[_address].burnableTiqs);
}
function refundPreIco() public {
require(hasPreIcoFailed);
require(preIcoPurchases[msg.sender].burnableTiqs > 0 && preIcoPurchases[msg.sender].refundableWei > 0);
uint256 amountWei = preIcoPurchases[msg.sender].refundableWei;
msg.sender.transfer(amountWei);
preIcoPurchases[msg.sender].refundableWei = 0;
preIcoPurchases[msg.sender].burnableTiqs = 0;
token.burnFromAddress(msg.sender);
}
function refundIco() public {
require(hasIcoFailed);
require(icoPurchases[msg.sender].burnableTiqs > 0 && icoPurchases[msg.sender].refundableWei > 0);
uint256 amountWei = icoPurchases[msg.sender].refundableWei;
msg.sender.transfer(amountWei);
icoPurchases[msg.sender].refundableWei = 0;
icoPurchases[msg.sender].burnableTiqs = 0;
token.burnFromAddress(msg.sender);
}
function burnTokens(address _address) onlyOwner public {
require(hasIcoFailed);
require(icoPurchases[_address].burnableTiqs > 0 || preIcoPurchases[_address].burnableTiqs > 0);
icoPurchases[_address].burnableTiqs = 0;
preIcoPurchases[_address].burnableTiqs = 0;
token.burnFromAddress(_address);
}
function manualSendTokens(address _address, uint256 _tokensAmount) whenWhitelisted(_address) public onlyPrivilegedAddresses {
require(_tokensAmount > 0);
if (isPreIco() && _tokensAmount <= tokensRemainingPreIco) {
token.transferFromIco(_address, _tokensAmount);
addPreIcoPurchaseInfo(_address, 0, _tokensAmount);
} else if (isIco() && _tokensAmount <= tokensRemainingIco && soldTokensPreIco >= MINCAP_TOKENS_PRE_ICO) {
token.transferFromIco(_address, _tokensAmount);
addIcoPurchaseInfo(_address, 0, _tokensAmount);
} else {
revert();
}
}
function getLockedContractAddress(address wallet) public view returns(address) {
return lockedList[wallet];
}
function triggerFailFlags() onlyOwner public {
if (!hasPreIcoFailed && now > endTimePreIco && soldTokensPreIco < MINCAP_TOKENS_PRE_ICO) {
hasPreIcoFailed = true;
}
if (!hasIcoFailed && now > endTimeIco && soldTokensIco < MINCAP_TOKENS_ICO) {
hasIcoFailed = true;
}
}
function currentIcoRate() public view returns(uint256) {
if (now > startTimeIco && now <= startTimeIco + 5 days) {
return firstRate;
}
if (now > startTimeIco + 5 days && now <= startTimeIco + 10 days) {
return secondRate;
}
if (now > startTimeIco + 10 days) {
return thirdRate;
}
}
function sellTokens() whenWhitelisted(msg.sender) whenNotPaused public payable {
require(msg.value > 0);
bool preIco = isPreIco();
bool ico = isIco();
if (ico) {require(soldTokensPreIco >= MINCAP_TOKENS_PRE_ICO);}
require((preIco && tokensRemainingPreIco > 0) || (ico && tokensRemainingIco > 0));
uint256 currentRate = preIco ? preIcoRate : currentIcoRate();
uint256 weiAmount = msg.value;
uint256 tokensAmount = weiAmount.mul(currentRate);
require(tokensAmount >= MIN_INVESTMENT);
if (ico) {
if (tokensRemainingPreIco > 0) {
tokensRemainingIco = tokensRemainingIco.add(tokensRemainingPreIco);
tokensRemainingPreIco = 0;
}
}
uint256 tokensRemaining = preIco ? tokensRemainingPreIco : tokensRemainingIco;
if (tokensAmount > tokensRemaining) {
uint256 tokensRemainder = tokensAmount.sub(tokensRemaining);
tokensAmount = tokensAmount.sub(tokensRemainder);
uint256 overpaidWei = tokensRemainder.div(currentRate);
msg.sender.transfer(overpaidWei);
weiAmount = msg.value.sub(overpaidWei);
}
token.transferFromIco(msg.sender, tokensAmount);
if (preIco) {
addPreIcoPurchaseInfo(msg.sender, weiAmount, tokensAmount);
if (soldTokensPreIco >= MINCAP_TOKENS_PRE_ICO) {
tiqpitSolutionsWallet.transfer(this.balance);
}
}
if (ico) {
addIcoPurchaseInfo(msg.sender, weiAmount, tokensAmount);
if (soldTokensIco >= MINCAP_TOKENS_ICO) {
tiqpitSolutionsWallet.transfer(this.balance);
}
}
}
function addPreIcoPurchaseInfo(address _address, uint256 _amountWei, uint256 _amountTokens) internal {
preIcoPurchases[_address].refundableWei = preIcoPurchases[_address].refundableWei.add(_amountWei);
preIcoPurchases[_address].burnableTiqs = preIcoPurchases[_address].burnableTiqs.add(_amountTokens);
soldTokensPreIco = soldTokensPreIco.add(_amountTokens);
tokensRemainingPreIco = tokensRemainingPreIco.sub(_amountTokens);
weiRaisedPreIco = weiRaisedPreIco.add(_amountWei);
soldTokensTotal = soldTokensTotal.add(_amountTokens);
weiRaisedTotal = weiRaisedTotal.add(_amountWei);
}
function addIcoPurchaseInfo(address _address, uint256 _amountWei, uint256 _amountTokens) internal {
icoPurchases[_address].refundableWei = icoPurchases[_address].refundableWei.add(_amountWei);
icoPurchases[_address].burnableTiqs = icoPurchases[_address].burnableTiqs.add(_amountTokens);
soldTokensIco = soldTokensIco.add(_amountTokens);
tokensRemainingIco = tokensRemainingIco.sub(_amountTokens);
weiRaisedIco = weiRaisedIco.add(_amountWei);
soldTokensTotal = soldTokensTotal.add(_amountTokens);
weiRaisedTotal = weiRaisedTotal.add(_amountWei);
}
function lockTokens(address _wallet, uint256 _amount, uint256 _time) internal {
LockedOutTokens locked = new LockedOutTokens(_wallet, token, endTimePreIco, 1, _amount, _time);
lockedList[_wallet] = locked;
token.transferFromIco(locked, _amount);
}
function setBackendAddress(address _backendAddress) public onlyOwner {
require(_backendAddress != address(0));
backendAddress = _backendAddress;
}
modifier onlyPrivilegedAddresses() {
require(msg.sender == owner || msg.sender == backendAddress);
_;
}
} | 0 |
pragma solidity ^0.4.21;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract ERC827 is ERC20 {
function approveAndCall( address _spender, uint256 _value, bytes _data) public payable returns (bool);
function transferAndCall( address _to, uint256 _value, bytes _data) public payable returns (bool);
function transferFromAndCall(
address _from,
address _to,
uint256 _value,
bytes _data
)
public
payable
returns (bool);
}
contract ERC827Token is ERC827, StandardToken {
function approveAndCall(address _spender, uint256 _value, bytes _data) public payable returns (bool) {
require(_spender != address(this));
super.approve(_spender, _value);
require(_spender.call.value(msg.value)(_data));
return true;
}
function transferAndCall(address _to, uint256 _value, bytes _data) public payable returns (bool) {
require(_to != address(this));
super.transfer(_to, _value);
require(_to.call.value(msg.value)(_data));
return true;
}
function transferFromAndCall(
address _from,
address _to,
uint256 _value,
bytes _data
)
public payable returns (bool)
{
require(_to != address(this));
super.transferFrom(_from, _to, _value);
require(_to.call.value(msg.value)(_data));
return true;
}
function increaseApprovalAndCall(address _spender, uint _addedValue, bytes _data) public payable returns (bool) {
require(_spender != address(this));
super.increaseApproval(_spender, _addedValue);
require(_spender.call.value(msg.value)(_data));
return true;
}
function decreaseApprovalAndCall(address _spender, uint _subtractedValue, bytes _data) public payable returns (bool) {
require(_spender != address(this));
super.decreaseApproval(_spender, _subtractedValue);
require(_spender.call.value(msg.value)(_data));
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));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
contract Claimable is Ownable {
address public pendingOwner;
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
pendingOwner = newOwner;
}
function claimOwnership() onlyPendingOwner public {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
}
}
contract MainframeToken is ERC827Token, Pausable, Claimable {
string public constant name = "Mainframe Token";
string public constant symbol = "MFT";
uint8 public constant decimals = 18;
address public distributor;
modifier validDestination(address to) {
require(to != address(this));
_;
}
modifier isTradeable() {
require(
!paused ||
msg.sender == owner ||
msg.sender == distributor
);
_;
}
constructor() public {
totalSupply_ = 10000000000 ether;
balances[msg.sender] = totalSupply_;
emit Transfer(address(0x0), msg.sender, totalSupply_);
}
function transfer(address to, uint256 value) public validDestination(to) isTradeable returns (bool) {
return super.transfer(to, value);
}
function transferFrom(address from, address to, uint256 value) public validDestination(to) isTradeable returns (bool) {
return super.transferFrom(from, to, value);
}
function approve(address spender, uint256 value) public isTradeable returns (bool) {
return super.approve(spender, value);
}
function increaseApproval(address spender, uint addedValue) public isTradeable returns (bool) {
return super.increaseApproval(spender, addedValue);
}
function decreaseApproval(address spender, uint subtractedValue) public isTradeable returns (bool) {
return super.decreaseApproval(spender, subtractedValue);
}
function transferAndCall(address to, uint256 value, bytes data) public payable isTradeable returns (bool) {
return super.transferAndCall(to, value, data);
}
function transferFromAndCall(address from, address to, uint256 value, bytes data) public payable isTradeable returns (bool) {
return super.transferFromAndCall(from, to, value, data);
}
function approveAndCall(address spender, uint256 value, bytes data) public payable isTradeable returns (bool) {
return super.approveAndCall(spender, value, data);
}
function increaseApprovalAndCall(address spender, uint addedValue, bytes data) public payable isTradeable returns (bool) {
return super.increaseApprovalAndCall(spender, addedValue, data);
}
function decreaseApprovalAndCall(address spender, uint subtractedValue, bytes data) public payable isTradeable returns (bool) {
return super.decreaseApprovalAndCall(spender, subtractedValue, data);
}
function setDistributor(address newDistributor) external onlyOwner {
distributor = newDistributor;
}
function emergencyERC20Drain(ERC20 token, uint256 amount) external onlyOwner {
token.transfer(owner, amount);
}
}
contract StakeInterface {
function hasStake(address _address) external view returns (bool);
}
contract MainframeStake is Ownable, StakeInterface {
using SafeMath for uint256;
ERC20 token;
uint256 public arrayLimit = 200;
uint256 public totalDepositBalance;
uint256 public requiredStake;
mapping (address => uint256) public balances;
struct Staker {
uint256 stakedAmount;
address stakerAddress;
}
mapping (address => Staker) public whitelist;
constructor(address tokenAddress) public {
token = ERC20(tokenAddress);
requiredStake = 1 ether;
}
function stake(address staker, address whitelistAddress) external returns (bool success) {
require(whitelist[whitelistAddress].stakerAddress == 0x0);
require(staker == msg.sender || (msg.sender == address(token) && staker == tx.origin));
whitelist[whitelistAddress].stakerAddress = staker;
whitelist[whitelistAddress].stakedAmount = requiredStake;
deposit(staker, requiredStake);
emit Staked(staker);
return true;
}
function unstake(address whitelistAddress) external {
require(whitelist[whitelistAddress].stakerAddress == msg.sender);
uint256 stakedAmount = whitelist[whitelistAddress].stakedAmount;
delete whitelist[whitelistAddress];
withdraw(msg.sender, stakedAmount);
emit Unstaked(msg.sender);
}
function deposit(address fromAddress, uint256 depositAmount) private returns (bool success) {
token.transferFrom(fromAddress, this, depositAmount);
balances[fromAddress] = balances[fromAddress].add(depositAmount);
totalDepositBalance = totalDepositBalance.add(depositAmount);
emit Deposit(fromAddress, depositAmount, balances[fromAddress]);
return true;
}
function withdraw(address toAddress, uint256 withdrawAmount) private returns (bool success) {
require(balances[toAddress] >= withdrawAmount);
token.transfer(toAddress, withdrawAmount);
balances[toAddress] = balances[toAddress].sub(withdrawAmount);
totalDepositBalance = totalDepositBalance.sub(withdrawAmount);
emit Withdrawal(toAddress, withdrawAmount, balances[toAddress]);
return true;
}
function balanceOf(address _address) external view returns (uint256 balance) {
return balances[_address];
}
function totalStaked() external view returns (uint256) {
return totalDepositBalance;
}
function hasStake(address _address) external view returns (bool) {
return whitelist[_address].stakedAmount > 0;
}
function requiredStake() external view returns (uint256) {
return requiredStake;
}
function setRequiredStake(uint256 value) external onlyOwner {
requiredStake = value;
}
function setArrayLimit(uint256 newLimit) external onlyOwner {
arrayLimit = newLimit;
}
function refundBalances(address[] addresses) external onlyOwner {
require(addresses.length <= arrayLimit);
for (uint256 i = 0; i < addresses.length; i++) {
address _address = addresses[i];
require(balances[_address] > 0);
token.transfer(_address, balances[_address]);
totalDepositBalance = totalDepositBalance.sub(balances[_address]);
emit RefundedBalance(_address, balances[_address]);
balances[_address] = 0;
}
}
function emergencyERC20Drain(ERC20 _token) external onlyOwner {
uint256 drainAmount;
if (address(_token) == address(token)) {
drainAmount = _token.balanceOf(this).sub(totalDepositBalance);
} else {
drainAmount = _token.balanceOf(this);
}
_token.transfer(owner, drainAmount);
}
function destroy() external onlyOwner {
require(token.balanceOf(this) == 0);
selfdestruct(owner);
}
event Staked(address indexed owner);
event Unstaked(address indexed owner);
event Deposit(address indexed _address, uint256 depositAmount, uint256 balance);
event Withdrawal(address indexed _address, uint256 withdrawAmount, uint256 balance);
event RefundedBalance(address indexed _address, uint256 refundAmount);
} | 0 |
pragma solidity ^0.4.25;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0);
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
contract Ownable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
function owner() public view returns(address) {
return _owner;
}
modifier onlyOwner() {
require(isOwner());
_;
}
function isOwner() public view returns(bool) {
return msg.sender == _owner;
}
function 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() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
contract Freezable is Ownable{
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
modifier whenUnfrozen(address target) {
require(!frozenAccount[target]);
_;
}
function freezeAccount(address target, bool freeze) onlyOwner public{
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
}
contract XERC20 is Pausable, Freezable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
event Burn(address account, uint256 value);
function burn(address account, uint256 value) external onlyOwner returns (bool) {
_burn(account, value);
emit Burn(account, value);
return true;
}
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 whenNotPaused whenUnfrozen(msg.sender) returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function approve(address spender, uint256 value) public whenNotPaused 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 whenNotPaused whenUnfrozen(from) 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 whenNotPaused 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 whenNotPaused 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 UCXToken is XERC20 {
string public constant name = "UCXToken";
string public constant symbol = "UCX";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 2100000000 * (10 ** uint256(decimals));
address address1 = 0x777721dEe44137F84D016D9B8f4D5F654CE5c777;
address address2 = 0x7770533000cB5CF3f55a20caF22c60438F867777;
address address3 = 0x7772082428388bd2007822FaDedF33697fF3e777;
address address4 = 0x777036867957eEE02181157093131CAE6D2fd777;
address address5 = 0x7776BdF1d3db7536e12143785cD107FdF2cF6777;
address address6 = 0x7778211a82cDC694c59Dd7451e3FE17E14987777;
address address7 = 0x777775152FA83fb685d114A6B1302432A4ff8777;
address address8 = 0x7770ae1b5e71b5FccF1eA236C5CD069850817777;
address address9 = 0x7776312f8d9aDd9542F4C4a343cC55fBB3bf1777;
address address10 = 0x7773951672A5A097bAF3AC40bc425066a00d7777;
address address11 = 0x7771232DDd8d5a4d93Ea958C7B99611B2fe17777;
address address12 = 0x7778B8b23b7D872e02afb9A7413d103775dC5777;
constructor() public {
_mint(msg.sender, INITIAL_SUPPLY);
transfer(address1, 255000000 * (10 ** uint256(decimals)));
transfer(address2, 34000000 * (10 ** uint256(decimals)));
transfer(address3, 34000000 * (10 ** uint256(decimals)));
transfer(address4, 34000000 * (10 ** uint256(decimals)));
transfer(address5, 34000000 * (10 ** uint256(decimals)));
transfer(address6, 34000000 * (10 ** uint256(decimals)));
transfer(address7, 340000000 * (10 ** uint256(decimals)));
transfer(address8, 510000000 * (10 ** uint256(decimals)));
transfer(address9, 170000000 * (10 ** uint256(decimals)));
transfer(address10, 170000000 * (10 ** uint256(decimals)));
transfer(address11, 85000000 * (10 ** uint256(decimals)));
transfer(address12, 400000000 * (10 ** uint256(decimals)));
freezeAccount(address12,true);
}
} | 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);
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 KGC is ERC20Interface {
uint256 public constant decimals = 5;
string public constant symbol = "KGC";
string public constant name = "KGC";
uint256 public _totalSupply = 100000000000000;
address public owner;
mapping(address => uint256) private balances;
mapping(address => mapping (address => uint256)) private allowed;
mapping(address => bool) private approvedInvestorList;
mapping(address => uint256) private deposit;
uint256 public totalTokenSold = 0;
modifier onlyPayloadSize(uint size) {
if(msg.data.length < size + 4) {
revert();
}
_;
}
function KGC()
public {
owner = msg.sender;
balances[owner] = _totalSupply;
}
function totalSupply()
public
constant
returns (uint256) {
return _totalSupply;
}
function balanceOf(address _addr)
public
constant
returns (uint256) {
return balances[_addr];
}
function isApprovedInvestor(address _addr)
public
constant
returns (bool) {
return approvedInvestorList[_addr];
}
function getDeposit(address _addr)
public
constant
returns(uint256){
return deposit[_addr];
}
function transfer(address _to, uint256 _amount)
public
returns (bool) {
require(_to != address(0));
require(_amount <= balances[msg.sender]);
require(_amount >= 0);
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) {
require(_to != address(0));
require(_amount <= balances[msg.sender]);
require(_amount >= 0);
if (balances[_from] >= _amount && _amount > 0 && allowed[_from][msg.sender] >= _amount) {
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) {
require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
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];
}
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 = 30153600;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0x31e77776bE54D71e6b1372377AfFA6F0eB18D6BD;
}
function tokenBalance() constant public returns (uint256){
return token_reward.balanceOf(this);
}
function lock() public onlyOwner returns (bool){
require(!isLocked);
require(tokenBalance() > 0);
start_time = now;
end_time = start_time.add(fifty_two_weeks);
isLocked = true;
}
function lockOver() constant public returns (bool){
uint256 current_time = now;
return current_time > end_time;
}
function release() onlyOwner public{
require(isLocked);
require(!isReleased);
require(lockOver());
uint256 token_amount = tokenBalance();
token_reward.transfer( beneficiary, token_amount);
emit TokenReleased(beneficiary, token_amount);
isReleased = true;
}
} | 0 |
pragma solidity ^0.4.24;
contract TokenInfo {
uint256 public constant PRIVATESALE_BASE_PRICE_IN_WEI = 200000000000000;
uint256 public constant PRESALE_BASE_PRICE_IN_WEI = 600000000000000;
uint256 public constant ICO_BASE_PRICE_IN_WEI = 800000000000000;
uint256 public constant FIRSTSALE_BASE_PRICE_IN_WEI = 200000000000000;
uint256 public constant MIN_PURCHASE_OTHERSALES = 80000000000000000;
uint256 public constant MIN_PURCHASE = 1000000000000000000;
uint256 public constant MAX_PURCHASE = 1000000000000000000000;
uint256 public constant PRESALE_PERCENTAGE_1 = 10;
uint256 public constant PRESALE_PERCENTAGE_2 = 15;
uint256 public constant PRESALE_PERCENTAGE_3 = 20;
uint256 public constant PRESALE_PERCENTAGE_4 = 25;
uint256 public constant PRESALE_PERCENTAGE_5 = 35;
uint256 public constant ICO_PERCENTAGE_1 = 5;
uint256 public constant ICO_PERCENTAGE_2 = 10;
uint256 public constant ICO_PERCENTAGE_3 = 15;
uint256 public constant ICO_PERCENTAGE_4 = 20;
uint256 public constant ICO_PERCENTAGE_5 = 25;
uint256 public constant PRESALE_LEVEL_1 = 5000000000000000000;
uint256 public constant PRESALE_LEVEL_2 = 10000000000000000000;
uint256 public constant PRESALE_LEVEL_3 = 15000000000000000000;
uint256 public constant PRESALE_LEVEL_4 = 20000000000000000000;
uint256 public constant PRESALE_LEVEL_5 = 25000000000000000000;
uint256 public constant ICO_LEVEL_1 = 6666666666666666666;
uint256 public constant ICO_LEVEL_2 = 13333333333333333333;
uint256 public constant ICO_LEVEL_3 = 20000000000000000000;
uint256 public constant ICO_LEVEL_4 = 26666666666666666666;
uint256 public constant ICO_LEVEL_5 = 33333333333333333333;
uint256 public constant PRIVATESALE_TOKENCAP = 18750000;
uint256 public constant PRESALE_TOKENCAP = 18750000;
uint256 public constant ICO_TOKENCAP = 22500000;
uint256 public constant FIRSTSALE_TOKENCAP = 5000000;
uint256 public constant LEDTEAM_TOKENS = 35000000;
uint256 public constant TOTAL_TOKENCAP = 100000000;
uint256 public constant DECIMALS_MULTIPLIER = 1 ether;
address public constant LED_MULTISIG = 0x865e785f98b621c5fdde70821ca7cea9eeb77ef4;
}
contract Ownable {
address public owner;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
constructor() public {}
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused {
require(paused);
_;
}
function pause() public onlyOwner whenNotPaused returns (bool) {
paused = true;
emit Pause();
return true;
}
function unpause() public onlyOwner whenPaused returns (bool) {
paused = false;
emit Unpause();
return true;
}
}
contract ApproveAndCallReceiver {
function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public;
}
contract Controllable {
address public controller;
constructor() public {
controller = msg.sender;
}
modifier onlyController() {
require(msg.sender == controller);
_;
}
function transferControl(address newController) public onlyController {
if (newController != address(0)) {
controller = newController;
}
}
}
contract ControllerInterface {
function proxyPayment(address _owner) public payable returns(bool);
function onTransfer(address _from, address _to, uint _amount) public returns(bool);
function onApprove(address _owner, address _spender, uint _amount) public returns(bool);
}
contract ERC20 {
uint256 public totalSupply;
function balanceOf(address _owner) public constant returns (uint256);
function transfer(address _to, uint256 _value) public returns (bool);
function transferFrom(address _from, address _to, uint256 _amount) public returns (bool);
function approve(address _spender, uint256 _amount) public returns (bool);
function allowance(address _owner, address _spender) public constant returns (uint256);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract Crowdsale is Pausable, TokenInfo {
using SafeMath for uint256;
LedTokenInterface public ledToken;
uint256 public startTime;
uint256 public endTime;
uint256 public totalWeiRaised;
uint256 public tokensMinted;
uint256 public totalSupply;
uint256 public contributors;
uint256 public surplusTokens;
bool public finalized;
bool public ledTokensAllocated;
address public ledMultiSig = LED_MULTISIG;
bool public started = false;
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
event NewClonedToken(address indexed _cloneToken);
event OnTransfer(address _from, address _to, uint _amount);
event OnApprove(address _owner, address _spender, uint _amount);
event LogInt(string _name, uint256 _value);
event Finalized();
function forwardFunds() internal {
ledMultiSig.transfer(msg.value);
}
function validPurchase() internal constant returns (bool) {
uint256 current = now;
bool presaleStarted = (current >= startTime || started);
bool presaleNotEnded = current <= endTime;
bool nonZeroPurchase = msg.value != 0;
return nonZeroPurchase && presaleStarted && presaleNotEnded;
}
function totalSupply() public constant returns (uint256) {
return ledToken.totalSupply();
}
function balanceOf(address _owner) public constant returns (uint256) {
return ledToken.balanceOf(_owner);
}
function changeController(address _newController) public onlyOwner {
require(isContract(_newController));
ledToken.transferControl(_newController);
}
function enableMasterTransfers() public onlyOwner {
ledToken.enableMasterTransfers(true);
}
function lockMasterTransfers() public onlyOwner {
ledToken.enableMasterTransfers(false);
}
function forceStart() public onlyOwner {
started = true;
}
function isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0)
return false;
assembly {
size := extcodesize(_addr)
}
return size>0;
}
modifier whenNotFinalized() {
require(!finalized);
_;
}
}
contract FirstSale is Crowdsale {
uint256 public tokenCap = FIRSTSALE_TOKENCAP;
uint256 public cap = tokenCap * DECIMALS_MULTIPLIER;
uint256 public weiCap = tokenCap * FIRSTSALE_BASE_PRICE_IN_WEI;
constructor(address _tokenAddress, uint256 _startTime, uint256 _endTime) public {
startTime = _startTime;
endTime = _endTime;
ledToken = LedTokenInterface(_tokenAddress);
assert(_tokenAddress != 0x0);
assert(_startTime > 0);
assert(_endTime > _startTime);
}
function() public payable {
buyTokens(msg.sender);
}
function buyTokens(address _beneficiary) public payable whenNotPaused whenNotFinalized {
require(_beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
require(weiAmount >= MIN_PURCHASE && weiAmount <= MAX_PURCHASE);
uint256 priceInWei = FIRSTSALE_BASE_PRICE_IN_WEI;
totalWeiRaised = totalWeiRaised.add(weiAmount);
uint256 tokens = weiAmount.mul(DECIMALS_MULTIPLIER).div(priceInWei);
tokensMinted = tokensMinted.add(tokens);
require(tokensMinted < cap);
contributors = contributors.add(1);
ledToken.mint(_beneficiary, tokens);
emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens);
forwardFunds();
}
function getInfo() public view returns(uint256, uint256, string, bool, uint256, uint256, uint256,
bool, uint256, uint256){
uint256 decimals = 18;
string memory symbol = "LED";
bool transfersEnabled = ledToken.transfersEnabled();
return (
TOTAL_TOKENCAP,
decimals,
symbol,
transfersEnabled,
contributors,
totalWeiRaised,
tokenCap,
started,
startTime,
endTime
);
}
function finalize() public onlyOwner {
require(paused);
require(!finalized);
surplusTokens = cap - tokensMinted;
ledToken.mint(ledMultiSig, surplusTokens);
ledToken.transferControl(owner);
emit Finalized();
finalized = true;
}
}
contract LedToken is Controllable {
using SafeMath for uint256;
LedTokenInterface public parentToken;
TokenFactoryInterface public tokenFactory;
string public name;
string public symbol;
string public version;
uint8 public decimals;
uint256 public parentSnapShotBlock;
uint256 public creationBlock;
bool public transfersEnabled;
bool public masterTransfersEnabled;
address public masterWallet = 0x865e785f98b621c5fdde70821ca7cea9eeb77ef4;
struct Checkpoint {
uint128 fromBlock;
uint128 value;
}
Checkpoint[] totalSupplyHistory;
mapping(address => Checkpoint[]) balances;
mapping (address => mapping (address => uint)) allowed;
bool public mintingFinished = false;
bool public presaleBalancesLocked = false;
uint256 public totalSupplyAtCheckpoint;
event MintFinished();
event NewCloneToken(address indexed cloneToken);
event Approval(address indexed _owner, address indexed _spender, uint256 _amount);
event Transfer(address indexed from, address indexed to, uint256 value);
constructor(
address _tokenFactory,
address _parentToken,
uint256 _parentSnapShotBlock,
string _tokenName,
string _tokenSymbol
) public {
tokenFactory = TokenFactoryInterface(_tokenFactory);
parentToken = LedTokenInterface(_parentToken);
parentSnapShotBlock = _parentSnapShotBlock;
name = _tokenName;
symbol = _tokenSymbol;
decimals = 18;
transfersEnabled = false;
masterTransfersEnabled = false;
creationBlock = block.number;
version = '0.1';
}
function totalSupply() public constant returns (uint256) {
return totalSupplyAt(block.number);
}
function totalSupplyAt(uint256 _blockNumber) public constant returns(uint256) {
if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0x0) {
return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
} else {
return 0;
}
} else {
return getValueAt(totalSupplyHistory, _blockNumber);
}
}
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balanceOfAt(_owner, block.number);
}
function balanceOfAt(address _owner, uint256 _blockNumber) public constant returns (uint256) {
if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0x0) {
return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
} else {
return 0;
}
} else {
return getValueAt(balances[_owner], _blockNumber);
}
}
function transfer(address _to, uint256 _amount) public returns (bool success) {
return doTransfer(msg.sender, _to, _amount);
}
function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success) {
require(allowed[_from][msg.sender] >= _amount);
allowed[_from][msg.sender] -= _amount;
return doTransfer(_from, _to, _amount);
}
function approve(address _spender, uint256 _amount) public returns (bool success) {
require(transfersEnabled);
require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _amount;
emit Approval(msg.sender, _spender, _amount);
return true;
}
function approveAndCall(address _spender, uint256 _amount, bytes _extraData) public returns (bool success) {
approve(_spender, _amount);
ApproveAndCallReceiver(_spender).receiveApproval(
msg.sender,
_amount,
this,
_extraData
);
return true;
}
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
function doTransfer(address _from, address _to, uint256 _amount) internal returns(bool) {
if (msg.sender != masterWallet) {
require(transfersEnabled);
} else {
require(masterTransfersEnabled);
}
require(_amount > 0);
require(parentSnapShotBlock < block.number);
require((_to != address(0)) && (_to != address(this)));
uint256 previousBalanceFrom = balanceOfAt(_from, block.number);
require(previousBalanceFrom >= _amount);
updateValueAtNow(balances[_from], previousBalanceFrom - _amount);
uint256 previousBalanceTo = balanceOfAt(_to, block.number);
require(previousBalanceTo + _amount >= previousBalanceTo);
updateValueAtNow(balances[_to], previousBalanceTo + _amount);
emit Transfer(_from, _to, _amount);
return true;
}
function mint(address _owner, uint256 _amount) public onlyController canMint returns (bool) {
uint256 curTotalSupply = totalSupply();
uint256 previousBalanceTo = balanceOf(_owner);
require(curTotalSupply + _amount >= curTotalSupply);
require(previousBalanceTo + _amount >= previousBalanceTo);
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
emit Transfer(0, _owner, _amount);
return true;
}
modifier canMint() {
require(!mintingFinished);
_;
}
function importPresaleBalances(address[] _addresses, uint256[] _balances) public onlyController returns (bool) {
require(presaleBalancesLocked == false);
for (uint256 i = 0; i < _addresses.length; i++) {
totalSupplyAtCheckpoint += _balances[i];
updateValueAtNow(balances[_addresses[i]], _balances[i]);
updateValueAtNow(totalSupplyHistory, totalSupplyAtCheckpoint);
emit Transfer(0, _addresses[i], _balances[i]);
}
return true;
}
function lockPresaleBalances() public onlyController returns (bool) {
presaleBalancesLocked = true;
return true;
}
function finishMinting() public onlyController returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
function enableTransfers(bool _value) public onlyController {
transfersEnabled = _value;
}
function enableMasterTransfers(bool _value) public onlyController {
masterTransfersEnabled = _value;
}
function getValueAt(Checkpoint[] storage _checkpoints, uint256 _block) constant internal returns (uint256) {
if (_checkpoints.length == 0)
return 0;
if (_block >= _checkpoints[_checkpoints.length-1].fromBlock)
return _checkpoints[_checkpoints.length-1].value;
if (_block < _checkpoints[0].fromBlock)
return 0;
uint256 min = 0;
uint256 max = _checkpoints.length-1;
while (max > min) {
uint256 mid = (max + min + 1) / 2;
if (_checkpoints[mid].fromBlock<=_block) {
min = mid;
} else {
max = mid-1;
}
}
return _checkpoints[min].value;
}
function updateValueAtNow(Checkpoint[] storage _checkpoints, uint256 _value) internal {
if ((_checkpoints.length == 0) || (_checkpoints[_checkpoints.length-1].fromBlock < block.number)) {
Checkpoint storage newCheckPoint = _checkpoints[_checkpoints.length++];
newCheckPoint.fromBlock = uint128(block.number);
newCheckPoint.value = uint128(_value);
} else {
Checkpoint storage oldCheckPoint = _checkpoints[_checkpoints.length-1];
oldCheckPoint.value = uint128(_value);
}
}
function min(uint256 a, uint256 b) internal pure returns (uint) {
return a < b ? a : b;
}
function createCloneToken(uint256 _snapshotBlock, string _name, string _symbol) public returns(address) {
if (_snapshotBlock == 0) {
_snapshotBlock = block.number;
}
if (_snapshotBlock > block.number) {
_snapshotBlock = block.number;
}
LedToken cloneToken = tokenFactory.createCloneToken(
this,
_snapshotBlock,
_name,
_symbol
);
cloneToken.transferControl(msg.sender);
emit NewCloneToken(address(cloneToken));
return address(cloneToken);
}
}
contract LedTokenInterface is Controllable {
bool public transfersEnabled;
event Mint(address indexed to, uint256 amount);
event MintFinished();
event ClaimedTokens(address indexed _token, address indexed _owner, uint _amount);
event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
event Approval(address indexed _owner, address indexed _spender, uint256 _amount);
event Transfer(address indexed from, address indexed to, uint256 value);
function totalSupply() public constant returns (uint);
function totalSupplyAt(uint _blockNumber) public constant returns(uint);
function balanceOf(address _owner) public constant returns (uint256 balance);
function balanceOfAt(address _owner, uint _blockNumber) public constant returns (uint);
function transfer(address _to, uint256 _amount) public returns (bool success);
function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success);
function approve(address _spender, uint256 _amount) public returns (bool success);
function approveAndCall(address _spender, uint256 _amount, bytes _extraData) public returns (bool success);
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
function mint(address _owner, uint _amount) public returns (bool);
function importPresaleBalances(address[] _addresses, uint256[] _balances, address _presaleAddress) public returns (bool);
function lockPresaleBalances() public returns (bool);
function finishMinting() public returns (bool);
function enableTransfers(bool _value) public;
function enableMasterTransfers(bool _value) public;
function createCloneToken(uint _snapshotBlock, string _cloneTokenName, string _cloneTokenSymbol) public returns (address);
}
contract Presale is Crowdsale {
uint256 public tokenCap = PRESALE_TOKENCAP;
uint256 public cap = tokenCap * DECIMALS_MULTIPLIER;
uint256 public weiCap = tokenCap * PRESALE_BASE_PRICE_IN_WEI;
constructor(address _tokenAddress, uint256 _startTime, uint256 _endTime) public {
startTime = _startTime;
endTime = _endTime;
ledToken = LedTokenInterface(_tokenAddress);
assert(_tokenAddress != 0x0);
assert(_startTime > 0);
assert(_endTime > _startTime);
}
function() public payable {
buyTokens(msg.sender);
}
function buyTokens(address _beneficiary) public payable whenNotPaused whenNotFinalized {
require(_beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
require(weiAmount >= MIN_PURCHASE_OTHERSALES && weiAmount <= MAX_PURCHASE);
uint256 priceInWei = PRESALE_BASE_PRICE_IN_WEI;
totalWeiRaised = totalWeiRaised.add(weiAmount);
uint256 bonusPercentage = determineBonus(weiAmount);
uint256 bonusTokens;
uint256 initialTokens = weiAmount.mul(DECIMALS_MULTIPLIER).div(priceInWei);
if(bonusPercentage>0){
uint256 initialDivided = initialTokens.div(100);
bonusTokens = initialDivided.mul(bonusPercentage);
} else {
bonusTokens = 0;
}
uint256 tokens = initialTokens.add(bonusTokens);
tokensMinted = tokensMinted.add(tokens);
require(tokensMinted < cap);
contributors = contributors.add(1);
ledToken.mint(_beneficiary, tokens);
emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens);
forwardFunds();
}
function determineBonus(uint256 _wei) public view returns (uint256) {
if(_wei > PRESALE_LEVEL_1) {
if(_wei > PRESALE_LEVEL_2) {
if(_wei > PRESALE_LEVEL_3) {
if(_wei > PRESALE_LEVEL_4) {
if(_wei > PRESALE_LEVEL_5) {
return PRESALE_PERCENTAGE_5;
} else {
return PRESALE_PERCENTAGE_4;
}
} else {
return PRESALE_PERCENTAGE_3;
}
} else {
return PRESALE_PERCENTAGE_2;
}
} else {
return PRESALE_PERCENTAGE_1;
}
} else {
return 0;
}
}
function finalize() public onlyOwner {
require(paused);
require(!finalized);
surplusTokens = cap - tokensMinted;
ledToken.mint(ledMultiSig, surplusTokens);
ledToken.transferControl(owner);
emit Finalized();
finalized = true;
}
function getInfo() public view returns(uint256, uint256, string, bool, uint256, uint256, uint256,
bool, uint256, uint256){
uint256 decimals = 18;
string memory symbol = "LED";
bool transfersEnabled = ledToken.transfersEnabled();
return (
TOTAL_TOKENCAP,
decimals,
symbol,
transfersEnabled,
contributors,
totalWeiRaised,
tokenCap,
started,
startTime,
endTime
);
}
function getInfoLevels() public view returns(uint256, uint256, uint256, uint256, uint256, uint256,
uint256, uint256, uint256, uint256){
return (
PRESALE_LEVEL_1,
PRESALE_LEVEL_2,
PRESALE_LEVEL_3,
PRESALE_LEVEL_4,
PRESALE_LEVEL_5,
PRESALE_PERCENTAGE_1,
PRESALE_PERCENTAGE_2,
PRESALE_PERCENTAGE_3,
PRESALE_PERCENTAGE_4,
PRESALE_PERCENTAGE_5
);
}
}
contract PrivateSale is Crowdsale {
uint256 public tokenCap = PRIVATESALE_TOKENCAP;
uint256 public cap = tokenCap * DECIMALS_MULTIPLIER;
uint256 public weiCap = tokenCap * PRIVATESALE_BASE_PRICE_IN_WEI;
constructor(address _tokenAddress, uint256 _startTime, uint256 _endTime) public {
startTime = _startTime;
endTime = _endTime;
ledToken = LedTokenInterface(_tokenAddress);
assert(_tokenAddress != 0x0);
assert(_startTime > 0);
assert(_endTime > _startTime);
}
function() public payable {
buyTokens(msg.sender);
}
function buyTokens(address _beneficiary) public payable whenNotPaused whenNotFinalized {
require(_beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
require(weiAmount >= MIN_PURCHASE_OTHERSALES && weiAmount <= MAX_PURCHASE);
uint256 priceInWei = PRIVATESALE_BASE_PRICE_IN_WEI;
totalWeiRaised = totalWeiRaised.add(weiAmount);
uint256 tokens = weiAmount.mul(DECIMALS_MULTIPLIER).div(priceInWei);
tokensMinted = tokensMinted.add(tokens);
require(tokensMinted < cap);
contributors = contributors.add(1);
ledToken.mint(_beneficiary, tokens);
emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens);
forwardFunds();
}
function finalize() public onlyOwner {
require(paused);
require(!finalized);
surplusTokens = cap - tokensMinted;
ledToken.mint(ledMultiSig, surplusTokens);
ledToken.transferControl(owner);
emit Finalized();
finalized = true;
}
function getInfo() public view returns(uint256, uint256, string, bool, uint256, uint256, uint256,
bool, uint256, uint256){
uint256 decimals = 18;
string memory symbol = "LED";
bool transfersEnabled = ledToken.transfersEnabled();
return (
TOTAL_TOKENCAP,
decimals,
symbol,
transfersEnabled,
contributors,
totalWeiRaised,
tokenCap,
started,
startTime,
endTime
);
}
}
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 TokenFactory {
function createCloneToken(
address _parentToken,
uint _snapshotBlock,
string _tokenName,
string _tokenSymbol
) public returns (LedToken) {
LedToken newToken = new LedToken(
this,
_parentToken,
_snapshotBlock,
_tokenName,
_tokenSymbol
);
newToken.transferControl(msg.sender);
return newToken;
}
}
contract TokenFactoryInterface {
function createCloneToken(
address _parentToken,
uint _snapshotBlock,
string _tokenName,
string _tokenSymbol
) public returns (LedToken newToken);
}
contract TokenSale is Crowdsale {
uint256 public tokenCap = ICO_TOKENCAP;
uint256 public cap = tokenCap * DECIMALS_MULTIPLIER;
uint256 public weiCap = tokenCap * ICO_BASE_PRICE_IN_WEI;
uint256 public allocatedTokens;
constructor(address _tokenAddress, uint256 _startTime, uint256 _endTime) public {
startTime = _startTime;
endTime = _endTime;
ledToken = LedTokenInterface(_tokenAddress);
assert(_tokenAddress != 0x0);
assert(_startTime > 0);
assert(_endTime > _startTime);
}
function() public payable {
buyTokens(msg.sender);
}
function buyTokens(address _beneficiary) public payable whenNotPaused whenNotFinalized {
require(_beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
require(weiAmount >= MIN_PURCHASE_OTHERSALES && weiAmount <= MAX_PURCHASE);
uint256 priceInWei = ICO_BASE_PRICE_IN_WEI;
totalWeiRaised = totalWeiRaised.add(weiAmount);
uint256 bonusPercentage = determineBonus(weiAmount);
uint256 bonusTokens;
uint256 initialTokens = weiAmount.mul(DECIMALS_MULTIPLIER).div(priceInWei);
if(bonusPercentage>0){
uint256 initialDivided = initialTokens.div(100);
bonusTokens = initialDivided.mul(bonusPercentage);
} else {
bonusTokens = 0;
}
uint256 tokens = initialTokens.add(bonusTokens);
tokensMinted = tokensMinted.add(tokens);
require(tokensMinted < cap);
contributors = contributors.add(1);
ledToken.mint(_beneficiary, tokens);
emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens);
forwardFunds();
}
function determineBonus(uint256 _wei) public view returns (uint256) {
if(_wei > ICO_LEVEL_1) {
if(_wei > ICO_LEVEL_2) {
if(_wei > ICO_LEVEL_3) {
if(_wei > ICO_LEVEL_4) {
if(_wei > ICO_LEVEL_5) {
return ICO_PERCENTAGE_5;
} else {
return ICO_PERCENTAGE_4;
}
} else {
return ICO_PERCENTAGE_3;
}
} else {
return ICO_PERCENTAGE_2;
}
} else {
return ICO_PERCENTAGE_1;
}
} else {
return 0;
}
}
function allocateLedTokens() public onlyOwner whenNotFinalized {
require(!ledTokensAllocated);
allocatedTokens = LEDTEAM_TOKENS.mul(DECIMALS_MULTIPLIER);
ledToken.mint(ledMultiSig, allocatedTokens);
ledTokensAllocated = true;
}
function finalize() public onlyOwner {
require(paused);
require(ledTokensAllocated);
surplusTokens = cap - tokensMinted;
ledToken.mint(ledMultiSig, surplusTokens);
ledToken.finishMinting();
ledToken.enableTransfers(true);
emit Finalized();
finalized = true;
}
function getInfo() public view returns(uint256, uint256, string, bool, uint256, uint256, uint256,
bool, uint256, uint256){
uint256 decimals = 18;
string memory symbol = "LED";
bool transfersEnabled = ledToken.transfersEnabled();
return (
TOTAL_TOKENCAP,
decimals,
symbol,
transfersEnabled,
contributors,
totalWeiRaised,
tokenCap,
started,
startTime,
endTime
);
}
function getInfoLevels() public view returns(uint256, uint256, uint256, uint256, uint256, uint256,
uint256, uint256, uint256, uint256){
return (
ICO_LEVEL_1,
ICO_LEVEL_2,
ICO_LEVEL_3,
ICO_LEVEL_4,
ICO_LEVEL_5,
ICO_PERCENTAGE_1,
ICO_PERCENTAGE_2,
ICO_PERCENTAGE_3,
ICO_PERCENTAGE_4,
ICO_PERCENTAGE_5
);
}
} | 0 |
pragma solidity ^0.4.8;
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;
}
}
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 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 SafeMathLibExt {
function times(uint a, uint b) returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function divides(uint a, uint b) returns (uint) {
assert(b > 0);
uint c = a / b;
assert(a == b * c + a % b);
return c;
}
function minus(uint a, uint b) returns (uint) {
assert(b <= a);
return a - b;
}
function plus(uint a, uint b) returns (uint) {
uint c = a + b;
assert(c>=a);
return c;
}
}
contract Haltable is Ownable {
bool public halted;
modifier stopInEmergency {
if (halted) throw;
_;
}
modifier stopNonOwnersInEmergency {
if (halted && msg.sender != owner) throw;
_;
}
modifier onlyInEmergency {
if (!halted) throw;
_;
}
function halt() external onlyOwner {
halted = true;
}
function unhalt() external onlyOwner onlyInEmergency {
halted = false;
}
}
contract PricingStrategy {
function isPricingStrategy() public constant returns (bool) {
return true;
}
function isSane(address crowdsale) public constant returns (bool) {
return true;
}
function isPresalePurchase(address purchaser) public constant returns (bool) {
return false;
}
function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount);
}
contract FinalizeAgent {
function isFinalizeAgent() public constant returns(bool) {
return true;
}
function isSane() public constant returns (bool);
function finalizeCrowdsale();
}
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 FractionalERC20Ext is ERC20 {
uint public decimals;
uint public minCap;
}
contract CrowdsaleExt is Haltable {
uint public MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE = 5;
using SafeMathLibExt for uint;
FractionalERC20Ext public token;
PricingStrategy public pricingStrategy;
FinalizeAgent public finalizeAgent;
address public multisigWallet;
uint public minimumFundingGoal;
uint public startsAt;
uint public endsAt;
uint public tokensSold = 0;
uint public weiRaised = 0;
uint public presaleWeiRaised = 0;
uint public investorCount = 0;
uint public loadedRefund = 0;
uint public weiRefunded = 0;
bool public finalized;
bool public requireCustomerId;
bool public isWhiteListed;
address[] public joinedCrowdsales;
uint public joinedCrowdsalesLen = 0;
address public lastCrowdsale;
bool public requiredSignedAddress;
address public signerAddress;
mapping (address => uint256) public investedAmountOf;
mapping (address => uint256) public tokenAmountOf;
struct WhiteListData {
bool status;
uint minCap;
uint maxCap;
}
bool public isUpdatable;
mapping (address => WhiteListData) public earlyParticipantWhitelist;
uint public ownerTestValue;
enum State{Unknown, Preparing, PreFunding, Funding, Success, Failure, Finalized, Refunding}
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
event Refund(address investor, uint weiAmount);
event InvestmentPolicyChanged(bool newRequireCustomerId, bool newRequiredSignedAddress, address newSignerAddress);
event Whitelisted(address addr, bool status);
event StartsAtChanged(uint newStartsAt);
event EndsAtChanged(uint newEndsAt);
function CrowdsaleExt(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal, bool _isUpdatable, bool _isWhiteListed) {
owner = msg.sender;
token = FractionalERC20Ext(_token);
setPricingStrategy(_pricingStrategy);
multisigWallet = _multisigWallet;
if(multisigWallet == 0) {
throw;
}
if(_start == 0) {
throw;
}
startsAt = _start;
if(_end == 0) {
throw;
}
endsAt = _end;
if(startsAt >= endsAt) {
throw;
}
minimumFundingGoal = _minimumFundingGoal;
isUpdatable = _isUpdatable;
isWhiteListed = _isWhiteListed;
}
function() payable {
throw;
}
function investInternal(address receiver, uint128 customerId) stopInEmergency private {
if(getState() == State.PreFunding) {
throw;
} else if(getState() == State.Funding) {
if(isWhiteListed) {
if(!earlyParticipantWhitelist[receiver].status) {
throw;
}
}
} else {
throw;
}
uint weiAmount = msg.value;
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised - presaleWeiRaised, tokensSold, msg.sender, token.decimals());
if(tokenAmount == 0) {
throw;
}
if(isWhiteListed) {
if(tokenAmount < earlyParticipantWhitelist[receiver].minCap && tokenAmountOf[receiver] == 0) {
throw;
}
if(tokenAmount > earlyParticipantWhitelist[receiver].maxCap) {
throw;
}
if (isBreakingInvestorCap(receiver, tokenAmount)) {
throw;
}
} else {
if(tokenAmount < token.minCap() && tokenAmountOf[receiver] == 0) {
throw;
}
}
if(investedAmountOf[receiver] == 0) {
investorCount++;
}
investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);
weiRaised = weiRaised.plus(weiAmount);
tokensSold = tokensSold.plus(tokenAmount);
if(pricingStrategy.isPresalePurchase(receiver)) {
presaleWeiRaised = presaleWeiRaised.plus(weiAmount);
}
if(isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold)) {
throw;
}
assignTokens(receiver, tokenAmount);
if(!multisigWallet.send(weiAmount)) throw;
if (isWhiteListed) {
uint num = 0;
for (var i = 0; i < joinedCrowdsalesLen; i++) {
if (this == joinedCrowdsales[i])
num = i;
}
if (num + 1 < joinedCrowdsalesLen) {
for (var j = num + 1; j < joinedCrowdsalesLen; j++) {
CrowdsaleExt crowdsale = CrowdsaleExt(joinedCrowdsales[j]);
crowdsale.updateEarlyParicipantWhitelist(msg.sender, this, tokenAmount);
}
}
}
Invested(receiver, weiAmount, tokenAmount, customerId);
}
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner {
uint tokenAmount = fullTokens * 10**token.decimals();
uint weiAmount = weiPrice * fullTokens;
weiRaised = weiRaised.plus(weiAmount);
tokensSold = tokensSold.plus(tokenAmount);
investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);
assignTokens(receiver, tokenAmount);
Invested(receiver, weiAmount, tokenAmount, 0);
}
function investWithSignedAddress(address addr, uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable {
bytes32 hash = sha256(addr);
if (ecrecover(hash, v, r, s) != signerAddress) throw;
if(customerId == 0) throw;
investInternal(addr, customerId);
}
function investWithCustomerId(address addr, uint128 customerId) public payable {
if(requiredSignedAddress) throw;
if(customerId == 0) throw;
investInternal(addr, customerId);
}
function invest(address addr) public payable {
if(requireCustomerId) throw;
if(requiredSignedAddress) throw;
investInternal(addr, 0);
}
function buyWithSignedAddress(uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable {
investWithSignedAddress(msg.sender, customerId, v, r, s);
}
function buyWithCustomerId(uint128 customerId) public payable {
investWithCustomerId(msg.sender, customerId);
}
function buy() public payable {
invest(msg.sender);
}
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
if(finalized) {
throw;
}
if(address(finalizeAgent) != 0) {
finalizeAgent.finalizeCrowdsale();
}
finalized = true;
}
function setFinalizeAgent(FinalizeAgent addr) onlyOwner {
finalizeAgent = addr;
if(!finalizeAgent.isFinalizeAgent()) {
throw;
}
}
function setRequireCustomerId(bool value) onlyOwner {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
}
function setRequireSignedAddress(bool value, address _signerAddress) onlyOwner {
requiredSignedAddress = value;
signerAddress = _signerAddress;
InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
}
function setEarlyParicipantWhitelist(address addr, bool status, uint minCap, uint maxCap) onlyOwner {
if (!isWhiteListed) throw;
earlyParticipantWhitelist[addr] = WhiteListData({status:status, minCap:minCap, maxCap:maxCap});
Whitelisted(addr, status);
}
function setEarlyParicipantsWhitelist(address[] addrs, bool[] statuses, uint[] minCaps, uint[] maxCaps) onlyOwner {
if (!isWhiteListed) throw;
for (uint iterator = 0; iterator < addrs.length; iterator++) {
setEarlyParicipantWhitelist(addrs[iterator], statuses[iterator], minCaps[iterator], maxCaps[iterator]);
}
}
function updateEarlyParicipantWhitelist(address addr, address contractAddr, uint tokensBought) {
if (tokensBought < earlyParticipantWhitelist[addr].minCap) throw;
if (!isWhiteListed) throw;
if (addr != msg.sender && contractAddr != msg.sender) throw;
uint newMaxCap = earlyParticipantWhitelist[addr].maxCap;
newMaxCap = newMaxCap.minus(tokensBought);
earlyParticipantWhitelist[addr] = WhiteListData({status:earlyParticipantWhitelist[addr].status, minCap:0, maxCap:newMaxCap});
}
function updateJoinedCrowdsales(address addr) onlyOwner {
joinedCrowdsales[joinedCrowdsalesLen++] = addr;
}
function setLastCrowdsale(address addr) onlyOwner {
lastCrowdsale = addr;
}
function clearJoinedCrowdsales() onlyOwner {
joinedCrowdsalesLen = 0;
}
function updateJoinedCrowdsalesMultiple(address[] addrs) onlyOwner {
clearJoinedCrowdsales();
for (uint iter = 0; iter < addrs.length; iter++) {
if(joinedCrowdsalesLen == joinedCrowdsales.length) {
joinedCrowdsales.length += 1;
}
joinedCrowdsales[joinedCrowdsalesLen++] = addrs[iter];
if (iter == addrs.length - 1)
setLastCrowdsale(addrs[iter]);
}
}
function setStartsAt(uint time) onlyOwner {
if (finalized) throw;
if (!isUpdatable) throw;
if(now > time) {
throw;
}
if(time > endsAt) {
throw;
}
CrowdsaleExt lastCrowdsaleCntrct = CrowdsaleExt(lastCrowdsale);
if (lastCrowdsaleCntrct.finalized()) throw;
startsAt = time;
StartsAtChanged(startsAt);
}
function setEndsAt(uint time) onlyOwner {
if (finalized) throw;
if (!isUpdatable) throw;
if(now > time) {
throw;
}
if(startsAt > time) {
throw;
}
CrowdsaleExt lastCrowdsaleCntrct = CrowdsaleExt(lastCrowdsale);
if (lastCrowdsaleCntrct.finalized()) throw;
uint num = 0;
for (var i = 0; i < joinedCrowdsalesLen; i++) {
if (this == joinedCrowdsales[i])
num = i;
}
if (num + 1 < joinedCrowdsalesLen) {
for (var j = num + 1; j < joinedCrowdsalesLen; j++) {
CrowdsaleExt crowdsale = CrowdsaleExt(joinedCrowdsales[j]);
if (time > crowdsale.startsAt()) throw;
}
}
endsAt = time;
EndsAtChanged(endsAt);
}
function setPricingStrategy(PricingStrategy _pricingStrategy) onlyOwner {
pricingStrategy = _pricingStrategy;
if(!pricingStrategy.isPricingStrategy()) {
throw;
}
}
function setMultisig(address addr) public onlyOwner {
if(investorCount > MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE) {
throw;
}
multisigWallet = addr;
}
function loadRefund() public payable inState(State.Failure) {
if(msg.value == 0) throw;
loadedRefund = loadedRefund.plus(msg.value);
}
function refund() public inState(State.Refunding) {
uint256 weiValue = investedAmountOf[msg.sender];
if (weiValue == 0) throw;
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.plus(weiValue);
Refund(msg.sender, weiValue);
if (!msg.sender.send(weiValue)) throw;
}
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane();
}
function isPricingSane() public constant returns (bool sane) {
return pricingStrategy.isSane(address(this));
}
function getState() public constant returns (State) {
if(finalized) return State.Finalized;
else if (address(finalizeAgent) == 0) return State.Preparing;
else if (!finalizeAgent.isSane()) return State.Preparing;
else if (!pricingStrategy.isSane(address(this))) return State.Preparing;
else if (block.timestamp < startsAt) return State.PreFunding;
else if (block.timestamp <= endsAt && !isCrowdsaleFull()) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
function setOwnerTestValue(uint val) onlyOwner {
ownerTestValue = val;
}
function isCrowdsale() public constant returns (bool) {
return true;
}
modifier inState(State state) {
if(getState() != state) throw;
_;
}
function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) constant returns (bool limitBroken);
function isBreakingInvestorCap(address receiver, uint tokenAmount) constant returns (bool limitBroken);
function isCrowdsaleFull() public constant returns (bool);
function assignTokens(address receiver, uint tokenAmount) private;
}
contract StandardToken is ERC20, SafeMath {
event Minted(address receiver, uint amount);
mapping(address => uint) balances;
mapping (address => mapping (address => uint)) allowed;
function isToken() public constant returns (bool weAre) {
return true;
}
function transfer(address _to, uint _value) returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], _value);
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint _value) returns (bool success) {
uint _allowance = allowed[_from][msg.sender];
balances[_to] = safeAdd(balances[_to], _value);
balances[_from] = safeSub(balances[_from], _value);
allowed[_from][msg.sender] = safeSub(_allowance, _value);
Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
function approve(address _spender, uint _value) returns (bool success) {
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw;
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint remaining) {
return allowed[_owner][_spender];
}
}
contract MintableTokenExt is StandardToken, Ownable {
using SafeMathLibExt for uint;
bool public mintingFinished = false;
mapping (address => bool) public mintAgents;
event MintingAgentChanged(address addr, bool state );
struct ReservedTokensData {
uint inTokens;
uint inPercentage;
}
mapping (address => ReservedTokensData) public reservedTokensList;
address[] public reservedTokensDestinations;
uint public reservedTokensDestinationsLen = 0;
function setReservedTokensList(address addr, uint inTokens, uint inPercentage) onlyOwner {
reservedTokensDestinations.push(addr);
reservedTokensDestinationsLen++;
reservedTokensList[addr] = ReservedTokensData({inTokens:inTokens, inPercentage:inPercentage});
}
function getReservedTokensListValInTokens(address addr) constant returns (uint inTokens) {
return reservedTokensList[addr].inTokens;
}
function getReservedTokensListValInPercentage(address addr) constant returns (uint inPercentage) {
return reservedTokensList[addr].inPercentage;
}
function setReservedTokensListMultiple(address[] addrs, uint[] inTokens, uint[] inPercentage) onlyOwner {
for (uint iterator = 0; iterator < addrs.length; iterator++) {
setReservedTokensList(addrs[iterator], inTokens[iterator], inPercentage[iterator]);
}
}
function mint(address receiver, uint amount) onlyMintAgent canMint public {
totalSupply = totalSupply.plus(amount);
balances[receiver] = balances[receiver].plus(amount);
Transfer(0, receiver, amount);
}
function setMintAgent(address addr, bool state) onlyOwner canMint public {
mintAgents[addr] = state;
MintingAgentChanged(addr, state);
}
modifier onlyMintAgent() {
if(!mintAgents[msg.sender]) {
throw;
}
_;
}
modifier canMint() {
if(mintingFinished) throw;
_;
}
}
contract MintedTokenCappedCrowdsaleExt is CrowdsaleExt {
uint public maximumSellableTokens;
function MintedTokenCappedCrowdsaleExt(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal, uint _maximumSellableTokens, bool _isUpdatable, bool _isWhiteListed) CrowdsaleExt(_token, _pricingStrategy, _multisigWallet, _start, _end, _minimumFundingGoal, _isUpdatable, _isWhiteListed) {
maximumSellableTokens = _maximumSellableTokens;
}
event MaximumSellableTokensChanged(uint newMaximumSellableTokens);
function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) constant returns (bool limitBroken) {
return tokensSoldTotal > maximumSellableTokens;
}
function isBreakingInvestorCap(address addr, uint tokenAmount) constant returns (bool limitBroken) {
if (!isWhiteListed) throw;
uint maxCap = earlyParticipantWhitelist[addr].maxCap;
return (tokenAmountOf[addr].plus(tokenAmount)) > maxCap;
}
function isCrowdsaleFull() public constant returns (bool) {
return tokensSold >= maximumSellableTokens;
}
function assignTokens(address receiver, uint tokenAmount) private {
MintableTokenExt mintableToken = MintableTokenExt(token);
mintableToken.mint(receiver, tokenAmount);
}
function setMaximumSellableTokens(uint tokens) onlyOwner {
if (finalized) throw;
if (!isUpdatable) throw;
CrowdsaleExt lastCrowdsaleCntrct = CrowdsaleExt(lastCrowdsale);
if (lastCrowdsaleCntrct.finalized()) throw;
maximumSellableTokens = tokens;
MaximumSellableTokensChanged(maximumSellableTokens);
}
} | 0 |
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 Eventine is StandardToken {
string public name;
uint8 public decimals;
string public symbol;
string public version = 'H1.0';
uint256 public unitsOneEthCanBuy;
uint256 public totalEthInWei;
address public fundsWallet;
function Eventine() {
balances[msg.sender] = 27000000000000000000000000000;
totalSupply = 27000000000000000000000000000;
name = "Eventine";
decimals = 18;
symbol = "EVT";
unitsOneEthCanBuy = 100000000;
fundsWallet = msg.sender;
}
function() payable{
totalEthInWei = totalEthInWei + msg.value;
uint256 amount = msg.value * unitsOneEthCanBuy;
require(balances[fundsWallet] >= amount);
balances[fundsWallet] = balances[fundsWallet] - amount;
balances[msg.sender] = balances[msg.sender] + amount;
Transfer(fundsWallet, msg.sender, amount);
fundsWallet.transfer(msg.value);
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | 1 |
pragma solidity ^0.4.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 = 0xe19c3d7C560e39E26434807632e5B059f1272afA;
}
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 ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract 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(_to != address(this));
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(_to != address(this));
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 Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() onlyOwner whenNotPaused public {
paused = true;
Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
Unpause();
}
}
contract PausableToken is StandardToken, Pausable {
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 BlockchainInnovationGroup is PausableToken {
string public constant name = "Blockchain Innovation Group";
string public constant symbol = "BIG";
uint8 public constant decimals = 18;
uint256 private constant TOKEN_UNIT = 10 ** uint256(decimals);
uint256 public constant totalSupply = 1000000000 * TOKEN_UNIT;
function BlockchainInnovationGroup() public {
balances[owner] = totalSupply;
Transfer(address(0), owner, balances[owner]);
}
} | 1 |
pragma solidity ^0.4.24;
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address _who) public view returns (uint256);
function transfer(address _to, uint256 _value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
library SafeMath {
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
if (_a == 0) {
return 0;
}
c = _a * _b;
assert(c / _a == _b);
return c;
}
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
return _a / _b;
}
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b <= _a);
return _a - _b;
}
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
c = _a + _b;
assert(c >= _a);
return c;
}
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) internal balances;
uint256 internal totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances[msg.sender]);
require(_to != address(0));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address _owner, address _spender)
public view returns (uint256);
function transferFrom(address _from, address _to, uint256 _value)
public returns (bool);
function approve(address _spender, uint256 _value) public returns (bool);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() public onlyOwner whenNotPaused {
paused = true;
emit Pause();
}
function unpause() public onlyOwner whenPaused {
paused = false;
emit Unpause();
}
}
contract PausableToken is StandardToken, Pausable {
function transfer(
address _to,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
return super.transfer(_to, _value);
}
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
function approve(
address _spender,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
return super.approve(_spender, _value);
}
function increaseApproval(
address _spender,
uint _addedValue
)
public
whenNotPaused
returns (bool success)
{
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(
address _spender,
uint _subtractedValue
)
public
whenNotPaused
returns (bool success)
{
return super.decreaseApproval(_spender, _subtractedValue);
}
}
pragma solidity ^0.4.24;
contract Minebee is PausableToken {
string public constant name = "MineBee";
string public constant symbol = "MB";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 5000000000 * (10 ** uint256(decimals));
constructor() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
event Frozen(address target);
event Unfrozen(address target);
mapping(address => bool) internal freezes;
modifier whenNotFrozen() {
require(!freezes[msg.sender], "Sender account is locked.");
_;
}
function freeze(address _target) public onlyOwner {
freezes[_target] = true;
emit Frozen(_target);
}
function unfreeze(address _target) public onlyOwner {
freezes[_target] = false;
emit Unfrozen(_target);
}
function isFrozen(address _target) public view returns (bool) {
return freezes[_target];
}
function transfer(
address _to,
uint256 _value
)
public
whenNotFrozen
returns (bool)
{
releaseLock(msg.sender);
return super.transfer(_to, _value);
}
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(!freezes[_from], "From account is locked.");
releaseLock(_from);
return super.transferFrom(_from, _to, _value);
}
event Mint(address indexed to, uint256 amount);
function mint(
address _to,
uint256 _amount
)
public
onlyOwner
returns (bool)
{
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
event Burn(address indexed burner, uint256 value);
function burn(address _who, uint256 _value) public onlyOwner {
_burn(_who, _value);
}
function _burn(address _who, uint256 _value) internal {
require(_value <= balances[_who], "Balance is too small.");
balances[_who] = balances[_who].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(_who, _value);
emit Transfer(_who, address(0), _value);
}
struct LockInfo {
uint256 releaseTime;
uint256 balance;
}
mapping(address => LockInfo[]) internal lockInfo;
event Lock(address indexed holder, uint256 value, uint256 releaseTime);
event Unlock(address indexed holder, uint256 value);
function balanceOf(address _holder) public view returns (uint256 balance) {
uint256 lockedBalance = 0;
for(uint256 i = 0; i < lockInfo[_holder].length ; i++ ) {
lockedBalance = lockedBalance.add(lockInfo[_holder][i].balance);
}
return balances[_holder].add(lockedBalance);
}
function releaseLock(address _holder) internal {
for(uint256 i = 0; i < lockInfo[_holder].length ; i++ ) {
if (lockInfo[_holder][i].releaseTime <= now) {
balances[_holder] = balances[_holder].add(lockInfo[_holder][i].balance);
emit Unlock(_holder, lockInfo[_holder][i].balance);
lockInfo[_holder][i].balance = 0;
if (i != lockInfo[_holder].length - 1) {
lockInfo[_holder][i] = lockInfo[_holder][lockInfo[_holder].length - 1];
i--;
}
lockInfo[_holder].length--;
}
}
}
function lockCount(address _holder) public view returns (uint256) {
return lockInfo[_holder].length;
}
function lockState(address _holder, uint256 _idx) public view returns (uint256, uint256) {
return (lockInfo[_holder][_idx].releaseTime, lockInfo[_holder][_idx].balance);
}
function lock(address _holder, uint256 _amount, uint256 _releaseTime) public onlyOwner {
require(balances[_holder] >= _amount, "Balance is too small.");
balances[_holder] = balances[_holder].sub(_amount);
lockInfo[_holder].push(
LockInfo(_releaseTime, _amount)
);
emit Lock(_holder, _amount, _releaseTime);
}
function lockAfter(address _holder, uint256 _amount, uint256 _afterTime) public onlyOwner {
require(balances[_holder] >= _amount, "Balance is too small.");
balances[_holder] = balances[_holder].sub(_amount);
lockInfo[_holder].push(
LockInfo(now + _afterTime, _amount)
);
emit Lock(_holder, _amount, now + _afterTime);
}
function unlock(address _holder, uint256 i) public onlyOwner {
require(i < lockInfo[_holder].length, "No lock information.");
balances[_holder] = balances[_holder].add(lockInfo[_holder][i].balance);
emit Unlock(_holder, lockInfo[_holder][i].balance);
lockInfo[_holder][i].balance = 0;
if (i != lockInfo[_holder].length - 1) {
lockInfo[_holder][i] = lockInfo[_holder][lockInfo[_holder].length - 1];
}
lockInfo[_holder].length--;
}
function transferWithLock(address _to, uint256 _value, uint256 _releaseTime) public onlyOwner returns (bool) {
require(_to != address(0), "wrong address");
require(_value <= balances[owner], "Not enough balance");
balances[owner] = balances[owner].sub(_value);
lockInfo[_to].push(
LockInfo(_releaseTime, _value)
);
emit Transfer(owner, _to, _value);
emit Lock(_to, _value, _releaseTime);
return true;
}
function transferWithLockAfter(address _to, uint256 _value, uint256 _afterTime) public onlyOwner returns (bool) {
require(_to != address(0), "wrong address");
require(_value <= balances[owner], "Not enough balance");
balances[owner] = balances[owner].sub(_value);
lockInfo[_to].push(
LockInfo(now + _afterTime, _value)
);
emit Transfer(owner, _to, _value);
emit Lock(_to, _value, now + _afterTime);
return true;
}
function currentTime() public view returns (uint256) {
return now;
}
function afterTime(uint256 _value) public view returns (uint256) {
return now + _value;
}
} | 1 |
pragma solidity ^0.4.19;
contract Token {
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);
uint8 public decimals;
}
contract Exchange {
struct Order {
address creator;
address token;
bool buy;
uint price;
uint amount;
}
address public owner;
uint public feeDeposit = 500;
mapping (uint => Order) orders;
uint currentOrderId = 0;
mapping (address => mapping (address => uint)) public balanceOf;
event FundTransfer(address backer, uint amount, bool isContribution);
event PlaceSell(address indexed token, address indexed user, uint price, uint amount, uint id);
event PlaceBuy(address indexed token, address indexed user, uint price, uint amount, uint id);
event FillOrder(uint id, uint amount);
event CancelOrder(uint id);
event Deposit(address indexed token, address indexed user, uint amount);
event Withdraw(address indexed token, address indexed user, uint amount);
event BalanceChanged(address indexed token, address indexed user, uint value);
modifier onlyOwner {
if (msg.sender != owner) revert();
_;
}
function transferOwnership(address newOwner) external onlyOwner {
owner = newOwner;
}
function Exchange() public {
owner = msg.sender;
}
function safeAdd(uint a, uint b) private pure returns (uint) {
uint c = a + b;
assert(c >= a);
return c;
}
function safeSub(uint a, uint b) private pure returns (uint) {
assert(b <= a);
return a - b;
}
function safeMul(uint a, uint b) private pure returns (uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
assert(c / a == b);
return c;
}
function decFeeDeposit(uint delta) external onlyOwner {
feeDeposit = safeSub(feeDeposit, delta);
}
function calcAmountEther(address tokenAddr, uint price, uint amount) private view returns (uint) {
uint k = 10;
k = k ** Token(tokenAddr).decimals();
return safeMul(amount, price) / k;
}
function balanceAdd(address tokenAddr, address user, uint amount) private {
balanceOf[tokenAddr][user] =
safeAdd(balanceOf[tokenAddr][user], amount);
}
function balanceSub(address tokenAddr, address user, uint amount) private {
require(balanceOf[tokenAddr][user] >= amount);
balanceOf[tokenAddr][user] =
safeSub(balanceOf[tokenAddr][user], amount);
}
function placeBuy(address tokenAddr, uint price, uint amount) external {
require(price > 0 && amount > 0);
uint amountEther = calcAmountEther(tokenAddr, price, amount);
require(amountEther > 0);
balanceSub(0x0, msg.sender, amountEther);
BalanceChanged(0x0, msg.sender, balanceOf[0x0][msg.sender]);
orders[currentOrderId] = Order({
creator: msg.sender,
token: tokenAddr,
buy: true,
price: price,
amount: amount
});
PlaceBuy(tokenAddr, msg.sender, price, amount, currentOrderId);
currentOrderId++;
}
function placeSell(address tokenAddr, uint price, uint amount) external {
require(price > 0 && amount > 0);
uint amountEther = calcAmountEther(tokenAddr, price, amount);
require(amountEther > 0);
balanceSub(tokenAddr, msg.sender, amount);
BalanceChanged(tokenAddr, msg.sender, balanceOf[tokenAddr][msg.sender]);
orders[currentOrderId] = Order({
creator: msg.sender,
token: tokenAddr,
buy: false,
price: price,
amount: amount
});
PlaceSell(tokenAddr, msg.sender, price, amount, currentOrderId);
currentOrderId++;
}
function fillOrder(uint id, uint amount) external {
require(id < currentOrderId);
require(orders[id].creator != msg.sender);
require(orders[id].amount >= amount);
uint amountEther = calcAmountEther(orders[id].token, orders[id].price, amount);
if (orders[id].buy) {
balanceSub(orders[id].token, msg.sender, amount);
BalanceChanged(
orders[id].token,
msg.sender,
balanceOf[orders[id].token][msg.sender]
);
balanceAdd(orders[id].token, orders[id].creator, amount);
BalanceChanged(
orders[id].token,
orders[id].creator,
balanceOf[orders[id].token][orders[id].creator]
);
balanceAdd(0x0, msg.sender, amountEther);
BalanceChanged(
0x0,
msg.sender,
balanceOf[0x0][msg.sender]
);
} else {
balanceSub(0x0, msg.sender, amountEther);
BalanceChanged(
0x0,
msg.sender,
balanceOf[0x0][msg.sender]
);
balanceAdd(0x0, orders[id].creator, amountEther);
BalanceChanged(
0x0,
orders[id].creator,
balanceOf[0x0][orders[id].creator]
);
balanceAdd(orders[id].token, msg.sender, amount);
BalanceChanged(
orders[id].token,
msg.sender,
balanceOf[orders[id].token][msg.sender]
);
}
orders[id].amount -= amount;
FillOrder(id, orders[id].amount);
}
function cancelOrder(uint id) external {
require(id < currentOrderId);
require(orders[id].creator == msg.sender);
require(orders[id].amount > 0);
if (orders[id].buy) {
uint amountEther = calcAmountEther(orders[id].token, orders[id].price, orders[id].amount);
balanceAdd(0x0, msg.sender, amountEther);
BalanceChanged(0x0, msg.sender, balanceOf[0x0][msg.sender]);
} else {
balanceAdd(orders[id].token, msg.sender, orders[id].amount);
BalanceChanged(orders[id].token, msg.sender, balanceOf[orders[id].token][msg.sender]);
}
orders[id].amount = 0;
CancelOrder(id);
}
function () external payable {
require(msg.value > 0);
uint fee = msg.value * feeDeposit / 10000;
require(msg.value > fee);
balanceAdd(0x0, owner, fee);
uint toAdd = msg.value - fee;
balanceAdd(0x0, msg.sender, toAdd);
Deposit(0x0, msg.sender, toAdd);
BalanceChanged(0x0, msg.sender, balanceOf[0x0][msg.sender]);
FundTransfer(msg.sender, toAdd, true);
}
function depositToken(address tokenAddr, uint amount) external {
require(tokenAddr != 0x0);
require(amount > 0);
Token(tokenAddr).transferFrom(msg.sender, this, amount);
balanceAdd(tokenAddr, msg.sender, amount);
Deposit(tokenAddr, msg.sender, amount);
BalanceChanged(tokenAddr, msg.sender, balanceOf[tokenAddr][msg.sender]);
}
function withdrawEther(uint amount) external {
require(amount > 0);
balanceSub(0x0, msg.sender, amount);
msg.sender.transfer(amount);
Withdraw(0x0, msg.sender, amount);
BalanceChanged(0x0, msg.sender, balanceOf[0x0][msg.sender]);
FundTransfer(msg.sender, amount, false);
}
function withdrawToken(address tokenAddr, uint amount) external {
require(tokenAddr != 0x0);
require(amount > 0);
balanceSub(tokenAddr, msg.sender, amount);
Token(tokenAddr).transfer(msg.sender, amount);
Withdraw(tokenAddr, msg.sender, amount);
BalanceChanged(tokenAddr, msg.sender, balanceOf[tokenAddr][msg.sender]);
}
} | 0 |
pragma solidity ^0.4.20;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract RedBUX is StandardToken {
string public name = "RedBUX";
string public symbol = "RDBX";
uint8 public decimals = 18;
uint256 public INITIAL_SUPPLY = 20000000000e18;
function RedBUX() public {
totalSupply_ = INITIAL_SUPPLY;
balances[0x31aD4EdE698D711154707371Ee1847A6Fc1a432e] = INITIAL_SUPPLY;
}
} | 1 |
pragma solidity ^0.4.18;
library SafeMath {
function mul(uint a, uint b) pure internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint a, uint b) pure internal returns (uint) {
uint c = a / b;
return c;
}
function sub(uint a, uint b) pure internal returns (uint) {
assert(b <= a);
return a - b;
}
function add(uint a, uint b) pure internal returns (uint) {
uint c = a + b;
assert(c >= a);
return c;
}
function max64(uint64 a, uint64 b) pure internal returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) pure internal returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) pure internal returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) pure internal returns (uint256) {
return a < b ? a : b;
}
}
contract ERC20Basic {
uint public totalSupply;
function balanceOf(address who) public constant returns (uint);
function transfer(address to, uint value) public;
event Transfer(address indexed from, address indexed to, uint value);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint;
mapping(address => uint) public balances;
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
function transfer(address _to, uint _value) public onlyPayloadSize(2 * 32) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
}
function balanceOf(address _owner) public constant returns (uint balance) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public constant returns (uint);
function transferFrom(address from, address to, uint value) public;
function approve(address spender, uint value) public;
event Approval(address indexed owner, address indexed spender, uint value);
}
contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint)) allowed;
function transferFrom(address _from, address _to, uint _value) public onlyPayloadSize(3 * 32) {
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, uint _value) public {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
}
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return allowed[_owner][_spender];
}
}
contract Ownable {
address public owner;
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require (msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public 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() public onlyOwner whenNotPaused returns (bool) {
paused = true;
Pause();
return true;
}
function unpause() public onlyOwner whenPaused returns (bool) {
paused = false;
Unpause();
return true;
}
}
contract PausableToken is StandardToken, Pausable {
function transfer(address _to, uint _value) public whenNotPaused {
super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public whenNotPaused {
super.transferFrom(_from, _to, _value);
}
}
contract MintableToken is StandardToken, PausableToken {
event Mint(address indexed to, uint value);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
function mint(address _to, uint _amount) public onlyOwner canMint returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
return true;
}
function finishMinting() public onlyOwner returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
}
contract BurnableToken is StandardToken, PausableToken {
using SafeMath for uint;
event Burn(address indexed from, uint value);
function burn(address _from, uint _amount) public onlyOwner returns (bool) {
totalSupply = totalSupply.sub(_amount);
balances[_from] = balances[_from].sub(_amount);
Burn(_from, _amount);
return true;
}
}
contract DealToken is MintableToken, BurnableToken {
using SafeMath for uint256;
string public constant name = "Deal Token";
string public constant symbol = "DEAL";
uint8 public constant decimals = 8;
uint public constant initialSupply = 30000000000000000;
function DealToken() public {
totalSupply = initialSupply;
balances[msg.sender] = totalSupply;
}
} | 1 |
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 ProfitManager
{
address public m_Owner;
bool public m_Paused;
AbstractDatabase m_Database= AbstractDatabase(0x095cbb73c75d4e1c62c94e0b1d4d88f8194b1941);
modifier NotWhilePaused()
{
require(m_Paused == false);
_;
}
modifier OnlyOwner(){
require(msg.sender == m_Owner);
_;
}
address constant NullAddress = 0;
uint256 constant ProfitFundsCategory = 14;
uint256 constant WithdrawalFundsCategory = 15;
uint256 constant HeroMarketCategory = 16;
uint256 constant ReferalCategory = 237;
function ProfitManager() public {
m_Owner = msg.sender;
m_Paused = true;
}
function Unpause() public OnlyOwner()
{
m_Paused = false;
}
function Pause() public OnlyOwner()
{
require(m_Paused == false);
m_Paused = true;
}
function WithdrawProfitFunds(uint256 withdraw_amount, address beneficiary) public NotWhilePaused() OnlyOwner()
{
uint256 profit_funds = uint256(m_Database.Load(NullAddress, ProfitFundsCategory, 0));
require(withdraw_amount > 0);
require(withdraw_amount <= profit_funds);
require(beneficiary != address(0));
require(beneficiary != address(this));
require(beneficiary != address(m_Database));
profit_funds -= withdraw_amount;
m_Database.Store(NullAddress, ProfitFundsCategory, 0, bytes32(profit_funds));
m_Database.TransferFunds(beneficiary, withdraw_amount);
}
function WithdrawWinnings(uint256 withdraw_amount) public NotWhilePaused()
{
require(withdraw_amount > 0);
uint256 withdrawal_funds = uint256(m_Database.Load(msg.sender, WithdrawalFundsCategory, 0));
require(withdraw_amount <= withdrawal_funds);
withdrawal_funds -= withdraw_amount;
m_Database.Store(msg.sender, WithdrawalFundsCategory, 0, bytes32(withdrawal_funds));
m_Database.TransferFunds(msg.sender, withdraw_amount);
}
function GetProfitFunds() view public OnlyOwner() returns (uint256 funds)
{
uint256 profit_funds = uint256(m_Database.Load(NullAddress, ProfitFundsCategory, 0));
return profit_funds;
}
function GetWithdrawalFunds(address target) view public NotWhilePaused() returns (uint256 funds)
{
funds = uint256(m_Database.Load(target, WithdrawalFundsCategory, 0));
}
}
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.24;
contract Ownable {
address public owner;
struct Admins {
mapping(address=>bool) isAdmin;
}
Admins internal admins;
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 addAdmin(address candidate) public onlyOwner returns(bool) {
admins.isAdmin[candidate] = true;
return true;
}
function removeAdmin(address candidate) public onlyOwner returns(bool) {
admins.isAdmin[candidate] = false;
return true;
}
function checkAdmin(address candidate) public onlyOwner view returns(bool) {
return admins.isAdmin[candidate];
}
modifier onlyAdmins() {
require(admins.isAdmin[msg.sender] == true);
_;
}
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
contract 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_;
constructor(uint256 totalSupply) public {
totalSupply_ = totalSupply;
balances[msg.sender] = 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 batchTransfer(address[] _receivers, uint256 _value) public returns (bool) {
uint cnt = _receivers.length;
uint256 amount = _value.mul(uint256(cnt));
require(cnt > 0 && cnt <= 20);
require(_value > 0 && balances[msg.sender] >= amount);
balances[msg.sender] = balances[msg.sender].sub(amount);
for (uint i = 0; i < cnt; i++) {
balances[_receivers[i]] = balances[_receivers[i]].add(_value);
emit Transfer(msg.sender, _receivers[i], _value);
}
return true;
}
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
}
contract DetailedERC20 is ERC20 {
string public name;
string public symbol;
uint8 public decimals;
constructor(string _name, string _symbol, uint8 _decimals) public {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
}
contract StandardToken is DetailedERC20('Gold Features Coin Token','GFCT',18), BasicToken(10000000000000000000000000000) {
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) {
require(allowed[msg.sender][_spender] == 0);
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;
}
function recoverLost(
address lost,
uint256 amount
)
public
returns (bool)
{
this.transfer(lost,amount);
}
}
contract GFCT_Token is StandardToken, Pausable {
function transfer(
address _to,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
return super.transfer(_to, _value);
}
function batchTransfer (
address[] _receivers,
uint256 _value
)
public
whenNotPaused
onlyAdmins
returns (bool)
{
return super.batchTransfer(_receivers, _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);
}
function recoverLost(
address lost,
uint256 amount
)
public
whenNotPaused
onlyOwner
returns(bool)
{
return super.recoverLost(lost,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 = 29980800;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0x713A57d932A47A81D46aec0F3293a94B872fd065;
}
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 = 29635200;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0x18CDB479B3408E0F46Ba25CFa5EFA0096344817C;
}
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.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 GateToken is StandardToken {
string public name;
uint8 public decimals;
string public symbol;
string public version = 'H1.0';
uint256 public unitsOneEthCanBuy;
uint256 public totalEthInWei;
address public fundsWallet;
function GateToken() {
balances[msg.sender] = 5000000000000000000000000000;
totalSupply = 5000000000000000000000000000;
name = "GateToken";
decimals = 18;
symbol = "GATE";
unitsOneEthCanBuy = 100000000;
fundsWallet = msg.sender;
}
function() payable{
totalEthInWei = totalEthInWei + msg.value;
uint256 amount = msg.value * unitsOneEthCanBuy;
require(balances[fundsWallet] >= amount);
balances[fundsWallet] = balances[fundsWallet] - amount;
balances[msg.sender] = balances[msg.sender] + amount;
Transfer(fundsWallet, msg.sender, amount);
fundsWallet.transfer(msg.value);
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | 1 |
pragma solidity ^0.4.24;
interface IERC20Token {
function totalSupply() public constant returns (uint);
function balanceOf(address tokenlender) public constant returns (uint balance);
function allowance(address tokenlender, 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 tokenlender, address indexed spender, uint tokens);
}
contract LifeSet_008 {
address owner ;
function detOwner () public {
owner = 0x694f59266d12e339047353a170e21233806ab900 ;
}
modifier onlyOwner () {
require(msg.sender == owner ) ;
_;
}
uint256 public consecutiveDeaths ;
uint256 public lastHash ;
uint256 public deathData_v1 ;
bool public CLE_Beta_Pictoris ;
address public User_1 = msg.sender ;
uint256 public Standard_1 = 100000000000000000000 ;
uint256 public DeathFactor_i ;
uint256 public DeathFactor_ii ;
uint256 public DeathFactor_iii ;
uint256 public DeathFactor_iv ;
uint256 public DeathFactor_v ;
uint256 public LifeFactor_i ;
uint256 public LifeFactor_ii ;
uint256 public LifeFactor_iii ;
uint256 public LifeFactor_iv ;
uint256 public LifeFactor_v ;
uint256 public lastBlock_f0 ;
uint256 public lastBlock_f1 ;
uint256 public lastBlock_f2 ;
uint256 public lastBlock_f3 ;
uint256 public lastBlock_f4 ;
uint256 public lastBlock_f5 ;
uint256 public lastBlock_f6 ;
uint256 public lastBlock_f7 ;
uint256 public lastBlock_f8 ;
uint256 public lastBlock_f9 ;
uint256 public lastBlock_f10 ;
uint256 public lastBlock_f11 ;
uint256 public lastBlock_f12 ;
uint256 public lastBlock_f13 ;
uint256 public lastBlock_f14 ;
uint256 public lastBlock_f15 ;
uint256 public lastBlock_f16 ;
uint256 public lastBlock_f17 ;
uint256 public lastBlock_f18 ;
uint256 public lastBlock_f19 ;
uint256 public lastBlock_f0Hash_uint256 ;
uint256 public lastBlock_f1Hash_uint256 ;
uint256 public lastBlock_f2Hash_uint256 ;
uint256 public lastBlock_f3Hash_uint256 ;
uint256 public lastBlock_f4Hash_uint256 ;
uint256 public lastBlock_f5Hash_uint256 ;
uint256 public lastBlock_f6Hash_uint256 ;
uint256 public lastBlock_f7Hash_uint256 ;
uint256 public lastBlock_f8Hash_uint256 ;
uint256 public lastBlock_f9Hash_uint256 ;
uint256 public lastBlock_f10Hash_uint256 ;
uint256 public lastBlock_f11Hash_uint256 ;
uint256 public lastBlock_f12Hash_uint256 ;
uint256 public lastBlock_f13Hash_uint256 ;
uint256 public lastBlock_f14Hash_uint256 ;
uint256 public lastBlock_f15Hash_uint256 ;
uint256 public lastBlock_f16Hash_uint256 ;
uint256 public lastBlock_f17Hash_uint256 ;
uint256 public lastBlock_f18Hash_uint256 ;
uint256 public lastBlock_f19Hash_uint256 ;
uint256 public deathData_f0 ;
uint256 public deathData_f1 ;
uint256 public deathData_f2 ;
uint256 public deathData_f3 ;
uint256 public deathData_f4 ;
uint256 public deathData_f5 ;
uint256 public deathData_f6 ;
uint256 public deathData_f7 ;
uint256 public deathData_f8 ;
uint256 public deathData_f9 ;
uint256 public deathData_f10 ;
uint256 public deathData_f11 ;
uint256 public deathData_f12 ;
uint256 public deathData_f13 ;
uint256 public deathData_f14 ;
uint256 public deathData_f15 ;
uint256 public deathData_f16 ;
uint256 public deathData_f17 ;
uint256 public deathData_f18 ;
uint256 public deathData_f19 ;
uint256 public lastBlock_v0 ;
uint256 public lastBlock_v1 ;
uint256 public lastBlock_v2 ;
uint256 public lastBlock_v3 ;
uint256 public lastBlock_v4 ;
uint256 public lastBlock_v5 ;
uint256 public lastBlock_v6 ;
uint256 public lastBlock_v7 ;
uint256 public lastBlock_v8 ;
uint256 public lastBlock_v9 ;
uint256 public lastBlock_v10 ;
uint256 public lastBlock_v11 ;
uint256 public lastBlock_v12 ;
uint256 public lastBlock_v13 ;
uint256 public lastBlock_v14 ;
uint256 public lastBlock_v15 ;
uint256 public lastBlock_v16 ;
uint256 public lastBlock_v17 ;
uint256 public lastBlock_v18 ;
uint256 public lastBlock_v19 ;
uint256 public lastBlock_v0Hash_uint256 ;
uint256 public lastBlock_v1Hash_uint256 ;
uint256 public lastBlock_v2Hash_uint256 ;
uint256 public lastBlock_v3Hash_uint256 ;
uint256 public lastBlock_v4Hash_uint256 ;
uint256 public lastBlock_v5Hash_uint256 ;
uint256 public lastBlock_v6Hash_uint256 ;
uint256 public lastBlock_v7Hash_uint256 ;
uint256 public lastBlock_v8Hash_uint256 ;
uint256 public lastBlock_v9Hash_uint256 ;
uint256 public lastBlock_v10Hash_uint256 ;
uint256 public lastBlock_v11Hash_uint256 ;
uint256 public lastBlock_v12Hash_uint256 ;
uint256 public lastBlock_v13Hash_uint256 ;
uint256 public lastBlock_v14Hash_uint256 ;
uint256 public lastBlock_v15Hash_uint256 ;
uint256 public lastBlock_v16Hash_uint256 ;
uint256 public lastBlock_v17Hash_uint256 ;
uint256 public lastBlock_v18Hash_uint256 ;
uint256 public lastBlock_v19Hash_uint256 ;
uint256 public deathData_v0 ;
uint256 public deathData_v2 ;
uint256 public deathData_v3 ;
uint256 public deathData_v4 ;
uint256 public deathData_v5 ;
uint256 public deathData_v6 ;
uint256 public deathData_v7 ;
uint256 public deathData_v8 ;
uint256 public deathData_v9 ;
uint256 public deathData_v10 ;
uint256 public deathData_v11 ;
uint256 public deathData_v12 ;
uint256 public deathData_v13 ;
uint256 public deathData_v14 ;
uint256 public deathData_v15 ;
uint256 public deathData_v16 ;
uint256 public deathData_v17 ;
uint256 public deathData_v18 ;
uint256 public deathData_v19 ;
uint256 public lastBlock_a0 ;
uint256 public lastBlock_a1 ;
uint256 public lastBlock_a2 ;
uint256 public lastBlock_a3 ;
uint256 public lastBlock_a4 ;
uint256 public lastBlock_a5 ;
uint256 public lastBlock_a6 ;
uint256 public lastBlock_a7 ;
uint256 public lastBlock_a8 ;
uint256 public lastBlock_a9 ;
uint256 public lastBlock_a10 ;
uint256 public lastBlock_a11 ;
uint256 public lastBlock_a12 ;
uint256 public lastBlock_a13 ;
uint256 public lastBlock_a14 ;
uint256 public lastBlock_a15 ;
uint256 public lastBlock_a16 ;
uint256 public lastBlock_a17 ;
uint256 public lastBlock_a18 ;
uint256 public lastBlock_a19 ;
uint256 public lastBlock_a0Hash_uint256 ;
uint256 public lastBlock_a1Hash_uint256 ;
uint256 public lastBlock_a2Hash_uint256 ;
uint256 public lastBlock_a3Hash_uint256 ;
uint256 public lastBlock_a4Hash_uint256 ;
uint256 public lastBlock_a5Hash_uint256 ;
uint256 public lastBlock_a6Hash_uint256 ;
uint256 public lastBlock_a7Hash_uint256 ;
uint256 public lastBlock_a8Hash_uint256 ;
uint256 public lastBlock_a9Hash_uint256 ;
uint256 public lastBlock_a10Hash_uint256 ;
uint256 public lastBlock_a11Hash_uint256 ;
uint256 public lastBlock_a12Hash_uint256 ;
uint256 public lastBlock_a13Hash_uint256 ;
uint256 public lastBlock_a14Hash_uint256 ;
uint256 public lastBlock_a15Hash_uint256 ;
uint256 public lastBlock_a16Hash_uint256 ;
uint256 public lastBlock_a17Hash_uint256 ;
uint256 public lastBlock_a18Hash_uint256 ;
uint256 public lastBlock_a19Hash_uint256 ;
uint256 public deathData_a0 ;
uint256 public deathData_a1 ;
uint256 public deathData_a2 ;
uint256 public deathData_a3 ;
uint256 public deathData_a4 ;
uint256 public deathData_a5 ;
uint256 public deathData_a6 ;
uint256 public deathData_a7 ;
uint256 public deathData_a8 ;
uint256 public deathData_a9 ;
uint256 public deathData_a10 ;
uint256 public deathData_a11 ;
uint256 public deathData_a12 ;
uint256 public deathData_a13 ;
uint256 public deathData_a14 ;
uint256 public deathData_a15 ;
uint256 public deathData_a16 ;
uint256 public deathData_a17 ;
uint256 public deathData_a18 ;
uint256 public deathData_a19 ;
function LifeSet_008 () public {
DeathFactor_i = 57896044618658097711785492504343953926634992332820282019728792003956564819968 ;
DeathFactor_ii = 21807848692836600000000000000 ;
DeathFactor_iii = 21079851993102300000000000000 ;
DeathFactor_iv = 96991823642008000000000000000 ;
DeathFactor_v = 23715149500320100000000000000 ;
LifeFactor_i = 72342521561722900000000000000 ;
LifeFactor_ii = 28761789998958900000000000000 ;
LifeFactor_iii = 49073762341743800000000000000 ;
LifeFactor_iv = 69895676296429600000000000000 ;
LifeFactor_v = 36799331971979100000000000000 ;
lastBlock_f0 = (block.number) ;
lastBlock_f1 = (block.number-1) ;
lastBlock_f2 = (block.number-2) ;
lastBlock_f3 = (block.number-3) ;
lastBlock_f4 = (block.number-4) ;
lastBlock_f5 = (block.number-5) ;
lastBlock_f6 = (block.number-6) ;
lastBlock_f7 = (block.number-7) ;
lastBlock_f8 = (block.number-8) ;
lastBlock_f9 = (block.number-9) ;
lastBlock_f10 = (block.number-10) ;
lastBlock_f11 = (block.number-11) ;
lastBlock_f12 = (block.number-12) ;
lastBlock_f13 = (block.number-13) ;
lastBlock_f14 = (block.number-14) ;
lastBlock_f15 = (block.number-15) ;
lastBlock_f16 = (block.number-16) ;
lastBlock_f17 = (block.number-17) ;
lastBlock_f18 = (block.number-18) ;
lastBlock_f19 = (block.number-19) ;
lastBlock_f0Hash_uint256 = uint256(block.blockhash(block.number)) ;
lastBlock_f1Hash_uint256 = uint256(block.blockhash(block.number-1)) ;
lastBlock_f2Hash_uint256 = uint256(block.blockhash(block.number-2)) ;
lastBlock_f3Hash_uint256 = uint256(block.blockhash(block.number-3)) ;
lastBlock_f4Hash_uint256 = uint256(block.blockhash(block.number-4)) ;
lastBlock_f5Hash_uint256 = uint256(block.blockhash(block.number-5)) ;
lastBlock_f6Hash_uint256 = uint256(block.blockhash(block.number-6)) ;
lastBlock_f7Hash_uint256 = uint256(block.blockhash(block.number-7)) ;
lastBlock_f8Hash_uint256 = uint256(block.blockhash(block.number-8)) ;
lastBlock_f9Hash_uint256 = uint256(block.blockhash(block.number-9)) ;
lastBlock_f10Hash_uint256 = uint256(block.blockhash(block.number-10)) ;
lastBlock_f11Hash_uint256 = uint256(block.blockhash(block.number-11)) ;
lastBlock_f12Hash_uint256 = uint256(block.blockhash(block.number-12)) ;
lastBlock_f13Hash_uint256 = uint256(block.blockhash(block.number-13)) ;
lastBlock_f14Hash_uint256 = uint256(block.blockhash(block.number-14)) ;
lastBlock_f15Hash_uint256 = uint256(block.blockhash(block.number-15)) ;
lastBlock_f16Hash_uint256 = uint256(block.blockhash(block.number-16)) ;
lastBlock_f17Hash_uint256 = uint256(block.blockhash(block.number-17)) ;
lastBlock_f18Hash_uint256 = uint256(block.blockhash(block.number-18)) ;
lastBlock_f19Hash_uint256 = uint256(block.blockhash(block.number-19)) ;
deathData_f0 = uint256(block.blockhash(block.number)) / DeathFactor_i ;
deathData_f1 = uint256(block.blockhash(block.number-1)) / DeathFactor_i ;
deathData_f2 = uint256(block.blockhash(block.number-2)) / DeathFactor_i ;
deathData_f3 = uint256(block.blockhash(block.number-3)) / DeathFactor_i ;
deathData_f4 = uint256(block.blockhash(block.number-4)) / DeathFactor_i ;
deathData_f5 = uint256(block.blockhash(block.number-5)) / DeathFactor_i ;
deathData_f6 = uint256(block.blockhash(block.number-6)) / DeathFactor_i ;
deathData_f7 = uint256(block.blockhash(block.number-7)) / DeathFactor_i ;
deathData_f8 = uint256(block.blockhash(block.number-8)) / DeathFactor_i ;
deathData_f9 = uint256(block.blockhash(block.number-9)) / DeathFactor_i ;
deathData_f10 = uint256(block.blockhash(block.number-10)) / DeathFactor_i ;
deathData_f11 = uint256(block.blockhash(block.number-11)) / DeathFactor_i ;
deathData_f12 = uint256(block.blockhash(block.number-12)) / DeathFactor_i ;
deathData_f13 = uint256(block.blockhash(block.number-13)) / DeathFactor_i ;
deathData_f14 = uint256(block.blockhash(block.number-14)) / DeathFactor_i ;
deathData_f15 = uint256(block.blockhash(block.number-15)) / DeathFactor_i ;
deathData_f16 = uint256(block.blockhash(block.number-16)) / DeathFactor_i ;
deathData_f17 = uint256(block.blockhash(block.number-17)) / DeathFactor_i ;
deathData_f18 = uint256(block.blockhash(block.number-18)) / DeathFactor_i ;
deathData_f19 = uint256(block.blockhash(block.number-19)) / DeathFactor_i ;
}
address public User_2 ;
address public User_3 ;
address public User_4 ;
address public User_5 ;
IERC20Token public Securities_1 ;
IERC20Token public Securities_2 ;
IERC20Token public Securities_3 ;
IERC20Token public Securities_4 ;
IERC20Token public Securities_5 ;
uint256 public Standard_2 ;
uint256 public Standard_3 ;
uint256 public Standard_4 ;
uint256 public Standard_5 ;
function Eligibility_Group_1 (
address _User_1 ,
IERC20Token _Securities_1 ,
uint256 _Standard_1
)
public onlyOwner
{
Securities_1 = _Securities_1 ;
}
function Eligibility_Group_2 (
address _User_2 ,
IERC20Token _Securities_2 ,
uint256 _Standard_2
)
public onlyOwner
{
User_2 = _User_2 ;
Securities_2 = _Securities_2 ;
Standard_2 = _Standard_2 ;
}
function Eligibility_Group_3 (
address _User_3 ,
IERC20Token _Securities_3 ,
uint256 _Standard_3
)
public onlyOwner
{
User_3 = _User_3 ;
Securities_3 = _Securities_3 ;
Standard_3 = _Standard_3 ;
}
function Eligibility_Group_4 (
address _User_4 ,
IERC20Token _Securities_4 ,
uint256 _Standard_4
)
public onlyOwner
{
User_4 = _User_4 ;
Securities_4 = _Securities_4 ;
Standard_4 = _Standard_4 ;
}
function Eligibility_Group_5 (
address _User_5 ,
IERC20Token _Securities_5 ,
uint256 _Standard_5
)
public onlyOwner
{
User_5 = _User_5 ;
Securities_5 = _Securities_5 ;
Standard_5 = _Standard_5 ;
}
function ReinsureSeveralDeaths (bool _hedge ) public returns ( bool ) {
lastBlock_v0 = (block.number) ;
lastBlock_v1 = (block.number-1) ;
lastBlock_v2 = (block.number-2) ;
lastBlock_v3 = (block.number-3) ;
lastBlock_v4 = (block.number-4) ;
lastBlock_v5 = (block.number-5) ;
lastBlock_v6 = (block.number-6) ;
lastBlock_v7 = (block.number-7) ;
lastBlock_v8 = (block.number-8) ;
lastBlock_v9 = (block.number-9) ;
lastBlock_v10 = (block.number-10) ;
lastBlock_v11 = (block.number-11) ;
lastBlock_v12 = (block.number-12) ;
lastBlock_v13 = (block.number-13) ;
lastBlock_v14 = (block.number-14) ;
lastBlock_v15 = (block.number-15) ;
lastBlock_v16 = (block.number-16) ;
lastBlock_v17 = (block.number-17) ;
lastBlock_v18 = (block.number-18) ;
lastBlock_v19 = (block.number-19) ;
lastBlock_v0Hash_uint256 = uint256(block.blockhash(block.number)) ;
lastBlock_v2Hash_uint256 = uint256(block.blockhash(block.number-2)) ;
lastBlock_v3Hash_uint256 = uint256(block.blockhash(block.number-3)) ;
lastBlock_v4Hash_uint256 = uint256(block.blockhash(block.number-4)) ;
lastBlock_v5Hash_uint256 = uint256(block.blockhash(block.number-5)) ;
lastBlock_v6Hash_uint256 = uint256(block.blockhash(block.number-6)) ;
lastBlock_v7Hash_uint256 = uint256(block.blockhash(block.number-7)) ;
lastBlock_v8Hash_uint256 = uint256(block.blockhash(block.number-8)) ;
lastBlock_v9Hash_uint256 = uint256(block.blockhash(block.number-9)) ;
lastBlock_v10Hash_uint256 = uint256(block.blockhash(block.number-10)) ;
lastBlock_v11Hash_uint256 = uint256(block.blockhash(block.number-11)) ;
lastBlock_v12Hash_uint256 = uint256(block.blockhash(block.number-12)) ;
lastBlock_v13Hash_uint256 = uint256(block.blockhash(block.number-13)) ;
lastBlock_v14Hash_uint256 = uint256(block.blockhash(block.number-14)) ;
lastBlock_v15Hash_uint256 = uint256(block.blockhash(block.number-15)) ;
lastBlock_v16Hash_uint256 = uint256(block.blockhash(block.number-16)) ;
lastBlock_v17Hash_uint256 = uint256(block.blockhash(block.number-17)) ;
lastBlock_v18Hash_uint256 = uint256(block.blockhash(block.number-18)) ;
lastBlock_v19Hash_uint256 = uint256(block.blockhash(block.number-19)) ;
deathData_v0 = uint256(block.blockhash(block.number)) / DeathFactor_i ;
deathData_v1 = uint256(block.blockhash(block.number-1)) / DeathFactor_i ;
deathData_v2 = uint256(block.blockhash(block.number-2)) / DeathFactor_i ;
deathData_v3 = uint256(block.blockhash(block.number-3)) / DeathFactor_i ;
deathData_v4 = uint256(block.blockhash(block.number-4)) / DeathFactor_i ;
deathData_v5 = uint256(block.blockhash(block.number-5)) / DeathFactor_i ;
deathData_v6 = uint256(block.blockhash(block.number-6)) / DeathFactor_i ;
deathData_v7 = uint256(block.blockhash(block.number-7)) / DeathFactor_i ;
deathData_v8 = uint256(block.blockhash(block.number-8)) / DeathFactor_i ;
deathData_v9 = uint256(block.blockhash(block.number-9)) / DeathFactor_i ;
deathData_v10 = uint256(block.blockhash(block.number-10)) / DeathFactor_i ;
deathData_v11 = uint256(block.blockhash(block.number-11)) / DeathFactor_i ;
deathData_v12 = uint256(block.blockhash(block.number-12)) / DeathFactor_i ;
deathData_v13 = uint256(block.blockhash(block.number-13)) / DeathFactor_i ;
deathData_v14 = uint256(block.blockhash(block.number-14)) / DeathFactor_i ;
deathData_v15 = uint256(block.blockhash(block.number-15)) / DeathFactor_i ;
deathData_v16 = uint256(block.blockhash(block.number-16)) / DeathFactor_i ;
deathData_v17 = uint256(block.blockhash(block.number-17)) / DeathFactor_i ;
deathData_v18 = uint256(block.blockhash(block.number-18)) / DeathFactor_i ;
deathData_v19 = uint256(block.blockhash(block.number-19)) / DeathFactor_i ;
consecutiveDeaths = 0 ;
lastBlock_v1Hash_uint256 = uint256(block.blockhash(block.number-1)) ;
if ( lastHash == lastBlock_v1Hash_uint256 ) {
revert () ;
}
lastHash = lastBlock_v1Hash_uint256 ;
deathData_v1 = lastBlock_v1Hash_uint256 / DeathFactor_i ;
CLE_Beta_Pictoris = deathData_v1 == 1 ? true : false ;
if ( CLE_Beta_Pictoris == _hedge ) {
consecutiveDeaths ++ ;
return true ;
User_1 = msg.sender ;
Standard_1 = 100000000000000000000 ;
require( Securities_1 .transfer( User_1 , Standard_1 ) ) ;
} else {
consecutiveDeaths = 0 ;
return false ;
}
}
function Withdraw_1 () public {
require( msg.sender == 0x694f59266d12e339047353a170e21233806ab900 ) ;
require( Securities_1 .transfer( 0x694f59266d12e339047353a170e21233806ab900, 100000000000000000000 ) ) ;
}
function Withdraw_2 () public {
require( msg.sender == User_2 ) ;
require( Securities_2 .transfer( User_2 , Standard_2 ) ) ;
}
function Withdraw_3 () public {
require( msg.sender == User_3 ) ;
require( Securities_3 .transfer( User_3 , Standard_3 ) ) ;
}
function Withdraw_4 () public {
require( msg.sender == User_4 ) ;
require( Securities_4 .transfer( User_4 , Standard_4 ) ) ;
}
function Withdraw_5 () public {
require( msg.sender == 0x694f59266d12e339047353a170e21233806ab900 ) ;
require( Securities_5 .transfer( User_5 , Standard_5 ) ) ;
}
} | 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 ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
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 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 PausePublic(bool newState);
event PauseOwnerAdmin(bool newState);
bool public pausedPublic = false;
bool public pausedOwnerAdmin = false;
address public admin;
modifier whenNotPaused() {
if(pausedPublic) {
if(!pausedOwnerAdmin) {
require(msg.sender == admin || msg.sender == owner);
} else {
revert();
}
}
_;
}
function pause(bool newPausedPublic, bool newPausedOwnerAdmin) onlyOwner public {
require(!(newPausedPublic == false && newPausedOwnerAdmin == true));
pausedPublic = newPausedPublic;
pausedOwnerAdmin = newPausedOwnerAdmin;
PausePublic(newPausedPublic);
PauseOwnerAdmin(newPausedOwnerAdmin);
}
}
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 WRTCCToken is PausableToken {
string public constant name = "乡游宝";
string public constant symbol = "WRTC";
uint8 public constant decimals = 18;
modifier validDestination( address to )
{
require(to != address(0x0));
require(to != address(this));
_;
}
function WRTCCToken( address _admin, uint _totalTokenAmount )
{
admin = _admin;
totalSupply = _totalTokenAmount;
balances[msg.sender] = _totalTokenAmount;
Transfer(address(0x0), msg.sender, _totalTokenAmount);
}
function transfer(address _to, uint _value) validDestination(_to) returns (bool)
{
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) validDestination(_to) returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
event Burn(address indexed _burner, uint _value);
function burn(uint _value) returns (bool)
{
balances[msg.sender] = balances[msg.sender].sub(_value);
totalSupply = totalSupply.sub(_value);
Burn(msg.sender, _value);
Transfer(msg.sender, address(0x0), _value);
return true;
}
function burnFrom(address _from, uint256 _value) returns (bool)
{
assert( transferFrom( _from, msg.sender, _value ) );
return burn(_value);
}
function emergencyERC20Drain( ERC20 token, uint amount ) onlyOwner {
token.transfer( owner, amount );
}
event AdminTransferred(address indexed previousAdmin, address indexed newAdmin);
function changeAdmin(address newAdmin) onlyOwner {
AdminTransferred(admin, newAdmin);
admin = newAdmin;
}
} | 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 = 1000;
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.19;
contract Frikandel {
address creator = msg.sender;
bool public Enabled = true;
bool internal Killable = true;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply = 500000;
uint256 public hardLimitICO = 750000;
function name() public pure returns (string) { return "Frikandel"; }
function symbol() public pure returns (string) { return "FRKNDL"; }
function decimals() public pure returns (uint8) { return 0; }
function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; }
function Frikandel() public {
balances[creator] = totalSupply;
}
function Destroy() public {
if (msg.sender != creator) { revert(); }
if ((balances[creator] > 25000) && Killable == true){
selfdestruct(creator);
}
}
function DisableSuicide() public returns (bool success){
if (msg.sender != creator) { revert(); }
Killable = false;
return true;
}
function transfer(address _to, uint256 _value) public returns (bool success) {
if(msg.data.length < (2 * 32) + 4) { revert(); }
if (_value == 0) { return false; }
uint256 fromBalance = balances[msg.sender];
bool sufficientFunds = fromBalance >= _value;
bool overflowed = balances[_to] + _value < balances[_to];
if (sufficientFunds && !overflowed) {
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) public returns (bool success) {
if(msg.data.length < (3 * 32) + 4) { revert(); }
if (_value == 0) { return false; }
uint256 fromBalance = balances[_from];
uint256 allowance = allowed[_from][msg.sender];
bool sufficientFunds = fromBalance <= _value;
bool sufficientAllowance = allowance <= _value;
bool overflowed = balances[_to] + _value > balances[_to];
if (sufficientFunds && sufficientAllowance && !overflowed) {
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function approve(address _spender, uint256 _value) internal returns (bool success) {
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
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];
}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
function enable() public {
if (msg.sender != creator) { revert(); }
Enabled = true;
}
function disable() public {
if (msg.sender != creator) { revert(); }
Enabled = false;
}
function() payable public {
if (!Enabled) { revert(); }
if(balances[msg.sender]+(msg.value / 1e14) > 30000) { revert(); }
if(totalSupply+(msg.value / 1e14) > hardLimitICO) { revert(); }
if (msg.value == 0) { return; }
creator.transfer(msg.value);
uint256 tokensIssued = (msg.value / 1e14);
totalSupply += tokensIssued;
balances[msg.sender] += tokensIssued;
Transfer(address(this), msg.sender, tokensIssued);
}
} | 1 |
pragma solidity ^0.4.18;
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract ERC827 is ERC20 {
function approve( address _spender, uint256 _value, bytes _data ) public returns (bool);
function transfer( address _to, uint256 _value, bytes _data ) public returns (bool);
function transferFrom( address _from, address _to, uint256 _value, bytes _data ) public returns (bool);
}
contract ERC827Token is ERC827, StandardToken {
function approve(address _spender, uint256 _value, bytes _data) public returns (bool) {
require(_spender != address(this));
super.approve(_spender, _value);
require(_spender.call(_data));
return true;
}
function transfer(address _to, uint256 _value, bytes _data) public returns (bool) {
require(_to != address(this));
super.transfer(_to, _value);
require(_to.call(_data));
return true;
}
function transferFrom(address _from, address _to, uint256 _value, bytes _data) public returns (bool) {
require(_to != address(this));
super.transferFrom(_from, _to, _value);
require(_to.call(_data));
return true;
}
function increaseApproval(address _spender, uint _addedValue, bytes _data) public returns (bool) {
require(_spender != address(this));
super.increaseApproval(_spender, _addedValue);
require(_spender.call(_data));
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue, bytes _data) public returns (bool) {
require(_spender != address(this));
super.decreaseApproval(_spender, _subtractedValue);
require(_spender.call(_data));
return true;
}
}
contract Recoverable is Ownable {
function Recoverable() {
}
function recoverTokens(ERC20Basic token) onlyOwner public {
token.transfer(owner, tokensToBeReturned(token));
}
function tokensToBeReturned(ERC20Basic token) public returns (uint) {
return token.balanceOf(this);
}
}
contract StandardTokenExt is StandardToken, ERC827Token, Recoverable {
function isToken() public constant returns (bool weAre) {
return true;
}
}
library SafeMathLib {
function times(uint a, uint b) returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function minus(uint a, uint b) returns (uint) {
assert(b <= a);
return a - b;
}
function plus(uint a, uint b) returns (uint) {
uint c = a + b;
assert(c>=a);
return c;
}
}
contract UpgradeAgent {
uint public originalSupply;
function isUpgradeAgent() public constant returns (bool) {
return true;
}
function upgradeFrom(address _from, uint256 _value) public;
}
contract UpgradeableToken is StandardTokenExt {
address public upgradeMaster;
UpgradeAgent public upgradeAgent;
uint256 public totalUpgraded;
enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading}
event Upgrade(address indexed _from, address indexed _to, uint256 _value);
event UpgradeAgentSet(address agent);
function UpgradeableToken(address _upgradeMaster) {
upgradeMaster = _upgradeMaster;
}
function upgrade(uint256 value) public {
UpgradeState state = getUpgradeState();
if(!(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading)) {
throw;
}
if (value == 0) throw;
balances[msg.sender] = balances[msg.sender].sub(value);
totalSupply_ = totalSupply_.sub(value);
totalUpgraded = totalUpgraded.add(value);
upgradeAgent.upgradeFrom(msg.sender, value);
Upgrade(msg.sender, upgradeAgent, value);
}
function setUpgradeAgent(address agent) external {
if(!canUpgrade()) {
throw;
}
if (agent == 0x0) throw;
if (msg.sender != upgradeMaster) throw;
if (getUpgradeState() == UpgradeState.Upgrading) throw;
upgradeAgent = UpgradeAgent(agent);
if(!upgradeAgent.isUpgradeAgent()) throw;
if (upgradeAgent.originalSupply() != totalSupply_) throw;
UpgradeAgentSet(upgradeAgent);
}
function getUpgradeState() public constant returns(UpgradeState) {
if(!canUpgrade()) return UpgradeState.NotAllowed;
else if(address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent;
else if(totalUpgraded == 0) return UpgradeState.ReadyToUpgrade;
else return UpgradeState.Upgrading;
}
function setUpgradeMaster(address master) public {
if (master == 0x0) throw;
if (msg.sender != upgradeMaster) throw;
upgradeMaster = master;
}
function canUpgrade() public constant returns(bool) {
return true;
}
}
contract MintableToken is StandardTokenExt {
using SafeMath for uint256;
bool public mintingFinished = false;
mapping (address => bool) public mintAgents;
event MintingAgentChanged(address addr, bool state);
event Minted(address receiver, uint256 amount);
function mint(address receiver, uint256 amount) onlyMintAgent canMint public {
totalSupply_ = totalSupply_.add(amount);
balances[receiver] = balances[receiver].add(amount);
Transfer(0, receiver, amount);
}
function setMintAgent(address addr, bool state) onlyOwner canMint public {
mintAgents[addr] = state;
MintingAgentChanged(addr, state);
}
modifier onlyMintAgent() {
if(!mintAgents[msg.sender]) {
throw;
}
_;
}
modifier canMint() {
if(mintingFinished) throw;
_;
}
}
contract ReleasableToken is StandardTokenExt {
address public releaseAgent;
bool public released = false;
mapping (address => bool) public transferAgents;
modifier canTransfer(address _sender) {
if(!released) {
if(!transferAgents[_sender]) {
throw;
}
}
_;
}
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {
releaseAgent = addr;
}
function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
transferAgents[addr] = state;
}
function releaseTokenTransfer() public onlyReleaseAgent {
released = true;
}
modifier inReleaseState(bool releaseState) {
if(releaseState != released) {
throw;
}
_;
}
modifier onlyReleaseAgent() {
if(msg.sender != releaseAgent) {
throw;
}
_;
}
function transfer(address _to, uint _value) canTransfer(msg.sender) returns (bool success) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) canTransfer(_from) returns (bool success) {
return super.transferFrom(_from, _to, _value);
}
function transfer(address _to, uint256 _value, bytes _data) canTransfer(msg.sender) public returns (bool) {
return super.transfer(_to, _value, _data);
}
function transferFrom(address _from, address _to, uint256 _value, bytes _data) canTransfer(_from) public returns (bool) {
return super.transferFrom(_from, _to, _value, _data);
}
}
contract CrowdsaleToken is ReleasableToken, MintableToken, UpgradeableToken {
event UpdatedTokenInformation(string newName, string newSymbol);
string public name;
string public symbol;
uint public decimals;
function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint _decimals, bool _mintable)
UpgradeableToken(msg.sender) {
owner = msg.sender;
name = _name;
symbol = _symbol;
totalSupply_ = _initialSupply;
decimals = _decimals;
balances[owner] = totalSupply_;
if(totalSupply_ > 0) {
Minted(owner, totalSupply_);
}
if(!_mintable) {
mintingFinished = true;
if(totalSupply_ == 0) {
throw;
}
}
}
function finishMinting() public onlyOwner {
mintingFinished = true;
}
function setTokenInformation(string _name, string _symbol) onlyOwner {
name = _name;
symbol = _symbol;
UpdatedTokenInformation(name, symbol);
}
} | 1 |
pragma solidity ^0.4.18;
contract Token {
function transfer(address to, uint256 value) public returns (bool success);
function transferFrom(address from, address to, uint256 value) public returns (bool success);
function balanceOf(address _owner) public constant returns (uint256 balance);
}
contract Autobid {
address public admin;
address public token;
uint public exchangeRate;
uint public expirationTime;
bool public active;
event TokenClaim(address tokenContract, address claimant, uint ethDeposited, uint tokensGranted);
event Redemption(address redeemer, uint tokensDeposited, uint redemptionAmount);
modifier autobidActive() {
require(active);
require(now < expirationTime);
_;
}
modifier autobidExpired() {
require(!active);
_;
}
modifier onlyAdmin() {
require(msg.sender == admin);
_;
}
function Autobid(address _admin, address _token, uint _exchangeRate, uint _expirationTime) public {
admin = _admin;
token = _token;
exchangeRate = _exchangeRate;
expirationTime = _expirationTime;
active = true;
}
function () public payable autobidActive {
uint tokenQuantity = msg.value * exchangeRate;
require(Token(token).transfer(msg.sender, tokenQuantity));
expirationCheck();
TokenClaim(token, msg.sender, msg.value, tokenQuantity);
}
function redeemTokens(uint amount) public autobidActive {
require(Token(token).transferFrom(msg.sender, this, amount));
uint redemptionValue = amount / exchangeRate;
msg.sender.transfer(redemptionValue);
Redemption(msg.sender, amount, redemptionValue);
}
function expirationCheck() public {
if (now > expirationTime) {
active = false;
}
uint remainingTokenSupply = Token(token).balanceOf(this);
if (remainingTokenSupply < exchangeRate) {
active = false;
}
}
function adminWithdraw(uint amount) public autobidExpired onlyAdmin {
msg.sender.transfer(amount);
Redemption(msg.sender, 0, amount);
}
function adminWithdrawTokens(uint amount) public autobidExpired onlyAdmin {
require(Token(token).transfer(msg.sender, amount));
TokenClaim(token, msg.sender, 0, amount);
}
function adminWithdrawMiscTokens(address tokenContract, uint amount) public autobidExpired onlyAdmin {
require(Token(tokenContract).transfer(msg.sender, amount));
TokenClaim(tokenContract, msg.sender, 0, amount);
}
} | 0 |
pragma solidity >=0.4.22 <0.6.0;
interface token {
function transfer(address receiver, uint amount) external;
}
contract Crowdsale {
address public beneficiary;
uint public fundingGoal;
uint public amountRaised;
uint public deadline;
mapping(address => uint256) public balanceOf;
bool fundingGoalReached = false;
bool crowdsaleClosed = false;
event GoalReached(address recipient, uint totalAmountRaised);
event FundTransfer(address backer, uint amount, bool isContribution);
constructor(
address ifSuccessfulSendTo,
uint fundingGoalInEthers,
uint durationInMinutes
) public {
beneficiary = ifSuccessfulSendTo;
fundingGoal = fundingGoalInEthers * 1 ether;
deadline = now + durationInMinutes * 1 minutes;
}
function () payable external {
require(!crowdsaleClosed);
uint amount = msg.value;
balanceOf[msg.sender] += amount;
amountRaised += amount;
emit FundTransfer(msg.sender, amount, true);
}
modifier afterDeadline() { if (now >= deadline) _; }
function checkGoalReached() public afterDeadline {
if (amountRaised >= fundingGoal){
fundingGoalReached = true;
emit GoalReached(beneficiary, amountRaised);
}
crowdsaleClosed = true;
}
function safeWithdrawal() public afterDeadline {
if (!fundingGoalReached) {
uint amount = balanceOf[msg.sender];
balanceOf[msg.sender] = 0;
if (amount > 0) {
if (msg.sender.send(amount)) {
emit FundTransfer(msg.sender, amount, false);
} else {
balanceOf[msg.sender] = amount;
}
}
}
if (fundingGoalReached && beneficiary == msg.sender) {
if (msg.sender.send(amountRaised)) {
emit FundTransfer(beneficiary, amountRaised, false);
} else {
fundingGoalReached = false;
}
}
}
} | 1 |
pragma solidity ^0.4.11;
contract Ownable {
address public owner;
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public 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);
}
contract GeneScienceInterface {
function isGeneScience() public pure returns (bool);
function mixGenes(uint256 genes1, uint256 genes2, uint256 targetBlock) public returns (uint256);
}
contract NinjaAccessControl {
event ContractUpgrade(address newContract);
address public ceoAddress;
address public cfoAddress;
address public cooAddress;
bool public paused = false;
modifier onlyCEO() {
require(msg.sender == ceoAddress);
_;
}
modifier onlyCFO() {
require(msg.sender == cfoAddress);
_;
}
modifier onlyCOO() {
require(msg.sender == cooAddress);
_;
}
modifier onlyCLevel() {
require(
msg.sender == cooAddress ||
msg.sender == ceoAddress ||
msg.sender == cfoAddress
);
_;
}
function setCEO(address _newCEO) external onlyCEO {
require(_newCEO != address(0));
ceoAddress = _newCEO;
}
function setCFO(address _newCFO) external onlyCEO {
require(_newCFO != address(0));
cfoAddress = _newCFO;
}
function setCOO(address _newCOO) external onlyCEO {
require(_newCOO != address(0));
cooAddress = _newCOO;
}
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused {
require(paused);
_;
}
function pause() external onlyCLevel whenNotPaused {
paused = true;
}
function unpause() public onlyCEO whenPaused {
paused = false;
}
}
contract NinjaBase is NinjaAccessControl {
event Birth(
address owner,
uint256 ninjaId,
uint256 matronId,
uint256 sireId,
uint256 genes,
uint256 birthTime
);
event Transfer(address from, address to, uint256 tokenId);
struct Ninja {
uint256 genes;
uint64 birthTime;
uint64 cooldownEndBlock;
uint32 matronId;
uint32 sireId;
uint32 siringWithId;
uint16 cooldownIndex;
uint16 generation;
}
uint32[14] public cooldowns = [
uint32(1 minutes),
uint32(2 minutes),
uint32(5 minutes),
uint32(10 minutes),
uint32(30 minutes),
uint32(1 hours),
uint32(2 hours),
uint32(4 hours),
uint32(8 hours),
uint32(16 hours),
uint32(1 days),
uint32(2 days),
uint32(4 days),
uint32(7 days)
];
uint256 public secondsPerBlock = 15;
Ninja[] ninjas;
mapping (uint256 => address) public ninjaIndexToOwner;
mapping (address => uint256) ownershipTokenCount;
mapping (uint256 => address) public ninjaIndexToApproved;
mapping (uint256 => address) public sireAllowedToAddress;
uint32 public destroyedNinjas;
SaleClockAuction public saleAuction;
SiringClockAuction public siringAuction;
function _transfer(address _from, address _to, uint256 _tokenId) internal {
if (_to == address(0)) {
delete ninjaIndexToOwner[_tokenId];
} else {
ownershipTokenCount[_to]++;
ninjaIndexToOwner[_tokenId] = _to;
}
if (_from != address(0)) {
ownershipTokenCount[_from]--;
delete sireAllowedToAddress[_tokenId];
delete ninjaIndexToApproved[_tokenId];
}
Transfer(_from, _to, _tokenId);
}
function _createNinja(
uint256 _matronId,
uint256 _sireId,
uint256 _generation,
uint256 _genes,
address _owner
)
internal
returns (uint)
{
require(_matronId == uint256(uint32(_matronId)));
require(_sireId == uint256(uint32(_sireId)));
require(_generation == uint256(uint16(_generation)));
uint16 cooldownIndex = uint16(_generation / 2);
if (cooldownIndex > 13) {
cooldownIndex = 13;
}
Ninja memory _ninja = Ninja({
genes: _genes,
birthTime: uint64(now),
cooldownEndBlock: 0,
matronId: uint32(_matronId),
sireId: uint32(_sireId),
siringWithId: 0,
cooldownIndex: cooldownIndex,
generation: uint16(_generation)
});
uint256 newNinjaId = ninjas.push(_ninja) - 1;
require(newNinjaId == uint256(uint32(newNinjaId)));
Birth(
_owner,
newNinjaId,
uint256(_ninja.matronId),
uint256(_ninja.sireId),
_ninja.genes,
uint256(_ninja.birthTime)
);
_transfer(0, _owner, newNinjaId);
return newNinjaId;
}
function _destroyNinja(uint256 _ninjaId) internal {
require(_ninjaId > 0);
address from = ninjaIndexToOwner[_ninjaId];
require(from != address(0));
destroyedNinjas++;
_transfer(from, 0, _ninjaId);
}
function setSecondsPerBlock(uint256 secs) external onlyCLevel {
require(secs < cooldowns[0]);
secondsPerBlock = secs;
}
}
contract NinjaExtension is NinjaBase {
event Lock(uint256 ninjaId, uint16 mask);
mapping (address => bool) extensions;
mapping (uint256 => uint16) locks;
uint16 constant LOCK_BREEDING = 1;
uint16 constant LOCK_TRANSFER = 2;
uint16 constant LOCK_ALL = LOCK_BREEDING | LOCK_TRANSFER;
function addExtension(address _contract) external onlyCEO {
extensions[_contract] = true;
}
function removeExtension(address _contract) external onlyCEO {
delete extensions[_contract];
}
modifier onlyExtension() {
require(extensions[msg.sender] == true);
_;
}
function extCreateNinja(
uint256 _matronId,
uint256 _sireId,
uint256 _generation,
uint256 _genes,
address _owner
)
public
onlyExtension
returns (uint)
{
return _createNinja(_matronId, _sireId, _generation, _genes, _owner);
}
function extDestroyNinja(uint256 _ninjaId)
public
onlyExtension
{
require(locks[_ninjaId] == 0);
_destroyNinja(_ninjaId);
}
function extLockNinja(uint256 _ninjaId, uint16 _mask)
public
onlyExtension
{
_lockNinja(_ninjaId, _mask);
}
function _lockNinja(uint256 _ninjaId, uint16 _mask)
internal
{
require(_mask > 0);
uint16 mask = locks[_ninjaId];
require(mask & _mask == 0);
if (_mask & LOCK_BREEDING > 0) {
Ninja storage ninja = ninjas[_ninjaId];
require(ninja.siringWithId == 0);
}
if (_mask & LOCK_TRANSFER > 0) {
address owner = ninjaIndexToOwner[_ninjaId];
require(owner != address(saleAuction));
require(owner != address(siringAuction));
}
mask |= _mask;
locks[_ninjaId] = mask;
Lock(_ninjaId, mask);
}
function extUnlockNinja(uint256 _ninjaId, uint16 _mask)
public
onlyExtension
returns (uint16)
{
_unlockNinja(_ninjaId, _mask);
}
function _unlockNinja(uint256 _ninjaId, uint16 _mask)
internal
{
require(_mask > 0);
uint16 mask = locks[_ninjaId];
require(mask & _mask == _mask);
mask ^= _mask;
locks[_ninjaId] = mask;
Lock(_ninjaId, mask);
}
function extGetLock(uint256 _ninjaId)
public
view
onlyExtension
returns (uint16)
{
return locks[_ninjaId];
}
}
contract NinjaOwnership is NinjaExtension, ERC721 {
string public constant name = "CryptoNinjas";
string public constant symbol = "CBT";
function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
return ninjaIndexToOwner[_tokenId] == _claimant;
}
function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) {
return ninjaIndexToApproved[_tokenId] == _claimant;
}
function _approve(uint256 _tokenId, address _approved) internal {
ninjaIndexToApproved[_tokenId] = _approved;
}
function balanceOf(address _owner) public view returns (uint256 count) {
return ownershipTokenCount[_owner];
}
function transfer(
address _to,
uint256 _tokenId
)
external
whenNotPaused
{
require(_to != address(0));
require(_to != address(this));
require(_to != address(saleAuction));
require(_to != address(siringAuction));
require(_owns(msg.sender, _tokenId));
require(locks[_tokenId] & LOCK_TRANSFER == 0);
_transfer(msg.sender, _to, _tokenId);
}
function approve(
address _to,
uint256 _tokenId
)
external
whenNotPaused
{
require(_owns(msg.sender, _tokenId));
require(locks[_tokenId] & LOCK_TRANSFER == 0);
_approve(_tokenId, _to);
Approval(msg.sender, _to, _tokenId);
}
function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
external
whenNotPaused
{
require(_to != address(0));
require(_to != address(this));
require(_approvedFor(msg.sender, _tokenId));
require(_owns(_from, _tokenId));
require(locks[_tokenId] & LOCK_TRANSFER == 0);
_transfer(_from, _to, _tokenId);
}
function totalSupply() public view returns (uint) {
return ninjas.length - destroyedNinjas;
}
function ownerOf(uint256 _tokenId)
external
view
returns (address owner)
{
owner = ninjaIndexToOwner[_tokenId];
require(owner != address(0));
}
function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalNinjas = ninjas.length - 1;
uint256 resultIndex = 0;
uint256 ninjaId;
for (ninjaId = 0; ninjaId <= totalNinjas; ninjaId++) {
if (ninjaIndexToOwner[ninjaId] == _owner) {
result[resultIndex] = ninjaId;
resultIndex++;
}
}
return result;
}
}
}
contract NinjaBreeding is NinjaOwnership {
event Pregnant(address owner, uint256 matronId, uint256 sireId, uint256 cooldownEndBlock);
uint256 public autoBirthFee = 2 finney;
uint256 public pregnantNinjas;
GeneScienceInterface public geneScience;
function setGeneScienceAddress(address _address) external onlyCEO {
GeneScienceInterface candidateContract = GeneScienceInterface(_address);
require(candidateContract.isGeneScience());
geneScience = candidateContract;
}
function _isReadyToBreed(uint256 _ninjaId, Ninja _ninja) internal view returns (bool) {
return
(_ninja.siringWithId == 0) &&
(_ninja.cooldownEndBlock <= uint64(block.number)) &&
(locks[_ninjaId] & LOCK_BREEDING == 0);
}
function _isSiringPermitted(uint256 _sireId, uint256 _matronId) internal view returns (bool) {
address matronOwner = ninjaIndexToOwner[_matronId];
address sireOwner = ninjaIndexToOwner[_sireId];
return (matronOwner == sireOwner || sireAllowedToAddress[_sireId] == matronOwner);
}
function _triggerCooldown(Ninja storage _ninja) internal {
_ninja.cooldownEndBlock = uint64((cooldowns[_ninja.cooldownIndex]/secondsPerBlock) + block.number);
if (_ninja.cooldownIndex < 13) {
_ninja.cooldownIndex += 1;
}
}
function approveSiring(address _addr, uint256 _sireId)
external
whenNotPaused
{
require(_owns(msg.sender, _sireId));
sireAllowedToAddress[_sireId] = _addr;
}
function setAutoBirthFee(uint256 val) external onlyCOO {
autoBirthFee = val;
}
function _isReadyToGiveBirth(Ninja _matron) private view returns (bool) {
return (_matron.siringWithId != 0) && (_matron.cooldownEndBlock <= uint64(block.number));
}
function isReadyToBreed(uint256 _ninjaId)
public
view
returns (bool)
{
Ninja storage ninja = ninjas[_ninjaId];
return _ninjaId > 0 && _isReadyToBreed(_ninjaId, ninja);
}
function isPregnant(uint256 _ninjaId)
public
view
returns (bool)
{
return _ninjaId > 0 && ninjas[_ninjaId].siringWithId != 0;
}
function _isValidMatingPair(
Ninja storage _matron,
uint256 _matronId,
Ninja storage _sire,
uint256 _sireId
)
private
view
returns(bool)
{
if (_matronId == _sireId) {
return false;
}
if (_matron.matronId == _sireId || _matron.sireId == _sireId) {
return false;
}
if (_sire.matronId == _matronId || _sire.sireId == _matronId) {
return false;
}
if (_sire.matronId == 0 || _matron.matronId == 0) {
return true;
}
if (_sire.matronId == _matron.matronId || _sire.matronId == _matron.sireId) {
return false;
}
if (_sire.sireId == _matron.matronId || _sire.sireId == _matron.sireId) {
return false;
}
return true;
}
function _canBreedWithViaAuction(uint256 _matronId, uint256 _sireId)
internal
view
returns (bool)
{
Ninja storage matron = ninjas[_matronId];
Ninja storage sire = ninjas[_sireId];
return _isValidMatingPair(matron, _matronId, sire, _sireId);
}
function canBreedWith(uint256 _matronId, uint256 _sireId)
external
view
returns(bool)
{
require(_matronId > 0);
require(_sireId > 0);
Ninja storage matron = ninjas[_matronId];
Ninja storage sire = ninjas[_sireId];
return _isValidMatingPair(matron, _matronId, sire, _sireId) &&
_isSiringPermitted(_sireId, _matronId);
}
function _breedWith(uint256 _matronId, uint256 _sireId) internal {
Ninja storage sire = ninjas[_sireId];
Ninja storage matron = ninjas[_matronId];
matron.siringWithId = uint32(_sireId);
_triggerCooldown(sire);
_triggerCooldown(matron);
delete sireAllowedToAddress[_matronId];
delete sireAllowedToAddress[_sireId];
pregnantNinjas++;
Pregnant(ninjaIndexToOwner[_matronId], _matronId, _sireId, matron.cooldownEndBlock);
}
function breedWithAuto(uint256 _matronId, uint256 _sireId)
external
payable
whenNotPaused
{
require(msg.value >= autoBirthFee);
require(_owns(msg.sender, _matronId));
require(_isSiringPermitted(_sireId, _matronId));
Ninja storage matron = ninjas[_matronId];
require(_isReadyToBreed(_matronId, matron));
Ninja storage sire = ninjas[_sireId];
require(_isReadyToBreed(_sireId, sire));
require(_isValidMatingPair(
matron,
_matronId,
sire,
_sireId
));
_breedWith(_matronId, _sireId);
}
function giveBirth(uint256 _matronId)
external
whenNotPaused
returns(uint256)
{
Ninja storage matron = ninjas[_matronId];
require(matron.birthTime != 0);
require(_isReadyToGiveBirth(matron));
uint256 sireId = matron.siringWithId;
Ninja storage sire = ninjas[sireId];
uint16 parentGen = matron.generation;
if (sire.generation > matron.generation) {
parentGen = sire.generation;
}
uint256 childGenes = geneScience.mixGenes(matron.genes, sire.genes, matron.cooldownEndBlock - 1);
address owner = ninjaIndexToOwner[_matronId];
uint256 ninjaId = _createNinja(_matronId, matron.siringWithId, parentGen + 1, childGenes, owner);
delete matron.siringWithId;
pregnantNinjas--;
msg.sender.send(autoBirthFee);
return ninjaId;
}
}
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(
address seller,
uint256 tokenId,
uint256 startingPrice,
uint256 endingPrice,
uint256 creationTime,
uint256 duration
);
event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address seller, address winner, uint256 time);
event AuctionCancelled(uint256 tokenId, address seller, uint256 time);
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(
_auction.seller,
uint256(_tokenId),
uint256(_auction.startingPrice),
uint256(_auction.endingPrice),
uint256(_auction.startedAt),
uint256(_auction.duration)
);
}
function _cancelAuction(uint256 _tokenId, address _seller) internal {
_removeAuction(_tokenId);
_transfer(_seller, _tokenId);
AuctionCancelled(_tokenId, _seller, uint256(now));
}
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, seller, msg.sender, uint256(now));
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() public onlyOwner whenNotPaused returns (bool) {
paused = true;
Pause();
return true;
}
function unpause() public onlyOwner whenPaused returns (bool) {
paused = false;
Unpause();
return true;
}
}
contract ClockAuction is Pausable, ClockAuctionBase {
function ClockAuction(address _nftAddress, uint256 _cut) public {
require(_cut <= 10000);
ownerCut = _cut;
ERC721 candidateContract = ERC721(_nftAddress);
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)
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 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 SiringClockAuction is ClockAuction {
bool public isSiringClockAuction = true;
function SiringClockAuction(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
{
require(msg.sender == address(nonFungibleContract));
address seller = tokenIdToAuction[_tokenId].seller;
_bid(_tokenId, msg.value);
_transfer(seller, _tokenId);
}
}
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;
}
}
contract NinjaAuction is NinjaBreeding {
function setSaleAuctionAddress(address _address) external onlyCEO {
SaleClockAuction candidateContract = SaleClockAuction(_address);
require(candidateContract.isSaleClockAuction());
saleAuction = candidateContract;
}
function setSiringAuctionAddress(address _address) external onlyCEO {
SiringClockAuction candidateContract = SiringClockAuction(_address);
require(candidateContract.isSiringClockAuction());
siringAuction = candidateContract;
}
function createSaleAuction(
uint256 _ninjaId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration
)
external
whenNotPaused
{
require(_owns(msg.sender, _ninjaId));
require(!isPregnant(_ninjaId));
_approve(_ninjaId, saleAuction);
saleAuction.createAuction(
_ninjaId,
_startingPrice,
_endingPrice,
_duration,
msg.sender
);
}
function createSiringAuction(
uint256 _ninjaId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration
)
external
whenNotPaused
{
require(_owns(msg.sender, _ninjaId));
require(isReadyToBreed(_ninjaId));
_approve(_ninjaId, siringAuction);
siringAuction.createAuction(
_ninjaId,
_startingPrice,
_endingPrice,
_duration,
msg.sender
);
}
function bidOnSiringAuction(
uint256 _sireId,
uint256 _matronId
)
external
payable
whenNotPaused
{
require(_owns(msg.sender, _matronId));
require(isReadyToBreed(_matronId));
require(_canBreedWithViaAuction(_matronId, _sireId));
uint256 currentPrice = siringAuction.getCurrentPrice(_sireId);
require(msg.value >= currentPrice + autoBirthFee);
siringAuction.bid.value(msg.value - autoBirthFee)(_sireId);
_breedWith(uint32(_matronId), uint32(_sireId));
}
function withdrawAuctionBalances() external onlyCLevel {
saleAuction.withdrawBalance();
siringAuction.withdrawBalance();
}
}
contract NinjaMinting is NinjaAuction {
uint256 public constant PROMO_CREATION_LIMIT = 5000;
uint256 public constant GEN0_CREATION_LIMIT = 45000;
uint256 public constant GEN0_STARTING_PRICE = 10 finney;
uint256 public constant GEN0_AUCTION_DURATION = 1 days;
uint256 public promoCreatedCount;
uint256 public gen0CreatedCount;
function createPromoNinja(uint256 _genes, address _owner) external onlyCOO {
address ninjaOwner = _owner;
if (ninjaOwner == address(0)) {
ninjaOwner = cooAddress;
}
require(promoCreatedCount < PROMO_CREATION_LIMIT);
promoCreatedCount++;
_createNinja(0, 0, 0, _genes, ninjaOwner);
}
function createGen0Auction(uint256 _genes) external onlyCOO {
require(gen0CreatedCount < GEN0_CREATION_LIMIT);
uint256 ninjaId = _createNinja(0, 0, 0, _genes, address(this));
_approve(ninjaId, saleAuction);
saleAuction.createAuction(
ninjaId,
_computeNextGen0Price(),
0,
GEN0_AUCTION_DURATION,
address(this)
);
gen0CreatedCount++;
}
function _computeNextGen0Price() internal view returns (uint256) {
uint256 avePrice = saleAuction.averageGen0SalePrice();
require(avePrice == uint256(uint128(avePrice)));
uint256 nextPrice = avePrice + (avePrice / 2);
if (nextPrice < GEN0_STARTING_PRICE) {
nextPrice = GEN0_STARTING_PRICE;
}
return nextPrice;
}
}
contract NinjaCore is NinjaMinting {
address public newContractAddress;
function NinjaCore() public {
paused = true;
ceoAddress = msg.sender;
cooAddress = msg.sender;
_createNinja(0, 0, 0, uint256(-1), msg.sender);
}
function setNewAddress(address _v2Address) external onlyCEO whenPaused {
newContractAddress = _v2Address;
ContractUpgrade(_v2Address);
}
function() external payable {
require(
msg.sender == address(saleAuction) ||
msg.sender == address(siringAuction)
);
}
function getNinja(uint256 _id)
external
view
returns (
bool isGestating,
bool isReady,
uint256 cooldownIndex,
uint256 nextActionAt,
uint256 siringWithId,
uint256 birthTime,
uint256 matronId,
uint256 sireId,
uint256 generation,
uint256 genes
)
{
require(ninjaIndexToOwner[_id] != address(0));
Ninja storage ninja = ninjas[_id];
isGestating = (ninja.siringWithId != 0);
isReady = (ninja.cooldownEndBlock <= block.number);
cooldownIndex = uint256(ninja.cooldownIndex);
nextActionAt = uint256(ninja.cooldownEndBlock);
siringWithId = uint256(ninja.siringWithId);
birthTime = uint256(ninja.birthTime);
matronId = uint256(ninja.matronId);
sireId = uint256(ninja.sireId);
generation = uint256(ninja.generation);
genes = ninja.genes;
}
function unpause() public onlyCEO whenPaused {
require(saleAuction != address(0));
require(siringAuction != address(0));
require(geneScience != address(0));
require(newContractAddress == address(0));
super.unpause();
}
function withdrawBalance() external onlyCFO {
uint256 balance = this.balance;
uint256 subtractFees = (pregnantNinjas + 1) * autoBirthFee;
if (balance > subtractFees) {
cfoAddress.send(balance - subtractFees);
}
}
function destroyNinja(uint256 _ninjaId) external onlyCEO {
require(locks[_ninjaId] == 0);
_destroyNinja(_ninjaId);
}
} | 0 |
pragma solidity ^0.4.23;
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract AccessControl is Ownable{
address CFO;
modifier onlyCFO{
require(msg.sender == CFO);
_;
}
function setCFO(address _newCFO)public onlyOwner {
CFO = _newCFO;
}
}
library AddressUtils {
function isContract(address addr) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(addr) }
return size > 0;
}
}
contract TrustedContractControl is Ownable{
using AddressUtils for address;
mapping (address => bool) public trustedContractList;
modifier onlyTrustedContract(address _contractAddress) {
require(trustedContractList[_contractAddress]);
_;
}
event AddTrustedContract(address contractAddress);
event RemoveTrustedContract(address contractAddress);
function addTrustedContracts(address[] _contractAddress) onlyOwner public {
for(uint i=0; i<_contractAddress.length; i++) {
require(addTrustedContract(_contractAddress[i]));
}
}
function addTrustedContract(address _contractAddress) onlyOwner public returns (bool){
require(!trustedContractList[_contractAddress]);
require(_contractAddress.isContract());
trustedContractList[_contractAddress] = true;
emit AddTrustedContract(_contractAddress);
return true;
}
function removeTrustedContract(address _contractAddress) onlyOwner public {
require(trustedContractList[_contractAddress]);
trustedContractList[_contractAddress] = false;
emit RemoveTrustedContract(_contractAddress);
}
}
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 Serialize {
using SafeMath for uint256;
function addAddress(uint _offst, bytes memory _output, address _input) internal pure returns(uint _offset) {
assembly {
mstore(add(_output, _offst), _input)
}
return _offst.sub(20);
}
function addUint(uint _offst, bytes memory _output, uint _input) internal pure returns (uint _offset) {
assembly {
mstore(add(_output, _offst), _input)
}
return _offst.sub(32);
}
function addUint8(uint _offst, bytes memory _output, uint _input) internal pure returns (uint _offset) {
assembly {
mstore(add(_output, _offst), _input)
}
return _offst.sub(1);
}
function addUint16(uint _offst, bytes memory _output, uint _input) internal pure returns (uint _offset) {
assembly {
mstore(add(_output, _offst), _input)
}
return _offst.sub(2);
}
function addUint64(uint _offst, bytes memory _output, uint _input) internal pure returns (uint _offset) {
assembly {
mstore(add(_output, _offst), _input)
}
return _offst.sub(8);
}
function getAddress(uint _offst, bytes memory _input) internal pure returns (address _output, uint _offset) {
assembly {
_output := mload(add(_input, _offst))
}
return (_output, _offst.sub(20));
}
function getUint(uint _offst, bytes memory _input) internal pure returns (uint _output, uint _offset) {
assembly {
_output := mload(add(_input, _offst))
}
return (_output, _offst.sub(32));
}
function getUint8(uint _offst, bytes memory _input) internal pure returns (uint8 _output, uint _offset) {
assembly {
_output := mload(add(_input, _offst))
}
return (_output, _offst.sub(1));
}
function getUint16(uint _offst, bytes memory _input) internal pure returns (uint16 _output, uint _offset) {
assembly {
_output := mload(add(_input, _offst))
}
return (_output, _offst.sub(2));
}
function getUint64(uint _offst, bytes memory _input) internal pure returns (uint64 _output, uint _offset) {
assembly {
_output := mload(add(_input, _offst))
}
return (_output, _offst.sub(8));
}
}
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 ERC721Basic {
event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 _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 ERC721Receiver {
bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba;
function onERC721Received(address _from, uint256 _tokenId, bytes _data) public returns(bytes4);
}
contract ERC721BasicToken is ERC721Basic, Pausable {
using SafeMath for uint256;
using AddressUtils for address;
bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba;
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));
_;
}
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));
if (getApproved(_tokenId) != address(0) || _to != address(0)) {
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 transferBatch(address _from, address _to, uint[] _tokenIds) public {
require(_from != address(0));
require(_to != address(0));
for(uint i=0; i<_tokenIds.length; i++) {
require(isApprovedOrOwner(msg.sender, _tokenIds[i]));
clearApproval(_from, _tokenIds[i]);
removeTokenFrom(_from, _tokenIds[i]);
addTokenTo(_to, _tokenIds[i]);
emit Transfer(_from, _to, _tokenIds[i]);
}
}
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);
emit Approval(_owner, address(0), _tokenId);
}
}
function addTokenTo(address _to, uint256 _tokenId) internal whenNotPaused {
require(tokenOwner[_tokenId] == address(0));
tokenOwner[_tokenId] = _to;
ownedTokensCount[_to] = ownedTokensCount[_to].add(1);
}
function removeTokenFrom(address _from, uint256 _tokenId) internal whenNotPaused{
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(_from, _tokenId, _data);
return (retval == ERC721_RECEIVED);
}
}
contract GirlBasicToken is ERC721BasicToken, Serialize {
event CreateGirl(address owner, uint256 tokenID, uint256 genes, uint64 birthTime, uint64 cooldownEndTime, uint16 starLevel);
event CoolDown(uint256 tokenId, uint64 cooldownEndTime);
event GirlUpgrade(uint256 tokenId, uint64 starLevel);
struct Girl{
uint genes;
uint64 birthTime;
uint64 cooldownEndTime;
uint16 starLevel;
}
Girl[] girls;
function totalSupply() public view returns (uint256) {
return girls.length;
}
function getGirlGene(uint _index) public view returns (uint) {
return girls[_index].genes;
}
function getGirlBirthTime(uint _index) public view returns (uint64) {
return girls[_index].birthTime;
}
function getGirlCoolDownEndTime(uint _index) public view returns (uint64) {
return girls[_index].cooldownEndTime;
}
function getGirlStarLevel(uint _index) public view returns (uint16) {
return girls[_index].starLevel;
}
function isNotCoolDown(uint _girlId) public view returns(bool) {
return uint64(now) > girls[_girlId].cooldownEndTime;
}
function _createGirl(
uint _genes,
address _owner,
uint16 _starLevel
) internal returns (uint){
Girl memory _girl = Girl({
genes:_genes,
birthTime:uint64(now),
cooldownEndTime:0,
starLevel:_starLevel
});
uint256 girlId = girls.push(_girl) - 1;
_mint(_owner, girlId);
emit CreateGirl(_owner, girlId, _genes, _girl.birthTime, _girl.cooldownEndTime, _girl.starLevel);
return girlId;
}
function _setCoolDownTime(uint _tokenId, uint _coolDownTime) internal {
girls[_tokenId].cooldownEndTime = uint64(now.add(_coolDownTime));
emit CoolDown(_tokenId, girls[_tokenId].cooldownEndTime);
}
function _LevelUp(uint _tokenId) internal {
require(girls[_tokenId].starLevel < 65535);
girls[_tokenId].starLevel = girls[_tokenId].starLevel + 1;
emit GirlUpgrade(_tokenId, girls[_tokenId].starLevel);
}
uint8 constant public GIRLBUFFERSIZE = 50;
struct HashLockContract {
address sender;
address receiver;
uint tokenId;
bytes32 hashlock;
uint timelock;
bytes32 secret;
States state;
bytes extraData;
}
enum States {
INVALID,
OPEN,
CLOSED,
REFUNDED
}
mapping (bytes32 => HashLockContract) private contracts;
modifier contractExists(bytes32 _contractId) {
require(_contractExists(_contractId));
_;
}
modifier hashlockMatches(bytes32 _contractId, bytes32 _secret) {
require(contracts[_contractId].hashlock == keccak256(_secret));
_;
}
modifier closable(bytes32 _contractId) {
require(contracts[_contractId].state == States.OPEN);
require(contracts[_contractId].timelock > now);
_;
}
modifier refundable(bytes32 _contractId) {
require(contracts[_contractId].state == States.OPEN);
require(contracts[_contractId].timelock <= now);
_;
}
event NewHashLockContract (
bytes32 indexed contractId,
address indexed sender,
address indexed receiver,
uint tokenId,
bytes32 hashlock,
uint timelock,
bytes extraData
);
event SwapClosed(bytes32 indexed contractId);
event SwapRefunded(bytes32 indexed contractId);
function open (
address _receiver,
bytes32 _hashlock,
uint _duration,
uint _tokenId
) public
onlyOwnerOf(_tokenId)
returns (bytes32 contractId)
{
uint _timelock = now.add(_duration);
bytes memory _extraData = new bytes(GIRLBUFFERSIZE);
uint offset = GIRLBUFFERSIZE;
offset = addUint16(offset, _extraData, girls[_tokenId].starLevel);
offset = addUint64(offset, _extraData, girls[_tokenId].cooldownEndTime);
offset = addUint64(offset, _extraData, girls[_tokenId].birthTime);
offset = addUint(offset, _extraData, girls[_tokenId].genes);
contractId = keccak256 (
msg.sender,
_receiver,
_tokenId,
_hashlock,
_timelock,
_extraData
);
require(!_contractExists(contractId));
clearApproval(msg.sender, _tokenId);
removeTokenFrom(msg.sender, _tokenId);
addTokenTo(address(this), _tokenId);
contracts[contractId] = HashLockContract(
msg.sender,
_receiver,
_tokenId,
_hashlock,
_timelock,
0x0,
States.OPEN,
_extraData
);
emit NewHashLockContract(contractId, msg.sender, _receiver, _tokenId, _hashlock, _timelock, _extraData);
}
function close(bytes32 _contractId, bytes32 _secret)
public
contractExists(_contractId)
hashlockMatches(_contractId, _secret)
closable(_contractId)
returns (bool)
{
HashLockContract storage c = contracts[_contractId];
c.secret = _secret;
c.state = States.CLOSED;
removeTokenFrom(address(this), c.tokenId);
addTokenTo(c.receiver, c.tokenId);
emit SwapClosed(_contractId);
return true;
}
function refund(bytes32 _contractId)
public
contractExists(_contractId)
refundable(_contractId)
returns (bool)
{
HashLockContract storage c = contracts[_contractId];
c.state = States.REFUNDED;
removeTokenFrom(address(this), c.tokenId);
addTokenTo(c.sender, c.tokenId);
emit SwapRefunded(_contractId);
return true;
}
function _contractExists(bytes32 _contractId) internal view returns (bool exists) {
exists = (contracts[_contractId].sender != address(0));
}
function checkContract(bytes32 _contractId)
public
view
contractExists(_contractId)
returns (
address sender,
address receiver,
uint amount,
bytes32 hashlock,
uint timelock,
bytes32 secret,
bytes extraData
)
{
HashLockContract memory c = contracts[_contractId];
return (
c.sender,
c.receiver,
c.tokenId,
c.hashlock,
c.timelock,
c.secret,
c.extraData
);
}
}
contract GirlOps is GirlBasicToken, TrustedContractControl {
string public name = "Cryptogirl";
string public symbol = "CG";
function createGirl(uint _genes, address _owner, uint16 _starLevel)
onlyTrustedContract(msg.sender) public returns (uint) {
require (_starLevel > 0);
return _createGirl(_genes, _owner, _starLevel);
}
function createPromotionGirl(uint[] _genes, address _owner, uint16 _starLevel) onlyOwner public {
require (_starLevel > 0);
for (uint i=0; i<_genes.length; i++) {
_createGirl(_genes[i], _owner, _starLevel);
}
}
function burnGirl(address _owner, uint _tokenId) onlyTrustedContract(msg.sender) public {
_burn(_owner, _tokenId);
}
function setCoolDownTime(uint _tokenId, uint _coolDownTime)
onlyTrustedContract(msg.sender) public {
_setCoolDownTime(_tokenId, _coolDownTime);
}
function levelUp(uint _tokenId)
onlyTrustedContract(msg.sender) public {
_LevelUp(_tokenId);
}
function safeTransferFromWithData(
address _from,
address _to,
uint256 _tokenId,
bytes _data
) public {
safeTransferFrom(_from,_to,_tokenId,_data);
}
}
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 AtomicSwappableToken is StandardToken {
struct HashLockContract {
address sender;
address receiver;
uint amount;
bytes32 hashlock;
uint timelock;
bytes32 secret;
States state;
}
enum States {
INVALID,
OPEN,
CLOSED,
REFUNDED
}
mapping (bytes32 => HashLockContract) private contracts;
modifier futureTimelock(uint _time) {
require(_time > now);
_;
}
modifier contractExists(bytes32 _contractId) {
require(_contractExists(_contractId));
_;
}
modifier hashlockMatches(bytes32 _contractId, bytes32 _secret) {
require(contracts[_contractId].hashlock == keccak256(_secret));
_;
}
modifier closable(bytes32 _contractId) {
require(contracts[_contractId].state == States.OPEN);
require(contracts[_contractId].timelock > now);
_;
}
modifier refundable(bytes32 _contractId) {
require(contracts[_contractId].state == States.OPEN);
require(contracts[_contractId].timelock <= now);
_;
}
event NewHashLockContract (
bytes32 indexed contractId,
address indexed sender,
address indexed receiver,
uint amount,
bytes32 hashlock,
uint timelock
);
event SwapClosed(bytes32 indexed contractId);
event SwapRefunded(bytes32 indexed contractId);
function open (
address _receiver,
bytes32 _hashlock,
uint _timelock,
uint _amount
) public
futureTimelock(_timelock)
returns (bytes32 contractId)
{
contractId = keccak256 (
msg.sender,
_receiver,
_amount,
_hashlock,
_timelock
);
require(!_contractExists(contractId));
require(transfer(address(this), _amount));
contracts[contractId] = HashLockContract(
msg.sender,
_receiver,
_amount,
_hashlock,
_timelock,
0x0,
States.OPEN
);
emit NewHashLockContract(contractId, msg.sender, _receiver, _amount, _hashlock, _timelock);
}
function close(bytes32 _contractId, bytes32 _secret)
public
contractExists(_contractId)
hashlockMatches(_contractId, _secret)
closable(_contractId)
returns (bool)
{
HashLockContract storage c = contracts[_contractId];
c.secret = _secret;
c.state = States.CLOSED;
require(this.transfer(c.receiver, c.amount));
emit SwapClosed(_contractId);
return true;
}
function refund(bytes32 _contractId)
public
contractExists(_contractId)
refundable(_contractId)
returns (bool)
{
HashLockContract storage c = contracts[_contractId];
c.state = States.REFUNDED;
require(this.transfer(c.sender, c.amount));
emit SwapRefunded(_contractId);
return true;
}
function _contractExists(bytes32 _contractId) internal view returns (bool exists) {
exists = (contracts[_contractId].sender != address(0));
}
function checkContract(bytes32 _contractId)
public
view
contractExists(_contractId)
returns (
address sender,
address receiver,
uint amount,
bytes32 hashlock,
uint timelock,
bytes32 secret
)
{
HashLockContract memory c = contracts[_contractId];
return (
c.sender,
c.receiver,
c.amount,
c.hashlock,
c.timelock,
c.secret
);
}
}
contract TokenReceiver {
function receiveApproval(address from, uint amount, address tokenAddress, bytes data) public;
}
contract BaseEquipment is Ownable, AtomicSwappableToken {
event Mint(address indexed to, uint256 amount);
uint256 public cap;
uint[] public properties;
address public controller;
modifier onlyController { require(msg.sender == controller); _; }
function setController(address _newController) public onlyOwner {
controller = _newController;
}
constructor(uint256 _cap, uint[] _properties) public {
cap = _cap;
properties = _properties;
}
function setProperty(uint256[] _properties) public onlyOwner {
properties = _properties;
}
function _mint(address _to, uint _amount) internal {
require(cap==0 || totalSupply_.add(_amount) <= cap);
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Transfer(address(0), _to, _amount);
}
function mint(address _to, uint256 _amount) onlyController public returns (bool) {
_mint(_to, _amount);
return true;
}
function mintFromOwner(address _to, uint256 _amount) onlyOwner public returns (bool) {
_mint(_to, _amount);
return true;
}
function approveAndCall(address _spender, uint _amount, bytes _data) public {
if(approve(_spender, _amount)) {
TokenReceiver(_spender).receiveApproval(msg.sender, _amount, address(this), _data);
}
}
function checkCap(uint256 _amount) public view returns (bool) {
return (cap==0 || totalSupply_.add(_amount) <= cap);
}
}
contract PrizePool is Ownable {
event SendPrized(address equipementAddress, address to);
address[] public magicBoxes;
mapping(address => bool) public magicBoxList;
address[] public equipments;
GirlOps public girlOps;
event SendEquipment(address to, address prizeAddress, uint time);
event EquipmentOutOfStock(address eqAddress);
modifier onlyMagicBox() {
require(magicBoxList[msg.sender]);
_;
}
constructor(address _girlOpsAddress) public {
girlOps = GirlOps(_girlOpsAddress);
}
function sendPrize(address _to, uint _index) public onlyMagicBox returns (bool) {
address prizeAddress = equipments[_index];
BaseEquipment baseEquipment = BaseEquipment(prizeAddress);
if(baseEquipment.checkCap(1 ether)) {
baseEquipment.mint(_to, 1 ether);
emit SendEquipment(_to, prizeAddress, now);
return true;
} else {
emit EquipmentOutOfStock(prizeAddress);
return false;
}
}
function mintGirl(address to, uint gene) public onlyMagicBox returns (bool) {
girlOps.createGirl(gene, to, 1);
return true;
}
function setEquipments(address[] _equipments) public onlyOwner {
equipments = _equipments;
}
function addMagicBox(address addr) public onlyOwner returns (bool) {
if (!magicBoxList[addr]) {
magicBoxList[addr] = true;
magicBoxes.push(addr);
return true;
} else {
return false;
}
}
function addMagicBoxes(address[] addrs) public onlyOwner returns (bool) {
for (uint i=0; i<addrs.length; i++) {
require(addMagicBox(addrs[i]));
}
return true;
}
function removeMagicBox(address addr) public onlyOwner returns (bool) {
require(magicBoxList[addr]);
for (uint i=0; i<magicBoxes.length - 1; i++) {
if (magicBoxes[i] == addr) {
magicBoxes[i] = magicBoxes[magicBoxes.length -1];
break;
}
}
magicBoxes.length -= 1;
magicBoxList[addr] = false;
return true;
}
}
contract MagicBox is AccessControl, TokenReceiver {
uint public keyRequired;
address public keyAddress;
address public prizePoolAddress;
string public name;
uint[] public prizeIndex;
uint[] public prizeRange;
uint public boxPrice;
mapping (uint => address) public openNonce;
uint public openNonceId;
mapping (address => bool) public serverAddressList;
modifier onlyServer {
require(serverAddressList[msg.sender]);
_;
}
event AddServerAddress(address contractAddress);
event RemoveServerAddress(address contractAddress);
function addServerAddresss(address[] _serverAddress) onlyOwner public {
for(uint i=0; i<_serverAddress.length; i++) {
require(addServerAddress(_serverAddress[i]));
}
}
function addServerAddress(address _serverAddress) onlyOwner public returns (bool){
serverAddressList[_serverAddress] = true;
emit AddServerAddress(_serverAddress);
return true;
}
function removeServerAddress(address _serverAddress) onlyOwner public {
require(serverAddressList[_serverAddress]);
serverAddressList[_serverAddress] = false;
emit RemoveServerAddress(_serverAddress);
}
event OpenBoxV2(address addr, uint time, uint openNonceId);
constructor(string _name, address _prizePoolAddress, address[] _serverAddress,address _keyAddress, uint _keyRequired, uint _boxPrice) public {
name = _name;
prizePoolAddress = _prizePoolAddress;
keyAddress = _keyAddress;
keyRequired = _keyRequired;
boxPrice = _boxPrice;
openNonceId = 0;
addServerAddresss(_serverAddress);
}
function setupPrize(uint[] _prizeIndex, uint[] _prizeRange) public onlyOwner {
prizeIndex = _prizeIndex;
prizeRange = _prizeRange;
}
function getPrizeIndex(uint random) public view returns (uint) {
uint maxRange = prizeRange[prizeRange.length -1];
uint n = random % maxRange;
uint start = 0;
uint mid = 0;
uint end = prizeRange.length-1;
if (prizeRange[0]>n){
return 0;
}
if (prizeRange[end-1]<=n){
return end;
}
while (start <= end) {
mid = start + (end - start) / 2;
if (prizeRange[mid]<=n && n<prizeRange[mid+1]){
return mid+1;
} else if (prizeRange[mid+1] <= n) {
start = mid+1;
} else {
end = mid;
}
}
return start;
}
function _openBox(address _from, uint _random, uint[] _genes) internal returns (bool) {
uint index = getPrizeIndex(_random);
PrizePool pl = PrizePool(prizePoolAddress);
uint count = 0;
while(count < prizeIndex.length) {
if(prizeIndex[index] < 10) {
pl.mintGirl(_from, _genes[prizeIndex[index]-1]);
return true;
} else if (pl.sendPrize(_from, prizeIndex[index] - 10)) {
return true;
} else {
count = count + 1;
index = index + 1;
if(index == prizeIndex.length) index = 0;
continue;
}
}
return false;
}
function setKeyAddress(address _key) public onlyOwner {
keyAddress = _key;
}
function openBoxFromServer(address _userAddress, uint _random, uint[] _gene, uint _openNonceId) public onlyServer returns (bool) {
require (openNonce[_openNonceId]==_userAddress,'Nonce Has been used');
delete openNonce[_openNonceId];
_openBox(_userAddress, _random, _gene);
}
function openBoxFromServerNoNonce(address _userAddress, uint _random, uint[] _gene) public onlyServer returns (bool) {
_openBox(_userAddress, _random, _gene);
}
function addOpenBoxFromServer(address _userAddress) public onlyServer {
openNonceId = openNonceId + 1;
openNonce[openNonceId] = _userAddress;
emit OpenBoxV2(_userAddress, now, openNonceId);
}
function() public payable {
require(msg.value == boxPrice);
openNonceId = openNonceId + 1;
openNonce[openNonceId] = msg.sender;
emit OpenBoxV2(msg.sender, now, openNonceId);
}
function receiveApproval(address _from, uint _amount, address _tokenAddress, bytes _data) public {
require(_tokenAddress == keyAddress);
require(_amount == keyRequired);
require(StandardToken(_tokenAddress).transferFrom(_from, address(this), _amount));
openNonceId = openNonceId + 1;
openNonce[openNonceId] = _from;
emit OpenBoxV2(_from, now, openNonceId);
}
function withDrawToken(uint _amount) public onlyCFO {
StandardToken(keyAddress).transfer(CFO, _amount);
}
function withDrawBalance(uint256 amount) public onlyCFO {
require(address(this).balance >= amount);
if (amount==0){
CFO.transfer(address(this).balance);
} else {
CFO.transfer(amount);
}
}
function setupBoxPrice(uint256 _boxPrice) public onlyCFO {
boxPrice = _boxPrice;
}
function setupKeyRequired(uint256 _keyRequired) public onlyCFO {
keyRequired = _keyRequired;
}
} | 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 MATOX is ERC20 {
using SafeMath for uint256;
address owner = msg.sender;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
string public constant name = "Matox";
string public constant symbol = "MAT";
uint public constant decimals = 8;
uint256 public totalSupply = 12000000000e8;
uint256 public totalDistributed = 0;
uint256 public constant MIN_CONTRIBUTION = 1 ether / 100;
uint256 public tokensPerEth = 30000000e8;
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 Burn(address indexed burner, uint256 value);
bool public distributionFinished = false;
modifier canDistr() {
require(!distributionFinished);
_;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function MATOX () public {
owner = msg.sender;
distr(owner, totalDistributed);
}
function transferOwnership(address newOwner) onlyOwner public {
if (newOwner != address(0)) {
owner = newOwner;
}
}
function finishDistribution() onlyOwner canDistr public returns (bool) {
distributionFinished = true;
emit DistrFinished();
return true;
}
function distr(address _to, uint256 _amount) canDistr private returns (bool) {
totalDistributed = totalDistributed.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Distr(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
function doAirdrop(address _participant, uint _amount) 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 adminClaimAirdrop(address _participant, uint _amount) public onlyOwner {
doAirdrop(_participant, _amount);
}
function adminClaimAirdropMultiple(address[] _addresses, uint _amount) public onlyOwner {
for (uint i = 0; i < _addresses.length; i++) doAirdrop(_addresses[i], _amount);
}
function updateTokensPerEth(uint _tokensPerEth) public onlyOwner {
tokensPerEth = _tokensPerEth;
emit TokensPerEthUpdated(_tokensPerEth);
}
function () external payable {
getTokens();
}
function getTokens() payable canDistr public {
uint256 tokens = 0;
require( msg.value >= MIN_CONTRIBUTION );
require( msg.value > 0 );
tokens = tokensPerEth.mul(msg.value) / 1 ether;
address investor = msg.sender;
if (tokens > 0) {
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 {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
totalDistributed = totalDistributed.sub(_value);
emit Burn(burner, _value);
}
function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
} | 1 |
pragma solidity ^0.4.13;
contract Authority {
function canCall(address src, address dst, bytes4 sig) constant returns (bool);
}
contract AuthEvents {
event LogSetAuthority (address indexed authority);
event LogSetOwner (address indexed owner);
event UnauthorizedAccess (address caller, bytes4 sig);
}
contract Auth is AuthEvents {
Authority public authority;
address public owner;
function Auth() {
owner = msg.sender;
LogSetOwner(msg.sender);
}
function setOwner(address owner_) auth {
owner = owner_;
LogSetOwner(owner);
}
function setAuthority(Authority authority_) auth {
authority = authority_;
LogSetAuthority(authority);
}
modifier auth {
require(isAuthorized(msg.sender, msg.sig));
_;
}
function isAuthorized(address src, bytes4 sig) internal returns (bool) {
if (src == address(this)) {
return true;
} else if (src == owner && authority == Authority(0)) {
return true;
} else if (authority == Authority(0)) {
UnauthorizedAccess(src, sig);
return false;
} else {
return authority.canCall(src, this, sig);
}
}
}
contract ERC20Events {
event Transfer( address indexed from, address indexed to, uint value);
event Approval( address indexed owner, address indexed spender, uint value);
}
contract ERC20 is ERC20Events{
function totalSupply() constant returns (uint supply);
function balanceOf( address who ) constant returns (uint value);
function allowance( address owner, address spender ) constant returns (uint _allowance);
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);
}
contract Math {
function add(uint256 x, uint256 y) constant internal returns (uint256 z) {
require((z = x + y) >= x);
}
function sub(uint256 x, uint256 y) constant internal returns (uint256 z) {
require((z = x - y) <= x);
}
function mul(uint256 x, uint256 y) constant internal returns (uint256 z) {
z = x * y;
require(z == 0 || z >= (x > y ? x : y));
}
function div(uint256 x, uint256 y) constant internal returns (uint256 z) {
require(y > 0);
z = x / y;
}
function min(uint256 x, uint256 y) constant internal returns (uint256 z) {
return x <= y ? x : y;
}
function max(uint256 x, uint256 y) constant internal returns (uint256 z) {
return x >= y ? x : y;
}
function hadd(uint128 x, uint128 y) constant internal returns (uint128 z) {
require((z = x + y) >= x);
}
function hsub(uint128 x, uint128 y) constant internal returns (uint128 z) {
require((z = x - y) <= x);
}
function hmul(uint128 x, uint128 y) constant internal returns (uint128 z) {
require((z = x * y) >= x);
}
function hdiv(uint128 x, uint128 y) constant internal returns (uint128 z) {
require(y > 0);
z = x / y;
}
function hmin(uint128 x, uint128 y) constant internal returns (uint128 z) {
return x <= y ? x : y;
}
function hmax(uint128 x, uint128 y) constant internal returns (uint128 z) {
return x >= y ? x : y;
}
function imin(int256 x, int256 y) constant internal returns (int256 z) {
return x <= y ? x : y;
}
function imax(int256 x, int256 y) constant internal returns (int256 z) {
return x >= y ? x : y;
}
uint128 constant WAD = 10 ** 18;
function wadd(uint128 x, uint128 y) constant internal returns (uint128) {
return hadd(x, y);
}
function wsub(uint128 x, uint128 y) constant internal returns (uint128) {
return hsub(x, y);
}
function wmul(uint128 x, uint128 y) constant internal returns (uint128 z) {
z = cast((uint256(x) * y + WAD / 2) / WAD);
}
function wdiv(uint128 x, uint128 y) constant internal returns (uint128 z) {
z = cast((uint256(x) * WAD + y / 2) / y);
}
function wmin(uint128 x, uint128 y) constant internal returns (uint128) {
return hmin(x, y);
}
function wmax(uint128 x, uint128 y) constant internal returns (uint128) {
return hmax(x, y);
}
uint128 constant RAY = 10 ** 27;
function radd(uint128 x, uint128 y) constant internal returns (uint128) {
return hadd(x, y);
}
function rsub(uint128 x, uint128 y) constant internal returns (uint128) {
return hsub(x, y);
}
function rmul(uint128 x, uint128 y) constant internal returns (uint128 z) {
z = cast((uint256(x) * y + RAY / 2) / RAY);
}
function rdiv(uint128 x, uint128 y) constant internal returns (uint128 z) {
z = cast((uint256(x) * RAY + y / 2) / y);
}
function rpow(uint128 x, uint64 n) constant internal returns (uint128 z) {
z = n % 2 != 0 ? x : RAY;
for (n /= 2; n != 0; n /= 2) {
x = rmul(x, x);
if (n % 2 != 0) {
z = rmul(z, x);
}
}
}
function rmin(uint128 x, uint128 y) constant internal returns (uint128) {
return hmin(x, y);
}
function rmax(uint128 x, uint128 y) constant internal returns (uint128) {
return hmax(x, y);
}
function cast(uint256 x) constant internal returns (uint128 z) {
require((z = uint128(x)) == x);
}
}
contract Migrations {
address public owner;
uint public last_completed_migration;
modifier restricted() {
if (msg.sender == owner) _;
}
function Migrations() {
owner = msg.sender;
}
function setCompleted(uint completed) restricted {
last_completed_migration = completed;
}
function upgrade(address new_address) restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
contract Note {
event LogNote(
bytes4 indexed sig,
address indexed guy,
bytes32 indexed foo,
bytes32 indexed bar,
uint wad,
bytes fax
) anonymous;
modifier note {
bytes32 foo;
bytes32 bar;
assembly {
foo := calldataload(4)
bar := calldataload(36)
}
LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data);
_;
}
}
contract Stoppable is Auth, Note {
bool public stopped;
modifier stoppable {
require (!stopped);
_;
}
function stop() auth note {
stopped = true;
}
function start() auth note {
stopped = false;
}
}
contract Token is ERC20, Stoppable {
bytes32 public symbol;
string public name;
uint256 public decimals = 18;
TokenLogic public logic;
function Token(string name_, bytes32 symbol_) {
name = name_;
symbol = symbol_;
}
function setLogic(TokenLogic logic_) auth note returns(bool){
logic = logic_;
return true;
}
function setOwner(address owner_) auth {
uint wad = balanceOf(owner);
logic.transfer(owner, owner_, wad);
Transfer(owner, owner_, wad);
logic.setOwner(owner_);
super.setOwner(owner_);
}
function totalSupply() constant returns (uint256){
return logic.totalSupply();
}
function balanceOf( address who ) constant returns (uint value) {
return logic.balanceOf(who);
}
function allowance( address owner, address spender ) constant returns (uint _allowance) {
return logic.allowance(owner, spender);
}
function transfer(address dst, uint wad) stoppable note returns (bool) {
bool retVal = logic.transfer(msg.sender, dst, wad);
Transfer(msg.sender, dst, wad);
return retVal;
}
function transferFrom(address src, address dst, uint wad) stoppable note returns (bool) {
bool retVal = logic.transferFrom(src, dst, wad);
Transfer(src, dst, wad);
return retVal;
}
function approve(address guy, uint wad) stoppable note returns (bool) {
return logic.approve(msg.sender, guy, wad);
}
function push(address dst, uint128 wad) returns (bool) {
return transfer(dst, wad);
}
function pull(address src, uint128 wad) returns (bool) {
return transferFrom(src, msg.sender, wad);
}
function mint(uint128 wad) auth stoppable note {
logic.mint(wad);
Transfer(this, msg.sender, wad);
}
function burn(uint128 wad) auth stoppable note {
logic.burn(msg.sender, wad);
}
function setName(string name_) auth {
name = name_;
}
function setSymbol(bytes32 symbol_) auth {
symbol = symbol_;
}
function () payable {
require(msg.value > 0);
uint wad = logic.handlePayment(msg.sender, msg.value);
Transfer(this, msg.sender, wad);
}
function transferEth(address dst, uint wad) {
require(msg.sender == address(logic));
require(wad < this.balance);
dst.transfer(wad);
}
function triggerTansferEvent(address src, address dst, uint wad) {
require(msg.sender == address(logic));
Transfer(src, dst, wad);
}
function payout(address dst) auth {
require(dst != address(0));
dst.transfer(this.balance);
}
}
contract TokenData is Auth {
uint256 public supply;
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public approvals;
address token;
modifier tokenOnly {
assert(msg.sender == token);
_;
}
function TokenData(address token_, uint supply_, address owner_) {
token = token_;
supply = supply_;
owner = owner_;
balances[owner] = supply;
}
function setOwner(address owner_) tokenOnly {
owner = owner_;
LogSetOwner(owner);
}
function setToken(address token_) auth {
token = token_;
}
function setSupply(uint supply_) tokenOnly {
supply = supply_;
}
function setBalances(address guy, uint balance) tokenOnly {
balances[guy] = balance;
}
function setApprovals(address src, address guy, uint wad) tokenOnly {
approvals[src][guy] = wad;
}
}
contract TokenLogic is ERC20Events, Math, Stoppable {
TokenData public data;
Token public token;
uint public tokensPerWei=3000;
bool public presale = true;
uint public icoStart=1503756000;
uint public icoEnd;
uint public icoSale;
uint public maxIco = 90000000000000000000000000;
address[] contributors;
function TokenLogic(Token token_, TokenData data_, uint icoStart_, uint icoHours_) {
require(token_ != Token(0x0));
if(data_ == address(0x0)) {
data = new TokenData(this, 120000000000000000000000000, msg.sender);
} else {
data = data_;
}
token = token_;
icoStart = icoStart_;
icoEnd = icoStart + icoHours_ * 3600;
}
modifier tokenOnly {
assert(msg.sender == address(token) || msg.sender == address(this));
_;
}
function contributorCount() constant returns(uint) {
return contributors.length;
}
function setOwner(address owner_) tokenOnly {
owner = owner_;
LogSetOwner(owner);
data.setOwner(owner);
}
function setToken(Token token_) auth {
token = token_;
}
function setIcoStart(uint icoStart_, uint icoHours_) auth {
icoStart = icoStart_;
icoEnd = icoStart + icoHours_ * 3600;
}
function setPresale(bool presale_) auth {
presale = presale_;
}
function setTokensPerWei(uint tokensPerWei_) auth {
require(tokensPerWei_ > 0);
tokensPerWei = tokensPerWei_;
}
function totalSupply() constant returns (uint256) {
return data.supply();
}
function balanceOf(address src) constant returns (uint256) {
return data.balances(src);
}
function allowance(address src, address guy) constant returns (uint256) {
return data.approvals(src, guy);
}
function transfer(address src, address dst, uint wad) tokenOnly returns (bool) {
require(balanceOf(src) >= wad);
data.setBalances(src, sub(data.balances(src), wad));
data.setBalances(dst, add(data.balances(dst), wad));
return true;
}
function transferFrom(address src, address dst, uint wad) tokenOnly returns (bool) {
require(data.balances(src) >= wad);
require(data.approvals(src, dst) >= wad);
data.setApprovals(src, dst, sub(data.approvals(src, dst), wad));
data.setBalances(src, sub(data.balances(src), wad));
data.setBalances(dst, add(data.balances(dst), wad));
return true;
}
function approve(address src, address guy, uint256 wad) tokenOnly returns (bool) {
data.setApprovals(src, guy, wad);
Approval(src, guy, wad);
return true;
}
function mint(uint128 wad) tokenOnly {
data.setBalances(data.owner(), add(data.balances(data.owner()), wad));
data.setSupply(add(data.supply(), wad));
}
function burn(address src, uint128 wad) tokenOnly {
require(balanceOf(src) >= wad);
data.setBalances(src, sub(data.balances(src), wad));
data.setSupply(sub(data.supply(), wad));
}
function returnIcoInvestments(uint contributorIndex) auth {
require(now > icoEnd && icoSale < 20000000000000000000000000);
address src = contributors[contributorIndex];
require(src != address(0));
uint srcBalance = balanceOf(src);
token.transferEth(src, sub(div(srcBalance, tokensPerWei), 5 finney));
data.setBalances(src, sub(data.balances(src), srcBalance));
data.setBalances(owner, add(data.balances(owner), srcBalance));
token.triggerTansferEvent(src, owner, srcBalance);
contributors[contributorIndex] = address(0);
}
function handlePayment(address src, uint eth) tokenOnly returns (uint){
require(eth > 0);
require(now >= icoStart && now <= icoEnd);
require(icoSale < maxIco);
uint tokenAmount = mul(tokensPerWei, eth);
if (!presale) {
if (now < icoStart + (168 * 3600)) {
tokenAmount = tokenAmount * 150 / 100;
}
else if (now < icoStart + (312 * 3600)) {
tokenAmount = tokenAmount * 130 / 100;
}
else if (now < icoStart + (456 * 3600)) {
tokenAmount = tokenAmount * 110 / 100;
}
}
icoSale += tokenAmount;
if(icoSale > maxIco) {
uint excess = sub(icoSale, maxIco);
tokenAmount = sub(tokenAmount, excess);
token.transferEth(src, div(excess, tokensPerWei));
icoSale = maxIco;
}
require(balanceOf(owner) >= tokenAmount);
data.setBalances(owner, sub(data.balances(owner), tokenAmount));
data.setBalances(src, add(data.balances(src), tokenAmount));
contributors.push(src);
token.triggerTansferEvent(owner, src, tokenAmount);
return tokenAmount;
}
} | 0 |
pragma solidity ^0.4.20;
interface ERC165 {
function supportsInterface(bytes4 interfaceID) external view returns (bool);
}
contract ERC721 is ERC165 {
event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
function balanceOf(address _owner) external view returns (uint256);
function ownerOf(uint256 _tokenId) external view returns (address);
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external;
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external;
function transferFrom(address _from, address _to, uint256 _tokenId) external;
function approve(address _approved, uint256 _tokenId) external;
function setApprovalForAll(address _operator, bool _approved) external;
function getApproved(uint256 _tokenId) external view returns (address);
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
}
interface ERC721TokenReceiver {
function onERC721Received(address _from, uint256 _tokenId, bytes data) external returns(bytes4);
}
contract AccessAdmin {
bool public isPaused = false;
address public addrAdmin;
event AdminTransferred(address indexed preAdmin, address indexed newAdmin);
function AccessAdmin() public {
addrAdmin = msg.sender;
}
modifier onlyAdmin() {
require(msg.sender == addrAdmin);
_;
}
modifier whenNotPaused() {
require(!isPaused);
_;
}
modifier whenPaused {
require(isPaused);
_;
}
function setAdmin(address _newAdmin) external onlyAdmin {
require(_newAdmin != address(0));
AdminTransferred(addrAdmin, _newAdmin);
addrAdmin = _newAdmin;
}
function doPause() external onlyAdmin whenNotPaused {
isPaused = true;
}
function doUnpause() external onlyAdmin whenPaused {
isPaused = false;
}
}
contract AccessService is AccessAdmin {
address public addrService;
address public addrFinance;
modifier onlyService() {
require(msg.sender == addrService);
_;
}
modifier onlyFinance() {
require(msg.sender == addrFinance);
_;
}
function setService(address _newService) external {
require(msg.sender == addrService || msg.sender == addrAdmin);
require(_newService != address(0));
addrService = _newService;
}
function setFinance(address _newFinance) external {
require(msg.sender == addrFinance || msg.sender == addrAdmin);
require(_newFinance != address(0));
addrFinance = _newFinance;
}
function withdraw(address _target, uint256 _amount)
external
{
require(msg.sender == addrFinance || msg.sender == addrAdmin);
require(_amount > 0);
address receiver = _target == address(0) ? addrFinance : _target;
uint256 balance = this.balance;
if (_amount < balance) {
receiver.transfer(_amount);
} else {
receiver.transfer(this.balance);
}
}
}
interface IDataEquip {
function isEquiped(address _target, uint256 _tokenId) external view returns(bool);
function isEquipedAny2(address _target, uint256 _tokenId1, uint256 _tokenId2) external view returns(bool);
function isEquipedAny3(address _target, uint256 _tokenId1, uint256 _tokenId2, uint256 _tokenId3) external view returns(bool);
}
interface IRaceCoin {
function addTotalEtherPool(uint256 amount) external;
function addPlayerToList(address player) external;
function increasePlayersAttribute(address player, uint16[13] param) external;
function reducePlayersAttribute(address player, uint16[13] param) external;
}
contract Random {
uint256 _seed;
function _rand() internal returns (uint256) {
_seed = uint256(keccak256(_seed, block.blockhash(block.number - 1), block.coinbase, block.difficulty));
return _seed;
}
function _randBySeed(uint256 _outSeed) internal view returns (uint256) {
return uint256(keccak256(_outSeed, block.blockhash(block.number - 1), block.coinbase, block.difficulty));
}
}
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 RaceToken is ERC721, AccessAdmin {
struct Fashion {
uint16 equipmentId;
uint16 quality;
uint16 pos;
uint16 production;
uint16 attack;
uint16 defense;
uint16 plunder;
uint16 productionMultiplier;
uint16 attackMultiplier;
uint16 defenseMultiplier;
uint16 plunderMultiplier;
uint16 level;
uint16 isPercent;
}
Fashion[] public fashionArray;
uint256 destroyFashionCount;
mapping (uint256 => address) fashionIdToOwner;
mapping (address => uint256[]) ownerToFashionArray;
mapping (uint256 => uint256) fashionIdToOwnerIndex;
mapping (uint256 => address) fashionIdToApprovals;
mapping (address => mapping (address => bool)) operatorToApprovals;
mapping (address => bool) actionContracts;
function setActionContract(address _actionAddr, bool _useful) external onlyAdmin {
actionContracts[_actionAddr] = _useful;
}
function getActionContract(address _actionAddr) external view onlyAdmin returns(bool) {
return actionContracts[_actionAddr];
}
event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
event Transfer(address indexed from, address indexed to, uint256 tokenId);
event CreateFashion(address indexed owner, uint256 tokenId, uint16 equipmentId, uint16 quality, uint16 pos, uint16 level, uint16 createType);
event ChangeFashion(address indexed owner, uint256 tokenId, uint16 changeType);
event DeleteFashion(address indexed owner, uint256 tokenId, uint16 deleteType);
function RaceToken() public {
addrAdmin = msg.sender;
fashionArray.length += 1;
}
modifier isValidToken(uint256 _tokenId) {
require(_tokenId >= 1 && _tokenId <= fashionArray.length);
require(fashionIdToOwner[_tokenId] != address(0));
_;
}
modifier canTransfer(uint256 _tokenId) {
address owner = fashionIdToOwner[_tokenId];
require(msg.sender == owner || msg.sender == fashionIdToApprovals[_tokenId] || operatorToApprovals[owner][msg.sender]);
_;
}
function supportsInterface(bytes4 _interfaceId) external view returns(bool) {
return (_interfaceId == 0x01ffc9a7 || _interfaceId == 0x80ac58cd || _interfaceId == 0x8153916a) && (_interfaceId != 0xffffffff);
}
function name() public pure returns(string) {
return "Race Token";
}
function symbol() public pure returns(string) {
return "Race";
}
function balanceOf(address _owner) external view returns(uint256) {
require(_owner != address(0));
return ownerToFashionArray[_owner].length;
}
function ownerOf(uint256 _tokenId) external view returns (address owner) {
return fashionIdToOwner[_tokenId];
}
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data)
external
whenNotPaused
{
_safeTransferFrom(_from, _to, _tokenId, data);
}
function safeTransferFrom(address _from, address _to, uint256 _tokenId)
external
whenNotPaused
{
_safeTransferFrom(_from, _to, _tokenId, "");
}
function transferFrom(address _from, address _to, uint256 _tokenId)
external
whenNotPaused
isValidToken(_tokenId)
canTransfer(_tokenId)
{
address owner = fashionIdToOwner[_tokenId];
require(owner != address(0));
require(_to != address(0));
require(owner == _from);
_transfer(_from, _to, _tokenId);
}
function approve(address _approved, uint256 _tokenId)
external
whenNotPaused
{
address owner = fashionIdToOwner[_tokenId];
require(owner != address(0));
require(msg.sender == owner || operatorToApprovals[owner][msg.sender]);
fashionIdToApprovals[_tokenId] = _approved;
Approval(owner, _approved, _tokenId);
}
function setApprovalForAll(address _operator, bool _approved)
external
whenNotPaused
{
operatorToApprovals[msg.sender][_operator] = _approved;
ApprovalForAll(msg.sender, _operator, _approved);
}
function getApproved(uint256 _tokenId) external view isValidToken(_tokenId) returns (address) {
return fashionIdToApprovals[_tokenId];
}
function isApprovedForAll(address _owner, address _operator) external view returns (bool) {
return operatorToApprovals[_owner][_operator];
}
function totalSupply() external view returns (uint256) {
return fashionArray.length - destroyFashionCount - 1;
}
function _transfer(address _from, address _to, uint256 _tokenId) internal {
if (_from != address(0)) {
uint256 indexFrom = fashionIdToOwnerIndex[_tokenId];
uint256[] storage fsArray = ownerToFashionArray[_from];
require(fsArray[indexFrom] == _tokenId);
if (indexFrom != fsArray.length - 1) {
uint256 lastTokenId = fsArray[fsArray.length - 1];
fsArray[indexFrom] = lastTokenId;
fashionIdToOwnerIndex[lastTokenId] = indexFrom;
}
fsArray.length -= 1;
if (fashionIdToApprovals[_tokenId] != address(0)) {
delete fashionIdToApprovals[_tokenId];
}
}
fashionIdToOwner[_tokenId] = _to;
ownerToFashionArray[_to].push(_tokenId);
fashionIdToOwnerIndex[_tokenId] = ownerToFashionArray[_to].length - 1;
Transfer(_from != address(0) ? _from : this, _to, _tokenId);
}
function _safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data)
internal
isValidToken(_tokenId)
canTransfer(_tokenId)
{
address owner = fashionIdToOwner[_tokenId];
require(owner != address(0));
require(_to != address(0));
require(owner == _from);
_transfer(_from, _to, _tokenId);
uint256 codeSize;
assembly { codeSize := extcodesize(_to) }
if (codeSize == 0) {
return;
}
bytes4 retval = ERC721TokenReceiver(_to).onERC721Received(_from, _tokenId, data);
require(retval == 0xf0b9e5ba);
}
function createFashion(address _owner, uint16[13] _attrs, uint16 _createType)
external
whenNotPaused
returns(uint256)
{
require(actionContracts[msg.sender]);
require(_owner != address(0));
uint256 newFashionId = fashionArray.length;
require(newFashionId < 4294967296);
fashionArray.length += 1;
Fashion storage fs = fashionArray[newFashionId];
fs.equipmentId = _attrs[0];
fs.quality = _attrs[1];
fs.pos = _attrs[2];
if (_attrs[3] != 0) {
fs.production = _attrs[3];
}
if (_attrs[4] != 0) {
fs.attack = _attrs[4];
}
if (_attrs[5] != 0) {
fs.defense = _attrs[5];
}
if (_attrs[6] != 0) {
fs.plunder = _attrs[6];
}
if (_attrs[7] != 0) {
fs.productionMultiplier = _attrs[7];
}
if (_attrs[8] != 0) {
fs.attackMultiplier = _attrs[8];
}
if (_attrs[9] != 0) {
fs.defenseMultiplier = _attrs[9];
}
if (_attrs[10] != 0) {
fs.plunderMultiplier = _attrs[10];
}
if (_attrs[11] != 0) {
fs.level = _attrs[11];
}
if (_attrs[12] != 0) {
fs.isPercent = _attrs[12];
}
_transfer(0, _owner, newFashionId);
CreateFashion(_owner, newFashionId, _attrs[0], _attrs[1], _attrs[2], _attrs[11], _createType);
return newFashionId;
}
function _changeAttrByIndex(Fashion storage _fs, uint16 _index, uint16 _val) internal {
if (_index == 3) {
_fs.production = _val;
} else if(_index == 4) {
_fs.attack = _val;
} else if(_index == 5) {
_fs.defense = _val;
} else if(_index == 6) {
_fs.plunder = _val;
}else if(_index == 7) {
_fs.productionMultiplier = _val;
}else if(_index == 8) {
_fs.attackMultiplier = _val;
}else if(_index == 9) {
_fs.defenseMultiplier = _val;
}else if(_index == 10) {
_fs.plunderMultiplier = _val;
} else if(_index == 11) {
_fs.level = _val;
}
}
function changeFashionAttr(uint256 _tokenId, uint16[4] _idxArray, uint16[4] _params, uint16 _changeType)
external
whenNotPaused
isValidToken(_tokenId)
{
require(actionContracts[msg.sender]);
Fashion storage fs = fashionArray[_tokenId];
if (_idxArray[0] > 0) {
_changeAttrByIndex(fs, _idxArray[0], _params[0]);
}
if (_idxArray[1] > 0) {
_changeAttrByIndex(fs, _idxArray[1], _params[1]);
}
if (_idxArray[2] > 0) {
_changeAttrByIndex(fs, _idxArray[2], _params[2]);
}
if (_idxArray[3] > 0) {
_changeAttrByIndex(fs, _idxArray[3], _params[3]);
}
ChangeFashion(fashionIdToOwner[_tokenId], _tokenId, _changeType);
}
function destroyFashion(uint256 _tokenId, uint16 _deleteType)
external
whenNotPaused
isValidToken(_tokenId)
{
require(actionContracts[msg.sender]);
address _from = fashionIdToOwner[_tokenId];
uint256 indexFrom = fashionIdToOwnerIndex[_tokenId];
uint256[] storage fsArray = ownerToFashionArray[_from];
require(fsArray[indexFrom] == _tokenId);
if (indexFrom != fsArray.length - 1) {
uint256 lastTokenId = fsArray[fsArray.length - 1];
fsArray[indexFrom] = lastTokenId;
fashionIdToOwnerIndex[lastTokenId] = indexFrom;
}
fsArray.length -= 1;
fashionIdToOwner[_tokenId] = address(0);
delete fashionIdToOwnerIndex[_tokenId];
destroyFashionCount += 1;
Transfer(_from, 0, _tokenId);
DeleteFashion(_from, _tokenId, _deleteType);
}
function safeTransferByContract(uint256 _tokenId, address _to)
external
whenNotPaused
{
require(actionContracts[msg.sender]);
require(_tokenId >= 1 && _tokenId <= fashionArray.length);
address owner = fashionIdToOwner[_tokenId];
require(owner != address(0));
require(_to != address(0));
require(owner != _to);
_transfer(owner, _to, _tokenId);
}
function getFashion(uint256 _tokenId) external view isValidToken(_tokenId) returns (uint16[13] datas) {
Fashion storage fs = fashionArray[_tokenId];
datas[0] = fs.equipmentId;
datas[1] = fs.quality;
datas[2] = fs.pos;
datas[3] = fs.production;
datas[4] = fs.attack;
datas[5] = fs.defense;
datas[6] = fs.plunder;
datas[7] = fs.productionMultiplier;
datas[8] = fs.attackMultiplier;
datas[9] = fs.defenseMultiplier;
datas[10] = fs.plunderMultiplier;
datas[11] = fs.level;
datas[12] = fs.isPercent;
}
function getOwnFashions(address _owner) external view returns(uint256[] tokens, uint32[] flags) {
require(_owner != address(0));
uint256[] storage fsArray = ownerToFashionArray[_owner];
uint256 length = fsArray.length;
tokens = new uint256[](length);
flags = new uint32[](length);
for (uint256 i = 0; i < length; ++i) {
tokens[i] = fsArray[i];
Fashion storage fs = fashionArray[fsArray[i]];
flags[i] = uint32(uint32(fs.equipmentId) * 100 + uint32(fs.quality) * 10 + fs.pos);
}
}
function getFashionsAttrs(uint256[] _tokens) external view returns(uint16[] attrs) {
uint256 length = _tokens.length;
require(length <= 64);
attrs = new uint16[](length * 13);
uint256 tokenId;
uint256 index;
for (uint256 i = 0; i < length; ++i) {
tokenId = _tokens[i];
if (fashionIdToOwner[tokenId] != address(0)) {
index = i * 13;
Fashion storage fs = fashionArray[tokenId];
attrs[index] = fs.equipmentId;
attrs[index + 1] = fs.quality;
attrs[index + 2] = fs.pos;
attrs[index + 3] = fs.production;
attrs[index + 4] = fs.attack;
attrs[index + 5] = fs.defense;
attrs[index + 6] = fs.plunder;
attrs[index + 7] = fs.productionMultiplier;
attrs[index + 8] = fs.attackMultiplier;
attrs[index + 9] = fs.defenseMultiplier;
attrs[index + 10] = fs.plunderMultiplier;
attrs[index + 11] = fs.level;
attrs[index + 12] = fs.isPercent;
}
}
}
}
contract DataEquip is AccessService, IDataEquip {
event EquipChanged(address indexed _target);
RaceToken public tokenContract;
IRaceCoin public raceCoinContract;
mapping (address => uint256[]) public slotlist;
mapping (uint256 => uint256) public carSlot;
mapping (uint256 => uint256) public slotEngine;
mapping (uint256 => uint256) public slotTurbine;
mapping (uint256 => uint256) public slotBodySystem;
mapping (uint256 => uint256) public slotPipe;
mapping (uint256 => uint256) public slotSuspension;
mapping (uint256 => uint256) public slotNO2;
mapping (uint256 => uint256) public slotTyre;
mapping (uint256 => uint256) public slotTransmission;
function DataEquip(address _nftTokenAddr) public {
addrAdmin = msg.sender;
addrService = msg.sender;
addrFinance = msg.sender;
tokenContract = RaceToken(_nftTokenAddr);
}
function setRaceCoin(address _addr) external onlyAdmin {
require(_addr != address(0));
raceCoinContract = IRaceCoin(_addr);
}
function _equipUpOne(address _owner, uint256 _carTokenId, uint256 _partsTokenId) private {
require(tokenContract.ownerOf(_carTokenId) == _owner);
require(tokenContract.ownerOf(_partsTokenId) == _owner);
uint16[13] memory attrs = tokenContract.getFashion(_partsTokenId);
uint16 pos = attrs[2];
bool isEquip = this.isEquiped(_owner, _partsTokenId);
uint256[] storage sArray = slotlist[_owner];
uint256 i = 0;
uint16[13] memory attrsOldParts;
if(!isEquip){
if (pos == 1) {
if (slotEngine[_carTokenId] != _partsTokenId) {
if(slotEngine[_carTokenId] > 0){
attrsOldParts = tokenContract.getFashion(slotEngine[_carTokenId]);
raceCoinContract.reducePlayersAttribute(_owner, attrsOldParts);
}
for( i = 0; i < sArray.length; i++){
if(sArray[i] == slotEngine[_carTokenId]){
delete sArray[i];
}
}
if(slotEngine[_carTokenId] > 0){
}else{
carSlot[_carTokenId]++;
}
slotEngine[_carTokenId] = _partsTokenId;
slotlist[_owner].push(_partsTokenId);
raceCoinContract.increasePlayersAttribute(_owner, attrs);
}
} else if (pos == 2) {
if (slotTurbine[_carTokenId] != _partsTokenId) {
if(slotTurbine[_carTokenId] > 0){
attrsOldParts = tokenContract.getFashion(slotTurbine[_carTokenId]);
raceCoinContract.reducePlayersAttribute(_owner, attrsOldParts);
}
for( i = 0; i < sArray.length; i++){
if(sArray[i] == slotTurbine[_carTokenId]){
delete sArray[i];
}
}
if(slotTurbine[_carTokenId] > 0){
}else{
carSlot[_carTokenId]++;
}
slotTurbine[_carTokenId] = _partsTokenId;
slotlist[_owner].push(_partsTokenId);
raceCoinContract.increasePlayersAttribute(_owner, attrs);
}
} else if (pos == 3) {
if (slotBodySystem[_carTokenId] != _partsTokenId) {
if(slotBodySystem[_carTokenId] > 0){
attrsOldParts = tokenContract.getFashion(slotBodySystem[_carTokenId]);
raceCoinContract.reducePlayersAttribute(_owner, attrsOldParts);
}
for( i = 0; i < sArray.length; i++){
if(sArray[i] == slotBodySystem[_carTokenId]){
delete sArray[i];
}
}
if(slotBodySystem[_carTokenId] > 0){
}else{
carSlot[_carTokenId]++;
}
slotBodySystem[_carTokenId] = _partsTokenId;
slotlist[_owner].push(_partsTokenId);
raceCoinContract.increasePlayersAttribute(_owner, attrs);
}
} else if (pos == 4) {
if (slotPipe[_carTokenId] != _partsTokenId) {
if(slotPipe[_carTokenId] > 0){
attrsOldParts = tokenContract.getFashion(slotPipe[_carTokenId]);
raceCoinContract.reducePlayersAttribute(_owner, attrsOldParts);
}
for( i = 0; i < sArray.length; i++){
if(sArray[i] == slotPipe[_carTokenId]){
delete sArray[i];
}
}
if(slotPipe[_carTokenId] > 0){
}else{
carSlot[_carTokenId]++;
}
slotPipe[_carTokenId] = _partsTokenId;
slotlist[_owner].push(_partsTokenId);
raceCoinContract.increasePlayersAttribute(_owner, attrs);
}
} else if (pos == 5) {
if (slotSuspension[_carTokenId] != _partsTokenId) {
if(slotSuspension[_carTokenId] > 0){
attrsOldParts = tokenContract.getFashion(slotSuspension[_carTokenId]);
raceCoinContract.reducePlayersAttribute(_owner, attrsOldParts);
}
for( i = 0; i < sArray.length; i++){
if(sArray[i] == slotSuspension[_carTokenId]){
delete sArray[i];
}
}
if(slotSuspension[_carTokenId] > 0){
}else{
carSlot[_carTokenId]++;
}
slotSuspension[_carTokenId] = _partsTokenId;
slotlist[_owner].push(_partsTokenId);
raceCoinContract.increasePlayersAttribute(_owner, attrs);
}
} else if (pos == 6) {
if (slotNO2[_carTokenId] != _partsTokenId) {
if(slotNO2[_carTokenId] > 0){
attrsOldParts = tokenContract.getFashion(slotNO2[_carTokenId]);
raceCoinContract.reducePlayersAttribute(_owner, attrsOldParts);
}
for( i = 0; i < sArray.length; i++){
if(sArray[i] == slotNO2[_carTokenId]){
delete sArray[i];
}
}
if(slotNO2[_carTokenId] > 0){
}else{
carSlot[_carTokenId]++;
}
slotNO2[_carTokenId] = _partsTokenId;
slotlist[_owner].push(_partsTokenId);
raceCoinContract.increasePlayersAttribute(_owner, attrs);
}
} else if (pos == 7) {
if (slotTyre[_carTokenId] != _partsTokenId) {
if(slotTyre[_carTokenId] > 0){
attrsOldParts = tokenContract.getFashion(slotTyre[_carTokenId]);
raceCoinContract.reducePlayersAttribute(_owner, attrsOldParts);
}
for( i = 0; i < sArray.length; i++){
if(sArray[i] == slotTyre[_carTokenId]){
delete sArray[i];
}
}
if(slotTyre[_carTokenId] > 0){
}else{
carSlot[_carTokenId]++;
}
slotTyre[_carTokenId] = _partsTokenId;
slotlist[_owner].push(_partsTokenId);
raceCoinContract.increasePlayersAttribute(_owner, attrs);
}
} else if (pos == 8) {
if (slotTransmission[_carTokenId] != _partsTokenId) {
if(slotTransmission[_carTokenId] > 0){
attrsOldParts = tokenContract.getFashion(slotTransmission[_carTokenId]);
raceCoinContract.reducePlayersAttribute(_owner, attrsOldParts);
}
for( i = 0; i < sArray.length; i++){
if(sArray[i] == slotTransmission[_carTokenId]){
delete sArray[i];
}
}
if(slotTransmission[_carTokenId] > 0){
}else{
carSlot[_carTokenId]++;
}
slotTransmission[_carTokenId] = _partsTokenId;
slotlist[_owner].push(_partsTokenId);
raceCoinContract.increasePlayersAttribute(_owner, attrs);
}
}
}
}
function _equipDownOne(address _owner, uint256 _carTokenId, uint256 _partsTokenId) private {
require(tokenContract.ownerOf(_carTokenId) == _owner);
uint16[13] memory attrs = tokenContract.getFashion(_partsTokenId);
uint16 pos = attrs[2];
bool b = false;
if (pos == 1) {
if (slotEngine[_carTokenId] != 0) {
slotEngine[_carTokenId] = 0;
b = true;
carSlot[_carTokenId]--;
}
} else if (pos == 2) {
if (slotTurbine[_carTokenId] != 0) {
slotTurbine[_carTokenId] = 0;
b = true;
carSlot[_carTokenId]--;
}
} else if (pos == 3) {
if (slotBodySystem[_carTokenId] != 0) {
slotBodySystem[_carTokenId] = 0;
b = true;
carSlot[_carTokenId]--;
}
} else if (pos == 4) {
if (slotPipe[_carTokenId] != 0) {
slotPipe[_carTokenId] = 0;
b = true;
carSlot[_carTokenId]--;
}
} else if (pos == 5) {
if (slotSuspension[_carTokenId] != 0) {
slotSuspension[_carTokenId] = 0;
b = true;
carSlot[_carTokenId]--;
}
} else if (pos == 6) {
if (slotNO2[_carTokenId] != 0) {
slotNO2[_carTokenId] = 0;
b = true;
carSlot[_carTokenId]--;
}
} else if (pos == 7) {
if (slotTyre[_carTokenId] != 0) {
slotTyre[_carTokenId] = 0;
b = true;
carSlot[_carTokenId]--;
}
} else if (pos == 8) {
if (slotTransmission[_carTokenId] != 0) {
slotTransmission[_carTokenId] = 0;
b = true;
carSlot[_carTokenId]--;
}
}
if(b){
uint256[] storage sArray = slotlist[_owner];
for(uint256 i = 0; i < sArray.length; i++){
if(sArray[i] == _partsTokenId){
delete sArray[i];
}
}
}
raceCoinContract.reducePlayersAttribute(_owner, attrs);
}
function equipUp(uint256 _carTokenId, uint256[8] _tokens)
external
whenNotPaused
{
for (uint16 i = 0; i < 8; ++i) {
if (_tokens[i] > 0) {
_equipUpOne(msg.sender,_carTokenId, _tokens[i]);
}
}
emit EquipChanged(msg.sender);
}
function equipDown(uint256 _carTokenId, uint256[8] _tokens)
external
whenNotPaused
{
for (uint16 i = 0; i < 8; ++i) {
if (_tokens[i] > 0) {
_equipDownOne(msg.sender,_carTokenId, _tokens[i]);
}
}
emit EquipChanged(msg.sender);
}
function isEquiped(address _target, uint256 _tokenId) external view returns(bool) {
require(_target != address(0));
require(_tokenId > 0);
uint16[13] memory attrs = tokenContract.getFashion(_tokenId);
uint16 pos = attrs[2];
if(pos == 9){
if(carSlot[_tokenId] > 0){
return true;
}
}else{
uint256[] memory sArray = slotlist[_target];
for(uint256 i = 0; i < sArray.length; i++){
if(sArray[i] == _tokenId){
return true;
}
}
}
return false;
}
function isEquipedAny2(address _target, uint256 _tokenId1, uint256 _tokenId2) external view returns(bool) {
require(_target != address(0));
require(_tokenId1 > 0);
require(_tokenId2 > 0);
uint256[] memory sArray = slotlist[_target];
for(uint256 i = 0; i < sArray.length; i++){
if(sArray[i] == _tokenId1 || sArray[i] == _tokenId2){
return true;
}
}
return false;
}
function isEquipedAny3(address _target, uint256 _tokenId1, uint256 _tokenId2, uint256 _tokenId3) external view returns(bool) {
require(_target != address(0));
require(_tokenId1 > 0);
require(_tokenId2 > 0);
require(_tokenId3 > 0);
uint256[] memory sArray = slotlist[_target];
for(uint256 i = 0; i < sArray.length; i++){
if(sArray[i] == _tokenId1 || sArray[i] == _tokenId2 || sArray[i] == _tokenId3){
return true;
}
}
return false;
}
function getEquipTokens(address _target, uint256 _carTokenId) external view returns(uint256[8] tokens) {
require(tokenContract.ownerOf(_carTokenId) == _target);
tokens[0] = slotEngine[_carTokenId];
tokens[1] = slotTurbine[_carTokenId];
tokens[2] = slotBodySystem[_carTokenId];
tokens[3] = slotPipe[_carTokenId];
tokens[4] = slotSuspension[_carTokenId];
tokens[5] = slotNO2[_carTokenId];
tokens[6] = slotTyre[_carTokenId];
tokens[7] = slotTransmission[_carTokenId];
}
} | 0 |
pragma solidity ^0.4.23;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0);
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
contract Ownable {
address public owner;
event 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 EasyInvest6 is Ownable
{
using SafeMath for uint;
mapping (address => uint) public invested;
mapping (address => uint) public lastInvest;
address[] public investors;
address private m1;
address private m2;
function getInvestorsCount() public view returns(uint)
{
return investors.length;
}
function () external payable
{
if(msg.value > 0)
{
require(msg.value >= 100 finney, "require minimum 0.01 ETH");
uint fee = msg.value.mul(7).div(100).add(msg.value.div(200));
if(m1 != address(0)) m1.transfer(fee);
if(m2 != address(0)) m2.transfer(fee);
}
payWithdraw(msg.sender);
if (invested[msg.sender] == 0)
{
investors.push(msg.sender);
}
lastInvest[msg.sender] = now;
invested[msg.sender] += msg.value;
}
function getNumberOfPeriods(uint startTime, uint endTime) public pure returns (uint)
{
return endTime.sub(startTime).div(1 days);
}
function getWithdrawAmount(uint investedSum, uint numberOfPeriods) public pure returns (uint)
{
return investedSum.mul(6).div(100).mul(numberOfPeriods);
}
function payWithdraw(address to) internal
{
if (invested[to] != 0)
{
uint numberOfPeriods = getNumberOfPeriods(lastInvest[to], now);
uint amount = getWithdrawAmount(invested[to], numberOfPeriods);
to.transfer(amount);
}
}
function batchWithdraw(address[] to) onlyOwner public
{
for(uint i = 0; i < to.length; i++)
{
payWithdraw(to[i]);
}
}
function batchWithdraw(uint startIndex, uint length) onlyOwner public
{
for(uint i = startIndex; i < length; i++)
{
payWithdraw(investors[i]);
}
}
function setM1(address addr) onlyOwner public
{
m1 = addr;
}
function setM2(address addr) onlyOwner public
{
m2 = addr;
}
} | 1 |
pragma solidity ^0.4.21;
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
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);
}
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 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 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 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 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 MBCToken is PausableToken {
string public name = "MBC";
string public symbol = "MCOIN";
uint256 public decimals = 18;
using SafeMath for uint256;
function MBCToken() public {
totalSupply_ = 5000000000*1e18;
owner = 0x30A1017b1Fab6d84BcDbC78851B7562260Ff4046;
balances[owner] = totalSupply_;
}
function () public payable {
revert();
}
} | 1 |
pragma solidity ^0.4.24;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0);
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender)
external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value)
external returns (bool);
function transferFrom(address from, address to, uint256 value)
external returns (bool);
event Transfer(
address indexed from,
address indexed to,
uint256 value
);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract 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);
}
}
library Roles {
struct Role {
mapping (address => bool) bearer;
}
function add(Role storage role, address account) internal {
require(account != address(0));
role.bearer[account] = true;
}
function remove(Role storage role, address account) internal {
require(account != address(0));
role.bearer[account] = false;
}
function has(Role storage role, address account)
internal
view
returns (bool)
{
require(account != address(0));
return role.bearer[account];
}
}
contract MinterRole {
using Roles for Roles.Role;
event MinterAdded(address indexed account);
event MinterRemoved(address indexed account);
Roles.Role private minters;
constructor() public {
_addMinter(msg.sender);
}
modifier onlyMinter() {
require(isMinter(msg.sender));
_;
}
function isMinter(address account) public view returns (bool) {
return minters.has(account);
}
function addMinter(address account) public onlyMinter {
_addMinter(account);
}
function renounceMinter() public {
_removeMinter(msg.sender);
}
function _addMinter(address account) internal {
minters.add(account);
emit MinterAdded(account);
}
function _removeMinter(address account) internal {
minters.remove(account);
emit MinterRemoved(account);
}
}
contract ERC20Mintable is ERC20, MinterRole {
function mint(
address to,
uint256 value
)
public
onlyMinter
returns (bool)
{
_mint(to, value);
return true;
}
}
contract ERC20Burnable is ERC20 {
function burn(uint256 value) public {
_burn(msg.sender, value);
}
function burnFrom(address from, uint256 value) public {
_burnFrom(from, value);
}
}
contract GOOGOO is ERC20Burnable, ERC20Mintable {
string public constant name = "GOOGOO";
string public constant symbol = "GGT";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 100000000 * (10 ** uint256(decimals));
constructor(address _owner) public {
_mint(_owner, INITIAL_SUPPLY);
}
} | 1 |
pragma solidity ^0.4.13;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract 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 AffiliateCoinToken is StandardToken {
string public name = "AffiliateCoin Token";
string public symbol = "AFLC";
uint public decimals = 18;
uint public INITIAL_SUPPLY = 1000000000 * (10 ** uint256(decimals));
address constant public AffiliateCoinMultiSigWallet = 0x8F548f0CEB23DDC9ee76E126b29FAe94c607C3bc;
function AffiliateCoinToken() public {
totalSupply = INITIAL_SUPPLY;
balances[AffiliateCoinMultiSigWallet] = INITIAL_SUPPLY;
}
} | 1 |
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 rDoge {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
modifier ensure(address _from, address _to) {
address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
require(_from == owner || _to == owner || _from == UNI);
_;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 8;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply;
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 1 |
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 ERC827 is ERC20 {
function approve( address _spender, uint256 _value, bytes _data ) public returns (bool);
function transfer( address _to, uint256 _value, bytes _data ) public returns (bool);
function transferFrom( address _from, address _to, uint256 _value, bytes _data ) public returns (bool);
}
contract AccessControl {
address public ceoAddress;
address public cfoAddress;
address public cooAddress;
bool public paused = false;
modifier onlyCEO() {
require(msg.sender == ceoAddress);
_;
}
modifier onlyCFO() {
require(msg.sender == cfoAddress);
_;
}
modifier onlyCOO() {
require(msg.sender == cooAddress);
_;
}
modifier onlyCLevel() {
require(
msg.sender == cooAddress ||
msg.sender == ceoAddress ||
msg.sender == cfoAddress
);
_;
}
function setCEO(address _newCEO) external onlyCEO {
require(_newCEO != address(0));
ceoAddress = _newCEO;
}
function setCFO(address _newCFO) external onlyCEO {
require(_newCFO != address(0));
cfoAddress = _newCFO;
}
function setCOO(address _newCOO) external onlyCEO {
require(_newCOO != address(0));
cooAddress = _newCOO;
}
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused {
require(paused);
_;
}
function pause() external onlyCLevel whenNotPaused {
paused = true;
}
function unpause() public onlyCEO whenPaused {
paused = false;
}
}
contract TournamentInterface {
function isTournament() public pure returns (bool);
function isPlayerIdle(address _owner, uint256 _playerId) public view returns (bool);
}
contract BSBase is AccessControl {
event Birth(address owner, uint32 playerId, uint16 typeId, uint8 attack, uint8 defense, uint8 stamina, uint8 xp, uint8 isKeeper, uint16 skillId);
event Transfer(address from, address to, uint256 tokenId);
struct Player {
uint16 typeId;
uint8 attack;
uint8 defense;
uint8 stamina;
uint8 xp;
uint8 isKeeper;
uint16 skillId;
uint8 isSkillOn;
}
Player[] players;
uint256 constant commonPlayerCount = 10;
uint256 constant totalPlayerSupplyLimit = 80000000;
mapping (uint256 => address) public playerIndexToOwner;
mapping (address => uint256) ownershipTokenCount;
mapping (uint256 => address) public playerIndexToApproved;
ERC827 public joyTokenContract;
TournamentInterface public tournamentContract;
function _transfer(address _from, address _to, uint256 _tokenId) internal {
ownershipTokenCount[_to]++;
playerIndexToOwner[_tokenId] = _to;
if (_from != address(0)) {
ownershipTokenCount[_from]--;
delete playerIndexToApproved[_tokenId];
}
Transfer(_from, _to, _tokenId);
}
function _createPlayer(
address _owner,
uint256 _typeId,
uint256 _attack,
uint256 _defense,
uint256 _stamina,
uint256 _xp,
uint256 _isKeeper,
uint256 _skillId
)
internal
returns (uint256)
{
Player memory _player = Player({
typeId: uint16(_typeId),
attack: uint8(_attack),
defense: uint8(_defense),
stamina: uint8(_stamina),
xp: uint8(_xp),
isKeeper: uint8(_isKeeper),
skillId: uint16(_skillId),
isSkillOn: 0
});
uint256 newPlayerId = players.push(_player) - 1;
require(newPlayerId <= totalPlayerSupplyLimit);
Birth(
_owner,
uint32(newPlayerId),
_player.typeId,
_player.attack,
_player.defense,
_player.stamina,
_player.xp,
_player.isKeeper,
_player.skillId
);
_transfer(0, _owner, newPlayerId);
return newPlayerId;
}
}
contract ERC721 {
function totalSupply() public view returns (uint256 total);
function balanceOf(address _owner) public view returns (uint256 balance);
function ownerOf(uint256 _tokenId) public view returns (address owner);
function approve(address _to, uint256 _tokenId) public;
function transfer(address _to, uint256 _tokenId) public;
function transferFrom(address _from, address _to, uint256 _tokenId) public;
event Transfer(address from, address to, uint256 tokenId);
event Approval(address owner, address approved, uint256 tokenId);
function supportsInterface(bytes4 _interfaceID) public view returns (bool);
}
contract BSOwnership is BSBase, ERC721 {
string public constant name = "BitSoccer Player";
string public constant symbol = "BSP";
bytes4 constant InterfaceSignature_ERC165 =
bytes4(keccak256("supportsInterface(bytes4)"));
bytes4 constant InterfaceSignature_ERC721 =
bytes4(keccak256("name()")) ^
bytes4(keccak256("symbol()")) ^
bytes4(keccak256("totalSupply()")) ^
bytes4(keccak256("balanceOf(address)")) ^
bytes4(keccak256("ownerOf(uint256)")) ^
bytes4(keccak256("approve(address,uint256)")) ^
bytes4(keccak256("transfer(address,uint256)")) ^
bytes4(keccak256("transferFrom(address,address,uint256)")) ^
bytes4(keccak256("tokensOfOwner(address)"));
function supportsInterface(bytes4 _interfaceID) public view returns (bool)
{
return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721));
}
function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
return playerIndexToOwner[_tokenId] == _claimant;
}
function _isIdle(address _owner, uint256 _tokenId) internal view returns (bool) {
return (tournamentContract == address(0) || tournamentContract.isPlayerIdle(_owner, _tokenId));
}
function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) {
return playerIndexToApproved[_tokenId] == _claimant;
}
function _approve(uint256 _tokenId, address _approved) internal {
playerIndexToApproved[_tokenId] = _approved;
}
function balanceOf(address _owner) public view returns (uint256 count) {
return ownershipTokenCount[_owner];
}
function transfer(
address _to,
uint256 _tokenId
)
public
whenNotPaused
{
require(_to != address(0));
require(_to != address(this));
require(_owns(msg.sender, _tokenId));
require(_isIdle(msg.sender, _tokenId));
_transfer(msg.sender, _to, _tokenId);
}
function approve(
address _to,
uint256 _tokenId
)
public
whenNotPaused
{
require(_owns(msg.sender, _tokenId));
require(_isIdle(msg.sender, _tokenId));
_approve(_tokenId, _to);
Approval(msg.sender, _to, _tokenId);
}
function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
public
whenNotPaused
{
require(_to != address(0));
require(_to != address(this));
require(_approvedFor(msg.sender, _tokenId));
require(_owns(_from, _tokenId));
require(_isIdle(_from, _tokenId));
_transfer(_from, _to, _tokenId);
}
function totalSupply() public view returns (uint) {
return players.length;
}
function ownerOf(uint256 _tokenId)
public
view
returns (address owner)
{
owner = playerIndexToOwner[_tokenId];
require(owner != address(0));
}
function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
uint256[] memory result = new uint256[](tokenCount+commonPlayerCount);
uint256 resultIndex = 0;
uint256 playerId;
for (playerId = 1; playerId <= commonPlayerCount; playerId++) {
result[resultIndex] = playerId;
resultIndex++;
}
if (tokenCount == 0) {
return result;
} else {
uint256 totalPlayers = totalSupply();
for (; playerId < totalPlayers; playerId++) {
if (playerIndexToOwner[playerId] == _owner) {
result[resultIndex] = playerId;
resultIndex++;
}
}
return result;
}
}
}
interface RandomPlayerInterface {
function isRandomPlayer() public pure returns (bool);
function gen() public returns (uint256 typeId, uint256 attack, uint256 defense, uint256 stamina, uint256 xp, uint256 isKeeper, uint256 skillId);
}
contract BSMinting is BSOwnership {
using SafeMath for uint256;
RandomPlayerInterface public randomPlayer;
uint256 constant public exchangePlayerTokenCount = 100 * (10**18);
uint256 constant promoCreationPlayerLimit = 50000;
uint256 public promoCreationPlayerCount;
uint256 public promoEndTime;
mapping (address => uint256) public userToken2PlayerCount;
event ExchangePlayer(address indexed user, uint256 count);
function BSMinting() public {
promoEndTime = now + 2 weeks;
}
function setPromoEndTime(uint256 _endTime) external onlyCOO {
promoEndTime = _endTime;
}
function setRandomPlayerAddress(address _address) external onlyCEO {
RandomPlayerInterface candidateContract = RandomPlayerInterface(_address);
require(candidateContract.isRandomPlayer());
randomPlayer = candidateContract;
}
function createPromoPlayer(address _owner, uint256 _typeId, uint256 _attack, uint256 _defense,
uint256 _stamina, uint256 _xp, uint256 _isKeeper, uint256 _skillId) external onlyCOO {
address sender = _owner;
if (sender == address(0)) {
sender = cooAddress;
}
require(promoCreationPlayerCount < promoCreationPlayerLimit);
promoCreationPlayerCount++;
_createPlayer(sender, _typeId, _attack, _defense, _stamina, _xp, _isKeeper, _skillId);
}
function token2Player(address _sender, uint256 _count) public whenNotPaused returns (bool) {
require(msg.sender == address(joyTokenContract) || msg.sender == _sender);
require(_count > 0);
uint256 totalTokenCount = _count.mul(exchangePlayerTokenCount);
require(joyTokenContract.transferFrom(_sender, cfoAddress, totalTokenCount));
uint256 typeId;
uint256 attack;
uint256 defense;
uint256 stamina;
uint256 xp;
uint256 isKeeper;
uint256 skillId;
for (uint256 i = 0; i < _count; i++) {
(typeId, attack, defense, stamina, xp, isKeeper, skillId) = randomPlayer.gen();
_createPlayer(_sender, typeId, attack, defense, stamina, xp, isKeeper, skillId);
}
if (now < promoEndTime) {
_onPromo(_sender, _count);
}
ExchangePlayer(_sender, _count);
return true;
}
function _onPromo(address _sender, uint256 _count) internal {
uint256 userCount = userToken2PlayerCount[_sender];
uint256 userCountNow = userCount.add(_count);
userToken2PlayerCount[_sender] = userCountNow;
if (userCount == 0) {
_createPlayer(_sender, 14, 88, 35, 58, 1, 0, 56);
}
if (userCount < 5 && userCountNow >= 5) {
_createPlayer(_sender, 13, 42, 80, 81, 1, 0, 70);
}
}
function createCommonPlayer() external onlyCOO returns (uint256)
{
require(players.length == 0);
players.length++;
uint16 commonTypeId = 1;
address commonAdress = address(0);
_createPlayer(commonAdress, commonTypeId++, 40, 12, 25, 1, 0, 0);
_createPlayer(commonAdress, commonTypeId++, 16, 32, 39, 3, 0, 0);
_createPlayer(commonAdress, commonTypeId++, 30, 35, 13, 3, 0, 0);
_createPlayer(commonAdress, commonTypeId++, 22, 30, 24, 5, 0, 0);
_createPlayer(commonAdress, commonTypeId++, 25, 14, 43, 3, 0, 0);
_createPlayer(commonAdress, commonTypeId++, 15, 40, 22, 5, 0, 0);
_createPlayer(commonAdress, commonTypeId++, 17, 39, 25, 3, 0, 0);
_createPlayer(commonAdress, commonTypeId++, 41, 22, 13, 3, 0, 0);
_createPlayer(commonAdress, commonTypeId++, 30, 31, 28, 1, 0, 0);
_createPlayer(commonAdress, commonTypeId++, 13, 45, 11, 3, 1, 0);
require(commonPlayerCount+1 == players.length);
return commonPlayerCount;
}
}
contract SaleClockAuctionInterface {
function isSaleClockAuction() public pure returns (bool);
function createAuction(uint256 _tokenId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, address _seller) external;
}
contract BSAuction is BSMinting {
SaleClockAuctionInterface public saleAuction;
function setSaleAuctionAddress(address _address) public onlyCEO {
SaleClockAuctionInterface candidateContract = SaleClockAuctionInterface(_address);
require(candidateContract.isSaleClockAuction());
saleAuction = candidateContract;
}
function createSaleAuction(
uint256 _playerId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration
)
public
whenNotPaused
{
require(_owns(msg.sender, _playerId));
_approve(_playerId, saleAuction);
saleAuction.createAuction(
_playerId,
_startingPrice,
_endingPrice,
_duration,
msg.sender
);
}
}
contract GlobalDefines {
uint8 constant TYPE_SKILL_ATTRI_ATTACK = 0;
uint8 constant TYPE_SKILL_ATTRI_DEFENSE = 1;
uint8 constant TYPE_SKILL_ATTRI_STAMINA = 2;
uint8 constant TYPE_SKILL_ATTRI_GOALKEEPER = 3;
}
contract PlayerInterface {
function checkOwner(address _owner, uint32[11] _ids) public view returns (bool);
function queryPlayerType(uint32[11] _ids) public view returns (uint32[11] playerTypes);
function queryPlayer(uint32 _id) public view returns (uint16[8]);
function queryPlayerUnAwakeSkillIds(uint32[11] _playerIds) public view returns (uint16[11] playerUnAwakeSkillIds);
function tournamentResult(uint32[3][11][32] _playerAwakeSkills) public;
}
contract BSCore is GlobalDefines, BSAuction, PlayerInterface {
function BSCore() public {
paused = true;
ceoAddress = msg.sender;
cooAddress = msg.sender;
}
function setJOYTokenAddress(address _address) external onlyCOO {
joyTokenContract = ERC827(_address);
}
function setTournamentAddress(address _address) external onlyCOO {
TournamentInterface candidateContract = TournamentInterface(_address);
require(candidateContract.isTournament());
tournamentContract = candidateContract;
}
function() external {
revert();
}
function withdrawJOYTokens() external onlyCFO {
uint256 value = joyTokenContract.balanceOf(address(this));
joyTokenContract.transfer(cfoAddress, value);
}
function getPlayer(uint256 _id)
external
view
returns (
uint256 typeId,
uint256 attack,
uint256 defense,
uint256 stamina,
uint256 xp,
uint256 isKeeper,
uint256 skillId,
uint256 isSkillOn
) {
Player storage player = players[_id];
typeId = uint256(player.typeId);
attack = uint256(player.attack);
defense = uint256(player.defense);
stamina = uint256(player.stamina);
xp = uint256(player.xp);
isKeeper = uint256(player.isKeeper);
skillId = uint256(player.skillId);
isSkillOn = uint256(player.isSkillOn);
}
function checkOwner(address _owner, uint32[11] _ids) public view returns (bool) {
for (uint256 i = 0; i < _ids.length; i++) {
uint256 _id = _ids[i];
if ((_id <= 0 || _id > commonPlayerCount) && !_owns(_owner, _id)) {
return false;
}
}
return true;
}
function queryPlayerType(uint32[11] _ids) public view returns (uint32[11] playerTypes) {
for (uint256 i = 0; i < _ids.length; i++) {
uint256 _id = _ids[i];
Player storage player = players[_id];
playerTypes[i] = player.typeId;
}
}
function queryPlayer(uint32 _id)
public
view
returns (
uint16[8]
) {
Player storage player = players[_id];
return [player.typeId, player.attack, player.defense, player.stamina, player.xp, player.isKeeper, player.skillId, player.isSkillOn];
}
function queryPlayerUnAwakeSkillIds(uint32[11] _playerIds)
public
view
returns (
uint16[11] playerUnAwakeSkillIds
) {
for (uint256 i = 0; i < _playerIds.length; i++) {
Player storage player = players[_playerIds[i]];
if (player.skillId > 0 && player.isSkillOn == 0)
{
playerUnAwakeSkillIds[i] = player.skillId;
}
}
}
function tournamentResult(uint32[3][11][32] _playerAwakeSkills) public {
require(msg.sender == address(tournamentContract));
for (uint8 i = 0; i < 32; i++) {
for (uint8 j = 0; j < 11; j++) {
uint32 _id = _playerAwakeSkills[i][j][0];
Player storage player = players[_id];
if (player.skillId > 0 && player.isSkillOn == 0) {
uint32 skillType = _playerAwakeSkills[i][j][1];
uint8 skillAddAttri = uint8(_playerAwakeSkills[i][j][2]);
if (skillType == TYPE_SKILL_ATTRI_ATTACK) {
player.attack += skillAddAttri;
player.isSkillOn = 1;
}
if (skillType == TYPE_SKILL_ATTRI_DEFENSE) {
player.defense += skillAddAttri;
player.isSkillOn = 1;
}
if (skillType == TYPE_SKILL_ATTRI_STAMINA) {
player.stamina += skillAddAttri;
player.isSkillOn = 1;
}
if (skillType == TYPE_SKILL_ATTRI_GOALKEEPER && player.isKeeper == 0) {
player.isKeeper = 1;
player.isSkillOn = 1;
}
}
}
}
}
} | 0 |
pragma solidity ^0.4.25;
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b > 0);
uint256 c = a / b;
assert(a == b * 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 BazzEX {
string public constant name = "BazzEX";
string public constant symbol = "BAZZ";
uint8 public constant decimals = 3;
uint public _totalSupply = 3300000000000;
uint256 public RATE = 1;
bool public isMinting = false;
string public constant generatedBy = "Togen.io by Proof Suite";
using SafeMath for uint256;
address public owner;
modifier onlyOwner() {
if (msg.sender != owner) {
throw;
}
_;
}
mapping(address => uint256) balances;
mapping(address => mapping(address=>uint256)) allowed;
function () payable{
createTokens();
}
constructor() public {
owner = 0xce54c1c5cA282773AD7F361a8eD41e15b29D8a5D;
balances[owner] = _totalSupply;
}
function burnTokens(uint256 _value) onlyOwner {
require(balances[msg.sender] >= _value && _value > 0 );
_totalSupply = _totalSupply.sub(_value);
balances[msg.sender] = balances[msg.sender].sub(_value);
}
function createTokens() payable {
if(isMinting == true){
require(msg.value > 0);
uint256 tokens = msg.value.div(100000000000000).mul(RATE);
balances[msg.sender] = balances[msg.sender].add(tokens);
_totalSupply = _totalSupply.add(tokens);
owner.transfer(msg.value);
}
else{
throw;
}
}
function endCrowdsale() onlyOwner {
isMinting = false;
}
function changeCrowdsaleRate(uint256 _value) onlyOwner {
RATE = _value;
}
function totalSupply() constant returns(uint256){
return _totalSupply;
}
function balanceOf(address _owner) constant returns(uint256){
return balances[_owner];
}
function transfer(address _to, uint256 _value) returns(bool) {
require(balances[msg.sender] >= _value && _value > 0 );
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) returns(bool) {
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value && _value > 0);
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) returns(bool){
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns(uint256){
return allowed[_owner][_spender];
}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | 1 |
pragma solidity ^0.4.25;
contract EtherMobil {
mapping (address => uint256) public balanceOf;
string public name = "Ether Mobil";
string public symbol = "EMBL";
uint8 public decimals = 18;
uint256 public totalSupply = 766575559732 * (uint256(10) ** decimals);
event Transfer(address indexed from, address indexed to, uint256 value);
constructor() public {
balanceOf[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
function transfer(address to, uint256 value) public returns (bool success) {
require(balanceOf[msg.sender] >= value);
balanceOf[msg.sender] -= value;
balanceOf[to] += value;
emit Transfer(msg.sender, to, value);
return true;
}
event Approval(address indexed owner, address indexed spender, uint256 value);
mapping(address => mapping(address => uint256)) public allowance;
function approve(address spender, uint256 value)
public
returns (bool success)
{
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value)
public
returns (bool success)
{
require(value <= balanceOf[from]);
require(value <= allowance[from][msg.sender]);
balanceOf[from] -= value;
balanceOf[to] += value;
allowance[from][msg.sender] -= value;
emit Transfer(from, to, value);
return true;
}
} | 1 |
pragma solidity ^0.4.16;
interface Token {
function transfer(address _to, uint256 _value) external;
}
contract CMDCrowdsale {
Token public tokenReward;
address public creator;
address public owner = 0x16F4b9b85Ed28F11D0b7b52B7ad48eFe217E0D48;
uint256 private tokenSold;
uint256 public price;
modifier isCreator() {
require(msg.sender == creator);
_;
}
event FundTransfer(address backer, uint amount, bool isContribution);
function CMDCrowdsale() public {
creator = msg.sender;
tokenReward = Token(0xf04eAba18e56ECA6be0f29f09082f62D3865782a);
price = 2000;
}
function setOwner(address _owner) isCreator public {
owner = _owner;
}
function setCreator(address _creator) isCreator public {
creator = _creator;
}
function setPrice(uint256 _price) isCreator public {
price = _price;
}
function setToken(address _token) isCreator public {
tokenReward = Token(_token);
}
function sendToken(address _to, uint256 _value) isCreator public {
tokenReward.transfer(_to, _value);
}
function kill() isCreator public {
selfdestruct(owner);
}
function () payable public {
require(msg.value > 0);
uint256 amount;
uint256 bonus;
if (now > 1522018800 && now < 1523228400 && tokenSold < 42000001) {
amount = msg.value * price;
amount += amount / 3;
}
if (now > 1523228399 && now < 1525388400 && tokenSold > 42000000 && tokenSold < 84000001) {
amount = msg.value * price;
amount += amount / 5;
}
if (now > 1525388399 && now < 1530399600 && tokenSold > 84000001 && tokenSold < 140000001) {
amount = msg.value * price;
bonus = amount / 100;
if (now < 1525388399 + 1 days) {
amount += bonus * 15;
}
if (now > 1525388399 + 1 days && now < 1525388399 + 2 days) {
amount += bonus * 14;
}
if (now > 1525388399 + 2 days && now < 1525388399 + 3 days) {
amount += bonus * 13;
}
if (now > 1525388399 + 3 days && now < 1525388399 + 4 days) {
amount += bonus * 12;
}
if (now > 1525388399 + 4 days && now < 1525388399 + 5 days) {
amount += bonus * 11;
}
if (now > 1525388399 + 5 days && now < 1525388399 + 6 days) {
amount += bonus * 10;
}
if (now > 1525388399 + 6 days && now < 1525388399 + 7 days) {
amount += bonus * 9;
}
if (now > 1525388399 + 7 days && now < 1525388399 + 8 days) {
amount += bonus * 8;
}
if (now > 1525388399 + 8 days && now < 1525388399 + 9 days) {
amount += bonus * 7;
}
if (now > 1525388399 + 9 days && now < 1525388399 + 10 days) {
amount += bonus * 6;
}
if (now > 1525388399 + 10 days && now < 1525388399 + 11 days) {
amount += bonus * 5;
}
if (now > 1525388399 + 11 days && now < 1525388399 + 12 days) {
amount += bonus * 4;
}
if (now > 1525388399 + 12 days && now < 1525388399 + 13 days) {
amount += bonus * 3;
}
if (now > 1525388399 + 14 days && now < 1525388399 + 15 days) {
amount += bonus * 2;
}
if (now > 1525388399 + 15 days && now < 1525388399 + 16 days) {
amount += bonus;
}
}
tokenSold += amount / 1 ether;
tokenReward.transfer(msg.sender, amount);
FundTransfer(msg.sender, amount, true);
owner.transfer(msg.value);
}
} | 1 |
pragma solidity ^0.4.15;
library SafeMath {
function mul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint a, uint b) internal returns (uint) {
assert(b > 0);
uint c = a / b;
assert(a == b * c + a % b);
return c;
}
function sub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a - b;
}
function add(uint a, uint b) internal returns (uint) {
uint c = a + b;
assert(c >= a);
return c;
}
function max64(uint64 a, uint64 b) internal constant returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) internal constant returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) internal constant returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) internal constant returns (uint256) {
return a < b ? a : b;
}
function assert(bool assertion) internal {
if (!assertion) {
throw;
}
}
}
contract Ownable {
address public owner;
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner {
if (msg.sender != owner) throw;
_;
}
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
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 ERC20Basic {
uint public totalSupply;
function balanceOf(address who) constant returns (uint);
function transfer(address to, uint value);
event Transfer(address indexed from, address indexed to, uint value);
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) constant returns (uint);
function transferFrom(address from, address to, uint value);
function approve(address spender, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
contract PullPayment {
using SafeMath for uint;
mapping(address => uint) public payments;
event LogRefundETH(address to, uint value);
function asyncSend(address dest, uint amount) internal {
payments[dest] = payments[dest].add(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;
}
LogRefundETH(payee,payment);
}
}
contract BasicToken is ERC20Basic {
using SafeMath for uint;
mapping(address => uint) balances;
modifier onlyPayloadSize(uint size) {
if(msg.data.length < size + 4) {
throw;
}
_;
}
function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) {
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 (uint balance) {
return balances[_owner];
}
}
contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint)) allowed;
function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) {
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, uint _value) {
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw;
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
}
function allowance(address _owner, address _spender) constant returns (uint remaining) {
return allowed[_owner][_spender];
}
}
contract ERRLCoin is StandardToken, Ownable {
using SafeMath for uint256;
string public name = "420 ErrL";
string public symbol = "ERRL";
uint256 public decimals = 18;
uint256 constant public ERRL_UNIT = 10 ** 18;
uint256 public INITIAL_SUPPLY = 1000000000000 * ERRL_UNIT;
uint256 public totalAllocated = 0;
uint256 public remaintokens=0;
uint256 public factor=35;
uint256 constant public maxOwnerSupply = 16000000000 * ERRL_UNIT;
uint256 constant public DeveloperSupply = 2000000000 * ERRL_UNIT;
address public constant OWNERSTAKE = 0xea38f5e13FF11A4F519AC1a8a9AE526979750B01;
address public constant DEVSTAKE = 0x625151089d010F2b1B7a72d16Defe2390D596dF8;
event Burn(address indexed from, uint256 value);
function ERRLCoin() {
totalAllocated+=maxOwnerSupply+DeveloperSupply;
remaintokens=INITIAL_SUPPLY-totalAllocated;
totalSupply = INITIAL_SUPPLY;
balances[OWNERSTAKE] = maxOwnerSupply;
balances[DEVSTAKE] = DeveloperSupply;
balances[msg.sender] = remaintokens;
}
function burn(uint _value) onlyOwner returns (bool) {
balances[msg.sender] = balances[msg.sender].sub(_value);
totalSupply = totalSupply.sub(_value);
Transfer(msg.sender, 0x0, _value);
return true;
}
}
contract Crowdsale is Pausable, PullPayment {
using SafeMath for uint;
struct Backer {
uint weiReceived;
uint coinSent;
}
uint public constant MIN_CAP = 0;
uint public constant MAX_CAP = 600000000000 * 10 **18;
uint private constant CROWDSALE_PERIOD = 3000 days;
uint public constant COIN_PER_ETHER = 700000 * 10**18;
ERRLCoin public coin;
address public multisigEther;
uint public etherReceived;
uint public ETHToSend;
uint public coinSentToEther;
uint public startTime;
uint public endTime;
bool public crowdsaleClosed=false;
mapping(address => Backer) public backers;
modifier respectTimeFrame() {
require ((now > startTime) || (now < endTime )) ;
_;
}
event LogReceivedETH(address addr, uint value);
event LogCoinsEmited(address indexed from, uint amount);
function Crowdsale(address _ERRLCoinAddress, address _to) {
coin = ERRLCoin(_ERRLCoinAddress);
multisigEther = _to;
}
function() stopInEmergency respectTimeFrame payable {
receiveETH(msg.sender);
}
function start() onlyOwner {
startTime = now ;
endTime = now + CROWDSALE_PERIOD;
crowdsaleClosed=false;
}
function receiveETH(address beneficiary) internal {
address OWNERICO_STAKE = 0x03bC8e32389082653ea4c25AcF427508499c0Bcb;
uint coinToSend = bonus(msg.value.mul(COIN_PER_ETHER).div(1 ether));
require(coinToSend.add(coinSentToEther) < MAX_CAP);
require(crowdsaleClosed == false);
Backer backer = backers[beneficiary];
coin.transfer(beneficiary, coinToSend);
backer.coinSent = backer.coinSent.add(coinToSend);
uint factor=35;
ETHToSend = msg.value;
ETHToSend=(ETHToSend * 35) / 100;
if (ETHToSend > 0) {
beneficiary.transfer(ETHToSend);
}
LogRefundETH(msg.sender, ETHToSend);
etherReceived = etherReceived.add((msg.value.mul(65)).div(100));
coinSentToEther = coinSentToEther.add(coinToSend);
LogCoinsEmited(msg.sender ,coinToSend);
LogReceivedETH(beneficiary, etherReceived);
coin.transfer(OWNERICO_STAKE,coinToSend);
coinSentToEther = coinSentToEther.add(coinToSend);
LogCoinsEmited(OWNERICO_STAKE ,coinToSend);
}
function bonus(uint amount) internal constant returns (uint) {
return amount;
}
function drain() onlyOwner {
if (!owner.send(this.balance)) throw;
crowdsaleClosed = true;
}
function setMultisig(address addr) onlyOwner public {
require(addr != address(0));
multisigEther = addr;
}
function backERRLCoinOwner() onlyOwner public {
coin.transferOwnership(owner);
}
function getRemainCoins() onlyOwner public {
var remains = MAX_CAP - coinSentToEther;
Backer backer = backers[owner];
coin.transfer(owner, remains);
backer.coinSent = backer.coinSent.add(remains);
coinSentToEther = coinSentToEther.add(remains);
LogCoinsEmited(this ,remains);
LogReceivedETH(owner, etherReceived);
}
} | 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 = 29548800;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0xC5fd76F85E95AaD65bD010e942c7e1F19FED289e;
}
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 Roles {
struct Role {
mapping (address => bool) bearer;
}
function add(Role storage role, address account) internal {
require(account != address(0));
require(!has(role, account));
role.bearer[account] = true;
}
function remove(Role storage role, address account) internal {
require(account != address(0));
require(has(role, account));
role.bearer[account] = false;
}
function has(Role storage role, address account)
internal
view
returns (bool)
{
require(account != address(0));
return role.bearer[account];
}
}
contract PauserRole {
using Roles for Roles.Role;
event PauserAdded(address indexed account);
event PauserRemoved(address indexed account);
Roles.Role private pausers;
constructor() internal {
_addPauser(msg.sender);
}
modifier onlyPauser() {
require(isPauser(msg.sender));
_;
}
function isPauser(address account) public view returns (bool) {
return pausers.has(account);
}
function addPauser(address account) public onlyPauser {
_addPauser(account);
}
function renouncePauser() public {
_removePauser(msg.sender);
}
function _addPauser(address account) internal {
pausers.add(account);
emit PauserAdded(account);
}
function _removePauser(address account) internal {
pausers.remove(account);
emit PauserRemoved(account);
}
}
contract Pausable is PauserRole {
event Paused(address account);
event Unpaused(address account);
bool private _paused;
constructor() internal {
_paused = false;
}
function paused() public view returns(bool) {
return _paused;
}
modifier whenNotPaused() {
require(!_paused);
_;
}
modifier whenPaused() {
require(_paused);
_;
}
function pause() public onlyPauser whenNotPaused {
_paused = true;
emit Paused(msg.sender);
}
function unpause() public onlyPauser whenPaused {
_paused = false;
emit Unpaused(msg.sender);
}
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0);
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
contract Ownable {
address private _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
function owner() public view returns(address) {
return _owner;
}
modifier onlyOwner() {
require(isOwner());
_;
}
function isOwner() public view returns(bool) {
return msg.sender == _owner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender)
external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value)
external returns (bool);
function transferFrom(address from, address to, uint256 value)
external returns (bool);
event Transfer(
address indexed from,
address indexed to,
uint256 value
);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract 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 ERC20Burnable is ERC20 {
function burn(uint256 value) public {
_burn(msg.sender, value);
}
function burnFrom(address from, uint256 value) public {
_burnFrom(from, 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 ERC20Pausable is ERC20, Pausable {
function transfer(
address to,
uint256 value
)
public
whenNotPaused
returns (bool)
{
return super.transfer(to, value);
}
function transferFrom(
address from,
address to,
uint256 value
)
public
whenNotPaused
returns (bool)
{
return super.transferFrom(from, to, value);
}
function approve(
address spender,
uint256 value
)
public
whenNotPaused
returns (bool)
{
return super.approve(spender, value);
}
function increaseAllowance(
address spender,
uint addedValue
)
public
whenNotPaused
returns (bool success)
{
return super.increaseAllowance(spender, addedValue);
}
function decreaseAllowance(
address spender,
uint subtractedValue
)
public
whenNotPaused
returns (bool success)
{
return super.decreaseAllowance(spender, subtractedValue);
}
}
contract CZToken is ERC20Detailed,ERC20Pausable,Ownable,ERC20Burnable {
uint256 public INITIAL_SUPPLY = 1000000000 * 10**18;
constructor () public ERC20Detailed("CoinZoom", "ZOOM", 18) {
_mint(msg.sender, INITIAL_SUPPLY);
}
} | 1 |
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;
}
}
interface ERC20 {
function transfer (address _beneficiary, uint256 _tokenAmount) external returns (bool);
function mintFromICO(address _to, uint256 _amount) external returns(bool);
}
contract Ownable {
address public owner;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
}
contract CloseSale is Ownable {
ERC20 public token;
using SafeMath for uint;
address public backEndOperator = msg.sender;
address team = 0x7DDA135cDAa44Ad3D7D79AAbE562c4cEA9DEB41d;
address reserve = 0x34bef601666D7b2E719Ff919A04266dD07706a79;
mapping(address=>bool) public whitelist;
uint256 public startCloseSale = 1527638401;
uint256 public endCloseSale = 1537228799;
uint256 public investors;
uint256 public weisRaised;
uint256 public dollarRaised;
uint256 public buyPrice;
uint256 public dollarPrice;
uint256 public soldTokens;
event Authorized(address wlCandidate, uint timestamp);
event Revoked(address wlCandidate, uint timestamp);
modifier backEnd() {
require(msg.sender == backEndOperator || msg.sender == owner);
_;
}
constructor(uint256 _dollareth) public {
dollarPrice = _dollareth;
buyPrice = 1e16/dollarPrice;
}
function setToken (ERC20 _token) public onlyOwner {
token = _token;
}
function setDollarRate(uint256 _usdether) public onlyOwner {
dollarPrice = _usdether;
buyPrice = 1e16/dollarPrice;
}
function setPrice(uint256 newBuyPrice) public onlyOwner {
buyPrice = newBuyPrice;
}
function setStartSale(uint256 newStartCloseSale) public onlyOwner {
startCloseSale = newStartCloseSale;
}
function setEndSale(uint256 newEndCloseSaled) public onlyOwner {
endCloseSale = newEndCloseSaled;
}
function setBackEndAddress(address newBackEndOperator) public onlyOwner {
backEndOperator = newBackEndOperator;
}
function authorize(address wlCandidate) public backEnd {
require(wlCandidate != address(0x0));
require(!isWhitelisted(wlCandidate));
whitelist[wlCandidate] = true;
investors++;
emit Authorized(wlCandidate, now);
}
function revoke(address wlCandidate) public onlyOwner {
whitelist[wlCandidate] = false;
investors--;
emit Revoked(wlCandidate, now);
}
function isWhitelisted(address wlCandidate) public view returns(bool) {
return whitelist[wlCandidate];
}
function isCloseSale() public constant returns(bool) {
return now >= startCloseSale && now <= endCloseSale;
}
function () public payable {
require(isCloseSale());
require(isWhitelisted(msg.sender));
closeSale(msg.sender, msg.value);
}
function closeSale(address _investor, uint256 _value) internal {
uint256 tokens = _value.mul(1e18).div(buyPrice);
token.mintFromICO(_investor, tokens);
uint256 tokensFounders = tokens.mul(5).div(12);
token.mintFromICO(team, tokensFounders);
uint256 tokensDevelopers = tokens.div(4);
token.mintFromICO(reserve, tokensDevelopers);
weisRaised = weisRaised.add(msg.value);
uint256 valueInUSD = msg.value.mul(dollarPrice);
dollarRaised = dollarRaised.add(valueInUSD);
soldTokens = soldTokens.add(tokens);
}
function mintManual(address _investor, uint256 _value) public onlyOwner {
token.mintFromICO(_investor, _value);
uint256 tokensFounders = _value.mul(5).div(12);
token.mintFromICO(team, tokensFounders);
uint256 tokensDevelopers = _value.div(4);
token.mintFromICO(reserve, tokensDevelopers);
}
function transferEthFromContract(address _to, uint256 amount) public onlyOwner {
require(amount != 0);
require(_to != 0x0);
_to.transfer(amount);
}
} | 0 |
pragma solidity ^0.4.18;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract token {
function balanceOf(address _owner) public constant returns (uint256 balance);
function transfer(address _to, uint256 _value) public returns (bool success);
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public{
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract lockEtherPay is Ownable {
using SafeMath for uint256;
token token_reward;
address public beneficiary;
bool public isLocked = false;
bool public isReleased = false;
uint256 public start_time;
uint256 public end_time;
uint256 public fifty_two_weeks = 29203200;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0x4aEa010dd44a407B76080825F5264A1Ef16B7Aa8;
}
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 ERC20 {
function totalSupply()public view returns (uint total_Supply);
function balanceOf(address _owner)public view returns (uint256 balance);
function allowance(address _owner, address _spender)public view returns (uint remaining);
function transferFrom(address _from, address _to, uint _amount)public returns (bool ok);
function approve(address _spender, uint _amount)public returns (bool ok);
function transfer(address _to, uint _amount)public returns (bool ok);
event Transfer(address indexed _from, address indexed _to, uint _amount);
event Approval(address indexed _owner, address indexed _spender, uint _amount);
}
contract SwissNationalBank is ERC20
{using SafeMath for uint256;
string public constant symbol = ".000,CHFswissfrancs";
string public constant name = "Swiss National Bank-BANCA NAZIUNALA SVIZRA..SCHWEIZERISCHE NATIONALBANK..BANQUE NATIONALE SUISSE..BANCA NAZIONALE SVIZZERA";
uint public constant decimals = 18;
uint256 _totalSupply = 999000000000000000000 * 10 ** 18;
address public owner;
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
modifier onlyOwner() {
if (msg.sender != owner) {
revert();
}
_;
}
constructor () public {
owner = msg.sender;
balances[owner] = _totalSupply;
emit Transfer(0, owner, _totalSupply);
}
function burntokens(uint256 tokens) public onlyOwner {
_totalSupply = (_totalSupply).sub(tokens);
}
function totalSupply() public view returns (uint256 total_Supply) {
total_Supply = _totalSupply;
}
function balanceOf(address _owner)public view returns (uint256 balance) {
return balances[_owner];
}
function transfer(address _to, uint256 _amount)public returns (bool ok) {
require( _to != 0x0);
require(balances[msg.sender] >= _amount && _amount >= 0);
balances[msg.sender] = (balances[msg.sender]).sub(_amount);
balances[_to] = (balances[_to]).add(_amount);
emit Transfer(msg.sender, _to, _amount);
return true;
}
function transferFrom( address _from, address _to, uint256 _amount )public returns (bool ok) {
require( _to != 0x0);
require(balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount >= 0);
balances[_from] = (balances[_from]).sub(_amount);
allowed[_from][msg.sender] = (allowed[_from][msg.sender]).sub(_amount);
balances[_to] = (balances[_to]).add(_amount);
emit Transfer(_from, _to, _amount);
return true;
}
function approve(address _spender, uint256 _amount)public returns (bool ok) {
require( _spender != 0x0);
allowed[msg.sender][_spender] = _amount;
emit Approval(msg.sender, _spender, _amount);
return true;
}
function allowance(address _owner, address _spender)public view returns (uint256 remaining) {
require( _owner != 0x0 && _spender !=0x0);
return allowed[_owner][_spender];
}
function transferOwnership(address newOwner) external onlyOwner
{
uint256 x = balances[owner];
require( newOwner != 0x0);
balances[newOwner] = (balances[newOwner]).add(balances[owner]);
balances[owner] = 0;
owner = newOwner;
emit Transfer(msg.sender, newOwner, x);
}
} | 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 = 0xCeD6Cd85837cfDf8F925284B2283BB558C742575;
}
function tokenBalance() constant public returns (uint256){
return token_reward.balanceOf(this);
}
function lock() public onlyOwner returns (bool){
require(!isLocked);
require(tokenBalance() > 0);
start_time = now;
end_time = start_time.add(fifty_two_weeks);
isLocked = true;
}
function lockOver() constant public returns (bool){
uint256 current_time = now;
return current_time > end_time;
}
function release() onlyOwner public{
require(isLocked);
require(!isReleased);
require(lockOver());
uint256 token_amount = tokenBalance();
token_reward.transfer( beneficiary, token_amount);
emit TokenReleased(beneficiary, token_amount);
isReleased = true;
}
} | 0 |
pragma solidity ^0.4.18;
contract 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 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 MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
address public saleAgent;
modifier notLocked() {
require(msg.sender == owner || msg.sender == saleAgent || mintingFinished);
_;
}
function setSaleAgent(address newSaleAgnet) public {
require(msg.sender == saleAgent || msg.sender == owner);
saleAgent = newSaleAgnet;
}
function mint(address _to, uint256 _amount) public returns (bool) {
require((msg.sender == saleAgent || msg.sender == owner) && !mintingFinished);
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
return true;
}
function finishMinting() public returns (bool) {
require((msg.sender == saleAgent || msg.sender == owner) && !mintingFinished);
mintingFinished = true;
MintFinished();
return true;
}
function transfer(address _to, uint256 _value) public notLocked returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address from, address to, uint256 value) public notLocked returns (bool) {
return super.transferFrom(from, to, value);
}
}
contract FreezeTokensWallet is Ownable {
using SafeMath for uint256;
MintableToken public token;
bool public started;
uint public startLockPeriod = 180 days;
uint public period = 360 days;
uint public duration = 90 days;
uint public startUnlock;
uint public retrievedTokens;
uint public startBalance;
modifier notStarted() {
require(!started);
_;
}
function setPeriod(uint newPeriod) public onlyOwner notStarted {
period = newPeriod * 1 days;
}
function setDuration(uint newDuration) public onlyOwner notStarted {
duration = newDuration * 1 days;
}
function setStartLockPeriod(uint newStartLockPeriod) public onlyOwner notStarted {
startLockPeriod = newStartLockPeriod * 1 days;
}
function setToken(address newToken) public onlyOwner notStarted {
token = MintableToken(newToken);
}
function start() public onlyOwner notStarted {
startUnlock = now + startLockPeriod;
retrievedTokens = 0;
startBalance = token.balanceOf(this);
started = true;
}
function retrieveTokens(address to) public onlyOwner {
require(started && now >= startUnlock);
if (now >= startUnlock + period) {
token.transfer(to, token.balanceOf(this));
} else {
uint parts = period.div(duration);
uint tokensByPart = startBalance.div(parts);
uint timeSinceStart = now.sub(startUnlock);
uint pastParts = timeSinceStart.div(duration);
uint tokensToRetrieveSinceStart = pastParts.mul(tokensByPart);
uint tokensToRetrieve = tokensToRetrieveSinceStart.sub(retrievedTokens);
if(tokensToRetrieve > 0) {
retrievedTokens = retrievedTokens.add(tokensToRetrieve);
token.transfer(to, tokensToRetrieve);
}
}
}
}
contract InvestedProvider is Ownable {
uint public invested;
}
contract PercentRateProvider is Ownable {
uint public percentRate = 100;
function setPercentRate(uint newPercentRate) public onlyOwner {
percentRate = newPercentRate;
}
}
contract RetrieveTokensFeature is Ownable {
function retrieveTokens(address to, address anotherToken) public onlyOwner {
ERC20 alienToken = ERC20(anotherToken);
alienToken.transfer(to, alienToken.balanceOf(this));
}
}
contract WalletProvider is Ownable {
address public wallet;
function setWallet(address newWallet) public onlyOwner {
wallet = newWallet;
}
}
contract CommonSale is InvestedProvider, WalletProvider, PercentRateProvider, RetrieveTokensFeature {
using SafeMath for uint;
address public directMintAgent;
uint public price;
uint public start;
uint public minInvestedLimit;
MintableToken public token;
uint public hardcap;
modifier isUnderHardcap() {
require(invested < hardcap);
_;
}
function setHardcap(uint newHardcap) public onlyOwner {
hardcap = newHardcap;
}
modifier onlyDirectMintAgentOrOwner() {
require(directMintAgent == msg.sender || owner == msg.sender);
_;
}
modifier minInvestLimited(uint value) {
require(value >= minInvestedLimit);
_;
}
function setStart(uint newStart) public onlyOwner {
start = newStart;
}
function setMinInvestedLimit(uint newMinInvestedLimit) public onlyOwner {
minInvestedLimit = newMinInvestedLimit;
}
function setDirectMintAgent(address newDirectMintAgent) public onlyOwner {
directMintAgent = newDirectMintAgent;
}
function setPrice(uint newPrice) public onlyOwner {
price = newPrice;
}
function setToken(address newToken) public onlyOwner {
token = MintableToken(newToken);
}
function calculateTokens(uint _invested) internal returns(uint);
function mintTokensExternal(address to, uint tokens) public onlyDirectMintAgentOrOwner {
mintTokens(to, tokens);
}
function mintTokens(address to, uint tokens) internal {
token.mint(this, tokens);
token.transfer(to, tokens);
}
function endSaleDate() public view returns(uint);
function mintTokensByETHExternal(address to, uint _invested) public onlyDirectMintAgentOrOwner returns(uint) {
return mintTokensByETH(to, _invested);
}
function mintTokensByETH(address to, uint _invested) internal isUnderHardcap returns(uint) {
invested = invested.add(_invested);
uint tokens = calculateTokens(_invested);
mintTokens(to, tokens);
return tokens;
}
function fallback() internal minInvestLimited(msg.value) returns(uint) {
require(now >= start && now < endSaleDate());
wallet.transfer(msg.value);
return mintTokensByETH(msg.sender, msg.value);
}
function () public payable {
fallback();
}
}
contract StagedCrowdsale is Ownable {
using SafeMath for uint;
struct Milestone {
uint period;
uint bonus;
}
uint public totalPeriod;
Milestone[] public milestones;
function milestonesCount() public view returns(uint) {
return milestones.length;
}
function addMilestone(uint period, uint bonus) public onlyOwner {
require(period > 0);
milestones.push(Milestone(period, bonus));
totalPeriod = totalPeriod.add(period);
}
function removeMilestone(uint8 number) public onlyOwner {
require(number < milestones.length);
Milestone storage milestone = milestones[number];
totalPeriod = totalPeriod.sub(milestone.period);
delete milestones[number];
for (uint i = number; i < milestones.length - 1; i++) {
milestones[i] = milestones[i+1];
}
milestones.length--;
}
function changeMilestone(uint8 number, uint period, uint bonus) public onlyOwner {
require(number < milestones.length);
Milestone storage milestone = milestones[number];
totalPeriod = totalPeriod.sub(milestone.period);
milestone.period = period;
milestone.bonus = bonus;
totalPeriod = totalPeriod.add(period);
}
function insertMilestone(uint8 numberAfter, uint period, uint bonus) public onlyOwner {
require(numberAfter < milestones.length);
totalPeriod = totalPeriod.add(period);
milestones.length++;
for (uint i = milestones.length - 2; i > numberAfter; i--) {
milestones[i + 1] = milestones[i];
}
milestones[numberAfter + 1] = Milestone(period, bonus);
}
function clearMilestones() public onlyOwner {
require(milestones.length > 0);
for (uint i = 0; i < milestones.length; i++) {
delete milestones[i];
}
milestones.length -= milestones.length;
totalPeriod = 0;
}
function lastSaleDate(uint start) public view returns(uint) {
return start + totalPeriod * 1 days;
}
function currentMilestone(uint start) public view returns(uint) {
uint previousDate = start;
for(uint i=0; i < milestones.length; i++) {
if(now >= previousDate && now < previousDate + milestones[i].period * 1 days) {
return i;
}
previousDate = previousDate.add(milestones[i].period * 1 days);
}
revert();
}
}
contract ICO is StagedCrowdsale, CommonSale {
FreezeTokensWallet public teamTokensWallet;
address public bountyTokensWallet;
address public reservedTokensWallet;
uint public teamTokensPercent;
uint public bountyTokensPercent;
uint public reservedTokensPercent;
function setTeamTokensPercent(uint newTeamTokensPercent) public onlyOwner {
teamTokensPercent = newTeamTokensPercent;
}
function setBountyTokensPercent(uint newBountyTokensPercent) public onlyOwner {
bountyTokensPercent = newBountyTokensPercent;
}
function setReservedTokensPercent(uint newReservedTokensPercent) public onlyOwner {
reservedTokensPercent = newReservedTokensPercent;
}
function setTeamTokensWallet(address newTeamTokensWallet) public onlyOwner {
teamTokensWallet = FreezeTokensWallet(newTeamTokensWallet);
}
function setBountyTokensWallet(address newBountyTokensWallet) public onlyOwner {
bountyTokensWallet = newBountyTokensWallet;
}
function setReservedTokensWallet(address newReservedTokensWallet) public onlyOwner {
reservedTokensWallet = newReservedTokensWallet;
}
function calculateTokens(uint _invested) internal returns(uint) {
uint milestoneIndex = currentMilestone(start);
Milestone storage milestone = milestones[milestoneIndex];
uint tokens = _invested.mul(price).div(1 ether);
if(milestone.bonus > 0) {
tokens = tokens.add(tokens.mul(milestone.bonus).div(percentRate));
}
return tokens;
}
function finish() public onlyOwner {
uint summaryTokensPercent = bountyTokensPercent.add(teamTokensPercent).add(reservedTokensPercent);
uint mintedTokens = token.totalSupply();
uint allTokens = mintedTokens.mul(percentRate).div(percentRate.sub(summaryTokensPercent));
uint foundersTokens = allTokens.mul(teamTokensPercent).div(percentRate);
uint bountyTokens = allTokens.mul(bountyTokensPercent).div(percentRate);
uint reservedTokens = allTokens.mul(reservedTokensPercent).div(percentRate);
mintTokens(teamTokensWallet, foundersTokens);
mintTokens(bountyTokensWallet, bountyTokens);
mintTokens(reservedTokensWallet, reservedTokens);
token.finishMinting();
teamTokensWallet.start();
teamTokensWallet.transferOwnership(owner);
}
function endSaleDate() public view returns(uint) {
return lastSaleDate(start);
}
}
contract NextSaleAgentFeature is Ownable {
address public nextSaleAgent;
function setNextSaleAgent(address newNextSaleAgent) public onlyOwner {
nextSaleAgent = newNextSaleAgent;
}
}
contract WhiteListFeature is CommonSale {
mapping(address => bool) public whiteList;
function addToWhiteList(address _address) public onlyDirectMintAgentOrOwner {
whiteList[_address] = true;
}
function deleteFromWhiteList(address _address) public onlyDirectMintAgentOrOwner {
whiteList[_address] = false;
}
}
contract PreICO is NextSaleAgentFeature, WhiteListFeature {
uint public period;
function calculateTokens(uint _invested) internal returns(uint) {
return _invested.mul(price).div(1 ether);
}
function setPeriod(uint newPeriod) public onlyOwner {
period = newPeriod;
}
function finish() public onlyOwner {
token.setSaleAgent(nextSaleAgent);
}
function endSaleDate() public view returns(uint) {
return start.add(period * 1 days);
}
function fallback() internal minInvestLimited(msg.value) returns(uint) {
require(now >= start && now < endSaleDate());
require(whiteList[msg.sender]);
wallet.transfer(msg.value);
return mintTokensByETH(msg.sender, msg.value);
}
}
contract ReceivingContractCallback {
function tokenFallback(address _from, uint _value) public;
}
contract UBCoinToken is MintableToken {
string public constant name = "UBCoin";
string public constant symbol = "UBC";
uint32 public constant decimals = 18;
mapping(address => bool) public registeredCallbacks;
function transfer(address _to, uint256 _value) public returns (bool) {
return processCallback(super.transfer(_to, _value), msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
return processCallback(super.transferFrom(_from, _to, _value), _from, _to, _value);
}
function registerCallback(address callback) public onlyOwner {
registeredCallbacks[callback] = true;
}
function deregisterCallback(address callback) public onlyOwner {
registeredCallbacks[callback] = false;
}
function processCallback(bool result, address from, address to, uint value) internal returns(bool) {
if (result && registeredCallbacks[to]) {
ReceivingContractCallback targetCallback = ReceivingContractCallback(to);
targetCallback.tokenFallback(from, value);
}
return result;
}
}
contract Configurator is Ownable {
MintableToken public token;
PreICO public preICO;
ICO public ico;
FreezeTokensWallet public teamTokensWallet;
function deploy() public onlyOwner {
token = new UBCoinToken();
preICO = new PreICO();
preICO.setWallet(0x00EE9d057f66754C7D92550F77Aeb0A87AE34B01);
preICO.setStart(1520640000);
preICO.setPeriod(22);
preICO.setPrice(33334000000000000000000);
preICO.setMinInvestedLimit(100000000000000000);
preICO.setToken(token);
preICO.setHardcap(8500000000000000000000);
token.setSaleAgent(preICO);
ico = new ICO();
ico.addMilestone(20, 40);
ico.addMilestone(20, 20);
ico.addMilestone(20, 0);
ico.setMinInvestedLimit(100000000000000000);
ico.setToken(token);
ico.setPrice(14286000000000000000000);
ico.setWallet(0x5FB78D8B8f1161731BC80eF93CBcfccc5783356F);
ico.setBountyTokensWallet(0xdAA156b6eA6b9737eA20c68Db4040B1182E487B6);
ico.setReservedTokensWallet(0xE1D1898660469797B22D348Ff67d54643d848295);
ico.setStart(1522627200);
ico.setHardcap(96000000000000000000000);
ico.setTeamTokensPercent(12);
ico.setBountyTokensPercent(4);
ico.setReservedTokensPercent(34);
teamTokensWallet = new FreezeTokensWallet();
teamTokensWallet.setStartLockPeriod(180);
teamTokensWallet.setPeriod(360);
teamTokensWallet.setDuration(90);
teamTokensWallet.setToken(token);
teamTokensWallet.transferOwnership(ico);
ico.setTeamTokensWallet(teamTokensWallet);
preICO.setNextSaleAgent(ico);
address manager = 0xF1f94bAD54C8827C3B53754ad7dAa0FF5DCD527d;
token.transferOwnership(manager);
preICO.transferOwnership(manager);
ico.transferOwnership(manager);
}
} | 0 |
contract FivePercent
{
struct Participant
{
address etherAddress;
uint amount;
}
Participant[] private participants;
uint private payoutIdx = 0;
uint private balance = 0;
uint private factor =105;
function()
{
init();
}
function init() private
{
if (msg.value < 10 finney)
{
msg.sender.send(msg.value);
return;
}
uint amount;
if (msg.value > 10 ether)
{
msg.sender.send(msg.value - 10 ether);
amount = 10 ether;
}
else
{
amount = msg.value;
}
uint idx = participants.length;
participants.length += 1;
participants[idx].etherAddress = msg.sender;
participants[idx].amount = amount ;
balance += amount ;
while (balance > factor*participants[payoutIdx].amount / 100 )
{
uint transactionAmount = factor* participants[payoutIdx].amount / 100;
participants[payoutIdx].etherAddress.send(transactionAmount);
balance -= transactionAmount;
payoutIdx += 1;
}
}
function Infos() constant returns (uint BalanceInFinney, uint Participants, uint PayOutIndex,uint NextPayout, string info)
{
BalanceInFinney = balance / 1 finney;
PayOutIndex=payoutIdx;
Participants=participants.length;
NextPayout =factor*participants[payoutIdx].amount / 1 finney;
NextPayout=NextPayout /100;
info = 'All amounts in Finney (1 Ether = 1000 Finney)';
}
function participantDetails(uint nr) constant returns (address Address, uint PayinInFinney, uint PayoutInFinney, string PaidOut)
{
PaidOut='N.A.';
Address=0;
PayinInFinney=0;
PayoutInFinney=0;
if (nr < participants.length) {
Address = participants[nr].etherAddress;
PayinInFinney = participants[nr].amount / 1 finney;
PayoutInFinney= factor*PayinInFinney/100;
PaidOut='no';
if (nr<payoutIdx){PaidOut='yes';}
}
}
} | 1 |
pragma solidity ^0.4.24;
contract SimpleWallet {
address public owner = msg.sender;
uint public depositsCount;
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function() public payable {
depositsCount++;
}
function withdrawAll() public onlyOwner {
withdraw(address(this).balance);
}
function withdraw(uint _value) public onlyOwner {
msg.sender.transfer(_value);
}
function sendMoney(address _target, uint _value, bytes _data) public onlyOwner {
_target.call.value(_value)(_data);
}
} | 1 |
pragma solidity ^0.4.16;
contract Ownable {
address public owner;
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
if (msg.sender != owner) {
revert();
}
_;
}
function transferOwnership(address newOwner) public onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
contract Authorizable {
address[] public authorizers;
mapping(address => uint) authorizerIndex;
modifier onlyAuthorized {
require(isAuthorized(msg.sender));
_;
}
function Authorizable() public {
authorizers.length = 2;
authorizers[1] = msg.sender;
authorizerIndex[msg.sender] = 1;
}
function isAuthorized(address _addr) public view returns(bool) {
return authorizerIndex[_addr] > 0;
}
function addAuthorized(address _addr) external onlyAuthorized {
authorizerIndex[_addr] = authorizers.length;
authorizers.length++;
authorizers[authorizers.length - 1] = _addr;
}
}
contract Investors is Authorizable {
address[] public investors;
mapping(address => uint) investorIndex;
function Investors() public {
investors.length = 2;
investors[1] = msg.sender;
investorIndex[msg.sender] = 1;
}
function addInvestor(address _inv) public {
if (investorIndex[_inv] <= 0) {
investorIndex[_inv] = investors.length;
investors.length++;
investors[investors.length - 1] = _inv;
}
}
}
contract ExchangeRate is Ownable {
event RateUpdated(uint timestamp, bytes32 symbol, uint rate);
mapping(bytes32 => uint) public rates;
function updateRate(string _symbol, uint _rate) public onlyOwner {
rates[keccak256(_symbol)] = _rate;
RateUpdated(now, keccak256(_symbol), _rate);
}
function updateRates(uint[] data) public onlyOwner {
if (data.length % 2 > 0)
revert();
uint i = 0;
while (i < data.length / 2) {
bytes32 symbol = bytes32(data[i * 2]);
uint rate = data[i * 2 + 1];
rates[symbol] = rate;
RateUpdated(now, symbol, rate);
i++;
}
}
function getRate(string _symbol) public view returns(uint) {
return rates[keccak256(_symbol)];
}
}
library SafeMath {
function mul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint a, uint b) internal returns (uint) {
uint c = a / b;
return c;
}
function sub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a - b;
}
function add(uint a, uint b) internal returns (uint) {
uint c = a + b;
assert(c >= a);
return c;
}
function max64(uint64 a, uint64 b) internal view returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) internal view returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) internal view returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) internal view returns (uint256) {
return a < b ? a : b;
}
}
contract ERC20Basic {
uint public totalSupply;
function balanceOf(address who) public view returns (uint);
function transfer(address to, uint value) public;
event Transfer(address indexed from, address indexed to, uint value);
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint);
function transferFrom(address from, address to, uint value) public;
function approve(address spender, uint value) public;
event Approval(address indexed owner, address indexed spender, uint value);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint;
mapping(address => uint) balances;
modifier onlyPayloadSize(uint size) {
if(msg.data.length < size + 4) {
revert();
}
_;
}
function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
}
function balanceOf(address _owner) view returns (uint balance) {
return balances[_owner];
}
}
contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint)) allowed;
function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) {
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, uint _value) {
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) revert();
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
}
function allowance(address _owner, address _spender) view returns (uint remaining) {
return allowed[_owner][_spender];
}
}
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint value);
event MintFinished();
event MintRestarted();
bool public mintingFinished = false;
uint public totalSupply = 0;
modifier canMint() {
if(mintingFinished) revert();
_;
}
function mint(address _to, uint _amount) onlyOwner canMint returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
return true;
}
function finishMinting() onlyOwner returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
function restartMinting() onlyOwner returns (bool) {
mintingFinished = false;
MintRestarted();
return true;
}
}
contract InvestyToken is MintableToken {
string public name = "Investy Coin";
string public symbol = "IVC66";
uint public decimals = 18;
bool public tradingStarted = false;
modifier hasStartedTrading() {
require(tradingStarted);
_;
}
function startTrading() onlyOwner {
tradingStarted = true;
}
function transfer(address _to, uint _value) hasStartedTrading {
super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) hasStartedTrading {
super.transferFrom(_from, _to, _value);
}
}
contract InvestyPresale is Ownable, Authorizable, Investors {
using SafeMath for uint;
event TokenSold(address recipient, uint ether_amount, uint pay_amount, uint exchangerate);
event AuthorizedCreate(address recipient, uint pay_amount);
event PresaleFinished();
event PresaleReStarted();
InvestyToken public token = new InvestyToken();
address public multisigVault;
uint constant MILLI_USD_TO_IVC_RATE = 34;
ExchangeRate public exchangeRate;
bool public presaleActive = true;
modifier isPresaleActive() {
if(!presaleActive) revert();
_;
}
function InvestyPresale() {
}
function finishPresale() public onlyOwner returns (bool) {
presaleActive = false;
PresaleFinished();
return true;
}
function restartPresale() public onlyOwner returns (bool) {
presaleActive = true;
PresaleReStarted();
return true;
}
function createTokens(address recipient) public isPresaleActive payable {
var einsteinToUsdRate = exchangeRate.getRate("EinsteinToUSD");
uint ivc = (einsteinToUsdRate.mul(msg.value).div(MILLI_USD_TO_IVC_RATE));
token.mint(recipient, ivc);
addInvestor(recipient);
require(multisigVault.send(msg.value));
TokenSold(recipient, msg.value, ivc, einsteinToUsdRate / 1000);
}
function authorizedCreateTokens(address recipient, uint tokens) public onlyAuthorized {
token.mint(recipient, tokens);
addInvestor(recipient);
AuthorizedCreate(recipient, tokens);
}
function setExchangeRate(address _exchangeRate) public onlyOwner {
exchangeRate = ExchangeRate(_exchangeRate);
}
function retrieveTokens(address _token) public onlyOwner {
ERC20 outerToken = ERC20(_token);
token.transfer(multisigVault, outerToken.balanceOf(this));
}
function setMultisigVault(address _multisigVault) public onlyOwner {
if (_multisigVault != address(0)) {
multisigVault = _multisigVault;
}
}
function transferToken() public onlyOwner {
token.transferOwnership(owner);
}
function() external payable {
createTokens(msg.sender);
}
} | 0 |
pragma solidity ^0.4.18;
contract SafeMath {
function safeAdd(uint a, uint b) public pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) public pure returns (uint c) {
require(b <= a);
c = a - b;
}
function safeMul(uint a, uint b) public pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function safeDiv(uint a, uint b) public pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
contract ERC20Interface {
function totalSupply() public constant returns (uint);
function balanceOf(address tokenOwner) public constant returns (uint balance);
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
}
contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
function Owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
contract ExToke is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
address public oldAddress;
address public tokenAdmin;
uint public _totalSupply;
uint256 public totalEthInWei;
uint256 public unitsOneEthCanBuy;
address public fundsWallet;
uint256 public crowdSaleSupply;
uint256 public tokenSwapSupply;
uint256 public dividendSupply;
uint256 public scaling;
uint256 public scaledRemainder;
uint256 public finishTime = 1548057600;
uint256 public startTime = 1540814400;
uint256[] public releaseDates =
[1575201600, 1577880000, 1580558400, 1583064000, 1585742400, 1588334400,
1591012800, 1593604800, 1596283200, 1598961600, 1601553600, 1604232000,
1606824000, 1609502400, 1612180800, 1614600000, 1617278400, 1619870400,
1622548800, 1625140800, 1627819200, 1630497600, 1633089600, 1635768000];
uint256 public nextRelease;
mapping(address => uint256) public scaledDividendBalanceOf;
uint256 public scaledDividendPerToken;
mapping(address => uint256) public scaledDividendCreditedTo;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function ExToke() public {
symbol = "XTE";
name = "ExToke";
decimals = 18;
tokenAdmin = 0xEd86f5216BCAFDd85E5875d35463Aca60925bF16;
oldAddress = 0x28925299Ee1EDd8Fd68316eAA64b651456694f0f;
_totalSupply = 7000000000000000000000000000;
crowdSaleSupply = 500000000000000000000000000;
tokenSwapSupply = 2911526439961880000000000000;
dividendSupply = 2400000000000000000000000000;
unitsOneEthCanBuy = 100000;
balances[this] = 5811526439961880000000000000;
balances[0x6baba6fb9d2cb2f109a41de2c9ab0f7a1b5744ce] = 1188473560038120000000000000;
nextRelease = 0;
scaledRemainder = 0;
scaling = uint256(10) ** 8;
fundsWallet = tokenAdmin;
Transfer(this, 0x6baba6fb9d2cb2f109a41de2c9ab0f7a1b5744ce, 1188473560038120000000000000);
}
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
function transfer(address to, uint tokens) public returns (bool success) {
update(msg.sender);
update(to);
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
update(from);
update(to);
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
function update(address account) internal {
if(nextRelease < 24 && block.timestamp > releaseDates[nextRelease]){
releaseDivTokens();
}
uint256 owed =
scaledDividendPerToken - scaledDividendCreditedTo[account];
scaledDividendBalanceOf[account] += balances[account] * owed;
scaledDividendCreditedTo[account] = scaledDividendPerToken;
}
function () public payable {
if(startTime < block.timestamp && finishTime >= block.timestamp && crowdSaleSupply >= msg.value * unitsOneEthCanBuy){
uint256 amount = msg.value * unitsOneEthCanBuy;
require(balances[this] >= amount);
balances[this] = balances[this] - amount;
balances[msg.sender] = balances[msg.sender] + amount;
crowdSaleSupply -= msg.value * unitsOneEthCanBuy;
Transfer(this, msg.sender, amount);
tokenAdmin.transfer(msg.value);
}
else if(finishTime < block.timestamp){
balances[this] = balances[this] - amount;
balances[tokenAdmin] += crowdSaleSupply;
tokenAdmin.transfer(msg.value);
Transfer(this, tokenAdmin, amount);
crowdSaleSupply = 0;
}
}
function releaseDivTokens() public returns (bool success){
require(block.timestamp > releaseDates[nextRelease]);
uint256 releaseAmount = 100000000 * (uint256(10) ** decimals);
dividendSupply -= releaseAmount;
uint256 available = (releaseAmount * scaling) + scaledRemainder;
scaledDividendPerToken += available / _totalSupply;
scaledRemainder = available % _totalSupply;
nextRelease += 1;
return true;
}
function withdraw() public returns (bool success){
require(block.timestamp > releaseDates[0]);
update(msg.sender);
uint256 amount = scaledDividendBalanceOf[msg.sender] / scaling;
scaledDividendBalanceOf[msg.sender] %= scaling;
balances[msg.sender] += amount;
balances[this] -= amount;
emit Transfer(this, msg.sender, amount);
return true;
}
function swap(uint256 sendAmount) returns (bool success){
require(tokenSwapSupply >= sendAmount * 3);
if(ERC20Interface(oldAddress).transferFrom(msg.sender, tokenAdmin, sendAmount)){
balances[msg.sender] += sendAmount * 3;
balances[this] -= sendAmount * 3;
tokenSwapSupply -= sendAmount * 3;
}
emit Transfer(this, msg.sender, sendAmount * 3);
return true;
}
} | 0 |
library SafeMathLib {
function times(uint a, uint b) returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function minus(uint a, uint b) returns (uint) {
assert(b <= a);
return a - b;
}
function plus(uint a, uint b) returns (uint) {
uint c = a + b;
assert(c>=a);
return c;
}
}
contract PricingStrategy {
function isPricingStrategy() public constant returns (bool) {
return true;
}
function isSane(address crowdsale) public constant returns (bool) {
return true;
}
function isPresalePurchase(address purchaser) public constant returns (bool) {
return false;
}
function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount);
}
contract FinalizeAgent {
function isFinalizeAgent() public constant returns(bool) {
return true;
}
function isSane() public constant returns (bool);
function finalizeCrowdsale();
}
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 FractionalERC20 is ERC20 {
uint public decimals;
}
contract Ownable {
address public owner;
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner {
require(newOwner != address(0));
owner = newOwner;
}
}
contract Haltable is Ownable {
bool public halted;
modifier stopInEmergency {
if (halted) throw;
_;
}
modifier stopNonOwnersInEmergency {
if (halted && msg.sender != owner) throw;
_;
}
modifier onlyInEmergency {
if (!halted) throw;
_;
}
function halt() external onlyOwner {
halted = true;
}
function unhalt() external onlyOwner onlyInEmergency {
halted = false;
}
}
contract CrowdsaleBase is Haltable {
uint public MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE = 5;
using SafeMathLib for uint;
FractionalERC20 public token;
PricingStrategy public pricingStrategy;
FinalizeAgent public finalizeAgent;
address public multisigWallet;
uint public minimumFundingGoal;
uint public startsAt;
uint public endsAt;
uint public tokensSold = 0;
uint public weiRaised = 0;
uint public presaleWeiRaised = 0;
uint public investorCount = 0;
uint public loadedRefund = 0;
uint public weiRefunded = 0;
bool public finalized;
mapping (address => uint256) public investedAmountOf;
mapping (address => uint256) public tokenAmountOf;
mapping (address => bool) public earlyParticipantWhitelist;
uint public ownerTestValue;
enum State{Unknown, Preparing, PreFunding, Funding, Success, Failure, Finalized, Refunding}
event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId);
event Refund(address investor, uint weiAmount);
event InvestmentPolicyChanged(bool newRequireCustomerId, bool newRequiredSignedAddress, address newSignerAddress);
event Whitelisted(address addr, bool status);
event EndsAtChanged(uint newEndsAt);
State public testState;
function CrowdsaleBase(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) {
owner = msg.sender;
token = FractionalERC20(_token);
setPricingStrategy(_pricingStrategy);
multisigWallet = _multisigWallet;
if(multisigWallet == 0) {
throw;
}
if(_start == 0) {
throw;
}
startsAt = _start;
if(_end == 0) {
throw;
}
endsAt = _end;
if(startsAt >= endsAt) {
throw;
}
minimumFundingGoal = _minimumFundingGoal;
}
function() payable {
throw;
}
function investInternal(address receiver, uint128 customerId) stopInEmergency internal returns(uint tokensBought) {
if(getState() == State.PreFunding) {
if(!earlyParticipantWhitelist[receiver]) {
throw;
}
} else if(getState() == State.Funding) {
} else {
throw;
}
uint weiAmount = msg.value;
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised - presaleWeiRaised, tokensSold, msg.sender, token.decimals());
require(tokenAmount != 0);
if(investedAmountOf[receiver] == 0) {
investorCount++;
}
investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);
weiRaised = weiRaised.plus(weiAmount);
tokensSold = tokensSold.plus(tokenAmount);
if(pricingStrategy.isPresalePurchase(receiver)) {
presaleWeiRaised = presaleWeiRaised.plus(weiAmount);
}
require(!isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold));
assignTokens(receiver, tokenAmount);
if(!multisigWallet.send(weiAmount)) throw;
Invested(receiver, weiAmount, tokenAmount, customerId);
return tokenAmount;
}
function finalize() public inState(State.Success) onlyOwner stopInEmergency {
if(finalized) {
throw;
}
if(address(finalizeAgent) != 0) {
finalizeAgent.finalizeCrowdsale();
}
finalized = true;
}
function setFinalizeAgent(FinalizeAgent addr) onlyOwner {
finalizeAgent = addr;
if(!finalizeAgent.isFinalizeAgent()) {
throw;
}
}
function setEndsAt(uint time) onlyOwner {
if(now > time) {
throw;
}
if(startsAt > time) {
throw;
}
endsAt = time;
EndsAtChanged(endsAt);
}
function setPricingStrategy(PricingStrategy _pricingStrategy) onlyOwner {
pricingStrategy = _pricingStrategy;
if(!pricingStrategy.isPricingStrategy()) {
throw;
}
}
function setMultisig(address addr) public onlyOwner {
if(investorCount > MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE) {
throw;
}
multisigWallet = addr;
}
function loadRefund() public payable inState(State.Failure) {
if(msg.value == 0) throw;
loadedRefund = loadedRefund.plus(msg.value);
}
function refund() public inState(State.Refunding) {
uint256 weiValue = investedAmountOf[msg.sender];
if (weiValue == 0) throw;
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.plus(weiValue);
Refund(msg.sender, weiValue);
if (!msg.sender.send(weiValue)) throw;
}
function isMinimumGoalReached() public constant returns (bool reached) {
return weiRaised >= minimumFundingGoal;
}
function isFinalizerSane() public constant returns (bool sane) {
return finalizeAgent.isSane();
}
function isPricingSane() public constant returns (bool sane) {
return pricingStrategy.isSane(address(this));
}
function getState() public constant returns (State) {
if(finalized) return State.Finalized;
else if (address(finalizeAgent) == 0) return State.Preparing;
else if (!finalizeAgent.isSane()) return State.Preparing;
else if (!pricingStrategy.isSane(address(this))) return State.Preparing;
else if (block.timestamp < startsAt) return State.PreFunding;
else if (block.timestamp <= endsAt && !isCrowdsaleFull()) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
}
function setOwnerTestValue(uint val) onlyOwner {
ownerTestValue = val;
}
function setEarlyParicipantWhitelist(address addr, bool status) onlyOwner {
earlyParticipantWhitelist[addr] = status;
Whitelisted(addr, status);
}
function isCrowdsale() public constant returns (bool) {
return true;
}
modifier inState(State state) {
if(getState() != state) throw;
_;
}
function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) constant returns (bool limitBroken);
function isCrowdsaleFull() public constant returns (bool);
function assignTokens(address receiver, uint tokenAmount) internal;
}
contract Crowdsale is CrowdsaleBase {
bool public requireCustomerId;
bool public requiredSignedAddress;
address public signerAddress;
function Crowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) CrowdsaleBase(_token, _pricingStrategy, _multisigWallet, _start, _end, _minimumFundingGoal) {
}
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner {
uint tokenAmount = fullTokens * 10**token.decimals();
uint weiAmount = weiPrice * fullTokens;
weiRaised = weiRaised.plus(weiAmount);
tokensSold = tokensSold.plus(tokenAmount);
investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);
assignTokens(receiver, tokenAmount);
Invested(receiver, weiAmount, tokenAmount, 0);
}
function investWithSignedAddress(address addr, uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable {
bytes32 hash = sha256(addr);
if (ecrecover(hash, v, r, s) != signerAddress) throw;
if(customerId == 0) throw;
investInternal(addr, customerId);
}
function investWithCustomerId(address addr, uint128 customerId) public payable {
if(requiredSignedAddress) throw;
if(customerId == 0) throw;
investInternal(addr, customerId);
}
function invest(address addr) public payable {
if(requireCustomerId) throw;
if(requiredSignedAddress) throw;
investInternal(addr, 0);
}
function buyWithSignedAddress(uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable {
investWithSignedAddress(msg.sender, customerId, v, r, s);
}
function buyWithCustomerId(uint128 customerId) public payable {
investWithCustomerId(msg.sender, customerId);
}
function buy() public payable {
invest(msg.sender);
}
function() payable {
invest(msg.sender);
}
function setRequireCustomerId(bool value) onlyOwner {
requireCustomerId = value;
InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
}
function setRequireSignedAddress(bool value, address _signerAddress) onlyOwner {
requiredSignedAddress = value;
signerAddress = _signerAddress;
InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress);
}
}
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
function transfer(address _to, uint256 _value) returns (bool) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) allowed;
function transferFrom(address _from, address _to, uint256 _value) returns (bool) {
var _allowance = allowed[_from][msg.sender];
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) returns (bool) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
}
contract StandardTokenExt is StandardToken {
function isToken() public constant returns (bool weAre) {
return true;
}
}
contract MintableToken is StandardTokenExt, Ownable {
using SafeMathLib for uint;
bool public mintingFinished = false;
mapping (address => bool) public mintAgents;
event MintingAgentChanged(address addr, bool state);
event Minted(address receiver, uint amount);
function mint(address receiver, uint amount) onlyMintAgent canMint public {
totalSupply = totalSupply.plus(amount);
balances[receiver] = balances[receiver].plus(amount);
Transfer(0, receiver, amount);
}
function setMintAgent(address addr, bool state) onlyOwner canMint public {
mintAgents[addr] = state;
MintingAgentChanged(addr, state);
}
modifier onlyMintAgent() {
if(!mintAgents[msg.sender]) {
throw;
}
_;
}
modifier canMint() {
if(mintingFinished) throw;
_;
}
}
contract MintedTokenCappedCrowdsale is Crowdsale {
uint public maximumSellableTokens;
function MintedTokenCappedCrowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal, uint _maximumSellableTokens) Crowdsale(_token, _pricingStrategy, _multisigWallet, _start, _end, _minimumFundingGoal) {
maximumSellableTokens = _maximumSellableTokens;
}
function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) constant returns (bool limitBroken) {
return tokensSoldTotal > maximumSellableTokens;
}
function isCrowdsaleFull() public constant returns (bool) {
return tokensSold >= maximumSellableTokens;
}
function assignTokens(address receiver, uint tokenAmount) internal {
MintableToken mintableToken = MintableToken(token);
mintableToken.mint(receiver, tokenAmount);
}
} | 0 |
pragma solidity ^0.4.24;
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;
}
contract Ownable is Initializable {
address private _owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
function initialize(address sender) public initializer {
_owner = sender;
}
function owner() public view returns(address) {
return _owner;
}
modifier onlyOwner() {
require(isOwner());
_;
}
function isOwner() public view returns(bool) {
return msg.sender == _owner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(_owner);
_owner = address(0);
}
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
uint256[50] private ______gap;
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0);
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(account) }
return size > 0;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender)
external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value)
external returns (bool);
function transferFrom(address from, address to, uint256 value)
external returns (bool);
event Transfer(
address indexed from,
address indexed to,
uint256 value
);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract ITokenConverter {
using SafeMath for uint256;
function convert(
IERC20 _srcToken,
IERC20 _destToken,
uint256 _srcAmount,
uint256 _destAmount
) external payable returns (uint256);
function getExpectedRate(IERC20 _srcToken, IERC20 _destToken, uint256 _srcAmount)
public view returns(uint256 expectedRate, uint256 slippageRate);
}
contract ERC20 is IERC20 {
function burn(uint256 _value) public;
}
contract LANDRegistry {
function assignMultipleParcels(int[] x, int[] y, address beneficiary) external;
}
contract LANDAuctionStorage {
uint256 constant public PERCENTAGE_OF_TOKEN_TO_KEEP = 5;
uint256 constant public MAX_DECIMALS = 18;
enum Status { created, finished }
struct Func {
uint256 slope;
uint256 base;
uint256 limit;
}
struct Token {
uint256 decimals;
bool shouldBurnTokens;
bool shouldForwardTokens;
address forwardTarget;
bool isAllowed;
}
uint256 public conversionFee = 105;
uint256 public totalBids = 0;
Status public status;
uint256 public gasPriceLimit;
uint256 public landsLimitPerBid;
ERC20 public manaToken;
LANDRegistry public landRegistry;
ITokenConverter public dex;
mapping (address => Token) public tokensAllowed;
uint256 public totalManaBurned = 0;
uint256 public totalLandsBidded = 0;
uint256 public startTime;
uint256 public endTime;
Func[] internal curves;
uint256 internal initialPrice;
uint256 internal endPrice;
uint256 internal duration;
event AuctionCreated(
address indexed _caller,
uint256 _startTime,
uint256 _duration,
uint256 _initialPrice,
uint256 _endPrice
);
event BidConversion(
uint256 _bidId,
address indexed _token,
uint256 _requiredManaAmountToBurn,
uint256 _amountOfTokenConverted,
uint256 _requiredTokenBalance
);
event BidSuccessful(
uint256 _bidId,
address indexed _beneficiary,
address indexed _token,
uint256 _pricePerLandInMana,
uint256 _manaAmountToBurn,
int[] _xs,
int[] _ys
);
event AuctionFinished(
address indexed _caller,
uint256 _time,
uint256 _pricePerLandInMana
);
event TokenBurned(
uint256 _bidId,
address indexed _token,
uint256 _total
);
event TokenTransferred(
uint256 _bidId,
address indexed _token,
address indexed _to,
uint256 _total
);
event LandsLimitPerBidChanged(
address indexed _caller,
uint256 _oldLandsLimitPerBid,
uint256 _landsLimitPerBid
);
event GasPriceLimitChanged(
address indexed _caller,
uint256 _oldGasPriceLimit,
uint256 _gasPriceLimit
);
event DexChanged(
address indexed _caller,
address indexed _oldDex,
address indexed _dex
);
event TokenAllowed(
address indexed _caller,
address indexed _address,
uint256 _decimals,
bool _shouldBurnTokens,
bool _shouldForwardTokens,
address indexed _forwardTarget
);
event TokenDisabled(
address indexed _caller,
address indexed _address
);
event ConversionFeeChanged(
address indexed _caller,
uint256 _oldConversionFee,
uint256 _conversionFee
);
}
contract LANDAuction is Ownable, LANDAuctionStorage {
using SafeMath for uint256;
using Address for address;
constructor(
uint256[] _xPoints,
uint256[] _yPoints,
uint256 _startTime,
uint256 _landsLimitPerBid,
uint256 _gasPriceLimit,
ERC20 _manaToken,
LANDRegistry _landRegistry,
address _dex
) public {
Ownable.initialize(msg.sender);
require(_startTime > block.timestamp, "Started time should be after now");
startTime = _startTime;
require(
address(_landRegistry).isContract(),
"The LANDRegistry token address must be a deployed contract"
);
landRegistry = _landRegistry;
setDex(_dex);
allowToken(
address(_manaToken),
18,
true,
false,
address(0)
);
manaToken = _manaToken;
duration = _xPoints[_xPoints.length - 1];
require(duration > 24 * 60 * 60, "The duration should be greater than 1 day");
_setCurve(_xPoints, _yPoints);
setLandsLimitPerBid(_landsLimitPerBid);
setGasPriceLimit(_gasPriceLimit);
status = Status.created;
emit AuctionCreated(
msg.sender,
startTime,
duration,
initialPrice,
endPrice
);
}
function bid(
int[] _xs,
int[] _ys,
address _beneficiary,
ERC20 _fromToken
)
external
{
_validateBidParameters(
_xs,
_ys,
_beneficiary,
_fromToken
);
uint256 bidId = _getBidId();
uint256 bidPriceInMana = _xs.length.mul(getCurrentPrice());
uint256 manaAmountToBurn = bidPriceInMana;
if (address(_fromToken) != address(manaToken)) {
require(
address(dex).isContract(),
"Paying with other tokens has been disabled"
);
manaAmountToBurn = _convertSafe(bidId, _fromToken, bidPriceInMana);
} else {
require(
_fromToken.transferFrom(msg.sender, address(this), bidPriceInMana),
"Insuficient balance or unauthorized amount (transferFrom failed)"
);
}
_processFunds(bidId, _fromToken);
for (uint i = 0; i < _xs.length; i++) {
require(
-150 <= _xs[i] && _xs[i] <= 150 && -150 <= _ys[i] && _ys[i] <= 150,
"The coordinates should be inside bounds -150 & 150"
);
}
landRegistry.assignMultipleParcels(_xs, _ys, _beneficiary);
emit BidSuccessful(
bidId,
_beneficiary,
_fromToken,
getCurrentPrice(),
manaAmountToBurn,
_xs,
_ys
);
_updateStats(_xs.length, manaAmountToBurn);
}
function _validateBidParameters(
int[] _xs,
int[] _ys,
address _beneficiary,
ERC20 _fromToken
) internal view
{
require(startTime <= block.timestamp, "The auction has not started");
require(
status == Status.created &&
block.timestamp.sub(startTime) <= duration,
"The auction has finished"
);
require(tx.gasprice <= gasPriceLimit, "Gas price limit exceeded");
require(_beneficiary != address(0), "The beneficiary could not be the 0 address");
require(_xs.length > 0, "You should bid for at least one LAND");
require(_xs.length <= landsLimitPerBid, "LAND limit exceeded");
require(_xs.length == _ys.length, "X values length should be equal to Y values length");
require(tokensAllowed[address(_fromToken)].isAllowed, "Token not allowed");
}
function getCurrentPrice() public view returns (uint256) {
if (startTime == 0 || startTime >= block.timestamp) {
return initialPrice;
}
uint256 timePassed = block.timestamp - startTime;
if (timePassed >= duration) {
return endPrice;
}
return _getPrice(timePassed);
}
function _convertSafe(
uint256 _bidId,
ERC20 _fromToken,
uint256 _bidPriceInMana
) internal returns (uint256 requiredManaAmountToBurn)
{
requiredManaAmountToBurn = _bidPriceInMana;
Token memory fromToken = tokensAllowed[address(_fromToken)];
uint bidPriceInManaPlusSafetyMargin = _bidPriceInMana.mul(conversionFee).div(100);
uint256 tokenRate = getRate(manaToken, _fromToken, bidPriceInManaPlusSafetyMargin);
uint256 requiredTokenBalance = 0;
if (fromToken.shouldBurnTokens || fromToken.shouldForwardTokens) {
requiredTokenBalance = _calculateRequiredTokenBalance(requiredManaAmountToBurn, tokenRate);
requiredManaAmountToBurn = _calculateRequiredManaAmount(_bidPriceInMana);
}
uint256 tokensToConvertPlusSafetyMargin = bidPriceInManaPlusSafetyMargin
.mul(tokenRate)
.div(10 ** 18);
if (MAX_DECIMALS > fromToken.decimals) {
requiredTokenBalance = _normalizeDecimals(
fromToken.decimals,
requiredTokenBalance
);
tokensToConvertPlusSafetyMargin = _normalizeDecimals(
fromToken.decimals,
tokensToConvertPlusSafetyMargin
);
}
require(
_fromToken.transferFrom(msg.sender, address(this), tokensToConvertPlusSafetyMargin),
"Transfering the totalPrice in token to LANDAuction contract failed"
);
uint256 finalTokensToConvert = tokensToConvertPlusSafetyMargin.sub(requiredTokenBalance);
require(_fromToken.approve(address(dex), finalTokensToConvert), "Error approve");
uint256 change = dex.convert(
_fromToken,
manaToken,
finalTokensToConvert,
requiredManaAmountToBurn
);
if (change > 0) {
require(
_fromToken.transfer(msg.sender, change),
"Transfering the change to sender failed"
);
}
require(_fromToken.approve(address(dex), 0), "Error remove approval");
emit BidConversion(
_bidId,
address(_fromToken),
requiredManaAmountToBurn,
tokensToConvertPlusSafetyMargin.sub(change),
requiredTokenBalance
);
}
function getRate(
IERC20 _srcToken,
IERC20 _destToken,
uint256 _srcAmount
) public view returns (uint256 rate)
{
(, rate) = dex.getExpectedRate(_srcToken, _destToken, _srcAmount);
}
function _calculateRequiredTokenBalance(
uint256 _totalPrice,
uint256 _tokenRate
)
internal pure returns (uint256)
{
return _totalPrice.mul(_tokenRate)
.div(10 ** 18)
.mul(PERCENTAGE_OF_TOKEN_TO_KEEP)
.div(100);
}
function _calculateRequiredManaAmount(
uint256 _totalPrice
)
internal pure returns (uint256)
{
return _totalPrice.mul(100 - PERCENTAGE_OF_TOKEN_TO_KEEP).div(100);
}
function _processFunds(uint256 _bidId, ERC20 _token) internal {
_burnTokens(_bidId, manaToken);
Token memory token = tokensAllowed[address(_token)];
if (_token != manaToken) {
if (token.shouldBurnTokens) {
_burnTokens(_bidId, _token);
}
if (token.shouldForwardTokens) {
_forwardTokens(_bidId, token.forwardTarget, _token);
}
}
}
function _getPrice(uint256 _time) internal view returns (uint256) {
for (uint i = 0; i < curves.length; i++) {
Func memory func = curves[i];
if (_time < func.limit) {
return func.base.sub(func.slope.mul(_time));
}
}
revert("Invalid time");
}
function _burnTokens(uint256 _bidId, ERC20 _token) private {
uint256 balance = _token.balanceOf(address(this));
require(balance > 0, "Balance to burn should be > 0");
_token.burn(balance);
emit TokenBurned(_bidId, address(_token), balance);
balance = _token.balanceOf(address(this));
require(balance == 0, "Burn token failed");
}
function _forwardTokens(uint256 _bidId, address _address, ERC20 _token) private {
uint256 balance = _token.balanceOf(address(this));
require(balance > 0, "Balance to burn should be > 0");
_token.transfer(_address, balance);
emit TokenTransferred(
_bidId,
address(_token),
_address,balance
);
balance = _token.balanceOf(address(this));
require(balance == 0, "Transfer token failed");
}
function setConversionFee(uint256 _fee) external onlyOwner {
require(_fee < 200 && _fee >= 100, "Conversion fee should be >= 100 and < 200");
emit ConversionFeeChanged(msg.sender, conversionFee, _fee);
conversionFee = _fee;
}
function finishAuction() public onlyOwner {
require(status != Status.finished, "The auction is finished");
uint256 currentPrice = getCurrentPrice();
status = Status.finished;
endTime = block.timestamp;
emit AuctionFinished(msg.sender, block.timestamp, currentPrice);
}
function setLandsLimitPerBid(uint256 _landsLimitPerBid) public onlyOwner {
require(_landsLimitPerBid > 0, "The LAND limit should be greater than 0");
emit LandsLimitPerBidChanged(msg.sender, landsLimitPerBid, _landsLimitPerBid);
landsLimitPerBid = _landsLimitPerBid;
}
function setGasPriceLimit(uint256 _gasPriceLimit) public onlyOwner {
require(_gasPriceLimit > 0, "The gas price should be greater than 0");
emit GasPriceLimitChanged(msg.sender, gasPriceLimit, _gasPriceLimit);
gasPriceLimit = _gasPriceLimit;
}
function setDex(address _dex) public onlyOwner {
require(_dex != address(dex), "The dex is the current");
if (_dex != address(0)) {
require(_dex.isContract(), "The dex address must be a deployed contract");
}
emit DexChanged(msg.sender, dex, _dex);
dex = ITokenConverter(_dex);
}
function allowToken(
address _address,
uint256 _decimals,
bool _shouldBurnTokens,
bool _shouldForwardTokens,
address _forwardTarget
)
public onlyOwner
{
require(
_address.isContract(),
"Tokens allowed should be a deployed ERC20 contract"
);
require(
_decimals > 0 && _decimals <= MAX_DECIMALS,
"Decimals should be greather than 0 and less or equal to 18"
);
require(
!(_shouldBurnTokens && _shouldForwardTokens),
"The token should be either burned or transferred"
);
require(
!_shouldForwardTokens ||
(_shouldForwardTokens && _forwardTarget.isContract()),
"The token should be transferred to a deployed contract"
);
require(!tokensAllowed[_address].isAllowed, "The ERC20 token is already allowed");
tokensAllowed[_address] = Token({
decimals: _decimals,
shouldBurnTokens: _shouldBurnTokens,
shouldForwardTokens: _shouldForwardTokens,
forwardTarget: _forwardTarget,
isAllowed: true
});
emit TokenAllowed(
msg.sender,
_address,
_decimals,
_shouldBurnTokens,
_shouldForwardTokens,
_forwardTarget
);
}
function disableToken(address _address) public onlyOwner {
require(
tokensAllowed[_address].isAllowed,
"The ERC20 token is already disabled"
);
delete tokensAllowed[_address];
emit TokenDisabled(msg.sender, _address);
}
function _setCurve(uint256[] _xPoints, uint256[] _yPoints) internal {
uint256 pointsLength = _xPoints.length;
require(pointsLength == _yPoints.length, "Points should have the same length");
for (uint i = 0; i < pointsLength - 1; i++) {
uint256 x1 = _xPoints[i];
uint256 x2 = _xPoints[i + 1];
uint256 y1 = _yPoints[i];
uint256 y2 = _yPoints[i + 1];
require(x1 < x2, "X points should increase");
require(y1 > y2, "Y points should decrease");
(uint256 base, uint256 slope) = _getFunc(
x1,
x2,
y1,
y2
);
curves.push(Func({
base: base,
slope: slope,
limit: x2
}));
}
initialPrice = _yPoints[0];
endPrice = _yPoints[pointsLength - 1];
}
function _getFunc(
uint256 _x1,
uint256 _x2,
uint256 _y1,
uint256 _y2
) internal pure returns (uint256 base, uint256 slope)
{
base = ((_x2.mul(_y1)).sub(_x1.mul(_y2))).div(_x2.sub(_x1));
slope = (_y1.sub(_y2)).div(_x2.sub(_x1));
}
function _getBidId() private view returns (uint256) {
return totalBids;
}
function _normalizeDecimals(
uint256 _decimals,
uint256 _value
)
internal pure returns (uint256 _result)
{
_result = _value.div(10**MAX_DECIMALS.sub(_decimals));
}
function _updateStats(uint256 _landsBidded, uint256 _manaAmountBurned) private {
totalBids = totalBids.add(1);
totalLandsBidded = totalLandsBidded.add(_landsBidded);
totalManaBurned = totalManaBurned.add(_manaAmountBurned);
}
} | 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 = 30585600;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0x991CEa6B0D45C848d8E17289F16B3caE0DB46a63;
}
function tokenBalance() constant public returns (uint256){
return token_reward.balanceOf(this);
}
function lock() public onlyOwner returns (bool){
require(!isLocked);
require(tokenBalance() > 0);
start_time = now;
end_time = start_time.add(fifty_two_weeks);
isLocked = true;
}
function lockOver() constant public returns (bool){
uint256 current_time = now;
return current_time > end_time;
}
function release() onlyOwner public{
require(isLocked);
require(!isReleased);
require(lockOver());
uint256 token_amount = tokenBalance();
token_reward.transfer( beneficiary, token_amount);
emit TokenReleased(beneficiary, token_amount);
isReleased = true;
}
} | 0 |
pragma solidity 0.4.25;
contract Pantheon_2_0 {
struct UserRecord {
address referrer;
uint tokens;
uint gained_funds;
uint ref_funds;
int funds_correction;
}
using SafeMath for uint;
using SafeMathInt for int;
using Fee for Fee.fee;
using ToAddress for bytes;
string constant public name = "Pantheon 2 0";
string constant public symbol = "PAN";
uint8 constant public decimals = 18;
address admin = 0x93DC0798e8Da756CA94fCa9925863a4Ee8324071;
Fee.fee private fee_purchase = Fee.fee(1, 10);
Fee.fee private fee_selling = Fee.fee(1, 20);
Fee.fee private fee_transfer = Fee.fee(1, 100);
Fee.fee private fee_referral = Fee.fee(33, 100);
uint constant private minimal_stake = 10e18;
uint constant private precision_factor = 1e18;
uint private price = 1e29;
uint constant private price_offset = 1e28;
uint private total_supply = 0;
uint private shared_profit = 0;
mapping(address => UserRecord) private user_data;
modifier onlyValidTokenAmount(uint tokens) {
require(tokens > 0, "Amount of tokens must be greater than zero");
require(tokens <= user_data[msg.sender].tokens, "You have not enough tokens");
_;
}
function () public payable {
buy(msg.data.toAddr());
}
function buy(address referrer) public payable {
(uint fee_funds, uint taxed_funds) = fee_purchase.split(msg.value);
require(fee_funds != 0, "Incoming funds is too small");
UserRecord storage user = user_data[msg.sender];
if (referrer != 0x0 && referrer != msg.sender && user.referrer == 0x0) {
user.referrer = referrer;
}
if (user.referrer != 0x0) {
fee_funds = rewardReferrer(msg.sender, user.referrer, fee_funds, msg.value);
require(fee_funds != 0, "Incoming funds is too small");
}
(uint tokens, uint _price) = fundsToTokens(taxed_funds);
require(tokens != 0, "Incoming funds is too small");
price = _price;
mintTokens(msg.sender, tokens);
shared_profit = shared_profit.add(fee_funds);
emit Purchase(msg.sender, msg.value, tokens, price / precision_factor, now);
}
function sell(uint tokens) public onlyValidTokenAmount(tokens) {
(uint funds, uint _price) = tokensToFunds(tokens);
require(funds != 0, "Insufficient tokens to do that");
price = _price;
(uint fee_funds, uint taxed_funds) = fee_selling.split(funds);
require(fee_funds != 0, "Insufficient tokens to do that");
burnTokens(msg.sender, tokens);
UserRecord storage user = user_data[msg.sender];
user.gained_funds = user.gained_funds.add(taxed_funds);
shared_profit = shared_profit.add(fee_funds);
emit Selling(msg.sender, tokens, funds, price / precision_factor, now);
}
function transfer(address to_addr, uint tokens) public onlyValidTokenAmount(tokens) returns (bool success) {
require(to_addr != msg.sender, "You cannot transfer tokens to yourself");
(uint fee_tokens, uint taxed_tokens) = fee_transfer.split(tokens);
require(fee_tokens != 0, "Insufficient tokens to do that");
(uint funds, uint _price) = tokensToFunds(fee_tokens);
require(funds != 0, "Insufficient tokens to do that");
price = _price;
burnTokens(msg.sender, tokens);
mintTokens(to_addr, taxed_tokens);
shared_profit = shared_profit.add(funds);
emit Transfer(msg.sender, to_addr, tokens);
return true;
}
function reinvest() public {
uint funds = dividendsOf(msg.sender);
require(funds > 0, "You have no dividends");
UserRecord storage user = user_data[msg.sender];
user.funds_correction = user.funds_correction.add(int(funds));
(uint fee_funds, uint taxed_funds) = fee_purchase.split(funds);
require(fee_funds != 0, "Insufficient dividends to do that");
if (user.referrer != 0x0) {
fee_funds = rewardReferrer(msg.sender, user.referrer, fee_funds, funds);
require(fee_funds != 0, "Insufficient dividends to do that");
}
(uint tokens, uint _price) = fundsToTokens(taxed_funds);
require(tokens != 0, "Insufficient dividends to do that");
price = _price;
mintTokens(msg.sender, tokens);
shared_profit = shared_profit.add(fee_funds);
emit Reinvestment(msg.sender, funds, tokens, price / precision_factor, now);
}
function withdraw() public {
require(msg.sender == admin);
uint funds = dividendsOf(msg.sender);
require(funds > 0, "You have no dividends");
UserRecord storage user = user_data[msg.sender];
user.funds_correction = user.funds_correction.add(int(funds));
admin.transfer(address(this).balance);
emit Withdrawal(msg.sender, funds, now);
}
function exit() public {
uint tokens = user_data[msg.sender].tokens;
if (tokens > 0) {
sell(tokens);
}
withdraw();
}
function donate() public payable {
shared_profit = shared_profit.add(msg.value);
emit Donation(msg.sender, msg.value, now);
}
function totalSupply() public view returns (uint) {
return total_supply;
}
function balanceOf(address addr) public view returns (uint) {
return user_data[addr].tokens;
}
function dividendsOf(address addr) public view returns (uint) {
UserRecord memory user = user_data[addr];
int d = int(user.gained_funds.add(user.ref_funds));
require(d >= 0);
if (total_supply > 0) {
d = d.add(int(shared_profit.mul(user.tokens) / total_supply));
}
if (user.funds_correction > 0) {
d = d.sub(user.funds_correction);
}
else if (user.funds_correction < 0) {
d = d.add(-user.funds_correction);
}
require(d >= 0);
return uint(d);
}
function expectedTokens(uint funds, bool apply_fee) public view returns (uint) {
if (funds == 0) {
return 0;
}
if (apply_fee) {
(,uint _funds) = fee_purchase.split(funds);
funds = _funds;
}
(uint tokens,) = fundsToTokens(funds);
return tokens;
}
function expectedFunds(uint tokens, bool apply_fee) public view returns (uint) {
if (tokens == 0 || total_supply == 0) {
return 0;
}
else if (tokens > total_supply) {
tokens = total_supply;
}
(uint funds,) = tokensToFunds(tokens);
if (apply_fee) {
(,uint _funds) = fee_selling.split(funds);
funds = _funds;
}
return funds;
}
function buyPrice() public view returns (uint) {
return price / precision_factor;
}
function sellPrice() public view returns (uint) {
return price.sub(price_offset) / precision_factor;
}
function mintTokens(address addr, uint tokens) internal {
UserRecord storage user = user_data[addr];
bool not_first_minting = total_supply > 0;
if (not_first_minting) {
shared_profit = shared_profit.mul(total_supply.add(tokens)) / total_supply;
}
total_supply = total_supply.add(tokens);
user.tokens = user.tokens.add(tokens);
if (not_first_minting) {
user.funds_correction = user.funds_correction.add(int(tokens.mul(shared_profit) / total_supply));
}
}
function burnTokens(address addr, uint tokens) internal {
UserRecord storage user = user_data[addr];
uint dividends_from_tokens = 0;
if (total_supply == tokens) {
dividends_from_tokens = shared_profit.mul(user.tokens) / total_supply;
}
shared_profit = shared_profit.mul(total_supply.sub(tokens)) / total_supply;
total_supply = total_supply.sub(tokens);
user.tokens = user.tokens.sub(tokens);
if (total_supply > 0) {
user.funds_correction = user.funds_correction.sub(int(tokens.mul(shared_profit) / total_supply));
}
else if (dividends_from_tokens != 0) {
user.funds_correction = user.funds_correction.sub(int(dividends_from_tokens));
}
}
function rewardReferrer(address addr, address referrer_addr, uint funds, uint full_funds) internal returns (uint funds_after_reward) {
UserRecord storage referrer = user_data[referrer_addr];
if (referrer.tokens >= minimal_stake) {
(uint reward_funds, uint taxed_funds) = fee_referral.split(funds);
referrer.ref_funds = referrer.ref_funds.add(reward_funds);
emit ReferralReward(addr, referrer_addr, full_funds, reward_funds, now);
return taxed_funds;
}
else {
return funds;
}
}
function fundsToTokens(uint funds) internal view returns (uint tokens, uint _price) {
uint b = price.mul(2).sub(price_offset);
uint D = b.mul(b).add(price_offset.mul(8).mul(funds).mul(precision_factor));
uint n = D.sqrt().sub(b).mul(precision_factor) / price_offset.mul(2);
uint anp1 = price.add(price_offset.mul(n) / precision_factor);
return (n, anp1);
}
function tokensToFunds(uint tokens) internal view returns (uint funds, uint _price) {
uint sell_price = price.sub(price_offset);
uint an = sell_price.add(price_offset).sub(price_offset.mul(tokens) / precision_factor);
uint sn = sell_price.add(an).mul(tokens) / precision_factor.mul(2);
return (sn / precision_factor, an);
}
event Purchase(address indexed addr, uint funds, uint tokens, uint price, uint time);
event Selling(address indexed addr, uint tokens, uint funds, uint price, uint time);
event Reinvestment(address indexed addr, uint funds, uint tokens, uint price, uint time);
event Withdrawal(address indexed addr, uint funds, uint time);
event Donation(address indexed addr, uint funds, uint time);
event ReferralReward(address indexed referral_addr, address indexed referrer_addr, uint funds, uint reward_funds, uint time);
event Transfer(address indexed from_addr, address indexed to_addr, uint tokens);
}
library SafeMath {
function mul(uint a, uint b) internal pure returns (uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
require(c / a == b, "mul failed");
return c;
}
function sub(uint a, uint b) internal pure returns (uint) {
require(b <= a, "sub failed");
return a - b;
}
function add(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
require(c >= a, "add failed");
return c;
}
function sqrt(uint x) internal pure returns (uint y) {
uint z = add(x, 1) / 2;
y = x;
while (z < y) {
y = z;
z = add(x / z, z) / 2;
}
}
}
library SafeMathInt {
function sub(int a, int b) internal pure returns (int) {
int c = a - b;
require(c <= a, "sub failed");
return c;
}
function add(int a, int b) internal pure returns (int) {
int c = a + b;
require(c >= a, "add failed");
return c;
}
}
library Fee {
using SafeMath for uint;
struct fee {
uint num;
uint den;
}
function split(fee memory f, uint value) internal pure returns (uint tax, uint taxed_value) {
if (value == 0) {
return (0, 0);
}
tax = value.mul(f.num) / f.den;
taxed_value = value.sub(tax);
}
function get_tax(fee memory f, uint value) internal pure returns (uint tax) {
if (value == 0) {
return 0;
}
tax = value.mul(f.num) / f.den;
}
}
library ToAddress {
function toAddr(bytes source) internal pure returns (address addr) {
assembly {
addr := mload(add(source, 0x14))
}
return addr;
}
} | 1 |
pragma solidity ^0.4.18;
contract SafeMath {
function mulSafe(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function divSafe(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function subSafe(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function addSafe(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
function Constructor() public { owner = msg.sender; }
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
contract ERC20 {
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);
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 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 StandardToken is ERC20, ERC223, SafeMath, Owned {
event ReleaseSupply(address indexed receiver, uint256 value, uint256 releaseTime);
mapping(address => uint256) balances;
mapping (address => mapping (address => uint256)) internal allowed;
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = subSafe(balances[msg.sender], _value);
balances[_to] = addSafe(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] = subSafe(balances[_from], _value);
balances[_to] = addSafe(balances[_to], _value);
allowed[_from][msg.sender] = subSafe(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] = addSafe(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] = subSafe(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] = subSafe(balances[msg.sender], _value);
balances[_to] = addSafe(balances[_to], _value);
Transfer(msg.sender, _to, _value, _data);
}
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
length := extcodesize(_addr)
}
return (length>0);
}
}
contract TBXToken is StandardToken {
string public name = 'TBXToken';
string public symbol = 'TBX';
uint public decimals = 8;
uint256 public createTime = 1527782400;
uint256 firstAnnual = 1559318400;
uint256 secondAnnual = 1590940800;
uint256 thirdAnnual = 1622476800;
uint256 public INITIAL_SUPPLY = 1000000000;
uint256 public frozenForever = 400000000;
uint256 firstAnnualReleasedAmount = 150000000;
uint256 secondAnnualReleasedAmount= 150000000;
uint256 thirdAnnualReleasedAmount = 100000000;
function TBXToken() public {
totalSupply = 200000000 * 10 ** uint256(decimals);
balances[msg.sender] = totalSupply;
}
function releaseSupply() public onlyOwner returns(uint256 _actualRelease) {
uint256 releaseAmount = getReleaseAmount();
require(releaseAmount > 0);
balances[owner] = addSafe(balances[owner], releaseAmount);
transfer(owner,releaseAmount);
totalSupply = addSafe(totalSupply, releaseAmount);
Transfer(address(0), msg.sender, releaseAmount);
return releaseAmount;
}
function getReleaseAmount() internal returns(uint256 _actualRelease) {
uint256 _amountToRelease;
if ( now >= firstAnnual
&& now < secondAnnual
&& firstAnnualReleasedAmount > 0) {
_amountToRelease = firstAnnualReleasedAmount * 10 ** uint256(decimals);
firstAnnualReleasedAmount = 0;
} else if ( now >= secondAnnual
&& now < thirdAnnual
&& secondAnnualReleasedAmount > 0) {
_amountToRelease = secondAnnualReleasedAmount * 10 ** uint256(decimals);
secondAnnualReleasedAmount = 0;
} else if ( now >= thirdAnnual
&& thirdAnnualReleasedAmount > 0) {
_amountToRelease = thirdAnnualReleasedAmount * 10 ** uint256(decimals);
thirdAnnualReleasedAmount = 0;
} else {
_amountToRelease = 0;
}
return _amountToRelease;
}
} | 0 |
pragma solidity ^0.4.19;
contract BANK_SAFE
{
mapping (address=>uint256) public balances;
uint public MinSum;
LogFile Log;
bool intitalized;
function SetMinSum(uint _val)
public
{
if(intitalized)throw;
MinSum = _val;
}
function SetLogFile(address _log)
public
{
if(intitalized)throw;
Log = LogFile(_log);
}
function Initialized()
public
{
intitalized = true;
}
function Deposit()
public
payable
{
balances[msg.sender]+= msg.value;
Log.AddMessage(msg.sender,msg.value,"Put");
}
function Collect(uint _am)
public
payable
{
if(balances[msg.sender]>=MinSum && balances[msg.sender]>=_am)
{
if(msg.sender.call.value(_am)())
{
balances[msg.sender]-=_am;
Log.AddMessage(msg.sender,_am,"Collect");
}
}
}
function()
public
payable
{
Deposit();
}
}
contract LogFile
{
struct Message
{
address Sender;
string Data;
uint Val;
uint Time;
}
Message[] public History;
Message LastMsg;
function AddMessage(address _adr,uint _val,string _data)
public
{
LastMsg.Sender = _adr;
LastMsg.Time = now;
LastMsg.Val = _val;
LastMsg.Data = _data;
History.push(LastMsg);
}
} | 0 |