@unique-nft/sdk
TypeScript icon, indicating that this package has built-in type declarations

0.7.3 • Public • Published
Unique Network

polkadotjs uniquenetwork language license GitHub Release Date GitHub stability-alpha

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

unpkg.com

<script src="https://unpkg.com/@unique-nft/sdk/bundles/index.js"></script>
<script src="https://unpkg.com/@unique-nft/sdk/bundles/evm.js"></script>
<script src="https://unpkg.com/@unique-nft/sdk/bundles/full.js"></script>
<script src="https://unpkg.com/@unique-nft/sdk/bundles/subscriptions.js"></script>

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
  });

Package Sidebar

Install

npm i @unique-nft/sdk

Weekly Downloads

14

Version

0.7.3

License

MIT

Unpacked Size

4.76 MB

Total Files

58

Last publish

Collaborators

  • ashkuc
  • fend25
  • ut-akuznetsov
  • lach
  • nonfungible