I am setting up unit tests with for my contracts using truffle. I am using also testrpc, but having accounts with 2.123...... *10^37 Wei is not very helpful to visualise and debug things.

I am trying to setup custom testRPC account balances using $ testrpc --account="<privatekey>,balance" as seen here. However, what I get back is one account with again "infinite ether".

I have also tried to do :

var TestRPC = require("ethereumjs-testrpc");
var accountConfig = [
  {balance: 20000000},
  {balance: 20000000}
web3.setProvider(TestRPC.provider({accounts: accountConfig}));

as seen here and here , however truffle complains it cannot find the module "ethereumjs-testrpc".

In short the question then is : how to set up custom account balances for testRPC?

1 Answer 1


From the documentation, you can explicity specify a new account address and balance using the following syntax:

--account: Specify --account=... (no 's') any number of times passing arbitrary private keys and their associated balances to generate initial addresses:

$ testrpc --account="<privatekey>,balance" [--account="<privatekey>,balance"]

Note that private keys are 64 characters long, and must be input as a 0x-prefixed hex string. Balance can either be input as an integer or 0x-prefixed hex value specifying the amount of wei in that account.

I'd suggest running testrpc without the --account option to get the randomly generated list of addresses, making a note of them, and then using them in conjunction with whatever balances you want them to have (by passing them to --account).

  • I don't understand the formatting of the documentation command Commented Apr 20, 2017 at 6:02
  • Hi Daniel. Thanks for pointing it out. There was an extra > in there which made it look odd. I've removed it. The important part is --account="<privatekey>,balance", which can be repeated multiple times, one for each account you want to add. Commented Apr 20, 2017 at 8:01
  • Sweet thanks, why do they surround private key in <> though? Commented Apr 20, 2017 at 8:08
  • @DanielKobe. Just because, really. It's a convention, although there may be some original historical reason. This is similar to keyboard commands being surrounded by brackets, e.g. [command]
    – JohnAllen
    Commented May 4, 2017 at 7:06
  • Thanks, @JohnAllen. I'd missed this follow-up question. :-) Commented May 4, 2017 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.