---
title: "Getting Started"
description: "Install the package and read one balance. The same shape comes back whether Etherscan or Mempool or dcrdata or an Arweave gateway answered."
canonical_url: "https://explorers.agntn.dev/guide"
---
# Getting Started

> Install the package and read one balance. The same shape comes back whether Etherscan or Mempool or dcrdata or an Arweave gateway answered.

<warning title="Pre-1.0">

The API and the tool list can still move. Pin exact versions if you build on it now.

</warning>

## Why this exists

Every block explorer answers the same questions and none of them agree on how. Etherscan wants a chain id and a key in the query. Blockscout wants neither. Koios wants the address in a POST body. TONAPI answers in nanotons, Arweave in winstons. Solscan and Helius can't even agree on which Solana questions exist.

Keep one client per explorer in a script or an agent and you've got twenty-three ways to misread a number.

So `@agntn/explorers` puts one abstract `Provider` in front of all of it. Two required reads, eight optional ones, one `Balance`, one `Transaction`, one `Utxo`, one `TokenBalance`, one `GasData`, one `BlockInfo`. Amounts are strings in the chain's smallest unit, so nothing gets rounded before you decide it should be. And when you don't say which provider, it picks one from the keys you have and tells you which.

## Install

```bash
pnpm add @agntn/explorers
```

Node.js 26 or newer.

## First call

Blockscout needs no key, so this works with no config at all:

```ts [balance.ts]
import { create, resolveEns, resolveProvider } from "@agntn/explorers";

const provider = await create(resolveProvider(undefined, "ethereum"));
const address = await resolveEns("vitalik.eth");
if (!address) throw new Error("ENS name did not resolve");

const balance = await provider.getBalance(address, "ethereum");
const transactions = await provider.getTxHistory(address, "ethereum", { limit: 10 });

console.log(`${balance.balanceFormatted} ${balance.symbol}`);
console.log(transactions.map((transaction) => transaction.hash));
```

