I began by trying to follow the article on front running bancor with Python. I thought it would be easy to send an api request to my full node then replicate the same request in Python–all following the tutorial. The only difference was that the author used Geth and I am running Parity. The inability to figure out how to use JSON RPC has led me down a rabbit hole. I don't really know (1) what I'm doing wrong or (2) if I even conceptually understand JSON RPC at this point.
The problem:
I should be able to run this curl command: curl -X POST --data \
'{"jsonrpc":"2.0","method":"eth_getTransactionByHash", \
"params":["0x314e0246cfc55bc0882cbf165145c168834e99924e3ff7619ebd8290e713386d"], \
"id":123}' localhost:8545
And get a result like this:
{"jsonrpc":"2.0","id":123, "result":{
"blockHash":"0x42ea1578c23b159186853961dfbdfcdec6b40d23d8f1d971827412bc6948386b",
"blockNumber":"0x3dfb88",
"From":"0xcaf82fcb3a0323566c0f306684376e3e66d6284b",
"To":"0x77a77eca75445841875ebb67a33d0a97dc34d924",
"gasPrice":"0xba43b7400",
"hash":"0x314e0246cfc55bc0882cbf165145c168834e99924e3ff7619ebd8290e713386d",
"value":"0x6c6b935b8bbd400000",
...}}
Howevever when I run it with localnode connected to parity I only get:
Supplied content type is not allowed. Content-Type: application/json is required
I found the Parity JSON-RPC API documentation and realized the formatting is different.
So I reformatted the curl command to look like this:
curl --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash",
"params":["0x314e0246cfc55bc0882cbf165145c168834e99924e3ff7619ebd8290e713386d"], "id":1, "jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
I solved the Content Type error but then got a null result:
{"jsonrpc":"2.0","result":null,"id":1}
Then looking at this stack exchange article I realized that Parity has it's own Web3 console. So, I thought maybe I don't have to use curl at all, and can just run.
web3.eth.getTransaction('0x314e0246cfc55bc0882cbf165145c168834e99924e3ff7619ebd8290e713386d')
and I still get null return.
As a side note I have also tried to do the call using Infura's api
curl --include \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
I really want to understand what I am doing wrong but I don't know where exactly to find the resources to teach myself, and feel a little stuck. Thanks in advance for anything that can point me in the right direction.
Best Answer
Call it like this
It need