Read Dogecoin balances, transactions and fees from servers you choose, cross-check several of them, and watch an address for payments.
Live demo · Documentation · All DogeJS projects
- Reads balances, transactions, coins and fees from an Esplora-style indexer (such as electrs-doge) or from your own Dogecoin Core node over JSON-RPC.
- Checks what a server says: responses are validated, amounts are exact, and a raw transaction must hash to the txid you asked for.
- Cross-checks several servers:
FallbackBackendfails over, can require two or three servers to agree, and refuses a server on the wrong network. - Watches an address or a transaction and tells you when a payment is detected, confirmed or reorged.
- Has named clients for the free public services (BlockCypher and Blockchair) with a request budget kept in the client. No runtime dependencies.
Watch a simulated payment arrive, compare three servers and check your own server: https://dogejs.com/backends/
npm install github:DogeJS-Dev/backends#v0.3.0Three simulated servers that must agree, one of which lies.
Point it at your own Esplora server and check which network it serves.
Nothing is on npm yet, so install straight from this repository (it needs a public repository, or a GitHub login that can read it). The prepare script builds dist as part of the install.
npm install github:DogeJS-Dev/backends#v0.3.0Once the package is on npm this becomes npm install @dogejs/backends. 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. This example starts a tiny stand-in indexer so that it runs offline:
import { createServer } from 'node:http';
import { EsploraBackend } from '@dogejs/backends';
// A stand-in indexer so the example runs offline. In real use, pass the URL of your own electrs-doge.
const server = createServer((req, res) => {
res.end(req.url === '/blocks/tip/height' ? '5123456' : '[]');
}).listen(0);
await new Promise((r) => server.once('listening', r));
const backend = new EsploraBackend({ baseUrl: `http://127.0.0.1:${server.address().port}` });
console.log(await backend.getTipHeight()); // 5123456
server.close();Watching an address for a payment:
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, confirmations: 1 });
watcher.on('confirmed', (c) => console.log('paid', c.amountKoinu));
watcher.on('error', (e) => console.log('retrying in', e.retryInMs, 'ms'));You bring a server. The package checks the shape and arithmetic of what it says, not whether it is true: a server is a remote party. Your own node is the strongest choice, and a quorum of independent servers protects against one that lies. assertNetwork reads the genesis block of a server and refuses one that serves another network, which catches a mainnet URL in a testnet setup. Watchers poll and emit detected, confirmation, confirmed and reorged. Subpath entries (/esplora, /core-rpc, /fallback, /watch, /lite, /public) keep bundles small.
The full reference is in docs/REFERENCE.md.
- core for keys, addresses and transactions. Backends has no runtime dependency on it (only its tests compare against it).
- Used by pay-button, cli, wallet, browser-utilities, shop-mode, payment-links, watch and integration-tests.
Version 0.3.0. It is not published to npm yet, so you install it from git. It has had no external security review. The Esplora and Core clients were written from the electrs-doge and Dogecoin Core sources and tested against mocked servers; they have never been run against a real server or a real Dogecoin node. The free public-service clients (BlockCypher and Blockchair) follow responses captured from the real services, read endpoints only. That service is free and public, not run by DogeJS, and limited: a successful broadcast through BlockCypher has never been made, and its free limits were taken from its documentation.
Bug reports, ideas and pull requests are welcome. Read the contributing guide first: small, tested, explained.
npm install
npm run build
npm run typecheck
npm testReport a security problem privately to hello@dogejs.com, never in a public issue. See SECURITY.md.
The maintainers keep one combined development workspace for all DogeJS projects and publish each project from it as a repository of its own. An accepted pull request is applied there and appears here with the next release.
MIT, see LICENSE.



