ERC1155 Primitives
- ERC1155, keeping track of ERC1155 ownership for a specified ERC1155 contract at the currently processed blockheight
ERC1155
Example
extensions:
- name: "My semi-fungible token"
type: "erc1155"
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 ownership for any ERC1155-compatible contract.
Paima Concise format
prefix|operator|from|to|ids|values
where:
prefix
is thescheduledPrefix
specified in the config file,operator
is the address of an account/contract that is approved to make the transfer,from
is the address that sent the tokens,to
is the address that received the tokensids
is a JSON-encoded array of token IDs included in the transfervalues
is a JSON-encoded array of the amount of each token ID sent in the transfer
If burnScheduledPrefix
is set, burn events are also emitted with the format:
prefix|operator|from|ids|values
where:
prefix
is the value ofburnScheduledPrefix
in the config file.operator
is the address of an account/contract that is approved to make the transfer,from
is the address that sent the tokens,ids
is a JSON-encoded array of token IDs included in the transfervalues
is a JSON-encoded array of the amount of each token ID sent in the transfer
Utility functions
getErc1155AllTokens
, get a listing of all tokens owned by a wallet within a single ERC-1155 contract.
import type { ICdeErc1155GetAllTokensResult } from '@paima/db';
// interface ICdeErc1155GetAllTokensResult {
// balance: string;
// cde_id: number;
// token_id: string;
// wallet_address: string;
// }
export async function getErc1155AllTokens(
readonlyDBConn: Pool,
extensionName: string,
wallet: string
): Promise<ICdeErc1155GetAllTokensResult[]>
getErc1155ByTokenId
, get info on a specific token within a single ERC-1155 contract.
import type { ICdeErc1155GetByTokenIdResult } from '@paima/db';
// interface ICdeErc1155GetByTokenIdResult {
// balance: string;
// cde_id: number;
// token_id: string;
// wallet_address: string;
// }
export async function getErc1155ByTokenId(
readonlyDBConn: Pool,
extensionName: string,
tokenId: bigint
): Promise<ICdeErc1155GetByTokenIdResult | null>
getErc1155ByTokenIdAndWallet
, get info on a specific token owned by a wallet within a single ERC-1155 contract.
import type { getErc1155ByTokenIdAndWallet } from '@paima/db';
// interface ICdeErc1155GetByTokenIdAndWalletResult {
// balance: string;
// cde_id: number;
// token_id: string;
// wallet_address: string;
// }
export async function getErc1155ByTokenIdAndWallet(
readonlyDBConn: Pool,
extensionName: string,
wallet: string,
tokenId: bigint
): Promise<ICdeErc1155GetByTokenIdAndWalletResult | null>