Geth version: 1.5.9
OS & Version: Windows
I have installed the Ethereum blockchain using docker (testnet), and know I would like to play with contracts using solidity. I am able to create accounts in my docker instance by using command get account new, but how can I access them now?
Regards,
Cl谩udio Ramos
It is not recommended to keep data in Docker containers. So if you were keeping the data in the container you will need to do the following do get it back:
docker cp <containerID>:/root/.ethereum/keystore DEST_PATH
Hello @Ali92hm ,
Although the installation was done with Docker, the blockchain data is locally in my PC, so I thought I could create accounts and expose them with geth --rpc commands. Is this possible?
Hugs
Oh you mean use the RPC methods?
When you run the docker container you need to expose the port 8545 and enable RPC. Try the following:
docker run -it <your other flags> -p 8545:8545 ethereum/client-go <your geth flags> --rpc
Well, in order to install the ethereum blockchain I sued the command:
docker run -d --name ethereum-node -v /Users/alice/ethereum:/root \
-p 8545:8545 -p 30303:30303 \
ethereum/client-go --fast --cache=512
It seems to be already ready to enable port 8545... If I do the same --prc command in shell, the localhost:8545 is enabled, but throws a JSON error (error -32600 ).
@Ali92hm
Try this:
docker run -d --name ethereum-node -v /Users/alice/ethereum:/root -p 8545:8545 -p 30303:30303 ethereum/client-go --fast --cache=512 --rpc --rpcaddr 0.0.0.0
And then to test it run:
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}' localhost:8545
Setting the --rpcaddr 0.0.0.0 makes the rpc endpoint to accept requests from outside!
@BardoBravo Did that solve your problem?
If so please close the issue.
Hello @Ali92hm ,
Once I execute the cURL command, I get the following error message:
{"jsonrpc":"2.0","error":{"code":-32600,"message":"invalid character '\ \ '' looking for beginning of value"}}
Any idea?
That may be a windows shell problem. Does that happen when you try to use Web3.js as well?
@Ali92hm how would I do so?
@Ali92hm From this post it seems that the EOF return from localhost:8545 is expected, thus we should use truffle to develop apps on private network. Do you agree?
No, there is no "should". You can use truffle. This problems definitely originates from something else.
I made this quick test try running it: https://github.com/Ali92hm/web3-test
@Ali92hm
I called geth --testnet --rpc --rpcaddr 0.0.0.0 --rpccorsdomain 0.0.0.0 console and opened other shell interface, In it, I followed your instruction and the result was as you said:
Web3 connected to RPC
Web3 listening: true
Web3 peerCount: 0
Web3 syncing: false
Web3 blockNumber: 208
localhost:8545 still shows the same JSON error.
Any conclusion from that?
Yeah that means that your RPC works, and the errors are probably because of the wrong things that are being passed to the endpoint. I don't know why your geth is not syncing though.
Web3js is one of the way of interaction with geth if you want to write JavaScript. Otherwise there are wrappers in any other language!
@Ali92hm is there a way I can track what is being passed to the endpoint?
You should be able to use Wireshark to monitor the traffic.
But let me ask you a question, how are you planning to write your application? what programming language are you trying to use? What are you trying to make?
I'm asking these questions cause, the majority of apps use Web3js to interact with Geth and that seems to be working for you!
@BardoBravo any luck?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Try this:
docker run -d --name ethereum-node -v /Users/alice/ethereum:/root -p 8545:8545 -p 30303:30303 ethereum/client-go --fast --cache=512 --rpc --rpcaddr 0.0.0.0And then to test it run:
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}' localhost:8545Setting the
--rpcaddr 0.0.0.0makes the rpc endpoint to accept requests from outside!