LinuxCommandLibrary

ganache-cli

Run local Ethereum blockchain for testing

TLDR

Run Ganache

$ ganache-cli
copy

Run Ganache with a specific number of accounts
$ ganache-cli --accounts=[number_of_accounts]
copy

Run Ganache and lock available accounts by default
$ ganache-cli --secure
copy

Run Ganache server and unlock specific accounts
$ ganache-cli --secure --unlock "[account_private_key1]" --unlock "[account_private_key2]"
copy

Run Ganache with a specific account and balance
$ ganache-cli --account="[account_private_key],[account_balance]"
copy

Run Ganache with accounts with a default balance
$ ganache-cli --defaultBalanceEther=[default_balance]
copy

Run Ganache and log all requests to stdout
$ ganache-cli --verbose
copy

SYNOPSIS

ganache-cli [options]

PARAMETERS

--account <value>, -a <value>
    Set accounts to use (e.g., '0x...,1000000')

--accounts <number>
    Number of accounts to generate (default: 10)

--host <string>, -h <string>
    Hostname to listen on (default: 127.0.0.1)

--port <number>, -p <number>
    Port to listen on (default: 8545)

--networkId <number>, -n <number>
    Network identifier (default: 5777)

--blockTime <number>
    Block time in seconds (default: 0, instant mining)

--gasLimit <number>
    Gas limit (default: 8000029)

--mnemonic <string>
    HD wallet mnemonic phrase

--seed <string>
    HD wallet seed phrase

--db <path>
    Database directory path

--debug
    Enable debugging

--verbose
    Increase verbosity

--help, -h
    Show help

--version, -v
    Show version

DESCRIPTION

Ganache CLI is a rapid, extensible Ethereum private network designed for smart contract development and testing.

It simulates a full Ethereum blockchain on your local machine, providing 10 fake Ether accounts by default, deterministic block mining, and instant transaction processing. Developers use it to deploy, test, and debug smart contracts without relying on the live Ethereum network, saving time and gas costs.

Key features include customizable genesis blocks, support for HD wallets via mnemonics, adjustable gas limits, network IDs, and block times for realistic simulations. It supports JSON-RPC API compatible with tools like Truffle, Hardhat, and Remix.

Ideal for solo devs or teams needing a disposable, forkable chain. Install via npm install -g ganache-cli. Note: Primarily for testing; not for production use.

CAVEATS

Development tool only; not for production. Requires Node.js/npm. Deprecated in favor of 'ganache' package. Instant mining may not simulate real network latency.

INSTALLATION

npm install -g ganache-cli
Run with ganache-cli for defaults.

EXAMPLE

ganache-cli --port 8545 --accounts 5 --blockTime 3
Starts network on port 8545 with 5 accounts, 3s blocks.

HISTORY

Originally developed by Truffle Suite (Consensys) around 2017 as TestRPC, rebranded to Ganache CLI. Evolved for Ethereum DApp testing. Version 6.x marked shift to modular design; now maintained under Ganache v7+ with UI companion.

SEE ALSO

geth(1), anvil(1)

Copied to clipboard