Options
All
  • Public
  • Public/Protected
  • All
Menu

ternoa-js

Index

Functions

  • addNftToCollection(nftId: number, nftCollectionId: number, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    addNftToCollection

    summary

    Add an NFT to a collection.

    Parameters

    • nftId: number

      The NFT id.

    • nftCollectionId: number

      The collection id to which the NFT will belong.

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data.

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made.

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction, or an unsigned transaction to be signed if no keyring pair is passed.

  • batchAllTx(txHexes: `0x${string}`[]): Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>
  • name

    batchAllTx

    summary

    Create a batchAll transaction of dispatch calls.

    Parameters

    • txHexes: `0x${string}`[]

      Transactions to execute in the batch call

    Returns Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>

    Submittable extrinsic unsigned

  • batchAllTxHex(txHexes: `0x${string}`[]): Promise<`0x${string}`>
  • name

    batchAllTxHex

    summary

    Create a batchAll transaction of dispatch calls in hex format.

    Parameters

    • txHexes: `0x${string}`[]

      Transactions to execute in the batch call

    Returns Promise<`0x${string}`>

    Hex of the submittable extrinsic unsigned

  • batchTx(txHexes: `0x${string}`[]): Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>
  • name

    batchTx

    summary

    Create a batch transaction of dispatch calls.

    Parameters

    • txHexes: `0x${string}`[]

      Transactions to execute in the batch call

    Returns Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>

    Submittable extrinsic unsigned

  • batchTxHex(txHexes: `0x${string}`[]): Promise<`0x${string}`>
  • name

    batchTxHex

    summary

    Create a batch transaction of dispatch calls in hex format.

    Parameters

    • txHexes: `0x${string}`[]

      Transactions to execute in the batch call

    Returns Promise<`0x${string}`>

    Hex of the submittable extrinsic unsigned

  • burnCollection(collectionId: number, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    burnCollection

    summary

    Remove a collection from the storage.

    Parameters

    • collectionId: number

      The collection id to burn.

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data. Must be the owner of the collection.

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made.

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction, or an unsigned transaction to be signed if no keyring pair is passed.

  • burnNft(nftId: number, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    burnNft

    summary

    Remove an NFT from the storage.

    Parameters

    • nftId: number

      The id of the NFT that need to be burned from the storage.

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data.

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made.

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction, or an unsigned transaction to be signed if no keyring pair is passed.

  • changeEndpoint(chain: string): void
  • name

    changeEndpoint

    summary

    Set the chainEndpoint to specified parameter.

    Parameters

    • chain: string

      Chain endpoint

    Returns void

  • checkBalanceForTransfer(address: string, value: number | BN): Promise<void>
  • name

    checkBalanceForTransfer

    summary

    Check if an account as enough funds to ensure a transfer

    Parameters

    • address: string

      Public address of the account to check balance for transfer

    • value: number | BN

      Token amount to transfer

    Returns Promise<void>

  • checkBalanceToMintNft(address: string): Promise<void>
  • name

    checkBalanceToMintNft

    summary

    Checks if an account as enough funds to support the NFT mint fee.

    Parameters

    • address: string

      Public address of the account to check balance to mint an NFT.

    Returns Promise<void>

  • checkCollectionOffchainDataLimit(offchainLength: number): Promise<void>
  • name

    checkCollectionOffchainDataLimit

    summary

    Checks if the collectionOffchain data length is lower than maximum authorized length.

    Parameters

    • offchainLength: number

      Offchain data length.

    Returns Promise<void>

  • checkCollectionSizeLimit(limit: number): Promise<void>
  • name

    checkCollectionSizeLimit

    summary

    Checks if the collection limit is lower than maximum limit.

    Parameters

    • limit: number

      Collection limit.

    Returns Promise<void>

  • checkFundsForTxFees(tx: SubmittableExtrinsic<"promise", ISubmittableResult>): Promise<void>
  • name

    checkFundsForTxFees

    summary

    Check if a signed transaction sender has enough funds to pay transaction gas fees on transaction submit.

    Parameters

    • tx: SubmittableExtrinsic<"promise", ISubmittableResult>

      Signed transaction object

    Returns Promise<void>

  • checkNftOffchainDataLimit(offchainLength: number): Promise<void>
  • name

    checkNftOffchainDataLimit

    summary

    Checks if the nftOffchain data length is lower than maximum authorized length.

    Parameters

    • offchainLength: number

      Offchain data length.

    Returns Promise<void>

  • checkTxAvailable(txPallet: string, txExtrinsic: string): Promise<boolean>
  • name

    checkTxAvailable

    summary

    Check if the pallet module and the subsequent extrinsic method exist in the Api instance.

    Parameters

    • txPallet: string

      Pallet module of the transaction

    • txExtrinsic: string

      Subsequent extrinsic method of the transaction

    Returns Promise<boolean>

    Boolean, true if the pallet module and the subsequent extrinsic method exist, throw an Error otherwise

  • closeCollection(collectionId: number, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    closeCollection

    summary

    Makes the collection closed.

    Parameters

    • collectionId: number

      The collection id to close.

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data. Must be the owner of the collection.

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made.

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction, or an unsigned transaction to be signed if no keyring pair is passed.

  • compareData<T>(data: T, attribute: string, value: T): Promise<void>
  • name

    compareData

    summary

    Compares the current value of a extrinsic attribute to the new one to avoid running a transaction if they are equal.

    Type parameters

    • T

    Parameters

    • data: T

      Current values to be compared.

    • attribute: string

      Attribute of the element to compare. (ex: nft.royalty, marketplace.commission_fee)

    • value: T

      New value to be compared to current data.

    Returns Promise<void>

  • consts(section: string, constantName: string): Promise<Codec>
  • name

    consts

    summary

    Generic function to get a chain constant.

    example

    console.log(api.consts.balances.existentialDeposit.toString())
    

    Parameters

    • section: string

      The section required to get the chain constant (eg. "balances")

    • constantName: string

      The constantName depending on the section (eg. "existentialDeposit")

    Returns Promise<Codec>

    The constant value

  • createCollection(collectionOffchainData: string, collectionLimit?: null | number, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    createCollection

    summary

    Create a new collection with the provided details.

    Parameters

    • collectionOffchainData: string

      Any offchain data to add to the collection.

    • collectionLimit: null | number = null

      Number max of NFTs in collection.

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data.

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made.

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction, or an unsigned transaction to be signed if no keyring pair is passed.

  • createNft(nftOffchainData: string, nftRoyalty: number, nftCollectionId?: null | number, nftIsSoulbound?: boolean, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    createNft

    summary

    Create a new NFT on blockchain with the provided details.

    Parameters

    • nftOffchainData: string

      Any offchain data to add to the NFT. (ex: a link, ipfs data, a text)

    • nftRoyalty: number

      Royalty can be set from 0% to 100%.

    • nftCollectionId: null | number = null

      The collection id to which the NFT will belong.

    • nftIsSoulbound: boolean = false

      Boolean that lock transfert after creation.

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data.

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made.

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction, or an unsigned transaction to be signed if no keyring pair is passed.

  • createTxHex(txPallet: string, txExtrinsic: string, txArgs?: any[]): Promise<`0x${string}`>
  • name

    createTxHex

    summary

    Create a transaction in hex format.

    Parameters

    • txPallet: string

      Pallet module of the transaction

    • txExtrinsic: string

      Subsequent extrinsic method of the transaction

    • txArgs: any[] = []

      Arguments of the transaction

    Returns Promise<`0x${string}`>

    Hex value of the transaction

  • delegateNft(nftId: number, nftRecipient?: null | string, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    delegateNft

    summary

    Delegate an NFT to a recipient (does not change ownership).

    Parameters

    • nftId: number
    • nftRecipient: null | string = null

      Address to which the NFT will be delegated. If not specified NFT will be undelegated.

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data.

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made.

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction, or an unsigned transaction to be signed if no keyring pair is passed.

  • formatBalance(input: BN, withSi?: boolean, withSiFull?: boolean, withUnit?: boolean, unit?: string): Promise<string>
  • name

    formatBalance

    summary

    Format balance from BN to number.

    Parameters

    • input: BN

      BN input.

    • withSi: boolean = true

      Format with SI, i.e. m/M/etc.

    • withSiFull: boolean = false

      Format with full SI, i.e. mili/Mega/etc.

    • withUnit: boolean = true

      Add the unit (useful in Balance formats).

    • unit: string = "CAPS"

      Token Unit.

    Returns Promise<string>

    Formatted balance with SI and unit notation.

  • formatRoyalty(royalty: number): Promise<number>
  • name

    formatRoyalty

    summary

    Checks that royalty is in range 0 to 100 and format to permill.

    Parameters

    • royalty: number

      Number in range from 0 to 100 with max 4 decimals.

    Returns Promise<number>

    The royalty in permill format.

  • generateSeed(): Promise<{ address: string; seed: string }>
  • name

    generateSeed

    summary

    Generate a new account

    Returns Promise<{ address: string; seed: string }>

    An object with the seed and the public address

  • getApiEndpoint(): string
  • name

    getApiEndpoint

    summary

    Returns the wss api endpoint

    Returns string

    String, the api endpoint connected with.

  • getBalances(address: string): Promise<{ feeFrozen: BN; free: BN; miscFrozen: BN; reserved: BN }>
  • name

    getBalances

    summary

    Get the balances of an account including free, reserved, miscFrozen and feeFrozen balances as well as the total.

    Parameters

    • address: string

      Public address of the account to get balances

    Returns Promise<{ feeFrozen: BN; free: BN; miscFrozen: BN; reserved: BN }>

    The balances of the account

  • getCapsuleMintFee(): Promise<BN>
  • name

    getCapsuleMintFee

    summary

    Get the amount of caps needed to mint a capsule.

    Returns Promise<BN>

    Capsule mint fee

  • name

    getCollectionData

    summary

    Provides the data related to one NFT collection. ex:{owner, creator, offchainData, limit, isClosed(...)}

    Parameters

    • collectionId: number

      The collection id.

    Returns Promise<ICollectionData>

    A JSON object with data of a single NFT collection.

  • getCollectionOffchainDataLimit(): Promise<number>
  • name

    getCollectionOffchainDataLimit

    summary

    Provides the maximum offchain data length.

    Returns Promise<number>

    Number.

  • getCollectionSizeLimit(): Promise<number>
  • name

    getCollectionSizeLimit

    summary

    Maximum collection length.

    Returns Promise<number>

    Number.

  • getFreeBalance(address: string): Promise<BN>
  • name

    getFreeBalance

    summary

    Get the free balance of an account

    Parameters

    • address: string

      Public address of the account to get free balance for

    Returns Promise<BN>

    The free balance of the account

  • getKeyringFromSeed(seed: string): Promise<KeyringPair>
  • name

    getKeyringFromSeed

    summary

    Create a keyring from a seed

    Parameters

    • seed: string

    Returns Promise<KeyringPair>

    A keyring pair

  • getMarketplaceMintFee(): Promise<BN>
  • name

    getMarketplaceMintFee

    summary

    Get the amount of caps needed to mint a marketplace.

    Returns Promise<BN>

    Marketplace mint fee

  • getNextCollectionId(): Promise<number>
  • name

    getNextCollectionId

    summary

    Get the next collection Id available.

    Returns Promise<number>

    Number.

  • getNextNftId(): Promise<number>
  • name

    getNextNftId

    summary

    Get the next NFT Id available.

    Returns Promise<number>

    Number.

  • getNftData(nftId: number): Promise<INftData>
  • name

    getNftData

    summary

    Provides the data related to one NFT.

    Parameters

    • nftId: number

      The NFT id.

    Returns Promise<INftData>

    A JSON object with the NFT data. ex:{owner, creator, offchainData, (...)}

  • getNftMintFee(): Promise<BN>
  • name

    getNftMintFee

    summary

    Fee to mint an NFT (extra fee on top of the tx fees).

    Returns Promise<BN>

    NFT mint fee.

  • getNftOffchainDataLimit(): Promise<number>
  • name

    getNftOffchainDataLimit

    summary

    Provides the maximum offchain data length.

    Returns Promise<number>

    Number.

  • getRawApi(): Promise<ApiPromise>
  • name

    getRawApi

    summary

    Get initialized substrate Api instance.

    Returns Promise<ApiPromise>

    Promise containing the actual Api instance, a wrapper around the RPC and interfaces of the chain.

  • getTxFees(txHex: `0x${string}`, address: string): Promise<BN>
  • name

    getTxFees

    summary

    Get the total fees for a transaction hex.

    Parameters

    • txHex: `0x${string}`

      Hex of the transaction

    • address: string

      Public address of the sender

    Returns Promise<BN>

    Total estimated fee which is the sum of the chain gas fee and the treasury fee

  • getTxGasFee(txHex: `0x${string}`, address: string): Promise<Balance>
  • name

    getTxGasFee

    summary

    Get the gas fee estimation for a transaction.

    Parameters

    • txHex: `0x${string}`

      Transaction hex

    • address: string

      Public address of the sender

    Returns Promise<Balance>

    Transaction fee estimation

  • getTxTreasuryFee(txHex: `0x${string}`): Promise<BN>
  • name

    getTxTreasuryFee

    summary

    Get the fee needed by Ternoa treasury for specific transaction services.

    description

    Some Ternoa's services required additional fees on top of chain gas fees, for example: minting a marketplace, minting an NFT or creating a capsule.

    Parameters

    • txHex: `0x${string}`

      Transaction hex

    Returns Promise<BN>

    Fee estimation

  • hexToString(_value?: null | string): string
  • name

    hexToU8a

    summary

    Creates a Uint8Array object from a hex string.

    description

    Hex input values return the actual bytes value converted to a string. Anything that is not a hex string (including the 0x prefix) throws an error.

    example

    import { hexToString } from '@polkadot/util';

    hexToU8a('0x68656c6c6f'); // hello

    Parameters

    • Optional _value: null | string

    Returns string

  • hexToU8a(_value?: null | string, bitLength?: number): Uint8Array
  • name

    hexToU8a

    summary

    Creates a Uint8Array object from a hex string.

    description

    null inputs returns an empty Uint8Array result. Hex input values return the actual bytes value converted to a Uint8Array. Anything that is not a hex string (including the 0x prefix) throws an error.

    example

    import { hexToU8a } from '@polkadot/util';

    hexToU8a('0x80001f'); // Uint8Array([0x80, 0x00, 0x1f])
    hexToU8a('0x80001f', 32); // Uint8Array([0x00, 0x80, 0x00, 0x1f])

    Parameters

    • Optional _value: null | string
    • Optional bitLength: number

    Returns Uint8Array

  • isApiConnected(): boolean
  • name

    isApiConnected

    summary

    Check if the Api instance existed and if it is connected.

    Returns boolean

    Boolean, true if the underlying provider is connected, false otherwise

  • isTransactionSuccess(result: ISubmittableResult): { indexInterrupted?: number; success: boolean }
  • name

    isTransactionSuccess

    summary

    Check if a transaction result is successful.

    Parameters

    • result: ISubmittableResult

      Generic result passed as a parameter in a transaction callback

    Returns { indexInterrupted?: number; success: boolean }

    Object containing a boolean success field indicating if transaction is successful and a indexInterrupted field to indicate where the transaction stopped in case of a batch

    • Optional indexInterrupted?: number
    • success: boolean
  • isValidAddress(address: string): boolean
  • name

    isValidAddress

    summary

    Check if an address is a valid Ternoa address.

    Parameters

    • address: string

    Returns boolean

    Boolean, true if the address is valid, false otherwise

  • isValidSignature(signedMessage: string, signature: `0x${string}`, address: string): boolean
  • name

    isValidSignature

    summary

    Check if a message has been signed by the passed address.

    Parameters

    • signedMessage: string

      Message to check.

    • signature: `0x${string}`
    • address: string

      Address to verify the signer.

    Returns boolean

    Boolean, true if the address signed the message, false otherwise

  • limitCollection(collectionId: number, setCollectionLimit: number, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    limitCollection

    summary

    Set the maximum number (limit) of nfts in the collection.

    Parameters

    • collectionId: number

      The collection id to close.

    • setCollectionLimit: number

      Number max of NFTs in collection.

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data.

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made.

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction, or an unsigned transaction to be signed if no keyring pair is passed.

  • query(module: string, call: string, args?: any[], callback?: (result: any) => void): Promise<Codec>
  • name

    query

    summary

    Generic function to make a chain query.

    example

    // you can query without any args
    const data = await query('balances', 'totalIssuance');

    // or you can pass args parameters to the storage query
    const data = await query('system', 'account', ['5GesFQSwhmuMKAHcDrfm21Z5xrq6kW93C1ch2Xosq1rXx2Eh']);

    Parameters

    • module: string

      The section required to make the chain query (eg. "system")

    • call: string

      The call depending on the section (eg. "account")

    • args: any[] = []

      Array of args for the call

    • Optional callback: (result: any) => void

      Callback function to enable subscription, if not given, no subscription will be made

        • (result: any): void
        • Parameters

          • result: any

          Returns void

    Returns Promise<Codec>

    Result of the query storage call

  • runTx(txPallet: string, txExtrinsic: string, txArgs: any[], keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    runTx

    summary

    Create, sign and submit a transaction on blockchain.

    Parameters

    • txPallet: string

      Pallet module of the transaction

    • txExtrinsic: string

      Subsequent extrinsic method of the transaction

    • txArgs: any[]

      Arguments of the transaction

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data, if not given, an unsigned transaction to be signed will be returned

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction, or an unsigned transaction to be signed if no keyring pair is passed

  • safeDisconnect(): Promise<void>
  • name

    safeDisconnect

    summary

    Disconnect safely from the underlying provider, halting all network traffic

    Returns Promise<void>

  • setRoyalty(nftId: number, nftRoyaltyFee: number, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    setRoyalty

    summary

    Set the royalty of an NFT.

    Parameters

    • nftId: number

      The id of the NFT that need to be burned from the storage.

    • nftRoyaltyFee: number

      Number in range from 0 to 100 with max 4 decimals.

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data.

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made.

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction, or an unsigned transaction to be signed if no keyring pair is passed.

  • signTx(keyring: IKeyringPair, txHex: `0x${string}`, nonce?: number, validity?: number): Promise<`0x${string}`>
  • name

    signTx

    summary

    Sign a transaction.

    Parameters

    • keyring: IKeyringPair

      Keyring pair to sign the data

    • txHex: `0x${string}`

      Tx hex of the unsigned transaction to be signed

    • nonce: number = -1

      Nonce to be used in the transaction, default to next available

    • validity: number = 0

      Number of blocks during which transaction can be submitted, default to immortal

    Returns Promise<`0x${string}`>

    Hex value of the signed transaction

  • stringToHex(value?: AnyString): HexString
  • name

    stringToHex

    summary

    Creates a hex string from a utf-8 string

    description

    String input values return the actual encoded hex value.

    example

    import { stringToHex } from '@polkadot/util';

    stringToU8a('hello'); // 0x68656c6c6f

    Parameters

    • Optional value: AnyString

    Returns HexString

  • submitTx(txHex: `0x${string}`, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    submitTx

    summary

    Send a signed transaction on the blockchain.

    Parameters

    • txHex: `0x${string}`

      Transaction hex of the signed transaction to be submitted

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction

  • transfer(to: string, value: number | BN, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    transfer

    summary

    Transfer some liquid free balance to another account

    Parameters

    • to: string

      Public address of the account to transfer amount to

    • value: number | BN

      Token amount to transfer

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction or the hex value of the signable tx

  • transferAll(to: string, keepAlive?: boolean, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    transferAll

    summary

    Transfer the entire transferable balance from the caller account

    Parameters

    • to: string

      Public address of the account to transfer amount to

    • keepAlive: boolean = true

      Ensure that the transfer does not kill the account, it retains the Existential Deposit

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction or the hex value of the signable tx

  • transferKeepAlive(to: string, value: number | BN, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    transferKeepAlive

    summary

    Transfer some liquid free balance to another account with a check that the transfer will not kill the origin account

    Parameters

    • to: string

      Public address of the account to transfer amount to

    • value: number | BN

      Token amount to transfer

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction or the hex value of the signable tx

  • transferNft(nftId: number, nftRecipient: string, keyring?: IKeyringPair, callback?: (result: ISubmittableResult) => void): Promise<`0x${string}`>
  • name

    transferNft

    summary

    Transfer an NFT from an account to another one.

    Parameters

    • nftId: number

      The id of the NFT that need to be burned from the storage.

    • nftRecipient: string

      Address that will received the ownership of the NFT.

    • Optional keyring: IKeyringPair

      Keyring pair to sign the data.

    • Optional callback: (result: ISubmittableResult) => void

      Callback function to enable subscription, if not given, no subscription will be made.

        • (result: ISubmittableResult): void
        • Parameters

          • result: ISubmittableResult

          Returns void

    Returns Promise<`0x${string}`>

    Hash of the transaction, or an unsigned transaction to be signed if no keyring pair is passed.

  • u8aToHex(value?: null | Uint8Array, bitLength?: number, isPrefixed?: boolean): HexString
  • name

    u8aToHex

    summary

    Creates a hex string from a Uint8Array object.

    description

    UInt8Array input values return the actual hex string. null or undefined values returns an 0x string.

    example

    import { u8aToHex } from '@polkadot/util';

    u8aToHex(new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0xf])); // 0x68656c0f

    Parameters

    • Optional value: null | Uint8Array
    • Optional bitLength: number
    • Optional isPrefixed: boolean

    Returns HexString

  • unFormatBalance(_input: number): Promise<BN>
  • name

    unFormatBalance

    summary

    Format balance from number to BN.

    Parameters

    • _input: number

      Number input

    Returns Promise<BN>

    BN output

Generated using TypeDoc