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

eth-fetch

v0.2.0

Published

A JavaScript interface for fetching data from Ethereum nodes and smart contracts.

Readme

ETH Fetch

NPM Version NPM License NPM Unpacked Size

A JavaScript interface for fetching data from Ethereum nodes and smart contracts.

The eth-fetch library is a JavaScript interface designed for fetching data from Ethereum nodes and smart contracts using read-only JSON-RPC calls. To get started, install the library:

npm install eth-fetch

ethFetch Methods

The library supports two methods, one for creating a provider instance for sending JSON-RPC requests over HTTP, and the other for creating an interface for smart contract interactions based on a contract address and ABI.

ethFetch.RpcProvider(providerUrl);

Creating a provider instance is supported by the ethFetch.RpcProvider(); method, and requires a providerUrl parameter be provided, which expects a provider. The provider should support a JSON-RPC interface over HTTP (e.g.. port 8545 of a Geth node, an endpoint for a service like Infura).

ethFetch.Contract(provider, address, abi);

Creating a contract interface is supported by the ethFetch.Contract(); method, and requires a provider, address, and abi parameter be provided. These should correspond to a provider instance (such as ethFetch.RpcProvider), a the contract's address, and the contract's ABI. The ABI encoding/decoding is supported by @ethersproject/abi, therefore the ABI supplied must match an ABI Format supported by Ethers.

Contract ABI Methods

A number of methods is made available via the contract interface for Ethereum smart contract interactions. This includes handling for encoding and decoding of function calls, responses, event topics, and logs. This also includes extracting metadata about functions and events, and ABI parsing. This functionality is supported by @ethersproject/abi.

.abi.encodeFunctionCall(functionName, params);
.abi.decodeFunctionResponse(functionName, data);

.abi.encodeParams(types, values);
.abi.decodeParams(types, data);

.abi.encodeEventTopics(eventName, params);
.abi.decodeEventLog(eventName, log);

.abi.getFunctionSelector(functionName);

.abi.parseAbi();

Example Use

In this first example, a provider instance is created, and used to fetch the current block number.

const ethFetch = require('eth-fetch');

// Create instance of the provider
const providerUrl = "https://mainnet.infura.io/v3/INFURA_API_KEY";
const provider = new ethFetch.RpcProvider(providerUrl);

// Fetch current Block Number
(async () => {
    try {
        const blockNumber = await provider.request({ method: 'eth_blockNumber' });
        console.log("Block Number:", parseInt(blockNumber, 16));
    } catch (error) {
        throw error;
    }
})();

// Sample Output:
// Block Number: 21589526

In this second example, an interface for an Ethereum Name Service smart contract is created, supplying the contract address, and ABI for the owner function, to retrieve the owner address for the ENS name ethereum.eth.

const ethFetch = require('eth-fetch');

// Create instance of the provider
const providerUrl = "http://127.0.0.1:8545";
const provider = new ethFetch.RpcProvider(providerUrl);

// Create smart contract interface
const contractAddress = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
const abi = ["function owner(bytes32 node) external view returns (address)"];
const contract = new ethFetch.Contract(provider, contractAddress, abi);

// Find the owner address for ethereum.eth (using namehash)
const namehash = "0x78c5b99cf4668cf6da387866de4331c78b75b7db0087988c552f73e1714447b9";

(async () => {
    try {
        const ownerAddress = await contract.owner(namehash);
        console.log("Owner Address:", ownerAddress);
    } catch (error) {
        throw error;
    }
})();

// Sample Output:
// Owner Address: [ '0xAd2e180019FCa9e55CADe76E4487F126Fd08DA34' ]