Skip to main content

Node JS

Installation

npm install bitvora

or

yarn install bitvora

Sending Bitcoin (withdrawal)

import { BitvoraClient } from "bitvora";

const bitvora = BitvoraClient(API_KEY, "mainnet"); // ["mainnet", "testnet", "signet"]

async function sendBitcoin(): Promise<Withdrawal> {
const withdrawal = await bitvora.withdraw(
"[email protected]", // accepts on-chain, lightning invoice (payment request), lightning address, lnurl
25 // amount, in sats
);

await withdrawal.isSettled(); // wait until the payment succeeds or fails, optional

return withdrawal;
}

Creating a Lightning Address

import { BitvoraClient } from "bitvora";

const bitvora = BitvoraClient(API_KEY, "mainnet"); // ["mainnet", "testnet", "signet"]

async function createLightningAddress(): Promise<CreateLightningAddressResponse> {
let metadata = {
userID: "your-internal-user-id",
email: "[email protected]",
}; // optional metadata object to attach, accepts any valid key-value object

return bitvora.createLightningAddress(metadata); // also accepts null
}

Creating a Lightning Invoice

import { BitvoraClient } from "bitvora";

const bitvora = BitvoraClient(API_KEY, "mainnet"); // ["mainnet", "testnet", "signet"]

async function createLightningInvoice(): Promise<LightningInvoice> {
let metadata = {
userID: "your-internal-user-id",
email: "[email protected]",
}; // optional metadata object to attach, accepts any valid key-value object

const invoice = await bitvora.createLightningInvoice(
50,
"this is from the sdk",
3600,
metadata
);

await invoice.isSettled();

return invoice;
}

Get Balance

import { BitvoraClient } from "bitvora";

const bitvora = BitvoraClient(API_KEY, "mainnet"); // ["mainnet", "testnet", "signet"]

async function getBalance(): Promise<number> {
return bitvora.getBalance();
}

Get Transactions

import { BitvoraClient } from "bitvora";

const bitvora = BitvoraClient(API_KEY, "mainnet"); // ["mainnet", "testnet", "signet"]

async function getTransactions(): Promise<GetTransactionsResponse> {
return bitvora.getTransactions();
}

Get Deposit

import { BitvoraClient } from "bitvora";

const bitvora = BitvoraClient(API_KEY, "mainnet"); // ["mainnet", "testnet", "signet"]

async function getDeposit(): Promise<BitcoinDepositResponse> {
return bitvora.getDeposit("UUID-HERE");
}

Get Withdrawal

import { BitvoraClient } from "bitvora";

const bitvora = BitvoraClient(API_KEY, "mainnet"); // ["mainnet", "testnet", "signet"]

async function getWithdrawal(): Promise<BitcoinWithdrawalResponse> {
return bitvora.getWithdrawal("UUID-HERE");
}