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 |
|---|---|---|---|---|
37 | // This is the function that will be called postLoan i.e. Encode the logic to handle your flashloaned funds here | function callFunction(
address sender,
Account.Info memory account,
bytes memory data
| function callFunction(
address sender,
Account.Info memory account,
bytes memory data
| 19,334 |
24 | // turns the public mint on and off mint allows minting at the price | function flipPublicMintState() public onlyOwner {
isPublicMintActive = !isPublicMintActive;
}
| function flipPublicMintState() public onlyOwner {
isPublicMintActive = !isPublicMintActive;
}
| 12,618 |
142 | // Emit event that holdings addresses changed. | emit HoldingsAddressesChanged();
| emit HoldingsAddressesChanged();
| 12,690 |
27 | // Enable or disable the mintable status/ | function toggleMintable(bool _mintStatus) public onlyOwner {
mintStatus = _mintStatus;
}
| function toggleMintable(bool _mintStatus) public onlyOwner {
mintStatus = _mintStatus;
}
| 10,104 |
16 | // resets the variables related to a sale process / | function resetSale() internal{
selling = false;
sellingTo = address(0);
askingPrice = 0;
}
| function resetSale() internal{
selling = false;
sellingTo = address(0);
askingPrice = 0;
}
| 29,377 |
302 | // Enables a fee amount with the given tickSpacing/Fee amounts may never be removed once enabled/fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)/tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount | function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
| function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
| 2,565 |
75 | // Transfer the balance rather than the deposit value in case there are any synths left over from direct transfers. | IERC20 sUSD = _sUSD();
uint balance = sUSD.balanceOf(address(this));
if (balance != 0) {
sUSD.transfer(beneficiary, balance);
}
| IERC20 sUSD = _sUSD();
uint balance = sUSD.balanceOf(address(this));
if (balance != 0) {
sUSD.transfer(beneficiary, balance);
}
| 32,934 |
74 | // transfer token for a specified address _from msg.sender from controller. _to The address to transfer to. _value The amount to be transferred. / | function transfer(address _from, address _to, uint256 _value) public onlyController returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
return true;
}
| function transfer(address _from, address _to, uint256 _value) public onlyController returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
return true;
}
| 36,532 |
26 | // balances[to] = balances[to].sub(tokens); | _totalSupply = _totalSupply.sub(tokens);
emit Transfer(to, address(0), tokens);
| _totalSupply = _totalSupply.sub(tokens);
emit Transfer(to, address(0), tokens);
| 54,443 |
31 | // required to withdraw WETH | receive() external payable {}
}
| receive() external payable {}
}
| 772 |
22 | // action type represented as uint8 (see enum ActionType) | uint8 action;
| uint8 action;
| 26,093 |
333 | // sanity check that frontend got same success result; require (v==0 && r==0 && s==0, "Sanity check failed"); | emit FailedHatch(toHatch.owner, toHatch.id);
incubations[id] = toHatch;
if (tmeReturnOnFail > 0){
tme.safeTransfer(toHatch.owner, tmeReturnOnFail);
}
| emit FailedHatch(toHatch.owner, toHatch.id);
incubations[id] = toHatch;
if (tmeReturnOnFail > 0){
tme.safeTransfer(toHatch.owner, tmeReturnOnFail);
}
| 25,441 |
734 | // Set the value to something else | _guardValue = 1;
| _guardValue = 1;
| 24,669 |
356 | // Safely transfers `tokenId` token from `from` to `to`. Requirements: - `from` cannot be the zero address.- `to` cannot be the zero address.- `tokenId` token must exist and be owned by `from`. | * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
| * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
| 500 |
15 | // This mapping is used for the token owner and crowdsale contract to transfer tokens before they are transferable | mapping(address => bool) public transferGrants;
| mapping(address => bool) public transferGrants;
| 13,514 |
36 | // lets the owner change the contract owner_newOwner the new owner address of the contract/ | function changeOwner(address payable _newOwner) external onlyOwner {
require(_newOwner != address(0), "_newOwner can not be null");
owner = _newOwner;
emit NewOwner(_newOwner);
}
| function changeOwner(address payable _newOwner) external onlyOwner {
require(_newOwner != address(0), "_newOwner can not be null");
owner = _newOwner;
emit NewOwner(_newOwner);
}
| 43,617 |
192 | // released percentage triggered by price, should divided by 100 | uint256 public _advancePercentage;
| uint256 public _advancePercentage;
| 31,329 |
14 | // Returns true if `self` starts with `needle`. self The slice to operate on. needle The slice to search for.return True if the slice starts with the provided text, false otherwise. / | function startsWith(slice memory self, slice memory needle)
internal
pure
returns (bool)
| function startsWith(slice memory self, slice memory needle)
internal
pure
returns (bool)
| 26,871 |
120 | // ~~0.3% pool fee | uint256 fee = ((amount * 3) / 997) + 1;
uint256 amountToRepay = amount + fee;
if (tokenBorrow == address(USDI)) {
| uint256 fee = ((amount * 3) / 997) + 1;
uint256 amountToRepay = amount + fee;
if (tokenBorrow == address(USDI)) {
| 7,939 |
5 | // Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.Beware that changing an allowance with this method brings the risk that someone may use both the oldand the new allowance by unfortunate transaction ordering. One possible solution to mitigate thisrace condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: spender The address which will spend the funds. value The amount of tokens to be spent. / | function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
| function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
| 4,882 |
197 | // Deposit and lock tokens for a user/_tokenId NFT that holds lock/_value Amount to deposit/unlock_time New time when to unlock the tokens, or 0 if unchanged/locked_balance Previous locked amount / timestamp/deposit_type The type of deposit | function _deposit_for(
uint _tokenId,
uint _value,
uint unlock_time,
LockedBalance memory locked_balance,
DepositType deposit_type
| function _deposit_for(
uint _tokenId,
uint _value,
uint unlock_time,
LockedBalance memory locked_balance,
DepositType deposit_type
| 48,120 |
183 | // Private function to remove a token from this extension's token tracking data structures.This has O(1) time complexity, but alters the order of the _allTokens array. tokenId uint256 ID of the token to be removed from the tokens list / | function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
| function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
| 149 |
145 | // Checks whether the minting is allowed or not, check for the owner if owner is no the msg.sender then check for the finishedSTOMinting flag because only STOs and owner are allowed for minting | modifier isMintingAllowed() {
if (msg.sender == owner) {
require(!finishedIssuerMinting, "Minting is finished for Issuer");
} else {
require(!finishedSTOMinting, "Minting is finished for STOs");
}
_;
}
| modifier isMintingAllowed() {
if (msg.sender == owner) {
require(!finishedIssuerMinting, "Minting is finished for Issuer");
} else {
require(!finishedSTOMinting, "Minting is finished for STOs");
}
_;
}
| 5,684 |
53 | // The index of an item in a set Returns -1 if the value is not found | function getIndexOf(bytes32 _key, address _value) override external view returns (int) {
return int(getUint(keccak256(abi.encodePacked(_key, ".index", _value)))) - 1;
}
| function getIndexOf(bytes32 _key, address _value) override external view returns (int) {
return int(getUint(keccak256(abi.encodePacked(_key, ".index", _value)))) - 1;
}
| 54,029 |
33 | // Prepares the installation of a plugin./_dao The address of the installing DAO./_params The struct containing the parameters for the `prepareInstallation` function./ return plugin The prepared plugin contract address./ return preparedSetupData The data struct containing the array of helper contracts and permissions that the setup has prepared. | function prepareInstallation(
address _dao,
PrepareInstallationParams calldata _params
| function prepareInstallation(
address _dao,
PrepareInstallationParams calldata _params
| 8,140 |
642 | // Emitted when the calculating the square root overflows UD60x18. | error PRBMathUD60x18__SqrtOverflow(uint256 x);
| error PRBMathUD60x18__SqrtOverflow(uint256 x);
| 53,181 |
32 | // Performs a Solidity function call using a low level `call`. A plain`call` is an unsafe replacement for a function call: use this function instead. If `target` reverts with a revert reason, it is bubbled up by this function (like regular Solidity function calls). Returns the raw returned data. To convert to the expected return value, Requirements: - `target` must be a contract. - calling `target` with `data` must not revert. _Available since v3.1._/ | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| 6,973 |
155 | // counting 1:1 | return _token_amount;
| return _token_amount;
| 39,298 |
13 | // Update ParagonsDAOPlayerID contract address/only owner/_pdp ParagonsDAOPlayerID contract address | function updatePDP(address _pdp) external onlyOwner {
if (_pdp == address(0)) revert ZeroAddress();
emit PDPUpdated(pdp, _pdp);
pdp = _pdp;
}
| function updatePDP(address _pdp) external onlyOwner {
if (_pdp == address(0)) revert ZeroAddress();
emit PDPUpdated(pdp, _pdp);
pdp = _pdp;
}
| 11,439 |
10 | // Create new super token wrapper for the underlying ERC20 token with extra token info underlyingToken Underlying ERC20 token upgradability Upgradability mode name Super token name symbol Super token symbolreturn superToken The deployed and initialized wrapper super tokenNOTE:- It assumes token provide the .decimals() function / | function createERC20Wrapper(
| function createERC20Wrapper(
| 29,339 |
93 | // can&39;t callback on the original block | require(uint64(block.number) != p.commit);
bytes32 bhash = blockhash(p.commit);
| require(uint64(block.number) != p.commit);
bytes32 bhash = blockhash(p.commit);
| 29,194 |
5 | // ERC20 events. | event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
| event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
| 17,034 |
133 | // See {IERC777-operatorBurn}. Emits {Burned} and {IERC20-Transfer} events. / | function operatorBurn(address account, uint256 amount, bytes memory data, bytes memory operatorData) public override {
require(isOperatorFor(_msgSender(), account), "ERC777: caller is not an operator for holder");
_burn(account, amount, data, operatorData);
}
| function operatorBurn(address account, uint256 amount, bytes memory data, bytes memory operatorData) public override {
require(isOperatorFor(_msgSender(), account), "ERC777: caller is not an operator for holder");
_burn(account, amount, data, operatorData);
}
| 40,935 |
44 | // NASR smart contract. / | contract NASRToken is AbstractToken {
/**
* Maximum allowed number of tokens in circulation.
* tokenSupply = tokensIActuallyWant * (10 ^ decimals)
*/
uint256 constant MAX_TOKEN_COUNT = 99999999999999 * (10**18);
/**
* Address of the owner of this smart contract.
*/
address private owner;
/**
* Frozen account list holder
*/
mapping (address => bool) private frozenAccount;
/**
* Current number of tokens in circulation.
*/
uint256 tokenCount = 0;
/**
* True if tokens transfers are currently frozen, false otherwise.
*/
bool frozen = false;
/**
* Create new token smart contract and make msg.sender the
* owner of this smart contract.
*/
function NASRToken () {
owner = msg.sender;
}
/**
* Get total number of tokens in circulation.
*
* @return total number of tokens in circulation
*/
function totalSupply() constant returns (uint256 supply) {
return tokenCount;
}
string constant public name = "NASR";
string constant public symbol = "NASR";
uint8 constant public decimals = 18;
/**
* Transfer given number of tokens from message sender to given recipient.
* @param _to address to transfer tokens to the owner of
* @param _value number of tokens to transfer to the owner of given address
* @return true if tokens were transferred successfully, false otherwise
*/
function transfer(address _to, uint256 _value) returns (bool success) {
require(!frozenAccount[msg.sender]);
if (frozen) return false;
else return AbstractToken.transfer (_to, _value);
}
/**
* Transfer given number of tokens from given owner to given recipient.
*
* @param _from address to transfer tokens from the owner of
* @param _to address to transfer tokens to the owner of
* @param _value number of tokens to transfer from given owner to given
* recipient
* @return true if tokens were transferred successfully, false otherwise
*/
function transferFrom(address _from, address _to, uint256 _value)
returns (bool success) {
require(!frozenAccount[_from]);
if (frozen) return false;
else return AbstractToken.transferFrom (_from, _to, _value);
}
/**
* Change how many tokens given spender is allowed to transfer from message
* spender. In order to prevent double spending of allowance,
* To change the approve amount you first have to reduce the addresses`
* allowance to zero by calling `approve(_spender, 0)` if it is not
* already 0 to mitigate the race condition described here:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender address to allow the owner of to transfer tokens from
* message sender
* @param _value number of tokens to allow to transfer
* @return true if token transfer was successfully approved, false otherwise
*/
function approve (address _spender, uint256 _value)
returns (bool success) {
require(allowance (msg.sender, _spender) == 0 || _value == 0);
return AbstractToken.approve (_spender, _value);
}
/**
* Create _value new tokens and give new created tokens to msg.sender.
* May only be called by smart contract owner.
*
* @param _value number of tokens to create
* @return true if tokens were created successfully, false otherwise
*/
function createTokens(uint256 _value)
returns (bool success) {
require (msg.sender == owner);
if (_value > 0) {
if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false;
accounts [msg.sender] = safeAdd (accounts [msg.sender], _value);
tokenCount = safeAdd (tokenCount, _value);
// adding transfer event and _from address as null address
emit Transfer(0x0, msg.sender, _value);
return true;
}
return false;
}
/**
* Set new owner for the smart contract.
* May only be called by smart contract owner.
*
* @param _newOwner address of new owner of the smart contract
*/
function setOwner(address _newOwner) {
require (msg.sender == owner);
owner = _newOwner;
}
/**
* Freeze ALL token transfers.
* May only be called by smart contract owner.
*/
function freezeTransfers () {
require (msg.sender == owner);
if (!frozen) {
frozen = true;
emit Freeze ();
}
}
/**
* Unfreeze ALL token transfers.
* May only be called by smart contract owner.
*/
function unfreezeTransfers () {
require (msg.sender == owner);
if (frozen) {
frozen = false;
emit Unfreeze ();
}
}
/*A user is able to unintentionally send tokens to a contract
* and if the contract is not prepared to refund them they will get stuck in the contract.
* The same issue used to happen for Ether too but new Solidity versions added the payable modifier to
* prevent unintended Ether transfers. However, there’s no such mechanism for token transfers.
* so the below function is created
*/
function refundTokens(address _token, address _refund, uint256 _value) {
require (msg.sender == owner);
require(_token != address(this));
AbstractToken token = AbstractToken(_token);
token.transfer(_refund, _value);
emit RefundTokens(_token, _refund, _value);
}
/**
* Freeze specific account
* May only be called by smart contract owner.
*/
function freezeAccount(address _target, bool freeze) {
require (msg.sender == owner);
require (msg.sender != _target);
frozenAccount[_target] = freeze;
emit FrozenFunds(_target, freeze);
}
/**
* Logged when token transfers were frozen.
*/
event Freeze ();
/**
* Logged when token transfers were unfrozen.
*/
event Unfreeze ();
/**
* Logged when a particular account is frozen.
*/
event FrozenFunds(address target, bool frozen);
/**
* when accidentally send other tokens are refunded
*/
event RefundTokens(address _token, address _refund, uint256 _value);
} | contract NASRToken is AbstractToken {
/**
* Maximum allowed number of tokens in circulation.
* tokenSupply = tokensIActuallyWant * (10 ^ decimals)
*/
uint256 constant MAX_TOKEN_COUNT = 99999999999999 * (10**18);
/**
* Address of the owner of this smart contract.
*/
address private owner;
/**
* Frozen account list holder
*/
mapping (address => bool) private frozenAccount;
/**
* Current number of tokens in circulation.
*/
uint256 tokenCount = 0;
/**
* True if tokens transfers are currently frozen, false otherwise.
*/
bool frozen = false;
/**
* Create new token smart contract and make msg.sender the
* owner of this smart contract.
*/
function NASRToken () {
owner = msg.sender;
}
/**
* Get total number of tokens in circulation.
*
* @return total number of tokens in circulation
*/
function totalSupply() constant returns (uint256 supply) {
return tokenCount;
}
string constant public name = "NASR";
string constant public symbol = "NASR";
uint8 constant public decimals = 18;
/**
* Transfer given number of tokens from message sender to given recipient.
* @param _to address to transfer tokens to the owner of
* @param _value number of tokens to transfer to the owner of given address
* @return true if tokens were transferred successfully, false otherwise
*/
function transfer(address _to, uint256 _value) returns (bool success) {
require(!frozenAccount[msg.sender]);
if (frozen) return false;
else return AbstractToken.transfer (_to, _value);
}
/**
* Transfer given number of tokens from given owner to given recipient.
*
* @param _from address to transfer tokens from the owner of
* @param _to address to transfer tokens to the owner of
* @param _value number of tokens to transfer from given owner to given
* recipient
* @return true if tokens were transferred successfully, false otherwise
*/
function transferFrom(address _from, address _to, uint256 _value)
returns (bool success) {
require(!frozenAccount[_from]);
if (frozen) return false;
else return AbstractToken.transferFrom (_from, _to, _value);
}
/**
* Change how many tokens given spender is allowed to transfer from message
* spender. In order to prevent double spending of allowance,
* To change the approve amount you first have to reduce the addresses`
* allowance to zero by calling `approve(_spender, 0)` if it is not
* already 0 to mitigate the race condition described here:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender address to allow the owner of to transfer tokens from
* message sender
* @param _value number of tokens to allow to transfer
* @return true if token transfer was successfully approved, false otherwise
*/
function approve (address _spender, uint256 _value)
returns (bool success) {
require(allowance (msg.sender, _spender) == 0 || _value == 0);
return AbstractToken.approve (_spender, _value);
}
/**
* Create _value new tokens and give new created tokens to msg.sender.
* May only be called by smart contract owner.
*
* @param _value number of tokens to create
* @return true if tokens were created successfully, false otherwise
*/
function createTokens(uint256 _value)
returns (bool success) {
require (msg.sender == owner);
if (_value > 0) {
if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false;
accounts [msg.sender] = safeAdd (accounts [msg.sender], _value);
tokenCount = safeAdd (tokenCount, _value);
// adding transfer event and _from address as null address
emit Transfer(0x0, msg.sender, _value);
return true;
}
return false;
}
/**
* Set new owner for the smart contract.
* May only be called by smart contract owner.
*
* @param _newOwner address of new owner of the smart contract
*/
function setOwner(address _newOwner) {
require (msg.sender == owner);
owner = _newOwner;
}
/**
* Freeze ALL token transfers.
* May only be called by smart contract owner.
*/
function freezeTransfers () {
require (msg.sender == owner);
if (!frozen) {
frozen = true;
emit Freeze ();
}
}
/**
* Unfreeze ALL token transfers.
* May only be called by smart contract owner.
*/
function unfreezeTransfers () {
require (msg.sender == owner);
if (frozen) {
frozen = false;
emit Unfreeze ();
}
}
/*A user is able to unintentionally send tokens to a contract
* and if the contract is not prepared to refund them they will get stuck in the contract.
* The same issue used to happen for Ether too but new Solidity versions added the payable modifier to
* prevent unintended Ether transfers. However, there’s no such mechanism for token transfers.
* so the below function is created
*/
function refundTokens(address _token, address _refund, uint256 _value) {
require (msg.sender == owner);
require(_token != address(this));
AbstractToken token = AbstractToken(_token);
token.transfer(_refund, _value);
emit RefundTokens(_token, _refund, _value);
}
/**
* Freeze specific account
* May only be called by smart contract owner.
*/
function freezeAccount(address _target, bool freeze) {
require (msg.sender == owner);
require (msg.sender != _target);
frozenAccount[_target] = freeze;
emit FrozenFunds(_target, freeze);
}
/**
* Logged when token transfers were frozen.
*/
event Freeze ();
/**
* Logged when token transfers were unfrozen.
*/
event Unfreeze ();
/**
* Logged when a particular account is frozen.
*/
event FrozenFunds(address target, bool frozen);
/**
* when accidentally send other tokens are refunded
*/
event RefundTokens(address _token, address _refund, uint256 _value);
} | 77,420 |
629 | // integral(V) =MCReth ^ 3C / (3V ^ 3)1e18computation result is multiplied by 1e18 to allow for a precision of 18 decimals.NOTE: omits the minus sign of the correct integral to use a uint result type for simplicityWARNING: this low-level function should be called from a contract which checks thatmcrEth / assetValue < 1e17 (no overflow) and assetValue != 0 / | function calculateIntegralAtPoint(
uint assetValue,
uint mcrEth
| function calculateIntegralAtPoint(
uint assetValue,
uint mcrEth
| 2,109 |
31 | // add storeman transaction info/ xHash hash of HTLC random number/ srcSmgIDID of source storeman group/ destSmgID ID of the storeman which will take over of the debt of source storeman group/ lockedTimeHTLC lock time/ statusStatus, should be 'Locked' for asset or 'DebtLocked' for debt | function addDebtTx(Data storage self, bytes32 xHash, bytes32 srcSmgID, bytes32 destSmgID, uint lockedTime, TxStatus status)
external
| function addDebtTx(Data storage self, bytes32 xHash, bytes32 srcSmgID, bytes32 destSmgID, uint lockedTime, TxStatus status)
external
| 14,544 |
8 | // the type of the arb asset (single asset, arb asset) 0... single asset (uses median price) 1... basket asset (uses weighted average price) 2... index asset(uses token address and oracle to get supply and price and calculates supplyprice / divisor) 3 .. sqrt index asset (uses token address and oracle to get supply and price and calculates sqrt(supplyprice) / divisor) | uint256 public _assetType;
| uint256 public _assetType;
| 11,757 |
11 | // Pause deposits on the pool. Withdraws still allowed | function pause() external;
| function pause() external;
| 46,785 |
7 | // solhint-disable-next-line | assembly {
recipientAddress := mload(add(destinationRecipientAddress, 0x20))
}
| assembly {
recipientAddress := mload(add(destinationRecipientAddress, 0x20))
}
| 39,403 |
21 | // To delete a key-value pair from the entries array in O(1), we swap the entry to delete with the last one in the array, and then remove the last entry (sometimes called as 'swap and pop'). This modifies the order of the array, as noted in {at}. |
uint256 toDeleteIndex = keyIndex - 1;
uint256 lastIndex = map.entries.length - 1;
|
uint256 toDeleteIndex = keyIndex - 1;
uint256 lastIndex = map.entries.length - 1;
| 44,581 |
20 | // amount should be more than 0 | require(balance > 0, "amount has to be more than 0");
| require(balance > 0, "amount has to be more than 0");
| 31,081 |
3 | // add credit token | tokens[creditToken].supply = 0;
tokens[creditToken].isValid = true;
tokenSet.push(creditToken);
| tokens[creditToken].supply = 0;
tokens[creditToken].isValid = true;
tokenSet.push(creditToken);
| 21,367 |
54 | // Pool | function pool_apply_cover(
address _pool,
uint256 _pending,
uint256 _payoutNumerator,
uint256 _payoutDenominator,
uint256 _incidentTimestamp,
bytes32 _merkleRoot,
string calldata _rawdata,
string calldata _memo
| function pool_apply_cover(
address _pool,
uint256 _pending,
uint256 _payoutNumerator,
uint256 _payoutDenominator,
uint256 _incidentTimestamp,
bytes32 _merkleRoot,
string calldata _rawdata,
string calldata _memo
| 38,431 |
22 | // Function to activate/desactivate the free mint | function toggleFreeMint()
external
onlyOwner
| function toggleFreeMint()
external
onlyOwner
| 35,415 |
12 | // fees in dweb token | return feesInWeiIfPaidViaDWEB.mul(estDWEBPerEth);
| return feesInWeiIfPaidViaDWEB.mul(estDWEBPerEth);
| 43,890 |
0 | // BEP20 basic token contract being held. | IBEP20 private immutable _token;
| IBEP20 private immutable _token;
| 36,575 |
201 | // Transfer from taker to maker NOTE(reentrancy): `takeOrder(s)` is marked nonReentrant NOTE2: _transferFromTakerToMaker returns the excessEth only, but we reuse the 'excessEthAndIntrinsicFuel' variable to work around 'CompilerError: Stack too deep'. | excessEthAndIntrinsicFuel = _transferFromTakerToMaker(
taker,
input.maker,
_takerValue,
_unpacked.pair,
excessEthAndIntrinsicFuel,
isBoosted
);
| excessEthAndIntrinsicFuel = _transferFromTakerToMaker(
taker,
input.maker,
_takerValue,
_unpacked.pair,
excessEthAndIntrinsicFuel,
isBoosted
);
| 13,944 |
567 | // Return boolean indicating whether given version is valid for given type _serviceType - type of service _serviceVersion - version of service to check / | function serviceVersionIsValid(bytes32 _serviceType, bytes32 _serviceVersion)
external view returns (bool)
| function serviceVersionIsValid(bytes32 _serviceType, bytes32 _serviceVersion)
external view returns (bool)
| 56,088 |
5 | // Transfer expected USDC from beneficiary | IERC20(usdc).safeTransferFrom(beneficiary, address(this), usdcAmount);
| IERC20(usdc).safeTransferFrom(beneficiary, address(this), usdcAmount);
| 10,655 |
99 | // initialise the fragments / | function initialiseFragments(
int256[3][3][] memory trisCameraSpace,
int256[3][3][] memory trisWorldSpace,
int256[3][3][] memory trisCols,
int256 canvasDim
| function initialiseFragments(
int256[3][3][] memory trisCameraSpace,
int256[3][3][] memory trisWorldSpace,
int256[3][3][] memory trisCols,
int256 canvasDim
| 45,267 |
155 | // maps facet addresses to function selectors | mapping(address => FacetFunctionSelectors) facetFunctionSelectors;
| mapping(address => FacetFunctionSelectors) facetFunctionSelectors;
| 19,985 |
58 | // Transfer the domains to the buyer | zNSRegistrar.transferFrom(address(this), msg.sender, domainId);
| zNSRegistrar.transferFrom(address(this), msg.sender, domainId);
| 50,998 |
10 | // 'owner' -> `tokenId` mapping used in {permitAll} for {setApprovalForAll}. | mapping(address => uint256) public noncesForAll;
constructor() {
DOMAIN_SEPARATOR_CHAIN_ID = block.chainid;
_DOMAIN_SEPARATOR = _calculateDomainSeparator();
}
| mapping(address => uint256) public noncesForAll;
constructor() {
DOMAIN_SEPARATOR_CHAIN_ID = block.chainid;
_DOMAIN_SEPARATOR = _calculateDomainSeparator();
}
| 54,055 |
62 | // _giverId The adminId of the liquidPledging pledge admin who is donating_receiverId The adminId of the liquidPledging pledge admin receiving the donation/ | function newFundsForwarder(uint64 _giverId, uint64 _receiverId) public {
address fundsForwarder = _deployMinimal(childImplementation);
FundsForwarder(fundsForwarder).initialize(_giverId, _receiverId);
// Store a registry of fundForwarders as events
emit NewFundForwarder(_giverId, _receiverId, fundsForwarder);
}
| function newFundsForwarder(uint64 _giverId, uint64 _receiverId) public {
address fundsForwarder = _deployMinimal(childImplementation);
FundsForwarder(fundsForwarder).initialize(_giverId, _receiverId);
// Store a registry of fundForwarders as events
emit NewFundForwarder(_giverId, _receiverId, fundsForwarder);
}
| 52,047 |
15 | // Mints tokens to an address/_account The account to mint to/_amount The amount to mint | function mint(address _account, uint256 _amount)
external
override
onlyMintAuthority
| function mint(address _account, uint256 _amount)
external
override
onlyMintAuthority
| 18,301 |
17 | // Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw account The address of the contract to query for support of an interface interfaceId The interface identifier, as specified in ERC-165return success true if the STATICCALL succeeded, false otherwisereturn result true if the STATICCALL succeeded and the contract at accountindicates support of the interface with identifier interfaceId, false otherwise / | function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool success, bool result)
| function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool success, bool result)
| 8,359 |
9 | // Allows caller to call multiple functions in a single TX. Does NOT return the function return values. / | function multicall(bytes[] calldata data) external {
for (uint256 i = 0; i < data.length; i++) address(this).functionDelegateCall(data[i]);
}
| function multicall(bytes[] calldata data) external {
for (uint256 i = 0; i < data.length; i++) address(this).functionDelegateCall(data[i]);
}
| 42,187 |
21 | // updates edition parameter. Careful: This will overwrite all previously set values on that edition. / | function updateEdition(
uint256 editionId,
uint24 _publicMintPriceInFinney,
uint32 _publicMintStartTS,
uint32 _publicMintEndTS,
uint8 _maxMintPerWallet,
uint24 _maxSupply,
bool _perTokenMetadata
| function updateEdition(
uint256 editionId,
uint24 _publicMintPriceInFinney,
uint32 _publicMintStartTS,
uint32 _publicMintEndTS,
uint8 _maxMintPerWallet,
uint24 _maxSupply,
bool _perTokenMetadata
| 13,019 |
118 | // from Old addressto New addressby Who made a change/ | event CryptonomicaVerificationContractAddressChanged(address from, address to, address indexed by);
| event CryptonomicaVerificationContractAddressChanged(address from, address to, address indexed by);
| 9,272 |
176 | // Mark the premined tickets as processed so that reserved tickets can't later be printed against them. Make sure int casting isnt overflowing the int. 2^255 - 1 is the largest number that can be stored in an int. | require(
_processedTicketTrackerOf[_projectId] < 0 ||
uint256(_processedTicketTrackerOf[_projectId]) +
uint256(_weightedAmount) <=
uint256(type(int256).max),
"TerminalV1::printTickets: INT_LIMIT_REACHED"
);
_processedTicketTrackerOf[_projectId] =
_processedTicketTrackerOf[_projectId] +
int256(_unreservedWeightedAmount);
| require(
_processedTicketTrackerOf[_projectId] < 0 ||
uint256(_processedTicketTrackerOf[_projectId]) +
uint256(_weightedAmount) <=
uint256(type(int256).max),
"TerminalV1::printTickets: INT_LIMIT_REACHED"
);
_processedTicketTrackerOf[_projectId] =
_processedTicketTrackerOf[_projectId] +
int256(_unreservedWeightedAmount);
| 20,897 |
12 | // SMART CONTRACT FUNCTIONS // Add an airline to the registration queue Can only be called from FlightSuretyApp contract/ | function registerAirline(address airline) external requireAppContract {
if (airlines[airline] == false) {
airlines[airline] = true;
}
}
| function registerAirline(address airline) external requireAppContract {
if (airlines[airline] == false) {
airlines[airline] = true;
}
}
| 15,186 |
12 | // can't unpause if contract was upgraded | paused = false;
| paused = false;
| 32,204 |
120 | // for determine the exact number of received pool | uint256 poolAmountReceive;
| uint256 poolAmountReceive;
| 9,084 |
144 | // 送金元、送金先、送金金額によって対象のトランザクションの手数料を決定する送金金額に対して手数料率をかけたものを計算し、最低手数料金額とのmax値を取る。sender 実行アドレス from 送金元 to 送金先 amount 送金金額 return 手数料金額 / | function transferFee(address sender, address from, address to, uint amount) public view returns (uint) {
sender; from; to; // #avoid warning
if (_transferFeeRate > 0) {
uint denominator = 1000000; // 0.01 pips だから 100 * 100 * 100 で 100万
uint numerator = mul(amount, _transferFeeRate);
uint fee = numerator / denominator;
uint remainder = sub(numerator, mul(denominator, fee));
// 余りがある場合はfeeに1を足す
if (remainder > 0) {
fee++;
}
if (fee < _transferMinimumFee) {
fee = _transferMinimumFee;
}
return fee;
} else {
return 0;
}
}
| function transferFee(address sender, address from, address to, uint amount) public view returns (uint) {
sender; from; to; // #avoid warning
if (_transferFeeRate > 0) {
uint denominator = 1000000; // 0.01 pips だから 100 * 100 * 100 で 100万
uint numerator = mul(amount, _transferFeeRate);
uint fee = numerator / denominator;
uint remainder = sub(numerator, mul(denominator, fee));
// 余りがある場合はfeeに1を足す
if (remainder > 0) {
fee++;
}
if (fee < _transferMinimumFee) {
fee = _transferMinimumFee;
}
return fee;
} else {
return 0;
}
}
| 76,231 |
24 | // release funds for the current vesting cyclewhile it is callable by anyone, funds are sent to a fixed addressregardless of who calls this function, so owner check is avoided to save gas/ | function release() public {
// make sure prepare function has been called and successfully executed
require(isPrepared() == true);
// ensure the current cycle hasn't been released
require(releases[currentCycle].released == 0, "already released");
// mark current cycle as released
releases[currentCycle].released = 1;
// get current timestamp
uint256 timestamp = dateI._now();
// ensure the current timestamp (date) is on or after the release date
require(timestamp >= releases[currentCycle].timestamp, "release timestamp not yet passed");
// transfer tokens to designated receiver wallet
require(levI.transfer(receiver, releaseAmount));
// move onto the next cycle (if we arent cycle 12 which is last)
if (currentCycle < 12) {
currentCycle += 1;
}
// emit event indicating tokens are released
emit TokensReleased();
}
| function release() public {
// make sure prepare function has been called and successfully executed
require(isPrepared() == true);
// ensure the current cycle hasn't been released
require(releases[currentCycle].released == 0, "already released");
// mark current cycle as released
releases[currentCycle].released = 1;
// get current timestamp
uint256 timestamp = dateI._now();
// ensure the current timestamp (date) is on or after the release date
require(timestamp >= releases[currentCycle].timestamp, "release timestamp not yet passed");
// transfer tokens to designated receiver wallet
require(levI.transfer(receiver, releaseAmount));
// move onto the next cycle (if we arent cycle 12 which is last)
if (currentCycle < 12) {
currentCycle += 1;
}
// emit event indicating tokens are released
emit TokensReleased();
}
| 77,978 |
203 | // Function to allow the Dao to register a new order/_contractorAddress The address of the contractor smart contract/_contractorProposalID The index of the contractor proposal/_amount The amount in wei of the order | function newOrder(
address _contractorAddress,
uint _contractorProposalID,
| function newOrder(
address _contractorAddress,
uint _contractorProposalID,
| 7,529 |
7 | // If x > 1, then we compute the fraction part of log2(x), which is larger than 0. | if (x > FIXED_1) {
for (uint8 i = MAX_PRECISION; i > 0; --i) {
x = (x * x) / FIXED_1; // now 1 < x < 4
if (x >= FIXED_2) {
x >>= 1; // now 1 < x < 2
res += ONE << (i - 1);
}
| if (x > FIXED_1) {
for (uint8 i = MAX_PRECISION; i > 0; --i) {
x = (x * x) / FIXED_1; // now 1 < x < 4
if (x >= FIXED_2) {
x >>= 1; // now 1 < x < 2
res += ONE << (i - 1);
}
| 14,380 |
65 | // A mapping from NFT ID to the address that owns it. / | mapping (uint256 => address) internal idToOwner;
| mapping (uint256 => address) internal idToOwner;
| 3,713 |
5 | // Parses a revert reason that should contain the numeric quote | function parseRevertReason(bytes memory reason) private pure returns (uint256) {
if (reason.length != 32) {
if (reason.length < 68) revert('Unexpected error');
assembly {
reason := add(reason, 0x04)
}
revert(abi.decode(reason, (string)));
}
return abi.decode(reason, (uint256));
}
| function parseRevertReason(bytes memory reason) private pure returns (uint256) {
if (reason.length != 32) {
if (reason.length < 68) revert('Unexpected error');
assembly {
reason := add(reason, 0x04)
}
revert(abi.decode(reason, (string)));
}
return abi.decode(reason, (uint256));
}
| 52,398 |
151 | // Contract name | string public name;
| string public name;
| 61,203 |
9 | // length of proofOutput is at s + 0x60 | mstore(0x200, 0xc0) // location of inputNotes
| mstore(0x200, 0xc0) // location of inputNotes
| 48,667 |
0 | // https:docs.synthetix.io/contracts/source/interfaces/iexchangerates | interface IExchangeRates {
function rateAndInvalid(bytes32 currencyKey) external view returns (uint rate, bool isInvalid);
}
| interface IExchangeRates {
function rateAndInvalid(bytes32 currencyKey) external view returns (uint rate, bool isInvalid);
}
| 15,736 |
1 | // Events//Functions/whitelist function for adding or open? |
function defineBytes32ID (string memory description, uint256 granularity)
public
returns(bytes32 _id)
|
function defineBytes32ID (string memory description, uint256 granularity)
public
returns(bytes32 _id)
| 44,261 |
15 | // See {IERC165-supportsInterface}./ | function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return ERC1155.supportsInterface(interfaceId);
}
| function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return ERC1155.supportsInterface(interfaceId);
}
| 10,627 |
32 | // check for ether received | taxAmount = (users[userAddress].rewardsInUSD.mul(uint256(taxPercentage))).div(100);
taxAmount = (taxAmount.div(oracle.getPrice(taxTokenAddress, oracle.getOracleType(taxTokenAddress)))).mul(oracle.getDecimalFactor());
emit TaxDetail(taxAmount);
return taxAmount;
| taxAmount = (users[userAddress].rewardsInUSD.mul(uint256(taxPercentage))).div(100);
taxAmount = (taxAmount.div(oracle.getPrice(taxTokenAddress, oracle.getOracleType(taxTokenAddress)))).mul(oracle.getDecimalFactor());
emit TaxDetail(taxAmount);
return taxAmount;
| 38,758 |
22 | // check cost | uint256 _cost = ComputeSnailCost(_id);
require(msg.value == _cost, "wrong amount of ETH");
| uint256 _cost = ComputeSnailCost(_id);
require(msg.value == _cost, "wrong amount of ETH");
| 22,362 |
165 | // Returns the index of the next element to be enqueued.return Index for the next queue element. / | function getNextQueueIndex() external view returns (uint40);
| function getNextQueueIndex() external view returns (uint40);
| 35,299 |
113 | // Nifty Gateway implementation of Non-Fungible Token Standard. / | contract ERC721 is NiftyEntity, Context, ERC165, IERC721, IERC721Metadata {
// Tracked individual instance spawned by {BuilderShop} contract.
uint immutable public _id;
// Number of distinct NFTs housed in this contract.
uint immutable public _typeCount;
// Intial receiver of all newly minted NFTs.
address immutable public _defaultOwner;
// Component(s) of 'tokenId' calculation.
uint immutable internal topLevelMultiplier;
uint immutable internal midLevelMultiplier;
// Token name.
string private _name;
// Token symbol.
string private _symbol;
// Token artifact location.
string private _baseURI;
// Mapping from Nifty type to name of token.
mapping(uint256 => string) private _niftyTypeName;
// Mapping from Nifty type to IPFS hash of canonical artifcat file.
mapping(uint256 => string) private _niftyTypeIPFSHashes;
// Mapping from token ID to owner address.
mapping (uint256 => address) internal _owners;
// Mapping owner address to token count, by aggregating all _typeCount NFTs in the contact.
mapping (address => uint256) internal _balances;
// Mapping from token ID to approved address.
mapping (uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals.
mapping (address => mapping (address => bool)) private _operatorApprovals;
/**
* @dev Initializes the token collection.
*
* @param name_ Of the collection being deployed.
* @param symbol_ Shorthand token identifier, for wallets, etc.
* @param id_ Number instance deployed by {BuilderShop} contract.
* @param baseURI_ The location where the artifact assets are stored.
* @param typeCount_ The number of different Nifty types (different
* individual NFTs) associated with the deployed collection.
* @param defaultOwner_ Intial receiver of all newly minted NFTs.
* @param niftyRegistryContract Points to the repository of authenticated
* addresses for stateful operations.
*/
constructor(string memory name_,
string memory symbol_,
uint id_,
string memory baseURI_,
uint typeCount_,
address defaultOwner_,
address niftyRegistryContract) NiftyEntity(niftyRegistryContract) {
_name = name_;
_symbol = symbol_;
_id = id_;
_baseURI = baseURI_;
_typeCount = typeCount_;
_defaultOwner = defaultOwner_;
midLevelMultiplier = 10000;
topLevelMultiplier = id_ * 100000000;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC721).interfaceId
|| interfaceId == type(IERC721Metadata).interfaceId
|| super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the link to artificat location for a given token by 'tokenId'.
* Throws if the token ID does not exist. May return an empty string.
* @param tokenId uint256 ID of the token to query.
* @return The location where the artifact assets are stored.
*/
function tokenURI(uint256 tokenId) external view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory tokenIdStr = Strings.toString(tokenId);
return string(abi.encodePacked(_baseURI, tokenIdStr));
}
/**
* @dev Returns an IPFS hash for a given token ID.
* Throws if the token ID does not exist. May return an empty string.
* @param tokenId uint256 ID of the token to query.
* @return IPFS hash for this (_typeCount) NFT.
*/
function tokenIPFSHash(uint256 tokenId) external view returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: IPFS hash query for nonexistent token");
uint niftyType = _getNiftyTypeId(tokenId);
return _niftyTypeIPFSHashes[niftyType];
}
/**
* @dev Determine which NFT in the contract (_typeCount) is associated
* with this 'tokenId'.
*/
function _getNiftyTypeId(uint tokenId) private view returns (uint) {
return (tokenId - topLevelMultiplier) / midLevelMultiplier;
}
/**
* @dev Returns the Name for a given token ID.
* Throws if the token ID does not exist. May return an empty string.
* @param tokenId uint256 ID of the token to query
*/
function tokenName(uint256 tokenId) external view returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: Name query for nonexistent token");
uint niftyType = _getNiftyTypeId(tokenId);
return _niftyTypeName[niftyType];
}
/**
* @dev Internal function to set the token IPFS hash for a nifty type.
* @param niftyType uint256 ID component of the token to set its IPFS hash
* @param ipfs_hash string IPFS link to assign
*/
function _setTokenIPFSHashNiftyType(uint256 niftyType, string memory ipfs_hash) internal {
require(bytes(_niftyTypeIPFSHashes[niftyType]).length == 0, "ERC721Metadata: IPFS hash already set");
_niftyTypeIPFSHashes[niftyType] = ipfs_hash;
}
/**
* @dev Internal function to set the name for a nifty type.
* @param niftyType uint256 of nifty type name to be set
* @param nifty_type_name name of nifty type
*/
function _setNiftyTypeName(uint256 niftyType, string memory nifty_type_name) internal {
_niftyTypeName[niftyType] = nifty_type_name;
}
/**
* @dev Base URI for computing {tokenURI}.
*/
function _setBaseURI(string memory baseURI_) internal {
_baseURI = baseURI_;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
private returns (bool)
{
if (isContract(to)) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
// solhint-disable-next-line no-inline-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
| contract ERC721 is NiftyEntity, Context, ERC165, IERC721, IERC721Metadata {
// Tracked individual instance spawned by {BuilderShop} contract.
uint immutable public _id;
// Number of distinct NFTs housed in this contract.
uint immutable public _typeCount;
// Intial receiver of all newly minted NFTs.
address immutable public _defaultOwner;
// Component(s) of 'tokenId' calculation.
uint immutable internal topLevelMultiplier;
uint immutable internal midLevelMultiplier;
// Token name.
string private _name;
// Token symbol.
string private _symbol;
// Token artifact location.
string private _baseURI;
// Mapping from Nifty type to name of token.
mapping(uint256 => string) private _niftyTypeName;
// Mapping from Nifty type to IPFS hash of canonical artifcat file.
mapping(uint256 => string) private _niftyTypeIPFSHashes;
// Mapping from token ID to owner address.
mapping (uint256 => address) internal _owners;
// Mapping owner address to token count, by aggregating all _typeCount NFTs in the contact.
mapping (address => uint256) internal _balances;
// Mapping from token ID to approved address.
mapping (uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals.
mapping (address => mapping (address => bool)) private _operatorApprovals;
/**
* @dev Initializes the token collection.
*
* @param name_ Of the collection being deployed.
* @param symbol_ Shorthand token identifier, for wallets, etc.
* @param id_ Number instance deployed by {BuilderShop} contract.
* @param baseURI_ The location where the artifact assets are stored.
* @param typeCount_ The number of different Nifty types (different
* individual NFTs) associated with the deployed collection.
* @param defaultOwner_ Intial receiver of all newly minted NFTs.
* @param niftyRegistryContract Points to the repository of authenticated
* addresses for stateful operations.
*/
constructor(string memory name_,
string memory symbol_,
uint id_,
string memory baseURI_,
uint typeCount_,
address defaultOwner_,
address niftyRegistryContract) NiftyEntity(niftyRegistryContract) {
_name = name_;
_symbol = symbol_;
_id = id_;
_baseURI = baseURI_;
_typeCount = typeCount_;
_defaultOwner = defaultOwner_;
midLevelMultiplier = 10000;
topLevelMultiplier = id_ * 100000000;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC721).interfaceId
|| interfaceId == type(IERC721Metadata).interfaceId
|| super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the link to artificat location for a given token by 'tokenId'.
* Throws if the token ID does not exist. May return an empty string.
* @param tokenId uint256 ID of the token to query.
* @return The location where the artifact assets are stored.
*/
function tokenURI(uint256 tokenId) external view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory tokenIdStr = Strings.toString(tokenId);
return string(abi.encodePacked(_baseURI, tokenIdStr));
}
/**
* @dev Returns an IPFS hash for a given token ID.
* Throws if the token ID does not exist. May return an empty string.
* @param tokenId uint256 ID of the token to query.
* @return IPFS hash for this (_typeCount) NFT.
*/
function tokenIPFSHash(uint256 tokenId) external view returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: IPFS hash query for nonexistent token");
uint niftyType = _getNiftyTypeId(tokenId);
return _niftyTypeIPFSHashes[niftyType];
}
/**
* @dev Determine which NFT in the contract (_typeCount) is associated
* with this 'tokenId'.
*/
function _getNiftyTypeId(uint tokenId) private view returns (uint) {
return (tokenId - topLevelMultiplier) / midLevelMultiplier;
}
/**
* @dev Returns the Name for a given token ID.
* Throws if the token ID does not exist. May return an empty string.
* @param tokenId uint256 ID of the token to query
*/
function tokenName(uint256 tokenId) external view returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: Name query for nonexistent token");
uint niftyType = _getNiftyTypeId(tokenId);
return _niftyTypeName[niftyType];
}
/**
* @dev Internal function to set the token IPFS hash for a nifty type.
* @param niftyType uint256 ID component of the token to set its IPFS hash
* @param ipfs_hash string IPFS link to assign
*/
function _setTokenIPFSHashNiftyType(uint256 niftyType, string memory ipfs_hash) internal {
require(bytes(_niftyTypeIPFSHashes[niftyType]).length == 0, "ERC721Metadata: IPFS hash already set");
_niftyTypeIPFSHashes[niftyType] = ipfs_hash;
}
/**
* @dev Internal function to set the name for a nifty type.
* @param niftyType uint256 of nifty type name to be set
* @param nifty_type_name name of nifty type
*/
function _setNiftyTypeName(uint256 niftyType, string memory nifty_type_name) internal {
_niftyTypeName[niftyType] = nifty_type_name;
}
/**
* @dev Base URI for computing {tokenURI}.
*/
function _setBaseURI(string memory baseURI_) internal {
_baseURI = baseURI_;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
private returns (bool)
{
if (isContract(to)) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
// solhint-disable-next-line no-inline-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
| 27,348 |
363 | // Attempts to withdraw `_amount` from silo0. If `_amount` is more than what's available, withdraw themaximum amount. This reads and writes from/to `maintenanceBudget0`, so use sparingly _amount The desired amount of token0 to withdraw from silo0return uint256 The actual amount of token0 that was withdrawn / | function _silo0Withdraw(uint256 _amount) private returns (uint256) {
unchecked {
uint256 a = silo0Basis;
uint256 b = silo0.balanceOf(address(this));
a = b > a ? (b - a) / MAINTENANCE_FEE : 0; // interest / MAINTENANCE_FEE
if (_amount > b - a) _amount = b - a;
silo0.delegate_withdraw(a + _amount);
maintenanceBudget0 += a;
silo0Basis = b - a - _amount;
return _amount;
}
}
| function _silo0Withdraw(uint256 _amount) private returns (uint256) {
unchecked {
uint256 a = silo0Basis;
uint256 b = silo0.balanceOf(address(this));
a = b > a ? (b - a) / MAINTENANCE_FEE : 0; // interest / MAINTENANCE_FEE
if (_amount > b - a) _amount = b - a;
silo0.delegate_withdraw(a + _amount);
maintenanceBudget0 += a;
silo0Basis = b - a - _amount;
return _amount;
}
}
| 38,678 |
7 | // mythical | uint256 i = uint256(keccak256(abi.encodePacked(tokenId))) % 4;
return string(abi.encodePacked("M00", Strings.toString(i + 1)));
| uint256 i = uint256(keccak256(abi.encodePacked(tokenId))) % 4;
return string(abi.encodePacked("M00", Strings.toString(i + 1)));
| 43,493 |
55 | // Modifier to use in the initializer function of a contract. / | modifier initializer() {
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
bool isTopLevelCall = !initializing;
if (isTopLevelCall) {
initializing = true;
initialized = true;
}
_;
if (isTopLevelCall) {
initializing = false;
}
}
| modifier initializer() {
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
bool isTopLevelCall = !initializing;
if (isTopLevelCall) {
initializing = true;
initialized = true;
}
_;
if (isTopLevelCall) {
initializing = false;
}
}
| 5,618 |
51 | // oracle getter function | function getOracle() external view returns (address);
| function getOracle() external view returns (address);
| 8,004 |
44 | // current tick is inside the passed range | uint128 liquidityBefore = liquidity; // SLOAD for gas optimization
| uint128 liquidityBefore = liquidity; // SLOAD for gas optimization
| 46,425 |
59 | // This method can be used by the controller to extract mistakenly sent tokens to this contract._token The address of the token contract that you want to recover set to 0 in case you want to extract ether. / | function claimTokens(address _token) public onlyController {
if (_token == 0x0) {
controller.transfer(this.balance);
return;
}
ExpositoProject token = ExpositoProject(_token);
uint balance = token.balanceOf(this);
token.transfer(controller, balance);
ClaimedTokens(_token, controller, balance);
}
| function claimTokens(address _token) public onlyController {
if (_token == 0x0) {
controller.transfer(this.balance);
return;
}
ExpositoProject token = ExpositoProject(_token);
uint balance = token.balanceOf(this);
token.transfer(controller, balance);
ClaimedTokens(_token, controller, balance);
}
| 27,302 |
45 | // Ensure that the voucher sig is valid and from the choonAuthority | require(verifyBalanceProof(receiver, balance, sig));
| require(verifyBalanceProof(receiver, balance, sig));
| 44,515 |
59 | // early bird investments | address[] public earlyBirds;
mapping (address => uint256) public earlyBirdInvestments;
| address[] public earlyBirds;
mapping (address => uint256) public earlyBirdInvestments;
| 51,658 |
290 | // Purchaser has been recruited. Grant the recruiter 10%. | uint256 tenPercent = msg.value.div(10);
uint256 ninetyPercent = msg.value.sub(tenPercent);
weiRaised = weiRaised.add(ninetyPercent);
asyncTransfer(wallet, ninetyPercent);
asyncTransfer(_recruiter, tenPercent);
emit Recruited(msg.sender, _beneficiary, _recruiter, msg.value, tenPercent, _tokenAmount);
| uint256 tenPercent = msg.value.div(10);
uint256 ninetyPercent = msg.value.sub(tenPercent);
weiRaised = weiRaised.add(ninetyPercent);
asyncTransfer(wallet, ninetyPercent);
asyncTransfer(_recruiter, tenPercent);
emit Recruited(msg.sender, _beneficiary, _recruiter, msg.value, tenPercent, _tokenAmount);
| 1,662 |
840 | // Calculates the exchange rate from cash to fCash before any liquidity fees are applied | int256 preFeeExchangeRate;
{
bool success;
(preFeeExchangeRate, success) = _getExchangeRate(
market.totalfCash,
totalCashUnderlying,
rateScalar,
rateAnchor,
fCashToAccount
);
| int256 preFeeExchangeRate;
{
bool success;
(preFeeExchangeRate, success) = _getExchangeRate(
market.totalfCash,
totalCashUnderlying,
rateScalar,
rateAnchor,
fCashToAccount
);
| 63,337 |
182 | // KYC would be needed/ | function convertTokenToStocks (uint256 _tokens) public returns (bool ){
address _holder = msg.sender;
transfer(owner, _tokens);
subCorrection(_holder,_tokens);
totalRewardsCorrection = totalRewardsCorrection.sub(withdrawnRewards[_holder].add(paidRewards[_holder]));
return true;
}
| function convertTokenToStocks (uint256 _tokens) public returns (bool ){
address _holder = msg.sender;
transfer(owner, _tokens);
subCorrection(_holder,_tokens);
totalRewardsCorrection = totalRewardsCorrection.sub(withdrawnRewards[_holder].add(paidRewards[_holder]));
return true;
}
| 14,953 |
31 | // timestamp after which Bob cannot claim, only Alice can refund | uint256 timeout1;
| uint256 timeout1;
| 16,521 |
36 | // sets offchain reporting protocol configuration incl. participating oracles _signers addresses with which oracles sign the reports _transmitters addresses oracles use to transmit the reports _threshold number of faulty oracles the system can tolerate _encodedConfigVersion version number for offchainEncoding schema _encoded encoded off-chain oracle configuration / | function setConfig(
address[] calldata _signers,
address[] calldata _transmitters,
uint8 _threshold,
uint64 _encodedConfigVersion,
bytes calldata _encoded
)
external
checkConfigValid(_signers.length, _transmitters.length, _threshold)
onlyOwner()
| function setConfig(
address[] calldata _signers,
address[] calldata _transmitters,
uint8 _threshold,
uint64 _encodedConfigVersion,
bytes calldata _encoded
)
external
checkConfigValid(_signers.length, _transmitters.length, _threshold)
onlyOwner()
| 25,907 |
0 | // Helper function to extract a useful revert message from a failed call./ If the returned data is malformed or not correctly abi encoded then this call can fail itself. | function _getRevertMsg(bytes memory _returnData)
internal
pure
returns (string memory)
| function _getRevertMsg(bytes memory _returnData)
internal
pure
returns (string memory)
| 24,426 |
1 | // Provenance Hash (Sha256) of Actual BaseRUI's CID:7ab17347adf3b34eac9f08c98fb1e045e13a7bed4013e212624e3eaa2d06ff02 | actualBaseURIHasBeenSet = true;
| actualBaseURIHasBeenSet = true;
| 62,243 |
1 | // 给定address对iLog实例化 | initiateSuperAdmin();
| initiateSuperAdmin();
| 50,449 |
524 | // can only claim stake back after WITHDRAWAL_DELAY | require(
deactivationEpoch > 0 &&
deactivationEpoch.add(WITHDRAWAL_DELAY) <= currentEpoch &&
validators[validatorId].status != Status.Unstaked
);
uint256 amount = validators[validatorId].amount;
uint256 newTotalStaked = totalStaked.sub(amount);
totalStaked = newTotalStaked;
| require(
deactivationEpoch > 0 &&
deactivationEpoch.add(WITHDRAWAL_DELAY) <= currentEpoch &&
validators[validatorId].status != Status.Unstaked
);
uint256 amount = validators[validatorId].amount;
uint256 newTotalStaked = totalStaked.sub(amount);
totalStaked = newTotalStaked;
| 43,163 |
19 | // convering back the amountToUser and amountToBank | return (amountToUser.div(10**uint256(18)), amountToBank.div(10**uint256(18)));
| return (amountToUser.div(10**uint256(18)), amountToBank.div(10**uint256(18)));
| 46,776 |
14 | // Sets `adminRole` as ``role``'s admin role. | * If ``role``'s admin role is not `adminRole` emits a {RoleAdminChanged} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function setRoleAdmin(bytes4 role, bytes4 adminRole) external virtual admin(role) {
_setRoleAdmin(role, adminRole);
}
| * If ``role``'s admin role is not `adminRole` emits a {RoleAdminChanged} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function setRoleAdmin(bytes4 role, bytes4 adminRole) external virtual admin(role) {
_setRoleAdmin(role, adminRole);
}
| 49,949 |
150 | // Consume one quota for transaction sending | assert(quota > 0);
quota -= 1;
_;
| assert(quota > 0);
quota -= 1;
_;
| 54,326 |
5 | // Remove address based on index _index number (obtained by removeAddressByAddress()) / | function removeAddressByIndex(uint256 _index) public onlyOwner {
address _approvedEntries = approvedEntries[_index];
inRegistry[_approvedEntries] = false;
// Move last to index location
approvedEntries[_index] = approvedEntries[approvedEntries.length - 1];
// Pop last one off
approvedEntries.pop();
}
| function removeAddressByIndex(uint256 _index) public onlyOwner {
address _approvedEntries = approvedEntries[_index];
inRegistry[_approvedEntries] = false;
// Move last to index location
approvedEntries[_index] = approvedEntries[approvedEntries.length - 1];
// Pop last one off
approvedEntries.pop();
}
| 29,966 |
121 | // Approve spender to transfer tokens and then execute a callback on recipient. spender The address allowed to transfer to. amount The amount allowed to be transferred. data Additional data with no specified format.return A boolean that indicates if the operation was successful. / | function approveAndCall(
address spender,
uint256 amount,
bytes memory data
| function approveAndCall(
address spender,
uint256 amount,
bytes memory data
| 18,070 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.