Skip to main content

Nfts

@nevermined-io/nevermined-sdk-js / Nfts

Class: Nfts

Nevermined Nft module

Hierarchy

  • Instantiable

    Nfts

Table of contents

Constructors

Accessors

Methods

Constructors

constructor

new Nfts()

Inherited from

Instantiable.constructor

Accessors

artifactsFolder

Protected get artifactsFolder(): string

Returns

string

Inherited from

Instantiable.artifactsFolder

Defined in

src/Instantiable.abstract.ts:96


config

Protected get config(): Config

Returns

Config

Inherited from

Instantiable.config

Defined in

src/Instantiable.abstract.ts:80


instanceConfig

Protected get instanceConfig(): InstantiableConfig

Returns

InstantiableConfig

Inherited from

Instantiable.instanceConfig

Defined in

src/Instantiable.abstract.ts:100


instantiableConfig

Protected get instantiableConfig(): InstantiableConfig

Returns

InstantiableConfig

Inherited from

Instantiable.instantiableConfig

Defined in

src/Instantiable.abstract.ts:73


logger

Protected get logger(): Logger

Returns

Logger

Inherited from

Instantiable.logger

Defined in

src/Instantiable.abstract.ts:87


nevermined

Protected get nevermined(): Nevermined

Returns

Nevermined

Inherited from

Instantiable.nevermined

Defined in

src/Instantiable.abstract.ts:33


web3

Protected get web3(): JsonRpcProvider

Returns

JsonRpcProvider

Inherited from

Instantiable.web3

Defined in

src/Instantiable.abstract.ts:63

Methods

access

access(did, consumer, destination?, index?, agreementId?): Promise<boolean>

Access the files associated with an NFT.

Remarks

This function will call the Node that will check if all the access conditions where fulfilled before providing the files.

Example

// TODO

Parameters

NameTypeDefault valueDescription
didstringundefinedThe Decentralized Identifier of the NFT asset.
consumerAccountundefinedThe NFT holder account.
destination?stringundefinedThe download destination for the files.
index?numberundefined-
agreementIdstring'0x'-

Returns

Promise<boolean>

true if the access was successful.

Defined in

src/nevermined/Nfts.ts:618


addresses

addresses(): Promise<string[]>

Returns

Promise<string[]>

Inherited from

Instantiable.addresses

Defined in

src/Instantiable.abstract.ts:129


balance

balance(did, account): Promise<default>

Get the NFT balance for a particular did

Example

// TODO

Parameters

NameTypeDescription
didstringThe Decentralized Identifier of the NFT asset.
accountAccountThe account to check the balance of.

Returns

Promise<default>

The amount of NFTs owned by the account.

Defined in

src/nevermined/Nfts.ts:645


burn

burn(did, nftAmount, publisher, params?): Promise<ContractReceipt>

Burn NFTs associated with an asset.

Remarks

The publisher can only burn NFTs that it owns. NFTs that were already transferred cannot be burned by the publisher.

Example

// TODO

Parameters

NameTypeDescription
didstringThe Decentralized Identifier of the NFT asset.
nftAmountdefaultThe amount of NFTs to burn.
publisherAccountThe account of the publisher of the NFT.
params?TxParametersOptional transaction parameters.

Returns

Promise<ContractReceipt>

The ethers.ContractReceipt

Defined in

src/nevermined/Nfts.ts:256


buySecondaryMarketNft

buySecondaryMarketNft(consumer, nftAmount?, agreementIdSeed, params?): Promise<boolean>

Buys a number of listed NFTs on secondary markets.

Example

// TODO

Throws

NFTError Thrown if there is an error buying the NFT.

Parameters

NameTypeDescription
consumerAccountThe account of the buyer/consumer.
nftAmountdefaultThe number of assets to buy. 1 by default.
agreementIdSeedstring-
params?TxParameters-

Returns

Promise<boolean>

true if the buy was successful.

Defined in

src/nevermined/Nfts.ts:934


checkExists

Protected checkExists(address): Promise<boolean>

Returns true of contract exists else it throws.

Parameters

NameType
addressstring

Returns

Promise<boolean>

true if the contract exists.

Inherited from

Instantiable.checkExists

Defined in

src/Instantiable.abstract.ts:44


create

create(metadata, publisher, cap, royaltyAttributes, assetRewards, nftAmount?, erc20TokenAddress?, preMint?, nftMetadata?, appId?, txParams?): SubscribablePromise<CreateProgressStep, DDO>

Create a new NFT Nevermined NFT.

Example

// TODO

Parameters

