View Source: contracts/token/ERC721/ERC721.sol
↗ Extends: ERC165, IERC721 ↘ Derived Contracts: ERC721Burnable, ERC721Enumerable, ERC721Full, ERC721Metadata, ERC721MetadataMintable, ERC721Mintable, ERC721Mock, ERC721Pausable
ERC721
see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
Constants & Variables
bytes4 private constant _ERC721_RECEIVED;
mapping(uint256 => address) private _tokenOwner;
mapping(uint256 => address) private _tokenApprovals;
mapping(address => uint256) private _ownedTokensCount;
mapping(address => mapping(address => bool)) private _operatorApprovals;
bytes4 private constant _InterfaceId_ERC721;
- balanceOf(address owner)
- ownerOf(uint256 tokenId)
- approve(address to, uint256 tokenId)
- getApproved(uint256 tokenId)
- setApprovalForAll(address to, bool approved)
- isApprovedForAll(address owner, address operator)
- transferFrom(address from, address to, uint256 tokenId)
- safeTransferFrom(address from, address to, uint256 tokenId)
- safeTransferFrom(address from, address to, uint256 tokenId, bytes _data)
- _exists(uint256 tokenId)
- _isApprovedOrOwner(address spender, uint256 tokenId)
- _mint(address to, uint256 tokenId)
- _burn(address owner, uint256 tokenId)
- _addTokenTo(address to, uint256 tokenId)
- _removeTokenFrom(address from, uint256 tokenId)
- _checkOnERC721Received(address from, address to, uint256 tokenId, bytes _data)
- _clearApproval(address owner, uint256 tokenId)
⤾ overrides IERC721.balanceOf
Gets the balance of the specified address
function balanceOf(address owner) public
returns(uint256)
Returns
uint256 representing the amount owned by the passed address
Arguments
Name | Type | Description |
---|---|---|
owner | address | address to query the balance of |
⤾ overrides IERC721.ownerOf
Gets the owner of the specified token ID
function ownerOf(uint256 tokenId) public
returns(address)
Returns
owner address currently marked as the owner of the given token ID
Arguments
Name | Type | Description |
---|---|---|
tokenId | uint256 | uint256 ID of the token to query the owner of |
⤾ overrides IERC721.approve
⤿ Overridden Implementation(s): ERC721Pausable.approve
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.
function approve(address to, uint256 tokenId) public undefined
Arguments
Name | Type | Description |
---|---|---|
to | address | address to be approved for the given token ID |
tokenId | uint256 | uint256 ID of the token to be approved |
⤾ overrides IERC721.getApproved
Gets the approved address for a token ID, or zero if no address set Reverts if the token ID does not exist.
function getApproved(uint256 tokenId) public
returns(address)
Returns
address currently approved for the given token ID
Arguments
Name | Type | Description |
---|---|---|
tokenId | uint256 | uint256 ID of the token to query the approval of |
⤾ overrides IERC721.setApprovalForAll
⤿ Overridden Implementation(s): ERC721Pausable.setApprovalForAll
Sets or unsets the approval of a given operator An operator is allowed to transfer all tokens of the sender on their behalf
function setApprovalForAll(address to, bool approved) public undefined
Arguments
Name | Type | Description |
---|---|---|
to | address | operator address to set the approval |
approved | bool | representing the status of the approval to be set |
⤾ overrides IERC721.isApprovedForAll
Tells whether an operator is approved by a given owner
function isApprovedForAll(address owner, address operator) public
returns(bool)
Returns
bool whether the given operator is approved by the given owner
Arguments
Name | Type | Description |
---|---|---|
owner | address | owner address which you want to query the approval of |
operator | address | operator address which you want to query the approval of |
⤾ overrides IERC721.transferFrom
⤿ Overridden Implementation(s): ERC721Pausable.transferFrom
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
function transferFrom(address from, address to, uint256 tokenId) public undefined
Arguments
Name | Type | Description |
---|---|---|
from | address | current owner of the token |
to | address | address to receive the ownership of the given token ID |
tokenId | uint256 | uint256 ID of the token to be transferred |
⤾ overrides IERC721.safeTransferFrom
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
function safeTransferFrom(address from, address to, uint256 tokenId) public undefined
Arguments
Name | Type | Description |
---|---|---|
from | address | current owner of the token |
to | address | address to receive the ownership of the given token ID |
tokenId | uint256 | uint256 ID of the token to be transferred |
⤾ overrides IERC721.safeTransferFrom
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
function safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) public undefined
Arguments
Name | Type | Description |
---|---|---|
from | address | current owner of the token |
to | address | address to receive the ownership of the given token ID |
tokenId | uint256 | uint256 ID of the token to be transferred |
_data | bytes | bytes data to send along with a safe transfer check |
Returns whether the specified token exists
function _exists(uint256 tokenId) internal
returns(bool)
Returns
whether the token exists
Arguments
Name | Type | Description |
---|---|---|
tokenId | uint256 | uint256 ID of the token to query the existence of |
Returns whether the given spender can transfer a given token ID
function _isApprovedOrOwner(address spender, uint256 tokenId) internal
returns(bool)
Returns
bool whether the msg.sender is approved for the given token ID, is an operator of the owner, or is the owner of the token
Arguments
Name | Type | Description |
---|---|---|
spender | address | address of the spender to query |
tokenId | uint256 | uint256 ID of the token to be transferred |
⤿ Overridden Implementation(s): ERC721Enumerable._mint
Internal function to mint a new token Reverts if the given token ID already exists
function _mint(address to, uint256 tokenId) internal undefined
Arguments
Name | Type | Description |
---|---|---|
to | address | The address that will own the minted token |
tokenId | uint256 | uint256 ID of the token to be minted by the msg.sender |
⤿ Overridden Implementation(s): ERC721Enumerable._burn,ERC721Metadata._burn
Internal function to burn a specific token Reverts if the token does not exist
function _burn(address owner, uint256 tokenId) internal undefined
Arguments
Name | Type | Description |
---|---|---|
owner | address | |
tokenId | uint256 | uint256 ID of the token being burned by the msg.sender |
⤿ Overridden Implementation(s): ERC721Enumerable._addTokenTo
Internal function to add a token ID to the list of a given address Note that this function is left internal to make ERC721Enumerable possible, but is not intended to be called by custom derived contracts: in particular, it emits no Transfer event.
function _addTokenTo(address to, uint256 tokenId) internal undefined
Arguments
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 |
⤿ Overridden Implementation(s): ERC721Enumerable._removeTokenFrom
Internal function to remove a token ID from the list of a given address Note that this function is left internal to make ERC721Enumerable possible, but is not intended to be called by custom derived contracts: in particular, it emits no Transfer event, and doesn't clear approvals.
function _removeTokenFrom(address from, uint256 tokenId) internal undefined
Arguments
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 |
Internal function to invoke onERC721Received
on a target address
The call is not executed if the target address is not a contract
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes _data) internal undefined
returns(bool)
Returns
whether the call correctly returned the expected magic value
Arguments
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 |
Private function to clear current approval of a given token ID Reverts if the given address is not indeed the owner of the token
function _clearApproval(address owner, uint256 tokenId) private undefined
Arguments
Name | Type | Description |
---|---|---|
owner | address | owner of the token |
tokenId | uint256 | uint256 ID of the token to be transferred |
- Address
- AddressImpl
- AllowanceCrowdsale
- AllowanceCrowdsaleImpl
- Arrays
- ArraysImpl
- CappedCrowdsale
- CappedCrowdsaleImpl
- CapperRole
- CapperRoleMock
- ConditionalEscrow
- ConditionalEscrowMock
- Counter
- CounterImpl
- Crowdsale
- CrowdsaleMock
- ECDSA
- ECDSAMock
- ERC165
- ERC165Checker
- ERC165CheckerMock
- ERC165InterfacesSupported
- ERC165Mock
- ERC165NotSupported
- ERC20
- ERC20Burnable
- ERC20BurnableMock
- ERC20Capped
- ERC20Detailed
- ERC20DetailedMock
- ERC20FailingMock
- ERC20Migrator
- ERC20Mintable
- ERC20MintableMock
- ERC20Mock
- ERC20Pausable
- ERC20PausableMock
- ERC20SucceedingMock
- ERC20TokenMetadata
- ERC20WithMetadata
- ERC20WithMetadataMock
- ERC721
- ERC721Burnable
- ERC721Enumerable
- ERC721Full
- ERC721FullMock
- ERC721Holder
- ERC721Metadata
- ERC721MetadataMintable
- ERC721Mintable
- ERC721MintableBurnableImpl
- ERC721Mock
- ERC721Pausable
- ERC721PausableMock
- ERC721ReceiverMock
- Escrow
- EventEmitter
- FinalizableCrowdsale
- FinalizableCrowdsaleImpl
- IERC165
- IERC20
- IERC721
- IERC721Enumerable
- IERC721Full
- IERC721Metadata
- IERC721Receiver
- IncreasingPriceCrowdsale
- IncreasingPriceCrowdsaleImpl
- IndividuallyCappedCrowdsale
- IndividuallyCappedCrowdsaleImpl
- Math
- MathMock
- MerkleProof
- MerkleProofWrapper
- MintedCrowdsale
- MintedCrowdsaleImpl
- MinterRole
- MinterRoleMock
- Ownable
- OwnableMock
- Pausable
- PausableMock
- PauserRole
- PauserRoleMock
- PaymentSplitter
- PostDeliveryCrowdsale
- PostDeliveryCrowdsaleImpl
- PullPayment
- PullPaymentMock
- ReentrancyAttack
- ReentrancyGuard
- ReentrancyMock
- RefundableCrowdsale
- RefundableCrowdsaleImpl
- RefundEscrow
- Roles
- RolesMock
- SafeERC20
- SafeERC20Helper
- SafeMath
- SafeMathMock
- SampleCrowdsale
- SampleCrowdsaleToken
- Secondary
- SecondaryMock
- SignatureBouncer
- SignatureBouncerMock
- SignerRole
- SignerRoleMock
- SimpleToken
- SupportsInterfaceWithLookupMock
- TimedCrowdsale
- TimedCrowdsaleImpl
- TokenTimelock
- TokenVesting