function
stringlengths 4
5.03k
| label
int64 0
1
|
---|---|
function purchase(uint256 _tokenId) public
payable
isNotContract(msg.sender)
{
CryptoColor storage cryptoColor = cryptoColorData[_tokenId];
uint256 price = cryptoColor.price;
address oldOwner = cryptoColor.owner;
address newOwner = msg.sender;
uint256 excess = msg.value.sub(price);
require(price > 0);
require(msg.value >= price);
require(oldOwner != msg.sender);
uint256 profit = price.sub(cryptoColor.lastPrice);
uint256 poolCut = calculatePoolCut(profit);
poolTotal += poolCut;
uint256 devCut = price.mul(5).div(100);
devOwed = devOwed.add(devCut);
transfer(oldOwner, newOwner, _tokenId);
cryptoColor.lastPrice = price;
cryptoColor.price = getNextPrice(price);
TokenSold(_tokenId, newOwner, price, cryptoColor.price, oldOwner);
oldOwner.transfer(price.sub(devCut.add(poolCut)));
if (excess > 0) {
newOwner.transfer(excess);
}
lastPurchase = now;
} | 1 |
function _transfer(uint _fromId, uint _toId, uint _value, bytes32 _symbol, string _reference, uint _senderId) internal returns (uint) {
if (_fromId == _toId) {
return _error(CAV_PLATFORM_CANNOT_APPLY_TO_ONESELF);
}
if (_value == 0) {
return _error(CAV_PLATFORM_INVALID_VALUE);
}
if (_balanceOf(_fromId, _symbol) < _value) {
return _error(CAV_PLATFORM_INSUFFICIENT_BALANCE);
}
if (_fromId != _senderId && _allowance(_fromId, _senderId, _symbol) < _value) {
return _error(CAV_PLATFORM_NOT_ENOUGH_ALLOWANCE);
}
_transferDirect(_fromId, _toId, _value, _symbol);
if (_fromId != _senderId) {
assets[_symbol].wallets[_fromId].allowance[_senderId] = assets[_symbol].wallets[_fromId].allowance[_senderId].sub(_value);
}
CAVPlatformEmitter(eventsHistory).emitTransfer(_address(_fromId), _address(_toId), _symbol, _value, _reference);
_proxyTransferEvent(_fromId, _toId, _value, _symbol);
return OK;
} | 0 |
function balanceOf(address _owner) constant returns (uint256 balance);
function transfer(address _to, uint256 _value) returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract AgoraToken is ERC20Interface {
address contractOwner;
string public constant name = "Agora";
string public constant symbol = "AGO";
uint8 public constant decimals = 0;
struct BalanceSnapshot {
bool initialized;
uint256 value;
} | 0 |
function undo() public {
var wad = to.balanceOf(msg.sender);
require(now < undo_deadline);
require(from.transfer(msg.sender, wad));
to.pull(msg.sender, wad);
} | 1 |
function LINKFund() {
min_buy_block = block.number + 5184;
min_refund_block = block.number + 86400;
} | 0 |
modifier hasEnoughUnlockedTokens(address _user, uint256 _value) {
if (ccLockedUpBalances[_user] > 0 && block.number < ccReleaseBlock) {
require ((SafeMath.sub(balances[_user], _value)) >= ccLockedUpBalances[_user]);
}
_;
} | 0 |
function mint(address _to, uint256 _amount) onlyOwner public returns (bool) {
require(_to != address(0));
require( add(totalSupply, _amount) <= (CAP_TO_GIVE_AWAY + (now >= TEAM_CAP_RELEASE_TIME ? CAP_FOR_THE_TEAM : 0)) );
totalSupply = add(totalSupply, _amount);
balanceOf[_to] = add(balanceOf[_to], _amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
} | 1 |
modifier onlyWhitelist() {
require(blacklist[msg.sender] == false);
_;
} | 1 |
} function thisweek() internal view returns (uint256) {
return now / 1 weeks;
} function getAirDropedToday() public view returns (uint256) {
if (thisweek() > lastWeek) return 0;
else return aDropedThisWeek;
}
function transferBalance(address upContract) external onlyControl {
require(upContract != address(0) && upContract.send(this.balance));
}
function () payable public {
uint256 qty = calc(msg.value);
if(qty > 0) {
balances[msg.sender] += qty;
balances[owner] -= qty;
RecordTransfer(owner, msg.sender, qty);
update();
} else revert(); | 1 |
function addressToString(address x) private pure returns (string) {
bytes memory b = new bytes(20);
for (uint i = 0; i < 20; i++)
b[i] = byte(uint8(uint(x) / (2**(8*(19 - i)))));
return string(b);
} | 1 |
function buyPreIco(address investor) internal{
uint256 weiAmount = msg.value;
uint256 bonusPrice = 0;
uint256 tokens = weiAmount.mul(10**18).div(price);
if(endBlockBonus1 >= getBlockNumber()){
if(tokens == qnt10k.mul(19) ){
bonusPrice = 2775652173913040;
}else if(tokens >= qnt10k.mul(18) && tokens < qnt10k.mul(19)){
bonusPrice = 2907826086956520;
}else if(tokens >= qnt10k.mul(17) && tokens < qnt10k.mul(18)){
bonusPrice = 3040000000000000;
}else if(tokens >= qnt10k.mul(16) && tokens < qnt10k.mul(17)){
bonusPrice = 3172173913043480;
}else if(tokens >= qnt10k.mul(15) && tokens < qnt10k.mul(16)){
bonusPrice = 3304347826086960;
}else if(tokens >= qnt10k.mul(14) && tokens < qnt10k.mul(15)){
bonusPrice = 3436521739130430;
}else if(tokens >= qnt10k.mul(13) && tokens < qnt10k.mul(14)){
bonusPrice = 3568695652173910;
}else if(tokens >= qnt10k.mul(12) && tokens < qnt10k.mul(13)){
bonusPrice = 3700869565217390;
}else if(tokens >= qnt10k.mul(11) && tokens < qnt10k.mul(12)){
bonusPrice = 3833043478260870;
}else if(tokens >= qnt10k.mul(10) && tokens < qnt10k.mul(11)){
bonusPrice = 3965217391304350;
}else if(tokens >= qnt10k.mul(9) && tokens < qnt10k.mul(10)){
bonusPrice = 4097391304347830;
}else if(tokens >= qnt10k.mul(8) && tokens < qnt10k.mul(9)){
bonusPrice = 4229565217391300;
}else if(tokens >= qnt10k.mul(7) && tokens < qnt10k.mul(8)){
bonusPrice = 4361739130434780;
}else if(tokens >= qnt10k.mul(6) && tokens < qnt10k.mul(7)){
bonusPrice = 4493913043478260;
}else if(tokens >= qnt10k.mul(5) && tokens < qnt10k.mul(6)){
bonusPrice = 4626086956521740;
}else{
bonusPrice = 5286956521739130;
}
}else if(endBlockBonus2 >= getBlockNumber()){
if(tokens == qnt10k.mul(19) ){
bonusPrice = 3436521739130430;
}else if(tokens >= qnt10k.mul(18) && tokens < qnt10k.mul(19)){
bonusPrice = 3568695652173910;
}else if(tokens >= qnt10k.mul(17) && tokens < qnt10k.mul(18)){
bonusPrice = 3700869565217390;
}else if(tokens >= qnt10k.mul(16) && tokens < qnt10k.mul(17)){
bonusPrice = 3833043478260870;
}else if(tokens >= qnt10k.mul(15) && tokens < qnt10k.mul(16)){
bonusPrice = 3965217391304350;
}else if(tokens >= qnt10k.mul(14) && tokens < qnt10k.mul(15)){
bonusPrice = 4097391304347830;
}else if(tokens >= qnt10k.mul(13) && tokens < qnt10k.mul(14)){
bonusPrice = 4229565217391300;
}else if(tokens >= qnt10k.mul(12) && tokens < qnt10k.mul(13)){
bonusPrice = 4361739130434780;
}else if(tokens >= qnt10k.mul(11) && tokens < qnt10k.mul(12)){
bonusPrice = 4493913043478260;
}else if(tokens >= qnt10k.mul(10) && tokens < qnt10k.mul(11)){
bonusPrice = 4626086956521740;
}else if(tokens >= qnt10k.mul(9) && tokens < qnt10k.mul(10)){
bonusPrice = 4758260869565220;
}else if(tokens >= qnt10k.mul(8) && tokens < qnt10k.mul(9)){
bonusPrice = 4890434782608700;
}else if(tokens >= qnt10k.mul(7) && tokens < qnt10k.mul(8)){
bonusPrice = 5022608695652170;
}else if(tokens >= qnt10k.mul(6) && tokens < qnt10k.mul(7)){
bonusPrice = 5154782608695650;
}else if(tokens >= qnt10k.mul(5) && tokens < qnt10k.mul(6)){
bonusPrice = 5286956521739130;
}else{
bonusPrice = 5947826086956520;
}
}else{
if(tokens == qnt10k.mul(19) ){
bonusPrice = 3766956521739130;
}else if(tokens >= qnt10k.mul(18) && tokens < qnt10k.mul(19)){
bonusPrice = 3899130434782610;
}else if(tokens >= qnt10k.mul(17) && tokens < qnt10k.mul(18)){
bonusPrice = 4031304347826090;
}else if(tokens >= qnt10k.mul(16) && tokens < qnt10k.mul(17)){
bonusPrice = 4163478260869570;
}else if(tokens >= qnt10k.mul(15) && tokens < qnt10k.mul(16)){
bonusPrice = 4295652173913040;
}else if(tokens >= qnt10k.mul(14) && tokens < qnt10k.mul(15)){
bonusPrice = 4427826086956520;
}else if(tokens >= qnt10k.mul(13) && tokens < qnt10k.mul(14)){
bonusPrice = 4560000000000000;
}else if(tokens >= qnt10k.mul(12) && tokens < qnt10k.mul(13)){
bonusPrice = 4692173913043480;
}else if(tokens >= qnt10k.mul(11) && tokens < qnt10k.mul(12)){
bonusPrice = 4824347826086960;
}else if(tokens >= qnt10k.mul(10) && tokens < qnt10k.mul(11)){
bonusPrice = 4956521739130430;
}else if(tokens >= qnt10k.mul(9) && tokens < qnt10k.mul(10)){
bonusPrice = 5088695652173910;
}else if(tokens >= qnt10k.mul(8) && tokens < qnt10k.mul(9)){
bonusPrice = 5220869565217390;
}else if(tokens >= qnt10k.mul(7) && tokens < qnt10k.mul(8)){
bonusPrice = 5353043478260870;
}else if(tokens >= qnt10k.mul(6) && tokens < qnt10k.mul(7)){
bonusPrice = 5485217391304350;
}else if(tokens >= qnt10k.mul(5) && tokens < qnt10k.mul(6)){
bonusPrice = 5617391304347830;
}else{
bonusPrice = 6278260869565220;
}
}
tokens = weiAmount.mul(10**18).div(bonusPrice);
require(pylonSelled + tokens <= bonusCap);
require(balanceOf[investor] + tokens <= maxTokens);
require(balanceOf[this] >= tokens);
balanceOf[this] -= tokens;
balanceOf[investor] += tokens;
amountRaised += weiAmount;
pylonSelled += tokens;
beneficiary.transfer(weiAmount);
frozenAccount[investor] = true;
FrozenFunds(investor, true);
TokenPurchase(msg.sender, investor, weiAmount, tokens);
} | 1 |
function getCompetitionStatusOfHopefuls()
view
returns(
address[] fundAddrs,
address[] fundManagers,
bool[] areCompeting,
bool[] areDisqualified
)
{
for (uint i = 0; i <= hopefuls.length - 1; i++) {
fundAddrs[i] = hopefuls[i].fund;
fundManagers[i] = hopefuls[i].manager;
areCompeting[i] = hopefuls[i].isCompeting;
areDisqualified[i] = hopefuls[i].isDisqualified;
}
return (fundAddrs, fundManagers, areCompeting, areDisqualified);
} | 1 |
function unlockTokens() public returns (bool) {
require(holderList[msg.sender].isActive);
require(!holderList[msg.sender].withdrawed);
require(now >= holderList[msg.sender].holdPeriodTimestamp);
OppToken.transfer(msg.sender, holderList[msg.sender].tokens);
holderList[msg.sender].withdrawed = true;
TokensTransfered(msg.sender, holderList[msg.sender].tokens);
return true;
} | 1 |
function emitError(bytes32 _message);
}
contract Proxy {
function emitTransfer(address _from, address _to, uint _value);
function emitApprove(address _from, address _spender, uint _value);
}
contract ChronoBankPlatform is Owned {
struct Asset {
uint owner;
uint totalSupply;
string name;
string description;
bool isReissuable;
uint8 baseUnit;
mapping(uint => Wallet) wallets;
} | 0 |
function logEvent() internal {
LogEvent(nonce++, msg.sender, msg.sig, msg.data, now, tx.gasprice);
} | 1 |
function approve(address _spender, uint _value) returns (bool success);
event Approval(address indexed owner, address indexed spender, uint value);
}
contract StandardToken is ERC20, SafeMathLib{
event Minted(address receiver, uint amount);
mapping(address => uint) balances;
mapping (address => mapping (address => uint)) allowed;
modifier onlyPayloadSize(uint size) {
if(msg.data.length != size + 4) {
throw;
}
_;
} | 0 |
function withdrawAfter18Years(address to)
public
{
require(now >= edaBirthday + 567648000);
require(msg.sender == dom || msg.sender == majaALubo);
withdraw(to);
} | 1 |
function isAuthorized(address logger) returns (bool) {
return authorizedLoggers[logger];
} | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.