Skip to main content
Version: 23.0.x

Class: Nft

api/entities/Asset/NonFungible/Nft.Nft

Class used to manage Nft functionality. Each NFT belongs to an NftCollection, which specifies the expected metadata values for each NFT

Hierarchy

Properties

collection

collection: NftCollection

The NftCollection this NFT belongs to

Defined in

api/entities/Asset/NonFungible/Nft.ts:40


id

id: BigNumber

Defined in

api/entities/Asset/NonFungible/Nft.ts:35


uuid

uuid: string

Inherited from

Entity.uuid

Defined in

api/entities/Entity.ts:46

Methods

exists

exists(): Promise<boolean>

Determine if the NFT exists on chain

Note

This method returns true, even if the token has been redeemed/burned

Returns

Promise<boolean>

Overrides

Entity.exists


getImageUri

getImageUri(): Promise<null | string>

Get the conventional image URI for the NFT

This function will check for a token level value and a collection level value. Token level values take precedence over base values in case of a conflict.

When creating a collection an issuer can either require per token images by specifying global metadata key imageUri as a collection key or by setting a collection base image URL by setting a value on the collection corresponding to the global metadata key baseImageUri.

This method will return null if the NFT issuer did not configure the collection according to the convention.

Per token URIs provide the most flexibility, but require more chain space to store, increasing the POLYX fee to issue each token.

The URI values can include {tokenId} that will be replaced with the NFTs ID. If a base URI does not specify this the ID will be appended onto the URL. Examples:

  • https://example.com/nfts/{tokenId}/image.png becomes https://example.com/nfts/1/image.png
  • https://example.com/nfts becomes https://example.com/nfts/1 if used a base value, but remain unchanged as a local value

Returns

Promise<null | string>


getMetadata

getMetadata(): Promise<NftMetadata[]>

Get metadata associated with this token

Returns

Promise<NftMetadata[]>


getTokenUri

getTokenUri(): Promise<null | string>

Get the conventional token URI for the NFT

This function will check for a token level value and a collection level value. Token level values take precedence over base values in case of a conflict.

When creating a collection an issuer can either require per token URL by specifying global metadata key tokenURI as a collection key or by setting a collection base URL by setting a value on the collection corresponding to the global metadata key baseTokenUri on the collection.

This method will return null if the NFT issuer did not configure the collection according to the convention.

Per token URIs provide the most flexibility, but require more chain space to store, increasing the POLYX fee to issue each token.

The URI values can include {tokenId} that will be replaced with the NFTs ID. If a base URI does not specify this the ID will be appended onto the URL. Examples:

  • https://example.com/nfts/{tokenId}/info.json becomes https://example.com/nfts/1/info.json
  • https://example.com/nfts becomes https://example.com/nfts/1 if used a base value, but remain unchanged as a local value

Returns

Promise<null | string>


isEqual

isEqual(entity): boolean

Determine whether this Entity is the same as another one

Parameters

NameType
entityEntity<unknown, unknown>

Returns

boolean

Inherited from

Entity.isEqual


redeem

redeem(args?, opts?): Promise<GenericPolymeshTransaction<void, void>>

Redeem (or "burns") the NFT, removing it from circulation

Note

this method is of type OptionalArgsProcedureMethod, which means you can call redeem.checkAuthorization on it to see whether the signing Account and Identity have the required roles and permissions to run it

Parameters

NameType
args?RedeemNftParams
opts?ProcedureOpts

Returns

Promise<GenericPolymeshTransaction<void, void>>


generateUuid

Static generateUuid<Identifiers>(identifiers): string

Generate the Entity's UUID from its identifying properties

Type parameters

Name
Identifiers

Parameters

NameType
identifiersIdentifiers

Returns

string

Inherited from

Entity.generateUuid


unserialize

Static unserialize<Identifiers>(serialized): Identifiers

Unserialize a UUID into its Unique Identifiers

Type parameters

Name
Identifiers

Parameters

NameTypeDescription
serializedstringUUID to unserialize

Returns

Identifiers

Inherited from

Entity.unserialize