@d13co/escreg-sdk 0.0.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/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # @d13co/escreg-sdk
2
+
3
+ [![npm](https://img.shields.io/npm/v/@d13co/escreg-sdk)](https://www.npmjs.com/package/@d13co/escreg-sdk)
4
+
5
+ TypeScript SDK for the [Escreg](https://github.com/d13co/escreg) on-chain escrow registry on Algorand.
6
+
7
+ Given any Algorand address, Escreg lets you answer: "Is this address an application escrow, and if so, which app ID owns it?"
8
+
9
+ The SDK wraps the generated typed client with batching, chunking, simulation-based lookups, and automatic opcode budget management.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @d13co/escreg-sdk
15
+ ```
16
+
17
+ Peer dependencies: `@algorandfoundation/algokit-utils` and `algosdk`.
18
+
19
+ ## Usage
20
+
21
+ ```typescript
22
+ import { EscregSDK } from '@d13co/escreg-sdk'
23
+
24
+ // Defaults to the current Fnet deployment (app ID, Algorand client)
25
+ const sdk = new EscregSDK({})
26
+
27
+ // Lookup addresses (via simulation, no signing required)
28
+ const results = await sdk.lookup({
29
+ addresses: ['A7NMWS3NT3IU...', 'B2XYZ...'],
30
+ concurrency: 4,
31
+ })
32
+ // results: { 'A7NMWS3NT3IU...': 1001n, 'B2XYZ...': undefined }
33
+
34
+ // For write operations, pass a writerAccount
35
+ const writer = new EscregSDK({ writerAccount })
36
+ await writer.register({ appIds: [1001n, 1002n, 1003n], concurrency: 4 })
37
+ ```
38
+
39
+ ### Constructor options
40
+
41
+ All options are optional and default to the current Fnet deployment.
42
+
43
+ | Option | Type | Description |
44
+ |---|---|---|
45
+ | `appId` | `bigint` | Escreg application ID |
46
+ | `algorand` | `AlgorandClient` | Algorand client instance |
47
+ | `writerAccount` | `TransactionSignerAccount` | Signing account for write operations |
48
+ | `readerAccount` | `string` | Address used as sender for read-only simulate calls |
49
+
50
+ ### Key behaviors
51
+
52
+ - **Register:** chunks app IDs into groups of 7 per transaction, 15 transactions per atomic group. Automatically prepends `increaseBudget` calls when opcode budget is insufficient. Retries failed chunks.
53
+ - **Lookup:** uses `simulate` with `allowEmptySignatures` so no signing key is needed. Chunks to 128 addresses per group, 63 per `getList` call.
54
+ - **MBR credits:** before registering, deposit credits via `depositCredit()` to cover box storage costs. Withdraw unused credits with `withdrawCredit()`.
55
+
56
+ ## API
57
+
58
+ | Method | Description |
59
+ |---|---|
60
+ | `lookup({ addresses, concurrency })` | Batch lookup addresses to app IDs (read-only, no signer needed) |
61
+ | `register({ appIds, concurrency, skipCheck })` | Batch register app IDs (requires `writerAccount`) |
62
+ | `depositCredit({ creditor, amount })` | Deposit MBR credits for an account |
63
+ | `withdrawCredit()` | Withdraw all remaining MBR credits |
64
+ | `deleteBoxes({ boxKeys, concurrency })` | Delete registry boxes by key (admin only) |
65
+ | `withdraw({ amount })` | Withdraw funds from the contract (admin only) |
66
+
67
+ ## License
68
+
69
+ ISC