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.214.tar.gz (188.1 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.214-cp313-cp313-win_amd64.whl (870.7 kB view details)

Uploaded CPython 3.13Windows x86-64

dank_mids-4.20.214-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.214-cp313-cp313-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

dank_mids-4.20.214-cp312-cp312-win_amd64.whl (870.3 kB view details)

Uploaded CPython 3.12Windows x86-64

dank_mids-4.20.214-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.214-cp312-cp312-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dank_mids-4.20.214-cp311-cp311-win_amd64.whl (862.7 kB view details)

Uploaded CPython 3.11Windows x86-64

dank_mids-4.20.214-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.214-cp311-cp311-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

dank_mids-4.20.214-cp310-cp310-win_amd64.whl (862.9 kB view details)

Uploaded CPython 3.10Windows x86-64

dank_mids-4.20.214-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.214-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.214.tar.gz.

File metadata

  • Download URL: dank_mids-4.20.214.tar.gz
  • Upload date:
  • Size: 188.1 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.214.tar.gz
Algorithm Hash digest
SHA256 5b5325a1645aaed53d69fd0faa85d85a1cf84e50430758963c8a1f5e0b143e04
MD5 af77b528cc1444b5d3ee5d8410386827
BLAKE2b-256 9ac3cf9e9c790657ae0c917f922d58a5adce8470983a405c4df7f0aec05f1cf3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dank_mids-4.20.214-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d7625f4dc6e6daf898eb454d5f3a4afee1c5a608e08f942f21940281b11a39b4
MD5 0cc07cf63b4833fda4072a31f47ddd0b
BLAKE2b-256 b40dbcf7e046e828689ffc6b7e77bca0056cb0b0c5ce866166e93e26e5a85664

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.214-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.214-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 58ab0601b75e80df78d412348c914efc59d112db383cae7492a3acb2c32628e0
MD5 78f290c9ac3a5f1671897114ccca70a2
BLAKE2b-256 ec1fb1d67237c54535dca65849969c483b3cbb0ccdbec2eef3a97a54a4b40637

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dank_mids-4.20.214-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 690ac9b1affc64b3e4a07151902a349de6e6200d54e7866cf5ca413a2349b0d6
MD5 5b4ee0bb01242582381cffd0ad7ad319
BLAKE2b-256 16e825883e547810452640c2afde6317677720d40afccc1085c6c7d1c51bd684

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dank_mids-4.20.214-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b5596adafb0da4f392b8c93a2313a5812a102661dfe5287b34cfc3b1483cbd57
MD5 9213bfc618cffc21dc116782fdb658ad
BLAKE2b-256 b7dc7826d6cc84a1e1b9103d8db761bde0af762c7ec1af311a7c181f4f1d19cc

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.214-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.214-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 37414c50a66c2aeae10175cf5521d4f46b5fb8ccb1bb53f6cd480e3c4d7f374d
MD5 a5758d025aae7e8d926f7f641989ce50
BLAKE2b-256 5242f79c8b7fe6d2b3a12873b4a9eca9c67f72f3b8aaaf53f757bc829bcf5f3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dank_mids-4.20.214-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2b2dadea7c9d185b8cfa81a0be888ef9b46d5b59164b78a826827e0ef2198911
MD5 a50041feefecf6e9985cee2bd87bdb5b
BLAKE2b-256 1e045f5cb6e40278170d2e3c2603001765f9325f6ebcc98dfdc75d1d19c24b0d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dank_mids-4.20.214-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5d5f08ac4243e17682c2eb03777bc3d9d2d3b6adedb857934f72e0c51e14d0e4
MD5 2a5f94ced9adc489898122f3c5ede6d2
BLAKE2b-256 c5469715ab5fe4ed4d7ab826084496ac925c54ce42ed6c82063de7af743f544b

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.214-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.214-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 599b7a22254220f6526bfefbcae65218e4a21d71239856d96c7e240b5b69ba08
MD5 ee7bd27437b0086a8be319b98fb90a34
BLAKE2b-256 ae91d4ee2efbf2e96c712b2b4c6023d2aaeb6f892899e30123db0d7e6ceafb73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dank_mids-4.20.214-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e0835880266f647fadc750a3e4888d0df0643a4f409b322faff605b865c88d4c
MD5 825c7c3021844bcd2eb6cf5eb55fb2ee
BLAKE2b-256 d8fd52ba048d099cfbc3d4d589ea4620862cc45fc936df054dd581df45a5c395

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dank_mids-4.20.214-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 02b70b347501f1a7ff881560d424837a0e143a07891d54bffb183e1c748da137
MD5 f867100bbb84127b66c6a48e0e5f1675
BLAKE2b-256 3958685ef14322472c14d3a33515615c8c19311c429dc6428039e170ae462aad

See more details on using hashes here.

File details

Details for the file dank_mids-4.20.214-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.214-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9fc42b6dede9f82f50524e143217c292cc63b0e3537f381c90477087b4948c13
MD5 3f68588cf94d7eb3983d571a9aa646cc
BLAKE2b-256 dd5d763b8c3727d08aa794df42442b0deab3488df5f0bd1fb35cf4e3c53f07ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dank_mids-4.20.214-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c0ef91c0b5cbd027fa3f5bc326f0684308b67e411317b271d3dcab96bbba7c8
MD5 3530acc7e24473dde2f59c8f44121ad0
BLAKE2b-256 734ac27f099d22fe2caad7d8c7393a6685278bd25dc97faaaa65c933f630d26f

See more details on using hashes here.

Release history Release notifications | RSS feed

4.20.215

13 files

This release

4.20.214 This release

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