How to Use

Installation

yarn add @xchainjs/xchain-litecoin

Peer Dependencies

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

Testing

yarn install
yarn test

Examples

Connect Wallet to New Litecoin Client

Create a new instance of Litecoin Client Retrieve and validate an address Check the balance of assets at the address The network default is Mainnet


//Imports 
import { Client } from "@xchainjs/xchain-litecoin"

// Connect wallet and retrieve address and balance of assets on address
const connectWallet =async () => {
    let phrase = "phrase"
    const ltcClient = new Client({network: Network.Mainnet, phrase})
    let address = ltcClient.getAddress()
    console.log(address)
    let isValid = ltcClient.validateAddress(address)
    if( isValid === true ){
        try {
            const balance = await ltcClient.getBalance(address)
            let assetAmount = (baseToAsset(balance[0].amount)).amount()
            console.log(`With balance: ${assetAmount}`)
    
        } catch (error) {
            console.log(`Caught: ${error}`)
        }
    }
}

Transfer Litecoin Using Litecoin Client Instance

The default fee rate is 1

Last updated