Providers

Blockbook

Bitcoin Gold through the Blockbook API of btgexplorer.com. Balances, history, unspent outputs, transactions and blocks. Satoshis, no key.
provider
create("blockbook")
auth
none
chains
Bitcoin Gold
capabilities
balance, history, tx detail, utxos, block
endpoint
btgexplorer.com
default chain
bitcoingold

Address it

import { Blockbook } from "@agntn/explorers/providers/blockbook";

const btg = new Blockbook(); // or create("blockbook")
await btg.getBalance("GNiT8AiCaMYPYW9uSgmq2qUsVjNgh1kdty", "bitcoingold");
await btg.getTxHistory("GNiT8AiCaMYPYW9uSgmq2qUsVjNgh1kdty", "bitcoingold", { limit: 10 });

One chain, no key. Blockbook is the indexer Trezor wrote for its wallet, and btgexplorer.com runs a public instance of it for Bitcoin Gold. baseUrl is the explorer root, the part before /api/v2, https://btgexplorer.com by default. There's no published limit and no key to raise one, so for anything heavy point baseUrl at your own Blockbook. Any other chain is an UnsupportedChainError. An address Bitcoin Gold doesn't take, a Bitcoin 1... one for example, fails before a request goes out.

What it reads

OperationRoute
balance/api/v2/address/{address}?details=basic
history/api/v2/address/{address}?details=txs
one transaction/api/v2/tx/{txid}
unspent outputs/api/v2/utxo/{address}
block/api/v2/block/{height}

No gas and no tokens. /api/v2/estimatefee quotes BTG per kilobyte straight from the node, and nothing else in this library speaks that unit, so gas stays unsupported rather than converted into something that looks like sat/vB.

Gotchas

  • Blockbook resolves every input to the address and the amount it spends. So the sender and the fee come with the transaction itself, one request per page, no parent lookups like on WhatsOnChain.
  • Seen from an address, a transaction is a send when one of its inputs spent from that address. Then value is what went to everyone else and to is the first of them. Otherwise it's a receive and value is what landed on the address.
  • Ask for a page past the end and Blockbook answers with the last page, not an empty one. The provider checks the page number it got back and returns [], so a loop over pages ends where it should.
  • History comes newest first and only that way. sort: "asc" throws instead of quietly giving you the wrong order. startBlock and endBlock work, they go out as Blockbook's from and to.
  • limit up to 100. A page carries full transactions, every input and its script, so 100 rows of a busy pool address are about 1.4 MB.
  • A transaction still in the mempool reads as pending at block 0.
  • Balance comes with funded and spent totals and the signed unconfirmed delta. No block height, the endpoint doesn't send one, so blockNumber stays null.
  • Unspent outputs come with the height and without the block hash, so blockHash stays null. Unconfirmed ones are in the list with confirmed: false.
  • A missing transaction or block is a 400 with the reason inside, which the provider turns into NotFoundError. Any other reason travels in the message of a plain ExplorerError.
  • OP_RETURN outputs never become the recipient. Their payloads stay in raw and don't get decoded into opReturn the way Mempool does it.
  • A block has an empty miner and gas fields of "0", like every other chain without gas.
  • The Explorer has no live feed for Bitcoin Gold. Search works, the hub says there's no tip.

Where it lives

src/providers/blockbook.ts.

@agntn/explorers·MIT license· Read-only. Addresses you type go to a public explorer API, never to a wallet.