@t3foundry/tasra-sdk 0.0.0-stage → 0.3.1-next.1
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/CHANGELOG.md +148 -0
- package/LICENSE +202 -0
- package/NOTICE +94 -0
- package/README.md +137 -2
- package/SECURITY.md +115 -0
- package/dist/app/approvals.d.ts +50 -0
- package/dist/app/approvals.js +90 -0
- package/dist/app/authorization.d.ts +19 -0
- package/dist/app/authorization.js +20 -0
- package/dist/app/client.d.ts +231 -0
- package/dist/app/client.js +272 -0
- package/dist/app/creation.d.ts +73 -0
- package/dist/app/creation.js +77 -0
- package/dist/app/deployment.d.ts +36 -0
- package/dist/app/deployment.js +18 -0
- package/dist/app/identity.d.ts +211 -0
- package/dist/app/identity.js +287 -0
- package/dist/app/index.d.ts +22 -0
- package/dist/app/index.js +12 -0
- package/dist/app/manifest.d.ts +74 -0
- package/dist/app/manifest.js +120 -0
- package/dist/app/node.d.ts +30 -0
- package/dist/app/node.js +159 -0
- package/dist/app/ready-slot.d.ts +157 -0
- package/dist/app/ready-slot.js +199 -0
- package/dist/app/tasra-client.d.ts +125 -0
- package/dist/app/tasra-client.js +79 -0
- package/dist/app/viem.d.ts +10 -0
- package/dist/app/viem.js +32 -0
- package/dist/app/wallet.d.ts +126 -0
- package/dist/app/wallet.js +137 -0
- package/dist/auth/dpop.d.ts +86 -0
- package/dist/auth/dpop.js +142 -0
- package/dist/auth/holderProof.d.ts +102 -0
- package/dist/auth/holderProof.js +161 -0
- package/dist/auth/identityScope.d.ts +19 -0
- package/dist/auth/identityScope.js +82 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.js +13 -0
- package/dist/auth/oid4vp.d.ts +230 -0
- package/dist/auth/oid4vp.js +780 -0
- package/dist/auth/rego/wasm/PINS.json +11 -0
- package/dist/auth/rego/wasm/keykeeper_rego_wasm.d.ts +76 -0
- package/dist/auth/rego/wasm/keykeeper_rego_wasm.js +379 -0
- package/dist/auth/rego/wasm/keykeeper_rego_wasm_bg.wasm +0 -0
- package/dist/auth/rego.d.ts +192 -0
- package/dist/auth/rego.js +492 -0
- package/dist/auth/verifier.d.ts +166 -0
- package/dist/auth/verifier.js +211 -0
- package/dist/chain/abis/accountantSetRegistry.d.ts +441 -0
- package/dist/chain/abis/accountantSetRegistry.js +574 -0
- package/dist/chain/abis/accountantSlashing.d.ts +2071 -0
- package/dist/chain/abis/accountantSlashing.js +2670 -0
- package/dist/chain/abis/bondingCurve.d.ts +398 -0
- package/dist/chain/abis/bondingCurve.js +521 -0
- package/dist/chain/abis/equivocationSlasher.d.ts +292 -0
- package/dist/chain/abis/equivocationSlasher.js +379 -0
- package/dist/chain/abis/fixedTasraPriceOracle.d.ts +52 -0
- package/dist/chain/abis/fixedTasraPriceOracle.js +72 -0
- package/dist/chain/abis/index.d.ts +12801 -0
- package/dist/chain/abis/index.js +64 -0
- package/dist/chain/abis/keeperShareRegistry.d.ts +519 -0
- package/dist/chain/abis/keeperShareRegistry.js +675 -0
- package/dist/chain/abis/keyRegistry.d.ts +2421 -0
- package/dist/chain/abis/keyRegistry.js +3114 -0
- package/dist/chain/abis/livenessRegistry.d.ts +402 -0
- package/dist/chain/abis/livenessRegistry.js +524 -0
- package/dist/chain/abis/mockEurc.d.ts +210 -0
- package/dist/chain/abis/mockEurc.js +276 -0
- package/dist/chain/abis/nodeRegistry.d.ts +1630 -0
- package/dist/chain/abis/nodeRegistry.js +2113 -0
- package/dist/chain/abis/platformExecutor.d.ts +328 -0
- package/dist/chain/abis/platformExecutor.js +429 -0
- package/dist/chain/abis/prevrandaoSaltBeacon.d.ts +16 -0
- package/dist/chain/abis/prevrandaoSaltBeacon.js +24 -0
- package/dist/chain/abis/serviceRegistry.d.ts +556 -0
- package/dist/chain/abis/serviceRegistry.js +719 -0
- package/dist/chain/abis/settlement.d.ts +1624 -0
- package/dist/chain/abis/settlement.js +2096 -0
- package/dist/chain/abis/tasraSwapRouter.d.ts +92 -0
- package/dist/chain/abis/tasraSwapRouter.js +122 -0
- package/dist/chain/abis/tasraToken.d.ts +455 -0
- package/dist/chain/abis/tasraToken.js +599 -0
- package/dist/chain/abis/tasraVestingVault.d.ts +165 -0
- package/dist/chain/abis/tasraVestingVault.js +215 -0
- package/dist/chain/abis/thresholdRandomBeacon.d.ts +378 -0
- package/dist/chain/abis/thresholdRandomBeacon.js +494 -0
- package/dist/chain/abis/treasury.d.ts +301 -0
- package/dist/chain/abis/treasury.js +390 -0
- package/dist/chain/abis/verifierSetRegistry.d.ts +445 -0
- package/dist/chain/abis/verifierSetRegistry.js +579 -0
- package/dist/chain/client.d.ts +212 -0
- package/dist/chain/client.js +576 -0
- package/dist/chain/commitmentRecovery.d.ts +21 -0
- package/dist/chain/commitmentRecovery.js +44 -0
- package/dist/chain/committeeClient.d.ts +102 -0
- package/dist/chain/committeeClient.js +137 -0
- package/dist/chain/deployments.d.ts +56 -0
- package/dist/chain/deployments.js +269 -0
- package/dist/chain/discovery.d.ts +49 -0
- package/dist/chain/discovery.js +107 -0
- package/dist/chain/events.d.ts +58 -0
- package/dist/chain/events.js +125 -0
- package/dist/chain/format.d.ts +25 -0
- package/dist/chain/format.js +51 -0
- package/dist/chain/index.d.ts +41 -0
- package/dist/chain/index.js +56 -0
- package/dist/chain/manifest.d.ts +165 -0
- package/dist/chain/manifest.js +132 -0
- package/dist/chain/network-profiles.json +75 -0
- package/dist/chain/networks.d.ts +73 -0
- package/dist/chain/networks.js +62 -0
- package/dist/chain/node.d.ts +44 -0
- package/dist/chain/node.js +176 -0
- package/dist/chain/offchain.d.ts +149 -0
- package/dist/chain/offchain.js +73 -0
- package/dist/chain/provisionRule.d.ts +164 -0
- package/dist/chain/provisionRule.js +212 -0
- package/dist/chain/registeredAgent.d.ts +64 -0
- package/dist/chain/registeredAgent.js +140 -0
- package/dist/chain/registeredOperation.d.ts +49 -0
- package/dist/chain/registeredOperation.js +136 -0
- package/dist/chain/registeredRelay.d.ts +206 -0
- package/dist/chain/registeredRelay.js +312 -0
- package/dist/chain/revertReason.d.ts +14 -0
- package/dist/chain/revertReason.js +62 -0
- package/dist/chain/ruleAmendment.d.ts +80 -0
- package/dist/chain/ruleAmendment.js +195 -0
- package/dist/chain/ruleAmendmentCore.d.ts +129 -0
- package/dist/chain/ruleAmendmentCore.js +152 -0
- package/dist/chain/ruleInput.d.ts +10 -0
- package/dist/chain/ruleInput.js +13 -0
- package/dist/chain/serviceIdentity.d.ts +176 -0
- package/dist/chain/serviceIdentity.js +237 -0
- package/dist/chain/serviceProfiles.d.ts +39 -0
- package/dist/chain/serviceProfiles.js +74 -0
- package/dist/chain/services.d.ts +141 -0
- package/dist/chain/services.js +79 -0
- package/dist/chain/slotClient.d.ts +55 -0
- package/dist/chain/slotClient.js +62 -0
- package/dist/chain/slotSeed.d.ts +31 -0
- package/dist/chain/slotSeed.js +98 -0
- package/dist/chain/write.d.ts +431 -0
- package/dist/chain/write.js +958 -0
- package/dist/client/client.d.ts +112 -0
- package/dist/client/client.js +111 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +2 -0
- package/dist/client/session.d.ts +67 -0
- package/dist/client/session.js +238 -0
- package/dist/committee/client.d.ts +284 -0
- package/dist/committee/client.js +351 -0
- package/dist/committee/dual-sign.d.ts +110 -0
- package/dist/committee/dual-sign.js +202 -0
- package/dist/committee/ecdsa.d.ts +36 -0
- package/dist/committee/ecdsa.js +45 -0
- package/dist/committee/extraction.d.ts +82 -0
- package/dist/committee/extraction.js +96 -0
- package/dist/committee/index.d.ts +19 -0
- package/dist/committee/index.js +13 -0
- package/dist/committee/oauth.d.ts +51 -0
- package/dist/committee/oauth.js +90 -0
- package/dist/committee/receipts.d.ts +51 -0
- package/dist/committee/receipts.js +59 -0
- package/dist/committee/request.d.ts +264 -0
- package/dist/committee/request.js +305 -0
- package/dist/committee/token.d.ts +274 -0
- package/dist/committee/token.js +418 -0
- package/dist/crypto/constants.d.ts +10 -0
- package/dist/crypto/constants.js +32 -0
- package/dist/crypto/detect.d.ts +20 -0
- package/dist/crypto/detect.js +44 -0
- package/dist/crypto/envelope.d.ts +60 -0
- package/dist/crypto/envelope.js +243 -0
- package/dist/crypto/frost.d.ts +49 -0
- package/dist/crypto/frost.js +152 -0
- package/dist/crypto/hex.d.ts +7 -0
- package/dist/crypto/hex.js +24 -0
- package/dist/crypto/ibe-blob.d.ts +114 -0
- package/dist/crypto/ibe-blob.js +208 -0
- package/dist/crypto/ibe.d.ts +88 -0
- package/dist/crypto/ibe.js +262 -0
- package/dist/crypto/index.d.ts +12 -0
- package/dist/crypto/index.js +12 -0
- package/dist/crypto/kem.d.ts +55 -0
- package/dist/crypto/kem.js +241 -0
- package/dist/decryption/client.d.ts +64 -0
- package/dist/decryption/client.js +82 -0
- package/dist/decryption/index.d.ts +2 -0
- package/dist/decryption/index.js +2 -0
- package/dist/errors.d.ts +124 -0
- package/dist/errors.js +167 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +98 -0
- package/dist/keys/index.d.ts +1 -0
- package/dist/keys/index.js +4 -0
- package/dist/keys/node-client.d.ts +27 -0
- package/dist/keys/node-client.js +97 -0
- package/dist/oid4vp/binding.d.ts +76 -0
- package/dist/oid4vp/binding.js +118 -0
- package/dist/oid4vp/did-web.d.ts +49 -0
- package/dist/oid4vp/did-web.js +57 -0
- package/dist/oid4vp/index.d.ts +9 -0
- package/dist/oid4vp/index.js +10 -0
- package/dist/oid4vp/jose.d.ts +166 -0
- package/dist/oid4vp/jose.js +242 -0
- package/dist/oid4vp/jwe.d.ts +30 -0
- package/dist/oid4vp/jwe.js +93 -0
- package/dist/oid4vp/oid4vci.d.ts +84 -0
- package/dist/oid4vp/oid4vci.js +85 -0
- package/dist/oid4vp/request-object.d.ts +109 -0
- package/dist/oid4vp/request-object.js +96 -0
- package/dist/oid4vp/sd-jwt.d.ts +177 -0
- package/dist/oid4vp/sd-jwt.js +208 -0
- package/dist/oid4vp/verifier-agent.d.ts +161 -0
- package/dist/oid4vp/verifier-agent.js +132 -0
- package/dist/oid4vp/wallet.d.ts +116 -0
- package/dist/oid4vp/wallet.js +108 -0
- package/dist/recipient/store.d.ts +67 -0
- package/dist/recipient/store.js +98 -0
- package/dist/signing/ecdsa.d.ts +49 -0
- package/dist/signing/ecdsa.js +79 -0
- package/dist/signing/frost.d.ts +88 -0
- package/dist/signing/frost.js +145 -0
- package/dist/signing/index.d.ts +4 -0
- package/dist/signing/index.js +3 -0
- package/dist/slots/faucet.d.ts +23 -0
- package/dist/slots/faucet.js +35 -0
- package/dist/slots/index.d.ts +2 -0
- package/dist/slots/index.js +4 -0
- package/dist/verifier-agent/index.d.ts +241 -0
- package/dist/verifier-agent/index.js +411 -0
- package/docs/DEVELOPER-EXPERIENCE.md +62 -0
- package/docs/README.md +33 -0
- package/docs/access-control.md +76 -0
- package/docs/ai-development.md +292 -0
- package/docs/api.md +338 -0
- package/docs/application-api.md +335 -0
- package/docs/architecture.md +65 -0
- package/docs/basics.md +48 -0
- package/docs/capabilities.md +86 -0
- package/docs/chain.md +153 -0
- package/docs/compatibility.md +36 -0
- package/docs/consumer-migrations.md +80 -0
- package/docs/create-slot.md +104 -0
- package/docs/document-signing.md +243 -0
- package/docs/encrypted-notes.md +129 -0
- package/docs/encryption.md +100 -0
- package/docs/errors.md +76 -0
- package/docs/flows.md +289 -0
- package/docs/fuji.md +127 -0
- package/docs/funding.md +126 -0
- package/docs/getting-started.md +94 -0
- package/docs/glossary.md +44 -0
- package/docs/installation.md +132 -0
- package/docs/manage-slot.md +95 -0
- package/docs/native-approvals.md +124 -0
- package/docs/prerequisites.md +137 -0
- package/docs/read-slot.md +41 -0
- package/docs/reference/README.md +30 -0
- package/docs/reference/app-node.md +102 -0
- package/docs/reference/app.md +1737 -0
- package/docs/reference/chain-node.md +159 -0
- package/docs/reference/chain.md +3609 -0
- package/docs/reference/committee.md +2176 -0
- package/docs/reference/main.md +4068 -0
- package/docs/reference/oid4vp.md +2547 -0
- package/docs/reference/verifier-agent.md +498 -0
- package/docs/shared-account.md +168 -0
- package/docs/signing-and-encryption.md +52 -0
- package/docs/signing.md +172 -0
- package/examples/committee-slot.ts +16 -0
- package/examples/connect-fuji.ts +41 -0
- package/examples/connect-network.ts +14 -0
- package/examples/credential-approvals.ts +46 -0
- package/examples/document-signing/README.md +59 -0
- package/examples/document-signing/backend.ts +132 -0
- package/examples/document-signing/build.mjs +19 -0
- package/examples/document-signing/config.ts +34 -0
- package/examples/document-signing/gitignore.template +9 -0
- package/examples/document-signing/model.ts +140 -0
- package/examples/document-signing/network.ts +58 -0
- package/examples/document-signing/package.json +25 -0
- package/examples/document-signing/public/index.html +27 -0
- package/examples/document-signing/public/sample.pdf +31 -0
- package/examples/document-signing/public/styles.css +531 -0
- package/examples/document-signing/server.ts +358 -0
- package/examples/document-signing/setup.ts +111 -0
- package/examples/document-signing/store.ts +105 -0
- package/examples/document-signing/tsconfig.json +24 -0
- package/examples/document-signing/verify.ts +24 -0
- package/examples/document-signing/web/app.ts +312 -0
- package/examples/document-signing/web/preview.ts +67 -0
- package/examples/document-signing/web/wallet.ts +146 -0
- package/examples/document-signing/workflow.test.ts +228 -0
- package/examples/document-signing/workflow.ts +241 -0
- package/examples/document-signing.ts +96 -0
- package/examples/encrypted-notes.ts +86 -0
- package/examples/ethers-signer.ts +204 -0
- package/examples/fund-slot.ts +73 -0
- package/examples/getting-started.ts +25 -0
- package/examples/learning-authorize.ts +23 -0
- package/examples/learning-cancel-slot.ts +11 -0
- package/examples/learning-context.ts +28 -0
- package/examples/learning-create-slot.ts +25 -0
- package/examples/learning-read-slot.ts +8 -0
- package/examples/learning-renew-slot.ts +12 -0
- package/examples/learning-sign.ts +8 -0
- package/examples/live-config.ts +71 -0
- package/examples/minimal.ts +6 -0
- package/examples/native-approvals.ts +57 -0
- package/examples/network.ts +58 -0
- package/examples/offline.ts +16 -0
- package/examples/personal-vault.ts +20 -0
- package/examples/provision-slot.ts +47 -0
- package/examples/shared-account.ts +46 -0
- package/examples/slot-address.ts +13 -0
- package/examples/slot-creation.ts +9 -0
- package/examples/tutorial-negative.ts +26 -0
- package/examples/tutorial-support.ts +76 -0
- package/examples/viem-account.ts +203 -0
- package/package.json +303 -4
package/docs/fuji.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Read the public Fuji deployment
|
|
2
|
+
|
|
3
|
+
This example downloads a release manifest and reads public contracts. It does
|
|
4
|
+
not establish support for signing, authorization or decryption. Check those service
|
|
5
|
+
requirements separately before using protected operations.
|
|
6
|
+
|
|
7
|
+
Build a small app that connects to Tasra's Fuji deployment and reads how new slots
|
|
8
|
+
are created. You will see the chain ID, deployment, current block, and registry address.
|
|
9
|
+
|
|
10
|
+
You need an internet connection and **Node.js 22.12 or newer**, which includes npm.
|
|
11
|
+
Install Node.js from [nodejs.org](https://nodejs.org/en/download), then check
|
|
12
|
+
`node --version` and `npm --version` in your IDE terminal.
|
|
13
|
+
This first app only reads public data: it needs no wallet, funds, or credentials.
|
|
14
|
+
|
|
15
|
+
## 1. Create the app
|
|
16
|
+
|
|
17
|
+
Run these commands in your terminal:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
mkdir my-tasra-app
|
|
21
|
+
cd my-tasra-app
|
|
22
|
+
npm init -y
|
|
23
|
+
npm pkg set type=module
|
|
24
|
+
npm install @t3foundry/tasra-sdk@latest
|
|
25
|
+
npm install --save-dev tsx
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Keep `package-lock.json` with your app so teammates install the same versions.
|
|
29
|
+
|
|
30
|
+
## 2. Add the code
|
|
31
|
+
|
|
32
|
+
Create **`app.ts`** in `my-tasra-app` and paste the entire file below.
|
|
33
|
+
All imports come from the installed SDK; there are no helper scripts to copy.
|
|
34
|
+
|
|
35
|
+
<!-- connect-fuji-example -->
|
|
36
|
+
```ts
|
|
37
|
+
import {
|
|
38
|
+
NETWORKS, parsePinnedNetworkManifest, addressBookFromManifest,
|
|
39
|
+
createTasraChainClient,
|
|
40
|
+
} from '@t3foundry/tasra-sdk/chain'
|
|
41
|
+
|
|
42
|
+
// Keep the pointer and manifest at the same reviewed tasra-releases commit.
|
|
43
|
+
const revision = '3b34d86432c4577eef5d8a10e14eda272f87769b'
|
|
44
|
+
const base = `https://raw.githubusercontent.com/t3foundry/tasra-releases/${revision}/networks/testnet/`
|
|
45
|
+
async function download(path: string): Promise<string> {
|
|
46
|
+
const response = await fetch(`${base}${path}`, {signal: AbortSignal.timeout(15_000)})
|
|
47
|
+
if (!response.ok) throw new Error(`Download ${path}: HTTP ${response.status}`)
|
|
48
|
+
return response.text()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const pointer = JSON.parse(await download('current.json')) as {
|
|
52
|
+
schemaVersion: number; network: string; chainId: number; status: string
|
|
53
|
+
manifest: string; sha256: string
|
|
54
|
+
}
|
|
55
|
+
if (pointer.schemaVersion !== 1 || pointer.network !== 'testnet' ||
|
|
56
|
+
pointer.chainId !== 43113 || pointer.status !== 'active' ||
|
|
57
|
+
typeof pointer.manifest !== 'string' || !/^deployments\/[a-z0-9.-]+\.json$/.test(pointer.manifest)) {
|
|
58
|
+
throw new Error('Expected an active Fuji deployment pointer')
|
|
59
|
+
}
|
|
60
|
+
const manifest = parsePinnedNetworkManifest(await download(pointer.manifest), pointer.sha256)
|
|
61
|
+
if (manifest.network !== 'testnet' || manifest.chainId !== 43113) {
|
|
62
|
+
throw new Error('Expected a Fuji manifest')
|
|
63
|
+
}
|
|
64
|
+
const addresses = addressBookFromManifest(manifest)
|
|
65
|
+
const chain = createTasraChainClient({
|
|
66
|
+
rpcUrl: NETWORKS.testnet.rpcUrl, chainId: manifest.chainId, addresses,
|
|
67
|
+
})
|
|
68
|
+
if (await chain.client.getChainId() !== manifest.chainId) {
|
|
69
|
+
throw new Error('RPC chain does not match the manifest')
|
|
70
|
+
}
|
|
71
|
+
const block = await chain.client.getBlockNumber()
|
|
72
|
+
const commitReveal = await chain.readers.keyRegistry.requiresCommitReveal()
|
|
73
|
+
console.log(`Connected to Fuji (${manifest.chainId})`)
|
|
74
|
+
console.log(`Deployment: ${manifest.deploymentId}`)
|
|
75
|
+
console.log(`Block: ${block}`)
|
|
76
|
+
console.log(`KeyRegistry: ${addresses.KeyRegistry}`)
|
|
77
|
+
console.log(`Slot creation: ${commitReveal ? 'commit/reveal' : 'direct'}`)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The deployment configuration comes from
|
|
81
|
+
[tasra-releases](https://github.com/t3foundry/tasra-releases).
|
|
82
|
+
Its `networks/testnet/current.json` points to `deployments/tasra-fuji-v1.json` and
|
|
83
|
+
provides the SHA-256 checked by the SDK. Both downloads use the same reviewed
|
|
84
|
+
commit, so a later deployment update cannot silently change your app's configuration.
|
|
85
|
+
When updating the deployment, review that repository and change `revision` deliberately.
|
|
86
|
+
|
|
87
|
+
## 3. Run it
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
npx tsx app.ts
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Expected output (the block number changes):
|
|
94
|
+
|
|
95
|
+
```text
|
|
96
|
+
Connected to Fuji (43113)
|
|
97
|
+
Deployment: tasra-fuji-v1
|
|
98
|
+
Block: 58698713
|
|
99
|
+
KeyRegistry: 0x45F432aB5709e9920b5ec349D29663D7200A8C39
|
|
100
|
+
Slot creation: commit/reveal
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
You have loaded a checksum-verified manifest and read the live KeyRegistry contract
|
|
104
|
+
using `@t3foundry/tasra-sdk`. This does not create a slot, authorize a user, or test signing.
|
|
105
|
+
For a check of every deployed contract's code, see [deployment verification](chain.md#verify-a-deployment).
|
|
106
|
+
|
|
107
|
+
Source: [examples/connect-fuji.ts](../examples/connect-fuji.ts), included in the
|
|
108
|
+
installed SDK package. The inline file can be copied directly.
|
|
109
|
+
|
|
110
|
+
## If it fails
|
|
111
|
+
|
|
112
|
+
| What you see | What to do |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `node` or `npm` is not found | Install Node.js and reopen the IDE terminal. |
|
|
115
|
+
| Cannot find `@t3foundry/tasra-sdk` | Run the install commands inside `my-tasra-app`. |
|
|
116
|
+
| Download error, timeout, or `fetch failed` | Check access to GitHub and the Fuji RPC; retry after connectivity is restored. |
|
|
117
|
+
| Manifest checksum mismatch | Re-fetch both files at the same revision. Preserve the original manifest bytes; do not bypass the check. |
|
|
118
|
+
| RPC chain mismatch | Use `NETWORKS.testnet.rpcUrl` or your own Fuji RPC (chain 43113). |
|
|
119
|
+
| Contract read fails | Check the RPC and whether the pinned deployment is still supported in `tasra-releases`. |
|
|
120
|
+
|
|
121
|
+
## Build the next part
|
|
122
|
+
|
|
123
|
+
- **Protect app data:** [encrypt and decrypt with credentials](encryption.md).
|
|
124
|
+
- **Build a shared Ethereum account:** [get an address and sign transactions](signing.md).
|
|
125
|
+
- **Read slots or discover keepers:** [chain APIs](chain.md).
|
|
126
|
+
|
|
127
|
+
[Documentation index](README.md)
|
package/docs/funding.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Fund a slot for use
|
|
2
|
+
|
|
3
|
+
Creating a slot prepares its key and access policy. Before signing or decrypting,
|
|
4
|
+
add **TASRA usage credits**. The token symbol used by the SDK is **TSRA**.
|
|
5
|
+
|
|
6
|
+
There are three steps:
|
|
7
|
+
|
|
8
|
+
1. Send **AVAX to the creator wallet** to pay transaction gas.
|
|
9
|
+
2. Buy **TSRA with EURC** from the network's **BondingCurve** contract.
|
|
10
|
+
3. Deposit **TSRA into the slot's Settlement balance**.
|
|
11
|
+
|
|
12
|
+
AVAX is not sent to a slot ID. An Ethereum slot's derived account separately needs
|
|
13
|
+
AVAX when it sends Ethereum transactions. Its account balance is not usage credit.
|
|
14
|
+
|
|
15
|
+
## 1. Fund the creator with AVAX
|
|
16
|
+
|
|
17
|
+
Run the [creation lesson](create-slot.md) to print your saved creator address.
|
|
18
|
+
For the downloaded Fuji manifest, use the
|
|
19
|
+
[official Avalanche Fuji C-Chain faucet](https://core.app/tools/testnet-faucet/?subnet=c&token=c)
|
|
20
|
+
and send test AVAX to that `0x` address on chain **43113**. The faucet may require
|
|
21
|
+
eligibility or a coupon; see [Avalanche's instructions](https://support.avax.network/en/articles/6110239-is-there-an-avax-faucet).
|
|
22
|
+
You can also transfer AVAX from a wallet you control on the same network.
|
|
23
|
+
|
|
24
|
+
Keep enough AVAX for creation, token approvals, purchases and deposits. Then rerun
|
|
25
|
+
creation. A nonzero gas balance does not guarantee every transaction can be paid.
|
|
26
|
+
|
|
27
|
+
## 2. Inspect the saved account and slot
|
|
28
|
+
|
|
29
|
+
Continue in the same project with its original `network.json`, `network-pin.json`
|
|
30
|
+
and private `.tasra/` state. Copy the funding command:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
cp node_modules/@t3foundry/tasra-sdk/examples/fund-slot.ts .
|
|
34
|
+
npx tsc --noEmit
|
|
35
|
+
npx tsx fund-slot.ts .tasra/first-slot status
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
For an application tutorial, replace `.tasra/first-slot` with the directory printed
|
|
39
|
+
by that app. It prints a complete status command when its slot needs credit.
|
|
40
|
+
The command restores the creator key; it never creates a replacement account.
|
|
41
|
+
|
|
42
|
+
Keep a terminal demo running while funding it in a second terminal, from the same
|
|
43
|
+
project directory. It waits up to 15 minutes. If it has exited, rerunning that demo
|
|
44
|
+
creates fresh state; funding its old slot will not resume the exited run. The first-slot
|
|
45
|
+
lessons and the web document app save state for later runs.
|
|
46
|
+
|
|
47
|
+
## 3. Buy TSRA with EURC
|
|
48
|
+
|
|
49
|
+
The curve accepts **EURC, not AVAX**. The funding helper reads the curve's EURC
|
|
50
|
+
token address from the contract named by your verified manifest; the manifest may
|
|
51
|
+
omit a separate token entry. The Fuji deployment uses test EURC; this optional command explicitly
|
|
52
|
+
mints **10 test EURC** to the saved creator:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
npx tsx fund-slot.ts .tasra/first-slot mint-test-eurc 10000000
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The SDK permits this only for a supported mock token. Real EURC must be acquired
|
|
59
|
+
and transferred to your creator wallet; it cannot be minted with this command.
|
|
60
|
+
|
|
61
|
+
Choose how much EURC to spend and the smallest TSRA output you will accept.
|
|
62
|
+
The following example spends **10 EURC** and requires at least **1 TSRA**. It reverts
|
|
63
|
+
if the curve cannot satisfy that minimum; these amounts are an example budget,
|
|
64
|
+
not a quoted exchange rate or a guarantee of how many operations you can run.
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
npx tsx fund-slot.ts .tasra/first-slot buy 10000000 1000000000000000000
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Internally the command uses two confirmed SDK calls:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
await writer.approveEurcForCurve(eurcAmount)
|
|
74
|
+
await writer.buyTsra(eurcAmount, minimumTsraOut)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Success:** an approval hash, purchase hash and updated wallet TSRA balance.
|
|
78
|
+
Buying TSRA does not automatically credit a slot.
|
|
79
|
+
|
|
80
|
+
## 4. Deposit TSRA into the slot
|
|
81
|
+
|
|
82
|
+
This example deposits **1 TSRA** from your saved creator wallet:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
npx tsx fund-slot.ts .tasra/first-slot fund 1000000000000000000
|
|
86
|
+
npx tsx fund-slot.ts .tasra/first-slot status
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The SDK approves Settlement and confirms the deposit:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
const {fundTx} = await writer.fundSlot(slotId, slotCredits)
|
|
93
|
+
console.log('Funding transaction:', fundTx)
|
|
94
|
+
console.log('Slot credit:', await writer.settlementBalance(slotId))
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Success:** a funding transaction hash and nonzero slot TSRA credit. Usage consumes
|
|
98
|
+
credit; top up according to the selected network's charges. A positive balance
|
|
99
|
+
alone does not guarantee sufficient credit for every operation.
|
|
100
|
+
|
|
101
|
+
All command amounts are **integer base units**: EURC has 6 decimals and TSRA has
|
|
102
|
+
18. The output labels these units. No extra token or wallet library is needed.
|
|
103
|
+
|
|
104
|
+
<details>
|
|
105
|
+
<summary>Several slots, transaction retries and recovery</summary>
|
|
106
|
+
|
|
107
|
+
Fund each slot separately. Add `--slot` with the ID printed by your application:
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
npx tsx fund-slot.ts .tasra/first-slot status --slot YOUR_PRINTED_SLOT_ID
|
|
111
|
+
npx tsx fund-slot.ts .tasra/first-slot fund 1000000000000000000 --slot YOUR_PRINTED_SLOT_ID
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Replace `YOUR_PRINTED_SLOT_ID` with the full `0x` slot ID. The command checks that
|
|
115
|
+
the slot exists and is not cancelled before depositing. Keep the original network
|
|
116
|
+
manifest; a different snapshot is rejected for this saved state.
|
|
117
|
+
|
|
118
|
+
Each explicit `buy`, `mint-test-eurc` or `fund` invocation submits new transactions.
|
|
119
|
+
It is not a resumable payment journal. After a timeout or uncertain result,
|
|
120
|
+
inspect the recorded transaction and balances before deciding what to do next.
|
|
121
|
+
Do not blindly repeat a purchase or deposit. A confirmed approval may remain even
|
|
122
|
+
if its following purchase or deposit fails.
|
|
123
|
+
|
|
124
|
+
</details>
|
|
125
|
+
|
|
126
|
+
**Next: [Read your slot →](read-slot.md)**
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Connect to TASRA
|
|
2
|
+
|
|
3
|
+
**Goal:** connect a TypeScript app and read network information. You need Node.js
|
|
4
|
+
22.12+ and npm. Use a macOS, Linux or WSL terminal for the commands below.
|
|
5
|
+
This lesson needs no wallet or precreated slot.
|
|
6
|
+
|
|
7
|
+
## 1. Create the app
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
mkdir my-tasra-app
|
|
11
|
+
cd my-tasra-app
|
|
12
|
+
npm init -y
|
|
13
|
+
npm pkg set type=module
|
|
14
|
+
npm install @t3foundry/tasra-sdk@latest
|
|
15
|
+
npm install --save-dev typescript tsx @types/node
|
|
16
|
+
cp node_modules/@t3foundry/tasra-sdk/examples/network.ts .
|
|
17
|
+
cp node_modules/@t3foundry/tasra-sdk/examples/connect-network.ts app.ts
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Save **tsconfig.json** in this folder:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"compilerOptions": {
|
|
25
|
+
"target": "ES2022",
|
|
26
|
+
"module": "NodeNext",
|
|
27
|
+
"moduleResolution": "NodeNext",
|
|
28
|
+
"strict": true,
|
|
29
|
+
"skipLibCheck": true,
|
|
30
|
+
"noEmit": true,
|
|
31
|
+
"types": ["node"]
|
|
32
|
+
},
|
|
33
|
+
"include": ["*.ts"]
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 2. Download the network configuration
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npx tsx network.ts
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The supplied helper downloads the testnet manifest from
|
|
44
|
+
[tasra-releases](https://github.com/t3foundry/tasra-releases), verifies its checksum
|
|
45
|
+
and saves `network.json` and `network-pin.json`. A manifest tells the SDK which
|
|
46
|
+
network and services to use. Keep these files for the following lessons.
|
|
47
|
+
|
|
48
|
+
## 3. Connect
|
|
49
|
+
|
|
50
|
+
Open **app.ts**:
|
|
51
|
+
|
|
52
|
+
<!-- connect-network-example -->
|
|
53
|
+
```ts
|
|
54
|
+
import {loadNetwork} from './network.js'
|
|
55
|
+
import {TasraClient} from '@t3foundry/tasra-sdk/app'
|
|
56
|
+
|
|
57
|
+
// Verify the manifest downloaded from tasra-releases; no wallet is needed.
|
|
58
|
+
const network = loadNetwork()
|
|
59
|
+
const tasra = new TasraClient({manifest: network.deployment, verifierAgentUrl: network.verifierAgentUrl})
|
|
60
|
+
|
|
61
|
+
// Check the actual chain and configured registries before using the network.
|
|
62
|
+
const health = await tasra.check()
|
|
63
|
+
if (!health.ready) throw new Error('Configured registries are unavailable')
|
|
64
|
+
console.log(`Connected to Tasra (${health.chainId})`)
|
|
65
|
+
console.log(`Block: ${await tasra.chain.client.getBlockNumber()}`)
|
|
66
|
+
console.log(`Active registered nodes: ${await tasra.chain.readers.nodeRegistry.activeCount()}`)
|
|
67
|
+
console.log('Registry contracts: available')
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
npx tsc --noEmit
|
|
72
|
+
npx tsx app.ts
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Success:** a chain ID, current block and registered-node count. The count includes
|
|
76
|
+
all registered node roles, not just keepers. These reads spend no gas.
|
|
77
|
+
|
|
78
|
+
<details>
|
|
79
|
+
<summary>What this check establishes</summary>
|
|
80
|
+
|
|
81
|
+
`check()` confirms the RPC chain and registry contracts. Later signing and
|
|
82
|
+
encryption steps also need compatible, available network services.
|
|
83
|
+
|
|
84
|
+
The helper uses the `lowest-operator-id` coordinator convention; confirm that it
|
|
85
|
+
matches your selected deployment before protected operations. Keep the downloaded
|
|
86
|
+
manifest unchanged while recovering a pending operation. For other manifests,
|
|
87
|
+
see [network configuration](fuji.md).
|
|
88
|
+
|
|
89
|
+
If the connection fails, check your network access and manifest. See
|
|
90
|
+
[installation help](installation.md) or [errors and recovery](errors.md).
|
|
91
|
+
|
|
92
|
+
</details>
|
|
93
|
+
|
|
94
|
+
**Next: [Create your first slot →](create-slot.md)**
|
package/docs/glossary.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Glossary
|
|
2
|
+
|
|
3
|
+
> Slot, k-of-n, MSK, epoch, DKG, DCQL, holder proof, committee — defined.
|
|
4
|
+
|
|
5
|
+
Every domain term this README uses, defined once.
|
|
6
|
+
|
|
7
|
+
- **Slot** — the unit of key management: one threshold keypair plus the policy
|
|
8
|
+
governing access to it. Created on-chain, identified by a 32-byte `slotId`.
|
|
9
|
+
Everything in this SDK is scoped to a slot.
|
|
10
|
+
- **k-of-n** — the threshold. A slot's key is split into `n` shards across `n`
|
|
11
|
+
nodes; any `k` of them can cooperate to decrypt or sign. Fewer than `k` can do
|
|
12
|
+
nothing, and no single node ever holds the whole key.
|
|
13
|
+
- **Shard** — one node's share of a slot's secret key.
|
|
14
|
+
- **MSK / master secret key** — the whole secret, reconstructed *in your process*
|
|
15
|
+
by Lagrange-interpolating `k` shards. Only the local-decrypt path does this;
|
|
16
|
+
threshold sign/decrypt never reconstructs it. `Session.close()` zeroizes it.
|
|
17
|
+
- **MPK / group public key** — the slot's public key. Public and served by any
|
|
18
|
+
node, so encryption needs no credentials.
|
|
19
|
+
- **Epoch** — the slot's key generation. Rotation (e.g. after revoking a holder)
|
|
20
|
+
bumps it; envelopes carry the epoch they were encrypted under so a rotated slot
|
|
21
|
+
can still read old ciphertext.
|
|
22
|
+
- **DKG** — distributed key generation. The committee generating a slot's key
|
|
23
|
+
among themselves after creation, with no dealer. Takes a moment after
|
|
24
|
+
`createSlot`, which is why `getting-started.ts` polls for a non-empty group key.
|
|
25
|
+
- **DCQL** — the query language a slot's access **rule** is written in, evaluated
|
|
26
|
+
against a holder's verifiable credentials. The chain stores only a salted hash
|
|
27
|
+
of the rule; the clear rule is provisioned to the nodes.
|
|
28
|
+
- **Credential / VC** — a signed claim about a holder (a verifiable credential),
|
|
29
|
+
presented to the verifier and evaluated against the DCQL rule.
|
|
30
|
+
- **Holder proof** — a proof-of-possession signed with the holder DID's
|
|
31
|
+
authentication key, binding a presentation to a fresh verifier nonce. Stops a
|
|
32
|
+
leaked credential from being replayed by someone else.
|
|
33
|
+
- **Verifier** — the service that checks credentials against a slot's rule and
|
|
34
|
+
mints the short-lived JWT the keeper nodes accept.
|
|
35
|
+
- **Committee** — two distinct things, unfortunately: (1) the *keeper* committee,
|
|
36
|
+
the `n` nodes drawn on-chain to hold a slot's shards; (2) the *verifier*
|
|
37
|
+
committee of the committee path, a per-request quorum drawn from the on-chain
|
|
38
|
+
verifier set. Where it matters below, which one is meant is stated.
|
|
39
|
+
- **TASRA** — the network's token, used for staking, metering, and settlement.
|
|
40
|
+
(Spelled `Tasra` in contract and type names.)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
[Back to the README](../README.md) · [Documentation index](README.md)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Install
|
|
2
|
+
|
|
3
|
+
> Installing, bundled adapters, module format, and runtime support.
|
|
4
|
+
|
|
5
|
+
New to Tasra? Follow the [TypeScript quickstart](getting-started.md) first.
|
|
6
|
+
|
|
7
|
+
Install the latest SDK from npm:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @t3foundry/tasra-sdk@latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Keep `package-lock.json` with your app to make subsequent installs reproducible.
|
|
14
|
+
|
|
15
|
+
The package ships JavaScript, type declarations, runnable examples and all eleven agent
|
|
16
|
+
skills; library implementation TypeScript and source maps are excluded (example TypeScript is included), so the shipped
|
|
17
|
+
JavaScript stays inspectable.
|
|
18
|
+
|
|
19
|
+
Releases published by the GitHub workflow carry [npm provenance](https://docs.npmjs.com/generating-provenance-statements)
|
|
20
|
+
— a signed attestation linking the tarball to the commit and workflow run that built
|
|
21
|
+
it, which npm shows on the package page. Manual bootstrap releases can omit provenance;
|
|
22
|
+
check the release notes and package page. Verify registry signatures and available
|
|
23
|
+
attestations with:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm audit signatures
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The SDK installs its crypto dependencies and viem wallet adapter automatically.
|
|
30
|
+
Apps using `@t3foundry/tasra-sdk/app` or `@t3foundry/tasra-sdk/chain` need only the SDK as a runtime dependency;
|
|
31
|
+
you do not need a separate crypto or Ethereum library to use the application API.
|
|
32
|
+
See the [manifest-first application guide](application-api.md).
|
|
33
|
+
|
|
34
|
+
For new applications, download a manifest from
|
|
35
|
+
[tasra-releases](https://github.com/t3foundry/tasra-releases) and load it with
|
|
36
|
+
`TasraClient.fromManifest(url, {sha256, coordinator})`. Remote manifest URLs require HTTPS unless an independently trusted SHA-256 pin is provided; loopback HTTP is allowed for development. Obtain the SHA-256 from a
|
|
37
|
+
trusted release pointer. Pass the deployment's coordinator convention explicitly;
|
|
38
|
+
the release schema does not specify it. Planned and retired manifests cannot
|
|
39
|
+
configure a live client. `check()` verifies the chain and registry availability,
|
|
40
|
+
not support for every service operation.
|
|
41
|
+
|
|
42
|
+
Advanced chain-only integrations can use `parsePinnedNetworkManifest`,
|
|
43
|
+
`addressBookFromManifest` and `observeNetworkManifest` from `@t3foundry/tasra-sdk/chain`.
|
|
44
|
+
|
|
45
|
+
## Typecheck a standalone Node tutorial
|
|
46
|
+
|
|
47
|
+
After installing the SDK and copying a complete example, add:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npm pkg set type=module
|
|
51
|
+
npm install --save-dev typescript tsx @types/node
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Save this as `tsconfig.json` beside the application's TypeScript files:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"compilerOptions": {
|
|
59
|
+
"target": "ES2022",
|
|
60
|
+
"module": "NodeNext",
|
|
61
|
+
"moduleResolution": "NodeNext",
|
|
62
|
+
"resolveJsonModule": true,
|
|
63
|
+
"strict": true,
|
|
64
|
+
"skipLibCheck": true,
|
|
65
|
+
"noEmit": true,
|
|
66
|
+
"types": ["node"]
|
|
67
|
+
},
|
|
68
|
+
"include": ["*.ts"]
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Run `npx tsc --noEmit`, then the lesson's `tsx` command. Explicit Node types make
|
|
73
|
+
imports such as `node:fs` available to the type checker. This configuration is for
|
|
74
|
+
the Node tutorial apps; browser and extension projects retain their own framework configuration.
|
|
75
|
+
|
|
76
|
+
**Using a coding agent?** Agent skills ship separately in the
|
|
77
|
+
[`@t3foundry/tasra-skills`](https://www.npmjs.com/package/@t3foundry/tasra-skills)
|
|
78
|
+
package — one folder per task (getting started, creating a slot, credentials,
|
|
79
|
+
DCQL rules, errors, signing, encryption, chain reads, the committee path, and
|
|
80
|
+
OID4VP). Installing the SDK does not register them; run
|
|
81
|
+
`npx @t3foundry/tasra-skills@latest init` and refresh copied skills after every
|
|
82
|
+
SDK upgrade.
|
|
83
|
+
|
|
84
|
+
Runs in the browser (Vite, Webpack, Next.js) and Node **≥22.12**. The SDK writes no state unless you supply a store. Node applications can use
|
|
85
|
+
`createFileStore` from `@t3foundry/tasra-sdk/app/node` for private, durable recovery state.
|
|
86
|
+
Browser and database applications provide their own `ApplicationStore` adapter.
|
|
87
|
+
Your product chooses where to keep credentials and exported identity keys.
|
|
88
|
+
|
|
89
|
+
## Module format
|
|
90
|
+
|
|
91
|
+
**This package is ESM-only** (`"type": "module"`, built with `tsc` under
|
|
92
|
+
`NodeNext`). There is no CommonJS build, and there deliberately won't be: the SDK
|
|
93
|
+
holds key material and session caches, and a dual ESM+CJS build would let two
|
|
94
|
+
copies of that state exist in one process.
|
|
95
|
+
|
|
96
|
+
You do not need a bundler or a transpile step. Modern Node and every current
|
|
97
|
+
bundler consume it directly:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import {TasraClient} from '@t3foundry/tasra-sdk/app' // ESM — application API
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
From CommonJS, both of these work on Node ≥22.12:
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
const sdk = require('@t3foundry/tasra-sdk/app') // Node ≥22.12 can require() an ES module
|
|
107
|
+
// Alternatively, load it asynchronously:
|
|
108
|
+
import('@t3foundry/tasra-sdk/app').then(sdk => { /* use sdk.TasraClient here */ })
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Compatibility
|
|
112
|
+
|
|
113
|
+
- **Node ≥ 22.12**, or any evergreen browser. WebCrypto (`crypto.subtle`,
|
|
114
|
+
`getRandomValues`) must be present — it is everywhere the above holds, but not
|
|
115
|
+
on an insecure-context browser page (`http://` off loopback).
|
|
116
|
+
- **ESM only** (above). `require()` works on Node ≥ 22.12 and nowhere older.
|
|
117
|
+
- **Wire compatibility with the network is fixed per SDK version, not negotiated at runtime.**
|
|
118
|
+
Every node, verifier and verifier-agent endpoint the SDK calls is under `/v1/`. The SDK
|
|
119
|
+
does not check a node's version or feature set; a mismatch surfaces as an
|
|
120
|
+
HTTP 404/403 at call time (`TasraHttpError`). Some routes are
|
|
121
|
+
per-deployment feature gates — threshold ECDSA (`/v1/sign/eoa-digest`) and
|
|
122
|
+
the admin scope among them — and `nodeApi.info()` in `@t3foundry/tasra-sdk/chain`
|
|
123
|
+
reports which are on.
|
|
124
|
+
|
|
125
|
+
Confirm operation support on the selected network before using protected routes.
|
|
126
|
+
A manifest or successful public read does not prove signing, authorization or
|
|
127
|
+
decryption compatibility.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
[Back to the README](../README.md) · [Documentation index](README.md)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Manage your slot
|
|
2
|
+
|
|
3
|
+
**Goal:** understand the slot lifecycle: create, read, renew and cancel.
|
|
4
|
+
A slot is an on-chain resource, so cancellation preserves its history.
|
|
5
|
+
|
|
6
|
+
| Action | SDK operation |
|
|
7
|
+
|---|---|
|
|
8
|
+
| Create | `tasra.slots.create(...)` |
|
|
9
|
+
| Read | `tasra.slots.get(slotId)` |
|
|
10
|
+
| Update its lease | `lifecycle.renewSlot(slotId)` |
|
|
11
|
+
| Stop using it | `lifecycle.cancelSlot(slotId)` |
|
|
12
|
+
|
|
13
|
+
The creator wallet performs management transactions. A user's signing credential
|
|
14
|
+
does not grant these administrative rights.
|
|
15
|
+
|
|
16
|
+
## Renew the lease
|
|
17
|
+
|
|
18
|
+
Run this when you want to extend the slot's lifetime. Renewal is a transaction
|
|
19
|
+
and needs native tokens for gas. Each execution requests another renewal.
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
cp node_modules/@t3foundry/tasra-sdk/examples/learning-renew-slot.ts .
|
|
23
|
+
npx tsc --noEmit
|
|
24
|
+
npx tsx learning-renew-slot.ts
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
<!-- learning-renew-slot-example -->
|
|
28
|
+
```ts
|
|
29
|
+
import {createTasraWriteClient} from '@t3foundry/tasra-sdk/chain'
|
|
30
|
+
import {savedCreator, savedSlotId, tasra} from './learning-context.js'
|
|
31
|
+
|
|
32
|
+
const slotId = await savedSlotId()
|
|
33
|
+
const creator = await savedCreator()
|
|
34
|
+
const lifecycle = createTasraWriteClient({...tasra.deployment, wallet: creator.wallet})
|
|
35
|
+
const before = await tasra.chain.readers.keyRegistry.getKeySlot(slotId)
|
|
36
|
+
const transaction = await lifecycle.renewSlot(slotId)
|
|
37
|
+
const after = await tasra.chain.readers.keyRegistry.getKeySlot(slotId)
|
|
38
|
+
console.log('Confirmed transaction:', transaction)
|
|
39
|
+
console.log('Previous lease expiry:', before.expiry)
|
|
40
|
+
console.log('Current lease expiry:', after.expiry)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Success:** a confirmed transaction hash and the previous/current lease expiry.
|
|
44
|
+
The chain writer handles administration; `TasraClient.slots` handles application use.
|
|
45
|
+
|
|
46
|
+
## Cancel when finished
|
|
47
|
+
|
|
48
|
+
Keep the slot active if you want to use it in the next lessons.
|
|
49
|
+
Cancellation is final for this slot; it does not erase historical data or previously
|
|
50
|
+
exported keys.
|
|
51
|
+
|
|
52
|
+
<details>
|
|
53
|
+
<summary>Show cancellation commands and code</summary>
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
cp node_modules/@t3foundry/tasra-sdk/examples/learning-cancel-slot.ts .
|
|
57
|
+
npx tsc --noEmit
|
|
58
|
+
npx tsx learning-cancel-slot.ts --confirm-cancel
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
<!-- learning-cancel-slot-example -->
|
|
62
|
+
```ts
|
|
63
|
+
import {createTasraWriteClient} from '@t3foundry/tasra-sdk/chain'
|
|
64
|
+
import {savedCreator, savedSlotId, tasra} from './learning-context.js'
|
|
65
|
+
|
|
66
|
+
if (!process.argv.includes('--confirm-cancel')) throw new Error('Cancellation is final. Add --confirm-cancel only when finished with this slot.')
|
|
67
|
+
const slotId = await savedSlotId()
|
|
68
|
+
const creator = await savedCreator()
|
|
69
|
+
const lifecycle = createTasraWriteClient({...tasra.deployment, wallet: creator.wallet})
|
|
70
|
+
console.log('Confirmed transaction:', await lifecycle.cancelSlot(slotId))
|
|
71
|
+
// Cancelled slots remain visible in the registry's historical record.
|
|
72
|
+
const record = await tasra.chain.readers.keyRegistry.getKeySlot(slotId)
|
|
73
|
+
console.log('Cancelled:', record.cancelled)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Success:** `Cancelled: true`. The registry reader still returns the record;
|
|
77
|
+
`tasra.slots.get()` rejects a cancelled slot.
|
|
78
|
+
|
|
79
|
+
</details>
|
|
80
|
+
|
|
81
|
+
<details>
|
|
82
|
+
<summary>What about changing the key or access rule?</summary>
|
|
83
|
+
|
|
84
|
+
There is no generic `slots.update()` or `slots.delete()`. Key rotation and resharing
|
|
85
|
+
are advanced operations. The verifier policy is set once. Access-rule amendments
|
|
86
|
+
require authority configured at creation; the basic slot's rule is fixed.
|
|
87
|
+
See [advanced application behavior](application-api.md) when you need those controls.
|
|
88
|
+
|
|
89
|
+
Renew/cancel do not use the creation workflow's durable journal. Keep returned
|
|
90
|
+
transaction hashes. If a request fails after submission, reconcile it before
|
|
91
|
+
retrying; a timeout does not prove that the transaction failed.
|
|
92
|
+
|
|
93
|
+
</details>
|
|
94
|
+
|
|
95
|
+
**Next: [Build an app →](README.md#build-an-app)**
|