Skip to content

How to subscribe to the balance change of multiple wallets #326

Answered by arjanz
realblackbot asked this question in Q&A
Discussion options

You must be logged in to vote

Since v1.6.0 is now possible to subscribe to multiple storage keys in one instance:

def subscription_handler(storage_key, updated_obj, update_nr, subscription_id):
    print(f"Update for {storage_key.params[0]}: {updated_obj.value}")

# Accounts to track
storage_keys = [
    substrate.create_storage_key(
        "System", "Account", ["5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"]
    ),
    substrate.create_storage_key(
        "System", "Account", ["5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"]
    )
]

result = substrate.subscribe_storage(
    storage_keys=storage_keys, subscription_handler=subscription_handler
)

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@arjanz
Comment options

@realblackbot
Comment options

@arjanz
Comment options

@realblackbot
Comment options

@realblackbot
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by arjanz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants