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
- Host: GitHub
- URL: https://github.com/bitvora/bitvora-ts
- Owner: bitvora
- Created: 2024-07-08T15:27:14.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-23T01:47:30.000Z (almost 2 years ago)
- Last Synced: 2024-07-23T18:59:30.596Z (almost 2 years ago)
- Language: TypeScript
- Size: 459 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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");
}
```