Skip to main content
The Anchor.toml file is the configuration file for Anchor workspaces. It defines workspace settings, program deployments, testing configuration, and build options.

File Structure

A complete Anchor.toml with all sections:

Required Sections

[provider]

Specifies the default cluster and wallet for all Anchor commands.
Cluster Options:
  • localnet - Local test validator (default: http://127.0.0.1:8899)
  • devnet - Solana devnet
  • mainnet - Solana mainnet-beta
  • Custom URL: "https://api.devnet.solana.com"
  • Custom with WebSocket:

[scripts]

Defines executable scripts for your workspace. The test script is required for anchor test.
Run scripts with:

Optional Sections

[toolchain]

Override toolchain versions and settings for the workspace.
Package Manager Values:
  • npm - Node Package Manager
  • yarn - Yarn (default)
  • pnpm - PNPM
  • bun - Bun runtime
The anchor_version field requires AVM (Anchor Version Manager) to be installed.

[features]

Configure Anchor framework features.
resolution: When enabled, the IDL includes account resolution information for clients. skip-lint: Disables checks for safety comments (e.g., // UNSAFE, // TODO) in generated code.

[registry]

Configure the Anchor Package Registry (APR) URL.

programs.cluster configuration

Map program library names to their on-chain addresses for each cluster.
Program IDs must match the declare_id!() in your program code. Use anchor keys sync to update program IDs.

[workspace]

Configure workspace member programs and TypeScript type generation.
members: Defaults to programs/* if not specified. types: When set, anchor build copies generated <program>.ts IDL files to this directory.

[hooks]

Run commands at specific stages of the build/test/deploy pipeline.
Available Hooks:
  • pre-build / post-build - Run before/after anchor build
  • pre-test / post-test - Run before/after anchor test
  • pre-deploy / post-deploy - Run before/after anchor deploy
Hook Behavior:
  • Single command: hook = "command"
  • Multiple commands: hook = ["cmd1", "cmd2"] (run in series)
  • Non-zero exit code aborts the operation
  • Supports both kebab-case (pre-build) and snake_case (pre_build)

[test]

Configure test validator behavior.
startup_wait: Increase if you’re cloning many accounts (increases startup time). upgradeable: When true, deploys with --upgradeable flag. Initial upgrade authority is set to provider.wallet.

[[test.genesis]]

Load programs at genesis when starting the test validator.
Use double brackets [[test.genesis]] for multiple entries.

[test.validator]

Configure the Solana test validator options.

[[test.validator.clone]]

Clone accounts from the configured cluster.
For upgradeable programs, Anchor automatically clones the program data account.

[[test.validator.account]]

Load account data from JSON files.
JSON Format:

Command Line Overrides

Override Anchor.toml settings via command line:

Environment Variables

Set provider options via environment variables:

Example Configurations

Minimal Configuration

Anchor.toml

Production Configuration

Anchor.toml

Testing with Mainnet Forks

Anchor.toml

Best Practices

Always specify exact versions:
Maintain separate program IDs for testing and production:
Always version control your Anchor.toml:
Automate verification in your deployment workflow:

Resources