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

@himanshum/basely

v1.1.2

Published

Base and EVM chain API SDK

Downloads

19

Readme

Basely

Basely is a small Node.js utility that fetches on-chain account insights (transaction counts, balances, and deployed contract counts) using Etherscan-style API endpoints. It is designed as a minimal SDK to inspect wallet and contract activity for Base and other chains supported by the API.


Repository layout


What this module does

  • Get native balance for an address: getNativeBalance
  • Get normal transactions for an address: getNormalTransactionsbyAddress
  • Count internal transactions for an address: getNumberofInternalTransactions
  • Count regular transactions for an address: getNumberofTransactions
  • Count deployed contracts by an address: getNumberOfDeployedContractsByAddress
  • Get contract deployment transactions: getContractDeploymentTransactions
  • Verify contract source code: makeGivenContractVerified

Implementation details live in index.js. The module uses axios to call Etherscan-style endpoints and parses the result array returned by the API.


Quick start

  1. Install dependencies:
npm install
  1. Create a .env file in the project root with your API key and optional chain id.

Required environment variables (as the code currently expects):

  • ETH_API_KEY — your API key for the Etherscan-style API
  • CHAIN_ID — numeric chain id (optional, defaults to 8453 in code)

Example .env (do NOT commit your real key):

# .env (example)
ETH_API_KEY=your_api_key_here
# Optional override:
# CHAIN_ID=8453
  1. Run the demo script (optional):
npm run main

This runs node index.js (see package.json).


Usage (programmatic)

Require the exported functions and call them:

// Example usage
const {
  getNativeBalance,
  getNormalTransactionsbyAddress,
  getNumberofInternalTransactions,
  getNumberofTransactions,
  getNumberOfDeployedContractsByAddress,
  getContractDeploymentTransactions,
  makeGivenContractVerified
} = require('./index.js');

(async () => {
  const address = '0xCAa6d6617690588371d3B94c692Fc3273F3e14f4';
  
  // Get native balance
  const balance = await getNativeBalance(address);
  console.log('Balance:', balance);
  
  // Get transactions
  const transactions = await getNormalTransactionsbyAddress(address);
  console.log('Transactions:', transactions.length);
  
  // Get counts
  console.log('Internal txs:', await getNumberofInternalTransactions(address));
  console.log('Total txs:', await getNumberofTransactions(address));
  console.log('Deployed contracts:', await getNumberOfDeployedContractsByAddress(address));
})();

Exported Functions

  • getNativeBalance(Addr) — async (Addr) => string — Returns native token balance for an address
  • getNormalTransactionsbyAddress(Addr) — async (Addr) => Array — Returns array of normal transactions for an address
  • getNumberofInternalTransactions(Addr) — async (Addr) => number — Returns count of internal transactions
  • getNumberofTransactions(Addr) — async (Addr) => number — Returns count of regular transactions
  • getNumberOfDeployedContractsByAddress(Addr) — async (Addr) => number — Returns count of contracts deployed by an address
  • getContractDeploymentTransactions(Addr) — async (Addr) => Array — Returns array of contract deployment transactions
  • makeGivenContractVerified(contractAddress, sourceCode, codeFormat, contractName, compilerVersion) — async (...) => Object — Verifies contract source code

API & Implementation Notes

  • Endpoints: Uses https://api.etherscan.io/v2/api?... with query parameters module=account and various actions (txlist, txlistinternal, balance, etc.)
  • Pagination: Most requests use page=1&offset=1000. If an account has more than 1000 records, you may need to implement paging
  • Contract creation detection: Transactions where tx.to is falsy (empty) are treated as contract creation
  • Error handling: Functions return empty arrays or default values (0) on error, with errors logged to console
  • API response validation: Functions check for status === "1" in API responses to ensure successful requests

Known Issues

  • Some catch blocks in getNumberofInternalTransactions and getNumberofTransactions use catch { ... } but reference err.message inside, which will cause a ReferenceError. These should be changed to catch (err) { ... }
  • The warning message in index.js mentions BASESCAN_API_KEY but the code actually reads ETH_API_KEY from environment variables

Scripts

  • npm run main — run the main script at index.js
  • npm test — run tests

See package.json for details.