Initialize the payments class.
The options to initialize the payments class.
An instance of Payments
const payments = new Payments({
returnUrl: 'https://mysite.example'
environment: 'staging'
appId: 'my-app-id'
version: '1.0.0'
})
Optional
accountOptional
appPrivate
Optional
nvmOptional
versionProperty to check if a user logged in.
True if the user is logged in.
payments.isLoggedIn
Burn credits for a given DID.
The DID (Decentralized Identifier) of the asset.
The amount of NFT (Non-Fungible Token) credits to burn.
Optional
nvmApiKey: string(Optional) The NVM (Nevermined Vault Manager) API key to use for authorization.
A Promise that resolves to the JSON response from the server.
Error if the server response is not successful.
Create a subscription on Nevermined.
Optional
nvmOptional
tags?: string[]The DID of the newly created subscription.
const { did } = await payments.createSubscription({
name: "test subscription",
description: "test",
price: 10000000n,
tokenAddress: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
duration: 30,
tags: ["test"]
}
Creates a file with the specified parameters.
Optional
amountOptional
curation?: objectOptional
dataOptional
filesOptional
fineOptional
framework?: stringOptional
maxOptional
minOptional
nvmOptional
programmingOptional
sampleOptional
tags?: string[]Optional
task?: stringOptional
trainingOptional
usageOptional
variations?: stringThe promise that resolves to the created file's DID.
Creates a service.
Optional
amountOptional
apiOptional
curation?: objectOptional
endpoints?: Endpoint[]Optional
integration?: stringOptional
maxOptional
minOptional
nvmOptional
openOptional
openOptional
password?: stringOptional
sampleOptional
tags?: string[]Optional
token?: stringOptional
username?: stringA promise that resolves to the created service DID.
Create a subscription on Nevermined.
Optional
duration?: numberOptional
nvmOptional
tags?: string[]The DID of the newly created subscription.
const { did } = await payments.createSubscription({
name: "test subscription",
description: "test",
price: 10000000n,
tokenAddress: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
duration: 30,
tags: ["test"]
}
Get the service token for a given DID.
The DID of the service.
Optional
nvmApiKey: stringA promise that resolves to the service token.
Get the balance of an account for a subscription.
The subscription DID of the service to be published.
Optional
accountAddress: stringThe address of the account to get the balance.
Optional
nvmApiKey: stringThe NVM API key to use for the request.
A promise that resolves to the balance result.
Method to initialize the class once the user has been logged in. This method should be called has soon as the user has been redirected back to the app (returnUrl).
This is a browser only function.
payments.init()
You may want to use useEffect
on the route that matches the passed
returnUrl
useEffect(() => {
payments.init()
})
Mint credits for a given DID and transfer them to a receiver.
The DID (Decentralized Identifier) of the asset.
The amount of NFT (Non-Fungible Token) credits to mint.
The address of the receiver where the credits will be transferred.
Optional
nvmApiKey: string(Optional) The NVM (Nevermined Vault Manager) API key to use for authorization.
A Promise that resolves to the JSON response from the server.
Error if the server response is not successful.
Orders a subscription.
The subscription DID.
Optional
agreementId: stringThe agreement ID.
Optional
nvmApiKey: stringThe NVM API key to use for the request.
A promise that resolves to the agreement ID and a boolean indicating if the operation was successful.
Main class that interacts with the Nevermined payments API.