Skip to content

Instantly share code, notes, and snippets.

@bogatyy
Created August 17, 2017 19:41
Show Gist options
  • Save bogatyy/cd9ed0506a88866e25879afdb4830a05 to your computer and use it in GitHub Desktop.
Save bogatyy/cd9ed0506a88866e25879afdb4830a05 to your computer and use it in GitHub Desktop.
Downloads transaction info using Ethereum client API in Python
$ pip install requests
$ python
import json
import requests
def get_transaction(tx_hash):
url = 'http://localhost:8545'
headers = {'content-type': 'application/json'}
request = {
'jsonrpc': '2.0', 'id': 1,
'method': 'eth_getTransactionByHash',
'params': [tx_hash]
}
return requests.post(
url, data=json.dumps(request), headers=headers).json()
print get_transaction('0x314e0246cfc55bc0882cbf165145c168834e99924e3ff7619ebd8290e713386d')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment