Norwegian Pony Master

    TypeScript icon, indicating that this package has built-in type declarations

    0.1.13 • Public • Published


    Definitely typed JS API for the Unique Network


    yarn add @unique-nft/api
    npm install @unique-nft/api

    Since this project requires the BigInt support, there may be needed some additional bundler settings.

    For example, you may need to add the following to your tsconfig.json file:

    "compilerOptions" {
    "target": "es2020",

    For Vite, you can do the same. Example of vite.config.ts:

    import { defineConfig } from 'vite'
    export default defineConfig({
      // ...
      build: {
        target: 'es2020'

    One more thing before you start, please make sure that you delete the ^ symbol in the package.json file. This is needed to avoid compatibility conflicts. The version of the library must be without this symbol:

    "dependencies": {
        "@unique-nft/api": "0.0.7",

    Quick Start

    Feel free to execute the code below to check some library features.

    import {init, Substrate, utils} from '@unique-nft/api'
    const run = async () => {
      await init({})
      const chain = new Substrate.Unique()
      await chain.connect(`wss://`)
      console.log(await chain.getChainProperties())
      await chain.disconnect()
    run().catch(err => console.error(err))


    Initializing with Polkadot extension enabling (works only in browser)

    import {init} from '@unique-nft/api'
    await init({connectToPolkadotExtensionsAs: 'my app'})

    or, another way to do the same:

    import {init, Substrate} from '@unique-nft/api'
    await init()
    await Substrate.extension.connectAs('my app')


    An extrinsic may be signed with keyring as well as with an account from the Polkadot extension.

    With keyring (available in both browser and Node.js):

    import {Substrate, init, WS_RPC} from '@unique-nft/api'
    await init()
    const chain = new Substrate.Unique()
    await chain.connect(WS_RPC.quartz)
    const keyring = Substrate.signer.keyringFromSeed('electric suit...')
    const result = await chain.transferCoins({toAddress: "5C...", amountInWei: 1_500_000_000_000_000_000n}).signAndSend(keyring)

    With the polkadot extension (available in browser only):

    import {Substrate, WS_RPC} from '@unique-nft/api'
    const quartz = new Substrate.Unique()
    const kusama = new Substrate.Common()
    await init({connectToPolkadotExtensionsAs: 'my app'})
    // we can create instances before init 
    // but connect must be invoked only after init call
    await quartz.connect(WS_RPC.quartz)
    await kusama.connect(WS_RPC.kusama)
    const accounts = await Substrate.extension.getAllAccounts()
    const account = accounts[0]
    // or, better option take some specific account
    // accounts.find(account => account.address === '5...')
    const KSMTransfer = await kusama.transferCoins({...}).signAndSend(account)
    const QTZTransfer = await quartz.transferCoins({...}).signAndSend(account)

    Note: in case of Substrate.Unique.transferCoins (but not for Substrate.Common),
    we can pass both substrate address (starting from 5 in normal form) and an Ethereum address (starting from 0x...).

    Unique's transferCoins (and other functions where it makes sense) can accept any address - substrate or ethereum.


    Substrate class provides methods which take extrinsic parameters and return an Extrinsic instance.


    const result = await quartz
      .transferCoins({toAddress: '5...', amountInWei: 1n})

    More verbose example:

    const quartz = new Substrate.Unique()
    const tx = quartz.transferCoins({toAddress: '5...', amountInWei: 1n})
    await tx.sign(keyringOrAccount)
    const result = await tx.send()

    All params have typings which can be imported this way:

    import {SubstrateMethodsParams} from '@unique-nft/api'
    const params: SubstrateMethodsParams.TransferCoins = {
      toAddress: '5...',
      amountInWei: 1n

    Extrinsic instance fields and methods:

    • async sign(signer: KeyringPair | InjectedAccountWithMeta) - returns it's instance
    • async send() - returns extrinsic result
    • async signAndSend(signer: KeyringPair | InjectedAccountWithMeta) - returns extrinsic result
    • isSigned - boolean
    • getRawTx() - returns SubmittableExtrinsic object


    npm i @unique-nft/api

    DownloadsWeekly Downloads






    Unpacked Size

    1.54 MB

    Total Files


    Last publish


    • fend25
    • degtiv
    • ut-akuznetsov
    • pkalachev
    • pasynkov
    • lach
    • nonfungible