NameTypeDescription
metadataMetaDataThe metadata associated with the NFT.
publisherAccountThe account of the creator od the NFT.
capdefaultThe max number of nfts.
royaltyAttributesRoyaltyAttributesThe royalties associated with the NFT.
assetRewardsdefaultThe sales reward distribution.
nftAmountdefaultThe amount of NFTs that an address needs to hold in order to access the DID's protected assets. Leave it undefined and it will default to 1.
erc20TokenAddress?stringThe ERC-20 Token used to price the NFT.
preMint?booleanSet to true to mint nftAmount during creation.
nftMetadata?stringUrl to the NFT metadata.
appId?stringThe id of the application creating the NFT.
txParams?TxParametersOptional transaction parameters

Returns

SubscribablePromise<CreateProgressStep, DDO>

The newly registered DDO.

Defined in

src/nevermined/Nfts.ts:64


create721

create721(metadata, publisher, assetRewards, nftTokenAddress, erc20TokenAddress?, royaltyAttributes?, nftMetadata?, nftTransfer?, duration?, appId?, txParams?): SubscribablePromise<CreateProgressStep, DDO>

Create a new Nevermined NFT-721.

Example

// TODO

Parameters

NameTypeDefault valueDescription
metadataMetaDataundefinedThe metadata associated with the NFT.
publisherAccountundefinedThe account of the creator od the NFT.
assetRewardsdefaultundefinedThe sales reward distribution.
nftTokenAddressstringundefinedThe address of the ERC-721 contract
erc20TokenAddress?stringundefinedThe ERC-20 Token used to price the NFT.
royaltyAttributes?RoyaltyAttributesundefinedThe royalties associated with the NFT.
nftMetadata?stringundefinedUrl to the NFT metadata.
nftTransferbooleantrueTODO
durationnumber0TODO
appId?stringundefinedId of the application creating this NFT.
txParams?TxParametersundefinedOptional transaction parameters

Returns

SubscribablePromise<CreateProgressStep, DDO>

The newly registered DDO.

Defined in

src/nevermined/Nfts.ts:173


createWithRoyalties

createWithRoyalties(metadata, publisher, cap, royaltyAttributes, assetRewards, nftAmount?, erc20TokenAddress?, preMint?, nftMetadata?, nftType?, appId?, txParams?): SubscribablePromise<CreateProgressStep, DDO>

Create a new Nevermined NFT with royalties.

Example

// TODO

Parameters

NameTypeDefault valueDescription
metadataMetaDataundefinedThe metadata associated with the NFT.
publisherAccountundefinedThe account of the creator od the NFT.
capdefaultundefinedThe max number of nfts.
royaltyAttributesRoyaltyAttributesundefinedThe royalties associated with the NFT.
assetRewardsdefaultundefinedThe sales reward distribution.
nftAmountdefaultundefinedThe amount of NFTs that an address needs to hold in order to access the DID's protected assets. Leave it undefined and it will default to 1.
erc20TokenAddress?stringundefinedThe ERC-20 Token used to price the NFT.
preMint?booleanundefinedSet to true to mint nftAmount during creation.
nftMetadata?stringundefinedUrl to the NFT metadata.
nftTypeNeverminedNFTTypeNeverminedNFT1155Type.nft1155-
appId?stringundefinedThe id of the application creating the NFT.
txParams?TxParametersundefinedOptional transaction parameters

Returns

SubscribablePromise<CreateProgressStep, DDO>

The newly registered DDO.

Defined in

src/nevermined/Nfts.ts:119


details

details(did): Promise<{ blockNumberUpdated: number ; lastChecksum: any ; lastUpdatedBy: any ; mintCap: number ; nftSupply: number ; owner: any ; providers: any ; royalties: number ; royaltyScheme: RoyaltyKind ; url: any }>

Get the details of an NFT

Example

// TODO

Parameters

NameTypeDescription
didstringThe Decentralized Identifier of the NFT asset.

Returns

Promise<{ blockNumberUpdated: number ; lastChecksum: any ; lastUpdatedBy: any ; mintCap: number ; nftSupply: number ; owner: any ; providers: any ; royalties: number ; royaltyScheme: RoyaltyKind ; url: any }>

The details of the NFT.

Defined in

src/nevermined/Nfts.ts:693


downloadFiles

Private downloadFiles(agreementId, ddo, consumer, destination?, index?): Promise<boolean>

Parameters

NameType
agreementIdstring
ddoDDO
consumerAccount
destination?string
index?number

Returns

Promise<boolean>

Defined in

src/nevermined/Nfts.ts:752


findSigner

findSigner(from): Promise<Signer>

Parameters

NameType
fromstring

Returns

Promise<Signer>

Inherited from

Instantiable.findSigner

Defined in

src/Instantiable.abstract.ts:105


getNftContractAddress

getNftContractAddress(ddo): string | number | string[]

Get the NFT contract address associated with a Nevermined asset.

Example

