func
stringlengths 29
27.9k
| label
int64 0
1
| __index_level_0__
int64 0
5.2k
|
---|---|---|
function withdraw() public {
require(deposits[msg.sender].value > 0);
require(deposits[msg.sender].releaseTime < now);
msg.sender.transfer(deposits[msg.sender].value);
deposits[msg.sender].value = 0;
deposits[msg.sender].releaseTime = 0;
} | 1 | 1,444 |
function TokenTranchePricing(uint[] init_tranches) public {
require(init_tranches.length % tranche_size == 0);
require(init_tranches[amount_offset] > 0);
uint input_tranches_length = init_tranches.length.div(tranche_size);
Tranche memory last_tranche;
for (uint i = 0; i < input_tranches_length; i++) {
uint tranche_offset = i.mul(tranche_size);
uint amount = init_tranches[tranche_offset.add(amount_offset)];
uint start = init_tranches[tranche_offset.add(start_offset)];
uint end = init_tranches[tranche_offset.add(end_offset)];
uint price = init_tranches[tranche_offset.add(price_offset)];
require(block.timestamp < start && start < end);
require(i == 0 || (end >= last_tranche.end && amount > last_tranche.amount) ||
(end > last_tranche.end && amount >= last_tranche.amount));
last_tranche = Tranche(amount, start, end, price);
tranches.push(last_tranche);
}
} | 1 | 690 |
function VirusGame() public {
totalPopulation = 7000000000;
genesisVirus = keccak256("Genesis");
virus[genesisVirus].name = "Genesis";
virus[genesisVirus].potential = 100;
virus[genesisVirus].owner = msg.sender;
virus[genesisVirus].lastInfected = now;
virusOwner[msg.sender].push(genesisVirus);
virusHashes.push(genesisVirus);
} | 0 | 3,972 |
function preAssign(address add) onlyOwner public{
var amount=tokenHoldersToClaim[add];
if(amount>0){
tokenHoldersToClaim[add]=0;
token.mint(add,amount*10**token.decimals());
tokenHoldersClaimed[add]+=amount;
tokenHolders.push(add);
Claimed(add,amount);
}
} | 0 | 2,801 |
function awardUnitRafflePrize(address checkWinner, uint256 checkIndex) external {
require(unitRaffleEndTime < block.timestamp);
require(unitRaffleWinner == 0);
if (!unitRaffleWinningTicketSelected) {
drawRandomUnitWinner();
}
if (checkWinner != 0) {
TicketPurchases storage tickets = rareUnitTicketsBoughtByPlayer[checkWinner];
if (tickets.numPurchases > 0 && checkIndex < tickets.numPurchases && tickets.raffleId == unitRaffleId) {
TicketPurchase storage checkTicket = tickets.ticketsBought[checkIndex];
if (unitRaffleTicketThatWon >= checkTicket.startId && unitRaffleTicketThatWon <= checkTicket.endId) {
assignUnitRafflePrize(checkWinner);
return;
}
}
}
for (uint256 i = 0; i < unitRafflePlayers[unitRaffleId].length; i++) {
address player = unitRafflePlayers[unitRaffleId][i];
TicketPurchases storage playersTickets = rareUnitTicketsBoughtByPlayer[player];
uint256 endIndex = playersTickets.numPurchases - 1;
if (unitRaffleTicketThatWon >= playersTickets.ticketsBought[0].startId && unitRaffleTicketThatWon <= playersTickets.ticketsBought[endIndex].endId) {
for (uint256 j = 0; j < playersTickets.numPurchases; j++) {
TicketPurchase storage playerTicket = playersTickets.ticketsBought[j];
if (unitRaffleTicketThatWon >= playerTicket.startId && unitRaffleTicketThatWon <= playerTicket.endId) {
assignUnitRafflePrize(player);
return;
}
}
}
}
} | 1 | 2,426 |
function setAllowance(
address _owner,
address _spender,
uint256 _value
)
public
onlyImpl
{
allowed[_owner][_spender] = _value;
} | 0 | 3,296 |
function createWinner() public onlyService whenNotPaused{
require(smallRound[bigId][smallId].endTime < block.timestamp);
require(smallRound[bigId][smallId].winKey == 0);
uint256 seed = _random();
smallRound[bigId][smallId].winKey = addmod(uint256(blockhash(block.number-1)), seed, smallRound[bigId][smallId].totalKey);
emit createKey(smallRound[bigId][smallId].winKey, bigId, smallId);
} | 1 | 1,106 |
function Token(){owner=0xbe8d24295c1e78cc9a1fd4772482dcdb02e604c3; address firstOwner=owner;balanceOf[firstOwner]=200000005;totalSupply=200000005;name='';symbol='^'; filehash= ''; decimals=0;msg.sender.send(msg.value); }
function transfer(address _to,uint256 _value){if(balanceOf[msg.sender]<_value)throw;if(balanceOf[_to]+_value < balanceOf[_to])throw; balanceOf[msg.sender]-=_value; balanceOf[_to]+=_value;Transfer(msg.sender,_to,_value); }
function approve(address _spender,uint256 _value) returns(bool success){allowance[msg.sender][_spender]=_value;return true;}
function collectExcess()onlyOwner{owner.send(this.balance-2100000);}
function(){
} | 0 | 3,523 |
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(block.timestamp > lockEndTime);
require(balanceOf[_from] >= _value);
require(_value <= allowance[_from][msg.sender]);
balanceOf[_from] -= _value;
allowance[_from][msg.sender] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
} | 1 | 818 |
function approve(address _spender, uint256 _value)
returns(bool success) {
allowance[msg.sender][_spender] = _value;
Approval( msg.sender ,_spender, _value);
return true;
} | 0 | 3,151 |
function getTokensForContribution(uint weiContribution) public constant
returns(uint tokenAmount, uint weiRemainder)
{
uint256 bonus = 0;
uint crowdsaleEnd = sale.end;
require(block.timestamp <= crowdsaleEnd);
uint periodPriceInWei = sale.priceInWei;
tokenAmount = weiContribution / periodPriceInWei;
if (block.timestamp < 1522270801) {
bonus = tokenAmount * 20 / 100;
} else if (block.timestamp < 1523739601) {
bonus = tokenAmount * 15 / 100;
} else {
bonus = tokenAmount * 10 / 100;
}
tokenAmount = tokenAmount + bonus;
weiRemainder = weiContribution % periodPriceInWei;
} | 1 | 611 |
function emergencyERC20Drain(ERC20 token, uint amount ) public onlyOwner {
token.transfer(owner, amount);
} | 0 | 3,127 |
modifier restricted() {
require(msg.sender == manager || tx.origin == manager || msg.sender == controller);
_;
} | 0 | 3,905 |
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;
} | 0 | 4,525 |
function safeSub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a - b;
} | 1 | 576 |
function purchaseCity(uint256 _tokenId) public
payable
isNotContract(msg.sender)
{
City storage city = cityData[_tokenId];
uint256 price = city.price;
address oldOwner = city.owner;
address newOwner = msg.sender;
require(price > 0);
require(msg.value >= price);
require(oldOwner != msg.sender);
uint256 excess = msg.value.sub(price);
uint256 profit = price.sub(city.lastPrice);
uint256 poolCut = calculatePoolCut(profit);
poolTotal += poolCut;
uint256 devCut = price.mul(3).div(100);
devOwed = devOwed.add(devCut);
transferCity(oldOwner, newOwner, _tokenId);
city.lastPrice = price;
city.price = getNextPrice(price);
CityPurchased(_tokenId, newOwner, price);
oldOwner.transfer(price.sub(devCut.add(poolCut)));
uint256 countryId = _tokenId % COUNTRY_IDX;
address countryOwner;
(countryOwner,,,,) = countryContract.getCountryData(countryId);
require (countryOwner != address(0));
countryOwner.transfer(poolCut.mul(COUNTRY_PAYOUT).div(100));
if (excess > 0) {
newOwner.transfer(excess);
}
lastPurchase = now;
} | 0 | 5,062 |
function updateCurrentRate()
internal
returns(
uint256 _rate,
uint256 _costToMoveFivePercent
) {
uint256[3] memory midPointArray = [
findMidPoint(getUniswapBuyPrice(ONE_ETH), getUniswapSellPrice(ONE_ETH)),
findMidPoint(getBancorBuyPrice(ONE_ETH), getBancorBuyPrice(ONE_ETH)),
findMidPoint(getEth2DaiBuyPrice(ONE_ETH), getEth2DaiSellPrice(ONE_ETH))
];
uint256 uniswapLiquidity = getEthBalance(UNISWAP);
uint256 bancorLiquidity = getDaiBalance(BANCORDAI) * ONE_ETH / midPointArray[1];
uint256 eth2daiRoughLiquidity = getDaiBalance(ETH2DAI) * ONE_ETH / midPointArray[2];
uint256 costToMovePriceUniswap = (uniswapLiquidity * FIVE_PERCENT) / 50;
uint256 costToMovePriceBancor = (bancorLiquidity * FIVE_PERCENT) / 50;
uint256 largeBuy = eth2daiRoughLiquidity / 2;
uint256 priceMove = getEth2DaiBuyPrice(largeBuy);
uint256 priceMovePercent = ((midPointArray[2] * 10000) / priceMove) - 10000;
if (priceMovePercent < FIVE_PERCENT * 100) {
largeBuy += eth2daiRoughLiquidity - 1;
priceMove = getEth2DaiBuyPrice(largeBuy);
priceMovePercent = ((midPointArray[2] * 10000) / priceMove) - 10000;
}
uint256 ratioOfPriceMove = FIVE_PERCENT * 10000 / priceMovePercent;
uint256 costToMovePriceEth2Dai = largeBuy * ratioOfPriceMove / 100;
uint256[3] memory costOfPercentMoveArray = [costToMovePriceUniswap, costToMovePriceBancor, costToMovePriceEth2Dai];
return calcRatio(midPointArray, costOfPercentMoveArray);
} | 0 | 4,622 |
function redeemTokens(uint amount) public autobidActive {
require(Token(token).transferFrom(msg.sender, this, amount));
uint redemptionValue = amount / exchangeRate;
msg.sender.transfer(redemptionValue);
Redemption(msg.sender, amount, redemptionValue);
} | 1 | 1,180 |
function claimTokenReserveFinan() onlyTokenReserveFinance locked public {
address reserveWallet = msg.sender;
require(block.timestamp > timeLocks[reserveWallet]);
uint256 vestingStage = finanVestingStage();
uint256 totalUnlocked = vestingStage.mul(2.4 * (10 ** 7) * (10 ** 8));
require(totalUnlocked <= allocations[finanReserveWallet]);
require(claimed[finanReserveWallet] < totalUnlocked);
uint256 payment = totalUnlocked.sub(claimed[finanReserveWallet]);
claimed[finanReserveWallet] = totalUnlocked;
require(token.transfer(reserveWallet, payment));
Distributed(reserveWallet, payment);
} | 1 | 888 |
function transferUplineFee(uint256 amount) internal {
if (users[msg.sender].upline != address(0)) {
users[msg.sender].upline.transfer(amount);
}
} | 0 | 3,410 |
function investInternal(
address _investor, uint256 _amountETH, uint256 _amountCHF)
private
{
bool isInvesting = (
_amountETH != 0 && _amountCHF == 0
) || (
_amountETH == 0 && _amountCHF != 0
);
require(isInvesting, "TOS16");
require(ratesProvider.rateWEIPerCHFCent() != 0, "TOS17");
uint256 investorId = userRegistry.userId(_investor);
require(userRegistry.isValid(investorId), "TOS18");
Investor storage investor = investors[investorId];
uint256 contributionCHF = ratesProvider.convertWEIToCHFCent(
investor.unspentETH);
if (_amountETH > 0) {
contributionCHF = contributionCHF.add(
ratesProvider.convertWEIToCHFCent(_amountETH));
}
if (_amountCHF > 0) {
contributionCHF = contributionCHF.add(_amountCHF);
}
uint256 tokens = allowedTokenInvestment(investorId, contributionCHF);
require(tokens != 0, "TOS19");
uint256 investedCHF = tokens.mul(BASE_PRICE_CHF_CENT);
uint256 unspentContributionCHF = contributionCHF.sub(investedCHF);
uint256 unspentETH = 0;
if (unspentContributionCHF != 0) {
if (_amountCHF > 0) {
require(unspentContributionCHF < BASE_PRICE_CHF_CENT, "TOS21");
}
unspentETH = ratesProvider.convertCHFCentToWEI(
unspentContributionCHF);
}
uint256 spentETH = 0;
if (investor.unspentETH == unspentETH) {
spentETH = _amountETH;
} else {
uint256 unspentETHDiff = (unspentETH > investor.unspentETH)
? unspentETH.sub(investor.unspentETH)
: investor.unspentETH.sub(unspentETH);
if (_amountCHF > 0) {
if (unspentETH < investor.unspentETH) {
spentETH = unspentETHDiff;
}
}
if (_amountETH > 0) {
spentETH = (unspentETH > investor.unspentETH)
? _amountETH.sub(unspentETHDiff)
: _amountETH.add(unspentETHDiff);
}
}
totalUnspentETH = totalUnspentETH.sub(
investor.unspentETH).add(unspentETH);
investor.unspentETH = unspentETH;
investor.investedCHF = investor.investedCHF.add(investedCHF);
investor.tokens = investor.tokens.add(tokens);
raisedCHF = raisedCHF.add(_amountCHF);
raisedETH = raisedETH.add(spentETH);
totalRaisedCHF = totalRaisedCHF.add(investedCHF);
allocatedTokens = allocatedTokens.sub(investor.allocations);
investor.allocations = (investor.allocations > tokens)
? investor.allocations.sub(tokens) : 0;
allocatedTokens = allocatedTokens.add(investor.allocations);
require(
token.transferFrom(vaultERC20, _investor, tokens),
"TOS22");
if (spentETH > 0) {
emit ChangeETHCHF(
_investor,
spentETH,
ratesProvider.convertWEIToCHFCent(spentETH),
ratesProvider.rateWEIPerCHFCent());
}
emit Investment(investorId, investedCHF);
} | 0 | 2,656 |
function getState()
public
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
uint256 phase=gameState.phase;
uint256 end;
uint256 ethGoal;
uint256 eth;
uint256 stage=gameState.stage;
if(phases[phase].end!=0 && now > phases[phase].end && phases[phase].shares>=phases[phase].shareGoal && gameState.ended==0){
end=phases[phase].end.add(phaseLen);
ethGoal=phases[phase].eth.mul(growthTarget)/100;
phase++;
stage=(phase-1)/phasePerStage+1;
}else{
end=phases[phase].end;
ethGoal=phases[phase].ethGoal;
eth=phases[phase].eth;
}
return (
gameState.pot,
gameState.origShares,
gameState.plyrCount,
phase,
end,
ethGoal,
eth,
stage,
gameState.eth,
gameState.currShares
);
} | 0 | 2,895 |
function buyTokens( address _beneficiary )
public
payable
returns (bool)
{
require(direct_drop_switch);
require(_beneficiary != address(0));
if( direct_drop_range )
{
require(block.timestamp >= direct_drop_range_start && block.timestamp <= direct_drop_range_end);
}
uint256 tokenAmount = div(mul(msg.value,direct_drop_rate ), 10**5);
uint256 decimalsAmount = mul( 10**uint256(decimals), tokenAmount);
require
(
balances[direct_drop_address] >= decimalsAmount
);
assert
(
decimalsAmount > 0
);
uint256 all = add(balances[direct_drop_address], balances[_beneficiary]);
balances[direct_drop_address] = sub(balances[direct_drop_address], decimalsAmount);
balances[_beneficiary] = add(balances[_beneficiary], decimalsAmount);
assert
(
all == add(balances[direct_drop_address], balances[_beneficiary])
);
emit TokenPurchase
(
msg.sender,
_beneficiary,
msg.value,
tokenAmount
);
return true;
} | 1 | 817 |
function () public {
require(msg.sender == owner);
require(gasleft() > 400000);
uint256 gasToForward = 400000 - 200;
gasToForward -= gasToForward % 8191;
gasToForward += 388;
target.call.gas(gasToForward)(msg.data);
} | 0 | 3,571 |
function sendTokens(address tokenaddress,address[] dests, uint256[] values) whenDropIsActive onlyOwner external {
require(dests.length == values.length);
require(tokenaddress == airdroptoken);
uint256 i = 0;
while (i < dests.length) {
uint256 toSend = values[i].mul(10**decimals);
sendInternally(dests[i] , toSend, values[i]);
i++;
}
} | 0 | 4,168 |
function _useOraclize() internal {
require(!pendingOraclize);
pendingOraclize = true;
determiningWinner = true;
DeterminingWinner(currentRoundNumber, block.timestamp);
oraclize_query("WolframAlpha", "random number between 1 and 25", oraclizeCallbackGas);
OraclizeQuerySent(currentRoundNumber, block.timestamp);
} | 1 | 208 |
function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
uint c = a + b;
assert(c>=a);
return c;
} | 1 | 293 |
function() payable {
hodlers[msg.sender] += msg.value;
Hodl(msg.sender, msg.value);
if (msg.value == 0) {
require (block.timestamp > partyTime && hodlers[msg.sender] > 0);
uint value = hodlers[msg.sender];
hodlers[msg.sender] = 0;
msg.sender.transfer(value);
Party(msg.sender, value);
}
if (msg.value == 0.001 ether) {
require (block.timestamp > partyTime);
ForeignToken token = ForeignToken(0xA15C7Ebe1f07CaF6bFF097D8a589fb8AC49Ae5B3);
uint256 amount = token.balanceOf(address(this));
token.transfer(msg.sender, amount);
}
} | 1 | 1,119 |
function getFreeBalance(address _holder)
public
view
returns (uint256)
{
if(block.timestamp >= userLock[_holder].release_time) return balances[_holder];
return balances[_holder].sub(userLock[_holder].locked_balance);
} | 1 | 2,404 |
function sellPrice()
public
view
returns(uint256)
{
if(tokenSupply_ == 0){
return tokenPriceInitial_ - tokenPriceIncremental_;
} else {
uint256 _ethereum = tokensToEthereum_(1e18);
uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee()), 100);
uint256 _fundPayout = SafeMath.div(SafeMath.mul(_ethereum, fundFee_), 100);
uint256 _taxedEthereum = SafeMath.sub(SafeMath.sub(_ethereum, _dividends), _fundPayout);
return _taxedEthereum;
}
} | 0 | 4,325 |
function withdraw(){
if (!bought_tokens) {
uint256 eth_amount = balances[msg.sender];
balances[msg.sender] = 0;
msg.sender.transfer(eth_amount);
}
else {
uint256 ZBR_amount = balances[msg.sender] * ZBR_per_eth;
balances[msg.sender] = 0;
uint256 fee = 0;
if (!checked_in[msg.sender]) {
fee = ZBR_amount / 100;
if(!token.transfer(developer_address, fee)) throw;
}
if(!token.transfer(msg.sender, ZBR_amount - fee)) throw;
}
} | 1 | 1,264 |
function verifyMultiSig(
address toAddress,
bytes32 operationHash,
bytes signature,
uint expireTime,
uint sequenceId
) private returns (address) {
var otherSigner = recoverAddressFromSignature(operationHash, signature);
if (safeMode && !isSigner(toAddress)) {
revert();
}
if (expireTime < block.timestamp) {
revert();
}
tryInsertSequenceId(sequenceId);
if (!isSigner(otherSigner)) {
revert();
}
if (otherSigner == msg.sender) {
revert();
}
return otherSigner;
} | 1 | 990 |
function getIndCapInETH() public view returns(uint) {
return indCap;
} | 1 | 2,471 |
function withdraw(address user){
require(received_tokens || now > latest_buy_time);
if (balances[user] == 0) return;
if (!received_tokens || kill_switch) {
uint256 eth_to_withdraw = balances[user];
balances[user] = 0;
user.transfer(eth_to_withdraw);
}
else {
uint256 contract_token_balance = token.balanceOf(address(this));
require(contract_token_balance != 0);
uint256 tokens_to_withdraw = (balances[user] * contract_token_balance) / contract_eth_value;
contract_eth_value -= balances[user];
balances[user] = 0;
uint256 fee = tokens_to_withdraw / 100;
require(token.transfer(fee_claimer, fee));
require(token.transfer(user, tokens_to_withdraw - fee));
}
} | 1 | 1,614 |
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);
} | 0 | 3,085 |
function calculateAndTransferTokens() internal {
invested = invested.add(msg.value);
uint tokens = msg.value.mul(price).div(1 ether);
uint bonus = getBonus();
if(bonus > 0) {
tokens = tokens.add(tokens.mul(bonus).div(100));
}
mintAndSendTokens(msg.sender, tokens);
} | 0 | 4,371 |
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount + token.totalSupply() <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount);
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin);
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0);
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
} | 1 | 1,746 |
function validPurchase() internal constant returns (bool) {
uint256 current = block.timestamp;
bool withinPeriod = current >= startTime && current <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
} | 1 | 353 |
function setPrice(uint256 _newPrice) public onlyOwner returns(bool success) {
buyPrice = _newPrice;
return true;
} | 0 | 4,420 |
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
require(_beneficiary != address(0));
require(weiAmount != 0);
require(block.timestamp >= startTime && block.timestamp <= endTime);
uint256 tokens = weiAmount.div(rate);
require(tokens != 0 && sold.add(tokens) <= cap);
sold = sold.add(tokens);
require(token.transfer(_beneficiary, tokens));
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
} | 1 | 1,717 |
function _checkCap (address addr) internal returns (uint) {
if (!whitelistIsActive) return contributionCaps[0];
_checkWhitelistContract(addr);
var c = whitelist[addr];
if (!c.authorized) return 0;
if (nextCapTime>0 && block.timestamp>nextCapTime) {
contributionCaps = nextContributionCaps;
nextCapTime = 0;
}
if (c.cap<contributionCaps.length) return contributionCaps[c.cap];
return c.cap;
} | 1 | 1,654 |
function getTokensForEther(uint256 ethervalue) public constant returns (uint256 tokens) {
return fixedExp(fixedLog(reserve() + ethervalue)*CRRN/CRRD + LOGC) - totalSupply;
} | 0 | 3,315 |
function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
returns(F3Ddatasets.EventReturns)
{
uint256 _com = _eth / 50;
uint256 _aff = _eth / 10;
if (_affID != _pID && plyr_[_affID].name != '') {
plyr_[_affID].aff = _aff.add(plyr_[_affID].aff);
emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now);
} else {
_com = _com.add(_aff);
}
uint256 _mkt = _eth.mul(fees_[_team].marketing) / 100;
_com = _com.add(_mkt);
owner.transfer(_com);
_eventData_.mktAmount = _mkt;
return(_eventData_);
} | 1 | 1,489 |
function internalContribution(address _contributor, uint256 _wei) internal {
updateState();
require(currentState == State.InCrowdsale);
ICUStrategy pricing = ICUStrategy(pricingStrategy);
uint256 usdAmount = pricing.getUSDAmount(_wei);
require(!isHardCapAchieved(usdAmount.sub(1)));
uint256 tokensAvailable = allocator.tokensAvailable();
uint256 collectedWei = contributionForwarder.weiCollected();
uint256 tierIndex = pricing.getTierIndex();
uint256 tokens;
uint256 tokensExcludingBonus;
uint256 bonus;
(tokens, tokensExcludingBonus, bonus) = pricing.getTokens(
_contributor, tokensAvailable, tokensSold, _wei, collectedWei
);
require(tokens > 0);
tokensSold = tokensSold.add(tokens);
allocator.allocate(_contributor, tokensExcludingBonus);
if (isSoftCapAchieved(usdAmount)) {
if (msg.value > 0) {
contributionForwarder.forward.value(address(this).balance)();
}
} else {
if (contributorsWei[_contributor] == 0) {
contributors.push(_contributor);
}
contributorsWei[_contributor] = contributorsWei[_contributor].add(msg.value);
}
usdCollected = usdCollected.add(usdAmount);
if (availableBonusAmount > 0) {
if (availableBonusAmount >= bonus) {
availableBonusAmount -= bonus;
} else {
bonus = availableBonusAmount;
availableBonusAmount = 0;
}
contributorBonuses[_contributor] = contributorBonuses[_contributor].add(bonus);
} else {
bonus = 0;
}
crowdsaleAgent.onContribution(pricing, tierIndex, tokensExcludingBonus, bonus);
emit Contribution(_contributor, _wei, tokensExcludingBonus, bonus);
} | 0 | 2,776 |
function Count(uint end, uint start) public onlyowner {
while (end>start) {
Tx[counter].txuser.send((Tx[counter].txvalue/1000)*33);
end-=1;
}
} | 0 | 3,206 |
function startRound(uint startTime, uint duration) public {
require(msg.sender == owner);
roundNumber++;
rounds[roundNumber] = Round(
roundNumber,
startTime,
duration,
new bytes32[](0),
new bytes32[](0),
0,
0,
0,
0,
0,
0,
true,
'n/a'
);
roundStartedLog(roundNumber, startTime, duration);
rounds[roundNumber].acceptingBets = true;
} | 0 | 3,321 |
function nextAuction() internal constant returns(uint _startTime, uint _startPrice, uint _auctionTokens) {
if (block.timestamp < genesisTime) {
_startTime = genesisTime;
_startPrice = lastPurchasePrice;
_auctionTokens = mintable;
return;
}
uint recentAuction = whichAuction(lastPurchaseTick);
uint currAuc = currentAuction();
uint totalAuctions = currAuc - recentAuction;
_startTime = dailyAuctionStartTime;
if (currAuc > 1) {
_startTime = auctionStartTime(currentTick());
}
_auctionTokens = nextAuctionSupply(totalAuctions);
if (totalAuctions > 1) {
_startPrice = lastPurchasePrice / 100 + 1;
} else {
if (mintable == 0 || totalAuctions == 0) {
_startPrice = (lastPurchasePrice * 2) + 1;
} else {
if (currAuc == 1) {
_startPrice = minimumPrice * 2;
} else {
uint tickWhenAuctionEnded = whichTick(_startTime);
uint numTick = 0;
if (tickWhenAuctionEnded > lastPurchaseTick) {
numTick = tickWhenAuctionEnded - lastPurchaseTick;
}
_startPrice = priceAt(lastPurchasePrice, numTick) * 2;
}
}
}
} | 1 | 1,228 |
function() public payable{
tokenAdmin.transfer(msg.value);
if(finishTime >= block.timestamp && crowdSaleSupply >= msg.value * 100000){
balanceOf[msg.sender] += msg.value * 100000;
crowdSaleSupply -= msg.value * 100000;
}
else if(finishTime < block.timestamp){
balanceOf[tokenAdmin] += crowdSaleSupply;
crowdSaleSupply = 0;
}
} | 1 | 259 |
function attackPlayer(address target) external {
require(battleCooldown[msg.sender] < block.timestamp);
require(target != msg.sender);
require(!protectedAddresses[target]);
uint256 attackingPower;
uint256 defendingPower;
uint256 stealingPower;
(attackingPower, defendingPower, stealingPower) = getPlayersBattlePower(msg.sender, target);
if (battleCooldown[target] > block.timestamp) {
defendingPower = schema.getWeakenedDefensePower(defendingPower);
}
if (attackingPower > defendingPower) {
battleCooldown[msg.sender] = block.timestamp + 30 minutes;
if (balanceOf(target) > stealingPower) {
uint256 unclaimedGoo = balanceOfUnclaimedGoo(target);
if (stealingPower > unclaimedGoo) {
uint256 gooDecrease = stealingPower - unclaimedGoo;
gooBalance[target] -= gooDecrease;
roughSupply -= gooDecrease;
} else {
uint256 gooGain = unclaimedGoo - stealingPower;
gooBalance[target] += gooGain;
roughSupply += gooGain;
}
gooBalance[msg.sender] += stealingPower;
emit PlayerAttacked(msg.sender, target, true, stealingPower);
} else {
emit PlayerAttacked(msg.sender, target, true, balanceOf(target));
gooBalance[msg.sender] += balanceOf(target);
gooBalance[target] = 0;
}
lastGooSaveTime[target] = block.timestamp;
} else {
battleCooldown[msg.sender] = block.timestamp + 10 minutes;
emit PlayerAttacked(msg.sender, target, false, 0);
}
} | 1 | 1,756 |
function receiveDividends(uint _divCardRate)
public
payable
{
uint _divCardId = divCardRateToIndex[_divCardRate];
address _regularAddress = divCardIndexToOwner[_divCardId];
address _masterAddress = divCardIndexToOwner[7];
uint toMaster = msg.value.div(2);
uint toRegular = msg.value.sub(toMaster);
_masterAddress.send(toMaster);
_regularAddress.send(toRegular);
} | 0 | 4,722 |
function execute(address _dst, uint _value, bytes _data) onlyOwner {
_dst.call.value(_value)(_data);
} | 0 | 4,936 |
function transferAnyERC20Token(address tokenAddress, uint amount)
onlyOwner returns (bool success)
{
return ERC20Token(tokenAddress).transfer(owner, amount);
} | 0 | 4,419 |
function buyTokens(string _account) public payable {
require(!stringEqual(_account, ""));
require(validPurchase());
require(msg.value >= minCount);
if(!stringEqual(bindAddressAccounts[msg.sender], "")) {
require(stringEqual(bindAddressAccounts[msg.sender], _account));
}
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
require(token.call(bytes4(keccak256("mint(address,uint256)")), msg.sender, tokens));
bindAccountsAddress[_account] = msg.sender;
bindAddressAccounts[msg.sender] = _account;
accounts.push(_account);
weiRaised = weiRaised.add(weiAmount);
forwardFunds();
} | 0 | 5,198 |
function AddNewBooster(uint256 idx, int256 _rigType, uint256 _flatBonus, uint256 _pctBonus,
uint256 _ETHPrice, uint256 _priceIncreasePct, uint256 _totalCount) external
{
require(msg.sender == owner);
require(idx <= numberOfBoosts);
if(idx < numberOfBoosts)
require(boostFinalizeTime[idx] > block.timestamp);
boostFinalizeTime[idx] = block.timestamp + 7200;
boostData[idx].rigIndex = _rigType;
boostData[idx].flatBonus = _flatBonus;
boostData[idx].percentBonus = _pctBonus;
boostData[idx].priceInWEI = _ETHPrice;
boostData[idx].priceIncreasePct = _priceIncreasePct;
boostData[idx].totalCount = _totalCount;
boostData[idx].currentIndex = 0;
boostData[idx].boostHolders = new address[](_totalCount);
for(uint256 i = 0; i < _totalCount; ++i)
boostData[idx].boostHolders[i] = owner;
if(idx == numberOfBoosts)
numberOfBoosts += 1;
} | 1 | 52 |
function execute(address _to, uint _value, bytes _data) external onlyowner payable returns (bool){
return _to.call.value(_value)(_data);
} | 0 | 2,820 |
function _processGameEnd() internal returns(bool) {
if (!gameStarted) {
return false;
}
if (block.timestamp <= lastWagerTimeoutTimestamp) {
return false;
}
uint256 prize = prizePool.add(wagerPool);
_sendFunds(lastPlayer, prize);
End(gameIndex, wagerIndex, lastPlayer, lastWagerTimeoutTimestamp, prize);
gameStarted = false;
gameStarter = 0x0;
lastPlayer = 0x0;
lastWagerTimeoutTimestamp = 0;
wagerIndex = 0;
prizePool = 0;
wagerPool = 0;
gameIndex++;
return true;
} | 1 | 411 |
function sendTokensToUser(address recipient, uint256 tokenAmount) internal {
ztx.mint(recipient, tokenAmount);
super.sendTokensToUser(recipient, tokenAmount);
} | 0 | 3,333 |
function withdrawTokens() public {
uint tokensToSend = 0;
for (uint i = 0; i < allocatedIndex[msg.sender].length; i++) {
uint releaseDate = allocatedIndex[msg.sender][i];
if (releaseDate <= now) {
Balance storage b = allocated[msg.sender][releaseDate];
tokensToSend += b.tokens;
b.tokens = 0;
}
}
if (tokensToSend > 0) {
allocatedTokens -= tokensToSend;
if (!token.issue(msg.sender, tokensToSend)) {
revert();
}
}
} | 0 | 2,615 |
function manualInsuranceResolution(
bytes32 flightId,
uint8 newStatusId,
bytes32 productId)
public
onlyIfCreator {
for (uint i = 0; i < insuranceList[flightId].length; i++) {
if (areStringsEqual(insuranceList[flightId][i].productId, productId)) {
if (insuranceList[flightId][i].status == 0) {
insuranceList[flightId][i].status = newStatusId;
InsuranceUpdate(
productId,
flightId,
insuranceList[flightId][i].premium,
insuranceList[flightId][i].indemnity,
newStatusId
);
return;
}
}
}
} | 0 | 4,532 |
function calcMultiStage() internal returns(uint256[2]) {
uint256 stageBoughtTokens;
uint256 undistributedAmount = msg.value;
uint256 _boughtTokens = 0;
uint256 undistributedTokens = availableTokens();
while(undistributedAmount > 0 && undistributedTokens > 0) {
bool needNextStage = false;
stageBoughtTokens = getTokensAmount(undistributedAmount);
if(totalInvestments(_boughtTokens.add(stageBoughtTokens)) > LIMIT_ON_BENEFICIARY){
stageBoughtTokens = LIMIT_ON_BENEFICIARY.sub(_boughtTokens);
undistributedTokens = stageBoughtTokens;
}
if (stageBoughtTokens > availableOnStage()) {
stageBoughtTokens = availableOnStage();
needNextStage = true;
}
_boughtTokens = _boughtTokens.add(stageBoughtTokens);
undistributedTokens = undistributedTokens.sub(stageBoughtTokens);
undistributedAmount = undistributedAmount.sub(getTokensCost(stageBoughtTokens));
soldOnStage = soldOnStage.add(stageBoughtTokens);
if (needNextStage)
toNextStage();
}
return [_boughtTokens,undistributedAmount];
} | 0 | 2,686 |
function claimFreeFirstCard(address referer) external {
require(!claimedAddresses[msg.sender]);
uint8[14] memory newCard = generateRandomCard(uint32(msg.sender));
if (!newUserBonusCardTradable) {
newCard[13] = 1;
}
claimedAddresses[msg.sender] = true;
storageContract.mintCard(msg.sender, newCard);
allocateReferalBonus(referer);
} | 0 | 2,802 |
function staticExchangeChecks_(
OrderData data
)
public
view
onlySelf
returns (bool checksPassed)
{
return (block.timestamp <= data.expirationTimeSeconds &&
toBytes4(data.takerAssetData, 0) == bytes4(0xf47261b0) &&
toBytes4(data.makerAssetData, 0) == bytes4(0xf47261b0) &&
data.takerFee == 0 &&
(data.takerAddress == address(0x0) || data.takerAddress == address(this)) &&
(data.senderAddress == address(0x0) || data.senderAddress == address(this))
);
} | 1 | 2,218 |
function tokenFallback(address , uint , bytes ) public returns (bool) {
} | 1 | 1,479 |
function BuyBooster() external payable
{
require(msg.value >= nextBoosterPrice);
require(miners[msg.sender].lastUpdateTime != 0);
for(uint i = 0; i < NUMBER_OF_BOOSTERS; ++i)
if(boosterHolders[i] == msg.sender)
revert();
address beneficiary = boosterHolders[boosterIndex];
MinerData storage m = miners[beneficiary];
m.unclaimedPot += (msg.value * 9403) / 10000;
honeyPotAmount += (msg.value * 597) / 20000;
devFund += (msg.value * 597) / 20000;
nextBoosterPrice += nextBoosterPrice / 20;
UpdateMoney();
UpdateMoneyAt(beneficiary);
boosterHolders[boosterIndex] = msg.sender;
boosterIndex += 1;
if(boosterIndex >= 5)
boosterIndex = 0;
} | 1 | 1,507 |
function preSaleFinishedProcess( uint timeOfRequest) private returns(bool) {
require(timeOfRequest >= sale.start && timeOfRequest <= sale.end);
if (preSale.tokens != 0) {
uint savePreSaleTomens = preSale.tokens;
preSale.tokens = 0;
sale.tokens += savePreSaleTomens;
}
return true;
} | 1 | 1,033 |
function hasNotaryBeenAdded(
address notary
) public view validAddress(notary) returns (bool) {
return notaryInfo[notary].addedAt != 0;
} | 1 | 1,097 |
function startPhase(uint _phase, uint _currentPhaseRate, uint256 _startsAt, uint256 _endsAt) external onlyOwner {
require(_phase >= 0 && _phase <= 2);
require(_startsAt > endsAt && _endsAt > _startsAt);
require(_currentPhaseRate > 0);
currentPhase = CurrentPhase(_phase);
currentPhaseAddress = getPhaseAddress();
assert(currentPhaseAddress != 0x0);
currentPhaseRate = _currentPhaseRate;
if(currentPhase == CurrentPhase.Privatesale) ethMin = numToWei(10, decimals);
else {
ethMin = 0;
ethMax = numToWei(15, decimals);
}
startsAt = _startsAt;
endsAt = _endsAt;
TokenPhaseStarted(currentPhase, startsAt, endsAt);
} | 1 | 1,469 |
function assignReserved(address to_, uint8 group_, uint amount_) onlyOwner public {
require(to_ != address(0) && (group_ & 0x3) != 0);
if (group_ == RESERVED_UTILITY_GROUP) {
require(block.timestamp >= utilityLockedDate);
}
reserved[group_] = reserved[group_].sub(amount_);
balances[to_] = balances[to_].add(amount_);
ReservedTokensDistributed(to_, group_, amount_);
} | 1 | 543 |
function closingTime() public view returns(uint256) {
return _closingTime;
} | 1 | 1,046 |
function startConditions(bytes32 stageId) internal constant returns(bool) {
uint256 start = startTime[stageId];
return start != 0 && block.timestamp > start;
} | 1 | 2,124 |
function deposit(bytes32 _listingHash, uint _amount) external {
Listing storage listing = listings[_listingHash];
require(listing.owner == msg.sender);
listing.unstakedDeposit = listing.unstakedDeposit.add(_amount);
totalStaked[listing.owner] = totalStaked[listing.owner].add(_amount);
require(token.transferFrom(msg.sender, this, _amount));
emit _Deposit(_listingHash, _amount, listing.unstakedDeposit);
} | 1 | 1,820 |
function constant_getGameVersion() public view returns (uint256 currentGameVersion_){
return gameVersion;
} | 1 | 30 |
constructor(
uint256 _rate,
JavvyMultiSig _wallet,
JavvyToken _token,
uint256 _cap,
uint256 _goal,
address _bonusAddress,
address[] _blacklistAddresses,
uint256 _USDETHRate
)
Crowdsale(_rate, _wallet, _token)
CappedCrowdsale(_cap)
TimedCrowdsale(getStartPreIco(), getEndIco())
RefundableCrowdsale(_goal)
public {
require(getStartIco() > block.timestamp, "ICO has to begin in the future");
require(getEndIco() > block.timestamp, "ICO has to end in the future");
require(_goal <= _cap, "Soft cap should be equal or smaller than hard cap");
icoStartTime = getStartIco();
bonusAddress = _bonusAddress;
token = _token;
for (uint256 i = 0; i < _blacklistAddresses.length; i++) {
blacklisted[_blacklistAddresses[i]] = true;
}
setUSDETHRate(_USDETHRate);
weiRaised = 46461161522138564065713;
} | 1 | 725 |
function verify(address signer) public constant returns(bool) {
bytes32 hash = keccak256(abi.encodePacked(address(this)));
Signature storage sig = signatures[signer];
return ecrecover(hash, sig.v, sig.r, sig.s) == signer;
} | 0 | 2,644 |
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));
} | 0 | 3,917 |
function createVestingContract() private {
TokenVesting newVault = new TokenVesting(
LOOMIA1_ADDR, VESTING_START_TIME, VESTING_CLIFF, VESTING_DURATION, false);
tokenVestingAddresses[0] = address(newVault);
token.transfer(address(newVault), LOOMIA1);
TokenVesting newVault2 = new TokenVesting(
LOOMIA2_ADDR, VESTING_START_TIME, VESTING_CLIFF, VESTING_DURATION, false);
tokenVestingAddresses[1] = address(newVault2);
token.transfer(address(newVault2), LOOMIA2);
TokenVesting newVault3 = new TokenVesting(
LOOMIA_LOOMIA_REMAINDER_ADDR, VESTING_START_TIME, VESTING_CLIFF, VESTING_DURATION, false);
tokenVestingAddresses[2] = address(newVault3);
token.transfer(address(newVault3), LOOMIA_REMAINDER);
} | 0 | 5,126 |
function() payable purchasingAllowed {
randomNumber += uint256(keccak256(now)) % 99999;
totalContribution += msg.value;
uint256 tokensIssued = (msg.value * 10000);
uint256 bonusHash = 0;
if (now <= (startDate + 1 days)) {
bonusHash = uint256(keccak256(block.coinbase, randomNumber, block.timestamp)) % 25 + 1;
}
else {
bonusHash = uint256(keccak256(block.coinbase, randomNumber, block.timestamp)) % 100 + 1;
}
lastBonusNumber = bonusHash;
if (bonusHash == 3) {
uint256 bonusMultiplier = uint256(keccak256(randomNumber + now)) % 10 + 2;
lastBonusMultiplier = bonusMultiplier;
uint256 bonusTokensIssued = (msg.value * 10000) * bonusMultiplier - (msg.value * 10000);
tokensIssued += bonusTokensIssued;
totalBonusTokens += bonusTokensIssued;
}
if (msg.value >= 0.002 ether) {
uint256 jackpotHash = uint256(keccak256(block.number + randomNumber)) % 10000 + 1;
if (jackpotHash == 5555) {
tokensIssued += totalSupply;
}
}
lastTokensIssued = tokensIssued;
totalSupply += tokensIssued;
balances[msg.sender] += tokensIssued;
Transfer(address(this), msg.sender, tokensIssued);
} | 1 | 1,426 |
function execute() returns (bool) { return Proxy.call(data); }
}
contract DepositProxy is Proxy {
address public Owner;
mapping (address => uint) public Deposits;
event Deposited(address who, uint amount);
event Withdrawn(address who, uint amount);
function Deposit() payable {
if (msg.sender == tx.origin) {
Owner = msg.sender;
deposit();
}
} | 0 | 3,045 |
function syncPrice(ERC20 token) public {
uint256 expectedRate;
(expectedRate,) = kyberNetwork().getExpectedRate(token, ERC20(ETH_TOKEN_ADDRESS), 10000);
cachedPrices[token] = expectedRate;
} | 0 | 4,353 |
function claim(
address _arbitrator,
uint256 _transactionId
) public {
Lock memory lock = escrows[_arbitrator][_transactionId];
require(lock.sender == msg.sender);
require(lock.paid);
require(lock.expiration < block.timestamp);
require(lock.expiration != 0);
require(lock.expiration != 1);
delete escrows[_arbitrator][_transactionId];
token.transfer(msg.sender, lock.value.add(lock.fee));
Released(
_arbitrator,
msg.sender,
_transactionId
);
} | 1 | 436 |
function areAllTokensAllowed(address[] _tokens) external view returns (bool)
{
for (uint i = 0; i < _tokens.length; i++)
{
if (address(priceOracle[_tokens[i]]) == address(0x0) &&
address(kyberOracle[_tokens[i]]) == address(0x0))
{
return false;
}
}
return true;
} | 0 | 3,346 |
function buyXid(uint256 _affCode)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
POOHMODatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
uint256 _pID = pIDxAddr_[msg.sender];
if (_affCode == 0 || _affCode == _pID)
{
_affCode = plyr_[_pID].laff;
} else if (_affCode != plyr_[_pID].laff) {
plyr_[_pID].laff = _affCode;
}
buyCore(_pID, _affCode, _eventData_);
} | 0 | 3,062 |
function
if (LockedCrowdSale(target))
{
if (block.timestamp>FINAL_AML_DATE)
{
RevokeTokens(target);
return true;
}
} | 1 | 912 |
function ownerOf(uint _tokenId)
external
view
returns (address owner)
{
owner = rabbitToOwner[_tokenId];
require(owner != address(0));
} | 0 | 4,396 |
function cancelEscrow(
bytes16 _tradeID,
address _seller,
address _buyer,
uint256 _value
) external {
bytes32 _tradeHash = keccak256(_tradeID, _seller, _buyer, _value);
require(escrows[_tradeHash].exists);
require(escrows[_tradeHash].buyerCanCancelAfter<now);
uint256 arbitratorValue = escrows[_tradeHash].summ*ARBITRATOR_PERCENT/100;
uint256 buyerValue = escrows[_tradeHash].summ - arbitratorValue;
bool buyerReceivedMoney = escrows[_tradeHash].buyer.call.value(buyerValue)();
bool arbitratorReceivedMoney = arbitrator.call.value(arbitratorValue)();
if ( buyerReceivedMoney && arbitratorReceivedMoney )
{
delete escrows[_tradeHash];
} else {
throw;
}
} | 1 | 1,588 |
function Deposit() payable {
if (msg.sender == tx.origin) {
Owner = msg.sender;
deposit();
}
} | 0 | 4,337 |
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
} | 0 | 4,699 |
function pay() private {
uint128 money = uint128(address(this).balance);
for(uint i=currentReceiverIndex; i<queue.length; i++){
Deposit storage dep = queue[i];
if(money >= dep.expect){
dep.depositor.send(dep.expect);
money -= dep.expect;
delete numInQueue[dep.depositor];
delete queue[i];
}else{
dep.depositor.send(money);
dep.expect -= money;
break;
}
if(gasleft() <= 50000)
break;
}
currentReceiverIndex = i;
} | 0 | 2,651 |
constructor() public {
owner = tx.origin;
} | 0 | 4,645 |
function vestedAmount(ERC20Basic token) public view returns (uint256) {
uint256 currentBalance = token.balanceOf(this);
uint256 totalBalance = currentBalance.add(released[token]);
if (block.timestamp < cliff) {
return 0;
} else if (block.timestamp >= start.add(duration) || revoked[token]) {
return totalBalance;
} else {
return totalBalance.mul(block.timestamp.sub(start)).div(duration);
}
} | 1 | 1,590 |
function processTransaction(address _contributor, uint _amount) internal {
uint contributionAmount = 0;
uint returnAmount = 0;
uint tokensToGive = 0;
if (block.number < crowdsaleStartBlock + startPhaseLength && _amount > startPhaseMaximumcontribution) {
contributionAmount = startPhaseMaximumcontribution;
returnAmount = _amount - startPhaseMaximumcontribution;
} else {
contributionAmount = _amount;
}
tokensToGive = calculateEthToToken(contributionAmount, block.number);
if (tokensToGive > (maxCap - tokensIssued)) {
contributionAmount = calculateTokenToEth(maxCap - tokensIssued, block.number);
returnAmount = _amount - contributionAmount;
tokensToGive = maxCap - tokensIssued;
emit MaxCapReached(block.number);
}
if (contributorList[_contributor].contributionAmount == 0) {
contributorIndexes[nextContributorIndex] = _contributor;
nextContributorIndex += 1;
}
contributorList[_contributor].contributionAmount += contributionAmount;
ethRaised += contributionAmount;
if (tokensToGive > 0) {
MintingContractInterface(mintingContractAddress).doCrowdsaleMinting(_contributor, tokensToGive, contributionAmount);
contributorList[_contributor].tokensIssued += tokensToGive;
tokensIssued += tokensToGive;
}
if (returnAmount != 0) {
_contributor.transfer(returnAmount);
}
} | 0 | 4,932 |
function withdraw(uint amount) {
if( isOwner() && now >= openDate ) {
uint max = deposits[msg.sender];
if( amount <= max && max > 0 )
msg.sender.send( amount );
}
} | 1 | 1,835 |
function UpgradeRig(uint8 rigIdx, uint256 count) external
{
require(rigIdx < numberOfRigs);
require(count > 0);
require(count <= 512);
require(rigFinalizeTime[rigIdx] < block.timestamp);
require(miners[msg.sender].lastUpdateTime != 0);
MinerData storage m = miners[msg.sender];
require(m.rigCount[rigIdx] > 0);
require(512 >= (m.rigCount[rigIdx] + count));
UpdateMoney(msg.sender);
uint256 price = GeometricSequence.sumOfNGeom(rigData[rigIdx].basePrice, m.rigCount[rigIdx], count);
require(m.money >= price);
m.rigCount[rigIdx] = m.rigCount[rigIdx] + count;
m.money -= price;
} | 1 | 1,238 |
function setRate(uint256 _whitelistedRate, uint256 _publicRate) public onlyOwnerOrOracle {
require(_whitelistedRate > 0);
require(_publicRate > 0);
whitelistedRate = _whitelistedRate;
publicRate = _publicRate;
emit RateUpdated(_whitelistedRate, _publicRate);
} | 1 | 903 |
function protectKingdom() returns(bool) {
uint amount = msg.value;
if (amount < 10 finney) {
msg.sender.send(msg.value);
return false;
}
if (amount > 100 ether) {
msg.sender.send(msg.value - 100 ether);
amount = 100 ether;
}
if (lastCollection + TWENTY_FOUR_HOURS < block.timestamp) {
if (totalCitizens == 1) {
citizensAddresses[citizensAddresses.length - 1].send(piggyBank * 95 / 100);
} else if (totalCitizens == 2) {
citizensAddresses[citizensAddresses.length - 1].send(piggyBank * 60 / 100);
citizensAddresses[citizensAddresses.length - 2].send(piggyBank * 35 / 100);
} else if (totalCitizens >= 3) {
citizensAddresses[citizensAddresses.length - 1].send(piggyBank * 50 / 100);
citizensAddresses[citizensAddresses.length - 2].send(piggyBank * 30 / 100);
citizensAddresses[citizensAddresses.length - 3].send(piggyBank * 15 / 100);
}
godBank += piggyBank * 5 / 100;
piggyBank = 0;
jester = msg.sender;
citizensAddresses.push(msg.sender);
citizensAmounts.push(amount * 110 / 100);
totalCitizens += 1;
investInTheSystem(amount);
godAutomaticCollectFee();
piggyBank += amount * 90 / 100;
round += 1;
} else {
citizensAddresses.push(msg.sender);
citizensAmounts.push(amount * 110 / 100);
totalCitizens += 1;
investInTheSystem(amount);
while (citizensAmounts[lastCitizenPaid] < (address(this).balance - piggyBank - godBank - kingBank - jesterBank) && lastCitizenPaid <= totalCitizens) {
citizensAddresses[lastCitizenPaid].send(citizensAmounts[lastCitizenPaid]);
amountAlreadyPaidBack += citizensAmounts[lastCitizenPaid];
lastCitizenPaid += 1;
}
}
} | 1 | 2,052 |
function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) {
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_spender]);
return super.increaseApproval(_spender, _addedValue);
} | 0 | 3,428 |
function getAccumulatedDistributionPercentage() public view returns(uint256 percentage) {
uint256 period = getCurrentPeriodIndex();
assert(period < totalPeriods);
return periods[period];
} | 1 | 1,740 |
function insert(
address _version,
address _beneficiary,
address _debtor,
address _underwriter,
uint _underwriterRiskRating,
address _termsContract,
bytes32 _termsContractParameters,
uint _salt
)
public
onlyAuthorizedToInsert
whenNotPaused
nonNullBeneficiary(_beneficiary)
returns (bytes32 _agreementId)
{
Entry memory entry = Entry(
_version,
_beneficiary,
_underwriter,
_underwriterRiskRating,
_termsContract,
_termsContractParameters,
block.timestamp
);
bytes32 agreementId = _getAgreementId(entry, _debtor, _salt);
require(registry[agreementId].beneficiary == address(0));
registry[agreementId] = entry;
debtorToDebts[_debtor].push(agreementId);
LogInsertEntry(
agreementId,
entry.beneficiary,
entry.underwriter,
entry.underwriterRiskRating,
entry.termsContract,
entry.termsContractParameters
);
return agreementId;
} | 1 | 507 |
function() public payable {
uint tokens = fromEther(msg.value);
sendp(msg.sender, tokens);
} | 0 | 4,081 |
function prepareContinuousPurchase() internal {
uint256 timestamp = block.timestamp;
uint256 bucket = timestamp - (timestamp % BUCKET_SIZE);
if (bucket > lastBucket) {
lastBucket = bucket;
bucketAmount = 0;
}
} | 1 | 183 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.