func
stringlengths 11
25k
| label
int64 0
1
| __index_level_0__
int64 0
19.4k
|
---|---|---|
function generateRandomNum() internal returns(bytes32){
if (randomGenerateMethod == 0){
randomQueryID += 1;
string memory queryString1 = "[URL] ['json(https:
string memory queryString1_1 = ",\"n\":1,\"min\":1,\"max\":100,\"replacement\":true,\"base\":10${[identity] \"}\"},\"id\":";
queryString1 = queryString1.toSlice().concat(randomApiKey.toSlice());
queryString1 = queryString1.toSlice().concat(queryString1_1.toSlice());
string memory queryString2 = uint2str(randomQueryID);
string memory queryString3 = "${[identity] \"}\"}']";
string memory queryString1_2 = queryString1.toSlice().concat(queryString2.toSlice());
string memory queryString1_2_3 = queryString1_2.toSlice().concat(queryString3.toSlice());
oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
return oraclize_query("nested", queryString1_2_3, gasForOraclize);
}
}
| 1 | 5,687 |
functions
function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) public constant returns (bool limitBroken);
function isBreakingInvestorCap(address receiver, uint tokenAmount) public constant returns (bool limitBroken);
function isCrowdsaleFull() public constant returns (bool);
function assignTokens(address receiver, uint tokenAmount) private;
}
contract StandardToken is ERC20, SafeMath {
event Minted(address receiver, uint amount);
mapping(address => uint) balances;
mapping (address => mapping (address => uint)) allowed;
function isToken() public constant returns (bool weAre) {
return true;
}
| 0 | 17,328 |
function setSupplyLimit(uint16 _talismanType, uint16 _supplyLimit) external onlyMinter {
require(talismanTypeToSupplyLimit[_talismanType] == 0 || _supplyLimit < talismanTypeToSupplyLimit[_talismanType],
"_supplyLimit is higher than current supply limit");
talismanTypeToSupplyLimit[_talismanType] = _supplyLimit;
}
| 0 | 18,307 |
function __callback(bytes32 myid, string result, bytes proof)
onlyOraclize
onlyIfBetExist(myid)
onlyIfNotProcessed(myid)
onlyIfValidRoll(myid, result)
onlyIfBetSizeIsStillCorrect(myid) {
uint numberRolled = parseInt(result);
bets[myid].numberRolled = numberRolled;
isWinningBet(bets[myid], numberRolled);
isLosingBet(bets[myid], numberRolled);
delete profitDistributed;
}
| 1 | 2,543 |
function updateMessage(uint _tokenId, string _personalMessage) {
require(tokenOwner[_tokenId] == msg.sender);
_message[_tokenId] = _personalMessage;
MessageUpdated(_tokenId, msg.sender, _personalMessage);
}
| 0 | 10,247 |
function sendToken(address _address, uint256 _amountTokens) public onlyOwner returns(bool success) {
_sendToken(_address, _amountTokens);
return true;
}
| 0 | 15,792 |
function doBuy(address _th) internal {
if (getBlockTimestamp() <= startTime + 1 days) {
require(canPurchase[_th] || msg.sender == collector);
} else if (notCollectedAmountAfter24Hours == 0) {
notCollectedAmountAfter24Hours = weiToCollect();
twentyPercentWithBonus = notCollectedAmountAfter24Hours.mul(20).div(100);
thirtyPercentWithBonus = notCollectedAmountAfter24Hours.mul(30).div(100);
}
require(msg.value >= minimumPerTransaction);
uint256 toFund = msg.value;
uint256 toCollect = weiToCollectByInvestor(_th);
if (toCollect > 0) {
if (toFund > toCollect) {
toFund = toCollect;
}
uint256 tokensGenerated = tokensToGenerate(toFund);
require(tokensGenerated > 0);
require(aix.generateTokens(_th, tokensGenerated));
contributionWallet.transfer(toFund);
individualWeiCollected[_th] = individualWeiCollected[_th].add(toFund);
totalWeiCollected = totalWeiCollected.add(toFund);
NewSale(_th, toFund, tokensGenerated);
} else {
toFund = 0;
}
uint256 toReturn = msg.value.sub(toFund);
if (toReturn > 0) {
_th.transfer(toReturn);
}
}
| 1 | 2,275 |
function _burn(uint value) internal {
_totalSupply = _totalSupply.sub(value);
_balances[msg.sender] = _balances[msg.sender].sub(value);
emit Transfer(msg.sender, address(0), value);
}
| 0 | 16,130 |
function nextWave() private {
m_investors = new InvestorsStorage();
changePaymode(Paymode.Push);
m_paysys.latestKeyIndex = m_investors.iterStart();
investmentsNum = 0;
waveStartup = now;
m_nextWave = false;
emit LogNextWave(now);
}
| 1 | 4,037 |
function buyXname(bytes32 _affCode, uint256 _team)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
MC2datasets.EventReturns memory _eventData_ = determinePID(_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);
buyCore(_pID, _affID, _team, _eventData_);
}
| 1 | 420 |
function arbitrateC4FContract(uint8 percentReturned) public onlyOwner returns (bool success) {
require((providerDisputed) || (requesterDisputed));
uint256 actTokens = getTokenValue();
uint256 arbitrationTokens = actTokens.mul(arbitrationCosts);
arbitrationTokens = arbitrationTokens.div(100);
actTokens = actTokens.sub(arbitrationTokens);
uint256 requesterTokens = actTokens.mul(percentReturned);
requesterTokens = requesterTokens.div(100);
actTokens = actTokens.sub(requesterTokens);
C4FToken C4F = C4FToken(owner);
address commissionTarget = C4F.getCommissionTarget();
if(!C4F.transfer(requester, requesterTokens)) revert();
if(!C4F.transfer(provider, actTokens)) revert();
if(!C4F.transfer(commissionTarget, arbitrationTokens)) revert();
status = 4;
closeTime = now;
success = true;
escrowArbitrated(provider,requesterTokens,arbitrationTokens);
return success;
}
| 1 | 284 |
(isAgent(spender) && super._isApprovedOrOwner(tx.origin, tokenId)) ||
owner() == spender
);
}
function mint(address to, uint256 genes, uint256 level) public onlyAgent returns (uint) {
lastId = lastId.add(1);
return mint(lastId, to, genes, level);
}
function mint(uint256 tokenId, address to, uint256 genes, uint256 level) public onlyAgent returns (uint) {
_mint(to, tokenId);
_setMetadata(tokenId, genes, level);
emit Mint(to, tokenId);
return tokenId;
}
function burn(uint256 tokenId) public returns (uint) {
require(_isApprovedOrOwner(msg.sender, tokenId));
address owner = ownerOf(tokenId);
_clearMetadata(tokenId);
_burn(owner, tokenId);
emit Burn(owner, tokenId);
return tokenId;
}
function addWin(uint256 _tokenId, uint _winsCount, uint _levelUp) external onlyAgent returns (bool){
require(_addWin(_tokenId, _winsCount, _levelUp));
return true;
}
function addLoss(uint256 _tokenId, uint _lossesCount, uint _levelDown) external onlyAgent returns (bool){
require(_addLoss(_tokenId, _lossesCount, _levelDown));
return true;
}
function lock(uint256 _tokenId, uint256 _lockedTo, bool _onlyFreeze) external onlyAgent returns(bool) {
require(_exists(_tokenId));
uint agentId = getAgentId(msg.sender);
Character storage c = characters[_tokenId];
if (c.lockId != 0 && agentId != c.lockId) {
address a = getAgentById(c.lockId);
if (isAgentHasAllowance(a)) {
AgentContract ac = AgentContract(a);
require(ac.isAllowed(_tokenId));
}
}
| 0 | 17,724 |
function start() public {
require(msg.sender == owner);
require(startTime == 0);
lrcInitialBalance = Token(lrcTokenAddress).balanceOf(address(this));
require(lrcInitialBalance > 0);
lrcUnlockPerMonth = lrcInitialBalance.div(24);
startTime = now;
Started(startTime);
}
| 1 | 998 |
function transfer(address _to, uint256 _value) returns (bool success) {
require (block.number >= tokenFrozenUntilBlock) ;
require (!rAddresses[_to]) ;
require (balances[msg.sender] >= _value);
require (balances[_to] + _value >= balances[_to]) ;
require (!(msg.sender == owner && block.timestamp < timeLock && (balances[msg.sender]-_value) < 10000000 * 10 ** 18));
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
}
| 0 | 18,791 |
function buyXid(uint256 _affCode, uint256 _team)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
Fumodatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
uint256 _pID = pIDxAddr_[msg.sender];
if (_affCode == 0 || _affCode == _pID)
{
_affCode = plyr_[_pID].laff;
} else if (_affCode != plyr_[_pID].laff) {
plyr_[_pID].laff = _affCode;
}
_team = verifyTeam(_team);
buyCore(_pID, _affCode, _team, _eventData_);
}
| 1 | 7,085 |
function() public payable {
buy();
if(softCapInTokens()==0 && token.isWhiteListed(msg.sender)==false){
revert('User needs to be immediatly whiteListed in Presale');
}
if (address(this).balance < devSum) {
devSum = devSum - address(this).balance;
uint256 tmp = address(this).balance;
dev.transfer(tmp);
} else {
dev.transfer(devSum);
emit Stage2(dev,70);
devSum = 0;
}
if(softCapInTokens()==0){
beneficiary.transfer(address(this).balance);
}
}
| 1 | 3,181 |
function setParameters(
uint[14] _params
)
public
returns(bytes32)
{
require(_params[0] <= 100 && _params[0] > 0,"0 < preBoostedVoteRequiredPercentage <= 100");
require(_params[4] > 0 && _params[4] <= 100000000,"0 < thresholdConstB < 100000000 ");
require(_params[3] <= 100000000 ether,"thresholdConstA <= 100000000 wei");
require(_params[9] <= 100,"stakerFeeRatioForVoters <= 100");
require(_params[10] <= 100,"votersReputationLossRatio <= 100");
require(_params[11] <= 100,"votersGainRepRatioFromLostRep <= 100");
require(_params[2] >= _params[6],"boostedVotePeriodLimit >= quietEndingPeriod");
require(_params[7] <= 100000000,"proposingRepRewardConstA <= 100000000");
require(_params[8] <= 100000000,"proposingRepRewardConstB <= 100000000");
require(_params[12] <= (2 * _params[9]),"daoBountyConst <= 2 * stakerFeeRatioForVoters");
require(_params[12] >= _params[9],"daoBountyConst >= stakerFeeRatioForVoters");
bytes32 paramsHash = getParametersHash(_params);
parameters[paramsHash] = Parameters({
preBoostedVoteRequiredPercentage: _params[0],
preBoostedVotePeriodLimit: _params[1],
boostedVotePeriodLimit: _params[2],
thresholdConstA:_params[3],
thresholdConstB:_params[4],
minimumStakingFee: _params[5],
quietEndingPeriod: _params[6],
proposingRepRewardConstA: _params[7],
proposingRepRewardConstB:_params[8],
stakerFeeRatioForVoters:_params[9],
votersReputationLossRatio:_params[10],
votersGainRepRatioFromLostRep:_params[11],
daoBountyConst:_params[12],
daoBountyLimit:_params[13]
});
return paramsHash;
}
| 0 | 17,167 |
function TradeFinancing(){
productsExported = false;
tradeDealRequested = false;
tradeDealConfirmed= false;
productsShipped = false;
bankersAcceptanceOfDeal = false;
discountedDealAmount = 0;
exporterAcceptedIBankDraft= false;
exporterReceivedPayment = false;
currentLiquidInDeal = 0;
gasPrice = 21000;
minimumDealAmount = 200;
creatorAddress = 0xDC78E37377eB0493cB41bD1900A541626FdC2F02;
}
| 0 | 14,727 |
function transfer(address _to, uint256 _value) {
checkForUpdates();
if (balanceOf[msg.sender] < _value) throw;
if (balanceOf[_to] + _value < balanceOf[_to]) throw;
if (frozenAccount[msg.sender]) throw;
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
}
| 1 | 8,390 |
function _processPurchase(
address _beneficiary,
uint256 _tokenAmount
)
internal
doesNotExceedLimit(_beneficiary, _tokenAmount, token.balanceOf(_beneficiary), kycLimitThreshold)
{
super._processPurchase(_beneficiary, _tokenAmount);
}
| 1 | 3,265 |
function withdrawAllToken() public {
lock();
uint256 _amount = userTokenOf[msg.sender];
_withdrawToken(msg.sender, _amount);
unLock();
}
| 1 | 3,073 |
function safeSymbol(address token) internal returns(bytes32 symbol) {
(bool success, bytes memory data) = token.call(abi.encodeWithSignature("symbol()"));
if (!success) {
(success, data) = token.call(abi.encodeWithSignature("Symbol()"));
}
if (!success) {
(success, data) = token.call(abi.encodeWithSignature("SYMBOL()"));
}
if (!success) {
return 0;
}
uint256 dataLength = data.length;
assembly {
symbol := mload(add(data, dataLength))
}
}
| 0 | 17,961 |
function mintToken(address target, uint256 mintedAmount) onlyOwner {
checkForUpdates();
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
Transfer(0, this, mintedAmount);
Transfer(this, target, mintedAmount);
}
| 1 | 3,698 |
function registerTickets(uint256 number_of_tickets) public returns (int8 registerTickets_STATUS)
{
if (raffle_bowl.length > 256)
{
next_week_timestamp = now;
}
if (now >= next_week_timestamp)
{
int8 RAFFLE_STATUS = resetRaffle();
if (RAFFLE_STATUS == -2)
return -3;
if (RAFFLE_STATUS == -3)
return -5;
if (RAFFLE_STATUS == -4)
return -6;
}
if ( (number_of_tickets == 0) || (number_of_tickets > 5) || (address_to_tickets[msg.sender] >= 5) )
return -1;
if (ERC20_CALLS.allowance(msg.sender, raffle_addr) < ticket_price * number_of_tickets)
return -2;
if (ERC20_CALLS.balanceOf(msg.sender) < ticket_price * number_of_tickets)
return - 2;
if (fillWeeklyArrays(number_of_tickets, msg.sender) == -1)
return -4;
else
{
ERC20_CALLS.transferFrom(msg.sender, raffle_addr, number_of_tickets * ticket_price);
return 0;
}
}
| 1 | 9,282 |
function semanticVersionHash(uint16[3] version) internal pure returns (bytes32) {
return keccak256(version[0], version[1], version[2]);
}
| 0 | 17,795 |
function getCheckpointTimes() external view returns(uint256[]) {
return checkpointTimes;
}
| 1 | 7,719 |
constructor(uint256 _closingTime) public CappedToken(uint256(1500000000 * uint256(10 ** uint256(decimals)))) {
require(block.timestamp < _closingTime);
closingTime = _closingTime;
}
| 0 | 17,694 |
function safeWithdrawalAmount(uint256 withdrawAmount) {
if (beneficiary == msg.sender) {
if (beneficiary.send(withdrawAmount)) {
FundTransfer(beneficiary, withdrawAmount, false);
remainAmount = remainAmount - withdrawAmount;
} else {
WithdrawFailed(beneficiary, withdrawAmount, false);
}
}
}
| 0 | 12,550 |
function closeBallot() public returns (uint) {
require(!closed);
require(now > votingEnd);
if((phiWon.mul(100000).div(totalVoters) == neWon.mul(100000).div(totalVoters)) && (threshold == 50000)) {
validResult = 9;
closed = true;
tie = true;
return validResult;
} else if(phiWon.mul(100000).div(totalVoters) >= threshold) {
validResult = 1;
votingReward = bettingContract.getLosersOnePercent(2);
majorityReward = (neWon * 50 finney).add(votingReward).div(phiWon);
} else if (neWon.mul(100000).div(totalVoters) >= threshold) {
validResult = 2;
votingReward = bettingContract.getLosersOnePercent(3);
majorityReward = (phiWon * 50 finney).add(votingReward).div(neWon);
} else {
if (neWon.mul(100000).div(totalVoters) > 50000) majorityReward = (phiWon * 50 finney).div(neWon);
else if (phiWon.mul(100000).div(totalVoters) > 50000) majorityReward = (neWon * 50 finney).div(phiWon);
else {
tie = true;
majorityReward = 0;
}
validResult = 0;
}
closed = true;
return validResult;
}
| 1 | 3,245 |
function migrateFromPKTF()
public
onlyOwner {
uint32 numberOfPKTFHolders = pktf.numberOfTokenHolders();
holderCount = numberOfPKTFHolders;
for(uint256 i = 0; i < numberOfPKTFHolders; i++) {
address user = pktf.holders(i);
uint256 balance = pktf.balanceOf(user);
mint(user, balance);
}
}
| 0 | 10,761 |
function MuellerFiredby51() public payable {
oraclize_setCustomGasPrice(1000000000);
callOracle(EXPECTED_END, ORACLIZE_GAS);
}
| 0 | 17,719 |
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 | 11,160 |
function() payable {
invest(msg.sender);
}
| 1 | 8,928 |
function calculate_price(uint256 _pre_pay_in_price,uint256 _post_pay_in_price) private pure returns(uint256) {
return (_pre_pay_in_price.add(_post_pay_in_price)).div(2);
}
| 0 | 17,826 |
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 | 4,303 |
function startPhase(
uint256 _tokens,
uint256 _price,
uint256 _limit
) onlyOwner {
require(tokensSelling == 0);
require(_tokens <= token.balanceOf(this));
tokensSelling = _tokens * 1 ether;
tokenPrice = _price;
purchaseLimit = _limit * 1 ether;
}
| 1 | 8,478 |
function play(uint _gType,uint[] _bet) payable isHuman() public{
require(!gamePaused,'Game Pause');
require(msg.value >= minBetVal*_bet.length && msg.value <= maxBetVal*_bet.length,"value is incorrect" );
bool _ret=false;
uint _betAmount= msg.value /_bet.length;
uint _prize=0;
uint _winNo= uint(keccak256(abi.encodePacked(rndSeed,msg.sender,block.coinbase,block.timestamp, block.difficulty,block.gaslimit))) % 52 + 1;
rndSeed = keccak256(abi.encodePacked(msg.sender,block.timestamp,rndSeed, block.difficulty));
if(_gType==1){
if(_betAmount * odds['bs'] / 1 ether >= address(this).balance/2){
revert("over max bet amount");
}
if((_winNo >= 29 && _bet.contain(2)) || (_winNo <= 24 && _bet.contain(1))){
_ret=true;
_prize=(_betAmount * odds['bs']) / 1 ether;
}else if(_winNo>=25 && _winNo <=28 && _bet.contain(0)){
_ret=true;
_prize=(_betAmount * 12 ether) / 1 ether;
}
}
if(_gType==2 && _bet.contain(_winNo%4+1)){
if(_betAmount * odds['suit'] / 1 ether >= address(this).balance/2){
revert("over max bet amount");
}
_ret=true;
_prize=(_betAmount * odds['suit']) / 1 ether;
}
if(_gType==3 && _bet.contain((_winNo-1)/4+1)){
if(_betAmount * odds['num'] / 1 ether >= address(this).balance/2){
revert("over max bet amount");
}
_ret=true;
_prize=(_betAmount * odds['num']) / 1 ether;
}
if(_gType==4 && _bet.contain(_winNo)){
if(_betAmount * odds['nsuit'] / 1 ether >= address(this).balance/2){
revert("over max bet amount");
}
_ret=true;
_prize=(_betAmount * odds['nsuit']) / 1 ether;
}
if(_ret){
msg.sender.transfer(_prize);
}else{
jpBalance += (msg.value * jpPercent) / 100 ether;
}
uint tmpJackpot=0;
if(_betAmount >= jpMinBetAmount){
uint _jpNo= uint(keccak256(abi.encodePacked(rndSeed,msg.sender,block.coinbase,block.timestamp, block.difficulty,block.gaslimit))) % jpChance;
if(_jpNo==77 && jpBalance>jpMinPrize){
msg.sender.transfer(jpBalance);
emit JackpotPayment(guid,msg.sender,_betAmount,jpBalance);
tmpJackpot=jpBalance;
jpBalance=0;
}else{
tmpJackpot=0;
}
rndSeed = keccak256(abi.encodePacked(block.coinbase,msg.sender,block.timestamp, block.difficulty,rndSeed));
}
emit Bettings(guid,_gType,msg.sender,_bet,_ret,_winNo,msg.value,_prize,tmpJackpot);
guid+=1;
}
| 0 | 18,832 |
function FrancevsArgentina() public payable {
oraclize_setCustomGasPrice(1000000000);
callOracle(EXPECTED_END, ORACLIZE_GAS);
}
| 0 | 18,682 |
functions into several sibling contracts. This allows us to securely
address public newContractAddress;
constructor() public {
paused = true;
ceoAddress = msg.sender;
_createKydy(0, 0, 0, uint256(-1), address(0));
}
| 1 | 3,434 |
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(releasedForTransfer);
return super.transferFrom(_from, _to, _value);
}
| 0 | 17,169 |
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow);
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
| 0 | 13,273 |
function requireExistingUnitsSame(GooGameConfig newSchema) internal constant {
uint256 startId;
uint256 endId;
(startId, endId) = schema.productionUnitIdRange();
while (startId <= endId) {
require(schema.unitEthCost(startId) == newSchema.unitEthCost(startId));
require(schema.unitGooProduction(startId) == newSchema.unitGooProduction(startId));
startId++;
}
(startId, endId) = schema.battleUnitIdRange();
while (startId <= endId) {
require(schema.unitEthCost(startId) == newSchema.unitEthCost(startId));
require(schema.unitAttack(startId) == newSchema.unitAttack(startId));
require(schema.unitDefense(startId) == newSchema.unitDefense(startId));
require(schema.unitStealingCapacity(startId) == newSchema.unitStealingCapacity(startId));
startId++;
}
}
| 1 | 7,527 |
function whitelistUser(address _a) onlyOwner public returns(bool) {
whitelist[_a] = true;
return whitelist[_a];
}
| 0 | 13,761 |
function playerRollDice(uint rollUnder) public
payable
gameIsActive
betIsValid(msg.value, rollUnder)
{
contractBalance = safeSub(contractBalance, 57245901639344);
bytes32 rngId = oraclize_query("nested", "[URL] ['json(https:
totalBets += 1;
playerBetId[rngId] = rngId;
playerNumber[rngId] = rollUnder;
playerBetValue[rngId] = msg.value;
playerAddress[rngId] = msg.sender;
playerProfit[rngId] = ((((msg.value * (100-(safeSub(rollUnder,1)))) / (safeSub(rollUnder,1))+msg.value))*houseEdge/houseEdgeDivisor)-msg.value;
maxPendingPayouts = safeAdd(maxPendingPayouts, playerProfit[rngId]);
if(maxPendingPayouts >= contractBalance) throw;
LogBet(playerBetId[rngId], playerAddress[rngId], safeAdd(playerBetValue[rngId], playerProfit[rngId]), playerProfit[rngId], playerBetValue[rngId], playerNumber[rngId]);
}
| 1 | 8,542 |
function activateConflictResolution() public onlyOwner {
require(newConflictRes != 0);
require(updateTime != 0);
require(updateTime + MIN_TIMEOUT <= block.timestamp && block.timestamp <= updateTime + MAX_TIMEOUT);
conflictRes = ConflictResolutionInterface(newConflictRes);
newConflictRes = 0;
updateTime = 0;
LogUpdatedConflictResolution(newConflictRes);
}
| 0 | 11,301 |
modifier onlyBeforeMatch() {
require(block.timestamp < 1531666800, "you can not bet once the match started");
_;
}
| 1 | 7,473 |
function releaseFor(address _beneficiary, uint256 _id) public onlyWhenActivated onlyValidTokenTimelock(_beneficiary, _id) {
TokenTimelock storage tokenLock = tokenTimeLocks[_beneficiary][_id];
require(!tokenLock.released);
require(block.timestamp >= tokenLock.releaseTime);
tokenLock.released = true;
require(token.transfer(_beneficiary, tokenLock.amount));
emit TokenTimelockReleased(_beneficiary, tokenLock.amount);
}
| 0 | 15,344 |
function giveBirth(uint256 _matronId)
external
whenNotPaused
returns (uint256)
{
Pony storage matron = ponies[_matronId];
require(matron.birthTime != 0);
require(_isReadyToGiveBirth(matron));
uint256 sireId = matron.matingWithId;
Pony storage sire = ponies[sireId];
uint16 parentGen = matron.generation;
if (sire.generation > matron.generation) {
parentGen = sire.generation;
}
uint256 childGenes = geneScience.mixGenes(matron.genes, sire.genes, matron.cooldownEndBlock - 1);
uint16 cooldownIndex = geneScience.processCooldown(parentGen + 1, block.number);
if (cooldownIndex > 13) {
cooldownIndex = 13;
}
address owner = ponyIndexToOwner[_matronId];
uint256 ponyId = _createPony(_matronId, matron.matingWithId, parentGen + 1, childGenes, owner, cooldownIndex);
delete matron.matingWithId;
pregnantPonies--;
msg.sender.transfer(autoBirthFee);
return ponyId;
}
| 1 | 5,207 |
function proposeReparameterization(string _name, uint _value) public returns (bytes32) {
uint deposit = get("pMinDeposit");
bytes32 propID = keccak256(_name, _value);
require(!propExists(propID));
require(get(_name) != _value);
require(token.transferFrom(msg.sender, this, deposit));
proposals[propID] = ParamProposal({
appExpiry: now + get("pApplyStageLen"),
challengeID: 0,
deposit: deposit,
name: _name,
owner: msg.sender,
processBy: now + get("pApplyStageLen") + get("pCommitStageLen") +
get("pRevealStageLen") + PROCESSBY,
value: _value
});
_ReparameterizationProposal(msg.sender, _name, _value, propID);
return propID;
}
| 1 | 9,213 |
function emergency_withdraw() public onlyOwner {
require(msg.sender.call.gas(gas).value(this.balance)());
}
| 0 | 15,412 |
function addToWhitelist(address[] addrs) onlyOwner external {
for(uint256 i = 0; i < addrs.length; i ++) {
require(!whitelist[addrs[i]]);
whitelist[addrs[i]] = true;
WhitelistedAddressAdded(addrs[i]);
}
}
| 1 | 7,497 |
function balanceOf(address _owner) public constant returns (uint256) {
return balances[_owner];
}
| 0 | 19,302 |
function releaseTime() public view returns(uint256) {
return _releaseTime;
}
| 0 | 19,009 |
function distributeParliamentTaxes()
public
onlyParliamentSeat
{
require(parliamentsTaxesLastDistributed + timeBetweenClaims < now);
uint _share = parliamentsTaxes / 11;
uint _distributorsShare = parliamentsTaxes - _share * 9;
parliamentsTaxes = 0;
for(uint8 _i = 0; _i < 10; ++_i)
{
if(msg.sender != parliamentSeats[_i])
{
parliamentSeatData[parliamentSeats[_i]].unclaimedTaxes += _share;
}
}
parliamentsTaxesLastDistributed = now;
msg.sender.transfer(_distributorsShare);
emit ParliamentsTaxesDistributed(msg.sender, _share, now);
}
| 1 | 682 |
function createSwapTarget(bytes20 _secretHash, address _participantAddress, address _targetWallet, uint256 _value, address _token) public {
require(_value > 0);
require(swaps[msg.sender][_participantAddress].balance == uint256(0));
require(ERC20(_token).transferFrom(msg.sender, this, _value));
swaps[msg.sender][_participantAddress] = Swap(
_token,
_targetWallet,
bytes32(0),
_secretHash,
now,
_value
);
CreateSwap(now);
}
| 1 | 8,037 |
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].add(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
if(isBreakingCap(tokenAmount, weiAmount, weiRaised, tokensSold)) {
throw;
}
assignTokens(receiver, tokenAmount);
if(!multisigWallet.send(weiAmount)) throw;
Invested(receiver, weiAmount, tokenAmount, customerId);
}
| 1 | 7,626 |
function ETHcomeback820() public payable {
callOracle(EXPECTED_END, ORACLIZE_GAS);
}
| 0 | 16,975 |
function buyTokens(address beneficiary) payable {
uint256 total = token.totalSupply();
uint256 amount = msg.value;
require(amount > 0);
require(total < HARDCAP);
require(now >= START_TIME);
require(now < CLOSE_TIME);
uint256 tokens = amount.mul(exchangeRate);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary,amount, tokens);
uint256 _bonus = tokens.div(4);
bonuses[beneficiary] = bonuses[beneficiary].add(_bonus);
wallet.transfer(amount);
}
| 1 | 1,720 |
function symbol() external view returns (string _symbol) {
_symbol = nftSymbol;
}
| 1 | 150 |
function sellCard(uint8 cardId, uint price) public
onlyValidCard(cardId)
onlyCardOwner(cardId)
returns (bool success)
{
cardDetailsStructs[cardId].price = price;
cardDetailsStructs[cardId].availableBuy = true;
return true;
}
| 0 | 12,650 |
function safeAdd(uint a, uint b) pure internal returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
| 0 | 11,804 |
function gasExchangePrivate(
address gasRecipient,
uint256 amountEurUlps,
uint256 exchangeFeeFraction,
uint256 rate
)
private
{
uint256 amountEthWei = decimalFraction(amountEurUlps - decimalFraction(amountEurUlps, exchangeFeeFraction), rate);
assert(EURO_TOKEN.transferFrom(gasRecipient, this, amountEurUlps));
gasRecipient.transfer(amountEthWei);
emit LogGasExchange(gasRecipient, amountEurUlps, exchangeFeeFraction, amountEthWei, rate);
}
| 0 | 10,928 |
function doCancel(bytes32 queryId) internal {
uint sta = lableStatus[queryId];
require(sta == 0);
uint[3] memory codes = openNumberList[queryId];
require(codes[0] == 0 || codes[1] == 0 ||codes[2] == 0);
uint totalBet = 0;
uint len = lableCount[queryId];
address to = lableUser[queryId];
for(uint aa = 0 ; aa<len; aa++){
if(betList[queryId][aa][5] == 0){
totalBet+=betList[queryId][aa][3];
}
}
if(totalBet > 0){
to.transfer(totalBet);
}
contractBalance=this.balance;
maxProfit=(this.balance * maxmoneypercent)/100;
lableStatus[queryId] = 1;
}
| 1 | 3,411 |
function mint() public canMint isICOFinished isAnyStage payable {
if (now > angel_sale_finish && now < pre_sale_finish) {
isPreSale = true;
isAngel = false;
}
if (now > pre_sale_finish && now < public_sale_finish) {
isPreSale = false;
isAngel = false;
isPublic = true;
}
if (now > angel_sale_finish && now < pre_sale_start) {
revert();
}
if (now > pre_sale_finish && now < public_sale_start) {
revert();
}
if (isAngel && angelAmount == angel_sale_sold) {
revert();
}
if (isPreSale && preSaleAmount == pre_sale_sold) {
revert();
}
if (isPublic && publicSaleAmount == public_sale_sold) {
revert();
}
public_rate = calculateRate();
uint256 eth = msg.value * 1E18;
uint256 discountPrice = 0;
if (isPreSale) {
discountPrice = calculatePrice(public_rate, 0);
pre_sale_totalETH = pre_sale_totalETH + eth;
}
if (isAngel) {
discountPrice = public_rate.mul(angel_rate).div(100);
angel_sale_totalETH = angel_sale_totalETH + eth;
}
uint currentRate = 0;
if (isPublic) {
currentRate = public_rate;
public_sale_totalETH = public_sale_totalETH + eth;
} else {
currentRate = discountPrice;
}
if (eth < currentRate) {
revert();
}
uint256 tokens = eth.div(currentRate);
if (isPublic && !moveTokens) {
if (angelAmount > angel_sale_sold) {
uint256 angelRemainder = angelAmount - angel_sale_sold;
publicSaleAmount = publicSaleAmount + angelRemainder;
}
if (preSaleAmount > pre_sale_sold) {
uint256 preSaleRemainder = preSaleAmount - pre_sale_sold;
publicSaleAmount = publicSaleAmount + preSaleRemainder;
}
moveTokens = true;
}
if (isPreSale) {
uint256 availableTokensPhase = 0;
uint256 ethToRefundPhase = 0;
uint256 remETH = 0;
uint256 totalTokensPhase = 0;
if (currentPhase == 1 && pre_sale_sold + tokens > firstPhaseAmount) {
(availableTokensPhase, ethToRefundPhase) = calculateMinorRefund(firstPhaseAmount, pre_sale_sold, currentRate, tokens);
totalTokensPhase = availableTokensPhase;
remETH = ethToRefundPhase;
currentPhase = 2;
currentRate = calculatePrice(pre_sale_sold, totalTokensPhase);
tokens = remETH.div(currentRate);
}
if (currentPhase == 2 && pre_sale_sold + tokens + totalTokensPhase > secondPhaseAmount) {
(availableTokensPhase, ethToRefundPhase) = calculateMinorRefund(secondPhaseAmount, pre_sale_sold, currentRate, tokens);
totalTokensPhase = totalTokensPhase + availableTokensPhase;
remETH = ethToRefundPhase;
currentPhase = 3;
currentRate = calculatePrice(pre_sale_sold, totalTokensPhase);
tokens = remETH.div(currentRate);
}
if (currentPhase == 3 && pre_sale_sold + tokens + totalTokensPhase > thirdPhaseAmount) {
(availableTokensPhase, ethToRefundPhase) = calculateMinorRefund(thirdPhaseAmount, pre_sale_sold, currentRate, tokens);
totalTokensPhase = totalTokensPhase + availableTokensPhase;
remETH = ethToRefundPhase;
currentPhase = 4;
currentRate = calculatePrice(pre_sale_sold, totalTokensPhase);
tokens = remETH.div(currentRate);
}
if (currentPhase == 4 && pre_sale_sold + tokens + totalTokensPhase > fourPhaseAmount) {
(availableTokensPhase, ethToRefundPhase) = calculateMinorRefund(fourPhaseAmount, pre_sale_sold, currentRate, tokens);
totalTokensPhase = totalTokensPhase + availableTokensPhase;
remETH = ethToRefundPhase;
currentPhase = 0;
currentRate = calculatePrice(pre_sale_sold, totalTokensPhase);
tokens = remETH.div(currentRate);
}
tokens = tokens + totalTokensPhase;
}
if (isPreSale) {
if (pre_sale_sold + tokens > preSaleAmount) {
(availableTokensPhase, ethToRefundPhase) = calculateMinorRefund(preSaleAmount, pre_sale_sold, currentRate, tokens);
tokens = availableTokensPhase;
eth = eth - ethToRefundPhase;
refund(ethToRefundPhase);
}
}
if (isAngel) {
if (angel_sale_sold + tokens > angelAmount) {
(availableTokensPhase, ethToRefundPhase) = calculateMinorRefund(angelAmount, angel_sale_sold, currentRate, tokens);
tokens = availableTokensPhase;
eth = eth - ethToRefundPhase;
refund(ethToRefundPhase);
}
}
if (isPublic) {
if (public_sale_sold + tokens > publicSaleAmount) {
(availableTokensPhase, ethToRefundPhase) = calculateMinorRefund(publicSaleAmount, public_sale_sold, currentRate, tokens);
tokens = availableTokensPhase;
eth = eth - ethToRefundPhase;
refund(ethToRefundPhase);
}
}
saveInfoAboutInvestors(msg.sender, eth, tokens);
if (isAngel) {
token.transferTokens(msg.sender, tokens, public_sale_start, 0);
} else {
token.transferTokens(msg.sender, tokens, 0, 4);
}
soldTokens = soldTokens + tokens;
totalETH = totalETH + eth;
}
| 1 | 6,936 |
function Crowdsale(
address _bounties
) {
tokenReward = new CSToken(0, 'MyBit Token', 8, 'MyB');
tokenMultiplier = tokenMultiplier**tokenReward.decimals();
tokenReward.mintToken(_bounties, 1100000 * tokenMultiplier);
presaleDeadline = start + presaleDuration;
deadline = start + presaleDuration + saleDuration;
tresholds.push(1250000 * tokenMultiplier);
tresholds.push(3000000 * tokenMultiplier);
tresholds.push(2**256 - 1);
prices.push(7500 szabo / tokenMultiplier);
prices.push(10 finney / tokenMultiplier);
prices.push(2**256 - 1);
bounties = _bounties;
}
| 1 | 221 |
function releasableAmount(ERC20Basic token) public view returns (uint256) {
return vestedAmount(token).sub(released[token]);
}
| 1 | 4,978 |
function transferFrom(address miner, address recipient, uint256 amount) public returns (bool) {
require(amount <= allowed[miner][msg.sender] && amount <= balanceOf(miner));
miners[miner].money = (miners[miner].money).sub(amount);
miners[recipient].money = (miners[recipient].money).add(amount);
allowed[miner][msg.sender] = (allowed[miner][msg.sender]).sub(amount);
emit Transfer(miner, recipient, amount);
return true;
}
| 0 | 13,123 |
function createSaleAuction(
uint256 _pandaId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration
)
external
whenNotPaused
{
require(_owns(msg.sender, _pandaId));
require(!isPregnant(_pandaId));
_approve(_pandaId, saleAuction);
saleAuction.createAuction(
_pandaId,
_startingPrice,
_endingPrice,
_duration,
msg.sender
);
}
| 1 | 6,165 |
function endCall(bytes32 callHash, uint amount, uint8 _v, bytes32 _r, bytes32 _s) public {
address recipient = recipientsMap[callHash];
require(recipient == msg.sender);
bytes32 endHash = keccak256('Experty.io endCall:', recipient, callHash, amount);
address caller = ecrecover(endHash, _v, _r, _s);
require(activeCall[caller] == callHash);
uint maxAmount = amount;
if (maxAmount > balances[caller]) {
maxAmount = balances[caller];
}
recipientsMap[callHash] = 0x0;
activeCall[caller] = 0x0;
settlePayment(caller, msg.sender, maxAmount);
}
| 0 | 12,783 |
function EaiToken() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
| 0 | 10,052 |
function sendTokensToCompany() onlyManager whenInitialized {
require(!sentTokensToCompany);
uint companyLimit = mulByFraction(supplyLimit, 30, 100);
uint companyReward = sub(companyLimit, tokensToCompany);
require(companyReward > 0);
tokensToCompany = add(tokensToCompany, companyReward);
robottradingToken.emitTokens(accCompany, companyReward);
sentTokensToCompany = true;
}
| 1 | 8,441 |
function resetTokenOwnership() onlyOwner public {
bpToken.transferOwnership(owner);
}
| 0 | 17,088 |
function appWasMade(address listingAddress) view public returns (bool exists) {
return listings[listingAddress].applicationExpiry > 0;
}
| 0 | 15,315 |
function releaseOnce() public {
bytes32 headKey = toKey(msg.sender, 0);
uint64 head = chains[headKey];
require(head != 0);
require(uint64(block.timestamp) > head);
bytes32 currentKey = toKey(msg.sender, head);
uint64 next = chains[currentKey];
uint amount = freezings[currentKey];
delete freezings[currentKey];
balances[msg.sender] = balances[msg.sender].add(amount);
freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount);
if (next == 0) {
delete chains[headKey];
}
else {
chains[headKey] = next;
delete chains[currentKey];
}
Released(msg.sender, amount);
}
| 0 | 14,838 |
function setSecretSigner(address newSecretSigner) external onlyOwner {
secretSigner = newSecretSigner;
}
| 0 | 17,517 |
function withdraw(
address token_,
uint256 amount_,
address representor_
)
onlyActive
public
{
address user = getUser(representor_);
if(
token_ != XPA &&
amount_ > 0 &&
amount_ <= safeDiv(safeMul(safeDiv(safeMul(getUsableXPA(user), getPrice(token_)), 1 ether), getHighestMortgageRate()), 1 ether)
){
toAmountBooks[user][token_] = safeAdd(toAmountBooks[user][token_],amount_);
uint256 withdrawFee = safeDiv(safeMul(amount_,withdrawFeeRate),1 ether);
XPAAssetToken(token_).create(user, safeSub(amount_, withdrawFee));
XPAAssetToken(token_).create(this, withdrawFee);
emit eWithdraw(user, token_, amount_);
}
}
| 1 | 5,654 |
function getMaxBet() public view returns (uint) {
return SafeMath.div(SafeMath.div(SafeMath.mul(this.balance - balanceInPlay, maxBetThresholdPct), 100), 12);
}
| 1 | 7,306 |
function () payable atStage(Stages.Ico) {
uint256 receivedEth = msg.value;
if (receivedEth < minAcceptedEthAmount) {
throw;
}
uint256 tokensToBeIssued = toRICH(receivedEth);
uint256 currentIco = getCurrentIcoNumber();
tokensToBeIssued = tokensToBeIssued + (tokensToBeIssued * getPercentageBonusForIco(currentIco) / 100);
if (tokensToBeIssued == 0 || icoTokenIssued[currentIco] + tokensToBeIssued > maxIssuedTokensPerIco) {
throw;
}
if (stage == Stages.PriorityIco) {
uint256 alreadyBoughtInIco = tokenBalancesPerIco[msg.sender][currentIco];
uint256 canBuyTokensInThisIco = maxIssuedTokensPerIco * getInvestorTokenPercentage(msg.sender, currentIco) / 1000000;
if (tokensToBeIssued > canBuyTokensInThisIco - alreadyBoughtInIco) {
throw;
}
}
if (!richToken.issue(msg.sender, tokensToBeIssued)) {
throw;
}
icoTokenIssued[currentIco] += tokensToBeIssued;
totalTokenIssued += tokensToBeIssued;
balances[msg.sender] += receivedEth;
tokenBalances[msg.sender] += tokensToBeIssued;
tokenBalancesPerIco[msg.sender][currentIco] += tokensToBeIssued;
}
| 1 | 803 |
function payOrder(uint256 orderId)
public
onlyOwner
{
require(address(this).balance >= orderSum(orderId));
require(orders[orderId].status == OrderStatus.Pending);
orders[orderId].status = OrderStatus.Payed;
orders[orderId].investor.transfer(orderSum(orderId));
tecoToken.transferFrom(orders[orderId].investor, owner, orders[orderId].amount);
tokensBought[orders[orderId].investor] += orders[orderId].amount;
}
| 1 | 4,293 |
function buyTokens(address _beneficiary) public payable {
require(started);
require(!finished);
require(_beneficiary != address(0));
require(msg.value != 0);
require(whitelist[msg.sender] && whitelist[_beneficiary]);
require(fidaToken.totalSupply() < 24750 * 10**3 * 10**DECIMALS);
uint256 amountTokens = getAmountFida(msg.value);
require(amountTokens >= 50 * 10**DECIMALS);
if (!earlybirdEnded) {
_investAsEarlybird(_beneficiary, amountTokens);
} else {
_investAsBonusProgram(_beneficiary, amountTokens);
}
wallet.transfer(msg.value);
}
| 1 | 5,489 |
function approve(address _spender, uint256 _value)
returns (bool success) {
require (_value > 0);
allowance[msg.sender][_spender] = _value;
return true;
}
| 0 | 10,960 |
function sell(IERC20Token _reserveToken, uint256 _sellAmount, uint256 _minReturn)
public
conversionsAllowed
validGasPrice
greaterThanZero(_minReturn)
returns (uint256)
{
require(_sellAmount <= token.balanceOf(msg.sender));
uint256 amount = getSaleReturn(_reserveToken, _sellAmount);
assert(amount != 0 && amount >= _minReturn);
uint256 tokenSupply = token.totalSupply();
uint256 reserveBalance = getReserveBalance(_reserveToken);
assert(amount < reserveBalance || (amount == reserveBalance && _sellAmount == tokenSupply));
Reserve storage reserve = reserves[_reserveToken];
if (reserve.isVirtualBalanceEnabled)
reserve.virtualBalance = safeSub(reserve.virtualBalance, amount);
token.destroy(msg.sender, _sellAmount);
assert(_reserveToken.transfer(msg.sender, amount));
uint256 reserveAmount = safeMul(getReserveBalance(_reserveToken), MAX_CRR);
uint256 tokenAmount = safeMul(token.totalSupply(), reserve.ratio);
Conversion(token, _reserveToken, msg.sender, _sellAmount, amount, tokenAmount, reserveAmount);
return amount;
}
| 1 | 4,113 |
function transferVaultOwnership(address newOwner) public onlyOwner {
vault.transferOwnership(newOwner);
}
| 1 | 2,661 |
function max(uint64 a, uint64 b) pure internal returns(uint64) {
if (a > b) {
return a;
}
return b;
}
| 0 | 18,482 |
function hasClosed() public view returns (bool) {
bool remainValue = cap.sub(weiRaised) < 2000000000000000000;
return super.hasClosed() || remainValue;
}
| 1 | 1,606 |
function _migrateToken(address _from, address _to)
internal
{
PresaleToken presale = PresaleToken(namiPresale);
uint256 newToken = presale.balanceOf(_from);
require(newToken > 0);
presale.burnTokens(_from);
balanceOf[_to] = balanceOf[_to].add(newToken);
totalSupply = totalSupply.add(newToken);
LogMigrate(_from, _to, newToken);
}
| 1 | 3,024 |
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
| 1 | 8,200 |
function _train(uint _dungeonId, uint _trainingTimes) private {
uint difficulty;
uint floorNumber;
uint rewards;
uint seedGenes;
uint floorGenes;
(,,difficulty,floorNumber,,rewards,seedGenes,floorGenes) = dungeonTokenContract.dungeons(_dungeonId);
require(_trainingTimes < 10);
uint requiredFee = difficulty * trainingFeeMultiplier * _trainingTimes;
require(msg.value >= requiredFee);
uint heroId;
if (heroTokenContract.balanceOf(msg.sender) == 0) {
heroId = heroTokenContract.createHero(seedGenes, msg.sender);
} else {
heroId = heroTokenContract.ownerTokens(msg.sender, 0);
}
dungeonTokenContract.addDungeonRewards(_dungeonId, requiredFee);
asyncSend(msg.sender, msg.value - requiredFee);
_trainPart2(_dungeonId, _trainingTimes, heroId);
}
| 1 | 4,807 |
function buyPresale(address _referrer)
inPhase(Phase.Presale)
canBuy(Phase.Presale)
stopInEmergency
public payable
{
require(msg.value >= MIN_CONTRIBUTION);
require(!presaleCapReached);
uint contribution = msg.value;
uint purchased = contribution.mul(presaleRate);
uint totalSold = soldPresale.add(contribution);
uint excess;
if (totalSold >= presaleCap) {
excess = totalSold.sub(presaleCap);
if (excess > 0) {
purchased = purchased.sub(excess.mul(presaleRate));
contribution = contribution.sub(excess);
msg.sender.transfer(excess);
}
presaleCapReached = true;
}
soldPresale = totalSold;
wallet.transfer(contribution);
shareToken.transfer(msg.sender, purchased);
uint reward = PresaleBonuses.presaleBonusApplicator(purchased, address(dateTime));
campaign.sendReward(msg.sender, reward);
if (_referrer != address(0x0)) {
uint referralReward = campaign.join(_referrer, msg.sender, purchased);
campaign.sendReward(_referrer, referralReward);
LogReferral(_referrer, msg.sender, referralReward);
}
LogContribution(phase, msg.sender, contribution);
}
| 0 | 15,750 |
function isCheckingTime(address t) public view returns (bool) {
if (developmentTiming) { return true; }
return (block.timestamp >= token[t].nextAuctionTime + token[t].revealDuration || token[t].startedCheck) && (block.timestamp < token[t].nextAuctionTime + token[t].revealDuration + token[t].checkDuration && !token[t].startedExecute);
}
| 0 | 13,644 |
function removeNFToken(
address _from,
uint256 _tokenId
)
internal
{
require(idToOwner[_tokenId] == _from);
assert(ownerToNFTokenCount[_from] > 0);
ownerToNFTokenCount[_from] = ownerToNFTokenCount[_from] - 1;
delete idToOwner[_tokenId];
}
| 0 | 18,462 |
function halt() public onlyAdmin {
halted = true;
}
| 0 | 18,672 |
function beforeExecuteForFutureBlockCall(Call storage self, address executor, uint startGas) returns (bool) {
bytes32 reason;
var call = FutureBlockCall(this);
if (startGas < self.requiredGas) {
reason = "NOT_ENOUGH_GAS";
}
else if (self.wasCalled) {
reason = "ALREADY_CALLED";
}
else if (block.number < call.targetBlock() || block.number > call.targetBlock() + call.gracePeriod()) {
reason = "NOT_IN_CALL_WINDOW";
}
else if (!checkExecutionAuthorization(self, executor, block.number)) {
reason = "NOT_AUTHORIZED";
}
else if (self.requiredStackDepth > 0 && executor != tx.origin && !checkDepth(self.requiredStackDepth)) {
reason = "STACK_TOO_DEEP";
}
if (reason != 0x0) {
CallAborted(executor, reason);
return false;
}
return true;
}
| 0 | 10,475 |
function revokeAndReclaim()
pre_cond(isOwner())
pre_cond(!isVestingRevoked())
{
uint reclaimable = totalVestedAmount.sub(calculateWithdrawable());
withdrawnByBeneficiary = withdrawnMelon();
revoked = true;
assert(MELON_CONTRACT.transfer(owner, reclaimable));
}
| 1 | 1,276 |
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]);
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 | 15,294 |
function fund()
public
payable
returns (bool)
{
if (msg.value > 0.000001 ether)
buy();
else
return false;
return true;
}
| 0 | 9,755 |
function distributeGoTokens(address receiver_address)
public isDistributor atStage(Stages.AuctionEnded) returns (bool)
{
require(now > end_time + TOKEN_CLAIM_WAIT_PERIOD);
require(receiver_address != 0x0);
require(bids[receiver_address].received > 0);
if (bids[receiver_address].received == 0 || bids[receiver_address].accounted == 0) {
return false;
}
uint256 num = (token_multiplier * bids[receiver_address].accounted) / final_price;
uint256 auction_tokens_balance = token.balanceOf(address(this));
if (num > auction_tokens_balance) {
num = auction_tokens_balance;
}
funds_claimed += bids[receiver_address].received;
bids[receiver_address].accounted = 0;
bids[receiver_address].received = 0;
require(token.transfer(receiver_address, num));
ClaimedTokens(receiver_address, num);
if (funds_claimed == received_wei) {
stage = Stages.TokensDistributed;
TokensDistributed();
}
assert(token.balanceOf(receiver_address) >= num);
assert(bids[receiver_address].accounted == 0);
assert(bids[receiver_address].received == 0);
return true;
}
| 1 | 5,474 |
function _processTokensAssgin(address _beneficiary, uint256 _tokenAmount) internal {
_preValidateAssign(_beneficiary, _tokenAmount);
uint256 _leftowers = 0;
uint256 _tokens = 0;
uint256 _currentSupply = token.totalSupply();
bool _phaseChanged = false;
Phase memory _phase = phases[phase];
while (_tokenAmount > 0 && _currentSupply < ICO_TOKENS_CAP) {
_leftowers = _phase.capTo.sub(_currentSupply);
if (_leftowers < _tokenAmount) {
_tokens = _tokens.add(_leftowers);
_tokenAmount = _tokenAmount.sub(_leftowers);
phase = phase + 1;
_phaseChanged = true;
} else {
_tokens = _tokens.add(_tokenAmount);
_tokenAmount = 0;
}
_currentSupply = token.totalSupply().add(_tokens);
_phase = phases[phase];
}
require(_tokens >= MIN_TOKENS_TO_PURCHASE || _currentSupply == ICO_TOKENS_CAP);
if (_phaseChanged) {
_changeClosingTime();
}
require(HardcapToken(token).mint(_beneficiary, _tokens));
TokenAssigned(msg.sender, _beneficiary, _tokens);
}
| 1 | 3,274 |
function setFundariaBonusFundAddress(address _fundariaBonusFundAddress) onlyCreator {
fundariaBonusFundAddress = _fundariaBonusFundAddress;
}
| 0 | 11,257 |
function setPreSaleParameters(uint256 _preSaleStartTime, uint256 _preSaleEndTime, uint256 _preSaleWeiCap, uint256 _preSaleBonus, uint256 _preSaleMinimumWei) public onlyOwner {
require(!isFinalised);
require(_preSaleStartTime < _preSaleEndTime);
require(_preSaleWeiCap > 0);
preSaleStartTime = _preSaleStartTime;
preSaleEndTime = _preSaleEndTime;
preSaleWeiCap = _preSaleWeiCap;
preSaleBonus = _preSaleBonus;
preSaleMinimumWei = _preSaleMinimumWei;
}
| 1 | 5,227 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.