You can use ethereumjs-testrpc as a web3 provider like this:
var TestRPC = require("ethereumjs-testrpc");
web3.setProvider(TestRPC.provider());
You can use ethereumjs-testrpc as a general HTTP server like this:
var TestRPC = require("ethereumjs-testrpc");
var server = TestRPC.server();
server.listen(port, function(err, blockchain) {});
Both provider() and server() take a single object that allows you to specify the behavior of the ethereumjs-testrpc. This parameter is optional. The available options are as follows:
- accounts: Value is an array of objects. Each object should have a balance key with a hexadecimal value. The secretKey key can also be specified, which represents the account's private key. If there's no secretKey, the address is autogenerated with the given balance. If specified, the key is used to determine the account's address.
- debug: Outputs VM opcodes for debugging.
- logger: Value is an object that implements a log() function.
- mnemonic: Uses a specific HD wallet mnemonic to generate initial addresses.
- port: The port number to listen on when running as a server.
- seed: Arbitrary data to generate the HD wallet mnemonic to be used.
- total_accounts: The number of accounts to generate at start up.
- fork: The same as the preceding --fork option.
- network_id: The same as the --networkId option. Used to specify a network ID that this node is part of.
- time: The date that the first block should start. Use this feature along with the evm_increaseTime method to test time-dependent code.
- locked: Specifies whether or not accounts are locked by default.
- unlocked_accounts: An array of addresses or address indexes specifying which accounts should be unlocked.