0

I try to run this (geth is started with rpc on http://localhost:8545)

#!/usr/bin/env python3
from urllib.parse import urlencode
from urllib.request import Request, urlopen
rpc = "http://localhost:8545"
print(urlopen(Request(rpc,urlencode({"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":42}).encode(),headers={'Content-Type': 'application/json'}), timeout=60).read().decode())

It print : {"jsonrpc":"2.0","error":{"code":-32600,"message":"invalid character 'j' looking for beginning of value"}}

1

You probably want to use web3.py to interact with your ethereum node from python. Web3.py will take care of these connection and encoding issues for you.

| improve this answer | |

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.