Skip to content

Instantly share code, notes, and snippets.

@brenzi
Created March 24, 2019 09:42
Show Gist options
  • Save brenzi/3f289376289ab0efe81f7309429f09e2 to your computer and use it in GitHub Desktop.
Save brenzi/3f289376289ab0efe81f7309429f09e2 to your computer and use it in GitHub Desktop.
python substrate RPC
import requests
import json
#url = "https://substrate-rpc.parity.io/"
url = "http://127.0.0.1:9944/"
headers = {'content-type': 'application/json'}
payload = {
"method": "chain_getRuntimeVersion",
"params": None,
"jsonrpc": "2.0",
"id": 0,
}
response = requests.post(url, data=json.dumps(payload), headers=headers)
# results in http 400
# substrate log says:
# 2019-03-24 10:40:46 Accepted a new tcp connection from 127.0.0.1:43476.
# 2019-03-24 10:40:46 WS Error <Protocol>: Unable to parse WebSocket key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment