Skip to content

Wagmi CLI should generate separated outputs for ABI, addresses, and React hooks to avoid unnecessary imports. #5000

@0xbuidler

Description

@0xbuidler

Check existing issues

Describe the bug

Problem

Currently, the wagmi CLI generates all artifacts into a single file, including:

  • Contract ABIs
  • Contract addresses
  • React hooks
  • Other generated helpers

This creates an issue when consuming only a subset of the generated output in a different environment.

For example, when importing only the ABI into a non-React project or a separate repository, the entire file is imported, including React hooks and related code that are not needed. This introduces unnecessary dependencies, reduces clarity, and makes cross-environment usage less ergonomic.

In short: I only want the ABI, but I end up importing a whole React toolbox along with it.


Why this is problematic

  • Makes it harder to reuse ABIs in backend, Node, or non-React contexts
  • Introduces unwanted React-specific code in unrelated repositories
  • Reduces tree-shaking clarity
  • Couples UI layer artifacts with protocol layer artifacts

Proposed Improvement

The wagmi CLI could support generating separate outputs by concern. For example:

  • abi.ts exports ABIs only
  • addresses.ts exports contract addresses only
  • react.ts exports React hooks
  • optionally actions.ts exports core viem actions

Or allow configuration like:

  • Generate separate files by default
  • Or provide an option to control outputs, for example:
{
  "out": {
    "abi": "src/generated/abi.ts",
    "react": "src/generated/react.ts",
    "addresses": "src/generated/addresses.ts"
  }
}

Happy to help think through the DX implications or contribute if this direction makes sense.

Link to Minimal Reproducible Example

No response

Steps To Reproduce

No response

What Wagmi package(s) are you using?

@wagmi/cli

Wagmi Package(s) Version(s)

2.8.0

Viem Version

2.45.3

TypeScript Version

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions