or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

accounts.mdcli.mdcontracts.mdconversion-testing.mdindex.mdnetwork.mdproject.md

cli.mddocs/

0

# Command Line Interface

1

2

Brownie provides a comprehensive command-line interface for project management, contract compilation, testing, deployment, and debugging. The CLI offers both powerful automation capabilities and interactive development tools.

3

4

## Capabilities

5

6

### Project Management Commands

7

8

Core commands for creating, initializing, and managing brownie projects with template support.

9

10

```bash { .api }

11

brownie init [project_name] [options]

12

# Initialize new brownie project in current or specified directory

13

# Options:

14

# --force Overwrite existing files

15

# Example: brownie init my-defi-project

16

17

brownie bake [template_name] [options]

18

# Create project from brownie-mix template

19

# Options:

20

# --force Overwrite existing files

21

# Example: brownie bake token

22

23

brownie pm [command] [package] [options]

24

# Package manager for brownie dependencies

25

# Commands:

26

# install Install package dependency

27

# uninstall Remove package dependency

28

# list List installed packages

29

# Example: brownie pm install OpenZeppelin/openzeppelin-contracts@4.3.0

30

```

31

32

### Compilation Commands

33

34

Contract compilation with support for multiple Solidity and Vyper versions plus optimization settings.

35

36

```bash { .api }

37

brownie compile [options]

38

# Compile project contracts

39

# Options:

40

# --all Recompile all contracts

41

# --size Display contract sizes

42

# --optimizer Enable compiler optimizer

43

# --runs N Optimizer runs setting

44

# --solc VERSION Specific Solidity version

45

# --vyper VERSION Specific Vyper version

46

# Example: brownie compile --optimizer --runs 200

47

```

48

49

### Console and Interactive Commands

50

51

Interactive development environment with Python console and web-based GUI.

52

53

```bash { .api }

54

brownie console [options]

55

# Launch interactive Python console with brownie environment

56

# Options:

57

# --network NAME Connect to specific network

58

# --tb Show full tracebacks on error

59

# Example: brownie console --network mainnet

60

61

brownie gui [options]

62

# Launch web-based GUI for contract interaction

63

# Options:

64

# --host HOST GUI host address (default: localhost)

65

# --port PORT GUI port number (default: random)

66

# --no-browser Don't auto-open browser

67

# Example: brownie gui --host 0.0.0.0 --port 8080

68

```

69

70

### Testing Commands

71

72

Comprehensive testing framework with coverage analysis and property-based testing.

73

74

```bash { .api }

75

brownie test [path] [options]

76

# Run project test suite with pytest integration

77

# Options:

78

# --network NAME Test network (default: development)

79

# --coverage Generate coverage report

80

# --gas Show gas usage analysis

81

# --update-snapshots Update test snapshots

82

# --stateful Run stateful tests

83

# --interactive Interactive debugger on failure

84

# -v, --verbose Verbose output

85

# -s Show print statements

86

# -x Stop on first failure

87

# Example: brownie test tests/test_token.py --coverage --gas

88

```

89

90

### Script Execution Commands

91

92

Execute project automation scripts with argument passing and method selection.

93

94

```bash { .api }

95

brownie run [script] [method] [args] [options]

96

# Execute project script with optional method and arguments

97

# Options:

98

# --network NAME Target network for execution

99

# --interactive Interactive debugger on error

100

# Examples:

101

# brownie run scripts/deploy.py --network mainnet

102

# brownie run scripts/manage.py transfer 1000 --network development

103

```

104

105

### Account Management Commands

106

107

Local account management with import, export, and password protection.

108

109

```bash { .api }

110

brownie accounts [command] [options]

111

# Manage local accounts

112

# Commands:

113

# list List all accounts

114

# new NAME Generate new account

115

# import NAME Import account from private key

116

# export NAME Export account private key

117

# delete NAME Remove account

118

# unlock NAME Unlock account for session

119

# password NAME Change account password

120

# Options:

121

# --password PASS Account password

122

# --force Skip confirmation prompts

123

# Examples:

124

# brownie accounts new deployer

125

# brownie accounts import mainnet-deployer

126

```

127

128

### Network Management Commands

129

130

Network configuration and connection management for different blockchain environments.

131

132

