w3m generate
Run the codegen pipeline to generate TypeScript bindings from compiled contract artifacts.
w3m generateAlias: w3m gen
Options
| Option | Description |
|---|---|
-w, --watch | Watch 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:
| Plugin | Output |
|---|---|
foundryResolverPlugin | Resolves ABIs from Foundry build output |
abiGeneratorPlugin | ABI constant exports (typed arrays) |
hookGeneratorPlugin | Typed React hooks (useRead*, useWrite*) |
createAddressGeneratorPlugin | Address 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 --watchKeeps 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