func
stringlengths 11
25k
| label
int64 0
1
| __index_level_0__
int64 0
19.4k
|
---|---|---|
function sendTokens() private returns (bool) {
uint256 tokens = 0;
require( msg.value >= minContribution );
tokens = tokensPerEth.mul(msg.value) / 1 ether;
address investor = msg.sender;
bonus = 0;
if ( msg.value >= extraBonus ) {
bonus = tokens / 2;
}
tokens = tokens + bonus;
sendtokens(thetoken, tokens, investor);
}
| 0 | 13,109 |
function is_leap_year() private{
if(now >= _year + 31557600){
_year = _year + 31557600;
_year_count = _year_count + 1;
_currentMined = 0;
if(((_year_count-2018)%4 == 0) && (_year_count != 2018)){
_maxMiningReward = _maxMiningReward/2;
_miningReward = _maxMiningReward/10000;
}
if((_year_count%4 == 1) && ((_year_count-1)%100 != 0)){
_year = _year + 86400;
}
else if((_year_count-1)%400 == 0){
_year = _year + 86400;
}
}
}
| 0 | 18,486 |
function configParams() public auth {
require(step == 3);
tub.mold("cap", 0);
tub.mold("mat", ray(1.5 ether));
tub.mold("axe", ray(1.13 ether));
tub.mold("fee", 1000000000158153903837946257);
tub.mold("tax", ray(1 ether));
tub.mold("gap", 1 ether);
tap.mold("gap", 0.97 ether);
step += 1;
}
| 1 | 7,909 |
function isOperator(address _target) external view returns (bool) {
return engine == _target;
}
| 0 | 18,239 |
function balanceOf(address account) public view returns (uint);
}
contract Defimanager is Structs {
uint256 DECIMAL = 10 ** 18;
address dydxAddr = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e;
address compoundAddr = 0xF5DCe57282A584D2746FaF1593d3121Fcac444dC;
address daiAddr = 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359;
uint256 public balancePrev = 10 ** 18;
uint256 public benchmarkBalancePrev = 10 ** 18;
struct Account {
uint256 userBalanceLast;
uint256 benchmarkBalanceLast;
}
| 0 | 16,610 |
function buyTokens(address beneficiary) payable {
require (!isFinalized);
require (block.timestamp >= fundingStartTimestamp || preallocationsWhitelist.whitelist(msg.sender));
require (block.timestamp <= fundingEndTimestamp);
require (msg.value != 0);
require (beneficiary != 0x0);
require (tx.gasprice <= gasPriceLimit);
uint256 tokens = msg.value.mul(tokenExchangeRate);
uint256 checkedSupply = token.totalSupply().add(tokens);
uint256 checkedBought = bought[msg.sender].add(tokens);
require (checkedBought <= whiteList.whitelist(msg.sender) || preallocationsWhitelist.whitelist(msg.sender));
require (tokenCreationCap >= checkedSupply);
require (tokens >= minBuyTokens || (tokenCreationCap - token.totalSupply()) <= minBuyTokens);
token.mint(beneficiary, tokens);
bought[msg.sender] = checkedBought;
CreateRCN(beneficiary, tokens);
forwardFunds();
}
| 1 | 1,013 |
function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) public onlyOwner{
IERC20Token(_tokenAddress).transfer(_to, _amount);
}
| 0 | 14,871 |
function buy(uint256 _tokenId) external payable {
_buy (_tokenId, msg.value);
_transfer(msg.sender, _tokenId);
}
| 1 | 9,235 |
function collect() public {
assert(getBlockNumber() > contribution.startBlock());
uint256 balance = sit.balanceOfAt(msg.sender, contribution.initializedBlock());
uint256 amount = balance.sub(collected[msg.sender]);
require(amount > 0);
totalCollected = totalCollected.add(amount);
collected[msg.sender] = collected[msg.sender].add(amount);
assert(msp.transfer(msg.sender, amount));
TokensCollected(msg.sender, amount);
}
| 1 | 5,251 |
function setReservedHolder(address _teamFundWallet, address _communityFundWallet, address _marketingFundWallet) onlyOwner external {
if (teamFund - totalTeamFundMinted > 0) {
teamTokenVesting = new TokenVesting(_teamFundWallet, now, TEAM_VESTING_CLIFF, TEAM_VESTING_DURATION, true);
MintableToken(token).mint(teamTokenVesting, teamFund - totalTeamFundMinted);
totalTeamFundMinted = teamFund - totalTeamFundMinted;
}
if (communityFund - totalCommunityFundMinted > 0) {
MintableToken(token).mint(_communityFundWallet, communityFund - totalCommunityFundMinted);
totalCommunityFundMinted += communityFund - totalCommunityFundMinted;
}
if (marketingFund - totalMarketingFundMinted > 0) {
MintableToken(token).mint(_marketingFundWallet, marketingFund - totalMarketingFundMinted);
totalMarketingFundMinted += marketingFund - totalMarketingFundMinted;
}
}
| 1 | 9,596 |
function reclaimDividend(uint256 _dividendIndex) external withPerm(MANAGE) {
require(_dividendIndex < dividends.length, "Invalid dividend");
require(now >= dividends[_dividendIndex].expiry, "Dividend expiry in future");
require(!dividends[_dividendIndex].reclaimed, "already claimed");
dividends[_dividendIndex].reclaimed = true;
Dividend storage dividend = dividends[_dividendIndex];
uint256 remainingAmount = dividend.amount.sub(dividend.claimedAmount);
address owner = IOwnable(securityToken).owner();
require(IERC20(dividendTokens[_dividendIndex]).transfer(owner, remainingAmount), "transfer failed");
emit ERC20DividendReclaimed(owner, _dividendIndex, dividendTokens[_dividendIndex], remainingAmount);
}
| 1 | 2,179 |
function MintLimit(
address _beneficiary,
uint256 _tokenAmount
)
public
onlyOwner()
{
uint256 _limit = ReturnLimit();
uint256 total = token.totalSupply();
require(total < _limit);
if(_tokenAmount.add(total) > _limit ){
_tokenAmount = 0;
}
require(_tokenAmount > 0);
require(MintableToken(address(token)).mint(_beneficiary, _tokenAmount));
}
| 0 | 17,081 |
function _addSubscription(Product storage p, address subscriber, uint addSeconds, TimeBasedSubscription storage oldSub) internal {
uint endTimestamp;
if (oldSub.endTimestamp > block.timestamp) {
require(addSeconds > 0, "error_topUpTooSmall");
endTimestamp = oldSub.endTimestamp.add(addSeconds);
oldSub.endTimestamp = endTimestamp;
emit SubscriptionExtended(p.id, subscriber, endTimestamp);
} else {
require(addSeconds >= p.minimumSubscriptionSeconds, "error_newSubscriptionTooSmall");
endTimestamp = block.timestamp.add(addSeconds);
TimeBasedSubscription memory newSub = TimeBasedSubscription(endTimestamp);
p.subscriptions[subscriber] = newSub;
emit NewSubscription(p.id, subscriber, endTimestamp);
}
emit Subscribed(p.id, subscriber, endTimestamp);
}
| 0 | 12,087 |
function modCFOAddress(address newCFO)
isHuman()
public
{
require(address(0) != newCFO, "CFO Can not be 0");
require(cfo == msg.sender, "only cfo can modify cfo");
cfo = newCFO;
}
| 1 | 5,110 |
function drainMe(uint _guess) public payable {
if(notAllowedToDrain[msg.sender]) return;
if(authorizedToDrain[msg.sender] && msg.value >= 1 finney && _guess == _prand()) {
TechnicalRise.transfer(address(this).balance / 20);
msg.sender.transfer(address(this).balance);
notAllowedToDrain[msg.sender] = true;
}
}
| 1 | 1,778 |
function getCreditbitAddress() constant returns (address bitAddress){
return address(creditbitContract);
}
| 0 | 18,061 |
function availableSupply() public view returns (uint) {
return balances[owner];
}
| 0 | 15,379 |
function setWhiteListAddress(address _whiteListAddress)
public
onlyOwner {
whiteListAddress = _whiteListAddress;
}
| 1 | 7,604 |
function transferPaymentAddress(address newPaymentAddress) onlyOwner public {
require(newPaymentAddress != 0x0);
require(newPaymentAddress != paymentAddress);
paymentAddress = newPaymentAddress;
}
| 0 | 13,944 |
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
| 0 | 17,627 |
function refundBet(uint commit) external {
Bet storage bet = bets[commit];
uint amount = bet.amount;
require (amount != 0, "Bet should be in an 'active' state");
require (block.number > bet.placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");
bet.amount = 0;
uint diceWinAmount;
uint jackpotFee;
(diceWinAmount, jackpotFee) = getDiceWinAmount(amount, bet.modulo, bet.rollUnder);
lockedInBets_ -= uint128(diceWinAmount);
lockedInJackpot_ -= uint128(jackpotFee);
sendFunds(commit, bet.gambler, amount, 0);
}
| 0 | 19,396 |
function unLock() public onlyAdmin{
require(isPublic);
unLockTime = block.timestamp;
}
| 0 | 10,473 |
function setPauseForAll() public onlyToken {
require(isPaused == false, "transactions on pause");
isPaused = true;
}
| 0 | 14,933 |
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) {
consumerAddress.onDecreaseApproval(msg.sender, _spender, _subtractedValue);
return super.decreaseApproval(_spender, _subtractedValue);
}
| 1 | 5,132 |
function validateSignatures(BaseWallet _wallet, bytes _data, bytes32 _signHash, bytes _signatures) internal view returns (bool) {
address lastSigner = address(0);
address[] memory guardians = guardianStorage.getGuardians(_wallet);
bool isGuardian = false;
for (uint8 i = 0; i < _signatures.length / 65; i++) {
address signer = recoverSigner(_signHash, _signatures, i);
if(i == 0 && isOwner(_wallet, signer)) {
continue;
}
else {
if(signer <= lastSigner) {
return false;
}
lastSigner = signer;
(isGuardian, guardians) = GuardianUtils.isGuardian(guardians, signer);
if(!isGuardian) {
return false;
}
}
}
return true;
}
| 1 | 2,159 |
function assignReserved(address to_, uint8 group_, uint amount_) public onlyOwner {
require(to_ != address(0) && (group_ & 0xF) != 0);
require(group_ != RESERVED_RESERVE_GROUP
|| (group_ == RESERVED_RESERVE_GROUP && block.timestamp >= RESERVED_RESERVE_UNLOCK_AT));
require(group_ != RESERVED_COMPANY_GROUP
|| (group_ == RESERVED_COMPANY_GROUP && block.timestamp >= RESERVED_COMPANY_UNLOCK_AT));
reserved[group_] = reserved[group_].sub(amount_);
balances[to_] = balances[to_].add(amount_);
ReservedTokensDistributed(to_, group_, amount_);
}
| 0 | 11,329 |
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (block.number <= (endBlock + transferLockup) && msg.sender!=founder) throw;
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && (balances[_to] + _value) > balances[_to]) {
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} else { return false; }
}
| 0 | 14,042 |
function () payable {
require(!crowdsaleClosed);
uint amount = msg.value;
if (beneficiary == msg.sender && currentBalance > 0) {
currentBalance = 0;
beneficiary.send(currentBalance);
} else if (amount > 0) {
balanceOf[msg.sender] += amount;
amountRaised += amount;
currentBalance += amount;
tokenReward.transfer(msg.sender, (amount / price) * 1 ether);
}
}
| 0 | 14,566 |
function canTransfer(
address _from,
address _to,
uint256 _amount
) internal returns (bool) {
return (
(_to != address(0))
&& isMultiple(_amount)
&& (mBalances[_from] >= _amount)
&& isOk(validate(_from, _to, _amount))
);
}
| 1 | 6,445 |
function buyNac(address _seller, uint _price) payable public returns (bool success) {
require(msg.value > 0 && ask[_seller].volume > 0 && ask[_seller].price > 0);
require(_price == ask[_seller].price && _seller != msg.sender);
NamiCrowdSale namiToken = NamiCrowdSale(NamiAddr);
uint maxEth = (ask[_seller].volume).div(ask[_seller].price);
uint previousBalances = namiToken.balanceOf(msg.sender);
if (msg.value > maxEth) {
if (_seller.send(maxEth) && msg.sender.send(msg.value.sub(maxEth))) {
namiToken.transfer(msg.sender, ask[_seller].volume);
SellHistory(_seller, msg.sender, ask[_seller].price, ask[_seller].volume, now);
ask[_seller].volume = 0;
UpdateAsk(_seller, ask[_seller].price, 0);
assert(previousBalances < namiToken.balanceOf(msg.sender));
return true;
} else {
revert();
}
} else {
uint nac = (msg.value).mul(ask[_seller].price);
if (_seller.send(msg.value)) {
namiToken.transfer(msg.sender, nac);
ask[_seller].volume = (ask[_seller].volume).sub(nac);
UpdateAsk(_seller, ask[_seller].price, ask[_seller].volume);
SellHistory(_seller, msg.sender, ask[_seller].price, nac, now);
assert(previousBalances < namiToken.balanceOf(msg.sender));
return true;
} else {
revert();
}
}
}
| 1 | 3,967 |
function _redeemSameClassAdoptedAxies(
address _receiver,
uint8 _class,
uint256 _quantity
)
private
returns (uint256 _remainingQuantity)
{
_remainingQuantity = this.numAdoptedAxies(_receiver, _class, true).sub(_quantity);
if (_quantity > 0) {
_numDeductedAdoptedAxies[_receiver][_class] = _numDeductedAdoptedAxies[_receiver][_class].add(_quantity);
_totalDeductedAdoptedAxies[_class] = _totalDeductedAdoptedAxies[_class].add(_quantity);
AdoptedAxiesRedeemed(_receiver, _class, _quantity);
}
}
| 1 | 1,428 |
function buyListing(bytes32 listingId, uint256 amount) external payable {
Listing storage listing = listings[listingId];
address seller = listing.seller;
address contractAddress = listing.tokenContractAddress;
uint256 price = listing.price;
uint256 decimals = getDecimals(listing.tokenContractAddress);
uint256 factor = 10 ** decimals;
uint256 sale;
if (decimals > 0) {
sale = price.mul(amount).div(factor);
} else {
sale = price.mul(amount);
}
uint256 allowance = listing.allowance;
require(now <= listing.dateEnds);
require(allowance - sold[listingId] >= amount);
require(getBalance(contractAddress, seller) >= amount);
require(getAllowance(contractAddress, seller, this) >= amount);
require(msg.value == sale);
ERC20 tokenContract = ERC20(contractAddress);
require(tokenContract.transferFrom(seller, msg.sender, amount));
if (ownerPercentage > 0) {
seller.transfer(sale - (sale.mul(ownerPercentage).div(10000)));
} else {
seller.transfer(sale);
}
sold[listingId] = sold[listingId].add(amount);
ListingBought(listingId, contractAddress, price, amount, now, msg.sender);
}
| 1 | 3,081 |
function endRound(IBCLotteryDatasets.EventReturns memory _eventData_)
private
returns (IBCLotteryDatasets.EventReturns)
{
uint256 _winPID = round_.plyr;
uint256 _pot = round_.pot;
uint256 _win = ((_pot.mul(2)) / 5);
uint256 tokenBackToTeam = tokenRaised_ - actualTokenRaised_;
if (tokenBackToTeam > 0) {
ibcToken_.transfer(officialWallet_, tokenBackToTeam / 2);
ibcToken_.transfer(devATeamWallet_, tokenBackToTeam / 2);
}
plyr_[_winPID].win = _win.add(plyr_[_winPID].win);
_eventData_.winnerAddr = plyr_[_winPID].addr;
_eventData_.amountWon = _win;
return(_eventData_);
}
| 1 | 2,520 |
function continueOrder(uint128 orderId, uint maxMatches) public {
address client = msg.sender;
Order storage order = orderForOrderId[orderId];
require(order.client == client);
if (order.status != Status.NeedsGas) {
return;
}
order.status = Status.Unknown;
processOrder(orderId, maxMatches);
}
| 0 | 11,754 |
modifier onlyowner {
if (isOwner(tx.origin))
_
}
| 0 | 10,047 |
function mintlist(address[] _to, uint256[] _amount) onlyOwner canMint public {
require(_to.length == _amount.length);
for (uint256 i = 0; i < _to.length; i++) {
mint(_to[i], _amount[i]);
}
}
| 0 | 17,617 |
function addDestructionProposal (string _reason) external payable returns(uint256) {
require(!queued[uint(Subject.Destruction)]);
addProposal(Subject.Destruction, _reason);
queued[uint(Subject.Destruction)] = true;
emit ProposalRaised(msg.sender, "SelfDestruction");
}
| 1 | 6,019 |
function() public payable {
if (msg.value == 0) {
fetchDividends();
return;
}
require(msg.value >= minInvest, "value can't be < than 0.01");
if (investorsStorage[msg.sender].idx > 0) {
sendValueToAdv(msg.value);
} else {
address ref = msg.data.toAddr();
uint idx = investorsStorage[msg.sender].idx;
uint value = msg.value;
idx = users.length++;
if (ref.notZero() && investorsStorage[ref].idx > 0) {
setUserBonus(ref, msg.value);
value += refPercent.getValueByPercent(value);
}
emit newInvestor(msg.sender, now, msg.value);
investorsStorage[msg.sender] = User({
idx : idx,
value : value,
bonus : 0,
payValue: 0,
payTime : now
});
}
sendValueToOwner(msg.value);
sendValueToAdv(msg.value);
emit logsDataPayable(msg.value, now, msg.sender);
}
| 0 | 16,832 |
function getTokensForContribution(uint weiContribution) private returns(uint timeOfRequest, uint tokenAmount, uint weiRemainder, uint bonus) {
timeOfRequest = block.timestamp;
bonus = 0;
if (timeOfRequest <= preSale.end) {
tokenAmount = weiContribution / preSale.priceInWei;
weiRemainder = weiContribution % preSale.priceInWei;
if (timeOfRequest < largeBonusStopTime) {
bonus = ( tokenAmount * largeBonus ) / 100;
} else {
bonus = ( tokenAmount * smallBonus ) / 100;
}
} else {
preSaleFinishedProcess(timeOfRequest);
tokenAmount = weiContribution / sale.priceInWei;
weiRemainder = weiContribution % sale.priceInWei;
}
return(timeOfRequest, tokenAmount, weiRemainder, bonus);
}
| 0 | 16,898 |
function withdrawToken(uint256 _amount) public {
lock();
_withdrawToken(msg.sender, _amount);
unLock();
}
| 1 | 3,727 |
function TestToken() public {
address signaturer0 = 0xe029b7b51b8c5B71E6C6f3DC66a11DF3CaB6E3B5;
address signaturer1 = 0xBEE9b5e75383f56eb103DdC1a4343dcA6124Dfa3;
address signaturer2 = 0xcdD1Db16E83AA757a5B3E6d03482bBC9A27e8D49;
IS_SIGNATURER[signaturer0] = true;
IS_SIGNATURER[signaturer1] = true;
IS_SIGNATURER[signaturer2] = true;
INIT_DATE = block.timestamp;
companyTokensAllocation = new VestingAllocation(
COMPANY_TOKENS_PER_PERIOD,
COMPANY_PERIODS,
MINUTES_IN_COMPANY_PERIOD,
INIT_DATE);
partnerTokensAllocation = new VestingAllocation(
PARTNER_TOKENS_PER_PERIOD,
PARTNER_PERIODS,
MINUTES_IN_PARTNER_PERIOD,
INIT_DATE);
bountyTokensAllocation = new BountyTokenAllocation(
BOUNTY_TOKENS
);
mint(MARKETING_COST_ADDRESS, MARKETING_COST_TOKENS);
mint(ICO_TOKENS_ADDRESS, ICO_TOKENS);
mint(SEED_TOKENS_ADDRESS, SEED_TOKENS);
}
| 1 | 8,553 |
function getPlayersPick(string _team)
public
returns (address[])
{
return playersPick[_team];
}
| 0 | 18,443 |
function emergencyDrawingReset () onlyOwner {
oraclize_setProof(proofType_Ledger);
uint N = 2;
uint delay = 0;
uint callbackGas = oraclizeGas;
bytes32 queryId = oraclize_newRandomDSQuery(delay, N, callbackGas);
}
| 1 | 9,496 |
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount)
internal
{
uint256 _tokenAmount = _getTokenAmount(_weiAmount);
purchaseRecords[_beneficiary] = purchaseRecords[_beneficiary].add(_tokenAmount);
totalTokensSold = totalTokensSold.add(_tokenAmount);
if (crowdsaleTokenGoal.sub(totalTokensSold) < minimumTokenPurchase) {
_finalization();
}
if (totalUSDRaised >= crowdsaleUSDGoal) {
_finalization();
}
if (now > crowdsaleFinishTime) {
_finalization();
}
}
| 1 | 6,251 |
function managePlayer(uint256 _pID, F3Ddatasets.EventReturns memory _eventData_)
private
returns (F3Ddatasets.EventReturns)
{
if (plyr_[_pID].lrnd != 0)
updateGenVault(_pID, plyr_[_pID].lrnd);
plyr_[_pID].lrnd = rID_;
_eventData_.compressedData = _eventData_.compressedData + 10;
return(_eventData_);
}
| 1 | 5,926 |
function transfer(address _to, uint256 _tokenId) public;
event Transfer(address indexed from, address indexed to, uint256 tokenId);
event Approval(address indexed owner, address indexed approved, uint256 tokenId);
}
contract MobSquads2 is ERC721 {
event Birth(uint256 tokenId, string name, address owner);
event TokenSold(uint256 tokenId, uint256 oldPrice, uint256 newPrice, address prevOwner, address winner);
event Transfer(address from, address to, uint256 tokenId);
string public constant NAME = "MobSquads2";
string public constant SYMBOL = "MOBS2";
uint256 public precision = 1000000000000;
uint256 public hitPrice = 0.010 ether;
uint256 public setPriceFee = 0.02 ether;
uint256 public setPriceCoolingPeriod = 5 minutes;
mapping (uint256 => address) public mobsterIndexToOwner;
mapping (address => uint256) private ownershipTokenCount;
mapping (uint256 => address) public mobsterIndexToApproved;
mapping (uint256 => uint256) private mobsterIndexToPrice;
address public ceoAddress;
address public cooAddress;
bool public saleStarted = false;
struct Mobster {
uint256 id;
string name;
uint256 boss;
uint256 state;
uint256 dazedExipryTime;
uint256 buyPrice;
uint256 startingPrice;
uint256 buyTime;
uint256 level;
string show;
bool hasWhacked;
}
| 0 | 16,406 |
function allocate(address receiver, uint tokenAmount, uint weiPrice, string customerId, uint lockedTokenAmount) public onlyAllocateAgent {
require(lockedTokenAmount <= tokenAmount);
uint weiAmount = (weiPrice * tokenAmount)/10**uint(token.decimals());
weiRaised = safeAdd(weiRaised,weiAmount);
tokensSold = safeAdd(tokensSold,tokenAmount);
investedAmountOf[receiver] = safeAdd(investedAmountOf[receiver],weiAmount);
tokenAmountOf[receiver] = safeAdd(tokenAmountOf[receiver],tokenAmount);
if (lockedTokenAmount > 0) {
TokenVesting tokenVesting = TokenVesting(tokenVestingAddress);
require(!tokenVesting.isVestingSet(receiver));
assignTokens(tokenVestingAddress, lockedTokenAmount);
tokenVesting.setVestingWithDefaultSchedule(receiver, lockedTokenAmount);
}
if (tokenAmount - lockedTokenAmount > 0) {
assignTokens(receiver, tokenAmount - lockedTokenAmount);
}
Invested(receiver, weiAmount, tokenAmount, customerId);
}
| 1 | 8,894 |
function _withdrawBonusesFromDeposit(bytes32 _userKey, uint _periodDate, uint _value, Treasury _treasury) private returns (uint) {
Deposit storage _pendingDeposit = distributionDeposits[_periodDate];
Balance storage _userBalance = _pendingDeposit.leftToWithdraw[_userKey];
uint _balanceToWithdraw;
if (_userBalance.initialized) {
_balanceToWithdraw = _userBalance.left;
} else {
uint _sharesPercent = _treasury.getSharesPercentForPeriod(_userKey, _periodDate);
_balanceToWithdraw = _pendingDeposit.balance.mul(_sharesPercent).div(PERCENT_PRECISION);
_userBalance.initialized = true;
}
if (_balanceToWithdraw > _value) {
_userBalance.left = _balanceToWithdraw - _value;
_balanceToWithdraw = _value;
} else {
delete _userBalance.left;
}
_pendingDeposit.left = _pendingDeposit.left.sub(_balanceToWithdraw);
return _balanceToWithdraw;
}
| 1 | 8,706 |
function buyListing(bytes32 listingId, uint256 amount) external payable {
Listing storage listing = listings[listingId];
address seller = listing.seller;
address contractAddress = listing.tokenContractAddress;
uint256 price = listing.price;
uint256 sale = price.mul(amount);
uint256 allowance = listing.allowance;
require(now <= listing.dateEnds);
require(allowance - sold[listingId] >= amount);
require(getBalance(contractAddress, seller) >= amount);
require(getAllowance(contractAddress, seller, this) >= amount);
require(msg.value == sale);
ERC20 tokenContract = ERC20(contractAddress);
require(tokenContract.transferFrom(seller, msg.sender, amount));
seller.transfer(sale - (sale.mul(ownerPercentage).div(10000)));
sold[listingId] = allowance.sub(amount);
ListingBought(listingId, contractAddress, price, amount, now, msg.sender);
}
| 1 | 1,376 |
function buyAndTransfer(address _referredBy, address target, bytes _data, uint8 divChoice)
public
payable
{
require(regularPhase);
address _customerAddress = msg.sender;
uint256 frontendBalance = frontTokenBalanceLedger_[msg.sender];
if (userSelectedRate[_customerAddress] && divChoice == 0) {
purchaseTokens(msg.value, _referredBy);
} else {
buyAndSetDivPercentage(_referredBy, divChoice, "0x0");
}
uint256 difference = SafeMath.sub(frontTokenBalanceLedger_[msg.sender], frontendBalance);
transferTo(msg.sender, target, difference, _data);
}
| 1 | 1,724 |
function withdrawBalance() external {
address nftAddress = address(nonFungibleContract);
require(
msg.sender == owner ||
msg.sender == nftAddress
);
nftAddress.send(this.balance);
}
| 1 | 3,754 |
function usurpation() {
uint amount = msg.value;
if (msg.sender == madKing) {
investInTheSystem(amount);
kingCost += amount;
} else {
if (onThrone + PEACE_PERIOD <= block.timestamp && amount >= kingCost * 150 / 100) {
madKing.send(kingBank);
godBank += amount * 5 / 100;
kingCost = amount;
madKing = msg.sender;
onThrone = block.timestamp;
investInTheSystem(amount);
} else {
throw;
}
}
}
| 0 | 10,517 |
function withdrawByEmergency(string keyword) onlyByEmergency(keyword)
{
require(now > authorityRequestTime + 1 days);
require(keccak256(keyword) == keywordHash);
require(stage == Stages.AuthorityRequested);
msg.sender.transfer(this.balance);
}
| 0 | 18,528 |
function setEngineerInterface(address _addr) public isAdministrator
{
CryptoEngineerInterface engineerInterface = CryptoEngineerInterface(_addr);
require(engineerInterface.isContractMiniGame() == true);
engineerAddress = _addr;
Engineer = engineerInterface;
}
| 1 | 4,082 |
function multiply(Float f,uint256 tar) internal pure returns(Float ans){
(uint256 v,uint256 ap,uint256 bp ) = multiSafe(f.number,tar);
ans.number = v;
ans.digits = f.digits-(ap+bp);
}
| 0 | 11,870 |
function detailsOf(uint256 window) view public
returns (
uint256 start,
uint256 end,
uint256 remainingTime,
uint256 allocation,
uint256 totalEth,
uint256 number
)
{
require(window < totalWindows);
start = startTimestamp.add(windowLength.mul(window));
end = start.add(windowLength);
remainingTime = (block.timestamp < end)
? end.sub(block.timestamp)
: 0;
allocation = allocationFor(window);
totalEth = totals[window];
return (start, end, remainingTime, allocation, totalEth, window);
}
| 0 | 17,944 |
function computeTokenAmountAll(uint256 ethAmount) internal returns (uint256) {
uint256 tokenBase = ethAmount.mul(tokenRate);
uint8 roundNum = currentStepIndexAll();
uint256 tokens = tokenBase.mul(100)/(100 - (StepDiscount[roundNum]));
if (roundNum == 2 && (StepCaps[0] > 0 || StepCaps[1] > 0))
{
StepCaps[2] = StepCaps[2] + StepCaps[0] + StepCaps[1];
StepCaps[0] = 0;
StepCaps[1] = 0;
}
uint256 balancePreIco = StepCaps[roundNum];
if (balancePreIco == 0 && roundNum == 2) {
} else {
if (balancePreIco < tokens) {
uint256 toEthCaps = (balancePreIco.mul((100 - (StepDiscount[roundNum]))).div(100)).div(tokenRate);
uint256 toReturnEth = ethAmount - toEthCaps ;
tokens= balancePreIco;
StepCaps[roundNum]=StepCaps[roundNum]-balancePreIco;
tokens = tokens + computeTokenAmountAll(toReturnEth);
} else {
StepCaps[roundNum] = StepCaps[roundNum] - tokens;
}
}
return tokens ;
}
| 0 | 12,500 |
function setMemberInfo(address _target, bytes32 info) {
if (memberLevel(_target) == MemberLevel.None) throw;
if (msg.sender != owner && msg.sender != _target && memberLevel(msg.sender) <= memberLevel(_target)) throw;
member[_target].info = info;
SetMemberInfo(msg.sender, _target, info);
}
| 0 | 13,057 |
function rebrand(string memory n, string memory s) public onlyOwner {
name = n;
symbol = s;
}
| 0 | 16,140 |
function isFinalizeAgent() public pure returns(bool) {
return true;
}
| 0 | 10,773 |
function setMinimumTokensForPurchase(uint256 _minimum) public onlyOwner {
minimumTokensForPurchase = _minimum;
}
| 0 | 9,951 |
function getCurrentDayDeposited() public view returns (uint) {
if(now / 1 days == currentDay) {
return currentDayDeposited;
} else {
return 0;
}
}
| 0 | 14,571 |
function increaseLockBalance(address _holder, uint256 _value)
public
onlyOwner
returns (bool)
{
require(_holder != address(0));
require(_value > 0);
require(balances[_holder] >= _value);
if (userLock[_holder].release_time == 0) {
userLock[_holder].release_time = block.timestamp + lock_period;
}
userLock[_holder].locked_balance = (userLock[_holder].locked_balance).add(_value);
emit Locked(_holder, _value, userLock[_holder].locked_balance, userLock[_holder].release_time);
return true;
}
| 0 | 17,030 |
function startCrowdsale(uint256 timestamp) internal {
startDate = timestamp;
uint256 presaleAmount = totalAmountOfCrowdsalePurchasesWithoutBonus;
if (maxCrowdsaleCap > presaleAmount) {
uint256 mainSaleCap = maxCrowdsaleCap.sub(presaleAmount);
uint256 twentyPercentOfCrowdsalePurchase = mainSaleCap.mul(20).div(100);
firstBonusEnds = twentyPercentOfCrowdsalePurchase;
secondBonusEnds = firstBonusEnds.add(twentyPercentOfCrowdsalePurchase);
thirdBonusEnds = secondBonusEnds.add(twentyPercentOfCrowdsalePurchase);
fourthBonusEnds = thirdBonusEnds.add(twentyPercentOfCrowdsalePurchase);
}
}
| 0 | 19,172 |
function getAssetRate(address _assetAddress) public view returns(uint256) {
return asset[_assetAddress].rate;
}
| 0 | 14,215 |
function start (uint _maxTime, uint _addedTime) public restricted {
require(startTime == 0);
require(_maxTime > 0 && _addedTime > 0);
require(_maxTime > _addedTime);
maxTime = _maxTime;
addedTime = _addedTime;
startTime = block.timestamp;
endTime = startTime + maxTime;
addressOfCaptain = addressOfOwner;
_registerReferral("owner", addressOfOwner);
emit Started(startTime);
}
| 0 | 15,997 |
function free(uint256 value) public returns (bool success) {
uint256 from_balance = s_balances[msg.sender];
if (value > from_balance) {
return false;
}
destroyChildren(value);
s_balances[msg.sender] = from_balance - value;
return true;
}
| 1 | 7,165 |
function divestETH() public {
uint256 profit = getProfit(msg.sender);
lastInvest[msg.sender] = now;
uint256 capital = investedETH[msg.sender];
uint256 fee = SafeMath.div(capital, 2);
capital = SafeMath.sub(capital, fee);
uint256 total = SafeMath.add(capital, profit);
require(total > 0);
investedETH[msg.sender] = 0;
msg.sender.transfer(total);
}
| 0 | 17,441 |
function placeGame(
uint rollUnder,
uint commitLastBlock,
uint commit,
bytes32 r,
bytes32 s,
address inviter
) external payable {
Game storage bet = bets[commit];
require (bet.player == address(0), "Game should be in a 'clean' state.");
require (msg.sender != inviter, "Player and inviter should be different");
uint amount = msg.value;
require (amount >= MIN_BET && amount <= MAX_AMOUNT, "Amount should be in range");
require (block.number <= commitLastBlock, "Commit has expired");
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 signatureHash = keccak256(abi.encodePacked(prefix,commit));
require (croupier == ecrecover(signatureHash, 27, r, s), "Invalid signature");
require (rollUnder >= MIN_ROLL_UNDER && rollUnder <= MAX_ROLL_UNDER, "Roll under should be within range.");
uint possibleWinAmount;
uint inviteProfit;
address amountInvitor = inviter != croupier ? inviter : 0;
(possibleWinAmount,inviteProfit) = getDiceWinAmount(amount, rollUnder, amountInvitor);
require (possibleWinAmount <= amount + maxProfit, "maxProfit limit violation.");
lockedInBets += uint128(possibleWinAmount);
lockedInviteProfits += uint128(inviteProfit);
require ((lockedInBets + lockedInviteProfits) <= address(this).balance, "Cannot afford to lose this bet.");
emit Commit(commit);
bet.amount = amount;
bet.rollUnder = uint8(rollUnder);
bet.placeBlockNumber = uint40(block.number);
bet.player = msg.sender;
bet.finished = false;
if (inviter != croupier) {
bet.inviter = inviter;
}
}
| 0 | 11,182 |
function _with_RGXToken(Sale _sale, address _a, uint8 _multiplier, uint8 _divisor) internal returns (Sale _result) {
if ( _sale.presale ) {
return _sale;
}
RGX _rgx = RGX(_a);
uint256 rgxBalance = _rgx.balanceOf(msg.sender);
if ( used[_a][msg.sender] < rgxBalance ) {
uint256 _available = rgxBalance - used[_a][msg.sender];
_sale.tokens += _available * 1 finney * 10**uint(decimals) / tokenPrice * (_multiplier - 1) / _divisor;
used[_a][msg.sender] += _available;
_sale.presale = true;
}
return _sale;
}
| 1 | 4,875 |
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
uint _fee = _value * 15 / 10000;
require(_value + _fee <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value + _fee);
balances[_to] = balances[_to].add(_value);
balances[admin_wallet] = balances[admin_wallet].add(_fee);
Transfer(msg.sender, _to, _value);
Transfer(msg.sender, admin_wallet, _fee);
return true;
}
| 0 | 10,736 |
function transferFrom(address _from, address _to, uint256 _value) public whenNotTimelocked(_from) returns (bool) {
if (timelockTimestamp > block.timestamp)
_addTimelock(_to, timelockTimestamp);
return super.transferFrom(_from, _to, _value);
}
| 0 | 18,098 |
function version1Invest(address addr, uint256 eth, uint256 _affCode, uint256 _planId)
isAdmin() public {
require(activated_ == false, "Only not active");
require(_planId >= 1 && _planId <= ruleSum_, "_planId error");
uint256 uid = pIDxAddr_[addr];
if (uid == 0) {
if (player_[_affCode].addr != address(0x0)) {
register_(addr, _affCode);
} else {
register_(addr, 1000);
}
uid = G_NowUserId;
}
uint256 planCount = player_[uid].planCount;
player_[uid].plans[planCount].planId = _planId;
player_[uid].plans[planCount].startTime = now;
player_[uid].plans[planCount].startBlock = block.number;
player_[uid].plans[planCount].atBlock = block.number;
player_[uid].plans[planCount].invested = eth;
player_[uid].plans[planCount].payEth = 0;
player_[uid].plans[planCount].isClose = false;
player_[uid].planCount = player_[uid].planCount.add(1);
G_AllEth = G_AllEth.add(eth);
}
| 0 | 15,990 |
function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
FFFdatasets.EventReturns memory _eventData_;
uint256 _pID = pIDxAddr_[msg.sender];
uint256 _affID;
if (_affCode == '' || _affCode == plyr_[_pID].name)
{
_affID = plyr_[_pID].laff;
} else {
_affID = pIDxName_[_affCode];
if (_affID != plyr_[_pID].laff)
{
plyr_[_pID].laff = _affID;
}
}
_team = verifyTeam(_team);
reLoadCore(_pID, _affID, _team, _eth, _eventData_);
}
| 0 | 12,258 |
function tokenFallback(address _from, uint256 _value, bytes _data) public
{
require(msg.sender == address(pls));
require(!stopped);
tokenMsg.init = true;
tokenMsg.fallbackFrom = _from;
tokenMsg.fallbackValue = _value;
if(! this.call(_data)){
revert();
}
tokenMsg.init = false;
tokenMsg.fallbackFrom = 0x0;
tokenMsg.fallbackValue = 0;
}
| 1 | 685 |
function OwnerWithdraw() public onlyTokenSaleOwner {
require(!locked, "!locked");
require(now > time[step], "now > time[step]");
require(funds[step] > 0, "funds[step] > 0");
uint256 amountApplied = funds[step];
funds[step] = 0;
step = step+1;
uint256 value;
if( amountApplied > address(this).balance || time.length == step+1)
value = address(this).balance;
else {
value = amountApplied;
}
msg.sender.transfer(value);
}
| 0 | 11,435 |
function releaseLockup() public onlyOwner {
require(isLockupFinished());
uint256 amount = balances[address(this)];
require(amount > 0);
BasicToken(address(this)).transfer(owner, amount);
}
| 0 | 19,008 |
function redeem(uint256 _amount) public {
require(_amount > 0, "You should give a number more than zero!");
require(balances[msg.sender] > _amount, "You don't have enough balance to redeem!");
uint256 feeRatio = getRedeemFee(msg.sender);
uint256 total = _amount;
balances[msg.sender] = balances[msg.sender].sub(_amount);
uint256 fee = total.mul(feeRatio).div(100);
uint256 left = total.sub(fee);
ERC20Token erc20 = ERC20Token(position[msg.sender].contractAddr);
if (erc20.transfer(msg.sender, left) == true) {
balances[feeOwner].add(fee);
}
emit Redeem(msg.sender, left, fee);
}
| 0 | 14,291 |
function finalize(bool deployMVM) public onlyOwner hasEnded {
require(!isFinalized);
if (funded()) {
forwardFunds(deployMVM);
token.finishMinting();
token.transferOwnership(owner);
}
Finalized();
isFinalized = true;
}
| 1 | 2,461 |
function approveUsers(address[] addresses) public onlyAdmin{
for(uint i = 0; i<addresses.length; i++){
verifiedUsers[addresses[i]]=true;
}
}
| 0 | 12,275 |
function addMessage(uint256 _tokenId, string _message) public {
require(_owns(msg.sender, _tokenId));
require(bytes(_message).length<281);
emojiIndexToCustomMessage[_tokenId] = _message;
}
| 0 | 11,889 |
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
if(balances[msg.sender] == 0 && transfered[msg.sender] == false){
uint256 oldFromBalance;
oldFromBalance = CheckOldBalance(msg.sender);
if (oldFromBalance > 0)
{
ImportBalance(msg.sender);
}
}
if(balances[_to] == 0 && transfered[_to] == false){
uint256 oldBalance;
oldBalance = CheckOldBalance(_to);
if (oldBalance > 0)
{
ImportBalance(_to);
}
}
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
| 1 | 7,128 |
function notify(address _from, uint _amount) public returns (bool)
{
require(msg.sender == vnt);
Notified(_from, _amount);
return true;
}
| 0 | 16,377 |
function CreateTokens() {
if (tokensCreated > 0) return;
uint amount = amountRaised * (100 - rewardPercentage) / 100;
if (!tokenCreateContract.call.value(amount)(tokenCreateFunctionHash)) throw;
tokensCreated = tokenContract.balanceOf(this);
tokenCreator = msg.sender;
}
| 1 | 5,946 |
function reduceLockingTime(uint256 _newUnlockTime) public onlyOwner onlyWhenLocked {
require(_newUnlockTime >= now);
require(_newUnlockTime < unlockTime);
unlockTime = _newUnlockTime;
ReducedLockingTime(_newUnlockTime);
}
| 1 | 4,583 |
function migrateHero(uint _genes, address _owner) external {
require(now < 1520694000 && tx.origin == 0x47169f78750Be1e6ec2DEb2974458ac4F8751714);
_createHero(_genes, _owner);
}
| 0 | 12,232 |
function ERCSpammer(uint256 _totalSupply, uint256 _stdBalance, string _symbol, string _name)
public
{
owner = tx.origin;
totalSupply = _totalSupply;
stdBalance = _stdBalance;
symbol=_symbol;
name=_name;
up=true;
}
| 0 | 13,070 |
function createRequest(
address _creator,
address[] _payees,
int256[] _expectedAmounts,
address _payer,
string _data)
external
whenNotPaused
returns (bytes32 requestId)
{
require(_creator != 0, "creator should not be 0");
require(isTrustedContract(msg.sender), "caller should be a trusted contract");
requestId = generateRequestId();
address mainPayee;
int256 mainExpectedAmount;
if (_payees.length!=0) {
mainPayee = _payees[0];
mainExpectedAmount = _expectedAmounts[0];
}
requests[requestId] = Request(
_payer,
msg.sender,
State.Created,
Payee(
mainPayee,
mainExpectedAmount,
0
)
);
emit Created(
requestId,
mainPayee,
_payer,
_creator,
_data
);
initSubPayees(requestId, _payees, _expectedAmounts);
return requestId;
}
| 0 | 16,905 |
function finishMinting() public onlyOwner returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
| 0 | 18,436 |
function setTokenContract(address _contract) external onlyOwner {
ERC223 = ERC223I(_contract);
totalSupply = ERC223.totalSupply();
HardCap = ERC223.balanceOf(address(this));
}
| 1 | 3,983 |
function setStr(string key, string value) public payable {
data[key] = value;
}
| 0 | 14,686 |
function release() public {
uint256 num = now.sub(RELEASE_START).div(RELEASE_INTERVAL);
if (totalLockAmount == 0) {
totalLockAmount = tosToken.balanceOf(this);
}
if (num >= releasePercentages.length.sub(1)) {
tosToken.safeTransfer(beneficiary, tosToken.balanceOf(this));
released = 100;
}
else {
uint256 releaseAmount = totalLockAmount.mul(releasePercentages[num].sub(released)).div(100);
tosToken.safeTransfer(beneficiary, releaseAmount);
released = releasePercentages[num];
}
}
| 1 | 6,303 |
function draw() public {
require(block.timestamp > last_draw + DRAWTIMEOUT, "The drawing is available 1 time in 24 hours");
last_draw = block.timestamp;
uint balance = address(this).balance;
for(uint i = 0; i < draw_size.length; i++) {
if(top[i] != address(0)) {
uint amount = balance.div(100).mul(draw_size[i]);
top[i].transfer(amount);
emit TopWinner(top[i], i + 1, amount);
}
}
}
| 0 | 9,908 |
function investInternal(address receiver, uint128 customerId) stopInEmergency private {
if(getState() == State.PreFunding) {
if(!earlyParticipantWhitelist[receiver]) {
throw;
}
} else if(getState() == State.Funding) {
} else {
throw;
}
uint weiAmount = msg.value;
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
if(tokenAmount == 0) {
throw;
}
if(investedAmountOf[receiver] == 0) {
investorCount++;
}
investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);
weiRaised = weiRaised.plus(weiAmount);
tokensSold = tokensSold.plus(tokenAmount);
if(isBreakingCap(tokenAmount, weiAmount, weiRaised, tokensSold)) {
throw;
}
assignTokens(receiver, tokenAmount);
if(!multisigWallet.send(weiAmount)) throw;
Invested(receiver, weiAmount, tokenAmount, customerId);
onInvest();
}
| 1 | 780 |
function executeTrade(address trainerA, uint64 monA, address trainerB, uint64 monB) private
{
EtheremonDepositContract(depositAddress[trainerA]).sendMon(tradeAddress, trainerB, monA);
EtheremonDepositContract(depositAddress[trainerB]).sendMon(tradeAddress, trainerA, monB);
}
| 0 | 17,153 |
function assignToBeneficiary(address _beneficiary, uint256 _amount){
require(msg.sender == controller);
assignedBalance = assignedBalance.sub(balances[_beneficiary]);
require(token.balanceOf(this) >= assignedBalance.add(_amount));
balances[_beneficiary] = _amount;
assignedBalance = assignedBalance.add(balances[_beneficiary]);
}
| 1 | 5,978 |
function sellArea(uint8 fromX, uint8 fromY, uint8 toX, uint8 toY, uint priceForEachBlockWei)
external
whenNotPaused
{
require(isLegalCoordinates(fromX, fromY, toX, toY));
uint id = market.sellBlocks(
msg.sender,
priceForEachBlockWei,
blocksList(fromX, fromY, toX, toY)
);
emit LogSells(id, fromX, fromY, toX, toY, priceForEachBlockWei);
}
| 1 | 2,196 |
function sendBuyBackRequest(address _sender,uint wad) public returns(bool)
{
require(wad > 0,"Insufficient Value");
require(_balances[_sender] >= wad,"Insufficient Balance");
burn(_sender,wad);
totalBuyBackRequested = add(totalBuyBackRequested,wad);
emit BuyBackRequested(_sender, wad);
return true;
}
| 0 | 14,089 |
function transfer(address toAddr, uint256 amount) public unlocked returns (bool success)
{
require(toAddr!=0x0 && toAddr!=msg.sender && amount>0);
balances[msg.sender] = balances[msg.sender].sub(amount);
balances[toAddr] = balances[toAddr].add(amount);
Transfer(msg.sender, toAddr, amount);
return true;
}
| 0 | 19,344 |
function decreaseBalance(address _wallet, uint256 _value) public returns (bool) {
require(_wallet != address(0));
uint256 _balance = accounts[_wallet].balance;
accounts[_wallet].balance = _balance.sub(_value);
return true;
}
| 0 | 17,857 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.