The testrpc command can be used to simulate an Ethereum node. To install this command-line app, you need to install ethereumjs-testrpc globally:
npm install -g ethereumjs-testrpc
Here are the various options that can be provided:
- -a or --accounts: This specifies the number of accounts to be generated at startup.
- -b or --blocktime: This specifies the blocktime in seconds for automatic mining. The default is 0, and there's no auto-mining.
- -d or --deterministic: Whenever the node is run, it will generate 10 deterministic addresses; that is, when you provide this flag, the same set of addresses are generated every time. This option can be used to generate deterministic addresses based on a predefined mnemonic as well.
- -n or --secure: Locks the available accounts by default. When this option is used without the --unlock option, the HD wallet will not be created.
- -m or --mnemonic: Uses a specific HD wallet mnemonic to generate initial addresses.
- -p or --port: The port number to listen on. Defaults to 8545.
- -h or --hostname: The hostname to listen on. Defaults to Node's server.listen() default.
- -s or --seed: The arbitrary data to generate the HD wallet mnemonic to be used.
- -g or --gasPrice: Uses a custom gas price (defaults to 1). If the gas price is not provided while sending the transaction to the node, then this gas price is used.
- -l or --gasLimit: Uses a custom limit (defaults to 0x47E7C4). If the gas limit is not provided while sending the transaction to node, then this gas limit is used.
- -f or --fork: This is the fork from another currently running Ethereum node at a given block. The input should be the HTTP location and port of the other client; for example, http://localhost:8545. Optionally, you can specify the block to fork from using an @ sign: http://localhost:8545@1599200.
- --debug: Outputs VM opcodes for debugging.
- --account: This option is used to import accounts. It specifies --account=... any number of times, passing arbitrary private keys and their associated balances to generate initial addresses. An testrpc --account="privatekey,balance" [--account="privatekey,balance"] an HD wallet will not be created for you when using --account.
- -u or --unlock: Specifies --unlock ... any number of times, passing either an address or an account index to unlock specific accounts. When used in conjunction with --secure, --unlock will override the locked state of the specified accounts: testrpc --secure --unlock "0x1234..." --unlock "0xabcd...". You can also specify a number, unlocking accounts by their index: testrpc --secure -u 0 -u 1. This feature can also be used to impersonate accounts and unlock addresses you wouldn't otherwise have access to. When used with the --fork feature, you can use the testrpc to make transactions as any address on the blockchain, which is very useful in testing and dynamic analysis.
- --networkId: Used to specify a network ID that this node is part of.
Note that private keys are 64 characters long and must be input as a 0x-prefixed hex string. The balance can either be input as an integer or a 0x-prefixed hex value specifying the amount of wei in that account.