Skip to content

Instantly share code, notes, and snippets.

@artiya4u
Created August 10, 2022 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artiya4u/51a9acde18bfe4ca3370c31b962343a5 to your computer and use it in GitHub Desktop.
Save artiya4u/51a9acde18bfe4ca3370c31b962343a5 to your computer and use it in GitHub Desktop.
Get Polkadot txHash by block number and height
# 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