Skip to content

richsunxs/use-chain-status

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

use-chain-status

Tiny real-time EVM chain health & gas status
Zero dependencies · React hook + core utility · Multi-chain

use-chain-status provides a tiny, zero-dependency utility + React hook
to monitor:

  • 🟢 Chain health (healthy / slow / degraded / offline)
  • ⛽ Base fee
  • 💵 Gas price (optional)
  • ⚡ Congestion level
  • ⏱ Block time delay
  • 🔢 Latest block number
  • 📈 Pending transactions (if supported)

Perfect for dashboards, wallets, block explorers, DApps, and monitoring UIs.


🚀 Install

npm install use-chain-status

📦 Usage (React)

import { useChainStatus } from 'use-chain-status';

export default function App() {
  const { status, loading } = useChainStatus(1);

  if (loading) return <div>Loading...</div>;

  return (
    <div>
      <p>Health: {status.health}</p>
      <p>Block: {status.blockNumber.toString()}</p>
      <p>Base Fee: {String(status.baseFee)}</p>
      <p>Congestion: {status.congestion}</p>
    </div>
  );
}

🔧 Options

useChainStatus(chainId, {
  rpcUrl?: string;
  interval?: number; // ms
});

Custom RPC

useChainStatus(137, {
  rpcUrl: 'https://polygon.llamarpc.com',
  interval: 4000,
});

🧩 Framework-Agnostic Core

import { getChainStatus } from 'use-chain-status';

const status = await getChainStatus(1, 'https://rpc.ankr.com/eth');

📊 What's calculated?

Congestion

Based on gasUsed / gasLimit.

Health Levels

  • No new block in >12s → offline

  • 6s → degraded

  • Extreme congestion → slow

  • Otherwise → healthy


📦 GitHub Repository

You can find the full source code, issues, discussions, and documentation here:

👉 https://github.com/felaur/use-chain-status

🪪 License

MIT

Releases

No releases published

Packages

No packages published