0.1.6 • Published 2 years ago

@unique-nft/client v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

polkadotjs uniquenetwork language license GitHub Release Date GitHub stability-alpha

Client

Table of Contents

About Client package

The @unique-nft/client 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/client package.

Installation

npm

npm install @unique-nft/client

Initialization

Node.js

import { Client, Options } from '@unique-nft/client';
const options: Options = {
    baseUrl: '<REST API URL>'
};
const client = new Client(options);

In the baseUrl parameter, you must pass one of the paths to the Unique Network

Opal

https://web-opal.unique.network

Quartz

https://web-quartz.unique.network

Unique

https://web-unique.unique.network

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 { KeyringProvider } from '@unique-nft/accounts/keyring';
import { Client } from "@unique-nft/client";

const options = {
  type: 'sr25519',
};
const provider = new KeyringProvider(options);
await provider.init();
const account = provider.addSeed('<seed of account>');
const signer = account.getSigner();

const clientOptions = {
  baseUrl: 'REST API URL',
  signer
};
const client = new Client(clientOptions);

Method call examples

const balanceResponse = await client.balance.get({ address: '<address>' });
const { parsed } = await client.balance.transfer.submitWaitResult(
  {
    address: '<address from>',
    destination: '<address to>',
    amount: 0.01
  });
0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago