Options
All
  • Public
  • Public/Protected
  • All
Menu

ternoa-js

Index

Namespaces

Enumerations

Classes

Interfaces

Type aliases

Functions

Type aliases

AccountListType: MarketplaceConfigAction.Noop | MarketplaceConfigAction.Remove | { set: string[] }
BalanceType: BN
CommissionFeeType: MarketplaceConfigAction.Noop | MarketplaceConfigAction.Remove | Marketplace.SetFeeType
INftData: { collectionId: number | undefined; creator: string; offchainData: string; owner: string; royalty: number; state: Nft.INftState }

Type declaration

  • collectionId: number | undefined
  • creator: string
  • offchainData: string
  • owner: string
  • royalty: number
  • state: Nft.INftState
INftState: { isCapsule: boolean; isDelegated: boolean; isSecret: boolean; isSoulbound: boolean; listedForSale: boolean }

Type declaration

  • isCapsule: boolean
  • isDelegated: boolean
  • isSecret: boolean
  • isSoulbound: boolean
  • listedForSale: boolean
ListingFeeType: MarketplaceConfigAction.Noop | MarketplaceConfigAction.Remove | Marketplace.SetFeeType
MarketplaceDataType: { accountList: string[] | undefined; commissionFee: Marketplace.IFeeType | undefined; kind: string; listingFee: Marketplace.IFeeType | undefined; offchainData: string | undefined; owner: string }

Type declaration

OffchainDataType: MarketplaceConfigAction.Noop | MarketplaceConfigAction.Remove | { set: string }
SetFeeType: { set: RequireOnlyOne<Marketplace.IFeeType> }

Type declaration

TransactionHashType: `0x${string}`

