How to Use

Installation

yarn add @xchainjs/xchain-thorchain

Peer Dependencies

You can visit the xchain-thorchain package repository to get the updated peer dependencies by looking at the "peerDependencies" object in the "package.json" file.

Testing

yarn install
yarn test

Examples

Connect wallet to new Thor Client

Create a new thorchain client The client has two different sets of parameters XchainClientParams & ThorchainClientParams ThorchainClient includes chainIds. getChainIds() returns all chain id's for default Client Url. The network default is Mainnet


// Imports 
import { Client, getChainIds, getDefaultClientUrl} from '@xchainjs/xchain-thorchain'
import { assetToBase, baseToAsset, assetAmount } from "@xchainjs/xchain-util"


// Create new instance of the client and query chain for balances. 
const connectWallet = async () => {

    let phrase = "phrase"
    const thorClient = new Client({phrase})
    let address = thorClient.getAddress()
    console.log(`Address: ${address}`)
    try {
        const balance = await thorClient.getBalance(address)
        let assetAmount = (baseToAsset(balance[0].amount)).amount()
        console.log(`With balance: ${assetAmount}`)
    } catch (error) {
        console.log(`Caught ${error}`)
    }
}

Transfer Rune using Thor Client

Create a new Thorchain client instance Convert amount to transfer to base amount Build transaction.

Get Transaction Data & Transaction History

Retrieve transaction data using transaction hash and address

Get Transfer Fees

Thorchain runs on a fee type of Flatfee set to 0.02 rune

Get Network and Explorer Data

Last updated