# electrs-client-node

> A javascript client for communicating with [Blockstream's electrs](https://github.com/Blockstream/electrs) HTTP api

Latest version **1.0.2** (published 2023-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install electrs-client-node
pnpm add electrs-client-node
yarn add electrs-client-node
bun add electrs-client-node
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-10-10 |
| First published | 2023-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 39.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | lexyblazy |

## Links

- npm: https://www.npmjs.com/package/electrs-client-node
- npm.io page: https://npm.io/package/electrs-client-node

## Dependencies (1)

- [apisauce](https://npm.io/package/apisauce.md) ^2.1.6

## Recent versions

- 1.0.2 (latest) — 2023-10-10
- 1.0.1 — 2023-10-10
- 1.0.0 — 2023-10-10

## README

# electrs-client-node

A javascript client for communicating with [Blockstream's electrs](https://github.com/Blockstream/electrs) HTTP api

```ts
import { Client } from "electrs-client-node";

const client = new Client({
  ELECTRUM_SERVER_URL: "http://localhost:30000",
});
```

## Transactions

```ts
// GET a transaction
const tx = await client.transaction.get(txId);

// GET transaction status
const txStatus = await client.transaction.status(txId);

// GET transaction  hex
const hex = await client.transaction.hex(txId);

// GET transaction raw
const raw = await client.transaction.raw(txId);

// GET merkle inclusion proof(using bitcoind's merkleblock format)
const merkleBlockProof = await client.transaction.merkleBlockProof(txId);

// GET merkle inclusion proof( using Electrum's blockchain.transaction.get_merkle format)
const merkleProof = await client.transaction.merkleProof(txId);

// GET spending status of a transaction output
const spendingStatus = await client.transaction.outputSpend(txId, vout);

// GET spending status of all transaction output
const spendingStatus = await client.transaction.outputsSpend(txId);

// CREATE a transaction
const tx = await client.transaction.create(hex);
```

## Addresses

```ts
// GET address information
const addressInfo = await client.address.getInfo(address);

// Get transaction history for the specified address/scripthash, sorted with newest first. Returns 25 transactions per page.
const addressTransactions = await client.address.getTransactions(address);

// More can be requested by specifying the last txid seen by the previous query.
const moreTransactions = await client.address.getTransactions(address, lastSeenTxId);

// Get unconfirmed transaction history for the specified address/scripthash.
// Returns up to 50 transactions (no paging)
const mempoolTxs = await client.address.getMempoolTransactions(address);

// Get the list of unspent transaction outputs associated with the address
const utxos = await client.address.getUtxo(address);

// Search for addresses beginning with :prefix.
// Returns a JSON array with up to 10 results.
const addresses = await client.address.getByPrefix(address);
```

## Blocks

```ts
// GET block information
const blockInfo = await client.block.get(blockHash);

// GET the hex-encoded block header.
const blockHeader = await client.block.getHeader(blockHash);

// GET the block status
const blockStatus = await client.block.getStatus(blockHash);

// Returns a list of transactions in the block (up to 25 transactions beginning)
const transactions = await client.block.getTransactions(blockHash);

// for a block with more than 25 transactions, the `startIndex`(which must be a multiple of 25 e.g 0, 25, 50, 75, 100 ... ) can be used for pagination.
const moreTransactions = await client.block.getTransactions(blockHash, startIndex);

// Returns list of all txids in the block
const transactionsIds = await client.block.getTransactionsIds(blockHash);

// Returns the transaction at index :index within the specified block.
const txIdAtIndex = await client.block.getTransactionIdAtIndex(blockHash, 1);

// Returns the hash of the block currently at height.
const hash = await client.block.getHash(height);

// Returns the 10 newest blocks starting at the tip or at start_height if specified.
const blocksList = await client.block.list();
const blocksListFromStartingHeight = await client.block.list(startHeight);

// Returns the height of the last block
const latestBlockHeight = await client.block.getLatestHeight();

// Returns the hash of the last block.
const latestBlockHash = await client.block.getLatestHash();
```

## Mempool

```ts
// Get mempool backlog statistics.
const mempoolStats = await client.mempool.getStats();

// Get the full list of txids in the mempool as an array.
const mempoolTxIds = await client.mempool.getTxIds();

// Get a list of the last 10 transactions to enter the mempool.
const recentTxs = await client.mempool.getRecentTxs();
```

## Fee

```ts
// GET fee-estimates
const feeEstimate = await client.fee.getEstimate();
```

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