w3m generate

Run the codegen pipeline to generate TypeScript bindings from compiled contract artifacts.

w3m generate

Alias: w3m gen

Options

OptionDescription
-w, --watchWatch for contract changes and re-generate

What It Does

The generate command runs the @web3marketlabs/codegen pipeline in four stages:

Stage 1: Resolve

Discovers contract artifacts from the filesystem. The foundryResolverPlugin scans Foundry’s out/ directory for compiled ABIs.

Stage 2: Parse

Parses and deduplicates ABI data. Categorizes contract items by type (functions by mutability, events, errors).

Stage 3: Generate

Generator plugins produce output files:

PluginOutput
foundryResolverPluginResolves ABIs from Foundry build output
abiGeneratorPluginABI constant exports (typed arrays)
hookGeneratorPluginTyped React hooks (useRead*, useWrite*)
createAddressGeneratorPluginAddress registries from deployment files

Stage 4: Write

All generated files are written to the configured output directory (default: src/generated, configurable via codegen.outDir in kit.config.ts).

Generated Files

src/generated/
  index.ts                # Barrel re-export file
  abis/
    Token.ts              # ABI constant for Token contract
  hooks/
    useToken.ts           # Typed read/write hooks for Token
  addresses.ts            # Address registry from deployments/

All generated files include a header comment: THIS FILE IS AUTO-GENERATED BY @web3marketlabs/codegen — DO NOT EDIT THIS FILE MANUALLY. Re-running the command overwrites these files.

Watch Mode

w3m generate --watch

Keeps the process running and re-generates files when contracts change. Press Ctrl+C to stop.

Examples

# Run codegen once
w3m generate
 
# Using the alias
w3m gen
 
# Watch for changes
w3m generate --watch