NFT

Git Source

Inherits: INFT

Author: mortimr @ Kiln

NFT contract using utils.sol storage format.

State Variables

$name

ERC721 name of the contract.

Slot: keccak256(bytes("nft.1.name")) - 1

types.String internal constant $name =
    types.String.wrap(0x8be0d77374e3002afd46fd09ae2c8e3afc7315322504f7f1a09d189f4925e72f);

$symbol

ERC721 symbol of the contract.

Slot: keccak256(bytes("nft.1.symbol")) - 1

types.String internal constant $symbol =
    types.String.wrap(0xddad2df2277e0186b34991db0b7ceafa36b49b76d0a1e87f6e4d44b6b17a207f);

$mintCounter

Internal ID counter to keep track of minted tokens.

Slot: keccak256(bytes("nft.1.mintCounter")) - 1

types.Uint256 internal constant $mintCounter =
    types.Uint256.wrap(0x3d706fc25ad0e96a2c3fb1b58cdd70ba377f331d59f761caecaf2f3a236d99a1);

$burnCounter

Internal burn counter used to keep track of the total supply.

Slot: keccak256(bytes("nft.1.burnCounter")) - 1

types.Uint256 internal constant $burnCounter =
    types.Uint256.wrap(0x0644144c18bf2aa8e15d5433cc3f6e2273ab9ccd122cd4f430275a2997cc0dc2);

$owners

Internal mapping that holds the links between owners and NFT IDs.

Type: mapping (uint256 => address)

Slot: keccak256(bytes("nft.1.owners")) - 1

types.Mapping internal constant $owners =
    types.Mapping.wrap(0xc1f66d46ebf7070ef20209d66f741219b00fb896714319503d158a28b0d103d3);

$balances

Internal mapping that holds the balances of every owner (how many NFTs they own).

Type: mapping (address => uint256)

Slot: keccak256(bytes("nft.1.balances")) - 1

types.Mapping internal constant $balances =
    types.Mapping.wrap(0xf9245bc1df90ea86e77b9f2423fe9cc12aa083c8ab9a55e727b285192b30d98a);

$tokenApprovals

Internal mapping that holds the token approval data.

Type: mapping (uint256 => address)

Slot: keccak256(bytes("nft.1.tokenApprovals")) - 1

types.Mapping internal constant $tokenApprovals =
    types.Mapping.wrap(0x3790264503275ecd52e8f0b419eb5ce016ca8a1f0fbac5a9ede429d0c1732004);

$operatorApprovals

Internal mapping of operator approvals.

Type: mapping (address => mapping (address => bool))

Slot: keccak256(bytes("nft.1.operatorApprovals")) - 1

uctypes.OperatorApprovalsMapping internal constant $operatorApprovals =
    uctypes.OperatorApprovalsMapping.wrap(0x6c716a91f6b5f5a0aa2affaf44bd88ea94ec69e363cf1fe9251e00a0fcc6c34e);

Functions

initializeNFT

Internal initializer to call when first deploying the contract.

function initializeNFT(string memory name_, string memory symbol_) internal;

tokenURI

Returns the token uri for the given token id.

To override

function tokenURI(uint256 tokenId) external view virtual returns (string memory);

Parameters

NameTypeDescription
tokenIduint256The token id to query

_onTransfer

Internal hook happening at each transfer. Not called during mint or burn. Use _onMint and _onBurn instead. The hook is called before state transitions are made.

To override

function _onTransfer(address from, address to, uint256 tokenId) internal virtual;

Parameters

NameTypeDescription
fromaddressThe address sending the token
toaddressThe address receiving the token
tokenIduint256The token id

_onMint

Internal hook happening at each mint. The hook is called before state transitions are made.

To override

function _onMint(address to, uint256 tokenId) internal virtual;

Parameters

NameTypeDescription
toaddressThe address receiving the token
tokenIduint256The token id

_onBurn

Internal hook happening at each burn. The hook is called before state transitions are made.

To override

function _onBurn(uint256 tokenId) internal virtual;

Parameters

NameTypeDescription
tokenIduint256The token id

totalSupply

Retrieve the total count of validator created with this contract.

function totalSupply() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total count of NFT validators of this contract

balanceOf

function balanceOf(address owner) public view virtual override returns (uint256);

ownerOf

