ERC 721

This set of interfaces, contracts, and utilities are all related to the ERC721 Non-Fungible Token Standard.

For a walkthrough on how to create an ERC721 token read our ERC721 guide.

The EIP consists of three interfaces, found here as IERC721, IERC721Metadata, and IERC721Enumerable. Only the first one is required in a contract to be ERC721 compliant.

Each interface is implemented separately in ERC721, ERC721Metadata, and ERC721Enumerable. You can choose the subset of functionality you would like to support in your token by combining the desired subset through inheritance.

The fully featured token implementing all three interfaces is prepackaged as ERC721Full.

Additionally, IERC721Receiver can be used to prevent tokens from becoming forever locked in contracts. Imagine sending an in-game item to an exchange address that can’t send it back!. When using safeTransferFrom, the token contract checks to see that the receiver is an IERC721Receiver, which implies that it knows how to handle ERC721 tokens. If you’re writing a contract that needs to receive ERC721 tokens, you’ll want to include this interface.

Finally, some custom extensions are also included:

  • ERC721Mintable — like the ERC20 version, this allows certain addresses to mint new tokens

  • ERC721Pausable — like the ERC20 version, this allows addresses to freeze transfers of tokens

This page is incomplete. We’re working to improve it for the next release. Stay tuned!

Core

IERC721

Required interface of an ERC721 compliant contract.

balanceOf(address owner) → uint256 balance public

Returns the number of NFTs in `owner’s account.

ownerOf(uint256 tokenId) → address owner public

Returns the owner of the NFT specified by tokenId.

safeTransferFrom(address from, address to, uint256 tokenId) public

Transfers a specific NFT (tokenId) from one account (from) to another (to).

Requirements: - from, to cannot be zero. - tokenId must be owned by from. - If the caller is not from, it must be have been allowed to move this NFT by either approve or setApprovalForAll.

transferFrom(address from, address to, uint256 tokenId) public

Transfers a specific NFT (tokenId) from one account (from) to another (to).

Requirements: - If the caller is not from, it must be approved to move this NFT by either approve or setApprovalForAll.

approve(address to, uint256 tokenId) public

getApproved(uint256 tokenId) → address operator public

setApprovalForAll(address operator, bool _approved) public

isApprovedForAll(address owner, address operator) → bool public

safeTransferFrom(address from, address to, uint256 tokenId, bytes data) public

supportsInterface(bytes4 interfaceId) → bool external

Returns true if this contract implements the interface defined by interfaceId. See the corresponding EIP section to learn more about how these ids are created.

This function call must use less than 30 000 gas.

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

ERC721

balanceOf(address owner) → uint256 public

Gets the balance of the specified address.

ownerOf(uint256 tokenId) → address public

Gets the owner of the specified token ID.

approve(address to, uint256 tokenId) public

Approves another address to transfer the given token ID The zero address indicates there is no approved address. There can only be one approved address per token at a given time. Can only be called by the token owner or an approved operator.

getApproved(uint256 tokenId) → address public

Gets the approved address for a token ID, or zero if no address set Reverts if the token ID does not exist.

setApprovalForAll(address to, bool approved) public

Sets or unsets the approval of a given operator An operator is allowed to transfer all tokens of the sender on their behalf.

isApprovedForAll(address owner, address operator) → bool public

Tells whether an operator is approved by a given owner.

transferFrom(address from, address to, uint256 tokenId) public

Transfers the ownership of a given token ID to another address. Usage of this method is discouraged, use safeTransferFrom whenever possible. Requires the msg.sender to be the owner, approved, or operator.

safeTransferFrom(address from, address to, uint256 tokenId) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the _msgSender() to be the owner, approved, or operator

_safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) internal

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

_exists(uint256 tokenId) → bool internal

Returns whether the specified token exists.

_isApprovedOrOwner(address spender, uint256 tokenId) → bool internal

Returns whether the given spender can transfer a given token ID.

_safeMint(address to, uint256 tokenId) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_safeMint(address to, uint256 tokenId, bytes _data) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_mint(address to, uint256 tokenId) internal

Internal function to mint a new token. Reverts if the given token ID already exists.

_burn(address owner, uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist. Deprecated, use _burn instead.

_burn(uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist.

_transferFrom(address from, address to, uint256 tokenId) internal

Internal function to transfer ownership of a given token ID to another address. As opposed to transferFrom, this imposes no restrictions on msg.sender.

_checkOnERC721Received(address from, address to, uint256 tokenId, bytes _data) → bool internal

Internal function to invoke IERC721Receiver.onERC721Received on a target address. The call is not executed if the target address is not a contract.

This function is deprecated.

constructor() internal

supportsInterface(bytes4 interfaceId) → bool external

Time complexity O(1), guaranteed to always use less than 30 000 gas.

_registerInterface(bytes4 interfaceId) internal

Registers the contract as an implementer of the interface defined by interfaceId. Support of the actual ERC165 interface is automatic and registering its interface id is not required.

Requirements:

  • interfaceId cannot be the ERC165 invalid interface (0xffffffff).

_msgSender() → address payable internal

_msgData() → bytes internal

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

IERC721Metadata

name() → string external

symbol() → string external

tokenURI(uint256 tokenId) → string external

balanceOf(address owner) → uint256 balance public

Returns the number of NFTs in `owner’s account.

