Last active
November 2, 2023 02:12
-
-
Save hernan-erasmo/31d866c2806dbe5da6468de6dece9efe to your computer and use it in GitHub Desktop.
How to check the logsBloom of an Ethereum block for topics?
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
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