You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.3 KiB

ERC721AQueryable

erc721a/contracts/extensions/ERC721AQueryable.sol

ERC721A subclass with convenience query functions.

Inherits:

Functions

explicitOwnershipOf

function explicitOwnershipOf(uint256 tokenId) public view returns (TokenOwnership memory)

Returns the TokenOwnership struct at tokenId without reverting.

This is useful for on-chain and off-chain querying of ownership data for tokenomics.

The returned struct will contain the following values:

  • If the tokenId is out of bounds:

    • addr = address(0)
    • startTimestamp = 0
    • burned = false
  • If the tokenId is burned:

    • addr = <Address of owner before token was burned>
    • startTimestamp = <Timestamp when token was burned>
    • burned = true
  • Otherwise:

    • addr = <Address of owner>
    • startTimestamp = <Timestamp of start of ownership>
    • burned = false

explicitOwnershipsOf

function explicitOwnershipsOf(
    uint256[] memory tokenIds
) external view returns (TokenOwnership[] memory)

Returns an array of TokenOwnership structs at tokenIds in order.

See explicitOwnershipOf.

tokensOfOwner

function tokensOfOwner(address owner) external view returns (uint256[] memory)

Returns an array of token IDs owned by owner.

This function scans the ownership mapping and is O(totalSupply) in complexity.
It is meant to be called off-chain.

See tokensOfOwnerIn for splitting the scan into multiple smaller scans if the collection is large enough to cause an out-of-gas error.

This function should work fine for 10k PFP collections.

tokensOfOwnerIn

function tokensOfOwnerIn(
    address owner,
    uint256 start,
    uint256 stop
) external view returns (uint256[] memory)

Returns an array of token IDs owned by owner, in the range [start, stop)
(i.e. starttokenId < stop).

This function allows for tokens to be queried if the collection grows too big for a single call of tokensOfOwner.

Requirements:

  • start < stop.