Skip to main content

Dank Mids

PyPI Monthly Downloads

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.

image

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.

Why is Dank so fast?

There are a number of optimizations that went into making Dank the fastest way to pull rpc data to Python.

  1. Implemented (mostly) in C.
  2. Bypasses the default formatters in web3.py
  3. JSON encoding and decoding is handled by msgspec. All responses are decoded to specialized msgspec.Struct objects defined in the evmspec library.
  4. We use my C-compiled faster-eth-abi and faster-eth-utils instead of the original python implementations eth-abi and eth-utils.
  5. Responses are decoded on a JIT (just-in-time) basis, meaning individual task cancellation works as expected even when response data is received as part of a larger batch.
  6. more stuff I'll write down later...

Batching Flow

This diagram shows how requests move from user calls into Dank Mids queues, then through batch execution and response spoofing.

flowchart TD
    A[User code<br/>await w3.eth.call / other RPC] --> B[DankMiddlewareController.__call__]

    B -->|eth_call| C[eth_call request]
    B -->|other RPC| D[RPCRequest]

    C -->|multicall compatible| E[pending_eth_calls<br/>block to Multicall]
    C -->|no multicall| D
    D --> F[pending_rpc_calls<br/>JSONRPCBatch queue]

    E --> G[RPCRequest.get_response<br/>triggers execute_batch when needed]
    F --> G

    G --> H[DankMiddlewareController.execute_batch]
    H --> I[DankBatch<br/>multicalls + rpc_calls]
    I --> J[DankBatch.coroutines]

    J -->|large multicall| K[Multicall.get_response]
    J -->|small multicall split| L[JSONRPCBatch]
    J -->|rpc calls| L

    K --> M[_requester.post<br/>eth_call to multicall contract]
    M --> N[Multicall.spoof_response<br/>split results to eth_call futures]

    L --> O[JSONRPCBatch.post<br/>build JSON-RPC batch payload]
    O --> P[_requester.post batch<br/>+ decode responses]
    P --> Q[JSONRPCBatch.spoof_response<br/>match by id, resolve futures]

    N --> R[User awaiters resolve]
    Q --> R

Notes:

  • Batches can start early when the queue is full (_Batch.append -> controller.early_start).
  • Otherwise, the first waiter to need results will trigger execute_batch from RPCRequest.get_response.

Installation

To install Dank Mids, use pip:

pip install dank-mids

Development and Contributing

This repository uses pre-commit for local commit-time checks. Setup and usage instructions live in CONTRIBUTING.md.

Benchmark

We've included a benchmark script that compares the time it takes to fetch the pool tokens (token0 and token1) for each pool on Sushiswap on Ethereum mainnet. To run it, first install the repo with uv sync and then run the benchmark with uv run brownie run examples/benchmark.

Running 'examples/benchmark.py::main'...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4213/4213 [08:50<00:00,  7.95it/s]
brownie sync end: 2025-04-14 21:21:35.531099
brownie sync took: 0:08:50.212665
brownie 4 threads start: 2025-04-14 21:21:35.548373
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4213/4213 [08:31<00:00,  8.23it/s]
brownie 4 threads end: 2025-04-14 21:30:08.065397
brownie 4 threads took: 0:08:32.517024
brownie 16 threads start: 2025-04-14 21:30:08.086342
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4213/4213 [08:26<00:00,  8.32it/s]
brownie 16 threads end: 2025-04-14 21:38:38.141635
brownie 16 threads took: 0:08:30.055293
dank start: 2025-04-14 21:38:38.161024
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4213/4213 [00:55<00:00, 75.49it/s]
dank end: 2025-04-14 21:39:33.982835
dank took: 0:00:55.821811

As you can see, dank_mids allowed us to save 7 minutes and 34 seconds vs brownie with 16 threads. That's an 89% reduction in runtime, or about 9x as fast as brownie!

Usage with web3.py

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 import dank_web3

# Then:
random_block = await dank_web3.eth.get_block(123)

Usage with eth-brownie

Usage with ape

  • COMING SOON: Dank Mids will also work with ape.

Observability (Retry Events)

Dank Mids exposes a retry observer API for capturing retry decisions, plus a stats observer for collector metrics. Internal emit points are deferred to a follow-up PR. For the full explanation and examples (structured logging, Prometheus, Sentry/Stats), see docs/retry_observer.rst.

Testimonials

Yearn big brain Tonkers Kuma had this to say:

image

Notes

You can also set DANK_MIDS_DEMO_MODE=True to see a visual representation of the batching in real time on your console.

Metadata

Release files for dank-mids 4.20.216

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dank-mids 4.20.216
File Size Uploaded Provenance Actions
dank_mids-4.20.216.tar.gz 188.6 kB Without provenance Details for dank_mids-4.20.216.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for dank-mids 4.20.216
File Actions
dank_mids-4.20.216-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for dank_mids-4.20.216-cp313-cp313-win_amd64.whl
dank_mids-4.20.216-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for dank_mids-4.20.216-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
dank_mids-4.20.216-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for dank_mids-4.20.216-cp313-cp313-macosx_11_0_arm64.whl
dank_mids-4.20.216-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for dank_mids-4.20.216-cp312-cp312-win_amd64.whl
dank_mids-4.20.216-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for dank_mids-4.20.216-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
dank_mids-4.20.216-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for dank_mids-4.20.216-cp312-cp312-macosx_11_0_arm64.whl
dank_mids-4.20.216-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for dank_mids-4.20.216-cp311-cp311-win_amd64.whl
dank_mids-4.20.216-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for dank_mids-4.20.216-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
dank_mids-4.20.216-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for dank_mids-4.20.216-cp311-cp311-macosx_11_0_arm64.whl
dank_mids-4.20.216-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for dank_mids-4.20.216-cp310-cp310-win_amd64.whl
dank_mids-4.20.216-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for dank_mids-4.20.216-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
dank_mids-4.20.216-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for dank_mids-4.20.216-cp310-cp310-macosx_11_0_arm64.whl

