npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

etherscan-client

v0.1.0

Published

A set of classes to work with etherscan-compatible blockchain observers

Readme

Etherscan client

Client for receiving blockchain data through block explorers (etherscan, routescan, OKLINK etc.).

Client instantiation examples:

import { Client, Chain } from 'etherscan-client';

const OKLINK_API_KEY = 'oklink_api_key';
const ETHERSCAN_API_KEY = 'etherscan_api_key';
const ROUTESCAN_API_KEY = 'routescan_api_key';

const ethV2Client = new Client({
  chainid: Chain.EthereumMainnet,
  apikey: ETHERSCAN_API_KEY
});

const ethClient = new Client({
  apikey: ETHERSCAN_API_KEY,
  url: 'https://api-sepolia.etherscan.io/api'
});

const routescanClient = new Client({
  apikey: ROUTESCAN_API_KEY,
  url: `https://api.routescan.io/v2/network/mainnet/evm/${Chain.EthereumMainnet}/etherscan/api`
});

const okLinkClient = new Client({
  apikey: OKLINK_API_KEY,
  url: `https://www.oklink.com/api/v5/explorer/eth/api`
});

At the moment, the number of available methods is limited to those indicated in the examples below:

Accounts section

import { Client, Chain } from 'etherscan-client';

const API_KEY = 'your_api_key';
const WALLET = 'your_wallet_address';
const TOKEN_ADDRESS = 'token_address';

const client = new Client({ chainid: Chain.EthereumMainnet, apikey: API_KEY });

// Get Ether Balance for a Single Address:
const balance = await blockExplorer.getAccountBalance({
  address: WALLET
});
console.log(balance);

// Get a list of 'Normal' Transactions By Address:
const normalTxsList = await blockExplorer.getNormalTxListByAddress({
  address: WALLET
});
console.log(normalTxsList);

// Get a list of 'Internal' Transactions By Address:
const internalTxsList = await blockExplorer.getInternalTxListByAddress({
  address: WALLET
});
console.log(internalTxsList);

const erc20TokenEvtList = await client.getErc20TokenTransferEventsList({
  address: WALLET,
  contractaddress: TOKEN_ADDRESS
});
console.log(erc20TokenEvtList);

Blocks section

import { Client, Chain } from 'etherscan-client';

const API_KEY = 'your_api_key';

const client = new Client({ chainid: Chain.EthereumMainnet, apikey: API_KEY });

const blockNumber = await client.getBlockNumberByTimestamp({
  timestamp: 1744030101
});
console.log(blockNumber);

Geth/Parity Proxy section

import { Client, Chain, Parameter } from 'etherscan-client';

const API_KEY = 'your_api_key';

const client = new Client({ chainid: Chain.EthereumMainnet, apikey: API_KEY });

// Get number of most recent block:
const blockNumber = await blockExplorer.eth_blockNumber();
console.log(blockNumber);

// Get information about a block by block number:
const block = await blockExplorer.eth_getBlockByNumber({
  boolean: true,
  tag: '0x10d4f'
});
console.log(block);

// Get information about a uncle by block number:
const uncleBlock = await blockExplorer.eth_getUncleByBlockNumberAndIndex({
  tag: '0xC63276',
  index: '0x0'
});
console.log(uncleBlock);

// Get the number of transactions in a block:
const blockTxCount = await blockExplorer.eth_getBlockTransactionCountByNumber({
  tag: '0x10FB78'
});
console.log(blockTxCount);

// Get the information about a transaction requested by transaction hash:
const tx = await blockExplorer.eth_getTransactionByHash({
  txhash: '0xbc78ab8a9e9a0bca7d0321a27b2c03addeae08ba81ea98b03cd3dd237eabed44'
});
console.log(tx);

// Get information about a transaction by block number and transaction index position:
const txSecond = await blockExplorer.eth_getTransactionByBlockNumberAndIndex({
  tag: '0xC6331D',
  index: '0x11A'
});
console.log(txSecond);

// Get the number of transactions performed by an address:
const txCount = await blockExplorer.eth_getTransactionCount({
  address: '0x4bd5900Cb274ef15b153066D736bf3e83A9ba44e'
});
console.log(txCount);

// Submits a pre-signed transaction for broadcast to the Ethereum network:
const txHash = await blockExplorer.eth_sendRawTransaction({
  hex: '0xf904808000831cfde080'
});
console.log(txHash);

// Get the receipt of a transaction by transaction hash:
const txReceipt = await blockExplorer.eth_getTransactionReceipt({
  txhash: '0xadb8aec59e80db99811ac4a0235efa3e45da32928bcff557998552250fa672eb'
});
console.log(txReceipt);

// Executes a new message call immediately without creating a transaction on the block chain:
const callResult = await blockExplorer.eth_call({
  to: '0xAEEF46DB4855E25702F8237E8f403FddcaF931C0',
  data: '0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724',
  tag: Parameter.Tag.Latest
});
console.log(callResult);

// Returns code at a given address:
const codeInHex = await blockExplorer.eth_getCode({
  address: '0xf75e354c5edc8efed9b59ee9f67a80845ade7d0c',
  tag: Parameter.Tag.Latest
});
console.log(codeIndex);

// Returns the value from a storage position at a given address:
const storageValue = await blockExplorer.eth_getStorageAt({
  address: '0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd',
  position: '0x0',
  tag: Parameter.Tag.Latest
});
console.log(storageValue);

// Returns the current price per gas in wei:
const gasPrice = await blockExplorer.eth_gasPrice();
console.log(gasPrice);

// Makes a call or transaction, which won't be added to the blockchain and returns the used gas:
const gas = await blockExplorerEth.eth_estimateGas({
  data: '0x4e71d92d',
  to: '0xf0160428a8552ac9bb7e050d90eeade4ddd52843',
  value: '0xff22',
  gasPrice: '0x51da038cc',
  gas: '0x5f5e0ff'
});
console.log(gas);

Tokens section

import { Client, Chain } from 'etherscan-client';

const API_KEY = 'your_api_key';

const client = new Client({ chainid: Chain.EthereumMainnet, apikey: API_KEY });

const tokenBalance = await client.getAccountTokenBalance({
  contractaddress: TOKEN_ADDRESS,
  address: WALLET
});
console.log(blockNumber);