3

I've tried to access geth by rpc.

$ geth --dev --datadir mydir --rpc --rpcaddr "localhost" --rpcport "8545" --rpccorsdomain "*" console

However it has returned the error. Could you tell me how to solve the problem?

{"jsonrpc":"2.0","error":{"code":-32600,"message":"EOF"}}

Update I've got connected by rpc, however on the browser-solidity I cannot connect my private node.

enter image description here

Toshi
  • 2,357
  • 8
  • 23
  • 34

1 Answers1

4

I suspect it is the command you are using.

This works:

user@Kumquat:~$ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://localhost:8545
{"jsonrpc":"2.0","id":1,"result":{"currentBlock":"0x1eb260","highestBlock":"0x1eb478","knownStates":"0x0","pulledStates":"0x0","startingBlock":"0x1eaea3"}}

And this does not work:

user@Kumquat:~$ curl '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://localhost:8545
curl: (3) [globbing] nested brace in column 50
{"jsonrpc":"2.0","error":{"code":-32600,"message":"EOF"}}

Here are some simple commands you can test with:

user@Kumquat:~$ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_coinbase","params":[],"id":1}' http://localhost:8545
{"jsonrpc":"2.0","id":1,"result":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}

user@Kumquat:~$ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":1}' http://localhost:8545
{"jsonrpc":"2.0","id":1,"result":"0x4a817c800"}
BokkyPooBah
  • 40,274
  • 14
  • 123
  • 193
  • $ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://localhost:8545

    {"jsonrpc":"2.0","id":1,"result":false}

    – Toshi Aug 06 '16 at 02:25
  • Yup. Your command is working perfectly. Your private node is not syncing and so the result is false. – BokkyPooBah Aug 06 '16 at 02:26
  • It seems doesn't work. I'll try debugging it. – Toshi Aug 06 '16 at 02:27
  • rpc

    { modules: { admin: "1.0", debug: "1.0", eth: "1.0", miner: "1.0", net: "1.0", personal: "1.0", rpc: "1.0", shh: "1.0", txpool: "1.0", web3: "1.0" }, getModules: function(callback) } My node uses rpc:1.0. Is it the reason?

    – Toshi Aug 06 '16 at 02:29
  • Your return result {"jsonrpc":"2.0","id":1,"result":false} is the correct result. The following will work on the Mainnet blockchain, returning the balance at address 0x0000...0000 - curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x0000000000000000000000000000000000000000", "latest"],"id":1}' http://localhost:8545 {"jsonrpc":"2.0","id":1,"result":"0x16d53d844d5d4397305"}

    RPC module v1.0 is perfect.

    – BokkyPooBah Aug 06 '16 at 02:33
  • 1
    $ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_coinbase","params":[],"id":1}' http://localhost:8545 {"jsonrpc":"2.0","id":1,"result":"0x86d13ef4629e9b855a8045cd8b2f67ba6a736ba6"} – Toshi Aug 06 '16 at 03:42
  • I've got data from node. Thx! However, at the browser-solidity, I cannot connect the local private node. Could you figure out what is the reason? – Toshi Aug 06 '16 at 03:47
  • Please ask a new questions and I'll look into it. – BokkyPooBah Aug 06 '16 at 03:50
  • 1
    I've questioned! Plz check it:) http://ethereum.stackexchange.com/questions/7796/invalid-json-rpc-response – Toshi Aug 06 '16 at 04:00