Total release size: 14.7 MB

Release files / dank_mids-4.20.216.tar.gz

Download URL dank_mids-4.20.216.tar.gz
Size 188.6 kB
Tags Source
SHA-256 checksum
How to use checksums
03443960ad6856284b1e772df0f052bbaf538bd2d720fa04267df8d81f3bcf44
BLAKE2b-256 checksum
How to use checksums
9221d5d0e11d7442ead733ff9a6f9ec5af351b940da7cc7b190ca4d2a2ca6b39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp313-cp313-win_amd64.whl

Download URL dank_mids-4.20.216-cp313-cp313-win_amd64.whl
Size 880.4 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
de913460406b3b96ed131adccfa68eb66e8be166045e0b680b7079744cede8dc
BLAKE2b-256 checksum
How to use checksums
6ed189a8c9612cb71b4bc48f743de87c81e4e6dd1c9c1c7ae7d4fd6bf675b121
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL dank_mids-4.20.216-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2b143e5e56848fa335ba8b57f0530efdfb7bfe7cf5d87c89c10ac4df3c8627e2
BLAKE2b-256 checksum
How to use checksums
3fad684c228e3365fc6386bca0feeecda158c509d7e03806435b8eb8b2b13237
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp313-cp313-macosx_11_0_arm64.whl

Download URL dank_mids-4.20.216-cp313-cp313-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ebac9b29ec87c1f034e06e0d34a258f008d656f303f3011d12746fcc2a9c96b0
BLAKE2b-256 checksum
How to use checksums
870d91ee53bf430e4b00a3105a887608262d3e3744c373b49459c0aca3d20ccc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp312-cp312-win_amd64.whl

Download URL dank_mids-4.20.216-cp312-cp312-win_amd64.whl
Size 877.0 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
6eef0bad1daf6a67f8fbea55821df5888a56dd85c13844209381d3a7771993a0
BLAKE2b-256 checksum
How to use checksums
e73ab9bbe0011fd45978ba5bbfc2f7a95fdd802a2f1d9ade0ceb91ae69d1cd2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL dank_mids-4.20.216-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d1cf271455d05d239a9cc2b63a8dd72abc3d4519d78873a3d3662130e78bcdb8
BLAKE2b-256 checksum
How to use checksums
2dbe36e8aa80102e5ae0d937be9a16eb2f66deed1be4d8a2f95962e75fb9e949
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp312-cp312-macosx_11_0_arm64.whl

Download URL dank_mids-4.20.216-cp312-cp312-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c7e16413174c5f7257d9d234c40969ae49b3c13c9fee7e4352c76e5c004da699
BLAKE2b-256 checksum
How to use checksums
10ecc6869c3887b8d938bb77227905065e44fee2b44f0efae0a95beef9a73548
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp311-cp311-win_amd64.whl

Download URL dank_mids-4.20.216-cp311-cp311-win_amd64.whl
Size 869.2 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
14aeb2826e8cca3581f4d4bb9b0b7a0aaa54faa3b22d30b26c8a1f410c261edb
BLAKE2b-256 checksum
How to use checksums
70cb0355243cf6b9ee17925d57410cb1ebcb4b29f9945b0ea12c61daae29aff1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL dank_mids-4.20.216-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.6 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e17da10ab75708545fc437cdc8f844826859c1742896fcb648dc5a8f040aa601
BLAKE2b-256 checksum
How to use checksums
d5f2dc6de651deb1301bb67211bcfdd33e6834ca37f47e6b65963b02739d26bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp311-cp311-macosx_11_0_arm64.whl

Download URL dank_mids-4.20.216-cp311-cp311-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
77a8f9349044f41e1f58257284b1a690eb9b79501730bc4b1685b339fc93fdc8
BLAKE2b-256 checksum
How to use checksums
8e17feef454aae90334380acee0a0ccf4392f2bc9a506f4c61f73687dea27033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp310-cp310-win_amd64.whl

Download URL dank_mids-4.20.216-cp310-cp310-win_amd64.whl
Size 869.6 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
cc8e65432b84eb5857dd711cf48d3ee6547089a777e94a91efb2f05165737cbb
BLAKE2b-256 checksum
How to use checksums
fadb083a83ee731534c9d15f191b2b6f00f23323af074b1ad3d8273d4cecf4ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL dank_mids-4.20.216-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.6 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
945b80370961574f240ceb8a06d1548836ca5324ab1bc56a8031b176d7208c0d
BLAKE2b-256 checksum
How to use checksums
539d991f6ef7c69d97811095f62862bd0b9a618438de8841dba239f3e8053b2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / dank_mids-4.20.216-cp310-cp310-macosx_11_0_arm64.whl

Download URL dank_mids-4.20.216-cp310-cp310-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b15b1cb1fdeb9d2bdd3d2dee1e5557ef9fcfe8b7142d46d734092efeede15809
BLAKE2b-256 checksum
How to use checksums
75171c730364e582dd9a7548426cf2f98dc36d114d52de65757c9c97be1db567
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for dank-mids 4.20.216

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

4.20.216 This release

13 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page