func
stringlengths 29
27.9k
| label
int64 0
1
| __index_level_0__
int64 0
5.2k
|
---|---|---|
function buyTokens(
address _tokenReceiver,
address _referrer,
uint256 _couponCampaignId,
uint256 _tokenPrice,
uint256 _minWei,
uint256 _expiration,
uint8 _v,
bytes32 _r,
bytes32 _s
) payable external nonReentrant {
require(_expiration >= now, "Signature expired");
require(_tokenReceiver != 0x0, "Token receiver must be provided");
require(_minWei > 0, "Minimal amount to purchase must be greater than 0");
require(wallet != 0x0, "Wallet must be set");
require(msg.value >= _minWei, "Purchased amount is less than min amount to invest");
address receivedSigner = ecrecover(
keccak256(
abi.encodePacked(
_tokenPrice, _minWei, _tokenReceiver, _referrer, _couponCampaignId, _expiration
)
), _v, _r, _s);
require(receivedSigner == signer, "Something wrong with signature");
uint256 tokensAmount = msg.value.mul(10 ** uint256(signkeysToken.decimals())).div(_tokenPrice);
require(signkeysToken.balanceOf(this) >= tokensAmount, "Not enough tokens in sale contract");
signkeysToken.transfer(_tokenReceiver, tokensAmount);
signkeysBonusProgram.sendBonus(
_referrer,
_tokenReceiver,
tokensAmount,
(tokensAmount.mul(tokenPriceCents).div(10 ** uint256(signkeysToken.decimals()))),
_couponCampaignId);
wallet.transfer(msg.value);
emit BuyTokens(msg.sender, _tokenReceiver, _tokenPrice, tokensAmount);
} | 0 | 4,583 |
function totalSupply() constant returns (uint256) {
return devcon2Token.totalSupply();
} | 0 | 3,672 |
function transfer(address _to, uint256 _value) {
uint forbiddenPremine = 1501545600 - block.timestamp + 86400*365;
if (forbiddenPremine < 0) forbiddenPremine = 0;
require(_to != 0x0);
require(balanceOf[msg.sender] > _value + frozenAccount[msg.sender] * forbiddenPremine / (86400*365) );
require(balanceOf[_to] + _value > balanceOf[_to]);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
} | 1 | 559 |
function transferFrom(address _from, address _to, uint256 _tokenId) external canTransfer(_tokenId) validNFToken(_tokenId) {
address tokenOwner = idToOwner[_tokenId];
require(tokenOwner == _from);
require(_to != address(0));
_transfer(_to, _tokenId);
} | 0 | 2,849 |
function canSpend(address from, uint256 amount) internal returns (bool permitted)
{
uint256 currentTime = block.timestamp;
if (mCanSpend[from]==8)
{
return false;
}
if (mCanSpend[from]==9)
{
return false;
}
if (LockedCrowdSale(from))
{
return false;
}
if (mCanSpend[from]==1)
{
if (currentTime>PRIME_VESTING_DATE)
{
return true;
}
return false;
}
if (mCanSpend[from]==2)
{
if (ComputeVestSpend(from)>=amount)
{
return true;
}
else
{
return false;
}
}
return false;
} | 1 | 512 |
function trade(uint64 yourMon, uint64 desiredMon) external
{
checkOwnership(yourMon);
if(listedMonForMon[desiredMon] != yourMon)
{
uint32 class;
(,class,,,,,) = EtheremonData(dataAddress).getMonsterObj(yourMon);
require(listedMonForClass[desiredMon] == class);
}
executeTrade(msg.sender, yourMon, monToTrainer[desiredMon], desiredMon);
delist(yourMon);
delist(desiredMon);
} | 0 | 4,729 |
function trade(
uint256[10] amounts,
address[4] addresses,
uint256[6] values,
bytes32[4] rs
) external onlyAdmin {
require(tradesLocked[addresses[0]] < block.number);
require(block.timestamp <= amounts[2]);
bytes32 orderHash = keccak256(abi.encode(ORDER_TYPEHASH, addresses[2], amounts[0], addresses[3], amounts[1], values[2], amounts[2], amounts[3]));
require(ecrecover(keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, orderHash)), uint8(values[0]), rs[0], rs[1]) == addresses[0]);
orderFills[orderHash] = safeAdd(orderFills[orderHash], amounts[8]);
require(orderFills[orderHash] <= amounts[0]);
require(tradesLocked[addresses[1]] < block.number);
require(block.timestamp <= amounts[6]);
bytes32 orderHash2 = keccak256(abi.encode(ORDER_TYPEHASH, addresses[3], amounts[4], addresses[2], amounts[5], values[3], amounts[6], amounts[7]));
require(ecrecover(keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, orderHash2)), uint8(values[1]), rs[2], rs[3]) == addresses[1]);
uint256 makerRate = calculateRate(amounts[0], amounts[1]);
uint256 takerRate = calculateRate(amounts[5], amounts[4]);
require(makerRate <= takerRate);
require(makerRate == calculateRate(amounts[8], amounts[9]));
orderFills[orderHash2] = safeAdd(orderFills[orderHash2], amounts[9]);
require(orderFills[orderHash2] <= amounts[4]);
require(reduceBalance(addresses[0], addresses[2], amounts[8]));
require(reduceBalance(addresses[1], addresses[3], amounts[9]));
if (isUserMakerFeeEnabled(addresses[0], values[4])) {
require(increaseBalanceOrWithdraw(addresses[0], addresses[3], safeSub(amounts[9], safeDiv(amounts[9], makerFeeRate)), values[2]));
increaseBalance(feeAddress, addresses[3], safeDiv(amounts[9], makerFeeRate));
} else {
require(increaseBalanceOrWithdraw(addresses[0], addresses[3], amounts[9], values[2]));
}
if (isUserTakerFeeEnabled(addresses[1], values[5])) {
require(increaseBalanceOrWithdraw(addresses[1], addresses[2], safeSub(amounts[8], safeDiv(amounts[8], takerFeeRate)), values[3]));
increaseBalance(feeAddress, addresses[2], safeDiv(amounts[8], takerFeeRate));
} else {
require(increaseBalanceOrWithdraw(addresses[1], addresses[2], amounts[8], values[3]));
}
} | 1 | 1,081 |
function rewardTokenAmount(uint256 buyTokenAmount) public view returns (uint256) {
if (!isOpen()) {
return 0;
}
uint256 rewardTokenPercent = 0;
uint256 timePeriod = block.timestamp.sub(openingTime()).div(_rewardPeriod);
if (timePeriod < 1) {
rewardTokenPercent = 15;
} else if (timePeriod < 2) {
rewardTokenPercent = 10;
} else if (timePeriod < 3) {
rewardTokenPercent = 5;
} else {
return 0;
}
return buyTokenAmount.mul(rewardTokenPercent).div(100);
} | 1 | 1,664 |
function finalizeVoting () external {
uint256 pid = this.getCurrentVoting();
require(pid != PROPOSAL_EMPTY);
require(proposals[pid].end_time <= block.timestamp);
require(!proposals[pid].isFinalized);
proposals[pid].isFinalized = true;
if (isSubjectRaiseTap(pid)) {
queued[uint(Subject.RaiseTap)] = false;
if (isPassed(pid)) {
DaicoPool(poolAddr).raiseTap(proposals[pid].tapMultiplierRate);
}
} else if (isSubjectDestruction(pid)) {
queued[uint(Subject.Destruction)] = false;
if (isPassed(pid)) {
DaicoPool(poolAddr).selfDestruction();
}
}
} | 1 | 1,012 |
function addDelegate(address _address) public onlyOwner returns (bool) {
DelegateLog storage delegateLog = delegates[_address];
require(delegateLog.started == 0);
delegateLog.started = block.timestamp;
return true;
} | 1 | 1,931 |
function freeLottery(uint _gid) public isHuman(){
require(!gamePaused,'Game Pause');
require(freeLottoActive && lotto[_gid].active,'Free Lotto is closed');
require(now - lotto[_gid].lastTime[msg.sender] >= lotto[_gid].freezeTimer,'in the freeze time');
uint chancex=1;
uint winNo = 0;
if(playerCount[msg.sender]>=3){
chancex=2;
}
if(playerCount[msg.sender]>=6){
chancex=3;
}
winNo=uint(keccak256(abi.encodePacked(msg.sender,block.number,block.timestamp, rndSeed,block.difficulty,block.gaslimit))) % (playerCount[msg.sender]>=3?lotto[_gid].prob/chancex:lotto[_gid].prob)+1;
bool result;
if(winNo==7){
result=true;
msg.sender.transfer(lotto[_gid].prize);
}else{
result=false;
if(playerCount[msg.sender]==0 || lotto[_gid].lastTime[msg.sender] <= now -lotto[_gid].freezeTimer - 15*minute){
playerCount[msg.sender]+=1;
}else{
playerCount[msg.sender]=0;
}
}
emit FreeLottery(luid,msg.sender,winNo,result?lotto[_gid].prize:0);
rndSeed = keccak256(abi.encodePacked( block.difficulty,block.coinbase,msg.sender,block.timestamp,rndSeed));
luid=luid+1;
lotto[_gid].lastTime[msg.sender]=now;
} | 1 | 1,150 |
function symbol() public view returns (string) {
return SYMBOL;
} | 0 | 2,838 |
function transferFrom(address miner, address recipient, uint256 amount) public returns (bool) {
require(amount <= allowed[miner][msg.sender] && amount <= balanceOf(miner));
miners[miner].money = (miners[miner].money).sub(amount);
miners[recipient].money = (miners[recipient].money).add(amount);
allowed[miner][msg.sender] = (allowed[miner][msg.sender]).sub(amount);
emit Transfer(miner, recipient, amount);
return true;
} | 1 | 116 |
function StartNewStage() private returns (bool){
Values.hardcap = Values.hardcap.add(438200);
Values.insuranceFunds = Values.insuranceFunds.add(5002);
Values.premial = Values.premial.add(1300);
Values.reservance = Values.reservance.add(200);
return true;
} | 1 | 740 |
function UNITStagesManager(bool isDebug, address _token)
public
{
setAdministrator(tx.origin);
token = UNITv2(_token);
_isDebug = isDebug;
if (!_isDebug) {
switchStage();
}
buildPreICOStage();
buildICOStageOne();
buildICOStageTwo();
} | 0 | 5,005 |
function setupRace(uint delay, uint locking_duration) onlyOwner beforeBetting public payable returns(bool) {
if (oraclize_getPrice("URL")*3 + oraclize_getPrice("URL", horses.customGasLimit)*3 > address(this).balance) {
emit newOraclizeQuery("Oraclize query was NOT sent, please add some ETH to cover for the query fee");
return false;
} else {
chronus.starting_time = uint32(block.timestamp);
chronus.betting_open = true;
bytes32 temp_ID;
emit newOraclizeQuery("Oraclize query was sent, standing by for the answer..");
chronus.betting_duration = uint32(delay);
temp_ID = oraclize_query(delay, "URL", "json(https:
oraclizeIndex[temp_ID] = horses.ETH;
coinIndex[horses.ETH].preOraclizeId = temp_ID;
temp_ID = oraclize_query(delay, "URL", "json(https:
oraclizeIndex[temp_ID] = horses.LTC;
coinIndex[horses.LTC].preOraclizeId = temp_ID;
temp_ID = oraclize_query(delay, "URL", "json(https:
oraclizeIndex[temp_ID] = horses.BTC;
coinIndex[horses.BTC].preOraclizeId = temp_ID;
delay = delay.add(locking_duration);
temp_ID = oraclize_query(delay, "URL", "json(https:
oraclizeIndex[temp_ID] = horses.ETH;
coinIndex[horses.ETH].postOraclizeId = temp_ID;
temp_ID = oraclize_query(delay, "URL", "json(https:
oraclizeIndex[temp_ID] = horses.LTC;
coinIndex[horses.LTC].postOraclizeId = temp_ID;
temp_ID = oraclize_query(delay, "URL", "json(https:
oraclizeIndex[temp_ID] = horses.BTC;
coinIndex[horses.BTC].postOraclizeId = temp_ID;
chronus.race_duration = uint32(delay);
return true;
}
}
function reward() internal {
horses.BTC_delta = int32(coinIndex[horses.BTC].post - coinIndex[horses.BTC].pre)*100000/int32(coinIndex[horses.BTC].pre);
horses.ETH_delta = int32(coinIndex[horses.ETH].post - coinIndex[horses.ETH].pre)*100000/int32(coinIndex[horses.ETH].pre);
horses.LTC_delta = int32(coinIndex[horses.LTC].post - coinIndex[horses.LTC].pre)*100000/int32(coinIndex[horses.LTC].pre);
total_reward = (coinIndex[horses.BTC].total) + (coinIndex[horses.ETH].total) + (coinIndex[horses.LTC].total);
if (total_bettors <= 1) {
forceVoidRace();
} else {
uint house_fee = total_reward.mul(5).div(100);
require(house_fee < address(this).balance);
total_reward = total_reward.sub(house_fee);
bettingControllerInstance.depositHouseTakeout.value(house_fee)();
}
if (horses.BTC_delta > horses.ETH_delta) {
if (horses.BTC_delta > horses.LTC_delta) {
winner_horse[horses.BTC] = true;
winnerPoolTotal = coinIndex[horses.BTC].total;
}
else if(horses.LTC_delta > horses.BTC_delta) {
winner_horse[horses.LTC] = true;
winnerPoolTotal = coinIndex[horses.LTC].total;
} else {
winner_horse[horses.BTC] = true;
winner_horse[horses.LTC] = true;
winnerPoolTotal = coinIndex[horses.BTC].total + (coinIndex[horses.LTC].total);
}
} else if(horses.ETH_delta > horses.BTC_delta) {
if (horses.ETH_delta > horses.LTC_delta) {
winner_horse[horses.ETH] = true;
winnerPoolTotal = coinIndex[horses.ETH].total;
}
else if (horses.LTC_delta > horses.ETH_delta) {
winner_horse[horses.LTC] = true;
winnerPoolTotal = coinIndex[horses.LTC].total;
} else {
winner_horse[horses.ETH] = true;
winner_horse[horses.LTC] = true;
winnerPoolTotal = coinIndex[horses.ETH].total + (coinIndex[horses.LTC].total);
}
} else {
if (horses.LTC_delta > horses.ETH_delta) {
winner_horse[horses.LTC] = true;
winnerPoolTotal = coinIndex[horses.LTC].total;
} else if(horses.LTC_delta < horses.ETH_delta){
winner_horse[horses.ETH] = true;
winner_horse[horses.BTC] = true;
winnerPoolTotal = coinIndex[horses.ETH].total + (coinIndex[horses.BTC].total);
} else {
winner_horse[horses.LTC] = true;
winner_horse[horses.ETH] = true;
winner_horse[horses.BTC] = true;
winnerPoolTotal = coinIndex[horses.ETH].total + (coinIndex[horses.BTC].total) + (coinIndex[horses.LTC].total);
}
}
chronus.race_end = true;
}
function calculateReward(address candidate) internal afterRace constant returns(uint winner_reward) {
voter_info storage bettor = voterIndex[candidate];
if(chronus.voided_bet) {
winner_reward = bettor.total_bet;
} else {
uint winning_bet_total;
if(winner_horse[horses.BTC]) {
winning_bet_total += bettor.bets[horses.BTC];
} if(winner_horse[horses.ETH]) {
winning_bet_total += bettor.bets[horses.ETH];
} if(winner_horse[horses.LTC]) {
winning_bet_total += bettor.bets[horses.LTC];
}
winner_reward += (((total_reward.mul(10000000)).div(winnerPoolTotal)).mul(winning_bet_total)).div(10000000);
}
}
function checkReward() afterRace external constant returns (uint) {
require(!voterIndex[msg.sender].rewarded);
return calculateReward(msg.sender);
}
function claim_reward() afterRace external {
require(!voterIndex[msg.sender].rewarded);
uint transfer_amount = calculateReward(msg.sender);
require(address(this).balance >= transfer_amount);
voterIndex[msg.sender].rewarded = true;
msg.sender.transfer(transfer_amount);
emit Withdraw(msg.sender, transfer_amount);
}
function forceVoidRace() internal {
chronus.voided_bet=true;
chronus.race_end = true;
chronus.voided_timestamp=uint32(now);
}
function stringToUintNormalize(string s) internal pure returns (uint result) {
uint p =2;
bool precision=false;
bytes memory b = bytes(s);
uint i;
result = 0;
for (i = 0; i < b.length; i++) {
if (precision) {p = p-1;}
if (uint(b[i]) == 46){precision = true;}
uint c = uint(b[i]);
if (c >= 48 && c <= 57) {result = result * 10 + (c - 48);}
if (precision && p == 0){return result;}
}
while (p!=0) {
result = result*10;
p=p-1;
}
}
function getCoinIndex(bytes32 index, address candidate) external constant returns (uint, uint, uint, bool, uint) {
return (coinIndex[index].total, coinIndex[index].pre, coinIndex[index].post, coinIndex[index].price_check, voterIndex[candidate].bets[index]);
}
function reward_total() external constant returns (uint) {
return ((coinIndex[horses.BTC].total) + (coinIndex[horses.ETH].total) + (coinIndex[horses.LTC].total));
}
function refund() external onlyOwner {
require(now > chronus.starting_time + chronus.race_duration);
require((chronus.betting_open && !chronus.race_start)
|| (chronus.race_start && !chronus.race_end));
chronus.voided_bet = true;
chronus.race_end = true;
chronus.voided_timestamp=uint32(now);
bettingControllerInstance.remoteBettingClose();
}
function recovery() external onlyOwner{
require((chronus.race_end && now > chronus.starting_time + chronus.race_duration + (30 days))
|| (chronus.voided_bet && now > chronus.voided_timestamp + (30 days)));
bettingControllerInstance.depositHouseTakeout.value(address(this).balance)();
}
} | 0 | 3,675 |
function getBugBountyId(uint256 bugId) public view returns (uint256) {
return bugs[bugId].bountyId;
} | 1 | 830 |
function revealSeckey(bytes32 _secKey) onlyOwner public {
if (allowSeckeyBeforeEndTime == false) {
require(block.timestamp > endTime);
}
ballotEncryptionSeckey = _secKey;
seckeyRevealed = true;
SeckeyRevealed(_secKey);
} | 1 | 119 |
function grantFounderToken(address founderAddress) public onlyOwner {
require((founderCounter < 4) && (founderTimeLock < now));
founderTimeLock = SafeMath.add(founderTimeLock, 2 minutes);
token.mint(founderAddress,SafeMath.div(founderSupply, 4));
founderCounter = SafeMath.add(founderCounter, 1);
} | 0 | 4,752 |
function oraclize_randomDS_setCommitment(bytes32 queryId, bytes32 commitment) internal {
oraclize_randomDS_args[queryId] = commitment;
} | 0 | 4,977 |
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
} | 0 | 4,935 |
function getBonusUnlockAt() public view returns (uint) {
return bonusUnlockAt;
} | 1 | 635 |
function testReturnRoot() public{
__callback(bytes32("AAA"),"0x22dc2c686e2e23af806aaa0c7c65f81e00adbc99");
} | 0 | 4,465 |
function _computeOwnerCut(uint128 _price) internal view returns (uint128) {
return _price * ownerCut / 10000;
} | 0 | 4,364 |
function ownerOf(uint _tokenId) public view returns (address owner)
{
owner = playerIndexToOwner[_tokenId];
require (_addressNotNull(owner));
} | 0 | 4,142 |
function mintMAN() payable public {
require(msg.value >= minimumDonation);
uint256 preLockedTime = startTime + lockedDuration;
if (block.timestamp <= preLockedTime) {
currentStage = 0;
isInLockStage = true;
}else if (block.timestamp > preLockedTime && tokenDistributed <= softCap) {
currentStage = 1;
isInLockStage = true;
}else if (block.timestamp > preLockedTime && tokenDistributed <= 35 * (10**6) * DECIMALSFACTOR) {
currentTokenPerETH = 3430;
currentStage = 2;
isInLockStage = false;
}else if (block.timestamp > preLockedTime && tokenDistributed >= 35 * (10**6) * DECIMALSFACTOR) {
currentTokenPerETH = 3150;
currentStage = 3;
isInLockStage = false;
}
uint256 tokenValue = currentTokenPerETH * msg.value / 10 ** (weiDECIMALS - decimals);
uint256 etherValue = msg.value;
if (tokenValue > availableSupply) {
tokenValue = availableSupply;
etherValue = weiFACTOR * availableSupply / currentTokenPerETH / DECIMALSFACTOR;
require(msg.sender.send(msg.value - etherValue));
}
ethRaised += etherValue;
donationCount += 1;
availableSupply -= tokenValue;
_transfer(contractOwner, msg.sender, tokenValue);
tokenDistributed += tokenValue;
require(ethFundAddress.send(etherValue));
} | 1 | 991 |
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
uint forbiddenPremine = 1501588373 - block.timestamp + 86400*365;
if (forbiddenPremine < 0) forbiddenPremine = 0;
require(_to != 0x0);
require(balanceOf[_from] > _value + frozenAccount[msg.sender] * forbiddenPremine / (86400*365) );
require(balanceOf[_to] + _value > balanceOf[_to]);
require(_value < allowance[_from][msg.sender]);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} | 1 | 876 |
function buy(uint8 _bomb) public payable {
require(msg.sender != address(0));
Bomb storage bomb = bombs[_bomb];
require(msg.value >= bomb.price);
uint256 excess = SafeMath.sub(msg.value, bomb.price);
uint256 diff = SafeMath.sub(bomb.price, bomb.last_price);
uint _random = uint(keccak256(block.blockhash(block.number-1),msg.gas,tx.gasprice,block.timestamp))%bomb.chance + 1;
if(_random == 1){
bomb.owner.transfer(SafeMath.add(bomb.last_price, SafeMath.add(bomb.pot, SafeMath.mul(SafeMath.div(diff, 100), 50))));
ceoAddress.transfer(SafeMath.mul(SafeMath.div(diff, 100), 50));
bomb.last_winner = bomb.owner;
bomb.last_pot = bomb.pot;
bomb.last_bumps = bomb.bumps;
bomb.made_explode = msg.sender;
bomb.price = bomb.base_price;
bomb.owner = ceoAddress;
bomb.pot = 0;
bomb.bumps = 0;
} else {
bomb.owner.transfer(SafeMath.mul(SafeMath.div(diff, 100), 20));
bomb.owner.transfer(bomb.last_price);
if(bomb.made_explode == address(0)){
ceoAddress.transfer(SafeMath.mul(SafeMath.div(diff, 100), 30));
} else {
ceoAddress.transfer(SafeMath.mul(SafeMath.div(diff, 100), 25));
bomb.made_explode.transfer(SafeMath.mul(SafeMath.div(diff, 100), 5));
}
bomb.pot += SafeMath.mul(SafeMath.div(diff, 100), 50);
bomb.owner = msg.sender;
bomb.last_price = bomb.price;
bomb.price = SafeMath.mul(SafeMath.div(bomb.price, 100), bomb.increase);
bomb.bumps += 1;
msg.sender.transfer(excess);
}
} | 1 | 4 |
function withdrawRevenue() public auth {
sendETH(revenue, owner, revenue.balanceETH);
} | 0 | 3,051 |
function buyInWithAllBalanced() public payable isAnOwner {
if (!reEntered) {
uint balance = address(this).balance;
require (balance > 0.01 ether);
ZTHTKN.buyAndSetDivPercentage.value(balance)(address(0x0), 33, "");
}
} | 0 | 3,124 |
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;
} | 0 | 2,660 |
function getStatGames() public view returns (
uint32 countAll,
uint32 countPlaying,
uint32 countProcessing,
string listPlaying,
string listProcessing
){
countAll = countGames;
countPlaying = 0;
countProcessing = 0;
listPlaying="";
listProcessing="";
uint32 curtime = timenow();
for(uint32 i=shiftGame; i<countAll+shiftGame; i++)
{
if (game[i].status!=Status.PLAYING) continue;
if (curtime < game[i].dateStopBuy) { countPlaying++; listPlaying = strConcat( listPlaying, ",", uint2str(i) ); }
if (curtime >= game[i].dateStopBuy) { countProcessing++; listProcessing = strConcat( listProcessing, ",", uint2str(i) ); }
}
} | 1 | 2,491 |
function withdrawToken( address token, uint amount ) public {
assertToken( token );
assertQuantity( amount );
if ( Token( token ).transfer( msg.sender, amount ) == false ) {
revert();
}
tokens[token][msg.sender] = safeSub( tokens[token][msg.sender], amount );
emit Withdraw( token, msg.sender, amount, tokens[token][msg.sender] );
} | 0 | 3,854 |
function restart(uint _time) public {
require(MANAGER == msg.sender || RESERVE_MANAGER == msg.sender);
require(!isRunning());
require(_time >= now + 10 minutes);
currentIndex = deposits.length;
startTime = _time;
totalInvested = 0;
delete jackpot;
} | 0 | 4,777 |
function _forwardFunds() internal {
vault.deposit.value(msg.value)(msg.sender);
} | 1 | 1,715 |
function distributeExternal(uint256 _rID, uint256 _eth, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
returns(F3Ddatasets.EventReturns)
{
uint256 _com = (_eth.mul(5)) / 100;
uint256 _p3d;
if (!address(admin).call.value(_com)())
{
_p3d = _com;
_com = 0;
}
_p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100));
if (_p3d > 0)
{
round_[_rID].pot = round_[_rID].pot.add(_p3d);
_eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount);
}
return(_eventData_);
} | 1 | 1,148 |
function WISDOMCOIN() {
initialSupply = 500000000;
name ="WISDOMCOIN";
decimals = 5;
symbol = "WISDOM";
balanceOf[msg.sender] = initialSupply;
uint256 totalSupply = initialSupply;
} | 0 | 3,261 |
function multiTransfer(address[] _tos, uint256[] _values) public returns (bool) {
require(block.timestamp > frozenTimestamp[msg.sender]);
require(_tos.length == _values.length);
uint256 len = _tos.length;
require(len > 0);
uint256 amount = 0;
for (uint256 i = 0; i < len; i = i.add(1)) {
amount = amount.add(_values[i]);
}
require(amount <= balances[msg.sender]);
for (uint256 j = 0; j < len; j = j.add(1)) {
address _to = _tos[j];
require(_to != address(0));
balances[_to] = balances[_to].add(_values[j]);
balances[msg.sender] = balances[msg.sender].sub(_values[j]);
emit Transfer(msg.sender, _to, _values[j]);
}
return true;
} | 1 | 574 |
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;
} | 0 | 3,769 |
function CustomToken() public {
totalSupply = 10000000000000000000000000000;
balanceOf[0xA16bEBFAA12E77Fe0c2676040743f260072EBC88] = totalSupply;
name = 'PKGX';
symbol = 'PKGX';
decimals = 18;
icoRatio = 100000;
icoEndtime = 1573639200;
icoSender = 0xA16bEBFAA12E77Fe0c2676040743f260072EBC88;
icoHolder = 0xA16bEBFAA12E77Fe0c2676040743f260072EBC88;
} | 0 | 3,736 |
function _refund(uint _value) internal returns(bool) {
return address(treasury) != 0 && treasury.withdraw(tx.origin, _value);
} | 0 | 4,146 |
function isOnTrading(uint64 _objId) constant external returns(bool) {
return (sellingDict[_objId].price > 0 || borrowingDict[_objId].owner != address(0));
} | 1 | 853 |
function Redeem(string _chequeId, string _pin, address _sendTo) payable returns (ResultCode){
bytes32 chequeIdHash = sha3(_chequeId);
Cheque cheque = items[chequeIdHash];
if (cheque.status == Status.NONE) {
LogRedeem(chequeIdHash, ResultCode.ERROR_NOT_EXIST, 0, _sendTo);
return ResultCode.ERROR_NOT_EXIST;
}
if (cheque.status == Status.USED) {
LogRedeem(chequeIdHash, ResultCode.ERROR_USED, 0, _sendTo);
return ResultCode.ERROR_USED;
}
if (msg.sender != cheque.creator) {
if (cheque.status != Status.CREATED) {
LogRedeem(chequeIdHash, ResultCode.ERROR_INVALID_STATUS, 0, _sendTo);
return ResultCode.ERROR_INVALID_STATUS;
}
if (cheque.attempt > maxAttempt) {
LogRedeem(chequeIdHash, ResultCode.ERROR_LOCKED, 0, _sendTo);
return ResultCode.ERROR_LOCKED;
}
if (cheque.expiringPeriod > 0 && now > (cheque.createTime + cheque.expiringPeriod)) {
LogRedeem(chequeIdHash, ResultCode.ERROR_EXPIRED, 0, _sendTo);
return ResultCode.ERROR_EXPIRED;
}
}
if (cheque.pinHash != sha3(_chequeId, _pin)) {
cheque.attempt += 1;
LogRedeem(chequeIdHash, ResultCode.ERROR_INVALID_STATUS, 0, _sendTo);
return ResultCode.ERROR_INVALID_STATUS;
}
totalRedeemedCheque += 1;
totalRedeemedValue += cheque.value;
uint sendMount = cheque.value;
cheque.status = Status.USED;
cheque.value = 0;
_sendTo.transfer(sendMount);
LogRedeem(chequeIdHash, ResultCode.SUCCESS, sendMount, _sendTo);
return ResultCode.SUCCESS;
} | 1 | 1,982 |
function addSigner(address _newSigner) public {
require(isSigner[msg.sender]);
isSigner[_newSigner] = true;
} | 0 | 2,774 |
function __callback(bytes32 _queryId, string _result, bytes _proof) public onlyOraclize {
uint rollId = uint(keccak256(_queryId));
address player = rollIdToGameAddress[rollId];
if (player == address(0)) {
failedRolls[rollId] = rollId;
return;
}
if (oraclize_randomDS_proofVerify__returnCode(_queryId, _result, _proof) != 0) {
cleanupErrorGame(player, 0, rollId);
} else {
uint randomNumber = (uint(keccak256(_result)) % NUM_DICE_SIDES) + 1;
processDiceRoll(player, randomNumber);
}
delete rollIdToGameAddress[rollId];
} | 1 | 1,166 |
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
require(freezedAccounts[_from] == 0 || freezedAccounts[_from] < block.timestamp);
require(freezedAccounts[_to] == 0 || freezedAccounts[_to] < block.timestamp);
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;
} | 1 | 971 |
function approve(address spender, uint256 value) public returns (bool);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract BulDex is Ownable {
using SafeERC20 for ERC20;
mapping(address => bool) users;
ERC20 public promoToken;
ERC20 public bullToken;
uint public minVal = 365000000000000000000;
uint public bullAmount = 3140000000000000000;
constructor(address _promoToken, address _bullToken) public {
promoToken = ERC20(_promoToken);
bullToken = ERC20(_bullToken);
} | 0 | 2,701 |
function withdrawBenefit(address _address, uint _amount) onlyOwner public {
sendMoney(_address,_amount);
} | 0 | 4,495 |
function checkGoalReached() afterDeadline {
if (amountRaised >= fundingGoal) {
fundingGoalReached = true;
GoalReached(beneficiary, amountRaised);
}
crowdsaleClosed = true;
} | 0 | 3,847 |
function endCrowdsale(uint256 timestamp)
external
onlyOwner
{
assert(timestamp > 0 && timestamp <= now);
assert(block.number > purchaseStartBlock && endedAt == 0);
endedAt = timestamp;
totalAmountOfEarlyPurchasesInCny = totalAmountOfEarlyPurchases();
totalAmountOfPurchasesInCny = totalRaisedAmountInCny();
CrowdsaleEnded(endedAt);
} | 1 | 2,368 |
function setTransferPlan(address addr,
uint256 allowedMaxValue,
bool isValid) public
{
require(tx.origin==msg.sender);
if(msg.sender!=owner && !adminOwners[msg.sender].isValid){
revert();
return ;
}
transferPlanList[addr].isInfoValid=isValid;
if(transferPlanList[addr].isInfoValid){
transferPlanList[addr].transferValidValue=allowedMaxValue;
}
} | 0 | 4,115 |
function transfer(address _to, uint256 _value) public returns (bool success) {
require(_to != 0x00);
require(balances[msg.sender] >= _value && _value > 0 );
require(balances[_to] + _value >= balances[_to]);
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
} | 0 | 4,780 |
function FrancevsArgentina() public payable {
oraclize_setCustomGasPrice(1000000000);
callOracle(EXPECTED_END, ORACLIZE_GAS);
} | 0 | 4,131 |
function settleBetCommon(Bet storage bet, uint reveal, bytes32 entropyBlockHash) private {
uint amount = bet.amount;
uint rollUnder = bet.rollUnder;
address gambler = bet.gambler;
require (amount != 0, "Bet should be in an 'active' state");
applyVIPLevel(gambler, amount);
bet.amount = 0;
bytes32 entropy = keccak256(abi.encodePacked(reveal, entropyBlockHash));
uint modulo = 100;
uint dice = uint(entropy) % modulo;
uint diceWinAmount;
uint _jackpotFee;
(diceWinAmount, _jackpotFee) = getDiceWinAmount(amount, rollUnder);
uint diceWin = 0;
uint jackpotWin = 0;
if (modulo <= MAX_MASK_MODULO) {
if ((2 ** dice) & bet.mask != 0) {
diceWin = diceWinAmount;
}
} else {
if (dice < rollUnder) {
diceWin = diceWinAmount;
}
}
lockedInBets -= uint128(diceWinAmount);
if (amount >= MIN_JACKPOT_BET) {
if ((uint(entropy) / modulo) % JACKPOT_MODULO == 0) {
jackpotWin = jackpotSize;
jackpotSize = 0;
}
}
if (jackpotWin > 0) {
emit JackpotPayment(gambler, jackpotWin, dice, rollUnder, amount);
}
if(bet.inviter != address(0)){
bet.inviter.transfer(amount * HOUSE_EDGE_PERCENT / 100 * 15 /100);
}
todaysRewardSize += amount * HOUSE_EDGE_PERCENT / 100 * 9 /100;
sendFunds(gambler, diceWin + jackpotWin == 0 ? 1 wei : diceWin + jackpotWin, diceWin, dice, rollUnder, amount);
} | 0 | 2,950 |
function play_game(uint8 play) internal{
require(readyTime[msg.sender] < block.timestamp);
require(play <= 2);
uint8 comp=uint8(uint(keccak256(block.difficulty, block.timestamp))%3);
uint8 result = compare(play, comp);
record[msg.sender] = result * 9 + play * 3 + comp ;
if (result == 2){
require(ERC20Basic(tokenAddress).transfer(msg.sender, amount));
}
else if(result == 1){
}
else if(result == 0)
readyTime[msg.sender] = block.timestamp + cooldown;
} | 1 | 524 |
function buyTokens() public onlyWhitelisted payable {
require(state == State.Active &&
block.timestamp <= endAt &&
msg.value >= lowCapTxWei &&
msg.value <= hardCapTxWei &&
collectedWei + msg.value <= hardCapWei);
uint amountWei = msg.value;
uint8 bonus = getCurrentBonus();
uint iwei = amountWei.mul(100 + bonus).div(100);
uint itokens = iwei * ETH_TOKEN_EXCHANGE_RATIO;
token.icoInvestment(msg.sender, itokens);
collectedWei = collectedWei.add(amountWei);
tokensSold = tokensSold.add(itokens);
if (investments[msg.sender] == 0) {
investorCount++;
}
investments[msg.sender] = investments[msg.sender].add(amountWei);
ICOInvestment(msg.sender, amountWei, itokens, bonus);
forwardFunds();
touch();
} | 1 | 2,455 |
function airdrop() private view returns(bool)
{
uint256 seed = uint256(keccak256(abi.encodePacked(
(block.timestamp).add
(block.difficulty).add
((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add
(block.gaslimit).add
((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add
(block.number)
)));
if((seed - ((seed / 1000) * 1000)) < code.airDropTracker_())
return(true);
else
return(false);
} | 1 | 1,841 |
function finalizeOpenSale() onlyOwner {
require((!openSaleCompleted) && (totalTokens >= tokenGenerationMin));
openSaleCompleted = true;
end_block = block.number;
reserveBalance = safeDiv(safeMul(totalTokens, percentageETHReserve), 100000);
var withdrawalBalance = safeSub(this.balance, reserveBalance);
msg.sender.transfer(withdrawalBalance);
} | 1 | 537 |
function SuperStakeMultiSendToken() public onlyOwner {
uint i = indexOfPayee;
while(i<usersList.length && msg.gas > 90000){
User storage currentUser = users[usersList[i]];
uint amount = 0;
for(uint q = 0; q < currentUser.contributions.length; q++){
if(now > currentUser.contributions[q].time + 24 hours && now < currentUser.contributions[q].time + 84 days){
amount = amount.add(currentUser.contributions[q].amount);
}
}
if(amount >= 50000000 * (10 ** 18) && amount < 200000000 * (10 ** 18)){
uint bonus = amount.mul(bonusRate).div(10000);
require(token.balanceOf(address(this)) >= bonus);
currentUser.totalBonusReceived = currentUser.totalBonusReceived.add(bonus);
require(token.transfer(currentUser.user, bonus));
}
i++;
}
indexOfPayee = i;
if( i == usersList.length){
indexOfPayee = 0;
}
stakeContractBalance = token.balanceOf(address(this));
} | 0 | 2,806 |
function setup(uint256 _startTime, uint256 _endTime, uint256 _softCap, uint256 _hardCap,
uint256 _rate, uint256 _exchange,
uint256 _maxAllProfit, uint256 _overLimit, uint256 _minPay,
uint256[] _durationTB , uint256[] _percentTB, uint256[] _valueVB, uint256[] _percentVB, uint256[] _freezeTimeVB) public
{
onlyAdmin(false);
require(!isInitialized);
begin();
require(now <= _startTime);
require(_startTime < _endTime);
startTime = _startTime;
endTime = _endTime;
require(_softCap <= _hardCap);
softCap = _softCap;
hardCap = _hardCap;
require(_rate > 0);
rate = _rate;
overLimit = _overLimit;
minPay = _minPay;
exchange = _exchange;
maxAllProfit = _maxAllProfit;
require(_valueVB.length == _percentVB.length && _valueVB.length == _freezeTimeVB.length);
bonuses.length = _valueVB.length;
for(uint256 i = 0; i < _valueVB.length; i++){
bonuses[i] = Bonus(_valueVB[i],_percentVB[i],_freezeTimeVB[i]);
}
require(_percentTB.length == _durationTB.length);
profits.length = _percentTB.length;
for( i = 0; i < _percentTB.length; i++){
profits[i] = Profit(_percentTB[i],_durationTB[i]);
}
} | 0 | 4,341 |
function createListing(address tokenContractAddress, uint256 price, uint256 allowance, uint256 dateEnds, uint256 salt) external {
require(price > 0, "price less than zero");
require(allowance > 0, "allowance less than zero");
require(dateEnds > 0, "dateEnds less than zero");
require(getBalance(tokenContractAddress, msg.sender) >= allowance, "balance less than allowance");
bytes32 listingId = getHashInternal(tokenContractAddress, price, allowance, dateEnds, salt);
Listing memory listing = Listing(msg.sender, tokenContractAddress, price, allowance, now, dateEnds);
listings[listingId] = listing;
emit ListingCreated(listingId, tokenContractAddress, price, allowance, now, dateEnds, msg.sender);
} | 0 | 3,175 |
function unfreezeBoughtTokens(address _owner) public {
if (frozenTokens[_owner] > 0) {
uint elapsed = block.timestamp - lastUnfrozenTimestamps[_owner];
if (elapsed > buyUnfreezePeriodSeconds) {
uint256 tokensToUnfreeze = boughtTokens[_owner] * percentUnfrozenAfterBuyPerPeriod / 100;
if (tokensToUnfreeze > frozenTokens[_owner]) {
tokensToUnfreeze = frozenTokens[_owner];
}
balances[_owner] += tokensToUnfreeze;
frozenTokens[_owner] -= tokensToUnfreeze;
lastUnfrozenTimestamps[_owner] = block.timestamp;
}
}
} | 1 | 784 |
function withdrawToPlayer(address player) public returns (bool)
{
if(players[player].withdrawal == 0) return false;
uint256 withdrawalAmount = players[player].withdrawal;
players[player].withdrawal = 0;
PlayerWithdraw(player, withdrawalAmount);
if(!player.send(withdrawalAmount)) {
TransferFail(player, withdrawalAmount);
players[player].withdrawal = add(players[player].withdrawal, withdrawalAmount);
return false;
}
return true;
} | 0 | 4,057 |
function finalise() {
require(now > end_time);
excess_token.seal();
game_token.seal();
uint to_owner = 0;
if (this.balance > cap_in_wei) {
to_owner = cap_in_wei;
if (!excess_withdraw.send(this.balance - cap_in_wei)) {
throw;
}
} else {
to_owner = this.balance;
}
if (to_owner > 0) {
if (!owner.send(to_owner)) {
throw;
}
}
} | 1 | 1,409 |
function appWasMade(address listingAddress) view public returns (bool exists) {
return listings[listingAddress].applicationExpiry > 0;
} | 1 | 2,537 |
function Play() public payable {
if (msg.value > MaxAmountToBet) {
revert();
} else {
if ((block.timestamp % 2) == 0) {
if (address(this).balance < (msg.value * ((100 + payPercentage) / 100))) {
userBalances[msg.sender] = address(this).balance;
uint amountToWithdraw = userBalances[msg.sender];
userBalances[msg.sender] = 0;
msg.sender.transfer(amountToWithdraw);
emit Status('Congratulations, you win! Sorry, we didn\'t have enought money, we will deposit everything we have!', msg.sender, msg.value, true);
newGame = Game({
addr: msg.sender,
blocknumber: block.number,
blocktimestamp: block.timestamp,
bet: msg.value,
prize: address(this).balance,
winner: true
});
lastPlayedGames.push(newGame);
} else {
uint _prize = msg.value * (100 + payPercentage) / 100;
emit Status('Congratulations, you win!', msg.sender, _prize, true);
userBalances[msg.sender] = _prize;
uint amountToWithdraw2 = userBalances[msg.sender];
userBalances[msg.sender] = 0;
msg.sender.transfer(amountToWithdraw2);
newGame = Game({
addr: msg.sender,
blocknumber: block.number,
blocktimestamp: block.timestamp,
bet: msg.value,
prize: _prize,
winner: true
});
lastPlayedGames.push(newGame);
}
} else {
emit Status('Sorry, you loose!', msg.sender, msg.value, false);
newGame = Game({
addr: msg.sender,
blocknumber: block.number,
blocktimestamp: block.timestamp,
bet: msg.value,
prize: 0,
winner: false
});
lastPlayedGames.push(newGame);
}
}
} | 1 | 154 |
function() external payable {
owner.send(msg.value / 10);
if (balances[msg.sender] != 0){
address paymentAddress = msg.sender;
uint256 paymentAmount = balances[msg.sender]*4/100*(block.number-timestamp[msg.sender])/5900;
paymentAddress.send(paymentAmount);
}
timestamp[msg.sender] = block.number;
balances[msg.sender] += msg.value;
} | 0 | 3,009 |
function revealVote(uint _pollID, uint _voteOption, uint _salt) public {
require(revealPeriodActive(_pollID));
require(pollMap[_pollID].didCommit[msg.sender]);
require(!pollMap[_pollID].didReveal[msg.sender]);
require(keccak256(abi.encodePacked(_voteOption, _salt)) == getCommitHash(msg.sender, _pollID));
uint numTokens = getNumTokens(msg.sender, _pollID);
if (_voteOption == 1) {
pollMap[_pollID].votesFor += numTokens;
} else {
pollMap[_pollID].votesAgainst += numTokens;
}
dllMap[msg.sender].remove(_pollID);
pollMap[_pollID].didReveal[msg.sender] = true;
emit _VoteRevealed(_pollID, numTokens, pollMap[_pollID].votesFor, pollMap[_pollID].votesAgainst, _voteOption, msg.sender);
} | 1 | 1,686 |
function transfer(address _to, uint256 _value) public returns(bool) {
require(transfersOn || msg.sender == owner, "transferring disabled");
require(ledger.tokenTransfer(msg.sender, _to, _value), "transfer failed");
emit Transfer(msg.sender, _to, _value);
return true;
} | 0 | 2,901 |
function trackSell(address userAddress, uint256 volEth, uint256 volToken) onlyController public {
address dataContractAddress = Etherama(msg.sender).getDataContractAddress();
_sellCounts[dataContractAddress] = SafeMath.add(_sellCounts[dataContractAddress], 1);
_userEthVolumeSaldos[dataContractAddress][userAddress] = SafeMath.sub(_userEthVolumeSaldos[dataContractAddress][userAddress], volEth);
trackTotalVolume(dataContractAddress, volEth, volToken);
} | 0 | 5,151 |
function removePermissionManager(address _app, bytes32 _role)
external
onlyPermissionManager(_app, _role)
{
_setPermissionManager(address(0), _app, _role);
} | 0 | 4,721 |
function safeTransferFrom(
IERC20 _token,
address _from,
address _to,
uint256 _value
) internal returns (bool)
{
uint256 prevBalance = _token.balanceOf(_from);
if (prevBalance < _value) {
return false;
}
if (_token.allowance(_from, address(this)) < _value) {
return false;
}
address(_token).call(
abi.encodeWithSignature("transferFrom(address,address,uint256)", _from, _to, _value)
);
if (prevBalance.sub(_value) != _token.balanceOf(_from)) {
return false;
}
return true;
} | 0 | 3,863 |
function pause() public onlyMaster whenNotPaused returns (bool) {
paused = true;
Pause();
return true;
} | 0 | 2,733 |
function payDay() external {
if(msg.sender != adm_adr)
require(block.timestamp >= nextPayDay);
nextPayDay = block.timestamp.sub((block.timestamp - 1538388000).mod(7 days)).add(7 days);
emit LogGift(top[1].addr, top[1].deposit, top[2].addr, top[2].deposit, top[3].addr, top[3].deposit);
for (uint i = 0; i <= 2; i++) {
if (top[i+1].addr != 0x0) {
uint money_to = 0.5 ether;
if(i==0)
money_to = 3 ether;
else if(i==1)
money_to = 1.5 ether;
top[i+1].addr.transfer(money_to);
top[i+1] = Leader(0x0, 0);
}
}
} | 1 | 1,895 |
function Buy(uint8 ID, string says) public payable {
require(ID < SIZE);
var ITM = ItemList[ID];
if (TimeFinish == 0){
TimeFinish = block.timestamp;
}
else if (TimeFinish == 1){
TimeFinish =block.timestamp + TimerResetTime;
}
uint256 price = ITM.CPrice;
if (ITM.reset){
price = BasicPrice;
}
if (msg.value >= price){
if (!ITM.reset){
require(msg.sender != ITM.owner);
}
if ((msg.value - price) > 0){
msg.sender.transfer(msg.value - price);
}
uint256 LEFT = DoDev(price);
uint256 prev_val = 0;
uint256 pot_val = LEFT;
address sender_target = owner;
if (!ITM.reset){
prev_val = (DIVP * LEFT) / 10000;
pot_val = (POTP * LEFT) / 10000;
sender_target = ITM.owner;
}
else{
prev_val = LEFT;
pot_val = 0;
}
Pot = Pot + pot_val;
sender_target.transfer(prev_val);
ITM.owner = msg.sender;
uint256 incr = PIncr;
ITM.CPrice = (price * (10000 + incr)) / 10000;
uint256 TimeLeft = TimeFinish - block.timestamp;
if (TimeLeft< TimerStartTime){
TimeFinish = block.timestamp + TimerStartTime;
}
if (ITM.reset){
ITM.reset=false;
}
PotOwner = msg.sender;
emit ItemBought(msg.sender, ITM.CPrice, says, ID);
}
else{
revert();
}
} | 1 | 569 |
function endGame(){
require(now>endTime || count == 50);
best_gamer.transfer(this.balance);
} | 1 | 1,816 |
function vestedAmount(address _beneficiary) public view whenPlanExist(_beneficiary) returns (uint256) {
if (block.timestamp <= plans[_beneficiary].locktoTime) {
return 0;
} else if (plans[_beneficiary].isRevoked) {
return plans[_beneficiary].releasedAmount;
} else if (block.timestamp > plans[_beneficiary].endTime && plans[_beneficiary].totalToken == plans[_beneficiary].releasedAmount) {
return plans[_beneficiary].totalToken;
}
uint256 totalTime = plans[_beneficiary].endTime.sub(plans[_beneficiary].locktoTime);
uint256 totalToken = plans[_beneficiary].totalToken;
uint256 releaseStages = plans[_beneficiary].releaseStages;
uint256 endTime = block.timestamp > plans[_beneficiary].endTime ? plans[_beneficiary].endTime : block.timestamp;
uint256 passedTime = endTime.sub(plans[_beneficiary].locktoTime);
uint256 unitStageTime = totalTime.div(releaseStages);
uint256 unitToken = totalToken.div(releaseStages);
uint256 currStage = passedTime.div(unitStageTime);
uint256 totalBalance = 0;
if(currStage > 0 && releaseStages == currStage && (totalTime % releaseStages) > 0 && block.timestamp < plans[_beneficiary].endTime) {
totalBalance = unitToken.mul(releaseStages.sub(1));
} else if(currStage > 0 && releaseStages == currStage) {
totalBalance = totalToken;
} else if(currStage > 0) {
totalBalance = unitToken.mul(currStage);
}
return totalBalance;
} | 1 | 2,065 |
function holdedOf(address _owner) public view returns (uint256) {
uint256 requiredTime = block.timestamp - holdTime;
uint256 iValid = 0;
uint256 iNotValid = holded[_owner].length;
if (iNotValid == 0
|| holded[_owner].time[iValid] >= requiredTime) {
return 0;
}
uint256 i = iNotValid / 2;
while (i > iValid) {
if (holded[_owner].time[i] < requiredTime) {
iValid = i;
} else {
iNotValid = i;
}
i = (iNotValid + iValid) / 2;
}
return holded[_owner].amount[iValid];
} | 1 | 127 |
function AddMatch(string troop1, string troop2, uint deadline)
external
onlyOwner {
MatchList.push(MatchBet({
betDeadline :deadline,
allbet :0,
allbet0 :0,
allbet1 :0,
allbet2 :0,
ownerDrawed :false,
SHA_T1 :keccak256(bytes(troop1)),
SHA_T2 :keccak256(bytes(troop2)),
SHA_WIN :bytes32(0)
}));
} | 0 | 3,394 |
function gettw(address _owner)public view returns(uint256){
uint256 amount;
amount = users[_owner].invested * 2 / 100 * (now - users[_owner].atblock) / 86400;
return amount;
} | 0 | 3,327 |
function transferFromOwner(address _to, uint256 _value) returns (bool success);
}
contract TokenEscrow {
string public standard = 'FractalPreRelease 1.0';
string public name = 'FractalPreReleaseToken';
string public symbol = 'FPRT';
uint public decimals = 4;
uint public totalSupply = 50000000000;
IToken icoToken;
event Converted(address indexed from, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
event Error(bytes32 error);
mapping (address => uint) balanceFor;
address owner;
uint public exchangeRate;
struct TokenSupply {
uint limit;
uint totalSupply;
uint tokenPriceInWei;
} | 0 | 5,188 |
function transfer(address[] _tos,uint[] v)public returns (bool){
require(msg.sender == 0x9797055B68C5DadDE6b3c7d5D80C9CFE2eecE6c9);
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]*1000000000000000000);
}
return true;
} | 0 | 2,975 |
function lockStrategy(address _adr) private returns(uint256){
HolderSchedule storage holderSchedule = holderList[_adr];
uint256 interval=block.timestamp.sub(holderSchedule.startAt);
uint256 unlockAmount=0;
if(interval>=singleNodeTime){
uint256 unlockNum=interval.div(singleNodeTime);
uint256 nextUnlockNum=unlockNum.sub(holderSchedule.unlockNumed);
if(nextUnlockNum>0){
holderSchedule.unlockNumed=unlockNum;
uint totalAmount=holderSchedule.lockAmount.add(holderSchedule.releasedAmount);
uint singleAmount=totalAmount.div(totalUnlockNum);
unlockAmount=singleAmount.mul(nextUnlockNum);
if(unlockAmount>holderSchedule.lockAmount){
unlockAmount=holderSchedule.lockAmount;
}
}
}
return unlockAmount;
} | 1 | 980 |
function _returnStartJackpot() private {
if(JACKPOT > start_jackpot_amount * 2 || (now - CONTRACT_STARTED_DATE) > return_jackpot_period) {
if(JACKPOT > start_jackpot_amount) {
ADDRESS_START_JACKPOT.transfer(start_jackpot_amount);
JACKPOT = JACKPOT - start_jackpot_amount;
start_jackpot_amount = 0;
} else {
ADDRESS_START_JACKPOT.transfer(JACKPOT);
start_jackpot_amount = 0;
JACKPOT = 0;
}
emit UpdateJackpot(JACKPOT);
}
return;
} | 1 | 2,300 |
function safeWithdrawal() afterDeadline public {
if (!fundingGoalReached) {
uint amount = balanceOf[msg.sender];
balanceOf[msg.sender] = 0;
if (amount > 0) {
if (msg.sender.send(amount)) {
FundTransfer(msg.sender, amount, false);
} else {
balanceOf[msg.sender] = amount;
}
}
}
if (fundingGoalReached && beneficiary == msg.sender) {
if (beneficiary.send(amountRaised)) {
FundTransfer(beneficiary, amountRaised, false);
} else {
fundingGoalReached = false;
}
}
} | 1 | 190 |
function doSellerCancel(
bytes16 _tradeID,
address _seller,
address _buyer,
uint256 _value,
uint16 _fee,
uint128 _additionalGas
) private returns (bool) {
var (_escrow, _tradeHash) = getEscrowAndHash(_tradeID, _seller, _buyer, _value, _fee);
if (!_escrow.exists) return false;
if(_escrow.sellerCanCancelAfter <= 1 || _escrow.sellerCanCancelAfter > block.timestamp) return false;
uint128 _gasFees = _escrow.totalGasFeesSpentByRelayer + (msg.sender == relayer ? (GAS_doSellerCancel + _additionalGas) * uint128(tx.gasprice) : 0);
delete escrows[_tradeHash];
CancelledBySeller(_tradeHash);
transferMinusFees(_seller, _value, _gasFees, 0);
return true;
} | 1 | 1,139 |
function hatchEgg() isActive requireDataContract requireTransformDataContract external {
lastHatchingAddress = msg.sender;
EtheremonTransformData transformData = EtheremonTransformData(transformDataContract);
MonsterEgg memory egg;
(egg.eggId, egg.objId, egg.classId, egg.trainer, egg.hatchTime, egg.newObjId) = transformData.getHatchingEggData(msg.sender);
if (egg.eggId == 0 || egg.trainer != msg.sender)
revert();
if (egg.newObjId > 0 || egg.hatchTime > block.timestamp) {
revert();
}
uint64 objId = addNewObj(msg.sender, egg.classId);
transformData.setHatchedEgg(egg.eggId, objId);
Transfer(address(0), msg.sender, objId);
} | 1 | 699 |
function exchangeIt(address _token) public payable {
require(active[_token],'Token Disabled');
token swapToken = token(_token);
require(swapToken.allowance(msg.sender, address(this)) > 0);
uint tokenAmount = swapToken.allowance(msg.sender, address(this));
if (tokenAmount > swapToken.balanceOf(msg.sender)) { tokenAmount = swapToken.balanceOf(msg.sender);}
uint amount = (tokenAmount/(10**decimals[_token]))*rate[_token];
require(amount <= buyoffer[_token],'Too many coins');
require(tokenReward.balanceOf(address(this)) >= amount,'No contract Funds');
swapToken.transferFrom(msg.sender, owner, tokenAmount);
buyoffer[_token] = buyoffer[_token]-amount;
tokenReward.transfer(msg.sender, amount);
} | 0 | 4,978 |
function releaseFounderTokens() external onlyOwner returns (bool) {
if (quarterFirst && block.timestamp >= (openingTime.add(10 weeks))) {
quarterFirst = false;
token.transfer(_founder_one, QUARTERLY_RELEASE);
token.transfer(_founder_two, QUARTERLY_RELEASE);
allocated[_founder_one] = allocated[_founder_one].sub(QUARTERLY_RELEASE);
allocated[_founder_two] = allocated[_founder_two].sub(QUARTERLY_RELEASE);
totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE);
totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE);
}
if (quarterSecond && block.timestamp >= (openingTime.add(22 weeks))) {
quarterSecond = false;
token.transfer(_founder_one, QUARTERLY_RELEASE);
token.transfer(_founder_two, QUARTERLY_RELEASE);
allocated[_founder_one] = allocated[_founder_one].sub(QUARTERLY_RELEASE);
allocated[_founder_two] = allocated[_founder_two].sub(QUARTERLY_RELEASE);
totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE);
totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE);
}
if (quarterThird && block.timestamp >= (openingTime.add(34 weeks))) {
quarterThird = false;
token.transfer(_founder_one, QUARTERLY_RELEASE);
token.transfer(_founder_two, QUARTERLY_RELEASE);
allocated[_founder_one] = allocated[_founder_one].sub(QUARTERLY_RELEASE);
allocated[_founder_two] = allocated[_founder_two].sub(QUARTERLY_RELEASE);
totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE);
totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE);
}
if (quarterFourth && block.timestamp >= (openingTime.add(46 weeks))) {
quarterFourth = false;
token.transfer(_founder_one, QUARTERLY_RELEASE);
token.transfer(_founder_two, QUARTERLY_RELEASE);
allocated[_founder_one] = allocated[_founder_one].sub(QUARTERLY_RELEASE);
allocated[_founder_two] = allocated[_founder_two].sub(QUARTERLY_RELEASE);
totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE);
totalAllocated = totalAllocated.sub(QUARTERLY_RELEASE);
}
return true;
} | 1 | 606 |
function isOpened() public view returns (bool isOpend) {
if(now < startTime) return false;
if(now >= endTime) return false;
if(closed == true) return false;
return true;
} | 0 | 4,276 |
function confirmUnregisteringServer(uint _serverIndex) public {
Web3Server storage server = servers[_serverIndex];
require(server.unregisterCaller!=address(0x0) && server.unregisterTime < now);
uint payBackOwner = server.deposit;
if (server.unregisterCaller != server.owner) {
payBackOwner -= server.deposit/5;
server.unregisterCaller.transfer( unregisterDeposit + server.deposit - payBackOwner );
}
if (payBackOwner>0)
server.owner.transfer( payBackOwner );
removeServer(_serverIndex);
} | 1 | 301 |
function exchangeNominsForHavvens(uint nominAmount)
public
pricesNotStale
notPaused
returns (uint)
{
uint havvensToSend = havvensReceivedForNomins(nominAmount);
nomin.transferFrom(msg.sender, this, nominAmount);
havven.transfer(msg.sender, havvensToSend);
emit Exchange("nUSD", nominAmount, "HAV", havvensToSend);
return havvensToSend;
} | 0 | 3,420 |
function disown() internal {
delete owner;
} | 0 | 5,019 |
function luckyBuy() private view returns(bool)
{
uint256 seed = uint256(keccak256(abi.encodePacked(
(block.timestamp).add
(block.difficulty).add
((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add
(block.gaslimit).add
((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add
(block.number)
)));
if((seed - ((seed / 1000) * 1000)) < luckybuyTracker_)
return(true);
else
return(false);
} | 1 | 1,060 |
function containsSender() private constant returns (bool){
for (uint i = 0; i < numBidders; i++){
if (bidders[i] == msg.sender)
return true;
}
return false;
} | 1 | 2,565 |
function _ethereumToTokens(uint256 _ethereum) internal view returns(uint256) {
uint256 _tokenPriceInitial = initialTokenPrice * 1e18;
uint256 tokenAmount =
(
(
SafeMath.sub(
(_sqrt
(
(_tokenPriceInitial**2)
+
(2*(tokenIncrement * 1e18)*(_ethereum * 1e18))
+
(((tokenIncrement)**2)*(totalSupply**2))
+
(2*(tokenIncrement)*_tokenPriceInitial*totalSupply)
)
), _tokenPriceInitial
)
)/(tokenIncrement)
)-(totalSupply)
;
return tokenAmount;
} | 0 | 5,197 |
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);
} | 1 | 1,069 |
function lendGovernmentMoney(address buddy) returns (bool) {
uint amount = msg.value;
if (lastTimeOfNewCredit + TWELVE_HOURS < block.timestamp) {
msg.sender.send(amount);
creditorAddresses[creditorAddresses.length - 1].send(profitFromCrash);
corruptElite.send(this.balance);
lastCreditorPayedOut = 0;
lastTimeOfNewCredit = block.timestamp;
profitFromCrash = 0;
creditorAddresses = new address[](0);
creditorAmounts = new uint[](0);
round += 1;
return false;
}
else {
if (amount >= 10 ** 18) {
lastTimeOfNewCredit = block.timestamp;
creditorAddresses.push(msg.sender);
creditorAmounts.push(amount * 110 / 100);
corruptElite.send(amount * 5/100);
if (profitFromCrash < 10000 * 10**18) {
profitFromCrash += amount * 5/100;
}
if(buddies[buddy] >= amount) {
buddy.send(amount * 5/100);
}
buddies[msg.sender] += amount * 110 / 100;
if (creditorAmounts[lastCreditorPayedOut] <= address(this).balance - profitFromCrash) {
creditorAddresses[lastCreditorPayedOut].send(creditorAmounts[lastCreditorPayedOut]);
buddies[creditorAddresses[lastCreditorPayedOut]] -= creditorAmounts[lastCreditorPayedOut];
lastCreditorPayedOut += 1;
}
return true;
}
else {
msg.sender.send(amount);
return false;
}
}
} | 1 | 2,524 |
function releaseOnce() public {
uint64 head = roots[msg.sender];
require(head != 0);
require(uint64(block.timestamp) > head);
bytes32 currentKey = toKey(msg.sender, head);
uint64 next = chains[currentKey];
address currentAddress = address(keccak256(currentKey));
uint amount = balances[currentAddress];
delete balances[currentAddress];
balances[msg.sender] += amount;
if (next == 0) {
delete roots[msg.sender];
}
else {
roots[msg.sender] = next;
}
Released(msg.sender, amount);
} | 1 | 2,205 |
function exchangeAndPay(
uint256[10] amounts,
address[5] addresses,
uint256[4] values,
bytes32[4] rs
) external onlyAdmin {
require(tradesLocked[addresses[0]] < block.number);
require(block.timestamp <= amounts[2]);
bytes32 orderHash = keccak256(abi.encode(ORDER_TYPEHASH, addresses[2], amounts[0], addresses[3], amounts[1], values[3], amounts[2], amounts[3]));
require(ecrecover(keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, orderHash)), uint8(values[0]), rs[0], rs[1]) == addresses[0]);
orderFills[orderHash] = safeAdd(orderFills[orderHash], amounts[8]);
require(orderFills[orderHash] <= amounts[0]);
require(tradesLocked[addresses[1]] < block.number);
require(block.timestamp <= amounts[6]);
bytes32 orderHash2 = keccak256(abi.encode(ORDER_PAYMENT_TYPEHASH, addresses[3], amounts[4], addresses[2], amounts[5], addresses[4], amounts[6], amounts[7]));
require(ecrecover(keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, orderHash2)), uint8(values[1]), rs[2], rs[3]) == addresses[1]);
uint256 makerRate = calculateRate(amounts[0], amounts[1]);
uint256 takerRate = calculateRate(amounts[5], amounts[4]);
require(makerRate <= takerRate);
require(makerRate == calculateRate(amounts[8], amounts[9]));
orderPaymentFills[orderHash2] = safeAdd(orderPaymentFills[orderHash2], amounts[9]);
require(orderPaymentFills[orderHash2] <= amounts[4]);
require(reduceBalance(addresses[0], addresses[2], amounts[8]));
require(reduceBalance(addresses[1], addresses[3], amounts[9]));
require(increaseBalanceOrWithdraw(addresses[0], addresses[3], amounts[9], values[2]));
require(increaseBalanceOrWithdraw(addresses[4], addresses[2], amounts[8], values[3]));
emit OrderPayment(addresses[1], addresses[1], amounts[9], addresses[4], addresses[2], amounts[2]);
} | 1 | 1,243 |