I have a running geth node and by using geth account new
command I created a new account:
$ geth account list
Account #0: {47978a69f410d0f…} …
Nevertheless, when using json rpc call to list my ether accounts a null result is obtained:
$ curl -X POST --data
'{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}'
http://127.0.0.1:8545{"jsonrpc":"2.0","id":1,"result":[]}
Why is that? Any hint? Thanks in advance!
I launched geth with the following command:
$geth --rpc --rpcapi "db,eth,net,web3" --rpcport "8545" --testnet
--etherbase "0x47978a6...."
Is it possible that geth working on testnet gets confused on json rpc calls? Do I need to specify somehow in these calls to use testnet and not mainnet?
Best Answer
You don't need to use the
params
field in your call. By doing this, you are executing this command:eth.accounts[]
which returns a null value. If you want to get a list of all the accounts, you should be executingeth.accounts
. So, your RPC command should be:P.S: I'm assuming you already enabled RPC on port 8545. Through the console, you can use
admin.startRPC()
to start RPC.