Skip to main content

NvmApp

@nevermined-io/sdk - v3.0.32 / NvmApp

Class: NvmApp

Represents the NvmApp class which is the main entry point for interacting with the Nevermined SDK.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new NvmApp(config): NvmApp

Represents the NvmApp class.

Parameters

NameTypeDescription
configNeverminedAppOptionsThe configuration options for the Nevermined App.

Returns

NvmApp

Defined in

src/nevermined/NvmApp.ts:129

Properties

assetProviders

assetProviders: NeverminedNodeInfo[] = []

Defined in

src/nevermined/NvmApp.ts:79


configNVM

Private configNVM: NeverminedAppOptions

Defined in

src/nevermined/NvmApp.ts:74


fullSDK

Private fullSDK: undefined | Nevermined

Defined in

src/nevermined/NvmApp.ts:77


loginCredentials

Private loginCredentials: undefined | string

Defined in

src/nevermined/NvmApp.ts:80


networkFee

Private networkFee: undefined | bigint

Defined in

src/nevermined/NvmApp.ts:82


networkFeeReceiver

Private networkFeeReceiver: undefined | string

Defined in

src/nevermined/NvmApp.ts:81


searchSDK

Private searchSDK: Nevermined

Defined in

src/nevermined/NvmApp.ts:76


userAccount

Private userAccount: undefined | NvmAccount

Defined in

src/nevermined/NvmApp.ts:75


zeroDevSignerAccount

Private zeroDevSignerAccount: undefined | SmartAccountSigner\<"custom", `0x${string}`>

Defined in

src/nevermined/NvmApp.ts:78


defaultAppInitializationOptions

Static Readonly defaultAppInitializationOptions: NeverminedInitializationOptions

Default initialization options for the Nevermined application.

Defined in

src/nevermined/NvmApp.ts:87

Accessors

config

get config(): NeverminedOptions

Gets the configuration options for the Nevermined application.

Returns

NeverminedOptions

The configuration options for the Nevermined application.

Defined in

src/nevermined/NvmApp.ts:241


networkFees

get networkFees(): Object

Gets the network fees.

Returns

Object

An object containing the receiver and fee.

NameType
feebigint
receiverstring

Defined in

src/nevermined/NvmApp.ts:276


sdk

get sdk(): Nevermined

Gets the Nevermined SDK instance.

Returns

Nevermined

The Nevermined SDK instance.

Throws

If Web3 is not connected, try calling the connect method first.

Defined in

src/nevermined/NvmApp.ts:266


get search(): SearchApi

Gets the SearchApi instance.

Returns

SearchApi

The SearchApi instance.

Defined in

src/nevermined/NvmApp.ts:249


services

get services(): ServicesApi

Gets the Services API instance.

Returns

ServicesApi

The Services API instance.

Defined in

src/nevermined/NvmApp.ts:257

Methods

addNetworkFee

addNetworkFee(price): AssetPrice

Adds the network fee to the given asset price. If the network fee is not already included in the price, it adjusts the price to include the network fees.

Parameters

NameTypeDescription
priceAssetPriceThe asset price to which the network fee will be added.

Returns

AssetPrice

The updated asset price with the network fee included, or the original price if the network fee is already included.

Defined in

src/nevermined/NvmApp.ts:871


claimSubscription

claimSubscription(agreementId, subscriptionDid, numberCredits, serviceIndex?): Promise\<boolean>

Claims a subscription by transferring the specified number of credits from the subscription owner to the user's account.

Parameters

NameTypeDescription
agreementIdstringThe ID of the agreement associated with the subscription.
subscriptionDidstringThe DID (Decentralized Identifier) of the subscription.
numberCreditsbigintThe number of credits to be claimed.
serviceIndex?number(Optional) The index of the service within the subscription.

Returns

Promise\<boolean>

A Promise that resolves to a boolean indicating whether the claim was successful.

Throws

If Web3 is not connected or if there is an error claiming the NFT of the subscription.

Defined in

src/nevermined/NvmApp.ts:610


connect

connect(account, message?, config?, initOptions?): Promise\<{ marketplaceAuthToken: string ; userAccount: NvmAccount ; zeroDevSignerAccount: undefined | SmartAccountSigner\<"custom", `0x${string}`> }>

Connects to the Nevermined network and initializes the NvmApp instance.

Parameters

NameTypeDescription
accountstring | NvmAccount | SmartAccountSigner\<"custom", `0x${string}`>The account to connect with. It can be either a string representing the account address or an instance of the Account class.
message?stringAn optional message to include in the client assertion for authentication.
config?NeverminedOptionsOptional configuration options for the Nevermined instance.
initOptions?NeverminedInitializationOptionsOptional initialization options for the Nevermined instance.

