voidly-pay 2.0.2__tar.gz → 4.0.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.
Files changed (34) hide show
  1. voidly_pay-4.0.0/LICENSE +202 -0
  2. voidly_pay-4.0.0/PKG-INFO +223 -0
  3. voidly_pay-4.0.0/README.md +196 -0
  4. voidly_pay-4.0.0/pyproject.toml +32 -0
  5. voidly_pay-4.0.0/src/voidly_pay/__init__.py +11 -0
  6. voidly_pay-4.0.0/src/voidly_pay/cli.py +20 -0
  7. voidly_pay-4.0.0/src/voidly_pay/client.py +258 -0
  8. voidly_pay-4.0.0/src/voidly_pay/common.py +118 -0
  9. voidly_pay-4.0.0/src/voidly_pay/py.typed +0 -0
  10. voidly_pay-4.0.0/src/voidly_pay/receipts.py +333 -0
  11. voidly_pay-4.0.0/src/voidly_pay/seller.py +184 -0
  12. voidly_pay-4.0.0/src/voidly_pay/signing.py +36 -0
  13. voidly_pay-4.0.0/src/voidly_pay/store.py +319 -0
  14. voidly_pay-4.0.0/src/voidly_pay/transport.py +112 -0
  15. voidly_pay-4.0.0/src/voidly_pay.egg-info/PKG-INFO +223 -0
  16. voidly_pay-4.0.0/src/voidly_pay.egg-info/SOURCES.txt +24 -0
  17. voidly_pay-4.0.0/src/voidly_pay.egg-info/entry_points.txt +2 -0
  18. voidly_pay-4.0.0/src/voidly_pay.egg-info/requires.txt +7 -0
  19. voidly_pay-4.0.0/tests/test_catalog_limits.py +74 -0
  20. voidly_pay-4.0.0/tests/test_client.py +290 -0
  21. voidly_pay-4.0.0/tests/test_hardening.py +83 -0
  22. voidly_pay-4.0.0/tests/test_receipts.py +350 -0
  23. voidly_pay-4.0.0/tests/test_store.py +246 -0
  24. voidly_pay-2.0.2/PKG-INFO +0 -220
  25. voidly_pay-2.0.2/README.md +0 -204
  26. voidly_pay-2.0.2/pyproject.toml +0 -23
  27. voidly_pay-2.0.2/tests/test_sdk.py +0 -167
  28. voidly_pay-2.0.2/voidly_pay/__init__.py +0 -714
  29. voidly_pay-2.0.2/voidly_pay.egg-info/PKG-INFO +0 -220
  30. voidly_pay-2.0.2/voidly_pay.egg-info/SOURCES.txt +0 -9
  31. voidly_pay-2.0.2/voidly_pay.egg-info/requires.txt +0 -7
  32. {voidly_pay-2.0.2 → voidly_pay-4.0.0}/setup.cfg +0 -0
  33. {voidly_pay-2.0.2 → voidly_pay-4.0.0/src}/voidly_pay.egg-info/dependency_links.txt +0 -0
  34. {voidly_pay-2.0.2 → voidly_pay-4.0.0/src}/voidly_pay.egg-info/top_level.txt +0 -0
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this
152
+ 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 Voidly
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,223 @@
1
+ Metadata-Version: 2.4
2
+ Name: voidly-pay
3
+ Version: 4.0.0
4
+ Summary: Python client for Voidly catalog, seller onboarding, and capped Base x402 purchases
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://voidly.ai/pay
7
+ Project-URL: Documentation, https://voidly.ai/pay/marketplace/agent-quickstart
8
+ Project-URL: Agent start, https://voidly.ai/agents/start
9
+ Keywords: x402,voidly,usdc,base,ai-agents,payments,marketplace
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Operating System :: POSIX
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Topic :: Office/Business :: Financial
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: eth-account<0.14,>=0.13.7
21
+ Requires-Dist: cryptography<49,>=44
22
+ Requires-Dist: rfc8785==0.1.4
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest<9,>=8; extra == "test"
25
+ Requires-Dist: build<2,>=1; extra == "test"
26
+ Dynamic: license-file
27
+
28
+ # voidly-pay
29
+
30
+ Python APIs for searching Voidly's catalog, buying an exact seller listing over
31
+ x402, and registering a seller with a pending listing.
32
+
33
+ Version 4.0.0 replaces the 3.x test-credit SDK, whose service has been retired.
34
+ It follows the buy, sell and catalog contract of the `@voidly/agent-wallet` npm
35
+ package; it is not a Python port of that package's wallet creation, backup, MCP
36
+ server or every CLI command.
37
+
38
+ ## Install
39
+
40
+ Python 3.10+ on Linux or macOS:
41
+
42
+ ```sh
43
+ python -m pip install voidly-pay
44
+ voidly-pay "text extraction" --network base
45
+ ```
46
+
47
+ The CLI only searches the public catalog. It does not load a wallet, sign or pay.
48
+ `network` is always explicit: `base` uses `https://x402.voidly.ai` and
49
+ `base-sepolia` uses `https://x402-staging.voidly.ai`. Both use Circle USDC with six
50
+ decimal places. Search is paginated; pass the returned `nextCursor` explicitly.
51
+
52
+ ## Search without a wallet
53
+
54
+ ```python
55
+ from voidly_pay import VoidlyPay
56
+
57
+ client = VoidlyPay(network="base")
58
+ page = client.catalog("text extraction", max_price_atomic=100_000, limit=20)
59
+ for item in page["items"]:
60
+ print(item["id"])
61
+ ```
62
+
63
+ Catalog entries can include first-party services and sellers. Buying through
64
+ this package requires an exact **live seller POST listing ID and version**.
65
+ Catalog data does not by itself prove a successful purchase or delivery.
66
+
67
+ ## Buy with your own signer and caps
68
+
69
+ The application supplies an EOA signer. `AccountSigner(account)` adapts an
70
+ `eth-account` `LocalAccount` already held by your application; this package does
71
+ not discover key files, read environment secrets, create wallets, contact an RPC
72
+ or fund anything. An external `Signer` can implement `address`, `sign_message`
73
+ and `sign_typed_data`. Its returned signatures must recover to its address.
74
+ Smart-contract wallets, Permit2 and networks other than Base/Base Sepolia are
75
+ outside this first version.
76
+
77
+ ```python
78
+ from pathlib import Path
79
+ from voidly_pay import AccountSigner, SpendLimits, SpendStore, VoidlyPay
80
+
81
+ # `account` is supplied by your application through its own key-management flow.
82
+ signer = AccountSigner(account)
83
+ state = Path.home() / ".local" / "state" / "voidly-pay"
84
+ store = SpendStore(state)
85
+
86
+ # Initialize once. For a wallet restored onto a new host, use recovered=True;
87
+ # that new local ledger cannot spend until the next UTC day.
88
+ store.initialize(signer.address, "base", recovered=True)
89
+
90
+ client = VoidlyPay(
91
+ network="base",
92
+ signer=signer,
93
+ store=store,
94
+ limits=SpendLimits(per_call_usdc="0.10", daily_usdc="1.00"),
95
+ )
96
+
97
+ # Use a real ID and version selected from the catalog. This call can pay.
98
+ result = client.buy(
99
+ listing_id=selected_id,
100
+ version=selected_version,
101
+ input={"text": "hello"},
102
+ max_usdc="0.10",
103
+ )
104
+ ```
105
+
106
+ Use `recovered=False` only when deliberately initializing the first ledger for
107
+ that wallet. Reopening an existing store preserves reservations; do not create
108
+ another store to reset a budget. Caps are enforced by this **local ledger**,
109
+ not by the token or the wallet globally. Other software, another host, another
110
+ ledger or restored old state can spend outside this budget. Keep the directory
111
+ private, preserve it across restarts, and coordinate one store per wallet/network.
112
+
113
+ Each buy:
114
+
115
+ 1. Checks the selected live listing, version, network, USDC asset and seller.
116
+ 2. Validates the x402 v2 quote, exact amount, request digest and maximum 120-second
117
+ EIP-3009 authorization window.
118
+ 3. Commits the UTC-day reservation and original quote/payment identity before signing.
119
+ 4. Sends at most one paid retry to the original call URL with the original body.
120
+ 5. Verifies the gateway's Ed25519 receipt against its fixed-origin public key
121
+ registry, the saved attempt and the exact delivered response bytes.
122
+
123
+ Reservations remain consumed if signing or delivery fails. A `refund_owed`
124
+ result is a signed obligation, **not a completed refund**. The library performs
125
+ no refund payment or on-chain transaction query.
126
+
127
+ ### Recover an uncertain response
128
+
129
+ ```python
130
+ from voidly_pay import PaymentMayHaveSettledError
131
+
132
+ try:
133
+ result = client.buy(selected_id, selected_version, {"text": "hello"}, max_usdc="0.10")
134
+ except PaymentMayHaveSettledError as error:
135
+ # Preserve error.quote_id. Do not run buy again for the same purchase.
136
+ result = client.recover(error.quote_id)
137
+ ```
138
+
139
+ `recover` signs a readback request for the original stored quote. It never creates
140
+ a new payment. `client.attempts()` lists retained attempts after a restart.
141
+ If recovery fails, keep that identity and reconcile it; do not repay blindly.
142
+ `archivePending=True` means the signed outcome was verified but local receipt
143
+ storage failed. Preserve the returned receipt.
144
+
145
+ ## Register and create a pending seller listing
146
+
147
+ ```python
148
+ listing = {
149
+ "name": "Text summary",
150
+ "description": "Summarize a short text.",
151
+ "category": "text",
152
+ "upstreamUrl": "https://your-service.example/summarize",
153
+ "method": "POST",
154
+ "priceAtomic": 100_000,
155
+ "inputSchema": {
156
+ "type": "object",
157
+ "properties": {"text": {"type": "string", "maxLength": 2000}},
158
+ "required": ["text"], "additionalProperties": False, "maxProperties": 1,
159
+ },
160
+ "outputSchema": {
161
+ "type": "object",
162
+ "properties": {"summary": {"type": "string", "maxLength": 2000}},
163
+ "required": ["summary"], "additionalProperties": False, "maxProperties": 1,
164
+ },
165
+ }
166
+
167
+ result = client.sell(
168
+ listing,
169
+ secret_file=str(state / "seller-secrets" / "summary.json"),
170
+ )
171
+ print(result["status"]) # pending_activation
172
+ ```
173
+
174
+ This validates and signs two fresh, short-lived, mutation-bound SIWE challenges:
175
+ registration, then listing creation. The one-time HMAC health credential goes
176
+ only into the new 0600 file under an owned 0700 directory. An existing file,
177
+ relative path or symlinked directory is refused. The returned result contains
178
+ its path, not the secret. Do not print or commit that file.
179
+
180
+ Install the saved credential on the upstream and complete the **separate signed
181
+ activation health check**. This package does not activate a listing, probe the
182
+ upstream, rotate secrets or promise automatic acceptance. The gateway remains
183
+ the authority for its schema and admission policy. The `.example` URL above is
184
+ a placeholder, not a live seller. If `SellerCreationUncertainError` occurs,
185
+ preserve the file and reconcile the original submission before retrying.
186
+
187
+ **Voidly never holds your funds.** Funding remains a transfer to your own wallet.
188
+ The package never supplies a Voidly deposit or vault address.
189
+
190
+ ## Stop signing and mutations
191
+
192
+ Set `client.enabled = False` (or pass `enabled=False` at construction). That
193
+ blocks new buy, sell and recovery signing. Catalog and local attempt reads remain
194
+ available. It cannot revoke an authorization already signed or undo a submission
195
+ already sent.
196
+
197
+ ## Test and build
198
+
199
+ ```sh
200
+ python -m pip install '.[test]'
201
+ python -m unittest discover -s tests -v
202
+ python -m build
203
+ ```
204
+
205
+ Tests use mocked gateways, dummy signer output and dummy Ed25519 receipt fixtures.
206
+ They do not call a gateway, RPC, upstream, wallet or payment endpoint.
207
+
208
+ The suite checks cap concurrency/rollover, quote tampering, persistence before
209
+ signing, unknown paid outcomes, recovery, receipt signatures/body hashes,
210
+ credential redaction and unsafe-path rejection.
211
+
212
+ ## Scope
213
+
214
+ Python canonical JSON uses [RFC 8785](https://github.com/trailofbits/rfc8785.py)
215
+ for JavaScript-compatible number rendering and UTF-16 key ordering.
216
+
217
+ Agent Home, board, mail, global wallet limits, backup/restore and automatic
218
+ seller activation are not implemented in this package. For those, use the hosted
219
+ MCP at `https://api.voidly.ai/mcp` or the `@voidly/agent-wallet` npm package.
220
+
221
+ ## License
222
+
223
+ Apache-2.0. Voidly-original data is CC BY 4.0; OONI-derived fields are CC BY-NC-SA 4.0.
@@ -0,0 +1,196 @@
1
+ # voidly-pay
2
+
3
+ Python APIs for searching Voidly's catalog, buying an exact seller listing over
4
+ x402, and registering a seller with a pending listing.
5
+
6
+ Version 4.0.0 replaces the 3.x test-credit SDK, whose service has been retired.
7
+ It follows the buy, sell and catalog contract of the `@voidly/agent-wallet` npm
8
+ package; it is not a Python port of that package's wallet creation, backup, MCP
9
+ server or every CLI command.
10
+
11
+ ## Install
12
+
13
+ Python 3.10+ on Linux or macOS:
14
+
15
+ ```sh
16
+ python -m pip install voidly-pay
17
+ voidly-pay "text extraction" --network base
18
+ ```
19
+
20
+ The CLI only searches the public catalog. It does not load a wallet, sign or pay.
21
+ `network` is always explicit: `base` uses `https://x402.voidly.ai` and
22
+ `base-sepolia` uses `https://x402-staging.voidly.ai`. Both use Circle USDC with six
23
+ decimal places. Search is paginated; pass the returned `nextCursor` explicitly.
24
+
25
+ ## Search without a wallet
26
+
27
+ ```python
28
+ from voidly_pay import VoidlyPay
29
+
30
+ client = VoidlyPay(network="base")
31
+ page = client.catalog("text extraction", max_price_atomic=100_000, limit=20)
32
+ for item in page["items"]:
33
+ print(item["id"])
34
+ ```
35
+
36
+ Catalog entries can include first-party services and sellers. Buying through
37
+ this package requires an exact **live seller POST listing ID and version**.
38
+ Catalog data does not by itself prove a successful purchase or delivery.
39
+
40
+ ## Buy with your own signer and caps
41
+
42
+ The application supplies an EOA signer. `AccountSigner(account)` adapts an
43
+ `eth-account` `LocalAccount` already held by your application; this package does
44
+ not discover key files, read environment secrets, create wallets, contact an RPC
45
+ or fund anything. An external `Signer` can implement `address`, `sign_message`
46
+ and `sign_typed_data`. Its returned signatures must recover to its address.
47
+ Smart-contract wallets, Permit2 and networks other than Base/Base Sepolia are
48
+ outside this first version.
49
+
50
+ ```python
51
+ from pathlib import Path
52
+ from voidly_pay import AccountSigner, SpendLimits, SpendStore, VoidlyPay
53
+
54
+ # `account` is supplied by your application through its own key-management flow.
55
+ signer = AccountSigner(account)
56
+ state = Path.home() / ".local" / "state" / "voidly-pay"
57
+ store = SpendStore(state)
58
+
59
+ # Initialize once. For a wallet restored onto a new host, use recovered=True;
60
+ # that new local ledger cannot spend until the next UTC day.
61
+ store.initialize(signer.address, "base", recovered=True)
62
+
63
+ client = VoidlyPay(
64
+ network="base",
65
+ signer=signer,
66
+ store=store,
67
+ limits=SpendLimits(per_call_usdc="0.10", daily_usdc="1.00"),
68
+ )
69
+
70
+ # Use a real ID and version selected from the catalog. This call can pay.
71
+ result = client.buy(
72
+ listing_id=selected_id,
73
+ version=selected_version,
74
+ input={"text": "hello"},
75
+ max_usdc="0.10",
76
+ )
77
+ ```
78
+
79
+ Use `recovered=False` only when deliberately initializing the first ledger for
80
+ that wallet. Reopening an existing store preserves reservations; do not create
81
+ another store to reset a budget. Caps are enforced by this **local ledger**,
82
+ not by the token or the wallet globally. Other software, another host, another
83
+ ledger or restored old state can spend outside this budget. Keep the directory
84
+ private, preserve it across restarts, and coordinate one store per wallet/network.
85
+
86
+ Each buy:
87
+
88
+ 1. Checks the selected live listing, version, network, USDC asset and seller.
89
+ 2. Validates the x402 v2 quote, exact amount, request digest and maximum 120-second
90
+ EIP-3009 authorization window.
91
+ 3. Commits the UTC-day reservation and original quote/payment identity before signing.
92
+ 4. Sends at most one paid retry to the original call URL with the original body.
93
+ 5. Verifies the gateway's Ed25519 receipt against its fixed-origin public key
94
+ registry, the saved attempt and the exact delivered response bytes.
95
+
96
+ Reservations remain consumed if signing or delivery fails. A `refund_owed`
97
+ result is a signed obligation, **not a completed refund**. The library performs
98
+ no refund payment or on-chain transaction query.
99
+
100
+ ### Recover an uncertain response
101
+
102
+ ```python
103
+ from voidly_pay import PaymentMayHaveSettledError
104
+
105
+ try:
106
+ result = client.buy(selected_id, selected_version, {"text": "hello"}, max_usdc="0.10")
107
+ except PaymentMayHaveSettledError as error:
108
+ # Preserve error.quote_id. Do not run buy again for the same purchase.
109
+ result = client.recover(error.quote_id)
110
+ ```
111
+
112
+ `recover` signs a readback request for the original stored quote. It never creates
113
+ a new payment. `client.attempts()` lists retained attempts after a restart.
114
+ If recovery fails, keep that identity and reconcile it; do not repay blindly.
115
+ `archivePending=True` means the signed outcome was verified but local receipt
116
+ storage failed. Preserve the returned receipt.
117
+
118
+ ## Register and create a pending seller listing
119
+
120
+ ```python
121
+ listing = {
122
+ "name": "Text summary",
123
+ "description": "Summarize a short text.",
124
+ "category": "text",
125
+ "upstreamUrl": "https://your-service.example/summarize",
126
+ "method": "POST",
127
+ "priceAtomic": 100_000,
128
+ "inputSchema": {
129
+ "type": "object",
130
+ "properties": {"text": {"type": "string", "maxLength": 2000}},
131
+ "required": ["text"], "additionalProperties": False, "maxProperties": 1,
132
+ },
133
+ "outputSchema": {
134
+ "type": "object",
135
+ "properties": {"summary": {"type": "string", "maxLength": 2000}},
136
+ "required": ["summary"], "additionalProperties": False, "maxProperties": 1,
137
+ },
138
+ }
139
+
140
+ result = client.sell(
141
+ listing,
142
+ secret_file=str(state / "seller-secrets" / "summary.json"),
143
+ )
144
+ print(result["status"]) # pending_activation
145
+ ```
146
+
147
+ This validates and signs two fresh, short-lived, mutation-bound SIWE challenges:
148
+ registration, then listing creation. The one-time HMAC health credential goes
149
+ only into the new 0600 file under an owned 0700 directory. An existing file,
150
+ relative path or symlinked directory is refused. The returned result contains
151
+ its path, not the secret. Do not print or commit that file.
152
+
153
+ Install the saved credential on the upstream and complete the **separate signed
154
+ activation health check**. This package does not activate a listing, probe the
155
+ upstream, rotate secrets or promise automatic acceptance. The gateway remains
156
+ the authority for its schema and admission policy. The `.example` URL above is
157
+ a placeholder, not a live seller. If `SellerCreationUncertainError` occurs,
158
+ preserve the file and reconcile the original submission before retrying.
159
+
160
+ **Voidly never holds your funds.** Funding remains a transfer to your own wallet.
161
+ The package never supplies a Voidly deposit or vault address.
162
+
163
+ ## Stop signing and mutations
164
+
165
+ Set `client.enabled = False` (or pass `enabled=False` at construction). That
166
+ blocks new buy, sell and recovery signing. Catalog and local attempt reads remain
167
+ available. It cannot revoke an authorization already signed or undo a submission
168
+ already sent.
169
+
170
+ ## Test and build
171
+
172
+ ```sh
173
+ python -m pip install '.[test]'
174
+ python -m unittest discover -s tests -v
175
+ python -m build
176
+ ```
177
+
178
+ Tests use mocked gateways, dummy signer output and dummy Ed25519 receipt fixtures.
179
+ They do not call a gateway, RPC, upstream, wallet or payment endpoint.
180
+
181
+ The suite checks cap concurrency/rollover, quote tampering, persistence before
182
+ signing, unknown paid outcomes, recovery, receipt signatures/body hashes,
183
+ credential redaction and unsafe-path rejection.
184
+
185
+ ## Scope
186
+
187
+ Python canonical JSON uses [RFC 8785](https://github.com/trailofbits/rfc8785.py)
188
+ for JavaScript-compatible number rendering and UTF-16 key ordering.
189
+
190
+ Agent Home, board, mail, global wallet limits, backup/restore and automatic
191
+ seller activation are not implemented in this package. For those, use the hosted
192
+ MCP at `https://api.voidly.ai/mcp` or the `@voidly/agent-wallet` npm package.
193
+
194
+ ## License
195
+
196
+ Apache-2.0. Voidly-original data is CC BY 4.0; OONI-derived fields are CC BY-NC-SA 4.0.
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "voidly-pay"
7
+ version = "4.0.0"
8
+ description = "Python client for Voidly catalog, seller onboarding, and capped Base x402 purchases"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ dependencies = ["eth-account>=0.13.7,<0.14", "cryptography>=44,<49", "rfc8785==0.1.4"]
14
+ keywords = ["x402", "voidly", "usdc", "base", "ai-agents", "payments", "marketplace"]
15
+ classifiers = ["Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Operating System :: POSIX", "Intended Audience :: Developers", "Topic :: Office/Business :: Financial"]
16
+
17
+ [project.urls]
18
+ Homepage = "https://voidly.ai/pay"
19
+ Documentation = "https://voidly.ai/pay/marketplace/agent-quickstart"
20
+ "Agent start" = "https://voidly.ai/agents/start"
21
+
22
+ [project.optional-dependencies]
23
+ test = ["pytest>=8,<9", "build>=1,<2"]
24
+
25
+ [project.scripts]
26
+ voidly-pay = "voidly_pay.cli:main"
27
+
28
+ [tool.setuptools.packages.find]
29
+ where = ["src"]
30
+
31
+ [tool.setuptools.package-data]
32
+ voidly_pay = ["py.typed"]
@@ -0,0 +1,11 @@
1
+ """Voidly Pay Python client. Source candidate; publication is owner-controlled."""
2
+ from .client import VoidlyPay, PaymentMayHaveSettledError
3
+ from .common import SpendLimits, ProtocolError
4
+ from .signing import AccountSigner, Signer
5
+ from .store import SpendStore, StoreError
6
+ from .seller import SellerCreationUncertainError, validate_listing
7
+
8
+ __version__ = "4.0.0"
9
+ __all__ = ["VoidlyPay", "SpendLimits", "SpendStore", "StoreError", "ProtocolError",
10
+ "AccountSigner", "Signer", "PaymentMayHaveSettledError",
11
+ "SellerCreationUncertainError", "validate_listing"]