2

I have started testrpc with the following command (which should give the account a balance of 1000):

testrpc --account="0x0116af719d217c12310c72c27a13509f192588735ae329f7c4cfef0e1518955e,1000"

Testrpc then starts up as expected:

EthereumJS TestRPC v3.9.2

Available Accounts

(0) 0x7a9a73cf766ec8340e41b0755691b0503947d982

Private Keys

(0) 0116af719d217c12310c72c27a13509f192588735ae329f7c4cfef0e1518955e

Listening on localhost:8545

Then I want to write a command to query the balance of this account. However, if I write something like eth.getBalance("0x7a9a73cf766ec8340e41b0755691b0503947d982") (which is what works when connected to a private blockchain with geth, for example) or anything else in the same command prompt window nothing happens - it just goes to a new line.

ZhouW
  • 1,348
  • 2
  • 18
  • 35

1 Answers1

11

What you are typing into is just an informational screen, you can't execute commands from it.

What you need is a JS console with web3 connected to testrpc via JSON RPC. A simple way that you can get this is to use the geth console: In another console enter

geth attach http://localhost:8545

If you don't have geth installed, you can alos just use node js with web3. Open a JS REPL with node and then

const Web3 = require('web3')
const web3 = new Web3(new Web3.providers.HttpProvider())
const eth = web3.eth
Tjaden Hess
  • 37,046
  • 10
  • 91
  • 118