Returns

Promise\<{ marketplaceAuthToken: string ; userAccount: NvmAccount ; zeroDevSignerAccount: undefined | SmartAccountSigner\<"custom", `0x${string}`> }>

An object containing the marketplace authentication token, user account, and zeroDev signer account (if applicable).

Defined in

src/nevermined/NvmApp.ts:151


createCreditsSubscription

createCreditsSubscription(susbcriptionMetadata, subscriptionPrice, numberCredits, subscriptionNFTContractCreditsAddress?): SubscribablePromise\<CreateProgressStep, DDO>

Creates a credits subscription.

Parameters

NameTypeDescription
susbcriptionMetadataMetaDataThe metadata for the subscription.
subscriptionPriceAssetPriceThe price of the subscription.
numberCreditsbigintThe number of credits for the subscription.
subscriptionNFTContractCreditsAddress?string-

Returns

SubscribablePromise\<CreateProgressStep, DDO>

A SubscribablePromise that resolves to a DDO object representing the created subscription.

Throws

If Web3 is not connected.

Throws

If the validation of the subscription fails.

Defined in

src/nevermined/NvmApp.ts:400


createCreditsSubscriptionAsync

createCreditsSubscriptionAsync(susbcriptionMetadata, subscriptionPrice, numberCredits): Promise\<DDO>

Creates a credits subscription asynchronously.

Parameters

NameTypeDescription
susbcriptionMetadataMetaDataThe metadata for the subscription.
subscriptionPriceAssetPriceThe price of the subscription.
numberCreditsbigintThe number of credits for the subscription.

Returns

Promise\<DDO>

A Promise that resolves to a DDO (Decentralized Data Object).

Defined in

src/nevermined/NvmApp.ts:466


createTimeSubscription

createTimeSubscription(susbcriptionMetadata, subscriptionPrice, duration, subscriptionNFTContractTimeAddress?): SubscribablePromise\<CreateProgressStep, DDO>

Creates a time-based subscription for a given asset.

Parameters

NameTypeDescription
susbcriptionMetadataMetaDataThe metadata of the subscription.
subscriptionPriceAssetPriceThe price of the subscription.
durationnumberThe duration of the subscription in seconds.
subscriptionNFTContractTimeAddress?string-

Returns

SubscribablePromise\<CreateProgressStep, DDO>

A promise that resolves to the progress steps and the resulting DDO (Decentralized Data Object).

Throws

If Web3 is not connected.

Throws

If the validation of the subscription fails.

Defined in

src/nevermined/NvmApp.ts:319


createTimeSubscriptionAsync

createTimeSubscriptionAsync(susbcriptionMetadata, subscriptionPrice, duration): Promise\<DDO>

Creates a time-based subscription asynchronously.

Parameters

NameTypeDescription
susbcriptionMetadataMetaDataThe metadata for the subscription.
subscriptionPriceAssetPriceThe price of the subscription.
durationnumberThe duration of the subscription in seconds.

Returns

Promise\<DDO>

A Promise that resolves to the DDO (Decentralized Data Object) of the created subscription.

Defined in

src/nevermined/NvmApp.ts:382


disconnect

disconnect(): Promise\<void>

Disconnects the NvmApp from the current web3 provider. Clears the fullSDK instance and resets the user account, zeroDevSigner settings, and login credentials.

Returns

Promise\<void>

Defined in

src/nevermined/NvmApp.ts:211


downloadFiles

downloadFiles(fileAssetDid, fileIndex?, destinationPath?, agreementId?): Promise\<OperationResult>

Downloads files associated with a given file asset DID.

Parameters

NameTypeDescription
fileAssetDidstringThe DID of the file asset.
fileIndex?number(Optional) The index of the file to download if the file asset contains multiple files.
destinationPath?string(Optional) The path where the downloaded files will be saved.
agreementId?string(Optional) The ID of the agreement associated with the file asset.

Returns

Promise\<OperationResult>

A Promise that resolves to an OperationResult object containing the agreement ID and the success status of the download operation.

Throws

If there is an error downloading the files.

Defined in

src/nevermined/NvmApp.ts:698


getBalance

getBalance(subscriptionDid, accountAddress?): Promise\<SubscriptionBalance>

Retrieves the balance and subscription information for a given subscription DID and account address. If no account address is provided, the user's account ID will be used.

Parameters

NameTypeDescription
subscriptionDidstringThe DID (Decentralized Identifier) of the subscription.
accountAddress?string(Optional) The Ethereum address of the account. If not provided, the user's account ID will be used.

Returns

Promise\<SubscriptionBalance>

