DeploymentDeployment Files

Deployment Files

After a successful deployment, contract addresses and metadata are saved to deployments/<chainId>.json in your project root. The codegen pipeline reads these files to generate typed address registries for your frontend.

File Format

Each deployment file is named by chain ID (e.g., 1.json, 11155111.json, 84532.json). The w3m deploy command writes the following structure:

{
  "chainId": 11155111,
  "chain": "sepolia",
  "timestamp": "2026-01-15T10:30:00.000Z",
  "output": "..."
}

The output field contains the raw output from forge script, which includes deployed contract addresses and transaction hashes.

Codegen Integration

After deployment, running w3m generate (or the automatic codegen step in w3m deploy) reads all deployment files from the deployments/ directory and generates a typed addresses.ts file in your codegen output directory (default: src/generated/).

The generated file contains per-contract address registries:

// THIS FILE IS AUTO-GENERATED BY @web3marketlabs/codegen
// DO NOT EDIT THIS FILE MANUALLY
 
export const tokenAddresses = {
  11155111: '0x1234567890abcdef1234567890abcdef12345678',
  84532: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
} as const satisfies Record<number, `0x${string}`>

This means deployed contracts are immediately usable in your frontend. Generated React hooks resolve the correct contract address based on the connected chain ID.

The codegen pipeline runs automatically after w3m deploy completes. If codegen fails, the CLI prints a warning and suggests running w3m generate manually.

Directory Structure

A typical project with deployments:

my-project/
  contracts/
    src/
      Token.sol
  deployments/
    31337.json       # Anvil local
    11155111.json    # Sepolia testnet
    84532.json       # Base Sepolia testnet
    1.json           # Ethereum mainnet
  src/
    generated/
      addresses.ts   # Auto-generated by codegen