Skip to main content

ERC721 Primitives

  • ERC721, keeping track of NFT ownership for a specified ERC721 contract at the currently processed blockheight, as well as generating scheduled inputs for newly minted NFTs;

ERC721

Example

extensions:
- name: "My NFT Contract"
type: "erc721"
contractAddress: "0x01...ef"
startBlockHeight: 7654321
scheduledPrefix: "newnft"
# optional - monitors both the 0-address and the dEaD-address
burnScheduledPrefix: "nftburn"

Meaning

This extension allows you to track NFT ownership for any ERC721-compatible contract. You may also use it with PaimaERC721 contracts, which additionally allow you to specify an arbitrary string when minting an NFT – this extension type supports retrieving that string using scheduled inputs.

Paima Concise format

prefix|contractAddress|tokenId|mintData

where:

  • prefix is the scheduledPrefix specified in the config file,
  • contractAddress is the address of the contract (also specified in the config file),
  • tokenId is the ID of the newly minted token (in base 10),
  • mintData is the string emitted when the NFT was minted for PaimaERC721 NFTs (used for specifying the type of Stateful NFT). For classical ERC721 contracts, it will always be an empty string.

If burnScheduledPrefix is set, burn events are also emitted with the format:

prefix|owner|tokenId

where:

  • prefix is the value of burnScheduledPrefix in the config file.
  • owner is the address that burned the token.
  • tokenId is the ID of the burned token (in base 10),

Utility functions

  • getNftOwner, to fetch the address which owns the NFT with the specified token ID:
export async function getNftOwner(
readonlyDBConn: PoolClient,
extensionName: string,
nftId: bigint
): Promise<string | null>;
  • isNftOwner, to check whether the specified address owns the specified NFT:
export async function isNftOwner(
readonlyDBConn: PoolClient,
extensionName: string,
nftId: bigint,
ownerAddress: string
): Promise<boolean>;
  • getOwnedNfts, to fetch a list of token IDs of NFTs owned by the specified wallet address:
export async function getOwnedNfts(
readonlyDBConn: PoolClient,
extensionName: string,
ownerAddress: string
): Promise<bigint[]>;
  • getAllOwnedNfts, to fetch a list of tokenId,extensionName pairs of NFTs owned by the specified wallet address across all Primitives:
export async function getAllOwnedNfts(
readonlyDBConn: PoolClient,
ownerAddress: string
): Promise<
{
extensionName: string;
tokenId: bigint;
}[]
>;