Ganache command line options¶
This reference describes the syntax of the Ganache command line interface (CLI) options for the Ethereum network.
Specify options¶
With the exception of detach mode, the startup options are grouped in the chain
, database
, logging
, miner
, wallet
, fork
, and server
namespaces, and should be used as follows on startup:
ganache --<namespace>.<option>=<value>
You can also use an alias for startup options that have them. For example to set the network ID of a network use ganache -i=<NETWORK_ID>
instead of ganache --chain.networkId=<NETWORK_ID>
.
When using the startup options programmatically, use the following:
const options = { <namespace>: { <option>: <value>}};
const provider = ganache.provider(options);
Note: Command line options are case-sensitive.
chain
¶
--chain.allowUnlimitedContractSize
--chain.allowUnlimitedContractSize=<BOOLEAN>
--chain.allowUnlimitedContractSize=true
Indicate whether to allow unlimited contract sizes while debugging. When set to true
, Ganache behaves differently than in production environments.
The default is false
.
** --chain.asyncRequestProcessing
**
--chain.asyncRequestProcessing=<BOOLEAN>
--chain.asyncRequestProcessing=false
Indicate whether to asynchronously process requests. When false
, only one request is processed at a time.
The default is true
.
--chain.chainId
--chain.chainId=<NUMBER>
--chain.chainId=10
The chain ID of the network.
The default is 1337
.
--chain.networkId
, -i
--chain.networkId=<NUMBER>
--chain.networkId=10
The network ID that's retrieved when running the net_version
JSON-RPC method.
The default is the system time when the process starts, or network ID of the forked blockchain if configured.
The alias --networkId
is deprecated, use -i
instead.
--chain.time
, -t
--chain.time=<DATE>
--chain.time=1662596414
Date and time that the first block should start. Accepts the date format supported by the JavaScript Date()
constructor. For example Unix epoch or a string.
The alias --time
is deprecated, use -t
instead.
--chain.hardfork
, -k
--chain.hardfork=<STRING>
--chain.hardfork="arrowGlacier"
The hardfork rules for the EVM. Valid options are: constantinople
, byzantium
, petersburg
, istanbul
, muirGlacier
, berlin
, london
, arrowGlacier
, and grayGlacier
.
The default is london
.
The alias --hardfork
has been deprecated, use -k
instead.
--chain.vmErrorsOnRPCResponse
--chain.vmErrorsOnRPCResponse=<BOOLEAN>
--chain.vmErrorsOnRPCResponse=true
Indicate whether to report runtime errors from EVM code as RPC errors.
The default is false
.
database
¶
--database.dbPath
--database.dbPath=<STRING>
--database.dbPath="/User/me/db"
The path to a directory to save the chain database.
The aliases --db
and --db_path
have been deprecated.
logging
¶
--logging.debug
--logging.debug=<BOOLEAN>
--logging.debug=true
Indicate whether to log debug information. Set to true
to log EVM opcodes.
The default is false
.
--logging.quiet
, q
--logging.quiet=<BOOLEAN>
--logging.quiet=true
Indicate whether to disable logging. Set to true
to disable logging.
The default is false
.
The alias --quiet
has been deprecated, use -q
instead.
--logging.verbose
, -v
--logging.verbose=<BOOLEAN>
--logging.verbose=true
Indicate whether to log detailed RPC requests.
The default is false
.
The alias --verbose
has been deprecated, use -v
instead.
miner
¶
--miner.blockTime
, b
--miner.blockTime=<NUMBER>
--miner.blockTime=10
The block time (in seconds) for automatic mining. A block time of 0
enables instamine mode
, where new executable transactions are mined instantly.
The default is 0
.
The alias --blockTime
has been deprecated, use -b
instead.
--miner.timestampIncrement
--miner.timestampIncrement=<NUMBER>
--miner.timestampIncrement=5
The amount of time (in seconds) to add to the timestamp of each new block header.
The default is clock
, which uses your system clock time as the timestamp for each new block.
--miner.defaultGasPrice
, g
--miner.defaultGasPrice=<STRING>
--miner.defaultGasPrice="0x87369400"
The default gas price in WEI for transactions if not specified.
The default is 0x77359400
(2 GWEI).
The alias --gasPrice
has been deprecated, use -g
instead.
--miner.blockGasLimit
, l
--miner.blockGasLimit=<STRING>
--miner.blockGasLimit="0x87369400"
The block gas limit in WEI.
The default is 0x1c9c380
(30 million WEI).
The alias --gasLimit
has been deprecated, use -l
instead.
--miner.defaultTransactionGasLimit
--miner.defaultTransactionGasLimit=<STRING>
--miner.defaultTransactionGasLimit="0x16F30"
The default transaction gas limit in WEI. Set to estimate
to use an estimate (slows down transaction execution by 40%+).
The defaults is 0x15f90
.
--miner.difficulty
--miner.difficulty=<STRING>
--miner.difficulty="0x2"
The block difficulty.
The default is 0x1
.
--miner.callGasLimit
--miner.callGasLimit=<STRING>
--miner.callGasLimit="0x58af080"
The transaction gas limit in WEI for eth_call
and eth_estimateGas
calls.
The default is 0x2faf080
.
--miner.instamine
--miner.instamine=<STRING>
--miner.instamine="strict"
The instamine
mode which is either eager
or strict
. In eager
mode a transaction is included in a block before its hash is returned to the caller. In strict
mode a transaction's hash is returned to the caller before the transaction is included in a block. This value has no effect if --miner.blockTime
is not 0
(the default).
The default is eager
.
--miner.coinbase
--miner.coinbase=<STRING>
--miner.coinbase="0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"
The mining reward address.
The default is 0x0000000000000000000000000000000000000000
.
--miner.extraData
--miner.extraData=<STRING>
--miner.extraData="0x444F4E27542050414E4943202120484F444C2C20484F444C2C20484F444C2021"
A hex string representing the 32 bytes included in the extra data field of a mined block.
The default is 0x
.
--miner.priceBump
--miner.priceBump=<STRING>
--miner.priceBump="0x1"
Minimum price bump percentage needed to replace a transaction that already exists in the transaction pool.
The default is 10
.
wallet
¶
--wallet.accounts
--wallet.accounts=<STRING>,<STRING>
--wallet.accounts="0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63","0X56BC75E2D63100000"
Account data in the form <private_key>,<initial_balance>
. Specify the option multiple times to add multiple private keys with an initial balance.
Private keys are 64 characters long, and must include the 0x
prefix. The account balance can be an integer, or a 0x
-prefixed hex string with either form specifying the initial balance in WEI.
The alias --account
has been deprecated.
--wallet.totalAccounts
, -a
--wallet.totalAccounts=<NUMBER>
--wallet.totalAccounts=5
Number of accounts to generate at startup.
The default is 10
.
The alias --accounts
has been deprecated, use -a
instead.
--wallet.deterministic
, -d
--wallet.deterministic=<BOOLEAN>
--wallet.deterministic=true
Use a pre-defined, deterministic seed.
The default is false
.
The alias --deterministic
has been deprecated, use -d
instead.
--wallet.seed
, -s
--wallet.seed=<STRING>
--wallet.seed="c0157f7c8240459516f42b518c1cba1da942b9a5fb5e6313a948872fcac2742e28250a8b2faef0924ae5d2d59781d7789c4c960a2fef8283d886198d40cf871f"
The seed to generate a mnemonic.
The default is a random value unless you specify --wallet.deterministic
.
The alias --seed
has been deprecated, use -s
instead.
--wallet.mnemonic
, -m
--wallet.mnemonic=<STRING>
--wallet.mnemonic="car casual program tourist aerobic broccoli link hamster resemble collect put october"
Use the specified HD wallet mnemonic to generate initial addresses.
The default is generated from --wallet.seed
.
The alias --mnemonic
has been deprecated, use -m
instead.
--wallet.unlockedAccounts
, -u
--wallet.unlockedAccounts=<STRING>
--wallet.unlockedAccounts="0x8060b4E5dc6a2ee2974873c1ec7B58d6c2932c47"
--wallet.unlockedAccounts=2
Addresses or address indexes specifying which accounts should be unlocked. You can specify the option multiple times.
The alias --unlock
has been deprecated, use -u
instead.
--wallet.lock
, -n
--wallet.lock=<BOOLEAN>
--wallet.lock=true
Locks all available accounts, which is good for third party transaction signing.
The --secure
and --lock
aliases have been deprecated, use -n
instead.
--wallet.passphrase
--wallet.passphrase=<STRING>
--wallet.passphrase="changeme"
The passphrase to use when locking accounts.
The alias --passphrase
has been deprecated.
--wallet.accountKeysPath
--wallet.accountKeysPath=<STRING>
--wallet.accountKeysPath="/Users/me/myKeys.txt"
Specify a file to save accounts and private keys to, for testing. The aliases --account_keys_path
and --acctKeys
have been deprecated.
--wallet.defaultBalance
, -e
--wallet.defaultBalance=<NUMBER>
--wallet.defaultBalance=120
Specify the default account balance in ether.
The default is 1000
.
--wallet.hdPath
--wallet.hdPath=<STRING>
--wallet.hdPath="m,44',60',160720',0"
The hierarchical deterministic (HD) path to use when generating accounts.
The default is m,44',60',0',0
.
fork
¶
--fork.url
, -f
--fork.url=<STRING>
--fork.url="http://localhost:1337"
Fork from a running Ethereum client. You can optionally specify the block to fork from using an @
character, for example http://localhost:1337@8675309
.
The specified URL supports basic authentication credentials as well. For example, wss://<user>:<password>@example.com/
. If you need to use an Infura API key secret, you would use it as follows:
wss://:<API-KEY-SECRET>@mainnet.infura.com/ws/v3/<API-KEY>
Alternatively, you can use the --fork.username
and --fork.password
options.
--fork.network
--fork.network=<STRING>
--fork.network="goerli"
The network to fork. Valid options are mainnet
, goerli
, gΓΆrli
, and sepolia
.
Use the command ganache --fork
to automatically fork Mainnet at the latest block.
--fork.blockNumber
--fork.blockNumber=<NUMBER>
--fork.blockNumber=182354
Block number to fork from. The default is the latest block.
--fork.preLatestConfirmations
--fork.preLatestConfirmations=<NUMBER>
--fork.preLatestConfirmations=8
When the --fork.blockNumber
is set to latest
(default), this option specifies the number of blocks before the remote node's latest block to fork from.
The default is 5
.
--fork.username
--fork.username=<STRING>
--fork.username="JohnDoe"
Username for basic authentication. Does not require setting --fork.password
. When combined with --fork.password
, the shorthand is { headers: { "Authorization": "Basic {ENCODED-BASIC-HEADER}" } }
.
If --fork.headers
specifies an authorization header, the header is inserted after the Basic token.
--fork.password
--fork.password=<STRING>
--fork.password="changeme"
Password for basic authentication. Does not require setting --fork.username
. When combined with --fork.username
, the shorthand is { headers: { "Authorization": "Basic {ENCODED-BASIC-HEADER}" } }
.
If the --fork.headers
specifies an authorization header, the header is inserted after the Basic token.
--fork.jwt
--fork.jwt=<STRING>
--fork.jwt="eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJwZXJtaXNzaW9ucyI6Iio6KiIsInByaXZhY3lQdWJsaWNLZXkiOiIyVUtIM1ZKVGhrT29Lc2tyTEZwd294Q25uUkFSeW9iVjFiRWRnc2VGSFRzPSIsImV4cCI6IjE2MDA4OTk5OTkwMDIiLCJpYXQiOjE2MzkxNTc2Mjd9.FGf-FmfDQlIPCRDGmNnsHZWlwrUr69d7AIDqQrIrUrSJLiwGpR3NCUhVHIDMpQvDHQYf-sFMZTYvZGrvztYRuBKWMbTfIZKN74onzNJbFIPBVQuUX2HMXmI4VQ3UFB11LShiUJHKLna13qdbqfbgJIO3HetxJhJQxTiwtixfHwyPXl-Nx8HbQy_AWH58lLAUeaoLzN7QIA9kborthBpvfK9C7Sv1lXT1cdCDC4oRKBoiMg2RWFZtGtxFsnWyloangwbhCB6Bc_elqY5nd9WkF4ix95xsP_HgBcouy1sDw6jxn5_LveX53H8owczVWP6S1e6hv6hq2fs6YkSntKMK2g"
Encoded JSON Web Token (JWT) used for authenticating to servers.
The shorthand is { headers: { "Authorization": "Bearer {YOUR-ENCODED-JWT}" } }
.
If the --fork.headers
option specifies an authorization header, the header is inserted after the JWT Bearer token.
--fork.userAgent
--fork.userAgent=<STRING>
--fork.userAgent="Ganache/7.0.0-beta.0 (https://www.trufflesuite.com/ganache; ganache<at>trufflesuite.com)]"
The User-Agent header sent to the fork on each request.
Sent as Api-User-Agent
when used in the browser. Is overridden by a User-Agent
defined in the --fork.headers
option, if provided.
The default is Ganache/VERSION (https://www.trufflesuite.com/ganache; ganache<at>trufflesuite.com)
.
--fork.origin
--fork.origin=<STRING>
--fork.origin="https://www.trufflesuite.com/ganache"
The Origin header sent to the fork on each request. Ignored in the browser.
Is overridden by an Origin
value defined in the --fork.headers
option, if provided.
--fork.headers
--fork.headers=<STRING>
--fork.headers="User-Agent: Ganache/VERSION (https://www.trufflesuite.com/ganache; ganache<at>trufflesuite.com)"
Headers to supply on each request to the forked provider. Headers set here override headers set by other options, unless otherwise specified.
The default is "User-Agent: Ganache/VERSION (https://www.trufflesuite.com/ganache; ganache<at>trufflesuite.com)"
.
--fork.requestsPerSecond
--fork.requestsPerSecond=<NUMBER>
--fork.requestsPerSecond=10
Restrict the number of requests sent per second to the fork provider.
The default is 0
, meaning no limit is applied.
--fork.disableCache
--fork.disableCache=<BOOLEAN>
--fork.disableCache=true
Disables caching forking requests.
The default is false
.
--fork.deleteCache
--fork.deleteCache=<BOOLEAN>
--fork.deleteCache=true
Deletes the persistent cache before starting.
The default is false
.
server
¶
--server.ws
--server.ws=<BOOLEAN>
--server.ws=false
Enables a WebSocket server.
The default is true
.
--server.wsBinary
--server.wsBinary=<BOOLEAN>
--server.wsBinary=false
Indicates whether WebSocket should respond with binary data (ArrayBuffers) or strings. Options are true
, false
, or auto
.
The default is auto
.
--server.rpcEndpoint
--server.rpcEndpoint=<STRING>
--server.rpcEndpoint="/v3"
Defines the endpoint route the HTTP and WebSocket servers listen on.
The default is /
for Ethereum and /rpc/v0
for Filecoin.
--server.host
, -h
--server.host=<STRING>
--server.host="127.0.0.1"
The hostname to listen on.
The default is 127.0.0.1
.
The aliases --host
and --hostname
have been deprecated, use -h
instead.
--server.port
, -p
--server.port=<NUMBER>
--server.port=9545
The port to listen on. The default is 8545
.
The alias --port
has been deprecated, use -p
instead.
Detach mode¶
Ganache can be started as a background process by passing the --detach
option, along with any valid combination of start-up options.
--detach
, -D
, --π
Runs Ganache as a background process, outputting a friendly name that can be used to reference the instance when managing the instance via the ganache instances
command.
Ganache will only return to the command line once it is ready to receive requests, making it handy for scripting - for example, you can start Ganache, execute a series of tests, and teardown the instance when complete with a one-liner:
GANACHE=$(ganache --detach) && npm run test; ganache instances stop $GANACHE
Or if you are running PowerShell, you can do:
$GANACHE=ganache --detach; npm run test; ganache instances stop $GANACHE; Remove-Variable GANACHE
Manage detached instances¶
The ganache instances <sub-command>
can be used to manage instances of Ganache running in detach mode.
list
¶
Output the list of instances running in detach mode.
instances list
ganache instances list
$ ganache instances list
βββββββββ¬βββββββββββββββββββββββββ¬βββββββββββ¬ββββββββββ¬βββββββββββββββββ¬βββββββββ
β PID β Name β Flavor β Version β Host β Uptime β
βββββββββΌβββββββββββββββββββββββββΌβββββββββββΌββββββββββΌβββββββββββββββββΌβββββββββ€
β 12182 β salted_caramel_ganache β ethereum β 7.6.0 β 127.0.0.1:8545 β 36s β
βββββββββ΄βββββββββββββββββββββββββ΄βββββββββββ΄ββββββββββ΄βββββββββββββββββ΄βββββββββ
stop
¶
Stop an instance of ganache running in detach mode.
instances stop
ganache instances stop <name>
ganache instances stop salted_caramel_ganache