The following code will return the balance for a few random accounts? How would I pass in a specific account that I am interested in?

url = 'wss://karura.polkawallet.io'
substrate = SubstrateInterface(url)
hash = substrate.get_chain_finalised_head()
result = substrate.query_map('System', 'Account', block_hash = hash, max_results=2)
for account, account_info in result:
     print(f"Free balance of account '{account.value}': {account_info.value['data']['free']}")

The docs mention that you can pass a list in the params argument, but I tried various ways to pass in a list and I can't get it to work. Here is one way I tried:

result = substrate.query_map('System', 'Account', params = ["account=qhYSTHXnF19w3ahxdyxWbrz4kuRm5R5S61RbzFed5LATc86"], block_hash = hash, max_results=2)

1 Answer 1


The query_map function queries multiple entries of a map.
If you just want a single value, you can use query instead.
Try the following on a local Substrate or Polkadot development node to see how it works:

from substrateinterface import SubstrateInterface

# Connect to a local `polkadot --dev` or `substrate --dev` node.
url = 'ws://'
substrate = SubstrateInterface(url)

# Alice' development address from https://docs.substrate.io/v3/tools/subkey/#well-known-keys
address = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'

block = substrate.get_chain_finalised_head()
result = substrate.query('System', 'Account', params = [address], block_hash = block)
free = result.value['data']['free']

print(f'Account {address} has {free} planks free balance')


Account 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY has 1000000000000000000000 planks free balance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.