Client

Custom Thorchain Client

Parameters

  • params XChainClientParams
    • params.network (optional, default 'testnet')
    • params.phrase
    • params.clientUrl
    • params.explorerUrl

purgeClient

Purge client.

Returns void

setNetwork

Set/update the current network.

Parameters

  • network Network mainnet or testnet.

  • Throws "Network must be provided" Thrown if network has not been set before.

Returns void

getNetwork

Get the current network.

Returns Network The current network. (mainnet or testnet)

setClientUrl

Set/update the client URL.

Parameters

  • clientUrl ClientUrl The client url to be set.

Returns void

getClientUrl

Get the client url.

Returns NodeUrl The client url for thorchain based on the current network.

getDefaultClientUrl

Get the client url.

Returns ClientUrl The client url (both mainnet and testnet) for thorchain.

getClientUrlByNetwork

Get the client url.

Parameters

  • network Network

Returns NodeUrl The client url (both node, rpc) for thorchain based on the network.

setExplorerUrl

Set/update the explorer URL.

Parameters

  • explorerUrl ExplorerUrl The explorer url to be set.

Returns void

getExplorerUrl

Get the explorer url.

Returns string The explorer url for thorchain based on the current network.

getDefaultExplorerUrl

Get the explorer url.

Returns ExplorerUrl The explorer url (both mainnet and testnet) for thorchain.

getExplorerUrlByNetwork

Get the explorer url.

Parameters

  • network Network

Returns string The explorer url for thorchain based on the network.

getChainId

Get the chain id.

Returns string The chain id based on the network.

getExplorerAddressUrl

Get the explorer url for the given address.

Parameters

  • address Address

Returns string The explorer url for the given address.

getExplorerNodeUrl

Get the explorer url for the given node.

Parameters

  • address
  • node Address address

Returns string The explorer url for the given node.

getExplorerTxUrl

Get the explorer url for the given transaction id.

Parameters

Returns string The explorer url for the given transaction id.

setPhrase

Set/update a new phrase

Parameters

  • phrase string A new phrase.

  • Throws "Invalid phrase" Thrown if the given phase is invalid.

Returns Address The address from the given phrase

getAddress

Get the current address.

  • Throws Error Thrown if phrase has not been set before. A phrase is needed to create a wallet and to derive an address from it.

Returns Address The current address.

validateAddress

Validate the given address.

Parameters

  • address Address

Returns boolean true or false

getBalance

Get the balance of a given address.

Parameters

  • address Address By default, it will return the balance of the current wallet. (optional)
  • asset Asset If not set, it will return all assets available. (optional)

Returns Array<Balance> The balance of the address.

getTransactions

Get transaction history of a given address with pagination options. By default it will return the transaction history of the current wallet.

Parameters

  • params TxHistoryParams The options to get transaction history. (optional)

Returns TxsPage The transaction history.

getTransactionData

Get the transaction details of a given transaction id.

Parameters

  • txId string The transaction id.

Returns Tx The transaction details of the given transaction id.

buildDepositTx

Structure StdTx from MsgNativeTx.

Parameters

  • msgNativeTx
  • txId string The transaction id.

  • Throws "Invalid client url" Thrown if the client url is an invalid one.

Returns Tx The transaction details of the given transaction id.

deposit

Transaction with MsgNativeTx.

Parameters

  • params DepositParam The transaction options.
    • params.asset (optional, default types_1.AssetRune)
    • params.amount
    • params.memo
  • Throws "insufficient funds" Thrown if the wallet has insufficient funds.
  • Throws "failed to broadcast transaction" Thrown if failed to broadcast transaction.

Returns TxHash The transaction hash.

transfer

Transfer balances with MsgSend

Parameters

  • params TxParams The transfer options.
    • params.asset (optional, default types_1.AssetRune)
    • params.amount
    • params.recipient
    • params.memo

Returns TxHash The transaction hash.

getFees

Get the fees.

Returns Fees