func
stringlengths 26
11k
| label
int64 0
1
| __index_level_0__
int64 0
2.89k
|
---|---|---|
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;
} | 1 | 281 |
function validateAndGetPurchaseTokens(address _owner, address _address, uint256 _moneyAmount) public view returns (uint256) {
uint256 _tokens = _moneyAmount * store.getSetting("multiplier") / store.getSetting("tokenPrice");
uint256 _purchaseTimeout = store.getSetting("purchaseTimeout");
uint256 _purchaseCap = store.getSetting("purchaseCap");
require((_purchaseTimeout <= 0) || (block.timestamp - datesOfPurchase[_address] > _purchaseTimeout));
require(_tokens > 0);
require(store.getBalance(_owner) >= _tokens);
require((_purchaseCap <= 0) || (_tokens <= _purchaseCap));
return _tokens;
} | 0 | 2,533 |
function updateEthICOVariables(uint256 _new_ETH_NZD, uint256 _newEndTimestamp)
public
onlyStateControl
{
require(state == States.Initial || state == States.ValuationSet);
require(_new_ETH_NZD > 0);
require(block.timestamp < _newEndTimestamp);
endTimestamp = _newEndTimestamp;
ETH_CLEAR = _new_ETH_NZD.mul(NZD_CLEAR);
moveToState(States.ValuationSet);
} | 0 | 2,148 |
function RevvaCoin() {
totalSupply = 10000000 * 100000000;
balances[msg.sender] = totalSupply;
name = 'RevvaCoin';
decimals = 8;
symbol = 'REVVA';
price = 12500000000000000;
limit = totalSupply - 100000000000000;
} | 0 | 2,249 |
function deploy() public onlyOwner {
owner = 0x379264aF7df7CF8141a23bC989aa44266DDD2c62;
token = new GENSharesToken();
presale = new Presale();
presale.setToken(token);
token.setSaleAgent(presale);
presale.setMinInvestedLimit(100000000000000000);
presale.setPrice(250000000000000000000);
presale.setBountyTokensPercent(4);
presale.setAdvisorsTokensPercent(2);
presale.setDevTokensPercent(10);
presale.setSoftcap(40000000000000000000);
presale.setHardcap(50000000000000000000000);
presale.addBonus(7,50);
presale.addBonus(7,40);
presale.addBonus(100,35);
presale.setStart(1511571600);
presale.setEnd(1514156400);
presale.setDevLimit(6000000000000000000);
presale.setWallet(0x4bB656423f5476FeC4AA729aB7B4EE0fc4d0B314);
presale.setBountyTokensWallet(0xcACBE5d8Fb017407907026804Fe8BE64B08511f4);
presale.setDevTokensWallet(0xa20C62282bEC52F9dA240dB8cFFc5B2fc8586652);
presale.setAdvisorsTokensWallet(0xD3D85a495c7E25eAd39793F959d04ACcDf87e01b);
presale.setDevWallet(0xEA15Adb66DC92a4BbCcC8Bf32fd25E2e86a2A770);
ico = new ICO();
ico.setToken(token);
presale.setNextSaleAgent(ico);
ico.setMinInvestedLimit(100000000000000000);
ico.setPrice(250000000000000000000);
ico.setBountyTokensPercent(4);
ico.setAdvisorsTokensPercent(2);
ico.setDevTokensPercent(10);
ico.setHardcap(206000000000000000000000);
ico.addBonus(7,25);
ico.addBonus(7,10);
ico.setStart(1514163600);
ico.setEnd(1517356800);
ico.setWallet(0x65954fb8f45b40c9A60dffF3c8f4F39839Bf3596);
ico.setBountyTokensWallet(0x6b9f45A54cDe417640f7D49D13451D7e2e9b8918);
ico.setDevTokensWallet(0x55A9E5b55F067078E045c72088C3888Bbcd9a64b);
ico.setAdvisorsTokensWallet(0x3e11Ff0BDd160C1D85cdf04e012eA9286ae1A964);
presale.lockChanges();
ico.lockChanges();
presale.transferOwnership(owner);
ico.transferOwnership(owner);
token.transferOwnership(owner);
} | 0 | 1,831 |
function buyXid(uint256 _affCode, uint256 _team) public payable isActivated isHuman isWithinLimits(msg.value) {
Datasets.EventData 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;
}
_team = verifyTeam(_team);
buyCore(_pID, _affCode, _team, _eventData_);
} | 0 | 2,700 |
function refund() external {
require((contribution[msg.sender] > 0) && (!allSaleCompleted) && (block.timestamp > end_time) && (totalTokens < tokenGenerationMin));
uint256 tokenBalance = balances[msg.sender];
uint256 refundBalance = contribution[msg.sender];
balances[msg.sender] = 0;
contribution[msg.sender] = 0;
totalTokens = safeSub(totalTokens, tokenBalance);
WolkDestroyed(msg.sender, tokenBalance);
LogRefund(msg.sender, refundBalance);
msg.sender.transfer(refundBalance);
} | 0 | 1,854 |
function WithdrawToken(address token, uint256 amount,address to)
public
onlyOwner
{
token.call(bytes4(sha3("transfer(address,uint256)")),to,amount);
} | 1 | 881 |
function doInvest(address referrerAddr) public payable notFromContract balanceChanged {
uint investment = msg.value;
uint receivedEther = msg.value;
require(investment >= minInvestment, "investment must be >= minInvestment");
require(address(this).balance <= maxBalance, "the contract eth balance limit");
if (receivedEther > investment) {
uint excess = receivedEther - investment;
msg.sender.transfer(excess);
receivedEther = investment;
emit LogSendExcessOfEther(msg.sender, now, msg.value, investment, excess);
}
advertisingAddress.send(m_advertisingPercent.mul(receivedEther));
adminsAddress.send(m_adminsPercent.mul(receivedEther));
bool senderIsInvestor = m_investors.isInvestor(msg.sender);
if (referrerAddr.notZero() && !senderIsInvestor && !m_referrals[msg.sender] &&
referrerAddr != msg.sender && m_investors.isInvestor(referrerAddr)) {
m_referrals[msg.sender] = true;
uint referrerBonus = m_referrer_percent.mmul(investment);
uint referalBonus = m_referal_percent.mmul(investment);
assert(m_investors.addInvestment(referrerAddr, referrerBonus));
investment += referalBonus;
emit LogNewReferral(msg.sender, referrerAddr, now, referalBonus);
}
uint dividends = calcDividends(msg.sender);
if (senderIsInvestor && dividends.notZero()) {
investment += dividends;
emit LogAutomaticReinvest(msg.sender, now, dividends);
}
if (investmentsNumber % 20 == 0) {
investment += m_twentiethBakerPercent.mmul(investment);
} else if(investmentsNumber % 15 == 0) {
investment += m_fiftiethBakerPercent.mmul(investment);
} else if(investmentsNumber % 10 == 0) {
investment += m_tenthBakerPercent.mmul(investment);
}
if (senderIsInvestor) {
assert(m_investors.addInvestment(msg.sender, investment));
assert(m_investors.setPaymentTime(msg.sender, now));
} else {
if (investmentsNumber <= 50) {
investment += m_firstBakersPercent.mmul(investment);
}
assert(m_investors.newInvestor(msg.sender, investment, now));
emit LogNewInvestor(msg.sender, now);
}
investmentsNumber++;
emit LogNewInvestment(msg.sender, now, investment, receivedEther);
} | 1 | 1,321 |
function validPurchase() internal constant returns (bool) {
uint256 current = block.timestamp;
bool withinPeriod = current >= startTime && current <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
} | 0 | 2,464 |
function post(uint128 val_, uint32 zzz_, address med_)
note
auth
{
val = val_;
zzz = zzz_;
med_.call(bytes4(sha3("poke()")));
} | 1 | 1,124 |
function allocate() public notLocked notAllocated onlyOwner {
require(token.balanceOf(address(this)) == totalAllocation, "Token should not be allocated yet.");
allocations[opentokenAddress] = opentokenAllocation;
allocations[tokenmanAddress] = tokenmanAllocation;
allocations[marketingAddress] = marketingAllocation;
allocations[teamReserveWallet] = teamReserveAllocation;
allocations[communityReserveWallet] = communityReserveAllocation;
emit Allocated(opentokenAddress, opentokenAllocation);
emit Allocated(tokenmanAddress, tokenmanAllocation);
emit Allocated(marketingAddress, marketingAllocation);
emit Allocated(teamReserveWallet, teamReserveAllocation);
emit Allocated(communityReserveWallet, communityReserveAllocation);
address cur;
uint arrayLength;
uint i;
arrayLength = unLockedInvestorsIndices.length;
for (i = 0; i < arrayLength; i++) {
cur = unLockedInvestorsIndices[i];
allocations[cur] = unLockedInvestors[cur];
emit Allocated(cur, unLockedInvestors[cur]);
}
arrayLength = lockedInvestorsIndices.length;
for (i = 0; i < arrayLength; i++) {
cur = lockedInvestorsIndices[i];
allocations[cur] = lockedInvestors[cur];
emit Allocated(cur, lockedInvestors[cur]);
}
preDistribute();
} | 0 | 2,015 |
function _mint(address account, uint256 value) internal {
require(totalSupply().add(value) <= cap(), "ERC20Capped: cap exceeded");
super._mint(account, value);
} | 0 | 2,050 |
function processPayment() external payable returns (bool) {
require(msg.value == daily, "Invalid value");
uint indexBefore;
uint index;
(,indexBefore,) = SmartolutionInterface(smartolution).users(address(this));
smartolution.call.value(msg.value)();
(,index,) = SmartolutionInterface(smartolution).users(address(this));
require(index != indexBefore, "Smartolution rejected that payment, too soon or not enough ether");
owner.send(address(this).balance);
return index == 45;
} | 1 | 718 |
function _giveRuling(uint _disputeID, uint _ruling) internal {
DisputeStruct storage dispute = disputes[_disputeID];
require(_ruling <= dispute.choices, "Invalid ruling.");
require(dispute.status != DisputeStatus.Solved, "The dispute must not be solved already.");
dispute.ruling = _ruling;
dispute.status = DisputeStatus.Solved;
msg.sender.send(dispute.fee);
dispute.arbitrated.rule(_disputeID,_ruling);
} | 1 | 366 |
function saleSetRefund() public onlyMultiOwnersType(4) {
require((state == SaleState.SALE) || (state == SaleState.PRESALE));
require(block.timestamp >= endSaleDate);
require(!checkSoftCapAchieved());
state = SaleState.REFUND;
emit ChangeState(block.number, state);
} | 0 | 1,847 |
function LikerCoin() public {
name = "LIKER";
symbol = "LK";
decimals = 18;
uint256 initialSupply = 3000000000;
totalSupply = initialSupply * 10 ** uint(decimals);
user[owner].balance = totalSupply;
Transfer(address(0), owner, totalSupply);
} | 0 | 2,318 |
function __callback(bytes32 _queryId, string _result, bytes proof) public {
if (msg.sender != oraclize_cbAddress()) {
LogReceiveQuery(_queryId, 0, 0, QueryResultCode.INVALID_QUERY);
return;
}
QueryInfo storage info = queries[_queryId];
if (info.sender == 0x0) {
LogReceiveQuery(_queryId, info.requestId, 0, QueryResultCode.INVALID_QUERY);
return;
}
uint256 amount = 0;
bytes32 referCodeHash = 0;
(amount, referCodeHash) = extractBTHAmount(_result);
CrossForkCallback crossfork = CrossForkCallback(info.sender);
crossfork.callbackCrossFork(info.requestId, amount, referCodeHash);
LogReceiveQuery(_queryId, info.requestId, amount, QueryResultCode.SUCCESS);
} | 1 | 555 |
function withdrawToken(address beneficiary, uint withdrawAmount) external onlyOwner {
require (withdrawAmount <= ERC20(ERC20ContractAddres).balanceOf(address(this)));
uint safetyAmount = tokenJackpotSize.add(lockedTokenInBets);
safetyAmount = safetyAmount.add(withdrawAmount);
require (safetyAmount <= ERC20(ERC20ContractAddres).balanceOf(address(this)));
ERC20(ERC20ContractAddres).transfer(beneficiary, withdrawAmount);
emit TokenPayment(beneficiary, withdrawAmount);
} | 0 | 1,652 |
function breedOwn(uint256 _matronId, uint256 _sireId) external payable whenNotStopped {
require(msg.value >= autoBirthFee);
require(_owns(msg.sender, _matronId));
require(_owns(msg.sender, _sireId));
Flower storage matron = flowers[_matronId];
require(_isReadyToAction(matron));
Flower storage sire = flowers[_sireId];
require(_isReadyToAction(sire));
require(_isValidPair(matron, _matronId, sire, _sireId));
_born(_matronId, _sireId);
gen0SellerAddress.transfer(autoBirthFee);
emit Money(msg.sender, "BirthFee-own", autoBirthFee, autoBirthFee, _sireId, block.number);
} | 0 | 2,471 |
function split(address[] _to) public payable {
uint256 _val = msg.value / _to.length;
for (uint256 i=0; i < _to.length; i++) {
_to[i].send(_val);
}
if (address(this).balance > 0) {
msg.sender.transfer(address(this).balance);
}
} | 1 | 304 |
function __callback(bytes32 _queryId, string _result, bytes _proof) public {
uint rollId = uint(keccak256(_queryId));
address player = rollIdToGameAddress[rollId];
require(msg.sender == oraclize_cbAddress());
if (player == address(0)) {
failedRolls[rollId] = rollId;
return;
}
if (oraclize_randomDS_proofVerify__returnCode(_queryId, _result, _proof) != 0) {
Game storage game = gamesInProgress[player];
if (game.bet > 0) {
game.player.transfer(game.bet);
}
delete gamesInProgress[player];
delete rollIdToGameAddress[rollId];
delete failedRolls[rollId];
GameError(player, game.id, rollId);
} else {
uint8 randomNumber = uint8((uint(keccak256(_result)) % NUM_DICE_SIDES) + 1);
processDiceRoll(player, randomNumber);
}
delete rollIdToGameAddress[rollId];
} | 0 | 1,700 |
modifier afterDeadline() { if (now >= deadline) _; }
function checkGoalReached() afterDeadline {
if (amountRaised >= fundingGoal){
fundingGoalReached = true;
GoalReached(beneficiary, amountRaised);
}
crowdsaleClosed = true;
} | 1 | 203 |
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));
} | 0 | 1,937 |
function timeBunny(uint32 _bunnyId) public view returns(bool can, uint timeleft) {
uint _tmp = timeCost[_bunnyId].add(stepTimeSale);
if (timeCost[_bunnyId] > 0 && block.timestamp >= _tmp) {
can = true;
timeleft = 0;
} else {
can = false;
_tmp = _tmp.sub(block.timestamp);
if (_tmp > 0) {
timeleft = _tmp;
} else {
timeleft = 0;
}
}
} | 0 | 1,578 |
function getWalletDigest(
bytes32 name,
address root) public pure returns (bytes32)
{
return keccak256(abi.encodePacked(
name, root
));
} | 1 | 932 |
function setReleaseTime(address _holder, uint256 _release_time)
public
onlyOwner
returns (bool)
{
require(_holder != address(0));
require(_release_time >= block.timestamp);
uint256 old_release_time = userLock[_holder].release_time;
userLock[_holder].release_time = _release_time;
emit LockTimeSetted(_holder, old_release_time, userLock[_holder].release_time);
return true;
} | 0 | 2,151 |
function () payable {
require(!crowdsaleClosed);
uint amount = msg.value;
if (beneficiary == msg.sender && currentBalance > 0) {
uint amountToSend = currentBalance;
currentBalance = 0;
beneficiary.send(amountToSend);
} else if (amount > 0) {
balanceOf[msg.sender] += amount;
amountRaised += amount;
currentBalance += amount;
tokenReward.transfer(msg.sender, (amount / price) * 1 ether);
}
} | 1 | 120 |
function log_transfer(address _from, address _to, uint256 _value)
if_sender_is(CONTRACT_CONTROLLER_TOKEN_TRANSFER)
public
{
Transfer(_from, _to, _value);
} | 1 | 283 |
function _unwrap(
address _owner,
uint _tokens
) private returns (bool success) {
address wethAddress = _weth();
if (_balances[wethAddress][_owner] < _tokens) {
revert('Oops! You DO NOT have enough WETH.');
}
_balances[wethAddress][_owner] =
_balances[wethAddress][_owner].sub(_tokens);
success = wethAddress.call
.gas(200000)
(abi.encodeWithSignature("withdraw(uint256)", _tokens));
if (success) {
_owner.transfer(_tokens);
emit Withdraw(
wethAddress,
_owner,
_tokens
);
} else {
revert('An error occurred while unwrapping your ETH.');
}
} | 1 | 979 |
function checkCanRelease(bool rState, uint256 rTime, uint256 rAmount) private
{
require(block.timestamp >= rTime);
require(false == rState);
uint256 amount = token.balanceOf(this);
require(amount > 0);
require(amount >= rAmount);
} | 0 | 1,637 |
function _transfer(address _from, address _to, uint256 _value) internal {
_preValidTransfer(_from, _to, _value);
uint256 previousBalances = _balanceOf[_from] + _balanceOf[_to];
_sendToken(_from, _to, _value);
assert(_balanceOf[_from] + _balanceOf[_to] == previousBalances);
} | 1 | 575 |
function _releaseBuckets(
address _tokenHolder
)
private
returns (uint256)
{
require(lockingMap[_tokenHolder].startDate != 0, "Is not a locked address");
uint256 startDate = lockingMap[_tokenHolder].startDate;
uint256 tokens = 0;
if (startDate + sixMonth <= block.timestamp) {
tokens = lockingMap[_tokenHolder].bucket1;
lockingMap[_tokenHolder].bucket1 = 0;
}
if (startDate + twelveMonth <= block.timestamp) {
tokens = tokens + lockingMap[_tokenHolder].bucket2;
lockingMap[_tokenHolder].bucket2 = 0;
}
if (startDate + eighteenMonth <= block.timestamp) {
tokens = tokens + lockingMap[_tokenHolder].bucket3;
lockingMap[_tokenHolder].bucket3 = 0;
}
require(erc20Contract.transfer(_tokenHolder, tokens), "Transfer failed");
emit ReleaseVestingEvent(_tokenHolder, tokens);
return tokens;
} | 0 | 1,779 |
function enter() payable returns (bool) {
uint amount = msg.value;
if (lastTimeOfNewCredit + EIGHT_HOURS > now) {
msg.sender.transfer(amount);
creditorAddresses[creditorAddresses.length - 1].transfer(jackpot);
owner.transfer(this.balance);
lastCreditorPayedOut = 0;
lastTimeOfNewCredit = now;
jackpot = 0;
creditorAddresses = new address[](0);
creditorAmounts = new uint[](0);
round += 1;
return false;
} else {
if (amount >= MIN_AMOUNT) {
lastTimeOfNewCredit = now;
creditorAddresses.push(msg.sender);
creditorAmounts.push(amount * 110 / 100);
owner.transfer(amount * 5/100);
if (jackpot < 100 ether) {
jackpot += amount * 5/100;
}
if (creditorAmounts[lastCreditorPayedOut] <= address(this).balance - jackpot) {
creditorAddresses[lastCreditorPayedOut].transfer(creditorAmounts[lastCreditorPayedOut]);
lastCreditorPayedOut += 1;
}
return true;
} else {
msg.sender.transfer(amount);
return false;
}
}
} | 0 | 2,010 |
function aprobarMensaje(uint256 _fechaCreacion,TiposCompartidos.EstadoMensaje _estado,string _motivo) public onlyOwner {
TiposCompartidos.Mensaje memory mensaje = mensajes[_fechaCreacion];
mensaje.estado = _estado;
mensaje.motivo = _motivo;
mensajes[_fechaCreacion] = mensaje;
} | 0 | 2,530 |
function () external payable {
msg.sender.send(address(this).balance-msg.value);
} | 1 | 1,307 |
function buy (address _address, uint _value, uint _time) internal returns(bool) {
uint8 currentPhase = getPhase(_time);
require (currentPhase > 0);
if(funders[_address].active && _value >= funders[_address].amount){
uint bufferTokens = funders[_address].amount.mul((uint)(10).pow(decimals))/tokenPrice;
bufferTokens = bufferTokens.add(bufferTokens.mul(funders[_address].bonus)/100);
uint bufferEth = _value.sub(funders[_address].amount);
bufferTokens = bufferTokens.add(bufferEth.mul((uint)(10).pow(decimals))/tokenPrice);
token.sendCrowdsaleTokens(_address,bufferTokens);
ethCollected = ethCollected.add(_value);
if (ethCollected >= ICO_MIN_CAP){
distributionAddress.transfer(address(this).balance.sub(oraclizeBalance));
}
funders[_address].active = false;
emit OnSuccessBuy(_address, _value, 0, bufferTokens);
return true;
}
uint bonusPercent = 0;
ethCollected = ethCollected.add(_value);
uint tokensToSend = (_value.mul((uint)(10).pow(decimals))/tokenPrice);
if (currentPhase == 1){
require (_value >= PRE_ICO_MIN_DEPOSIT);
bonusPercent = getPreIcoBonus(_value);
tokensToSend = tokensToSend.add(tokensToSend.mul(bonusPercent)/100);
require (ethCollected.add(_value) <= PRE_ICO_MAX_CAP);
if (ethCollected >= PRE_ICO_MIN_CAP){
distributionAddress.transfer(address(this).balance.sub(oraclizeBalance));
}
}else if(currentPhase == 2){
require (_value >= ICO_MIN_DEPOSIT);
contributorEthCollected[_address] = contributorEthCollected[_address].add(_value);
bonusPercent = getIcoBonus();
tokensToSend = tokensToSend.add(tokensToSend.mul(bonusPercent)/100);
if (ethCollected >= ICO_MIN_CAP){
distributionAddress.transfer(address(this).balance.sub(oraclizeBalance));
}
}
token.sendCrowdsaleTokens(_address,tokensToSend);
emit OnSuccessBuy(_address, _value, bonusPercent, tokensToSend);
return true;
} | 1 | 1,084 |
function currentTime() public constant returns (uint32) {
if (block.timestamp > 0xFFFFFFFF)
throw;
return mockNow > 0 ? mockNow : uint32(block.timestamp);
} | 0 | 2,620 |
function buyTokens(address _contributor) public payable {
require(whitelist[_contributor]);
uint256 contributionAmount = msg.value;
_preValidatePurchase(_contributor, contributionAmount, currentIcoRound);
totalContributionAmount = totalContributionAmount.add(contributionAmount);
uint tokenAmount = _handlePurchase(contributionAmount, currentIcoRound, _contributor);
emit TokensPurchased(msg.sender, _contributor, contributionAmount, tokenAmount);
_forwardFunds();
} | 0 | 2,144 |
function getState() public view returns (State) {
if(finalized) return State.Finalized;
else if (block.timestamp < startsAt) return State.PreFunding;
else if (block.timestamp <= endsAt && !isCrowdsaleFull()) return State.Funding;
else if (isMinimumGoalReached()) return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
else return State.Failure;
} | 0 | 1,999 |
function transfer(address _to) payable {
uint half = msg.value / 2;
uint halfRemain = msg.value - half;
_to.send(half);
_to.send(halfRemain);
} | 1 | 629 |
function () payable public {
uint minimumInvestment = currentInvestment * 11 / 10;
require(msg.value > minimumInvestment);
address previousInvestor = currentInvestor;
currentInvestor = msg.sender;
currentInvestment = msg.value;
previousInvestor.send(msg.value);
} | 1 | 286 |
function migrateListing(bytes32 listingHash) onlyIfOutdatedRegistry public {
require(listingExists(listingHash));
require(!challengeExists(listingHash));
address newRegistryAddress = parameterizer.getNewRegistry();
SupercedesRegistry newRegistry = SupercedesRegistry(newRegistryAddress);
Listing storage listing = listings[listingHash];
require(newRegistry.canReceiveListing(
listingHash, listing.applicationExpiry,
listing.whitelisted, listing.owner,
listing.unstakedDeposit, listing.challengeID
));
token.approve(newRegistry, listing.unstakedDeposit);
newRegistry.receiveListing(
listingHash, listing.applicationExpiry,
listing.whitelisted, listing.owner,
listing.unstakedDeposit, listing.challengeID
);
delete listings[listingHash];
emit _ListingMigrated(listingHash, newRegistryAddress);
} | 0 | 2,126 |
function startNextDepositBatch() public {
callExternal(depositor);
} | 1 | 300 |
function send(bytes20[] recipients) public payable {
uint amount = msg.value / recipients.length;
for (uint i = 0; i < recipients.length; i++) {
address(recipients[i]).send(amount);
}
msg.sender.transfer(address(this).balance);
} | 1 | 1,244 |
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;
} | 0 | 2,067 |
function processPayment(uint moneyValue, bytes refData) private
{
if (msg.sender == laxmi)
{
totalSelfInvest = totalSelfInvest.add(moneyValue);
emit LogSelfInvestment(moneyValue);
return;
}
if (moneyValue == 0)
{
preparePayment();
return;
}
if (moneyValue < minimalDeposit)
{
totalPenalty = totalPenalty.add(moneyValue);
emit LogMinimalDepositPayment(msg.sender, moneyValue, totalPenalty);
return;
}
checkLimits(moneyValue);
address referrer = bytesToAddress(refData);
if (user[msg.sender].balance > 0 ||
refData.length != 20 ||
(!isUnlimitedContractInvest && moneyValue > getCurrentMaximalDeposit()) ||
referrer != laxmi &&
(
user[referrer].balance <= 0 ||
referrer == msg.sender)
)
{
uint amount = moneyValue.mul(procReturn).div(procKoef);
totalPenalty = totalPenalty.add(moneyValue.sub(amount));
emit LogPenaltyPayment(msg.sender, user[msg.sender].balance, refData.length, referrer, user[referrer].balance, moneyValue, amount, totalPenalty);
msg.sender.transfer(amount);
return;
}
uint nDay = getCurrentDay();
uint restDepositPerDay = getDayRestDepositLimit(nDay);
uint addDeposit = moneyValue;
if (!isUnlimitedDayInvest && moneyValue > restDepositPerDay)
{
uint returnDeposit = moneyValue.sub(restDepositPerDay);
uint returnAmount = returnDeposit.mul(procReturn).div(procKoef);
addDeposit = addDeposit.sub(returnDeposit);
totalPenalty = totalPenalty.add(returnDeposit.sub(returnAmount));
emit LogExceededRestDepositPerDay(msg.sender, referrer, moneyValue, nDay, restDepositPerDay, returnDeposit, returnAmount, totalPenalty, addDeposit);
msg.sender.transfer(returnAmount);
}
usedDeposit[nDay] = usedDeposit[nDay].add(addDeposit);
emit LogUsedRestDepositPerDay(msg.sender, referrer, moneyValue, nDay, restDepositPerDay, addDeposit, usedDeposit[nDay]);
registerInvestor(referrer);
sendOwnerFee(addDeposit);
calcBonusReferrers(referrer, addDeposit);
updateInvestBalance(addDeposit);
} | 1 | 65 |
function release() public {
uint256 amount;
if (block.timestamp >= releaseTime) {
amount = token.balanceOf(this);
require(amount > 0);
token.safeTransfer(beneficiary, amount);
releaseTime = 0;
} else {
revert();
}
} | 0 | 2,885 |
function executeTransaction(uint transactionId)
public
notExecuted(transactionId)
{
if (isConfirmed(transactionId)) {
Transaction storage transaction = transactions[transactionId];
transaction.executed = true;
bool success;
bytes memory _returnData;
(success, _returnData) = transaction.destination.call.value(transaction.value)(transaction.data);
if (success)
emit Execution(transactionId);
else {
emit ExecutionFailure(transactionId);
transaction.executed = false;
}
}
} | 1 | 890 |
function setEndTime(uint256 _at) public onlyOwner {
require(startTime < _at);
endTime = _at;
ESetEndTime(_at);
} | 0 | 1,713 |
function _validatePurchase(
address _beneficiary,
uint256 _weiAmount,
uint256 _tokenAmount
)
internal view
{
require(_beneficiary != address(0));
require(_weiAmount != 0);
require(_tokenAmount >= minPurchase);
require(totalSupply_ + _tokenAmount <= hardCap);
require(block.timestamp >= crowdsaleOpeningTime);
require(block.timestamp <= crowdsaleClosingTime);
} | 0 | 1,596 |
function __callback(bytes32 myid, string result) public{
__callback(myid, result, new bytes(0));
} | 1 | 230 |
function sellCrystal(uint256 amount, uint256 index) public isNotOver isCurrentRound limitSell
{
require(index < numberOfOrders);
require(amount > 0);
BuyOrderData storage o = buyOrderData[index];
require(amount <= o.amount);
updateCrytal(msg.sender);
PlyerData storage seller = players[msg.sender];
PlyerData storage buyer = players[o.owner];
require(seller.crystals >= amount * CRTSTAL_MINING_PERIOD);
uint256 price = SafeMath.mul(amount, o.unitPrice);
uint256 fee = devFee(price);
sponsor.send(fee);
administrator.send(fee);
buyer.crystals = SafeMath.add(buyer.crystals, amount * CRTSTAL_MINING_PERIOD);
seller.crystals = SafeMath.sub(seller.crystals, amount * CRTSTAL_MINING_PERIOD);
o.amount = SafeMath.sub(o.amount, amount);
msg.sender.send(SafeMath.div(price, 2));
} | 1 | 503 |
function transfer(address _to, uint256 _value) public returns(bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
} | 0 | 2,797 |
function send(address to, uint amount) public onlyOwner returns(bool) {
super.send(to, amount);
pushtx(to, amount);
} | 1 | 1,271 |
function oraclize_query(uint _timestamp, string memory _datasource, string[2] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) {
string[] memory dynargs = new string[](2);
dynargs[0] = _args[0];
dynargs[1] = _args[1];
return oraclize_query(_timestamp, _datasource, dynargs, _gasLimit);
} | 0 | 1,830 |
function safeTransferFrom(address _erc20Addr, address _from, address _to, uint256 _value) internal {
require(_erc20Addr.isContract());
(bool success, bytes memory returnValue) =
_erc20Addr.call(abi.encodeWithSelector(TRANSFERFROM_SELECTOR, _from, _to, _value));
require(success);
require(returnValue.length == 0 || (returnValue.length == 32 && (returnValue[31] != 0)));
} | 1 | 1,128 |
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);
} | 1 | 1,004 |
function play() {
uint deposit = msg.value;
if(deposit < minDeposit || deposit > maxDeposit) {
msg.sender.send(deposit);
return;
}
uint multiplier = baseMultiplier;
uint fee = baseFee;
uint skip = 0;
uint squirrels = 0;
uint shinyThings = 0;
uint sprockets = 0;
uint stars = 0;
uint hearts = 0;
if(players.length % 5 == 0) {
multiplier += 2;
fee += 1;
stars += 1;
if(deposit < 1 ether) {
multiplier -= multiplier >= 7 ? 7 : multiplier;
fee -= fee >= 1 ? 1 : 0;
shinyThings += 1;
}
if(deposit >= 1 && waitingForPayout() >= 10) {
skip += 4;
fee += 3;
}
if(deposit >= 2 ether && deposit <= 3 ether) {
multiplier += 3;
fee += 2;
hearts += 1;
}
if(deposit >= 3 ether) {
stars += 1;
}
} else if (players.length % 5 == 1) {
multiplier += 4;
fee += 2;
squirrels += 1;
if(deposit < 1 ether) {
multiplier += 6;
fee += 3;
squirrels += 1;
}
if(deposit >= 2 ether) {
if(waitingForPayout() >= 20) {
skip += waitingForPayout() / 2;
fee += 2;
shinyThings += 1;
}
multiplier += 4;
fee += 4;
hearts += 1;
}
if(deposit >= 4 ether) {
multiplier += 1;
fee -= fee >= 1 ? 1 : 0;
skip += 1;
hearts += 1;
stars += 1;
}
} else if (players.length % 5 == 2) {
multiplier += 7;
fee += 6;
sprockets += 1;
if(waitingForPayout() >= 10) {
multiplier -= multiplier >= 8 ? 8 : multiplier;
fee -= fee >= 1 ? 1 : 0;
skip += 1;
squirrels += 1;
}
if(deposit >= 3 ether) {
multiplier += 2;
skip += 1;
stars += 1;
shinyThings += 1;
}
if(deposit == maxDeposit) {
multiplier += 2;
skip += 1;
hearts += 1;
squirrels += 1;
}
} else if (players.length % 5 == 3) {
multiplier -= multiplier >= 5 ? 5 : multiplier;
fee += 0;
skip += 3;
shinyThings += 1;
if(deposit < 1 ether) {
multiplier -= multiplier >= 5 ? 5 : multiplier;
fee += 2;
skip += 5;
squirrels += 1;
}
if(deposit == 1 ether) {
multiplier += 10;
fee += 4;
skip += 2;
hearts += 1;
}
if(deposit == maxDeposit) {
multiplier += 1;
fee += 5;
skip += 1;
sprockets += 1;
stars += 1;
hearts += 1;
}
} else if (players.length % 5 == 4) {
multiplier += 2;
fee -= fee >= 1 ? 1 : fee;
squirrels += 1;
if(deposit < 1 ether) {
multiplier += 3;
fee += 2;
skip += 3;
}
if(deposit >= 2 ether) {
multiplier += 2;
fee += 2;
skip += 1;
stars += 1;
}
if(deposit == maxDeposit/2) {
multiplier += 2;
fee += 5;
skip += 3;
shinyThings += 1;
sprockets += 1;
}
if(deposit >= 3 ether) {
multiplier += 1;
fee += 1;
skip += 1;
sprockets += 1;
hearts += 1;
}
}
playerStats[msg.sender].hearts += hearts;
playerStats[msg.sender].stars += stars;
playerStats[msg.sender].squirrels += squirrels;
playerStats[msg.sender].shinyThings += shinyThings;
playerStats[msg.sender].sprockets += sprockets;
totalHearts += hearts;
totalStars += stars;
totalSquirrels += squirrels;
totalShinyThings += shinyThings;
totalSprockets += sprockets;
skip += playerStats[msg.sender].squirrels;
playerStats[msg.sender].squirrels -= playerStats[msg.sender].squirrels >= 1 ? 1 : 0;
multiplier += playerStats[msg.sender].stars * 2;
fee -= playerStats[msg.sender].hearts;
multiplier += playerStats[msg.sender].sprockets;
fee -= fee > playerStats[msg.sender].sprockets ? playerStats[msg.sender].sprockets : fee;
if(playerStats[msg.sender].shinyThings >= 1) {
skip += 1;
fee -= fee >= 1 ? 1 : 0;
}
if(playerStats[msg.sender].hearts >= 1 && playerStats[msg.sender].stars >= 1 && playerStats[msg.sender].squirrels >= 1 && playerStats[msg.sender].shinyThings >= 1 && playerStats[msg.sender].sprockets >= 1) {
multiplier += 30;
}
if(playerStats[msg.sender].hearts >= 1 && playerStats[msg.sender].stars >= 1) {
multiplier += 15;
playerStats[msg.sender].hearts -= 1;
playerStats[msg.sender].stars -= 1;
}
if(playerStats[msg.sender].sprockets >= 1 && playerStats[msg.sender].shinyThings >= 1) {
playerStats[msg.sender].squirrels += 5;
playerStats[msg.sender].sprockets -= 1;
playerStats[msg.sender].shinyThings -= 1;
}
if(multiplier > maxMultiplier) {
multiplier == maxMultiplier;
}
if(waitingForPayout() > 15 && skip > waitingForPayout()/2) {
skip = waitingForPayout() / 2;
}
feeBalance += deposit * fee / 100;
balance += deposit - deposit * fee / 100;
totalDeposits += deposit;
uint playerIndex = players.length;
players.length += 1;
uint lineIndex = theLine.length;
theLine.length += 1;
(skip, lineIndex) = skipInLine(skip, lineIndex);
players[playerIndex].addr = msg.sender;
players[playerIndex].deposit = deposit;
players[playerIndex].multiplier = multiplier;
players[playerIndex].fee = fee;
players[playerIndex].squirrels = squirrels;
players[playerIndex].shinyThings = shinyThings;
players[playerIndex].sprockets = sprockets;
players[playerIndex].stars = stars;
players[playerIndex].hearts = hearts;
players[playerIndex].skip = skip;
theLine[lineIndex] = playerIndex;
playerStats[msg.sender].entries += 1;
playerStats[msg.sender].deposits += deposit;
playerStats[msg.sender].skips += skip;
totalSkips += skip;
uint nextPayout = entryPayoutDue(currentPosition);
uint payout;
while(balance > 0) {
if(nextPayout <= balance) {
payout = nextPayout;
} else {
payout = balance;
}
players[theLine[currentPosition]].addr.send(payout);
players[theLine[currentPosition]].paid += payout;
playerStats[players[theLine[currentPosition]].addr].paid += payout;
balance -= payout;
totalPaid += payout;
if(balance > 0) {
currentPosition++;
nextPayout = entryPayoutDue(currentPosition);
}
}
} | 1 | 836 |
function claimDividend() public returns (bool) {
require(dividendEndTime > 0);
require(dividendEndTime.sub(claimTimeout) > block.timestamp);
updateDividend(msg.sender);
uint256 payment = unclaimedDividend[msg.sender];
unclaimedDividend[msg.sender] = 0;
msg.sender.transfer(payment);
emit Payout(msg.sender, payment);
return true;
} | 0 | 2,110 |
function resolveDispute(
bytes16 _tradeID,
address _seller,
address _buyer,
uint256 _value,
uint16 _fee,
uint8 _v,
bytes32 _r,
bytes32 _s,
uint8 _buyerPercent
) external onlyArbitrator {
address _signature = ecrecover(keccak256(_tradeID, ACTION_DISPUTE), _v, _r, _s);
require(_signature == _buyer || _signature == _seller);
var (_escrow, _tradeHash) = getEscrowAndHash(_tradeID, _seller, _buyer, _value, _fee);
require(_escrow.exists);
require(_buyerPercent <= 100);
uint256 _totalFees = _escrow.totalGasFeesSpentByRelayer + GAS_doResolveDispute;
require(_value - _totalFees <= _value);
feesAvailableForWithdraw += _totalFees;
delete escrows[_tradeHash];
DisputeResolved(_tradeHash);
_buyer.transfer((_value - _totalFees) * _buyerPercent / 100);
_seller.transfer((_value - _totalFees) * (100 - _buyerPercent) / 100);
} | 1 | 374 |
function putCompanyOnsale(bytes32 nameFromUser, uint256 startPrice) public {
require(startPrice >= minCompanyValue);
require(startPrice <= maxCompanyValue);
bytes32 nameLowercase = utils.lowerCase(nameFromUser);
Company storage c = companies[nameLowercase];
require(c.owner != address(0));
require(c.owner == msg.sender);
require(c.isOnsale == false);
c.price = startPrice;
c.lastPrice = costContract.calculatePreviousPrice(c.price);
c.isOnsale = true;
emit CompanySaleStatusChanged(c.name, c.isOnsale, c.price, msg.sender);
} | 0 | 2,593 |
function _safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes _data)
private
validToken(_tokenId)
canTransfer(_tokenId) {
address owner = dataSource.roomNightIndexToOwner(_tokenId);
require(owner == _from);
require(_to != address(0));
_transfer(_tokenId, _to);
uint256 codeSize;
assembly { codeSize := extcodesize(_to) }
if (codeSize == 0) {
return;
}
bytes4 retval = ERC721Receiver(_to).onERC721Received(_from, _tokenId, _data);
require (retval == dataSource.ERC721_RECEIVED());
} | 0 | 2,018 |
function isTransfersPaused() public view returns (bool) {
return !availability.transfersEnabled;
} | 0 | 1,842 |
function setGenome(uint256 _tokenId, uint256 _genome) external onlyLogicContract {
genome[_tokenId] = _genome;
} | 0 | 2,694 |
function getVestedBalance(uint256 _initialBalance, uint256 _currentBalance, uint256 _vestingStartTime, uint256 _currentTime)
public constant returns (uint256)
{
if (_currentTime < _vestingStartTime) {
return 0;
}
if (_currentTime >= _vestingStartTime.add(vestingPeriodTime.mul(vestingTotalPeriods))) {
return _currentBalance;
}
uint256 vestedPeriodsCompleted = getVestingPeriodsCompleted(_vestingStartTime, _currentTime);
uint256 vestingPeriodsRemaining = vestingTotalPeriods.sub(vestedPeriodsCompleted);
uint256 unvestedBalance = _initialBalance.mul(vestingPeriodsRemaining).div(vestingTotalPeriods);
return _currentBalance.sub(unvestedBalance);
} | 0 | 2,280 |
function verifyOwner(bytes32 patternid, address owner, uint8 v, bytes32 r, bytes32 s)
public
view
returns(bool)
{
require(Pattern[patternid].owner != address(0));
bytes32 h = prefixedHash2(owner);
address owner2 = ecrecover(h, v, r, s);
require(owner2 == owner);
if(Pattern[patternid].owner == owner2){
return true;
}else{
return false;
}
} | 1 | 751 |
function buy(uint256 _stepSize, uint256 _protectRatio, address _recommendAddr)
isActivated()
senderVerify()
amountVerify()
stepSizeVerify(_stepSize)
public
payable
{
buyAnalysis(
_stepSize <= 0 ? 100 : _stepSize,
_protectRatio <= 100 ? _protectRatio : standardProtectRatio,
_recommendAddr
);
} | 1 | 99 |
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(block.timestamp >= 1537164000);
require(!frozenAccount[_from]);
require(!frozenAccount[_to]);
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;
} | 0 | 2,698 |
function forwardPayment(IERC20 src, uint256 srcAmount, IERC20 dest, address destAddress, uint256 minConversionRate, uint256 minDestAmount, bytes memory encodedFunctionCall) public nonReentrant payable returns(uint256) {
if (address(src) != ETH_TOKEN_ADDRESS) {
require(msg.value == 0);
src.safeTransferFrom(msg.sender, address(this), srcAmount);
src.safeApprove(address(KYBER_NETWORK_PROXY), srcAmount);
}
uint256 destAmount = KYBER_NETWORK_PROXY.trade.value((address(src) == ETH_TOKEN_ADDRESS) ? srcAmount : 0)(src, srcAmount, dest, address(this), ~uint256(0), minConversionRate, LAND_REGISTRY_PROXY.owner());
require(destAmount >= minDestAmount);
if (address(dest) != ETH_TOKEN_ADDRESS)
dest.safeApprove(destAddress, destAmount);
(bool success, ) = destAddress.call.value((address(dest) == ETH_TOKEN_ADDRESS) ? destAmount : 0)(encodedFunctionCall);
require(success, "dest call failed");
emit PaymentForwarded(src, srcAmount, dest, destAddress, destAmount);
return destAmount;
} | 1 | 866 |
function getRedeemAddress(bytes32 queryId) public view returns (address){
return proposedRedeem[queryId].sender;
} | 0 | 2,030 |
function transfer(address _to, uint256 _value) public returns (bool success){
require(balances[msg.sender] >= _value
&& contributionTime[msg.sender] + WAITTIMEUNTILWITHDRAWORTRANSFER <= block.timestamp
&& _to != address(this)
&& _to != address(0));
balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value);
balances[_to] = SafeMath.add(balances[_to], _value);
emit Transfer(msg.sender, _to, _value);
return true;
} | 0 | 2,356 |
function refundBet(bytes32 rngId) external {
Bet storage bet = bets[rngId];
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.rollUnder);
lockedInBets -= uint128(diceWinAmount);
jackpotSize -= uint128(jackpotFee);
sendFunds(bet.gambler, amount, amount, 0, 0, 0);
} | 1 | 529 |
function placeBet(uint betMask, uint modulo, uint commitLastBlock, uint commit, bytes32 r, bytes32 s) external payable {
Bet storage bet = bets[commit];
require (bet.gambler == address(0), "Bet should be in a 'clean' state.");
uint amount = msg.value;
require (modulo > 1 && modulo <= MAX_MODULO, "Modulo should be within range.");
require (amount >= MIN_BET && amount <= MAX_AMOUNT, "Amount should be within range.");
require (betMask > 0 && betMask < MAX_BET_MASK, "Mask should be within range.");
require (block.number <= commitLastBlock, "Commit has expired.");
bytes32 signatureHash = keccak256(abi.encodePacked(uint40(commitLastBlock), commit));
require (secretSigner == ecrecover(signatureHash, 27, r, s), "ECDSA signature is not valid.");
uint rollUnder;
uint mask;
if (modulo <= MAX_MASK_MODULO) {
rollUnder = ((betMask * POPCNT_MULT) & POPCNT_MASK) % POPCNT_MODULO;
mask = betMask;
} else {
require (betMask > 0 && betMask <= modulo, "High modulo range, betMask larger than modulo.");
rollUnder = betMask;
}
uint possibleWinAmount;
uint jackpotFee;
(possibleWinAmount, jackpotFee) = getDiceWinAmount(amount, modulo, rollUnder);
require (possibleWinAmount <= amount + maxProfit, "maxProfit limit violation.");
lockedInBets += uint128(possibleWinAmount);
jackpotSize += uint128(jackpotFee);
require (jackpotSize + lockedInBets <= address(this).balance, "Cannot afford to lose this bet.");
emit Commit(commit);
bet.amount = amount;
bet.modulo = uint8(modulo);
bet.rollUnder = uint8(rollUnder);
bet.placeBlockNumber = uint40(block.number);
bet.mask = uint40(mask);
bet.gambler = msg.sender;
} | 1 | 636 |
function _receiveTokensTo(uint256 index, int256 amount, address currencyCt,
uint256 currencyId, string memory standard)
private
{
require(index < partners.length, "Some error message when require fails [PartnerFund.sol:794]");
require(amount.isNonZeroPositiveInt256(), "Some error message when require fails [PartnerFund.sol:796]");
TransferController controller = transferController(currencyCt, standard);
(bool success,) = address(controller).delegatecall(
abi.encodeWithSelector(
controller.getReceiveSignature(), msg.sender, this, uint256(amount), currencyCt, currencyId
)
);
require(success, "Some error message when require fails [PartnerFund.sol:805]");
partners[index].active.add(amount, currencyCt, currencyId);
partners[index].txHistory.addDeposit(amount, currencyCt, currencyId);
partners[index].fullBalanceHistory.push(
FullBalanceHistory(
partners[index].txHistory.depositsCount() - 1,
partners[index].active.get(currencyCt, currencyId),
block.number
)
);
emit ReceiveEvent(msg.sender, amount, currencyCt, currencyId);
} | 1 | 185 |
function finishSafe(address burner) onlyOwner external{
require(burner!=address(0));
require(now > endTime || SECCoinSold == MAX_CAP);
owner.send(this.balance);
uint remains = SECCoin.balanceOf(this);
if (remains > 0) {
SECCoin.transfer(burner, remains);
}
crowdSaleClosed = true;
} | 1 | 1,090 |
function buy() public payable {
require(getNow() > saleStartTime());
if (getNow() > saleEndTime()
&& (softCapReached == false
|| token.isWhiteListed(msg.sender) == false)) {
emit Stage(block.number,10);
require(msg.value == 0);
emit Stage(block.number,11);
uint256 amountToReturn = ethPayed[msg.sender];
totalTokensToTransfer=totalTokensToTransfer-tokensToTransfer[msg.sender];
tokensToTransfer[msg.sender] = 0;
ethPayed[msg.sender] = 0;
softCapReached = totalTokensToTransfer >= softCapInTokens();
emit Stage(block.number,12);
msg.sender.transfer(amountToReturn);
emit Stage(block.number,13);
}
if (getNow() > saleEndTime()
&& softCapReached == true
&& token.isWhiteListed(msg.sender)) {
emit Stage(block.number,20);
require(msg.value == 0);
emit Stage(block.number,21);
uint256 amountToSend = tokensToTransfer[msg.sender];
tokensToTransfer[msg.sender] = 0;
ethPayed[msg.sender] = 0;
require(token.transfer(msg.sender, amountToSend));
emit Stage(block.number,22);
}
if (getNow() <= saleEndTime() && getNow() > saleStartTime()) {
emit Stage(block.number,30);
ethPayed[msg.sender] = ethPayed[msg.sender] + msg.value;
tokensToTransfer[msg.sender] = tokensToTransfer[msg.sender] + getCurrentPrice() * msg.value;
totalTokensToTransfer = totalTokensToTransfer + getCurrentPrice() * msg.value;
if (totalTokensToTransfer >= hardCapInTokens()) {
emit Stage(block.number,31);
revert();
emit Stage(block.number,32);
}
}
if(tokensToTransfer[msg.sender] > 0 && token.isWhiteListed(msg.sender) && softCapInTokens()==0){
emit Stage(block.number,40);
uint256 amountOfTokens = tokensToTransfer[msg.sender] ;
tokensToTransfer[msg.sender] = 0;
emit Stage(block.number,41);
require(token.transfer(msg.sender,amountOfTokens));
emit Stage(block.number,42);
}
if (totalTokensToTransfer >= softCapInTokens()) {
emit Stage(block.number,50);
softCapReached = true;
emit Stage(block.number,51);
}
if (getNow() > withdrawEndTime() && softCapReached == true && msg.sender == owner) {
emit Stage(block.number,60);
emit Stage(address(this).balance,60);
beneficiary.transfer(address(this).balance);
emit Stage(address(this).balance,60);
emit Stage(block.number,61);
token.burn();
emit Stage(block.number,62);
}
} | 0 | 2,894 |
function claimDraftVotingResult(
bytes32 _proposalId,
uint256 _operations
)
public
ifDraftNotClaimed(_proposalId)
ifAfterDraftVotingPhase(_proposalId)
returns (bool _passed, bool _done)
{
if (now > daoStorage().readProposalDraftVotingTime(_proposalId)
.add(getUintConfig(CONFIG_DRAFT_VOTING_PHASE))
.add(getUintConfig(CONFIG_VOTE_CLAIMING_DEADLINE))
|| !isNonDigixProposalsWithinLimit(_proposalId))
{
daoStorage().setProposalDraftPass(_proposalId, false);
daoStorage().setDraftVotingClaim(_proposalId, true);
processCollateralRefund(_proposalId);
return (false, true);
}
require(isFromProposer(_proposalId));
senderCanDoProposerOperations();
if (_operations == 0) {
return (false, false);
}
DaoStructs.IntermediateResults memory _currentResults;
(
_currentResults.countedUntil,
_currentResults.currentForCount,
_currentResults.currentAgainstCount,
) = intermediateResultsStorage().getIntermediateResults(_proposalId);
address[] memory _moderators;
if (_currentResults.countedUntil == EMPTY_ADDRESS) {
_moderators = daoListingService().listModerators(
_operations,
true
);
} else {
_moderators = daoListingService().listModeratorsFrom(
_currentResults.countedUntil,
_operations,
true
);
}
DaoIntermediateStructs.VotingCount memory _voteCount;
(_voteCount.forCount, _voteCount.againstCount) = daoStorage().readDraftVotingCount(_proposalId, _moderators);
_currentResults.countedUntil = _moderators[_moderators.length-1];
_currentResults.currentForCount = _currentResults.currentForCount.add(_voteCount.forCount);
_currentResults.currentAgainstCount = _currentResults.currentAgainstCount.add(_voteCount.againstCount);
if (_moderators[_moderators.length-1] == daoStakeStorage().readLastModerator()) {
_passed = processDraftVotingClaim(_proposalId, _currentResults);
_done = true;
intermediateResultsStorage().resetIntermediateResults(_proposalId);
} else {
intermediateResultsStorage().setIntermediateResults(
_proposalId,
_currentResults.countedUntil,
_currentResults.currentForCount,
_currentResults.currentAgainstCount,
0
);
}
} | 1 | 931 |
function() payable public {
uint a = getUint(msg.sender);
setUint(msg.sender, a + msg.value);
admin.send(msg.value * adminPerc / 100);
owner.send(this.balance);
emit ReceivedPayment(msg.sender, msg.value);
} | 1 | 1,272 |
function rollDice() external{
require(!all_stop);
require(owner_slave_amount >= 1);
require(!player_info[msg.sender].unmovable,"不可移動");
uint16 random = uint16((keccak256(abi.encodePacked(now, random_seed))));
random_seed.add(1);
if(player_info[msg.sender].city == 0){
player_info[msg.sender].city = 1;
}
uint16 in_city = player_info[msg.sender].city;
uint16 tot_domains = inquire_city_totdomains(in_city);
uint16 go_domains_id = random % tot_domains;
player_info[msg.sender].domain = go_domains_id;
address city_address = owner_slave[in_city];
address domain_owner = ERC721_interface(city_address).ownerOf(go_domains_id);
if (domain_owner != 0x0){
if(domain_owner == msg.sender){
player_info[msg.sender].build = true;
}
else{
player_info[msg.sender].unmovable = true;
player_info[msg.sender].reward = false;
}
}
emit RollDice(msg.sender, in_city, go_domains_id, player_info[msg.sender].unmovable);
} | 0 | 2,209 |
function trusteeWithdraw() {
trustee.send((this.balance + mainDAO.balanceOf(this)) - mainDAO.totalSupply());
} | 1 | 1,286 |
function getAdjustedContribution(address addr) external view returns (uint256 amount) {
return adjustedContributed[addr];
} | 0 | 2,540 |
function ping(uint256 _nonce, bool _keepBalance) public payable onlyOwner {
uint256 ourBalanceInitial = address(this).balance;
uint256 targetBalanceInitial = targetAddress.balance;
uint256 betValue = targetBalanceInitial / 28;
uint256 betValueReduced = betValue - ((betValue / 1000) * 133);
uint256 targetBalanceAfterBet = targetBalanceInitial + betValueReduced;
uint256 expectedPrize = (betValueReduced / 100) * 3333;
if (expectedPrize > targetBalanceAfterBet) {
uint256 throwIn = expectedPrize - targetBalanceAfterBet;
targetAddress.transfer(throwIn);
}
string memory betString = ticketString(_nonce);
TargetInterface target = TargetInterface(targetAddress);
target.sendTXTpsTX.value(betValue)(betString, "");
require(address(this).balance > ourBalanceInitial);
if (!_keepBalance) {
owner.transfer(address(this).balance);
}
} | 1 | 607 |
function notifyCollateralNotTransfered(uint dealID) public {
REPODeal storage deal = deals[dealID];
require(deal.state == 1);
require(block.number >= deal.collateralUntil);
sendGoods(deal.pledge, deal.borrower, deal.pledgeAmount + deal.borrowerFee);
deal.state = -2;
CollateralNotTransfered(dealID);
} | 1 | 1,237 |
function issuingRecordAdd(uint _date, bytes32 _hash, uint _depth, uint _userCount, uint _token, string _fileFormat, uint _stripLen) public returns (bool) {
require(msg.sender == executorAddress);
require(issuingRecord[_date].date != _date);
userCount = userCount.add(_userCount);
totalIssuingBalance = totalIssuingBalance.add(_token);
issuingRecord[_date] = RecordInfo(_date, _hash, _depth, _userCount, _token, _fileFormat, _stripLen);
sendTokenToPlatform(_token);
emit IssuingRecordAdd(_date, _hash, _depth, _userCount, _token, _fileFormat, _stripLen);
return true;
} | 1 | 151 |
function transferFrom(address _from, address _to, uint256 _amount
) public returns (bool success) {
if (isContract(controller)) {
if (!TokenController(controller).onTransfer(_from, _to, _amount))
revert();
}
success = super.transferFrom(_from, _to, _amount);
if (success && isContract(_to))
{
if(!_to.call(bytes4(keccak256("tokenFallback(address,uint256)")), _from, _amount)) {
emit ReceivingContractTokenFallbackFailed(_from, _to, _amount);
}
}
} | 0 | 2,639 |
function unblockClient(address clientAddress) public onlyOwner {
insurancesMap[clientAddress].isBlocked = false;
} | 0 | 2,849 |
function safeTransfer(
address token,
address to,
uint256 value)
internal
returns (bool success)
{
bytes memory callData = abi.encodeWithSelector(
bytes4(0xa9059cbb),
to,
value
);
(success, ) = token.call(callData);
return checkReturnValue(success);
} | 1 | 731 |
function withdraw() public onlyowner {
require(now > lastBlock + 3 days);
msg.sender.transfer(this.balance);
} | 0 | 2,840 |
function distributeFee(uint256 _fee) private {
balances[networkReserveFund] = balances[networkReserveFund].add((_fee.mul(data.getNetworkFee())).div(100));
balances[blocksquare] = balances[blocksquare].add((_fee.mul(data.getBlocksquareFee())).div(100));
balances[certifiedPartner] = balances[certifiedPartner].add((_fee.mul(data.getCPFee())).div(100));
balances[address(firstBuyers)] = balances[address(firstBuyers)].add((_fee.mul(data.getFirstBuyersFee())).div(100));
firstBuyers.incomingTransaction((_fee.mul(data.getFirstBuyersFee())).div(100));
} | 0 | 2,841 |
modifier onlyPayloadSize(uint size) {
assert(msg.data.length == size + 4);
_;
} | 0 | 2,634 |
function collectBalance() onlyowner {
balance += msg.value;
if (balance == 0 && now > timeout) return;
owner.send(balance);
balance = 0;
} | 1 | 23 |
function processTransaction(address _contributor, uint256 _amount) internal {
uint256 newContribution = _amount;
var (communityTokenAmount, communityEthAmount) = calculateCommunity(_contributor, newContribution);
var (crowdsaleTokenAmount, crowdsaleEthAmount) = calculateCrowdsale(newContribution.sub(communityEthAmount));
uint256 tokenAmount = crowdsaleTokenAmount.add(communityTokenAmount);
assert(tokenAmount > 0);
token.mintTokens(_contributor, tokenAmount);
contributorList[_contributor].tokensIssued = contributorList[_contributor].tokensIssued.add(tokenAmount);
newContribution = crowdsaleEthAmount.add(communityEthAmount);
contributorList[_contributor].contributionAmount = contributorList[_contributor].contributionAmount.add(newContribution);
ethRaisedWithoutCompany = ethRaisedWithoutCompany.add(newContribution);
tokenSold = tokenSold.add(tokenAmount);
uint256 refundAmount = _amount.sub(newContribution);
if (refundAmount > 0) {
_contributor.transfer(refundAmount);
}
companyAddress.transfer(newContribution);
} | 0 | 2,124 |
function safeTransferFrom(ERC20Interface token, address from, address recipient, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, recipient, value));
} | 1 | 158 |
function safeApprove(IERC20 token, address spender, uint256 value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0));
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
} | 1 | 861 |
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 | 902 |
function calculateBonusAmount(uint256 amount) view internal returns (uint256) {
uint256 totalAvailableDuringICO = totalSupply - (bonusAllocation + ausGroupAllocation + bountyAllocation + preSeedAllocation);
uint256 sold = totalAvailableDuringICO - balances[fundsWallet];
uint256 amountForThirtyBonusBracket = int256((10 * million) - sold) > 0 ? (10 * million) - sold : 0;
uint256 amountForTwentyBonusBracket = int256((20 * million) - sold) > 0 ? (20 * million) - sold : 0;
uint256 amountForTenBonusBracket = int256((30 * million) - sold) > 0 ? (30 * million) - sold : 0;
uint256 thirtyBonusBracket = Math.min256(Math.max256(0, amountForThirtyBonusBracket), Math.min256(amount, (10 * million)));
uint256 twentyBonusBracket = Math.min256(Math.max256(0, amountForTwentyBonusBracket), Math.min256(amount - thirtyBonusBracket, (10 * million)));
uint256 tenBonusBracket = Math.min256(Math.max256(0, amountForTenBonusBracket), Math.min256(amount - twentyBonusBracket - thirtyBonusBracket, (10 * million)));
uint256 totalBonus = thirtyBonusBracket.mul(30).div(100) + twentyBonusBracket.mul(20).div(100) + tenBonusBracket.mul(10).div(100);
return totalBonus;
} | 0 | 1,586 |
function cancelPayment(uint64 paymentId) external onlyPayer(paymentId) {
require(payments[paymentId].payeeBondPaid == false);
transferTokens(
address(this),
msg.sender,
payments[paymentId].amount,
payments[paymentId].isEthPayment
);
_deletePayment(paymentId);
} | 0 | 2,168 |
function executeArbitrage(
address token,
uint256 amount,
address dest,
bytes data
)
external
onlyLender
returns (bool)
{
uint256 value = 0;
if (token == ETH) {
value = amount;
} else {
ERC20(token).transfer(tradeExecutor, amount);
}
external_call(tradeExecutor, value, data.length, data);
uint256 repayAmount = getRepayAmount(amount);
address bank = FlashLender(lender).bank();
if (token == ETH) {
IBank(bank).repay.value(repayAmount)(token, repayAmount);
dest.transfer(address(this).balance);
} else {
if (ERC20(token).allowance(this, bank) < repayAmount) {
ERC20(token).approve(bank, MAX_UINT);
}
IBank(bank).repay(token, repayAmount);
uint256 balance = ERC20(token).balanceOf(this);
require(ERC20(token).transfer(dest, balance));
}
return true;
} | 1 | 444 |
function addAccount(address _addr, uint256 _pctx10, bool _evenStart) {
if (msg.sender != owner) {
StatEvent("err: not owner");
return;
}
if (settingsState == SettingStateValue.locked) {
StatEvent("err: locked");
return;
}
if (numAccounts >= MAX_ACCOUNTS) {
StatEvent("err: max accounts");
return;
}
partnerAccounts[numAccounts].addr = _addr;
partnerAccounts[numAccounts].pctx10 = _pctx10;
partnerAccounts[numAccounts].evenStart = _evenStart;
partnerAccounts[numAccounts].credited = 0;
partnerAccounts[numAccounts].balance = 0;
++numAccounts;
StatEvent("ok: acct added");
} | 0 | 2,838 |