Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IApiClient

Api client interface that manages multiple chains' api client and expose all functions.

Hierarchy

  • IApiClient

Implemented by

Index

Methods

addCoin

buildTransaction

  • buildTransaction(coinType: string, from: string, to: string, value: BigNumber, options: any): Promise<any>
  • Build up transaction object to sign. transaction nonce should be encapsulated into transaction object.

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • from: string

      transaction sender

    • to: string

      amount receiver. this field isn't alway transaction's to field. if the transaction is a token transfer, transaction to field is token contract address, this field is encoded in contract method parameters.

    • value: BigNumber

      amount value. this field isn't alwasy transaction's value field. if the transaction is a token transfer, transaction value field is zero, this field is encoded in contract method parameters.

    • options: any

      common options could be: gas limit, gas price, contract address, is token transfer, data, etc.

    Returns Promise<any>

getAccountTokenBalance

  • getAccountTokenBalance(coinType: string, contractAddress: string, address: string): Promise<any>
  • Get token balance of the given account

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • contractAddress: string

      token contract address

    • address: string

      account address

    Returns Promise<any>

getAccountTokenTransferHistory

  • getAccountTokenTransferHistory(coinType: string, address: string, symbolAddress: string, page?: number, size?: number, timestamp?: number): Promise<any>
  • Get token transfer history of the given account. For pagination, user could use combination of page + size or timestamp + size.

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • address: string

      account address

    • symbolAddress: string

      token contract address

    • Optional page: number

      page number

    • Optional size: number

      number of transfer records in this page

    • Optional timestamp: number

      get transfer records earlier than this timestamp

    Returns Promise<any>

getAccountTokens

  • getAccountTokens(coinType: string, address: string): Promise<any>
  • Get tokens whose balance > 0 for the given account.

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • address: string

      account address

    Returns Promise<any>

getBalance

  • getBalance(coinType: string, address: string): Promise<any>
  • Get balance of the given account

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • address: string

      account's public address

    Returns Promise<any>

    balance in hex string or biginteger

getBlockByNumber

  • getBlockByNumber(coinType: string, blockNumber: string): Promise<any>
  • Get block information by the given block number

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • blockNumber: string

      block number. integer or hex string depends on kernel rpc implementation.

    Returns Promise<any>

    depends on different chains' block structure

getBlockNumber

  • getBlockNumber(coinType: string): Promise<any>
  • Get latest block number of the given chain

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    Returns Promise<any>

    latest block number whose type should be biginteger or hex string

getCoinPrices

  • getCoinPrices(currency: string): Promise<Array<CoinPrice>>

getTokenDetail

  • getTokenDetail(coinType: string, contractAddress: string): Promise<any>
  • Get token details. In general token details contains: contractAddress, symbol, name, tokenDecimals

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • contractAddress: string

      token contract address

    Returns Promise<any>

    toke details

getTokenIconUrl

  • getTokenIconUrl(coinType: string, tokenSymbol: string, contractAddress: string): string
  • Get token icon url.

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • tokenSymbol: string

      token symbol

    • contractAddress: string

      token creation contract address

    Returns string

    token icon url

getTopTokens

  • getTopTokens(coinType: string, topN?: number): Promise<any>

getTransactionExplorerUrl

  • getTransactionExplorerUrl(coinType: string, hash: any): string
  • Get web page url that can display transaction details.

    The url should be able to access from web browser by plain HTTP GET request.

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • hash: any

      transaction hash

    Returns string

    web page url that display transaction details

getTransactionStatus

  • getTransactionStatus(coinType: string, hash: string): Promise<any>
  • Get transation status

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • hash: string

      transaction hash

    Returns Promise<any>

    transaction status, depends on different api client's implementation

getTransactionsByAddress

  • getTransactionsByAddress(coinType: string, address: string, page: number, size: number, timestamp?: number): Promise<any>
  • Get the given account's recent transactions by page.

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • address: string

      account's public address

    • page: number

      page number

    • size: number

      how mnay transactions to get in this page

    • Optional timestamp: number

    Returns Promise<any>

removeCoin

  • removeCoin(coinType: string): boolean

sameAddress

  • sameAddress(coinType: string, address1: string, address2: string): boolean
  • Check if two address are the same account.

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • address1: string

      first address to compare

    • address2: string

      second address to compare

    Returns boolean

    if two address are the same account.

searchTokens

  • searchTokens(coinType: string, keyword: string): Promise<any>

sendTransaction

  • sendTransaction<T>(coinType: string, unsignedTx: any, signer: T, signerParams: any): Promise<any>
  • Broadcast transaction.

    Type parameters

    Parameters

    • coinType: string

      coin type name you specified in addCoin

    • unsignedTx: any

      unsigned transaction object. User can call buildTransaction to get unsigned transaction.

    • signer: T

      implementation of IkeystoreSigner

    • signerParams: any

      sign parameters for differernt implementation IkeystoreSigner

    Returns Promise<any>

    transaction hash