A Promise that resolves to a SubscriptionBalance object containing the subscription type, balance, and access information.

Throws

If the Web3 provider is not connected.

Throws

If there is an error retrieving the subscription information.

Defined in

src/nevermined/NvmApp.ts:645


getEncryptedAPIKey

getEncryptedAPIKey(sessionKey): Promise\<string>

It gets an encrypted Nevermined API Key that can be used to interact with the Nevermined. The generation of the API Key requires to have a ZeroDev Session Key that is given as parameter to this method.

Parameters

NameTypeDescription
sessionKeystringThe Zero Dev Session Key.

Returns

Promise\<string>

A encrypted Nevermined API Key.

Throws

If Web3 is not connected. Call the connect method first.

Defined in

src/nevermined/NvmApp.ts:289


getLoginCredentials

getLoginCredentials(): undefined | string

Retrieves the login credentials.

Returns

undefined | string

The login credentials as a string, or undefined if not set.

Defined in

src/nevermined/NvmApp.ts:233


getProviderAddresses

getProviderAddresses(): string[]

Returns

string[]

Defined in

src/nevermined/NvmApp.ts:303


getServiceAccessToken

getServiceAccessToken(serviceDid): Promise\<SubscriptionToken>

Retrieves the service access token for a given service DID.

Parameters

NameTypeDescription
serviceDidstringThe service DID for which to retrieve the access token.

Returns

Promise\<SubscriptionToken>

A promise that resolves to the subscription token.

Throws

If Web3 is not connected. Call the connect method first.

Defined in

src/nevermined/NvmApp.ts:681


initializeSearch

initializeSearch(config?): Promise\<void>

Initializes the search functionality of the Nevermined App.

Parameters

NameTypeDescription
config?NeverminedAppOptionsOptional configuration options for the Nevermined App.

Returns

Promise\<void>

A Promise that resolves to void.

Defined in

src/nevermined/NvmApp.ts:138


isNetworkFeeIncluded

isNetworkFeeIncluded(price): boolean

Checks if the network fee is included in the given asset price.

Parameters

NameTypeDescription
priceAssetPriceThe asset price to check.

Returns

boolean

A boolean indicating whether the network fee is included.

Defined in

src/nevermined/NvmApp.ts:886


isWeb3Connected

isWeb3Connected(): boolean

Checks if the web3 provider is connected.

Returns

boolean

True if the web3 provider is connected, false otherwise.

Defined in

src/nevermined/NvmApp.ts:225


orderSubscription

orderSubscription(subscriptionDid, numberCredits, serviceIndex?): SubscribablePromise\<OrderProgressStep, string>

Orders a subscription for a given NFT.

Parameters

NameTypeDescription
subscriptionDidstringThe DID of the subscription NFT.
numberCreditsbigintThe number of credits to be used for the subscription.
serviceIndex?number(Optional) The index of the service to be used for the subscription.

Returns

SubscribablePromise\<OrderProgressStep, string>

A SubscribablePromise that resolves to the progress of the order or rejects with an error message.

Throws

If Web3 is not connected.

Throws

If there is an error ordering the subscription.

Defined in

src/nevermined/NvmApp.ts:580


orderSubscriptionAsync

orderSubscriptionAsync(subscriptionDid, agreementId?): Promise\<OperationResult>

Orders a subscription and claim asynchronously.

Parameters

NameTypeDescription
subscriptionDidstringThe DID of the subscription.
agreementId?stringThe ID of the agreement (optional).

Returns

Promise\<OperationResult>

A Promise that resolves to an OperationResult object.

Throws

If Web3 is not connected.

Throws

If there is an error ordering the subscription.

Defined in

src/nevermined/NvmApp.ts:521


registerFileAsset

registerFileAsset(metadata, subscriptionDid, costInCredits?, nftContractAddress): SubscribablePromise\<CreateProgressStep, DDO>

Registers a file asset by creating a new DDO (Decentralized Data Object) on the network.

Parameters

NameTypeDescription
metadataMetaDataThe metadata of the file asset.
subscriptionDidstringThe subscription DID (Decentralized Identifier) associated with the file asset.
costInCreditsbigintThe cost of the file asset in credits (default is 1).
nftContractAddressstringThe address of the NFT contract associated with the file asset.

Returns

SubscribablePromise\<CreateProgressStep, DDO>

A SubscribablePromise that resolves to a DDO (Decentralized Data Object) representing the registered file asset.

Throws

If the Web3 connection is not established.

Throws

If the file asset metadata is not valid.

Defined in

src/nevermined/NvmApp.ts:805


registerFileAssetAsync

registerFileAssetAsync(metadata, subscriptionDid, costInCredits?, nftContractAddress): Promise\<DDO>

