erpc-py 0.1.0b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. erpc_py-0.1.0b1/CHANGELOG.md +20 -0
  2. erpc_py-0.1.0b1/LICENSE +21 -0
  3. erpc_py-0.1.0b1/MANIFEST.in +4 -0
  4. erpc_py-0.1.0b1/PKG-INFO +328 -0
  5. erpc_py-0.1.0b1/README.md +284 -0
  6. erpc_py-0.1.0b1/erpc/__init__.py +154 -0
  7. erpc_py-0.1.0b1/erpc/async_process.py +254 -0
  8. erpc_py-0.1.0b1/erpc/auth.py +241 -0
  9. erpc_py-0.1.0b1/erpc/cli.py +212 -0
  10. erpc_py-0.1.0b1/erpc/client.py +196 -0
  11. erpc_py-0.1.0b1/erpc/config.py +364 -0
  12. erpc_py-0.1.0b1/erpc/database.py +361 -0
  13. erpc_py-0.1.0b1/erpc/docker.py +373 -0
  14. erpc_py-0.1.0b1/erpc/dynamic.py +295 -0
  15. erpc_py-0.1.0b1/erpc/exceptions.py +25 -0
  16. erpc_py-0.1.0b1/erpc/failsafe.py +340 -0
  17. erpc_py-0.1.0b1/erpc/install.py +132 -0
  18. erpc_py-0.1.0b1/erpc/logging.py +120 -0
  19. erpc_py-0.1.0b1/erpc/mixins.py +64 -0
  20. erpc_py-0.1.0b1/erpc/monitoring.py +45 -0
  21. erpc_py-0.1.0b1/erpc/networks.py +231 -0
  22. erpc_py-0.1.0b1/erpc/process.py +342 -0
  23. erpc_py-0.1.0b1/erpc/providers.py +502 -0
  24. erpc_py-0.1.0b1/erpc/py.typed +0 -0
  25. erpc_py-0.1.0b1/erpc/rate_limiters.py +321 -0
  26. erpc_py-0.1.0b1/erpc/server.py +169 -0
  27. erpc_py-0.1.0b1/erpc/upstreams.py +53 -0
  28. erpc_py-0.1.0b1/erpc/version.py +67 -0
  29. erpc_py-0.1.0b1/erpc_py.egg-info/PKG-INFO +328 -0
  30. erpc_py-0.1.0b1/erpc_py.egg-info/SOURCES.txt +34 -0
  31. erpc_py-0.1.0b1/erpc_py.egg-info/dependency_links.txt +1 -0
  32. erpc_py-0.1.0b1/erpc_py.egg-info/entry_points.txt +2 -0
  33. erpc_py-0.1.0b1/erpc_py.egg-info/requires.txt +16 -0
  34. erpc_py-0.1.0b1/erpc_py.egg-info/top_level.txt +1 -0
  35. erpc_py-0.1.0b1/pyproject.toml +136 -0
  36. erpc_py-0.1.0b1/setup.cfg +4 -0
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2025-02-24
9
+
10
+ ### Added
11
+
12
+ - `ERPCProcess` — subprocess manager with start/stop/restart/health checks.
13
+ - `ERPCConfig` / `CacheConfig` — programmatic YAML config generation.
14
+ - `find_erpc_binary()` — automatic binary discovery (PATH, env var, common locations).
15
+ - `install_erpc()` — download eRPC binary from GitHub releases.
16
+ - `get_erpc_version()` — detect installed eRPC version.
17
+ - Context manager support (`with ERPCProcess(...) as erpc:`).
18
+ - Exception hierarchy: `ERPCError`, `ERPCNotFound`, `ERPCNotRunning`, `ERPCStartupError`, `ERPCHealthCheckError`.
19
+
20
+ [0.1.0]: https://github.com/tars-endurance/erpc.py/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 TARS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include LICENSE
2
+ include README.md
3
+ include CHANGELOG.md
4
+ recursive-include erpc py.typed
@@ -0,0 +1,328 @@
1
+ Metadata-Version: 2.4
2
+ Name: erpc-py
3
+ Version: 0.1.0b1
4
+ Summary: Python subprocess manager for eRPC v0.0.62 — fault-tolerant EVM RPC proxy
5
+ Author-email: TARS <tars@endurance.sh>, Kieran Prasch <kieran@thethirdroom.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/tars-endurance/erpc.py
8
+ Project-URL: Documentation, https://tars-endurance.github.io/erpc.py
9
+ Project-URL: Repository, https://github.com/tars-endurance/erpc.py
10
+ Project-URL: Issues, https://github.com/tars-endurance/erpc.py/issues
11
+ Project-URL: Changelog, https://github.com/tars-endurance/erpc.py/blob/main/CHANGELOG.md
12
+ Keywords: ethereum,evm,rpc,proxy,cache,erpc,web3,blockchain,subprocess
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Software Development :: Libraries
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: pyyaml>=6.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7.0; extra == "dev"
32
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
33
+ Requires-Dist: pytest-cov<7,>=4.0; extra == "dev"
34
+ Requires-Dist: pytest-timeout>=2.0; extra == "dev"
35
+ Requires-Dist: ruff>=0.9.0; extra == "dev"
36
+ Requires-Dist: mypy>=1.14; extra == "dev"
37
+ Requires-Dist: pre-commit>=4.0; extra == "dev"
38
+ Requires-Dist: types-PyYAML>=6.0; extra == "dev"
39
+ Provides-Extra: docs
40
+ Requires-Dist: mkdocs>=1.6; extra == "docs"
41
+ Requires-Dist: mkdocs-material>=9.5; extra == "docs"
42
+ Requires-Dist: mkdocstrings[python]>=0.27; extra == "docs"
43
+ Dynamic: license-file
44
+
45
+ <div align="center">
46
+
47
+ # erpc.py
48
+
49
+ **Python subprocess manager for [eRPC](https://github.com/erpc/erpc) — the fault-tolerant EVM RPC proxy.**
50
+
51
+ Like [py-geth](https://github.com/ethereum/py-geth) for Go-Ethereum, but for eRPC.
52
+
53
+ [![PyPI](https://img.shields.io/pypi/v/erpc-py)](https://pypi.org/project/erpc-py/)
54
+ [![CI](https://github.com/tars-endurance/erpc.py/actions/workflows/ci.yml/badge.svg)](https://github.com/tars-endurance/erpc.py/actions/workflows/ci.yml)
55
+ [![codecov](https://codecov.io/gh/tars-endurance/erpc.py/branch/main/graph/badge.svg)](https://codecov.io/gh/tars-endurance/erpc.py)
56
+ [![Python](https://img.shields.io/badge/python-3.10%E2%80%933.14-blue)](https://pypi.org/project/erpc-py/)
57
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
58
+ [![mypy](https://img.shields.io/badge/type--checked-mypy%20strict-blue)](https://mypy-lang.org/)
59
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://docs.astral.sh/ruff/)
60
+ [![eRPC](https://img.shields.io/badge/eRPC-v0.0.62-orange)](https://github.com/erpc/erpc/releases/tag/0.0.62)
61
+
62
+ </div>
63
+
64
+ ---
65
+
66
+ > [!NOTE]
67
+ > **This repository was built entirely by an AI agent** ([TARS](https://github.com/tars-endurance)) under the direction of a human engineer ([Kieran Prasch](https://github.com/KPrasch)). Every commit is co-authored. The architecture, priorities, and quality bar were set by a human; the implementation, tests, and documentation were produced by an AI — from first scaffold to 451 tests at 98% coverage. We believe this is how software will increasingly be built: human intent, machine execution, shared accountability.
68
+
69
+ ---
70
+
71
+ ## Compatibility
72
+
73
+ | erpc.py | eRPC binary | Status |
74
+ |---------|-------------|--------|
75
+ | `0.1.x` | [`v0.0.62`](https://github.com/erpc/erpc/releases/tag/0.0.62) | ✅ Current |
76
+
77
+ erpc.py pins a specific eRPC binary version (`erpc.ERPC_VERSION`). All config generation, tests, and CI target this version. Use `install_erpc()` to install the matching binary automatically.
78
+
79
+ ```python
80
+ from erpc import ERPC_VERSION, install_erpc
81
+
82
+ print(ERPC_VERSION) # "0.0.62"
83
+ install_erpc() # downloads the pinned version
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Overview
89
+
90
+ **erpc.py** gives you full programmatic control over [eRPC](https://github.com/erpc/erpc) from Python — binary installation, YAML config generation, process lifecycle, health monitoring, and runtime metrics. Pure Python with only `pyyaml` as a runtime dependency.
91
+
92
+ ```python
93
+ from erpc import ERPCProcess
94
+
95
+ with ERPCProcess(upstreams={1: ["https://eth.llamarpc.com"]}) as erpc:
96
+ url = erpc.endpoint_url(1) # http://127.0.0.1:4000/py-erpc/evm/1
97
+ print(f"Proxying Ethereum mainnet at {url}")
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Installation
103
+
104
+ ```bash
105
+ pip install erpc-py
106
+ ```
107
+
108
+ To install the eRPC binary:
109
+
110
+ ```bash
111
+ erpc-py install --version 0.0.62
112
+ ```
113
+
114
+ Or programmatically:
115
+
116
+ ```python
117
+ from erpc.install import install_erpc
118
+
119
+ install_erpc("0.0.62") # → /usr/local/bin/erpc
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Quick Start
125
+
126
+ ### Minimal — just upstreams
127
+
128
+ ```python
129
+ from erpc import ERPCProcess
130
+
131
+ with ERPCProcess(upstreams={1: ["https://eth.llamarpc.com"]}) as erpc:
132
+ print(erpc.endpoint_url(1))
133
+ print(f"Healthy: {erpc.is_healthy}")
134
+ ```
135
+
136
+ ### Full config
137
+
138
+ ```python
139
+ from erpc import ERPCConfig, ERPCProcess, CacheConfig
140
+
141
+ config = ERPCConfig(
142
+ project_id="my-project",
143
+ upstreams={
144
+ 1: ["https://eth.llamarpc.com", "https://rpc.ankr.com/eth"],
145
+ 137: ["https://polygon-rpc.com"],
146
+ },
147
+ server_port=4000,
148
+ metrics_port=4001,
149
+ log_level="info",
150
+ cache=CacheConfig(max_items=50_000),
151
+ )
152
+
153
+ with ERPCProcess(config=config) as erpc:
154
+ print(erpc.endpoint_url(1))
155
+ print(erpc.endpoint_url(137))
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Features
161
+
162
+ ### 🔧 Binary Management
163
+
164
+ Auto-detect or install eRPC binaries from GitHub releases with optional SHA256 verification.
165
+
166
+ ```python
167
+ from erpc.install import install_erpc
168
+
169
+ path = install_erpc("0.0.62", checksum="abc123...")
170
+ ```
171
+
172
+ ### 📝 Config Builder
173
+
174
+ Full-fidelity Python config that generates valid `erpc.yaml` — networks, upstreams, failsafe policies, rate limiters, auth, caching, database connectors, and more.
175
+
176
+ ```python
177
+ from erpc import ERPCConfig, DatabaseConfig, RedisConnector, AuthConfig, SecretAuth
178
+
179
+ config = ERPCConfig(
180
+ project_id="production",
181
+ upstreams={1: ["https://eth.llamarpc.com"]},
182
+ database=DatabaseConfig(
183
+ evm_json_rpc_cache=RedisConnector(addr="localhost:6379"),
184
+ ),
185
+ auth=AuthConfig(
186
+ strategies=[SecretAuth(value="my-secret-key")],
187
+ ),
188
+ )
189
+
190
+ config.write("erpc.yaml") # Write to file
191
+ print(config.to_yaml()) # Or get YAML string
192
+ ```
193
+
194
+ **Supported config sections:**
195
+ - Networks with per-chain policies
196
+ - Upstream defaults and rich upstream configs
197
+ - 20+ provider presets (Alchemy, Infura, QuickNode, Ankr, etc.)
198
+ - Rate limiters and failsafe policies
199
+ - Auth strategies (Secret, JWT, SIWE, Network-based)
200
+ - Database connectors (Redis, PostgreSQL, DynamoDB, Memory)
201
+ - Cache policies with per-method TTLs
202
+ - Server config (CORS, timeouts) and metrics
203
+
204
+ ### 🏥 Health & Metrics Client
205
+
206
+ Query eRPC's runtime health and Prometheus metrics — stdlib only, no `requests` needed.
207
+
208
+ ```python
209
+ from erpc.client import ERPCClient
210
+
211
+ client = ERPCClient("http://localhost:4000")
212
+
213
+ # Structured health check
214
+ status = client.health()
215
+ print(f"{status.version} — uptime: {status.uptime}s")
216
+
217
+ # Prometheus metrics as dict
218
+ metrics = client.metrics()
219
+ print(metrics.get("erpc_requests_total"))
220
+ ```
221
+
222
+ ### 📊 Health Monitoring
223
+
224
+ Track health state transitions over time.
225
+
226
+ ```python
227
+ from erpc import HealthMonitor, HealthEvent
228
+
229
+ monitor = HealthMonitor(url="http://localhost:4000", interval=30.0)
230
+ event = monitor.latest_event() # HealthEvent.HEALTHY / DOWN / etc.
231
+ ```
232
+
233
+ ### 🐳 Docker Integration
234
+
235
+ Run eRPC as a Docker container — no local binary needed. Uses the `docker` CLI, no Python Docker SDK required.
236
+
237
+ ```python
238
+ from erpc import ERPCConfig, DockerERPCProcess
239
+
240
+ config = ERPCConfig(upstreams={1: ["https://eth.llamarpc.com"]})
241
+
242
+ with DockerERPCProcess(config=config, name="my-erpc") as erpc:
243
+ print(erpc.endpoint_url(1))
244
+ print(erpc.logs(tail=20))
245
+ ```
246
+
247
+ ### 🖥️ CLI Tool
248
+
249
+ Manage eRPC from the command line:
250
+
251
+ ```bash
252
+ erpc-py version # Show versions
253
+ erpc-py install --version 0.0.62 # Install binary
254
+ erpc-py health # Check health
255
+ erpc-py metrics # Show Prometheus metrics
256
+ erpc-py config generate \
257
+ --chains 1,137 \
258
+ --upstreams https://eth.llamarpc.com,https://polygon-rpc.com \
259
+ --output erpc.yaml # Generate config
260
+ erpc-py start --config erpc.yaml # Start eRPC
261
+ erpc-py stop # Stop eRPC
262
+ ```
263
+
264
+ ### 🛡️ Provider Presets
265
+
266
+ 20+ built-in provider configurations for popular RPC services:
267
+
268
+ ```python
269
+ from erpc import AlchemyProvider, InfuraProvider, ERPCConfig
270
+
271
+ config = ERPCConfig(
272
+ upstreams={1: ["https://eth.llamarpc.com"]},
273
+ providers=[
274
+ AlchemyProvider(api_key="..."),
275
+ InfuraProvider(api_key="..."),
276
+ ],
277
+ )
278
+ ```
279
+
280
+ <details>
281
+ <summary>All supported providers</summary>
282
+
283
+ Alchemy · Ankr · BlastAPI · BlockPi · Chainstack · Conduit · DRPC · Dwellir · Envio · Etherspot · Infura · OnFinality · Pimlico · QuickNode · Repository · RouteMesh · Superchain · Tenderly · Thirdweb
284
+
285
+ </details>
286
+
287
+ ---
288
+
289
+ ## API Overview
290
+
291
+ | Class | Description |
292
+ |---|---|
293
+ | `ERPCConfig` | Config builder — generates `erpc.yaml` from Python dataclasses |
294
+ | `ERPCProcess` | Subprocess lifecycle manager with context manager support |
295
+ | `DockerERPCProcess` | Docker container lifecycle manager |
296
+ | `ERPCClient` | Health and Prometheus metrics client (stdlib HTTP) |
297
+ | `HealthMonitor` | Health state tracking with event history |
298
+ | `install_erpc()` | Binary installer from GitHub releases |
299
+ | `CacheConfig` | Memory cache settings with per-method TTLs |
300
+ | `DatabaseConfig` | Database connector config (Redis, Postgres, DynamoDB, Memory) |
301
+ | `AuthConfig` | Auth strategies (Secret, JWT, SIWE, Network) |
302
+ | `ServerConfig` | Server settings (CORS, timeouts, host/port) |
303
+
304
+ ---
305
+
306
+ ## Development
307
+
308
+ ```bash
309
+ git clone https://github.com/tars-endurance/erpc.py.git
310
+ cd erpc.py
311
+ pip install -e ".[dev]"
312
+
313
+ # Run tests (319 tests, 96% coverage)
314
+ pytest
315
+
316
+ # Type checking
317
+ mypy erpc/
318
+
319
+ # Linting
320
+ ruff check .
321
+ ruff format --check .
322
+ ```
323
+
324
+ ---
325
+
326
+ ## License
327
+
328
+ [MIT](LICENSE)
@@ -0,0 +1,284 @@
1
+ <div align="center">
2
+
3
+ # erpc.py
4
+
5
+ **Python subprocess manager for [eRPC](https://github.com/erpc/erpc) — the fault-tolerant EVM RPC proxy.**
6
+
7
+ Like [py-geth](https://github.com/ethereum/py-geth) for Go-Ethereum, but for eRPC.
8
+
9
+ [![PyPI](https://img.shields.io/pypi/v/erpc-py)](https://pypi.org/project/erpc-py/)
10
+ [![CI](https://github.com/tars-endurance/erpc.py/actions/workflows/ci.yml/badge.svg)](https://github.com/tars-endurance/erpc.py/actions/workflows/ci.yml)
11
+ [![codecov](https://codecov.io/gh/tars-endurance/erpc.py/branch/main/graph/badge.svg)](https://codecov.io/gh/tars-endurance/erpc.py)
12
+ [![Python](https://img.shields.io/badge/python-3.10%E2%80%933.14-blue)](https://pypi.org/project/erpc-py/)
13
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
14
+ [![mypy](https://img.shields.io/badge/type--checked-mypy%20strict-blue)](https://mypy-lang.org/)
15
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://docs.astral.sh/ruff/)
16
+ [![eRPC](https://img.shields.io/badge/eRPC-v0.0.62-orange)](https://github.com/erpc/erpc/releases/tag/0.0.62)
17
+
18
+ </div>
19
+
20
+ ---
21
+
22
+ > [!NOTE]
23
+ > **This repository was built entirely by an AI agent** ([TARS](https://github.com/tars-endurance)) under the direction of a human engineer ([Kieran Prasch](https://github.com/KPrasch)). Every commit is co-authored. The architecture, priorities, and quality bar were set by a human; the implementation, tests, and documentation were produced by an AI — from first scaffold to 451 tests at 98% coverage. We believe this is how software will increasingly be built: human intent, machine execution, shared accountability.
24
+
25
+ ---
26
+
27
+ ## Compatibility
28
+
29
+ | erpc.py | eRPC binary | Status |
30
+ |---------|-------------|--------|
31
+ | `0.1.x` | [`v0.0.62`](https://github.com/erpc/erpc/releases/tag/0.0.62) | ✅ Current |
32
+
33
+ erpc.py pins a specific eRPC binary version (`erpc.ERPC_VERSION`). All config generation, tests, and CI target this version. Use `install_erpc()` to install the matching binary automatically.
34
+
35
+ ```python
36
+ from erpc import ERPC_VERSION, install_erpc
37
+
38
+ print(ERPC_VERSION) # "0.0.62"
39
+ install_erpc() # downloads the pinned version
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Overview
45
+
46
+ **erpc.py** gives you full programmatic control over [eRPC](https://github.com/erpc/erpc) from Python — binary installation, YAML config generation, process lifecycle, health monitoring, and runtime metrics. Pure Python with only `pyyaml` as a runtime dependency.
47
+
48
+ ```python
49
+ from erpc import ERPCProcess
50
+
51
+ with ERPCProcess(upstreams={1: ["https://eth.llamarpc.com"]}) as erpc:
52
+ url = erpc.endpoint_url(1) # http://127.0.0.1:4000/py-erpc/evm/1
53
+ print(f"Proxying Ethereum mainnet at {url}")
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Installation
59
+
60
+ ```bash
61
+ pip install erpc-py
62
+ ```
63
+
64
+ To install the eRPC binary:
65
+
66
+ ```bash
67
+ erpc-py install --version 0.0.62
68
+ ```
69
+
70
+ Or programmatically:
71
+
72
+ ```python
73
+ from erpc.install import install_erpc
74
+
75
+ install_erpc("0.0.62") # → /usr/local/bin/erpc
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Quick Start
81
+
82
+ ### Minimal — just upstreams
83
+
84
+ ```python
85
+ from erpc import ERPCProcess
86
+
87
+ with ERPCProcess(upstreams={1: ["https://eth.llamarpc.com"]}) as erpc:
88
+ print(erpc.endpoint_url(1))
89
+ print(f"Healthy: {erpc.is_healthy}")
90
+ ```
91
+
92
+ ### Full config
93
+
94
+ ```python
95
+ from erpc import ERPCConfig, ERPCProcess, CacheConfig
96
+
97
+ config = ERPCConfig(
98
+ project_id="my-project",
99
+ upstreams={
100
+ 1: ["https://eth.llamarpc.com", "https://rpc.ankr.com/eth"],
101
+ 137: ["https://polygon-rpc.com"],
102
+ },
103
+ server_port=4000,
104
+ metrics_port=4001,
105
+ log_level="info",
106
+ cache=CacheConfig(max_items=50_000),
107
+ )
108
+
109
+ with ERPCProcess(config=config) as erpc:
110
+ print(erpc.endpoint_url(1))
111
+ print(erpc.endpoint_url(137))
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Features
117
+
118
+ ### 🔧 Binary Management
119
+
120
+ Auto-detect or install eRPC binaries from GitHub releases with optional SHA256 verification.
121
+
122
+ ```python
123
+ from erpc.install import install_erpc
124
+
125
+ path = install_erpc("0.0.62", checksum="abc123...")
126
+ ```
127
+
128
+ ### 📝 Config Builder
129
+
130
+ Full-fidelity Python config that generates valid `erpc.yaml` — networks, upstreams, failsafe policies, rate limiters, auth, caching, database connectors, and more.
131
+
132
+ ```python
133
+ from erpc import ERPCConfig, DatabaseConfig, RedisConnector, AuthConfig, SecretAuth
134
+
135
+ config = ERPCConfig(
136
+ project_id="production",
137
+ upstreams={1: ["https://eth.llamarpc.com"]},
138
+ database=DatabaseConfig(
139
+ evm_json_rpc_cache=RedisConnector(addr="localhost:6379"),
140
+ ),
141
+ auth=AuthConfig(
142
+ strategies=[SecretAuth(value="my-secret-key")],
143
+ ),
144
+ )
145
+
146
+ config.write("erpc.yaml") # Write to file
147
+ print(config.to_yaml()) # Or get YAML string
148
+ ```
149
+
150
+ **Supported config sections:**
151
+ - Networks with per-chain policies
152
+ - Upstream defaults and rich upstream configs
153
+ - 20+ provider presets (Alchemy, Infura, QuickNode, Ankr, etc.)
154
+ - Rate limiters and failsafe policies
155
+ - Auth strategies (Secret, JWT, SIWE, Network-based)
156
+ - Database connectors (Redis, PostgreSQL, DynamoDB, Memory)
157
+ - Cache policies with per-method TTLs
158
+ - Server config (CORS, timeouts) and metrics
159
+
160
+ ### 🏥 Health & Metrics Client
161
+
162
+ Query eRPC's runtime health and Prometheus metrics — stdlib only, no `requests` needed.
163
+
164
+ ```python
165
+ from erpc.client import ERPCClient
166
+
167
+ client = ERPCClient("http://localhost:4000")
168
+
169
+ # Structured health check
170
+ status = client.health()
171
+ print(f"{status.version} — uptime: {status.uptime}s")
172
+
173
+ # Prometheus metrics as dict
174
+ metrics = client.metrics()
175
+ print(metrics.get("erpc_requests_total"))
176
+ ```
177
+
178
+ ### 📊 Health Monitoring
179
+
180
+ Track health state transitions over time.
181
+
182
+ ```python
183
+ from erpc import HealthMonitor, HealthEvent
184
+
185
+ monitor = HealthMonitor(url="http://localhost:4000", interval=30.0)
186
+ event = monitor.latest_event() # HealthEvent.HEALTHY / DOWN / etc.
187
+ ```
188
+
189
+ ### 🐳 Docker Integration
190
+
191
+ Run eRPC as a Docker container — no local binary needed. Uses the `docker` CLI, no Python Docker SDK required.
192
+
193
+ ```python
194
+ from erpc import ERPCConfig, DockerERPCProcess
195
+
196
+ config = ERPCConfig(upstreams={1: ["https://eth.llamarpc.com"]})
197
+
198
+ with DockerERPCProcess(config=config, name="my-erpc") as erpc:
199
+ print(erpc.endpoint_url(1))
200
+ print(erpc.logs(tail=20))
201
+ ```
202
+
203
+ ### 🖥️ CLI Tool
204
+
205
+ Manage eRPC from the command line:
206
+
207
+ ```bash
208
+ erpc-py version # Show versions
209
+ erpc-py install --version 0.0.62 # Install binary
210
+ erpc-py health # Check health
211
+ erpc-py metrics # Show Prometheus metrics
212
+ erpc-py config generate \
213
+ --chains 1,137 \
214
+ --upstreams https://eth.llamarpc.com,https://polygon-rpc.com \
215
+ --output erpc.yaml # Generate config
216
+ erpc-py start --config erpc.yaml # Start eRPC
217
+ erpc-py stop # Stop eRPC
218
+ ```
219
+
220
+ ### 🛡️ Provider Presets
221
+
222
+ 20+ built-in provider configurations for popular RPC services:
223
+
224
+ ```python
225
+ from erpc import AlchemyProvider, InfuraProvider, ERPCConfig
226
+
227
+ config = ERPCConfig(
228
+ upstreams={1: ["https://eth.llamarpc.com"]},
229
+ providers=[
230
+ AlchemyProvider(api_key="..."),
231
+ InfuraProvider(api_key="..."),
232
+ ],
233
+ )
234
+ ```
235
+
236
+ <details>
237
+ <summary>All supported providers</summary>
238
+
239
+ Alchemy · Ankr · BlastAPI · BlockPi · Chainstack · Conduit · DRPC · Dwellir · Envio · Etherspot · Infura · OnFinality · Pimlico · QuickNode · Repository · RouteMesh · Superchain · Tenderly · Thirdweb
240
+
241
+ </details>
242
+
243
+ ---
244
+
245
+ ## API Overview
246
+
247
+ | Class | Description |
248
+ |---|---|
249
+ | `ERPCConfig` | Config builder — generates `erpc.yaml` from Python dataclasses |
250
+ | `ERPCProcess` | Subprocess lifecycle manager with context manager support |
251
+ | `DockerERPCProcess` | Docker container lifecycle manager |
252
+ | `ERPCClient` | Health and Prometheus metrics client (stdlib HTTP) |
253
+ | `HealthMonitor` | Health state tracking with event history |
254
+ | `install_erpc()` | Binary installer from GitHub releases |
255
+ | `CacheConfig` | Memory cache settings with per-method TTLs |
256
+ | `DatabaseConfig` | Database connector config (Redis, Postgres, DynamoDB, Memory) |
257
+ | `AuthConfig` | Auth strategies (Secret, JWT, SIWE, Network) |
258
+ | `ServerConfig` | Server settings (CORS, timeouts, host/port) |
259
+
260
+ ---
261
+
262
+ ## Development
263
+
264
+ ```bash
265
+ git clone https://github.com/tars-endurance/erpc.py.git
266
+ cd erpc.py
267
+ pip install -e ".[dev]"
268
+
269
+ # Run tests (319 tests, 96% coverage)
270
+ pytest
271
+
272
+ # Type checking
273
+ mypy erpc/
274
+
275
+ # Linting
276
+ ruff check .
277
+ ruff format --check .
278
+ ```
279
+
280
+ ---
281
+
282
+ ## License
283
+
284
+ [MIT](LICENSE)