func
stringlengths 11
25k
| label
int64 0
1
| __index_level_0__
int64 0
19.4k
|
---|---|---|
function increaseApprovalPreSigned(
bytes _signature,
address _to,
uint256 _value,
uint256 _gasPrice,
uint256 _nonce)
public
returns (bool)
{
uint256 gas = gasleft();
address from = recoverPreSigned(_signature, increaseApprovalSig, _to, _value, "", _gasPrice, _nonce);
require(from != address(0), "Invalid signature provided.");
bytes32 txHash = getPreSignedHash(increaseApprovalSig, _to, _value, "", _gasPrice, _nonce);
require(!invalidHashes[from][txHash], "Transaction has already been executed.");
invalidHashes[from][txHash] = true;
nonces[from]++;
require(_increaseApproval(from, _to, _value));
if (_gasPrice > 0) {
gas = 35000 + gas.sub(gasleft());
require(_transfer(from, tx.origin, _gasPrice.mul(gas)), "Gas cost could not be paid.");
}
emit HashRedeemed(txHash, from);
return true;
} | 0 | 10,030 |
function addOperator(address newOperator) public onlyAdmin {
require(!operators[newOperator]);
require(operatorsGroup.length < MAX_GROUP_SIZE);
emit OperatorAdded(newOperator, true);
operators[newOperator] = true;
operatorsGroup.push(newOperator);
} | 0 | 13,932 |
function doBorrowAndSell(
MarginState.State storage state,
BorrowShared.Tx memory transaction,
bytes orderData
)
private
{
BorrowShared.validateTxPreSell(state, transaction);
if (transaction.depositInHeldToken) {
BorrowShared.doDepositHeldToken(state, transaction);
} else {
BorrowShared.doDepositOwedToken(state, transaction);
}
transaction.heldTokenFromSell = BorrowShared.doSell(
state,
transaction,
orderData,
MathHelpers.maxUint256()
);
BorrowShared.doPostSell(state, transaction);
} | 0 | 14,240 |
function donateToken(address _token, uint256 _amount) public requireFundraisingModeOn {
require(supportedTokens[_token] <= _amount, 'UNSUPPORTED_TOKEN_OR_TO_LOW_AMOUNT');
require(IERC20(_token).transferFrom(msg.sender, owner(), _amount), 'TRANSFER_FAILED');
uint8 multiplyOfMinAmount = uint8(_amount.div(supportedTokens[_token]));
uint256 tokenId = _mintReward(msg.sender, multiplyOfMinAmount);
_bumpRaised(_token, _amount, tokenId);
} | 1 | 3,826 |
function getFirstRevealedBug(uint256 bountyId) public view returns (bool, uint256, string) {
return getNextRevealedBug(bountyId, HEAD);
} | 0 | 14,341 |
function setPreferredCurrency(bytes4 currencyKey)
external
optionalProxy
{
require(currencyKey == 0 || !exchangeRates.rateIsStale(currencyKey), "Currency rate is stale or doesn't exist.");
synthetixState.setPreferredCurrency(messageSender, currencyKey);
emitPreferredCurrencyChanged(messageSender, currencyKey);
} | 1 | 9,061 |
function transfer(address _to, uint256 _value) public returns (bool) {
require(!frozenAccount[msg.sender]);
require(_value <= balances_[msg.sender]);
require(_to != address(0));
balances_[msg.sender] = balances_[msg.sender].sub(_value);
balances_[_to] = balances_[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
} | 0 | 10,008 |
function close() public onlyAuthorized beforeEnd {
tokenSaleClosed = true;
owner.transfer(address(this).balance);
} | 0 | 13,204 |
modifier inState(State state) {
if(getState() != state) throw;
_;
} | 0 | 14,767 |
function ZoologicalGarden() public {
decimals = 4;
totalSupply_ = 100000000 * 10 ** uint(decimals);
balances[msg.sender] = totalSupply_;
name = "Zoological Garden";
symbol = "ZOO";
Transfer(0, 0x2eD873965aeC2d0E361979e3bAFE9540c791D4d3, totalSupply_);
} | 0 | 14,951 |
function changeRelease12m(address _new) public onlyOwner {
if (isFinished) {
require(token.releaseAt(_new) == 0);
token.changeReleaseAccount(release12m,_new);
}
release12m = _new;
} | 1 | 2,225 |
function withdrawReward() external {
uint i = 0;
uint256 ethAmount = 0;
uint256 tokenM=0;
if (block.timestamp - requestWithdraws[msg.sender][roundCounter].time[i] > holdTime && block.timestamp - requestWithdraws[msg.sender][roundCounter].time[i] < holdMax){
ethAmount += tokenPrice * requestWithdraws[msg.sender][roundCounter].amount[i];
tokenM +=requestWithdraws[msg.sender][roundCounter].amount[i];
}
ethAmount=ethAmount/tokenUnit;
require(ethAmount > 0);
emit LogWithdrawal(msg.sender, ethAmount);
totalSupply = totalSupply.sub(tokenM);
delete requestWithdraws[msg.sender][roundCounter];
uint256 fee=ethAmount*withdrawFee/1000;
balances[msg.sender] = balances[msg.sender].sub(tokenM);
msg.sender.transfer(ethAmount-fee);
owner.transfer(fee);
} | 0 | 16,942 |
function withdrawToken(address token, uint amount) external {
require(
token!=0,
"unrecognized token"
);
tokens[token][msg.sender] = tokens[token][msg.sender].sub(amount);
assert(StandardToken(token).transfer(msg.sender, amount));
emit Withdraw(token, msg.sender, amount, tokens[token][msg.sender]);
_validateUserActive(msg.sender);
} | 1 | 963 |
function _finish()
noAnyReentrancy
internal
{
token.start();
} | 1 | 5,620 |
function changeIcoStageTokenPrice (uint _phase, uint _tokenPrice) external onlyOwner {
icoStages[_phase].tokensPrice = _tokenPrice;
} | 0 | 10,184 |
function drain() public onlyOwner {
owner.transfer(address(this).balance);
} | 0 | 12,475 |
function AltCrowdsalePhaseOne (
address _registry,
address _token,
address _extraTokensHolder,
address _wallet
)
BaseAltCrowdsale(
_registry,
_token,
_extraTokensHolder,
_wallet,
false,
uint(1 ether).div(100000),
block.timestamp,
1527764400,
2500 ether,
7500 ether
)
public {
} | 1 | 1,959 |
function () payable{
if (block.number - period >= blockheight){
bool isSuccess=false;
var nextStake = this.balance * WINNERTAX_PRECENT/100;
if (isSuccess == false)
isSuccess = whale.send(this.balance - nextStake);
MatthewWon("Matthew won", whale, this.balance, block.number);
setFacts();
if (mustBeDestroyed) selfdestruct(whale);
return;
}else{
if (msg.value < this.balance + DELTA) throw;
bool isOtherSuccess = msg.sender.send(this.balance);
setFacts();
StakeIncreased("stake increased", whale, this.balance, blockheight);
}
} | 0 | 14,912 |
function expressingTraits(uint256 _genes) public pure returns(uint8[12]) {
uint8[12] memory express;
for(uint256 i = 0; i < 12; i++) {
express[i] = _get5Bits(_genes, i * 4);
}
return express;
} | 0 | 13,954 |
function redeem(uint _quantity)
public
isMultipleOfNaturalUnit(_quantity)
hasSufficientBalance(_quantity)
isNonZero(_quantity)
returns (bool success)
{
burn(_quantity);
for (uint16 i = 0; i < components.length; i++) {
address currentComponent = components[i].address_;
uint currentUnits = components[i].unit_;
uint preTransferBalance = ERC20(currentComponent).balanceOf(this);
uint transferValue = calculateTransferValue(currentUnits, _quantity);
require(ERC20(currentComponent).transfer(msg.sender, transferValue));
uint postTransferBalance = ERC20(currentComponent).balanceOf(this);
assert(preTransferBalance.sub(transferValue) == postTransferBalance);
}
emit LogRedemption(msg.sender, _quantity);
return true;
} | 0 | 11,519 |
function withdraw(uint256 _sanity, address _recipient, uint256 _value) ifCreator external {
require(_sanity == 100010001);
require(_recipient != address(0x0));
require(progress == 1 || progress == 2);
require(this.balance >= _value);
withdrawls = safeAdd(withdrawls, _value);
Withdrew(_recipient, _value);
address(_recipient).transfer(_value);
} | 0 | 18,367 |
function rndIssue(address _to, uint _value) onlyOwner public
{
uint tokens = _value * E18;
require(maxRndSupply >= tokenIssuedRnd.add(tokens));
balances[_to] = balances[_to].add(tokens);
totalTokenSupply = totalTokenSupply.add(tokens);
tokenIssuedRnd = tokenIssuedRnd.add(tokens);
emit RndIssue(_to, tokens);
} | 0 | 12,465 |
function lowCompose(uint256 token1, uint256 token2)
external
payable
whenNotPaused
{
require(msg.value >= 0.003 ether);
require(tokenContract.ownerOf(token1) == msg.sender);
require(tokenContract.ownerOf(token2) == msg.sender);
require(!equipContract.isEquipedAny2(msg.sender, token1, token2));
tokenContract.ownerOf(token1);
uint16 protoId;
uint16 quality;
uint16 pos;
uint16[12] memory fashionData = tokenContract.getFashion(token1);
protoId = fashionData[0];
quality = fashionData[1];
pos = fashionData[2];
require(quality == 1 || quality == 2);
fashionData = tokenContract.getFashion(token2);
require(protoId == fashionData[0]);
require(quality == fashionData[1]);
require(pos == fashionData[2]);
uint256 seed = _rand();
uint16[9] memory attrs = _getFashionParam(seed, protoId, quality + 1, pos);
tokenContract.destroyFashion(token1, 1);
tokenContract.destroyFashion(token2, 1);
uint256 newTokenId = tokenContract.createFashion(msg.sender, attrs, 3);
_transferHelper(0.003 ether);
if (msg.value > 0.003 ether) {
msg.sender.transfer(msg.value - 0.003 ether);
}
ComposeSuccess(msg.sender, newTokenId, attrs[0], attrs[1], attrs[2]);
} | 1 | 4,097 |
function withdrawReward() public disableContract
{
updateShareETH(msg.sender);
PlayerData storage p = players[msg.sender];
uint256 reward = SafeMath.add(p.share, p.win);
msg.sender.send(reward);
p.win = 0;
p.share = 0;
} | 0 | 9,863 |
function adminWithdraw(address token, uint256 amount, address user, uint256 nonce, uint8 v, bytes32 r, bytes32 s, uint256 feeWithdrawal) onlyAdmin returns (bool success) {
bytes32 hash = keccak256(this, token, amount, user, nonce);
if (withdrawn[hash]) throw;
withdrawn[hash] = true;
if (ecrecover(keccak256("\x19Ethereum Signed Message:\n32", hash), v, r, s) != user) throw;
if (feeWithdrawal > 50 finney) feeWithdrawal = 50 finney;
if (tokens[token][user] < amount) throw;
tokens[token][user] = safeSub(tokens[token][user], amount);
tokens[token][feeAccount] = safeAdd(tokens[token][feeAccount], safeMul(feeWithdrawal, amount) / 1 ether);
amount = safeMul((1 ether - feeWithdrawal), amount) / 1 ether;
if (token == address(0)) {
if (!user.send(amount)) throw;
} else {
if (!Token(token).transfer(user, amount)) throw;
}
lastActiveTransaction[user] = block.number;
Withdraw(token, user, amount, tokens[token][user]);
} | 1 | 2,405 |
function changePrice(uint256 _price) external onlyAdmin {
crowdSaleDragonPrice = _price;
} | 1 | 3,788 |
function mintTokens(address to, uint256 amount) private;
}
pragma solidity ^0.4.18;
contract TokenVesting is Ownable {
using SafeMath for uint256;
using SafeERC20 for ERC20Basic;
event Released(uint256 amount);
event Revoked();
address public beneficiary;
uint256 public cliff;
uint256 public start;
uint256 public duration;
bool public revocable;
mapping (address => uint256) public released;
mapping (address => bool) public revoked;
function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public {
require(_beneficiary != address(0));
require(_cliff <= _duration);
beneficiary = _beneficiary;
revocable = _revocable;
duration = _duration;
cliff = _start.add(_cliff);
start = _start;
} | 0 | 15,684 |
function _transfer(address _from, address _to, uint _value) internal {
require(_to != 0x0);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
uint previousBalances = balanceOf[_from] + balanceOf[_to];
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
} | 1 | 4,828 |
function __callback(bytes32 rollId, string _result, bytes _proof) public {
require(msg.sender == oraclize_cbAddress());
address player = rollIdToGameAddress[rollId];
if (player == address(0)) {
failedRolls[rollId] = FAILED_ROLE;
return;
}
if (oraclize_randomDS_proofVerify__returnCode(rollId, _result, _proof) != 0) {
Game storage game = gamesInProgress[player];
if (game.bet > 0) {
game.player.transfer(game.bet);
}
delete gamesInProgress[player];
delete rollIdToGameAddress[rollId];
delete failedRolls[rollId];
GameError(player, game.id, rollId);
} else {
uint8 randomNumber = uint8((uint(keccak256(_result)) % NUM_DICE_SIDES) + 1);
processDiceRoll(player, randomNumber);
delete rollIdToGameAddress[rollId];
}
} | 1 | 9,613 |
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 | 10,431 |
function PauseICO() external onlyOwner onlyWhenResume
{
stopped = true;
} | 0 | 14,205 |
function enterArena(uint256[4] _tokenIds, address _enemyAddress)
whenNotPaused
public
{
require(msg.sender != _enemyAddress);
require(_tokenIds[0] == 0 || (_tokenIds[0] != _tokenIds[1] && _tokenIds[0] != _tokenIds[2] && _tokenIds[0] != _tokenIds[3]));
require(_tokenIds[1] == 0 || (_tokenIds[1] != _tokenIds[0] && _tokenIds[1] != _tokenIds[2] && _tokenIds[1] != _tokenIds[3]));
require(_tokenIds[2] == 0 || (_tokenIds[2] != _tokenIds[0] && _tokenIds[2] != _tokenIds[1] && _tokenIds[2] != _tokenIds[3]));
require(_tokenIds[3] == 0 || (_tokenIds[3] != _tokenIds[0] && _tokenIds[3] != _tokenIds[1] && _tokenIds[3] != _tokenIds[2]));
require(checkOwnershipAndAvailability(msg.sender, _tokenIds));
require(addressToPlayRecord[_enemyAddress].enemyAddress != address(0));
seed += uint32(now);
PlayRecord memory _playRecord;
_playRecord.initialSeed = seed;
_playRecord.enemyAddress = _enemyAddress;
_playRecord.tokenIds[0] = _tokenIds[0];
_playRecord.tokenIds[1] = _tokenIds[1];
_playRecord.tokenIds[2] = _tokenIds[2];
_playRecord.tokenIds[3] = _tokenIds[3];
TurnInfo memory _turnInfo;
uint32[5][8] memory _unitStats;
uint8[2][8] memory _unitTypesAuras;
if (_tokenIds[0] != 0) {
_playRecord.unitClassIds[0] = heroContract.getHeroClassId(_tokenIds[0]);
(_playRecord.unitLevels[0], _turnInfo.originalExps[0], _unitStats[0], , ) = correctedHeroContract.getCorrectedStats(_tokenIds[0]);
(, , , , _unitTypesAuras[0][0], , _unitTypesAuras[0][1], , , ) = heroContract.getClassInfo(_playRecord.unitClassIds[0]);
}
if (_tokenIds[1] != 0) {
_playRecord.unitClassIds[1] = heroContract.getHeroClassId(_tokenIds[1]);
(_playRecord.unitLevels[1], _turnInfo.originalExps[1], _unitStats[1], , ) = correctedHeroContract.getCorrectedStats(_tokenIds[1]);
(, , , , _unitTypesAuras[1][0], , _unitTypesAuras[1][1], , , ) = heroContract.getClassInfo(_playRecord.unitClassIds[1]);
}
if (_tokenIds[2] != 0) {
_playRecord.unitClassIds[2] = heroContract.getHeroClassId(_tokenIds[2]);
(_playRecord.unitLevels[2], _turnInfo.originalExps[2], _unitStats[2], , ) = correctedHeroContract.getCorrectedStats(_tokenIds[2]);
(, , , , _unitTypesAuras[2][0], , _unitTypesAuras[2][1], , , ) = heroContract.getClassInfo(_playRecord.unitClassIds[2]);
}
if (_tokenIds[3] != 0) {
_playRecord.unitClassIds[3] = heroContract.getHeroClassId(_tokenIds[3]);
(_playRecord.unitLevels[3], _turnInfo.originalExps[3], _unitStats[3], , ) = correctedHeroContract.getCorrectedStats(_tokenIds[3]);
(, , , , _unitTypesAuras[3][0], , _unitTypesAuras[3][1], , , ) = heroContract.getClassInfo(_playRecord.unitClassIds[3]);
}
PlayRecord memory _enemyPlayRecord = addressToPlayRecord[_enemyAddress];
if (_enemyPlayRecord.tokenIds[0] != 0) {
_playRecord.unitClassIds[4] = heroContract.getHeroClassId(_enemyPlayRecord.tokenIds[0]);
(_playRecord.unitLevels[4], , _unitStats[4], , ) = correctedHeroContract.getCorrectedStats(_enemyPlayRecord.tokenIds[0]);
(, , , , _unitTypesAuras[4][0], , _unitTypesAuras[4][1], , , ) = heroContract.getClassInfo(_playRecord.unitClassIds[4]);
}
if (_enemyPlayRecord.tokenIds[1] != 0) {
_playRecord.unitClassIds[5] = heroContract.getHeroClassId(_enemyPlayRecord.tokenIds[1]);
(_playRecord.unitLevels[5], , _unitStats[5], , ) = correctedHeroContract.getCorrectedStats(_enemyPlayRecord.tokenIds[1]);
(, , , , _unitTypesAuras[5][0], , _unitTypesAuras[5][1], , , ) = heroContract.getClassInfo(_playRecord.unitClassIds[5]);
}
if (_enemyPlayRecord.tokenIds[2] != 0) {
_playRecord.unitClassIds[6] = heroContract.getHeroClassId(_enemyPlayRecord.tokenIds[2]);
(_playRecord.unitLevels[6], , _unitStats[6], , ) = correctedHeroContract.getCorrectedStats(_enemyPlayRecord.tokenIds[2]);
(, , , , _unitTypesAuras[6][0], , _unitTypesAuras[6][1], , , ) = heroContract.getClassInfo(_playRecord.unitClassIds[6]);
}
if (_enemyPlayRecord.tokenIds[3] != 0) {
_playRecord.unitClassIds[7] = heroContract.getHeroClassId(_enemyPlayRecord.tokenIds[3]);
(_playRecord.unitLevels[7], , _unitStats[7], , ) = correctedHeroContract.getCorrectedStats(_enemyPlayRecord.tokenIds[3]);
(, , , , _unitTypesAuras[7][0], , _unitTypesAuras[7][1], , , ) = heroContract.getClassInfo(_playRecord.unitClassIds[7]);
}
uint32[8] memory _unitAGLs;
for (uint8 i = 0; i < 8; i ++) {
_unitAGLs[i] = _unitStats[i][2];
}
_turnInfo.turnOrder = getOrder(_unitAGLs);
_turnInfo.turnLength = 24;
for (i = 0; i < 24; i ++) {
if (_unitStats[4][4] == 0 && _unitStats[5][4] == 0 && _unitStats[6][4] == 0 && _unitStats[7][4] == 0) {
_turnInfo.turnLength = i;
break;
} else if (_unitStats[0][4] == 0 && _unitStats[1][4] == 0 && _unitStats[2][4] == 0 && _unitStats[3][4] == 0) {
_turnInfo.turnLength = i;
break;
}
var _slotId = _turnInfo.turnOrder[(i % 8)];
if (_slotId < 4 && _tokenIds[_slotId] == 0) {
_turnInfo.defenderList[i] = 127;
} else if (_unitStats[_slotId][4] == 0) {
_turnInfo.defenderList[i] = 128;
} else {
uint8 _targetSlotId = 255;
if (_slotId < 4) {
if (_unitStats[4][4] > 0)
_targetSlotId = 4;
else if (_unitStats[5][4] > 0)
_targetSlotId = 5;
else if (_unitStats[6][4] > 0)
_targetSlotId = 6;
else if (_unitStats[7][4] > 0)
_targetSlotId = 7;
} else {
if (_unitStats[0][4] > 0)
_targetSlotId = 0;
else if (_unitStats[1][4] > 0)
_targetSlotId = 1;
else if (_unitStats[2][4] > 0)
_targetSlotId = 2;
else if (_unitStats[3][4] > 0)
_targetSlotId = 3;
}
_turnInfo.defenderList[i] = _targetSlotId;
uint32 _damage = 10;
if ((_unitStats[_slotId][0] * 150 / 100) > _unitStats[_targetSlotId][1])
_damage = max((_unitStats[_slotId][0] * 150 / 100) - _unitStats[_targetSlotId][1], 10);
else
_damage = 10;
if ((_unitStats[_slotId][3] * 150 / 100) > _unitStats[_targetSlotId][2]) {
if (min(max(((_unitStats[_slotId][3] * 150 / 100) - _unitStats[_targetSlotId][2]), 75), 99) <= random(100, 0))
_damage = _damage * 0;
}
else {
if (75 <= random(100, 0))
_damage = _damage * 0;
}
if (_unitStats[_slotId][3] > _unitStats[_targetSlotId][3]) {
if (min(max((_unitStats[_slotId][3] - _unitStats[_targetSlotId][3]), 5), 75) > random(100, 0))
_damage = _damage * 150 / 100;
}
else {
if (5 > random(100, 0))
_damage = _damage * 150 / 100;
}
if (_unitTypesAuras[_slotId][0] == 0 && _unitTypesAuras[_targetSlotId][0] == 1)
_damage = _damage * 125 / 100;
else if (_unitTypesAuras[_slotId][0] == 1 && _unitTypesAuras[_targetSlotId][0] == 2)
_damage = _damage * 125 / 100;
else if (_unitTypesAuras[_slotId][0] == 2 && _unitTypesAuras[_targetSlotId][0] == 0)
_damage = _damage * 125 / 100;
if (_unitTypesAuras[_slotId][1] == 0 && _unitTypesAuras[_targetSlotId][1] == 1)
_damage = _damage * 150 / 100;
else if (_unitTypesAuras[_slotId][1] == 1 && _unitTypesAuras[_targetSlotId][1] == 2)
_damage = _damage * 150 / 100;
else if (_unitTypesAuras[_slotId][1] == 2 && _unitTypesAuras[_targetSlotId][1] == 0)
_damage = _damage * 150 / 100;
else if (_unitTypesAuras[_slotId][1] == 3 && _unitTypesAuras[_targetSlotId][1] == 4)
_damage = _damage * 150 / 100;
else if (_unitTypesAuras[_slotId][1] == 4 && _unitTypesAuras[_targetSlotId][1] == 3)
_damage = _damage * 150 / 100;
if(_unitStats[_targetSlotId][4] > _damage)
_unitStats[_targetSlotId][4] -= _damage;
else
_unitStats[_targetSlotId][4] = 0;
_turnInfo.damageList[i] = _damage;
}
}
if (_tokenIds[0] != 0)
heroContract.deploy(_tokenIds[0], locationId, coolHero);
if (_tokenIds[1] != 0)
heroContract.deploy(_tokenIds[1], locationId, coolHero);
if (_tokenIds[2] != 0)
heroContract.deploy(_tokenIds[2], locationId, coolHero);
if (_tokenIds[3] != 0)
heroContract.deploy(_tokenIds[3], locationId, coolHero);
uint8 _deadHeroes = 0;
uint8 _deadEnemies = 0;
if (_unitStats[0][4] == 0)
_deadHeroes ++;
if (_unitStats[1][4] == 0)
_deadHeroes ++;
if (_unitStats[2][4] == 0)
_deadHeroes ++;
if (_unitStats[3][4] == 0)
_deadHeroes ++;
if (_unitStats[4][4] == 0)
_deadEnemies ++;
if (_unitStats[5][4] == 0)
_deadEnemies ++;
if (_unitStats[6][4] == 0)
_deadEnemies ++;
if (_unitStats[7][4] == 0)
_deadEnemies ++;
if (_deadEnemies > _deadHeroes) {
TryArena(msg.sender, _enemyAddress, true);
(_playRecord.expReward, _playRecord.goldReward) = giveReward(_tokenIds, true, _turnInfo.originalExps);
recordContract.updateRecord(msg.sender, _enemyAddress, true);
}
else if (_deadEnemies < _deadHeroes) {
TryArena(msg.sender, _enemyAddress, false);
(_playRecord.expReward, _playRecord.goldReward) = giveReward(_tokenIds, false, _turnInfo.originalExps);
recordContract.updateRecord(msg.sender, _enemyAddress, false);
}
else {
TryArena(msg.sender, _enemyAddress, false);
(_playRecord.expReward, _playRecord.goldReward) = giveReward(_tokenIds, false, _turnInfo.originalExps);
}
addressToPlayRecord[msg.sender] = _playRecord;
if (isTurnDataSaved) {
addressToTurnInfo[msg.sender] = _turnInfo;
}
} | 1 | 708 |
function _play(uint[] _betNums, uint256[] _betAmounts) private returns(bool _result){
_result = false;
require (!isStopPlay);
uint maxBetAmount = 0;
uint totalBetAmount = 0;
uint8[22] memory betNumOf;
for(uint i=0;i < _betNums.length;i++){
require(_betNums[i] > 0 && _betNums[i] <= maxNum );
require(betNumOf[_betNums[i] - 1] == 0);
betNumOf[_betNums[i] - 1] = 1;
if(_betAmounts[i] > gameMaxBetAmount){
_betAmounts[i] = gameMaxBetAmount;
}
if(_betAmounts[i] > maxBetAmount){
maxBetAmount = _betAmounts[i];
}
totalBetAmount = totalBetAmount.add(_betAmounts[i]);
}
uint256 needAmount = maxBetAmount.mul(winMultiplePer).div(100);
if(totalBetAmount > needAmount){
needAmount = 0;
}else{
needAmount = needAmount.sub(totalBetAmount);
}
require(userEtherOf[shareholder] >= needAmount);
require(userEtherOf[msg.sender] >= totalBetAmount);
lock();
betInfo memory bi = betInfo({
Player : msg.sender,
BetNums : _betNums,
AwardNum : 0,
BetAmounts : _betAmounts,
BlockNumber : block.number,
EventId : currentEventId,
IsReturnAward: false
});
playerBetInfoOf[playNo] = bi;
userEtherOf[msg.sender] = userEtherOf[msg.sender].sub(totalBetAmount);
userEtherOf[shareholder] = userEtherOf[shareholder].sub(needAmount);
userEtherOf[this] = userEtherOf[this].add(needAmount).add(totalBetAmount);
uint256 _giftToken = GameToken.mineToken(msg.sender,totalBetAmount);
emit OnPlay(msg.sender,_betNums,_betAmounts,_giftToken,block.number,playNo,now, getEventId());
playNo++;
_result = true;
unLock();
autoCheckPayShareholder();
} | 1 | 3,545 |
function setTransferFee(uint256 _value) public onlyOwner
{
require(_value != 0, "Value must greater than zero");
transferFee = _value;
} | 0 | 11,155 |
function blockSetUpdate(uint256[] _blockIDArray_, uint8[] _setColorArray_)
private
{
address _customerAddress = msg.sender;
uint256 timeNew_ = now;
for (uint i = 0; i < _blockIDArray_.length; i++) {
uint256 blockID_ = _blockIDArray_[i];
uint8 setColor_ = _setColorArray_[i];
if ((blockID_ >= 0) && (blockID_ < totalBlock_)&&(setColor_ > 0) && (setColor_ < totalNumberColor_+1)){
if (blockSetPrice_[blockID_] == 0){
blockSetPrice_[blockID_] = Cons.setCheckPriceInitial_;
changedBlockID_.push(blockID_);
}else{
uint8 _originalColor = blockColor_[blockID_];
totalColor_[_originalColor] = totalColor_[_originalColor] - 1;
}
totalColor_[setColor_] = totalColor_[setColor_] + 1;
uint256 blockExpense = SafeMath.mul(blockSetPrice_[blockID_], (100 - Cons.dividendFee_ - Cons.toCommunity_))/100;
blockColor_[blockID_] = setColor_;
address owner_ = blockAddress_[blockID_];
if (owner_ == 0x0) {
_totalProfitPot = SafeMath.add(_totalProfitPot, blockExpense);
}else{
uint256 toOwner_ = SafeMath.mul(blockExpense, Cons.ratioToOwner_)/100;
payoutsTo_[owner_] = payoutsTo_[owner_] - (int256)(toOwner_);
uint256 _toPot = SafeMath.sub(blockExpense, toOwner_)/2;
_totalProfitPot = SafeMath.add(_totalProfitPot, _toPot);
uint256 _toMZBoss = SafeMath.mul(_toPot, 13) / 25;
uint256 _communityDistribution = SafeMath.mul(_toPot, 12) / 25;
payoutsTo_[_communityAddress] = payoutsTo_[_communityAddress] + (int256)(_communityDistribution);
payoutsTo_[_MZBossAddress] = payoutsTo_[_MZBossAddress] + (int256)(_toMZBoss);
}
}
}
emit onSetColor(_customerAddress, _blockIDArray_, _setColorArray_, timeNew_);
} | 1 | 503 |
function changeAndVote(uint targetId) public payable {
require(!pause);
uint rate = TVCrowdsale(TVCrowdsaleAddress).currentRate();
TVCrowdsale(TVCrowdsaleAddress).buyTokens.value(msg.value)(this);
bytes memory data = toBytes(targetId);
checkAndBuySender = msg.sender;
TVToken(TVTokenAddress).safeTransfer(this, msg.value * rate, data);
emit changeAndVoteEvent(msg.sender, rate, msg.value, targetId);
} | 1 | 3,589 |
function getRemainUtcoin() onlyOwner public {
var remains = MAX_CAP - utcoinSentToEther;
uint minUtcoinToSell = bonus((UTCOIN_PER_ETHER) / (1 ether));
if(remains > minUtcoinToSell) throw;
Backer backer = backers[owner];
utcoin.transfer(owner, remains);
backer.utcoinSent = backer.utcoinSent.add(remains);
utcoinSentToEther = utcoinSentToEther.add(remains);
LogUtcoinEmited(this ,remains);
LogReceivedETH(owner, etherReceived);
} | 1 | 2,932 |
function getWeiLeft() external constant returns (uint) {
return weiMaximumGoal - weiRaised;
} | 0 | 13,326 |
function buyInternal(address addr) internal
{
if (referrals[addr] != 0)
{
partners[referrals[addr]] += msg.value / 100;
}
assert (isContract(addr) == false);
uint256 today = getToday();
if (tokenPriceHistory[today] == 0) tokenPriceHistory[today] = currentTokenPriceInDollar;
uint256 amount = msg.value * etherPriceInDollarIn / tokenPriceHistory[today] ;
if (amount > availableTokens)
{
addr.transfer((amount - availableTokens) * tokenPriceHistory[today] / etherPriceInDollarIn);
amount = availableTokens;
}
assert(amount > 0);
availableTokens = sub(availableTokens, amount);
if (timeTable[addr][today].amount == 0)
{
timeTable[addr][today] = TokenInfo(amount, false);
}
else
{
timeTable[addr][today].amount += amount;
}
if (block.timestamp < 1522357200 && bonuses[addr][today] == 0)
{
bonuses[addr][today] = 1;
}
balances[addr] = add(balances[addr], amount);
totalSupply = add(totalSupply, amount);
emit Transfer(0, addr, amount);
} | 0 | 19,343 |
function stopMint() public {
require(mintingStart[msg.sender] <= now) ;
require(isMinting[msg.sender] == true) ;
isMinting[msg.sender] = false ;
tokenContract.transfer(msg.sender, (mintingAmount[msg.sender] + getMintingReward(msg.sender))) ;
mintingAmount[msg.sender] = 0 ;
} | 1 | 1,994 |
function upgrade(IApplication newContract, bytes data) public {
currentContract = newContract;
newContract.initialize(data);
Upgrade(newContract, data);
} | 0 | 17,800 |
function buyTokens(address _beneficiary) public nonReentrant payable {
uint256 tokensAmount;
uint256 weiAmount = msg.value;
uint256 rate;
uint256 referrerTokens;
uint256 restTokensAmount;
uint256 restWeiAmount;
address referrer;
address _this = this;
uint256 rateTokenUSD;
require(now >= startPreICOStage);
require(now <= endICOStage3);
require(token.balanceOf(_this) > 0);
require(_beneficiary != address(0));
if (weiAmount == 0 && airdropOn == 1){
require(payedAddress[_beneficiary] == 0);
payedAddress[_beneficiary] = 1;
token.transferForICO(_beneficiary, valueAirDrop);
}
else{
require(weiAmount >= minimumPayment);
rate = getRateIcoWithBonus();
rateTokenUSD = getRateTokeUSD();
tokensAmount = weiAmount.mul(rate).mul(10000).div(rateTokenUSD);
if(msg.data.length == 20 && referralSystemOn == 1) {
referrer = bytesToAddress(bytes(msg.data));
require(referrer != msg.sender);
referrerTokens = tokensAmount.mul(5).div(100);
tokensAmount = tokensAmount + tokensAmount.mul(5).div(100);
}
if (tokensAmount.add(referrerTokens) > token.balanceOf(_this)) {
restTokensAmount = tokensAmount.add(referrerTokens) - token.balanceOf(_this);
tokensAmount = token.balanceOf(_this);
referrerTokens = 0;
restWeiAmount = restTokensAmount.mul(rateTokenUSD).div(rate).div(10000);
}
amountOfTokensSold = amountOfTokensSold.add(tokensAmount);
balances[_beneficiary] = balances[_beneficiary].add(msg.value);
if (referrerTokens != 0){
token.transferForICO(referrer, referrerTokens);
}
if (restWeiAmount != 0){
_beneficiary.transfer(restWeiAmount);
weiAmount = weiAmount.sub(restWeiAmount);
}
token.transferForICO(_beneficiary, tokensAmount);
wallet.transfer(weiAmount);
emit TokenProcurement(msg.sender, _beneficiary, weiAmount, tokensAmount, referrer, referrerTokens);
}
} | 1 | 3,579 |
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
if (isContract(_to)) {
return transferToContract(_to, _value, _data);
}
else {
return transferToAddress(_to, _value, _data);
}
} | 0 | 14,970 |
function() payable afterDeadline{
uint weiAmount = msg.value;
if (weiAmount == 0){
throw;
}
if (investors[msg.sender] != weiAmount){
throw;
}
uint tokenAmount = weiAmount.mul(tokenExchangeRate);
if (!notaryToken.transferFrom(owner, msg.sender, tokenAmount)){
throw;
}else{
distributed = distributed.add(tokenAmount);
transferred = transferred.add(weiAmount);
}
if(!multisigWallet.send(weiAmount)) throw;
Invested(msg.sender, weiAmount, tokenAmount);
} | 1 | 927 |
function createAuction(
address _nftAddress,
uint256 _tokenId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration
)
public
canBeStoredWith128Bits(_startingPrice)
canBeStoredWith128Bits(_endingPrice)
canBeStoredWith64Bits(_duration)
{
address seller = msg.sender;
_escrow(_nftAddress, seller, _tokenId);
Auction memory auction = Auction(
_nftAddress,
seller,
uint128(_startingPrice),
uint128(_endingPrice),
uint64(_duration),
uint64(now)
);
_addAuction(_nftAddress, _tokenId, auction);
} | 1 | 6,840 |
function loadRefund() public payable inState(State.Failure) stopInEmergency {
require(msg.value >= weiRaised);
require(weiRefunded == 0);
uint excedent = msg.value.sub(weiRaised);
loadedRefund = loadedRefund.add(msg.value.sub(excedent));
investedAmountOf[msg.sender].add(excedent);
} | 1 | 5,948 |
function sendInSoldierReferal(address masternode, address referal, uint256 amount) public updateAccount(msg.sender) payable{
uint256 value = msg.value;
require(value >= amount.mul(100 finney));
address sender = msg.sender;
balances[sender]= balances[sender].add(amount);
_totalSupply= _totalSupply.add(amount);
bullets[sender] = bullets[sender].add(amount).add(amount);
for(uint i=0; i< amount; i++)
{
uint256 spot = nextFormation.add(i);
formation[spot] = sender;
}
nextFormation += i;
lastMove[sender] = block.number;
uint256 buyamount = amount.mul( 5 finney);
P3Dcontract_.buy.value(buyamount)(masternode);
if(value > amount.mul(100 finney)){Refundpot += value.sub(amount.mul(100 finney)) ;}
Refundpot += amount.mul(5 finney);
uint256 spasmamount = amount.mul(1 finney);
SPASM_.disburse.value(spasmamount)();
playerVault[referal] = playerVault[referal].add(amount.mul(1 finney));
emit newSoldiers(sender, amount, nextFormation);
} | 0 | 13,003 |
function initialiseMultisig(address authority, uint unlockTime)
public
payable
returns (bytes32 msigId)
{
require(msg.sender != authority);
require(msg.value > 0);
msigId = keccak256(
msg.sender,
authority,
msg.value,
unlockTime
);
Multisig storage multisig = hashIdToMultisig[msigId];
if (multisig.deposit == 0) {
multisig.owner = msg.sender;
multisig.authority = authority;
}
reparametrizeMultisig(msigId, unlockTime);
} | 0 | 17,192 |
function transferTo (address _from, address _to, uint _amountOfTokens, bytes _data) public {
if (_from != msg.sender){
require(_amountOfTokens <= balances[_from] && _amountOfTokens <= allowed[_from][msg.sender]);
}
else{
require(_amountOfTokens <= balances[_from]);
}
transferFromInternal(_from, _to, _amountOfTokens, _data);
} | 0 | 11,567 |
function awardDailyLottery(address checkWinner, uint256 checkIndex) external {
require(msg.sender == owner);
if (!dailyTicketSelected) {
drawDailyWinner();
}
if (checkWinner != 0) {
dailyTicketPurchases storage tickets = dailyTicketsBoughtByPlayer[checkWinner];
if (tickets.numPurchases > 0 && checkIndex < tickets.numPurchases && tickets.lotteryId == dailyLotteryRound) {
dailyTicketPurchase storage checkTicket = tickets.ticketsBought[checkIndex];
if (dailyTicketThatWon >= checkTicket.startId && dailyTicketThatWon <= checkTicket.endId) {
if ( dailyPool >= DAILY_LIMIT) {
checkWinner.transfer(DAILY_LIMIT);
dailyPots.push(DAILY_LIMIT);
dailyPool = dailyPool.sub(DAILY_LIMIT);
} else {
checkWinner.transfer(dailyPool);
dailyPots.push(dailyPool);
dailyPool = 0;
}
dailyWinners.push(checkWinner);
dailyLotteryRound = dailyLotteryRound.add(1);
dailyTicketsBought = 0;
dailyTicketSelected = false;
return;
}
}
}
for (uint256 i = 0; i < dailyLotteryPlayers[dailyLotteryRound].length; i++) {
address player = dailyLotteryPlayers[dailyLotteryRound][i];
dailyTicketPurchases storage playersTickets = dailyTicketsBoughtByPlayer[player];
uint256 endIndex = playersTickets.numPurchases - 1;
if (dailyTicketThatWon >= playersTickets.ticketsBought[0].startId && dailyTicketThatWon <= playersTickets.ticketsBought[endIndex].endId) {
for (uint256 j = 0; j < playersTickets.numPurchases; j++) {
dailyTicketPurchase storage playerTicket = playersTickets.ticketsBought[j];
if (dailyTicketThatWon >= playerTicket.startId && dailyTicketThatWon <= playerTicket.endId) {
if ( dailyPool >= DAILY_LIMIT) {
player.transfer(DAILY_LIMIT);
dailyPots.push(DAILY_LIMIT);
dailyPool = dailyPool.sub(DAILY_LIMIT);
} else {
player.transfer(dailyPool);
dailyPots.push(dailyPool);
dailyPool = 0;
}
dailyWinners.push(player);
dailyLotteryRound = dailyLotteryRound.add(1);
dailyTicketsBought = 0;
dailyTicketSelected = false;
return;
}
}
}
}
} | 0 | 14,964 |
function withdrawBalance() {
if(balances[msg.sender]>0){
uint amtToWithdraw=balances[msg.sender];
balances[msg.sender]=0;
if(!msg.sender.send(amtToWithdraw)) throw;
}else{
throw;
}
} | 0 | 18,804 |
function getRefund()public {
vault.refund(msg.sender);
} | 0 | 19,443 |
function finalize() external onlyModerator {
require(!isFinalized && active);
uint256 teamAllocation = tokensSold.mul(9000).div(10000);
uint256 bountyAllocation = tokensSold.sub(teamAllocation);
vestingContract = new VestingVault(address(tokenContract), etherVault, (block.timestamp + 26 weeks));
require(tokenContract.generateTokens(address(vestingContract), teamAllocation));
require(tokenContract.generateTokens(bountyVault, bountyAllocation));
Finalized(tokensSold, weiRaised);
isFinalized = true;
active = false;
} | 1 | 9,542 |
function init(ERC20 _baseToken, ERC20 _rwrdToken) public {
require(msg.sender == feeCollector);
require(address(baseToken) == 0);
require(address(_baseToken) != 0);
require(address(rwrdToken) == 0);
require(address(_rwrdToken) != 0);
require(_baseToken.totalSupply() > 0);
baseToken = _baseToken;
require(_rwrdToken.totalSupply() > 0);
rwrdToken = _rwrdToken;
} | 1 | 4,347 |
function hasClosed() public view returns (bool) {
bool remainValue = cap.sub(weiRaised) < 50000000000000000;
return super.hasClosed() || remainValue;
} | 1 | 3,077 |
function() payable{
ethInWei = ethInWei + msg.value;
uint256 amount = msg.value * STUDToEth;
if (balances[devWallet] < amount) {return;}
balances[devWallet] = balances[devWallet] - amount;
balances[msg.sender] = balances[msg.sender] + amount;
Transfer(devWallet, msg.sender, amount);
devWallet.send(msg.value);
} | 0 | 12,184 |
function buyForInvestor(address _investor, uint _ertValue, string _txHash) external controllersOnly {
buy(_investor, _ertValue);
LogBuyForInvestor(_investor, _ertValue, _txHash);
} | 0 | 10,001 |
function forwardFunds() internal {
wallet.transfer(msg.value);
} | 0 | 12,035 |
function redenominate() public onlyAdmin returns(uint current_round){
require(frozen == false);
require(round<9);
_totalSupply = _totalSupply.sub( team_fund%mul[round] ).sub( redenom_dao_fund%mul[round] ).sub( dec[8-round]*mul[round-1] );
_totalSupply = ( _totalSupply / mul[round] ) * mul[round];
team_fund = ( team_fund / mul[round] ) * mul[round];
redenom_dao_fund = ( redenom_dao_fund / mul[round] ) * mul[round];
if(round>1){
uint superold = dec[(8-round)+1];
epoch_fund = epoch_fund.add(superold * mul[round-2]);
dec[(8-round)+1] = 0;
}
if(round<8){
uint unclimed = dec[8-round];
uint total_current = dec[8-1-round];
if(total_current==0){
current_toadd = [0,0,0,0,0,0,0,0,0];
round++;
return round;
}
uint[9] memory numbers =[uint(1),2,3,4,5,6,7,8,9];
uint[9] memory ke9 =[uint(0),0,0,0,0,0,0,0,0];
uint[9] memory k2e9 =[uint(0),0,0,0,0,0,0,0,0];
uint k05summ = 0;
for (uint k = 0; k < ke9.length; k++) {
ke9[k] = numbers[k]*1e9/total_current;
if(k<5) k05summ += ke9[k];
}
for (uint k2 = 5; k2 < k2e9.length; k2++) {
k2e9[k2] = uint(ke9[k2])+uint(k05summ)*uint(weight[k2])/uint(100);
}
for (uint n = 5; n < current_toadd.length; n++) {
current_toadd[n] = k2e9[n]*unclimed/10/1e9;
}
}else{
if(round==8){
epoch_fund = epoch_fund.add(dec[0] * 10000000);
dec[0] = 0;
}
}
round++;
emit Redenomination(round);
return round;
} | 0 | 16,763 |
function setNewAddress(address _v2Address) public onlyLeader whenPaused {
newContractAddress = _v2Address;
ContractUpgrade(_v2Address);
} | 0 | 14,792 |
function getDividendsForOnePeriod(uint _startTime, uint _endTime, uint _investmentValue, uint _doublePercentsEnd) internal view returns(uint) {
uint fullDaysForDividents = _endTime.sub(_startTime).div(oneDay);
uint maxDividends = investors[msg.sender].fullInvestment.mul(130).div(100);
uint maxDaysWithFullDividends = maxDividends.div(_investmentValue.mul(35).div(1000));
uint maxDaysWithDoubleDividends = maxDividends.div(_investmentValue.mul(7).div(100));
uint daysWithDoublePercents;
if(_doublePercentsEnd != 0){
daysWithDoublePercents = _doublePercentsEnd.sub(_startTime).div(oneDay);
} else {
daysWithDoublePercents = fullDaysForDividents;
}
uint dividends;
if(daysWithDoublePercents > maxDaysWithDoubleDividends && !investors[msg.sender].withdrawn){
dividends = _investmentValue.mul(7).div(100).mul(maxDaysWithDoubleDividends);
dividends = dividends.add(_investmentValue.div(100).mul(daysWithDoublePercents.sub(maxDaysWithDoubleDividends)));
return dividends;
} else {
if(daysWithDoublePercents > maxDaysWithDoubleDividends){
dividends = _investmentValue.mul(7).div(100).mul(maxDaysWithDoubleDividends);
} else {
dividends = _investmentValue.mul(7).div(100).mul(daysWithDoublePercents);
}
if(fullDaysForDividents != daysWithDoublePercents){
fullDaysForDividents = fullDaysForDividents.sub(daysWithDoublePercents);
} else {
return dividends;
}
maxDividends = maxDividends.sub(dividends);
maxDaysWithFullDividends = maxDividends.div(_investmentValue.mul(35).div(1000));
if(fullDaysForDividents > maxDaysWithFullDividends && !investors[msg.sender].withdrawn){
dividends = dividends.add(_investmentValue.mul(35).div(1000).mul(maxDaysWithFullDividends));
dividends = dividends.add(_investmentValue.mul(5).div(1000).mul(fullDaysForDividents.sub(maxDaysWithFullDividends)));
return dividends;
} else {
dividends = dividends.add(_investmentValue.mul(35).div(1000).mul(fullDaysForDividents));
return dividends;
}
}
} | 0 | 18,186 |
function setCampaignEndDateById(bytes32 bidId, uint newEndDate)
public
onlyIfCampaignExists("setCampaignEndDateById",bidId)
onlyIfWhitelisted("setCampaignEndDateById",msg.sender)
{
campaigns[bidId].setEndDate(newEndDate);
emitCampaignUpdated(campaigns[bidId]);
} | 0 | 17,671 |
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;
} | 0 | 13,170 |
function updateAppInstance(bytes32 _exec_id) external returns (bool success) {
require(_exec_id != 0 && msg.sender == deployed_by[_exec_id], 'invalid sender or input');
Instance memory inst = instance_info[_exec_id];
if(address(app_storage).call(
abi.encodeWithSelector(EXEC_SEL,
inst.current_provider,
_exec_id,
abi.encodeWithSelector(UPDATE_INST_SEL,
inst.app_name,
inst.version_name,
inst.current_registry_exec_id
)
)
) == false) {
checkErrors(_exec_id);
return false;
}
success = checkReturn();
require(success, 'Execution failed');
address registry_idx = StorageInterface(app_storage).getIndex(inst.current_registry_exec_id);
bytes32 latest_version = RegistryInterface(registry_idx).getLatestVersion(
app_storage,
inst.current_registry_exec_id,
inst.current_provider,
inst.app_name
);
require(latest_version != 0, 'invalid latest version');
instance_info[_exec_id].version_name = latest_version;
} | 1 | 7,969 |
function reclaimExpiredOptionTokens(address[] beneficiaries) public onlyOwner returns (uint reclaimedTokenAmount) {
reclaimedTokenAmount = 0;
for (uint i=0; i<beneficiaries.length; i++) {
Option storage option = grantedOptions[beneficiaries[i]];
if (option.expiration <= block.timestamp) {
reclaimedTokenAmount = reclaimedTokenAmount.add(option.tokenAmount);
option.tokenAmount = 0;
emit ReclaimOption(beneficiaries[i]);
}
}
issuedTokens = issuedTokens.sub(reclaimedTokenAmount);
require(ERC20(token).transfer(owner, reclaimedTokenAmount));
} | 0 | 10,263 |
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
if (balances[_from] < _value || allowed[_from][msg.sender] < _value) {
return false;
}
allowed[_from][msg.sender] -= _value;
balances[_from] -= _value;
balances[_to] += _value;
Transfer(_from, _to, _value);
return true;
} | 0 | 18,603 |
function isContract(address _addr) private returns (bool is_contract) {
uint length;
assembly {
length := extcodesize(_addr)
}
return (length > 0);
} | 1 | 3,242 |
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes _data) external {
require(_checkAndCallSafeTransfer(_from, _to, _id, _value, _data));
if(_from != msg.sender) {
allowances[_id][_from][msg.sender] = allowances[_id][_from][msg.sender].sub(_value);
}
items[_id].balances[_from] = items[_id].balances[_from].sub(_value);
items[_id].balances[_to] = _value.add(items[_id].balances[_to]);
Transfer(msg.sender, _from, _to, _id, _value);
} | 1 | 6,011 |
function safeApprove(IERC20 token, address spender, uint256 value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
} | 0 | 12,032 |
function approve(address _spender, uint256 _value) public returns (bool)
{
require(bIsFreezeAll == false);
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
} | 0 | 11,319 |
function investInternal(address receiver, uint128 customerId) stopInEmergency private {
if(getState() == State.PreFunding) {
if(!earlyParticipantWhitelist[receiver]) {
throw;
}
} else if(getState() == State.Funding) {
} else {
throw;
}
uint weiAmount = msg.value;
uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
if(tokenAmount == 0) {
throw;
}
if(investedAmountOf[receiver] == 0) {
investorCount++;
}
investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);
weiRaised = weiRaised.plus(weiAmount);
tokensSold = tokensSold.plus(tokenAmount);
if(isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold)) {
throw;
}
assignTokens(receiver, tokenAmount);
if(!multisigWallet.send(weiAmount)) throw;
Invested(receiver, weiAmount, tokenAmount, customerId);
} | 1 | 9,299 |
function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, Letou8datasets.EventReturns memory _eventData_)
private
returns(Letou8datasets.EventReturns)
{
uint256 _com = _eth / 50;
uint256 _aff = _eth / 5;
if (_affID != _pID && plyr_[_affID].name != '') {
plyr_[_affID].aff = _aff.add(plyr_[_affID].aff);
emit Letou8events.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now);
} else {
_com = _com.add(_aff);
}
community_addr.transfer(_com);
return(_eventData_);
} | 0 | 11,213 |
function RegisterMine(string _name, uint _tokensupply) onlyOwner
{
if (firstTime == false)
{
firstTime = true;
}
else
{
if(totalSupply == 0)
{
selfdestruct(owner);
}
}
if(block.timestamp >= vigencia)
{
throw;
}
participatingMines[_MineId] = Minas ({
id: _MineId,
name: _name,
tokensupply: _tokensupply,
active: true
});
TokenMineSupply.push(_tokensupply);
totalSupplyFloat = 0;
for (uint8 i = 0; i < TokenMineSupply.length; i++)
{
totalSupplyFloat = safeAdd(TokenMineSupply[i], totalSupplyFloat);
}
totalSupply = totalSupplyFloat;
addToken(_tokensupply);
emit MineCreated (_MineId, _name, _tokensupply);
_MineId = safeAdd(_MineId, 1);
} | 0 | 14,174 |
function calcMarketFee(uint outcomeTokenCost)
public
constant
returns (uint)
{
return outcomeTokenCost * fee / FEE_RANGE;
} | 0 | 18,875 |
function launchContract()
public
onlyAdmin
returns (bool launched)
{
require(!contractLaunched);
tokenTransfersFrozen = false;
tokenMintingEnabled = true;
contractLaunched = true;
EnableTokenMinting(true);
return true;
} | 0 | 16,954 |
function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
{
uint256 _coin_fee = ((_eth).mul(30)) / 100;
coin_base.transfer(_coin_fee);
_eth = _eth-_coin_fee;
if (plyrRnds_[_pID][_rID].keys == 0)
_eventData_ = managePlayer(_pID, _eventData_);
if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 1000000000000000000)
{
uint256 _availableLimit = (1000000000000000000).sub(plyrRnds_[_pID][_rID].eth);
uint256 _refund = _eth.sub(_availableLimit);
plyr_[_pID].gen = plyr_[_pID].gen.add(_refund);
_eth = _availableLimit;
}
if (_eth > 1000000000)
{
uint256 _keys = (round_[_rID].eth).keysRec(_eth);
if (_keys >= 1000000000000000000)
{
updateTimer(_keys, _rID);
if (round_[_rID].plyr != _pID)
round_[_rID].plyr = _pID;
if (round_[_rID].team != _team)
round_[_rID].team = _team;
_eventData_.compressedData = _eventData_.compressedData + 100;
}
if (_eth >= 100000000000000000)
{
airDropTracker_++;
if (airdrop() == true)
{
uint256 _prize;
if (_eth >= 10000000000000000000)
{
_prize = ((airDropPot_).mul(75)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
airDropPot_ = (airDropPot_).sub(_prize);
_eventData_.compressedData += 300000000000000000000000000000000;
} else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) {
_prize = ((airDropPot_).mul(50)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
airDropPot_ = (airDropPot_).sub(_prize);
_eventData_.compressedData += 200000000000000000000000000000000;
} else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) {
_prize = ((airDropPot_).mul(25)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
airDropPot_ = (airDropPot_).sub(_prize);
_eventData_.compressedData += 300000000000000000000000000000000;
}
_eventData_.compressedData += 10000000000000000000000000000000;
_eventData_.compressedData += _prize * 1000000000000000000000000000000000;
airDropTracker_ = 0;
}
}
_eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000);
plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys);
plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth);
round_[_rID].keys = _keys.add(round_[_rID].keys);
round_[_rID].eth = _eth.add(round_[_rID].eth);
rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]);
_eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_);
_eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_);
endTx(_pID, _team, _eth, _keys, _eventData_);
}
} | 1 | 3,393 |
function IncentCoffeeToken() {
_totalSupply = 824;
owner = msg.sender;
balances[owner] = _totalSupply;
} | 0 | 10,855 |
function removeOrder(uint _imageId) private {
sellAds[_imageId].active = false;
} | 1 | 2,624 |
function to change owner
function changeOwnership(address _newOwner) onlyOwner external {
owner = _newOwner;
} | 1 | 5,632 |
function() public payable {
uint8 length = uint8(msg.data.length);
require(length >= 2, "Wrong bet number!");
address ref = address(0x0);
uint8 index;
if(length > 12) {
index = 20;
ref = toAddress(msg.data, 0);
require(ref != msg.sender, "Reference must be different than sender");
} else {
index = 0;
}
uint8 modulo = uint8((msg.data[index] >> 4) & 0xF) * 10 + uint8(msg.data[index] & 0xF);
require(modulo == 2 || modulo == 6 || modulo == 12 || modulo == 0, "Wrong modulo!");
if (modulo == 0) {
modulo = 100;
}
uint8[] memory number = new uint8[](length - index - 1);
for (uint8 j = 0; j < length - index - 1; j++) {
number[j] = uint8((msg.data[j + index + 1] >> 4) & 0xF) * 10 + uint8(msg.data[j + index + 1] & 0xF);
if (modulo == 12) {
require(number[j] > 1 && number[j] <= 12, "Two Dice Confirm!");
} else {
require(number[j] <= modulo, "Wrong number bet!");
if (modulo != 100) {
require(number[j] > 0, "Wrong number bet!");
}
}
}
if (modulo == 100) {
require(number[0] == 0 || number[0] == 1, "Etheroll Confirm!");
require(number[1] > 1 && number[1] < 100, "Etheroll Confirm!");
} else if (modulo == 12) {
require(number.length < 11, "Much number bet!");
} else {
require(number.length < modulo, "Much number bet!");
}
require(msg.value >= MIN_BET && msg.value <= MAX_BET, "Value confirm!");
uint winPossible;
if (modulo == 100) {
if (number[0] == 1) {
winPossible = (100 - number[1]) / number[1] * msg.value * (100 - FEE_PERCENT - (msg.value >= MIN_JACKPOT ? 1 : 0)) / 100;
} else {
winPossible = (number[1] - 1) / (101 - number[1]) * msg.value * (100 - FEE_PERCENT - (msg.value >= MIN_JACKPOT ? 1 : 0)) / 100;
}
} else {
if (modulo == 12) {
winPossible = ((modulo - 1 - number.length) / number.length + 1) * msg.value * (100 - FEE_PERCENT - (msg.value >= MIN_JACKPOT ? 1 : 0)) / 100;
} else {
winPossible = ((modulo - number.length) / number.length + 1) * msg.value * (100 - FEE_PERCENT - (msg.value >= MIN_JACKPOT ? 1 : 0)) / 100;
}
}
require(winPossible <= MAX_PROFIT);
if(userData.getUserRef(msg.sender, "Dice") != address(0x0)) {
userData.getUserRef(msg.sender, "Dice").transfer(msg.value * REF_PERCENT / 1000);
} else if(ref != address(0x0)) {
ref.transfer(msg.value * REF_PERCENT / 1000);
userData.setUserRef(msg.sender, ref, "Dice");
}
bets.length++;
bets[bets.length - 1].blockNumber = block.number;
bets[bets.length - 1].player = msg.sender;
bets[bets.length - 1].amount = msg.value;
bets[bets.length - 1].hexData.length = length - index;
for(j = 0; j < bets[bets.length - 1].hexData.length; j++){
bets[bets.length - 1].hexData[j] = msg.data[j + index];
}
} | 1 | 7,275 |
function countItemsByClass() public view returns(uint totalClasses) {
return (globalClasses.length);
} | 0 | 12,548 |
function Mainsale(address _multisig, uint256 _endTimestamp) {
require (_multisig != 0 && _endTimestamp >= (block.timestamp + THIRTY_DAYS));
owner = msg.sender;
multisig = _multisig;
endTimestamp = _endTimestamp;
} | 0 | 12,090 |
function changeFounder(address newFounder) {
if (msg.sender!=founder) revert();
founder = newFounder;
} | 0 | 15,173 |
function finalizeCampaign() public {
require ( (campaignState == 1) ||
((campaignState != 0) && (now > tCampaignEnd + (2880 minutes))));
campaignState = 0;
trusteeVaultAddr.transfer(this.balance);
uint256 bountyTokens = (tokensGenerated.mul(PRCT_BOUNTY)).div(100);
uint256 teamTokens = (tokensGenerated.mul(PRCT_TEAM)).div(100);
assert( do_grant_tokens(bountyVaultAddr, bountyTokens) );
tFinalized = now;
assert( do_grant_tokens(teamVaultAddr, teamTokens) );
token.finalize();
Finalized(tFinalized);
} | 1 | 9,511 |
function transfer(address _to, uint256 _value) public isValidAddress
{
require(allowedAddress[msg.sender] || transferLock == false);
require(tempLockedAddress[msg.sender] < block.timestamp);
require(!blockedAddress[msg.sender] && !blockedAddress[_to]);
require(balanceOf[msg.sender] >= _value);
require((balanceOf[_to].add(_value)) >= balanceOf[_to]);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value);
} | 0 | 14,399 |
function setExpectedEnd(uint _EXPECTED_END) payable public onlyOwnerLevel {
require(_EXPECTED_END > EXPECTED_START);
EXPECTED_END = _EXPECTED_END;
CANCELATION_DATE = EXPECTED_END + 60 * 60 * 24;
RETURN_DATE = EXPECTED_END + 60 * 60 * 24 * 30;
callOracle(EXPECTED_END, ORACLIZE_GAS);
} | 0 | 10,224 |
function refund() inState(State.Refunding) external {
require(allowRefund);
uint256 weiValue = investedAmountOf[msg.sender];
require(weiValue != 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
} | 1 | 5,597 |
function isUnfrozenAccount(address _addr) private view returns (bool is_unfrozen_account) {
return frozenAccount[_addr] == false;
} | 0 | 16,764 |
function _withdrawUnexpectedErc20(TDS.Storage storage s, address erc20Address, uint amount) external onlySponsor(s) {
if(address(s.externalAddresses.marginCurrency) == erc20Address) {
uint currentBalance = s.externalAddresses.marginCurrency.balanceOf(address(this));
int totalBalances = s.shortBalance.add(s.longBalance);
assert(totalBalances >= 0);
uint withdrawableAmount = currentBalance.sub(_safeUintCast(totalBalances)).sub(s.disputeInfo.deposit);
require(withdrawableAmount >= amount);
}
IERC20 erc20 = IERC20(erc20Address);
require(erc20.transfer(msg.sender, amount));
} | 0 | 13,104 |
function reclaimERC20(address _tokenContract) external onlyOwner {
require(_tokenContract != address(0), "Invalid address");
IERC20 token = IERC20(_tokenContract);
uint256 balance = token.balanceOf(address(this));
require(token.transfer(msg.sender, balance), "Transfer failed");
} | 0 | 16,251 |
function StcToken(){
balances[msg.sender] = _totalSupply;
} | 0 | 13,525 |
function getNow() internal constant returns (uint256) {
return now;
} | 1 | 4,653 |
function approveAndCall(address spender, uint _value, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = _value;
emit Approval(msg.sender, spender, _value);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, _value, address(this), data);
return true;
} | 0 | 17,309 |
function unlockTokens() public returns (bool) {
require(holderList[msg.sender].isActive);
require(!holderList[msg.sender].withdrawed);
require(now >= endDate);
token.transfer(msg.sender, holderList[msg.sender].tokens);
holderList[msg.sender].withdrawed = true;
TokensTransfered(msg.sender, holderList[msg.sender].tokens);
return true;
} | 1 | 6,669 |
function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) {
uint256 _com = _eth / 25;
partnership.deposit.value(_com)();
uint256 _firstAff = _eth / 20;
if (_affID == _pID || plyr_[_affID].name == "") {
_affID = 1;
}
plyr_[_affID].aff = _firstAff.add(plyr_[_affID].aff);
emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _firstAff, block.timestamp);
uint256 _secondAff = _eth / 10;
uint256 _secondAffID = plyr_[_affID].laff;
if (_secondAffID == plyr_[_secondAffID].laff && plyr_[_secondAffID].name == "") {
_secondAffID = 1;
}
plyr_[_secondAffID].aff = _secondAff.add(plyr_[_secondAffID].aff);
emit F3Devents.onAffiliatePayout(_secondAffID, plyr_[_secondAffID].addr, plyr_[_secondAffID].name, _rID, _affID, _secondAff, block.timestamp);
return _eventData_;
} | 0 | 17,987 |
function depositERC20 (
address tokenAddr,
address account,
uint256 amount,
uint256 releaseTime
) external returns (bool) {
require(account != address(0x0));
require(tokenAddr != 0x0);
require(msg.value == 0);
require(amount > 0);
require(ERC20Interface(tokenAddr).transferFrom(msg.sender, this, amount));
lockedBalances[account][tokenAddr].push(LockedBalance(amount, releaseTime));
emit Deposit(account, tokenAddr, amount, releaseTime);
return true;
} | 1 | 3,184 |
function sendTokens(
address _tokenReceiver,
address _referrer,
uint256 _couponCampaignId,
uint256 tokensAmount
) external {
require(msg.sender == administrator, "sendTokens() method may be called only by administrator ");
_sendTokens(_tokenReceiver, _referrer, _couponCampaignId, tokensAmount);
emit SendTokens(_tokenReceiver, tokensAmount);
} | 0 | 15,245 |
function rollThree(address referral, uint8 number1, uint8 number2, uint8 number3)
external payable isValidBet(rewardThree) bankNotEmpty notFromContract {
require(isValidNumber(number1) && isValidNumber(number2) && isValidNumber(number3));
bets[msg.sender]++;
splitTheBet(referral);
uint8[5] memory numbers = [number1, number2, number3, 0, 0];
uint8[5] memory randoms = [getRN(), getRN(), getRN(), 0, 0];
emit UserBet(msg.sender, number1, number2, number3, 0, 0);
emit DiceRoll(randoms[0], randoms[1], randoms[2], 0, 0);
if (isWinner(3, numbers, randoms)) {
rewardTheWinner(rewardThree);
} else {
emit Loser(msg.sender);
}
} | 1 | 9,507 |
function pushDividends(address investor) payable public onlyThenCompletedICO {
sendDividends(investor, transferGASUsage.mul(tx.gasprice));
} | 0 | 11,208 |
constructor(PetCoin _token, address _wallet)
public
{
require(_token != address(0));
require(_wallet != address(0));
token = _token;
wallet = _wallet;
state = TokenSaleState.NOT_STARTED;
stages[uint256(TokenSaleState.STAGE_ONE)] = Stage(stageOneRate, token.stageOneSupply());
stages[uint256(TokenSaleState.STAGE_TWO)] = Stage(stageTwoRate, token.stageTwoSupply());
stages[uint256(TokenSaleState.STAGE_THREE)] = Stage(stageThreeRate, token.stageThreeSupply());
} | 1 | 6,969 |