DogeJS / All tools / Backends

Chain data from servers you choose

Read balances, transactions and fees from your own indexer or node, cross-check several servers, and watch an address for payments.

npm install @dogejs/backends. No runtime dependencies. You choose the servers: there is no default one.

A run example: an Esplora backend giving a balance and history, and refusing a server on the wrong network.

What it does

A run example watching an address for a payment, with the events it printed.

Watch an address for a payment

Say how much you expect and how many confirmations you need. You get events as the payment is seen, confirmed or moved by a reorg.

  • detected, confirmation, confirmed and reorged events
  • Retries after errors with a delay you can read
  • Stops when it is paid enough
A run example of fallback and quorum across servers, with the output.

Ask several servers and compare

Fallback tries the next server when one fails. Quorum asks several and only answers when enough of them agree.

  • One bad server cannot decide the answer
  • Works across indexers and nodes
  • A mismatch is reported with the groups of answers
A run example of the Core JSON-RPC backend, with the output.

Your own node

Talk to your own Dogecoin Core through its JSON-RPC. Read the tip height, the network and fee estimates with the same calls as the other backends.

  • Exact wallet amounts through callExact
  • Your server stays yours
  • The RPC login stays in your own code
A run example of public services and the request budget, with the output.

Free public services, with a budget

Clients for BlockCypher and Blockchair count your requests against the free limits, so a busy page does not get blocked.

  • Free limits tracked: 3 a second, 100 an hour, 1000 a day
  • Read how many requests are left at any time
  • Move to your own server when you outgrow them

Chain data from servers you choose

Open source, MIT licensed, on GitHub.

For developers

Documentation

Modules, run examples, complete reference and FAQ.

Quick start

Install the package. It has no runtime dependencies and runs in browsers and in Node 20 or later.

Shell
npm install @dogejs/backends

Point a backend at your own indexer, check which network it serves, then wait for a payment.

JavaScript
import { EsploraBackend, assertNetwork, watchAddress } from '@dogejs/backends';

const backend = new EsploraBackend({ baseUrl: 'https://your-electrs-doge.example.com' });
await assertNetwork(backend, 'testnet');

const watcher = watchAddress(backend, {
  address: 'nUCAGGgZEPN1QyknmQe1oAku817bQAFKFt',
  minAmountKoinu: 100_000_000n, // 1 DOGE
  confirmations: 1,
});
watcher.on('confirmed', (c) => console.log('paid', c.amountKoinu));
watcher.on('error', (e) => console.log('retrying in', e.retryInMs, 'ms'));

There is no default server for the Esplora, Core and fallback clients: each needs the address of an indexer or node that you run or trust. The free public services have their own named clients (below). Before you release goods of real value, confirm the payment on your own server.

How it works

  1. Bring a server

    An Esplora-style indexer such as electrs-doge, or your own Dogecoin Core node.

  2. Check the data

    Responses are validated, amounts are exact, and raw transactions must hash to the txid you asked for.

  3. Cross-check

    FallbackBackend fails over, can require several servers to agree, and refuses a server on the wrong network.

  4. Watch

    Watchers poll and emit events: detected, confirmation, confirmed and reorged.

A server is a remote party. The package checks the shape of what it says, not whether it is true. Your own node is the strongest choice, and a quorum of independent servers protects against one that lies.

Examples

A payment, event by event

For one payment to an address with confirmations: 2, watchAddress emits these events in this order.

  1. detectedThe payment is in the mempool. amountKoinu, totalKoinu and satisfied say whether it is enough.
  2. confirmationIt reached a block. Fires again as the depth grows, up to the target.
  3. confirmedEnough value with enough confirmations. Fires once.
  4. reorgedA known payment went back to the mempool, moved to another block, or disappeared. It is re-evaluated, and confirmed may fire again.

poll fires after every successful check, and error fires when a check fails, with the delay before the next try.

Wrong-network detection

assertNetwork reads the genesis block of a server and refuses a server on another network. It catches a mainnet URL in a testnet setup.

JavaScript
import { assertNetwork } from '@dogejs/backends';

// Simulated: the server's genesis block says testnet
await assertNetwork(backend, 'testnet');
// resolves: the genesis block matches

Watching a transaction you sent

watchTransaction follows one txid until it has enough confirmations.

JavaScript
import { watchTransaction } from '@dogejs/backends';

const txid = await backend.broadcastTransaction(signedHex);
const watcher = watchTransaction(backend, { txid, confirmations: 3, pollSeconds: 0.5 });

watcher.on('seen',         (s) => show(s.confirmations));
watcher.on('confirmation', (c) => show(c.confirmations));
watcher.on('confirmed',    (c) => show(c.blockHeight));
watcher.on('reorged',      (r) => show(r.reason));

Reference

Which backend supports what

MethodEsploraCore RPCFallbackLite
getTipHeightyesyesyesyes
getAddressUtxosyesnoif a member has itno
getAddressTransactionsyesnoif a member has ityes
getTransactionyesyes, with -txindexyesyes
getRawTransactionyesyes, with -txindexyesno
broadcastTransactionyesyesyesno
getFeeEstimatesyesyesyesno
getNetworkyesyesyesyes
getUtxoyesyesyesno
watchAddressyesnoif a member has historyyes
watchTransactionyesyesyesyes

Core has no address index, so address methods reject with UNSUPPORTED. Combine Core with an Esplora backend in a FallbackBackend if you need both.

Import paths

ImportContains
@dogejs/backendsEverything, in one self-contained file (about 26 KB gzipped, of which the public-service clients are about 11 KB).
@dogejs/backends/esploraEsploraBackend, EsploraLiteBackend, assertNetwork
@dogejs/backends/core-rpcCoreRpcBackend, RawNumber
@dogejs/backends/fallbackFallbackBackend
@dogejs/backends/watchwatchAddress, watchTransaction
@dogejs/backends/liteEsploraLiteBackend, watchAddress, assertNetwork, BackendError
@dogejs/backends/publicPublicServiceBackend, BlockCypherBackend, BlockchairBackend, RequestBudget, assertNetwork

Free public services

BlockCypher's Dogecoin mainnet API answers a web page without a key, and Blockchair gives a second view of the latest block and of raw transactions. PublicServiceBackend combines them as one backend. Its RequestBudget counts your requests in your browser so a page stays within the free limits (3 a second, 100 an hour, 1000 a day per connection) and says when it can go on (RATE_LIMITED with retryAt). Every answer is checked against the address you asked about, the script that address must have, and the hash of every transaction. Confirmations are as the service reports them: neither sends block headers.

Options

WhereOptionDefaultWhat it does
EsploraBackendbaseUrlrequiredBase URL of your indexer.
timeoutMs15000Deadline per request, headers and body.
headersnoneExtra request headers, for example an API key.
requireInputsfalseFail when a transaction has no inputs.
CoreRpcBackendurlrequiredYour own node. URLs with user:pass@ are refused.
usernamenoneRPC user.
passwordnoneRPC password. Keep it out of web pages.
FallbackBackendagreement.quorumoffHow many servers must give the same answer.
agreement.criticaltransactions, UTXOs, outpointsWhich reads need agreement. Add getAddressTransactions for history.
expectedNetworknoneRefuse members on any other network.
verifyNetworktrueCheck every member's network before use.
watchAddressaddressrequiredThe address to watch.
minAmountKoinu1nTotal to wait for, summed over payments.
confirmations1Depth that counts as confirmed.
pollSeconds15Seconds between checks.
sincenoneIgnore confirmed transactions in older blocks (unix seconds).
signalnoneAn AbortSignal that stops the watcher.
watchTransactiontxidrequiredThe transaction to follow.
confirmations1Depth that counts as confirmed.
missingPolls2Polls in a row without the transaction before it counts as gone.

Events

EventWatcherFires when
detectedaddressA payment is seen for the first time. Each txid fires once.
seentransactionThe server first knows the transaction.
confirmationbothThe depth grows, until the target is reached.
confirmedbothThe target is reached.
reorgedbothA payment disappeared, went back to the mempool, or moved to another block.
pollbothAfter every successful check, with at and durationMs.
errorbothA check failed. Retries with backoff.

Error codes

CodeMeaning
NETWORKNo HTTP response: offline, blocked by CORS, or aborted.
HTTPAn error status, or a Core JSON-RPC error.
TIMEOUTThe server did not answer in time.
BAD_RESPONSEInvalid or untrustworthy data, or servers that disagree.
UNSUPPORTEDThe backend cannot do this.
REJECTEDA node refused a broadcast.
WRONG_NETWORKThe server serves a different network. See expectedNetwork and actualNetwork.

Run examples

These ran against a fake Esplora server and a fake chain (below), so every number is reproducible. Nothing here touches a real network.

JavaScript (fake-esplora.mjs)
// A tiny in-memory Esplora server (the few routes the examples use), so the examples run offline.
// It is the "chain": call chain.pay(address, koinu) to add a payment and chain.mine() to add a block.
import { createServer } from 'node:http';
import { randomBytes } from 'node:crypto';
import { addressToScript, testnet } from '@dogejs/core';

const TESTNET_GENESIS = 'bb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e';
const MAINNET_GENESIS = '1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691';
const hex = (n) => randomBytes(n).toString('hex');
const toHex = (u8) => Buffer.from(u8).toString('hex');

export class FakeChain {
  constructor({ network = 'testnet', tip = 5_000_000 } = {}) { this.network = network; this.tip = tip; this.txs = []; this.hidden = new Set(); }
  pay(address, koinu) {
    const tx = { txid: hex(32), address, koinu: Number(koinu), height: null, blockHash: null };
    this.txs.push(tx); return tx.txid;
  }
  mine(n = 1) {
    for (let i = 0; i < n; i++) { this.tip += 1; for (const t of this.txs) if (t.height === null) { t.height = this.tip; t.blockHash = hex(32); } }
  }
  json(t) {
    return {
      txid: t.txid, version: 1, locktime: 0,
      vin: [{ txid: '11'.repeat(32), vout: 0, prevout: null, scriptsig: '0151', scriptsig_asm: 'OP_PUSHBYTES_1 51', is_coinbase: false, sequence: 4294967295 }],
      vout: [{ scriptpubkey: toHex(addressToScript(t.address, testnet)), scriptpubkey_asm: 'x', scriptpubkey_type: 'p2pkh', scriptpubkey_address: t.address, value: t.koinu }],
      size: 87, weight: 348, fee: 100000,
      status: t.height === null ? { confirmed: false } : { confirmed: true, block_height: t.height, block_hash: t.blockHash, block_time: 1_700_000_000 },
    };
  }
}

