Skip to content

Instantly share code, notes, and snippets.

@elsehow
Created December 29, 2021 21:18
Show Gist options
  • Save elsehow/92937f826c2aacc159d21345358a9a8f to your computer and use it in GitHub Desktop.
Save elsehow/92937f826c2aacc159d21345358a9a8f to your computer and use it in GitHub Desktop.
ABCI query with Tendermint RPC
def abci_query (rpc, path, data):
# from
# https://functionx.gitbook.io/home/developers/json-rcp-abci-query
q = {
"jsonrpc": "2.0",
"id": 0,
"method": "abci_query",
"params": {
"path": path,
"data": json.dumps(data).encode('utf-8').hex(),
},
}
resp = post(rpc, json=q, headers={'height': '0'})
b64str = resp.json()['result']['response']['value']
bs = b64str.encode('ascii')
return json.loads(base64.b64decode(bs).decode('ascii'))
d = {
"address": "my-juno-address",
}
abci_query(juno_rpc, 'custom/bank/all_balances', d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment