Skip to main content
Version: 29.0.x

Class: Nft

Defined in: src/api/entities/Asset/NonFungible/Nft.ts:43

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

Extends​

Properties​

collection​

collection: NftCollection

Defined in: src/api/entities/Asset/NonFungible/Nft.ts:49

The NftCollection this NFT belongs to


id​

id: BigNumber

Defined in: src/api/entities/Asset/NonFungible/Nft.ts:44


uuid​

uuid: string

Defined in: src/api/entities/Entity.ts:46

Inherited from​

Entity.uuid

Methods​

exists()​

exists(): Promise<boolean>

Defined in: src/api/entities/Asset/NonFungible/Nft.ts:124

Determine if the NFT exists on chain

Returns​

Promise<boolean>

Overrides​

Entity.exists


getImageUri()​

getImageUri(): Promise<null | string>

Defined in: src/api/entities/Asset/NonFungible/Nft.ts:146

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[]>

Defined in: src/api/entities/Asset/NonFungible/Nft.ts:92

Get metadata associated with this token

Returns​

Promise<NftMetadata[]>


getOwner()​

getOwner(): Promise<null | DefaultPortfolio | NumberedPortfolio>

Defined in: src/api/entities/Asset/NonFungible/Nft.ts:207

Get owner of the NFT

Returns​

Promise<null | DefaultPortfolio | NumberedPortfolio>

Note​

This method returns null if there is no existing holder for the token. This may happen even if the token has been redeemed/burned


getTokenUri()​

getTokenUri(): Promise<null | string>

Defined in: src/api/entities/Asset/NonFungible/Nft.ts:182

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: Entity<unknown, unknown>): boolean

Defined in: src/api/entities/Entity.ts:61

Determine whether this Entity is the same as another one

Parameters​

ParameterType

entity

Entity<unknown, unknown>

Returns​

boolean

Inherited from​

Entity.isEqual


isLocked()​

isLocked(): Promise<boolean>

Defined in: src/api/entities/Asset/NonFungible/Nft.ts:239

Check if the NFT is locked in any settlement instruction

Returns​

Promise<boolean>

Throws​

if NFT has no owner (has been redeemed)


redeem()​

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

Defined in: src/api/entities/Asset/NonFungible/Nft.ts:54

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

Parameters​

ParameterType

args?

RedeemNftParams

opts?

ProcedureOpts

Returns​

Promise<GenericPolymeshTransaction<void, void>>

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


generateUuid()​

static generateUuid<Identifiers>(identifiers: Identifiers): string

Defined in: src/api/entities/Entity.ts:14

Generate the Entity's UUID from its identifying properties

Type Parameters​

Type Parameter

Identifiers

Parameters​

ParameterTypeDescription

identifiers

Identifiers

Returns​

string

Inherited from​

Entity.generateUuid


unserialize()​

static unserialize<Identifiers>(serialized: string): Identifiers

Defined in: src/api/entities/Entity.ts:23

Unserialize a UUID into its Unique Identifiers

Type Parameters​

Type Parameter

Identifiers

Parameters​

ParameterTypeDescription

serialized

string

UUID to unserialize

Returns​

Identifiers

Inherited from​

Entity.unserialize