Functions

  • name

    addNftToCollection

    summary

    Adds an NFT to an existing collection.

    Parameters

    • nft_id: number

      The ID of the NFT.

    • collection_id: number

      The ID of the Collection.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.NFTAddedToCollectionEvent>

    NFTAddedToCollectionEvent Blockchain event.

  • addNftToCollectionTx(nft_id: number, collection_id: number): Promise<`0x${string}`>
  • name

    addNftToCollectionTx

    summary

    Creates an unsigned unsubmitted Add-NFT-To-Collection Transaction Hash.

    Parameters

    • nft_id: number

      The ID of the NFT.

    • collection_id: number

      The ID of the Collection.

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

    Unsigned unsubmitted Add-NFT-To-Collection Transaction Hash. The Hash is only valid for 5 minutes.

  • name

    balancesTransfer

    summary

    Transfers some liquid free balance to another account.

    Parameters

    • to: string

      Public address of the account to transfer the amount to.

    • value: number | BN

      Token amount to transfer.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.BalancesTransferEvent>

    BalancesTransferEvent Blockchain event.

  • balancesTransferAll(to: string, keepAlive?: boolean, keyring: IKeyringPair, waitUntil: WaitUntil): Promise<Events.BalancesTransferEvent>
  • name

    balancesTransferAll

    summary

    Transfers the entire transferable balance from the caller account.

    Parameters

    • to: string

      Public address of the account to transfer the amount to.

    • keepAlive: boolean = true

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

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.BalancesTransferEvent>

    BalancesTransferEvent Blockchain event.

  • balancesTransferAllTx(to: string, keepAlive?: boolean): Promise<`0x${string}`>
  • name

    balancesTransferAllTx

    summary

    Creates an unsigned unsubmitted Balance-TransfertAll Transaction Hash.

    Parameters

    • to: string

      Public address of the account to transfer the amount to.

    • keepAlive: boolean = true

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

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

    Unsigned unsubmitted Balance-TransfertAll Transaction Hash. The Hash is only valid for 5 minutes.

  • balancesTransferKeepAlive(to: string, value: number | BN, keyring: IKeyringPair, waitUntil: WaitUntil): Promise<Events.BalancesTransferEvent>
  • name

    balancesTransferKeepAlive

    summary

    Transfers 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 the amount to.

    • value: number | BN

      Token amount to transfer.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.BalancesTransferEvent>

    BalancesTransferEvent Blockchain event.

  • balancesTransferKeepAliveTx(to: string, value: number | BN): Promise<`0x${string}`>
  • name

    balancesTransferKeepAliveTx

    summary

    Creates an unsigned unsubmitted Balance-TransfertKeepAlive Transaction Hash.

    Parameters

    • to: string

      Public address of the account to transfer the amount to.

    • value: number | BN

      Token amount to transfer.

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

    Unsigned unsubmitted Balance-TransfertKeepAlive Transaction Hash. The Hash is only valid for 5 minutes.

  • balancesTransferTx(to: string, value: number | BN): Promise<`0x${string}`>
  • name

    balancesTransferTx

    summary

    Creates an unsigned unsubmitted Balance-Transfert Transaction Hash.

    Parameters

    • to: string

      Public address of the account to transfer the amount to.

    • value: number | BN

      Token amount to transfer.

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

    Unsigned unsubmitted Balance-Transfert Transaction Hash. The Hash is only valid for 5 minutes.

  • 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

  • blockNumberToDate(blockNumber: number): Promise<Date>
  • blockNumberToMsDuration(blockNumber: number, duration?: undefined | number): Promise<number>
  • name

    burnCollection

    summary

    Burns an existing collection. The collections needs to be empty before it can be burned.

    Parameters

    • id: number

      The ID of the Collection.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.CollectionBurnedEvent>

    CollectionBurnedEvent Blockchain event.

  • burnCollectionTx(id: number): Promise<`0x${string}`>
  • name

    burnCollectionTx

    summary

    Creates an unsigned unsubmitted Burn-Collection Transaction Hash.

    Parameters

    • id: number

      The ID of the Collection.

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

    Unsigned unsubmitted Burn-Collection Transaction Hash. The Hash is only valid for 5 minutes.

  • name

    burnNft

    summary

    Burns an NFT from the chain.

    Parameters

    • id: number

      The ID of the NFT.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.NFTBurnedEvent>

    NFTBurnedEvent Blockchain event.

  • burnNftTx(id: number): Promise<`0x${string}`>
  • name

    burnNftTx

    summary

    Creates an unsigned unsubmitted Burn-NFT Transaction Hash.

    Parameters

    • id: number

      The ID of the NFT.

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

    Unsigned unsubmitted Burn-NFT Transaction Hash. The Hash is only valid for 5 minutes.

  • buyNft(nft_id: number, keyring: IKeyringPair, waitUntil: WaitUntil): Promise<Events.NFTSoldEvent>
  • name

    buyNft

    summary

    Buys an NFT on a marketplace.

    Parameters

    • nft_id: number

      NFT Id of the NFT for sale.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.NFTSoldEvent>

    NFTSoldEvent Blockchain event.

  • buyNftTx(nft_id: number): Promise<`0x${string}`>
  • name

    buyNftTx

    summary

    Creates an unsigned unsubmitted Buy-NFT Transaction Hash.

    Parameters

    • nft_id: number

      NFT Id of the NFT for sale.

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

    Unsigned unsubmitted Buy-NFT Transaction Hash. The Hash is only valid for 5 minutes.

  • checkBalanceForTransfer(address: string, value: number | BN): Promise<boolean>
  • 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 check before transfer.

    Returns Promise<boolean>

  • 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>

  • name

    closeCollection

    summary

    Closes the collection so that no new NFTs can be added.

    Parameters

    • id: number

      The ID of the Collection.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.CollectionClosedEvent>

    CollectionClosedEvent Blockchain event.

  • closeCollectionTx(id: number): Promise<`0x${string}`>
  • name

    closeCollectionTx

    summary

    Creates an unsigned unsubmitted Close-Collection Transaction Hash.

    Parameters

    • id: number

      The ID of the Collection.

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

    Unsigned unsubmitted Close-Collection Transaction Hash. The Hash is only valid for 5 minutes.

  • collectionIpfsUpload(data: Nft.ICollectionMetadata, ipfsGateway?: string, apiKey?: string): Promise<{ hash: any; name: any; size: any; type: string }>
  • name

    collectionIpfsUpload

    summary

    Uploads your Collection offchain metadata on IPFS.

    Parameters

    • data: Nft.ICollectionMetadata

      Offchain metadata to be uploaded. It must fit the ICollectionMetadata interface format with a name, description, profileFile and a bannerFile.

    • Optional ipfsGateway: string

      IPFS gateway to upload your file on. If not provided, default is https://ipfs.ternoa.dev/api/v0/add

    • Optional apiKey: string

      API Key to validate the upload on the IPFS gateway.

    Returns Promise<{ hash: any; name: any; size: any; type: string }>

    The data object with the hash to add as offchain metadata in the extrinsic.

  • consts(section: string, constantName: string): 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 Codec

    The constant value

  • createCollection(offchainData: string, limit?: undefined | number, keyring: IKeyringPair, waitUntil: WaitUntil): Promise<Events.CollectionCreatedEvent>
  • name

    createCollection

    summary

    Creates a collection.

    Parameters

    • offchainData: string

      Off-chain related Collection metadata. Can be an IPFS Hash, an URL or plain text.

    • limit: undefined | number = undefined

      Amount of NFTs that can be associated with this collection. This is optional

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.CollectionCreatedEvent>

    CollectionCreatedEvent Blockchain event.

  • createCollectionTx(offchainData: string, limit?: undefined | number): Promise<`0x${string}`>
  • name

    createCollectionTx

    summary

    Creates an unsigned unsubmitted Create-Collection Transaction Hash.

    Parameters

    • offchainData: string

      Off-chain related Collection metadata. Can be an IPFS Hash, an URL or plain text.

    • limit: undefined | number = undefined

      The maximum amount that NFTs that the collection can hold. This is optional

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

    Unsigned unsubmitted Create-Collection Transaction Hash. The Hash is only valid for 5 minutes.

  • name

    createMarketplace

    summary

    Creates a Marketplace on the chain.

    Parameters

    • kind: MarketplaceKind

      Kind of marketplace : It must be public or private.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.MarketplaceCreatedEvent>

    MarketplaceCreatedEvent Blockchain event.

  • createMarketplaceTx(kind: MarketplaceKind): Promise<`0x${string}`>
  • name

    createMarketplaceTx

    summary

    Creates an unsigned unsubmitted Create-Marketplace Transaction Hash.

    Parameters

    • kind: MarketplaceKind

      Kind of marketplace : It must be public or private.

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

    Unsigned unsubmitted Create-Marketplace Transaction Hash. The Hash is only valid for 5 minutes.

  • createNft(offchainData: string, royalty?: number, collectionId?: undefined | number, isSoulbound?: boolean, keyring: IKeyringPair, waitUntil: WaitUntil): Promise<Events.NFTCreatedEvent>
  • name

    createNft

    summary

    Creates an NFT on the chain.

    Parameters

    • offchainData: string

      Off-chain related NFT metadata. Can be an IPFS Hash, an URL or plain text.

    • royalty: number = 0

      Percentage of all second sales that the creator will receive. It's a decimal number in range [0, 100]. Default is 0.

    • collectionId: undefined | number = undefined

      The collection that this NFT will belong. Optional Parameter.

    • isSoulbound: boolean = false

      If true makes the NFT untransferable. Default is false.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.NFTCreatedEvent>

    NFTCreatedEvent Blockchain event.

  • createNftTx(offchainData: string, royalty?: number, collectionId?: undefined | number, isSoulbound?: boolean): Promise<`0x${string}`>
  • name

    createNftTx

    summary

    Creates an unsigned unsubmitted Create-NFT Transaction Hash.

    Parameters

    • offchainData: string

      Off-chain related NFT metadata. Can be an IPFS Hash, an URL or plain text.

    • royalty: number = 0

      Percentage of all second sales that the creator will receive. It's a decimal number in range [0, 100]. Default is 0.

    • collectionId: undefined | number = undefined

      The collection that this NFT will belong. Optional Parameter.

    • isSoulbound: boolean = false

      If true makes the NFT untransferable. Default is false.

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

    Unsigned unsubmitted Create-NFT Transaction Hash. The Hash is only valid for 5 minutes.

  • createTx(txPallet: string, txExtrinsic: string, txArgs?: any[]): Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>
  • name

    createTx

    summary

    Create a transaction.

    Parameters

    • txPallet: string

      Pallet module of the transaction

    • txExtrinsic: string

      Subsequent extrinsic method of the transaction

    • txArgs: any[] = []

      Arguments of the transaction

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

    Transaction object unsigned

  • 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

  • dateToBlockNumber(date: Date): Promise<number>
  • delegateNft(id: number, recipient?: undefined | string, keyring: IKeyringPair, waitUntil: WaitUntil): Promise<Events.NFTDelegatedEvent>
  • name

    delegateNft

    summary

    Delegates an NFT to someone.

    Parameters

    • id: number

      The ID of the NFT.

    • recipient: undefined | string = undefined

      Destination account. If set to undefined this functions acts as a way to undelegate a delegated NFT.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.NFTDelegatedEvent>

    NFTDelegatedEvent Blockchain event.

  • delegateNftTx(id: number, recipient?: undefined | string): Promise<`0x${string}`>
  • name

    delegateNftTx

    summary

    Creates an unsigned unsubmitted Delegate-NFT Transaction Hash.

    Parameters

    • id: number

      The ID of the NFT.

    • recipient: undefined | string = undefined

      Destination account. If set to undefined this functions acts as a way to undelegate a delegated NFT.

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

    Unsigned unsubmitted Delegate-NFT Transaction Hash. The Hash is only valid for 5 minutes.

  • 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.

  • 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<null | Nft.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.

  • getInitialMintFee(): Promise<BN>
  • name

    getInitialMintFee

    summary

    Original mint fee.

    Returns Promise<BN>

    Original NFT mint fee.

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

    getKeyringFromSeed

    summary

    Create a keyring from a seed

    Parameters

    • seed: string

    Returns Promise<KeyringPair>

    A keyring pair

  • getMarketplaceAccountSizeLimit(): Promise<number>
  • name

    getMarketplaceAccountSizeLimit

    summary

    The maximum number of accounts that can be stored inside the account list.

    Returns Promise<number>

    Number.

  • name

    getMarketplaceData

    summary

    Provides the data related to a marketplace.

    Parameters

    • marketplaceId: number

      The Markeplace id.

    Returns Promise<null | Marketplace.MarketplaceDataType>

    A JSON object with the marketplace data. ex:{owner, kind, accountList, (...)}

  • getMarketplaceMintFee(): Promise<BN>
  • name

    getMarketplaceMintFee

    summary

    Fee to mint a Marketplace. (extra fee on top of the tx fees).

    Returns Promise<BN>

    Marketplace mint fee.

  • getMarketplaceOffchainDataLimit(): Promise<number>
  • name

    getMarketplaceOffchainDataLimit

    summary

    Provides the maximum offchain data length.

    Returns Promise<number>

    Number.

  • getNextCollectionId(): Promise<number>
  • name

    getNextCollectionId

    summary

    Get the next collection Id available.

    Returns Promise<number>

    Number.

  • getNextMarketplaceId(): Promise<number>
  • getNextNftId(): Promise<number>
  • name

    getNextNftId

    summary

    Get the next NFT Id available.

    Returns Promise<number>

    Number.

  • getNftData(nftId: number): Promise<null | Nft.INftData>
  • name

    getNftData

    summary

    Provides the data related to one NFT.

    Parameters

    • nftId: number

      The NFT id.

    Returns Promise<null | Nft.INftData>

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

  • getNftMintFee(): Promise<BN>
  • name

    nftMintFee

    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(): ApiPromise
  • name

    getRawApi

    summary

    Get initialized substrate Api instance.

    Returns ApiPromise

    Raw polkadot api instance, a wrapper around the RPC and interfaces of the chain.

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

    getTotalBalance

    summary

    Get the total balance of an account (free & reserve balances)

    Parameters

    • address: string

      Public address of the account to get total balance for.

    Returns Promise<BN>

    The total balance of an account (free & reserve balances)

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

    getTransferrableBalance

    summary

    Get the transferrable balance of an account.

    Parameters

    • address: string

      Public address of the account to get transferrable balance for.

    Returns Promise<BN>

    The transferrable balance of an account.

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

    getTxAdditionalFee

    summary

    Get the fee needed by Ternoa 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

  • 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 initial fee and the optional additional fee

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

    getTxInitialFee

    summary

    Get the weight fee estimation for a transaction.

    Parameters

    • txHex: `0x${string}`

      Transaction hex

    • address: string

      Public address of the sender

    Returns Promise<Balance>

    Transaction 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

  • initializeApi(endpoint?: string): Promise<void>
  • name

    initializeApi

    summary

    Initialize substrate api with selected or default wss endpoint.

    description

    The default chainEndpoint is "wss://alphanet.ternoa.com"

    Parameters

    • Optional endpoint: string

    Returns Promise<void>

  • 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

  • name

    limitCollection

    summary

    Limits how many NFTs can be associated with this collection.

    Parameters

    • id: number

      The ID of the Collection.

    • limit: number

      Amount of NFTs that can be associated with this collection.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.CollectionLimitedEvent>

    CollectionLimitedEvent Blockchain event.

  • limitCollectionTx(id: number, limit: number): Promise<`0x${string}`>
  • name

    limitCollectionTx

    summary

    Creates an unsigned unsubmitted Limit-Collection Transaction Hash.

    Parameters

    • id: number

      The ID of the Collection.

    • limit: number

      Amount of NFTs that can be associated with this collection.

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

    Unsigned unsubmitted Limit-Collection Transaction Hash. The Hash is only valid for 5 minutes.

  • listNft(nft_id: number, marketplace_id: number, price: number | BN, keyring: IKeyringPair, waitUntil: WaitUntil): Promise<Events.NFTListedEvent>
  • name

    listNft

    summary

    Lists an NFT on a marketplace.

    Parameters

    • nft_id: number

      NFT Id of the NFT to be listed for sale.

    • marketplace_id: number

      Marketplace Id of the marketplace to list the NFT on.

    • price: number | BN

      Price of the NFT.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.NFTListedEvent>

    NFTListedEvent Blockchain event.

  • listNftTx(nft_id: number, marketplace_id: number, price: number | BN): Promise<`0x${string}`>
  • name

    listNftTx

    summary

    Creates an unsigned unsubmitted List-NFT Transaction Hash.

    Parameters

    • nft_id: number

      NFT Id of the NFT to be listed for sale.

    • marketplace_id: number

      Marketplace Id of the marketplace to list the NFT on.

    • price: number | BN

      Price of the NFT.

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

    Unsigned unsubmitted List-NFT Transaction Hash. The Hash is only valid for 5 minutes.

  • msDurationToBlockNumber(msDuration: number, duration?: undefined | number): Promise<number>
  • nftIpfsUpload(data: Nft.INFTMetadata, ipfsGateway?: string, apiKey?: string): Promise<{ hash: any; name: any; size: any; type: string }>
  • name

    nftIpfsUpload

    summary

    Uploads your NFT offchain metadata on IPFS.

    Parameters

    • data: Nft.INFTMetadata

      Offchain metadata to be uploaded. It must fit the INFTMetadata interface format with a description, file and title.

    • Optional ipfsGateway: string

      IPFS gateway to upload your file on. If not provided, default is https://ipfs.ternoa.dev/api/v0/add

    • Optional apiKey: string

      API Key to validate the upload on the IPFS gateway.

    Returns Promise<{ hash: any; name: any; size: any; type: string }>

    The data object with the hash to add as offchain metadata in the extrinsic.

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

    numberToBalance

    summary

    Format balance from number to BN.

    Parameters

    • _input: number

      Number input

    Returns Promise<BN>

    BN output

  • 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

  • safeDisconnect(): Promise<void>
  • name

    safeDisconnect

    summary

    Disconnect safely from the underlying provider, halting all network traffic

    Returns Promise<void>

  • name

    setMarketplaceConfiguration

    summary

    Set or Remove (Noop for No Operation) the marketplace parameters configuration : Commission fee, listing fee, the account list or any offchain datas.

    Each of the parameters of the marketplace, need one of the following type: Noop is set by default for each of the parameters. Noop : No Operation, nothing change. Removed : Current datas will be deleted. Set : Un object that update parameter value: Commission Fee and Listing Fee require a data type (flat or percentage) under format : { [MarketplaceConfigAction.Set]: { setFeeType: number || BN}} AccountList require an array of string: { [MarketplaceConfigAction.Set]: string[]} OffChainData require a string: { [MarketplaceConfigAction.Set]: string}

    Parameters

    • id: number

      Marketplace Id of the marketplace to update.

    • commissionFee: Marketplace.CommissionFeeType = MarketplaceConfigAction.Noop

      Commission when an NFT is sold on the marketplace : it can be set as flat (number) or as percentage. ex: { [MarketplaceConfigAction.Set]: { percentage: 10 } }

    • listingFee: Marketplace.ListingFeeType = MarketplaceConfigAction.Noop

      Fee when an NFT is added for sale to marketplace : it can be set as flat (number) or as percentage. ex: { [MarketplaceConfigAction.Set]: { flat: 5 } }

    • accountList: Marketplace.AccountListType = MarketplaceConfigAction.Noop

      A list of accounts : if the marketplace kind is private, it allows these accounts to sell NFT. If the marketplace kind is public, it bans these accounts from selling NFT.

    • offchainData: Marketplace.OffchainDataType = MarketplaceConfigAction.Noop

      Off-chain related marketplace metadata. Can be an IPFS Hash, an URL or plain text.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.MarketplaceConfigSetEvent>

    MarketplaceConfigSetEvent Blockchain event.

  • name

    setMarketplaceConfigurationTx

    summary

    Creates an unsigned unsubmitted Set-Marketplace-Configuration Transaction Hash.

    Each of the parameters of the marketplace, need one of the following type: Noop is set by default for each of the parameters. Noop : No Operation, nothing change. Removed : Current datas will be deleted. Set : Un object that update parameter value: Commission Fee and Listing Fee require a data type (flat or percentage) under format : { [MarketplaceConfigAction.Set]: { setFeeType: number || BN}} AccountList require an array of string: { [MarketplaceConfigAction.Set]: string[]} OffChainData require a string: { [MarketplaceConfigAction.Set]: string}

    Parameters

    • id: number

      Marketplace Id of the marketplace to update.

    • commissionFee: Marketplace.CommissionFeeType = MarketplaceConfigAction.Noop

      Commission when an NFT is sold on the marketplace : it can be set as flat (number) or as percentage. ex: { [MarketplaceConfigAction.Set]: { percentage: 10 } }

    • listingFee: Marketplace.ListingFeeType = MarketplaceConfigAction.Noop

      Fee when an NFT is added for sale to marketplace : it can be set as flat (number) or as percentage. ex: { [MarketplaceConfigAction.Set]: { flat: 5 } }

    • accountList: Marketplace.AccountListType = MarketplaceConfigAction.Noop

      A list of accounts : if the marketplace kind is private, it allows these accounts to sell NFT. If the marketplace kind is public, it bans these accounts from selling NFT.

    • offchainData: Marketplace.OffchainDataType = MarketplaceConfigAction.Noop

      Off-chain related marketplace metadata. Can be an IPFS Hash, an URL or plain text.

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

    MarketplaceConfigSetEvent Blockchain event.

  • name

    setMarketplaceKind

    summary

    Set the new marketplace kind on the chain.

    Parameters

    • id: number
    • kind: MarketplaceKind

      Kind of marketplace : It must be public or private.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.MarketplaceKindSetEvent>

    MarketplaceKindSetEvent Blockchain event.

  • setMarketplaceKindTx(id: number, kind: MarketplaceKind): Promise<`0x${string}`>
  • name

    setMarketplaceKindTx

    summary

    Creates an unsigned unsubmitted Set-Marketplace-Kind Transaction Hash.

    Parameters

    • id: number
    • kind: MarketplaceKind

      Kind of marketplace : It must be public or private.

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

    Unsigned unsubmitted Set-Marketplace-Kind Transaction Hash. The Hash is only valid for 5 minutes.

  • name

    setMarketplaceMintFee

    summary

    Set the new marketplace minting fee on the chain.

    Parameters

    • fee: number | BN

      Fee to mint a marketplace.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.MarketplaceMintFeeSetEvent>

    NFTSoldEvent Blockchain event.

  • setMarketplaceMintFeeTx(fee: number | BN): Promise<`0x${string}`>
  • name

    setMarketplaceMintFeeTx

    summary

    Creates an unsigned unsubmitted Set-Marketplace-Mint-Fee Transaction Hash.

    Parameters

    • fee: number | BN

      Fee to mint a marketplace.

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

    Unsigned unsubmitted Set-Marketplace-Mint-Fee Transaction Hash. The Hash is only valid for 5 minutes.

  • name

    setMarketplaceOwner

    summary

    Set the new marketplace owner on the chain.

    Parameters

    • id: number

      Marketplace Id of the marketplace to be transferred.

    • recipient: string

      Adress of the new marketplace owner.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.MarketplaceOwnerSetEvent>

    MarketplaceOwnerSetEvent Blockchain event.

  • setMarketplaceOwnerTx(id: number, recipient: string): Promise<`0x${string}`>
  • name

    setMarketplaceOwnerTx

    summary

    Creates an unsigned unsubmitted Set-Marketplace-Owner Transaction Hash.

    Parameters

    • id: number

      Marketplace Id of the marketplace to be transferred.

    • recipient: string

      Adress of the new marketplace owner.

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

    Unsigned unsubmitted Set-Marketplace-Owner Transaction Hash. The Hash is only valid for 5 minutes.

  • name

    setRoyalty

    summary

    Sets the royalty of an NFT.

    Parameters

    • id: number

      The ID of the NFT.

    • amount: number

      The new royalty value.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.NFTRoyaltySetEvent>

    NFTRoyaltySetEvent Blockchain event.

  • setRoyaltyTx(id: number, amount: number): Promise<`0x${string}`>
  • name

    setRoyaltyTx

    summary

    Creates an unsigned unsubmitted Set-Royalty Transaction Hash.

    Parameters

    • id: number

      The ID of the NFT.

    • amount: number

      The new royalty value.

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

    Unsigned unsubmitted Set-Royalty-NFT Transaction Hash. The Hash is only valid for 5 minutes.

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

    signTxHex

    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

  • sleep(ms: number): Promise<unknown>
  • 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

  • submitTxBlocking(tx: `0x${string}`, waitUntil: WaitUntil, keyring?: IKeyringPair): Promise<Events.BlockchainEvents>
  • name

    submitTxBlocking

    summary

    Signs and submits a transaction. It blocks the execution flow until the transaction is in a block or in a finalized block.

    Parameters

    • tx: `0x${string}`

      Unsigned unsubmitted transaction Hash. The Hash is only valid for 5 minutes.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    • Optional keyring: IKeyringPair

      Account that will sign the transaction if provided

    Returns Promise<Events.BlockchainEvents>

    A list of blockchain events related to an extrinsics execution.

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

    submitTxHex

    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

  • name

    submitTxNonBlocking

    summary

    Signs and submits a transaction in a non-blocking way. Signing is optional.

    Parameters

    • tx: `0x${string}`

      Unsigned unsubmitted transaction Hash. The Hash is only valid for 5 minutes.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    • Optional keyring: IKeyringPair

      Account that will sign the transaction if provided

    Returns Promise<[Blockchain.ConditionalVariable, Events.BlockchainEvents]>

    Returns a pair objects that are used to track the progress of the transaction execution. The first returned object is a conditional variable which can yield the information if the operation is finished. The second returned objects is an array of events which gets populated automatically once the operation is finished.

  • name

    transferNft

    summary

    Sends an NFT to someone.

    Parameters

    • id: number

      The ID of the NFT.

    • recipient: string

      Destination account.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.NFTTransferredEvent>

    NFTTransferredEvent Blockchain event.

  • transferNftTx(id: number, recipient: string): Promise<`0x${string}`>
  • name

    transferNftTx

    summary

    Creates an unsigned unsubmitted Transfer-NFT Transaction Hash.

    Parameters

    • id: number

      The ID of the NFT.

    • recipient: string

      Destination account.

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

    Unsigned unsubmitted Transfer-NFT Transaction Hash. The Hash is only valid for 5 minutes

  • 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

  • name

    unlistNft

    summary

    Unlists an NFT from a marketplace.

    Parameters

    • nft_id: number

      NFT Id of the NFT to be unlisted from sale.

    • keyring: IKeyringPair

      Account that will sign the transaction.

    • waitUntil: WaitUntil

      Execution trigger that can be set either to BlockInclusion or BlockFinalization.

    Returns Promise<Events.NFTUnlistedEvent>

    NFTUnlistedEvent Blockchain event.

  • unlistNftTx(nft_id: number): Promise<`0x${string}`>
  • name

    unlistNftTx

    summary

    Creates an unsigned unsubmitted Unlist-NFT Transaction Hash.

    Parameters

    • nft_id: number

      NFT Id of the NFT to be unlisted from sale.

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

    Unsigned unsubmitted Unlist-NFT Transaction Hash. The Hash is only valid for 5 minutes.

Generated using TypeDoc