An open API service indexing awesome lists of open source software.

https://github.com/bitvora/bitvora-ts

Bitvora Typescript SDK
https://github.com/bitvora/bitvora-ts

Last synced: 5 months ago
JSON representation

Bitvora Typescript SDK

Awesome Lists containing this project

README

          

# Bitvora SDK

A Node.js SDK written in Typescript for the Bitvora API and Webhooks.

## Installation

```bash
npm install bitvora
```

## Usage

### Sending Bitcoin (withdrawal)

```typescript
import { BitvoraClient } from "bitvora";

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

async function sendBitcoin(): Promise {
const withdrawal = await bitvora.withdraw(
"utxo1@getalby.com", // accepts on-chain, lightning invoice (payment request), lightning address, lnurl
10.0, // amount in your desired currency
Currency.USD // currency code
);

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

return withdrawal;
}
```

### Creating a Lightning Address

```typescript
import { BitvoraClient } from "bitvora";

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

async function createLightningAddress(): Promise {
let metadata = {
userID: "your-internal-user-id",
email: "useremail@protonmail.com",
}; // optional metadata object to attach, accepts any valid key-value object

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

### Create a Lightning Invoice

```typescript
import { BitvoraClient } from "bitvora";

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

async function createLightningInvoice(): Promise {
let metadata = {
userID: "your-internal-user-id",
email: "useremail@protonmail.com",
}; // optional metadata object to attach, accepts any valid key-value object

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

await invoice.isSettled();

return invoice;
}
```

### Get Balance

```typescript
import { BitvoraClient } from "bitvora";

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

async function getBalance(): Promise {
return bitvora.getBalance();
}
```

### Get Transactions

```typescript
import { BitvoraClient } from "bitvora";

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

async function getTransactions(): Promise {
return bitvora.getTransactions();
}
```

### Get Deposit

```typescript
import { BitvoraClient } from "bitvora";

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

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

### Get Withdrawal

```typescript
import { BitvoraClient } from "bitvora";

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

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