function ownerOf(uint256 tokenId) public view virtual override returns (address);

name

function name() external view virtual returns (string memory);

symbol

function symbol() external view virtual returns (string memory);

supportsInterface

function supportsInterface(bytes4 interfaceId) external pure returns (bool);

approve

function approve(address to, uint256 tokenId) public virtual override;

getApproved

function getApproved(uint256 tokenId) public view virtual override returns (address);

setApprovalForAll

function setApprovalForAll(address operator, bool approved) public virtual override;

isApprovedForAll

function isApprovedForAll(address owner, address operator) public view virtual override returns (bool);

transferFrom

function transferFrom(address from, address to, uint256 tokenId) public virtual override;

safeTransferFrom

function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override;

safeTransferFrom

function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override;

_setName

Internal utility to set the ERC721 name value.

function _setName(string memory newName) internal;

Parameters

NameTypeDescription
newNamestringThe new name to set

_setSymbol

Internal utility to set the ERC721 symbol value.

function _setSymbol(string memory newSymbol) internal;

Parameters

NameTypeDescription
newSymbolstringThe new symbol to set

_safeTransfer

Internal utility to perform a safe transfer (transfer + extra checks on contracts).

function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual;

Parameters

NameTypeDescription
fromaddressThe address sending the token
toaddressThe address receiving the token
tokenIduint256The ID of the token
databytesThe extra data provided to contract callback calls

_ownerOf

Internal utility to retrieve the owner of the specified token id.

function _ownerOf(uint256 tokenId) internal view virtual returns (address);

Parameters

NameTypeDescription
tokenIduint256The token id to lookup

Returns

NameTypeDescription
<none>addressThe address of the token owner

_exists

Internal utility to verify if a token id exists.

function _exists(uint256 tokenId) internal view virtual returns (bool);

Parameters

NameTypeDescription
tokenIduint256The token id to verify

Returns

NameTypeDescription
<none>boolTrue if exists

_isApprovedOrOwner

Internal utility to check if the specified address is either approved by the owner or the owner for the given token id.

function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool);

Parameters

NameTypeDescription
spenderaddressThe address to verify
tokenIduint256The token id to verify

Returns

NameTypeDescription
<none>boolTrue if approved or owner

_safeMint

Internal utility to perform a safe mint operation (mint + extra checks on contracts).

function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual;

Parameters

NameTypeDescription
toaddressThe address receiving the token
tokenIduint256The token id to create
databytesThe xtra data provided to contract callback calls

_mint

Internal utility to mint the desired token id.

function _mint(address to, uint256 tokenId) internal virtual;

Parameters

NameTypeDescription
toaddressThe address that receives the token id
tokenIduint256The token id to create

_burn

Internal utility to burn the desired token id.

function _burn(uint256 tokenId) internal virtual;

Parameters

NameTypeDescription
tokenIduint256The token id to burn

_transfer

Internal utility to perform a regular transfer of a token.

function _transfer(address from, address to, uint256 tokenId) internal virtual;

Parameters

NameTypeDescription
fromaddressThe address sending the token
toaddressThe address receiving the token
tokenIduint256The tokenId to transfer

_approve

Internal utility to approve an account for a token id.

function _approve(address to, address owner, uint256 tokenId) internal virtual;

Parameters

NameTypeDescription
toaddressThe address receiving the approval
owneraddressThe owner of the token id
tokenIduint256The token id

_setApprovalForAll

Internal utility to approve an account for all tokens of another account.

function _setApprovalForAll(address owner, address operator, bool approved) internal virtual;

Parameters

NameTypeDescription
owneraddressThe address owning the tokens
operatoraddressThe address receiving the approval
approvedboolTrue if approved, false otherwise

_requireExists

Internal utility to check and revert if a token doesn't exists.

function _requireExists(uint256 tokenId) internal view virtual;

Parameters

NameTypeDescription
tokenIduint256The token id to verify

_checkOnERC721Received

Internal utility to perform checks upon transfer in the case of sending to a contract.

function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private returns (bool);

Parameters

NameTypeDescription
fromaddressThe address sending the token
toaddressThe address receiving the token
tokenIduint256
databytesThe extra data to provide in the case where to is a contract

Returns

NameTypeDescription
<none>boolTrue if all checks are good