```bash { .api }

133

brownie networks [command] [options]

134

# Manage network configurations

135

# Commands:

136

# list List available networks

137

# add [environment] [id] [host] [options] # Add new network

138

# modify [id] [options] # Modify network settings

139

# delete [id] # Remove network

140

# set-default [id] # Set default network

141

# Network options:

142

# --host URL RPC endpoint URL

143

# --chainid ID Chain ID number

144

# --gas-limit N Default gas limit

145

# --gas-price N Default gas price

146

# Examples:

147

# brownie networks list

148

# brownie networks add Ethereum mainnet-fork http://localhost:8545 --chainid 1

149

```

150

151

## Usage Examples

152

153

### Project Setup Workflow

154

155

```bash

156

# Create new project from template

157

brownie bake token my-token-project

158

cd my-token-project

159

160

# Install dependencies

161

brownie pm install OpenZeppelin/openzeppelin-contracts@4.3.0

162

163

# Compile contracts

164

brownie compile --optimizer

165

166

# Run tests with coverage

167

brownie test --coverage --gas

168

169

# Deploy to testnet

170

brownie run scripts/deploy.py --network goerli

171

```

172

173

### Development Workflow

174

175

```bash

176

# Start interactive development

177

brownie console --network development

178

179

# In another terminal, run tests continuously

180

brownie test --watch

181

182

# Deploy and test interactively

183

brownie gui --network development

184

```

185

186

### Account Management Workflow

187

188

```bash

189

# Create deployment account

190

brownie accounts new mainnet-deployer

191

192

# Import existing account

193

brownie accounts import backup-account

194

195

# List all accounts

196

brownie accounts list

197

198

# Use specific account in script

199

brownie run scripts/deploy.py --network mainnet --account mainnet-deployer

200

```

201

202

### Network Configuration Examples

203

204

```bash

205

# Add local development network

206

brownie networks add Development local http://localhost:8545 --chainid 1337

207

208

# Add mainnet fork for testing

209

brownie networks add Ethereum mainnet-fork http://localhost:8545 --chainid 1 --gas-price 20000000000

210

211

# Add custom testnet

212

brownie networks add Ethereum custom-testnet https://rpc.custom-testnet.io --chainid 12345

213

```

214

215

### Testing and Debugging

216

217

```bash

218

# Run specific test file with verbose output

219

brownie test tests/test_token.py -v -s

220

221

# Run single test function

222

brownie test tests/test_token.py::test_transfer -s

223

224

# Generate coverage report and open in browser

225

brownie test --coverage

226

brownie gui --coverage

227

228

# Run tests with interactive debugger

229

brownie test --interactive

230

231

# Run stateful property-based tests

232

brownie test --stateful

233

```

234

235

### Advanced Usage

236

237

```bash

238

# Compile specific contract

239

brownie compile contracts/Token.sol

240

241

# Force recompilation of all contracts

242

brownie compile --all --force

243

244

# Run script with specific method

245

brownie run scripts/manage.py mint_tokens 1000000

246

247

# Execute with gas profiling

248

brownie test --gas --network mainnet-fork

249

250

# Interactive console with custom network

251

brownie console --network http://localhost:7545

252

```

253

254

## Global Options

255

256

Options available for all brownie commands:

257

258

```bash { .api }

259

# Global flags (available for all commands):

260

--help, -h Show command help

261

--verbose, -v Verbose output

262

--tb Show full Python tracebacks

263

--quiet, -q Suppress console output

264

--color / --no-color Control colored output

265

```

266

267

## Environment Variables

268

269

Environment variables that affect brownie CLI behavior:

270

271

```bash { .api }

272

BROWNIE_CONFIG_FILE # Custom config file path

273

BROWNIE_DATA_FOLDER # Custom data directory

274

BROWNIE_LIB # Library installation mode

275

WEB3_INFURA_PROJECT_ID # Infura project ID

276

ETHERSCAN_TOKEN # Etherscan API token

277

```

278

279

## Integration with Other Tools

280

281

### CI/CD Integration

282

283

```bash

284

# Example GitHub Actions workflow

285

- name: Run Brownie Tests

286

run: |

287

brownie test --network development --coverage

288

brownie gui --coverage --no-browser

289

```

290

291

### Docker Integration

292

293

```bash

294

# Run brownie in Docker container

295

docker run -v $(pwd):/project -w /project eth-brownie/brownie:latest test

296

297

# Interactive console in Docker

298

docker run -it -v $(pwd):/project -w /project eth-brownie/brownie:latest console

299

```

300

301

## Type Definitions

302

303

```bash { .api }

304

# Command return codes

305

0 # Success

306

1 # General error

307

2 # Configuration error

308

3 # Network connection error

309

4 # Compilation error

310

5 # Test failure

311

```