I am trying to request a block hash for a specific block using the Polkadot JSON-RPC but no matter how I construct the request (with Python), it always returns the latest block and not the one I want. How can I solve that?
import requests
import json
def get_block_hash(block_number):
url = "https://dot.getblock.io/mainnet/"
payload = json.dumps({
"jsonrpc": "2.0",
"method": "chain_getBlockHash",
"id": 1
})
headers = {
'x-api-key': 'enter-api-key',
'blockNumber': block_number,
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
return response