How to Use
Installation
yarn add @xchainjs/xchain-avaxPeer Dependencies
You can visit the xchain-avax package repository to get the updated peer dependencies by looking at the "peerDependencies" object in the "package.json" file.
Testing
yarn install
yarn testExample
/import { Client, defaultAvaxParams } from "@xchainjs/xchain-avax"
import { FeeOption } from "@xchainjs/xchain-client"
import { assetToBase, baseToAsset, assetAmount, Asset, Chain } from "@xchainjs/xchain-util"Connect Wallet to New Avax Chain Client
The network default is Mainnet
// Create new Avax Asset
const assetRIP: Asset = {
chain: Chain.Avalanche,
symbol: `RIP-0x224695ba2a98e4a096a519b503336e06d9116e48`,
ticker: `RIP`,
synth: false,
}
// Create new Avax Client Instance
const connectWallet =async () => {
defaultAvaxParams.phrase = "phrase"
const avaxClient = new Client(defaultAvaxParams)
let address = avaxClient.getAddress()
console.log(`Address: ${address}`)
let isValid = avaxClient.validateAddress(address)
if( isValid === true ){
try {
const balance = await avaxClient.getBalance(address)
let assetAmount = (baseToAsset(balance[1].amount)).amount()
console.log(`With balance: ${assetAmount}`)
} catch (error) {
console.log(`Caught: ${error}`)
}
}
}Transfer Avax Using AvaxClient
Get Fees
Get Transaction Data & History
Last updated