Skip to main content

Initialize Configuration

The flow init command creates a new Flow project with a basic flow.json configuration file. This is the first step in setting up any Flow project.

Basic Usage


_10
flow init

This command will:

  • Create a new flow.json configuration file
  • Set up default networks (emulator, testnet, mainnet)
  • Create an emulator service account
  • Generate a basic project structure with cadence/ directories

Example Output


_10
> flow init
_10
_10
Configuration initialized
_10
Service account: 0xf8d6e0586b0a20c7
_10
_10
Start emulator by running: 'flow emulator'
_10
Reset configuration using: 'flow init --reset'

Project Structure

After running flow init, you'll have:


_10
my-project/
_10
├── flow.json
_10
├── emulator-account.pkey
_10
└── cadence/
_10
├── contracts/
_10
├── scripts/
_10
├── transactions/
_10
└── tests/

Configuration Only

If you only want to generate the flow.json file without creating the full project structure, use the --config-only flag:


_10
flow init --config-only

This is useful when:

  • You already have a project structure
  • You want to add Flow configuration to an existing project
  • You're setting up configuration for a specific environment

Global Configuration

You can create a global flow.json file that applies to all Flow projects on your system:


_10
flow init --global

Global configuration locations:

  • macOS/Linux: ~/flow.json
  • Windows: C:\Users\$USER\flow.json

Priority order:

  1. Local flow.json (highest priority)
  2. Global flow.json (lowest priority)

Local configuration files will override global settings for overlapping properties.

Error Handling

If a flow.json file already exists, you'll see this error:


_10
❌ Command Error: configuration already exists at: flow.json, if you want to reset configuration use the reset flag

Solutions:

  • Use --reset flag to overwrite existing configuration
  • Delete the existing flow.json file first
  • Initialize in a different directory

Flags

Reset Configuration


_10
flow init --reset

Overwrites existing configuration with a fresh setup.

Configuration Only


_10
flow init --config-only

Creates only the flow.json file without project structure.

Global Configuration


_10
flow init --global

Creates a global configuration file in your home directory.

Service Account Customization

Private Key


_10
flow init --service-private-key <hex-key>

Specify a custom private key for the service account.

Signature Algorithm


_10
flow init --service-sig-algo ECDSA_P256

Options: ECDSA_P256, ECDSA_secp256k1 Default: ECDSA_P256

Hash Algorithm


_10
flow init --service-hash-algo SHA3_256

Options: SHA2_256, SHA3_256 Default: SHA3_256

Log Level


_10
flow init --log debug

Options: none, error, debug Default: info

Next Steps

After initializing your configuration:

  1. Review the generated flow.json - Understand the default setup
  2. Add your contracts - Use flow config add contract
  3. Create accounts - Use flow accounts create or flow config add account
  4. Configure deployments - Use flow config add deployment
  5. Start developing - Run flow emulator start