0

If you use truffle for a while, you gradually deplete all your ether from the default account. Now truffle is defunct. How do I top-up the ether?

Note I think truffle uses testrpc in the default when you run truffle test or truffle develop. But I don't know how to take advantage of this, and can't find where testrpc is installed.

Clarifications added after initial post:

Truffle starts testrpc internally when you run truffle test, so I can't provide parameters to testrpc. Truffle/testrpc save the ether balances from run to run, so that the ether balance for accounts[0] is continuously depleted over time. I have been constantly replenishing the ethers in accounts[0] by transferring ether manually from higher numbered accounts in the truffle develop console. Also, I can't find where testrpc is installed so I can't run it manually. Additionally, I can't figure out how truffle runs testrpc, though I have looked in the truffle executable file (/usr/local/bin/truffle on my computer).

Solution:

Turns out my problem was I had an instance of truffle develop running in another tab. That is why the ether balances were continuously depleting. Oops!

1

I cannot answer how to replenish after the local blockchain is already running, but it is possible to start your accounts with (much) more ether.

Firstly, testrpc has now been replaced by ganache-cli, which is just the same. It stands for ganache command line as there is also a gui available. As you said, when you run commands such as truffle test, the default setup of ganache-cli is launched. Therefore to add options you have to first start your custom ganache. Assuming you have Node.js installed just run the following to install ganache-cli:

npm install -g ganache-cli

Then to start ganache with, for example, 10'000 ether on each of the 10 addresses run:

ganache-cli --defaultBalanceEther 10000

Now when you run truffle test, it will be on this local blockchain and you should have enough to work with.

Refer to the following link for more options such as number of accounts or gas price: ganache-cli doc

0

If you are running Truffle with TestRPC, each test accounts starts with a default of 100 ETH, if you run out, either use a different account (10 are provided at TestRPC start up) or simply restart TestRPC and the new tests accounts will have balance again. You can also provide a different default balance using the --defaultBalanceEther option.

  • Hi, thanks for taking time to attempt an answer. Truffle starts testrpc internally when you run "truffle test", so I can't provide parameters to it. Truffle saves the balances from run to run, so that the ether balance for accounts[0] is continuously depleted over time. Also, I can't find where testrpc is installed so I can't run it manually. Additionally, I can't figure out how truffle runs it, though I have looked in the truffle executable file (/usr/local/bin/truffle on my computer). Therefore I can't do what you say (unless I misunderstand you). – Thomas Brian Feb 9 '18 at 6:18
  • Note that I was unaware of the "5 minute edit rule" so I added clarification in my original question (see above) if you ever get a chance to look. Thanks! – Thomas Brian Feb 9 '18 at 6:28
  • it seems you are running a unix based machine so you should be able to run testrpc from anywhere, just open a terminal window and run testrpc -u 0, if not then its not added to your PATH, but you can find out where it is installed running which testrpc. – Julien Feb 9 '18 at 14:26
  • Hey thanks again. which testrpc gives nothing. I'm pretty sure it only searches your path. – Thomas Brian Feb 9 '18 at 22:55
  • I figured out my problem, edited post. – Thomas Brian Feb 9 '18 at 23:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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