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
9
// queried by others ({ERC165Checker}). For an implementation, see {ERC165}./
interface IERC165 {
interface IERC165 {
14,798
74
// Returns a newly allocated string containing the concatenation of `self` and `other`. self The first slice to concatenate. other The second slice to concatenate.return The concatenation of the two strings. /
function concat(slice self, slice other) internal returns (string) { var ret = new string(self._len + other._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); memcpy(retptr + self._len, other._ptr, other._len); return ret; ...
function concat(slice self, slice other) internal returns (string) { var ret = new string(self._len + other._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); memcpy(retptr + self._len, other._ptr, other._len); return ret; ...
3,027
79
// PUSH30
OpCodes[125].Ins = 0; OpCodes[125].Outs = 1; OpCodes[125].Gas = 3;
OpCodes[125].Ins = 0; OpCodes[125].Outs = 1; OpCodes[125].Gas = 3;
3,089
85
// Emitted when the pause is lifted by `account`. /
event Unpaused(address account); bool private _paused;
event Unpaused(address account); bool private _paused;
3,049
336
// Looping through all pairs of prices to find the closest double
for (uint8 i = 0; i < 3; i++) { uint8 j = (i + 1) % 3; if ( isOutdated(data[i].updatedAt, cachedValidPeriod) || isOutdated(data[j].updatedAt, cachedValidPeriod) ) continue; uint256 diff = Math.absDiff(data[i].answer, data[j].answer); if (diff < mnDiff) { (answer...
for (uint8 i = 0; i < 3; i++) { uint8 j = (i + 1) % 3; if ( isOutdated(data[i].updatedAt, cachedValidPeriod) || isOutdated(data[j].updatedAt, cachedValidPeriod) ) continue; uint256 diff = Math.absDiff(data[i].answer, data[j].answer); if (diff < mnDiff) { (answer...
35,659
321
// - mapping of (serviceType -> (serviceInstanceId <-> serviceProviderInfo))/- stores the actual service provider data like endpoint and owner wallet/ with the ability lookup by service type and service id /
mapping(bytes32 => mapping(uint256 => ServiceEndpoint)) private serviceProviderInfo;
mapping(bytes32 => mapping(uint256 => ServiceEndpoint)) private serviceProviderInfo;
41,267
6
// Requires the given NFT contract supports the interfaces currently required by this market for minting,/ and that it has granted this market the MINTER_ROLE.
modifier onlySupportedCollectionType(address nftContract) { if (!nftContract.supportsInterface(type(INFTLazyMintedCollectionMintCountTo).interfaceId)) { // Must support the mint interface this market depends on. revert NFTDropMarketCore_Must_Support_Collection_Mint_Interface(); } if (!nftContr...
modifier onlySupportedCollectionType(address nftContract) { if (!nftContract.supportsInterface(type(INFTLazyMintedCollectionMintCountTo).interfaceId)) { // Must support the mint interface this market depends on. revert NFTDropMarketCore_Must_Support_Collection_Mint_Interface(); } if (!nftContr...
27,422
194
// reverts if the caller does not have access /
modifier checkAccess() { require(hasAccess(msg.sender, msg.data), "No access"); _; }
modifier checkAccess() { require(hasAccess(msg.sender, msg.data), "No access"); _; }
3,295
128
// Stakes a list of ERC721 tokens in the pool to earn rewards/idList The list of ERC721 token IDs to stake
function stake(uint256[] calldata idList) external { if (paused) { revert Error_ContractIsPaused(); } /// ----------------------------------------------------------------------- /// Validation /// -------------------------------------------------------------------...
function stake(uint256[] calldata idList) external { if (paused) { revert Error_ContractIsPaused(); } /// ----------------------------------------------------------------------- /// Validation /// -------------------------------------------------------------------...
44,227
53
// (ds c)/(1-c)
uint256 num = desiredSupply * targetLTV; uint256 den = MANTISSA - targetLTV; uint256 desiredBorrow = num / den; if (desiredBorrow > 1e5) {
uint256 num = desiredSupply * targetLTV; uint256 den = MANTISSA - targetLTV; uint256 desiredBorrow = num / den; if (desiredBorrow > 1e5) {
6,078
47
// The default value for the NFT recipient is the highest bidder /
function _getNftRecipient(NFT memory _nft) internal view returns (address)
function _getNftRecipient(NFT memory _nft) internal view returns (address)
52,878
17
// decrement the account balance for sender
accountBalances[msg.sender] -= amount;
accountBalances[msg.sender] -= amount;
40,157
79
// Calculates the amount that has already vested but hasn't been released yet. _recipient The address which is being vested /
function releasableAmount(address _recipient) public view returns (uint256) { require( vestedAmount(_recipient) >= beneficiaries[_recipient].amountClaimed ); require( vestedAmount(_recipient) <= beneficiaries[_recipient].totalAllocated ); return sub( vestedAmount(_recipient), beneficiaries[_recipient].amo...
function releasableAmount(address _recipient) public view returns (uint256) { require( vestedAmount(_recipient) >= beneficiaries[_recipient].amountClaimed ); require( vestedAmount(_recipient) <= beneficiaries[_recipient].totalAllocated ); return sub( vestedAmount(_recipient), beneficiaries[_recipient].amo...
3,999
26
// The amount of currency available to be lended. token The loan currency.return The amount of `token` that can be borrowed. /
function maxFlashAmount(address token) external view returns (uint256);
function maxFlashAmount(address token) external view returns (uint256);
9,886
10
// Modifies data.
function modifyRole( address contributor,
function modifyRole( address contributor,
85,202
7
// Lets an account claim a given quantity of tokens. receiver The receiver of the tokens to claim.quantity The quantity of tokens to claim.currency The currency in which to pay for the claim.pricePerTokenThe price per token (i.e. price per 1 ether unit of the token)to pay for the claim.proofs The proof of the claimer's...
function claim( address receiver, uint256 quantity, address currency, uint256 pricePerToken, bytes32[] calldata proofs, uint256 proofMaxQuantityPerTransaction ) external payable;
function claim( address receiver, uint256 quantity, address currency, uint256 pricePerToken, bytes32[] calldata proofs, uint256 proofMaxQuantityPerTransaction ) external payable;
22,009
10
// Function to get address of owner
function getOwner(
function getOwner(
15,872
4
// Set the auction recovery health factor value The new auction health factor /
function setAuctionRecoveryHealthFactor(uint64 value) external;
function setAuctionRecoveryHealthFactor(uint64 value) external;
11,219
5
// Emit event to notify battle start
emit BattleStarted(tokenId, msg.sender, address(0));
emit BattleStarted(tokenId, msg.sender, address(0));
16,224
84
// Store new Merkle root at `windowindex`. Pull `rewardsDeposited` from caller to seed distribution for this root.
function _setWindow( uint256 windowIndex, uint256 rewardsDeposited, address rewardToken, bytes32 merkleRoot, string memory ipfsHash
function _setWindow( uint256 windowIndex, uint256 rewardsDeposited, address rewardToken, bytes32 merkleRoot, string memory ipfsHash
70,368
239
// Get data for a all bAssets in basketreturn bAssetsStruct[] with full bAsset datareturn lenNumber of bAssets in the Basket /
function getBassets() external view returns ( Basset[] memory bAssets, uint256 len )
function getBassets() external view returns ( Basset[] memory bAssets, uint256 len )
40,933
130
// ensure the long asset is valid for the short asset
require( _isMarginableLong(_vault, _vaultDetails), "MarginCalculator: long asset not marginable for short asset" );
require( _isMarginableLong(_vault, _vaultDetails), "MarginCalculator: long asset not marginable for short asset" );
22,411
6
// 1000000000
function getConversionRate (uint256 ethAmount) public view returns(uint256) { uint256 ethPrice = getPrice(); uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1000000000000000000; return ethAmountInUsd; }
function getConversionRate (uint256 ethAmount) public view returns(uint256) { uint256 ethPrice = getPrice(); uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1000000000000000000; return ethAmountInUsd; }
12,323
67
// constuctor(<other arguments>, address _vrfCoordinator, address _link)
* @dev VRFConsumerBase(_vrfCoordinator, _link) public { * @dev <initialization with other arguments goes here> * @dev }
* @dev VRFConsumerBase(_vrfCoordinator, _link) public { * @dev <initialization with other arguments goes here> * @dev }
7,234
103
// The ERC20 Token for ampleforthgold
UFragments public afgToken = UFragments(0x8E54954B3Bbc07DbE3349AEBb6EAFf8D91Db5734);
UFragments public afgToken = UFragments(0x8E54954B3Bbc07DbE3349AEBb6EAFf8D91Db5734);
27,118
12
// set chainlink registry
registry = 0x02777053d6764996e594c3E88AF1D58D5363a2e6; costBuffer = 200;
registry = 0x02777053d6764996e594c3E88AF1D58D5363a2e6; costBuffer = 200;
18,304
1
// have to make sure that this can be set to the voter address during init script
require(msg.sender == deployer, 'Not authorised to set voter.'); voter = _voter; emit VoterSet(msg.sender, _voter);
require(msg.sender == deployer, 'Not authorised to set voter.'); voter = _voter; emit VoterSet(msg.sender, _voter);
13,264
3
// Can only be called from an initializer or constructor
modifier onlyInitializer() { if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError(); _; }
modifier onlyInitializer() { if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError(); _; }
21,600
35
// This function will be used to generate the total supply while deploying the contract This function can never be called again after deploying contract/
function _tokengeneration(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: generation to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = amount; _balances[account] = amount; emit Transfer(addres...
function _tokengeneration(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: generation to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = amount; _balances[account] = amount; emit Transfer(addres...
2,998
317
// Deposits tokens prior to the beginning of the Quest./tokenDeposits The addresses and amounts of tokens to deposit.
function depositTokens( TokenDeposit[] memory tokenDeposits ) external payable;
function depositTokens( TokenDeposit[] memory tokenDeposits ) external payable;
38,651
37
// Current Goal in the CustomCrowdsale
function getGoal() public view returns (uint) { return contributionGoal; }
function getGoal() public view returns (uint) { return contributionGoal; }
9,942
5
// Store adopters in memory rather than contract's storage
address[16] memory adopters = adoption.getAdopters(); Assert.equal(adopters[expectedBorId], expectedAdopter, "Owner of the expected Borrowers should be this contract");
address[16] memory adopters = adoption.getAdopters(); Assert.equal(adopters[expectedBorId], expectedAdopter, "Owner of the expected Borrowers should be this contract");
45,517
166
// we have too little in hot wallet, pull from farmBoss
if (_balanceHere < _hotAmount){ return (true, _hotAmount.sub(_balanceHere)); }
if (_balanceHere < _hotAmount){ return (true, _hotAmount.sub(_balanceHere)); }
2,243
1,310
// See {IERC721CreatorCoreEnumerable-tokenByIndexBase}. /
function tokenByIndexBase(uint256 index) external view virtual override returns (uint256) { require(index < totalSupplyBase(), "ERC721Creator: Index out of bounds"); return _extensionTokens[address(this)][index]; }
function tokenByIndexBase(uint256 index) external view virtual override returns (uint256) { require(index < totalSupplyBase(), "ERC721Creator: Index out of bounds"); return _extensionTokens[address(this)][index]; }
44,308
145
// Lets the contract owner to finalize an update of withdrawal/ delay parameter value. This call has to be preceded with/ a call to beginWithdrawalDelayUpdate and the governance delay/ has to pass.
function finalizeWithdrawalDelayUpdate() external onlyOwner onlyAfterWithdrawalGovernanceDelay(withdrawalDelayChangeInitiated)
function finalizeWithdrawalDelayUpdate() external onlyOwner onlyAfterWithdrawalGovernanceDelay(withdrawalDelayChangeInitiated)
61,540
102
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other assetamountIn input amount of the asset reserveIn reserves of the asset being sold reserveOut reserves if the asset being purchased /
function getAmountOut( uint amountIn, uint reserveIn, uint reserveOut ) internal pure returns (uint amountOut)
function getAmountOut( uint amountIn, uint reserveIn, uint reserveOut ) internal pure returns (uint amountOut)
13,011
74
// See {IERC165-supportsInterface}. Interfaces Supported by this Standard
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC165).interfaceId || interfaceId == Dood...
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC165).interfaceId || interfaceId == Dood...
45,990
13
// Collects the fees associated with provided liquidity/The contract must hold the erc721 token before it can collect fees/tokenId The id of the erc721 token/ return amount0 The amount of fees collected in token0/ return amount1 The amount of fees collected in token1
function collectAllFees( uint256 tokenId
function collectAllFees( uint256 tokenId
6,117
207
// Returns the downcasted uint128 from uint256, reverting onoverflow (when the input is greater than largest uint128). Counterpart to Solidity's `uint128` operator. Requirements: - input must fit into 128 bits /
function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); }
function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); }
12,746
70
// Allows user to mint NFTs for winning tickets or claim refund for losing tickets/tickets indices of all raffle tickets owned by caller
function claimRaffle(uint256[] calldata tickets) external { // Ensure raffle has ended require(block.timestamp > RAFFLE_END_TIME, "Raffle has not ended"); // Ensure raffle has been cleared require( // Either no shuffling required (raffleEntries.length < AVAILA...
function claimRaffle(uint256[] calldata tickets) external { // Ensure raffle has ended require(block.timestamp > RAFFLE_END_TIME, "Raffle has not ended"); // Ensure raffle has been cleared require( // Either no shuffling required (raffleEntries.length < AVAILA...
8,528
331
// Interface for adding and removing liquidity that all Pool contracts should implement. Note that this is notthe complete Pool contract interface, as it is missing the swap hooks. Pool contracts should also inherit fromeither IGeneralPool or IMinimalSwapInfoPool /
interface IBasePool is IPoolSwapStructs { /** * @dev Called by the Vault when a user calls `IVault.joinPool` to add liquidity to this Pool. Returns how many of * each registered token the user should provide, as well as the amount of protocol fees the Pool owes to the Vault. * The Vault will then tak...
interface IBasePool is IPoolSwapStructs { /** * @dev Called by the Vault when a user calls `IVault.joinPool` to add liquidity to this Pool. Returns how many of * each registered token the user should provide, as well as the amount of protocol fees the Pool owes to the Vault. * The Vault will then tak...
3,156
118
// File: erc3156/contracts/interfaces/IERC3156FlashBorrower.sol
pragma solidity >=0.6.0 <0.9.0;
pragma solidity >=0.6.0 <0.9.0;
10,088
4
// Requests randomness/
function getRandomNumber() public restricted returns (bytes32 requestId) { require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet"); return requestRandomness(keyHash, fee); }
function getRandomNumber() public restricted returns (bytes32 requestId) { require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet"); return requestRandomness(keyHash, fee); }
15,643
65
// Approves another address to transfer the given token IDThe zero address indicates there is no approved address.There can only be one approved address per token at a given time.Can only be called by the token owner or an approved operator. to address to be approved for the given token ID tokenId uint256 ID of the tok...
function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: approve caller is not owner nor approved for all" ...
function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: approve caller is not owner nor approved for all" ...
8,158
177
// Get return variable
totalAmountLocked = lockedTokenBalances[msg.sender];
totalAmountLocked = lockedTokenBalances[msg.sender];
24,359
22
// Gets the segment corresponding to the first pool in the path/path The bytes encoded swap path/ return The segment containing all data necessary to target the first pool in the path
function getFirstPool(bytes memory path) internal pure returns (bytes memory) { return path.slice(0, POP_OFFSET); }
function getFirstPool(bytes memory path) internal pure returns (bytes memory) { return path.slice(0, POP_OFFSET); }
27,043
6
// Create a new Auction in memory and add it to the storage mapping. We must keep track of the owner as we must transfer
Auction memory auction = Auction(msg.sender, uint128(_startPrice), uint128(_endPrice), uint128(now), uint128(_duration)); auctionByTokenId[_tokenId] = auction;
Auction memory auction = Auction(msg.sender, uint128(_startPrice), uint128(_endPrice), uint128(now), uint128(_duration)); auctionByTokenId[_tokenId] = auction;
18,145
110
// Mapping from token ID to approved address
mapping (uint256 => address) public tokenApprovals;
mapping (uint256 => address) public tokenApprovals;
37,062
2
// public
function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { require(msg.val...
function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { require(msg.val...
13,282
63
// decreasing the staking limit so the key at _index can't be used anymore
operators[_operator_id].stakingLimit = uint64(_index);
operators[_operator_id].stakingLimit = uint64(_index);
16,153
322
// Compound's repay ETH function signature is: repayBorrow(). No return, revert on fail
_setToken.invoke(_cToken, _repayNotional, abi.encodeWithSignature("repayBorrow()"));
_setToken.invoke(_cToken, _repayNotional, abi.encodeWithSignature("repayBorrow()"));
35,937
165
// Reveal/NonReveal
string public _baseTokenURI; string public _baseTokenEXT = ".json"; string public notRevealedUri; bool public revealed = false; bool public _paused = false;
string public _baseTokenURI; string public _baseTokenEXT = ".json"; string public notRevealedUri; bool public revealed = false; bool public _paused = false;
15,193
22
// 'tag' is used to allow a wrapper contract to distinguish between different users.
mapping(address => mapping(uint256 => mapping(uint256 => mapping(uint256 => Payment)))) public payments;
mapping(address => mapping(uint256 => mapping(uint256 => mapping(uint256 => Payment)))) public payments;
4,974
3
// call by governance when submitting a vote choice: unused param for future usagereturn votingPower of voter /
function handleVote( address voter,
function handleVote( address voter,
7,305
110
// Reads an RLP list value into a list of RLP items. _in RLP list value.return Decoded RLP list items. /
function readList(RLPItem memory _in) internal pure returns (RLPItem[] memory)
function readList(RLPItem memory _in) internal pure returns (RLPItem[] memory)
13,900
28
// Enables a static method by specifying the target module to which the call must be delegated._module The target module._method The static method signature./
function enableStaticCall(address _module, bytes4 _method) external;
function enableStaticCall(address _module, bytes4 _method) external;
29,071
102
// NOTE: Reentrancy is allowed here to allow flashloan use cases
function borrow( bytes32 loanId, // 0 if new loan uint256 withdrawAmount, uint256 initialLoanDuration, // duration in seconds uint256 collateralTokenSent, // if 0, loanId must be provided; any ETH sent must equal this value address collateralTokenAddress...
function borrow( bytes32 loanId, // 0 if new loan uint256 withdrawAmount, uint256 initialLoanDuration, // duration in seconds uint256 collateralTokenSent, // if 0, loanId must be provided; any ETH sent must equal this value address collateralTokenAddress...
57,241
93
// bonus
if (now >= startIcoPreICO && now < startIcoPreICO.add( 2 * 7 * 1 days )){ bonus = 10; }
if (now >= startIcoPreICO && now < startIcoPreICO.add( 2 * 7 * 1 days )){ bonus = 10; }
58,847
151
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
uint256[] private _allTokens;
2,233
121
// Burn tokens, after accumulating rewards for an user and update the rewards per token accumulator.
function _burn(address src, uint256 wad) internal virtual override returns (bool)
function _burn(address src, uint256 wad) internal virtual override returns (bool)
51,466
100
// verifiy if an address can mint new tokens_admin : the address to verify minting rights of return a boolean, truthy when _admin has rights to mint new tokens/
function isMinter(address _admin) public view returns (bool) { if (_admin == owner()) return true; else return( admins[_admin] > 0 ); }
function isMinter(address _admin) public view returns (bool) { if (_admin == owner()) return true; else return( admins[_admin] > 0 ); }
18,927
101
// Set end time for each tier
function setTierEndTime() internal AtStage(Stages.Pending) { tierEndTime[0] = startTimePresale + 1 days; tierEndTime[1] = tierEndTime[0] + 2 days; tierEndTime[2] = tierEndTime[1] + 6 days; }
function setTierEndTime() internal AtStage(Stages.Pending) { tierEndTime[0] = startTimePresale + 1 days; tierEndTime[1] = tierEndTime[0] + 2 days; tierEndTime[2] = tierEndTime[1] + 6 days; }
33,966
95
// Returns the count of all existing NFTokens.return Total supply of NFTs. /
function totalSupply() external override view returns (uint256)
function totalSupply() external override view returns (uint256)
25,130
115
// owner function to withdraw this contracts raw resource balance20% to the Imperial guild treasury, the remainder is then burned
function withdrawRawAndBurn(uint16 id) external onlyOwner { uint256 rawBalance = raw.getBalance(address(this), id); uint256 guildAmt = rawBalance * (ImperialGuildTax / 100); uint256 amtToBurn = rawBalance - guildAmt; raw.safeTransferFrom( address(this), Imperi...
function withdrawRawAndBurn(uint16 id) external onlyOwner { uint256 rawBalance = raw.getBalance(address(this), id); uint256 guildAmt = rawBalance * (ImperialGuildTax / 100); uint256 amtToBurn = rawBalance - guildAmt; raw.safeTransferFrom( address(this), Imperi...
29,331
65
// Allow load refunds back on the contract for the refunding. The team can transfer the funds back on the smart contract in the case the minimum goal was not reached../
function loadRefund() external payable { require(msg.value > 0); require(!isMinimumGoalReached()); loadedRefund = loadedRefund.add(msg.value); }
function loadRefund() external payable { require(msg.value > 0); require(!isMinimumGoalReached()); loadedRefund = loadedRefund.add(msg.value); }
37,322
172
// string public constant baseExtension = ".json";
string public constant baseExtension = ""; address public constant proxyRegistryAddress = 0xA4D04BA51e81F81E6B83Db5e3E02cAb05aC8c46F; uint256 public constant MAX_PER_TX_FREE = 1; uint256 public constant FREE_MAX_SUPPLY = 100; uint256 public constant MAX_PER_TX = 2; uint256 public MAX_SUPPLY = 3...
string public constant baseExtension = ""; address public constant proxyRegistryAddress = 0xA4D04BA51e81F81E6B83Db5e3E02cAb05aC8c46F; uint256 public constant MAX_PER_TX_FREE = 1; uint256 public constant FREE_MAX_SUPPLY = 100; uint256 public constant MAX_PER_TX = 2; uint256 public MAX_SUPPLY = 3...
18,446
69
// Loop through all the `ids` and load the balances.
for {} i {} {
for {} i {} {
6,582
200
// change the amount of tokens users can buy at once
function changeMaxPurchase(uint256 amount) external onlyOwner { maxPurchase = amount; }
function changeMaxPurchase(uint256 amount) external onlyOwner { maxPurchase = amount; }
20,582
98
// Admin function: withdraw PLAT balance
function withdrawPLAT() public onlyOwner payable { uint balance = PLAT.balanceOf(this); PLAT.transfer(msg.sender, balance); }
function withdrawPLAT() public onlyOwner payable { uint balance = PLAT.balanceOf(this); PLAT.transfer(msg.sender, balance); }
10,046
772
// auto-incrementing integer; first valid ID = 1
uint256 private latestID; mapping(uint256 => TrustedNotifier) private IDToTrustedNotifierMap;
uint256 private latestID; mapping(uint256 => TrustedNotifier) private IDToTrustedNotifierMap;
7,778
10
// Update a sale's state saleId ID of sale that's being updated saleState New sale state /
function updateSaleState(uint256 saleId, SaleState saleState) external;
function updateSaleState(uint256 saleId, SaleState saleState) external;
36,094
11
// Get gas cost for interest transfer so can be used in the calculation of collectable interest for particular gas amountreturn returns hardcoded gas cost /
function getGasCostForInterestTransfer() external view virtual
function getGasCostForInterestTransfer() external view virtual
4,934
53
// Reference to base NFT implementation
function implementation() public view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; }
function implementation() public view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; }
16,600
364
// Verify the inclusion of the receipt in the checkpoint data RLP encoded data of the reference tx(s) that encodes the following fields for each txheaderNumber Header block number of which the reference tx was a part ofblockProof Proof that the block header (in the child chain) is a leaf in the submitted merkle rootblo...
function verifyInclusion( bytes calldata data, uint8 offset, bool verifyTxInclusion ) external view returns ( uint256 /* ageOfInput */ )
function verifyInclusion( bytes calldata data, uint8 offset, bool verifyTxInclusion ) external view returns ( uint256 /* ageOfInput */ )
49,017
6
// Return a product
function returnProduct(string memory productType) external onlyExisting(productType) { address buyer = msg.sender; uint blockNum = block.number; require(boughtProducts[buyer][productType].isBought, "Customer doesn't own this product"); require(blockNum - boughtProducts[buyer][produc...
function returnProduct(string memory productType) external onlyExisting(productType) { address buyer = msg.sender; uint blockNum = block.number; require(boughtProducts[buyer][productType].isBought, "Customer doesn't own this product"); require(blockNum - boughtProducts[buyer][produc...
27,325
144
// Reentrancy Guard // Prevents a contract from calling itself, directly or indirectly. /
modifier nonReentrant() { require(_notEntered, "re-entered"); _notEntered = false; _; _notEntered = true; // get a gas-refund post-Istanbul }
modifier nonReentrant() { require(_notEntered, "re-entered"); _notEntered = false; _; _notEntered = true; // get a gas-refund post-Istanbul }
8,833
161
// 不能超过最大利率
require(borrowRate <= borrowRateMax, "borrow rate is too high");
require(borrowRate <= borrowRateMax, "borrow rate is too high");
17,465
142
// Check authorization of the owner
require(recovered == rental.interactionAddress);
require(recovered == rental.interactionAddress);
43,448
293
// Get reserves of a token available to use in defi/_tokenAddress Token address
function getDefiAvaliableReserves(address _tokenAddress) external view returns (uint256);
function getDefiAvaliableReserves(address _tokenAddress) external view returns (uint256);
71,889
164
// force balances to match reserves
function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20Uniswap(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20Uniswap(_token1).balanceOf(address(t...
function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20Uniswap(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20Uniswap(_token1).balanceOf(address(t...
1,660
1
// Extract the transition type
uint8 transitionType = Transitions.extractTransitionType(_transition); bytes32[2] memory outputs; DataTypes.AccountInfo memory updatedAccountInfo; DataTypes.StrategyInfo memory updatedStrategyInfo;
uint8 transitionType = Transitions.extractTransitionType(_transition); bytes32[2] memory outputs; DataTypes.AccountInfo memory updatedAccountInfo; DataTypes.StrategyInfo memory updatedStrategyInfo;
9,645
1
// Constructs a payment splitting test wallet /
constructor( address[] memory payees, uint256[] memory shares_ ) PaymentSplitter( payees, shares_ ) public
constructor( address[] memory payees, uint256[] memory shares_ ) PaymentSplitter( payees, shares_ ) public
40,507
10
// Get content item for token. token Address of token contract.return itemId itemId of content item. /
function getItemId(address token) external view returns (bytes32 itemId) { itemId = tokenItemId[token]; require (itemId != 0, "Token not registered."); }
function getItemId(address token) external view returns (bytes32 itemId) { itemId = tokenItemId[token]; require (itemId != 0, "Token not registered."); }
45,019
71
// execute cut function
bytes memory cutFunction = abi.encodeWithSelector(Diamond.diamondCut.selector, diamondCut); (bool success,) = address(diamondFacet).delegatecall(cutFunction); require(success, "Adding functions failed.");
bytes memory cutFunction = abi.encodeWithSelector(Diamond.diamondCut.selector, diamondCut); (bool success,) = address(diamondFacet).delegatecall(cutFunction); require(success, "Adding functions failed.");
37,396
18
// If `account` had not been already granted `role`, emits a {RoleGranted}event. Note that unlike {grantRole}, this function doesn't perform anychecks on the calling account. [WARNING]====This function should only be called from the constructor when settingup the initial roles for the system. Using this function in any...
function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); }
function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); }
10,444
28
// Force crowdsale refund /
function forceCrowdsaleRefund() public onlyOwner { pause(); fund.enableCrowdsaleRefund(); reservationFund.onCrowdsaleEnd(); token.finishIssuance(); bnbRefundEnabled = true; }
function forceCrowdsaleRefund() public onlyOwner { pause(); fund.enableCrowdsaleRefund(); reservationFund.onCrowdsaleEnd(); token.finishIssuance(); bnbRefundEnabled = true; }
47,546
38
// 722,333 people died that summer but history won't remember a single one.722,3 solhint-disable-next-line avoid-low-level-calls722,333 people died that summer but history won't remember a single one.722,3
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);//722,333 people died that summer but history won't remember a single one.722,3
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);//722,333 people died that summer but history won't remember a single one.722,3
34,216
12
// administrators can: -> change the name of the contract -> change the name of the token -> change the PoS difficultythey CANNOT: -> take funds -> disable withdrawals -> kill the contract -> change the price of tokens
modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[_customerAddress], "SEEK_GOLD: Only owner"); _; }
modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[_customerAddress], "SEEK_GOLD: Only owner"); _; }
20,764
96
// if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; }
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ takeFee = false; }
37,557
11
// This is the storage layout for the Mythics contract. The fields in this struct MUST NOT be removed, renamed, or reordered. Only additionas are allowed to keepthe storage layout compatible between upgrades. /
struct Layout { /** * @notice The number of tokens that have been minted. */ uint256 numMinted; /** * @notice The base URI for the token metadata. */ string baseTokenURI; /** * @notice The number of purchases handled by the seller ...
struct Layout { /** * @notice The number of tokens that have been minted. */ uint256 numMinted; /** * @notice The base URI for the token metadata. */ string baseTokenURI; /** * @notice The number of purchases handled by the seller ...
7,634
56
// switch between set for sale and set not for sale
function toggleForSale(uint256 _tokenId) public { // require caller of the function is not an empty address require(msg.sender != address(0)); // require that token should exist require(_exists(_tokenId)); // get the token's owner address tokenOwner = ownerOf(_tokenId); // check that token...
function toggleForSale(uint256 _tokenId) public { // require caller of the function is not an empty address require(msg.sender != address(0)); // require that token should exist require(_exists(_tokenId)); // get the token's owner address tokenOwner = ownerOf(_tokenId); // check that token...
8,436
40
// Adding modifier to transfer/approval functions
function transfer(address _to, uint256 _value) public whenNotPausedOrWhitelisted(msg.sender) returns (bool) { return super.transfer(_to, _value); }
function transfer(address _to, uint256 _value) public whenNotPausedOrWhitelisted(msg.sender) returns (bool) { return super.transfer(_to, _value); }
36,010
20
// Emits when option tokens are redeemed. Fired when an account redeems their option tokens after the option's expiration. optionType The type of the option (0 for call, 1 for put). optionID The ID of the option. account The account that redeemed the tokens. baseTokenAmount The amount of base tokens redeemed. targetTok...
event RedeemedToken(
event RedeemedToken(
25,610
43
// Becomes true if cancelled by owner
bool public stopped;
bool public stopped;
70,152
305
// Update liquidities
_total_liquidity_locked += addl_liq; _locked_liquidity[msg.sender] += addl_liq;
_total_liquidity_locked += addl_liq; _locked_liquidity[msg.sender] += addl_liq;
4,531
5
// Courtesy of https:github.com/gnosis/MultiSigWallet/blob/master/contracts/MultiSigWallet.sol/ This method allows the pre-defined recipient to call other smart contracts.
function externalCall(address destination, uint256 value, bytes data) public returns (bool) { require(msg.sender == recipient, "Sender must be the recipient."); uint256 dataLength = data.length; bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free m...
function externalCall(address destination, uint256 value, bytes data) public returns (bool) { require(msg.sender == recipient, "Sender must be the recipient."); uint256 dataLength = data.length; bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free m...
26,437
0
// Mapping from token ID to unlock time
mapping(uint256 => uint256) public lockedTokens;
mapping(uint256 => uint256) public lockedTokens;
25,245
8
// Compute `v` and store it in the memory.
mstore(add(m, 0x20), byte(0, mload(add(signature, 0x60)))) pop( staticcall( gas(), // Amount of gas left for the transaction. 0x01, // Address of `ecrecover`. ...
mstore(add(m, 0x20), byte(0, mload(add(signature, 0x60)))) pop( staticcall( gas(), // Amount of gas left for the transaction. 0x01, // Address of `ecrecover`. ...
20,398
725
// authorize the contract to receive the native token requirements: - isPayable must return true /
receive() external payable { if (!isPayable()) { revert NotPayable(); } }
receive() external payable { if (!isPayable()) { revert NotPayable(); } }
3,705
18
// For each x_n, we test if that term is present in the decomposition (if x is larger than it), and if so deduct it and compute the accumulated product.
int256 firstAN; if (x >= x0) { x -= x0; firstAN = a0; } else if (x >= x1) {
int256 firstAN; if (x >= x0) { x -= x0; firstAN = a0; } else if (x >= x1) {
16,759