Hooks
useGetTokenMetadata
Hook for fetching token-specific metadata for individual tokens within a contract
Import
Usage
Return Type: UseQueryResult<TokenMetadata[]>
The hook returns all properties from React Query’s UseQueryResult
with token metadata. Here’s the detailed structure:
Properties
data
TokenMetadata[] | undefined
Array of objects containing metadata for each requested token:
tokenId
: ID of the specific tokensource
: Source/origin of the token metadata (e.g. “sequence”, “opensea”)name
: Name of the specific token (e.g., “Bored Ape #1234”)description
: Description of the specific tokenimage
: Token image URL (automatically proxied through image service)video
: Video URL if token has video contentaudio
: Audio URL if token has audio contentproperties
: Additional metadata properties as key-value pairsattributes
: Array of trait objects for NFTsimage_data
: Raw SVG/image data if providedexternal_url
: External URL associated with the tokenbackground_color
: Background color in hex formatanimation_url
: URL for animated contentdecimals
: Token decimals (for ERC1155 fungible tokens)updatedAt
: ISO timestamp of last metadata updateassets
: Array of additional asset filesstatus
: Current status of the metadata (“READY”, “PENDING”, “ERROR”)queuedAt
: ISO timestamp when metadata indexing was queuedlastFetched
: ISO timestamp of last successful fetch
isLoading
boolean
Loading state for the data fetch.
isError
boolean
Error state indicating if the query failed.
error
Error | null
Any error that occurred during data fetching.
Parameters
The hook accepts two parameters:
args: GetTokenMetadataArgs
Parameter | Type | Description |
---|---|---|
chainID | string | Chain ID as string (e.g., “1” for Ethereum mainnet) |
contractAddress | string | Contract address of the token/NFT |
tokenIDs | string[] | Array of token IDs to fetch metadata for |
options: HooksOptions
Parameter | Type | Description |
---|---|---|
disabled | boolean | (Optional) Disable the query from automatically running |
retry | boolean | (Optional) Whether to retry failed queries |
Was this page helpful?