payperbyte-sdk 0.1.0__py3-none-any.whl

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.
byte/__init__.py ADDED
@@ -0,0 +1,53 @@
1
+ """
2
+ payperbyte-sdk — Python SDK for PayPerByte (the BYTE Library data layer).
3
+
4
+ Verified, provenance-first data for AI agents. No token; settlement is in
5
+ external USDC on Arbitrum. Three on-chain contracts: DataRegistry (publisher /
6
+ subscriber social registry), SchemaRegistry (feed schemas), and DataStream
7
+ (per-message settlement). Subscribers approve DataStream as a direct USDC
8
+ spender — there is no escrow contract. Keyless x402 payments (a wallet, not an
9
+ API key) for pay-per-call feed access via the gateway.
10
+
11
+ Usage:
12
+ from byte import (
13
+ Publisher, Subscriber, GatewayClient,
14
+ verify_payload, HashMismatchError, ARBITRUM_SEPOLIA,
15
+ )
16
+
17
+ # Publisher: register a schema + publisher (no token stake), then publish.
18
+ publisher = Publisher(private_key, ARBITRUM_SEPOLIA)
19
+ publisher.register("eth-price", schema)
20
+ publisher.publish(subscriber_addr, {"signal": "short"})
21
+
22
+ # Subscriber: register in the social registry + approve DataStream to pull
23
+ # per-message fees directly (no escrow / no deposit), then stream payloads.
24
+ subscriber = Subscriber(private_key, ARBITRUM_SEPOLIA)
25
+ subscriber.subscribe(publisher_addr, allowance_usdc=10.0)
26
+ async for msg in subscriber.stream():
27
+ payload = fetch_from_archive(msg["payload_hash"])
28
+ try:
29
+ verify_payload(payload, msg["payload_hash"]) # keccak256 vs attested hash
30
+ except HashMismatchError:
31
+ continue # do NOT consume mismatched bytes
32
+ consume(payload)
33
+
34
+ # Gateway: keyless x402 pay-per-call (a wallet signs EIP-3009; no API key).
35
+ from eth_account import Account
36
+ gw = GatewayClient(account=Account.from_key(private_key))
37
+ result = gw.fetch_feed("crypto-top100")
38
+ """
39
+
40
+ from byte.publisher import Publisher
41
+ from byte.subscriber import Subscriber
42
+ from byte.mercat import Mercat
43
+ from byte.client import ByteClient
44
+ from byte.gateway import GatewayClient
45
+ from byte.networks import ARBITRUM_SEPOLIA, ARBITRUM_ONE, LOCAL_ANVIL
46
+ from byte.verify import (
47
+ verify_payload, verify_event_payload, fetch_and_verify, HashMismatchError,
48
+ )
49
+
50
+ __all__ = ["Publisher", "Subscriber", "Mercat", "ByteClient", "GatewayClient",
51
+ "ARBITRUM_SEPOLIA", "ARBITRUM_ONE", "LOCAL_ANVIL",
52
+ "verify_payload", "verify_event_payload", "fetch_and_verify",
53
+ "HashMismatchError"]
@@ -0,0 +1,341 @@
1
+ [
2
+ {
3
+ "type": "constructor",
4
+ "inputs": [
5
+ {
6
+ "name": "_settlementToken",
7
+ "type": "address",
8
+ "internalType": "address"
9
+ },
10
+ {
11
+ "name": "_schemaRegistry",
12
+ "type": "address",
13
+ "internalType": "address"
14
+ },
15
+ {
16
+ "name": "_admin",
17
+ "type": "address",
18
+ "internalType": "address"
19
+ }
20
+ ],
21
+ "stateMutability": "nonpayable"
22
+ },
23
+ {
24
+ "type": "function",
25
+ "name": "deregister",
26
+ "inputs": [],
27
+ "outputs": [],
28
+ "stateMutability": "nonpayable"
29
+ },
30
+ {
31
+ "type": "function",
32
+ "name": "getPublisher",
33
+ "inputs": [
34
+ {
35
+ "name": "publisher",
36
+ "type": "address",
37
+ "internalType": "address"
38
+ }
39
+ ],
40
+ "outputs": [
41
+ {
42
+ "name": "",
43
+ "type": "tuple",
44
+ "internalType": "struct DataRegistryLib.Publisher",
45
+ "components": [
46
+ {
47
+ "name": "status",
48
+ "type": "uint8",
49
+ "internalType": "enum DataRegistryLib.PublisherStatus"
50
+ },
51
+ {
52
+ "name": "tier",
53
+ "type": "uint8",
54
+ "internalType": "enum DataRegistryLib.Tier"
55
+ },
56
+ {
57
+ "name": "stakedAmount",
58
+ "type": "uint256",
59
+ "internalType": "uint256"
60
+ },
61
+ {
62
+ "name": "sandboxStartTime",
63
+ "type": "uint256",
64
+ "internalType": "uint256"
65
+ },
66
+ {
67
+ "name": "registeredAt",
68
+ "type": "uint256",
69
+ "internalType": "uint256"
70
+ },
71
+ {
72
+ "name": "subscriberCount",
73
+ "type": "uint256",
74
+ "internalType": "uint256"
75
+ },
76
+ {
77
+ "name": "messageCount",
78
+ "type": "uint256",
79
+ "internalType": "uint256"
80
+ },
81
+ {
82
+ "name": "totalRevenue",
83
+ "type": "uint256",
84
+ "internalType": "uint256"
85
+ },
86
+ {
87
+ "name": "lastActiveTimestamp",
88
+ "type": "uint256",
89
+ "internalType": "uint256"
90
+ },
91
+ {
92
+ "name": "publicKey",
93
+ "type": "bytes32",
94
+ "internalType": "bytes32"
95
+ },
96
+ {
97
+ "name": "slashCount",
98
+ "type": "uint256",
99
+ "internalType": "uint256"
100
+ }
101
+ ]
102
+ }
103
+ ],
104
+ "stateMutability": "view"
105
+ },
106
+ {
107
+ "type": "function",
108
+ "name": "getPublisherStatus",
109
+ "inputs": [
110
+ {
111
+ "name": "publisher",
112
+ "type": "address",
113
+ "internalType": "address"
114
+ }
115
+ ],
116
+ "outputs": [
117
+ {
118
+ "name": "",
119
+ "type": "uint8",
120
+ "internalType": "enum DataRegistry.PublisherStatus"
121
+ }
122
+ ],
123
+ "stateMutability": "view"
124
+ },
125
+ {
126
+ "type": "function",
127
+ "name": "getSubscriberCount",
128
+ "inputs": [
129
+ {
130
+ "name": "publisher",
131
+ "type": "address",
132
+ "internalType": "address"
133
+ }
134
+ ],
135
+ "outputs": [
136
+ {
137
+ "name": "",
138
+ "type": "uint256",
139
+ "internalType": "uint256"
140
+ }
141
+ ],
142
+ "stateMutability": "view"
143
+ },
144
+ {
145
+ "type": "function",
146
+ "name": "graduateFromSandbox",
147
+ "inputs": [],
148
+ "outputs": [],
149
+ "stateMutability": "nonpayable"
150
+ },
151
+ {
152
+ "type": "function",
153
+ "name": "isSandbox",
154
+ "inputs": [
155
+ {
156
+ "name": "publisher",
157
+ "type": "address",
158
+ "internalType": "address"
159
+ }
160
+ ],
161
+ "outputs": [
162
+ {
163
+ "name": "",
164
+ "type": "bool",
165
+ "internalType": "bool"
166
+ }
167
+ ],
168
+ "stateMutability": "view"
169
+ },
170
+ {
171
+ "type": "function",
172
+ "name": "isSubscribed",
173
+ "inputs": [
174
+ {
175
+ "name": "subscriber",
176
+ "type": "address",
177
+ "internalType": "address"
178
+ },
179
+ {
180
+ "name": "publisher",
181
+ "type": "address",
182
+ "internalType": "address"
183
+ }
184
+ ],
185
+ "outputs": [
186
+ {
187
+ "name": "",
188
+ "type": "bool",
189
+ "internalType": "bool"
190
+ }
191
+ ],
192
+ "stateMutability": "view"
193
+ },
194
+ {
195
+ "type": "function",
196
+ "name": "publisherCount",
197
+ "inputs": [],
198
+ "outputs": [
199
+ {
200
+ "name": "",
201
+ "type": "uint256",
202
+ "internalType": "uint256"
203
+ }
204
+ ],
205
+ "stateMutability": "view"
206
+ },
207
+ {
208
+ "type": "function",
209
+ "name": "registerPublisher",
210
+ "inputs": [
211
+ {
212
+ "name": "amount",
213
+ "type": "uint256",
214
+ "internalType": "uint256"
215
+ },
216
+ {
217
+ "name": "publicKey",
218
+ "type": "bytes32",
219
+ "internalType": "bytes32"
220
+ }
221
+ ],
222
+ "outputs": [],
223
+ "stateMutability": "nonpayable"
224
+ },
225
+ {
226
+ "type": "function",
227
+ "name": "subscribe",
228
+ "inputs": [
229
+ {
230
+ "name": "publisher",
231
+ "type": "address",
232
+ "internalType": "address"
233
+ }
234
+ ],
235
+ "outputs": [],
236
+ "stateMutability": "nonpayable"
237
+ },
238
+ {
239
+ "type": "function",
240
+ "name": "unsubscribe",
241
+ "inputs": [
242
+ {
243
+ "name": "publisher",
244
+ "type": "address",
245
+ "internalType": "address"
246
+ }
247
+ ],
248
+ "outputs": [],
249
+ "stateMutability": "nonpayable"
250
+ },
251
+ {
252
+ "type": "function",
253
+ "name": "updateLastActive",
254
+ "inputs": [
255
+ {
256
+ "name": "publisher",
257
+ "type": "address",
258
+ "internalType": "address"
259
+ }
260
+ ],
261
+ "outputs": [],
262
+ "stateMutability": "nonpayable"
263
+ },
264
+ {
265
+ "type": "function",
266
+ "name": "updatePublicKey",
267
+ "inputs": [
268
+ {
269
+ "name": "newKey",
270
+ "type": "bytes32",
271
+ "internalType": "bytes32"
272
+ }
273
+ ],
274
+ "outputs": [],
275
+ "stateMutability": "nonpayable"
276
+ },
277
+ {
278
+ "type": "event",
279
+ "name": "PublicKeyUpdated",
280
+ "inputs": [
281
+ {
282
+ "name": "publisher",
283
+ "type": "address",
284
+ "indexed": true,
285
+ "internalType": "address"
286
+ },
287
+ {
288
+ "name": "newKey",
289
+ "type": "bytes32",
290
+ "indexed": false,
291
+ "internalType": "bytes32"
292
+ }
293
+ ],
294
+ "anonymous": false
295
+ },
296
+ {
297
+ "type": "event",
298
+ "name": "PublisherRegistered",
299
+ "inputs": [
300
+ {
301
+ "name": "publisher",
302
+ "type": "address",
303
+ "indexed": true,
304
+ "internalType": "address"
305
+ },
306
+ {
307
+ "name": "amount",
308
+ "type": "uint256",
309
+ "indexed": false,
310
+ "internalType": "uint256"
311
+ },
312
+ {
313
+ "name": "publicKey",
314
+ "type": "bytes32",
315
+ "indexed": false,
316
+ "internalType": "bytes32"
317
+ }
318
+ ],
319
+ "anonymous": false
320
+ },
321
+ {
322
+ "type": "error",
323
+ "name": "AlreadyRegistered",
324
+ "inputs": []
325
+ },
326
+ {
327
+ "type": "error",
328
+ "name": "AlreadySubscribed",
329
+ "inputs": []
330
+ },
331
+ {
332
+ "type": "error",
333
+ "name": "NotRegistered",
334
+ "inputs": []
335
+ },
336
+ {
337
+ "type": "error",
338
+ "name": "NotSubscribed",
339
+ "inputs": []
340
+ }
341
+ ]