@ethernauta/cli
v0.0.48
Published
Code generator for Ethernauta — emits ABI method bindings from contract ABIs.
Maintainers
Readme
Philosophy
This module ships a CLI for working with ABIs in an Ethernauta codebase. Two subcommands:
ethernauta abi— generate ready-to-use TypeScript methods from an ABI JSON, a Foundry artifact, or a Solidity source (.abi). With no flags it walkspackages/**/*.abi.jsonandpackages/**/*.abiand regeneratesmethods/next to each ABI source.ethernauta registry— walk a directory of ABI JSONs and emit a 4-byte selector → method-metadata map (used by the wallet to surface human-readable function names)
Prerequisites
Node 20+ — runtime for the CLI itself.
Foundry's
forge— required when the walker encounters a.abi(Solidity) source, since the ABI is extracted inline viaforge inspect <path>:<Contract> abi. Install:curl -L https://foundry.paradigm.xyz | bash foundryupNot required when only
.abi.jsonfiles are walked.
Modules
- abi [NPM]
- chain [NPM]
- cli [NPM]
- core [NPM]
- crypto [NPM]
- eip [NPM]
- ens [NPM]
- erc [NPM]
- eth [NPM]
- react [NPM]
- transaction [NPM]
- transport [NPM]
- utils [NPM]
- wallet
API
ethernauta abi
Regenerate contract method TypeScript files. Two modes:
Walker mode (no flags)
npx ethernauta abiDiscovers every packages/**/*.abi.json and packages/**/*.abi under the workspace root (the directory holding pnpm-workspace.yaml), skipping node_modules, dist, and .git. One ABI per folder is required; multiple ABIs in the same folder is an error. methods/ is fully overwritten next to each ABI source. For .abi files (Solidity sources) the walker invokes forge inspect <path>:<ContractName> abi — the contract name must match the filename.
This is the common case in the Ethernauta monorepo. A repo-level regen script chains it with a Biome format pass to keep generated files canonical.
Single-file mode
npx ethernauta abi --in abis/IERC20.abi.json --out app/methodsEach function in the ABI emits one file under <out>/methods/. View / pure functions emit Callable<T>; state-changing functions emit Signable<Bytes>. A barrel file at <out>/methods/index.ts re-exports everything. Use this form when consuming the CLI from outside the monorepo, or for one-off regeneration of a single contract.
A typical setup wires this into a package.json script so generated methods stay in sync with the contract:
{
"scripts": {
"regen:methods": "ethernauta abi --in contracts/out/MyContract.sol/MyContract.json --out app/generated/my-contract"
}
}Flags:
| Flag | Description |
| ------- | ---------------------------------------------------------------------------- |
| --in | Path to a raw ABI JSON array or a Foundry artifact with an abi field |
| --out | Output directory; the generator writes <out>/methods/*.ts + a barrel file |
ethernauta registry
Walk a directory for *.abi.json files and emit a single REGISTRY mapping 4-byte selectors to method metadata.
npx ethernauta registry --in src --out src/registry/registry.generated.tsThe registry is used by the wallet to verify and display function names for transactions whose call data carries an unknown selector.
Flags:
| Flag | Description |
| ------- | ----------------------------------------------------------------- |
| --in | Directory walked recursively for *.abi.json files |
| --out | Output file path for the generated REGISTRY TypeScript module |
