Created
August 10, 2022 12:02
-
-
Save artiya4u/51a9acde18bfe4ca3370c31b962343a5 to your computer and use it in GitHub Desktop.
Get Polkadot txHash by block number and height
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install substrate-interface | |
from substrateinterface import SubstrateInterface | |
substrate = SubstrateInterface( | |
url="https://rpc.polkadot.io" | |
) | |
block_number = 11542800 | |
number = 2 | |
# Get block hash by number | |
block_hash = substrate.get_block_hash(block_number) | |
# Retrieve extrinsics in block | |
result = substrate.get_block(block_hash=block_hash) | |
print(result['extrinsics'][number]) | |
print(result['extrinsics'][number].extrinsic_hash.hex()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment