purechain-sdk 0.0.1__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 (54) hide show
  1. purechain_sdk-0.0.1/.github/workflows/release.yml +72 -0
  2. purechain_sdk-0.0.1/.gitignore +30 -0
  3. purechain_sdk-0.0.1/LICENSE +202 -0
  4. purechain_sdk-0.0.1/PKG-INFO +320 -0
  5. purechain_sdk-0.0.1/README.md +290 -0
  6. purechain_sdk-0.0.1/pyproject.toml +63 -0
  7. purechain_sdk-0.0.1/src/purechain/__init__.py +162 -0
  8. purechain_sdk-0.0.1/src/purechain/abi.py +77 -0
  9. purechain_sdk-0.0.1/src/purechain/address.py +58 -0
  10. purechain_sdk-0.0.1/src/purechain/benchmark.py +486 -0
  11. purechain_sdk-0.0.1/src/purechain/client/__init__.py +4 -0
  12. purechain_sdk-0.0.1/src/purechain/client/factory.py +49 -0
  13. purechain_sdk-0.0.1/src/purechain/client/interface.py +180 -0
  14. purechain_sdk-0.0.1/src/purechain/core/__init__.py +0 -0
  15. purechain_sdk-0.0.1/src/purechain/core/capabilities.py +211 -0
  16. purechain_sdk-0.0.1/src/purechain/core/errors.py +184 -0
  17. purechain_sdk-0.0.1/src/purechain/core/fees.py +85 -0
  18. purechain_sdk-0.0.1/src/purechain/core/types.py +235 -0
  19. purechain_sdk-0.0.1/src/purechain/metrics.py +347 -0
  20. purechain_sdk-0.0.1/src/purechain/py.typed +0 -0
  21. purechain_sdk-0.0.1/src/purechain/units.py +80 -0
  22. purechain_sdk-0.0.1/src/purechain/variants/__init__.py +0 -0
  23. purechain_sdk-0.0.1/src/purechain/variants/besu/__init__.py +53 -0
  24. purechain_sdk-0.0.1/src/purechain/variants/dag/__init__.py +48 -0
  25. purechain_sdk-0.0.1/src/purechain/variants/evm/__init__.py +0 -0
  26. purechain_sdk-0.0.1/src/purechain/variants/evm/contract.py +293 -0
  27. purechain_sdk-0.0.1/src/purechain/variants/evm/engine.py +470 -0
  28. purechain_sdk-0.0.1/src/purechain/variants/evm/mapping.py +134 -0
  29. purechain_sdk-0.0.1/src/purechain/variants/evm/signer.py +105 -0
  30. purechain_sdk-0.0.1/src/purechain/variants/evm/wait.py +95 -0
  31. purechain_sdk-0.0.1/src/purechain/variants/evm/watcher.py +188 -0
  32. purechain_sdk-0.0.1/src/purechain/variants/geth/__init__.py +61 -0
  33. purechain_sdk-0.0.1/src/purechain/variants/geth/networks.py +41 -0
  34. purechain_sdk-0.0.1/src/purechain/variants/stub.py +105 -0
  35. purechain_sdk-0.0.1/src/purechain/wallet.py +221 -0
  36. purechain_sdk-0.0.1/tests/__init__.py +0 -0
  37. purechain_sdk-0.0.1/tests/fake_node.py +195 -0
  38. purechain_sdk-0.0.1/tests/helpers.py +88 -0
  39. purechain_sdk-0.0.1/tests/test_benchmark.py +344 -0
  40. purechain_sdk-0.0.1/tests/test_capabilities.py +145 -0
  41. purechain_sdk-0.0.1/tests/test_client.py +179 -0
  42. purechain_sdk-0.0.1/tests/test_contract.py +331 -0
  43. purechain_sdk-0.0.1/tests/test_engine.py +375 -0
  44. purechain_sdk-0.0.1/tests/test_errors.py +118 -0
  45. purechain_sdk-0.0.1/tests/test_fees.py +45 -0
  46. purechain_sdk-0.0.1/tests/test_live_network.py +100 -0
  47. purechain_sdk-0.0.1/tests/test_live_write.py +102 -0
  48. purechain_sdk-0.0.1/tests/test_mapping.py +134 -0
  49. purechain_sdk-0.0.1/tests/test_metrics.py +215 -0
  50. purechain_sdk-0.0.1/tests/test_namespaces.py +220 -0
  51. purechain_sdk-0.0.1/tests/test_stub.py +87 -0
  52. purechain_sdk-0.0.1/tests/test_wait.py +117 -0
  53. purechain_sdk-0.0.1/tests/test_watcher.py +139 -0
  54. purechain_sdk-0.0.1/uv.lock +2334 -0
