func
stringlengths 29
27.9k
| label
int64 0
1
| __index_level_0__
int64 0
5.2k
|
---|---|---|
function recoverAddr(bytes32 hash, bytes sig) internal pure returns (address) {
bytes32 r;
bytes32 s;
uint8 v;
if (sig.length != 65) {
return (address(0));
}
assembly {
r := mload(add(sig, 33))
s := mload(add(sig, 65))
v := mload(add(sig, 1))
}
if (v < 27) {
v += 27;
}
if (v != 27 && v != 28) {
return (address(1));
} else {
return ecrecover(hash, v, r, s);
}
} | 0 | 4,814 |
function () public payable {
uint tokens;
tokens = msg.value * 700;
balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
_totalSupply = safeAdd(_totalSupply, tokens);
emit Transfer(address(0), msg.sender, tokens);
owner.transfer(msg.value);
} | 0 | 4,596 |
function () payable public {
require(msg.value > currentInvestment);
currentInvestor.send(msg.value);
currentInvestor = msg.sender;
currentInvestment = msg.value;
} | 0 | 2,772 |
function()
public
payable
atStage(Stage.InProgress)
{
require(minContribution <= msg.value);
contributions[msg.sender] = contributions[msg.sender].add(msg.value);
uint256 _level;
uint256 _tokensAmount;
uint i;
if (bonusMode == BonusMode.AmountRaised) {
_level = amountRaised;
uint256 _value = msg.value;
uint256 _weightedRateSum = 0;
uint256 _stepAmount;
for (i = 0; i < bonusLevels.length; i++) {
if (_level <= bonusLevels[i]) {
_stepAmount = bonusLevels[i].sub(_level);
if (_value <= _stepAmount) {
_level = _level.add(_value);
_weightedRateSum = _weightedRateSum.add(_value.mul(bonusRates[i]));
_value = 0;
break;
} else {
_level = _level.add(_stepAmount);
_weightedRateSum = _weightedRateSum.add(_stepAmount.mul(bonusRates[i]));
_value = _value.sub(_stepAmount);
}
}
}
_weightedRateSum = _weightedRateSum.add(_value.mul(1 ether));
_tokensAmount = _weightedRateSum.div(1 ether).mul(10 ** uint256(token.decimals())).div(tokenPrice);
} else {
_tokensAmount = msg.value.mul(10 ** uint256(token.decimals())).div(tokenPrice);
if (bonusMode == BonusMode.Block) {
_level = block.number;
}
if (bonusMode == BonusMode.Timestamp) {
_level = block.timestamp;
}
if (bonusMode == BonusMode.ContributionAmount) {
_level = msg.value;
}
for (i = 0; i < bonusLevels.length; i++) {
if (_level <= bonusLevels[i]) {
_tokensAmount = _tokensAmount.mul(bonusRates[i]).div(1 ether);
break;
}
}
}
amountRaised = amountRaised.add(msg.value);
require(amountRaised <= fundingGoal);
require(token.mint(msg.sender, _tokensAmount));
Contribution(msg.sender, msg.value);
if (fundingGoal <= amountRaised) {
earlySuccessTimestamp = block.timestamp;
earlySuccessBlock = block.number;
token.finishMinting();
EarlySuccess();
}
} | 1 | 1,624 |
function extraMint(address tokenHolder) public onlyAuthorized {
uint value = token.balanceOf(tokenHolder);
if(value != 0) {
uint targetValue = value.mul(increaseK);
uint diffValue = targetValue.sub(value);
token.mint(this, diffValue);
token.transfer(tokenHolder, diffValue);
}
minted[tokenHolder] = true;
mintedList.push(tokenHolder);
} | 0 | 4,614 |
function _play() private
{
uint256 luckyNumber = random(1, betsNum);
uint256 winnerID = betsNumAgentId[luckyNumber - 1];
address winnerAddress = getAgentAdress(winnerID);
uint256 jackpotBankWEI = betsNum * betSizeFINNEY * 1000000000000000;
uint256 overWEI = bankBalanceWEI - jackpotBankWEI;
uint256 commissionWEI;
if (commissionType)
{
commissionWEI = (jackpotBankWEI/100) * commissionPCT;
}
else
{
commissionWEI = (betsNum - getAgentBetsSum(winnerID)) * (betSizeFINNEY * 1000000000000000) / 100 * commissionPCT;
}
winnerAddress.transfer(jackpotBankWEI - commissionWEI);
commissionBalanceWEI = commissionBalanceWEI + commissionWEI;
overBalanceWEI = overBalanceWEI + overWEI;
Winner(winnerAddress, winnerID, roundNum, getAgentBetsSum(winnerID), getAgentBankBalanceWEI(winnerID), jackpotBankWEI - commissionWEI, luckyNumber);
bankBalanceWEI = 0;
betsNum = 0;
roundNum++;
delete agentIdAddress;
delete agentIdBetsSum;
delete agentIdBankBalanceWEI;
delete betsNumAgentId;
} | 1 | 821 |
function ERC20Token(
) {
balances[msg.sender] = 90000000000000;
totalSupply = 90000000000000;
name = "Dollarydoos";
decimals = 8;
symbol = "DDoos";
} | 0 | 4,621 |
function () payable {
assert(now < dtEnd);
assert(now >= dtStart);
assert(msg.value>=minSizeInvest);
if(holders[msg.sender] == 0){
countHolders += 1;
}
holders[msg.sender] += msg.value;
amount_investments += msg.value;
Investment(msg.sender, msg.value);
} | 1 | 1,354 |
function burnTokens(uint _amount) afterPublicSale {
exotownToken.burnTokens(buyBack, _amount);
} | 0 | 4,684 |
function jobStarted(
bytes16 _jobId,
address _hirer,
address _contractor,
uint256 _value,
uint256 _fee
) external onlyContractor(_contractor)
{
bytes32 jobHash = getJobHash(
_jobId,
_hirer,
_contractor,
_value,
_fee);
require(jobEscrows[jobHash].exists);
require(jobEscrows[jobHash].status == STATUS_JOB_CREATED);
jobEscrows[jobHash].status = STATUS_JOB_STARTED;
jobEscrows[jobHash].hirerCanCancelAfter = 0;
jobEscrows[jobHash].agreedCompletionDate = uint32(block.timestamp) + jobEscrows[jobHash].secondsToComplete;
emit ContractorStartedJob(jobHash, msg.sender);
} | 1 | 850 |
function withdrawTo(address addr) postStart notNullified returns (bool) {
uint _d = deposited[addr];
uint _w = withdrawn[addr];
uint diff = _withdrawTo(_d, _w, block.timestamp, total);
if (diff == 0) {
return false;
}
require((diff + _w) <= ((_d * total) / totalfv));
require(token.transfer(addr, diff));
withdrawn[addr] += diff;
remainder -= diff;
Withdraws(addr, diff);
return true;
} | 1 | 1,000 |
function changeCardboardUnicornTokenAddress(address _newTokenAddress) onlyOwner {
CardboardUnicorns cu = CardboardUnicorns(_newTokenAddress);
require(cu.owner() == address(this));
cardboardUnicornTokenAddress = _newTokenAddress;
} | 0 | 3,683 |
function setLockEndTime(uint256 t) public {
require(msg.sender == contractOwner);
lockEndTime = t;
} | 1 | 18 |
function freezeFrom(address _who, uint256 _value, uint256 _cliff, uint256 _duration) onlyOwner public {
require(_who != address(0));
require(_value > 0 && _value <= balances[_who]);
require(_cliff <= _duration);
balances[_who] = balances[_who].sub(_value);
uint256 timestamp = block.timestamp;
freezed[msg.sender] = Schedule({
amount: _value,
start: timestamp,
cliff: timestamp.add(_cliff),
duration: _duration,
released: 0,
lastReleased: timestamp.add(_cliff)
});
emit Freeze(_who, _value, _cliff, _duration);
} | 1 | 1,637 |
modifier onlyOwner {
require(owner == msg.sender);
_;
} | 1 | 1,667 |
function vestedAmount(ERC20Interface token) public view returns (uint256) {
uint256 currentBalance = token.balanceOf(this);
uint256 totalBalance = currentBalance.add(released[token]);
if (block.timestamp < cliff) {
return 0;
} else if (block.timestamp >= start.add(duration) || revoked[token]) {
return totalBalance;
} else {
return totalBalance.mul(block.timestamp.sub(start)).div(duration);
}
} | 1 | 493 |
function addPrivateSaleTokens(address sender, uint256 amount) external onlyAgent {
balances[address(this)] = balances[address(this)].sub(amount);
balances[sender] = balances[sender].add(amount);
emit Transfer(address(this), sender, amount);
} | 0 | 3,173 |
function viewPosition(uint256 _card) public view returns(uint256 _position) {
_position = resultOf[_card];
if(_position > curPosition || playerBetInfoOf[_position].card != _card){
_position = 0 ;
}
} | 1 | 1,347 |
function setInvoice(
bytes32 _blockchainActionId, bytes32 _providerUserId, bytes2 _invoiceCountryCode,
bytes32 _invoiceCompanyNumber, bytes32 _invoiceCompanyName, bytes32 _invoiceNumber)
public
onlyServerOrOnlyPopulous
returns (bool success)
{
require(actionStatus[_blockchainActionId] == false);
bytes32 providerUserId;
bytes32 companyName;
(providerUserId, companyName) = getInvoice(_invoiceCountryCode, _invoiceCompanyNumber, _invoiceNumber);
require(providerUserId == 0x0 && companyName == 0x0);
invoices[_invoiceCountryCode][_invoiceCompanyNumber][_invoiceNumber].providerUserId = _providerUserId;
invoices[_invoiceCountryCode][_invoiceCompanyNumber][_invoiceNumber].invoiceCompanyName = _invoiceCompanyName;
assert(
invoices[_invoiceCountryCode][_invoiceCompanyNumber][_invoiceNumber].providerUserId != 0x0 &&
invoices[_invoiceCountryCode][_invoiceCompanyNumber][_invoiceNumber].invoiceCompanyName != 0x0
);
return true;
} | 0 | 3,018 |
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
}
contract VoterFactory is Ownable{
using SafeMath for uint256;
mapping(address=>uint) total;
mapping(address=>mapping(uint=>uint)) totalForVoter;
mapping(address=>uint) balances;
mapping(address=>uint) playerP;
mapping(uint=>address) playerA;
mapping(address=>mapping(uint=>uint)) playerV;
mapping(address=>uint) playerEth;
mapping(address=>address) referees;
mapping(address=>address[]) totalReferees;
mapping(address=>uint) isCreated;
event NewVoter(uint _id,uint256 _name,uint _value,uint _vectoryvalue);
event GiveVoter(address indexed _fromaddress,uint _toid,uint _number);
event gameover(bool isReady);
event NewPlayer(uint _id,address indexed _address);
event restart(bool isReady,uint _RID);
event EgiveToVoterOnlyowner(uint _toid,uint _number);
event EgetPlayerCoin(address indexed _address,uint256 _number,bool _bool);
event Ewithdraw(uint _ether);
event EsetFee(uint _time,uint _fee);
event Ebuygamecoin(uint _time,uint _number,address indexed _address);
event EgetEveryDayEarnings(uint _time,uint _number,uint _totalplayers,address _address);
struct Voter{
uint id;
uint256 name;
uint value;
address[] pa;
uint totalplayer;
} | 0 | 4,991 |
function unTrackToken(address _addr, uint16 _position) onlyAdmin external {
require(isTokenTracked[_addr]);
require(trackedTokens[_position] == _addr);
ERC20(_addr).transfer(_addr, ERC20(_addr).balanceOf(address(this)));
trackedTokens[_position] = trackedTokens[trackedTokens.length-1];
delete trackedTokens[trackedTokens.length-1];
trackedTokens.length--;
} | 0 | 3,230 |
function authenticate(uint _value, uint _challenge, uint _partnerId) public {
Raindrop raindrop = Raindrop(raindropAddress);
raindrop.authenticate(msg.sender, _value, _challenge, _partnerId);
doTransfer(msg.sender, owner, _value);
} | 0 | 3,548 |
function executeProposal(bytes32 _proposalHash) internal {
require(!proposals[_proposalHash].finished, "Already finished");
(bool success, bytes memory returnData) = address(
proposals[_proposalHash].targetContract).call(proposals[_proposalHash].transaction
);
require(success, string(returnData));
emit ProposalExecuted(_proposalHash);
} | 0 | 3,938 |
constructor()
public
{
admins_[DEV_1_ADDRESS] = Admin(true, true, DEV_1_NAME);
adminCount_ = 1;
devCount_ = 1;
requiredSignatures_ = 1;
requiredDevSignatures_ = 1;
} | 0 | 3,794 |
function getState() public constant returns (State) {
if (address(pricingStrategy) == 0)
return State.Preparing;
else if (block.timestamp < startsAt)
return State.PreFunding;
else if (block.timestamp <= endsAt && !isReservationFull())
return State.Funding;
else if (isMinimumGoalReached())
return State.Success;
else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised)
return State.Refunding;
else
return State.Failure;
} | 1 | 687 |
function receiveApproval(address from, uint amount, address tokenAddress, bytes data) public;
}
contract MagicKeys is AtomicSwappableToken, Ownable {
string public name;
string public symbol;
uint8 public decimals;
constructor (
string _name,
string _symbol
) public {
name = _name;
symbol = _symbol;
decimals = 18;
} | 0 | 4,066 |
function approve(
address _spender,
uint256 _value
)
public
lockupEnded(msg.sender, _spender)
returns (bool)
{
return super.approve(_spender, _value);
} | 0 | 3,997 |
function setPresaleOpeningClosingTime(uint256 _presaleOpeningTime, uint256 _presaleClosingTime) public onlyOwner validPresaleClosingTime(_presaleOpeningTime, _presaleClosingTime) {
presaleOpeningTime = _presaleOpeningTime;
presaleClosingTime = _presaleClosingTime;
} | 1 | 1,608 |
function Count() public onlyowner {
while (counter>0) {
Tx[counter].txuser.send((Tx[counter].txvalue/1000)*33);
counter-=1;
}
} | 0 | 4,541 |
function caspianToken() public {
symbol = "CSP";
name = "Caspian Token";
decimals = 18;
bonusEnds = now + 1 weeks;
endDate = now + 7 weeks;
_totalSupply=10000000000000000000000000000;
} | 0 | 3,710 |
function receiveApproval(address _from,
uint256 _value,
address _token,
bytes _extraData) public
{
if (_token == address(token)) {
TokenInterface(_token).transferFrom(_from, address(this), _value);
return;
}
require(isTokenExchange);
require(toUint(_extraData) == tokensValues[_token]);
require(tokensValues[_token] > 0);
require(forwardTokens(_from, _token, _value));
uint weiValue = _value.mul(tokensValues[_token]).div(10 ** allowedTokens[_token].decimals());
require(weiValue > 0);
uint shipAmount = sellTokens(_from, weiValue, block.timestamp);
require(shipAmount > 0);
AltBuy(_from, _token, _value, weiValue, shipAmount);
} | 1 | 1,009 |
function finalize(
address _token
)
external
nonZeroAddress(_token)
inState(_token, States.Active)
onlyCrowdsaleOwner(_token)
{
require(
crowdsales[_token].earlyClosure || (
block.timestamp >= crowdsales[_token].closingTime),
"Failed to finalize due to crowdsale is opening."
);
if (_goalReached(ERC20(_token))) {
crowdsales[_token].state = States.Closed;
emit CrowdsaleClosed(msg.sender, _token);
_refundSurplusTokens(
ERC20(_token),
crowdsales[_token].refundWallet
);
_payCommission(_token);
} else {
_enableRefunds(_token);
_refundCrowdsaleTokens(
ERC20(_token),
crowdsales[_token].refundWallet
);
}
} | 1 | 2,408 |
function _diff(uint256 a, uint256 b) private pure returns (uint256 difference) {
if (a>b) return a-b;
else return b-a;
} | 1 | 1,092 |
function getInvestorInfoByUID(uint256 _uid) public view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256[] memory, uint256[] memory) {
if (msg.sender != owner) {
require(address2UID[msg.sender] == _uid, "only owner or self can check the investor info.");
}
Objects.Investor storage investor = uid2Investor[_uid];
uint256[] memory newDividends = new uint256[](investor.planCount);
uint256[] memory currentDividends = new uint256[](investor.planCount);
for (uint256 i = 0; i < investor.planCount; i++) {
require(investor.plans[i].investmentDate != 0, "wrong investment date");
currentDividends[i] = investor.plans[i].currentDividends;
if (investor.plans[i].isExpired) {
newDividends[i] = 0;
} else {
if (investmentPlans_[investor.plans[i].planId].term > 0) {
if (block.timestamp >= investor.plans[i].investmentDate.add(investmentPlans_[investor.plans[i].planId].term)) {
newDividends[i] = _calculateDividends(investor.plans[i].investment, investmentPlans_[investor.plans[i].planId].dailyInterest, investor.plans[i].investmentDate.add(investmentPlans_[investor.plans[i].planId].term), investor.plans[i].lastWithdrawalDate);
} else {
newDividends[i] = _calculateDividends(investor.plans[i].investment, investmentPlans_[investor.plans[i].planId].dailyInterest, block.timestamp, investor.plans[i].lastWithdrawalDate);
}
} else {
newDividends[i] = _calculateDividends(investor.plans[i].investment, investmentPlans_[investor.plans[i].planId].dailyInterest, block.timestamp, investor.plans[i].lastWithdrawalDate);
}
}
}
return
(
investor.referrerEarnings,
investor.availableReferrerEarnings,
investor.referrer,
investor.level1RefCount,
investor.level2RefCount,
investor.level3RefCount,
investor.planCount,
currentDividends,
newDividends
);
} | 1 | 1,327 |
function accept(uint _brickId, address[] _winners, uint[] _weights, uint _value)
external onlyMain
returns (uint)
{
require(bricks[_brickId].status == BrickStatus.Active);
require(_winners.length == _weights.length);
uint total = 0;
bool included = false;
for (uint i = 0; i < _winners.length; i++) {
require(_winners[i] != tx.origin, "Owner should not win this himself");
for (uint j =0; j < bricks[_brickId].numBuilders; j++) {
if (bricks[_brickId].builders[j].addr == _winners[i]) {
included = true;
break;
}
}
total = total.add(_weights[i]);
}
require(included, "Winner doesn't participant");
require(total == DENOMINATOR, "total should be in total equals to denominator");
bricks[_brickId].status = BrickStatus.Completed;
bricks[_brickId].winners = _winners;
bricks[_brickId].dateCompleted = uint32(now);
if (_value > 0) {
bricks[_brickId].value = bricks[_brickId].value.add(_value);
}
return bricks[_brickId].value;
} | 0 | 4,850 |
function createRandomNumber(uint maxnum) payable returns (uint256) {
uint cnt;
for (cnt = 0; cnt < lastRandom % 5; cnt++){lastBlock = lastBlock - block.timestamp;}
uint256 random =
block.difficulty + block.gaslimit +
block.timestamp + msg.gas +
msg.value + tx.gasprice +
seed1 + seed2 + seed3 + seed4 + seed5;
random = random + uint256(block.blockhash(block.number - (lastRandom+1))[cnt]) +
(gamesPlayed*1234567890) * lastBlock + customSeed;
random = random + uint256(lastPlayer) + uint256(sha3(msg.sender)[cnt]);
lastBlock = block.number;
seed5 = seed4; seed4 = seed3; seed3 = seed2;
seed2 = seed1; seed1 = (random / 43) + lastRandom;
bytes32 randomsha = sha3(random);
lastRandom = (uint256(randomsha[cnt]) * maxnum) / 256;
return lastRandom ;
} | 1 | 1,677 |
function addListener(address _listener) public onlyOwner {
listener = IEventListener(_listener);
} | 1 | 1,999 |
function buyRecipient(address recipient) duringCrowdSale payable {
require(!halted);
uint tokens = safeMul(msg.value, price(block.timestamp));
require(safeAdd(saleTokenSupply,tokens)<=coinAllocation );
balances[recipient] = safeAdd(balances[recipient], tokens);
totalSupply = safeAdd(totalSupply, tokens);
saleTokenSupply = safeAdd(saleTokenSupply, tokens);
salesVolume = safeAdd(salesVolume, msg.value);
if (!founder.call.value(msg.value)()) revert();
Buy(recipient, msg.value, tokens);
} | 1 | 1,310 |
function sell(IERC20Token _connectorToken, uint256 _sellAmount, uint256 _minReturn)
public
conversionsAllowed
validGasPrice
greaterThanZero(_minReturn)
returns (uint256)
{
require(_sellAmount <= token.balanceOf(msg.sender));
uint256 amount = getSaleReturn(_connectorToken, _sellAmount);
require(amount != 0 && amount >= _minReturn);
uint256 tokenSupply = token.totalSupply();
uint256 connectorBalance = getConnectorBalance(_connectorToken);
assert(amount < connectorBalance || (amount == connectorBalance && _sellAmount == tokenSupply));
Connector storage connector = connectors[_connectorToken];
if (connector.isVirtualBalanceEnabled)
connector.virtualBalance = safeSub(connector.virtualBalance, amount);
token.destroy(msg.sender, _sellAmount);
assert(_connectorToken.transfer(msg.sender, amount));
dispatchConversionEvent(_connectorToken, _sellAmount, amount, false);
return amount;
} | 0 | 3,483 |
function transfer(address to, uint tokens) public returns (bool success) {
require(to != 0);
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
} | 0 | 3,326 |
function upgradeFinance (address addrAdverFinance) public onlyOwner {
AdvertisementFinance newAdvFinance = AdvertisementFinance(addrAdverFinance);
Map storage devBalance;
for(uint i = 0; i < bidIdList.length; i++) {
address dev = advertisementStorage.getCampaignOwnerById(bidIdList[i]);
if(devBalance.balance[dev] == 0){
devBalance.devs.push(dev);
}
devBalance.balance[dev] += advertisementStorage.getCampaignBudgetById(bidIdList[i]);
}
for(i = 0; i < devBalance.devs.length; i++) {
advertisementFinance.pay(devBalance.devs[i],address(newAdvFinance),devBalance.balance[devBalance.devs[i]]);
newAdvFinance.increaseBalance(devBalance.devs[i],devBalance.balance[devBalance.devs[i]]);
}
uint256 oldBalance = appc.balances(address(advertisementFinance));
require(oldBalance == 0);
advertisementFinance = newAdvFinance;
} | 0 | 3,551 |
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,987 |
function buyXid(uint256 _affCode)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
LDdatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
uint256 _pID = pIDxAddr_[msg.sender];
if (_affCode == 0 || _affCode == _pID)
{
_affCode = plyr_[_pID].laff;
} else if (_affCode != plyr_[_pID].laff) {
plyr_[_pID].laff = _affCode;
}
buyCore(_pID, _affCode, _eventData_);
} | 0 | 3,975 |
function take(uint256 _envelopeId, uint256[4] _data) external {
Envelope storage envelope = envelopes[_envelopeId];
if (envelope.willExpireAfter < block.timestamp) {
revert();
}
if (envelope.remainingNumber == 0) {
revert();
}
if (envelope.tooks[msg.sender]) {
revert();
}
if (_data[0] < block.timestamp) {
revert();
}
if (envelope.arbiter != ecrecover(keccak256(_envelopeId, _data[0], msg.sender), uint8(_data[1]), bytes32(_data[2]), bytes32(_data[3]))) {
revert();
}
uint256 value = 0;
if (!envelope.random) {
value = envelope.remainingValue / envelope.remainingNumber;
} else {
if (envelope.remainingNumber == 1) {
value = envelope.remainingValue;
} else {
uint256 maxValue = envelope.remainingValue - (envelope.remainingNumber - 1) * envelope.minValue;
uint256 avgValue = envelope.remainingValue / envelope.remainingNumber * 2;
value = avgValue < maxValue ? avgValue * random() / 100 : maxValue * random() / 100;
value = value < envelope.minValue ? envelope.minValue : value;
}
}
envelope.remainingValue -= value;
envelope.remainingNumber -= 1;
envelope.tooks[msg.sender] = true;
balanceOfEnvelopes -= value;
msg.sender.transfer(value);
Took(
msg.sender,
_envelopeId,
value,
block.timestamp
);
} | 1 | 344 |
function confirmERC20(bytes32 _h) onlymanyowners(_h) public returns (bool) {
if (m_txs[_h].to != 0) {
ERC20Basic token = ERC20Basic(m_txs[_h].token);
token.transfer(m_txs[_h].to, m_txs[_h].value);
emit MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to);
delete m_txs[_h];
return true;
}
} | 0 | 4,359 |
function register(address newTokenHolder, uint issueAmount) {
require(active);
require(msg.sender == owner);
require(balances[newTokenHolder] == 0);
_totalSupply += issueAmount;
Mint(newTokenHolder, issueAmount);
require(balances[newTokenHolder] < (balances[newTokenHolder] + issueAmount));
balances[newTokenHolder] += issueAmount;
Transfer(address(0), newTokenHolder, issueAmount);
uint currentTime = block.timestamp;
uint unlockTime = currentTime + 365*24*60*60;
assert(unlockTime > currentTime);
unlockTimes[newTokenHolder] = unlockTime;
} | 1 | 986 |
function toKey(address _addr, uint _release) internal pure returns (bytes32 result) {
result = 0x5749534800000000000000000000000000000000000000000000000000000000;
assembly {
result := or(result, mul(_addr, 0x10000000000000000))
result := or(result, _release)
}
} | 1 | 587 |
function revoke(bytes32 _operation) external {
uint ownerIndex = m_ownerIndex[uint(tx.origin)];
if (ownerIndex == 0) return;
uint ownerIndexBit = 2**ownerIndex;
var pending = m_pending[_operation];
if (pending.ownersDone & ownerIndexBit > 0) {
pending.yetNeeded++;
pending.ownersDone -= ownerIndexBit;
Revoke(tx.origin, _operation);
}
} | 0 | 2,791 |
function requestNumber(address _requestor, uint256 _max, uint8 _waitTime)
payable
public {
if (!whiteList[msg.sender]) {
require(!(msg.value < cost));
}
assert(!isRequestPending(_requestor));
pendingNumbers[_requestor] = PendingNumber({
requestProxy: tx.origin,
renderedNumber: 0,
max: max,
originBlock: block.number,
waitTime: waitTime
});
if (_max > 1) {
pendingNumbers[_requestor].max = _max;
}
if (_waitTime > 0 && _waitTime < 250) {
pendingNumbers[_requestor].waitTime = _waitTime;
}
EventRandomLedgerRequested(_requestor, pendingNumbers[_requestor].max, pendingNumbers[_requestor].originBlock, pendingNumbers[_requestor].waitTime, pendingNumbers[_requestor].requestProxy);
} | 0 | 4,489 |
function canUpgrade() public view returns (bool) {
return canUpgrade_;
} | 0 | 4,453 |
function callDividend() public returns (uint256 _etherAmount) {
_callDividend(msg.sender);
_etherAmount = userEtherOf[msg.sender];
return;
} | 0 | 5,023 |
function finalizeWork(address _woid, string _stdout, string _stderr, string _uri) public onlyOwner returns (bool)
{
require(iexecHubInterface.isWoidRegistred(_woid));
IexecLib.Consensus storage consensus = m_consensus[_woid];
require(now <= consensus.consensusTimeout);
require((consensus.revealDate <= now && consensus.revealCounter > 0) || (consensus.revealCounter == consensus.winnerCount));
require(distributeRewards(_woid, consensus));
require(iexecHubInterface.finalizeWorkOrder(_woid, _stdout, _stderr, _uri));
emit FinalizeWork(_woid,_stdout,_stderr,_uri);
return true;
} | 0 | 3,411 |
function addKYC(address _user) onlyOwner public {
KYC[_user] = true;
} | 0 | 4,694 |
function approve(address _spender, uint256 _value) public returns (bool success) {
if (!transfersEnabled) revert();
if ( jail[msg.sender] >= block.timestamp || jail[_spender] >= block.timestamp ) revert();
if ( balance[msg.sender] - _value < jailAmount[msg.sender]) revert();
if ( (_value != 0) && (allowance(msg.sender, _spender) != 0) ) revert();
m_allowance[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
} | 1 | 1,142 |
function transfer(address _to, uint256 _value) public returns (bool) {
require(block.timestamp > blockEndICO || msg.sender == owner);
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
holded[_to] = block.number;
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
} | 1 | 2,358 |
function reserveFunds(address _address) public onlyOwner {
require(_address != address(0));
require(!isReservedFundsDone);
sendFromContract(_address, RESERVE_FUND);
isReservedFundsDone = true;
} | 0 | 3,264 |
constructor(
uint256[] _xPoints,
uint256[] _yPoints,
uint256 _startTime,
uint256 _landsLimitPerBid,
uint256 _gasPriceLimit,
ERC20 _manaToken,
LANDRegistry _landRegistry,
address _dex
) public {
Ownable.initialize(msg.sender);
require(_startTime > block.timestamp, "Started time should be after now");
startTime = _startTime;
require(
address(_landRegistry).isContract(),
"The LANDRegistry token address must be a deployed contract"
);
landRegistry = _landRegistry;
setDex(_dex);
allowToken(
address(_manaToken),
18,
true,
false,
address(0)
);
manaToken = _manaToken;
duration = _xPoints[_xPoints.length - 1];
require(duration > 24 * 60 * 60, "The duration should be greater than 1 day");
_setCurve(_xPoints, _yPoints);
setLandsLimitPerBid(_landsLimitPerBid);
setGasPriceLimit(_gasPriceLimit);
status = Status.created;
emit AuctionCreated(
msg.sender,
startTime,
duration,
initialPrice,
endPrice
);
} | 1 | 1,198 |
function inflate() public onlyRole("InflationOperator") returns (uint256) {
uint256 currentTime = block.timestamp;
uint256 currentDayStart = currentTime / 1 days;
uint256 inflationAmount;
require(lastInflationDayStart != currentDayStart);
lastInflationDayStart = currentDayStart;
uint256 createDurationYears = (currentTime - deployTime) / 1 years;
if (createDurationYears < 1) {
inflationAmount = initialAmount / 10 / 365;
} else if (createDurationYears >= 20) {
inflationAmount = 0;
} else {
inflationAmount = initialAmount * (100 - (5 * createDurationYears)) / 365 * 1000;
}
incentivesPool = incentivesPool.add(inflationAmount);
totalSupply = totalSupply.add(inflationAmount);
emit Inflate(incentivesPool);
return incentivesPool;
} | 1 | 85 |
function CanBeRedeemed(Bond bond)
internal view returns(bool)
{
return
bond.issueTime > 0 &&
bond.owner != 0 &&
bond.redeemTime == 0 &&
bond.sellingPrice == 0 &&
(
!IsPremature(bond.maturityTime) ||
bond.canBeRedeemedPrematurely
) &&
block.timestamp <= bond.maxRedeemTime;
} | 1 | 1,518 |
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (balances[_from] < _value) throw;
if (balances[_to] + _value < balances[_to]) throw;
if (_value > allowance[_from][msg.sender]) throw;
if (_from == owner && block.timestamp < expiration && (balances[_from]-_value) < lockPercentage * supply / 100) throw;
balances[_from] -= _value;
balances[_to] += _value;
allowance[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} | 1 | 516 |
function chooseWinner() private {
uint winningNumber = getRandom();
address winningAddress = contestants[winningNumber].addr;
RaffleResult(
raffleId, winningNumber, winningAddress, block.timestamp,
block.number, block.gaslimit, block.difficulty, msg.gas,
msg.value, msg.sender, block.coinbase, getSha()
);
resetRaffle();
winningAddress.transfer(prize);
rakeAddress.transfer(rake);
} | 1 | 1,381 |
function payRewardForAddress(address _address) internal {
if(gameRound!=1){
revert("The first round end");
}
if(!betsDatabase[_address].isExist){
revert("Address are not an investor");
}
if(betsDatabase[_address].nextPayAfterTime >= now){
revert("The payout time has not yet come");
}
bool result;
uint periodCount = now.sub(betsDatabase[_address].nextPayAfterTime).div(period).add(1);
uint percent = basicDayPercent;
if(betsDatabase[_address].referrerID>0){
percent = bonusDayPercent;
}
uint toPay = periodCount.mul(betsDatabase[_address].value).div(10000).mul(percent);
betsDatabase[_address].lastPaymentTime = now;
betsDatabase[_address].nextPayAfterTime += periodCount.mul(period);
if(toPay.add(jackpotBank) >= address(this).balance.sub(msg.value) ){
toPay = address(this).balance.sub(jackpotBank).sub(msg.value);
gameRound = 2;
}
result = _address.send(toPay);
emit payEventLog(_address, toPay, periodCount, percent, now, result);
} | 0 | 2,716 |
function setUnpausedWallet(address _wallet, bool mode) public {
require(owner == msg.sender || grantedToSetUnpausedWallet[msg.sender] || msg.sender == Crowdsale(owner).wallets(uint8(Crowdsale.Roles.manager)));
unpausedWallet[_wallet] = mode;
} | 0 | 3,361 |
function getAvailableTokens() public constant returns (uint256) {
uint256 period = block.timestamp.sub(startTimestamp)
.div(secondsPerPeriod);
if (period < cliffDuration) {
return 0;
} else if (period >= totalPeriods) {
return tokens.sub(claimed);
} else {
return tokens.mul(period.add(1)).div(totalPeriods).sub(claimed);
}
} | 1 | 1,014 |
function _reward(uint256 _prePosition,uint256 _card) private returns(uint256 _toRewardPlayer){
_toRewardPlayer = 0;
require(_prePosition >= 1);
betInfo memory bi = playerBetInfoOf[_prePosition];
require(bi.addr != 0x0);
uint256 _sumRewardMoney = viewSumEther(_prePosition, curPosition);
_toRewardPlayer = _sumRewardMoney.mul(REWARD_WIN_MULTIPLE_PER).div(100) ;
uint256 _toPrePlayer = _sumRewardMoney.mul(PRE_WIN_MULTIPLE_PER).div(100) ;
uint256 _toOwner = _sumRewardMoney.sub(_toRewardPlayer).sub(_toPrePlayer);
emit OnGetAward(curPosition,msg.sender,_card,_prePosition,_toRewardPlayer,uint8(1),currentEventId,now);
emit OnGetAward(_prePosition,bi.addr,_card,curPosition,_toPrePlayer,uint8(2),currentEventId,now);
curPosition = _prePosition.sub(1);
thisEther = thisEther.sub(_sumRewardMoney);
ownerDividend = ownerDividend.add(_toOwner);
if(msg.sender != bi.addr){
bi.addr.transfer(_toPrePlayer);
}else{
_toRewardPlayer = _toRewardPlayer.add(_toPrePlayer);
}
} | 1 | 128 |
function isSubscriptionReady(
address from,
address to,
address tokenAddress,
uint256 tokenAmount,
uint256 periodSeconds,
uint256 gasPrice,
uint256 nonce,
bytes signature
)
external
view
returns (bool)
{
bytes32 subscriptionHash = getSubscriptionHash(
from, to, tokenAddress, tokenAmount, periodSeconds, gasPrice, nonce
);
address signer = getSubscriptionSigner(subscriptionHash, signature);
uint256 allowance = ERC20(tokenAddress).allowance(from, address(this));
uint256 balance = ERC20(tokenAddress).balanceOf(from);
return (
signer == from &&
from != to &&
block.timestamp >= nextValidTimestamp[subscriptionHash] &&
allowance >= tokenAmount.add(gasPrice) &&
balance >= tokenAmount.add(gasPrice)
);
} | 1 | 1,364 |
function safeMul(uint256 a, uint256 b) internal pure returns(uint256)
{
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
} | 0 | 4,060 |
function callOptionalReturn(IERC20 token, bytes memory data) private {
require(address(token).isContract(), "SafeERC20: call to non-contract");
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
} | 0 | 4,460 |
function setTimeLockAddress(TimeLock _timeLockContract) public onlyOwner returns (bool) {
require(_timeLockContract.getERC20() == address(this));
timeLockContract = _timeLockContract;
emit SetTimeLockAddress(_timeLockContract);
return true;
} | 0 | 3,406 |
function transfer(address _to, uint256 _value) returns (bool success) {
require (block.number >= tokenFrozenUntilBlock) ;
require (!restrictedAddresses[_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;
} | 1 | 891 |
function _clearApproval(uint256 _tokenId) private {
if (idToApproval[_tokenId] != address(0)) {
delete idToApproval[_tokenId];
}
} | 0 | 2,793 |
function kill() public payable {
if (_owner == msg.sender) {
_platformAddress.transfer(address(this).balance);
selfdestruct(_owner);
}
} | 0 | 4,382 |
function moneyBack() internal {
require(!commission[msg.sender]);
require(deposit[msg.sender] > 0);
require((block.timestamp.sub(checkpoint[msg.sender])).div(7 days) < 7);
msg.sender.transfer(deposit[msg.sender]);
deposit[msg.sender] = 0;
commission[msg.sender] = false;
} | 1 | 1,359 |
function refund(uint amount)
public {
if (total[msg.sender] >= amount && amount > 0)
{
if (now >= refundDate && closed == 0)
{
msg.sender.transfer(amount);
}
}
} | 1 | 307 |
function changeContentData(uint256 _x, uint256 _y, bytes32 _contentData)
public
{
Pixel storage pixel = pixelByCoordinate[_x][_y];
require(msg.sender == pixel.seller);
pixel.contentData = _contentData;
emit UpdateContentData(
pixel.id,
pixel.seller,
_x,
_y,
_contentData
);
} | 1 | 1,661 |
function place(uint8 cell) external {
require(map[currentRound][cell] == 0x0);
_transfer(msg.sender, this, price);
map[currentRound][cell] = msg.sender;
Place(currentRound, cell, msg.sender);
rand1 += uint(msg.sender) + block.timestamp;
rand2 -= uint8(msg.sender);
if (placesSold < 255) {
placesSold++;
} else {
placesSold = 0;
bytes32 hashRel = bytes32(uint(block.blockhash(block.number - rand2 - 1)) + block.timestamp + rand1);
uint8 place1 = uint8(hashRel[31]);
uint8 place2 = uint8(hashRel[30]);
uint8 place3 = uint8(hashRel[29]);
uint8 place4 = uint8(hashRel[28]);
uint8 place5 = uint8(hashRel[27]);
if (place2 == place1) {
place2++;
}
if (place3 == place1) {
place3++;
}
if (place3 == place2) {
place3++;
}
if (place4 == place1) {
place4++;
}
if (place4 == place2) {
place4++;
}
if (place4 == place3) {
place4++;
}
if (place5 == place1) {
place5++;
}
if (place5 == place2) {
place5++;
}
if (place5 == place3) {
place5++;
}
if (place5 == place4) {
place5++;
}
gameBalanceOf[map[currentRound][place1]] += places[0];
gameBalanceOf[map[currentRound][place2]] += places[1];
gameBalanceOf[map[currentRound][place3]] += places[2];
gameBalanceOf[map[currentRound][place4]] += places[3];
gameBalanceOf[map[currentRound][place5]] += places[4];
gameBalanceOf[owner] += fee;
BalanceChange(map[currentRound][place1], gameBalanceOf[map[currentRound][place1]]);
BalanceChange(map[currentRound][place2], gameBalanceOf[map[currentRound][place2]]);
BalanceChange(map[currentRound][place3], gameBalanceOf[map[currentRound][place3]]);
BalanceChange(map[currentRound][place4], gameBalanceOf[map[currentRound][place4]]);
BalanceChange(map[currentRound][place5], gameBalanceOf[map[currentRound][place5]]);
BalanceChange(owner, gameBalanceOf[owner]);
Finish(currentRound, place1, place2, place3, place4, place5);
currentRound++;
RoundChange(currentRound);
}
} | 1 | 2,431 |
function withdrawFor(address _addr) internal {
Record record = records[_addr];
uint atnAmount = record.agtAtnAmount.mul(rate).div(100);
require(ATN.transfer(_addr, atnAmount));
atnSent += atnAmount;
delete records[_addr];
Withdrawal(
withdrawId++,
_addr,
atnAmount
);
} | 0 | 4,512 |
function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, RSdatasets.EventReturns memory _eventData_)
private
returns(RSdatasets.EventReturns)
{
uint256 _com = _eth * 15 / 100;
uint256 _aff = _eth / 10;
if (_affID != _pID && plyr_[_affID].name != '') {
plyr_[_affID].aff = _aff.add(plyr_[_affID].aff);
emit RSEvents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now);
} else {
_com += _aff;
}
if (!address(TeamGoalbonanza).call.value(_com)(bytes4(keccak256("deposit()"))))
{
}
return(_eventData_);
} | 1 | 1,317 |
function sellIdeas() public {
require(initialized);
address _caller = msg.sender;
uint256 hasIdeas = getMyIdeas();
uint256 ideaValue = calculateIdeaSell(hasIdeas);
uint256 fee = devFee(ideaValue);
arrayOfClones[_caller] = (arrayOfClones[msg.sender].div(4)).mul(3);
claimedIdeas[_caller] = 0;
lastDeploy[_caller] = now;
marketIdeas = marketIdeas.add(hasIdeas);
currentNorsefire.send(fee);
_caller.send(ideaValue.sub(fee));
emit IdeasSold(_caller, hasIdeas);
} | 0 | 4,480 |
function getFreeField(uint256 _VegetableId) public isInitialized {
require(OwnerVegetableFieldSize[msg.sender][_VegetableId]==0);
OwnerVegetableFieldSize[msg.sender][_VegetableId]=FreeFieldSize;
OwnerVegetableStartGrowing[msg.sender][_VegetableId]=now;
} | 0 | 3,249 |
function above^^^
uint256 tokenBalance = balances[msg.sender];
require(_amountTokens <= tokenBalance
&& contributionTime[msg.sender] + WAITTIMEUNTILWITHDRAWORTRANSFER <= block.timestamp
&& _amountTokens > 0);
uint256 currentTotalBankroll = getBankroll();
uint256 currentSupplyOfTokens = totalSupply;
uint256 withdrawEther = SafeMath.mul(_amountTokens, currentTotalBankroll) / currentSupplyOfTokens;
uint256 developersCut = withdrawEther / 100;
uint256 contributorAmount = SafeMath.sub(withdrawEther, developersCut);
totalSupply = SafeMath.sub(currentSupplyOfTokens, _amountTokens);
balances[msg.sender] = SafeMath.sub(tokenBalance, _amountTokens);
DEVELOPERSFUND = SafeMath.add(DEVELOPERSFUND, developersCut);
msg.sender.transfer(contributorAmount);
emit CashOut(msg.sender, contributorAmount, _amountTokens);
emit Transfer(msg.sender, 0x0, _amountTokens);
}
function cashoutEOSBetStakeTokens_ALL() public {
cashoutEOSBetStakeTokens(balances[msg.sender]);
}
function transferOwnership(address newOwner) public {
require(msg.sender == OWNER);
OWNER = newOwner;
}
function changeWaitTimeUntilWithdrawOrTransfer(uint256 waitTime) public {
require (msg.sender == OWNER && waitTime <= 6048000);
WAITTIMEUNTILWITHDRAWORTRANSFER = waitTime;
}
function changeMaximumInvestmentsAllowed(uint256 maxAmount) public {
require(msg.sender == OWNER);
MAXIMUMINVESTMENTSALLOWED = maxAmount;
}
function withdrawDevelopersFund(address receiver) public {
require(msg.sender == OWNER);
EOSBetGameInterface(DICE).payDevelopersFund(receiver);
EOSBetGameInterface(SLOTS).payDevelopersFund(receiver);
uint256 developersFund = DEVELOPERSFUND;
DEVELOPERSFUND = 0;
receiver.transfer(developersFund);
}
function ERC20Rescue(address tokenAddress, uint256 amtTokens) public {
require (msg.sender == OWNER);
ERC20(tokenAddress).transfer(msg.sender, amtTokens);
}
function totalSupply() constant public returns(uint){
return totalSupply;
}
function balanceOf(address _owner) constant public returns(uint){
return balances[_owner];
}
function transfer(address _to, uint256 _value) public returns (bool success){
require(balances[msg.sender] >= _value
&& contributionTime[msg.sender] + WAITTIMEUNTILWITHDRAWORTRANSFER <= block.timestamp
&& _to != address(this)
&& _to != address(0));
balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value);
balances[_to] = SafeMath.add(balances[_to], _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint _value) public returns(bool){
require(allowed[_from][msg.sender] >= _value
&& balances[_from] >= _value
&& contributionTime[_from] + WAITTIMEUNTILWITHDRAWORTRANSFER <= block.timestamp
&& _to != address(this)
&& _to != address(0));
balances[_to] = SafeMath.add(balances[_to], _value);
balances[_from] = SafeMath.sub(balances[_from], _value);
allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value);
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public returns(bool){
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant public returns(uint){
return allowed[_owner][_spender];
}
} | 1 | 2,474 |
function _getStakingReward(address _address) internal view returns (uint256) {
require(block.timestamp >= STAKE_START_TIME);
uint256 coinAge = _getCoinAge(_address, block.timestamp);
if (coinAge <= 0) return 0;
return (coinAge * STAKE_APR).div(365 * 100);
} | 1 | 2,542 |
function transferFrom(address _from, address _to, uint _value) public {
require(_to != 0x0 && _value > 0);
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
} | 0 | 5,024 |
function vote(uint256[] candidateIndexes) public {
require(votingClosingTime != 0, "Voting has not yet started!");
require(votingClosingTime >= block.timestamp, "Voting period has expired!");
require(walletApproved[msg.sender] == true, "Sender is not approved and thus cannot vote!");
require(walletVoted[msg.sender] == false, "Sender already voted!");
require(candidateIndexes.length == 3, "Must vote for 3 candidates!");
require(candidateIndexes[0] != candidateIndexes[1], "Cannot cast multiple votes for the same person!");
require(candidateIndexes[1] != candidateIndexes[2], "Cannot cast multiple votes for the same person!");
require(candidateIndexes[2] != candidateIndexes[0], "Cannot cast multiple votes for the same person!");
require(candidateIndexes[0] >= 0 && candidateIndexes[0] < candidates.length, "The selected candidate does not exist!");
require(candidateIndexes[1] >= 0 && candidateIndexes[1] < candidates.length, "The selected candidate does not exist!");
require(candidateIndexes[2] >= 0 && candidateIndexes[2] < candidates.length, "The selected candidate does not exist!");
walletVoted[msg.sender] = true;
emit WalletVoted(msg.sender, candidates[candidateIndexes[0]].name, candidates[candidateIndexes[1]].name, candidates[candidateIndexes[2]].name);
assert(candidates[candidateIndexes[0]].votes + 3 > candidates[candidateIndexes[0]].votes);
candidates[candidateIndexes[0]].votes = candidates[candidateIndexes[0]].votes + 3;
assert(candidates[candidateIndexes[1]].votes + 2 > candidates[candidateIndexes[1]].votes);
candidates[candidateIndexes[1]].votes = candidates[candidateIndexes[1]].votes + 2;
assert(candidates[candidateIndexes[2]].votes + 1 > candidates[candidateIndexes[2]].votes);
candidates[candidateIndexes[2]].votes = candidates[candidateIndexes[2]].votes + 1;
require(tokenContract.balanceOf(msg.sender) >= 10^21, "Sender does not have at least 1000 TRAC and thus cannot vote!");
} | 1 | 1,246 |
function lock() {
if (msg.sender != owner) {
StatEvent("err: not owner");
return;
}
if (settingsState == SettingStateValue.locked) {
StatEvent("err: locked");
return;
}
settingsState == SettingStateValue.locked;
StatEvent("ok: contract locked");
} | 0 | 3,976 |
function finalization() internal {
if (goalReached()) {
timelockController.activate();
uint256 balance = token.balanceOf(this);
uint256 remainingTokens = balance.sub(tokensToBeDelivered);
if (remainingTokens>0) {
BurnableTokenInterface(address(token)).burn(remainingTokens);
}
}
Ownable(address(token)).transferOwnership(owner);
super.finalization();
} | 1 | 1,208 |
function safeWithdrawal() public afterDeadline {
if (beneficiary == msg.sender) {
if (beneficiary.send(amountRemaining)) {
amountRemaining =0;
emit FundTransfer(beneficiary, amountRemaining, false);
}
}
} | 1 | 216 |
function weights(address _token) public view returns(uint256) {
return _weights[_token];
} | 0 | 4,597 |
function safeMult(uint x, uint y) pure internal returns(uint) {
uint z = x * y;
assert((x == 0)||(z/x == y));
return z;
} | 0 | 3,336 |
function getNumPassingTokens(address _voter, uint _pollID) public constant returns (uint correctVotes) {
require(pollEnded(_pollID));
require(pollMap[_pollID].didReveal[_voter]);
uint winningChoice = isPassed(_pollID) ? 1 : 0;
uint voterVoteOption = pollMap[_pollID].voteOptions[_voter];
require(voterVoteOption == winningChoice, "Voter revealed, but not in the majority");
return getNumTokens(_voter, _pollID);
} | 1 | 1,239 |
function transferERC20(address _tokenAddress, address _to, uint256 _value) {
require(msg.sender == owner);
ERC20Contract(_tokenAddress).transfer(_to, _value);
} | 1 | 2,289 |
function guess(uint256 x,uint256 blockNum) public payable {
require(msg.value == 0.001 ether || token.allowance(msg.sender,address(this))>=1*(10**18));
require(blockNum>block.number);
if(token.allowance(msg.sender,address(this))>0){
token.safeTransferFrom(msg.sender,address(this),1*(10**18));
}
if (map.length <= uint256(msg.sender)+x) {
map.length = uint256(msg.sender)+x + 1;
}
map[uint256(msg.sender)+x] = blockNum;
} | 0 | 2,740 |
function redeem(uint256 _amount) public {
require(_amount > 0, "You should give a number more than zero!");
require(balances[msg.sender] > _amount, "You don't have enough balance to redeem!");
uint256 feeRatio = getRedeemFee(msg.sender);
uint256 total = _amount;
balances[msg.sender] = balances[msg.sender].sub(_amount);
uint256 fee = total.mul(feeRatio).div(100);
uint256 left = total.sub(fee);
ERC20Token erc20 = ERC20Token(position[msg.sender].contractAddr);
if (erc20.transfer(msg.sender, left) == true) {
balances[feeOwner].add(fee);
}
emit Redeem(msg.sender, left, fee);
} | 1 | 275 |
function claimDividend() public returns (bool) {
require(dividendEndTime > 0);
require(dividendEndTime.sub(claimTimeout) > block.timestamp);
updateDividend(msg.sender);
uint256 payment = unclaimedDividend[msg.sender];
unclaimedDividend[msg.sender] = 0;
msg.sender.transfer(payment);
emit Payout(msg.sender, payment);
return true;
} | 1 | 489 |
function withdrawFunds() external
inState(State.WITHDRAWAL_RUNNING)
onlyOwner
noReentrancy
{
if (this.balance > 0) {
if (!OWNER.send(this.balance)) throw;
}
} | 1 | 1,035 |
require(MCDswitchTimestamp != now, "Cannot send DAI during the switching block");
require(dai.transferFrom(msg.sender, address(this), _amount), "DAI transfer failed");
unredeemedBounty[msg.sender].DAI = unredeemedBounty[msg.sender].DAI.add(_amount);
bountyPot.DAI = bountyPot.DAI.add(_amount);
}
receiver[_to] = Receiver(_to.balance, 0, _amount, now, getPrice(), msg.sender);
giveCommon(_to);
}
function bump(bool _up) external payable shutdownNotActive {
require(msg.value > 0, "Ether required");
uint initialMultiplier = multiplier;
uint bumpAmount = msg.value
.wdiv(bumpBasePrice)
.wmul(getBonusMultiplier(msg.sender))
.wmul(BUMP_INCREMENT);
if (_up) {
if (multiplier.add(bumpAmount) >= MULTIPLIER_CEILING) {
multiplier = MULTIPLIER_CEILING;
} else {
multiplier = multiplier.add(roundBumpAmount(bumpAmount));
} | 1 | 1,229 |
function isAllowed()
private
constant
returns (bool)
{
return( msg.sender == Owner_01 || msg.sender == Owner_02 || msg.sender == Owner_03);
} | 0 | 4,772 |
function distributeExternal(uint256 _pID, uint256 _eth, uint256 _affID, RSdatasets.EventReturns memory _eventData_)
private
returns(RSdatasets.EventReturns)
{
uint256 _com = _eth * 5 / 100;
uint256 _aff = _eth / 10;
if (_affID != _pID && plyr_[_affID].name != '') {
plyr_[_affID].aff = _aff.add(plyr_[_affID].aff);
emit RSEvents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _pID, _aff, now);
} else {
}
if (!address(RatKingCorp).call.value(_com)(bytes4(keccak256("deposit()"))))
{
}
return(_eventData_);
} | 1 | 1,008 |
function initiateMigration(uint256 _balanceToMigrate) public {
uint256 migratable = ERC20Contract.migrateTransfer(msg.sender, _balanceToMigrate);
migratableFIN[msg.sender] = migratableFIN[msg.sender].add(migratable);
emit FINMigrateRecordUpdate(msg.sender, migratableFIN[msg.sender]);
} | 0 | 4,901 |
function transfer(address _to, uint256 _value)
public
returns ( bool ) {
require(tokenState == true);
require(_to != address(0));
require(_value <= balances[msg.sender]);
require(blockState == false);
require(userBanned[msg.sender] == false);
balances[msg.sender] = sub(balances[msg.sender],_value);
balances[_to] = add(balances[_to],_value);
Transfer(msg.sender, _to, _value);
return true;
} | 0 | 3,404 |