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

@foundryprotocol/0gkit-contracts

v1.0.1

Published

Typed contract clients for 0G. Five standard 0G contracts pre-bundled (ERC-20, ERC-721, Multicall3, provider registry, attestation verifier) plus `forge build` → typed TS codegen. Wagmi-style .read.method() / .write.method() / .events.Event(); no hand-wri

Downloads

267

Readme

@foundryprotocol/0gkit-contracts

Typed contract clients for 0G. No hand-written ABIs.

  • Five standard 0G contracts pre-bundled — ERC-20, ERC-721, Multicall3, provider registry, attestation verifier.
  • Wagmi-style .read.method() / .write.method() / .events.Event() — full IntelliSense, zero any.
  • 0g contracts generate --abi <forge-artifact>.json --out <dir> consumes Foundry build output and emits typed .ts clients.
npm i @foundryprotocol/0gkit-contracts viem

Standard contracts

import { standardContracts } from "@foundryprotocol/0gkit-contracts";

// Multicall3 is universal — same address on every EVM chain.
const m3 = standardContracts.multicall3({ network: "galileo" });
const block = await m3.read.getBlockNumber();

// ERC-20 needs an address (no per-network singleton).
const usdc = standardContracts.erc20({
  address: "0xa0b8...e3c8",
  network: "galileo",
  signer, // optional; required for .write.*
});
const balance = await usdc.read.balanceOf("0x1234...");
const tx = await usdc.write.transfer("0xabcd...", 100n);
console.log(tx.txHash, tx.blockNumber);

| Contract | Network address | Status | | --------------------- | ------------------------------------ | ---------------------------------------------------------- | | multicall3 | Universal | Auto-resolved per network | | erc20 | Per-deployment | Pass { address } | | erc721 | Per-deployment | Pass { address } | | registry | Pinned per network when 0G publishes | Throws CONFIG with hint until then; pass { address } now | | attestationVerifier | Pinned per network when 0G publishes | Throws CONFIG with hint until then; pass { address } now |

Codegen — your own contracts

After forge build, point 0g contracts generate at the artifact:

0g contracts generate \
  --abi out/MyContract.sol/MyContract.json \
  --out src/contracts

Emits one .ts file per contract:

import { MyContract } from "./contracts/MyContract";

const c = MyContract.attach({ address: "0x...", signer });
const value = await c.read.totalSupply(); // typed bigint
const tx = await c.write.transfer(to, amount); // returns Receipt
const events = await c.events.Transfer({ fromBlock: 0n });

Generated code passes tsc --strict --noEmit with zero any. Output is byte-deterministic — same artifact in, same TS out — so diffs in PR are obvious.

Programmatic codegen

import { generate } from "@foundryprotocol/0gkit-contracts/codegen";

await generate({
  abiPath: "out/MyContract.sol/MyContract.json",
  outDir: "src/contracts",
  name: "MyContract", // optional override
});

Custom contracts via createTypedContract

For one-offs where codegen would be overkill:

import { createTypedContract } from "@foundryprotocol/0gkit-contracts";
import { parseAbi } from "viem";

const c = createTypedContract({
  abi: parseAbi(["function ping() view returns (uint256)"]),
  address: "0x...",
  network: "galileo",
});
const n = await c.read.ping();

CLI

0g contracts list                       # show bundled standard contracts
0g contracts info erc20                 # methods + events for one contract
0g contracts generate --abi <p> --out <d>  # codegen from Foundry artifact

API

createTypedContract({ abi, address, signer?, ... })

Returns { read, write, events, address, abi }.

  • read.<method>(args) — delegates to viem.getContract.
  • write.<method>(args) — submits via the wallet client, awaits the receipt, returns { txHash, blockNumber, latencyMs } (the 0gkit-core.Receipt shape). Requires { signer } whose privateKey is exposed (the fromPrivateKey / fromFile / fromEnv loaders from 0gkit-wallet).
  • events.<EventName>({ fromBlock?, toBlock?, args? }) — pull-only log query via viem.getLogs. SP6 (0gkit-indexer) adds live subscriptions with reorg safety.

Errors

All thrown errors are 0gkit-core.ZeroGError subclasses with a code and a one-line hint:

  • CONFIG — wrong/missing args, or a non-pinned contract address. Includes a remedy.
  • CHAIN — viem write/read/getLogs failed. Original message preserved.

Estimating & dry-run

const c = createTypedContract({ abi, address, network, signer });

const est = await c.estimate.transfer(recipient, 1_000n);
// { kind: "contract", gas, fee, breakdown: { method: "transfer", gasPrice }, expectedSeconds: 3 }

const dr = await c.write.transfer([recipient, 1_000n], { dryRun: true });
// { dryRun: true, estimate, result: { latencyMs: 0 } }

estimate uses viem's estimateContractGas + getGasPrice; write({ dryRun }) also runs simulateContract so EVM revert paths surface before any broadcast happens. From the CLI:

0g estimate contracts --abi ./out/MyContract.json --address 0x... --method transfer --args '["0x...","1000"]'

License

MIT