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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ethereum-hooks

v2.0.4

Published

Resourceful NPM package that contains React hooks for working with the Ethereum Blockchain.

Readme

ethereum-hooks

Useful package that contains custom React hooks that can be used for rapid development while working with the Ethereum blockchain.

These hooks make use of various crypto APIs (free versions only) and save developer time by taking away the need for manual configuration and setup.

The following resources were utilized when building these client hooks:

  • Alchemy
  • Blocknative
  • CoinGecko
  • Moralis
  • Opensea
  • Transpose

React Hooks

This package uses AWS Lambda functions to construct authenticated API calls. The architecture follows a simple flow: Client Hook → useFetch → AWS Lambda → Response.

The AWS Lambda functions handle authentication automatically using pre-configured API keys for various blockchain services:

  • OPENSEA_API_KEY - For NFT marketplace data
  • MORALIS_API_KEY - For Web3 data aggregation
  • BLK_API_KEY - For Blocknative gas and mempool data
  • TRANSPOSE_API_KEY - For indexed blockchain data
  • ALCHEMY_API_KEY - For Ethereum node access and enhanced APIs

No backend setup or environment variables are required on your end.

React Client Hooks

The hooks cover several areas of the Ethereum blockchain and can be used for Layer Two chains as well.

Each hook automatically connects to its dedicated AWS Lambda endpoint - no manual URL configuration is needed.

Import Structure (v2.0.2+)

Starting with version 2.0.2, hooks are organized into grouped imports for better organization:

// ENS Hooks
import { useAddressENSLookup, useENSNameLookup, useENSAddressLookup, useENSIDLookup } from 'ethereum-hooks/ens';

// ERC20 Token Hooks
import { useERC20Holdings, useERC20Transfers, useERC20CollectionOwners } from 'ethereum-hooks/erc20';

// ERC721 Token Hooks
import { useERC721CollectionData, useERC721Holdings, useERC721LookupData } from 'ethereum-hooks/erc721';

// Gas Hooks
import { useGasLookup } from 'ethereum-hooks/gas';

// Price Hooks
import { useETHPrice, useERC20Price, useERC721Price, useLayerTwoPrice } from 'ethereum-hooks/prices';

This structured approach makes it easier to:

  • Import only what you need
  • Understand which category each hook belongs to
  • Maintain cleaner import statements

Here is a quick example of how you can work with client hooks. The following is a code snippet for working with React.js:

ENSToAddressPage.tsx

import React, { FC }  from 'react';
import { useENSAddressLookup } from 'ethereum-hooks/ens';

// Incorporating the ENS to Address Client Hook.. using Vitalik Buterin's address
// No server setup required - connects directly to AWS Lambda

const ENSToAddressPage: FC = () => {
    // Hook automatically connects to AWS Lambda - no server setup required
    const addressInformation = useENSAddressLookup('vitalik.eth');
    
    // Each client hook uses the useFetch custom hook
    // It returns three states: data, error, loading
    // We capture these states in a variable (like above) and conditionally render the component
    if (addressInformation.loading){
        return <div>Loading..</div>
    }
    else if (addressInformation.error){
        return <div>Error loading data...</div>
    }
    else { 
        // Hardcoded some parts for demonstrative purposes only
        return (
            <div className='home-page'>
                <table>
                    <tr>
                        <th>ENS</th>
                        <th>Address</th>
                    </tr>
                    <tr>
                        <td>vitalik.eth</td>
                        <td>{ addressInformation.data?.information }</td>
                    </tr>
                </table>
            </div>
        )
    }
}

export default ENSToAddressPage;

A list of chains supported is provided below in the Types section.

AWS Lambda Endpoints

The following table shows the 30 different client hooks and their corresponding AWS Lambda endpoints:

Custom Hooks

Custom hooks were incorporated into the main client hooks. The following table details the custom hooks used in this package:

Types

Custom data types were developed for monitoring data fetch status and defining a set of available layer two networks: