janzeer-sdk 0.1.0__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.
- janzeer_sdk-0.1.0/.gitignore +10 -0
- janzeer_sdk-0.1.0/CHANGELOG.md +20 -0
- janzeer_sdk-0.1.0/LICENSE +202 -0
- janzeer_sdk-0.1.0/PKG-INFO +144 -0
- janzeer_sdk-0.1.0/README.md +108 -0
- janzeer_sdk-0.1.0/docs/conformance.md +15 -0
- janzeer_sdk-0.1.0/docs/errors.md +62 -0
- janzeer_sdk-0.1.0/docs/json-rpc-and-subscriptions.md +65 -0
- janzeer_sdk-0.1.0/docs/reading-chain-data.md +87 -0
- janzeer_sdk-0.1.0/docs/sending-transactions.md +109 -0
- janzeer_sdk-0.1.0/docs/vault.md +33 -0
- janzeer_sdk-0.1.0/docs/wallet-and-keys.md +60 -0
- janzeer_sdk-0.1.0/examples/01_quickstart_transfer.py +20 -0
- janzeer_sdk-0.1.0/examples/02_subscribe_address_activity.py +27 -0
- janzeer_sdk-0.1.0/examples/03_token_create_and_transfer.py +28 -0
- janzeer_sdk-0.1.0/examples/04_register_validator.py +24 -0
- janzeer_sdk-0.1.0/examples/05_vault_roundtrip.py +14 -0
- janzeer_sdk-0.1.0/pyproject.toml +68 -0
- janzeer_sdk-0.1.0/src/janzeer/__init__.py +71 -0
- janzeer_sdk-0.1.0/src/janzeer/_json.py +48 -0
- janzeer_sdk-0.1.0/src/janzeer/account.py +78 -0
- janzeer_sdk-0.1.0/src/janzeer/amounts.py +103 -0
- janzeer_sdk-0.1.0/src/janzeer/bip39_english.txt +2048 -0
- janzeer_sdk-0.1.0/src/janzeer/constants.py +56 -0
- janzeer_sdk-0.1.0/src/janzeer/crypto.py +192 -0
- janzeer_sdk-0.1.0/src/janzeer/errors.py +168 -0
- janzeer_sdk-0.1.0/src/janzeer/helpers.py +108 -0
- janzeer_sdk-0.1.0/src/janzeer/mnemonic.py +78 -0
- janzeer_sdk-0.1.0/src/janzeer/py.typed +0 -0
- janzeer_sdk-0.1.0/src/janzeer/rest.py +279 -0
- janzeer_sdk-0.1.0/src/janzeer/rpc.py +270 -0
- janzeer_sdk-0.1.0/src/janzeer/tx.py +304 -0
- janzeer_sdk-0.1.0/src/janzeer/vault.py +50 -0
- janzeer_sdk-0.1.0/src/janzeer/ws.py +250 -0
- janzeer_sdk-0.1.0/tests/e2e/test_e2e.py +117 -0
- janzeer_sdk-0.1.0/tests/test_amounts.py +47 -0
- janzeer_sdk-0.1.0/tests/test_builders.py +64 -0
- janzeer_sdk-0.1.0/tests/test_clients.py +197 -0
- janzeer_sdk-0.1.0/tests/test_vectors.py +96 -0
- janzeer_sdk-0.1.0/tests/test_ws.py +87 -0
- janzeer_sdk-0.1.0/tests/vectors/SHA256SUMS +2 -0
- janzeer_sdk-0.1.0/tests/vectors/vault-fixture.json +18 -0
- janzeer_sdk-0.1.0/tests/vectors/wallet-parity-vectors.json +71 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this package. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
4
|
+
and the package follows [Semantic Versioning](https://semver.org/).
|
|
5
|
+
|
|
6
|
+
## 0.1.0 — 2026-10-28
|
|
7
|
+
|
|
8
|
+
First release on PyPI, for node 0.1.10 (API 1.1.0, protocol 3.4.0); the source has been public since 2026-10-01 and was
|
|
9
|
+
verified against every node release from 0.1.0 to 0.1.10.
|
|
10
|
+
|
|
11
|
+
- Keys: BIP39 mnemonics, Janzeer seed and `m/0/0/0` derivation, addresses with the EIP-55 display form, RFC-6979
|
|
12
|
+
low-S signatures.
|
|
13
|
+
- Transactions: transfer, validator registration and exit, JZT-1 token operations; unsigned / signed objects.
|
|
14
|
+
- Clients: REST and JSON-RPC over HTTP, blocking and `asyncio`; JSON-RPC over WebSocket with `newBlocks` and
|
|
15
|
+
`addressActivity` subscriptions and automatic resubscription.
|
|
16
|
+
- Flows: `next_nonce`, `wait_for_finality`, `send_and_wait` and their async twins.
|
|
17
|
+
- Vault: PBKDF2-HMAC-SHA256 (250,000 rounds) + AES-256-GCM, interoperable with the TypeScript, Dart and Kotlin SDKs.
|
|
18
|
+
- WebSocket: a subscription is registered when its answer is read, so a notification sent right behind the answer is
|
|
19
|
+
never dropped.
|
|
20
|
+
- Conformance: all vectors (format v2) and the 14-step end-to-end flow.
|
|
@@ -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 [yyyy] [name of copyright owner]
|
|
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,144 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: janzeer-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK of the Janzeer blockchain: wallet keys and signing, transaction builders, REST, JSON-RPC and WebSocket clients.
|
|
5
|
+
Project-URL: Homepage, https://janzeer.org
|
|
6
|
+
Project-URL: Repository, https://github.com/janzeerorg/janzeer-sdk-python
|
|
7
|
+
Project-URL: Documentation, https://github.com/janzeerorg/janzeer-sdk-python#readme
|
|
8
|
+
Project-URL: Changelog, https://github.com/janzeerorg/janzeer-sdk-python/blob/master/CHANGELOG.md
|
|
9
|
+
Author-email: Janzeer <info@janzeer.org>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: blockchain,janzeer,json-rpc,sdk,wallet
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: coincurve>=20
|
|
24
|
+
Requires-Dist: httpx>=0.27
|
|
25
|
+
Requires-Dist: pycryptodome>=3.20
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: build; extra == 'dev'
|
|
28
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
32
|
+
Requires-Dist: websockets>=13; extra == 'dev'
|
|
33
|
+
Provides-Extra: ws
|
|
34
|
+
Requires-Dist: websockets>=13; extra == 'ws'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# janzeer-sdk (Python)
|
|
38
|
+
|
|
39
|
+
Official Python SDK for the [Janzeer](https://janzeer.org) blockchain — a stake-free, permissionless Layer-1 with
|
|
40
|
+
instant finality. Wallet keys and signing, transaction builders, a REST client, JSON-RPC over HTTP and WebSocket
|
|
41
|
+
subscriptions, blocking and `asyncio`. Non-custodial by construction: keys never leave your process, the node only
|
|
42
|
+
verifies.
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install janzeer-sdk # add [ws] for WebSocket subscriptions: pip install "janzeer-sdk[ws]"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Releases are published to PyPI from this repository's GitHub releases (trusted publishing, no stored token). To install the
|
|
52
|
+
development head instead:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install "janzeer-sdk[ws] @ git+https://github.com/janzeerorg/janzeer-sdk-python"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 60-second quickstart
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from janzeer import Account, JanzeerClient, JanzeerRpc, TxBuilder, format_jnz, wait_for_finality
|
|
62
|
+
|
|
63
|
+
client = JanzeerClient("https://onion.janzeer.org") # REST (/api/v1)
|
|
64
|
+
rpc = JanzeerRpc("https://onion.janzeer.org") # JSON-RPC (/rpc)
|
|
65
|
+
me = Account.from_mnemonic("abandon abandon … about") # 12/24-word BIP39 phrase
|
|
66
|
+
|
|
67
|
+
print(me.checksum_address, format_jnz(client.balance(me.address)))
|
|
68
|
+
|
|
69
|
+
tx = me.sign_tx(TxBuilder.transfer(
|
|
70
|
+
sender=me.address, to="0x598b1301acef3baba6ce25e38dd17b723f7b98b1",
|
|
71
|
+
amount="1.25", data="hello", nonce=client.nonce(me.address),
|
|
72
|
+
))
|
|
73
|
+
client.submit(tx) # HTTP 201, or a typed error
|
|
74
|
+
final = wait_for_finality(rpc, tx.hash) # one or two 15-second slots
|
|
75
|
+
print("final in block", final["blockHeight"])
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
That is the whole integration: derive → nonce → build → sign → submit → wait. A committed block is final
|
|
79
|
+
(2f+1 BFT commit), so there is no confirmation count.
|
|
80
|
+
|
|
81
|
+
The same with `asyncio`: `AsyncJanzeerClient`, `AsyncJanzeerRpc`, `JanzeerRpcWs` and `await_finality` have the same
|
|
82
|
+
methods and return awaitables.
|
|
83
|
+
|
|
84
|
+
## What is in the box
|
|
85
|
+
|
|
86
|
+
| Area | Entry points | Guide |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| Keys & addresses | `mnemonic`, `Account`, `to_checksum_address`, `is_valid_address` | [wallet-and-keys](docs/wallet-and-keys.md) |
|
|
89
|
+
| Transactions | `TxBuilder.transfer / register_validator / exit_validator / token.*` → `UnsignedTx` → `SignedTx` | [sending-transactions](docs/sending-transactions.md) |
|
|
90
|
+
| Amounts | `to_scaled`, `from_scaled`, `format_jnz`, `parse_jnz`, `add_amounts`… | [sending-transactions](docs/sending-transactions.md#amounts) |
|
|
91
|
+
| REST | `JanzeerClient` / `AsyncJanzeerClient`: balances, nonces, transactions, blocks, validators, tokens | [reading-chain-data](docs/reading-chain-data.md) |
|
|
92
|
+
| JSON-RPC | `JanzeerRpc` / `AsyncJanzeerRpc` (HTTP, batches) and `JanzeerRpcWs` (WebSocket + `newBlocks` / `addressActivity`) | [json-rpc-and-subscriptions](docs/json-rpc-and-subscriptions.md) |
|
|
93
|
+
| Flows | `wait_for_finality`, `send_and_wait`, `next_nonce` (and `await_finality`, `asend_and_wait`) | [json-rpc-and-subscriptions](docs/json-rpc-and-subscriptions.md#finality) |
|
|
94
|
+
| Errors | `TxRejectedError`, `NonceMismatchError`, `RateLimitedError`, `RpcError`… | [errors](docs/errors.md) |
|
|
95
|
+
| Vault | `encrypt_vault` / `decrypt_vault` (PBKDF2 + AES-GCM, compatible with the other SDKs) | [vault](docs/vault.md) |
|
|
96
|
+
|
|
97
|
+
## Money is never a float
|
|
98
|
+
|
|
99
|
+
Amounts are decimal **strings** (`"1.25"`), `int` (whole coins) or `decimal.Decimal`. A `float` is refused with a
|
|
100
|
+
`TypeError` everywhere — in the builders, in the amount helpers and in request bodies — because `0.1` is not
|
|
101
|
+
representable in binary and a payment must not depend on how a float prints. Responses are parsed losslessly:
|
|
102
|
+
numbers with a fraction arrive as `Decimal`, `client.balance()` returns a decimal string.
|
|
103
|
+
|
|
104
|
+
## Results are plain JSON
|
|
105
|
+
|
|
106
|
+
Network calls return the node's JSON as `dict` / `list` values with the field names the node uses
|
|
107
|
+
(`blockHeight`, `senderAddress`, …), documented in the
|
|
108
|
+
[API reference](https://github.com/janzeerorg/janzeer-docs/blob/master/en/api-reference.md). Keys, transactions and
|
|
109
|
+
errors are typed classes; the package ships `py.typed`.
|
|
110
|
+
|
|
111
|
+
## Requirements
|
|
112
|
+
|
|
113
|
+
- Python 3.10 – 3.13 on Linux, macOS or Windows.
|
|
114
|
+
- `coincurve` (libsecp256k1), `pycryptodome` (keccak-256, AES-GCM), `httpx`; `websockets` for subscriptions.
|
|
115
|
+
Wheels exist for all three systems: no compiler is needed.
|
|
116
|
+
|
|
117
|
+
## Compatibility
|
|
118
|
+
|
|
119
|
+
| SDK | Node | REST envelope `version` | Wire protocol | Vectors |
|
|
120
|
+
|---|---|---|---|---|
|
|
121
|
+
| 0.1.x | 0.1.3 | 1.1.0 | 3.4.0 | v2 |
|
|
122
|
+
|
|
123
|
+
`SPEC_VERSION` exports these values; the e2e test checks them against the node on the first call.
|
|
124
|
+
|
|
125
|
+
## Examples
|
|
126
|
+
|
|
127
|
+
Runnable scripts in [`examples/`](examples): a transfer to finality, an address-activity subscription, the token
|
|
128
|
+
life cycle, a validator registration, and a vault round trip. They read the `JANZEER_*` environment variables
|
|
129
|
+
described in [CONTRIBUTING](CONTRIBUTING.md).
|
|
130
|
+
|
|
131
|
+
## Conformance
|
|
132
|
+
|
|
133
|
+
This SDK reproduces, byte for byte, the public test vectors every Janzeer SDK is tested against (key derivation,
|
|
134
|
+
addresses, every transaction preimage, hash and signature, the vault fixture) and passes the shared 14-step
|
|
135
|
+
end-to-end flow: <https://github.com/janzeerorg/janzeer-sdk-conformance>. See [docs/conformance.md](docs/conformance.md).
|
|
136
|
+
|
|
137
|
+
## Other SDKs
|
|
138
|
+
|
|
139
|
+
[TypeScript](https://github.com/janzeerorg/janzeer-sdk-ts) · [Dart / Flutter](https://github.com/janzeerorg/janzeer-sdk-dart) ·
|
|
140
|
+
[Kotlin / JVM / Android](https://github.com/janzeerorg/janzeer-sdk-kotlin) · [Go](https://github.com/janzeerorg/janzeer-sdk-go)
|
|
141
|
+
|
|
142
|
+
## Licence
|
|
143
|
+
|
|
144
|
+
Apache License 2.0 — see [LICENSE](LICENSE). Security reports: see [SECURITY](SECURITY.md).
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# janzeer-sdk (Python)
|
|
2
|
+
|
|
3
|
+
Official Python SDK for the [Janzeer](https://janzeer.org) blockchain — a stake-free, permissionless Layer-1 with
|
|
4
|
+
instant finality. Wallet keys and signing, transaction builders, a REST client, JSON-RPC over HTTP and WebSocket
|
|
5
|
+
subscriptions, blocking and `asyncio`. Non-custodial by construction: keys never leave your process, the node only
|
|
6
|
+
verifies.
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install janzeer-sdk # add [ws] for WebSocket subscriptions: pip install "janzeer-sdk[ws]"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Releases are published to PyPI from this repository's GitHub releases (trusted publishing, no stored token). To install the
|
|
16
|
+
development head instead:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install "janzeer-sdk[ws] @ git+https://github.com/janzeerorg/janzeer-sdk-python"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 60-second quickstart
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from janzeer import Account, JanzeerClient, JanzeerRpc, TxBuilder, format_jnz, wait_for_finality
|
|
26
|
+
|
|
27
|
+
client = JanzeerClient("https://onion.janzeer.org") # REST (/api/v1)
|
|
28
|
+
rpc = JanzeerRpc("https://onion.janzeer.org") # JSON-RPC (/rpc)
|
|
29
|
+
me = Account.from_mnemonic("abandon abandon … about") # 12/24-word BIP39 phrase
|
|
30
|
+
|
|
31
|
+
print(me.checksum_address, format_jnz(client.balance(me.address)))
|
|
32
|
+
|
|
33
|
+
tx = me.sign_tx(TxBuilder.transfer(
|
|
34
|
+
sender=me.address, to="0x598b1301acef3baba6ce25e38dd17b723f7b98b1",
|
|
35
|
+
amount="1.25", data="hello", nonce=client.nonce(me.address),
|
|
36
|
+
))
|
|
37
|
+
client.submit(tx) # HTTP 201, or a typed error
|
|
38
|
+
final = wait_for_finality(rpc, tx.hash) # one or two 15-second slots
|
|
39
|
+
print("final in block", final["blockHeight"])
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
That is the whole integration: derive → nonce → build → sign → submit → wait. A committed block is final
|
|
43
|
+
(2f+1 BFT commit), so there is no confirmation count.
|
|
44
|
+
|
|
45
|
+
The same with `asyncio`: `AsyncJanzeerClient`, `AsyncJanzeerRpc`, `JanzeerRpcWs` and `await_finality` have the same
|
|
46
|
+
methods and return awaitables.
|
|
47
|
+
|
|
48
|
+
## What is in the box
|
|
49
|
+
|
|
50
|
+
| Area | Entry points | Guide |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| Keys & addresses | `mnemonic`, `Account`, `to_checksum_address`, `is_valid_address` | [wallet-and-keys](docs/wallet-and-keys.md) |
|
|
53
|
+
| Transactions | `TxBuilder.transfer / register_validator / exit_validator / token.*` → `UnsignedTx` → `SignedTx` | [sending-transactions](docs/sending-transactions.md) |
|
|
54
|
+
| Amounts | `to_scaled`, `from_scaled`, `format_jnz`, `parse_jnz`, `add_amounts`… | [sending-transactions](docs/sending-transactions.md#amounts) |
|
|
55
|
+
| REST | `JanzeerClient` / `AsyncJanzeerClient`: balances, nonces, transactions, blocks, validators, tokens | [reading-chain-data](docs/reading-chain-data.md) |
|
|
56
|
+
| JSON-RPC | `JanzeerRpc` / `AsyncJanzeerRpc` (HTTP, batches) and `JanzeerRpcWs` (WebSocket + `newBlocks` / `addressActivity`) | [json-rpc-and-subscriptions](docs/json-rpc-and-subscriptions.md) |
|
|
57
|
+
| Flows | `wait_for_finality`, `send_and_wait`, `next_nonce` (and `await_finality`, `asend_and_wait`) | [json-rpc-and-subscriptions](docs/json-rpc-and-subscriptions.md#finality) |
|
|
58
|
+
| Errors | `TxRejectedError`, `NonceMismatchError`, `RateLimitedError`, `RpcError`… | [errors](docs/errors.md) |
|
|
59
|
+
| Vault | `encrypt_vault` / `decrypt_vault` (PBKDF2 + AES-GCM, compatible with the other SDKs) | [vault](docs/vault.md) |
|
|
60
|
+
|
|
61
|
+
## Money is never a float
|
|
62
|
+
|
|
63
|
+
Amounts are decimal **strings** (`"1.25"`), `int` (whole coins) or `decimal.Decimal`. A `float` is refused with a
|
|
64
|
+
`TypeError` everywhere — in the builders, in the amount helpers and in request bodies — because `0.1` is not
|
|
65
|
+
representable in binary and a payment must not depend on how a float prints. Responses are parsed losslessly:
|
|
66
|
+
numbers with a fraction arrive as `Decimal`, `client.balance()` returns a decimal string.
|
|
67
|
+
|
|
68
|
+
## Results are plain JSON
|
|
69
|
+
|
|
70
|
+
Network calls return the node's JSON as `dict` / `list` values with the field names the node uses
|
|
71
|
+
(`blockHeight`, `senderAddress`, …), documented in the
|
|
72
|
+
[API reference](https://github.com/janzeerorg/janzeer-docs/blob/master/en/api-reference.md). Keys, transactions and
|
|
73
|
+
errors are typed classes; the package ships `py.typed`.
|
|
74
|
+
|
|
75
|
+
## Requirements
|
|
76
|
+
|
|
77
|
+
- Python 3.10 – 3.13 on Linux, macOS or Windows.
|
|
78
|
+
- `coincurve` (libsecp256k1), `pycryptodome` (keccak-256, AES-GCM), `httpx`; `websockets` for subscriptions.
|
|
79
|
+
Wheels exist for all three systems: no compiler is needed.
|
|
80
|
+
|
|
81
|
+
## Compatibility
|
|
82
|
+
|
|
83
|
+
| SDK | Node | REST envelope `version` | Wire protocol | Vectors |
|
|
84
|
+
|---|---|---|---|---|
|
|
85
|
+
| 0.1.x | 0.1.3 | 1.1.0 | 3.4.0 | v2 |
|
|
86
|
+
|
|
87
|
+
`SPEC_VERSION` exports these values; the e2e test checks them against the node on the first call.
|
|
88
|
+
|
|
89
|
+
## Examples
|
|
90
|
+
|
|
91
|
+
Runnable scripts in [`examples/`](examples): a transfer to finality, an address-activity subscription, the token
|
|
92
|
+
life cycle, a validator registration, and a vault round trip. They read the `JANZEER_*` environment variables
|
|
93
|
+
described in [CONTRIBUTING](CONTRIBUTING.md).
|
|
94
|
+
|
|
95
|
+
## Conformance
|
|
96
|
+
|
|
97
|
+
This SDK reproduces, byte for byte, the public test vectors every Janzeer SDK is tested against (key derivation,
|
|
98
|
+
addresses, every transaction preimage, hash and signature, the vault fixture) and passes the shared 14-step
|
|
99
|
+
end-to-end flow: <https://github.com/janzeerorg/janzeer-sdk-conformance>. See [docs/conformance.md](docs/conformance.md).
|
|
100
|
+
|
|
101
|
+
## Other SDKs
|
|
102
|
+
|
|
103
|
+
[TypeScript](https://github.com/janzeerorg/janzeer-sdk-ts) · [Dart / Flutter](https://github.com/janzeerorg/janzeer-sdk-dart) ·
|
|
104
|
+
[Kotlin / JVM / Android](https://github.com/janzeerorg/janzeer-sdk-kotlin) · [Go](https://github.com/janzeerorg/janzeer-sdk-go)
|
|
105
|
+
|
|
106
|
+
## Licence
|
|
107
|
+
|
|
108
|
+
Apache License 2.0 — see [LICENSE](LICENSE). Security reports: see [SECURITY](SECURITY.md).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Conformance
|
|
2
|
+
|
|
3
|
+
Janzeer's signing scheme is custom (see [wallet-and-keys](wallet-and-keys.md)); a client that deviates by one byte
|
|
4
|
+
produces transactions every node rejects. Two artefacts keep every official SDK in line:
|
|
5
|
+
|
|
6
|
+
1. **Vectors** — `wallet-parity-vectors.json`, generated by the node's own cryptography: mnemonic → seed → key →
|
|
7
|
+
address, a raw-key address, and for each transaction type the exact signed bytes, hash and signature; plus an
|
|
8
|
+
EIP-55 table and an amount-scaling table. This SDK vendors them under `tests/vectors/` and `pytest` reproduces
|
|
9
|
+
every entry. The signature check is exact equality, which only holds with RFC-6979 and low-S.
|
|
10
|
+
2. **The end-to-end flow** — `e2e/SPEC.md`, 14 steps against a real network: version gate, account, subscribe,
|
|
11
|
+
build and sign, submit over REST, idempotent resubmit over RPC, finality on another node, exact balance
|
|
12
|
+
arithmetic, the WebSocket notification, and three negative cases (nonce gap, forged signature, bad address).
|
|
13
|
+
`pytest -m e2e` runs it.
|
|
14
|
+
|
|
15
|
+
Both live in <https://github.com/janzeerorg/janzeer-sdk-conformance>.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Errors, nonces and rate limits
|
|
2
|
+
|
|
3
|
+
Everything the SDK raises for a node or network problem extends `JanzeerError`. Branch on the class, never on message
|
|
4
|
+
text. (Local input mistakes — a float amount, a bad address — raise the built-in `TypeError` / `ValueError`.)
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
JanzeerError
|
|
8
|
+
├─ NetworkError node unreachable / non-JSON / socket closed / timeout
|
|
9
|
+
├─ TxRejectedError the node refused a transaction — `type` names the rule
|
|
10
|
+
│ └─ NonceMismatchError `expected`, `got`, `address`
|
|
11
|
+
├─ ApiError other REST errors: `status`, `type`, `body`
|
|
12
|
+
│ ├─ ValidationError 400 with a list of field messages (`messages`)
|
|
13
|
+
│ └─ NotFoundError 404
|
|
14
|
+
├─ NotSynchronizedError the node is still syncing (REST 400 / RPC -32002) — retry shortly
|
|
15
|
+
├─ RateLimitedError HTTP 429 / RPC -32004 — `retry_after` (seconds)
|
|
16
|
+
├─ RpcError `code`, `data`
|
|
17
|
+
│ ├─ RpcInvalidParamsError -32602 (data: field messages)
|
|
18
|
+
│ ├─ RpcNotFoundError -32000
|
|
19
|
+
│ ├─ RpcLimitError -32003 (range / timeout above the cap)
|
|
20
|
+
│ └─ RpcMethodNotFoundError -32601
|
|
21
|
+
└─ FinalityTimeoutError wait_for_finality deadline (`last` view)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`TxRejectedError` and `NonceMismatchError` are the same classes on every transport (`transport` is `"rest"`, `"rpc"`
|
|
25
|
+
or `"ws"`, with `http_status` or `rpc_code`).
|
|
26
|
+
|
|
27
|
+
## Rejection types
|
|
28
|
+
|
|
29
|
+
| `type` | Meaning | What to do |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| `INVALID_NONCE` | nonce ≠ the sender's next nonce (`NonceMismatchError.expected`) | refresh the nonce and rebuild |
|
|
32
|
+
| `INCORRECT_SIGNATURE` | the signature does not verify | you signed other bytes — check the fields and the network id |
|
|
33
|
+
| `INCORRECT_HASH` | `hash` ≠ double-SHA256 of the signed bytes | same |
|
|
34
|
+
| `INCORRECT_ADDRESS` | `senderAddress` is not the address of `senderPublicKey` | derive both from one `Account` |
|
|
35
|
+
| `INSUFFICIENT_ACTUAL_BALANCE` / `INSUFFICIENT_BALANCE` | not enough spendable balance for amount + fee | — |
|
|
36
|
+
| `INCORRECT_PROMOTER_KEY` / `ALREADY_PROMOTER` | validator key invalid / already registered | — |
|
|
37
|
+
|
|
38
|
+
A newer node may add types; `e.type` carries the string as received.
|
|
39
|
+
|
|
40
|
+
## Nonce handling pattern
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
def send_with_retry(build): # build(nonce) -> SignedTx
|
|
44
|
+
nonce = client.nonce(me.address)
|
|
45
|
+
for _ in range(3):
|
|
46
|
+
try:
|
|
47
|
+
return client.submit(build(nonce))
|
|
48
|
+
except NonceMismatchError as e:
|
|
49
|
+
if e.expected is None:
|
|
50
|
+
raise
|
|
51
|
+
nonce = e.expected
|
|
52
|
+
raise RuntimeError("could not agree on a nonce")
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Pipelining: after submitting nonce `n`, `client.nonce()` already answers `n+1`; you may keep sending. If a pending
|
|
56
|
+
transaction is dropped (6 h mempool expiry) the ones behind it become gaps — rebuild from `expected`.
|
|
57
|
+
|
|
58
|
+
## Rate limits
|
|
59
|
+
|
|
60
|
+
Nodes throttle `POST /api/v1/transactions/**` and `/rpc` per client IP (default 20 requests/s, burst 40). Reads are
|
|
61
|
+
never limited. The clients retry **once** after a 429, honouring `Retry-After` (`retry_on_rate_limit=False` to
|
|
62
|
+
disable); resubmitting a transaction is safe because acceptance is idempotent by hash.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# JSON-RPC and subscriptions
|
|
2
|
+
|
|
3
|
+
The node serves JSON-RPC 2.0 at `POST /rpc` and over WebSocket at `/rpc/ws` (the same methods, plus subscriptions).
|
|
4
|
+
`JanzeerRpc`, `AsyncJanzeerRpc` and `JanzeerRpcWs` expose **one method per `janzeer_*` method**; `call()` sends
|
|
5
|
+
anything else.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
rpc = JanzeerRpc("https://onion.janzeer.org") # '/rpc' appended automatically
|
|
9
|
+
rpc.get_info(); rpc.get_chain_spec(); rpc.get_stats(); rpc.get_epoch(); rpc.get_genesis()
|
|
10
|
+
rpc.get_account(addr); rpc.get_balance(addr); rpc.get_nonce(addr)
|
|
11
|
+
rpc.get_transactions_by_address(addr, size=20) # {list, pending, total…}
|
|
12
|
+
rpc.get_transaction_by_hash(hash) # status FINAL | PENDING | UNKNOWN
|
|
13
|
+
rpc.get_tip(); rpc.get_block_by_number(12, True); rpc.get_blocks(1, 100)
|
|
14
|
+
rpc.list_validators(); rpc.get_active_validators(); rpc.get_validator(key)
|
|
15
|
+
rpc.list_tokens(); rpc.get_token(token_id); rpc.get_token_holders(token_id)
|
|
16
|
+
rpc.estimate_fee("transfer") # {fee, rule: 'minimum' | 'exact'}
|
|
17
|
+
rpc.send(signed_tx)
|
|
18
|
+
rpc.call("janzeer_methods") # raw
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Batches
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
nonce, tip = rpc.batch([("janzeer_getNonce", {"address": addr}), ("janzeer_getTip", None)])
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Up to 50 requests per batch, 512 KiB per body. Results keep the request order. One failing entry does not raise: its
|
|
28
|
+
slot holds the error **instance** (`isinstance(x, JanzeerError)`), the others hold their results.
|
|
29
|
+
|
|
30
|
+
## Finality
|
|
31
|
+
|
|
32
|
+
`rpc.wait_for_finality(hash, timeout_ms)` is the node's long-poll (at most 60 s per call). The helper
|
|
33
|
+
`wait_for_finality(rpc_or_client, hash, timeout=180)` chains calls until a client-side deadline, tolerates a dropped
|
|
34
|
+
connection, and raises `FinalityTimeoutError` (with the last view) on expiry. Given a REST client it polls the
|
|
35
|
+
transaction endpoints. `await_finality` is the async twin and also accepts a `JanzeerRpcWs`.
|
|
36
|
+
|
|
37
|
+
A `FINAL` view carries `blockHash`, `blockHeight` and `receipt["successful"]`. The chain has instant finality (2f+1
|
|
38
|
+
BFT commit), so no confirmation counting exists anywhere in the API.
|
|
39
|
+
|
|
40
|
+
## WebSocket
|
|
41
|
+
|
|
42
|
+
Install the extra: `pip install "janzeer-sdk[ws]"`.
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
ws = await JanzeerRpcWs.connect("wss://onion.janzeer.org") # http(s) URLs are converted
|
|
46
|
+
await ws.get_tip() # every method works over the socket
|
|
47
|
+
|
|
48
|
+
blocks = await ws.subscribe_new_blocks(print, from_height=100, include_transactions=True)
|
|
49
|
+
watch = await ws.subscribe_address_activity([addr1, addr2], lambda ev: print(ev["blockHeight"], ev["transaction"]["hash"]))
|
|
50
|
+
await watch.unsubscribe()
|
|
51
|
+
await ws.close()
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- `newBlocks` replays committed blocks from `from_height`, then streams live ones — exactly once per height.
|
|
55
|
+
- `addressActivity` fires for every **final** transaction whose sender, recipient or token recipient is in the list
|
|
56
|
+
(at most 1000 addresses, 16 subscriptions per socket).
|
|
57
|
+
- A handler may be a plain function or an `async def`.
|
|
58
|
+
- **Reconnect**: on a dropped socket the client reconnects with exponential backoff (1 s up to 30 s) and re-issues
|
|
59
|
+
every subscription; `subscription.id` changes, handlers stay. Pass `reconnect=False` to opt out and `on_event=` to
|
|
60
|
+
log `open` / `close` / `error` / `resubscribed`.
|
|
61
|
+
- The node disconnects slow consumers (2 MiB send buffer, 5 s send timeout): keep handlers fast.
|
|
62
|
+
|
|
63
|
+
## Errors
|
|
64
|
+
|
|
65
|
+
JSON-RPC errors map to the same classes as REST — see [errors](errors.md).
|