@fangorn-network/sdk 2026.3.11 → 2026.3.28
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.
- package/README.md +311 -198
- package/lib/builders/a2aCardBuilder.js +1 -0
- package/lib/cli/cli.d.ts +0 -0
- package/lib/cli/cli.js +399 -380
- package/lib/cli/index.d.ts +170 -170
- package/lib/cli/index.js +1 -4
- package/lib/config.d.ts +543 -163
- package/lib/config.js +11 -8
- package/lib/fangorn.d.ts +31 -43
- package/lib/fangorn.js +101 -117
- package/lib/index.d.ts +8 -5
- package/lib/index.js +8 -7
- package/lib/modules/encryption/index.d.ts +4 -3
- package/lib/modules/encryption/lit.d.ts +3 -18
- package/lib/modules/encryption/lit.js +20 -49
- package/lib/modules/encryption/rand.js +2 -2
- package/lib/modules/encryption/types.d.ts +23 -8
- package/lib/modules/gadgets/settledGadget.d.ts +31 -0
- package/lib/modules/gadgets/settledGadget.js +75 -0
- package/lib/modules/gadgets/types.d.ts +16 -4
- package/lib/providers/storage/index.d.ts +15 -4
- package/lib/providers/storage/pinata/index.d.ts +5 -4
- package/lib/providers/storage/pinata/index.js +17 -2
- package/lib/providers/storage/storacha/index.d.ts +13 -0
- package/lib/providers/storage/storacha/index.js +49 -0
- package/lib/providers/storage/storacha/readOnly.d.ts +8 -0
- package/lib/providers/storage/storacha/readOnly.js +16 -0
- package/lib/{interface → registries}/datasource-registry/abi.d.ts +29 -43
- package/lib/registries/datasource-registry/abi.js +16 -0
- package/lib/registries/datasource-registry/index.d.ts +24 -0
- package/lib/{interface/datasource-registry/dataSourceRegistry.js → registries/datasource-registry/index.js} +35 -34
- package/lib/registries/index.d.ts +3 -0
- package/lib/registries/index.js +4 -0
- package/lib/registries/schema-registry/abi.d.ts +127 -0
- package/lib/registries/schema-registry/abi.js +19 -0
- package/lib/registries/schema-registry/index.d.ts +29 -0
- package/lib/registries/schema-registry/index.js +114 -0
- package/lib/registries/settlement-registry/abi.d.ts +228 -0
- package/lib/registries/settlement-registry/abi.js +29 -0
- package/lib/registries/settlement-registry/index.d.ts +72 -0
- package/lib/registries/settlement-registry/index.js +316 -0
- package/lib/registries/settlement-registry/types.d.ts +51 -0
- package/lib/roles/consumer/index.d.ts +64 -0
- package/lib/roles/consumer/index.js +114 -0
- package/lib/roles/consumer/types.d.ts +66 -0
- package/lib/roles/index.js +1 -0
- package/lib/roles/publisher/index.d.ts +68 -0
- package/lib/roles/publisher/index.js +205 -0
- package/lib/roles/publisher/types.d.ts +93 -0
- package/lib/roles/publisher/types.js +1 -0
- package/lib/roles/schema/index.d.ts +44 -0
- package/lib/roles/schema/index.js +137 -0
- package/lib/roles/schema/types.d.ts +67 -0
- package/lib/roles/schema/types.js +1 -0
- package/lib/test/index.d.ts +5 -2
- package/lib/test/index.js +5 -3
- package/lib/test/testbed.d.ts +52 -32
- package/lib/test/testbed.js +138 -137
- package/lib/types/index.d.ts +65 -21
- package/lib/types/index.js +1 -12
- package/lib/utils/index.d.ts +2 -3
- package/lib/utils/index.js +4 -18
- package/package.json +85 -81
- package/lib/cli/registry.d.ts +0 -29
- package/lib/cli/registry.js +0 -53
- package/lib/deployContract.d.ts +0 -23
- package/lib/deployContract.js +0 -78
- package/lib/interface/datasource-registry/abi.js +0 -110
- package/lib/interface/datasource-registry/dataSourceRegistry.d.ts +0 -24
- package/lib/interface/index.d.ts +0 -3
- package/lib/interface/index.js +0 -4
- package/lib/interface/manifest.d.ts +0 -7
- package/lib/interface/manifest.js +0 -10
- package/lib/interface/settlement-tracker/abi.d.ts +0 -26
- package/lib/interface/settlement-tracker/abi.js +0 -88
- package/lib/interface/settlement-tracker/settlementTracker.d.ts +0 -32
- package/lib/interface/settlement-tracker/settlementTracker.js +0 -64
- package/lib/modules/gadgets/acc/gadgets.d.ts +0 -7
- package/lib/modules/gadgets/acc/gadgets.js +0 -10
- package/lib/modules/gadgets/acc.d.ts +0 -15
- package/lib/modules/gadgets/acc.js +0 -24
- package/lib/modules/gadgets/builder.d.ts +0 -1
- package/lib/modules/gadgets/payment.d.ts +0 -23
- package/lib/modules/gadgets/payment.js +0 -88
- package/lib/test/test-gadget.d.ts +0 -7
- package/lib/test/test-gadget.js +0 -10
- /package/lib/{modules/gadgets/builder.js → registries/settlement-registry/types.js} +0 -0
- /package/lib/{providers/storage/s3/index.js → roles/consumer/types.js} +0 -0
- /package/lib/{providers/storage/s3 → roles}/index.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,276 +1,389 @@
|
|
|
1
|
-
# Fangorn
|
|
1
|
+
# Fangorn SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Intent-bound encrypted data for the agentic web.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Fangorn is a programmable data framework that lets you **register datasources** and **publish encrypted data** under public conditions, or predicates, such that it can only be decrypted if you meet the condition(s).
|
|
5
|
+
Fangorn lets you publish data encrypted under programmable access conditions — called **gadgets** — so it can only be decrypted by a party that satisfies them. Data is organized by **schemas**, enabling agent-based discovery across any number of publishers.
|
|
8
6
|
|
|
9
7
|
## Supported Networks
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
Arbitrum Sepolia (Base Sepolia in progress).
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
---
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## Installation
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
```sh
|
|
16
|
+
npm i @fangorn-network/sdk
|
|
17
|
+
```
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
---
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
## CLI Quickstart
|
|
22
|
+
|
|
23
|
+
Install globally and initialize:
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
```sh
|
|
26
|
+
npm i -g @fangorn-network/sdk
|
|
27
|
+
fangorn init
|
|
28
|
+
```
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
- `fangorn init` prompts for a wallet private key, Pinata JWT, Pinata gateway URL, and default chain. Config is written to `~/.fangorn/config.json`.
|
|
31
|
+
- You can also configure via environment variables instead of `fangorn init`:
|
|
28
32
|
|
|
29
33
|
```sh
|
|
30
|
-
|
|
34
|
+
DELEGATOR_ETH_PRIVATE_KEY=0x...
|
|
35
|
+
# if you use pinata over storacha
|
|
36
|
+
PINATA_JWT=...
|
|
37
|
+
PINATA_GATEWAY=https://your-gateway.mypinata.cloud
|
|
38
|
+
# else email for storacha
|
|
39
|
+
STORACHA_EMAIL=...
|
|
40
|
+
CHAIN_NAME=arbitrumSepolia
|
|
31
41
|
```
|
|
32
42
|
|
|
33
|
-
###
|
|
43
|
+
### Register a Schema
|
|
34
44
|
|
|
35
|
-
|
|
45
|
+
```sh
|
|
46
|
+
# Registers an ERC-8004 agent identity and a schema
|
|
47
|
+
fangorn schema register <name>
|
|
36
48
|
|
|
37
|
-
|
|
49
|
+
# Skip agent registration
|
|
50
|
+
fangorn schema register <name> --skip-erc
|
|
51
|
+
|
|
52
|
+
# Fetch a registered schema by name
|
|
53
|
+
fangorn schema get schema.name.v1
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Publish Data
|
|
38
57
|
|
|
39
58
|
```sh
|
|
40
|
-
|
|
59
|
+
# Encrypt and publish files under a schema, priced at 1 USDC unit
|
|
60
|
+
fangorn publish upload file.ext -s schema.name.v1 -p 1
|
|
61
|
+
|
|
62
|
+
# List your manifest entries for a schema
|
|
63
|
+
fangorn publish list -s schema.name.v1
|
|
64
|
+
|
|
65
|
+
# Inspect a specific entry
|
|
66
|
+
fangorn publish entry track1 -s schema.name.v1
|
|
41
67
|
```
|
|
42
68
|
|
|
43
|
-
|
|
69
|
+
> A price of `1` equals the smallest USDC unit (0.000001 USDC).
|
|
70
|
+
|
|
71
|
+
### Consume Data
|
|
72
|
+
|
|
73
|
+
The consumer flow is three phases: **purchase => claim => decrypt**.
|
|
44
74
|
|
|
45
75
|
```sh
|
|
46
|
-
|
|
76
|
+
# Phase 1: pay and join the sempaphore group group
|
|
77
|
+
fangorn consume purchase <owner> <tag> \
|
|
78
|
+
-s schema.name.v1 \
|
|
79
|
+
--burner-key 0x... \
|
|
80
|
+
--amount 1 \
|
|
81
|
+
--usdc 0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d
|
|
82
|
+
|
|
83
|
+
# Save the identity string printed by purchase — required for the next steps.
|
|
84
|
+
|
|
85
|
+
# Phase 2: prove membership and claim access (generates a Groth16 ZK proof)
|
|
86
|
+
fangorn consume claim <owner> <tag> \
|
|
87
|
+
-s schema.name.v1 \
|
|
88
|
+
--identity '<identity-string>' \
|
|
89
|
+
--stealth <stealth-address>
|
|
90
|
+
|
|
91
|
+
# Phase 3: decrypt a specific field
|
|
92
|
+
fangorn consume decrypt <owner> <tag> \
|
|
93
|
+
-s schema.name.v1 \
|
|
94
|
+
-f audio \
|
|
95
|
+
--nullifier <nullifier> \
|
|
96
|
+
--stealth-key 0x... \
|
|
97
|
+
-o output.mp3
|
|
98
|
+
|
|
99
|
+
# List a publisher's manifest
|
|
100
|
+
fangorn consume list -s schema.name.v1 --owner <address>
|
|
101
|
+
|
|
102
|
+
# Inspect a publisher's entry
|
|
103
|
+
fangorn consume entry track1 -s schema.name.v1 --owner <address>
|
|
47
104
|
```
|
|
48
105
|
|
|
49
|
-
|
|
106
|
+
---
|
|
50
107
|
|
|
51
|
-
|
|
108
|
+
## SDK Usage
|
|
52
109
|
|
|
53
|
-
|
|
110
|
+
### Initialization
|
|
54
111
|
|
|
55
|
-
|
|
112
|
+
```ts
|
|
113
|
+
import { Fangorn, FangornConfig } from "@fangorn-network/sdk";
|
|
56
114
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
chain,
|
|
115
|
+
const fangorn = await Fangorn.create({
|
|
116
|
+
privateKey: "0x...",
|
|
117
|
+
storage: { pinata: { jwt: "...", gateway: "https://your-gateway.mypinata.cloud" } },
|
|
118
|
+
encryption: { lit: true },
|
|
119
|
+
config: FangornConfig.ArbitrumSepolia,
|
|
120
|
+
domain: "localhost",
|
|
64
121
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Storage options:**
|
|
125
|
+
|
|
126
|
+
| Config | Mode |
|
|
127
|
+
|---|---|
|
|
128
|
+
| `{ pinata: { jwt, gateway } }` | Read + write |
|
|
129
|
+
| `{ storacha: { email } }` | Read + write |
|
|
130
|
+
| `{ storacha: { readOnly: true } }` | Read only |
|
|
131
|
+
|
|
132
|
+
### Schemas
|
|
133
|
+
|
|
134
|
+
A `SchemaDefinition` is a JSON object where each field declares its type. Fields marked `@type: "encrypted"` are automatically encrypted by the SDK at publish time. All other fields are stored in plaintext. The `gadget` hint on an encrypted field tells the SDK which access condition to apply.
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
// Define a schema
|
|
138
|
+
const definition: SchemaDefinition = {
|
|
139
|
+
title: { "@type": "string" },
|
|
140
|
+
artist: { "@type": "string" },
|
|
141
|
+
audio: { "@type": "encrypted", gadget: "settled" }, // field-level encryption
|
|
142
|
+
cover: { "@type": "file" }, // plaintext
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Register an ERC-8004 agent identity
|
|
146
|
+
const { agentId } = await fangorn.schema.registerAgent({
|
|
147
|
+
name: "schema.agent.name.v1",
|
|
148
|
+
description: "Music streaming data source agent",
|
|
74
149
|
});
|
|
75
|
-
// we only support pinata right now, more to come
|
|
76
|
-
const storage = new PinataStorage(pinata);
|
|
77
150
|
|
|
78
|
-
// the
|
|
79
|
-
const
|
|
151
|
+
// Register the schema on-chain
|
|
152
|
+
const { schemaId, schemaCid } = await fangorn.schema.register({
|
|
153
|
+
name: "schema.name.v1",
|
|
154
|
+
definition,
|
|
155
|
+
agentId,
|
|
156
|
+
});
|
|
80
157
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
158
|
+
// Fetch a schema by name
|
|
159
|
+
const schema = await fangorn.schema.get("schema.name.v1");
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
When a record conforming to this schema is published, Fangorn encrypts each `@type: "encrypted"` field and replaces its value with a ciphertext handle and a gadget descriptor:
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
// Input record
|
|
166
|
+
{
|
|
167
|
+
"tag": "track1",
|
|
168
|
+
"fields": {
|
|
169
|
+
"title": "Cassini Division",
|
|
170
|
+
"artist": "Arca",
|
|
171
|
+
"audio": { "data": "<bytes>", "fileType": "audio/mp3" }
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Stored manifest entry (audio field encrypted)
|
|
176
|
+
{
|
|
177
|
+
"tag": "track1",
|
|
178
|
+
"fields": {
|
|
179
|
+
"title": "Cassini Division",
|
|
180
|
+
"artist": "Arca",
|
|
181
|
+
"audio": {
|
|
182
|
+
"@type": "encrypted",
|
|
183
|
+
"handle": {
|
|
184
|
+
"cid": "bafkrei...",
|
|
185
|
+
"gateway": "your-gateway.mypinata.cloud"
|
|
186
|
+
},
|
|
187
|
+
"gadgetDescriptor": {
|
|
188
|
+
"type": "settled",
|
|
189
|
+
"description": "Settlement-gated: SettlementRegistry.isSettled(resourceId, caller)",
|
|
190
|
+
"params": {
|
|
191
|
+
"resourceId": "0xce16c0...",
|
|
192
|
+
"settlementRegistryAddress": "0x4536881306ee355c2f18ae81658771c4488139a3",
|
|
193
|
+
"chainName": "arbitrumSepolia"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
The `gadgetDescriptor` is human- and agent-readable: it describes exactly what a consumer must do to unlock the field. Plaintext fields (`title`, `artist`) remain directly readable in the manifest without any purchase flow.
|
|
202
|
+
|
|
203
|
+
### Publishing
|
|
204
|
+
|
|
205
|
+
Each upload encrypts files via the gadget returned by `gadgetFactory`, pins the manifest to IPFS, and commits the new CID on-chain. Subsequent uploads merge with the existing manifest unless `overwrite` is set.
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
import { SettledGadget } from "@fangorn-network/sdk/gadgets";
|
|
209
|
+
import { SettlementRegistry } from "@fangorn-network/sdk/registries";
|
|
210
|
+
|
|
211
|
+
const owner = fangorn.getAddress();
|
|
212
|
+
|
|
213
|
+
await fangorn.publisher.upload(
|
|
214
|
+
{
|
|
215
|
+
records: [
|
|
216
|
+
{ tag: "track1", field: "audio", data: audioBytes, extension: ".mp3", fileType: "audio/mpeg" },
|
|
217
|
+
{ tag: "track1", field: "cover", data: imageBytes, extension: ".png", fileType: "image/png" },
|
|
218
|
+
],
|
|
219
|
+
schema: schemaDefinition,
|
|
220
|
+
schemaId,
|
|
221
|
+
gateway: "https://your-gateway.mypinata.cloud",
|
|
222
|
+
gadgetFactory: (tag) =>
|
|
223
|
+
new SettledGadget({
|
|
224
|
+
resourceId: SettlementRegistry.deriveResourceId(owner, schemaId, tag),
|
|
225
|
+
settlementRegistryAddress: FangornConfig.ArbitrumSepolia.settlementRegistryContractAddress,
|
|
226
|
+
chainName: "arbitrumSepolia",
|
|
227
|
+
pinataJwt: "...",
|
|
228
|
+
}),
|
|
229
|
+
},
|
|
230
|
+
1n, // price in smallest USDC units
|
|
87
231
|
);
|
|
88
232
|
```
|
|
89
233
|
|
|
90
|
-
###
|
|
234
|
+
### Consuming
|
|
91
235
|
|
|
92
|
-
|
|
236
|
+
#### Phase 1: Purchase
|
|
93
237
|
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
```
|
|
238
|
+
```ts
|
|
239
|
+
import { Identity } from "@semaphore-protocol/identity";
|
|
240
|
+
|
|
241
|
+
const identity = new Identity();
|
|
99
242
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
- payment: must submit a specific payment to decrypt
|
|
109
|
-
|
|
110
|
-
```js
|
|
111
|
-
// configure data using a json array, note that all data in this array will be encrypted under the same condition
|
|
112
|
-
// each entry has as (tag, data, extension, fileTpe)
|
|
113
|
-
let filedata = [
|
|
114
|
-
{
|
|
115
|
-
tag: "test0",
|
|
116
|
-
data: "content0",
|
|
117
|
-
extension: ".txt",
|
|
118
|
-
fileType: "text/plain",
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
tag: "test1",
|
|
122
|
-
data: "content1",
|
|
123
|
-
extension: ".png",
|
|
124
|
-
fileType: "image/png",
|
|
125
|
-
},
|
|
126
|
-
];
|
|
127
|
-
|
|
128
|
-
// this encrypts the file under a USDC payment condition, useful for x402
|
|
129
|
-
await fangorn.upload(datasourceName, filedata, async (file) => {
|
|
130
|
-
const commitment = await computeTagCommitment(
|
|
131
|
-
this.delegatorAddress,
|
|
132
|
-
datasourceName,
|
|
133
|
-
file.tag,
|
|
134
|
-
usdcPrice,
|
|
135
|
-
);
|
|
136
|
-
return new PaymentGadget({
|
|
137
|
-
commitment: fieldToHex(commitment),
|
|
138
|
-
chainName: this.config.chainName,
|
|
139
|
-
settlementTrackerContractAddress,
|
|
140
|
-
usdcPrice,
|
|
141
|
-
});
|
|
243
|
+
// Sign ERC-3009 authorization with the burner wallet
|
|
244
|
+
const preparedRegister = await fangorn.consumer.prepareRegister({
|
|
245
|
+
burnerPrivateKey: "0x...",
|
|
246
|
+
paymentRecipient: ownerAddress,
|
|
247
|
+
amount: 1n,
|
|
248
|
+
usdcAddress: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
|
|
249
|
+
usdcDomainName: "USD Coin",
|
|
250
|
+
usdcDomainVersion: "2",
|
|
142
251
|
});
|
|
252
|
+
|
|
253
|
+
// Submit payment and join the Semaphore group
|
|
254
|
+
const { txHash } = await fangorn.consumer.register({
|
|
255
|
+
owner: ownerAddress,
|
|
256
|
+
schemaId,
|
|
257
|
+
tag: "track1",
|
|
258
|
+
identityCommitment: identity.commitment,
|
|
259
|
+
relayerPrivateKey: "0x...",
|
|
260
|
+
preparedRegister,
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// Save identity.export(). Required for Phase 2 and 3
|
|
143
264
|
```
|
|
144
265
|
|
|
145
|
-
|
|
266
|
+
#### Phase 2: Claim
|
|
146
267
|
|
|
147
|
-
|
|
268
|
+
```ts
|
|
269
|
+
// Generate Groth16 ZK proof of group membership
|
|
270
|
+
const preparedSettle = await fangorn.consumer.prepareSettle({
|
|
271
|
+
resourceId: SettlementRegistry.deriveResourceId(ownerAddress, schemaId, "track1"),
|
|
272
|
+
identity,
|
|
273
|
+
stealthAddress: "0x...",
|
|
274
|
+
});
|
|
148
275
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
276
|
+
// Submit the proof and trigger the hook call (if configured)
|
|
277
|
+
const { txHash, nullifier } = await fangorn.consumer.claim({
|
|
278
|
+
owner: ownerAddress,
|
|
279
|
+
schemaId,
|
|
280
|
+
tag: "track1",
|
|
281
|
+
relayerPrivateKey: "0x...",
|
|
282
|
+
preparedSettle,
|
|
283
|
+
});
|
|
156
284
|
|
|
157
|
-
|
|
158
|
-
const outputAsString = new TextDecoder().decode(output);
|
|
159
|
-
console.log("we got the plaintext " + outputAsString);
|
|
285
|
+
// Store nullifier. required for Phase 3.
|
|
160
286
|
```
|
|
161
287
|
|
|
162
|
-
|
|
288
|
+
#### Phase 3: Decrypt
|
|
163
289
|
|
|
164
|
-
|
|
290
|
+
```ts
|
|
291
|
+
import { createWalletClient, http } from "viem";
|
|
292
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
293
|
+
import { arbitrumSepolia } from "viem/chains";
|
|
165
294
|
|
|
166
|
-
|
|
295
|
+
const walletClient = createWalletClient({
|
|
296
|
+
account: privateKeyToAccount(stealthPrivateKey),
|
|
297
|
+
chain: arbitrumSepolia,
|
|
298
|
+
transport: http(rpcUrl),
|
|
299
|
+
});
|
|
167
300
|
|
|
168
|
-
|
|
169
|
-
|
|
301
|
+
const plaintext = await fangorn.consumer.decrypt({
|
|
302
|
+
owner: ownerAddress,
|
|
303
|
+
walletClient,
|
|
304
|
+
schemaId,
|
|
305
|
+
nullifierHash: nullifier,
|
|
306
|
+
tag: "track1",
|
|
307
|
+
field: "audio",
|
|
308
|
+
identity,
|
|
309
|
+
});
|
|
170
310
|
```
|
|
171
311
|
|
|
172
|
-
###
|
|
312
|
+
### Gadgets
|
|
173
313
|
|
|
174
|
-
|
|
314
|
+
Gadgets define the access control condition baked into encryption. Built-in gadgets:
|
|
175
315
|
|
|
176
|
-
|
|
316
|
+
| Gadget | Condition |
|
|
317
|
+
|---|---|
|
|
318
|
+
| `SettledGadget` | Caller must complete a USDC payment + ZK claim flow |
|
|
177
319
|
|
|
178
|
-
|
|
320
|
+
More coming soon ;)
|
|
179
321
|
|
|
180
|
-
|
|
181
|
-
2. Fill in the ENVs:
|
|
182
|
-
- `DELEGATOR_ETH_PRIVATE_KEY`: The private key of the delegator account
|
|
183
|
-
- Needs to have a balance of test ETH to send transactions
|
|
184
|
-
- `DELEGATEE_ETH_PRIVATE_KEY`: The private key of the delegatee account
|
|
185
|
-
- Needs to have a balance of test ETH to send transactions
|
|
322
|
+
See the [gadgets](./src/modules/gadgets/README.md) docs for details on implementing your own gadgets.
|
|
186
323
|
|
|
187
|
-
|
|
188
|
-
- Can be obtained from: https://app.pinata.cloud/developers/api-keys
|
|
189
|
-
- `PINATA_GATEWAY`: The gateway for Pinata
|
|
190
|
-
- Can use your own gateway or the default 'https://gateway.pinata.cloud'
|
|
191
|
-
- `CHAIN_NAME`: arbitrumSepolia or baseSepolia
|
|
192
|
-
- `CAIP2`: The CAIP-2 identifier for the network.
|
|
193
|
-
- 421614 for Arbitrum Sepolia, 84532 for Base Sepolia
|
|
194
|
-
- `CHAIN_RPC_URL`: The RPC URL of the chain
|
|
195
|
-
- Expected to be Base sepolia testnet: https://base-sepolia-public.nodies.app or Arbitrum Sepolia: https://sepolia-rollup.arbitrum.io/rpc
|
|
196
|
-
- `USDC_CONTRACT_ADDRESS`: The address of the deployed USDC contract
|
|
197
|
-
- 0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d for Arbitrum Sepolia 0x036CbD53842c5426634e7929541eC2318f3dCF7e for Base Sepolia
|
|
198
|
-
- `DS_REGISTRY_ADDR`: The address of the deployed data registry contract
|
|
199
|
-
- Can be deployed by the test script, else use 0x5bd547ce3b5964c2fc0325f523679f66de391d6f for Arbitrum Sepolia and 0x6fd0e50073dbd8169bcaf066bb4a4991bfa48eeb on Base Sepolia
|
|
200
|
-
- `SETTLEMENT_TRACKER_ADDR`: The address of the deployed settlement tracker contract address. This is only needed if you plan to run tests using the payment gadget.
|
|
201
|
-
- Can be deployed by the test script, else use 0x7c6ae9eb3398234eb69b2f3acfae69065505ff69 for Arbitrum Sepolia
|
|
324
|
+
---
|
|
202
325
|
|
|
203
|
-
|
|
326
|
+
## Contracts
|
|
204
327
|
|
|
205
|
-
|
|
328
|
+
### Arbitrum Sepolia
|
|
206
329
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
DS_REGISTRY_ADDR=0x602aedafe1096004d4db591b6537bc39d7ac71a6
|
|
213
|
-
SETTLEMENT_TRACKER_ADDR=0x7c6ae9eb3398234eb69b2f3acfae69065505ff69
|
|
214
|
-
```
|
|
330
|
+
| Contract | Address |
|
|
331
|
+
|---|---|
|
|
332
|
+
| DataSource Registry | `0x3941c7d50caa56f7f676554bc4e78d77aaf27ebb` |
|
|
333
|
+
| Schema Registry | `0x49ab3d52b997e63ad56c91178df48263fd80b2dc` |
|
|
334
|
+
| Settlement Registry | `0x4536881306ee355c2f18ae81658771c4488139a3` |
|
|
215
335
|
|
|
216
|
-
|
|
336
|
+
---
|
|
217
337
|
|
|
218
|
-
|
|
219
|
-
CHAIN_NAME=baseSepolia
|
|
220
|
-
CAIP2=84532
|
|
221
|
-
CHAIN_RPC_URL=https://base-sepolia-public.nodies.app
|
|
222
|
-
USDC_CONTRACT_ADDRESS=0x036CbD53842c5426634e7929541eC2318f3dCF7e
|
|
223
|
-
DS_REGISTRY_ADDR=0x6fd0e50073dbd8169bcaf066bb4a4991bfa48eeb
|
|
224
|
-
SETTLEMENT_TRACKER_ADDR=0x708751829f5f5f584da4142b62cd5cc9235c8a18
|
|
225
|
-
```
|
|
338
|
+
## Testing
|
|
226
339
|
|
|
227
|
-
###
|
|
340
|
+
### Unit Tests
|
|
228
341
|
|
|
229
|
-
|
|
342
|
+
```sh
|
|
343
|
+
pnpm test
|
|
344
|
+
```
|
|
230
345
|
|
|
231
|
-
|
|
346
|
+
### E2E Tests
|
|
232
347
|
|
|
233
|
-
|
|
234
|
-
2. Upload the Lit Action to IPFS (unless it is defined in .env)
|
|
348
|
+
Copy the example env and fill in values:
|
|
235
349
|
|
|
236
|
-
|
|
350
|
+
```sh
|
|
351
|
+
cp env.example .env
|
|
352
|
+
pnpm test:e2e
|
|
353
|
+
```
|
|
237
354
|
|
|
238
|
-
|
|
239
|
-
| -------------------------------------- | ------------------------------------------------------------ | -------------------------------------------------------------- |
|
|
240
|
-
| Datsource Registry Contract Deployment | 0x602aedafe1096004d4db591b6537bc39d7ac71a6 | 0x6fd0e50073dbd8169bcaf066bb4a4991bfa48eeb |
|
|
241
|
-
| Datsource Registry Contract Code | [lib.rs](./contracts/arbitrum/DatasourceRegistry/src/lib.rs) | [DSRegistry.sol](./contracts/src/DSRegistry.sol) |
|
|
242
|
-
| Settlement Tracker Contract Deployment | 0x7c6ae9eb3398234eb69b2f3acfae69065505ff69 | 0x708751829f5f5f584da4142b62cd5cc9235c8a18 |
|
|
243
|
-
| Settlement Tracker Contract Code | [lib.rs](./contracts/arbitrum/SettlementTracker//src/lib.rs) | [SettlementTracker.sol](./contracts/src/SettlementTracker.sol) |
|
|
355
|
+
Required variables:
|
|
244
356
|
|
|
245
|
-
|
|
357
|
+
| Variable | Description |
|
|
358
|
+
|---|---|
|
|
359
|
+
| `DELEGATOR_ETH_PRIVATE_KEY` | Publisher private key (needs testnet ETH) |
|
|
360
|
+
| `DELEGATEE_ETH_PRIVATE_KEY` | Consumer private key |
|
|
361
|
+
| `PINATA_JWT` | Pinata API JWT |
|
|
362
|
+
| `PINATA_GATEWAY` | Pinata gateway URL |
|
|
363
|
+
| `CHAIN_NAME` | `arbitrumSepolia` |
|
|
364
|
+
| `CAIP2` | `421614` |
|
|
365
|
+
| `CHAIN_RPC_URL` | RPC endpoint |
|
|
366
|
+
| `USDC_CONTRACT_ADDRESS` | USDC contract address |
|
|
367
|
+
| `DS_REGISTRY_ADDR` | DataSourceRegistry address |
|
|
368
|
+
| `SCHEMA_REGISTRY_ADDR` | SchemaRegistry address |
|
|
369
|
+
| `SETTLEMENT_TRACKER_ADDR` | SettlementTracker address |
|
|
246
370
|
|
|
247
|
-
|
|
371
|
+
Sample `.env` for Arbitrum Sepolia:
|
|
248
372
|
|
|
249
373
|
```sh
|
|
250
|
-
|
|
251
|
-
|
|
374
|
+
CHAIN_NAME=arbitrumSepolia
|
|
375
|
+
CAIP2=421614
|
|
376
|
+
CHAIN_RPC_URL=https://sepolia-rollup.arbitrum.io/rpc
|
|
377
|
+
USDC_CONTRACT_ADDRESS=0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d
|
|
378
|
+
DS_REGISTRY_ADDR=0x6fb3579bfd504cce85b923db335dfc096d912478
|
|
379
|
+
SCHEMA_REGISTRY_ADDR=0x49ab3d52b997e63ad56c91178df48263fd80b2dc
|
|
380
|
+
SETTLEMENT_TRACKER_ADDR=0x7c6ae9eb3398234eb69b2f3acfae69065505ff69
|
|
252
381
|
```
|
|
253
382
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
CLI for Fangorn
|
|
258
|
-
|
|
259
|
-
Options:
|
|
260
|
-
-V, --version output the version number
|
|
261
|
-
-h, --help display help for command
|
|
262
|
-
|
|
263
|
-
Commands:
|
|
264
|
-
init Configure your Fangorn credentials
|
|
265
|
-
register [options] <name> Register a new datasource as an agent.
|
|
266
|
-
upload [options] <name> <files...> Upload file(s) to a data source
|
|
267
|
-
list [options] <name> List contents (index) of a data source
|
|
268
|
-
info [options] <name> Get data source info from contract
|
|
269
|
-
entry [options] <name> <tag> Get info about a specific entry
|
|
270
|
-
decrypt [options] <owner> <name> <tag> Decrypt a file from a vault
|
|
271
|
-
help [command] display help for command
|
|
272
|
-
```
|
|
383
|
+
E2E tests deploy any contracts not defined in `.env`, register a test schema, publish manifests, and verify the full purchase → claim → decrypt cycle end-to-end.
|
|
384
|
+
|
|
385
|
+
---
|
|
273
386
|
|
|
274
387
|
## License
|
|
275
388
|
|
|
276
|
-
MIT
|
|
389
|
+
MIT
|
package/lib/cli/cli.d.ts
CHANGED
|
File without changes
|