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
-
Entity
<NftUniqueIdentifiers
,HumanReadable
>↳
Nft
Properties
collection
• collection: NftCollection
The NftCollection this NFT belongs to
Defined in
api/entities/Asset/NonFungible/Nft.ts:50
id
• id: BigNumber
Defined in
api/entities/Asset/NonFungible/Nft.ts:45
uuid
• uuid: string
Inherited from
Defined in
Methods
exists
▸ exists(): Promise
<boolean
>
Determine if the NFT exists on chain
Returns
Promise
<boolean
>
Overrides
Defined in
api/entities/Asset/NonFungible/Nft.ts:124
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
becomeshttps://example.com/nfts/1/image.png
https://example.com/nfts
becomeshttps://example.com/nfts/1
if used a base value, but remain unchanged as a local value
Returns
Promise
<null
| string
>
Defined in
api/entities/Asset/NonFungible/Nft.ts:146
getMetadata
▸ getMetadata(): Promise
<NftMetadata
[]>
Get metadata associated with this token
Returns
Promise
<NftMetadata
[]>
Defined in
api/entities/Asset/NonFungible/Nft.ts:95
getOwner
▸ getOwner(): Promise
<null
| NumberedPortfolio
| DefaultPortfolio
>
Get owner of the NFT
Returns
Promise
<null
| NumberedPortfolio
| DefaultPortfolio
>
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
Defined in
api/entities/Asset/NonFungible/Nft.ts:207
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
becomeshttps://example.com/nfts/1/info.json
https://example.com/nfts
becomeshttps://example.com/nfts/1
if used a base value, but remain unchanged as a local value
Returns
Promise
<null
| string
>
Defined in
api/entities/Asset/NonFungible/Nft.ts:182
isEqual
▸ isEqual(entity
): boolean
Determine whether this Entity is the same as another one
Parameters
Name | Type |
---|---|
entity | Entity <unknown , unknown > |
Returns
boolean
Inherited from
Defined in
isLocked
▸ isLocked(): Promise
<boolean
>
Check if the NFT is locked in any settlement instruction
Returns
Promise
<boolean
>
Throws
if NFT has no owner (has been redeemed)
Defined in
api/entities/Asset/NonFungible/Nft.ts:238
redeem
▸ redeem(args?
, opts?
): Promise
<GenericPolymeshTransaction
<void
, void
>>
Redeem (or "burns") the NFT, removing it from circulation
Parameters
Name | Type |
---|---|
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
Defined in
api/entities/Asset/NonFungible/Nft.ts:58
generateUuid
▸ Static
generateUuid<Identifiers
>(identifiers
): string
Generate the Entity's UUID from its identifying properties
Type parameters
Name |
---|
Identifiers |
Parameters
Name | Type |
---|---|
identifiers | Identifiers |
Returns
string
Inherited from
Defined in
unserialize
▸ Static
unserialize<Identifiers
>(serialized
): Identifiers
Unserialize a UUID into its Unique Identifiers
Type parameters
Name |
---|
Identifiers |
Parameters
Name | Type | Description |
---|---|---|
serialized | string | UUID to unserialize |
Returns
Identifiers