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
_10flow init
This command will:
- Create a new
flow.jsonconfiguration file - Set up default networks (emulator, testnet, mainnet)
- Create an emulator service account
- Generate a basic project structure with
cadence/directories - Give you options for project scaffolding
Project Structure
After running flow init, you'll have:
_10my-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:
_10flow 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:
_10flow init --global
Global configuration locations:
- macOS/Linux:
~/flow.json - Windows:
C:\Users\$USER\flow.json
Priority order:
- Local
flow.json(highest priority) - 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
Solutions:
- Delete the existing
flow.jsonfile first - Initialize in a different directory
- Use
--config-onlyto create a new config in a different location
Flags
Configuration Only
_10flow init --config-only
Creates only the flow.json file without project structure.
Global Flags
The following global flags are also available:
_10# Log level_10flow init --log debug_10_10# Output format_10flow init --output json_10_10# Approve prompts automatically_10flow init --yes
Available log levels: debug, info, error, none
Next Steps
After initializing your configuration:
- Review the generated
flow.json- Understand the default setup - Add your contracts - Use
flow config add contract - Create accounts - Use
flow accounts createorflow config add account - Configure deployments - Use
flow config add deployment - Start developing - Run
flow emulator start
Related Commands
flow config add- Add configuration itemsflow accounts create- Create new accountsflow project deploy- Deploy contracts