export async function serve(chain) {
  const server = createServer((req, res) => {
    const path = new URL(req.url, 'http://x').pathname;
    const send = (body, type = 'application/json') => { res.setHeader('content-type', type); res.end(typeof body === 'string' ? body : JSON.stringify(body)); };
    if (path === '/blocks/tip/height') return send(String(chain.tip), 'text/plain');
    if (path === '/block-height/0') return send(chain.network === 'mainnet' ? MAINNET_GENESIS : TESTNET_GENESIS, 'text/plain');
    let m;
    if ((m = path.match(/^\/address\/([^/]+)\/txs$/))) return send(chain.txs.filter((t) => t.address === m[1] && !chain.hidden.has(t.txid)).reverse().map((t) => chain.json(t)));
    if ((m = path.match(/^\/address\/([^/]+)\/txs\/chain\/.+$/))) return send([]);
    if ((m = path.match(/^\/tx\/([0-9a-f]{64})$/))) { const t = chain.txs.find((x) => x.txid === m[1]); if (t) return send(chain.json(t)); }
    res.statusCode = 404; res.end('Transaction not found');
  });
  await new Promise((r) => server.listen(0, '127.0.0.1', r));
  return { url: `http://127.0.0.1:${server.address().port}`, close: () => server.close() };
}

Run: Esplora: balance, history and a wrong-network check

JavaScript
import { EsploraBackend, assertNetwork, BackendError } from '@dogejs/backends';
import { generatePrivateKey, getPublicKey, p2pkhAddress, parseDoge, testnet } from '@dogejs/core';
import { FakeChain, serve } from './fake-esplora.mjs';

const address = p2pkhAddress(getPublicKey(generatePrivateKey()), testnet);
const chain = new FakeChain({ network: 'testnet' });
const server = await serve(chain);
chain.pay(address, parseDoge('12.5')); chain.mine(3);

const backend = new EsploraBackend({ baseUrl: server.url, timeoutMs: 5000 });
console.log('tip height:', await backend.getTipHeight());
console.log('network:', await backend.getNetwork());

const history = await backend.getAddressTransactions(address);
const tx = history[0];
console.log('transactions:', history.length, '| first pays', tx.outputs[0].valueKoinu, 'koinu, confirmed:', tx.status.confirmed, 'at height', tx.status.blockHeight);
console.log('same transaction by id:', (await backend.getTransaction(tx.txid))?.txid === tx.txid, '| unknown id:', await backend.getTransaction('ab'.repeat(32)));

await assertNetwork(backend, 'testnet');
try { await assertNetwork(backend, 'mainnet'); } catch (e) { console.log(e instanceof BackendError, e.code, e.expectedNetwork, e.actualNetwork); }
server.close();
Output
tip height: 5000003
network: testnet
transactions: 1 | first pays 1250000000n koinu, confirmed: true at height 5000001
same transaction by id: true | unknown id: null
true WRONG_NETWORK mainnet testnet

Run: Watch an address for a payment

JavaScript
import { EsploraBackend, watchAddress } from '@dogejs/backends';
import { generatePrivateKey, getPublicKey, p2pkhAddress, parseDoge, testnet } from '@dogejs/core';
import { FakeChain, serve } from './fake-esplora.mjs';

const address = p2pkhAddress(getPublicKey(generatePrivateKey()), testnet);
const chain = new FakeChain();
const server = await serve(chain);
const backend = new EsploraBackend({ baseUrl: server.url });

// Wait for 2 DOGE in total, with 2 confirmations. Poll every second so the example is quick.
const w = watchAddress(backend, { address, minAmountKoinu: parseDoge('2'), confirmations: 2, pollSeconds: 1, stopWhenConfirmed: true });
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const short = (id) => id.slice(0, 8);
w.on('detected', (e) => console.log('detected    ', short(e.txid), e.amountKoinu, 'koinu | total', e.totalKoinu, '| enough:', e.satisfied));
w.on('confirmation', (e) => console.log('confirmation', short(e.txid), e.confirmations, 'confirmation(s)'));
w.on('confirmed', (e) => console.log('confirmed   ', e.txids.length, 'payments, total', e.amountKoinu, 'koinu'));
w.on('error', (e) => console.log('error', e.error.code));

await sleep(300);
console.log('-- customer pays 1 DOGE (not enough yet)');
chain.pay(address, parseDoge('1')); await sleep(1300);
console.log('-- customer pays 1.5 DOGE more');
chain.pay(address, parseDoge('1.5')); await sleep(1300);
console.log('-- a block is found');
chain.mine(1); await sleep(1300);
console.log('-- another block');
chain.mine(1); await sleep(1500);
await w.done;
console.log('confirmed state:', w.getState().confirmed, 'total', w.getState().totalKoinu, 'koinu');
server.close();
Output
-- customer pays 1 DOGE (not enough yet)
detected     acce0d07 100000000n koinu | total 100000000n | enough: false
-- customer pays 1.5 DOGE more
detected     32f9fb0a 150000000n koinu | total 250000000n | enough: true
-- a block is found
confirmation 32f9fb0a 1 confirmation(s)
confirmation acce0d07 1 confirmation(s)
-- another block
confirmation 32f9fb0a 2 confirmation(s)
confirmation acce0d07 2 confirmation(s)
confirmed    2 payments, total 250000000n koinu
confirmed state: true total 250000000n koinu

Run: Fallback and quorum across servers

JavaScript
import { EsploraBackend, FallbackBackend, BackendError } from '@dogejs/backends';
import { generatePrivateKey, getPublicKey, p2pkhAddress, parseDoge, testnet } from '@dogejs/core';
import { FakeChain, serve } from './fake-esplora.mjs';

const address = p2pkhAddress(getPublicKey(generatePrivateKey()), testnet);
const honest = new FakeChain(); const liar = new FakeChain(); // two independent "servers"
honest.pay(address, parseDoge('5')); honest.mine(2);
liar.tip = honest.tip;                                        // the second one never saw the payment
const servers = [await serve(honest), await serve(honest), await serve(liar)];
const make = (s) => new EsploraBackend({ baseUrl: s.url });
const [a, b, c] = servers.map(make);

// 1. Plain fail-over: the first backend that answers wins. If it hides a payment, you do not know.
console.log('plain, liar first:', (await new FallbackBackend([c, a]).getAddressTransactions(address)).length, 'transactions');

// 2. Quorum of 2 on address history: the answers must match.
const careful = (list) => new FallbackBackend(list, { agreement: { quorum: 2, critical: ['getAddressTransactions'] } });
console.log('honest + honest:', (await careful([a, b]).getAddressTransactions(address)).length, 'transaction');
try { await careful([a, c]).getAddressTransactions(address); } catch (e) {
  console.log('honest + liar :', e instanceof BackendError, e.code);
  console.log('  groups:', e.disagreement.map((g) => `${g.backends.join('+')}: ${g.summary}`).join(' | '));
}
console.log('liar + honest + honest:', (await careful([c, a, b]).getAddressTransactions(address)).length, 'transaction (the two that agree win)');

// 3. A server on the wrong network is refused before any data request.
const main = await serve(new FakeChain({ network: 'mainnet' })); servers.push(main);
try { await new FallbackBackend([a, make(main)]).getTipHeight(); } catch (e) { console.log('mixed networks:', e.code); }
try { await new FallbackBackend([a], { expectedNetwork: 'mainnet' }).getTipHeight(); } catch (e) { console.log('expected mainnet:', e.code, e.expectedNetwork, e.actualNetwork); }
servers.forEach((s) => s.close());
Output
plain, liar first: 0 transactions
honest + honest: 1 transaction
honest + liar : true BAD_RESPONSE
  groups: esplora: 1 transaction | esplora: 0 transactions
liar + honest + honest: 1 transaction (the two that agree win)
mixed networks: WRONG_NETWORK
expected mainnet: WRONG_NETWORK mainnet testnet

Run: Core JSON-RPC

JavaScript
import { createServer } from 'node:http';
import { CoreRpcBackend, BackendError } from '@dogejs/backends';

// A stand-in for dogecoind's JSON-RPC port (the real one is http://127.0.0.1:22555/ on mainnet).
const results = { getblockcount: 5_123_456, getblockhash: 'bb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e', getblockchaininfo: { chain: 'test', blocks: 5_123_456 }, getbalance: 12.5,
  estimatesmartfee: { feerate: 0.01, blocks: 2 } };
const seen = [];
const server = createServer((req, res) => {
  let body = ''; req.on('data', (d) => (body += d));
  req.on('end', () => {
    const { id, method } = JSON.parse(body); seen.push(method);
    res.setHeader('content-type', 'application/json');
    if (method in results) return res.end(JSON.stringify({ result: results[method], error: null, id }));
    res.statusCode = 500; res.end(JSON.stringify({ result: null, error: { code: -32601, message: 'Method not found' }, id }));
  });
});
await new Promise((r) => server.listen(0, '127.0.0.1', r));

