I am trying to use py-substrate-interface to query the acalaOracle.value for Acala/Karura. Below I show a screenshot of how to get the data using polkadot{js}. Here is the python code I am trying:
url = 'wss://acala-rpc-0.aca-api.network'
substrate = SubstrateInterface(url)
hash = substrate.get_chain_finalised_head()
timestamp = substrate.query(module='Timestamp',storage_function='Now',block_hash=hash).value
block = substrate.get_block_number(hash)
result = substrate.query('AcalaOracle', 'Values', params = [{'Token': 'KSM'}], block_hash = block)
I am getting an error substrateinterface.exceptions.SubstrateRequestException: {'code': -32602, 'message': 'invalid type: integer
1234601, expected a (both 0x-prefixed or not) hex string with length of 64 at line 1 column 7'}
, so I am not defining the parameter correctly. Would anyone know how to do that?
I tried to following the examples given in this question, but I still can't figure it out. The following code:
result_map = substrate.query_map('AcalaOracle', 'Values')
print(list(result_map))
returns
[[<scale_info::50(value={'Token': 'ACA'})>, <scale_info::495(value={'value': 264510000000000000, 'timestamp': 1655316318429})>], [<scale_info::50(value={'Token': 'DOT'})>, <scale_info::495(value={'value': 7051400000000000000, 'timestamp': 1655316318429})>]]
but I still don't know what to pass as the parameter.