Skip to content

Instantly share code, notes, and snippets.

@hernan-erasmo
Last active November 2, 2023 02:12
Show Gist options
  • Save hernan-erasmo/31d866c2806dbe5da6468de6dece9efe to your computer and use it in GitHub Desktop.
Save hernan-erasmo/31d866c2806dbe5da6468de6dece9efe to your computer and use it in GitHub Desktop.
How to check the logsBloom of an Ethereum block for topics?
from eth_bloom import BloomFilter
def check_bloom():
logs_bloom = "0x123..."
logs_bloom_bytes = int(logs_bloom, 16)
topic = "0x321..."
topic_bytes = bytes.fromhex(topic[2:])
filter = BloomFilter(logs_bloom_bytes)
print(f"is topic in bloom? {topic_bytes in filter}")
if __name__ == '__main__':
check_bloom()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment