1

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);

3 Answers3

1

You need to pass --rpc on the command line to enable it, as per https://github.com/ethereum/wiki/wiki/JSON-RPC#go.

user19510
  • 27,999
  • 2
  • 30
  • 48
1

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

salanfe
  • 611
  • 4
  • 9
1

As per your reply. If you enabled rpc port. Then there might a chance of geth client is not mining.

If you want to post any thing. You should start mining. Your transactions in UTX or pending. By default geth will not start mining.

So add --mine as a option in geth.

Otherwise if your eth client is running you can connect attach via ipc or rpc url and port

$> geth attach 127.0.01:8585

geth> miner.start()

Then execute your code

Jitendra Kumar. Balla
  • 2,154
  • 1
  • 8
  • 15