# bitcoin-nodejs

> Simple Bitcoin API: easily create wallets and check balances.

Latest version **1.0.3** (published 2023-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install bitcoin-nodejs
pnpm add bitcoin-nodejs
yarn add bitcoin-nodejs
bun add bitcoin-nodejs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-05-20 |
| First published | 2023-05-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | viniciuswkf |
| Maintainers | viniciuswkf |
| Keywords | bitcoin, bitcore, bitcore-lib, bitcoin development, bitcoin wallet, bitcoin nodejs, bitcoin javascript, blockchain, bitcoin account, ethereum |

## Links

- npm: https://www.npmjs.com/package/bitcoin-nodejs
- npm.io page: https://npm.io/package/bitcoin-nodejs

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^1.4.0
- [bitcore-lib](https://npm.io/package/bitcore-lib.md) ^10.0.5

## Recent versions

- 1.0.3 (latest) — 2023-05-20
- 1.0.1 — 2023-05-20
- 1.0.0 — 2023-05-20

## README

# 🟡 Bitcoin NodeJS API

Simple Bitcoin API: easily create wallets and check balances.

## Installation

NPM

```bash
  npm install bitcoin-nodejs
```

YARN

```base
  yarn add bitcoin-nodejs
```

## Example

```javascript
const { createWallet, getBalance, getWallet } = require('bitcoin-nodejs');

async function test() {
  const { privateKey, address } = createWallet({ network: 'mainnet' });
  console.log(`Private Key: ${privateKey}\nAddress: ${address}`);
  // Private Key: 8d4da74160b4bcd2c363ebb1a49f95e572667d5
  // Address: 1JRC8aUgdVc1tBYfdvrZUsbwyKv81qhSTB

  const balance = await getBalance({ address, inSatoshi: false });
  console.log(balance);
  // 2450

  const balanceInSatoshi = await getBalance({ address, inSatoshi: true });
  console.log(balanceInSatoshi);
  // 0.0002450

  const wallet = await getWallet({ address });
  console.log(wallet);
  // { address, total_received, total_sent, ... }
}

test();
```

## Functions

- `createWallet({ network: "mainnet", "testnet" })`
  - `network: "mainnet" || "testnet"`
- `getBalance({ address: "...", inSatoshi: true })`

  - `address: Wallet public address`
  - `inSatoshi: true || false`

- `getWallet({ address: "..." })`
  - Object:
  ```javascript
  {
     address: '1GSiT5ZUm85ECZswyu49maJmteCabosUGL',
     total_received: 0,
     total_sent: 0,
     balance: 0,
     unconfirmed_balance: 0,
     final_balance: 0,
     n_tx: 0,
     unconfirmed_n_tx: 0,
     final_n_tx: 0,
     tx_url: 'https://api.blockcypher.com/v1/btc/main/txs/'
  }
  ```

## To-do

[ ] Transactions - Send transactions

## Buy me a coffee

If you liked it and want this project to stay active, buy me a coffee.

    BTC: 1KmZyRhAVcAMH8vJKcGPNp5QpCJ3HNZgzv
    ETH: 0x42eF534C4172b02351b90A4184bedCD8bcfE8eE6
    LTC: LbendKmgoYy8hgMMZMWtxNNNjeJh5CYo7Q

---
_Source: https://npm.io/package/bitcoin-nodejs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