const core = new CoreRpcBackend({ url: `http://127.0.0.1:${server.address().port}/`, username: 'rpcuser', password: 'rpcpass' });
console.log('tip:', await core.getTipHeight());
console.log('network:', await core.getNetwork());
console.log('fee estimates:', JSON.stringify(await core.getFeeEstimates({ targets: [2] }), (k, v) => (typeof v === 'bigint' ? v.toString() : v)));
console.log('exact wallet balance:', (await core.callExact('getbalance')).text);
console.log('capabilities:', Object.entries(core.capabilities).filter(([, v]) => v).map(([k]) => k).join(', '));
try { await core.getAddressTransactions('nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); } catch (e) { console.log('address history:', e instanceof BackendError, e.code); }
try { await core.call('nosuchmethod'); } catch (e) { console.log('unknown method:', e.code, e.status, e.rpcCode); }
console.log('RPC methods used:', [...new Set(seen)].join(', '));
server.close();
Output
tip: 5123456
network: testnet
fee estimates: {"koinuPerKb":{"2":"1000000"}}
exact wallet balance: 12.5
capabilities: getTipHeight, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork, getUtxo
address history: true UNSUPPORTED
unknown method: HTTP 500 -32601
RPC methods used: getblockcount, getblockhash, getblockchaininfo, estimatesmartfee, getbalance, nosuchmethod

Run: Public services and the request budget

JavaScript
import { PublicServiceBackend, RequestBudget, BLOCKCYPHER_FREE_LIMITS, assertNetwork } from '@dogejs/backends/public';
import { createFakePublic, p2pkhAddressOfPubkey, fakePubkey } from './test/fake-public.mjs';

// The fake speaks the response shapes captured from the real BlockCypher and Blockchair (see test/fixtures).
const fake = createFakePublic();
const address = p2pkhAddressOfPubkey(fakePubkey('shop'));
fake.fund(address, 2_500_000_000n); // 25 DOGE paid to the shop

let store = null; // in a browser: localStorage.getItem / setItem
const free = new PublicServiceBackend({ blockcypher: { fetch: fake.fetch(), budgetStore: { get: () => store, set: (v) => { store = v; } } }, blockchair: { fetch: fake.fetch() } });

await assertNetwork(free, 'mainnet');
console.log('balance:', (await free.getAddressBalance(address)).confirmedKoinu, 'koinu');
const history = await free.getAddressTransactions(address);
console.log('history:', history.length, 'transaction, confirmed:', history[0].status.confirmed);
console.log('utxos:', (await free.getAddressUtxos(address)).map((u) => u.valueKoinu));
const hour = free.budget().blockcypher.windows.find((w) => w.label === 'hour');
console.log('hour window:', `${hour.used} used, ${hour.remaining} of ${hour.max} left`);
console.log('requests that reached the fake service:', fake.state.counts);

// The budget on its own: three requests a second, 100 an hour, 1000 a day.
console.log('free limits:', BLOCKCYPHER_FREE_LIMITS.map((w) => `${w.max}/${w.label}`).join(', '));
const tiny = new RequestBudget({ windows: [{ ms: 3_600_000, max: 2, label: 'hour' }] });
await tiny.acquire(); await tiny.acquire();
try { await tiny.acquire(); } catch (e) { console.log('third request:', e.code, 'retry in about', Math.round((e.retryAt - Date.now()) / 60000), 'minutes'); }
Output
balance: 2500000000n koinu
history: 1 transaction, confirmed: true
utxos: [ 2500000000n ]
hour window: 4 used, 96 of 100 left
requests that reached the fake service: { blockcypher: 4, blockchair: 1 }
free limits: 3/second, 100/hour, 1000/day
third request: RATE_LIMITED retry in about 60 minutes

Complete API

Generated from the built type declarations of @dogejs/backends 0.3.0 (281 exports; some are re-exported by several entries).

index79 exports
NameKindSignatureWhat it does
AddressBalanceinterface{ address, confirmedKoinu, unconfirmedKoinu, finalKoinu, totalReceivedKoinu, totalSentKoinu, txCount, unconfirmedTxCount }Balance of one address as BlockCypher reports it (koinu; exact for any size).
AddressTransactionsOptionsinterface{ limit? }Options for `getAddressTransactions`: how many transactions to return.
AddressWatcherclassclass: getState(), poll()Polls `backend.getAddressTransactions` and emits events. EventTarget based: use `on()` (returns an unsubscribe function) or `addEventListener` (events are WatchEvent with a typed `detail`).
AddressWatchSourceinterface{ name, capabilities, getAddressTransactions, getTipHeight, getTransaction? }What the address watcher needs from a backend. Every `ChainBackend` fits, and so does the small `EsploraLiteBackend` from `@dogejs/backends/lite`.
AgreementMethodtypeAgreementMethod = 'getTransaction' | 'getAddressUtxos' | 'getTipHeight' | 'getAddressTransactions' | 'getUtxo';Reads that can be cross-checked between backends. Raw transactions are self-verifying (hash == txid) and are never compared.
AgreementOptionsinterface{ quorum, critical?, tipHeightTolerance? }Makes a FallbackBackend ask several backends and compare answers: how many must agree and which reads need it.
assertNetworkfunctionassertNetwork(backend: NetworkReporter, expected: Exclude<DogeNetwork, 'unknown'>, opts?: { signal?: AbortSignal; }): Promise<void>;Throws a `BackendError` with code `WRONG_NETWORK` unless the backend reports `expected`. `expected` must be a real network ('mainnet', 'testnet' or 'regtest'). A backend that reports `unknown` (a genesis hash that is not one of the three) fails the check. A backend that cannot report its network at all fails with `UNSUPPORTED`: it never passes silently.
BackendCapabilitiesinterface{ getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }Which ChainBackend methods a backend can serve. `getTipHeight` and the rest are never silently emulated.
BackendErrorclassclass: code, status, rpcCode, causes, expectedNetwork, actualNetwork, disagreement, retryAt, [Symbol.hasInstance](), [BRAND]Error thrown by every backend. Messages never contain credentials, the Authorization header or URL user-info.
BackendErrorCodetypeBackendErrorCode = 'NETWORK' | 'HTTP' | 'TIMEOUT' | 'BAD_RESPONSE' | 'UNSUPPORTED' | 'REJECTED' | 'WRONG_NETWORK' | 'RATE_LIMITED';Machine-readable reason codes for BackendError.
BackendErrorDetailsinterface{ status?, rpcCode?, causes?, cause?, expectedNetwork?, actualNetwork?, disagreement?, retryAt? }Extra facts a BackendError can carry: HTTP status, JSON-RPC code, the errors of each backend tried and how backends disagreed. Never contains credentials.
BackendMethodtypeBackendMethod = keyof BackendCapabilities;Name of a data method a backend may serve (a key of BackendCapabilities).
BLOCKCHAIR_DOGECOIN_URLconstBLOCKCHAIR_DOGECOIN_URL = "https://api.blockchair.com/dogecoin"The public Blockchair Dogecoin (mainnet) API.
BLOCKCHAIR_FREE_LIMITSconstBLOCKCHAIR_FREE_LIMITS: readonly BudgetWindow[]Blockchair's documented keyless allowance (about 30 per minute and 1,440 per day per IP; not verified by DogeJS).
BlockchairBackendclassclass: name, capabilities, http, budgetStatus(), getTip(), getTipHeight(), getRawTransaction(), getAddressUtxos(), getAddressTransactions(), getTransaction(), broadcastTransaction(), getFeeEstimates()A second, independent free service with only two uses here: the chain tip (to cross-check BlockCypher's) and raw transactions (hash-checked, so a copy that comes from an indexer other than the one that listed your coins). It is a partial ChainBackend: the other methods are not offered (`capabilities` says so) and throw UNSUPPORTED. It cannot report its network from a genesis hash; its URL path names the chain.
BLOCKCYPHER_FREE_LIMITSconstBLOCKCYPHER_FREE_LIMITS: readonly BudgetWindow[]BlockCypher's published free allowance (pricing page, per IP): 3 per second, 100 per hour, 1000 per day.
BLOCKCYPHER_MAINNET_URLconstBLOCKCYPHER_MAINNET_URL = "https://api.blockcypher.com/v1/doge/main"The public BlockCypher Dogecoin mainnet API.
BlockCypherBackendclassclass: name, capabilities, http, budgetStatus(), getTip(), getTipHeight(), getNetwork(), getAddressBalance(), getAddressBalances(), getAddressUtxos(), getAddressTransactions(), getTransaction(), getRawTransaction(), cachedTransaction(), cachedRawTransaction(), broadcastTransaction(), getFeeEstimates()ChainBackend for the free BlockCypher Dogecoin API (mainnet only; BlockCypher has no Dogecoin test network). No API key: the browser calls it directly, so the limits apply to the visitor's IP.
BlockCypherOptionsinterface{ tipCacheMs? }Settings of a BlockCypherBackend.
BudgetStatusinterface{ windows, pausedUntil?, nextAt }Snapshot of a budget: every window, a 429 pause if any, and when the next request may go.
BudgetStoreinterface{ get, set }Where a RequestBudget keeps its counts between page loads (and between tabs of the same site, which share one IP address and so one allowance). `localStorage` fits: pass `{ get: () => localStorage.getItem(k), set: (v) => localStorage.setItem(k, v) }`. Both calls must be synchronous; failures are ignored (the budget then lives in memory only).
BudgetWindowinterface{ ms, max, label }One limit: at most `max` requests in any `ms` long window.
BudgetWindowStatusinterface{ label, max, used, remaining, nextAt }Remaining requests in one window, and when the next slot in it frees up.
ChainBackendinterface{ name, capabilities, getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }What every chain data client offers: tip height, address UTXOs and transactions, one transaction, broadcast and fee estimates. Methods a backend cannot serve are listed in `capabilities`; calling one throws a BackendError with code UNSUPPORTED. Amounts are koinu (bigint).
ChainTipinterface{ height, hash }A chain tip: height and block hash.
ConfirmationDetailinterface{ txid, amountKoinu, confirmations }Payload of the address watcher's `confirmation` event: the payment and its current confirmation count (amount in koinu).
ConfirmedDetailinterface{ txid, txids, amountKoinu, confirmations }Payload of the address watcher's `confirmed` event: the payments that satisfied the requirement and their total in koinu.
CoreRpcBackendclassclass: name, capabilities, call(), callExact(), getTipHeight(), getNetwork(), getUtxo(), getAddressUtxos(), getAddressTransactions(), getTransaction(), getRawTransaction(), broadcastTransaction(), getFeeEstimates()ChainBackend over Dogecoin Core's JSON-RPC.
CoreRpcOptionsinterface{ url, username?, password?, timeoutMs?, maxResponseBytes?, requireInputs?, fetch?, name? }Settings of a CoreRpcBackend. `url` is required: there is no default endpoint.
CrossCheckinterface{ at, agree, blockcypher?, blockchair? }Last comparison of the two services' chain tips.
DetectedDetailinterface{ txid, amountKoinu, confirmations, totalKoinu, satisfied, transaction }Payload of the address watcher's `detected` event: a new payment (amount in koinu) and the running total.
DisagreementGroupinterface{ backends, summary }Which backends gave which answer when a FallbackBackend could not reach agreement.
DogeNetworktypeDogeNetwork = 'mainnet' | 'testnet' | 'regtest' | 'unknown';The Dogecoin networks this package can tell apart. `unknown` means a genesis hash that is none of the three embedded ones.
ErrorDetailinterface{ error, consecutiveFailures, retryInMs }Payload of a watcher's `error` event: the error, how many polls in a row failed and the delay before the next try.
EsploraBackendclassclass: capabilities, getAddressUtxos(), getUtxo(), getRawTransaction(), broadcastTransaction(), getFeeEstimates()ChainBackend for an Esplora-compatible REST API (electrs-doge). Extends EsploraLiteBackend (tip height, address history, single transactions, network check) with UTXOs, raw transactions, broadcast, fee estimates and outspend lookups.
EsploraLiteBackendclassclass: name, capabilities, base, timeoutMs, maxBytes, pageSize, requireInputs, headers, fetchImpl, getTipHeight(), getNetwork(), getAddressTransactions(), getTransaction(), parseTxList(), getJson(), send(), expectOk()The small Esplora client: only tip height, address history, single transactions and the network check. It is what `@dogejs/backends/lite` exports for web components such as a pay button. It uses the SAME parsers and validation as EsploraBackend (which extends it): nothing is weakened, the unused methods (UTXOs, raw transactions with SHA-256, broadcast, fee estimates, outspends) are just not here. It is not a full ChainBackend, but it is accepted by `watchAddress`.
EsploraOptionsinterface{ baseUrl, timeoutMs?, maxResponseBytes?, chainPageSize?, headers?, requireInputs?, fetch?, name? }Settings of an EsploraBackend or EsploraLiteBackend. `baseUrl` is required: there is no default endpoint.
FallbackBackendclassclass: name, capabilities, getTipHeight(), getAddressUtxos(), getAddressTransactions(), getTransaction(), getRawTransaction(), broadcastTransaction(), getFeeEstimates(), getUtxo(), getNetwork()Wraps several backends.
FallbackOptionsinterface{ agreement?, verifyNetwork?, expectedNetwork?, name? }Settings of a FallbackBackend: optional agreement between backends and network checking.
FeeEstimateOptionsinterface{ targets? }Options for `getFeeEstimates`: the confirmation targets to ask for.
FeeEstimatesinterface{ koinuPerKb, source? }Fee estimates by confirmation target in blocks, as koinu per 1000 bytes (bigint).
GENESIS_HASHESconstGENESIS_HASHES: Readonly<Record<'mainnet' | 'testnet' | 'regtest', string>>Genesis block hash of each network, in the order `getblockhash 0` and Esplora's `/block-height/0` print it.
isBackendErrorfunctionisBackendError(e: unknown): e is BackendError;True if `e` is a BackendError. Works for errors thrown by every backend in this package.
JsonValuetypeJsonValue = null | boolean | string | RawNumber | JsonValue[] | { [key: string]: JsonValue; };A parsed JSON value. Numbers are kept as RawNumber so amounts are never rounded.
networkFromGenesisHashfunctionnetworkFromGenesisHash(hash: string): DogeNetwork;Maps a genesis block hash (any case) to a network name. Anything else is `unknown`.
NetworkReporterinterface{ name, getNetwork? }Anything that can report its network (every ChainBackend in this package that implements `getNetwork`).
PollDetailinterface{ at, durationMs }Detail of the `poll` event, emitted after EVERY successful poll (also when nothing changed).
PublicServiceBackendclassclass: name, capabilities, blockcypher, blockchair, lastCrossCheck, budget(), getNetwork(), getTipHeight(), crossCheck(), getAddressUtxos(), getAddressTransactions(), getTransaction(), getAddressBalance(), independentlySeen(), getRawTransaction(), crossFetchRawTransaction(), broadcastTransaction(), getFeeEstimates()The free public service as one ChainBackend: BlockCypher serves everything (balances, unspent outputs, history, transactions, broadcast); Blockchair, a second independent service, is used to
PublicServiceClientOptionsinterface{ baseUrl?, timeoutMs?, maxResponseBytes?, budget?, budgetStore?, limits?, cacheMs?, fetch?, name?, now? }Settings shared by the free public-service clients (BlockCypherBackend, BlockchairBackend).
PublicServiceOptionsinterface{ blockcypher?, blockchair?, tipTolerance?, crossCheckMs?, absentAfterConfirmations?, name?, now? }Settings of a PublicServiceBackend.
RawNumberclassclass: textA JSON number kept as its exact source text. Dogecoin Core prints amounts as JSON numbers with 8 decimals (`ValueFromAmount`, src/rpc/server.cpp:137 formats "%d.%08d") and Esplora prints koinu as u64 numbers; `JSON.parse` would turn both into IEEE doubles and silently lose precision. This parser keeps the text.
RECOMMENDED_FEE_KOINU_PER_KBconstRECOMMENDED_FEE_KOINU_PER_KB = 1000000nDogecoin Core's recommended fee rate: RECOMMENDED_MIN_TX_FEE = COIN / 100 per 1000 bytes (src/policy/policy.h:23).
ReorgedDetailinterface{ txid, reason, amountKoinu, previousConfirmations, confirmations }Payload of the address watcher's `reorged` event: a payment that was lost or moved, why, and its confirmations before and after.
ReorgReasontypeReorgReason = 'disappeared' | 'unconfirmed' | 'block-changed';Why a watcher reports a reorg: the transaction `disappeared`, went back to `unconfirmed`, or its block changed (`block-changed`).
RequestBudgetclassclass: windows, status(), remaining(), whenFits(), canAfford(), acquire(), record(), pause(), ok()Counts this device's requests to a free public service so it never goes over the published allowance. Every window is a SLIDING window (a log of request times), which is stricter than a refilling token bucket: a token bucket of 100 per hour lets up to 200 requests through in some hour-long spans (a full bucket, then the refill), a sliding window never more than 100.
RequestBudgetOptionsinterface{ windows?, store?, now?, maxWaitMs?, name? }Settings of a RequestBudget.
RequestOptionsinterface{ signal? }Chain data types shared by all backends. All amounts are bigint koinu (1 DOGE = 100_000_000 koinu); no floating point is used for money.
Transactioninterface{ txid, outputs, inputs?, status, feeKoinu? }A transaction as a backend reports it: txid, inputs, outputs (amounts in koinu), status and, when known, the fee.
TransactionWatcherclassclass: getState(), poll()Follows one transaction you sent until it has enough confirmations.
TransactionWatchSourceinterface{ name, capabilities, getTransaction, getTipHeight }What the transaction watcher needs. Every `ChainBackend` fits, and so does the `EsploraLiteBackend` from `@dogejs/backends/lite`.
TxConfirmationDetailinterface{ txid, confirmations }Payload of the transaction watcher's `confirmation` event.
TxConfirmedDetailinterface{ txid, confirmations, blockHeight, blockHash }Payload of the transaction watcher's `confirmed` event, with the block when the backend reports it.
TxInputinterface{ txid, vout, coinbase, sequence?, prevout? }A transaction input as a backend reports it: the outpoint spent, whether it is a coinbase, and the previous output when the server supplies it.
TxOutputinterface{ index, valueKoinu, address?, scriptPubKeyHex? }A transaction output as a backend reports it: index, value in koinu, address (when it is a single standard address) and script.
TxPrevoutinterface{ valueKoinu, address?, scriptPubKeyHex? }The output a transaction input spends, when the backend says what it was.
TxReorgedDetailinterface{ txid, reason, previousConfirmations, confirmations }Payload of the transaction watcher's `reorged` event.
TxSeenDetailinterface{ txid, confirmations, transaction }Payload of the transaction watcher's `seen` event: the transaction as the backend reports it.
TxStatusinterface{ confirmed, blockHeight?, blockHash?, blockTime? }Confirmation status of a transaction: whether it is confirmed and, if so, the block height, hash and time.
TxWatchEventMapinterface{ seen, confirmation, confirmed, reorged, poll, error }The events of a transaction watcher and their payloads: seen, confirmation, confirmed, reorged, poll, error.
TxWatchOptionsinterface{ txid, confirmations?, missingPolls?, stopWhenConfirmed? }Options for watching one transaction: its txid, the confirmations that count as done, and polling settings.
TxWatchStateinterface{ txid, stopped, seen, confirmed, confirmations }Snapshot of a transaction watcher: whether the transaction was seen and confirmed, and its confirmation count.
Utxointerface{ txid, vout, valueKoinu, status }An unspent output: outpoint, value in koinu and the status of the transaction that created it.
UtxoLookuptypeUtxoLookup = { state: 'unspent'; /** The output, with the confirmation status of the transaction that created it. */ utxo: Utxo & { address?: string; scriptPubKeyHex?: string; coinbase?: boolean; }; } | { state: 'spent'; /** The spending transaction and input index, when the backend says (Esplora does; Core does not). */ spentBy?: { txid: string; vin: number; confirmed: boolean; }; } | { /** Th...Result of ChainBackend.getUtxo. `unknown` is returned instead of guessing.
watchAddressfunctionwatchAddress(backend: AddressWatchSource, options: WatchOptions): AddressWatcher;Starts watching an address. Returns immediately; the first poll runs on the next tick.
WatchEventclassclass: detailThe event object a watcher emits (a DOM `Event`); the payload is in `detail`.
WatchEventMapinterface{ detected, confirmation, confirmed, reorged, poll, error }The events of an address watcher and their payloads: detected, confirmation, confirmed, reorged, poll, error.
WatchOptionsinterface{ address, minAmountKoinu?, confirmations?, since?, historyLimit?, stopWhenConfirmed? }Client-side payment detection. This is a CONVENIENCE for showing status in a page. It trusts whatever backend it is given and runs in a browser tab the visitor controls, so it must never be the only check before releasing goods of real value: confirm on the server side (your own node) as well.
WatchStateinterface{ address, stopped, confirmed, totalKoinu, payments }Snapshot of an address watcher: the tracked payments (koinu), their total and whether the requirement is met.
watchTransactionfunctionwatchTransaction(backend: TransactionWatchSource, options: TxWatchOptions): TransactionWatcher;Starts watching one transaction. Returns immediately; the first poll runs on the next tick.
entry-esplora26 exports
NameKindSignatureWhat it does
AddressTransactionsOptionsinterface{ limit? }Options for `getAddressTransactions`: how many transactions to return.
assertNetworkfunctionassertNetwork(backend: NetworkReporter, expected: Exclude<DogeNetwork, 'unknown'>, opts?: { signal?: AbortSignal; }): Promise<void>;Throws a `BackendError` with code `WRONG_NETWORK` unless the backend reports `expected`. `expected` must be a real network ('mainnet', 'testnet' or 'regtest'). A backend that reports `unknown` (a genesis hash that is not one of the three) fails the check. A backend that cannot report its network at all fails with `UNSUPPORTED`: it never passes silently.
BackendCapabilitiesinterface{ getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }Which ChainBackend methods a backend can serve. `getTipHeight` and the rest are never silently emulated.
BackendErrorclassclass: code, status, rpcCode, causes, expectedNetwork, actualNetwork, disagreement, retryAt, [Symbol.hasInstance](), [BRAND]Error thrown by every backend. Messages never contain credentials, the Authorization header or URL user-info.
BackendErrorCodetypeBackendErrorCode = 'NETWORK' | 'HTTP' | 'TIMEOUT' | 'BAD_RESPONSE' | 'UNSUPPORTED' | 'REJECTED' | 'WRONG_NETWORK' | 'RATE_LIMITED';Machine-readable reason codes for BackendError.
BackendErrorDetailsinterface{ status?, rpcCode?, causes?, cause?, expectedNetwork?, actualNetwork?, disagreement?, retryAt? }Extra facts a BackendError can carry: HTTP status, JSON-RPC code, the errors of each backend tried and how backends disagreed. Never contains credentials.
BackendMethodtypeBackendMethod = keyof BackendCapabilities;Name of a data method a backend may serve (a key of BackendCapabilities).
ChainBackendinterface{ name, capabilities, getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }What every chain data client offers: tip height, address UTXOs and transactions, one transaction, broadcast and fee estimates. Methods a backend cannot serve are listed in `capabilities`; calling one throws a BackendError with code UNSUPPORTED. Amounts are koinu (bigint).
DisagreementGroupinterface{ backends, summary }Which backends gave which answer when a FallbackBackend could not reach agreement.
DogeNetworktypeDogeNetwork = 'mainnet' | 'testnet' | 'regtest' | 'unknown';The Dogecoin networks this package can tell apart. `unknown` means a genesis hash that is none of the three embedded ones.
EsploraBackendclassclass: capabilities, getAddressUtxos(), getUtxo(), getRawTransaction(), broadcastTransaction(), getFeeEstimates()ChainBackend for an Esplora-compatible REST API (electrs-doge). Extends EsploraLiteBackend (tip height, address history, single transactions, network check) with UTXOs, raw transactions, broadcast, fee estimates and outspend lookups.
EsploraLiteBackendclassclass: name, capabilities, base, timeoutMs, maxBytes, pageSize, requireInputs, headers, fetchImpl, getTipHeight(), getNetwork(), getAddressTransactions(), getTransaction(), parseTxList(), getJson(), send(), expectOk()The small Esplora client: only tip height, address history, single transactions and the network check. It is what `@dogejs/backends/lite` exports for web components such as a pay button. It uses the SAME parsers and validation as EsploraBackend (which extends it): nothing is weakened, the unused methods (UTXOs, raw transactions with SHA-256, broadcast, fee estimates, outspends) are just not here. It is not a full ChainBackend, but it is accepted by `watchAddress`.
EsploraOptionsinterface{ baseUrl, timeoutMs?, maxResponseBytes?, chainPageSize?, headers?, requireInputs?, fetch?, name? }Settings of an EsploraBackend or EsploraLiteBackend. `baseUrl` is required: there is no default endpoint.
FeeEstimateOptionsinterface{ targets? }Options for `getFeeEstimates`: the confirmation targets to ask for.
FeeEstimatesinterface{ koinuPerKb, source? }Fee estimates by confirmation target in blocks, as koinu per 1000 bytes (bigint).
GENESIS_HASHESconstGENESIS_HASHES: Readonly<Record<'mainnet' | 'testnet' | 'regtest', string>>Genesis block hash of each network, in the order `getblockhash 0` and Esplora's `/block-height/0` print it.
isBackendErrorfunctionisBackendError(e: unknown): e is BackendError;True if `e` is a BackendError. Works for errors thrown by every backend in this package.
networkFromGenesisHashfunctionnetworkFromGenesisHash(hash: string): DogeNetwork;Maps a genesis block hash (any case) to a network name. Anything else is `unknown`.
RequestOptionsinterface{ signal? }Chain data types shared by all backends. All amounts are bigint koinu (1 DOGE = 100_000_000 koinu); no floating point is used for money.
Transactioninterface{ txid, outputs, inputs?, status, feeKoinu? }A transaction as a backend reports it: txid, inputs, outputs (amounts in koinu), status and, when known, the fee.
TxInputinterface{ txid, vout, coinbase, sequence?, prevout? }A transaction input as a backend reports it: the outpoint spent, whether it is a coinbase, and the previous output when the server supplies it.
TxOutputinterface{ index, valueKoinu, address?, scriptPubKeyHex? }A transaction output as a backend reports it: index, value in koinu, address (when it is a single standard address) and script.
TxPrevoutinterface{ valueKoinu, address?, scriptPubKeyHex? }The output a transaction input spends, when the backend says what it was.
TxStatusinterface{ confirmed, blockHeight?, blockHash?, blockTime? }Confirmation status of a transaction: whether it is confirmed and, if so, the block height, hash and time.
Utxointerface{ txid, vout, valueKoinu, status }An unspent output: outpoint, value in koinu and the status of the transaction that created it.
UtxoLookuptypeUtxoLookup = { state: 'unspent'; /** The output, with the confirmation status of the transaction that created it. */ utxo: Utxo & { address?: string; scriptPubKeyHex?: string; coinbase?: boolean; }; } | { state: 'spent'; /** The spending transaction and input index, when the backend says (Esplora does; Core does not). */ spentBy?: { txid: string; vin: number; confirmed: boolean; }; } | { /** Th...Result of ChainBackend.getUtxo. `unknown` is returned instead of guessing.
entry-core-rpc27 exports
NameKindSignatureWhat it does
AddressTransactionsOptionsinterface{ limit? }Options for `getAddressTransactions`: how many transactions to return.
assertNetworkfunctionassertNetwork(backend: NetworkReporter, expected: Exclude<DogeNetwork, 'unknown'>, opts?: { signal?: AbortSignal; }): Promise<void>;Throws a `BackendError` with code `WRONG_NETWORK` unless the backend reports `expected`. `expected` must be a real network ('mainnet', 'testnet' or 'regtest'). A backend that reports `unknown` (a genesis hash that is not one of the three) fails the check. A backend that cannot report its network at all fails with `UNSUPPORTED`: it never passes silently.
BackendCapabilitiesinterface{ getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }Which ChainBackend methods a backend can serve. `getTipHeight` and the rest are never silently emulated.
BackendErrorclassclass: code, status, rpcCode, causes, expectedNetwork, actualNetwork, disagreement, retryAt, [Symbol.hasInstance](), [BRAND]Error thrown by every backend. Messages never contain credentials, the Authorization header or URL user-info.
BackendErrorCodetypeBackendErrorCode = 'NETWORK' | 'HTTP' | 'TIMEOUT' | 'BAD_RESPONSE' | 'UNSUPPORTED' | 'REJECTED' | 'WRONG_NETWORK' | 'RATE_LIMITED';Machine-readable reason codes for BackendError.
BackendErrorDetailsinterface{ status?, rpcCode?, causes?, cause?, expectedNetwork?, actualNetwork?, disagreement?, retryAt? }Extra facts a BackendError can carry: HTTP status, JSON-RPC code, the errors of each backend tried and how backends disagreed. Never contains credentials.
BackendMethodtypeBackendMethod = keyof BackendCapabilities;Name of a data method a backend may serve (a key of BackendCapabilities).
ChainBackendinterface{ name, capabilities, getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }What every chain data client offers: tip height, address UTXOs and transactions, one transaction, broadcast and fee estimates. Methods a backend cannot serve are listed in `capabilities`; calling one throws a BackendError with code UNSUPPORTED. Amounts are koinu (bigint).
CoreRpcBackendclassclass: name, capabilities, call(), callExact(), getTipHeight(), getNetwork(), getUtxo(), getAddressUtxos(), getAddressTransactions(), getTransaction(), getRawTransaction(), broadcastTransaction(), getFeeEstimates()ChainBackend over Dogecoin Core's JSON-RPC.
CoreRpcOptionsinterface{ url, username?, password?, timeoutMs?, maxResponseBytes?, requireInputs?, fetch?, name? }Settings of a CoreRpcBackend. `url` is required: there is no default endpoint.
DisagreementGroupinterface{ backends, summary }Which backends gave which answer when a FallbackBackend could not reach agreement.
DogeNetworktypeDogeNetwork = 'mainnet' | 'testnet' | 'regtest' | 'unknown';The Dogecoin networks this package can tell apart. `unknown` means a genesis hash that is none of the three embedded ones.
FeeEstimateOptionsinterface{ targets? }Options for `getFeeEstimates`: the confirmation targets to ask for.
FeeEstimatesinterface{ koinuPerKb, source? }Fee estimates by confirmation target in blocks, as koinu per 1000 bytes (bigint).
GENESIS_HASHESconstGENESIS_HASHES: Readonly<Record<'mainnet' | 'testnet' | 'regtest', string>>Genesis block hash of each network, in the order `getblockhash 0` and Esplora's `/block-height/0` print it.
isBackendErrorfunctionisBackendError(e: unknown): e is BackendError;True if `e` is a BackendError. Works for errors thrown by every backend in this package.
JsonValuetypeJsonValue = null | boolean | string | RawNumber | JsonValue[] | { [key: string]: JsonValue; };A parsed JSON value. Numbers are kept as RawNumber so amounts are never rounded.
networkFromGenesisHashfunctionnetworkFromGenesisHash(hash: string): DogeNetwork;Maps a genesis block hash (any case) to a network name. Anything else is `unknown`.
RawNumberclassclass: textA JSON number kept as its exact source text. Dogecoin Core prints amounts as JSON numbers with 8 decimals (`ValueFromAmount`, src/rpc/server.cpp:137 formats "%d.%08d") and Esplora prints koinu as u64 numbers; `JSON.parse` would turn both into IEEE doubles and silently lose precision. This parser keeps the text.
RequestOptionsinterface{ signal? }Chain data types shared by all backends. All amounts are bigint koinu (1 DOGE = 100_000_000 koinu); no floating point is used for money.
Transactioninterface{ txid, outputs, inputs?, status, feeKoinu? }A transaction as a backend reports it: txid, inputs, outputs (amounts in koinu), status and, when known, the fee.
TxInputinterface{ txid, vout, coinbase, sequence?, prevout? }A transaction input as a backend reports it: the outpoint spent, whether it is a coinbase, and the previous output when the server supplies it.
TxOutputinterface{ index, valueKoinu, address?, scriptPubKeyHex? }A transaction output as a backend reports it: index, value in koinu, address (when it is a single standard address) and script.
TxPrevoutinterface{ valueKoinu, address?, scriptPubKeyHex? }The output a transaction input spends, when the backend says what it was.
TxStatusinterface{ confirmed, blockHeight?, blockHash?, blockTime? }Confirmation status of a transaction: whether it is confirmed and, if so, the block height, hash and time.
Utxointerface{ txid, vout, valueKoinu, status }An unspent output: outpoint, value in koinu and the status of the transaction that created it.
UtxoLookuptypeUtxoLookup = { state: 'unspent'; /** The output, with the confirmation status of the transaction that created it. */ utxo: Utxo & { address?: string; scriptPubKeyHex?: string; coinbase?: boolean; }; } | { state: 'spent'; /** The spending transaction and input index, when the backend says (Esplora does; Core does not). */ spentBy?: { txid: string; vin: number; confirmed: boolean; }; } | { /** Th...Result of ChainBackend.getUtxo. `unknown` is returned instead of guessing.
entry-fallback27 exports
NameKindSignatureWhat it does
AddressTransactionsOptionsinterface{ limit? }Options for `getAddressTransactions`: how many transactions to return.
AgreementMethodtypeAgreementMethod = 'getTransaction' | 'getAddressUtxos' | 'getTipHeight' | 'getAddressTransactions' | 'getUtxo';Reads that can be cross-checked between backends. Raw transactions are self-verifying (hash == txid) and are never compared.
AgreementOptionsinterface{ quorum, critical?, tipHeightTolerance? }Makes a FallbackBackend ask several backends and compare answers: how many must agree and which reads need it.
assertNetworkfunctionassertNetwork(backend: NetworkReporter, expected: Exclude<DogeNetwork, 'unknown'>, opts?: { signal?: AbortSignal; }): Promise<void>;Throws a `BackendError` with code `WRONG_NETWORK` unless the backend reports `expected`. `expected` must be a real network ('mainnet', 'testnet' or 'regtest'). A backend that reports `unknown` (a genesis hash that is not one of the three) fails the check. A backend that cannot report its network at all fails with `UNSUPPORTED`: it never passes silently.
BackendCapabilitiesinterface{ getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }Which ChainBackend methods a backend can serve. `getTipHeight` and the rest are never silently emulated.
BackendErrorclassclass: code, status, rpcCode, causes, expectedNetwork, actualNetwork, disagreement, retryAt, [Symbol.hasInstance](), [BRAND]Error thrown by every backend. Messages never contain credentials, the Authorization header or URL user-info.
BackendErrorCodetypeBackendErrorCode = 'NETWORK' | 'HTTP' | 'TIMEOUT' | 'BAD_RESPONSE' | 'UNSUPPORTED' | 'REJECTED' | 'WRONG_NETWORK' | 'RATE_LIMITED';Machine-readable reason codes for BackendError.
BackendErrorDetailsinterface{ status?, rpcCode?, causes?, cause?, expectedNetwork?, actualNetwork?, disagreement?, retryAt? }Extra facts a BackendError can carry: HTTP status, JSON-RPC code, the errors of each backend tried and how backends disagreed. Never contains credentials.
BackendMethodtypeBackendMethod = keyof BackendCapabilities;Name of a data method a backend may serve (a key of BackendCapabilities).
ChainBackendinterface{ name, capabilities, getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }What every chain data client offers: tip height, address UTXOs and transactions, one transaction, broadcast and fee estimates. Methods a backend cannot serve are listed in `capabilities`; calling one throws a BackendError with code UNSUPPORTED. Amounts are koinu (bigint).
DisagreementGroupinterface{ backends, summary }Which backends gave which answer when a FallbackBackend could not reach agreement.
DogeNetworktypeDogeNetwork = 'mainnet' | 'testnet' | 'regtest' | 'unknown';The Dogecoin networks this package can tell apart. `unknown` means a genesis hash that is none of the three embedded ones.
FallbackBackendclassclass: name, capabilities, getTipHeight(), getAddressUtxos(), getAddressTransactions(), getTransaction(), getRawTransaction(), broadcastTransaction(), getFeeEstimates(), getUtxo(), getNetwork()Wraps several backends.
FallbackOptionsinterface{ agreement?, verifyNetwork?, expectedNetwork?, name? }Settings of a FallbackBackend: optional agreement between backends and network checking.
FeeEstimateOptionsinterface{ targets? }Options for `getFeeEstimates`: the confirmation targets to ask for.
FeeEstimatesinterface{ koinuPerKb, source? }Fee estimates by confirmation target in blocks, as koinu per 1000 bytes (bigint).
GENESIS_HASHESconstGENESIS_HASHES: Readonly<Record<'mainnet' | 'testnet' | 'regtest', string>>Genesis block hash of each network, in the order `getblockhash 0` and Esplora's `/block-height/0` print it.
isBackendErrorfunctionisBackendError(e: unknown): e is BackendError;True if `e` is a BackendError. Works for errors thrown by every backend in this package.
networkFromGenesisHashfunctionnetworkFromGenesisHash(hash: string): DogeNetwork;Maps a genesis block hash (any case) to a network name. Anything else is `unknown`.
RequestOptionsinterface{ signal? }Chain data types shared by all backends. All amounts are bigint koinu (1 DOGE = 100_000_000 koinu); no floating point is used for money.
Transactioninterface{ txid, outputs, inputs?, status, feeKoinu? }A transaction as a backend reports it: txid, inputs, outputs (amounts in koinu), status and, when known, the fee.
TxInputinterface{ txid, vout, coinbase, sequence?, prevout? }A transaction input as a backend reports it: the outpoint spent, whether it is a coinbase, and the previous output when the server supplies it.
TxOutputinterface{ index, valueKoinu, address?, scriptPubKeyHex? }A transaction output as a backend reports it: index, value in koinu, address (when it is a single standard address) and script.
TxPrevoutinterface{ valueKoinu, address?, scriptPubKeyHex? }The output a transaction input spends, when the backend says what it was.
TxStatusinterface{ confirmed, blockHeight?, blockHash?, blockTime? }Confirmation status of a transaction: whether it is confirmed and, if so, the block height, hash and time.
Utxointerface{ txid, vout, valueKoinu, status }An unspent output: outpoint, value in koinu and the status of the transaction that created it.
UtxoLookuptypeUtxoLookup = { state: 'unspent'; /** The output, with the confirmation status of the transaction that created it. */ utxo: Utxo & { address?: string; scriptPubKeyHex?: string; coinbase?: boolean; }; } | { state: 'spent'; /** The spending transaction and input index, when the backend says (Esplora does; Core does not). */ spentBy?: { txid: string; vin: number; confirmed: boolean; }; } | { /** Th...Result of ChainBackend.getUtxo. `unknown` is returned instead of guessing.
entry-watch44 exports
NameKindSignatureWhat it does
AddressTransactionsOptionsinterface{ limit? }Options for `getAddressTransactions`: how many transactions to return.
AddressWatcherclassclass: getState(), poll()Polls `backend.getAddressTransactions` and emits events. EventTarget based: use `on()` (returns an unsubscribe function) or `addEventListener` (events are WatchEvent with a typed `detail`).
AddressWatchSourceinterface{ name, capabilities, getAddressTransactions, getTipHeight, getTransaction? }What the address watcher needs from a backend. Every `ChainBackend` fits, and so does the small `EsploraLiteBackend` from `@dogejs/backends/lite`.
BackendCapabilitiesinterface{ getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }Which ChainBackend methods a backend can serve. `getTipHeight` and the rest are never silently emulated.
BackendErrorclassclass: code, status, rpcCode, causes, expectedNetwork, actualNetwork, disagreement, retryAt, [Symbol.hasInstance](), [BRAND]Error thrown by every backend. Messages never contain credentials, the Authorization header or URL user-info.
BackendErrorCodetypeBackendErrorCode = 'NETWORK' | 'HTTP' | 'TIMEOUT' | 'BAD_RESPONSE' | 'UNSUPPORTED' | 'REJECTED' | 'WRONG_NETWORK' | 'RATE_LIMITED';Machine-readable reason codes for BackendError.
BackendErrorDetailsinterface{ status?, rpcCode?, causes?, cause?, expectedNetwork?, actualNetwork?, disagreement?, retryAt? }Extra facts a BackendError can carry: HTTP status, JSON-RPC code, the errors of each backend tried and how backends disagreed. Never contains credentials.
BackendMethodtypeBackendMethod = keyof BackendCapabilities;Name of a data method a backend may serve (a key of BackendCapabilities).
ChainBackendinterface{ name, capabilities, getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }What every chain data client offers: tip height, address UTXOs and transactions, one transaction, broadcast and fee estimates. Methods a backend cannot serve are listed in `capabilities`; calling one throws a BackendError with code UNSUPPORTED. Amounts are koinu (bigint).
ConfirmationDetailinterface{ txid, amountKoinu, confirmations }Payload of the address watcher's `confirmation` event: the payment and its current confirmation count (amount in koinu).
ConfirmedDetailinterface{ txid, txids, amountKoinu, confirmations }Payload of the address watcher's `confirmed` event: the payments that satisfied the requirement and their total in koinu.
DetectedDetailinterface{ txid, amountKoinu, confirmations, totalKoinu, satisfied, transaction }Payload of the address watcher's `detected` event: a new payment (amount in koinu) and the running total.
DisagreementGroupinterface{ backends, summary }Which backends gave which answer when a FallbackBackend could not reach agreement.
DogeNetworktypeDogeNetwork = 'mainnet' | 'testnet' | 'regtest' | 'unknown';The Dogecoin networks this package can tell apart. `unknown` means a genesis hash that is none of the three embedded ones.
ErrorDetailinterface{ error, consecutiveFailures, retryInMs }Payload of a watcher's `error` event: the error, how many polls in a row failed and the delay before the next try.
FeeEstimateOptionsinterface{ targets? }Options for `getFeeEstimates`: the confirmation targets to ask for.
FeeEstimatesinterface{ koinuPerKb, source? }Fee estimates by confirmation target in blocks, as koinu per 1000 bytes (bigint).
isBackendErrorfunctionisBackendError(e: unknown): e is BackendError;True if `e` is a BackendError. Works for errors thrown by every backend in this package.
PollDetailinterface{ at, durationMs }Detail of the `poll` event, emitted after EVERY successful poll (also when nothing changed).
ReorgedDetailinterface{ txid, reason, amountKoinu, previousConfirmations, confirmations }Payload of the address watcher's `reorged` event: a payment that was lost or moved, why, and its confirmations before and after.
ReorgReasontypeReorgReason = 'disappeared' | 'unconfirmed' | 'block-changed';Why a watcher reports a reorg: the transaction `disappeared`, went back to `unconfirmed`, or its block changed (`block-changed`).
RequestOptionsinterface{ signal? }Chain data types shared by all backends. All amounts are bigint koinu (1 DOGE = 100_000_000 koinu); no floating point is used for money.
Transactioninterface{ txid, outputs, inputs?, status, feeKoinu? }A transaction as a backend reports it: txid, inputs, outputs (amounts in koinu), status and, when known, the fee.
TransactionWatcherclassclass: getState(), poll()Follows one transaction you sent until it has enough confirmations.
TransactionWatchSourceinterface{ name, capabilities, getTransaction, getTipHeight }What the transaction watcher needs. Every `ChainBackend` fits, and so does the `EsploraLiteBackend` from `@dogejs/backends/lite`.
TxConfirmationDetailinterface{ txid, confirmations }Payload of the transaction watcher's `confirmation` event.
TxConfirmedDetailinterface{ txid, confirmations, blockHeight, blockHash }Payload of the transaction watcher's `confirmed` event, with the block when the backend reports it.
TxInputinterface{ txid, vout, coinbase, sequence?, prevout? }A transaction input as a backend reports it: the outpoint spent, whether it is a coinbase, and the previous output when the server supplies it.
TxOutputinterface{ index, valueKoinu, address?, scriptPubKeyHex? }A transaction output as a backend reports it: index, value in koinu, address (when it is a single standard address) and script.
TxPrevoutinterface{ valueKoinu, address?, scriptPubKeyHex? }The output a transaction input spends, when the backend says what it was.
TxReorgedDetailinterface{ txid, reason, previousConfirmations, confirmations }Payload of the transaction watcher's `reorged` event.
TxSeenDetailinterface{ txid, confirmations, transaction }Payload of the transaction watcher's `seen` event: the transaction as the backend reports it.
TxStatusinterface{ confirmed, blockHeight?, blockHash?, blockTime? }Confirmation status of a transaction: whether it is confirmed and, if so, the block height, hash and time.
TxWatchEventMapinterface{ seen, confirmation, confirmed, reorged, poll, error }The events of a transaction watcher and their payloads: seen, confirmation, confirmed, reorged, poll, error.
TxWatchOptionsinterface{ txid, confirmations?, missingPolls?, stopWhenConfirmed? }Options for watching one transaction: its txid, the confirmations that count as done, and polling settings.
TxWatchStateinterface{ txid, stopped, seen, confirmed, confirmations }Snapshot of a transaction watcher: whether the transaction was seen and confirmed, and its confirmation count.
Utxointerface{ txid, vout, valueKoinu, status }An unspent output: outpoint, value in koinu and the status of the transaction that created it.
UtxoLookuptypeUtxoLookup = { state: 'unspent'; /** The output, with the confirmation status of the transaction that created it. */ utxo: Utxo & { address?: string; scriptPubKeyHex?: string; coinbase?: boolean; }; } | { state: 'spent'; /** The spending transaction and input index, when the backend says (Esplora does; Core does not). */ spentBy?: { txid: string; vin: number; confirmed: boolean; }; } | { /** Th...Result of ChainBackend.getUtxo. `unknown` is returned instead of guessing.
watchAddressfunctionwatchAddress(backend: AddressWatchSource, options: WatchOptions): AddressWatcher;Starts watching an address. Returns immediately; the first poll runs on the next tick.
WatchEventclassclass: detailThe event object a watcher emits (a DOM `Event`); the payload is in `detail`.
WatchEventMapinterface{ detected, confirmation, confirmed, reorged, poll, error }The events of an address watcher and their payloads: detected, confirmation, confirmed, reorged, poll, error.
WatchOptionsinterface{ address, minAmountKoinu?, confirmations?, since?, historyLimit?, stopWhenConfirmed? }Client-side payment detection. This is a CONVENIENCE for showing status in a page. It trusts whatever backend it is given and runs in a browser tab the visitor controls, so it must never be the only check before releasing goods of real value: confirm on the server side (your own node) as well.
WatchStateinterface{ address, stopped, confirmed, totalKoinu, payments }Snapshot of an address watcher: the tracked payments (koinu), their total and whether the requirement is met.
watchTransactionfunctionwatchTransaction(backend: TransactionWatchSource, options: TxWatchOptions): TransactionWatcher;Starts watching one transaction. Returns immediately; the first poll runs on the next tick.
entry-lite37 exports
NameKindSignatureWhat it does
AddressTransactionsOptionsinterface{ limit? }Options for `getAddressTransactions`: how many transactions to return.
AddressWatcherclassclass: getState(), poll()Polls `backend.getAddressTransactions` and emits events. EventTarget based: use `on()` (returns an unsubscribe function) or `addEventListener` (events are WatchEvent with a typed `detail`).
AddressWatchSourceinterface{ name, capabilities, getAddressTransactions, getTipHeight, getTransaction? }What the address watcher needs from a backend. Every `ChainBackend` fits, and so does the small `EsploraLiteBackend` from `@dogejs/backends/lite`.
assertNetworkfunctionassertNetwork(backend: NetworkReporter, expected: Exclude<DogeNetwork, 'unknown'>, opts?: { signal?: AbortSignal; }): Promise<void>;Throws a `BackendError` with code `WRONG_NETWORK` unless the backend reports `expected`. `expected` must be a real network ('mainnet', 'testnet' or 'regtest'). A backend that reports `unknown` (a genesis hash that is not one of the three) fails the check. A backend that cannot report its network at all fails with `UNSUPPORTED`: it never passes silently.
BackendCapabilitiesinterface{ getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }Which ChainBackend methods a backend can serve. `getTipHeight` and the rest are never silently emulated.
BackendErrorclassclass: code, status, rpcCode, causes, expectedNetwork, actualNetwork, disagreement, retryAt, [Symbol.hasInstance](), [BRAND]Error thrown by every backend. Messages never contain credentials, the Authorization header or URL user-info.
BackendErrorCodetypeBackendErrorCode = 'NETWORK' | 'HTTP' | 'TIMEOUT' | 'BAD_RESPONSE' | 'UNSUPPORTED' | 'REJECTED' | 'WRONG_NETWORK' | 'RATE_LIMITED';Machine-readable reason codes for BackendError.
BackendErrorDetailsinterface{ status?, rpcCode?, causes?, cause?, expectedNetwork?, actualNetwork?, disagreement?, retryAt? }Extra facts a BackendError can carry: HTTP status, JSON-RPC code, the errors of each backend tried and how backends disagreed. Never contains credentials.
BackendMethodtypeBackendMethod = keyof BackendCapabilities;Name of a data method a backend may serve (a key of BackendCapabilities).
ChainBackendinterface{ name, capabilities, getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }What every chain data client offers: tip height, address UTXOs and transactions, one transaction, broadcast and fee estimates. Methods a backend cannot serve are listed in `capabilities`; calling one throws a BackendError with code UNSUPPORTED. Amounts are koinu (bigint).
ConfirmationDetailinterface{ txid, amountKoinu, confirmations }Payload of the address watcher's `confirmation` event: the payment and its current confirmation count (amount in koinu).
ConfirmedDetailinterface{ txid, txids, amountKoinu, confirmations }Payload of the address watcher's `confirmed` event: the payments that satisfied the requirement and their total in koinu.
DetectedDetailinterface{ txid, amountKoinu, confirmations, totalKoinu, satisfied, transaction }Payload of the address watcher's `detected` event: a new payment (amount in koinu) and the running total.
DisagreementGroupinterface{ backends, summary }Which backends gave which answer when a FallbackBackend could not reach agreement.
DogeNetworktypeDogeNetwork = 'mainnet' | 'testnet' | 'regtest' | 'unknown';The Dogecoin networks this package can tell apart. `unknown` means a genesis hash that is none of the three embedded ones.
ErrorDetailinterface{ error, consecutiveFailures, retryInMs }Payload of a watcher's `error` event: the error, how many polls in a row failed and the delay before the next try.
EsploraLiteBackendclassclass: name, capabilities, base, timeoutMs, maxBytes, pageSize, requireInputs, headers, fetchImpl, getTipHeight(), getNetwork(), getAddressTransactions(), getTransaction(), parseTxList(), getJson(), send(), expectOk()The small Esplora client: only tip height, address history, single transactions and the network check. It is what `@dogejs/backends/lite` exports for web components such as a pay button. It uses the SAME parsers and validation as EsploraBackend (which extends it): nothing is weakened, the unused methods (UTXOs, raw transactions with SHA-256, broadcast, fee estimates, outspends) are just not here. It is not a full ChainBackend, but it is accepted by `watchAddress`.
EsploraOptionsinterface{ baseUrl, timeoutMs?, maxResponseBytes?, chainPageSize?, headers?, requireInputs?, fetch?, name? }Settings of an EsploraBackend or EsploraLiteBackend. `baseUrl` is required: there is no default endpoint.
FeeEstimateOptionsinterface{ targets? }Options for `getFeeEstimates`: the confirmation targets to ask for.
FeeEstimatesinterface{ koinuPerKb, source? }Fee estimates by confirmation target in blocks, as koinu per 1000 bytes (bigint).
isBackendErrorfunctionisBackendError(e: unknown): e is BackendError;True if `e` is a BackendError. Works for errors thrown by every backend in this package.
PollDetailinterface{ at, durationMs }Detail of the `poll` event, emitted after EVERY successful poll (also when nothing changed).
ReorgedDetailinterface{ txid, reason, amountKoinu, previousConfirmations, confirmations }Payload of the address watcher's `reorged` event: a payment that was lost or moved, why, and its confirmations before and after.
ReorgReasontypeReorgReason = 'disappeared' | 'unconfirmed' | 'block-changed';Why a watcher reports a reorg: the transaction `disappeared`, went back to `unconfirmed`, or its block changed (`block-changed`).
RequestOptionsinterface{ signal? }Chain data types shared by all backends. All amounts are bigint koinu (1 DOGE = 100_000_000 koinu); no floating point is used for money.
Transactioninterface{ txid, outputs, inputs?, status, feeKoinu? }A transaction as a backend reports it: txid, inputs, outputs (amounts in koinu), status and, when known, the fee.
TxInputinterface{ txid, vout, coinbase, sequence?, prevout? }A transaction input as a backend reports it: the outpoint spent, whether it is a coinbase, and the previous output when the server supplies it.
TxOutputinterface{ index, valueKoinu, address?, scriptPubKeyHex? }A transaction output as a backend reports it: index, value in koinu, address (when it is a single standard address) and script.
TxPrevoutinterface{ valueKoinu, address?, scriptPubKeyHex? }The output a transaction input spends, when the backend says what it was.
TxStatusinterface{ confirmed, blockHeight?, blockHash?, blockTime? }Confirmation status of a transaction: whether it is confirmed and, if so, the block height, hash and time.
Utxointerface{ txid, vout, valueKoinu, status }An unspent output: outpoint, value in koinu and the status of the transaction that created it.
UtxoLookuptypeUtxoLookup = { state: 'unspent'; /** The output, with the confirmation status of the transaction that created it. */ utxo: Utxo & { address?: string; scriptPubKeyHex?: string; coinbase?: boolean; }; } | { state: 'spent'; /** The spending transaction and input index, when the backend says (Esplora does; Core does not). */ spentBy?: { txid: string; vin: number; confirmed: boolean; }; } | { /** Th...Result of ChainBackend.getUtxo. `unknown` is returned instead of guessing.
watchAddressfunctionwatchAddress(backend: AddressWatchSource, options: WatchOptions): AddressWatcher;Starts watching an address. Returns immediately; the first poll runs on the next tick.
WatchEventclassclass: detailThe event object a watcher emits (a DOM `Event`); the payload is in `detail`.
WatchEventMapinterface{ detected, confirmation, confirmed, reorged, poll, error }The events of an address watcher and their payloads: detected, confirmation, confirmed, reorged, poll, error.
WatchOptionsinterface{ address, minAmountKoinu?, confirmations?, since?, historyLimit?, stopWhenConfirmed? }Client-side payment detection. This is a CONVENIENCE for showing status in a page. It trusts whatever backend it is given and runs in a browser tab the visitor controls, so it must never be the only check before releasing goods of real value: confirm on the server side (your own node) as well.
WatchStateinterface{ address, stopped, confirmed, totalKoinu, payments }Snapshot of an address watcher: the tracked payments (koinu), their total and whether the requirement is met.
entry-public41 exports
NameKindSignatureWhat it does
AddressBalanceinterface{ address, confirmedKoinu, unconfirmedKoinu, finalKoinu, totalReceivedKoinu, totalSentKoinu, txCount, unconfirmedTxCount }Balance of one address as BlockCypher reports it (koinu; exact for any size).
AddressTransactionsOptionsinterface{ limit? }Options for `getAddressTransactions`: how many transactions to return.
assertNetworkfunctionassertNetwork(backend: NetworkReporter, expected: Exclude<DogeNetwork, 'unknown'>, opts?: { signal?: AbortSignal; }): Promise<void>;Throws a `BackendError` with code `WRONG_NETWORK` unless the backend reports `expected`. `expected` must be a real network ('mainnet', 'testnet' or 'regtest'). A backend that reports `unknown` (a genesis hash that is not one of the three) fails the check. A backend that cannot report its network at all fails with `UNSUPPORTED`: it never passes silently.
BackendCapabilitiesinterface{ getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }Which ChainBackend methods a backend can serve. `getTipHeight` and the rest are never silently emulated.
BackendErrorclassclass: code, status, rpcCode, causes, expectedNetwork, actualNetwork, disagreement, retryAt, [Symbol.hasInstance](), [BRAND]Error thrown by every backend. Messages never contain credentials, the Authorization header or URL user-info.
BackendErrorCodetypeBackendErrorCode = 'NETWORK' | 'HTTP' | 'TIMEOUT' | 'BAD_RESPONSE' | 'UNSUPPORTED' | 'REJECTED' | 'WRONG_NETWORK' | 'RATE_LIMITED';Machine-readable reason codes for BackendError.
BackendErrorDetailsinterface{ status?, rpcCode?, causes?, cause?, expectedNetwork?, actualNetwork?, disagreement?, retryAt? }Extra facts a BackendError can carry: HTTP status, JSON-RPC code, the errors of each backend tried and how backends disagreed. Never contains credentials.
BackendMethodtypeBackendMethod = keyof BackendCapabilities;Name of a data method a backend may serve (a key of BackendCapabilities).
BLOCKCHAIR_DOGECOIN_URLconstBLOCKCHAIR_DOGECOIN_URL = "https://api.blockchair.com/dogecoin"The public Blockchair Dogecoin (mainnet) API.
BLOCKCHAIR_FREE_LIMITSconstBLOCKCHAIR_FREE_LIMITS: readonly BudgetWindow[]Blockchair's documented keyless allowance (about 30 per minute and 1,440 per day per IP; not verified by DogeJS).
BlockchairBackendclassclass: name, capabilities, http, budgetStatus(), getTip(), getTipHeight(), getRawTransaction(), getAddressUtxos(), getAddressTransactions(), getTransaction(), broadcastTransaction(), getFeeEstimates()A second, independent free service with only two uses here: the chain tip (to cross-check BlockCypher's) and raw transactions (hash-checked, so a copy that comes from an indexer other than the one that listed your coins). It is a partial ChainBackend: the other methods are not offered (`capabilities` says so) and throw UNSUPPORTED. It cannot report its network from a genesis hash; its URL path names the chain.
BLOCKCYPHER_FREE_LIMITSconstBLOCKCYPHER_FREE_LIMITS: readonly BudgetWindow[]BlockCypher's published free allowance (pricing page, per IP): 3 per second, 100 per hour, 1000 per day.
BLOCKCYPHER_MAINNET_URLconstBLOCKCYPHER_MAINNET_URL = "https://api.blockcypher.com/v1/doge/main"The public BlockCypher Dogecoin mainnet API.
BlockCypherBackendclassclass: name, capabilities, http, budgetStatus(), getTip(), getTipHeight(), getNetwork(), getAddressBalance(), getAddressBalances(), getAddressUtxos(), getAddressTransactions(), getTransaction(), getRawTransaction(), cachedTransaction(), cachedRawTransaction(), broadcastTransaction(), getFeeEstimates()ChainBackend for the free BlockCypher Dogecoin API (mainnet only; BlockCypher has no Dogecoin test network). No API key: the browser calls it directly, so the limits apply to the visitor's IP.
BlockCypherOptionsinterface{ tipCacheMs? }Settings of a BlockCypherBackend.
BudgetStatusinterface{ windows, pausedUntil?, nextAt }Snapshot of a budget: every window, a 429 pause if any, and when the next request may go.
BudgetStoreinterface{ get, set }Where a RequestBudget keeps its counts between page loads (and between tabs of the same site, which share one IP address and so one allowance). `localStorage` fits: pass `{ get: () => localStorage.getItem(k), set: (v) => localStorage.setItem(k, v) }`. Both calls must be synchronous; failures are ignored (the budget then lives in memory only).
BudgetWindowinterface{ ms, max, label }One limit: at most `max` requests in any `ms` long window.
BudgetWindowStatusinterface{ label, max, used, remaining, nextAt }Remaining requests in one window, and when the next slot in it frees up.
ChainBackendinterface{ name, capabilities, getTipHeight, getAddressUtxos, getAddressTransactions, getTransaction, getRawTransaction, broadcastTransaction, getFeeEstimates, getNetwork?, getUtxo? }What every chain data client offers: tip height, address UTXOs and transactions, one transaction, broadcast and fee estimates. Methods a backend cannot serve are listed in `capabilities`; calling one throws a BackendError with code UNSUPPORTED. Amounts are koinu (bigint).
ChainTipinterface{ height, hash }A chain tip: height and block hash.
CrossCheckinterface{ at, agree, blockcypher?, blockchair? }Last comparison of the two services' chain tips.
DisagreementGroupinterface{ backends, summary }Which backends gave which answer when a FallbackBackend could not reach agreement.
DogeNetworktypeDogeNetwork = 'mainnet' | 'testnet' | 'regtest' | 'unknown';The Dogecoin networks this package can tell apart. `unknown` means a genesis hash that is none of the three embedded ones.
FeeEstimateOptionsinterface{ targets? }Options for `getFeeEstimates`: the confirmation targets to ask for.
FeeEstimatesinterface{ koinuPerKb, source? }Fee estimates by confirmation target in blocks, as koinu per 1000 bytes (bigint).
isBackendErrorfunctionisBackendError(e: unknown): e is BackendError;True if `e` is a BackendError. Works for errors thrown by every backend in this package.
PublicServiceBackendclassclass: name, capabilities, blockcypher, blockchair, lastCrossCheck, budget(), getNetwork(), getTipHeight(), crossCheck(), getAddressUtxos(), getAddressTransactions(), getTransaction(), getAddressBalance(), independentlySeen(), getRawTransaction(), crossFetchRawTransaction(), broadcastTransaction(), getFeeEstimates()The free public service as one ChainBackend: BlockCypher serves everything (balances, unspent outputs, history, transactions, broadcast); Blockchair, a second independent service, is used to
PublicServiceClientOptionsinterface{ baseUrl?, timeoutMs?, maxResponseBytes?, budget?, budgetStore?, limits?, cacheMs?, fetch?, name?, now? }Settings shared by the free public-service clients (BlockCypherBackend, BlockchairBackend).
PublicServiceOptionsinterface{ blockcypher?, blockchair?, tipTolerance?, crossCheckMs?, absentAfterConfirmations?, name?, now? }Settings of a PublicServiceBackend.
RECOMMENDED_FEE_KOINU_PER_KBconstRECOMMENDED_FEE_KOINU_PER_KB = 1000000nDogecoin Core's recommended fee rate: RECOMMENDED_MIN_TX_FEE = COIN / 100 per 1000 bytes (src/policy/policy.h:23).
RequestBudgetclassclass: windows, status(), remaining(), whenFits(), canAfford(), acquire(), record(), pause(), ok()Counts this device's requests to a free public service so it never goes over the published allowance. Every window is a SLIDING window (a log of request times), which is stricter than a refilling token bucket: a token bucket of 100 per hour lets up to 200 requests through in some hour-long spans (a full bucket, then the refill), a sliding window never more than 100.
RequestBudgetOptionsinterface{ windows?, store?, now?, maxWaitMs?, name? }Settings of a RequestBudget.
RequestOptionsinterface{ signal? }Chain data types shared by all backends. All amounts are bigint koinu (1 DOGE = 100_000_000 koinu); no floating point is used for money.
Transactioninterface{ txid, outputs, inputs?, status, feeKoinu? }A transaction as a backend reports it: txid, inputs, outputs (amounts in koinu), status and, when known, the fee.
TxInputinterface{ txid, vout, coinbase, sequence?, prevout? }A transaction input as a backend reports it: the outpoint spent, whether it is a coinbase, and the previous output when the server supplies it.
TxOutputinterface{ index, valueKoinu, address?, scriptPubKeyHex? }A transaction output as a backend reports it: index, value in koinu, address (when it is a single standard address) and script.
TxPrevoutinterface{ valueKoinu, address?, scriptPubKeyHex? }The output a transaction input spends, when the backend says what it was.
TxStatusinterface{ confirmed, blockHeight?, blockHash?, blockTime? }Confirmation status of a transaction: whether it is confirmed and, if so, the block height, hash and time.
Utxointerface{ txid, vout, valueKoinu, status }An unspent output: outpoint, value in koinu and the status of the transaction that created it.
UtxoLookuptypeUtxoLookup = { state: 'unspent'; /** The output, with the confirmation status of the transaction that created it. */ utxo: Utxo & { address?: string; scriptPubKeyHex?: string; coinbase?: boolean; }; } | { state: 'spent'; /** The spending transaction and input index, when the backend says (Esplora does; Core does not). */ spentBy?: { txid: string; vin: number; confirmed: boolean; }; } | { /** Th...Result of ChainBackend.getUtxo. `unknown` is returned instead of guessing.

Self-hosting and source

Source: github.com/DogeJS-Dev/backends (package @dogejs/backends).

Shell
git clone https://github.com/DogeJS-Dev/backends
cd backends
npm install
npm run build
npm test

FAQ

Which backend should I use?

Run an Esplora-style indexer (electrs-doge) you control, and put a second one behind a FallbackBackend for quorum. Public services are free but rate limited; the request budget keeps you under their limits.

Does Core RPC have an address index?

No. The Core backend reads what Core can answer by itself; see the capability matrix above for what that excludes.

What happens when a server lies?

Responses are validated, amounts are exact and previous transactions are checked by txid; with a fallback you can require several servers to agree.