test-actions-bump-sdk
v1.3.1
Published
The @unique-nft/sdk package implements the SDK methods via the REST API. The package implements all the basic methods for working with the Unique Network SDK.
Downloads
9
Maintainers
Readme
Client
Table of Contents
About Client package
The @unique-nft/sdk package implements the SDK methods via the REST API. The package implements all the basic methods for working with the SDK:
The package is under construction. Check the SDK package methods list to learn more about the methods, that will be implemented in the @unique-nft/sdk package.
Installation
npm
npm install @unique-nft/sdk
Initialization
Node.js
import { Sdk, Options } from '@unique-nft/sdk';
const options: Options = {
baseUrl: '<REST API URL>'
};
const sdk = new Sdk(options);
In the baseUrl
parameter, you must pass one of the paths to the Unique Network
Opal
https://rest.unique.network/opal/v1
Quartz
https://rest.unique.network/quartz/v1
Unique
https://rest.unique.network/unique/v1
Set a signer
To be able to sign extrinsics, you need to install the Accounts
package
npm install @unique-nft/accounts
Pass the singer
in the parameters when creating the Client
object
import { KeyringOptions } from "@polkadot/keyring/types";
import { KeyringProvider } from '@unique-nft/accounts/keyring';
import { Sdk } from "@unique-nft/sdk";
const options: KeyringOptions = {
type: 'sr25519',
};
const provider = new KeyringProvider(options);
await provider.init();
const signer = provider.addSeed('<seed of account>');
const clientOptions = {
baseUrl: 'REST API URL',
signer
};
const sdk = new Sdk(clientOptions);
Method call examples
const balanceResponse = await sdk.balance.get({ address: '<address>' });
const { parsed } = await sdk.balance.transfer.submitWaitResult(
{
address: '<address from>',
destination: '<address to>',
amount: 0.01
});