Skip to content

WestWallet/westwallet-js-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

westwallet-js-api

npm

westwallet-js-api is a WestWallet Public API wrapper for JavaScript programming language. Use it for building payment solutions.

Installing

Install from npm:

npm install westwallet-api

Create withdrawal example

// Sending 0.1 ETH to 0x57689002367b407f031f1BB5Ef2923F103015A32
const westwallet = require('westwallet-api');
const westwalletErrors = westwallet.WestWalletAPIErrors;

let client = new westwallet.WestWalletAPI(
    "your_public_key",
    "your_private_key"
);
client.createWithdrawal("ETH", "0.1", "0x57689002367b407f031f1BB5Ef2923F103015A32")
.then((data) => {
    console.log(data);
}).catch((error) => {
    if (error instanceof westwalletErrors.InsufficientFundsError) {
        console.log("Insufficient funds");
    } else if (error instanceof westwalletErrors.BadAddressError) {
        console.log("Bad address regex");
    } else {
        console.log(error);
    }
});

Generate address example

const westwallet = require('westwallet-api');
const westwalletErrors = westwallet.WestWalletAPIErrors;

let client = new westwallet.WestWalletAPI(
    "your_public_key",
    "your_private_key"
);
client.generateAddress("BTC").then((data) => {
    console.log(data);
}).catch((error) => {
    if (error instanceof westwalletErrors.CurrencyNotFoundError) {
        console.log("No such currency");
    }
});

Documentation

Other languages