Unnamed: 0
int64 0
7.36k
| comments
stringlengths 3
35.2k
| code_string
stringlengths 1
527k
| code
stringlengths 1
527k
| __index_level_0__
int64 0
88.6k
|
---|---|---|---|---|
13 | // Fractionalize an ERC721 token/nftContract The ERC721 contract for the token you're fractionalizing/tokenId The ID of the token you're fractionalizing/supply The amount of ERC20 tokens to issue for this token. These will be distributed to the caller/name The name for the resultant ERC20 token/symbol The symbol for the resultant ERC20 token/ return The ID of the created vault/Remember to call setApprovalForAll(<address of this contract>, true) on the ERC721's contract before calling this function | function split(
ERC721 nftContract,
uint256 tokenId,
uint256 supply,
string memory name,
string memory symbol
| function split(
ERC721 nftContract,
uint256 tokenId,
uint256 supply,
string memory name,
string memory symbol
| 30,656 |
34 | // pick a winner and transfer winnings to account | address luckyDrawWinner = luckyDraw.draw();
plyr_[luckyDrawWinner].gen = plyr_[luckyDrawWinner].gen.add(luckyDrawVault_);
lastLuckyDrawAmt = luckyDrawVault_;
luckyDrawVault_ = 0;
lastLuckyDrawTime = now;
emit luckyDrawDeclared(luckyDrawWinner, lastLuckyDrawAmt, now);
| address luckyDrawWinner = luckyDraw.draw();
plyr_[luckyDrawWinner].gen = plyr_[luckyDrawWinner].gen.add(luckyDrawVault_);
lastLuckyDrawAmt = luckyDrawVault_;
luckyDrawVault_ = 0;
lastLuckyDrawTime = now;
emit luckyDrawDeclared(luckyDrawWinner, lastLuckyDrawAmt, now);
| 11,355 |
11 | // Transfer balances to origin | uint256 sellBal = sell.balanceOf(address(this));
boughtAmt = buy.balanceOf(address(this));
if (sellBal > 0) IERC20Upgradeable(address(sell)).safeTransfer(origin, sellBal);
if (boughtAmt > 0) IERC20Upgradeable(address(buy)).safeTransfer(origin, boughtAmt);
| uint256 sellBal = sell.balanceOf(address(this));
boughtAmt = buy.balanceOf(address(this));
if (sellBal > 0) IERC20Upgradeable(address(sell)).safeTransfer(origin, sellBal);
if (boughtAmt > 0) IERC20Upgradeable(address(buy)).safeTransfer(origin, boughtAmt);
| 50,794 |
36 | // check if this token is sold or reserved | if (_is_extra_sold(minted_id) || _is_airdrop_reservered(minted_id)) {
| if (_is_extra_sold(minted_id) || _is_airdrop_reservered(minted_id)) {
| 13,335 |
174 | // The typehash for the data type specified in the structured data https:github.com/ethereum/EIPs/blob/master/EIPS/eip-712.mdrationale-for-typehash | bytes32 internal constant MINTER_TYPEHASH = keccak256("Minter(address wallet,int max)");
| bytes32 internal constant MINTER_TYPEHASH = keccak256("Minter(address wallet,int max)");
| 78,094 |
163 | // 仅允许在 2019/11/01 00:00:01 之后提取 | require(block.timestamp >= TIMESTAMP_OF_20191101000001);
require(transfer(ownerWallet, _amount));
emit TransferLog(owner, ownerWallet, bytes32("withdrawToTeamStep2"), _amount);
totalTeamReleased2 = totalTeamReleased2.add(_amount);
| require(block.timestamp >= TIMESTAMP_OF_20191101000001);
require(transfer(ownerWallet, _amount));
emit TransferLog(owner, ownerWallet, bytes32("withdrawToTeamStep2"), _amount);
totalTeamReleased2 = totalTeamReleased2.add(_amount);
| 39,368 |
17 | // more than 50% of approvers to finalize | DecimalMath.UFixed memory percentOfRequestApprovals = DecimalMath.muld(
DecimalMath.divd(
DecimalMath.toUFixed(request.approvalCount),
DecimalMath.toUFixed(campaignInterface.approversCount())
),
campaignInterface.percent()
);
require(
percentOfRequestApprovals.value >=
CampaignFactoryLib
| DecimalMath.UFixed memory percentOfRequestApprovals = DecimalMath.muld(
DecimalMath.divd(
DecimalMath.toUFixed(request.approvalCount),
DecimalMath.toUFixed(campaignInterface.approversCount())
),
campaignInterface.percent()
);
require(
percentOfRequestApprovals.value >=
CampaignFactoryLib
| 50,302 |
455 | // 2、添加流动池 | bool hasPool = false;
uint poolIndex;
for(uint i = 0; i < pools.length; i++){
| bool hasPool = false;
uint poolIndex;
for(uint i = 0; i < pools.length; i++){
| 50,271 |
448 | // Store wrapped token ID | wrappedTokenID = IERC20Wrapper(_tokenWrapper).getTokenID(_erc20);
| wrappedTokenID = IERC20Wrapper(_tokenWrapper).getTokenID(_erc20);
| 35,145 |
113 | // Allow owner to adjust the cap during the presale. This allows e.g. US dollar pegged caps. / | function setWeiCap(uint newCap) public onlyOwner {
saleWeiCap = newCap;
CapUpdated(newCap);
}
| function setWeiCap(uint newCap) public onlyOwner {
saleWeiCap = newCap;
CapUpdated(newCap);
}
| 68,289 |
6 | // accumulated Choco Token, updated every time a user stake its LP tokens | uint256 accChocoPerShare;
| uint256 accChocoPerShare;
| 26,406 |
135 | // address public RVPToken = address(0x3B00Ef435fA4FcFF5C209a37d1f3dcff37c705aD); |
bool private swapping;
TESTMAINDividendTracker public dividendTracker;
address public liquidityWallet;
address public deadWallet = 0x000000000000000000000000000000000000dEaD;
uint256 public swapTokensAtAmount = 1000000000 * (10**9);
|
bool private swapping;
TESTMAINDividendTracker public dividendTracker;
address public liquidityWallet;
address public deadWallet = 0x000000000000000000000000000000000000dEaD;
uint256 public swapTokensAtAmount = 1000000000 * (10**9);
| 32,124 |
4 | // Control | function getLockAmount() public view returns (uint256){
return token.balanceOf(address(this));
}
| function getLockAmount() public view returns (uint256){
return token.balanceOf(address(this));
}
| 38,676 |
37 | // `balances` is the map that tracks the balance of each address, in thiscontract when the balance changes the block number that the changeoccurred is also included in the map | mapping (address => Checkpoint[]) private balances;
| mapping (address => Checkpoint[]) private balances;
| 10,001 |
136 | // Emit the reward ID for frontend | uint32 moves = furball.moves + 1;
furballs[tokenId].moves = moves;
emit Collection(tokenId, moves);
| uint32 moves = furball.moves + 1;
furballs[tokenId].moves = moves;
emit Collection(tokenId, moves);
| 33,901 |
4 | // Interface for our erc20 token | interface IMuseToken {
function totalSupply() external view returns (uint256);
function balanceOf(address tokenOwner)
external
view
returns (uint256 balance);
function allowance(address tokenOwner, address spender)
external
view
returns (uint256 remaining);
function transfer(address to, uint256 tokens)
external
returns (bool success);
function approve(address spender, uint256 tokens)
external
returns (bool success);
function transferFrom(
address from,
address to,
uint256 tokens
) external returns (bool success);
function mintingFinished() external view returns (bool);
function mint(address to, uint256 amount) external;
function burn(uint256 amount) external;
function burnFrom(address account, uint256 amount) external;
}
| interface IMuseToken {
function totalSupply() external view returns (uint256);
function balanceOf(address tokenOwner)
external
view
returns (uint256 balance);
function allowance(address tokenOwner, address spender)
external
view
returns (uint256 remaining);
function transfer(address to, uint256 tokens)
external
returns (bool success);
function approve(address spender, uint256 tokens)
external
returns (bool success);
function transferFrom(
address from,
address to,
uint256 tokens
) external returns (bool success);
function mintingFinished() external view returns (bool);
function mint(address to, uint256 amount) external;
function burn(uint256 amount) external;
function burnFrom(address account, uint256 amount) external;
}
| 7,327 |
10 | // Calculate pending rewards for the provided 'address'. The rate is the moving reward rate. holderAddress: contract address / | function getHolderData(address holderAddress)
public
view
virtual
override
returns (
address[] memory whitelistedAddresses,
address[] memory sTokenAddresses,
address[] memory uTokenAddresses,
address lpTokenAddress
| function getHolderData(address holderAddress)
public
view
virtual
override
returns (
address[] memory whitelistedAddresses,
address[] memory sTokenAddresses,
address[] memory uTokenAddresses,
address lpTokenAddress
| 46,001 |
4 | // uint256 MAX_INT = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; | 3,640 |
||
13 | // ______/\\\\\\\\\__/\\\_______/\\\__/\\\\\\\\\\\__/\\\\\\\\\\\\\___/ CXIP Asset CXIP-Labs A smart contract for providing a single entry for checking validity of collections and tokens minted through CXIP. Listen events broadcasted by this smart contract, to get all collections and NFT being minted with CXIP smart contracts. / | contract CxipAsset {
function getRegistry () internal pure returns (ICxipRegistry) {
return ICxipRegistry (0xC267d41f81308D7773ecB3BDd863a902ACC01Ade);
}
using Address for address;
event CollectionAdded (address collectionAddress, address creatorWallet);
event CollectionCreated (address collectionAddress, address creatorWallet);
event TokenAdded (address collectionAddress, address creatorWallet, uint256 tokenId);
event TokenCreated (address collectionAddress, address creatorWallet, uint256 tokenId);
UriType private _defaultUri;
mapping (address => address) _collectionIdentity;
constructor () {
_defaultUri = UriType.ARWEAVE;
}
function defaultUriType () public view returns (UriType) {
return _defaultUri;
}
function AddCollection (address creator, address collection, bool fresh) public {
address identityAddress = msg.sender;
require (
ICxipProvenance (getRegistry ().getProvenance ()).isIdentityValid (identityAddress),
'CXIP: invalid Identity contract'
);
ICxipIdentity identity = ICxipIdentity (identityAddress);
require (identity.isWalletRegistered (creator), 'CXIP: creator wallet not owner');
require (identity.isCollectionRegistered (collection), 'CXIP: not registered collection');
bool certified = false;
if (fresh) {
require (identity.isNew (), 'CXIP: not a new collection');
certified = true;
emit CollectionCreated (collection, creator);
} else {
emit CollectionAdded (collection, creator);
}
_collectionIdentity [collection] = identityAddress;
}
function AddToken (address creator, address collection, uint256 tokenId, bool fresh) public {
address identityAddress = msg.sender;
require (
ICxipProvenance (getRegistry ().getProvenance ()).isIdentityValid (identityAddress),
'CXIP: invalid Identity contract'
);
ICxipIdentity identity = ICxipIdentity (identityAddress);
require (identity.isWalletRegistered (creator), 'CXIP: creator wallet not owner');
require (identity.isCollectionRegistered (collection), 'CXIP: not registered collection');
require (identity.isTokenRegistered (collection, tokenId), 'CXIP: not registered token');
bool certified = false;
if (fresh) {
require (identity.isNew (), 'CXIP: not a new collection token');
certified = true;
emit TokenCreated (collection, creator, tokenId);
} else {
emit TokenAdded (collection, creator, tokenId);
}
}
function _getIdentity (address collection) internal view returns (ICxipIdentity) {
address identityAddress = _collectionIdentity [collection];
return ICxipIdentity (identityAddress);
}
function getCollectionIdentity (address collection) public view returns (address) {
ICxipIdentity identity = _getIdentity (collection);
return address (identity);
}
function getCollectionType (address collection) public view returns (InterfaceType) {
ICxipIdentity identity = _getIdentity (collection);
require (!address (identity).isZero (), 'CXIP: not registered collection');
return identity.getCollectionType (collection);
}
function isCollectionOpen (address collection) public view returns (bool) {
ICxipIdentity identity = _getIdentity (collection);
if (address (identity).isZero ()) {
return false;
}
return identity.isCollectionOpen (collection);
}
function isCollectionCertified (address collection) public view returns (bool) {
ICxipIdentity identity = _getIdentity (collection);
if (address (identity).isZero ()) {
return false;
}
return identity.isCollectionCertified (collection);
}
function isCollectionRegistered (address collection) public view returns (bool) {
ICxipIdentity identity = _getIdentity (collection);
if (address (identity).isZero ()) {
return false;
}
return identity.isCollectionRegistered (collection);
}
function isTokenCertified (address collection, uint256 tokenId) public view returns (bool) {
ICxipIdentity identity = _getIdentity (collection);
if (address (identity).isZero ()) {
return false;
}
return identity.isTokenCertified (collection, tokenId);
}
function isTokenRegistered (address collection, uint256 tokenId) public view returns (bool) {
ICxipIdentity identity = _getIdentity (collection);
if (address (identity).isZero ()) {
return false;
}
return identity.isTokenRegistered (collection, tokenId);
}
}
| contract CxipAsset {
function getRegistry () internal pure returns (ICxipRegistry) {
return ICxipRegistry (0xC267d41f81308D7773ecB3BDd863a902ACC01Ade);
}
using Address for address;
event CollectionAdded (address collectionAddress, address creatorWallet);
event CollectionCreated (address collectionAddress, address creatorWallet);
event TokenAdded (address collectionAddress, address creatorWallet, uint256 tokenId);
event TokenCreated (address collectionAddress, address creatorWallet, uint256 tokenId);
UriType private _defaultUri;
mapping (address => address) _collectionIdentity;
constructor () {
_defaultUri = UriType.ARWEAVE;
}
function defaultUriType () public view returns (UriType) {
return _defaultUri;
}
function AddCollection (address creator, address collection, bool fresh) public {
address identityAddress = msg.sender;
require (
ICxipProvenance (getRegistry ().getProvenance ()).isIdentityValid (identityAddress),
'CXIP: invalid Identity contract'
);
ICxipIdentity identity = ICxipIdentity (identityAddress);
require (identity.isWalletRegistered (creator), 'CXIP: creator wallet not owner');
require (identity.isCollectionRegistered (collection), 'CXIP: not registered collection');
bool certified = false;
if (fresh) {
require (identity.isNew (), 'CXIP: not a new collection');
certified = true;
emit CollectionCreated (collection, creator);
} else {
emit CollectionAdded (collection, creator);
}
_collectionIdentity [collection] = identityAddress;
}
function AddToken (address creator, address collection, uint256 tokenId, bool fresh) public {
address identityAddress = msg.sender;
require (
ICxipProvenance (getRegistry ().getProvenance ()).isIdentityValid (identityAddress),
'CXIP: invalid Identity contract'
);
ICxipIdentity identity = ICxipIdentity (identityAddress);
require (identity.isWalletRegistered (creator), 'CXIP: creator wallet not owner');
require (identity.isCollectionRegistered (collection), 'CXIP: not registered collection');
require (identity.isTokenRegistered (collection, tokenId), 'CXIP: not registered token');
bool certified = false;
if (fresh) {
require (identity.isNew (), 'CXIP: not a new collection token');
certified = true;
emit TokenCreated (collection, creator, tokenId);
} else {
emit TokenAdded (collection, creator, tokenId);
}
}
function _getIdentity (address collection) internal view returns (ICxipIdentity) {
address identityAddress = _collectionIdentity [collection];
return ICxipIdentity (identityAddress);
}
function getCollectionIdentity (address collection) public view returns (address) {
ICxipIdentity identity = _getIdentity (collection);
return address (identity);
}
function getCollectionType (address collection) public view returns (InterfaceType) {
ICxipIdentity identity = _getIdentity (collection);
require (!address (identity).isZero (), 'CXIP: not registered collection');
return identity.getCollectionType (collection);
}
function isCollectionOpen (address collection) public view returns (bool) {
ICxipIdentity identity = _getIdentity (collection);
if (address (identity).isZero ()) {
return false;
}
return identity.isCollectionOpen (collection);
}
function isCollectionCertified (address collection) public view returns (bool) {
ICxipIdentity identity = _getIdentity (collection);
if (address (identity).isZero ()) {
return false;
}
return identity.isCollectionCertified (collection);
}
function isCollectionRegistered (address collection) public view returns (bool) {
ICxipIdentity identity = _getIdentity (collection);
if (address (identity).isZero ()) {
return false;
}
return identity.isCollectionRegistered (collection);
}
function isTokenCertified (address collection, uint256 tokenId) public view returns (bool) {
ICxipIdentity identity = _getIdentity (collection);
if (address (identity).isZero ()) {
return false;
}
return identity.isTokenCertified (collection, tokenId);
}
function isTokenRegistered (address collection, uint256 tokenId) public view returns (bool) {
ICxipIdentity identity = _getIdentity (collection);
if (address (identity).isZero ()) {
return false;
}
return identity.isTokenRegistered (collection, tokenId);
}
}
| 76,283 |
118 | // Calculates 1 - t/ return Returns 1 - t, encoded as a fraction in 18 decimal fixed point | function _getYieldExponent() internal view virtual returns (uint256) {
// The fractional time
uint256 timeTillExpiry = block.timestamp < expiration
? expiration - block.timestamp
: 0;
timeTillExpiry *= 1e18;
// timeTillExpiry now contains the a fixed point of the years remaining
timeTillExpiry = timeTillExpiry.divDown(unitSeconds * 1e18);
uint256 result = uint256(FixedPoint.ONE).sub(timeTillExpiry);
// Sanity Check
require(result != 0);
// Return result
return result;
}
| function _getYieldExponent() internal view virtual returns (uint256) {
// The fractional time
uint256 timeTillExpiry = block.timestamp < expiration
? expiration - block.timestamp
: 0;
timeTillExpiry *= 1e18;
// timeTillExpiry now contains the a fixed point of the years remaining
timeTillExpiry = timeTillExpiry.divDown(unitSeconds * 1e18);
uint256 result = uint256(FixedPoint.ONE).sub(timeTillExpiry);
// Sanity Check
require(result != 0);
// Return result
return result;
}
| 34,377 |
3 | // YieldVault | if (assets == 0) {
| if (assets == 0) {
| 22,031 |
115 | // _tempPlayersList = new IPlayer[]; | for (uint i = 0; i < _players.length; i++)
{
IPlayer player = _players[i];
if (!player.GetIsAlive())
{
_tempPlayersList.push(player);
}
| for (uint i = 0; i < _players.length; i++)
{
IPlayer player = _players[i];
if (!player.GetIsAlive())
{
_tempPlayersList.push(player);
}
| 27,367 |
299 | // effect: update claimableAmount for the user | claims[msg.sender][_cToken] = _amount;
emit Claimed(msg.sender, _cToken, _amount);
| claims[msg.sender][_cToken] = _amount;
emit Claimed(msg.sender, _cToken, _amount);
| 4,242 |
3 | // Updates the listing price of the contract / | function updateListingPrice(uint _listingPrice) public payable onlyOwner {
listingPrice = _listingPrice;
}
| function updateListingPrice(uint _listingPrice) public payable onlyOwner {
listingPrice = _listingPrice;
}
| 52,002 |
86 | // Interface of the ERC3156 FlashLender, as defined in _Available since v4.1._ / | interface IERC3156FlashLender {
/**
* @dev The amount of currency available to be lended.
* @param token The loan currency.
* @return The amount of `token` that can be borrowed.
*/
function maxFlashLoan(address token) external view returns (uint256);
/**
* @dev The fee to be charged for a given loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @return The amount of `token` to be charged for the loan, on top of the returned principal.
*/
function flashFee(address token, uint256 amount) external view returns (uint256);
/**
* @dev Initiate a flash loan.
* @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
*/
function flashLoan(
IERC3156FlashBorrower receiver,
address token,
uint256 amount,
bytes calldata data
) external returns (bool);
}
| interface IERC3156FlashLender {
/**
* @dev The amount of currency available to be lended.
* @param token The loan currency.
* @return The amount of `token` that can be borrowed.
*/
function maxFlashLoan(address token) external view returns (uint256);
/**
* @dev The fee to be charged for a given loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @return The amount of `token` to be charged for the loan, on top of the returned principal.
*/
function flashFee(address token, uint256 amount) external view returns (uint256);
/**
* @dev Initiate a flash loan.
* @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
*/
function flashLoan(
IERC3156FlashBorrower receiver,
address token,
uint256 amount,
bytes calldata data
) external returns (bool);
}
| 15,548 |
38 | // Allows to replace an owner with a new owner. Transaction has to be sent by wallet. owner Address of owner to be replaced.newOwnerAddress of new owner. / | function replaceOwner(
address owner,
address newOwner
)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
notNull(newOwner)
| function replaceOwner(
address owner,
address newOwner
)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
notNull(newOwner)
| 18,063 |
3 | // Init Constructor | function Roulette() {
sWelcome = "\n-----------------------------\n Welcome to Roulette \n Got coins? Then come on in! \n-----------------------------\n";
privSeed = 1;
casino.addr = msg.sender;
casino.balance = 0;
casino.bettingLimitMin = 1*10**18;
casino.bettingLimitMax = 10*10**18;
}
| function Roulette() {
sWelcome = "\n-----------------------------\n Welcome to Roulette \n Got coins? Then come on in! \n-----------------------------\n";
privSeed = 1;
casino.addr = msg.sender;
casino.balance = 0;
casino.bettingLimitMin = 1*10**18;
casino.bettingLimitMax = 10*10**18;
}
| 1,130 |
5 | // create an array with all adresses and associated balances of the cryptocurrency |
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
|
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
| 7,972 |
55 | // to referer, or to ownerPool | if (players[_pAddr].referer == 0) {
ownerPool = ownerPool.add(_eth.mul(toRefer) / 1000);
} else {
| if (players[_pAddr].referer == 0) {
ownerPool = ownerPool.add(_eth.mul(toRefer) / 1000);
} else {
| 23,963 |
80 | // require(quantity > 0, "Quantity should be more than 0"); | uint256 usdAmount = getValueInUSDT(msg.value);
uint256 solidaAmt = ((usdAmount / USDTprice) * 1e9);
_totalETHInvestment += msg.value;
if (Refferals[_refferalAddress].userAddress == address(0)) {
Refferals[_refferalAddress] = refferalData(
_refferalAddress,
1,
(usdAmount * _levelOne) / 100,
(msg.value * _levelOne) / 100
| uint256 usdAmount = getValueInUSDT(msg.value);
uint256 solidaAmt = ((usdAmount / USDTprice) * 1e9);
_totalETHInvestment += msg.value;
if (Refferals[_refferalAddress].userAddress == address(0)) {
Refferals[_refferalAddress] = refferalData(
_refferalAddress,
1,
(usdAmount * _levelOne) / 100,
(msg.value * _levelOne) / 100
| 30,178 |
127 | // Allow Dog to kick auctions in ilk Clipper | authorize(_clip, _dog);
| authorize(_clip, _dog);
| 22,912 |
2 | // get all entries as arrays of names and values/totalCount and offset can be used for paging | function getEntries(uint256 offset) public view returns (
string[10] names,
bytes32[10] values,
DigitalTwinLibrary.EntryType[10] entryTypes,
uint256 totalCount
| function getEntries(uint256 offset) public view returns (
string[10] names,
bytes32[10] values,
DigitalTwinLibrary.EntryType[10] entryTypes,
uint256 totalCount
| 5,637 |
5 | // Stakes AGO token and registers it. Claims rewards automatically/_communityId The community's id, to which the stake will belong to/_amount The amount to stake. | function deposit(uint256 _communityId, uint256 _amount) external {
// Claim rewards in the community
uint256[] memory communityArray = new uint256[](1);
communityArray[0] = _communityId;
claimReward(communityArray);
// Register the stake details
stakes[_communityId][msg.sender].amount += _amount;
stakes[_communityId][msg.sender].lockExpires = uint128(block.number + lockInterval);
totalStakes += _amount;
// Actually get the tokens
IAgoraToken(agoAddress).transferFrom(msg.sender, address(this), _amount);
emit Deposit(_communityId, msg.sender, _amount);
}
| function deposit(uint256 _communityId, uint256 _amount) external {
// Claim rewards in the community
uint256[] memory communityArray = new uint256[](1);
communityArray[0] = _communityId;
claimReward(communityArray);
// Register the stake details
stakes[_communityId][msg.sender].amount += _amount;
stakes[_communityId][msg.sender].lockExpires = uint128(block.number + lockInterval);
totalStakes += _amount;
// Actually get the tokens
IAgoraToken(agoAddress).transferFrom(msg.sender, address(this), _amount);
emit Deposit(_communityId, msg.sender, _amount);
}
| 31,411 |
264 | // Adjust for pending rewards | totalAmountStaked += tokenDistributor.calculatePendingRewards(address(this));
| totalAmountStaked += tokenDistributor.calculatePendingRewards(address(this));
| 68,475 |
9 | // Claim fund value./_id Claim lookup key value./_signature Sender signature./_destination Destination address. | function claim(
bytes32 _id,
bytes memory _signature,
bytes32 _claimHash,
address _destination
)
public
ifValidFund(_id)
returns (bool)
| function claim(
bytes32 _id,
bytes memory _signature,
bytes32 _claimHash,
address _destination
)
public
ifValidFund(_id)
returns (bool)
| 25,496 |
81 | // $GP exchange amount handled within alter contract | alter.burn(TREASURE_CHEST, qty, _msgSender());
| alter.burn(TREASURE_CHEST, qty, _msgSender());
| 15,958 |
4 | // Events and modifiers | event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndRedirectEthFeesUpdated(bool enabled);
event OnSwapAndRedirectEthFees(
uint256 tokensSwapped,
uint256 ethToDevWallet
);
event MaxTxAmountUpdated(uint256 maxTxAmount);
event GenericTransferChanged(bool useGenericTransfer);
event ExcludeFromFees(address wallet);
event IncludeInFees(address wallet);
| event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndRedirectEthFeesUpdated(bool enabled);
event OnSwapAndRedirectEthFees(
uint256 tokensSwapped,
uint256 ethToDevWallet
);
event MaxTxAmountUpdated(uint256 maxTxAmount);
event GenericTransferChanged(bool useGenericTransfer);
event ExcludeFromFees(address wallet);
event IncludeInFees(address wallet);
| 13,819 |
137 | // ==== Lock ==== | struct LockPool {
bool enable;
uint256 recipK;
bool siglePool;
address store;
uint256 pid;
uint256 totalAmount;
uint256 totalTime;
uint256 totalUser;
}
| struct LockPool {
bool enable;
uint256 recipK;
bool siglePool;
address store;
uint256 pid;
uint256 totalAmount;
uint256 totalTime;
uint256 totalUser;
}
| 75,824 |
41 | // mints a non-fungible token/type_ token type/to beneficiaries of minted tokens | function mintNonFungible(
uint256 type_,
address[] calldata to
)
external
override
onlyCreator(type_)
| function mintNonFungible(
uint256 type_,
address[] calldata to
)
external
override
onlyCreator(type_)
| 16,423 |
105 | // Withdraw a partial amount of this token | if(_withdrawAmount > 0){
| if(_withdrawAmount > 0){
| 19,526 |
4 | // ============================== ERC223 | event Transfer(
address indexed from,
address indexed to,
uint256 tokens,
bytes data
);
| event Transfer(
address indexed from,
address indexed to,
uint256 tokens,
bytes data
);
| 26,505 |
48 | // ZOM Token smart contract / | contract ZOMToken is ERC20Mintable, ERC20Burnable {
string private constant _name = "ZOM";
string private constant _symbol = "ZOM";
uint8 private constant _decimals = 18;
uint256 private constant _initialSupply = 50000000 * 1 ether; // 50,000,000.00 ZOM
constructor () public {
_mint(msg.sender, initialSupply());
}
/**
* @return the name of the token.
*/
function name() public pure returns (string memory) {
return _name;
}
/**
* @return the symbol of the token.
*/
function symbol() public pure returns (string memory) {
return _symbol;
}
/**
* @return the number of decimals of the token.
*/
function decimals() public pure returns (uint8) {
return _decimals;
}
/**
* @return the number of initial supply tokens.
*/
function initialSupply() public pure returns (uint256) {
return _initialSupply;
}
}
| contract ZOMToken is ERC20Mintable, ERC20Burnable {
string private constant _name = "ZOM";
string private constant _symbol = "ZOM";
uint8 private constant _decimals = 18;
uint256 private constant _initialSupply = 50000000 * 1 ether; // 50,000,000.00 ZOM
constructor () public {
_mint(msg.sender, initialSupply());
}
/**
* @return the name of the token.
*/
function name() public pure returns (string memory) {
return _name;
}
/**
* @return the symbol of the token.
*/
function symbol() public pure returns (string memory) {
return _symbol;
}
/**
* @return the number of decimals of the token.
*/
function decimals() public pure returns (uint8) {
return _decimals;
}
/**
* @return the number of initial supply tokens.
*/
function initialSupply() public pure returns (uint256) {
return _initialSupply;
}
}
| 53,655 |
28 | // require(_tokenAddr != address(0)); | require(_target != address(0));
require(_value > 0);
require(_frozenEndTime > 0 && _releasePeriod >= 0);
uint256 len = frozenAccounts.length;
for (uint256 i = 0; i < len; i = i.add(1)) {
if (frozenAccounts[i] == _target) {
break;
}
| require(_target != address(0));
require(_value > 0);
require(_frozenEndTime > 0 && _releasePeriod >= 0);
uint256 len = frozenAccounts.length;
for (uint256 i = 0; i < len; i = i.add(1)) {
if (frozenAccounts[i] == _target) {
break;
}
| 22,495 |
135 | // Validate that the mortgage wasn&39;t claimed | require(mortgage.status == Status.Ongoing, "Mortgage not ongoing");
require(mortgage.loanId == loanId, "Mortgage don't match loan id");
if (mortgage.engine.getStatus(loanId) == Engine.Status.paid || mortgage.engine.getStatus(loanId) == Engine.Status.destroyed) {
| require(mortgage.status == Status.Ongoing, "Mortgage not ongoing");
require(mortgage.loanId == loanId, "Mortgage don't match loan id");
if (mortgage.engine.getStatus(loanId) == Engine.Status.paid || mortgage.engine.getStatus(loanId) == Engine.Status.destroyed) {
| 20,400 |
10 | // Address of uniswapv2 factory; | address public override v2Factory;
| address public override v2Factory;
| 27,391 |
602 | // calculate current bond premiumreturn price_ uint/ | // function bondPrice() public view returns ( uint price_ ) {
// price_ = terms.controlVariable.mul( debtRatio() ).add( 1000000000 ).div( 1e7 );
// if ( price_ < terms.minimumPrice ) {
// price_ = terms.minimumPrice;
// }
// }
| // function bondPrice() public view returns ( uint price_ ) {
// price_ = terms.controlVariable.mul( debtRatio() ).add( 1000000000 ).div( 1e7 );
// if ( price_ < terms.minimumPrice ) {
// price_ = terms.minimumPrice;
// }
// }
| 22,964 |
41 | // Get fee for a specific action_value: the value on which to assess the fee _feeDivisor: the inverse of the percentage of the fee (i.e. 1% = 100) return fee: total amount of fee to be assessed / | function _calculateFee(uint256 _value, uint256 _feeDivisor) internal pure returns (uint256 fee) {
if (_feeDivisor > 0) {
fee = _value.div(_feeDivisor);
}
}
| function _calculateFee(uint256 _value, uint256 _feeDivisor) internal pure returns (uint256 fee) {
if (_feeDivisor > 0) {
fee = _value.div(_feeDivisor);
}
}
| 66,388 |
29 | // Used to get the price of a book on sale/_bookId the book's price needed/ return price the price of the book on sale, it's zero if the book is not on sale | function getPrice(uint _bookId) public view returns(uint price){
price = prices.contains(_bookId) ? prices.get(_bookId) : 0;
}
| function getPrice(uint _bookId) public view returns(uint price){
price = prices.contains(_bookId) ? prices.get(_bookId) : 0;
}
| 2,491 |
3 | // Allows the pending owner to transfer control of the contract. / | function transferOwnership() public {
require(msg.sender == pendingOwner);
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
}
| function transferOwnership() public {
require(msg.sender == pendingOwner);
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
}
| 2,006 |
29 | // Get gift card of the owner using index. | function getGiftCardByIndex(uint256 index)
public
view
returns (GiftCard memory)
| function getGiftCardByIndex(uint256 index)
public
view
returns (GiftCard memory)
| 7,877 |
19 | // Update event that gets triggered when a thing is updated. eventids - The identity of the thing.owner - The owner address.isValid - The validity of the thing./ | event Updated(bytes32[] ids, address indexed owner, bool isValid);
| event Updated(bytes32[] ids, address indexed owner, bool isValid);
| 56,689 |
4 | // This sets where calls from modules are fowarded (eg: calls fowarded to the safe) | setAvatar(_owner);
setTarget(_owner);
transferOwnership(_owner);
| setAvatar(_owner);
setTarget(_owner);
transferOwnership(_owner);
| 46,249 |
128 | // can only self-refund 4 weeks after agreed completion date | require(block.timestamp > jobEscrows[jobHash].agreedCompletionDate + 4 weeks);
| require(block.timestamp > jobEscrows[jobHash].agreedCompletionDate + 4 weeks);
| 33,356 |
12 | // The current sale round index. | uint256 public currentSaleIndex;
| uint256 public currentSaleIndex;
| 80,148 |
8 | // See {BEP20-totalSupply}. / | function totalSupply() external view returns (uint256) {
return _totalSupply;
}
| function totalSupply() external view returns (uint256) {
return _totalSupply;
}
| 2,725 |
129 | // 通过chainID查找跑图 | uint256 tokenID = chainIDToTokenID[_chainID];
if(tokenID != 0){ //链跑图已存在,仅修改跑图属性
ChainDrawings storage drawing = drawings[tokenID];
drawing.author = _author;
return;
}
| uint256 tokenID = chainIDToTokenID[_chainID];
if(tokenID != 0){ //链跑图已存在,仅修改跑图属性
ChainDrawings storage drawing = drawings[tokenID];
drawing.author = _author;
return;
}
| 6,274 |
85 | // Get the Staking address | function getStakingAddress() external view returns (address) {
_requireIsInitialized();
return stakingAddress;
}
| function getStakingAddress() external view returns (address) {
_requireIsInitialized();
return stakingAddress;
}
| 26,579 |
266 | // Flag for allowing AA withdraws | bool public allowAAWithdraw;
| bool public allowAAWithdraw;
| 29,491 |
1 | // ERC20 trade name and symbol | string public name = "Ventana";
string public symbol = "VNT";
| string public name = "Ventana";
string public symbol = "VNT";
| 48,212 |
18 | // administrators | administrators[0x8889885f4a4800abC7F32aC661765cd1FAaC7D49] = true;
| administrators[0x8889885f4a4800abC7F32aC661765cd1FAaC7D49] = true;
| 14,907 |
18 | // Step increments are 0.25% (upon genesis, changable by setFraxStep()) |
if (frax_price_cur > price_target.add(price_band)) { //decrease collateral ratio
if(global_collateral_ratio <= frax_step){ //if within a step of 0, go to 0
global_collateral_ratio = 0;
} else {
|
if (frax_price_cur > price_target.add(price_band)) { //decrease collateral ratio
if(global_collateral_ratio <= frax_step){ //if within a step of 0, go to 0
global_collateral_ratio = 0;
} else {
| 32,235 |
42 | // Decimals of taxBurn. Used for have tax less than 1%. | uint8 private _taxBurnDecimals;
| uint8 private _taxBurnDecimals;
| 25,164 |
187 | // bg colors | traitTypes[0].push(Trait("Aero Blue","Background","C1FFD7",0));
traitTypes[0].push(Trait("Gold","Background","FECD51",0));
traitTypes[0].push(Trait("Green Crayola","Background","C6D57E",0));
traitTypes[0].push(Trait("Light Coral","Background","F16F6F",0));
traitTypes[0].push(Trait("Maximum Purple","Background","CAB8FF",0));
traitTypes[0].push(Trait("New York Pink","Background","D57E7E",0));
traitTypes[0].push(Trait("Opal","Background","A2CDCD",0));
traitTypes[0].push(Trait("Peach","Background","FFE1AF",0));
traitTypes[0].push(Trait("Snow","Background","F9F3F3",0));
traitTypes[0].push(Trait("Uranian Blue","Background","B5DEFF",0));
| traitTypes[0].push(Trait("Aero Blue","Background","C1FFD7",0));
traitTypes[0].push(Trait("Gold","Background","FECD51",0));
traitTypes[0].push(Trait("Green Crayola","Background","C6D57E",0));
traitTypes[0].push(Trait("Light Coral","Background","F16F6F",0));
traitTypes[0].push(Trait("Maximum Purple","Background","CAB8FF",0));
traitTypes[0].push(Trait("New York Pink","Background","D57E7E",0));
traitTypes[0].push(Trait("Opal","Background","A2CDCD",0));
traitTypes[0].push(Trait("Peach","Background","FFE1AF",0));
traitTypes[0].push(Trait("Snow","Background","F9F3F3",0));
traitTypes[0].push(Trait("Uranian Blue","Background","B5DEFF",0));
| 27,653 |
130 | // verify that we haven't already staked | require(!_airDroppedStakeClaimed(msg.sender, stakeType), "Already staked");
_stake(msg.sender, stakeType, duration, uint240(rate), amount);
| require(!_airDroppedStakeClaimed(msg.sender, stakeType), "Already staked");
_stake(msg.sender, stakeType, duration, uint240(rate), amount);
| 3,933 |
12 | // getState() returns the state of a receiver in an string format | function getState(uint _id, address _sender, address _receiver) public view returns (string) {
if (messages[_sender][_id].receiversState[_receiver].state==State.notexists) {
return "not exists";
} else if (messages[_sender][_id].receiversState[_receiver].state==State.cancelled) {
return "cancelled";
} else if (messages[_sender][_id].receiversState[_receiver].state==State.finished) {
return "finished";
}
}
| function getState(uint _id, address _sender, address _receiver) public view returns (string) {
if (messages[_sender][_id].receiversState[_receiver].state==State.notexists) {
return "not exists";
} else if (messages[_sender][_id].receiversState[_receiver].state==State.cancelled) {
return "cancelled";
} else if (messages[_sender][_id].receiversState[_receiver].state==State.finished) {
return "finished";
}
}
| 3,066 |
101 | // Emitted if this contract successfully posts a capped-to-max price. / | event CappedPricePosted(
| event CappedPricePosted(
| 17,802 |
152 | // There must be either a collateral change or a debt change. | error NoCollateralOrDebtChange();
| error NoCollateralOrDebtChange();
| 17,722 |
128 | // additional protection so we don't burn the funds |
IERC20(want).safeTransfer(_vault, _amount);
|
IERC20(want).safeTransfer(_vault, _amount);
| 10,255 |
104 | // Method called by owner of contract to withdraw all tokens after timeout has reached/ | function withdraw() onlyOwner public {
require(contractTimeout <= getBlockTime());
// send remaining tokens back to owner.
uint256 tokens = token.balanceOf(this);
bytes memory empty;
token.transfer(owner, tokens, empty);
}
| function withdraw() onlyOwner public {
require(contractTimeout <= getBlockTime());
// send remaining tokens back to owner.
uint256 tokens = token.balanceOf(this);
bytes memory empty;
token.transfer(owner, tokens, empty);
}
| 21,217 |
2 | // returns uri for audio file for owner | function mediaURI() public view returns(string memory) {
return _mediaURI;
}
| function mediaURI() public view returns(string memory) {
return _mediaURI;
}
| 22,951 |
116 | // We do not expect to have more than 3-4 pools, so this loop should be fine | for (uint i = 0; i < _numPools; i++) {
pool = pools[i];
assets = assets.add(
_settToBtc(
pool,
pool.sett.balanceOf(address(this))
)
);
}
| for (uint i = 0; i < _numPools; i++) {
pool = pools[i];
assets = assets.add(
_settToBtc(
pool,
pool.sett.balanceOf(address(this))
)
);
}
| 15,596 |
1 | // Thrown when trying to set the zero address as governor | error GovernorIsZeroAddress();
| error GovernorIsZeroAddress();
| 36,305 |
11 | // Throws if `_tokenId` is not a valid NFT. Get the approved address for a single NFT. _tokenId The NFT to find the approved address for.return Address that _tokenId is approved for. / | function getApproved(uint256 _tokenId) external view returns (address);
| function getApproved(uint256 _tokenId) external view returns (address);
| 33,366 |
5 | // State modifying | function swapETHForExactTokens(
uint256 amountOut, // DAI
address[] calldata path,
address to,
uint256 deadline
| function swapETHForExactTokens(
uint256 amountOut, // DAI
address[] calldata path,
address to,
uint256 deadline
| 24,127 |
26 | // UpgradeabilityProxy This contract represents a proxy where the implementation address to which it will delegate can be upgraded / | contract UpgradeabilityProxy is Proxy, UpgradeabilityStorage {
/**
* @dev This event will be emitted every time the implementation gets upgraded
* @param version representing the version name of the upgraded implementation
* @param implementation representing the address of the upgraded implementation
*/
event Upgraded(uint256 version, address indexed implementation);
/**
* @dev Upgrades the implementation address
* @param version representing the version name of the new implementation to be set
* @param implementation representing the address of the new implementation to be set
*/
function _upgradeTo(uint256 version, address implementation) internal {
require(_implementation != implementation);
// This additional check verifies that provided implementation is at least a contract
require(AddressUtils.isContract(implementation));
// This additional check guarantees that new version will be at least greater than the privios one,
// so it is impossible to reuse old versions, or use the last version twice
require(version > _version);
_version = version;
_implementation = implementation;
emit Upgraded(version, implementation);
}
}
| contract UpgradeabilityProxy is Proxy, UpgradeabilityStorage {
/**
* @dev This event will be emitted every time the implementation gets upgraded
* @param version representing the version name of the upgraded implementation
* @param implementation representing the address of the upgraded implementation
*/
event Upgraded(uint256 version, address indexed implementation);
/**
* @dev Upgrades the implementation address
* @param version representing the version name of the new implementation to be set
* @param implementation representing the address of the new implementation to be set
*/
function _upgradeTo(uint256 version, address implementation) internal {
require(_implementation != implementation);
// This additional check verifies that provided implementation is at least a contract
require(AddressUtils.isContract(implementation));
// This additional check guarantees that new version will be at least greater than the privios one,
// so it is impossible to reuse old versions, or use the last version twice
require(version > _version);
_version = version;
_implementation = implementation;
emit Upgraded(version, implementation);
}
}
| 23,607 |
47 | // transfer token for a specified address _to The address to transfer to. _value The amount to be transferred.return bool success/ | function transfer(address _to, uint256 _value) whenNotPaused notBlacklisted(msg.sender) notBlacklisted(_to) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| function transfer(address _to, uint256 _value) whenNotPaused notBlacklisted(msg.sender) notBlacklisted(_to) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| 16,985 |
88 | // 100,000 BASE (18 Decimals) | _mint(msg.sender, 100000000000000000000000);
| _mint(msg.sender, 100000000000000000000000);
| 9,732 |
69 | // Gives a ruling for a dispute. Must be called by the arbitrator. The purpose of this function is to ensure that the address calling it has the right to rule on the contract._disputeID ID of the dispute in the Arbitrator contract._ruling Ruling given by the arbitrator. Note that 0 is reserved for "Refuse to arbitrate". / | function rule(uint _disputeID, uint _ruling) public {
Session storage session = sessions[sessions.length - 1];
require(msg.sender == address(arbitrator), "Must be called by the arbitrator.");
require(session.status == Status.DisputeCreated, "The dispute has already been resolved.");
require(_ruling <= session.submittedLists.length, "Ruling is out of bounds.");
if (shadowWinner != NO_SHADOW_WINNER) {
emit Ruling(Arbitrator(msg.sender), _disputeID, shadowWinner + 1);
executeRuling(_disputeID, shadowWinner + 1);
} else {
emit Ruling(Arbitrator(msg.sender), _disputeID, _ruling);
executeRuling(_disputeID, _ruling);
}
}
| function rule(uint _disputeID, uint _ruling) public {
Session storage session = sessions[sessions.length - 1];
require(msg.sender == address(arbitrator), "Must be called by the arbitrator.");
require(session.status == Status.DisputeCreated, "The dispute has already been resolved.");
require(_ruling <= session.submittedLists.length, "Ruling is out of bounds.");
if (shadowWinner != NO_SHADOW_WINNER) {
emit Ruling(Arbitrator(msg.sender), _disputeID, shadowWinner + 1);
executeRuling(_disputeID, shadowWinner + 1);
} else {
emit Ruling(Arbitrator(msg.sender), _disputeID, _ruling);
executeRuling(_disputeID, _ruling);
}
}
| 42,885 |
6 | // The value is stored at length-1, but we add 1 to all indexes and use 0 as a sentinel value | set._indexes[value] = set._values.length;
return true;
| set._indexes[value] = set._values.length;
return true;
| 7,021 |
158 | // View function to see pending UNIFARM on frontend. | function pendingUNIFARM(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accUNIFARMPerShare = pool.accUNIFARMPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 UNIFARMReward = multiplier.mul(UNIFARMPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accUNIFARMPerShare = accUNIFARMPerShare.add(UNIFARMReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accUNIFARMPerShare).div(1e12).sub(user.rewardDebt);
}
| function pendingUNIFARM(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accUNIFARMPerShare = pool.accUNIFARMPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 UNIFARMReward = multiplier.mul(UNIFARMPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accUNIFARMPerShare = accUNIFARMPerShare.add(UNIFARMReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accUNIFARMPerShare).div(1e12).sub(user.rewardDebt);
}
| 22,495 |
38 | // if new root doesnt match what was submitted by coordinator slash and rollback | if (updatedBalanceRoot != batches[_batch_id].stateRoot) {
invalidBatchMarker = _batch_id;
SlashAndRollback();
return;
}
| if (updatedBalanceRoot != batches[_batch_id].stateRoot) {
invalidBatchMarker = _batch_id;
SlashAndRollback();
return;
}
| 29,676 |
3 | // Owner check modifier/ | modifier onlyContractOwner() {
if (contractOwner == msg.sender) {
_;
}
}
| modifier onlyContractOwner() {
if (contractOwner == msg.sender) {
_;
}
}
| 20,411 |
141 | // Update enableWhitelist _enable enable whitelist flag / | function updateEnableWhitelist(bool _enable) external onlyOwner {
| function updateEnableWhitelist(bool _enable) external onlyOwner {
| 50,036 |
328 | // Mint caps enforced by mintAllowed for each AuToken address. Defaults to zero which corresponds to unlimited mints. | mapping(address => uint) public mintCaps;
| mapping(address => uint) public mintCaps;
| 35,219 |
27 | // approve spend | function approve(address _spender, uint256 _value) public returns (bool success) {
require(_spender != address(0));
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| function approve(address _spender, uint256 _value) public returns (bool success) {
require(_spender != address(0));
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| 12,697 |
170 | // Set function costs and payment address per node, in Wei / | function setOperationCosts(
| function setOperationCosts(
| 62,736 |
13 | // Public and privateTwo |
_;
|
_;
| 23,939 |
0 | // ERC20Interface The ERC20Interface contract has an owner address, and provides basic authorization controlfunctions, this simplifies the implementation of "user permissions". / | contract ERC20Interface {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
| contract ERC20Interface {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
| 21,088 |
29 | // Add new grain contract to portfolio _grainCategory - Grain category _grainContractInfo - Grain Contract's details _grainAmount - amount of grain in tonsreturn success / | function addNewGrainContract(
string memory _grainCategory,
string memory _grainContractInfo,
uint256 _grainAmount
| function addNewGrainContract(
string memory _grainCategory,
string memory _grainContractInfo,
uint256 _grainAmount
| 12,217 |
28 | // Start the BeastDAO token sale | require(msg.sender == owner && startDate==0);
startDate=now;
| require(msg.sender == owner && startDate==0);
startDate=now;
| 33,504 |
189 | // notify the world | Finalized(tFinalized);
| Finalized(tFinalized);
| 33,484 |
26 | // [desc] Get parcel's amount. [param] _direction: parcel's direction (0: means sent, 1: means received). [param] _srcCountry: country code of parcels sent (0: means all countries). [param] _destCountry: country code of parcels received (0: means all countries). [param] _startTime: start time (0: means ignore time). [param] _endTime: end time (0: means ignore time). [return] parcel amount./ | function getParcelAmount(uint8 _direction, uint16 _srcCountry, uint16 _destCountry, uint64 _startTime, uint64 _endTime) external view _checkCoreAddr returns (uint) {
uint i = 0;
uint amount = 0;
uint16 srcCountry = 0;
uint16 destCountry = 0;
// check param
require((0 == _direction) || (1 == _direction));
require(_startTime <= _endTime);
for (i=0; i<LogisticsCore(coreAddr_).number(); i++) {
if(_checkValid(_direction, i)) {
srcCountry = uint16(_getParcelTrackElement(i, 0, "country").toUint());
destCountry = uint16(LogisticsCore(coreAddr_).getBriefElementByIndex(i, "destinationCountry").toUint());
// 1. all -> all
// 2. all -> dest
// 3. src -> all
// 4. src -> dest
if (((0 == _srcCountry) && (0 == _destCountry))
|| ((0 == _srcCountry) && (0 != _destCountry) && (_destCountry == destCountry))
|| ((0 != _srcCountry) && (0 == _destCountry) && (_srcCountry == srcCountry))
|| ((0 != _srcCountry) && (0 != _destCountry) && (_srcCountry == srcCountry) && (_destCountry == destCountry))) {
if ((0 == _startTime) && (0 == _endTime)) {
amount ++;
} else {
if (_checkTime(_direction, i, _startTime, _endTime)) {
amount ++;
}
}
}
}
}
return amount;
}
| function getParcelAmount(uint8 _direction, uint16 _srcCountry, uint16 _destCountry, uint64 _startTime, uint64 _endTime) external view _checkCoreAddr returns (uint) {
uint i = 0;
uint amount = 0;
uint16 srcCountry = 0;
uint16 destCountry = 0;
// check param
require((0 == _direction) || (1 == _direction));
require(_startTime <= _endTime);
for (i=0; i<LogisticsCore(coreAddr_).number(); i++) {
if(_checkValid(_direction, i)) {
srcCountry = uint16(_getParcelTrackElement(i, 0, "country").toUint());
destCountry = uint16(LogisticsCore(coreAddr_).getBriefElementByIndex(i, "destinationCountry").toUint());
// 1. all -> all
// 2. all -> dest
// 3. src -> all
// 4. src -> dest
if (((0 == _srcCountry) && (0 == _destCountry))
|| ((0 == _srcCountry) && (0 != _destCountry) && (_destCountry == destCountry))
|| ((0 != _srcCountry) && (0 == _destCountry) && (_srcCountry == srcCountry))
|| ((0 != _srcCountry) && (0 != _destCountry) && (_srcCountry == srcCountry) && (_destCountry == destCountry))) {
if ((0 == _startTime) && (0 == _endTime)) {
amount ++;
} else {
if (_checkTime(_direction, i, _startTime, _endTime)) {
amount ++;
}
}
}
}
}
return amount;
}
| 35,260 |
19 | // Set allowance for other address and notify Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it_spender The address authorized to spend_value the max amount they can spend_extraData some extra information to send to the approved contract/ | function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
| function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
| 12,437 |
26 | // ensure the address is valid. | function _transfer(address _from, address _to, uint256 _value) internal {
_balanceOf[_from] = _balanceOf[_from].sub(_value);
_balanceOf[_to] = _balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
}
| function _transfer(address _from, address _to, uint256 _value) internal {
_balanceOf[_from] = _balanceOf[_from].sub(_value);
_balanceOf[_to] = _balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
}
| 45,261 |
10 | // migrates a list of pools between pool collections notes: - invalid or incompatible pools will be skipped gracefully / | function migratePools(Token[] calldata pools) external;
| function migratePools(Token[] calldata pools) external;
| 22,989 |
94 | // attempt to transfer sufficient amount of tokens from sender | uint256 due = _totalLockedAmount - owned;
| uint256 due = _totalLockedAmount - owned;
| 24,159 |
21 | // emit event in both cases | emit AmountWithdrawEvent(destination, amount, tokenAddress);
| emit AmountWithdrawEvent(destination, amount, tokenAddress);
| 12,673 |
192 | // This function transfers the nft from your address on the source chain to the same address on the destination chain | function traverseChains(uint16 _chainId, uint256 tokenId) public payable {
require(
msg.sender == ownerOf(tokenId),
"You must own the token to traverse"
);
require(
trustedRemoteLookup[_chainId].length > 0,
"This chain is currently unavailable for travel"
);
// burn NFT, eliminating it from circulation on src chain
_burn(tokenId);
// abi.encode() the payload with the values to send
bytes memory payload = abi.encode(msg.sender, tokenId);
// encode adapterParams to specify more gas for the destination
uint16 version = 1;
bytes memory adapterParams = abi.encodePacked(
version,
gasForDestinationLzReceive
);
// get the fees we need to pay to LayerZero + Relayer to cover message delivery
// you will be refunded for extra gas paid
(uint256 messageFee, ) = endpoint.estimateFees(
_chainId,
address(this),
payload,
false,
adapterParams
);
require(
msg.value >= messageFee,
"st0ked: msg.value not enough to cover messageFee. Send gas for message fees"
);
endpoint.send{value: msg.value}(
_chainId, // destination chainId
trustedRemoteLookup[_chainId], // destination address of nft contract
payload, // abi.encoded()'ed bytes
payable(msg.sender), // refund address
address(0x0), // 'zroPaymentAddress' unused for this
adapterParams // txParameters
);
}
| function traverseChains(uint16 _chainId, uint256 tokenId) public payable {
require(
msg.sender == ownerOf(tokenId),
"You must own the token to traverse"
);
require(
trustedRemoteLookup[_chainId].length > 0,
"This chain is currently unavailable for travel"
);
// burn NFT, eliminating it from circulation on src chain
_burn(tokenId);
// abi.encode() the payload with the values to send
bytes memory payload = abi.encode(msg.sender, tokenId);
// encode adapterParams to specify more gas for the destination
uint16 version = 1;
bytes memory adapterParams = abi.encodePacked(
version,
gasForDestinationLzReceive
);
// get the fees we need to pay to LayerZero + Relayer to cover message delivery
// you will be refunded for extra gas paid
(uint256 messageFee, ) = endpoint.estimateFees(
_chainId,
address(this),
payload,
false,
adapterParams
);
require(
msg.value >= messageFee,
"st0ked: msg.value not enough to cover messageFee. Send gas for message fees"
);
endpoint.send{value: msg.value}(
_chainId, // destination chainId
trustedRemoteLookup[_chainId], // destination address of nft contract
payload, // abi.encoded()'ed bytes
payable(msg.sender), // refund address
address(0x0), // 'zroPaymentAddress' unused for this
adapterParams // txParameters
);
}
| 31,922 |
99 | // must pay a penalty fee | rewardToGiveBack += _setupsInfo[_setups[farmingPosition.setupIndex].infoIndex].penaltyFee == 0 ? 0 : (farmingPosition.reward * ((_setupsInfo[_setups[farmingPosition.setupIndex].infoIndex].penaltyFee * 1e18) / ONE_HUNDRED) / 1e18);
| rewardToGiveBack += _setupsInfo[_setups[farmingPosition.setupIndex].infoIndex].penaltyFee == 0 ? 0 : (farmingPosition.reward * ((_setupsInfo[_setups[farmingPosition.setupIndex].infoIndex].penaltyFee * 1e18) / ONE_HUNDRED) / 1e18);
| 3,484 |
3 | // Maps airline address to struct | mapping(address => Airline) public registeredAirlines;
| mapping(address => Airline) public registeredAirlines;
| 22,176 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.