Configurationkit.config.ts

kit.config.ts

Complete reference for the kit.config.ts configuration file. This is the single configuration file for your entire web3market-kit project. It lives at the root of your project directory.

import { defineConfig } from '@web3marketlabs/config'
 
export default defineConfig({
  // all options documented below
})

The defineConfig() helper provides TypeScript type inference and autocompletion. At runtime, the config is loaded using jiti for TypeScript transpilation and validated against Zod schemas defined in @web3marketlabs/config.


contracts

Configures the smart contract development framework and source file locations.

FieldTypeDefaultDescription
framework'foundry' | 'hardhat'(required)Contract development framework
rootstring'contracts'Root directory for contract sources, relative to project root
includestring[]['**/*.sol']Glob patterns for contract files to include
excludestring[]['**/test/**', '**/script/**']Glob patterns for contract files to exclude
contracts: {
  framework: 'foundry',
  root: 'contracts',
  include: ['**/*.sol'],
  exclude: ['**/test/**', '**/script/**'],
}

framework is the only required field in the entire config. All other fields across all sections have defaults.


chains

Configures which blockchain networks the project targets for deployment.

FieldTypeDefaultDescription
defaultstring'localhost'Default chain for development (must be a key in targets)
targetsRecord<string, { chainId: number, rpcUrl: string | { env: string } }>{ localhost: { chainId: 31337, rpcUrl: 'http://127.0.0.1:8545' } }Chain deployment targets

The rpcUrl field accepts either a literal URL string or an object referencing an environment variable:

chains: {
  default: 'sepolia',
  targets: {
    localhost: {
      chainId: 31337,
      rpcUrl: 'http://127.0.0.1:8545',
    },
    sepolia: {
      chainId: 11155111,
      rpcUrl: { env: 'SEPOLIA_RPC_URL' },
    },
    mainnet: {
      chainId: 1,
      rpcUrl: { env: 'MAINNET_RPC_URL' },
    },
  },
}
⚠️

When using {"{ env: 'ENV_VAR_NAME' }"}, the environment variable is resolved at runtime, not at config load time. Make sure the variable is set in your shell or .env file before running deploy commands.

Chain Target Schema

Each entry in targets must include:

FieldTypeDescription
chainIdnumberThe numeric chain ID (must be a positive integer)
rpcUrlstring | { env: string }RPC endpoint URL or environment variable reference

codegen

Controls automatic TypeScript and React code generation from compiled contract ABIs.

FieldTypeDefaultDescription
outDirstring'src/generated'Output directory for generated code, relative to project root
hooksbooleantrueGenerate React hooks for contract interactions
componentsbooleanfalseGenerate React components for contract interactions
codegen: {
  outDir: 'src/generated',
  hooks: true,
  components: false,
}

deploy

Controls deployment behavior when running w3m deploy.

FieldTypeDefaultDescription
verifybooleantrueVerify contracts on block explorer after deployment
confirmationsnumber2Number of block confirmations to wait before considering deployment finalized
deploy: {
  verify: true,
  confirmations: 2,
}

modules

Optional. Per-module configuration. Each module registers its own config under its key and validates its own section independently.

FieldTypeDefaultDescription
modulesRecord<string, unknown>{}Module-specific configuration keyed by module ID
modules: {
  token: { initialSupply: '5000000' },
}

components

Optional. List of installed component identifiers in the project.

FieldTypeDefaultDescription
componentsstring[][]List of installed components
components: ['token']

ai

Optional. Configuration for AI-powered features (contract review, error debugging, parameter explanations).

FieldTypeDefaultDescription
enabledbooleanfalseEnable AI assistance
modelstring'claude-sonnet-4-5-20250929'Claude model to use for AI features
ai: {
  enabled: true,
  model: 'claude-sonnet-4-5-20250929',
}

apiKeys

Optional. API keys for premium and AI-powered features.

FieldTypeDefaultDescription
web3marketstring(optional)Web3.Market API key for premium features (deploy, analysis)
anthropicstring(optional)Anthropic API key for AI-powered features
apiKeys: {
  web3market: 'wm_...',
  anthropic: 'sk-ant-...',
}
⚠️

Avoid committing API keys to version control. Use environment variables or a .env file and reference them via the chains.targets env syntax, or set keys through w3m auth.


vercel

Optional. Configuration for Vercel deployment integration.

FieldTypeDefaultDescription
enabledbooleanfalseEnable Vercel deployment integration
projectNamestring(optional)Vercel project name
vercel: {
  enabled: true,
  projectName: 'my-dapp',
}

marketplace

Optional. Configuration for Web3.Market marketplace publishing defaults.

FieldTypeDefaultDescription
autoPublishbooleanfalseAutomatically publish to marketplace on deploy
defaultPricestring'0'Default product price in USD (0 for free)
supportEnabledbooleantrueEnable support for marketplace listings by default
marketplace: {
  autoPublish: true,
  defaultPrice: '49',
  supportEnabled: true,
}

Complete Example

A full kit.config.ts with all sections populated:

kit.config.ts
import { defineConfig } from '@web3marketlabs/config'
 
export default defineConfig({
  contracts: {
    framework: 'foundry',
    root: 'contracts',
    include: ['**/*.sol'],
    exclude: ['**/test/**', '**/script/**'],
  },
 
  chains: {
    default: 'sepolia',
    targets: {
      localhost: {
        chainId: 31337,
        rpcUrl: 'http://127.0.0.1:8545',
      },
      sepolia: {
        chainId: 11155111,
        rpcUrl: { env: 'SEPOLIA_RPC_URL' },
      },
      mainnet: {
        chainId: 1,
        rpcUrl: { env: 'MAINNET_RPC_URL' },
      },
    },
  },
 
  codegen: {
    outDir: 'src/generated',
    hooks: true,
    components: false,
  },
 
  deploy: {
    verify: true,
    confirmations: 2,
  },
 
  modules: {},
 
  components: ['token'],
 
  ai: {
    enabled: true,
    model: 'claude-sonnet-4-5-20250929',
  },
 
  apiKeys: {
    web3market: 'wm_live_abc123',
    anthropic: 'sk-ant-api03-...',
  },
 
  vercel: {
    enabled: true,
    projectName: 'my-dapp',
  },
 
  marketplace: {
    autoPublish: false,
    defaultPrice: '0',
    supportEnabled: true,
  },
})

How Config Loading Works

File Discovery

The CLI searches for kit.config.ts in the current working directory (or a path specified with --config).

TypeScript Transpilation

The file is loaded using jiti, which transpiles TypeScript to JavaScript at runtime. This means you can use full TypeScript syntax, imports, and type annotations in your config file.

Zod Validation

The exported config object is validated against the Zod schema defined in @web3marketlabs/config. Missing optional fields are filled with their default values. Invalid values produce clear error messages with the exact path and issue.

Resolved Config

The fully validated and defaulted KitConfig object is returned and used by all CLI commands, codegen, and deployment pipelines.