How to Use
Installation
yarn add @xchainjs/xchain-bitcoincashPeer Dependencies
You can visit the xchain-bitcoincash package repository to get the updated peer dependencies by looking at the "peerDependencies" object in the "package.json" file.
Testing
yarn install
yarn testExample
Connect Wallet to New Bitcoincash Client
The network default is Mainnet
// Imports
import { Client } from "@xchainjs/xchain-bitcoincash"
// Connect wallet to new BitcoinCash Client & validate address
const connectWallet = async () => {
let phrase = "phrase"
const bchClient = new Client({phrase})
let address = bchClient.getAddress()
let isValid = bchClient.validateAddress(address)
if( isValid === true ){
try {
const balance = await bchClient.getBalance(address)
let assetAmount = (baseToAsset(balance[0].amount)).amount()
console.log(`With balance: ${assetAmount}`)
} catch (error) {
console.log(`Caught: ${error}`)
}
} else {
console.log(`Address ${address} is not valid`)
}
}
Transfer Using BitcoinCash Client
Transaction parameters. The default fee rate is: 1 Returns transaction hash string
Get Current Fees & Fee Rates.
getFees() returns fees in base amount i.e BCH Fees Fast: 0.00000234 Fastest: 0.0000117 Average: 0.00000117
getFeeRates() returns feeRates as number
Get Transaction Data & Transaction History
Last updated