{"id":20433857,"url":"https://github.com/flashbots/web3-data-tools","last_synced_at":"2025-04-12T21:08:40.975Z","repository":{"id":190185484,"uuid":"682126205","full_name":"flashbots/web3-data-tools","owner":"flashbots","description":"Data tools for Web3 ","archived":false,"fork":false,"pushed_at":"2024-05-31T14:13:46.000Z","size":499,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-11T20:48:03.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://flashbots.github.io/web3-data-tools/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flashbots.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-23T13:52:46.000Z","updated_at":"2024-05-31T14:13:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"c032e29b-e351-44d6-b558-8787bd32e157","html_url":"https://github.com/flashbots/web3-data-tools","commit_stats":null,"previous_names":["flashbots/web3-data-tools"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashbots%2Fweb3-data-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashbots%2Fweb3-data-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashbots%2Fweb3-data-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashbots%2Fweb3-data-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flashbots","download_url":"https://codeload.github.com/flashbots/web3-data-tools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631676,"owners_count":21136562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T08:21:51.328Z","updated_at":"2025-04-12T21:08:40.942Z","avatar_url":"https://github.com/flashbots.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# web3-data-tools\n\n\n\u003c!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! --\u003e\n\n## Install\n\n``` sh\npip install web3_data_tools\n```\n\n## How to use\n\n``` python\nfrom datetime import datetime, timezone\nfrom web3_data_tools.core import *\nfrom web3_data_tools.web3 import *\n```\n\nSet your web3 object with multiple rpcs.\n\n``` python\nw3 = MultiRPCWeb3.from_rpcs('http://bad_rpc', 'http://localhost:8545')\n```\n\nBefore fetching data sort the RPCs so w3 calls the one that is most up\nto date\n\n``` python\nw3.sort_providers(tolerance=0)\n```\n\n    RPC connection http://bad_rpc failed with: HTTPConnectionPool(host='bad_rpc', port=80): Max retries exceeded with url: / (Caused by NameResolutionError(\"\u003curllib3.connection.HTTPConnection object\u003e: Failed to resolve 'bad_rpc' ([Errno 8] nodename nor servname provided, or not known)\"))\n\n    ['http://localhost:8545', 'http://bad_rpc']\n\nAccess `Web3.Eth` methods\n\n``` python\nw3.eth.get_block_number()\n```\n\n    19990236\n\n### Use web3 list like interfacte\n\nthe `len` function will give you the latest block number\n\n``` python\nlen(w3)\n```\n\n    19990236\n\nthe `__getitem__` method maps `block_number-\u003eblock_timestamp`\n\n``` python\nw3[len(w3)]\n```\n\n    1717163651\n\nUsing the list-like interace you can implement any algorithm that uses\nlists. For example, you can use the\n[`interpolation_search`](https://flashbots.github.io/web3-data-tools/core.html#interpolation_search)\nmethod to find a block number at a specific timestamp\n\n``` python\nw3.find_block_at_timestamp(datetime(2022, 10, 1, tzinfo=timezone.utc).timestamp(), low=FIRST_POS_BLOCK, how='after')\n```\n\n    15649595\n\n### Asycn Mode and Batched Calls\n\n``` python\naw3 = MultiRPCWeb3.async_from_rpcs('http://bad_provider:1234', 'http://localhost:8545')\nawait aw3.asort_providers(tolerance=0)\nawait aw3.afind_block_at_timestamp(datetime(2022, 10, 1, tzinfo=timezone.utc).timestamp(), low=FIRST_POS_BLOCK, how='after')\n```\n\n    RPC connection http://bad_provider:1234 failed with: Cannot connect to host bad_provider:1234 ssl:default [nodename nor servname provided, or not known]\n\n    15649595\n\n``` python\nblock_numbers = range(FIRST_POS_BLOCK, FIRST_POS_BLOCK + 72)\nblocks = await aw3.abatch_method('get_block', block_numbers, method_args=(), method_kwargs={'full_transactions': False}, batch_size=72)\n```\n\n``` python\nlen(blocks)\n```\n\n    72\n\n``` python\nblocks[0]\n```\n\n    AttributeDict({'baseFeePerGas': 48811794595,\n     'difficulty': 0,\n     'extraData': HexBytes('0x'),\n     'gasLimit': 30000000,\n     'gasUsed': 29983006,\n     'hash': HexBytes('0x56a9bb0302da44b8c0b3df540781424684c3af04d0b7a38d72842b762076a664'),\n     'logsBloom': HexBytes('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'),\n     'miner': '0xeEE27662c2B8EBa3CD936A23F039F3189633e4C8',\n     'mixHash': HexBytes('0xa86c2e601b6c44eb4848f7d23d9df3113fbcac42041c49cbed5000cb4f118777'),\n     'nonce': HexBytes('0x0000000000000000'),\n     'number': 15537394,\n     'parentHash': HexBytes('0x55b11b918355b1ef9c5db810302ebad0bf2544255b530cdce90674d5887bb286'),\n     'receiptsRoot': HexBytes('0x928073fb98ce316265ea35d95ab7e2e1206cecd85242eb841dbbcc4f568fca4b'),\n     'sha3Uncles': HexBytes('0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'),\n     'size': 18559,\n     'stateRoot': HexBytes('0x40c07091e16263270f3579385090fea02dd5f061ba6750228fcc082ff762fda7'),\n     'timestamp': 1663224179,\n     'totalDifficulty': 58750003716598352816469,\n     'transactions': [HexBytes('0x5ad934ee3bf2f8938d8518a3b978e81f178eaa21824ee52fef83338f786e7b59'),\n      HexBytes('0xcf92f67b37495b4149a522da5dce665cddd1c183c79ba1e870564f77ffaabbca'),\n      HexBytes('0x714b934c3dad0f28fbc9d0438312a3801ab863480b98be4548f36a436cf270b5'),\n      HexBytes('0x1b86278143e06a8dcd0944d336100c8187ff1e4277ef5fd39360dd7bfcdc355b'),\n      HexBytes('0xee199f9280622e1990c649c23907d819ab6d5a27a41dc50b625812d02af8ff0f'),\n      HexBytes('0x810681d62880142079ffd8df6bee87cebb8fa6f8c66a836f1e4c33678cb0837d'),\n      HexBytes('0x0235355b47d026438f0c66f09db5ed2b4462044aa632164b394cd2553fb2693e'),\n      HexBytes('0x72c32e24f7438f3f94c9dd8c2b5a3a3121ae415a011ea26a64b8745b92b44fed'),\n      HexBytes('0xe77cbd77faeadef0c709fc23992a37510ed06c0e9f989dc4b51400015ee434ed'),\n      HexBytes('0xc18d08faee7bbb924b77ea5d09cac3ff3bf008f51fffd30d14e54feeb3ea61e4'),\n      HexBytes('0xc1ef8077e3df62f078182a48b18fdb82d9aa69b523d9b6f300c2b8e1dac5ebd6'),\n      HexBytes('0x339832e1a0bbb712f1fa25cb7fb90c7c9faca2d9520c35620bd2f1106b66efc7'),\n      HexBytes('0x553a3a38ebf871c3ab98edacd50fa9e76a8c6c39ccd352ee4e2d1b2e3a0b969f'),\n      HexBytes('0xc158ea664d7cfbcaf9af680b3ad7712da42ca4dc2fc3fd8d2adaf65d45c2ef6c'),\n      HexBytes('0xa950cb26eec201768a73546683f8a9d0886ab670ef5fa7e9b81d50373b799235'),\n      HexBytes('0x22d749c5302aae6698c54867c08399f838784522fadd53ffd024fe2f16f1052e'),\n      HexBytes('0x7036e375dbd2c2a54e9a4041e8d8ca0623fffa7adf489d79a08914b49b3c6f1f'),\n      HexBytes('0xf037c976a34578f42c88025cd51fcc358c510b4cec459af5462200305808a6d0'),\n      HexBytes('0xeef5e4a5a8a557f927120bddbb55cb4ad87a082c63c3cf8581ad8a4990614c65'),\n      HexBytes('0xd6fa4d5e7042c09e6e4fb503fbd69945a71195318bc6c8116d790eea862bdd71'),\n      HexBytes('0x732fd0215b35bc6ba2ba370fa67133c3020c46de78c8a7b7981946cea069d874'),\n      HexBytes('0xfc5e7ea32890c90f9f884772e7cbbbaa4976688c80133835dde5b158dae6f4a8'),\n      HexBytes('0x5fde395a33a15f2e0b012988d047af21d8d434c3f74ccca69c3579a26cc62462'),\n      HexBytes('0x409f265e490b0b962332b08a9bea522cbbaf3f84c812b22e5e851a330cc7d3b0'),\n      HexBytes('0x1eef2fed2a234716f9e7546049c08f136904ad2622ae3b69ab98fcfaa52018cd'),\n      HexBytes('0x216b67f3ad43ca4a2e64fc7a7d29643a19a4c460ad771f21a1483a23205ec45d'),\n      HexBytes('0x61fa6bfa7d2b7d522aba1b2d9899f21f05dfca3e0498b09ff8262c921262450e'),\n      HexBytes('0x9faff8b4d5334090550fb879260d353d81c1178c6531e8ca225a9e0a032da24a'),\n      HexBytes('0xf0e4e1f83a2a14f076e31caf5cfa9ac26254d8cfb4fe4a5dc5bcd25ee9d428a1'),\n      HexBytes('0xe66b3c6d173fa768ed64fa5e87b5374ff3fcf0205e5bae65ee958160c2da9fa7'),\n      HexBytes('0x05d528b4a8a659ccea73c3946b6c049b09cbc714aefd0d26bf17739157f2fcd5'),\n      HexBytes('0xccd037ccb864784af8932e68b1335d03ad108acac16591fe2118b3056b03b942'),\n      HexBytes('0x1f3647004a42dca3eef8801ee35705c8f63abfec50fb2144984bcdf0e3b1741a'),\n      HexBytes('0x8889b2ddfedc4da7b03a155ac4141978503ce7963e2f26bfc8ee94b596f43d30'),\n      HexBytes('0x511248feb7d0e1b585b413a2adc17fa3b291ced1449031fe45ac41f602bb9b30'),\n      HexBytes('0xa28db5a9e809a14486e747d017def59c4ef458c7b28c30e64826ec429da0d358'),\n      HexBytes('0xe8153d04b57a972ede68a6bacbf2b5d7300764008748ba6fcee5a948da7a2c61'),\n      HexBytes('0xf16d6eb80ec921c5ef06e1acd5a0a0f005eff6b980dd150ea079e47a61af371d'),\n      HexBytes('0xff22311453c633e90a34514dd8c623d8fad5a8424438b86007c7db8665b4f644'),\n      HexBytes('0x8116c74edd4607b4229babd542b13cdb99e9f7ac31d19e1be40ff43b8d740770'),\n      HexBytes('0x44503d86e543e5574afd67df4e2ee11033a1e26573bf1abf3477a954e27e0bf6'),\n      HexBytes('0x119c2cdcfa03938e6cd7ce3f8d99dde5062d96ec9cc25c891291784bd6d34bd1'),\n      HexBytes('0x69a19ec0f276e8e022d6bdaebd3db544a8329a686110cea653e5590add13e34e'),\n      HexBytes('0xb6fa2bdc210a93a55d70a68fb35fae461533262f23f70d044f21df0cb9e5c488'),\n      HexBytes('0xadfb7d1527cc88307ef4d42d1b9728f220e746aae0db16d51b056563bb8d8e20'),\n      HexBytes('0x35d8d742844b967047de36dbd3af43144e395be9c5afc396a281070e3de4abaa'),\n      HexBytes('0xea1435bcea16eadc48fc64fc28a90b36e054e9a2e79109651e72ef140706bbf2'),\n      HexBytes('0xff527682816e12a83d188b61a2e4bc5b110100c59d14560495b67e5944aab130'),\n      HexBytes('0xcb9f25127bd802e39d8297bfbdf4e63d66387513f88beb813069550ab7f504d9'),\n      HexBytes('0xf043430838905980a823430e5c499bd19cea82f301f6e6b92598dfb5a5d5d919'),\n      HexBytes('0xbdb461b75bc5dbd1da7dbe3c1d3c540e5f09ebd034de12de06a2235d046bf996'),\n      HexBytes('0x2f6dcd0baee7e9ed29d4137f66ac997caf90117da391d4b37cc8ba04a2029bb6'),\n      HexBytes('0x4f4bec2cf3076789402b606b644f6df0f0db8c04d3ff78320177a641d94daf88'),\n      HexBytes('0x08c87430710930718e5cc23c16c8f6f5cc5417a17f46c17c27102b9129adc1a1'),\n      HexBytes('0xdc57e2c6414198a302c313bb79f292ec714957182dc6e6a51c739718e3378d06'),\n      HexBytes('0x3af096859a880d9c33718eda59cb96e1504db7390d0e086c7260d91e87139eab'),\n      HexBytes('0xf5787c239852670e313cf5eed13cf89c2ba1f5209b37c28595123f5940996338'),\n      HexBytes('0xbbc970691625eda88a1cc18841f1fc8907f86549c93c230353d876a9718cb483'),\n      HexBytes('0xceae7d3ab98899982623304631355510a70a1ca73fe3cb8a88216dea99e89c1d'),\n      HexBytes('0xdd3b620b49afa578c51266b7e38da38f466150385f54a4878f3a0b794bdb926f'),\n      HexBytes('0x1e66b94dc423d6b95c9161b4b88d8862e1d05704379386e1b5e6b7f28d62c646'),\n      HexBytes('0xd29b41f69babd4c5c680234579467ecb3857e39e42c5b53680bc230f6832b425'),\n      HexBytes('0x2eee61013dfe1380c8794aa110522f112ff83be81ac34e9f7995dac81b6cfced'),\n      HexBytes('0xfe1d19700fcd7d337e8ac2f985eef5e1ef05b4802d26a1637788a2d9d3464277'),\n      HexBytes('0xb2c83000b69838c40fc55b81970e05099bd6bb9687ae80a66b8b86f38cfe26e7'),\n      HexBytes('0x63c06123f3faac825ff6c61a08bc551e60628d68e1479d52620ded995d0f24bc'),\n      HexBytes('0x1d4e4495d368f7f07f62af7ca6c22215a83d872a123dfcdbb6704d8d9f3e5a92'),\n      HexBytes('0x181372058f61ffd1e64d8c1a3732234414fdb8443a57b488b940d4eeeafe7223'),\n      HexBytes('0x0374cabdae148b333f73a939ce24c54a613f46db615599f3a25f850493a06384'),\n      HexBytes('0x7e6735c14377af079e148458b4e10e8a0e061c3d0e85ed53fb51680b2e373d86'),\n      HexBytes('0xda595d3ed8d21d0af4859d4f84e17cf6436470770d084dde94d2a7cf53406bf7'),\n      HexBytes('0x1ed7f450ac9df7e9350567679574fda3b241f7eee1997df32aa00ef4f5f5e9f2'),\n      HexBytes('0xf25815081739f4fff71b857c2007519e9d5b742819a0209dfcf82fed66555d50'),\n      HexBytes('0x1d88b8e30c399767d64caebb6eb53fc8ade60a9782e36383973385257c79d8c3'),\n      HexBytes('0x000b787fdfd48ea77db5bba828b64cf04253210841921b0f478bab4d01b35448'),\n      HexBytes('0xaa10c416b655d7810e8aa17a232e021c9a472d41d3867ffc1c5b905a4a261a01'),\n      HexBytes('0x96362d53e53ec15a69315edcd2477a85aefbc375262865cf3e17c683d9a3c781'),\n      HexBytes('0x0790001ef84d89fd5bd397bbf221a97b6a4ddc744ba2c3b9d0466957857b1ac5'),\n      HexBytes('0x09b57a092d6cf3939eb4f9f59ef4121fa438b2b1a0544fce1772f42b3944502c'),\n      HexBytes('0xf1ea27d7b3f760a68b4d57d25bb36886dbde8d76356dcdb77cf6b5e69627844d')],\n     'transactionsRoot': HexBytes('0x1ea1746468686159ce730c1cc49a886721244e5d1fa9a06d6d4196b6f013c82c'),\n     'uncles': []})\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflashbots%2Fweb3-data-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflashbots%2Fweb3-data-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflashbots%2Fweb3-data-tools/lists"}