ownerOf(uint256 tokenId) → address owner public

Returns the owner of the NFT specified by tokenId.

safeTransferFrom(address from, address to, uint256 tokenId) public

Transfers a specific NFT (tokenId) from one account (from) to another (to).

Requirements: - from, to cannot be zero. - tokenId must be owned by from. - If the caller is not from, it must be have been allowed to move this NFT by either approve or setApprovalForAll.

transferFrom(address from, address to, uint256 tokenId) public

Transfers a specific NFT (tokenId) from one account (from) to another (to).

Requirements: - If the caller is not from, it must be approved to move this NFT by either approve or setApprovalForAll.

approve(address to, uint256 tokenId) public

getApproved(uint256 tokenId) → address operator public

setApprovalForAll(address operator, bool _approved) public

isApprovedForAll(address owner, address operator) → bool public

safeTransferFrom(address from, address to, uint256 tokenId, bytes data) public

supportsInterface(bytes4 interfaceId) → bool external

Returns true if this contract implements the interface defined by interfaceId. See the corresponding EIP section to learn more about how these ids are created.

This function call must use less than 30 000 gas.

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

ERC721Metadata

constructor(string name, string symbol) public

Constructor function

name() → string external

Gets the token name.

symbol() → string external

Gets the token symbol.

tokenURI(uint256 tokenId) → string external

Returns an URI for a given token ID. Throws if the token ID does not exist. May return an empty string.

_setTokenURI(uint256 tokenId, string uri) internal

Internal function to set the token URI for a given token. Reverts if the token ID does not exist.

_burn(address owner, uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist. Deprecated, use _burn(uint256) instead.

balanceOf(address owner) → uint256 public

Gets the balance of the specified address.

ownerOf(uint256 tokenId) → address public

Gets the owner of the specified token ID.

approve(address to, uint256 tokenId) public

Approves another address to transfer the given token ID The zero address indicates there is no approved address. There can only be one approved address per token at a given time. Can only be called by the token owner or an approved operator.

getApproved(uint256 tokenId) → address public

Gets the approved address for a token ID, or zero if no address set Reverts if the token ID does not exist.

setApprovalForAll(address to, bool approved) public

Sets or unsets the approval of a given operator An operator is allowed to transfer all tokens of the sender on their behalf.

isApprovedForAll(address owner, address operator) → bool public

Tells whether an operator is approved by a given owner.

transferFrom(address from, address to, uint256 tokenId) public

Transfers the ownership of a given token ID to another address. Usage of this method is discouraged, use safeTransferFrom whenever possible. Requires the msg.sender to be the owner, approved, or operator.

safeTransferFrom(address from, address to, uint256 tokenId) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the _msgSender() to be the owner, approved, or operator

_safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) internal

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