// TODO

Parameters

NameTypeDescription
ddoDDOThe DDO of the asset.

Returns

string | number | string[]

The NFT contract address.

Defined in

src/nevermined/Nfts.ts:739


listOnSecondaryMarkets

listOnSecondaryMarkets(ddo, assetRewards, nftAmount, provider, token, owner): Promise<string>

After purchase re-list an NFT to enable secondary market sales.

Example

// TODO

Throws

NFTError Thrown if there is an error listing the NFT.

Parameters

NameTypeDescription
ddoDDOThe DDO of the asset.
assetRewardsdefaultThe current setup of asset rewards.
nftAmountdefaultThe number of NFTs put up for secondary sale.
providerstringThe address that will be the provider of the secondary sale.
tokendefault-
ownerstringThe account of the current owner.

Returns

Promise<string>

the agreementId of the secondary sale.

Defined in

src/nevermined/Nfts.ts:859


mint

mint(did, nftAmount, publisher, params?): Promise<ContractReceipt>

Mint NFTs associated with an asset.

Remarks

This function can be called multiple times as long as the minting does not exceed the maximum cap set during creation.

Example

// TODO

Parameters

NameTypeDescription
didstringThe Decentralized Identifier of the NFT asset.
nftAmountdefaultThe amount of NFTs to mint.
publisherAccountThe account of the publisher of the NFT.
params?TxParametersOptional transaction parameters.

Returns

Promise<ContractReceipt>

The ethers.ContractReceipt

Defined in

src/nevermined/Nfts.ts:224


order

order(did, nftAmount, consumer, txParams?): SubscribablePromise<OrderProgressStep, string>

Buy NFTs.

Remarks

This will lock the funds of the consumer in escrow pending the transfer of the NFTs from the publisher.

Example

// TODO

Parameters

NameTypeDescription
didstringThe Decentralized Identifier of the NFT asset.
nftAmountdefaultThe amount of NFTs to buy.
consumerAccountThe account of the NFT buyer.
txParams?TxParametersOptional transaction parameters.

Returns

SubscribablePromise<OrderProgressStep, string>

The agreement ID.

Defined in

src/nevermined/Nfts.ts:291


order721

order721(did, consumer, txParams?): SubscribablePromise<OrderProgressStep, string>

Buy NFT-721.

Remarks

This will lock the funds of the consumer in escrow pending the transfer of the NFTs from the publisher.

Example

// TODO

Parameters

NameTypeDescription
didstringThe Decentralized Identifier of the NFT asset.
consumerAccountThe account of the NFT buyer.
txParams?TxParametersOptional transaction parameters.

Returns

SubscribablePromise<OrderProgressStep, string>

The agreement ID.

Defined in

src/nevermined/Nfts.ts:340


ownerOf

ownerOf(did, nftTokenAddress, agreementId?): Promise<string>

Get the owner of the NFT

Example

// TODO

Parameters

NameTypeDescription
didstringThe Decentralized identifier of the NFT asset.
nftTokenAddressstringThe address of the ERC-721 contract.
agreementId?stringThe NFT sales agreement id.

Returns

Promise<string>

The address of the NFT owner.

Defined in

src/nevermined/Nfts.ts:663


release721Rewards

release721Rewards(agreementId, did, publisher, txParams?): Promise<boolean>

Release the funds from escrow.

Remarks

A publisher is able to release the funds put on escrow by the consumer after transferring the NFTs.

Example

// TODO

Throws

NFTError Thrown if there is an error releasing the rewards.

Parameters

NameTypeDescription
agreementIdstringThe NFT sales agreement id.
didstringThe Decentralized identifier of the NFT asset.
publisherAccountThe current owner of the NFTs.
txParams?TxParametersOptional transaction parameters.

Returns

Promise<boolean>

true if the funds release was successful.

Defined in

src/nevermined/Nfts.ts:574


releaseRewards

releaseRewards(agreementId, did, nftAmount, publisher, txParams?): Promise<boolean>

Release the funds from escrow.

Remarks

A publisher is able to release the funds put on escrow by the consumer after transferring the NFTs.

Example

// TODO

Throws

NFTError Thrown if there is an error releasing the rewards

Parameters

NameTypeDescription
agreementIdstringThe NFT sales agreement id.
didstringThe Decentralized identifier of the NFT asset.
nftAmountdefaultThe amount of NFTs to transfer.
publisherAccountThe current owner of the NFTs.
txParams?TxParametersOptional transaction parameters.

Returns

Promise<boolean>

true if the funds release was successful.

Defined in

src/nevermined/Nfts.ts:526


releaseSecondaryMarketRewards

releaseSecondaryMarketRewards(owner, consumer, agreementIdSeed, params?): Promise<boolean>

