Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Blockchain

Index

Type aliases

BalanceType: BN
TransactionHashType: `0x${string}`

Functions

  • 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

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

  • 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

  • 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

  • getApiEndpoint(): string
  • name

    getApiEndpoint

    summary

    Returns the wss api endpoint

    Returns string

    String, the api endpoint connected with.

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

  • 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

  • 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

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

  • 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>
  • 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: TernoaConstants.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<TernoaEvents.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: TernoaConstants.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, TernoaEvents.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.

Generated using TypeDoc