Dank Mids is a EVM RPC batching library that helps reduce the number of HTTP requests to a node, saving time and resources. It automatically collects eth_call calls into multicalls and bundles all RPC calls together in jsonrpc batch calls. tl;dr: its fast as fuck.
The goal of this tool is to reduce the workload on RPC nodes and allow users to make calls to their preferred node more efficiently. This optimization is especially useful for developers writing scripts that perform large-scale blockchain analysis, as it can save development time and resources.
To install Dank Mids, use pip:
pip install dank-mids
The primary function you need to use Dank Mids is setup_dank_w3_from_sync
. This function takes a sync Web3 instance and wraps it for async use. If using dank_mids with eth-brownie, you can just import the premade dank_web3 object as well
Example usage of Dank Mids with web3py:
from dank_mids.helpers import setup_dank_w3_from_sync
dank_web3 = setup_dank_w3_from_sync(w3)
# OR
from dank_mids.helpers import dank_web3
# Then:
random_block = await dank_web3.eth.get_block(123)
- COMING SOON: Dank Mids will also work with ape.
Yearn big brain Tonkers Kuma had this to say:
You can also set DANK_MIDS_DEMO_MODE=True
to see a visual representation of the batching in real time on your console.