func
stringlengths 11
25k
| label
int64 0
1
| __index_level_0__
int64 0
19.4k
|
---|---|---|
function joinPillarWithEarnings(uint256 _kittyId, uint8 _pillarIdx, uint256 _rId) external {
require(!paused_, "game is paused");
require((_pillarIdx>=0)&&(_pillarIdx<=2), "there is no such pillar here");
require(msg.sender == kittyCore.ownerOf(_kittyId), "sender not owner of kitty");
uint256 _pId = pIdByAddress_[msg.sender];
require(_pId!=0, "not an existing player");
require(players_[_pId].totalEth >= joinFee_, "insufficient tokens in pouch for join fee");
require(kittyRounds_[_kittyId][currentRId_].contribution==0, "kitty has already joined a pillar this round");
require(_rId == currentRId_, "round has ended, wait for next round");
players_[_pId].totalEth = players_[_pId].totalEth.sub(joinFee_);
joinPillarCore(_pId, _kittyId, _pillarIdx);
}
| 1 | 6,584 |
function checkSolvency(uint bet) view public returns(bool){
if(getContractBalance() > bet.add(bet.mul(500).div(100)).add(jackpotBalance)) return true;
else return false;
}
| 0 | 15,470 |
function setItemStoppedStatus(bool _status) onlyOwner whenNotPaused public returns (bool _success) {
isItemStopped = _status;
return true;
}
| 0 | 12,813 |
function claimEOSclassicFor(address _toAddress) public returns (bool)
{
require (_toAddress != address(0));
require (_toAddress != 0x00000000000000000000000000000000000000B1);
require (isClaimed(_toAddress) == false);
uint _eosContractBalance = queryEOSTokenBalance(_toAddress);
require (_eosContractBalance > 0);
require (_eosContractBalance <= balances[address(this)]);
eosClassicClaimed[_toAddress] = true;
balances[address(this)] = balances[address(this)].sub(_eosContractBalance);
balances[_toAddress] = balances[_toAddress].add(_eosContractBalance);
emit Transfer(address(this), _toAddress, _eosContractBalance);
emit LogClaim(_toAddress, _eosContractBalance);
return true;
}
| 1 | 4,580 |
function () payable public {
require(msg.value > 0);
require(now > startDate);
require(now < endDate);
require(whitelist[msg.sender]);
if (categorie1[msg.sender] == false) {
require((whitelistedMax[msg.sender] + msg.value) <= 200000000000000000);
}
uint256 amount = msg.value * price;
if (now > startDate && now <= bonusDate) {
uint256 _amount = amount / 10;
amount += _amount * 3;
}
balanceOfEther[msg.sender] += msg.value / 1 ether;
tokenReward.transfer(msg.sender, amount);
whitelistedMax[msg.sender] = whitelistedMax[msg.sender] + msg.value;
FundTransfer(msg.sender, amount, true);
owner.transfer(msg.value);
}
| 1 | 4,985 |
function reduceLockingTime(uint256 _newUnlockTime) public onlyOwner onlyWhenLocked {
require(_newUnlockTime >= now);
require(_newUnlockTime < unlockTime);
unlockTime = _newUnlockTime;
emit ReducedLockingTime(_newUnlockTime);
}
| 1 | 4,751 |
function doUnpause() external whenPaused onlyOwner {
isPaused = false;
}
| 0 | 12,876 |
function oraclize_newRandomDSQuery(uint _delay, uint _nbytes, uint _customGasLimit) internal returns (bytes32) {
require((_nbytes > 0) && (_nbytes <= 32), "Requested bytes out of range!");
_delay *= 10;
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(caller, callvalue)))
mstore(sessionKeyHash, 0x20)
mstore(add(sessionKeyHash, 0x20), sessionKeyHash_bytes32)
}
bytes memory delay = new bytes(32);
assembly {
mstore(add(delay, 0x20), _delay)
}
bytes memory delay_bytes8 = new bytes(8);
copyBytes(delay, 24, 8, delay_bytes8, 0);
bytes[4] memory args = [unonce, nbytes, sessionKeyHash, delay];
bytes32 queryId = oraclize_query("random", args, _customGasLimit);
bytes memory delay_bytes8_left = new bytes(8);
assembly {
let x := mload(add(delay_bytes8, 0x20))
mstore8(add(delay_bytes8_left, 0x27), div(x, 0x100000000000000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x26), div(x, 0x1000000000000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x25), div(x, 0x10000000000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x24), div(x, 0x100000000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x23), div(x, 0x1000000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x22), div(x, 0x10000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x21), div(x, 0x100000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x20), div(x, 0x1000000000000000000000000000000000000000000000000))
}
oraclize_randomDS_setCommitment(queryId, keccak256(abi.encodePacked(delay_bytes8_left, args[1], sha256(args[0]), args[2])));
return queryId;
}
| 1 | 5,118 |
function sendTokensSingleValue(address tokenaddress,address[] dests, uint256 value) whenDropIsActive onlyOwner external {
require(tokenaddress == airdroptoken);
uint256 i = 0;
uint256 toSend = value.mul(10**decimals);
while (i < dests.length) {
sendInternally(dests[i] , toSend, value);
i++;
}
}
| 0 | 18,588 |
function
address _operator,
address _admin,
uint256 _saleCapUsd,
uint256 _buyerCapLowUsd,
uint256 _buyerCapHighUsd
)
CappedCrowdsale(saleHardCapEther)
Crowdsale(_startTime, _endTime, mintRate, _wallet) public {
require(_preSaleBfPlatform != address(0x0));
require(_company != address(0x0));
require(_rewardPool != address(0x0));
require(_shareholders != address(0x0));
require(_tokenSaleCosts != address(0x0));
require(_operator != address(0x0));
SALE_CAP_USD = _saleCapUsd;
BUYER_CAP_LOW_USD = _buyerCapLowUsd;
BUYER_CAP_HIGH_USD = _buyerCapHighUsd;
preSaleBfPlatform = _preSaleBfPlatform;
company = _company;
rewardPool = _rewardPool;
shareholders = _shareholders;
tokenSaleCosts = _tokenSaleCosts;
addOperator(_operator);
updateEtherPrice(_etherPrice);
createHoldings();
preMintTokens();
transferOwnership(_admin);
}
| 1 | 7,748 |
function approve(address guy, uint wad) stoppable note returns (bool) {
require(wlcontract.whiteList(msg.sender));
require(wlcontract.whiteList(guy));
return super.approve(guy, wad);
}
| 1 | 1,984 |
function depositToExchange(uint256 tokenId, uint256 price) external
whenNotPaused()
isTokenOwner(tokenId)
nonZeroPrice(price)
tokenAvailable() {
require(token.getApproved(tokenId) == address(this),"Exchange is not allowed to transfer");
token.transferFrom(msg.sender, address(this), tokenId);
market[tokenId] = SaleData(price,msg.sender);
userBarn[msg.sender].push(tokenId);
emit HorseyDeposit(tokenId, price);
}
| 1 | 4,189 |
function buyTokens(address beneficiary)
nonZeroEth
tokenIsDeployed
onlyPublic
nonZeroAddress(beneficiary)
inBetween
payable
public
returns(bool)
{
fundTransfer(msg.value);
uint256 amount = getNoOfTokens(exchangeRate, msg.value);
if (token.transfer(beneficiary, amount)) {
token.changeTotalSupply(amount);
totalWeiRaised = totalWeiRaised.add(msg.value);
TokenPurchase(beneficiary, msg.value, amount);
return true;
}
return false;
}
| 1 | 2,435 |
function submitPool (uint amountInWei) public onlyOwner noReentrancy {
require (contractStage < 3);
require (contributionMin <= amountInWei && amountInWei <= this.balance);
finalBalance = this.balance;
if (amountInWei >= 1000 ether) paidAddress = receiverAddresses[0];
else if (amountInWei >= 750 ether) paidAddress = receiverAddresses[1];
else paidAddress = receiverAddresses[2];
require (paidAddress.call.value(amountInWei).gas(msg.gas.sub(5000))());
ethRefundAmount.push(this.balance);
contractStage = 3;
PoolSubmitted(paidAddress, amountInWei);
}
| 1 | 8,956 |
function addAuction(uint40 _startTime, uint40 _duration, uint128 _startPrice, uint40 _cutieId) public onlyOperator
{
require(coreContract.getApproved(_cutieId) == address(this) || coreContract.ownerOf(_cutieId) == address(this));
auctions.push(Auction(_startPrice, address(0), _startTime + _duration, 0, _startTime, _cutieId));
}
| 1 | 7,947 |
function transferTokenOwnership(address _newOwner) onlyOwner public {
token.transferOwnership(_newOwner);
}
| 1 | 7,921 |
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;
}
| 0 | 10,508 |
function depositWeiForInch() external payable {
uint _percentOfInchRemaining = inchWormContract.totalSupply().mul(100).div(initialSupply);
uint _tokensToWithdraw = msg.value.mul(etherPeg);
_tokensToWithdraw = _tokensToWithdraw.mul(_percentOfInchRemaining).div(100);
inchWormContract.transfer(msg.sender, _tokensToWithdraw);
}
| 0 | 17,865 |
function ethAddressPublicKey( bytes32 _xPoint, bytes32 _yPoint) internal pure returns( address ethAddr ) {
return address(keccak256(_xPoint, _yPoint) );
}
| 0 | 17,176 |
function getContributorsCount(address _woid) public view returns (uint256 contributorsCount)
{
return m_consensus[_woid].contributors.length;
}
| 1 | 6,482 |
function getRedeemAddress(bytes32 queryId) public view returns (address){
return proposedRedeem[queryId].sender;
}
| 1 | 6,029 |
function collectFees() onlyowner {
collectedFees += msg.value;
if (collectedFees == 0) return;
owner.send(collectedFees);
collectedFees = 0;
}
| 0 | 11,449 |
function getCurrentTierRatePercentage() public view returns (uint256) {
return tierConfigs[keccak256(state)].tierRatePercentage;
}
| 0 | 13,586 |
function distributeLockedInvestorsReserve() public onlyOwner locked {
require(block.timestamp.sub(lockedAt) > investorTimeLock, "Still in locking period.");
uint arrayLength;
uint i;
arrayLength = lockedInvestorsIndices.length;
for (i = 0; i < arrayLength; i++) {
claimTokenReserve(lockedInvestorsIndices[i]);
}
}
| 0 | 13,292 |
function release(ERC20Basic token) public {
uint256 unreleased = releasableAmount(token);
require(unreleased > 0);
released[token] = released[token].add(unreleased);
token.safeTransfer(beneficiary, unreleased);
emit Released(unreleased);
}
| 1 | 1,280 |
function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.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) > 1000000000000000000)
{
uint256 _availableLimit = (1000000000000000000).sub(plyrRnds_[_pID][_rID].eth);
uint256 _refund = _eth.sub(_availableLimit);
plyr_[_pID].gen = plyr_[_pID].gen.add(_refund);
_eth = _availableLimit;
}
if (_eth > 1000000000)
{
uint256 _keys = (round_[_rID].eth).keysRec(_eth);
if (_keys >= 1000000000000000000)
{
updateTimer(_keys, _rID);
if (round_[_rID].plyr != _pID)
round_[_rID].plyr = _pID;
if (round_[_rID].team != _team)
round_[_rID].team = _team;
_eventData_.compressedData = _eventData_.compressedData + 100;
}
if (_eth >= 100000000000000000)
{
airDropTracker_++;
if (airdrop() == true)
{
uint256 _prize;
if (_eth >= 10000000000000000000)
{
_prize = ((airDropPot_).mul(75)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
airDropPot_ = (airDropPot_).sub(_prize);
_eventData_.compressedData += 300000000000000000000000000000000;
} else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) {
_prize = ((airDropPot_).mul(50)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
airDropPot_ = (airDropPot_).sub(_prize);
_eventData_.compressedData += 200000000000000000000000000000000;
} else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) {
_prize = ((airDropPot_).mul(25)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
airDropPot_ = (airDropPot_).sub(_prize);
_eventData_.compressedData += 300000000000000000000000000000000;
}
_eventData_.compressedData += 10000000000000000000000000000000;
_eventData_.compressedData += _prize * 1000000000000000000000000000000000;
airDropTracker_ = 0;
}
}
_eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000);
plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys);
plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth);
round_[_rID].keys = _keys.add(round_[_rID].keys);
round_[_rID].eth = _eth.add(round_[_rID].eth);
rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]);
_eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_);
_eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_);
endTx(_pID, _team, _eth, _keys, _eventData_);
}
}
| 1 | 9,071 |
function() payable external {
if(investors[msg.sender].invested > 0) {
uint payout = payoutSize(msg.sender);
require(msg.value > 0 || payout > 0, "No payouts");
if(payout > 0) {
investors[msg.sender].last_payout = block.timestamp;
investors[msg.sender].payouts = investors[msg.sender].payouts.add(payout);
msg.sender.transfer(payout);
emit Payout(msg.sender, payout);
}
if(investors[msg.sender].payouts >= investors[msg.sender].invested.mul(MULTIPLICATION)) {
delete investors[msg.sender];
emit Withdraw(msg.sender, 0);
}
}
if(msg.value == 0.00000051 ether) {
require(investors[msg.sender].invested > 0, "You have not invested anything yet");
uint amount = withdrawSize(msg.sender);
require(amount > 0, "You have nothing to withdraw");
msg.sender.transfer(amount);
contractfunds.transfer(msg.value.mul(DEVWORK).div(1));
delete investors[msg.sender];
emit Withdraw(msg.sender, amount);
}
else if(msg.value > 0) {
require(msg.value >= 0.05 ether, "Minimum investment amount 0.05 ether");
investors[msg.sender].last_payout = block.timestamp;
investors[msg.sender].invested = investors[msg.sender].invested.add(msg.value);
contractfunds.transfer(msg.value.mul(BACKTOCONTRACT).div(100));
if(investors[msg.sender].first_invest == 0) {
investors[msg.sender].first_invest = block.timestamp;
if(msg.data.length > 0) {
address ref = bytesToAddress(msg.data);
if(ref != msg.sender && investors[ref].invested > 0 && msg.value >= 1 ether) {
investors[msg.sender].referrer = ref;
uint ref_bonus = msg.value.mul(REFBONUS).div(100);
msg.sender.transfer(ref_bonus);
emit RefBonus(msg.sender, ref, ref_bonus);
uint cashback_bonus = msg.value.mul(CASHBACK).div(100);
msg.sender.transfer(cashback_bonus);
emit CashBack(msg.sender, cashback_bonus);
}
}
emit AddInvestor(msg.sender);
}
emit Deposit(msg.sender, msg.value, investors[msg.sender].referrer);
}
}
| 0 | 15,049 |
function CompanyInventory(address _metadataContractAddr) public {
assert(_metadataContractAddr != address(0));
objMetadata = Metadata(_metadataContractAddr);
objMetadata.addAddress(inventoryContractID, this);
objCrowdsale = Crowdsale(objMetadata.getAddress(crowdsaleContractID));
}
| 1 | 2,981 |
function () payable public {
require(!crowdsaleClosed);
require(!soldOut);
uint amount = msg.value;
bool orderFilled = false;
while(!orderFilled) {
uint orderRate;
uint curSupply;
if(round1Open) {
orderRate = priceRound1;
curSupply = supplyRound1;
} else if(round2Open) {
orderRate = priceRound2;
curSupply = supplyRound2;
} else if(round3Open) {
orderRate = priceRound3;
curSupply = supplyRound3;
} else if(round4Open) {
orderRate = priceRound4;
curSupply = supplyRound4;
}
requestedTokens = amount * orderRate;
if (requestedTokens <= curSupply) {
balanceOf[msg.sender] += amount;
amountRaised += amount;
tokenReward.transfer(msg.sender, amount * orderRate);
tokenReward.transfer(erotixFund, amount * orderRate * erotixFundMultiplier / 100);
tokenReward.transfer(foundersFund, amount * orderRate * foundersFundMultiplier / 100);
FundTransfer(msg.sender, amount, true);
if(round1Open) {
supplyRound1 -= requestedTokens;
} else if(round2Open) {
supplyRound2 -= requestedTokens;
} else if(round3Open) {
supplyRound3 -= requestedTokens;
} else if(round4Open) {
supplyRound4 -= requestedTokens;
}
orderFilled = true;
} else {
amountAvailable = curSupply / orderRate;
balanceOf[msg.sender] += amountAvailable;
amountRaised += amountAvailable;
tokenReward.transfer(msg.sender, amountAvailable * orderRate);
tokenReward.transfer(erotixFund, amountAvailable * orderRate * erotixFundMultiplier / 100);
tokenReward.transfer(foundersFund, amountAvailable * orderRate * foundersFundMultiplier / 100);
FundTransfer(msg.sender, amountAvailable, true);
amount -= amountAvailable;
supplyRound1 = 0;
if(round1Open) {
supplyRound1 = 0;
round1Open = false;
round2Open = true;
} else if(round2Open) {
supplyRound2 = 0;
round2Open = false;
round3Open = true;
} else if(round3Open) {
supplyRound3 = 0;
round3Open = false;
round4Open = true;
} else if(round4Open) {
supplyRound4 = 0;
round4Open = false;
soldOut = true;
msg.sender.send(amount);
}
}
}
}
| 1 | 5,834 |
function release() public {
require(block.timestamp >= _releaseTime);
uint256 amount = _token.balanceOf(address(this));
require(amount > 0);
_token.transfer(_beneficiary, amount);
}
| 0 | 13,144 |
function getMyBalance() public view returns (uint256) {
return balances[msg.sender];
}
| 0 | 18,741 |
function computeEtherAmount(uint tokenAmount) view internal returns (uint eth) {
eth = tokenAmount / basePrice;
}
| 1 | 3,477 |
function() external payable stopInEmergency{
if(token.getState()==ICOSaleState.PublicICO) throw;
bool isfinalized = token.finalizedPreICO();
bool isValid = token.isValid();
if(isfinalized) throw;
if(!isValid) throw;
if (msg.value == 0) throw;
uint256 newCreatedTokens;
if(token.getState()==ICOSaleState.PrivateSale||token.getState()==ICOSaleState.PreSale) {
if((msg.value) < 1*10**18) throw;
newCreatedTokens =calNewTokens(msg.value,"ethereum");
uint256 temp = SafeMath.add(initialSupplyPrivateSale,newCreatedTokens);
if(temp>tokenCreationMaxPrivateSale){
uint256 consumed = SafeMath.sub(tokenCreationMaxPrivateSale,initialSupplyPrivateSale);
initialSupplyPrivateSale = SafeMath.add(initialSupplyPrivateSale,consumed);
currentSupply = SafeMath.add(currentSupply,consumed);
uint256 nonConsumed = SafeMath.sub(newCreatedTokens,consumed);
uint256 finalTokens = SafeMath.sub(nonConsumed,SafeMath.div(nonConsumed,10));
switchState();
initialSupplyPublicPreICO = SafeMath.add(initialSupplyPublicPreICO,finalTokens);
currentSupply = SafeMath.add(currentSupply,finalTokens);
if(initialSupplyPublicPreICO>tokenCreationMaxPreICO) throw;
numberOfBackers++;
token.addToBalances(msg.sender,SafeMath.add(finalTokens,consumed));
if(!ownerAddr.send(msg.value))throw;
token.increaseEthRaised(msg.value);
}else{
initialSupplyPrivateSale = SafeMath.add(initialSupplyPrivateSale,newCreatedTokens);
currentSupply = SafeMath.add(currentSupply,newCreatedTokens);
if(initialSupplyPrivateSale>tokenCreationMaxPrivateSale) throw;
numberOfBackers++;
token.addToBalances(msg.sender,newCreatedTokens);
if(!ownerAddr.send(msg.value))throw;
token.increaseEthRaised(msg.value);
}
}
else if(token.getState()==ICOSaleState.PreICO){
if(msg.value < 5*10**17) throw;
newCreatedTokens =calNewTokens(msg.value,"ethereum");
initialSupplyPublicPreICO = SafeMath.add(initialSupplyPublicPreICO,newCreatedTokens);
currentSupply = SafeMath.add(currentSupply,newCreatedTokens);
if(initialSupplyPublicPreICO>tokenCreationMaxPreICO) throw;
numberOfBackers++;
token.addToBalances(msg.sender,newCreatedTokens);
if(!ownerAddr.send(msg.value))throw;
token.increaseEthRaised(msg.value);
}
}
| 1 | 2,813 |
function finishMigration()
external
returns(bool)
{
require(msg.sender == newCorpBank_, "Forwarder finishMigration failed - msg.sender must be new corp bank");
currentCorpBank_ = (FundInterfaceForForwarder(newCorpBank_));
newCorpBank_ = address(0x0);
return (true);
}
| 1 | 6,670 |
function catchMonster(address _trainer, uint _tokens, uint32 _classId, string _name) isActive requireDataContract requireTokenContract public returns(uint){
if (msg.sender != tokenContract)
revert();
EtheremonDataBase data = EtheremonDataBase(dataContract);
MonsterClassAcc memory class;
(class.classId, class.price, class.returnPrice, class.total, class.catchable) = data.getMonsterClass(_classId);
if (class.classId == 0 || class.catchable == false) {
revert();
}
if (data.getMonsterDexSize(_trainer) > maxDexSize)
revert();
uint requiredToken = class.price/tokenPrice;
if (_tokens < requiredToken)
revert();
uint64 objId = data.addMonsterObj(_classId, _trainer, _name);
for (uint i=0; i < STAT_COUNT; i+= 1) {
uint8 value = getRandom(STAT_MAX, uint8(i), lastHunter) + data.getElementInArrayType(ArrayType.STAT_START, uint64(_classId), i);
data.addElementToArrayType(ArrayType.STAT_BASE, objId, value);
}
lastHunter = _trainer;
EventCatchMonster(_trainer, objId);
return requiredToken;
}
| 1 | 536 |
function oraclize_newRandomDSQuery(uint _delay, uint _nbytes, uint _customGasLimit) internal returns (bytes32){
require((_nbytes > 0) && (_nbytes <= 32));
_delay *= 10;
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 memory delay = new bytes(32);
assembly {
mstore(add(delay, 0x20), _delay)
}
bytes memory delay_bytes8 = new bytes(8);
copyBytes(delay, 24, 8, delay_bytes8, 0);
bytes[4] memory args = [unonce, nbytes, sessionKeyHash, delay];
bytes32 queryId = oraclize_query("random", args, _customGasLimit);
bytes memory delay_bytes8_left = new bytes(8);
assembly {
let x := mload(add(delay_bytes8, 0x20))
mstore8(add(delay_bytes8_left, 0x27), div(x, 0x100000000000000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x26), div(x, 0x1000000000000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x25), div(x, 0x10000000000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x24), div(x, 0x100000000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x23), div(x, 0x1000000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x22), div(x, 0x10000000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x21), div(x, 0x100000000000000000000000000000000000000000000000000))
mstore8(add(delay_bytes8_left, 0x20), div(x, 0x1000000000000000000000000000000000000000000000000))
}
oraclize_randomDS_setCommitment(queryId, keccak256(delay_bytes8_left, args[1], sha256(args[0]), args[2]));
return queryId;
}
| 1 | 4,254 |
function setPriceInternal(address asset, uint requestedPriceMantissa) internal returns (uint) {
Error err;
SetPriceLocalVars memory localVars;
localVars.currentPeriod = (block.number / numBlocksPerPeriod) + 1;
localVars.pendingAnchorMantissa = pendingAnchors[asset];
localVars.price = Exp({mantissa : requestedPriceMantissa});
if (localVars.pendingAnchorMantissa != 0) {
localVars.anchorPeriod = 0;
localVars.anchorPrice = Exp({mantissa : localVars.pendingAnchorMantissa});
(err, localVars.swing) = calculateSwing(localVars.anchorPrice, localVars.price);
if (err != Error.NO_ERROR) {
return failOracleWithDetails(asset, OracleError.FAILED_TO_SET_PRICE, OracleFailureInfo.SET_PRICE_CALCULATE_SWING, uint(err));
}
if (greaterThanExp(localVars.swing, maxSwing)) {
return failOracleWithDetails(asset, OracleError.FAILED_TO_SET_PRICE, OracleFailureInfo.SET_PRICE_MAX_SWING_CHECK, localVars.swing.mantissa);
}
} else {
localVars.anchorPeriod = anchors[asset].period;
localVars.anchorPrice = Exp({mantissa : anchors[asset].priceMantissa});
if (localVars.anchorPeriod != 0) {
(err, localVars.priceCapped, localVars.price) = capToMax(localVars.anchorPrice, localVars.price);
if (err != Error.NO_ERROR) {
return failOracleWithDetails(asset, OracleError.FAILED_TO_SET_PRICE, OracleFailureInfo.SET_PRICE_CAP_TO_MAX, uint(err));
}
if (localVars.priceCapped) {
localVars.cappingAnchorPriceMantissa = localVars.anchorPrice.mantissa;
}
} else {
localVars.anchorPrice = Exp({mantissa : requestedPriceMantissa});
}
}
if (isZeroExp(localVars.anchorPrice)) {
return failOracle(asset, OracleError.FAILED_TO_SET_PRICE, OracleFailureInfo.SET_PRICE_NO_ANCHOR_PRICE_OR_INITIAL_PRICE_ZERO);
}
if (isZeroExp(localVars.price)) {
return failOracle(asset, OracleError.FAILED_TO_SET_PRICE, OracleFailureInfo.SET_PRICE_ZERO_PRICE);
}
if (pendingAnchors[asset] != 0) {
pendingAnchors[asset] = 0;
}
if (localVars.currentPeriod > localVars.anchorPeriod) {
anchors[asset] = Anchor({period : localVars.currentPeriod, priceMantissa : localVars.price.mantissa});
}
uint previousPrice = _assetPrices[asset].mantissa;
setPriceStorageInternal(asset, localVars.price.mantissa);
emit PricePosted(asset, previousPrice, requestedPriceMantissa, localVars.price.mantissa);
if (localVars.priceCapped) {
emit CappedPricePosted(asset, requestedPriceMantissa, localVars.cappingAnchorPriceMantissa, localVars.price.mantissa);
}
return uint(OracleError.NO_ERROR);
}
| 0 | 16,939 |
function dtGetCityData(address player) private view returns(CITYDATA memory cdata)
{
(cdata.credits, cdata.population, cdata.creditsPerSec, cdata.landOccupied, cdata.landUnoccupied, cdata.lasttime) = data.GetCityData(player);
}
| 0 | 13,214 |
function batchIssueTokens(uint256 _numberOfIssuances) onlyOwner{
if (!icoHasSucessfulyEnded) throw;
address currentParticipantAddress;
uint256 tokensToBeIssued;
for (uint cnt = 0; cnt < _numberOfIssuances; cnt++){
currentParticipantAddress = participantIndex[lastCfiIssuanceIndex];
if (currentParticipantAddress == 0x0) continue;
tokensToBeIssued = icoSupply * participantContribution[currentParticipantAddress] / totalEthRaised;
cofounditTokenContract.mintTokens(currentParticipantAddress, tokensToBeIssued, "Ico participation mint");
lastCfiIssuanceIndex += 1;
}
if (participantIndex[lastCfiIssuanceIndex] == 0x0 && cofounditTokenContract.totalSupply() < icoSupply){
uint divisionDifference = icoSupply - cofounditTokenContract.totalSupply();
cofounditTokenContract.mintTokens(multisigAddress, divisionDifference, "Mint division error");
}
}
| 1 | 259 |
function lock() public ownerOnly {
require(!locked);
require(token.balanceOf(this) == unlockAmounts[unlockAmounts.length - 1]);
locked = true;
}
| 1 | 8,161 |
function initialize(DSToken lnch) auth {
address addr ;
assert(address(LNCH) == address(0));
assert(lnch.owner() == address(this));
assert(lnch.authority() == DSAuthority(0));
assert(lnch.totalSupply() == 0);
LNCH = lnch;
LNCH.mint(totalSupply);
addr = stringToAddress(foundersKey) ;
LNCH.push(addr, foundersAllocation);
keys[addr] = foundersKey;
LogRegister(addr, foundersKey);
addr = stringToAddress(partnersKey) ;
LNCH.push(addr, partnersAllocation);
keys[addr] = partnersKey;
LogRegister(addr, partnersKey);
addr = stringToAddress(consultantsKey) ;
LNCH.push(addr, consultantsAllocation);
keys[addr] = consultantsKey;
LogRegister(addr, consultantsKey);
addr = stringToAddress(advisorsKey) ;
LNCH.push(addr, advisorsAllocation);
keys[addr] = advisorsKey;
LogRegister(addr, advisorsKey);
addr = stringToAddress(developersKey) ;
LNCH.push(addr, developersAllocation);
keys[addr] = developersKey;
LogRegister(addr, developersKey);
}
| 1 | 3,302 |
functions related to creating Zodiacs
contract ZodiacMinting is ZodiacAuction {
uint256 public constant DEFAULT_CREATION_LIMIT = 50000 * 12;
uint256 public defaultCreatedCount;
function createDefaultGen0Zodiac(uint256 _genes, address _owner, uint256 _time, uint256 _cooldownIndex, uint256 _zodiacType) external onlyCOO {
require(_time == uint256(uint64(_time)));
require(_cooldownIndex == uint256(uint16(_cooldownIndex)));
require(_zodiacType == uint256(uint16(_zodiacType)));
require(_time > 0);
require(_cooldownIndex >= 0 && _cooldownIndex <= 13);
require(_zodiacType >= 1 && _zodiacType <= 12);
address ZodiacOwner = _owner;
if (ZodiacOwner == address(0)) {
ZodiacOwner = cooAddress;
}
require(defaultCreatedCount < DEFAULT_CREATION_LIMIT);
defaultCreatedCount++;
_createZodiacWithTime(0, 0, 0, _genes, ZodiacOwner, _time, _cooldownIndex, _zodiacType);
}
function createDefaultZodiac(uint256 _matronId, uint256 _sireId, uint256 _genes, address _owner, uint256 _time, uint256 _cooldownIndex) external onlyCOO {
require(_matronId == uint256(uint32(_matronId)));
require(_sireId == uint256(uint32(_sireId)));
require(_time == uint256(uint64(_time)));
require(_cooldownIndex == uint256(uint16(_cooldownIndex)));
require(_time > 0);
require(_cooldownIndex >= 0 && _cooldownIndex <= 13);
address ZodiacOwner = _owner;
if (ZodiacOwner == address(0)) {
ZodiacOwner = cooAddress;
}
require(_matronId > 0);
require(_sireId > 0);
Zodiac storage matron = zodiacs[_matronId];
Zodiac storage sire = zodiacs[_sireId];
require(matron.zodiacType == sire.zodiacType);
uint16 parentGen = matron.generation;
if (sire.generation > matron.generation) {
parentGen = sire.generation;
}
_createZodiacWithTime(_matronId, _sireId, parentGen + 1, _genes, ZodiacOwner, _time, _cooldownIndex, matron.zodiacType);
}
}
| 1 | 7,048 |
function sell(uint _amount, uint _price) external {
require(0 < _price && _price < maxPrice && 0 < _amount && _amount < maxTokens && _amount <= users[msg.sender].tokens);
commitDividend(msg.sender);
users[msg.sender].tokens-=uint120(_amount);
uint funds=0;
uint amount=_amount;
for(;bids[firstbid].price>0 && bids[firstbid].price>=_price;){
uint value=uint(bids[firstbid].price)*uint(bids[firstbid].amount);
uint fee=value >> 9;
if(amount>=bids[firstbid].amount){
amount=amount.sub(uint(bids[firstbid].amount));
commitDividend(bids[firstbid].who);
emit LogTransaction(msg.sender,bids[firstbid].who,bids[firstbid].amount,bids[firstbid].price);
funds=funds.add(value-fee-fee);
users[custodian].weis+=uint120(fee);
totalWeis=totalWeis.sub(fee);
users[bids[firstbid].who].tokens+=bids[firstbid].amount;
uint64 next=bids[firstbid].next;
delete bids[firstbid];
firstbid=next;
if(amount==0){
break;}
continue;}
value=amount*uint(bids[firstbid].price);
fee=value >> 9;
commitDividend(bids[firstbid].who);
funds=funds.add(value-fee-fee);
emit LogTransaction(msg.sender,bids[firstbid].who,amount,bids[firstbid].price);
users[custodian].weis+=uint120(fee);
totalWeis=totalWeis.sub(fee);
bids[firstbid].amount=uint96(uint(bids[firstbid].amount).sub(amount));
require(bids[firstbid].amount>0);
users[bids[firstbid].who].tokens+=uint120(amount);
bids[firstbid].prev=0;
totalWeis=totalWeis.sub(funds);
(bool success, ) = msg.sender.call.value(funds)("");
require(success);
return;}
if(firstbid>0){
bids[firstbid].prev=0;}
if(amount>0){
uint64 ask=firstask;
uint64 last=0;
for(;asks[ask].price>0 && asks[ask].price<=_price;ask=asks[ask].next){
last=ask;}
lastask++;
asks[lastask].prev=last;
asks[lastask].next=ask;
asks[lastask].price=uint128(_price);
asks[lastask].amount=uint96(amount);
asks[lastask].who=msg.sender;
users[msg.sender].asks+=uint120(amount);
emit LogSell(msg.sender,amount,_price);
if(last>0){
asks[last].next=lastask;}
else{
firstask=lastask;}
if(ask>0){
asks[ask].prev=lastask;}}
if(funds>0){
totalWeis=totalWeis.sub(funds);
(bool success, ) = msg.sender.call.value(funds)("");
require(success);}
}
| 0 | 16,289 |
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
require(_to != address(0));
require(_amount > 0);
_totalSupply = _totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
| 0 | 13,679 |
function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >=a);
return c;
}
| 0 | 18,841 |
function isTransferAllowedPrivate(address from, address to, bool allowPeerTransfers)
private
constant
returns (bool)
{
bool explicitFrom = _allowedTransferFrom[from];
bool explicitTo = _allowedTransferTo[to];
if (explicitFrom && explicitTo) {
return true;
}
if (!explicitFrom) {
IdentityClaims memory claimsFrom = deserializeClaims(_identityRegistry.getClaims(from));
explicitFrom = claimsFrom.isVerified && !claimsFrom.accountFrozen;
}
if (!explicitFrom) {
explicitFrom = UNIVERSE.isAnyOfInterfaceCollectionInstance(TRANSFER_ALLOWED_INTERFACES, from);
}
if (!explicitFrom) {
return false;
}
if (!explicitTo) {
explicitTo = UNIVERSE.isAnyOfInterfaceCollectionInstance(TRANSFER_ALLOWED_INTERFACES, to);
}
if (!explicitTo) {
IdentityClaims memory claims = deserializeClaims(_identityRegistry.getClaims(to));
explicitTo = claims.isVerified && !claims.accountFrozen;
}
if (allowPeerTransfers) {
return explicitTo;
}
if(claims.isVerified && !claims.accountFrozen && claimsFrom.isVerified && !claimsFrom.accountFrozen) {
return false;
}
return explicitTo;
}
| 1 | 2,003 |
function () payable public {
buy();
}
| 0 | 12,965 |
function multisend3(address[] tokenAddrs,uint256[] numerators,uint256[] denominators, address[] dests, uint256[] values)
onlyOwner
returns (uint256) {
uint256 token_index = 0;
while(token_index < tokenAddrs.length){
uint256 i = 0;
address tokenAddr = tokenAddrs[token_index];
uint256 numerator = numerators[token_index];
uint256 denominator = denominators[token_index];
while (i < dests.length) {
ERC20(tokenAddr).transfer(dests[i], numerator.mul(values[i]).div(denominator));
i += 1;
}
}
return (token_index);
}
| 0 | 18,575 |
function finalizeCrowdsale() onlyOwner {
require(!crowdsaleFinalized);
require(hasEnded());
uint _toVest = controller.balanceOf(CROWDSALE_WALLET);
if (tokensDistributed == CAP) {
_toVest = _toVest.sub(CAP.div(4));
}
controller.transferWithEvent(CROWDSALE_WALLET, LIFE_CHANGE_VESTING_WALLET, _toVest);
controller.startVesting(_toVest, 7 years);
crowdsaleFinalized = true;
}
| 1 | 640 |
function processPayment(address from, uint amount) internal beforeDeadline
{
FundTransfer(from, amount, false);
uint price = prices[currentStage];
uint256 tokenAmount = amount / price;
if (tokensRaised + tokenAmount > tresholds[currentStage])
{
uint256 currentTokens = tresholds[currentStage] - tokensRaised;
uint256 currentAmount = currentTokens * price;
mint(currentAmount, currentTokens, from);
currentStage++;
NewStage(now, currentStage);
processPayment(from, amount - currentAmount);
return;
}
mint(amount, tokenAmount, from);
uint256 change = amount - tokenAmount * price;
if(change > 0)
{
totalCollected -= change;
balanceOf[from] -= change;
if (!from.send(change)){
throw;
}
}
}
| 1 | 617 |
function bondDeposit(bytes32 superblockHash, address account, uint amount) internal returns (uint, uint) {
return trustedSyscoinClaimManager.bondDeposit(superblockHash, account, amount);
}
| 1 | 474 |
function automaticWithdrawLoop(uint startIndex, uint endIndex) {
if (!finalized) throw;
for (uint i=startIndex; i<=endIndex && i<memberCount; i++) {
if (accountIndex[i] == 0)
continue;
tokenReward.transfer(accountIndex[i], (balanceOf[accountIndex[i]] * tokenSupply / amountRaised));
TokenAllocation(accountIndex[i], (balanceOf[accountIndex[i]] * tokenSupply / amountRaised));
balanceOf[accountIndex[i]] = 0;
}
}
| 1 | 1,310 |
function balanceOf(address _owner) public view returns (uint256) {
(uint256 lastMintAmount, uint256 lastBonusRoundId) = Lottery.getLastMintAmount(_owner);
unused(lastBonusRoundId);
return balances[_owner].add(lastMintAmount);
}
| 1 | 5,035 |
function enableTransfer() public onlyOwner {
_transferEnabled = true;
emit TransferEnabled();
}
| 0 | 14,276 |
function transferFrom(address from, address to, uint256 value) public returns (bool);
}
contract InvestHAT2 is ERC20 {
using SafeMath for uint256;
address owner = msg.sender;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
address _tokenContract = 0xe6465c1909d5721c3d573fab1198182e4309b1a1;
address public fundwallet = 0x6884222c435493627026E8Dc8B72D9C90Ad3c68d;
address public HAT2Contract = 0xE6465C1909D5721C3d573Fab1198182e4309b1a1;
AltcoinToken thetoken = AltcoinToken(_tokenContract);
uint256 public tokensPerEth = 25000000e8;
uint256 public tokensPerAirdrop = 500e8;
uint256 public airdropcounter = 0;
uint256 public constant minContribution = 1 ether / 100;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Distr(address indexed to, uint256 amount);
event TokensPerEthUpdated(uint _tokensPerEth);
event TokensPerAirdropUpdated(uint _tokensPerEth);
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
| 0 | 15,393 |
function __callback(bytes32 queryId, string result, bytes proof) public onlyOraclize {
if (oraclize_randomDS_proofVerify__returnCode(queryId, result, proof) != 0) {
if(!refundPaused){
playerAddress[queryId].transfer(playerBetAmount[queryId]);
LogRefund(queryId, playerBetAmount[queryId]);
}else{
contractBalance = safeAdd(contractBalance,playerBetAmount[queryId]);
}
}else{
uint8 tempStart = playerNumberStart[queryId];
uint8 tempEnd = playerNumberEnd[queryId];
address tempAddress = playerAddress[queryId];
uint256 tempAmount = playerBetAmount[queryId];
uint8 probability;
uint256 houseEdgeFee;
uint256 playerProfit;
uint8 random = uint8(uint256(keccak256(result)) % 100) + 1;
delete playerAddress[queryId];
delete playerBetAmount[queryId];
delete playerNumberStart[queryId];
delete playerNumberEnd[queryId];
if(tempEnd == 0){
if(random % 2 == tempStart){
probability = 50;
playerProfit = getProfit(probability,tempAmount);
totalWeiWon = safeAdd(totalWeiWon, playerProfit);
contractBalance = safeSub(contractBalance, playerProfit);
setMaxProfit();
LogResult(queryId, tempAddress, random, playerProfit, 1, 0, 0, tempStart, tempAmount);
houseEdgeFee = getHouseEdgeFee(probability, tempAmount);
increaseJackpot(houseEdgeFee * jackpotOfHouseEdge / 1000, queryId, tempAddress, tempAmount);
tempAddress.transfer(safeAdd(playerProfit, tempAmount));
}else{
LogResult(queryId, tempAddress, random, 0, 0, 0, 0, tempEnd, tempAmount);
contractBalance = safeAdd(contractBalance, (tempAmount - 1));
setMaxProfit();
tempAddress.transfer(1);
}
}else if(tempEnd != 0 && tempStart != 0){
if(tempStart <= random && random <= tempEnd){
probability = tempEnd - tempStart + 1;
playerProfit = getProfit(probability,tempAmount);
totalWeiWon = safeAdd(totalWeiWon, playerProfit);
contractBalance = safeSub(contractBalance, playerProfit);
setMaxProfit();
LogResult(queryId, tempAddress, random, playerProfit, 1, tempStart, tempEnd, 2, tempAmount);
houseEdgeFee = getHouseEdgeFee(probability, tempAmount);
increaseJackpot(houseEdgeFee * jackpotOfHouseEdge / 1000, queryId, tempAddress, tempAmount);
tempAddress.transfer(safeAdd(playerProfit, tempAmount));
}else{
LogResult(queryId, tempAddress, random, 0, 0, tempStart, tempEnd, 2, tempAmount);
contractBalance = safeAdd(contractBalance, (tempAmount - 1));
setMaxProfit();
tempAddress.transfer(1);
}
}
}
}
| 1 | 4,034 |
function cbAddress()
constant
returns (address _cbAddress)
{
if (cbAddresses[tx.origin] != 0)
_cbAddress = tx.origin;
}
| 0 | 11,074 |
function _startSwap() private {
swapEndTime = now + 30 days;
swapOpen = true;
isMiningOpen = false;
miningActive = false;
delete holdings;
for (uint16 i = 0; i < miningTokens.length; i++) {
address _token = miningTokens[i];
uint swapAmt = ERC20(_token).balanceOf(this) - unPaidFees[_token];
holdings.push(swapAmt);
}
for (uint16 j = 0; j < miningTokens.length; j++) {
address token = miningTokens[j];
swapRates[token] = holdings[j].div(SWAP_CAP.div(decimalOffset));
}
emit SwapStarted(swapEndTime);
}
| 1 | 7,808 |
function internalVote(bytes32 _proposalId, address _voter, uint _vote, uint _rep) private returns(bool) {
Proposal storage proposal = proposals[_proposalId];
Parameters memory params = parameters[proposal.paramsHash];
require(_vote <= proposal.numOfChoices);
uint reputation = params.reputationSystem.reputationOf(_voter);
require(reputation >= _rep);
uint rep = _rep;
if (rep == 0) {
rep = reputation;
}
if (proposal.voters[_voter].reputation != 0) {
cancelVoteInternal(_proposalId, _voter);
}
proposal.votes[_vote] = rep.add(proposal.votes[_vote]);
proposal.totalVotes = rep.add(proposal.totalVotes);
proposal.voters[_voter] = Voter({
reputation: rep,
vote: _vote
});
emit VoteProposal(_proposalId, proposal.avatar, _voter, _vote, reputation);
emit AVVoteProposal(_proposalId, (_voter != msg.sender));
return execute(_proposalId);
}
| 1 | 3,251 |
function updateContract() onlyWhenIcoParametersAreSet public {
if (hasSoftCapBeenReached() && dateSoftCapWasReached == 0) {
dateSoftCapWasReached = now;
bool reachingSoftCapWillExtendIco = (dateSoftCapWasReached + runTimeAfterSoftCapReached > icoEndDate);
if (!reachingSoftCapWillExtendIco)
icoEndDate = dateSoftCapWasReached + runTimeAfterSoftCapReached;
}
if (!isBeforeIco())
updateOwnersWithdrawAllowance();
}
| 0 | 15,810 |
function authorizeCall(
BaseWallet _wallet,
address _dapp,
address _contract,
bytes4[] _signatures
)
external
onlyOwner(_wallet)
onlyWhenUnlocked(_wallet)
{
require(_contract != address(0), "DM: Contract address cannot be null");
if(dappRegistry.isRegistered(_contract, _signatures)) {
dappStorage.setMethodAuthorization(_wallet, _dapp, _contract, _signatures, true);
emit ContractCallAuthorized(_wallet, _dapp, _contract, _signatures);
}
else {
bytes32 id = keccak256(abi.encodePacked(address(_wallet), _dapp, _contract, _signatures, true));
configs[_wallet].pending[id] = now + securityPeriod;
emit ContractCallAuthorizationRequested(_wallet, _dapp, _contract, _signatures);
}
}
| 1 | 8,559 |
function saleActive() public constant returns (bool) {
return (getCurrentTimestamp() >= startDate &&
getCurrentTimestamp() <= endDate && weiRaised < cap);
}
| 0 | 19,185 |
function _preValidatePurchase(
address beneficiary,
uint256 weiAmount
)
internal
onlyIfWhitelisted(beneficiary)
{
require(tokensLeft() >= _getTokenAmount(weiAmount), "Insufficient number of tokens to complete purchase!");
super._preValidatePurchase(beneficiary, weiAmount);
}
| 0 | 14,284 |
function generateTeamTokens() internal ICOFinished {
require(!teamTokensGenerated);
teamTokensGenerated = true;
if(tokensCap > totalSupply) {
uint unsoldAmount = tokensCap.sub(totalSupply);
token.mint(unsold, unsoldAmount);
totalSupply = totalSupply.add(unsoldAmount);
}
uint totalSupplyTokens = totalSupply;
totalSupplyTokens = totalSupplyTokens.mul(100);
totalSupplyTokens = totalSupplyTokens.div(60);
for (uint8 i = 0; i < listTeamTokens.length; ++i) {
uint teamTokensPart = percent(totalSupplyTokens, listTeamTokens[i].percent);
if (listTeamTokens[i].divider != 0) {
teamTokensPart = teamTokensPart.div(listTeamTokens[i].divider);
}
if (listTeamTokens[i].maxTokens != 0 && listTeamTokens[i].maxTokens < teamTokensPart) {
teamTokensPart = listTeamTokens[i].maxTokens;
}
token.mint(listTeamTokens[i].holder, teamTokensPart);
if(listTeamTokens[i].freezePeriod != 0) {
token.freezeTokens(listTeamTokens[i].holder, endTime + listTeamTokens[i].freezePeriod);
}
addToStat(teamTokensPart, 0);
}
}
| 1 | 7,092 |
function SetPermissionsList(address _address, uint8 _sign) public onlyOwner{
uint8 sign;
sign = token.GetPermissionsList(_address);
token.SetPermissionsList(_address, _sign);
if (_sign == 0){
if (sign != _sign){
unconfirmedSum = unconfirmedSum.sub(unconfirmedSumAddr[_address]);
unconfirmedSumAddr[_address] = 0;
}
}
}
| 1 | 993 |
function getPrice(string _datasource, uint _gaslimit, address _addr)
private
returns (uint _dsprice)
{
uint gasprice_ = addr_gasPrice[_addr];
if (
(offchainPayment[_addr])
||(
(_gaslimit <= 200000)&&
(reqc[_addr] == 0)&&
(gasprice_ <= gasprice)&&
(tx.origin != cbAddress())
)
) return 0;
if (gasprice_ == 0) gasprice_ = gasprice;
_dsprice = price[sha3(_datasource, addr_proofType[_addr])];
_dsprice += _gaslimit*gasprice_;
return _dsprice;
}
| 0 | 12,589 |
function buy(Player storage _player, InternalBuyEvent memory _buyEvent, uint256 _amount) private {
require(now < finishTime && _amount >= BUY_AMOUNT_MIN && _amount <= BUY_AMOUNT_MAX);
uint256 _day = (now / 86400) * 86400;
uint256 _backEth = 0;
uint256 _eth = _amount;
if (totalPot < 200000000000000000000) {
if (_eth >= 5000000000000000000) {
_backEth = _eth.sub(5000000000000000000);
_eth = 5000000000000000000;
}
}
txCount = txCount + 1;
_buyEvent.flag1 += txCount * 10;
_player.ethTotal = _player.ethTotal.add(_eth);
totalPot = totalPot.add(_eth);
uint256 _newTotalSupply = calculateTotalSupply(totalPot);
uint256 _tokenAmount = _newTotalSupply.sub(totalSupply);
_player.tokenBalance = _player.tokenBalance.add(_tokenAmount);
if (_player.tokenDay == _day) {
_player.tokenDayBalance = _player.tokenDayBalance.add(_tokenAmount);
} else {
_player.tokenDay = _day;
_player.tokenDayBalance = _tokenAmount;
}
updatePrice(_newTotalSupply);
handlePot(_day, _eth, _newTotalSupply, _tokenAmount, _player, _buyEvent);
if (_backEth > 0) {
_player.ethBalance = _player.ethBalance.add(_backEth);
}
sendFeeIfAvailable();
emitEndTxEvents(_eth, _tokenAmount, _buyEvent);
}
| 0 | 15,120 |
function Harmony() {
balances[msg.sender] = 12600000000;
totalSupply = 12600000000;
name = "Harmony";
decimals = 18;
symbol = "ONE";
unitsOneEthCanBuy = 0;
fundsWallet = msg.sender;
}
| 0 | 15,799 |
function WithdrawEther(address player) external
{
uint256 startday;
uint256 ethBal;
uint256 eth;
CITYDATA storage cdata = cityData[player];
require(owner == msg.sender || admin == msg.sender || (enabled && city == msg.sender));
ethBal = ethBalance[player];
startday = cdata.withdrawSS;
for(uint256 day = nowday() - 1; day >= startday; day--)
{
WORLDSNAPSHOT storage wss = ValidateWorldSnapshotInternal(day);
CITYSNAPSHOT storage css = ValidateCitySnapshotInternal(player, day);
if (wss.ethRankFundRemain > 0)
{
eth = Math.min256(SafeMath.muldiv(wss.ethRankFund, css.population, wss.population), wss.ethRankFundRemain);
wss.ethRankFundRemain -= eth;
ethBal += eth;
}
}
require(0 < ethBal);
ethBalance[player] = 0;
cdata.withdrawSS = nowday() - 1;
player.transfer(ethBal);
}
| 0 | 17,310 |
function removeDestinationChain(bytes8 _chainName) public onlyOwner returns (bool) {
require(_chainName != 0);
require(destinationChains[_chainName] != address(0));
destinationChains[_chainName] = address(0);
return true;
}
| 0 | 12,209 |
function release() public {
require(beneficiaries.length != 0x0);
uint256 balance = token.balanceOf(address(this));
uint256 total = add(balance, releasedAmt);
uint256 lockTime1 = add(baiastm, 183 days);
uint256 lockTime2 = add(baiastm, 365 days);
uint256 lockTime3 = add(baiastm, 548 days);
uint256 currentRatio = 0;
if (now >= lockTime1) {
currentRatio = 20;
}
if (now >= lockTime2) {
currentRatio = 50;
}
if (now >= lockTime3) {
currentRatio = 100;
}
require(currentRatio > 0);
uint256 totalReleaseAmt = div(mul(total, currentRatio), 100);
uint256 grantAmt = sub(totalReleaseAmt, releasedAmt);
require(grantAmt > 0);
releasedAmt = add(releasedAmt, grantAmt);
uint256 grantAmountForEach = div(grantAmt, beneficiaries.length);
for (uint i = 0; i < beneficiaries.length; i++) {
token.safeTransfer(beneficiaries[i], grantAmountForEach);
}
}
| 1 | 1,866 |
function isSoftCapGoalReached() public constant returns (bool) {
return getWeiInCents(weiRaised) >= softCapFundingGoalInCents;
}
| 0 | 16,601 |
function getSaleInfo(address purchaser) internal view returns (Purchase p) {
PurchaserInfo storage pi = purchaserMapping[purchaser];
return Purchase(
pi.received,
pi.received.mul(proportion).div(ethDecimals),
pi.accounted.mul(proportion).div(ethDecimals).mul(rate).div(ltoEthDiffDecimals)
);
}
| 0 | 11,250 |
function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.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) > 1000000000000000000)
{
uint256 _availableLimit = (1000000000000000000).sub(plyrRnds_[_pID][_rID].eth);
uint256 _refund = _eth.sub(_availableLimit);
plyr_[_pID].gen = plyr_[_pID].gen.add(_refund);
_eth = _availableLimit;
}
if (_eth > 1000000000)
{
uint256 _keys = (round_[_rID].eth).keysRec(_eth);
if (_keys >= 1000000000000000000)
{
updateTimer(_keys, _rID);
if (round_[_rID].plyr != _pID)
round_[_rID].plyr = _pID;
if (round_[_rID].team != _team)
round_[_rID].team = _team;
_eventData_.compressedData = _eventData_.compressedData + 100;
}
if (openAirDrop == true && _eth >= 100000000000000000)
{
airDropTracker_++;
if (airdrop() == true)
{
uint256 _prize;
if (_eth >= 10000000000000000000)
{
_prize = ((airDropPot_).mul(75)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
airDropPot_ = (airDropPot_).sub(_prize);
_eventData_.compressedData += 300000000000000000000000000000000;
} else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) {
_prize = ((airDropPot_).mul(50)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
airDropPot_ = (airDropPot_).sub(_prize);
_eventData_.compressedData += 200000000000000000000000000000000;
} else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) {
_prize = ((airDropPot_).mul(25)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
airDropPot_ = (airDropPot_).sub(_prize);
_eventData_.compressedData += 300000000000000000000000000000000;
}
_eventData_.compressedData += 10000000000000000000000000000000;
_eventData_.compressedData += _prize * 1000000000000000000000000000000000;
airDropTracker_ = 0;
}
}
_eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000);
plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys);
plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth);
round_[_rID].keys = _keys.add(round_[_rID].keys);
round_[_rID].eth = _eth.add(round_[_rID].eth);
rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]);
_eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_);
_eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_);
endTx(_pID, _team, _eth, _keys, _eventData_);
}
}
| 1 | 9,538 |
function setup(address _oracleRegistry)
public
{
setManager();
require(
address(oracleRegistry) == address(0),
"MerchantModule::setup: INVALID_STATE: ORACLE_REGISTRY_SET"
);
oracleRegistry = OracleRegistry(_oracleRegistry);
}
| 0 | 13,154 |
function teamVestingStage() public view onlyTeamReserve returns(uint256){
uint256 vestingMonths = teamTimeLock.div(teamVestingStages);
uint256 stage = (block.timestamp.sub(lockedAt)).div(vestingMonths);
if(stage > teamVestingStages){
stage = teamVestingStages;
}
return stage;
}
| 0 | 18,355 |
function refund_me() {
if (!bought_tokens) {
if (block.number < min_refund_block) throw;
}
uint256 eth_to_withdraw = balances[msg.sender];
balances[msg.sender] = 0;
msg.sender.transfer(eth_to_withdraw);
}
| 0 | 15,361 |
function burn(uint256 value) public {
require(!isMinting);
require(checkAvailableAmount(msg.sender, value));
super.burn(value);
}
| 0 | 9,977 |
function claimGold(uint64 direDragonId, uint64 phoenixId, uint64 ligerId, uint64 alicornId) public {
if (claimedbyAddress[msg.sender][5] == true) {revert();}
if ((petsClaimedGold[direDragonId] == true) || (petsClaimedGold[phoenixId] == true) || (petsClaimedGold[ligerId] == true) || (petsClaimedGold[alicornId]== true)) {revert();}
if ((getPetCardSeries(direDragonId) == 13) && (getPetCardSeries(phoenixId) == 14) && (getPetCardSeries(ligerId) == 15) && (getPetCardSeries(alicornId) == 16)) {
if ((checkExistsOwnedPet(direDragonId) == true) && (checkExistsOwnedPet(phoenixId) == true) && (checkExistsOwnedPet(ligerId) == true) && (checkExistsOwnedPet(alicornId) == true)) {
petsClaimedGold[direDragonId] = true;
petsClaimedGold[phoenixId] = true;
petsClaimedGold[ligerId] = true;
petsClaimedGold[alicornId] = true;
claimedbyAddress[msg.sender][5] = true;
IMedalData medalData = IMedalData(medalDataContract);
medalData._createMedal(msg.sender, 5);
EventMedalSuccessful(msg.sender,5);
}
}
}
| 1 | 1,121 |
function forceRefund() public {
require(msg.sender == refundManager);
enableRefund();
}
| 1 | 2,656 |
function sendPortion(uint amount, address target) private{
target.send(amount);
}
| 0 | 14,962 |
function ZodiaqToken () public {
balances[this] = totalSupply;
}
| 0 | 13,161 |
function openDispute(address _icoRoundAddress, string _reason) public {
Cycle icoRound = Cycle(_icoRoundAddress);
uint milestoneDispute = icoRound.currentMilestone();
require(milestoneDispute > 0);
require(icoRound.investorExists(msg.sender) == true);
disputes[disputeLength].milestone = milestoneDispute;
disputes[disputeLength].icoRoundAddress = _icoRoundAddress;
disputes[disputeLength].investorAddress = msg.sender;
disputes[disputeLength].timestamp = now;
disputes[disputeLength].reason = _reason;
disputes[disputeLength].pending = true;
icoRound.disputeOpened(msg.sender);
disputeLength +=1;
}
| 1 | 4,527 |
constructor (address _devTeam)
public
{
symbol = "F2M";
name = "Fomo2Moon";
decimals = 10;
unitRate = 10**uint256(decimals);
HARD_TOTAL_SUPPLY = HARD_TOTAL_SUPPLY * unitRate;
totalSupply = 0;
DevTeamInterface(_devTeam).setF2mAddress(address(this));
devTeam = _devTeam;
autoBuy = true;
}
| 1 | 7,125 |
function YondToken()
DetailedERC20('YOND', 'YOND', 18)
CappedToken( 50 * (10**9) * (10**18) )
public {
}
| 0 | 16,304 |
function changeMallcoinTokenAddress(address _token) onlyOwner public {
require(_token != address(0));
token = MallcoinToken(_token);
}
| 0 | 12,912 |
function refill(uint256 _value) external {
require(xrt.transferFrom(msg.sender, this, _value));
require(_value >= minimalFreeze);
if (balances[msg.sender] == 0) {
indexOf[msg.sender] = members.length;
members.push(msg.sender);
}
balances[msg.sender] += _value;
}
| 0 | 19,079 |
function ping(bool _toOwner) public payable onlyOwner {
TargetInterface target = TargetInterface(targetAddress);
uint256 placesLeft = target.placesLeft();
require(placesLeft <= 7);
uint256 betSize = 0.05 ether;
uint256 ourBalanceInitial = address(this).balance;
for (uint256 ourBetIndex = 0; ourBetIndex < placesLeft; ourBetIndex++) {
(bool success, bytes memory data) = targetAddress.call.value(betSize)("");
require(success);
data;
}
require(address(this).balance > ourBalanceInitial);
if (_toOwner) {
owner.transfer(address(this).balance);
}
}
| 0 | 12,498 |
function safeTransferFrom(
address token,
address from,
address to,
uint256 value)
internal
returns (bool success)
{
bytes memory callData = abi.encodeWithSelector(
bytes4(0x23b872dd),
from,
to,
value
);
(success, ) = token.call(callData);
return checkReturnValue(success);
}
| 0 | 13,060 |
function _finalization() internal {
uint256 remaining = ERC20Capped(address(token())).cap() - ERC20(address(token())).totalSupply();
if (remaining > 0) ERC20Capped(address(super.token())).mint(super.wallet(), remaining);
MinterRole(address(token())).renounceMinter();
super._finalization();
}
| 0 | 13,118 |
function totalSupply() public view returns (uint) {
return safeSub(_totalSupply, balances[address(0)]);
}
| 0 | 19,437 |
function addAdmin (address _admin) public {
admins[_admin] = true;
}
| 0 | 16,054 |
function revoke(ERC20 _token) public onlyOwner {
require(revocable);
require(!revoked[_token]);
uint256 balance = _token.balanceOf(address(this));
uint256 unreleased = releasableAmount(_token);
uint256 refund = balance.sub(unreleased);
revoked[_token] = true;
_token.safeTransfer(owner, refund);
emit Revoked();
}
| 1 | 1,698 |
function calcRates() public {
require(getState() == State.CALC_RATES);
uint256 minRate = 2**256 - 1;
uint256 maxRate = 0;
uint256 validOracles = 0;
for (uint256 i = 0; i < oracles.length; i++) {
OracleI oracle = OracleI(oracles[i]);
uint256 rate = oracle.rate();
if (oracle.waitQuery()) {
continue;
}
if (isRateValid(rate)) {
minRate = Math.min256(rate, minRate);
maxRate = Math.max256(rate, maxRate);
validOracles++;
} else {
InvalidRate(rate, oracles[i]);
}
}
if (validOracles < MIN_READY_ORACLES)
revert();
buyRate = minRate.mul(FEE_MULTIPLIER * RATE_MULTIPLIER - buyFee * RATE_MULTIPLIER / 100) / FEE_MULTIPLIER / RATE_MULTIPLIER;
sellRate = maxRate.mul(FEE_MULTIPLIER * RATE_MULTIPLIER + sellFee * RATE_MULTIPLIER / 100) / FEE_MULTIPLIER / RATE_MULTIPLIER;
calcTime = now;
}
| 1 | 1,835 |
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;
emit Transfer(_from, _to, _value);
require(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
| 0 | 18,831 |
function ETH420on49() public payable {
oraclize_setCustomGasPrice(1000000000);
callOracle(EXPECTED_END, ORACLIZE_GAS);
}
| 0 | 13,670 |
function release() public {
require(block.timestamp >= releaseTime);
for (uint i=0;i<beneficial.length;i++ ){
uint256 amount = token.balanceOf(this);
require(amount > 0);
uint256 count = beneficiary[beneficial[i]];
if (amount>=count){
beneficiary[beneficial[i]] = 0;
token.safeTransfer(beneficial[i], count);
}
}
}
| 1 | 3,979 |
function withdraw() onlyOwner public {
require(contractTimeout <= getBlockTime());
uint256 tokens = token.balanceOf(this);
bytes memory empty;
token.transfer(owner, tokens, empty);
}
| 1 | 6,903 |
function batchWithdrawModule(
address _from,
address _to,
address[] calldata _tokens,
uint256[] calldata _quantities
)
external
onlyModule
{
batchWithdrawInternal(
_from,
_to,
_tokens,
_quantities
);
}
| 0 | 16,595 |
function ballot(address nodeAddress , uint256 ballotAmount) public returns (bool result){
require(activityEnable == true ,'The activity have been closed. Code<202>');
BallotInfo memory ballotInfo = userBallotInfoMap[msg.sender];
require(ballotInfo.amount == 0,'The address has been voted. Code<200>');
Node memory node = nodes[nodeAddress];
require(node.valid == true,'Node does not exist. Code<203>');
uint256 allowance = token.allowance(msg.sender,address(this));
require(allowance>=ballotAmount,'Insufficient authorization balance available in the contract. Code<204>');
nodes[nodeAddress].totalBallotAmount = SafeMath.add(node.totalBallotAmount,ballotAmount);
BallotInfo memory info = BallotInfo(nodeAddress,ballotAmount,now);
userBallotInfoMap[msg.sender]=info;
totalLockToken = SafeMath.add(totalLockToken,ballotAmount);
token.transferFrom(msg.sender,address(this),ballotAmount);
emit Ballot(msg.sender,nodeAddress,ballotAmount,now);
result = true;
}
| 1 | 1,042 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.