How to Use
Installation
yarn add @xchainjs/xchain-binancePeer Dependencies
You can visit the xchain-binance 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 Binance Chain Client
The network default is Mainnet
//Imports
import { Client } from '@xchainjs/xchain-binance'
import { FeeOption } from "@xchainjs/xchain-client"
// Connect wallet to new btc client
const connectWallet = async () => {
let phrase = "phrase"
const bncClient = new Client({phrase })
let address = bncClient.getAddress()
console.log(`Asset Address is: ${address}`)
let balances = await bncClient.getBalance(address)
try {
let assetAmount = (baseToAsset(balances[0].amount)).amount()
console.log(`with balance: ${assetAmount}`)
} catch (error) {
console.log('no balance')
}
}Transfer BNB Using BncClient
Create a new instance of BncClient Set the correct amount using xchain-util helper functions Build new transactions using TxParams and call transfer.
Get Transaction Data & Transaction History
Create a new BncClient instance
Call getTransactionData(hash) returns [object object]
Retrieve relevant data
Get Current Fees
BNC is a fixed fee client, average, fast, and fastest return the same value. getFees() returns current fees for the network getMultiSendFees() returns current fees for a multi-send tx
Multisend Transaction
Building a multisend transaction with BncClient Build transactions with transactions taking an Array of objects.
Last updated