Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. By default, the owner account will be the one that deploys the contract. This can later be changed with {transferOwnership}. This module is used through inheritance. It will make available the modifier `onlyOwner`, which can be applied to your functions to restrict their use to the owner.
address _ownerevent OwnershipTransferred(address previousOwner, address newOwner)constructor() internalInitializes the contract setting the deployer as the initial owner.
function owner() public view virtual returns (address)Returns the address of the current owner.
modifier onlyOwner()Throws if called by any account other than the owner.
function renounceOwnership() public virtualLeaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
function transferOwnership(address newOwner) public virtualTransfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.
function _setOwner(address newOwner) private_Implementation of the {IERC20} interface. This implementation is agnostic to the way tokens are created. This means that a supply mechanism has to be added in a derived contract using {mint}. For a generic mechanism see {ERC20PresetMinterPauser}. TIP: For a detailed writeup see our guide https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How to implement supply mechanisms]. We have followed general OpenZeppelin Contracts guidelines: functions revert instead returning `false` on failure. This behavior is nonetheless conventional and does not conflict with the expectations of ERC20 applications. Additionally, an {Approval} event is emitted on calls to {transferFrom}. This allows applications to reconstruct the allowance for all accounts just by listening to said events. Other implementations of the EIP may not emit these events, as it isn't required by the specification. Finally, the non-standard {decreaseAllowance} and {increaseAllowance} functions have been added to mitigate the well-known issues around setting allowances. See {IERC20-approve}.
mapping(address => uint256) _balancesmapping(address => mapping(address => uint256)) _allowancesuint256 _totalSupplystring _namestring _symbolconstructor(string name_, string symbol_) publicSets the values for {name} and {symbol}. The default value of {decimals} is 18. To select a different value for {decimals} you should overload it. All two of these values are immutable: they can only be set once during construction.
function name() public view virtual returns (string)Returns the name of the token.
function symbol() public view virtual returns (string)Returns the symbol of the token, usually a shorter version of the name.
function decimals() public view virtual returns (uint8)Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for display purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.
function totalSupply() public view virtual returns (uint256)See {IERC20-totalSupply}.
function balanceOf(address account) public view virtual returns (uint256)See {IERC20-balanceOf}.
function transfer(address recipient, uint256 amount) public virtual returns (bool)_See {IERC20-transfer}. Requirements:
- `recipient` cannot be the zero address.
- the caller must have a balance of at least `amount`._
function allowance(address owner, address spender) public view virtual returns (uint256)See {IERC20-allowance}.
function approve(address spender, uint256 amount) public virtual returns (bool)_See {IERC20-approve}. Requirements:
- `spender` cannot be the zero address._
function transferFrom(address sender, address recipient, uint256 amount) public virtual returns (bool)_See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements:
- `sender` and `recipient` cannot be the zero address.
- `sender` must have a balance of at least `amount`.
- the caller must have allowance for ``sender``'s tokens of at least `amount`._
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool)_Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:
- `spender` cannot be the zero address._
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool)_Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:
- `spender` cannot be the zero address.
- `spender` must have allowance for the caller of at least `subtractedValue`._
function _transfer(address sender, address recipient, uint256 amount) internal virtual_Moves `amount` of tokens from `sender` to `recipient`. This internal function is equivalent to {transfer}, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements:
- `sender` cannot be the zero address.
- `recipient` cannot be the zero address.
- `sender` must have a balance of at least `amount`._
function _mint(address account, uint256 amount) internal virtual_Creates `amount` tokens and assigns them to `account`, increasing the total supply. Emits a {Transfer} event with `from` set to the zero address. Requirements:
- `account` cannot be the zero address._
function _burn(address account, uint256 amount) internal virtual_Destroys `amount` tokens from `account`, reducing the total supply. Emits a {Transfer} event with `to` set to the zero address. Requirements:
- `account` cannot be the zero address.
- `account` must have at least `amount` tokens._
function _approve(address owner, address spender, uint256 amount) internal virtual_Sets `amount` as the allowance of `spender` over the `owner` s tokens. This internal function is equivalent to `approve`, and can be used to e.g. set automatic allowances for certain subsystems, etc. Emits an {Approval} event. Requirements:
- `owner` cannot be the zero address.
- `spender` cannot be the zero address._
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual_Hook that is called before any transfer of tokens. This includes minting and burning. Calling conditions:
- when `from` and `to` are both non-zero, `amount` of ``from``'s tokens will be transferred to `to`.
- when `from` is zero, `amount` tokens will be minted for `to`.
- when `to` is zero, `amount` of ``from``'s tokens will be burned.
- `from` and `to` are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]._
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual_Hook that is called after any transfer of tokens. This includes minting and burning. Calling conditions:
- when `from` and `to` are both non-zero, `amount` of ``from``'s tokens has been transferred to `to`.
- when `from` is zero, `amount` tokens have been minted for `to`.
- when `to` is zero, `amount` of ``from``'s tokens have been burned.
- `from` and `to` are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]._
Interface of the ERC20 standard as defined in the EIP.
function totalSupply() external view returns (uint256)Returns the amount of tokens in existence.
function balanceOf(address account) external view returns (uint256)Returns the amount of tokens owned by `account`.
function transfer(address recipient, uint256 amount) external returns (bool)Moves `amount` tokens from the caller's account to `recipient`. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.
function allowance(address owner, address spender) external view returns (uint256)Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. This value changes when {approve} or {transferFrom} are called.
function approve(address spender, uint256 amount) external returns (bool)Sets `amount` as the allowance of `spender` over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: ethereum/EIPs#20 (comment) Emits an {Approval} event.
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool)Moves `amount` tokens from `sender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.
event Transfer(address from, address to, uint256 value)Emitted when `value` tokens are moved from one account (`from`) to another (`to`). Note that `value` may be zero.
event Approval(address owner, address spender, uint256 value)Emitted when the allowance of a `spender` for an `owner` is set by a call to {approve}. `value` is the new allowance.
Interface for the optional metadata functions from the ERC20 standard. Available since v4.1.
function name() external view returns (string)Returns the name of the token.
function symbol() external view returns (string)Returns the symbol of the token.
function decimals() external view returns (uint8)Returns the decimals places of the token.
Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including the Metadata extension, but not including the Enumerable extension, which is available separately as {ERC721Enumerable}.
string _namestring _symbolmapping(uint256 => address) _ownersmapping(address => uint256) _balancesmapping(uint256 => address) _tokenApprovalsmapping(address => mapping(address => bool)) _operatorApprovalsconstructor(string name_, string symbol_) publicInitializes the contract by setting a `name` and a `symbol` to the token collection.
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)See {IERC165-supportsInterface}.
function balanceOf(address owner) public view virtual returns (uint256)See {IERC721-balanceOf}.
function ownerOf(uint256 tokenId) public view virtual returns (address)See {IERC721-ownerOf}.
function name() public view virtual returns (string)See {IERC721Metadata-name}.
function symbol() public view virtual returns (string)See {IERC721Metadata-symbol}.
function tokenURI(uint256 tokenId) public view virtual returns (string)See {IERC721Metadata-tokenURI}.
function _baseURI() internal view virtual returns (string)Base URI for computing {tokenURI}. If set, the resulting URI for each token will be the concatenation of the `baseURI` and the `tokenId`. Empty by default, can be overriden in child contracts.
function approve(address to, uint256 tokenId) public virtualSee {IERC721-approve}.
function getApproved(uint256 tokenId) public view virtual returns (address)See {IERC721-getApproved}.
function setApprovalForAll(address operator, bool approved) public virtualSee {IERC721-setApprovalForAll}.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool)See {IERC721-isApprovedForAll}.
function transferFrom(address from, address to, uint256 tokenId) public virtualSee {IERC721-transferFrom}.
function safeTransferFrom(address from, address to, uint256 tokenId) public virtualSee {IERC721-safeTransferFrom}.
function safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) public virtualSee {IERC721-safeTransferFrom}.
function _safeTransfer(address from, address to, uint256 tokenId, bytes _data) internal virtual_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 _exists(uint256 tokenId) internal view virtual returns (bool)_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 _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool)_Returns whether `spender` is allowed to manage `tokenId`. Requirements:
- `tokenId` must exist._
function _safeMint(address to, uint256 tokenId) internal virtual_Safely mints `tokenId` and transfers it to `to`. Requirements:
- `tokenId` must not exist.
- If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event._
function _safeMint(address to, uint256 tokenId, bytes _data) internal virtual_Same as {xref-ERC721-_safeMint-address-uint256-}[`safeMint`], with an additional `data` parameter which is forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
function _mint(address to, uint256 tokenId) internal virtual_Mints `tokenId` and transfers it to `to`. WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible Requirements:
- `tokenId` must not exist.
- `to` cannot be the zero address. Emits a {Transfer} event._
function _burn(uint256 tokenId) internal virtual_Destroys `tokenId`. The approval is cleared when the token is burned. Requirements:
- `tokenId` must exist. Emits a {Transfer} event._
function _transfer(address from, address to, uint256 tokenId) internal virtual_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 _approve(address to, uint256 tokenId) internal virtualApprove `to` to operate on `tokenId` Emits a {Approval} event.
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes _data) private returns (bool)Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. The call is not executed if the target address is not a contract.
| Name | Type | Description |
|---|---|---|
| from | address | address representing the previous owner of the given token ID |
| to | address | target address that will receive the tokens |
| tokenId | uint256 | uint256 ID of the token to be transferred |
| _data | bytes | bytes optional data to send along with the call |
| Name | Type | Description |
|---|---|---|
| [0] | bool | bool whether the call correctly returned the expected magic value |
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual_Hook that is called before any token transfer. This includes minting and burning. Calling conditions:
- When `from` and `to` are both non-zero, ``from``'s `tokenId` will be transferred to `to`.
- When `from` is zero, `tokenId` will be minted for `to`.
- When `to` is zero, ``from``'s `tokenId` will be burned.
- `from` and `to` are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]._
Required interface of an ERC721 compliant contract.
event Transfer(address from, address to, uint256 tokenId)Emitted when `tokenId` token is transferred from `from` to `to`.
event Approval(address owner, address approved, uint256 tokenId)Emitted when `owner` enables `approved` to manage the `tokenId` token.
event ApprovalForAll(address owner, address operator, bool approved)Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
function balanceOf(address owner) external view returns (uint256 balance)Returns the number of tokens in ``owner``'s account.
function ownerOf(uint256 tokenId) external view returns (address owner)_Returns the owner of the `tokenId` token. Requirements:
- `tokenId` must exist._
function safeTransferFrom(address from, address to, uint256 tokenId) external_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 transferFrom(address from, address to, uint256 tokenId) external_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 approve(address to, uint256 tokenId) external_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 getApproved(uint256 tokenId) external view returns (address operator)_Returns the account approved for `tokenId` token. Requirements:
- `tokenId` must exist._
function setApprovalForAll(address operator, bool _approved) external_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 isApprovedForAll(address owner, address operator) external view returns (bool)Returns if the `operator` is allowed to manage all of the assets of `owner`. See {setApprovalForAll}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) external_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._
Interface for any contract that wants to support safeTransfers from ERC721 asset contracts.
function onERC721Received(address operator, address from, uint256 tokenId, bytes data) external returns (bytes4)Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} by `operator` from `from`, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
This implements an optional extension of {ERC721} defined in the EIP that adds enumerability of all the token ids in the contract as well as all token ids owned by each account.
mapping(address => mapping(uint256 => uint256)) _ownedTokensmapping(uint256 => uint256) _ownedTokensIndexuint256[] _allTokensmapping(uint256 => uint256) _allTokensIndexfunction supportsInterface(bytes4 interfaceId) public view virtual returns (bool)See {IERC165-supportsInterface}.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256)See {IERC721Enumerable-tokenOfOwnerByIndex}.
function totalSupply() public view virtual returns (uint256)See {IERC721Enumerable-totalSupply}.
function tokenByIndex(uint256 index) public view virtual returns (uint256)See {IERC721Enumerable-tokenByIndex}.
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual_Hook that is called before any token transfer. This includes minting and burning. Calling conditions:
- When `from` and `to` are both non-zero, ``from``'s `tokenId` will be transferred to `to`.
- When `from` is zero, `tokenId` will be minted for `to`.
- When `to` is zero, ``from``'s `tokenId` will be burned.
- `from` cannot be the zero address.
- `to` cannot be the zero address. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]._
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) privatePrivate function to add a token to this extension's ownership-tracking data structures.
| Name | Type | Description |
|---|---|---|
| to | address | address representing the new owner of the given token ID |
| tokenId | uint256 | uint256 ID of the token to be added to the tokens list of the given address |
function _addTokenToAllTokensEnumeration(uint256 tokenId) privatePrivate function to add a token to this extension's token tracking data structures.
| Name | Type | Description |
|---|---|---|
| tokenId | uint256 | uint256 ID of the token to be added to the tokens list |
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private_Private function to remove a token from this extension's ownership-tracking data structures. Note that while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is not updated: this allows for gas optimizations e.g. when performing a transfer operation (avoiding double writes). This has O(1) time complexity, but alters the order of the ownedTokens array.
| Name | Type | Description |
|---|---|---|
| from | address | address representing the previous owner of the given token ID |
| tokenId | uint256 | uint256 ID of the token to be removed from the tokens list of the given address |
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private_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.
| Name | Type | Description |
|---|---|---|
| tokenId | uint256 | uint256 ID of the token to be removed from the tokens list |
See https://eips.ethereum.org/EIPS/eip-721
function totalSupply() external view returns (uint256)Returns the total amount of tokens stored by the contract.
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId)Returns a token ID owned by `owner` at a given `index` of its token list. Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
function tokenByIndex(uint256 index) external view returns (uint256)Returns a token ID at a given `index` of all the tokens stored by the contract. Use along with {totalSupply} to enumerate all tokens.
See https://eips.ethereum.org/EIPS/eip-721
function name() external view returns (string)Returns the token collection name.
function symbol() external view returns (string)Returns the token collection symbol.
function tokenURI(uint256 tokenId) external view returns (string)Returns the Uniform Resource Identifier (URI) for `tokenId` token.
Collection of functions related to the address type
function isContract(address account) internal view returns (bool)_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 sendValue(address payable recipient, uint256 amount) internalReplacement for Solidity's `transfer`: sends `amount` wei to `recipient`, forwarding all available gas and reverting on errors. https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by `transfer`, making them unable to receive funds via `transfer`. {sendValue} removes this limitation. https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. IMPORTANT: because control is transferred to `recipient`, care must be taken to not create reentrancy vulnerabilities. Consider using {ReentrancyGuard} or the https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
function functionCall(address target, bytes data) internal returns (bytes)_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, use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. Requirements:
- `target` must be a contract.
- calling `target` with `data` must not revert. Available since v3.1._
function functionCall(address target, bytes data, string errorMessage) internal returns (bytes)Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with `errorMessage` as a fallback revert reason when `target` reverts. Available since v3.1.
function functionCallWithValue(address target, bytes data, uint256 value) internal returns (bytes)_Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but also transferring `value` wei to `target`. Requirements:
- the calling contract must have an ETH balance of at least `value`.
- the called Solidity function must be `payable`. Available since v3.1._
function functionCallWithValue(address target, bytes data, uint256 value, string errorMessage) internal returns (bytes)Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but with `errorMessage` as a fallback revert reason when `target` reverts. Available since v3.1.
function functionStaticCall(address target, bytes data) internal view returns (bytes)Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but performing a static call. Available since v3.3.
function functionStaticCall(address target, bytes data, string errorMessage) internal view returns (bytes)Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a static call. Available since v3.3.
function functionDelegateCall(address target, bytes data) internal returns (bytes)Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but performing a delegate call. Available since v3.4.
function functionDelegateCall(address target, bytes data, string errorMessage) internal returns (bytes)Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], but performing a delegate call. Available since v3.4.
function verifyCallResult(bool success, bytes returndata, string errorMessage) internal pure returns (bytes)Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the revert reason using the provided one. Available since v4.3.
Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.
function _msgSender() internal view virtual returns (address)function _msgData() internal view virtual returns (bytes)String operations.
bytes16 _HEX_SYMBOLSfunction toString(uint256 value) internal pure returns (string)Converts a `uint256` to its ASCII `string` decimal representation.
function toHexString(uint256 value) internal pure returns (string)Converts a `uint256` to its ASCII `string` hexadecimal representation.
function toHexString(uint256 value, uint256 length) internal pure returns (string)Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
Implementation of the {IERC165} interface. Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example: ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ``` Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)See {IERC165-supportsInterface}.
Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.
function supportsInterface(bytes4 interfaceId) external view returns (bool)Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
Wrappers over Solidity's arithmetic operations. NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler now has built in overflow checking.
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256)Returns the addition of two unsigned integers, with an overflow flag. Available since v3.4.
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256)Returns the substraction of two unsigned integers, with an overflow flag. Available since v3.4.
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256)Returns the multiplication of two unsigned integers, with an overflow flag. Available since v3.4.
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256)Returns the division of two unsigned integers, with a division by zero flag. Available since v3.4.
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256)Returns the remainder of dividing two unsigned integers, with a division by zero flag. Available since v3.4.
function add(uint256 a, uint256 b) internal pure returns (uint256)_Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's `+` operator. Requirements:
- Addition cannot overflow._
function sub(uint256 a, uint256 b) internal pure returns (uint256)_Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's `-` operator. Requirements:
- Subtraction cannot overflow._
function mul(uint256 a, uint256 b) internal pure returns (uint256)_Returns the multiplication of two unsigned integers, reverting on overflow. Counterpart to Solidity's `*` operator. Requirements:
- Multiplication cannot overflow._
function div(uint256 a, uint256 b) internal pure returns (uint256)_Returns the integer division of two unsigned integers, reverting on division by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Requirements:
- The divisor cannot be zero._
function mod(uint256 a, uint256 b) internal pure returns (uint256)_Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), reverting when dividing by zero. Counterpart to Solidity's `%` operator. This function uses a `revert` opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:
- The divisor cannot be zero._
function sub(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)_Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). CAUTION: This function is deprecated because it requires allocating memory for the error message unnecessarily. For custom revert reasons use {trySub}. Counterpart to Solidity's `-` operator. Requirements:
- Subtraction cannot overflow._
function div(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)_Returns the integer division of two unsigned integers, reverting with custom message on division by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Note: this function uses a `revert` opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:
- The divisor cannot be zero._
function mod(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)_Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), reverting with custom message when dividing by zero. CAUTION: This function is deprecated because it requires allocating memory for the error message unnecessarily. For custom revert reasons use {tryMod}. Counterpart to Solidity's `%` operator. This function uses a `revert` opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:
- The divisor cannot be zero._
constructor(address tbAddress) publicuint256 _totalSupplyuint256 _totalTrafficaddress _TBAddressuint256 referalFeeuint256 feePointuint256 publishFeemapping(uint256 => struct IDAppMarket.DAppStruct) DAppDatafunction collectTraffic(uint256 length, uint256[] _tokenId, uint256[] _traffic) publicCollect Traffic to NFT's and transfer referalFee to this contract
| Name | Type | Description |
|---|---|---|
| length | uint256 | uint - size of arrays |
| _tokenId | uint256[] | - array of token ids [1,2,3] |
| _traffic | uint256[] | - array of amount of bytes [1024^3, 5x1024^3, 10x1024^3] |
function getMetaData(uint256 _tokenId) public view returns (struct IDAppMarket.DAppStruct)return full metadata, for external apps can be expensive to check, but retuns full info
function getNFTBalance(uint256 _itemId) public view returns (uint256)(NFT.traffic - NFT.payedTraffic) x this.tbBalance / totalTraffic
| Name | Type | Description |
|---|---|---|
| _itemId | uint256 | - NFT token id |
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | TB balance of this token |
function tokenURI(uint256 tokenId) public view returns (string)Returns the Uniform Resource Identifier (URI) for `tokenId` token.
function tokenContentHash(uint256 tokenId) public view returns (bytes32)Return the content hash of resourse for `tokenId`.
function totalSupply() public view returns (uint256)totalSupply - amount of minted dapps tokens
function claimReward(uint256 _itemId) public_Owner of item can get collected reward Check owner of itemId, no need to check exist, because in exist check owner != 0
function claimRewardMany(uint256[] _itemIds) publicClaim many
| Name | Type | Description |
|---|---|---|
| _itemIds | uint256[] | - array of NFTids owned by user |
mapping(bytes32 => uint256) wrappedPointerkeccak(origin.address + origin.id) => WNFT id
function CreateDApp(string dAppURI, bytes32 _contentHash) publicCreating DApp as NFT
function updateVersion(uint256 tokenId, string dAppURI, bytes32 contentHash) publicowner can deploy updates, if content hash modified
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes _data) public view returns (bytes4)SafeTransferFrom require this function
constructor(address tbAddress) publicstruct DeNetDNS {
string URI;
string DomainZone;
bytes32 URIHash;
uint256 nextPaymentBefore;
uint256 DAppID;
bytes32 DAppContentHash;
}constructor(string _name, string _symbol) publicuint256 _counterfunction mintMe() publicfunction counter() public view returns (uint256)_Contract PoSAdmin - modifier for ProofOfStorage API's
- onlyOldAddress
- onlyGovernance
- whenNotPaused
- whenPaused
- onlyGateway_
address proofOfStorageAddressaddress governanceAddressaddress _rewardTokenAddressbool pausedmapping(address => bool) _isGatewayconstructor(address _pos, address _reward) publicmodifier onlyGovernance()modifier whenNotPaused()modifier whenPaused()function pause() externalfunction unpause() externalfunction changeGovernance(address _new) externalmodifier onlyPoS()modifier onlyGateway()function changePoS(address _newAddress) publicfunction addGateway(address account) publicfunction delGateway(address account) publicfunction updateRewardTokenAddress(address _new) publicPossibility update token address for next updates, will removed at finalized version
_Contract WNFT - Wrapped NFT made for NFT Staking program in DeNet
- Minimal reward ~1MB
- Amount of reward 5% (constant) of traffic, will upgraded in future with governance_
constructor(address tbAddress) publicAddress of TB Token
uint256 _totalSupplyuint256 _totalTrafficuint256 referalFeeuint256 feePointmapping(uint256 => struct IWrapper.WrappedStruct) _wrappedDatafunction collectTraffic(uint256 length, uint256[] _tokenId, uint256[] _traffic) publicCollect Traffic to NFT's and transfer referalFee to this contract
| Name | Type | Description |
|---|---|---|
| length | uint256 | uint - size of arrays |
| _tokenId | uint256[] | - array of token ids [1,2,3] |
| _traffic | uint256[] | - array of amount of bytes [1024^3, 5x1024^3, 10x1024^3] |
function getMetaData(uint256 _tokenId) public view returns (struct IWrapper.WrappedStruct)return full metadata, for external apps can be expensive to check, but retuns full info
function getNFTBalance(uint256 _itemId) public view returns (uint256)(NFT.traffic - NFT.payedTraffic) x this.tbBalance / totalTraffic
| Name | Type | Description |
|---|---|---|
| _itemId | uint256 | - NFT token id |
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | TB balance of this token |
function tokenURI(uint256 tokenId) public view returns (string)Returns the Uniform Resource Identifier (URI) for `tokenId` token.
function tokenContentHash(uint256 tokenId) public view returns (bytes32)Return the content hash of resourse for `tokenId`.
function totalSupply() public view returns (uint256)_totalSupply - total amount of supplied WNFT's
function claimReward(uint256 _itemId) publicApproved operator can claim reward on own address
_Owner of item can get collected reward Check owner of itemId, no need to check exist, because in exist check owner != 0
function claimRewardMany(uint256[] _itemIds) publicClaim many
| Name | Type | Description |
|---|---|---|
| _itemIds | uint256[] | array of NFTids owned by user |
function wrap(address originAddress, uint256 tokenId, bytes32 originContentHash, string storageURI, uint256 contentSize) public_Make NFT as WrappedNFT
- Create pointer: keccak(address, token_id)
- TransferFrom origin to this
- Fill Metadata_
function unwrap(uint256 tokenId) public_unwrap and burn
- Sender == Owner or Approved
- Transfer to Sender
- Burn wrapped_
struct DAppStruct {
string URI;
uint256 traffic;
uint256 payedTraffic;
bytes32 contentHash;
bool burned;
bytes32[] versionHashes;
uint256 currentVersion;
}function claimReward(uint256 _itemId) external_Owner of item can get collected reward Check owner of itemId, no need to check exist, because in exist check owner != 0
function claimRewardMany(uint256[] _itemIds) externalClaim many
| Name | Type | Description |
|---|---|---|
| _itemIds | uint256[] | - array of NFTids owned by user |
function tokenContentHash(uint256 _itemId) external view returns (bytes32)return Content Hash of NFT
function getNFTBalance(uint256 _itemId) external view returns (uint256)returns NFT Balanc of earned tokens
function getMetaData(uint256 _tokenId) external view returns (struct IDAppMarket.DAppStruct)return full metadata, for external apps can be expensive to check, but retuns full info
function updateVersion(uint256 tokenId, string dAppURI, bytes32 contentHash) externalfunction CreateDApp(string dAppURI, bytes32 _contentHash) externalevent ChangePoSAddress(address newPoSAddress)struct WrappedStruct {
string URI;
uint256 contentSize;
uint256 traffic;
uint256 payedTraffic;
bytes32 contentHash;
address oldAddress;
uint256 tokenId;
bool burned;
}function claimReward(uint256 _itemId) external_Owner of item can get collected reward Check owner of itemId, no need to check exist, because in exist check owner != 0
function claimRewardMany(uint256[] _itemIds) externalClaim many
| Name | Type | Description |
|---|---|---|
| _itemIds | uint256[] | - array of NFTids owned by user |
function wrap(address _contract, uint256 tokenId, bytes32 _contentHash, string _DeNetStorageURI, uint256 contentSize) external_Make NFT as WrappedNFT
- Check is approved
- Check is sender == owner
- Create pointer: keccak(address, token_id)
- Create wrapped NFT_
function unwrap(uint256 tokenId) external_unwrap and burn
- Sender == Owner
- Transfer to Sender
- Burn wrapped_
function tokenContentHash(uint256 _itemId) external view returns (bytes32)return Content Hash of NFT
function getNFTBalance(uint256 _itemId) external view returns (uint256)returns NFT Balanc of earned tokens
function getMetaData(uint256 _tokenId) external view returns (struct IWrapper.WrappedStruct)return full metadata, for external apps can be expensive to check, but retuns full info
constructor(string name, string symbol) publicfunction mint(address account, uint256 amount) externalfunction burn(address account, uint256 amount) external