@@ -0,0 +1,72 @@
1
+ name: Release
2
+
3
+ # Publishing is irreversible — PyPI never lets a version number be reused, even
4
+ # after a release is deleted. So this fires only on an explicit version tag,
5
+ # never on a push to main, and it runs the full gate before publishing.
6
+ on:
7
+ push:
8
+ tags:
9
+ - "v*"
10
+
11
+ jobs:
12
+ publish:
13
+ runs-on: ubuntu-latest
14
+ # Requires a PyPI Trusted Publisher configured for this repo and workflow.
15
+ # That exchanges a short-lived OIDC token for upload rights, so no API token
16
+ # is ever stored as a repository secret.
17
+ environment: pypi
18
+ permissions:
19
+ contents: read
20
+ id-token: write
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+
25
+ - name: Install uv
26
+ uses: astral-sh/setup-uv@v5
27
+ with:
28
+ enable-cache: true
29
+
30
+ - name: Verify the tag matches pyproject.toml
31
+ # A tag that disagrees with the manifest publishes the wrong version
32
+ # under the right name, and PyPI will not let it be corrected.
33
+ run: |
34
+ TAG="${GITHUB_REF_NAME#v}"
35
+ PKG=$(python -c "import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
36
+ if [ "$TAG" != "$PKG" ]; then
37
+ echo "Tag v$TAG does not match pyproject.toml version $PKG" >&2
38
+ exit 1
39
+ fi
40
+ echo "Publishing version $PKG"
41
+
42
+ - name: Install from the lockfile
43
+ run: uv sync --all-extras --frozen
44
+
45
+ - name: Typecheck and lint
46
+ run: |
47
+ uv run mypy
48
+ uv run ruff check src tests
49
+
50
+ - name: Test
51
+ # Offline suite only. The live suites reach the public network, and the
52
+ # write suite would broadcast real transactions from CI.
53
+ run: uv run pytest -q
54
+
55
+ - name: Build
56
+ run: uv build
57
+
58
+ - name: Check the wheel carries py.typed
59
+ # Without the PEP 561 marker the library ships untyped, silently
60
+ # discarding every annotation for consumers.
61
+ run: |
62
+ python - <<'EOF'
63
+ import glob, sys, zipfile
64
+ wheel = glob.glob("dist/*.whl")[0]
65
+ names = zipfile.ZipFile(wheel).namelist()
66
+ if "purechain/py.typed" not in names:
67
+ sys.exit("py.typed missing from the wheel — consumers would get no types")
68
+ print(f"py.typed present in {wheel}")
69
+ EOF
70
+
71
+ - name: Publish to PyPI
72
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,30 @@
1
+ # Virtual environments
2
+ .venv/
3
+ venv/
4
+ env/
5
+
6
+ # Byte-compiled / cache
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+
11
+ # Packaging
12
+ build/
13
+ dist/
14
+ *.egg-info/
15
+ *.egg
16
+
17
+ # Tooling caches
18
+ .pytest_cache/
19
+ .mypy_cache/
20
+ .ruff_cache/
21
+ .coverage
22
+ .coverage.*
23
+ htmlcov/
24
+ .tox/
25
+
26
+ # Secrets. Keystores and key material must never be committed — the live write
27
+ # tests generate throwaway keys at runtime and write nothing to disk.
28
+ .env
29
+ *.key
30
+ keystore*.json
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Pure Wallet LLC
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,320 @@
1
+ Metadata-Version: 2.5
2
+ Name: purechain-sdk
3
+ Version: 0.0.1
4
+ Summary: Client library for the PureChain network family (geth, besu, dag variants)
5
+ Project-URL: Homepage, https://github.com/isongjosiah/purechain-py
6
+ Project-URL: Repository, https://github.com/isongjosiah/purechain-py
7
+ Project-URL: Issues, https://github.com/isongjosiah/purechain-py/issues
8
+ Author: isongjosiah
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: blockchain,clique,ethereum,evm,purechain,web3,zero-gas
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: web3<9,>=7.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: mypy>=1.13; extra == 'dev'
25
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
26
+ Requires-Dist: pytest-cov>=6.0; extra == 'dev'
27
+ Requires-Dist: pytest>=8.0; extra == 'dev'
28
+ Requires-Dist: ruff>=0.8; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # purechain
32
+
33
+ A client library for the PureChain network family. Three variants — `geth`,
34
+ `besu`, `dag` — behind one interface, so application code does not change when
35
+ the variant does.
36
+
37
+ Status: the **geth** variant (the live public PureChain network) is implemented
38
+ and tested against the real chain. `besu` and `dag` are stubs with the full
39
+ interface in place; every call raises `NotImplementedError_` naming the variant.
40
+
41
+ This is the Python half of a pair; the TypeScript library mirrors it method for
42
+ method, with the same types, error codes, and defaults.
43
+
44
+ ```bash
45
+ pip install purechain-sdk
46
+ ```
47
+
48
+ > Installed as `purechain-sdk`, imported as `purechain` — the distribution name
49
+ > and the import name are separate in Python. The TypeScript library is
50
+ > `@purechain/client` on npm; the two registries differ only in the name, not in
51
+ > the API.
52
+
53
+ ## Usage
54
+
55
+ The API is async throughout.
56
+
57
+ ```python
58
+ import asyncio
59
+ from purechain import PrivateKeySigner, TxRequest, create_client
60
+
61
+ async def main():
62
+ async with create_client(signer=PrivateKeySigner(PRIVATE_KEY)) as client:
63
+ tx_hash = await client.send_transaction(TxRequest(to="0xabc...", value=1))
64
+ receipt = await client.wait_for(tx_hash)
65
+ print(receipt.status, receipt.block_number)
66
+
67
+ asyncio.run(main())
68
+ ```
69
+
70
+ Point it at your own node, or at a private deployment with its own genesis:
71
+
72
+ ```python
73
+ client = create_client(
74
+ url="http://localhost:8545",
75
+ network={"name": "devnet", "chain_id": 424242},
76
+ )
77
+ ```
78
+
79
+ ## What this library does differently
80
+
81
+ PureChain is a permissioned, free-gas EVM network, and three of its properties
82
+ break assumptions that general-purpose Ethereum libraries build in. Each one is
83
+ handled here by default rather than left to the caller.
84
+
85
+ **Fees are zero, and the oracle is never consulted.** Transactions are built with
86
+ zero fees and signed locally; `eth_gasPrice` is not called. A node started
87
+ without the `--gpo.*` flags reports a non-zero price on a chain whose base fee is
88
+ pinned to zero, so trusting the oracle is how callers end up overpaying — or
89
+ getting rejected. Override with `fees` if a network ever charges:
90
+
91
+ ```python
92
+ from purechain import TipFeePolicy
93
+ create_client(fees=TipFeePolicy(tip_wei=1_000_000_000))
94
+ ```
95
+
96
+ **Blocks are not produced on a fixed interval.** Smart Auto Mining seals only
97
+ while transactions are pending and pauses when the network is idle, so a static
98
+ head is healthy rather than stalled. `wait_for` therefore defaults to inclusion,
99
+ not a confirmation count — waiting for depth on a chain that goes quiet right
100
+ afterwards would never resolve. Depth is opt-in and always bounded:
101
+
102
+ ```python
103
+ await client.wait_for(tx_hash) # inclusion
104
+ await client.wait_for(tx_hash, WaitOptions(until="final", confirmations=3))
105
+ ```
106
+
107
+ A timeout against a head that never moved raises `ChainIdleError` rather than
108
+ `TimeoutError_`, so "the network is quiet" is distinguishable from "something
109
+ went wrong".
110
+
111
+ **There is no replace-by-fee.** A pending transaction cannot be bumped or
112
+ cancelled at zero fee — the pool requires a strictly higher fee, and nothing is
113
+ higher than zero. Sends are serialised per sender so concurrent calls cannot
114
+ collide on a nonce, because the usual escape hatch does not exist here.
115
+
116
+ ## Capabilities are detected, not assumed
117
+
118
+ Which JSON-RPC namespaces are available is a property of the node you connected
119
+ to, not of the variant. The public endpoints run `--http.api eth,net,web3`, so
120
+ `clique_*`, `txpool_*`, `admin_*` and `debug_*` are absent even though
121
+ purechain-geth implements them.
122
+
123
+ ```python
124
+ caps = await client.capabilities()
125
+ caps.zero_fee # True
126
+ caps.replace_by_fee # False
127
+ caps.subscriptions # False -- public endpoints are HTTP-only
128
+ caps.has("clique_getSigners") # False on the public RPC
129
+ caps.validator_api # "clique" | "qbft" | "ibft" | None
130
+ ```
131
+
132
+ Anything outside the core surface is reachable through the raw escape hatch,
133
+ once you have checked for it:
134
+
135
+ ```python
136
+ if caps.has("clique_getSigners"):
137
+ signers = await client.rpc("clique_getSigners", [])
138
+ ```
139
+
140
+ ## Events
141
+
142
+ `eth_subscribe` is unavailable on the public endpoints, so watching polls by
143
+ default and tolerates idle gaps. Delivery is ordered and gap-free.
144
+
145
+ ```python
146
+ sub = await client.watch_logs(
147
+ token.filter("Transfer"),
148
+ lambda log: print(token.decode_log(log).args),
149
+ )
150
+ await sub.close()
151
+ ```
152
+
153
+ ## Contracts
154
+
155
+ ABIs are the JSON form (a list of dicts), as produced by `solc` and consumed by
156
+ the rest of the Python ecosystem.
157
+
158
+ ```python
159
+ from purechain import Contract, deploy_contract
160
+
161
+ token = Contract("0xabc...", abi, client)
162
+ balance = await token.read("balanceOf", [address])
163
+ await token.write_and_wait("transfer", [to, 100])
164
+
165
+ result = await deploy_contract(client, abi=abi, bytecode=bytecode)
166
+ print(result.address)
167
+ ```
168
+
169
+ Gas is free, so an account with a zero balance can deploy and call. No balance
170
+ pre-check is performed; a balance is only needed to move value.
171
+
172
+ ## Development
173
+
174
+ ```bash
175
+ uv sync --all-extras # exact versions from uv.lock
176
+ pytest # offline unit tests
177
+ PURECHAIN_LIVE=1 pytest # plus read-only tests against the public network
178
+ mypy && ruff check src tests
179
+ ```
180
+
181
+ `uv.lock` pins all 54 packages, so every machine and CI run resolves the same
182
+ versions. Commit it. Use `uv lock --upgrade` to move dependencies forward
183
+ deliberately, rather than letting a fresh install drift on its own.
184
+
185
+ There is a third suite that **broadcasts real transactions** to the public
186
+ network. It is behind its own flag so it never runs by accident:
187
+
188
+ ```bash
189
+ PURECHAIN_LIVE_WRITE=1 pytest tests/test_live_write.py
190
+ ```
191
+
192
+ It generates a throwaway key and sends zero-value transfers to itself. No
193
+ funding is needed — gas is free, which is precisely what the test proves.
194
+
195
+ ## Design
196
+
197
+ These are the rules the library is built on. New code should follow them.
198
+
199
+ ### Layout
200
+
201
+ ```
202
+ src/purechain/
203
+ __init__.py public API
204
+ wallet.py keys, mnemonics, keystore, signature verification
205
+ units.py PCN <-> wei
206
+ address.py validate, checksum, compare
207
+ abi.py offline encode / decode
208
+ metrics.py throughput, block timing, gas utilisation (reads)
209
+ benchmark.py latency and throughput under load (BROADCASTS)
210
+ core/ variant-agnostic types, errors, fee policy, capability detection
211
+ client/ the PureChainClient interface and the create_client factory
212
+ variants/
213
+ evm/ shared EVM engine, signing, contracts, waiting, watching
214
+ geth/ purechain-geth -- implemented
215
+ besu/ stub
216
+ dag/ stub
217
+ ```
218
+
219
+ The root modules are the namespaces from rule 9. `metrics` only reads;
220
+ `benchmark` writes to the chain, which is why they are separate. They sit beside `core`,
221
+ `client` and `variants` because they are top-level concerns, not a sub-part of
222
+ any of them. The TypeScript package has the same file names in the same places.
223
+
224
+ ### 1. One interface, three variants
225
+
226
+ Every variant implements the same `PureChainClient` interface. That interface
227
+ holds only what all three can genuinely do — the intersection, not the union.
228
+
229
+ This is why `wait_for` is built around a finality level, with a confirmation
230
+ count only as an opt-in extra: a DAG has no block depth to count. Anything one
231
+ variant can do beyond the interface sits behind a capability check, or on that
232
+ variant's own class.
233
+
234
+ ### 2. Three layers, one direction
235
+
236
+ `core` → `client` → `variants`. Code in `core` never imports from `variants`.
237
+
238
+ Nothing in `core` assumes blocks, a block interval, or an EVM. That single
239
+ constraint is what keeps the DAG variant possible behind the same interface.
240
+
241
+ ### 3. Detect, don't assume
242
+
243
+ What a node can do is a property of the node, not the variant. The same
244
+ purechain-geth build exposes `clique_*` on your own machine and not on the
245
+ public RPC.
246
+
247
+ Capabilities are read once when the client connects, then cached. Check them
248
+ before using anything outside the core surface.
249
+
250
+ ### 4. Defaults match this network, not the ecosystem
251
+
252
+ Zero fees, and the gas-price oracle is never called. Wait for inclusion, not
253
+ depth. Poll for events instead of subscribing.
254
+
255
+ Each of those is unusual for an Ethereum library and correct here. Where the
256
+ network forbids something outright — replace-by-fee — the library says so with a
257
+ named error rather than failing in a confusing way.
258
+
259
+ ### 5. Wrap the cryptography, own the policy
260
+
261
+ web3.py does three jobs: signing, ABI coding, transport. This library decides
262
+ fees, nonces, waiting, and retries.
263
+
264
+ web3 types never appear in the public API. That is what lets the TypeScript port
265
+ sit on ethers and still behave identically.
266
+
267
+ ### 6. Always leave an escape hatch
268
+
269
+ Blocks, transactions, receipts and logs all carry `raw` — the node's response
270
+ untouched, including fields the typed surface does not name. Clients with a real
271
+ backend also expose `rpc(method, params)`, which reaches any method at all. Stubs
272
+ do not, because they have nothing to call.
273
+
274
+ A typed API you cannot step outside of is a dead end on a network that adds its
275
+ own methods.
276
+
277
+ ### 7. Errors carry codes
278
+
279
+ Branch on `err.code`, never on the message text. Messages are written for humans
280
+ and will change; codes will not. The code strings are identical in both
281
+ languages.
282
+
283
+ Two classes take a trailing underscore — `NotImplementedError_`, `TimeoutError_`
284
+ — so they do not shadow Python builtins. Their `code` values match TypeScript.
285
+
286
+ ### 8. Stubs are honest
287
+
288
+ An unfinished variant still exposes the whole interface, and every call fails
289
+ with an error naming the variant. You find out at the call site, not three
290
+ frames deep in an `AttributeError`.
291
+
292
+ ### 9. Objects hold state, namespaces hold pure functions
293
+
294
+ A client owns a connection, so it is an object. Creating a key or parsing an
295
+ amount needs no state, so those belong in namespaces — plain modules here, since
296
+ a Python module already is a namespace:
297
+
298
+ ```python
299
+ from purechain import address, units, wallet
300
+
301
+ signer = wallet.create() # no network needed
302
+ wei = units.parse_pcn("1.5")
303
+ ok = address.is_valid(some_string)
304
+ ```
305
+
306
+ There are four: `wallet`, `units`, `address`, and `abi`. Binding an ABI to a
307
+ deployed address needs a client, so that stays on the `Contract` class rather
308
+ than becoming a fifth namespace — one way to do it, not two.
309
+
310
+ ### 10. The two libraries match
311
+
312
+ Same folders, same module names, same method names, same error codes. The only
313
+ intended difference is casing: `snake_case` here, `camelCase` in TypeScript.
314
+
315
+ A change to one library is a change to both.
316
+
317
+ Where a language convention genuinely differs, follow the local one and say so.
318
+ Two cases exist today: ABIs are JSON lists here and may also be
319
+ human-readable signature strings in TypeScript, and async iteration and context
320
+ managers follow Python norms.