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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dank_mids-4.20.215.tar.gz (188.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

dank_mids-4.20.215-cp313-cp313-win_amd64.whl (880.2 kB view details)

Uploaded CPython 3.13Windows x86-64

dank_mids-4.20.215-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

dank_mids-4.20.215-cp313-cp313-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

dank_mids-4.20.215-cp312-cp312-win_amd64.whl (877.0 kB view details)

Uploaded CPython 3.12Windows x86-64

dank_mids-4.20.215-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

dank_mids-4.20.215-cp312-cp312-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dank_mids-4.20.215-cp311-cp311-win_amd64.whl (869.1 kB view details)

Uploaded CPython 3.11Windows x86-64

dank_mids-4.20.215-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

dank_mids-4.20.215-cp311-cp311-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

dank_mids-4.20.215-cp310-cp310-win_amd64.whl (869.2 kB view details)

Uploaded CPython 3.10Windows x86-64

dank_mids-4.20.215-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

dank_mids-4.20.215-cp310-cp310-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file dank_mids-4.20.215.tar.gz.

File metadata

  • Download URL: dank_mids-4.20.215.tar.gz
  • Upload date:
  • Size: 188.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dank_mids-4.20.215.tar.gz
Algorithm Hash digest
SHA256 3467f681230980d37edf5cc0bf89e2c0352b436114a187b7c743bf5442e733d8
MD5 a8f02bb4e657f6afdc2625db42c04949
BLAKE2b-256 a4d4f02f500953996049ec640a76b27d96f1d6ac746c22a289a514df53b1eda1

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d676b7e5e4384d0895bec9b4422eb8a1ffd8e7256e952849f45ab7255beb5a66
MD5 c4a0091be527a3e89f1362b7837db9b1
BLAKE2b-256 b2776efeefd71091b9e8b32832754a515a66ee11a6ea19df466ec0d3513dfb86

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 383c70097d0d02893c37b781740bf52409796f37fdfe4d9ab1a043e5dd319f83
MD5 27d8fc6018211f9a31bcd11869ed00d4
BLAKE2b-256 3a3f4d799d71ab97b94c2378200b91d56996848a9889e5535a7b6b7cee862f85

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b0cb5496270cfd57681d14d94c235ceb795b7a6c871634f3f32462f963ed937
MD5 df87e9ee690d89909acd90576d97c1ec
BLAKE2b-256 df920f89f5c61287b550ec93dfb5a18638e5eb16e4a9fcb566b8e570a92c41e5

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6777772bbace42e6a39ac69b5b086bc500934ff50165afbc074a72a64ca392ca
MD5 b6cf51437e06d1c77590cf3f76ec5dc4
BLAKE2b-256 eaa720cdf32eea3649c16a3c0be48c247951f96d33e20880304eab8b5a2841bf

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 359010cf34ecbba75cd3f47997eb5f8004dae3d1056a700a254abedd1a8a2374
MD5 c86c6f0ee9a359a7449d419475c83adf
BLAKE2b-256 a6593d66d8411eba197f94dc1aa0f3f4b409b842d760f864540f3e53fbbaa594

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1ef45b5c72ead2b28a9d90c7503b3613a8e271767d2bb8cef74a29c1ddd93adc
MD5 b071d89cdd6975014813af6e380e4ba9
BLAKE2b-256 eaed445480a36f4c62f6c79707df6bd7e47018bfb36b5b54dcd9e757e1db5724

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7d7ae1acba23ce2ea88c9a751e186618a1c513c691323d961b962df5648a1269
MD5 b145d1cf82f6060a36c459c1b1ea5eb5
BLAKE2b-256 e628f7af66c6b888e458a1a0114cba6af534afe55d6bfc0b66b10e0505f45df8

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eb9f4c7c217786ba504ce82b1c847711c6287d597833e139c4741c59ce252f96
MD5 867668bf5e3664888cf44f0cc487a58f
BLAKE2b-256 843615d7dbb4cbe56d54485e240bde6565d8dcba46e1ce11ac4caa6fea334333

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec755401f518a3b807cac75236a7a2107c7ef14948d10e70e0cc69bd3ef1f215
MD5 27c9d175c18e1eb2d52bcdfb9af49ce6
BLAKE2b-256 4fbb7b374421563c7e3ff9b2fedec73c84d81b80489386ad9b9e200e0fcc4517

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2f555db285dc42fa5502a91f9d8d590bd3793f6b6a76f2b04d1594cace334db4
MD5 ddfaa7c4d1e0cef1f863c0802a29e6fa
BLAKE2b-256 63d58e35a1d52c3051dc797b5b6ec2a1238fbaf16b4d6d4ec43686cbaf5f0115

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3497131897b2f0f82803dd6c7a5240a6c5ff44456c5dd378c516fc0e9f5d9540
MD5 ca88e24f2e965d8abe3a747c9e661d3a
BLAKE2b-256 f694135fb7c9e707758a4f6fcb6a8643604d36d1dffa244278543632138938fd

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.215-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dank_mids-4.20.215-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e184cb3b4deb8919c47768a37cf4b676b936ffcaad2b579fd7f7d4c442da1556
MD5 3dc8f5258d6eabd6eaa0d2e2ebfcbac7
BLAKE2b-256 14f2baa0da92fef259c819186a155e84f8026d8ef541a64d0cd443c70dc66f5b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

4.20.215 This release

13 files

4.20.214

13 files

4.20.213

13 files

4.20.212

13 files

4.20.211

13 files

4.20.210

13 files

4.20.209

13 files

4.20.207

2 files

4.20.206

2 files

4.20.205

2 files

4.20.204

2 files

4.20.203

2 files

4.20.202

2 files

4.20.201

2 files

4.20.200

2 files

4.20.199

2 files

4.20.198

2 files

4.20.197

2 files

4.20.196

2 files

4.20.195

2 files

4.20.194

2 files

4.20.192

2 files

4.20.191

2 files

4.20.190

2 files

4.20.189

2 files

4.20.188

2 files

4.20.187

2 files

4.20.186

2 files

4.20.185

2 files

4.20.184

2 files

4.20.183

2 files

4.20.182

2 files

4.20.181

2 files

4.20.180

2 files

4.20.179

2 files

4.20.178

2 files

4.20.177

2 files

4.20.176

2 files

4.20.175

2 files

4.20.174

2 files

4.20.173

2 files

4.20.172

2 files

4.20.171

2 files

4.20.170

2 files

4.20.169

2 files

4.20.168

2 files

4.20.167

2 files

4.20.166

2 files

4.20.165

2 files

4.20.164

2 files

4.20.163

2 files

4.20.162

2 files

4.20.161

2 files

4.20.160

2 files

4.20.159

2 files

4.20.158

2 files

4.20.157

2 files

4.20.156

2 files

4.20.155

2 files

4.20.154

2 files

4.20.153

2 files

4.20.152

2 files

4.20.151

2 files

4.20.150

2 files

4.20.149

2 files

4.20.148

2 files

4.20.147

2 files

4.20.146

2 files

4.20.145

2 files

4.20.144

2 files

4.20.143

2 files

4.20.142

2 files

4.20.141

2 files

4.20.140

2 files

4.20.139

2 files

4.20.138

2 files

4.20.137

2 files

4.20.136

2 files

4.20.135

2 files

4.20.134

2 files

4.20.133

2 files

4.20.132

2 files

4.20.131

2 files

4.20.130

2 files

4.20.129

2 files

4.20.128

2 files

4.20.127

2 files

4.20.126

2 files

4.20.125

2 files

4.20.124

2 files

4.20.123

2 files

4.20.122

2 files

4.20.121

2 files

4.20.120

2 files

4.20.119

2 files

4.20.118

2 files

4.20.117

2 files

4.20.116

2 files

4.20.115

2 files

4.20.114

2 files

4.20.113

2 files

4.20.112

2 files

4.20.111

2 files

4.20.110

2 files

4.20.109

2 files

4.20.108

2 files

4.20.107

2 files

4.20.106

2 files

4.20.105

2 files

4.20.104

2 files

4.20.103

2 files

4.20.102

2 files

4.20.101

2 files

4.20.100

2 files

4.20.99

2 files

4.20.98

2 files

4.20.97

2 files

4.20.96

2 files

4.20.95

2 files

4.20.94

2 files

4.20.93

2 files

4.20.92

2 files

4.20.91

2 files

4.20.90

2 files

4.20.89

2 files

4.20.88

2 files

4.20.87

2 files

4.20.86

2 files

4.20.85

2 files

4.20.84

2 files

4.20.83

2 files

4.20.82

2 files

4.20.81

2 files

4.20.80

2 files

4.20.79

2 files

4.20.78

2 files

4.20.77

2 files

4.20.76

2 files

4.20.75

2 files

4.20.74

2 files

4.20.73

2 files

4.20.72

2 files

4.20.71

2 files

4.20.70

2 files

4.20.69

2 files

4.20.68

2 files

4.20.67

2 files

4.20.66

2 files

4.20.65

2 files

4.20.64

2 files

4.20.63

2 files

4.20.62

2 files

4.20.61

2 files

4.20.60

2 files

4.20.59

2 files

4.20.58

2 files

4.20.57

2 files

4.20.56

2 files

4.20.55

2 files

4.20.54

2 files

4.20.53

2 files

4.20.52

2 files

4.20.51

2 files

4.20.50

2 files

4.20.49

2 files

4.20.48

2 files

4.20.47

2 files

4.20.46

2 files

4.20.45

2 files

4.20.44

2 files

4.20.43

2 files

4.20.42

2 files

4.20.41

2 files

4.20.40

2 files

4.20.39

2 files

4.20.38

2 files

4.20.37

2 files

4.20.36

2 files

4.20.34

2 files

4.20.33

2 files

4.20.32

2 files

4.20.31

2 files

4.20.30

2 files

4.20.29

2 files

4.20.28

2 files

4.20.27

2 files

4.20.26

2 files

4.20.25

2 files

4.20.24

2 files

4.20.23

2 files

4.20.22

2 files

4.20.21

2 files

4.20.20

2 files

4.20.19

2 files

4.20.18

2 files

4.20.17

2 files

4.20.16

2 files

4.20.15

2 files

4.20.14

2 files

4.20.13

2 files

4.20.12

2 files

4.20.11

2 files

4.20.10

2 files

4.20.9

2 files

4.20.8

2 files

4.20.7

2 files

4.20.6

2 files

4.20.5

2 files

4.20.4

2 files

4.20.3

2 files

4.20.2

2 files

4.20.1

2 files

4.20.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

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