@0xdoublesharp/abi-typegen
v0.2.0
Published
Generate typed bindings from Solidity ABI artifacts — pre-built binary
Downloads
431
Maintainers
Readme
@0xdoublesharp/abi-typegen
Pre-built binary for abi-typegen. Reads compiled Solidity artifacts and generates production-ready typed bindings — no native toolchain required.
Install
npm install -D @0xdoublesharp/abi-typegen
yarn add -D @0xdoublesharp/abi-typegen
pnpm add -D @0xdoublesharp/abi-typegenUsage
# Single target
npx abi-typegen generate --target viem
# Hardhat artifact layout
npx abi-typegen generate --hardhat --target ethers
# Multi-target (each gets its own output subdirectory)
npx abi-typegen generate --target viem,python,rustTargets
| Target | Flag | Language | Ecosystem |
|---|---|---|---|
| viem | --target viem | TypeScript | viem |
| zod | --target zod | TypeScript | Zod 4 |
| wagmi | --target wagmi | TypeScript | wagmi v2 |
| ethers v6 | --target ethers | TypeScript | ethers v6 |
| ethers v5 | --target ethers5 | TypeScript | ethers v5 |
| web3.js | --target web3js | TypeScript | web3.js v4 |
| Python | --target python | Python | web3.py |
| Go | --target go | Go | go-ethereum |
| Rust | --target rust | Rust | alloy |
| Swift | --target swift | Swift | web3swift |
| C# | --target csharp | C# | Nethereum |
| Kotlin | --target kotlin | Kotlin | web3j |
| Solidity | --target solidity | Solidity | External interfaces |
| YAML | --target yaml | YAML | Human-readable ABI descriptions |
Target aliases: ethers6 → ethers, web3 → web3js, cs → csharp, kt → kotlin, sol → solidity, yml → yaml
Commands
npx abi-typegen generate # write generated bindings
npx abi-typegen generate --check # fail if output is stale (CI)
npx abi-typegen generate --clean # remove stale generated files
npx abi-typegen diff # show what would change (dry run)
npx abi-typegen json --pretty # dump parsed ABI as JSON
npx abi-typegen watch # watch artifacts and regenerate
npx abi-typegen fetch --name WETH \
--network mainnet 0xc02aaa... # fetch ABI from block explorer
npx abi-typegen fetch --name WETH \
--file ./WETH.abi.json # import a local ABI fileCLI Options
| Option | Description |
|---|---|
| --target <name> | Target name or comma-separated names (see table above) |
| --artifacts <path> | Path to compiled artifacts directory |
| --out <path> | Output directory |
| --hardhat | Use Hardhat artifact layout (artifacts/contracts/) |
| --contracts <names> | Comma-separated contract allowlist |
| --exclude <patterns> | Comma-separated glob patterns (e.g. *Test,*Mock) |
| --no-wrappers | Disable wrapper function generation |
| --check | Exit non-zero if output is stale |
| --clean | Remove stale generated files |
Fetch Networks
The fetch command supports 80+ networks via --network. Some examples:
| Group | Networks |
|---|---|
| Ethereum | mainnet (default), sepolia, holesky, hoodi |
| OP Stack | optimism, base, blast, fraxtal, worldchain, unichain |
| Arbitrum | arbitrum, arbitrum-nova, arbitrum-sepolia |
| Polygon | polygon, polygon-amoy, polygon-zkevm |
| BNB Chain | bsc, opbnb |
| Avalanche | avalanche, fuji |
| L2s | linea, scroll, zksync, mantle, sonic, taiko, swellchain |
| Alt L1s | gnosis, celo, moonbeam, moonriver, fantom, cronos, berachain, sei |
| Newer chains | hyperevm, abstract, monad, megaeth, apechain, katana |
| Other | manta, metis, xdc, bittorrent |
Pass --url <URL> for any Etherscan-compatible explorer not in the list.
Hardhat Plugin
For automatic generation on compile, use @0xdoublesharp/hardhat-abi-typegen.
Configuration
Multi-target generation can also be configured in foundry.toml:
[abi-typegen]
target = ["viem", "python", "rust"] # also accepts "viem,python,rust"Notes
- When using
--target zod, install the latestzodpackage in the consuming project - Multi-target runs write each target to its own subdirectory under the output path
See github.com/doublesharp/abi-typegen for full documentation.