Set `ETHERSCAN_API_KEY` and the same two lines go through Etherscan instead. Nothing else changes. The whole ranking is in [Provider selection](https://explorers.agntn.dev/guide/selection).

## Same call, any chain

```ts
const mempool = await create("mempool");
await mempool.getBalance("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa", "bitcoin");

const dcrdata = await create("dcrdata");
await dcrdata.getBlockInfo(1000, "decred");

const arweave = await create("arweave");
await arweave.getBalance("FPjbN_btYKzcf8QASjs30v5C0FPv7XpwKXENBW8dqVw", "arweave");
```

The [Explorer](https://explorers.agntn.dev/explorer) runs these exact calls against the docs worker, so you see what comes back before you write a line.

## Optional operations

Required operations live on `Provider`. Optional ones stay absent when a backend can't serve them, so both the flag and the method have to say yes. `requireOperation()` asks both and hands the method back bound:

```ts
import { requireOperation } from "@agntn/explorers";

const getContractInfo = requireOperation(provider, "getContractInfo");
const contract = await getContractInfo("0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", "ethereum");
console.log(contract.isVerified, contract.name);
```

A provider without contract metadata gets `UnsupportedOperationError` right there, before any request. There's no stub that returns convincing nonsense, and no `if` you can pair with the wrong flag. The CLI, the MCP server, both agent extensions and the docs worker all gate through this one function.

## What ships

<table>
<thead>
  <tr>
    <th>
      Operation
    </th>
    
    <th>
      Method
    </th>
    
    <th>
      Where
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      native balance
    </td>
    
    <td>
      <code>
        getBalance
      </code>
    </td>
    
    <td>
      every provider except Helius, eCash Explorer and Aptos
    </td>
  </tr>
  
  <tr>
    <td>
      transaction history
    </td>
    
    <td>
      <code>
        getTxHistory
      </code>
    </td>
    
    <td>
      every provider except Aptos
    </td>
  </tr>
  
  <tr>
    <td>
      one transaction
    </td>
    
    <td>
      <code>
        getTxDetail
      </code>
    </td>
    
    <td>
      all but TONAPI, Blockberry, eCash Explorer and Aptos
    </td>
  </tr>
  
  <tr>
    <td>
      where outputs went
    </td>
    
    <td>
      <code>
        getOutspends
      </code>
    </td>
    
    <td>
      Mempool on Bitcoin and Litecoin, Blockstream
    </td>
  </tr>
  
  <tr>
    <td>
      signed hex
    </td>
    
    <td>
      <code>
        getTxHex
      </code>
    </td>
    
    <td>
      Mempool, Blockstream
    </td>
  </tr>
  
  <tr>
    <td>
      unspent outputs
    </td>
    
    <td>
      <code>
        getUtxos
      </code>
    </td>
    
    <td>
      Mempool, Blockstream, WhatsOnChain, Blockbook, Haskoin, BlockCypher
    </td>
  </tr>
  
  <tr>
    <td>
      shown public key
    </td>
    
    <td>
      <code>
        getPubkey
      </code>
    </td>
    
    <td>
      Mempool, Blockstream
    </td>
  </tr>
  
  <tr>
    <td>
      contract metadata
    </td>
    
    <td>
      <code>
        getContractInfo
      </code>
    </td>
    
    <td>
      Etherscan, Blockscout
    </td>
  </tr>
  
  <tr>
    <td>
      token holdings
    </td>
    
    <td>
      <code>
        getTokenBalances
      </code>
    </td>
    
    <td>
      Etherscan, Blockscout, Helius, Koios, Horizon, XRPSCAN
    </td>
  </tr>
  
  <tr>
    <td>
      token transfers
    </td>
    
    <td>
      <code>
        getTokenTransfers
      </code>
    </td>
    
    <td>
      Etherscan, Blockscout, Horizon
    </td>
  </tr>
  
  <tr>
    <td>
      gas suggestions
    </td>
    
    <td>
      <code>
        getGasData
      </code>
    </td>
    
    <td>
      Etherscan, Blockscout, Mempool on Bitcoin and Litecoin, Horizon
    </td>
  </tr>
  
  <tr>
    <td>
      one block
    </td>
    
    <td>
      <code>
        getBlockInfo
      </code>
    </td>
    
    <td>
      all but TONAPI, Helius, Blockberry, Koios and Aptos
    </td>
  </tr>
</tbody>
</table>

The per provider detail, with the traps, is on the [provider pages](https://explorers.agntn.dev/providers). The per chain view is on [Chains](https://explorers.agntn.dev/providers/chains).

## One provider, no registry

```ts
import { Mempool } from "@agntn/explorers/providers/mempool";

const mempool = new Mempool({ timeout: 30_000 });
```

A sub path import gives you the class and leaves the other eighteen out of your bundle. `create()` is asynchronous for the same reason: it imports the one provider it was asked for and nothing else. Everything the registry answers without an instance, `providers()`, `has()`, `supportsChain()`, `supportsCapability()`, `getDefaultURL()` and `resolveProvider()`, stays synchronous and reads only metadata.

## Next

- [CLI](https://explorers.agntn.dev/guide/cli): the same reads from a terminal, `explorers vitalik.eth` and done.
- [Provider selection](https://explorers.agntn.dev/guide/selection): how a provider gets picked and when a read is retried.
- [Balances](https://explorers.agntn.dev/guide/balances), [Transactions](https://explorers.agntn.dev/guide/transactions), [Tokens](https://explorers.agntn.dev/guide/tokens), [Contracts](https://explorers.agntn.dev/guide/contracts), [Gas and blocks](https://explorers.agntn.dev/guide/gas-and-blocks).
- [Errors](https://explorers.agntn.dev/guide/errors): one hierarchy, keys stripped from every message.
- [Agents](https://explorers.agntn.dev/guide/agents): twelve tools over MCP, Pi, OMP and the AI SDK.


## Sitemap

See the full [sitemap](https://explorers.agntn.dev/sitemap.md) for all pages.
