10

I started doing a bit of work in the geth console:

geth --dev console 

but have moved to developing using truffle.

To debug in the geth console, I'm used to executing the following:

eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(1, "ether")});

then manually calling miner.start().

Is there a way to do this using testrprc?

6

Instead of $geth --dev console you can do:

Type $testrpc on the terminal in order to activate testrpc .

Then deploy your contracts and open the truffle console as described here. The truffle console has access to the web3 api, and therefore you can practically do the same things as your geth console.

For the steps in the paragraph above, in short you open another terminal and do $truffle deploy and then $truffle console. When the console opens you can type eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(1, "ether")}); as usual.

  • Since testrpc is to test your contracts and simulate the ethereum environment. Obviously you can do transaction but no mining will be happening imediately you will deducted and receive ethers. As @EugVal mentioned you can test it in truffle console. – Seetharaman GR Apr 20 '17 at 17:34
4

In testrpc:

truffle(development)> web3.eth.getBalance(web3.eth.accounts[0])
                { [String: '98599991999999979000'] s: 1, e: 19, c: [ 985999, 91999999979000 ] }

truffle(development)> web3.eth.getBalance(web3.eth.accounts[1])
                { [String: '101000000000000000000'] s: 1, e: 20, c: [ 1010000 ] }

truffle(development)> web3.eth.sendTransaction({from: web3.eth.accounts[0], to: web3.eth.accounts[1], value: web3.toWei(1, "ether")});
                '0x3b9
        115191839b371200e107600c27e98ef64b2b823e7b4e02556262db06ee609'

truffle(development)> web3.eth.getBalance(web3.eth.accounts[0])
                { [String: '97599991999999958000'] s: 1, e: 19, c: [ 975999, 91999999958000 ] }

truffle(development)> web3.eth.getBalance(web3.eth.accounts[1])
                { [String: '102000000000000000000'] s: 1, e: 20, c: [ 1020000 ] }

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.