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);
8
  • Can you explain what "don't get any response" means? Does the connection time out? Do you get an error? If you try a different port, e.g. 9999, does the same thing happen or something different?
    – user19510
    Feb 10, 2018 at 3:35
  • I dont get any result. I did try,I still get no response. Feb 11, 2018 at 3:48
  • What programming language and environment are you using? The code kind of looks like it's for an Arduino, but surely you're not running geth on an Arduino?
    – user19510
    Feb 11, 2018 at 4:32
  • I have geth installed on my PC. In the callGeth function the IP address used is the IP of the PC. Is it right ? Feb 11, 2018 at 5:31
  • Your question says you used "localhost," which is not the IP address of your PC.
    – user19510
    Feb 11, 2018 at 5:56

3 Answers 3

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

1

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

3
  • I id that.Still no response Feb 10, 2018 at 3:12
  • Can you share the code you're using to make the JSON-RPC request?
    – user19510
    Feb 10, 2018 at 3:16
  • I've edited the question. I cant figure out whats wrong Feb 10, 2018 at 3:31
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.