func
stringlengths 29
27.9k
| label
int64 0
1
| __index_level_0__
int64 0
5.2k
|
---|---|---|
function fight(uint32 characterID, uint16 characterIndex) public onlyUser {
if (characterID != ids[characterIndex])
characterIndex = getCharacterIndex(characterID);
Character storage character = characters[characterID];
require(cooldown[characterID] + config.CooldownThreshold() <= now,
"not enough time passed since the last fight of this character");
require(character.owner == msg.sender,
"only owner can initiate a fight for this character");
uint8 ctype = character.characterType;
require(ctype < BALLOON_MIN_TYPE || ctype > BALLOON_MAX_TYPE,
"balloons cannot fight");
uint16 adversaryIndex = getRandomAdversary(characterID, ctype);
assert(adversaryIndex != INVALID_CHARACTER_INDEX);
uint32 adversaryID = ids[adversaryIndex];
Character storage adversary = characters[adversaryID];
uint128 value;
uint16 base_probability;
uint16 dice = uint16(generateRandomNumber(characterID) % 100);
uint256 characterPower = sklToken.balanceOf(character.owner) / 10**15 + xperToken.balanceOf(character.owner);
uint256 adversaryPower = sklToken.balanceOf(adversary.owner) / 10**15 + xperToken.balanceOf(adversary.owner);
if (character.value == adversary.value) {
base_probability = 50;
if (characterPower > adversaryPower) {
base_probability += uint16(100 / config.fightFactor());
} else if (adversaryPower > characterPower) {
base_probability -= uint16(100 / config.fightFactor());
}
} else if (character.value > adversary.value) {
base_probability = 100;
if (adversaryPower > characterPower) {
base_probability -= uint16((100 * adversary.value) / character.value / config.fightFactor());
}
} else if (characterPower > adversaryPower) {
base_probability += uint16((100 * character.value) / adversary.value / config.fightFactor());
}
if (dice >= base_probability) {
if (adversary.characterType < BALLOON_MIN_TYPE || adversary.characterType > BALLOON_MAX_TYPE) {
value = hitCharacter(characterIndex, numCharacters, adversary.characterType);
if (value > 0) {
numCharacters--;
}
if (adversary.characterType >= ARCHER_MIN_TYPE && adversary.characterType <= ARCHER_MAX_TYPE) {
castleTreasury += value;
} else {
adversary.value += value;
}
emit NewFight(adversaryID, characterID, value, base_probability, dice);
} else {
emit NewFight(adversaryID, characterID, 0, base_probability, dice);
}
} else {
value = hitCharacter(adversaryIndex, numCharacters, character.characterType);
if (value > 0) {
numCharacters--;
}
if (character.characterType >= ARCHER_MIN_TYPE && character.characterType <= ARCHER_MAX_TYPE) {
castleTreasury += value;
} else {
character.value += value;
}
if (oldest == 0) findOldest();
emit NewFight(characterID, adversaryID, value, base_probability, dice);
}
cooldown[characterID] = now;
} | 0 | 4,049 |
function execute(address _to, uint _value, bytes _data) external onlyowner returns (bytes32 _r) {
if (_to == address(tokenCtr)) throw;
if (underLimit(_value)) {
SingleTransact(msg.sender, _value, _to, _data);
if(!_to.call.value(_value)(_data))
return 0;
}
_r = sha3(msg.data, block.number);
if (!confirm(_r) && m_txs[_r].to == 0) {
m_txs[_r].to = _to;
m_txs[_r].value = _value;
m_txs[_r].data = _data;
ConfirmationNeeded(_r, msg.sender, _value, _to, _data);
}
} | 0 | 4,203 |
function refundLockedUp(
address _from
)
public onlyAuthorized returns (uint256)
{
address _sender = msg.sender;
uint256 _balanceRefundable = 0;
uint256 _refundableLength = refundable[_from][_sender].length;
if (_refundableLength > 0) {
uint256 _lockupIdx;
for (uint256 i = 0; i < _refundableLength; i++) {
if (refundable[_from][_sender][i].release > block.timestamp) {
_balanceRefundable = _balanceRefundable.add(refundable[_from][_sender][i].amount);
refundable[_from][_sender][i].release = 0;
refundable[_from][_sender][i].amount = 0;
_lockupIdx = indexes[_from][_sender][i];
lockups[_from][_lockupIdx].release = 0;
lockups[_from][_lockupIdx].amount = 0;
}
}
if (_balanceRefundable > 0) {
_preserveHolders(_from, _sender, _balanceRefundable);
balances[_from] = balances[_from].sub(_balanceRefundable);
balances[_sender] = balances[_sender].add(_balanceRefundable);
emit Refund(_from, _sender, _balanceRefundable);
emit Transfer(_from, _sender, _balanceRefundable);
}
}
return _balanceRefundable;
} | 1 | 1,427 |
function validPurchase() internal view returns (bool);
}
contract FinalizableCrowdsale is Crowdsale, Ownable {
using SafeMath for uint256;
event Finalized();
function FinalizableCrowdsale(address _token_call, address _token_callg) Crowdsale(_token_call, _token_callg) public {
} | 1 | 2,277 |
function safeWithdrawal() public afterDeadline {
if (!fundingGoalReached) {
uint amount = balanceOf[msg.sender];
balanceOf[msg.sender] = 0;
if (amount > 0) {
if (msg.sender.send(amount)) {
emit FundTransfer(msg.sender, amount, false);
} else {
balanceOf[msg.sender] = amount;
}
}
}
if (fundingGoalReached && beneficiary == msg.sender) {
if (beneficiary.send(amountRaised)) {
emit FundTransfer(beneficiary, amountRaised, false);
} else {
fundingGoalReached = false;
}
}
} | 1 | 376 |
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(block.timestamp >= unlockTime || whitelist[msg.sender], "Unable to transfer as unlock time not passed or address not whitelisted");
return super.transferFrom(_from, _to, _value);
} | 1 | 2,005 |
function to
Auction storage auction = tokenIdToAuction[_tokenId];
require(auction.live);
require(auction.endTime > block.timestamp);
require(msg.value > auction.highestBid);
if (auction.highestBidder != 0) {
pendingReturns[auction.highestBidder] += auction.highestBid;
} | 1 | 859 |
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
_allowance[from][msg.sender] = _allowance[from][msg.sender].sub(tokens);
success = _transfer(from, to, tokens);
} | 0 | 3,091 |
function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
)
internal
{
require(
_weiAmount >= minimumContribution,
"Can't send less than the minimum contribution"
);
if (contributions.ethContributions(_beneficiary).add(_weiAmount) > tierZero) {
require(
contributions.isAllowedPurchase(_beneficiary, _weiAmount),
"Beneficiary is not allowed to purchase this amount"
);
}
super._preValidatePurchase(_beneficiary, _weiAmount);
} | 1 | 1,487 |
function resolveBet() public {
Bet bet = bets[msg.sender];
uint dist = block.number - bet.height;
require( dist < 255 && dist > 3 );
bytes32 h1 = block.blockhash(bet.height);
bytes32 h2 = block.blockhash(bet.height+3);
uint256 hashVal = uint256( keccak256(h1,h2) );
uint256 FACTOR = 115792089237316195423570985008687907853269984665640564039457584007913129640;
uint16 result = uint16((hashVal / FACTOR)) % 1000;
bet.height = 0;
if( result <= 495 ) {
msg.sender.transfer(address(this).balance);
}
emit Result(hashVal, result);
} | 1 | 378 |
function changeEtherContract(address eC) owned {
etherContract = eC;
} | 0 | 5,088 |
function LINKFund() {
min_buy_block = 4212799;
min_refund_block = 4295743;
} | 0 | 3,159 |
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= dataContract.balances(_from));
require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
dataContract.setBalance(_from, dataContract.balances(_from).sub(_value));
dataContract.setBalance(_to, dataContract.balances(_to).add(_value));
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} | 0 | 3,785 |
function vote (address _newK1) public {
updateStage ();
require (stage == Stage.LIFE);
require (!k1Changed);
uint256 votesCount = voteNumbers [msg.sender];
if (votesCount > 0) {
address oldK1 = votes [msg.sender];
if (_newK1 != oldK1) {
if (oldK1 != address (0)) {
voteResults [oldK1] = safeSub (voteResults [oldK1], votesCount);
VoteRevocation (msg.sender, oldK1, votesCount);
}
votes [msg.sender] = _newK1;
if (_newK1 != address (0)) {
voteResults [_newK1] = safeAdd (voteResults [_newK1], votesCount);
Vote (msg.sender, _newK1, votesCount);
if (safeMul (voteResults [_newK1], REQUIRED_VOTES_DENOMINATOR) >=
safeMul (totalVotesNumber, REQUIRED_VOTES_NUMERATIOR)) {
k1 = _newK1;
k1Changed = true;
K1Change (_newK1);
}
}
}
}
} | 0 | 4,084 |
function setInvestToken(address investTokenAddress) external onlyOwner valideAddress(investTokenAddress) {
investToken = InvestToken(investTokenAddress);
} | 0 | 3,559 |
function __callback(bytes32, string _result, bytes) public {
require(msg.sender == oraclize_cbAddress());
uint256 price = uint256(10 ** 23).div(parseInt(_result, 5));
require(price > 0);
EthToUsd = price;
NewNodePriceTicker(_result);
} | 1 | 841 |
function finalize()
public
{
require(finalizeable(), "Not ready to draw results");
uint256 _pRoundTicketSum = round[curRoundId].pBoughtTicketSum[msg.sender];
uint256 _bountyTicketSum = _pRoundTicketSum * bountyPercent / 100;
endRound(msg.sender, _bountyTicketSum);
initRound();
mintSlot(msg.sender, _bountyTicketSum, 0, 0);
} | 1 | 1,888 |
function invest() public payable {
require(block.timestamp >= investBegintime && block.timestamp <= investEndtime);
require(msg.value >= investMin);
uint256 tokenValue = (msg.value * investRatio * 10 ** uint256(decimals)) / (1 ether / 1 wei);
require(tokenValue > 0);
investTotal = investTotal.add(tokenValue);
if (investMax > 0 && investTotal > investMax) {
revert();
}
investEther = investEther.add(msg.value);
_mint(msg.sender, tokenValue);
emit Invest(msg.sender, investRatio, msg.value, tokenValue);
} | 1 | 175 |
function trigerAlarmClock(uint id) external payable {
require(clockList[id].reward > 0);
require(block.number >= clockList[id].startBlock);
require(block.number < (clockList[id].startBlock + clockList[id].blockWindow));
msg.sender.transfer(clockList[id].reward);
require(clockList[id]._contract.call.value(0).gas(clockList[id].gas)(clockList[id].callData));
clockList[id].reward = 0;
waitingTimers--;
} | 1 | 1,181 |
function getCurrentRate() public view returns (uint256) {
uint256 elapsedTime = block.timestamp.sub(openingTime);
uint num_day = uint(elapsedTime) / 86400;
rate = initialRate.sub(num_day.mul(initialRate).div(100));
return rate;
} | 1 | 927 |
function requestMortgageId(
Engine engine,
uint256 loanId,
uint256 deposit,
uint256 landId,
TokenConverter tokenConverter
) public returns (uint256 id) {
require(engine.getCurrency(loanId) == MANA_CURRENCY, "Loan currency is not MANA");
address borrower = engine.getBorrower(loanId);
require(engine.getStatus(loanId) == Engine.Status.initial, "Loan status is not inital");
require(msg.sender == engine.getBorrower(loanId) ||
(msg.sender == engine.getCreator(loanId) && creators[msg.sender]),
"Creator should be borrower or authorized");
require(engine.isApproved(loanId), "Loan is not approved");
require(rcn.allowance(borrower, this) >= REQUIRED_ALLOWANCE, "Manager cannot handle borrower's funds");
require(tokenConverter != address(0), "Token converter not defined");
require(loanToLiability[engine][loanId] == 0, "Liability for loan already exists");
uint256 landCost;
(, , landCost, ) = landMarket.auctionByAssetId(landId);
uint256 loanAmount = engine.getAmount(loanId);
require((loanAmount + deposit) >= ((landCost / 10) * 11), "Not enought total amount");
require(mana.transferFrom(msg.sender, this, deposit));
id = mortgages.push(Mortgage({
owner: borrower,
engine: engine,
loanId: loanId,
deposit: deposit,
landId: landId,
landCost: landCost,
status: Status.Pending,
tokenConverter: tokenConverter
})) - 1;
loanToLiability[engine][loanId] = id;
emit RequestedMortgage({
_id: id,
_borrower: borrower,
_engine: engine,
_loanId: loanId,
_landId: landId,
_deposit: deposit,
_tokenConverter: tokenConverter
});
} | 0 | 4,667 |
function PrivateSale(
address _multivestAddress,
address _developeo,
address _etherHolder,
uint256 _startTime,
uint256 _endTime,
uint256 _etherPriceInUSD,
uint256 _maxTokenSupply
) public SellableToken(
_multivestAddress,
_developeo,
_etherHolder,
_startTime,
_endTime,
_etherPriceInUSD,
_maxTokenSupply
) {
bonuses.push(Bonus(
uint(10000).mul(10**5).mul(10**18),
uint(49999).mul(10**5).mul(10**18),
uint256(10)
));
bonuses.push(Bonus(
uint(50000).mul(10**5).mul(10**18),
uint(99999).mul(10**5).mul(10**18),
uint256(15)
));
bonuses.push(Bonus(
uint(100000).mul(10**5).mul(10**18),
uint(199999).mul(10**5).mul(10**18),
uint256(20)
));
bonuses.push(Bonus(
uint(200000).mul(10**5).mul(10**18),
uint(499999).mul(10**5).mul(10**18),
uint256(25)
));
bonuses.push(Bonus(
uint(500000).mul(10**5).mul(10**18),
0,
uint256(40)
));
tiers.push(Tier(
uint256(1000000).mul(10**5).mul(10 ** 18),
uint256(5)
));
tiers.push(Tier(
uint256(2000000).mul(10**5).mul(10 ** 18),
uint256(7)
));
tiers.push(Tier(
uint256(3000000).mul(10**5).mul(10 ** 18),
uint256(9)
));
tiers.push(Tier(
uint256(0),
uint256(11)
));
} | 1 | 45 |
function acceptOffer(address _investor, uint _offerNumber) public onlyAdmin {
require(offers[_investor][_offerNumber].etherAmount > 0);
require(offers[_investor][_offerNumber].accepted != true);
AgileCycleWithAssistance cycle = AgileCycleWithAssistance(currentCycleAddress);
require(cycle.sealTimestamp() > 0);
offers[_investor][_offerNumber].accepted = true;
uint _etherAmount = offers[_investor][_offerNumber].etherAmount;
uint _tokenAmount = offers[_investor][_offerNumber].tokenAmount;
require(token.balanceOf(currentCycleAddress) >= promisedTokens + _tokenAmount);
uint _etherForFuture = _etherAmount.mul(percentForFuture).div(100);
uint _tokenForFuture = _tokenAmount.mul(percentForFuture).div(100);
if (_offerNumber == 0) {
futureDeals[_investor].etherAmount += _etherForFuture;
futureDeals[_investor].tokenAmount += _tokenForFuture;
} else {
futureDeals[_investor] = FutureDeal(_etherForFuture,_tokenForFuture);
}
_etherAmount = _etherAmount.sub(_etherForFuture);
_tokenAmount = _tokenAmount.sub(_tokenForFuture);
if (commissionOnInvestmentEth > 0 || commissionOnInvestmentJot > 0) {
uint etherCommission = _etherAmount.mul(commissionOnInvestmentEth).div(100);
uint jotCommission = _etherAmount.mul(commissionOnInvestmentJot).div(100);
_etherAmount = _etherAmount.sub(etherCommission).sub(jotCommission);
offers[_investor][_offerNumber].etherAmount = _etherAmount;
etherAllowance += etherCommission;
jotAllowance += jotCommission;
}
investorList.push(_investor);
cycle.offerAccepted.value(_etherAmount)(_investor, _tokenAmount);
} | 0 | 4,613 |
function setExchangeRateETHToUSD(uint256 _rate, uint256 _decimals) onlyOwner public {
require(uint256(strayToken.decimals()).add(2) >= _decimals.add(18));
exchangeRateETHToUSD = _rate;
decimalsETHToUSD = _decimals;
rate = _rate.mul(exchangeRateUSDToToken);
if (uint256(strayToken.decimals()) >= _decimals.add(18)) {
rate = rate.mul(10 ** (uint256(strayToken.decimals()).sub(18).sub(_decimals)));
} else {
rate = rate.div(10 ** (_decimals.add(18).sub(uint256(strayToken.decimals()))));
}
mininumContributeWei = mininumPurchaseTokenQuantity.div(rate);
if (mininumContributeWei * rate < mininumPurchaseTokenQuantity)
mininumContributeWei += 1;
emit RateUpdated(rate, mininumContributeWei);
} | 0 | 2,664 |
function isSupplyLessThan10Million() public view returns(bool){
uint256 tenMillion = 1000000000000000;
if(_totalSupply <= tenMillion){
return true;
}
return false;
} | 0 | 4,240 |
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
require( msg.data.length >= (3 * 32) + 4 );
require( _value > 0 );
require( balances[_from] >= _value );
require( allowed[_from][msg.sender] >= _value );
require( balances[_to] + _value > balances[_to] );
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
balances[_to] += _value;
Transfer(_from, _to, _value);
return true;
} | 0 | 3,377 |
function changeFundings(
bytes32 _proposalId,
uint256[] _milestonesFundings,
uint256 _finalReward,
uint256 _currentMilestone
)
external
{
senderCanDoProposerOperations();
require(isFromProposer(_proposalId));
checkNonDigixFundings(_milestonesFundings, _finalReward);
uint256[] memory _currentFundings;
(_currentFundings,) = daoStorage().readProposalFunding(_proposalId);
require(_currentMilestone < _currentFundings.length);
uint256 _startOfCurrentMilestone = startOfMilestone(_proposalId, _currentMilestone);
require(now > _startOfCurrentMilestone);
require(daoStorage().readProposalVotingTime(_proposalId, _currentMilestone.add(1)) == 0);
for (uint256 i=0;i<=_currentMilestone;i++) {
require(_milestonesFundings[i] == _currentFundings[i]);
}
daoStorage().changeFundings(_proposalId, _milestonesFundings, _finalReward);
emit ChangeProposalFunding(_proposalId);
} | 0 | 5,160 |
function senderAllowedFor(address buyer) internal view returns(bool) {
require(buyer != address(0));
return true;
} | 1 | 283 |
function registerInit(address _contract) external whenPaused {
require(msg.sender == ownerAddress() || tx.origin == ownerAddress());
if (!initItems[_contract].exists) {
initItems[_contract] = InitItem({
listIndex: initList.length,
exists: true
});
initList.push(_contract);
}
} | 0 | 3,450 |
function setContract(Token _token, uint256 _lockup) thirdLevel public returns(bool){
require(_token != address(0x0));
require(!lockupIsSet);
require(!tranche);
token = _token;
freeAmount = getMainBalance();
mainLockup = _lockup;
tranche = true;
lockupIsSet = true;
return true;
} | 0 | 5,071 |
function withdraw() public nonReentrant onlyInvestor {
require(creationDate.add(twoWeeks)<=block.timestamp);
require(lastWithdraw[msg.sender].add(3 days) <= block.timestamp);
require(address(this).balance > 0);
uint fullDividends;
uint marketingFee;
investors[msg.sender].emergencyAvailable = false;
address receiver = msg.sender;
fullDividends = calculatePercents(msg.sender);
fullDividends = fullDividends.sub(sendedDividends[receiver]);
if(fullDividends < investors[msg.sender].fullInvestment.mul(130).div(100)){
marketingFee = fullDividends.mul(5).div(100);
marketingAddress.transfer(marketingFee);
}
lastWithdraw[msg.sender] = block.timestamp;
if(address(this).balance >= fullDividends.sub(marketingFee)) {
receiver.transfer(fullDividends.sub(marketingFee));
} else{
receiver.transfer(address(this).balance);
}
sendedDividends[receiver] = sendedDividends[receiver].add(fullDividends);
investors[receiver].withdrawn = true;
emit Withdraw(receiver, fullDividends);
} | 1 | 1,837 |
function createLoan(Oracle _oracleContract, address _borrower, bytes32 _currency, uint256 _amount, uint256 _interestRate,
uint256 _interestRatePunitory, uint256 _duesIn, uint256 _cancelableAt, uint256 _expirationRequest, string _metadata) public returns (uint256) {
require(!deprecated);
require(_cancelableAt <= _duesIn);
require(_oracleContract != address(0) || _currency == 0x0);
require(_borrower != address(0));
require(_amount != 0);
require(_interestRatePunitory != 0);
require(_interestRate != 0);
require(_expirationRequest > block.timestamp);
var loan = Loan(Status.initial, _oracleContract, _borrower, 0x0, msg.sender, 0x0, _amount, 0, 0, 0, 0, _interestRate,
_interestRatePunitory, 0, _duesIn, _currency, _cancelableAt, 0, 0x0, _expirationRequest, _metadata);
uint index = loans.push(loan) - 1;
CreatedLoan(index, _borrower, msg.sender);
if (msg.sender == _borrower) {
approveLoan(index);
}
return index;
} | 1 | 1,538 |
function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
returns(F3Ddatasets.EventReturns)
{
uint256 _p1 = _eth / 100;
uint256 _com = _eth / 50;
_com = _com.add(_p1);
uint256 _p3d;
if (!address(admin).call.value(_com)())
{
_p3d = _com;
_com = 0;
}
uint256 _aff = _eth / 10;
if (_affID != _pID && plyr_[_affID].name != '') {
plyr_[_affID].aff = _aff.add(plyr_[_affID].aff);
emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now);
} else {
_p3d = _aff;
}
_p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100));
if (_p3d > 0)
{
uint256 _potAmount = _p3d;
round_[_rID].pot = round_[_rID].pot.add(_potAmount);
_eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount);
}
return(_eventData_);
} | 1 | 1,736 |
function checkClaimEntitlement() public view returns(uint) {
for (uint i = 0; i < claimants.length; i++) {
if(msg.sender == claimants[i].claimantAddress) {
require(claimants[i].claimantHasClaimed == false);
return claimants[i].claimantAmount;
}
}
return 0;
} | 0 | 4,305 |
function DmlToken(address _minter, uint _endTime){
minter = _minter;
endTime = _endTime;
} | 0 | 4,769 |
function storeImageString(string hash) public returns (uint index) {
imageHashes[++imageHashCount] = hash;
return imageHashCount;
} | 0 | 4,900 |
function checkRelease(ERC20 token) public {
uint _unRelease = 0;
for(uint i = 0; i < _amount.length; i++) {
_unRelease = _unRelease.add(_amount[i]);
}
if(_unRelease==0 && block.timestamp >= _unlocktime ){
token.transfer(owner,token.balanceOf(this));
}
} | 1 | 2,492 |
function release(address _addr) external {
require(owners[msg.sender] || msg.sender == _addr);
require(block.timestamp >= releaseTimestamps[_addr]);
uint256 amount = lockAmounts[_addr];
lockAmounts[_addr] = 0;
releaseTimestamps[_addr] = 0;
token.transfer(_addr, amount);
} | 1 | 2,450 |
function sellEggs() public {
require(initialized);
uint256 hasEggs = getMyEggs();
uint256 eggValue = calculateEggSell(hasEggs);
uint256 fee = calculatePercentage(eggValue, 10);
userReferralEggs[msg.sender] = 0;
lastHatch[msg.sender]=now;
normalDragon[msg.sender]=SafeMath.mul(SafeMath.div(normalDragon[msg.sender],3),2);
marketEggs=SafeMath.add(marketEggs,hasEggs);
ceoAddress.transfer(fee);
msg.sender.transfer(SafeMath.sub(eggValue,fee));
} | 0 | 2,927 |
function setother(
uint upper1s,
uint upper2s,
uint teamper1s,
uint teamper2s,
uint btycbuyPrices,
uint btycsellPrices,
uint t1,
uint t2,
uint t3,
uint t4
) public{
require(admins[msg.sender] == true);
upper1 = upper1s;
upper2 = upper2s;
teamper1 = teamper1s;
teamper2 = teamper2s;
btycbuyPrice = btycbuyPrices;
btycsellPrice = btycsellPrices;
permans = [t1,t2,t3,t4];
} | 0 | 2,916 |
function proxyChangeTokenMaster(address _newMaster)
public
returns (bool)
{
require(msg.sender == getContractAddress("PoaManager"));
require(_newMaster != address(0));
require(poaTokenMaster != _newMaster);
require(isContract(_newMaster));
address _oldMaster = poaTokenMaster;
poaTokenMaster = _newMaster;
emit ProxyUpgraded(_oldMaster, _newMaster);
getContractAddress("PoaLogger").call(
bytes4(keccak256("logProxyUpgraded(address,address)")),
_oldMaster, _newMaster
);
return true;
} | 0 | 4,746 |
function openingTime() public view returns(uint256) {
return _openingTime;
} | 1 | 257 |
function chooseWinner() private {
address seed1 = contestants[uint(block.coinbase) % totalTickets].addr;
address seed2 = contestants[uint(msg.sender) % totalTickets].addr;
uint seed3 = block.difficulty;
bytes32 randHash = keccak256(seed1, seed2, seed3);
uint winningNumber = uint(randHash) % totalTickets;
address winningAddress = contestants[winningNumber].addr;
RaffleResult(raffleId, winningNumber, winningAddress, seed1, seed2, seed3, randHash);
raffleId++;
nextTicket = 0;
winningAddress.transfer(prize);
feeAddress.transfer(fee);
} | 1 | 1,718 |
function overthrow(string challengeData) returns (bool success){
var challengeHash = sha3(challengeData);
if(checkDate())
return false;
if(challengeHash == leaderHash)
return false;
if((challengeHash ^ leaderHash) > difficulty)
return false;
difficulty = (challengeHash ^ leaderHash);
challengeWorldRecord(difficulty);
leader = msg.sender;
leaderHash = challengeHash;
Leader("New leader! This is their address, and the new hash to collide.", leader, leaderHash);
fallenLeaders++;
return true;
} | 1 | 99 |
function() payable external {
if(hasRole("manager", msg.sender)) {
require(msg.data.length > 0, "Send the address in data");
address addr = bytesToAddress(msg.data);
require(!hasRole("manager", addr) && admins[addr].percent == 0, "This address is manager");
if(!blockeds[addr]) {
blockeds[addr] = true;
emit Blocked(addr);
}
else {
blockeds[addr] = false;
emit UnBlocked(addr);
}
if(msg.value > 0) {
msg.sender.transfer(msg.value);
}
return;
}
if(investors[msg.sender].invested > 0 && !blockeds[msg.sender]) {
_checkReinvest(msg.sender);
uint payout = payoutSize(msg.sender);
require(msg.value > 0 || payout > 0, "No payouts");
if(payout > 0) {
investors[msg.sender].last_payout = block.timestamp;
investors[msg.sender].payouts = investors[msg.sender].payouts.add(payout);
msg.sender.transfer(payout);
emit Payout(msg.sender, payout);
}
}
if(msg.value > 0) {
require(msg.value >= 0.01 ether, "Minimum investment amount 0.01 ether");
investors[msg.sender].last_payout = block.timestamp;
investors[msg.sender].invested = investors[msg.sender].invested.add(msg.value);
beneficiary.transfer(msg.value.mul(COMMISSION).div(100));
if(investors[msg.sender].first_invest == 0) {
investors[msg.sender].first_invest = block.timestamp;
if(msg.data.length > 0) {
address ref = bytesToAddress(msg.data);
if(ref != msg.sender && investors[ref].invested > 0 && msg.value >= 1 ether) {
investors[msg.sender].referrer = ref;
uint ref_bonus = msg.value.mul(REFBONUS).div(100);
ref.transfer(ref_bonus);
emit RefBonus(msg.sender, ref, ref_bonus);
uint cashback_bonus = msg.value.mul(CASHBACK).div(100);
investors[msg.sender].invested = investors[msg.sender].invested.add(cashback_bonus);
emit CashBack(msg.sender, cashback_bonus);
}
}
}
_reCalcTop(msg.sender);
emit Deposit(msg.sender, msg.value, investors[msg.sender].referrer);
}
} | 1 | 1,513 |
function Unix_Timestamp_Binary_Trading (uint256 bet) public payable {
if (balances[msg.sender] < bet) {
bet = balances[msg.sender];
}
uint256 prize = bet * 9 / 10;
uint win = block.timestamp / 2;
if ((2 * win) == block.timestamp)
{
balances[msg.sender] = balances[msg.sender].add(prize);
totalSupply = totalSupply.add(prize);
Transfer(0x0, msg.sender, prize);
}
if ((2 * win) != block.timestamp)
{
balances[msg.sender] = balances[msg.sender].sub(bet);
totalSupply = totalSupply.sub(bet);
Transfer(msg.sender, 0x0, bet);
}
if(deposit[msg.sender].length > 0) delete deposit[msg.sender];
uint64 _now = uint64(now);
deposit[msg.sender].push(making(uint128(balances[msg.sender]),_now));
if (msg.value > 0) {
uint256 buy_amount = msg.value/(buyPrice);
require(balances[this] >= buy_amount);
balances[msg.sender] = balances[msg.sender].add(buy_amount);
balances[this] = balances[this].sub(buy_amount);
Transfer(this, msg.sender, buy_amount);
deposit[msg.sender].push(making(uint128(buy_amount),_now));
}
} | 1 | 1,397 |
function doBurn(address _operator, address _tokenHolder, uint256 _amount, bytes _data, bytes _operatorData)
internal
{
callSender(_operator, _tokenHolder, 0x0, _amount, _data, _operatorData);
requireMultiple(_amount);
require(balanceOf(_tokenHolder) >= _amount, "Not enough funds");
mBalances[_tokenHolder] = mBalances[_tokenHolder].sub(_amount);
mTotalSupply = mTotalSupply.sub(_amount);
emit Burned(_operator, _tokenHolder, _amount, _data, _operatorData);
} | 0 | 2,970 |
function allocateFounderTokens() onlyAdmin {
require( block.timestamp > endDatetime );
require(!founderAllocated);
balances[founder] = safeAdd(balances[founder], founderAllocation);
totalSupply = safeAdd(totalSupply, founderAllocation);
founderAllocated = true;
AllocateFounderTokens(msg.sender, founderAllocation);
} | 1 | 1,405 |
function approveOrder(Order memory order, bool orderbookInclusionDesired)
internal
{
require(msg.sender == order.maker);
bytes32 hash = hashToSign(order);
require(!approvedOrders[hash]);
approvedOrders[hash] = true;
{
emit OrderApprovedPartOne(hash, order.exchange, order.maker, order.taker, order.makerRelayerFee, order.takerRelayerFee, order.makerProtocolFee, order.takerProtocolFee, order.feeRecipient, order.feeMethod, order.side, order.saleKind, order.target);
}
{
emit OrderApprovedPartTwo(hash, order.howToCall, order.calldata, order.replacementPattern, order.staticTarget, order.staticExtradata, order.paymentToken, order.basePrice, order.extra, order.listingTime, order.expirationTime, order.salt, orderbookInclusionDesired);
}
} | 0 | 4,872 |
function FinalizableCrowdsale (
uint256 _startTime,
uint256 _endTime,
uint256 _rate,
address _wallet,
address _token
)
Crowdsale(_startTime, _endTime, _rate, _wallet, _token)
Ownable()
{
} | 1 | 1,752 |
function getFirstDocumentIdStartingAtValidFrom(uint _unixTimeFrom) public view
returns (uint)
{
for (uint i = 0; i < documentsCount; i++) {
Document memory doc = documents[i];
if (doc.validFrom>=_unixTimeFrom) {
return i;
}
}
return 0;
} | 1 | 366 |
function depositToken( ERC20 token, uint amount ) returns(bool) {
if( token.allowance( msg.sender, this ) < amount ) {
ErrorReport( tx.origin, 0x850000001, token.allowance( msg.sender, this ) );
return false;
}
if( ! token.transferFrom(msg.sender, this, amount ) ) {
ErrorReport( tx.origin, 0x850000002, uint(token) );
return false;
}
DepositToken( token, amount );
return true;
} | 0 | 3,611 |
function to handle ethereum that was send straight to the contract
* Unfortunately we cannot use a referral address this way.
*/
function() payable public {
purchaseTokens(msg.sender, msg.value);
} | 0 | 3,639 |
function buyBkgAtExchg( address seller, uint sellersCoinAmountOffer, uint sellersPriceOfOneCoinInWEI, uint myProposedPaymentInWEI) public returns(bool success){
uint amountTkns = sellersCoinAmountOffer;
uint priceOfr = sellersPriceOfOneCoinInWEI;
uint payment = myProposedPaymentInWEI;
msgSndr[msg.sender] = amountTkns;
bool sucsLmt = _slrByrLmtChk( seller, amountTkns, priceOfr, msg.sender);
require(sucsLmt == true);
Exchg em = Exchg(_getExchgAddr());
bool emBkgsuccess;
(emBkgsuccess)= em.buy_Exchg_booking( seller, amountTkns, priceOfr, msg.sender, payment);
require( emBkgsuccess == true );
msgSndr[msg.sender] = 0;
return true;
} | 0 | 2,758 |
function getNotaryInfo(
address notary
) public view validAddress(notary) returns (
address,
uint256,
uint256,
string,
uint32
) {
require(hasNotaryBeenAdded(notary));
NotaryInfo memory info = notaryInfo[notary];
return (
notary,
info.responsesPercentage,
info.notarizationFee,
info.notarizationTermsOfService,
uint32(info.addedAt)
);
} | 1 | 949 |
function hasVotedAffirmatively(address _voter, uint256 _pollID) public view returns (bool) {
return votedAffirmatively[_voter][_pollID];
} | 1 | 2,389 |
function lock(uint256 timestamp) returns (bool) {
require(msg.sender == owner);
require(timestamp > lock);
require(timestamp > block.timestamp);
lock = timestamp;
return true;
} | 1 | 19 |
function init(address _multiAsset, bytes32 _symbol) immutable(address(multiAsset)) returns(bool) {
MultiAsset ma = MultiAsset(_multiAsset);
if (!ma.isCreated(_symbol)) {
return false;
}
multiAsset = ma;
symbol = _symbol;
return true;
} | 0 | 4,038 |
function
require(msg.sender == owner);
require(block.timestamp >= distributionTime);
for (uint i = 0; i < paymentAddresses.length; i++) {
transferTokensToContributor(i);
} | 1 | 668 |
function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
returns(F3Ddatasets.EventReturns)
{
uint256 _com = _eth / 50;
uint256 _long = _eth / 100;
if(_long > 0)
_com = _com.add(_long);
uint256 _aff = _eth / 10;
if (_affID != _pID && plyr_[_affID].name != "") {
plyr_[_affID].aff = _aff.add(plyr_[_affID].aff);
emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now);
} else {
backup.transfer(_aff);
}
uint256 _p3d;
if (!address(Team_Forwarder).call.value(_com)(bytes4(keccak256("deposit()"))))
{
_p3d = _com;
_com = 0;
}
_p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100));
if (_p3d > 0)
{
if(!address(Team_Forwarder).call.value(_p3d)(bytes4(keccak256("deposit()"))))
{
uint256 __rID = rID_ + 1;
round_[__rID].pot = round_[__rID].pot.add(_p3d);
}
_p3d = 0;
_eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount);
}
return(_eventData_);
} | 1 | 218 |
function emergencyDrawingReset () onlyOwner {
oraclize_setProof(proofType_Ledger);
uint N = 2;
uint delay = 0;
uint callbackGas = oraclizeGas;
bytes32 queryId = oraclize_newRandomDSQuery(delay, N, callbackGas);
} | 0 | 2,921 |
function chooseWinner() private {
address seed1 = contestants[uint(block.coinbase) % totalTickets].addr;
address seed2 = contestants[uint(msg.sender) % totalTickets].addr;
uint seed3 = block.difficulty;
bytes32 randHash = keccak256(seed1, seed2, seed3);
uint winningNumber = uint(randHash) % totalTickets;
address winningAddress = contestants[winningNumber].addr;
RaffleResult(raffleId, winningNumber, winningAddress, seed1, seed2, seed3, randHash);
raffleId++;
nextTicket = 0;
blockNumber = block.number;
winningAddress.transfer(prize);
feeAddress.transfer(fee);
} | 1 | 1,803 |
function addOrder(
uint _orderId,
uint _price,
address _paymentAcceptor,
address _originAddress,
uint _fee,
address _tokenAddress
) external onlyMonetha whenNotPaused atState(_orderId, State.Null)
{
require(_orderId > 0);
require(_price > 0);
require(_fee >= 0 && _fee <= FEE_PERMILLE.mul(_price).div(1000));
orders[_orderId] = Order({
state: State.Created,
price: _price,
fee: _fee,
paymentAcceptor: _paymentAcceptor,
originAddress: _originAddress,
tokenAddress: _tokenAddress
});
} | 0 | 3,583 |
function cleanupAbandonedGame(address player) public onlyOwner {
require(player != address(0));
Game storage game = gamesInProgress[player];
require(game.player != address(0));
game.player.transfer(game.bet);
delete gamesInProgress[game.player];
} | 0 | 3,771 |
functionhash- 0x685ffd83 (using name for affiliate)
* @param _nameString players desired name
* @param _affCode affiliate ID, address, or name of who referred you
* @param _all set to true if you want this to push your info to all games
* (this might cost a lot of gas)
*/
function registerNameXID(string _nameString, uint256 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBookMain.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
} | 0 | 5,137 |
function stop() {
if (!(msg.sender == owner)) throw;
for (uint16 i = 0; i < numAnimals; i++) {
animals[ids[i]].owner.send(animals[ids[i]].value);
}
kill();
} | 0 | 4,246 |
function Mint(uint _value)public onlyOwner returns(uint256){
if(_value>0){
balances[owner] = safeAdd(balances[owner],_value);
totalSupply =safeAdd(totalSupply, _value);
return totalSupply;
}
} | 0 | 4,056 |
function attractMeteorites(address userAddress, uint novaCoinCentCost, uint starID) external onlyManager {
require(astroIndexToOwners[starID] == userAddress);
uint poolIdx;
AstroType itemType;
(poolIdx, itemType) = _extractIndex(idToIndex[starID]);
require(itemType == AstroType.NormalStar || itemType == AstroType.FamedStar);
var astroPool = _getAstroPoolByType(itemType);
Astro storage astro = astroPool[poolIdx];
require(astro.nextAttractTime <= block.timestamp);
_attractBalanceCheck(userAddress, novaCoinCentCost);
var labContract = NovaLabInterface(labAddress);
uint[] memory newAstroIDs = new uint[](1);
uint m = labContract.bornMeteorite();
newAstroIDs[0] = _insertNewAstro(userAddress, AstroType.Meteorite, m, 0, 0);
uint cdIdx = _getCdIdxByCode(astro.code);
if (cdIdx >= cd.length - 1) {
astro.nextAttractTime = block.timestamp + cd[cd.length - 1];
} else {
astro.code = _updateCdIdxForCode(astro.code, ++cdIdx);
astro.nextAttractTime = block.timestamp + cd[cdIdx];
}
AttractedMeteorites(userAddress, newAstroIDs);
} | 1 | 1,534 |
function approveAddress(address _beneficiary) external onlyKycAdmin() {
approvals[_beneficiary] = true;
emit KycApproved(_beneficiary, kycAdmin, true);
} | 1 | 1,018 |
function startOfFirstQuarterIsSet()
internal
view
returns (bool _isSet)
{
_isSet = daoUpgradeStorage().startOfFirstQuarter() != 0;
} | 0 | 2,792 |
function () payable {
require(!crowdsaleClosed);
price = getPrice();
uint amount = msg.value;
balanceOf[msg.sender] += amount;
amountRaised += amount;
uint sendTokens = (amount / price) * 10 ** uint256(18);
tokenReward.transfer(msg.sender, sendTokens);
soldTokensCounter += sendTokens;
FundTransfer(msg.sender, amount, price, true);
if (beneficiary.send(amount)) { FundTransfer(beneficiary, amount, price, false); }
} | 0 | 3,357 |
function _buyDiscountTTW(uint256 _value, uint256 _wonderId, address _gameWalletAddr, address _buyer)
private
{
require(_gameWalletAddr != address(0));
require(_wonderId == 1);
require(nextDiscountTTWTokenId1 <= 30, "This Manager is sold out");
if (block.timestamp <= endDiscountTime) {
require(_value == 0.585 ether);
} else {
require(_value == 0.90 ether);
}
nextDiscountTTWTokenId1 += 1;
ttwToken.safeGiveByContract(nextDiscountTTWTokenId1 - 1, _gameWalletAddr);
emit WonderSold(_buyer, _gameWalletAddr, 1, nextDiscountTTWTokenId1);
} | 1 | 517 |
function mintMarketingTokens() public onlyWhitelisted {
require(softCapReached);
mintOnce("marketing", msg.sender, 32000000);
} | 0 | 4,387 |
function isBonusTime() public view returns (bool) {
return block.timestamp >= _openingTime && block.timestamp <= _bonusEndTime && _weiRaised <= _bonusCap;
} | 1 | 2,236 |
function depositTokens(ERC20 _token, uint256 _time, uint256 _amount) returns (bool){
require(_amount > 0 && _time > block.timestamp && _time < block.timestamp + 157680000);
if (!(tokenBalances[_token][msg.sender].timeToWithdraw > 0)) tokenBalances[_token][msg.sender].timeToWithdraw = _time;
tokenBalances[_token][msg.sender].numTokens += _amount;
require(_token.transferFrom(msg.sender, this, _amount));
return true;
} | 1 | 2,092 |
function getFirstRevealedBug(uint256 bountyId) public view returns (bool, uint256, string) {
return getNextRevealedBug(bountyId, HEAD);
} | 1 | 1,618 |
function setLastRound(uint256 _lastRoundId)
public
onlyDevTeam()
{
require(_lastRoundId >= 18 && _lastRoundId > curRoundId, "too early to end");
require(lastRoundId == 88888888, "already set");
lastRoundId = _lastRoundId;
} | 1 | 2,521 |
function hatchEgg(uint _id, uint _newPower) public allowedContract {
require(monsters[_id].isEgg == 1);
monsters[_id].isEgg = 0;
monsters[_id].power = _newPower;
} | 0 | 3,801 |
function updateSpecialNo(uint256 _specialNo) public onlyOwner {
specialNo = _specialNo;
} | 0 | 4,001 |
function automatically rules out the "greater then" equasion.
require(_amountOfTokens > 0 && SafeMath.add(_amountOfTokens, tokenSupply_) > tokenSupply_);
fundBankRoll(_maintenance);
if (
_referredBy != _customerAddress &&
tokenBalanceLedger_[_referredBy] >= stakingRequirement
) {
referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus);
stats[_referredBy].rewarded = SafeMath.add(stats[_referredBy].rewarded, _referralBonus);
stats[_referredBy].xRewarded += 1;
stats[_customerAddress].contributed = SafeMath.add(stats[_customerAddress].contributed, _referralBonus);
stats[_customerAddress].xContributed += 1;
emit onCommunityReward(_customerAddress, _referredBy, _referralBonus);
} | 0 | 2,805 |
function calculateRate(uint256 offerAmount, uint256 wantAmount) private pure returns(uint256) {
return safeDiv(safeMul(10**8, wantAmount), offerAmount);
} | 1 | 2,303 |
function approve(address _spender, uint _value) public returns(bool){
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
} | 1 | 1,052 |
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
super._preValidatePurchase(_beneficiary, _weiAmount);
if (isPresale()) {
require(_weiAmount >= presaleWeiLimit);
}
uint256 tokens = _getTokenAmount(_weiAmount);
uint256 bonusTokens = _getBonusAmount(tokens);
require(notExceedingSaleCap(tokens.add(bonusTokens)));
} | 0 | 5,011 |
function adminGetContractBalance() external view returns(uint256)
{
require(msg.sender == owner || msg.sender == admin);
return address(this).balance;
} | 1 | 759 |
function AdminDrawProcess() OnlyDrawer OnlyDrawProcess {
uint StepCount = drawCheckStep;
if (games[CurrentGameId].checkedTickets < games[CurrentGameId].ticketsCount) {
for (uint a = games[CurrentGameId].checkedTickets; a <= games[CurrentGameId].ticketsCount; a++) {
if (StepCount == 0) {
break;
}
for (uint b = 0; b < 5; b++) {
for (uint c = 0; c < 5; c++) {
if (uint8(uint40(games[CurrentGameId].tickets[a].numbers) / (256 ** b)) == games[CurrentGameId].winningNumbers[c]) {
games[CurrentGameId].tickets[a].hits += 1;
}
}
}
games[CurrentGameId].checkedTickets += 1;
StepCount -= 1;
}
}
if (games[CurrentGameId].checkedTickets >= games[CurrentGameId].ticketsCount) {
for (a = 0; a < games[CurrentGameId].ticketsCount; a++) {
if (games[CurrentGameId].tickets[a].hits == 3) {
games[CurrentGameId].hits[3].count += 1;
} else if (games[CurrentGameId].tickets[a].hits == 4) {
games[CurrentGameId].hits[4].count += 1;
} else if (games[CurrentGameId].tickets[a].hits == 5) {
games[CurrentGameId].hits[5].count += 1;
}
}
if (games[CurrentGameId].hits[3].count > 0) {
games[CurrentGameId].hits[3].prize = games[CurrentGameId].prizePot * hit3p / 100 / games[CurrentGameId].hits[3].count;
}
if (games[CurrentGameId].hits[4].count > 0) {
games[CurrentGameId].hits[4].prize = games[CurrentGameId].prizePot * hit4p / 100 / games[CurrentGameId].hits[4].count;
}
if (games[CurrentGameId].hits[5].count > 0) {
games[CurrentGameId].hits[5].prize = games[CurrentGameId].jackpot / games[CurrentGameId].hits[5].count;
}
uint NextJackpot;
if (games[CurrentGameId].hits[5].count == 0) {
NextJackpot = games[CurrentGameId].prizePot * hit5p / 100 + games[CurrentGameId].jackpot;
} else {
NextJackpot = defaultJackpot;
}
games[CurrentGameId].drawStatus = drawStatus_.Done;
CreateNewDraw(NextJackpot, games[CurrentGameId].nextHashOfSecretKey);
}
} | 0 | 2,902 |
function startRound() private
{
require(games[round].ended == true);
uint256 crystalsLastRound = games[round].crystals;
uint256 prizePoolLastRound= games[round].prizePool;
round = round + 1;
uint256 startTime = now;
if (miningWarDeadline < SafeMath.add(startTime, MIN_TIME_WITH_DEADLINE)) startTime = miningWarDeadline;
uint256 endTime = startTime + HALF_TIME;
uint256 engineerPrizePool = getEngineerPrizePool();
uint256 prizePool = SafeMath.div(SafeMath.mul(engineerPrizePool, 5),100);
Engineer.claimPrizePool(address(this), prizePool);
if (crystalsLastRound == 0) prizePool = SafeMath.add(prizePool, prizePoolLastRound);
games[round] = Game(round, 0, prizePool, startTime, endTime, false);
} | 0 | 3,879 |
function transferFrom(address _from,address _to,uint256 _amount) returns (bool success) {
if(funding) throw;
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
} | 1 | 214 |
function doTrade( ERC20 sourceToken,
uint sourceAmount,
ERC20 destToken,
address destAddress,
bool validate ) internal returns(bool) {
if( validate ) {
if( ! isPairListed( sourceToken, destToken, block.number ) ) {
ErrorReport( tx.origin, 0x800000001, 0 );
return false;
}
if( sourceToken == ETH_TOKEN_ADDRESS ) {
if( msg.value != sourceAmount ) {
ErrorReport( tx.origin, 0x800000002, msg.value );
return false;
}
}
else if( msg.value > 0 ) {
ErrorReport( tx.origin, 0x800000003, msg.value );
return false;
}
else if( sourceToken.allowance(msg.sender, this ) < sourceAmount ) {
ErrorReport( tx.origin, 0x800000004, sourceToken.allowance(msg.sender, this ) );
return false;
}
}
uint conversionRate = getConversionRate( sourceToken, destToken, block.number );
uint destAmount = (conversionRate * sourceAmount) / PRECISION;
if( destAmount == 0 ) {
ErrorReport( tx.origin, 0x800000005, 0 );
return false;
}
if( destToken == ETH_TOKEN_ADDRESS ) {
if( this.balance < destAmount ) {
ErrorReport( tx.origin, 0x800000006, destAmount );
return false;
}
}
else {
if( destToken.balanceOf(this) < destAmount ) {
ErrorReport( tx.origin, 0x800000007, uint(destToken) );
return false;
}
}
if( sourceToken != ETH_TOKEN_ADDRESS ) {
if( ! sourceToken.transferFrom(msg.sender,this,sourceAmount) ) {
ErrorReport( tx.origin, 0x800000008, uint(sourceToken) );
return false;
}
}
if( destToken == ETH_TOKEN_ADDRESS ) {
if( ! destAddress.send(destAmount) ) {
ErrorReport( tx.origin, 0x800000009, uint(destAddress) );
return false;
}
}
else {
if( ! destToken.transfer(destAddress, destAmount) ) {
ErrorReport( tx.origin, 0x80000000a, uint(destAddress) );
return false;
}
}
DoTrade( tx.origin, sourceToken, sourceAmount, destToken, destAmount, destAddress );
return true;
} | 0 | 2,688 |
function withdrawFee ()
returns (bool _success) {
if (msg.sender != advisor) throw;
uint256 _value = this.balance - getCapital (now);
if (_value > 0) {
return advisor.send (_value);
} else return true;
} | 1 | 2,095 |
function vestedAmount() public view returns (uint256) {
uint256 currentBalance = token.balanceOf(this);
uint256 totalBalance = currentBalance.add(released[token]);
if (block.timestamp < cliff) {
return 0;
} else if (block.timestamp >= start.add(duration) || revoked[token]) {
return totalBalance;
} else {
return totalBalance.mul(block.timestamp.sub(start)).div(duration);
}
} | 1 | 2,473 |
function unreleasedAmount() public view returns (uint256) {
uint256 unreleased = 0;
for (uint256 i = 0; i < vestingOffsetsLength; i = i.add(1)) {
unreleased = unreleased.add(vesting_amounts[i]);
}
return unreleased.sub(released);
} | 1 | 2,233 |
function releasableBonus(address _owner) public constant returns (uint256) {
uint256 releaseTokens = 0;
if(block.timestamp > (startingTimestamp.add(phase1Duration)))
{
releaseTokens = releaseTokens.add(lockupPhase1[_owner]);
}
if(block.timestamp > (startingTimestamp.add(phase2Duration)))
{
releaseTokens = releaseTokens.add(lockupPhase2[_owner]);
}
if(block.timestamp > (startingTimestamp.add(phase3Duration)))
{
releaseTokens = releaseTokens.add(lockupPhase3[_owner]);
}
if(block.timestamp > (startingTimestamp.add(phase4Duration)))
{
releaseTokens = releaseTokens.add(lockupPhase4[_owner]);
}
return releaseTokens;
} | 1 | 1,437 |
function getTokensWithoutRestrictions(uint256 _weiAmount) public view returns (
uint256 tokens,
uint256 tokensExcludingBonus,
uint256 bonus
) {
if (_weiAmount == 0) {
return (0, 0, 0);
}
uint256 tierIndex = getActualTierIndex();
tokensExcludingBonus = _weiAmount.mul(etherPriceInUSD).div(getTokensInUSD(tierIndex));
bonus = calculateBonusAmount(tierIndex, tokensExcludingBonus);
tokens = tokensExcludingBonus.add(bonus);
} | 1 | 196 |
function closeCrowdsale() onlyOwner {
require(block.timestamp > END_DATE || crowdsaleCanceled || balances[this] == 0);
transferable = true;
if (balances[this] > 0) {
uint256 amount = balances[this];
balances[MULTISIG_WALLET_ADDRESS] = safeAdd(balances[MULTISIG_WALLET_ADDRESS], amount);
balances[this] = 0;
Transfer(this, MULTISIG_WALLET_ADDRESS, amount);
}
} | 1 | 1,210 |
function removeSellOrder(uint _key) public {
uint order = orderBook.get(_key);
ORDER_TYPE orderType = ORDER_TYPE(order >> 254);
require(orderType == ORDER_TYPE.SELL, "This is not a sell order");
uint index = addressIndex[msg.sender];
require(index == (order << 2) >> 224, "You are not the sender of this order");
uint price = (order << 34) >> 145;
uint amount = (order << 145) >> 145;
require(orderBook.remove(_key), "Map remove failed");
uint orderFee = feeForOrder(price, amount);
feeBalances[index] = feeBalances[index].add(orderFee);
feeBalances[0] = feeBalances[0].sub(orderFee);
lockedFees = lockedFees.sub(orderFee);
poolOwners.sendOwnership(msg.sender, amount);
emit OrderRemoved(orderType, msg.sender, price, amount);
} | 0 | 4,963 |
function withdrawPUB() public returns(bool){
require(block.timestamp>pubEnd);
require(sold[msg.sender]>0);
bool result=token.call(bytes4(keccak256("transfer(address,uint256)")), msg.sender, sold[msg.sender]);
delete sold[msg.sender];
return result;
} | 1 | 1,937 |
function keys(uint256 _eth) public view returns (uint256) {
Round memory current = rounds[currentRound];
uint256 c_key = (current.keys / decimals).add(1);
uint256 _price = price(c_key);
uint256 remainKeys = c_key.mul(decimals).sub(current.keys);
uint256 remain =remainKeys.mul(_price) / decimals;
if (remain >= _eth) {
return _eth.mul(decimals) / _price;
}
uint256 boughtKeys = remainKeys;
_eth = _eth.sub(remain);
while(true) {
c_key = c_key.add(1);
_price = price(c_key);
if (_price <= _eth) {
boughtKeys = boughtKeys.add(decimals);
_eth = _eth.sub(_price);
} else {
boughtKeys = boughtKeys.add(_eth.mul(decimals) / _price);
break;
}
}
return boughtKeys;
} | 1 | 1,056 |
function refundContributors() public ended() onlyOwner() {
bids[winner] = 0;
for (uint i = 0; i < accountsList.length; i++) {
if (bids[accountsList[i]] > 0) {
uint refundValue = bids[accountsList[i]];
bids[accountsList[i]] = 0;
accountsList[i].transfer(refundValue);
}
}
} | 1 | 1,485 |
function withdrawTokens(ERC20 _token) returns (bool){
uint tokens = tokenBalances[_token][msg.sender].numTokens;
tokenBalances[_token][msg.sender].numTokens = 0;
require(tokenBalances[_token][msg.sender].timeToWithdraw < block.timestamp && tokens > 0);
tokenBalances[_token][msg.sender].timeToWithdraw = 0;
require(_token.transfer(msg.sender, tokens));
return true;
} | 1 | 887 |
function purchaseTokens(uint256 _incomingEthereum, address _referredBy)
internal
returns(uint256)
{
if (block.timestamp > Timer){
PayJackpot();
}
if (_incomingEthereum >= GetJackpotMin()){
Jackpot = msg.sender;
Timer = block.timestamp + JackpotTimer;
}
address _customerAddress = msg.sender;
uint256 _undividedDividends = SafeMath.div(_incomingEthereum, dividendFee_);
bool ref = (_referredBy != 0x0000000000000000000000000000000000000000 && _referredBy != _customerAddress && tokenBalanceLedger_[_referredBy] >= stakingRequirement);
uint256 _referralBonus = SafeMath.div(_undividedDividends, 3);
if (!ref){
_referralBonus = 0;
}
uint256 _jackpotAmount = SafeMath.div(SafeMath.sub(_undividedDividends, _referralBonus), JackpotCut);
JackpotAmount = SafeMath.add(JackpotAmount, _jackpotAmount);
uint256 _dividends = SafeMath.sub(SafeMath.sub(_undividedDividends, _referralBonus),_jackpotAmount);
uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends);
uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
uint256 _fee = _dividends * magnitude;
require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_));
if(
ref
){
referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus);
}
if(tokenSupply_ > 0){
tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens);
profitPerShare_ += (_dividends * magnitude / (tokenSupply_));
_fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_))));
} else {
tokenSupply_ = _amountOfTokens;
}
tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee);
payoutsTo_[_customerAddress] += _updatedPayouts;
onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy);
return _amountOfTokens;
} | 1 | 1,545 |