Registers a file asset asynchronously.

Parameters

NameTypeDescription
metadataMetaDataThe metadata of the file asset.
subscriptionDidstringThe subscription DID.
costInCreditsbigintThe cost in credits (default: 1n).
nftContractAddressstring-

Returns

Promise\<DDO>

A Promise that resolves to the registered DDO (Decentralized Data Object).

Defined in

src/nevermined/NvmApp.ts:850


registerServiceAsset

registerServiceAsset(metadata, subscriptionDid, costInCredits?, minCreditsToCharge?, maxCreditsToCharge?, nftContractAddress): SubscribablePromise\<CreateProgressStep, DDO>

Registers a service asset.

Parameters

NameTypeDescription
metadataMetaDataThe metadata of the asset.
subscriptionDidstringThe subscription DID.
costInCreditsbigintThe cost in credits (default: 1).
minCreditsToChargebigintThe minimum credits required to charge (default: 1).
maxCreditsToChargebigintThe maximum credits to charge (default: 1).
nftContractAddressstringThe address of the NFT contract associated with the file asset.

Returns

SubscribablePromise\<CreateProgressStep, DDO>

A promise that resolves to the progress steps and the registered DDO.

Throws

If Web3 is not connected.

Throws

If the metadata validation fails.

Defined in

src/nevermined/NvmApp.ts:734


registerServiceAssetAsync

registerServiceAssetAsync(metadata, subscriptionDid, costInCredits?, minCreditsToCharge?, maxCreditsToCharge?, nftContractAddress): Promise\<DDO>

Parameters

NameType
metadataMetaData
subscriptionDidstring
costInCreditsbigint
minCreditsToChargebigint
maxCreditsToChargebigint
nftContractAddressstring

Returns

Promise\<DDO>

Defined in

src/nevermined/NvmApp.ts:776


updateAsset

updateAsset(did, metadata): SubscribablePromise\<UpdateProgressStep, DDO>

Updates the metadata of an asset.

Parameters

NameTypeDescription
didstringThe decentralized identifier (DID) of the asset.
metadataMetaDataThe updated metadata for the asset.

Returns

SubscribablePromise\<UpdateProgressStep, DDO>

A SubscribablePromise that resolves to the updated DDO (Decentralized Data Object).

Throws

If Web3 is not connected. Call the connect method first.

Defined in

src/nevermined/NvmApp.ts:486


updateAssetAsync

updateAssetAsync(did, metadata): Promise\<DDO>

Updates the asset with the specified DID using the provided metadata.

Parameters

NameTypeDescription
didstringThe DID (Decentralized Identifier) of the asset to update.
metadataMetaDataThe updated metadata for the asset.

Returns

Promise\<DDO>

A Promise that resolves to the updated DDO (Decentralized Data Object) of the asset.

Defined in

src/nevermined/NvmApp.ts:508


validateFileAssetMetadata

validateFileAssetMetadata(_susbcriptionMetadata): MetadataValidationResults

Parameters

NameType
_susbcriptionMetadataMetaData

Returns

MetadataValidationResults

Defined in

src/nevermined/NvmApp.ts:934


validateServiceAssetMetadata

validateServiceAssetMetadata(_susbcriptionMetadata): MetadataValidationResults

Parameters

NameType
_susbcriptionMetadataMetaData

Returns

MetadataValidationResults

Defined in

src/nevermined/NvmApp.ts:927


validateSubscription

validateSubscription(metadata, price, subscriptionType): MetadataValidationResults

Parameters

NameType
metadataMetaData
priceAssetPrice
subscriptionTypeSubscriptionType

Returns

MetadataValidationResults

Defined in

src/nevermined/NvmApp.ts:901


getConfigFromTagName

getConfigFromTagName(appEnv): NeverminedOptions

Parameters

NameType
appEnvNVMAppEnvironments

Returns

NeverminedOptions

Defined in

src/nevermined/NvmApp.ts:938


getInstance

getInstance(appEnv, config?): Promise\<NvmApp>

Returns an instance of the NvmApp class.

Parameters

NameTypeDescription
appEnvNVMAppEnvironmentsThe environment for the NvmApp instance.
config?Partial\<NeverminedOptions | NeverminedAppOptions>Optional configuration options for the NvmApp instance.

Returns

Promise\<NvmApp>

A Promise that resolves to an instance of the NvmApp class.

Defined in

src/nevermined/NvmApp.ts:112


switchConfigBetweenEnvs

switchConfigBetweenEnvs(appEnv): NeverminedOptions

Parameters

NameType
appEnvNVMAppEnvironments

Returns

NeverminedOptions

Defined in

src/nevermined/NvmApp.ts:943