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

@bun-eth/hooks

v0.2.0

Published

Custom React hooks for Web3 interactions with Bun-Eth

Downloads

14

Readme

@bun-eth/hooks

Custom React hooks for Web3 interactions, inspired by Scaffold-ETH 2's hook architecture.

Features

  • 🎣 Type-safe hooks - Full TypeScript support with auto-completion
  • Optimized for Bun - Fast execution and hot reload
  • 🔄 Auto-refresh - Real-time updates on new blocks
  • 📝 Transaction notifications - Built-in feedback system
  • 🎯 Contract-first - Works with auto-generated contract types

Installation

bun add @bun-eth/hooks

Core Hooks

Contract Interaction

useDeployedContractInfo

Gets contract deployment information (address and ABI).

const contractInfo = useDeployedContractInfo("YourContract");
// Returns: { address: "0x...", abi: [...] }

useScaffoldContract

Returns a viem contract instance with automatic ABI and address loading.

const contract = useScaffoldContract({
  contractName: "YourContract",
  walletClient: true, // Enable for write operations
});

useScaffoldReadContract

Read from contracts with automatic type inference and caching.

const { data, isLoading } = useScaffoldReadContract({
  contractName: "YourContract",
  functionName: "getValue",
  args: [],
  watch: true, // Auto-refresh on new blocks
});

useScaffoldWriteContract

Write to contracts with integrated transaction notifications.

const { writeContractAsync, isMining } = useScaffoldWriteContract("YourContract");

await writeContractAsync("setValue", [42]);

Event Monitoring

useScaffoldEventHistory

Fetch historical events with automatic batching.

const { events, isLoading } = useScaffoldEventHistory(
  "YourContract",
  "ValueChanged",
  0n // From block
);

useScaffoldWatchContractEvent

Real-time event listener.

useScaffoldWatchContractEvent({
  contractName: "YourContract",
  eventName: "ValueChanged",
  onLogs: (logs) => console.log("New events:", logs),
});

Blockchain Data

useWatchBalance

Watch address balance with auto-refresh on new blocks.

const { data: balance } = useWatchBalance(address);

useTargetNetwork

Get the current target network.

const { targetNetwork } = useTargetNetwork();

Transactions

useTransactor

Wrap transactions with notifications and confirmation tracking.

const transactor = useTransactor({
  blockConfirmations: 1,
  onBlockConfirmation: (receipt) => console.log("Confirmed!", receipt),
});

const txHash = await transactor(() =>
  writeContractAsync(...)
);

Usage Example

import { useScaffoldReadContract, useScaffoldWriteContract } from "@bun-eth/hooks";

function MyComponent() {
  // Read contract state
  const { data: value } = useScaffoldReadContract({
    contractName: "SimpleStorage",
    functionName: "retrieve",
    watch: true,
  });

  // Write to contract
  const { writeContractAsync, isMining } = useScaffoldWriteContract("SimpleStorage");

  const handleStore = async () => {
    await writeContractAsync("store", [42]);
  };

  return (
    <div>
      <p>Current Value: {value?.toString()}</p>
      <button onClick={handleStore} disabled={isMining}>
        {isMining ? "Mining..." : "Store 42"}
      </button>
    </div>
  );
}

Architecture

All hooks follow the Scaffold-ETH 2 pattern:

  1. Base Hook: useDeployedContractInfo loads contract metadata
  2. Composition: Higher-level hooks compose the base hook
  3. Type Safety: Full TypeScript inference throughout
  4. Caching: React Query integration for optimal performance

Requirements

  • React 18.2+ or React 19+
  • wagmi ^2.16.4
  • viem ^2.7.8
  • @tanstack/react-query ^5.17.19

License

MIT