Client Packages

Full Multichain Wallet Example

A wallet class has been created that instantiates every chain client and leverages the interface which greatly simplifies working with wallets and THORChain. See the below code example.

Client Packages breakdown

Client packages have been created for each blockchain that connects to THORChain. All clients implement xchain-crypto which acts like a super class and gives each client a common interface.

Common functions with code examples are:

Config and Set Up of a Wallet

Some chains require address history to query balances and Txs

Querying

All clients implement these functions. While most can use the same code, some have slight client differences.

  • Get Explorer URL - for the specific blockchain
  • Get Balance - returns the balance of an address
  • Get Transactions - returns a simplified array of recent transactions for an address.
  • Get Transaction Data - returns transaction information from the transaction ID/hash.

See below for a Bitcoin example. Also see Ethereum, THORChain, Cosmos, and Avalanche examples.

Some chains require address history to query balances and Txs

Transactions

  • Get Fees - get the transaction fee for the chain, separate from THORChain fees
  • Transfer - transfer funds from one wallet to another.
  • Purge - When a wallet is "locked" the private key should be purged in each client by setting it back to null.

See http://docs.xchainjs.org/xchain-client/overview.html for more information.