Providers

WhatsOnChain

Bitcoin SV through WhatsOnChain. Balances, history, unspent outputs, transactions and blocks. Satoshis. Three requests a second without a key.
provider
create("whatsonchain")
auth
optional WHATSONCHAIN_API_KEY
chains
Bitcoin SV
capabilities
balance, history, tx detail, utxos, block
endpoint
api.whatsonchain.com/v1/bsv/main
default chain
bitcoinsv

Address it

import { WhatsOnChain } from "@agntn/explorers/providers/whatsonchain";

const woc = new WhatsOnChain(); // or create("whatsonchain")
await woc.getBalance("1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF", "bitcoinsv");
await woc.getTxHistory("1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF", "bitcoinsv", { limit: 10 });

One chain. The key is optional: WhatsOnChain answers three requests a second without one, and WHATSONCHAIN_API_KEY goes out in the Authorization header for a paid plan. baseUrl is the network root, https://api.whatsonchain.com/v1/bsv/main by default. Any other chain is an UnsupportedChainError. An address Bitcoin SV doesn't take, a 3... P2SH one for example, fails before a request goes out.

What it reads

OperationRoute
balance/address/{address}/confirmed/balance and /unconfirmed/balance
history/address/{address}/confirmed/history, then POST /txs, 20 hashes a go
one transaction/tx/hash/{txid}
unspent outputs/address/{address}/unspent/all
block/block/height/{height}

No gas and no tokens. /feerecommendation quotes satoshis per kilobyte, and nothing else in this library speaks that unit, so gas stays unsupported rather than converted into something that looks like sat/vB.

Gotchas

  • A legacy 1... address is valid on Bitcoin and on Bitcoin SV. Without a chain it reads as Bitcoin, where far more of them live, so ask for -c bsv or -p whatsonchain when you mean the fork. Naming the provider is enough, the address then reads as the one chain WhatsOnChain serves.
  • An input on WhatsOnChain names only the output it spends, not the address or the amount. So the sender, the fee and the question "did this address pay into it" all come from the parent transactions, fetched through POST /txs twenty at a time. A page of 25 transactions is about five requests. A read stops after 200 parents, which is ten requests, so a consolidation of thousands of inputs doesn't eat your rate limit. Past that the fee stays out of the row, since half a sum would be a wrong number.
  • Seen from an address, a transaction is a send when one of its inputs spent that address's output. 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.
  • History lists confirmed transactions only. Pending ones show up as the signed unconfirmed delta on the balance and as unconfirmed unspent outputs, not as rows.
  • limit up to 100, page up to 10. WhatsOnChain pages with next-page tokens, so page 3 costs three requests. startBlock and endBlock throw. The API also lists a page the other way round from the order you asked for, transactions of one block included, and the provider reverses it back.
  • Amounts arrive as BSV in JSON numbers, and the small ones in exponent form, one satoshi as 1e-8. The provider turns them into satoshis from the decimal spelling, no float multiplication.
  • OP_RETURN outputs, bare or the OP_FALSE OP_RETURN Bitcoin SV uses, never become the recipient. Their payloads stay in raw and don't get decoded into opReturn the way Mempool does it.
  • Unspent outputs come back with the height and without the block hash, because WhatsOnChain doesn't send one, so blockHash stays null. An output some mempool transaction already spends is left out. The list stops after ten pages, about ten thousand confirmed outputs.
  • A block has an empty miner, since WhatsOnChain names the pool by its tag and not by an address, and gas fields of "0", like every other chain without gas.
  • The Explorer has no live feed for Bitcoin SV. Search works, the hub says there's no tip.

Where it lives

src/providers/whatsonchain.ts.

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