Class default

The main class of the ain-js SDK library.

Constructors

  • Creates a new Ain object.

    Parameters

    • providerUrl: string

      The endpoint URL of the network provider.

    • Optional eventHandlerUrl: string

      The endpoint URL of the event handler websocket server.

    • Optional chainId: number

      The chain ID of the blockchain network.

    • Optional ainOptions: AinOptions

      The options of the class.

    Returns default

Properties

axiosConfig: undefined | AxiosRequestConfig

The axios request config object.

chainId: number

The chain ID of the blockchain network.

The database object.

The event manager object.

eventHandlerUrl?: null | string

The endpoint Url of the event handler websocket server.

The homorphic encryption object.

net: default

The network object.

provider: default

The network provider object.

rawResultMode: boolean

The raw result mode option.

signer: Signer

The signer object.

wallet: default

The wallet object.

Accessors

  • get utils(): __module
  • Getter for ain-util library.

    Returns __module

Methods

  • Sends a transaction that deposits AIN for consensus staking.

    Parameters

    Returns Promise<any>

  • Fetches a block with a block hash.

    Parameters

    • blockHash: string

      The block hash.

    • Optional returnTransactionObjects: boolean

      If it's true, returns a block with full transaction objects. Otherwise, returns a block with only transaction hashes.

    Returns Promise<Block>

  • Fetches a block with a block number.

    Parameters

    • blockNumber: number

      The block number.

    • Optional returnTransactionObjects: boolean

      If it's true, returns a block with full transaction objects. Otherwise, returns a block with only transaction hashes.

    Returns Promise<Block>

  • Fetches block headers with a block number range.

    Parameters

    • from: number

      The begining block number (inclusive).

    • to: number

      The ending block number (exclusive).

    Returns Promise<Block[]>

  • Fetches blocks with a block number range.

    Parameters

    • from: number

      The begining block number (inclusive).

    • to: number

      The ending block number (exclusive).

    Returns Promise<Block[]>

  • Fetches block transaction count with a block hash.

    Parameters

    • hash: string

      The block hash.

    Returns Promise<Number>

  • Fetches block transaction count with a block number.

    Parameters

    • number: number

      The block number.

    Returns Promise<Number>

  • Fetches the amount of AIN currently staked for participating in consensus protocol.

    Parameters

    • Optional account: string

      The account to fetch the value with. If not specified, the default account of the signer is used.

    Returns Promise<number>

  • Fetches pending transactions.

    Returns Promise<any>

  • Fetches the block proproser's address of a block with a block hash.

    Parameters

    • blockHash: string

      The block hash.

    Returns Promise<string>

  • Fetches the block proproser's address of a block with a block number.

    Parameters

    • blockNumber: number

      The block number.

    Returns Promise<string>

  • Fetches a blockchain app's state usage information with an app name.

    Parameters

    • appName: string

      The blockchain app name.

    Returns Promise<StateUsageInfo>

  • Fetches a transaction's information with a block hash and an index.

    Parameters

    • blockHash: string

      The block hash.

    • index: number

      The transaction index in the block

    Returns Promise<TransactionInfo>

  • Fetches a transaction's information with a block hash and an index.

    Parameters

    • blockNumber: number

      The block number.

    • index: number

      The transaction index in the block

    Returns Promise<TransactionInfo>

  • Fetches a transaction's information with a transaction hash.

    Parameters

    • transactionHash: string

      The transaction hash.

    Returns Promise<TransactionInfo>

  • Fetches transaction pool size utilization.

    Returns Promise<any>

  • Fetches the information of the given validator address.

    Parameters

    • address: string

      The validator address.

    Returns Promise<any>

  • Fetches the validator list of a block with a block hash.

    Parameters

    • blockHash: string

      The block hash.

    Returns Promise<any>

  • Fetches the validator list of a block with a block number.

    Parameters

    • blockNumber: number

      The block number.

    Returns Promise<any>

  • Sends a signed transaction to the network.

    Parameters

    • signature: string

      The signature of the transaction.

    • txBody: TransactionBody

      The transaction body.

    • isDryrun: boolean = false

      The dryrun option.

    Returns Promise<any>

  • Signs and sends a transaction to the network.

    Parameters

    • transactionObject: TransactionInput

      The transaction input object.

    • isDryrun: boolean = false

      The dryrun option.

    Returns Promise<any>

  • Signs and sends multiple transactions in a batch to the network.

    Parameters

    • transactionObjects: TransactionInput[]

      The list of the transaction input objects.

    Returns Promise<any>

  • Sets a new provider.

    Parameters

    • providerUrl: string

      The endpoint URL of the network provider. e.g. http://localhost:8081, https://testnet-api.ainetwork.ai

    • Optional eventHandlerUrl: string

      The endpoint URL of the event handler websocket server. e.g. ws://localhost:5100, wss://testnet-event.ainetwork.ai

    • Optional chainId: number

      The chain ID of the blockchain network. e.g. 0 for local or testnet, and 1 for mainnet

    • Optional axiosConfig: AxiosRequestConfig

      The axios request config.

    Returns void

  • Sets a new signer.

    Parameters

    • signer: Signer

      The signer to set.

    Returns void

  • A base function for all staking related database changes. It builds a deposit/withdraw transaction and sends the transaction by calling sendTransaction().

    Parameters

    • path: string

      The path to set a value with.

    • transactionObject: ValueOnlyTransactionInput

      The transaction input object.

    • isDryrun: boolean = false

      The dryrun option.

    Returns Promise<any>

  • Sends a transaction that withdraws AIN for consensus staking.

    Parameters

    Returns Promise<any>

  • Checks whether an object is an instance of TransactionBody interface.

    Parameters

    • object: any

      The object to check.

    Returns object is TransactionBody