---
title: "Etherscan"
description: "The v2 API with one key for ten EVM chains and every operation. Five requests a second on the free tier. First choice whenever ETHERSCAN_API_KEY is set."
canonical_url: "https://explorers.agntn.dev/providers/etherscan"
---
# Etherscan

> The v2 API with one key for ten EVM chains and every operation. Five requests a second on the free tier. First choice whenever ETHERSCAN_API_KEY is set.

<provider-facts provider="etherscan">



</provider-facts>

## Address it

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

const etherscan = await create("etherscan"); // ETHERSCAN_API_KEY from the environment
await etherscan.getBalance("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "base");
```

One key, ten chains. The provider sends the chain id with every request to `api.etherscan.io/v2/api`, so Base, Arbitrum, Optimism, Polygon, BSC, Avalanche, Gnosis, Linea and Berachain go through the same endpoint as Ethereum. Without the key the constructor throws `AuthError` before any request goes out.

## What it reads

<table>
<thead>
  <tr>
    <th>
      Operation
    </th>
    
    <th>
      Action
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      balance
    </td>
    
    <td>
      <code>
        account.balance
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      history
    </td>
    
    <td>
      <code>
        account.txlist
      </code>
      
      , with <code>
        startblock
      </code>
      
      , <code>
        endblock
      </code>
      
      , <code>
        sort
      </code>
      
      , <code>
        page
      </code>
      
      , <code>
        offset
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      one transaction
    </td>
    
    <td>
      <code>
        proxy.eth_getTransactionByHash
      </code>
      
       plus the receipt for status and fee
    </td>
  </tr>
  
  <tr>
    <td>
      contract
    </td>
    
    <td>
      <code>
        contract.getsourcecode
      </code>
      
      , with proxy and implementation
    </td>
  </tr>
  
  <tr>
    <td>
      token holdings
    </td>
    
    <td>
      <code>
        account.addresstokenbalance
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      token transfers
    </td>
    
    <td>
      <code>
        account.tokentx
      </code>
      
      , optionally one <code>
        contractaddress
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      gas
    </td>
    
    <td>
      <code>
        gastracker.gasoracle
      </code>
      
      , in gwei
    </td>
  </tr>
  
  <tr>
    <td>
      block
    </td>
    
    <td>
      <code>
        proxy.eth_getBlockByNumber
      </code>
    </td>
  </tr>
</tbody>
</table>

## Gotchas

- Five requests a second on the free tier, and Etherscan counts them. Past that you get a rate limit message dressed up as a normal answer; the provider waits and retries that same backend, then an automatic selection moves the read to Blockscout, once.
- On BNB Chain, Base, OP Mainnet, Avalanche and Gnosis the free plan refuses every read except contract source, and you find out at runtime. Token holdings need API Pro even on Ethereum. That's a `PlanRestrictedError`, and the fallback pass tries Blockscout if it serves the chain, which for BNB Chain it doesn't. Automatic selection remembers the refusal for an hour, so on the chains Blockscout serves the next read of that kind goes there first instead of paying for the same no again.
- "No transactions found" is an empty list, not an error. Etherscan phrases an empty page as a failure, which is silly, and the provider knows the phrasing.
- Amounts arrive as decimal strings and stay strings. Token decimals come with each transfer row.

## Where it lives

`src/providers/etherscan.ts`.


## Sitemap

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