go-ethereum – Troubleshooting JSON-RPC No Response Issues

go-ethereumjson-rpc

I'm trying to use jscon-rpc but I dont get any response. After installing geth and loading the rinkeby test net does the ethereum node start ? I used "localhost" as the IP and "8545" as the port number. Have I missed out on anything? Please help

String callGeth(String inputJSON)

{

HTTPClient http;
http.begin("http://IP address of my PC(have geth running) :8545/");
http.addHeader("Content-Type", "application/json");
int httpCode = http.POST(inputJSON);
String JSONResult = http.getString();
Serial.println(JSONResult);
http.end();
return JSONResult;

}

StaticJsonBuffer<1000> JSONbuffer;   
JsonObject& gethQueryJSON = JSONbuffer.createObject(); 
gethQueryJSON["jsonrpc"] = "2.0";
gethQueryJSON["method"] = "eth_call";
JsonArray&  gethQueryParams = gethQueryJSON.createNestedArray("params");
JsonObject& gethCallParams = JSONbuffer.createObject();
gethCallParams["to"] = "0xC2eafE628dB80634Fdd657965B38136Ec6F3338A";
gethCallParams["data"] = "0x9de4d683";
gethQueryParams.add(gethCallParams);
gethQueryParams.add("account3");
gethQueryJSON["id"] = 1;
String gethStringJSON;
gethQueryJSON.printTo(gethStringJSON);
Serial.println("First Geth query JSON message isLightTurnedOn function: ");
Serial.println(gethStringJSON);  
String gethResult = callGeth(gethStringJSON); 
Serial.println(gethResult);

Best Answer

as already mentioned by @smarx make sur to enable rpc on your node. For example

--rpc --rpcaddr 'localhost' --rpcport 8545 --rpcapi 'personal,db,eth,net,web3,txpool,miner'

then regarding your python code I've publish a full working example for deploying and interacting with a smart contract using raw HTTP JSON-RPC requests. I am pretty sure you'll find helpful hints. Here is my post https://ethereum.stackexchange.com/a/38965/30452

I hope this helps