LaserEyes

Base Client

Read-only client with explicit addresses.

The base client is read-only and takes explicit addresses. Build it with a network and a backend, then .extend(publicActions()) for the read methods.

import { createClient, publicActions, combineBackends, MAINNET } from '@lasereyes/client'
import { mempool } from '@lasereyes/client/backends/mempool'
import { sandshrew } from '@lasereyes/client/backends/sandshrew'

// sandshrew primary (broad coverage), mempool fallback for base BTC reads
const backend = combineBackends(sandshrew({ apiKey: '…' }), mempool())(MAINNET)

const client = createClient({ network: MAINNET, backend }).extend(publicActions())

const balance = await client.getAddressBalance('bc1q…')
const utxos = await client.getAddressUtxos('bc1q…')

A single backend works too:

const backend = mempool()(MAINNET)

Note that the backend factory resolves against a network — mempool()(MAINNET) — before being handed to createClient.