Used to release the secondary market NFT & the locked rewards.

Example

// TODO

Throws

NFTError Thrown if there is an error releasing the rewards.

Parameters

NameTypeDescription
ownerAccountThe owner account.
consumerAccount-
agreementIdSeedstring-
params?TxParameters-

Returns

Promise<boolean>

true if the transaction was successful.

Defined in

src/nevermined/Nfts.ts:997


setApprovalForAll

setApprovalForAll(operatorAddress, approved, from): Promise<ContractReceipt>

Enable or disable NFT transfer rights for an operator.

See

transferForDelegate

Example

// TODO

Parameters

NameTypeDescription
operatorAddressstringThe address that of the operator we want to give transfer rights to.
approvedbooleanGive or remove transfer rights from the operator.
fromAccountThe account that wants to give transfer rights to the operator.

Returns

Promise<ContractReceipt>

The ethers.ContractReceipt

Defined in

src/nevermined/Nfts.ts:822


setInstanceConfig

Protected setInstanceConfig(config): void

Parameters

NameType
configInstantiableConfig

Returns

void

Inherited from

Instantiable.setInstanceConfig

Defined in

src/Instantiable.abstract.ts:171


transfer

transfer(agreementId, did, nftAmount, publisher, txParams?): Promise<boolean>

Transfer NFTs to the consumer.

Remarks

A publisher/provider will check if the consumer put the funds in escrow and execute the transfer in order to be able to release the rewards.

Example

// TODO

Throws

NFTError Thrown if there is an error transferring the NFT

Parameters

NameTypeDescription
agreementIdstringThe NFT sales agreement id.
didstringThe Decentralized identifier of the NFT asset.
nftAmountdefaultThe number of NFTs to transfer.
publisherAccountThe current owner of the NFTs.
txParams?TxParametersOptional transaction parameters.

Returns

Promise<boolean>

true if the transfer was successful.

Defined in

src/nevermined/Nfts.ts:394


transfer721

transfer721(agreementId, did, publisher, txParams?): Promise<boolean>

Transfer NFT-721 to the consumer.

Remarks

A publisher/provider will check if the consumer put the funds in escrow and execute the transfer in order to be able to release the rewards.

Example

// TODO

Throws

NFTError Thrown if there is an error transferring the NFT

Parameters

NameTypeDescription
agreementIdstringThe NFT sales agreement id.
didstringThe Decentralized identifier of the NFT asset.
publisherAccountThe current owner of the NFTs.
txParams?TxParametersOptional transaction parameters.

Returns

Promise<boolean>

true if the transfer was successful.

Defined in

src/nevermined/Nfts.ts:481


transferForDelegate

transferForDelegate(agreementId, nftHolder, nftReceiver, nftAmount, ercType?): Promise<boolean>

Asks the Node to transfer the NFT on behalf of the publisher.

Remarks

This is useful when the consumer does not want to wait for the publisher to transfer the NFT once the payment is made. Assuming the publisher delegated transfer permissions to the Node.

One example would be a marketplace where the user wants to get access to the NFT as soon as the payment is made

Example

// TODO

Parameters

NameTypeDefault valueDescription
agreementIdstringundefinedThe NFT sales agreement id.
nftHolderstringundefinedThe address of the current owner of the NFT.
nftReceiverstringundefinedThe address where the NFT should be transferred.
nftAmountdefaultundefinedThe amount of NFTs to transfer.
ercTypeERCType1155The Type of the NFT ERC (1155 or 721).

Returns

Promise<boolean>

true if the transfer was successful.

Defined in

src/nevermined/Nfts.ts:443


addressesStatic

Static addressesStatic(config, web3): Promise<string[]>

Parameters

NameType
configConfig
web3JsonRpcProvider

Returns

Promise<string[]>

Inherited from

Instantiable.addressesStatic

Defined in

src/Instantiable.abstract.ts:142


findSignerStatic

Static findSignerStatic(config, web3, from): Promise<Signer>

Parameters

NameType
configConfig
web3JsonRpcProvider
fromstring

Returns

Promise<Signer>

Inherited from

Instantiable.findSignerStatic

Defined in

src/Instantiable.abstract.ts:115


getInstance

Static getInstance(config): Promise<Nfts>

Parameters

NameType
configInstantiableConfig

Returns

Promise<Nfts>

Overrides

Instantiable.getInstance

Defined in

src/nevermined/Nfts.ts:36


setInstanceConfig

Static Protected setInstanceConfig<T>(instance, instantiableConfig): void

Type parameters

NameType
Textends Instantiable<T>

Parameters

NameType
instanceT
instantiableConfigInstantiableConfig

Returns

void

Inherited from

Instantiable.setInstanceConfig

Defined in

src/Instantiable.abstract.ts:162