_exists(uint256 tokenId) → bool internal

Returns whether the specified token exists.

_isApprovedOrOwner(address spender, uint256 tokenId) → bool internal

Returns whether the given spender can transfer a given token ID.

_safeMint(address to, uint256 tokenId) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_safeMint(address to, uint256 tokenId, bytes _data) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_mint(address to, uint256 tokenId) internal

Internal function to mint a new token. Reverts if the given token ID already exists.

_burn(uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist.

_transferFrom(address from, address to, uint256 tokenId) internal

Internal function to transfer ownership of a given token ID to another address. As opposed to transferFrom, this imposes no restrictions on msg.sender.

_checkOnERC721Received(address from, address to, uint256 tokenId, bytes _data) → bool internal

Internal function to invoke IERC721Receiver.onERC721Received on a target address. The call is not executed if the target address is not a contract.

This function is deprecated.

supportsInterface(bytes4 interfaceId) → bool external

Time complexity O(1), guaranteed to always use less than 30 000 gas.

_registerInterface(bytes4 interfaceId) internal

Registers the contract as an implementer of the interface defined by interfaceId. Support of the actual ERC165 interface is automatic and registering its interface id is not required.

Requirements:

  • interfaceId cannot be the ERC165 invalid interface (0xffffffff).

_msgSender() → address payable internal

_msgData() → bytes internal

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

ERC721Enumerable

constructor() public

Constructor function.

tokenOfOwnerByIndex(address owner, uint256 index) → uint256 public

Gets the token ID at a given index of the tokens list of the requested owner.

totalSupply() → uint256 public

Gets the total amount of tokens stored by the contract.

tokenByIndex(uint256 index) → uint256 public

Gets the token ID at a given index of all the tokens in this contract Reverts if the index is greater or equal to the total number of tokens.

_transferFrom(address from, address to, uint256 tokenId) internal

Internal function to transfer ownership of a given token ID to another address. As opposed to transferFrom, this imposes no restrictions on msg.sender.

_mint(address to, uint256 tokenId) internal

Internal function to mint a new token. Reverts if the given token ID already exists.

_burn(address owner, uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist. Deprecated, use ERC721._burn instead.

_tokensOfOwner(address owner) → [.var-type]#uint256[] [.item-kind]#internal

Gets the list of token IDs of the requested owner.

balanceOf(address owner) → uint256 public

Gets the balance of the specified address.

ownerOf(uint256 tokenId) → address public

Gets the owner of the specified token ID.

approve(address to, uint256 tokenId) public

Approves another address to transfer the given token ID The zero address indicates there is no approved address. There can only be one approved address per token at a given time. Can only be called by the token owner or an approved operator.

getApproved(uint256 tokenId) → address public

Gets the approved address for a token ID, or zero if no address set Reverts if the token ID does not exist.

setApprovalForAll(address to, bool approved) public

Sets or unsets the approval of a given operator An operator is allowed to transfer all tokens of the sender on their behalf.

isApprovedForAll(address owner, address operator) → bool public

Tells whether an operator is approved by a given owner.

transferFrom(address from, address to, uint256 tokenId) public

Transfers the ownership of a given token ID to another address. Usage of this method is discouraged, use safeTransferFrom whenever possible. Requires the msg.sender to be the owner, approved, or operator.

safeTransferFrom(address from, address to, uint256 tokenId) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the _msgSender() to be the owner, approved, or operator

_safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) internal

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

_exists(uint256 tokenId) → bool internal

Returns whether the specified token exists.

_isApprovedOrOwner(address spender, uint256 tokenId) → bool internal

Returns whether the given spender can transfer a given token ID.

_safeMint(address to, uint256 tokenId) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_safeMint(address to, uint256 tokenId, bytes _data) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_burn(uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist.

_checkOnERC721Received(address from, address to, uint256 tokenId, bytes _data) → bool internal

Internal function to invoke IERC721Receiver.onERC721Received on a target address. The call is not executed if the target address is not a contract.

This function is deprecated.

supportsInterface(bytes4 interfaceId) → bool external

Time complexity O(1), guaranteed to always use less than 30 000 gas.

_registerInterface(bytes4 interfaceId) internal

Registers the contract as an implementer of the interface defined by interfaceId. Support of the actual ERC165 interface is automatic and registering its interface id is not required.

Requirements:

  • interfaceId cannot be the ERC165 invalid interface (0xffffffff).

_msgSender() → address payable internal

_msgData() → bytes internal

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

IERC721Enumerable

totalSupply() → uint256 public

tokenOfOwnerByIndex(address owner, uint256 index) → uint256 tokenId public

tokenByIndex(uint256 index) → uint256 public

balanceOf(address owner) → uint256 balance public

Returns the number of NFTs in `owner’s account.

ownerOf(uint256 tokenId) → address owner public

Returns the owner of the NFT specified by tokenId.

safeTransferFrom(address from, address to, uint256 tokenId) public

Transfers a specific NFT (tokenId) from one account (from) to another (to).

Requirements: - from, to cannot be zero. - tokenId must be owned by from. - If the caller is not from, it must be have been allowed to move this NFT by either approve or setApprovalForAll.

transferFrom(address from, address to, uint256 tokenId) public

Transfers a specific NFT (tokenId) from one account (from) to another (to).

Requirements: - If the caller is not from, it must be approved to move this NFT by either approve or setApprovalForAll.

approve(address to, uint256 tokenId) public

getApproved(uint256 tokenId) → address operator public

setApprovalForAll(address operator, bool _approved) public

isApprovedForAll(address owner, address operator) → bool public

safeTransferFrom(address from, address to, uint256 tokenId, bytes data) public

supportsInterface(bytes4 interfaceId) → bool external

Returns true if this contract implements the interface defined by interfaceId. See the corresponding EIP section to learn more about how these ids are created.

This function call must use less than 30 000 gas.

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

IERC721Full

name() → string external

symbol() → string external

tokenURI(uint256 tokenId) → string external

totalSupply() → uint256 public

tokenOfOwnerByIndex(address owner, uint256 index) → uint256 tokenId public

tokenByIndex(uint256 index) → uint256 public

balanceOf(address owner) → uint256 balance public

Returns the number of NFTs in `owner’s account.

ownerOf(uint256 tokenId) → address owner public

Returns the owner of the NFT specified by tokenId.

safeTransferFrom(address from, address to, uint256 tokenId) public

Transfers a specific NFT (tokenId) from one account (from) to another (to).

Requirements: - from, to cannot be zero. - tokenId must be owned by from. - If the caller is not from, it must be have been allowed to move this NFT by either approve or setApprovalForAll.

transferFrom(address from, address to, uint256 tokenId) public

Transfers a specific NFT (tokenId) from one account (from) to another (to).

Requirements: - If the caller is not from, it must be approved to move this NFT by either approve or setApprovalForAll.

approve(address to, uint256 tokenId) public

getApproved(uint256 tokenId) → address operator public

setApprovalForAll(address operator, bool _approved) public

isApprovedForAll(address owner, address operator) → bool public

safeTransferFrom(address from, address to, uint256 tokenId, bytes data) public

supportsInterface(bytes4 interfaceId) → bool external

Returns true if this contract implements the interface defined by interfaceId. See the corresponding EIP section to learn more about how these ids are created.

This function call must use less than 30 000 gas.

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

ERC721Full

This implementation includes all the required and some optional functionality of the ERC721 standard Moreover, it includes approve all functionality using operator terminology.

constructor(string name, string symbol) public

name() → string external

Gets the token name.

symbol() → string external

Gets the token symbol.

tokenURI(uint256 tokenId) → string external

Returns an URI for a given token ID. Throws if the token ID does not exist. May return an empty string.

_setTokenURI(uint256 tokenId, string uri) internal

Internal function to set the token URI for a given token. Reverts if the token ID does not exist.

_burn(address owner, uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist. Deprecated, use _burn(uint256) instead.

tokenOfOwnerByIndex(address owner, uint256 index) → uint256 public

Gets the token ID at a given index of the tokens list of the requested owner.

totalSupply() → uint256 public

Gets the total amount of tokens stored by the contract.

tokenByIndex(uint256 index) → uint256 public

Gets the token ID at a given index of all the tokens in this contract Reverts if the index is greater or equal to the total number of tokens.

_transferFrom(address from, address to, uint256 tokenId) internal

Internal function to transfer ownership of a given token ID to another address. As opposed to transferFrom, this imposes no restrictions on msg.sender.

_mint(address to, uint256 tokenId) internal

Internal function to mint a new token. Reverts if the given token ID already exists.

_tokensOfOwner(address owner) → [.var-type]#uint256[] [.item-kind]#internal

Gets the list of token IDs of the requested owner.

balanceOf(address owner) → uint256 public

Gets the balance of the specified address.

ownerOf(uint256 tokenId) → address public

Gets the owner of the specified token ID.

approve(address to, uint256 tokenId) public

Approves another address to transfer the given token ID The zero address indicates there is no approved address. There can only be one approved address per token at a given time. Can only be called by the token owner or an approved operator.

getApproved(uint256 tokenId) → address public

Gets the approved address for a token ID, or zero if no address set Reverts if the token ID does not exist.

setApprovalForAll(address to, bool approved) public

Sets or unsets the approval of a given operator An operator is allowed to transfer all tokens of the sender on their behalf.

isApprovedForAll(address owner, address operator) → bool public

Tells whether an operator is approved by a given owner.

transferFrom(address from, address to, uint256 tokenId) public

Transfers the ownership of a given token ID to another address. Usage of this method is discouraged, use safeTransferFrom whenever possible. Requires the msg.sender to be the owner, approved, or operator.

safeTransferFrom(address from, address to, uint256 tokenId) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the _msgSender() to be the owner, approved, or operator

_safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) internal

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

_exists(uint256 tokenId) → bool internal

Returns whether the specified token exists.

_isApprovedOrOwner(address spender, uint256 tokenId) → bool internal

Returns whether the given spender can transfer a given token ID.

_safeMint(address to, uint256 tokenId) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_safeMint(address to, uint256 tokenId, bytes _data) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_burn(uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist.

_checkOnERC721Received(address from, address to, uint256 tokenId, bytes _data) → bool internal

Internal function to invoke IERC721Receiver.onERC721Received on a target address. The call is not executed if the target address is not a contract.

This function is deprecated.

supportsInterface(bytes4 interfaceId) → bool external

Time complexity O(1), guaranteed to always use less than 30 000 gas.

_registerInterface(bytes4 interfaceId) internal

Registers the contract as an implementer of the interface defined by interfaceId. Support of the actual ERC165 interface is automatic and registering its interface id is not required.

Requirements:

  • interfaceId cannot be the ERC165 invalid interface (0xffffffff).

_msgSender() → address payable internal

_msgData() → bytes internal

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

IERC721Receiver

Interface for any contract that wants to support safeTransfers from ERC721 asset contracts.

onERC721Received(address operator, address from, uint256 tokenId, bytes data) → bytes4 public

The ERC721 smart contract calls this function on the recipient after a IERC721.safeTransferFrom. This function MUST return the function selector, otherwise the caller will revert the transaction. The selector to be returned can be obtained as this.onERC721Received.selector. This function MAY throw to revert and reject the transfer. Note: the ERC721 contract address is always the message sender.

Extensions

ERC721Mintable

ERC721 minting logic.

Modifiers
MinterRole

onlyMinter() modifier

mint(address to, uint256 tokenId) → bool public

Function to mint tokens.

safeMint(address to, uint256 tokenId) → bool public

Function to safely mint tokens.

safeMint(address to, uint256 tokenId, bytes _data) → bool public

Function to safely mint tokens.

constructor() internal

isMinter(address account) → bool public

addMinter(address account) public

renounceMinter() public

_addMinter(address account) internal

_removeMinter(address account) internal

balanceOf(address owner) → uint256 public

Gets the balance of the specified address.

ownerOf(uint256 tokenId) → address public

Gets the owner of the specified token ID.

approve(address to, uint256 tokenId) public

Approves another address to transfer the given token ID The zero address indicates there is no approved address. There can only be one approved address per token at a given time. Can only be called by the token owner or an approved operator.

getApproved(uint256 tokenId) → address public

Gets the approved address for a token ID, or zero if no address set Reverts if the token ID does not exist.

setApprovalForAll(address to, bool approved) public

Sets or unsets the approval of a given operator An operator is allowed to transfer all tokens of the sender on their behalf.

isApprovedForAll(address owner, address operator) → bool public

Tells whether an operator is approved by a given owner.

transferFrom(address from, address to, uint256 tokenId) public

Transfers the ownership of a given token ID to another address. Usage of this method is discouraged, use safeTransferFrom whenever possible. Requires the msg.sender to be the owner, approved, or operator.

safeTransferFrom(address from, address to, uint256 tokenId) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the _msgSender() to be the owner, approved, or operator

_safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) internal

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

_exists(uint256 tokenId) → bool internal

Returns whether the specified token exists.

_isApprovedOrOwner(address spender, uint256 tokenId) → bool internal

Returns whether the given spender can transfer a given token ID.

_safeMint(address to, uint256 tokenId) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_safeMint(address to, uint256 tokenId, bytes _data) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_mint(address to, uint256 tokenId) internal

Internal function to mint a new token. Reverts if the given token ID already exists.

_burn(address owner, uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist. Deprecated, use _burn instead.

_burn(uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist.

_transferFrom(address from, address to, uint256 tokenId) internal

Internal function to transfer ownership of a given token ID to another address. As opposed to transferFrom, this imposes no restrictions on msg.sender.

_checkOnERC721Received(address from, address to, uint256 tokenId, bytes _data) → bool internal

Internal function to invoke IERC721Receiver.onERC721Received on a target address. The call is not executed if the target address is not a contract.

This function is deprecated.

supportsInterface(bytes4 interfaceId) → bool external

Time complexity O(1), guaranteed to always use less than 30 000 gas.

_registerInterface(bytes4 interfaceId) internal

Registers the contract as an implementer of the interface defined by interfaceId. Support of the actual ERC165 interface is automatic and registering its interface id is not required.

Requirements:

  • interfaceId cannot be the ERC165 invalid interface (0xffffffff).

_msgSender() → address payable internal

_msgData() → bytes internal

MinterAdded(address account) event

MinterRemoved(address account) event

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

ERC721MetadataMintable

ERC721 minting logic with metadata.

Modifiers
MinterRole

onlyMinter() modifier

mintWithTokenURI(address to, uint256 tokenId, string tokenURI) → bool public

Function to mint tokens.

constructor() internal

isMinter(address account) → bool public

addMinter(address account) public

renounceMinter() public

_addMinter(address account) internal

_removeMinter(address account) internal

name() → string external

Gets the token name.

symbol() → string external

Gets the token symbol.

tokenURI(uint256 tokenId) → string external

Returns an URI for a given token ID. Throws if the token ID does not exist. May return an empty string.

_setTokenURI(uint256 tokenId, string uri) internal

Internal function to set the token URI for a given token. Reverts if the token ID does not exist.

_burn(address owner, uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist. Deprecated, use _burn(uint256) instead.

balanceOf(address owner) → uint256 public

Gets the balance of the specified address.

ownerOf(uint256 tokenId) → address public

Gets the owner of the specified token ID.

approve(address to, uint256 tokenId) public

Approves another address to transfer the given token ID The zero address indicates there is no approved address. There can only be one approved address per token at a given time. Can only be called by the token owner or an approved operator.

getApproved(uint256 tokenId) → address public

Gets the approved address for a token ID, or zero if no address set Reverts if the token ID does not exist.

setApprovalForAll(address to, bool approved) public

Sets or unsets the approval of a given operator An operator is allowed to transfer all tokens of the sender on their behalf.

isApprovedForAll(address owner, address operator) → bool public

Tells whether an operator is approved by a given owner.

transferFrom(address from, address to, uint256 tokenId) public

Transfers the ownership of a given token ID to another address. Usage of this method is discouraged, use safeTransferFrom whenever possible. Requires the msg.sender to be the owner, approved, or operator.

safeTransferFrom(address from, address to, uint256 tokenId) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the _msgSender() to be the owner, approved, or operator

_safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) internal

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

_exists(uint256 tokenId) → bool internal

Returns whether the specified token exists.

_isApprovedOrOwner(address spender, uint256 tokenId) → bool internal

Returns whether the given spender can transfer a given token ID.

_safeMint(address to, uint256 tokenId) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_safeMint(address to, uint256 tokenId, bytes _data) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_mint(address to, uint256 tokenId) internal

Internal function to mint a new token. Reverts if the given token ID already exists.

_burn(uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist.

_transferFrom(address from, address to, uint256 tokenId) internal

Internal function to transfer ownership of a given token ID to another address. As opposed to transferFrom, this imposes no restrictions on msg.sender.

_checkOnERC721Received(address from, address to, uint256 tokenId, bytes _data) → bool internal

Internal function to invoke IERC721Receiver.onERC721Received on a target address. The call is not executed if the target address is not a contract.

This function is deprecated.

supportsInterface(bytes4 interfaceId) → bool external

Time complexity O(1), guaranteed to always use less than 30 000 gas.

_registerInterface(bytes4 interfaceId) internal

Registers the contract as an implementer of the interface defined by interfaceId. Support of the actual ERC165 interface is automatic and registering its interface id is not required.

Requirements:

  • interfaceId cannot be the ERC165 invalid interface (0xffffffff).

_msgSender() → address payable internal

_msgData() → bytes internal

MinterAdded(address account) event

MinterRemoved(address account) event

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

ERC721Burnable

ERC721 Token that can be irreversibly burned (destroyed).

burn(uint256 tokenId) public

Burns a specific ERC721 token.

balanceOf(address owner) → uint256 public

Gets the balance of the specified address.

ownerOf(uint256 tokenId) → address public

Gets the owner of the specified token ID.

approve(address to, uint256 tokenId) public

Approves another address to transfer the given token ID The zero address indicates there is no approved address. There can only be one approved address per token at a given time. Can only be called by the token owner or an approved operator.

getApproved(uint256 tokenId) → address public

Gets the approved address for a token ID, or zero if no address set Reverts if the token ID does not exist.

setApprovalForAll(address to, bool approved) public

Sets or unsets the approval of a given operator An operator is allowed to transfer all tokens of the sender on their behalf.

isApprovedForAll(address owner, address operator) → bool public

Tells whether an operator is approved by a given owner.

transferFrom(address from, address to, uint256 tokenId) public

Transfers the ownership of a given token ID to another address. Usage of this method is discouraged, use safeTransferFrom whenever possible. Requires the msg.sender to be the owner, approved, or operator.

safeTransferFrom(address from, address to, uint256 tokenId) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the _msgSender() to be the owner, approved, or operator

_safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) internal

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

_exists(uint256 tokenId) → bool internal

Returns whether the specified token exists.

_isApprovedOrOwner(address spender, uint256 tokenId) → bool internal

Returns whether the given spender can transfer a given token ID.

_safeMint(address to, uint256 tokenId) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_safeMint(address to, uint256 tokenId, bytes _data) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_mint(address to, uint256 tokenId) internal

Internal function to mint a new token. Reverts if the given token ID already exists.

_burn(address owner, uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist. Deprecated, use _burn instead.

_burn(uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist.

_transferFrom(address from, address to, uint256 tokenId) internal

Internal function to transfer ownership of a given token ID to another address. As opposed to transferFrom, this imposes no restrictions on msg.sender.

_checkOnERC721Received(address from, address to, uint256 tokenId, bytes _data) → bool internal

Internal function to invoke IERC721Receiver.onERC721Received on a target address. The call is not executed if the target address is not a contract.

This function is deprecated.

constructor() internal

supportsInterface(bytes4 interfaceId) → bool external

Time complexity O(1), guaranteed to always use less than 30 000 gas.

_registerInterface(bytes4 interfaceId) internal

Registers the contract as an implementer of the interface defined by interfaceId. Support of the actual ERC165 interface is automatic and registering its interface id is not required.

Requirements:

  • interfaceId cannot be the ERC165 invalid interface (0xffffffff).

_msgSender() → address payable internal

_msgData() → bytes internal

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

ERC721Pausable

ERC721 modified with pausable transfers.

Modifiers

whenNotPaused() modifier

Modifier to make a function callable only when the contract is not paused.

whenPaused() modifier

Modifier to make a function callable only when the contract is paused.

onlyPauser() modifier

approve(address to, uint256 tokenId) public

setApprovalForAll(address to, bool approved) public

_transferFrom(address from, address to, uint256 tokenId) internal

constructor() internal

Initializes the contract in unpaused state. Assigns the Pauser role to the deployer.

paused() → bool public

Returns true if the contract is paused, and false otherwise.

pause() public

Called by a pauser to pause, triggers stopped state.

unpause() public

Called by a pauser to unpause, returns to normal state.

isPauser(address account) → bool public

addPauser(address account) public

renouncePauser() public

_addPauser(address account) internal

_removePauser(address account) internal

balanceOf(address owner) → uint256 public

Gets the balance of the specified address.

ownerOf(uint256 tokenId) → address public

Gets the owner of the specified token ID.

getApproved(uint256 tokenId) → address public

Gets the approved address for a token ID, or zero if no address set Reverts if the token ID does not exist.

isApprovedForAll(address owner, address operator) → bool public

Tells whether an operator is approved by a given owner.

transferFrom(address from, address to, uint256 tokenId) public

Transfers the ownership of a given token ID to another address. Usage of this method is discouraged, use safeTransferFrom whenever possible. Requires the msg.sender to be the owner, approved, or operator.

safeTransferFrom(address from, address to, uint256 tokenId) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) public

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the _msgSender() to be the owner, approved, or operator

_safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) internal

Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operator

_exists(uint256 tokenId) → bool internal

Returns whether the specified token exists.

_isApprovedOrOwner(address spender, uint256 tokenId) → bool internal

Returns whether the given spender can transfer a given token ID.

_safeMint(address to, uint256 tokenId) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_safeMint(address to, uint256 tokenId, bytes _data) internal

Internal function to safely mint a new token. Reverts if the given token ID already exists. If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

_mint(address to, uint256 tokenId) internal

Internal function to mint a new token. Reverts if the given token ID already exists.

_burn(address owner, uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist. Deprecated, use _burn instead.

_burn(uint256 tokenId) internal

Internal function to burn a specific token. Reverts if the token does not exist.

_checkOnERC721Received(address from, address to, uint256 tokenId, bytes _data) → bool internal

Internal function to invoke IERC721Receiver.onERC721Received on a target address. The call is not executed if the target address is not a contract.

This function is deprecated.

supportsInterface(bytes4 interfaceId) → bool external

Time complexity O(1), guaranteed to always use less than 30 000 gas.

_registerInterface(bytes4 interfaceId) internal

Registers the contract as an implementer of the interface defined by interfaceId. Support of the actual ERC165 interface is automatic and registering its interface id is not required.

Requirements:

  • interfaceId cannot be the ERC165 invalid interface (0xffffffff).

_msgSender() → address payable internal

_msgData() → bytes internal

Paused(address account) event

Emitted when the pause is triggered by a pauser (account).

Unpaused(address account) event

Emitted when the pause is lifted by a pauser (account).

PauserAdded(address account) event

PauserRemoved(address account) event

Transfer(address from, address to, uint256 tokenId) event

Approval(address owner, address approved, uint256 tokenId) event

ApprovalForAll(address owner, address operator, bool approved) event

Convenience

ERC721Holder

onERC721Received(address, address, uint256, bytes) → bytes4 public