@akta/sdk 1.2.2 → 1.2.3

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 (2) hide show
  1. package/README.md +395 -751
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,274 +1,183 @@
1
- # ARC58 Wallet SDK
2
-
3
- A TypeScript SDK for interacting with ARC58 Abstracted Accounts on the Algorand blockchain. This SDK provides a high-level interface for creating and managing smart contract wallets with plugin-based functionality, escrow management, and spending allowances.
4
-
5
- ## Table of Contents
6
-
7
- - [Installation](#installation)
8
- - [Quick Start](#quick-start)
9
- - [Core Concepts](#core-concepts)
10
- - [Creating Wallets](#creating-wallets)
11
- - [Managing Plugins](#managing-plugins)
12
- - [Using Plugins](#using-plugins)
13
- - [Escrow Management](#escrow-management)
14
- - [Allowances](#allowances)
15
- - [Profile Management](#profile-management)
16
- - [Advanced Features](#advanced-features)
17
- - [Available Plugins](#available-plugins)
18
- - [Configuration](#configuration)
19
- - [API Reference](#api-reference)
1
+ # @akta/sdk
2
+
3
+ TypeScript SDK for the Akita protocol on Algorand. Provides high-level interfaces for ARC58 abstracted account wallets, social features, rewards, auctions, staking, subscriptions, and more.
20
4
 
21
5
  ## Installation
22
6
 
23
7
  ```bash
24
- npm install akita-sdk
8
+ npm install @akta/sdk
25
9
  # or
26
- pnpm add akita-sdk
10
+ pnpm add @akta/sdk
11
+ ```
12
+
13
+ **Peer dependencies:**
14
+
15
+ ```bash
16
+ npm install algosdk @algorandfoundation/algokit-utils
17
+ ```
18
+
19
+ ## Modules
20
+
21
+ The SDK is organized into sub-path exports. Import only what you need:
22
+
23
+ ```typescript
24
+ import { WalletSDK, WalletFactorySDK, PayPluginSDK } from '@akta/sdk/wallet'
25
+ import { SocialSDK } from '@akta/sdk/social'
26
+ import { RewardsSDK } from '@akta/sdk/rewards'
27
+ import { AuctionSDK, AuctionFactorySDK } from '@akta/sdk/auction'
28
+ import { AkitaDaoSDK } from '@akta/sdk/dao'
29
+ import { StakingSDK } from '@akta/sdk/staking'
30
+ import { StakingPoolSDK, StakingPoolFactorySDK } from '@akta/sdk/staking-pool'
31
+ import { SubscriptionsSDK } from '@akta/sdk/subscriptions'
32
+ import { MarketplaceSDK } from '@akta/sdk/marketplace'
33
+ import { EscrowSDK, EscrowFactorySDK } from '@akta/sdk/escrow'
34
+ import { PollSDK, PollFactorySDK } from '@akta/sdk/poll'
35
+ import { RaffleSDK, RaffleFactorySDK } from '@akta/sdk/raffle'
36
+ import { PrizeBoxSDK, PrizeBoxFactorySDK } from '@akta/sdk/prize-box'
37
+ import { GateSDK } from '@akta/sdk/gates'
38
+ import { HyperSwapSDK } from '@akta/sdk/hyper-swap'
39
+ import { MetaMerklesSDK } from '@akta/sdk/meta-merkles'
40
+ ```
41
+
42
+ Or import everything from the root:
43
+
44
+ ```typescript
45
+ import { WalletSDK, SocialSDK, RewardsSDK, getNetworkAppIds } from '@akta/sdk'
27
46
  ```
28
47
 
29
48
  ## Quick Start
30
49
 
31
50
  ```typescript
32
- import { AlgorandClient, microAlgo } from '@algorandfoundation/algokit-utils';
33
- import { newWallet, PayPluginSDK, WalletSDK } from 'akita-sdk/wallet';
51
+ import { AlgorandClient, microAlgo } from '@algorandfoundation/algokit-utils'
52
+ import { newWallet, PayPluginSDK } from '@akta/sdk/wallet'
34
53
 
35
- // Initialize Algorand client
36
- const algorand = AlgorandClient.fromEnvironment();
54
+ const algorand = AlgorandClient.fromEnvironment()
37
55
 
38
- // Create a new wallet
56
+ // Create a wallet
39
57
  const wallet = await newWallet({
40
58
  algorand,
41
- factoryParams: {
42
- appId: WALLET_FACTORY_APP_ID,
43
- defaultSender: myAddress,
44
- defaultSigner: mySigner,
45
- },
59
+ factoryParams: { appId: WALLET_FACTORY_APP_ID, defaultSender: myAddress, defaultSigner: mySigner },
46
60
  sender: myAddress,
47
61
  signer: mySigner,
48
62
  nickname: 'my_wallet',
49
- });
63
+ })
50
64
 
51
- // Initialize a plugin SDK
52
- const payPlugin = new PayPluginSDK({
53
- factoryParams: { appId: PAY_PLUGIN_APP_ID },
54
- algorand,
55
- });
56
-
57
- // Calculate MBR and fund the wallet for plugins
58
- const mbr = await wallet.getMbr({ escrow: '', methodCount: 0n, plugin: '', groups: 0n });
59
- await wallet.client.appClient.fundAppAccount({
60
- amount: microAlgo(mbr.plugins + 1_000_000n) // MBR + 1 ALGO for payments
61
- });
65
+ // Install a plugin
66
+ const payPlugin = new PayPluginSDK({ factoryParams: { appId: PAY_PLUGIN_APP_ID }, algorand })
67
+ await wallet.addPlugin({ client: payPlugin, global: true })
62
68
 
63
- // Add the plugin to your wallet (global access)
64
- await wallet.addPlugin({
65
- client: payPlugin,
66
- global: true,
67
- });
68
-
69
- // Send a payment through the wallet
69
+ // Send a payment
70
70
  await wallet.usePlugin({
71
71
  global: true,
72
+ consolidateFees: true,
72
73
  calls: [
73
74
  payPlugin.pay({
74
- payments: [
75
- { receiver: recipientAddress, amount: 1_000_000n, asset: 0n }
76
- ],
75
+ payments: [{ receiver: recipientAddress, amount: 1_000_000n, asset: 0n }],
77
76
  }),
78
77
  ],
79
- });
78
+ })
80
79
  ```
81
80
 
82
- ## Core Concepts
83
-
84
- ### Abstracted Accounts (ARC58)
85
-
86
- ARC58 wallets are smart contract-based accounts that provide:
87
-
88
- - **Plugin System**: Modular functionality through installable plugins
89
- - **Escrow Management**: Isolated spending pools for different purposes
90
- - **Allowances**: Fine-grained spending limits and rate controls
91
- - **Execution Keys**: Pre-authorized transaction batches
92
-
93
- ### SDK Components
94
-
95
- | Component | Description |
96
- |-----------|-------------|
97
- | `WalletFactorySDK` | Creates new wallet instances |
98
- | `WalletSDK` | Main wallet interface for all operations |
99
- | `PayPluginSDK`, etc. | Plugin-specific SDKs for transactions |
100
-
101
- ## Creating Wallets
102
-
103
- ### Using the `newWallet` Helper
104
-
105
- The recommended approach combines creation and registration:
106
-
107
- ```typescript
108
- import { newWallet, WalletSDK } from 'akita-sdk/wallet';
81
+ ## Configuration
109
82
 
110
- const wallet: WalletSDK = await newWallet({
111
- algorand,
112
- factoryParams: {
113
- appId: walletFactory.appId,
114
- defaultSender: sender,
115
- defaultSigner: signer,
116
- },
117
- readerAccount: sender, // Account used for read-only queries
118
- sender: sender,
119
- signer: signer,
120
- nickname: 'test_wallet',
121
- admin: customAdmin, // Optional: defaults to sender
122
- referrer: referrerAddress, // Optional: for referral tracking
123
- });
124
-
125
- // Verify wallet was created
126
- expect(wallet.client.appId).toBeGreaterThan(0n);
127
-
128
- // Check wallet state
129
- const walletState = await wallet.client.state.global.getAll();
130
- console.log('Admin:', walletState.admin);
131
- console.log('Nickname:', walletState.nickname);
132
- console.log('Controlled Address:', walletState.controlledAddress);
133
- ```
83
+ ### Network Detection
134
84
 
135
- ### Using the Factory Directly
85
+ The SDK automatically detects the network from the AlgorandClient URL, environment variables, or explicit configuration:
136
86
 
137
87
  ```typescript
138
- import { WalletFactorySDK } from 'akita-sdk/wallet';
88
+ import { setCurrentNetwork, getCurrentNetwork, getNetworkAppIds } from '@akta/sdk'
139
89
 
140
- const factory = new WalletFactorySDK({
141
- factoryParams: { appId: WALLET_FACTORY_APP_ID },
142
- algorand,
143
- });
90
+ setCurrentNetwork('mainnet')
91
+ const network = getCurrentNetwork() // 'mainnet' | 'testnet' | 'localnet'
144
92
 
145
- // Check creation cost
146
- const cost = await factory.cost();
147
- console.log('Wallet creation cost:', cost, 'microAlgos');
93
+ // Get all app IDs for the current network
94
+ const appIds = getNetworkAppIds()
95
+ ```
148
96
 
149
- // Create a new wallet
150
- const wallet = await factory.new({
151
- sender: myAddress,
152
- signer: mySigner,
153
- nickname: 'my_wallet',
154
- admin: adminAddress, // Optional: defaults to sender
155
- referrer: referrerAddress, // Optional: for referral tracking
156
- });
97
+ ### Environment Variables
157
98
 
158
- // Register the wallet with the escrow factory
159
- await wallet.register({ escrow: '' });
99
+ ```bash
100
+ ALGORAND_NETWORK=mainnet
101
+ WALLET_FACTORY_APP_ID=123456789
102
+ PAY_PLUGIN_APP_ID=123456791
103
+ # ... etc
160
104
  ```
161
105
 
162
- ### Getting an Existing Wallet
106
+ ### SDK Construction Pattern
107
+
108
+ All SDKs follow the same construction pattern:
163
109
 
164
110
  ```typescript
165
- const wallet = await factory.get({ appId: existingWalletAppId });
111
+ const sdk = new SomeSDK({
112
+ algorand, // AlgorandClient instance
113
+ factoryParams: { appId: APP_ID }, // App ID (or resolved from env/network)
114
+ readerAccount: readOnlyAddress, // Optional: for read-only queries
115
+ })
166
116
  ```
167
117
 
168
- ## Managing Plugins
169
-
170
- ### Funding the Wallet for Plugins
118
+ App IDs resolve in order: explicit param > environment variable > network config.
171
119
 
172
- Before adding plugins, calculate and fund the minimum balance requirement:
120
+ ---
173
121
 
174
- ```typescript
175
- // Calculate MBR for plugins
176
- const mbr = await wallet.getMbr({
177
- escrow: '', // Empty string for main wallet, or escrow name
178
- methodCount: 0n, // Number of method restrictions
179
- plugin: '', // Plugin identifier
180
- groups: 0n // Number of execution key groups
181
- });
182
-
183
- // Fund the wallet
184
- await wallet.client.appClient.fundAppAccount({
185
- amount: microAlgo(mbr.plugins)
186
- });
187
- ```
122
+ ## Wallet (ARC58 Abstracted Accounts)
188
123
 
189
- ### Adding a Global Plugin
124
+ The wallet module is the core of the SDK. ARC58 wallets are smart contract accounts with a plugin system, escrow management, and spending allowances.
190
125
 
191
- Global plugins can be used by anyone through the wallet:
126
+ ### Creating Wallets
192
127
 
193
128
  ```typescript
194
- import { PayPluginSDK } from 'akita-sdk/wallet';
129
+ import { newWallet, WalletFactorySDK } from '@akta/sdk/wallet'
195
130
 
196
- const payPlugin = new PayPluginSDK({
197
- factoryParams: { appId: PAY_PLUGIN_APP_ID },
131
+ // Recommended: newWallet helper (creates + registers in one call)
132
+ const wallet = await newWallet({
198
133
  algorand,
199
- });
134
+ factoryParams: { appId: WALLET_FACTORY_APP_ID, defaultSender: sender, defaultSigner: signer },
135
+ sender, signer,
136
+ nickname: 'my_wallet',
137
+ admin: customAdmin, // Optional: defaults to sender
138
+ referrer: referrerAddr, // Optional: referral tracking
139
+ })
200
140
 
201
- // Add plugin with global access (no method restrictions)
202
- await wallet.addPlugin({
203
- client: payPlugin,
204
- global: true,
205
- });
141
+ // Or use the factory directly
142
+ const factory = new WalletFactorySDK({ factoryParams: { appId: WALLET_FACTORY_APP_ID }, algorand })
143
+ const wallet = await factory.new({ sender, signer, nickname: 'my_wallet' })
144
+ await wallet.register({ escrow: '' })
206
145
 
207
- // Verify plugin was added
208
- const plugins = await wallet.getPlugins();
209
- expect(plugins.size).toBe(1);
146
+ // Get an existing wallet
147
+ const existing = await factory.get({ appId: existingWalletAppId })
210
148
  ```
211
149
 
212
- ### Adding a Caller-Specific Plugin
213
-
214
- Restrict plugin usage to a specific address:
150
+ ### Managing Plugins
215
151
 
216
152
  ```typescript
217
- const mbr = await wallet.getMbr({
218
- escrow: '',
219
- methodCount: 1n, // One method restriction
220
- plugin: '',
221
- groups: 0n
222
- });
153
+ import { PayPluginSDK, OptInPluginSDK, AsaMintPluginSDK } from '@akta/sdk/wallet'
223
154
 
224
- await wallet.client.appClient.fundAppAccount({
225
- amount: microAlgo(mbr.plugins)
226
- });
155
+ const payPlugin = new PayPluginSDK({ factoryParams: { appId: PAY_PLUGIN_APP_ID }, algorand })
227
156
 
228
- await wallet.addPlugin({
229
- client: payPlugin,
230
- caller: userAddress, // Only this address can use the plugin
231
- methods: [
232
- { name: payPlugin.pay(), cooldown: 0n }
233
- ]
234
- });
235
- ```
157
+ // Calculate and fund MBR
158
+ const mbr = await wallet.getMbr({ escrow: '', methodCount: 0n, plugin: '', groups: 0n })
159
+ await wallet.client.appClient.fundAppAccount({ amount: microAlgo(mbr.plugins) })
236
160
 
237
- ### Adding a Plugin with Cooldown
161
+ // Add a global plugin (anyone can use)
162
+ await wallet.addPlugin({ client: payPlugin, global: true })
238
163
 
239
- ```typescript
164
+ // Add a caller-specific plugin with cooldown
240
165
  await wallet.addPlugin({
241
166
  client: payPlugin,
242
- global: true,
243
- cooldown: 100n, // 100 second/round cooldown between uses
244
- useRounds: true, // Use round numbers instead of timestamps
245
- });
246
- ```
247
-
248
- ### Adding a Plugin with Method Cooldown
249
-
250
- ```typescript
251
- await wallet.addPlugin({
252
- client: payPlugin,
253
- caller: sender,
167
+ caller: userAddress,
254
168
  useRounds: true,
255
- methods: [
256
- { name: payPlugin.pay(), cooldown: 100n }, // 100 round cooldown per method
257
- ]
258
- });
259
- ```
169
+ methods: [{ name: payPlugin.pay(), cooldown: 100n }],
170
+ })
260
171
 
261
- ### Plugin with Expiration
262
-
263
- ```typescript
264
- await wallet.addPlugin({
265
- client: payPlugin,
266
- global: true,
267
- lastValid: 0n, // Plugin expires immediately (for testing)
268
- });
172
+ // Remove a plugin
173
+ await wallet.removePlugin({
174
+ plugin: payPlugin.appId,
175
+ caller: ALGORAND_ZERO_ADDRESS_STRING,
176
+ escrow: '',
177
+ })
269
178
  ```
270
179
 
271
- ### Plugin Options Reference
180
+ **Plugin options:**
272
181
 
273
182
  | Option | Type | Description |
274
183
  |--------|------|-------------|
@@ -286,672 +195,431 @@ await wallet.addPlugin({
286
195
  | `lastValid` | `bigint` | Plugin expiration round |
287
196
  | `admin` | `boolean` | Grant admin privileges |
288
197
 
289
- ### Removing a Plugin
198
+ ### Using Plugins
290
199
 
291
200
  ```typescript
292
- await wallet.removePlugin({
293
- plugin: payPlugin.appId,
294
- caller: ALGORAND_ZERO_ADDRESS_STRING, // For global plugins
295
- escrow: '',
296
- });
297
- ```
298
-
299
- ### Querying Plugins
300
-
301
- ```typescript
302
- // Get all plugins
303
- const plugins = await wallet.getPlugins();
304
-
305
- // Get a specific plugin by key
306
- const pluginInfo = wallet.plugins.get({
307
- plugin: payPlugin.appId,
308
- caller: ALGORAND_ZERO_ADDRESS_STRING,
309
- escrow: ''
310
- });
311
-
312
- // Check plugin state
313
- expect(pluginInfo).toBeDefined();
314
- expect(pluginInfo.lastCalled).toBeGreaterThan(0n);
315
- ```
316
-
317
- ## Using Plugins
318
-
319
- ### Basic Payment (ALGO)
320
-
321
- ```typescript
322
- // Fund wallet for payment
323
- const paymentAmount = 1_000_000n; // 1 ALGO
324
- await wallet.client.appClient.fundAppAccount({
325
- amount: microAlgo(paymentAmount)
326
- });
327
-
328
- // Send payment
329
- const results = await wallet.usePlugin({
201
+ // ALGO payment
202
+ await wallet.usePlugin({
330
203
  global: true,
204
+ consolidateFees: true,
331
205
  calls: [
332
206
  payPlugin.pay({
333
- payments: [{
334
- receiver: recipientAddress,
335
- asset: 0n, // 0 = ALGO
336
- amount: paymentAmount,
337
- }]
207
+ payments: [{ receiver: recipientAddress, asset: 0n, amount: 1_000_000n }],
338
208
  }),
339
- ]
340
- });
341
-
342
- expect(results.txIds.length).toBeGreaterThan(0);
343
- ```
209
+ ],
210
+ })
344
211
 
345
- ### Asset (ASA) Payment
212
+ // Multiple payments in one call
213
+ await wallet.usePlugin({
214
+ global: true,
215
+ consolidateFees: true,
216
+ calls: [
217
+ payPlugin.pay({
218
+ payments: [
219
+ { receiver: receiver1, asset: 0n, amount: 500_000n },
220
+ { receiver: receiver2, asset: assetId, amount: 100_000_000n },
221
+ ],
222
+ }),
223
+ ],
224
+ })
346
225
 
347
- ```typescript
348
- // First mint an asset
349
- const mintResults = await wallet.usePlugin({
226
+ // Mint an asset
227
+ await wallet.usePlugin({
350
228
  global: true,
229
+ consolidateFees: true,
351
230
  calls: [
352
231
  asaMintPlugin.mint({
353
232
  assets: [{
354
- assetName: 'Test Token',
355
- unitName: 'TEST',
356
- total: 1_000_000_000_000n,
357
- decimals: 6n,
233
+ assetName: 'Token', unitName: 'TKN', total: 1_000_000_000_000n, decimals: 6n,
358
234
  manager: wallet.client.appAddress.toString(),
359
235
  reserve: wallet.client.appAddress.toString(),
360
236
  freeze: ALGORAND_ZERO_ADDRESS_STRING,
361
237
  clawback: ALGORAND_ZERO_ADDRESS_STRING,
362
- defaultFrozen: false,
363
- url: 'https://test.token',
364
- }]
238
+ defaultFrozen: false, url: 'https://example.com',
239
+ }],
365
240
  }),
366
- ]
367
- });
368
-
369
- const assetId = mintResults.returns[1][0];
241
+ ],
242
+ })
370
243
 
371
- // Send ASA payment
244
+ // Opt into assets
372
245
  await wallet.usePlugin({
373
246
  global: true,
374
- calls: [
375
- payPlugin.pay({
376
- payments: [{
377
- receiver: recipientAddress,
378
- asset: assetId,
379
- amount: 100_000_000n, // 100 tokens
380
- }]
381
- }),
382
- ]
383
- });
247
+ calls: [optInPlugin.optIn({ assets: [assetId] })],
248
+ })
384
249
  ```
385
250
 
386
- ### Multiple Payments in One Call
251
+ ### Available Wallet Plugins
387
252
 
388
- ```typescript
389
- await wallet.usePlugin({
390
- global: true,
391
- calls: [
392
- payPlugin.pay({
393
- payments: [
394
- { receiver: receiver1, asset: 0n, amount: 500_000n },
395
- { receiver: receiver2, asset: 0n, amount: 750_000n },
396
- ]
397
- }),
398
- ]
399
- });
400
- ```
253
+ | Plugin | Import | Description |
254
+ |--------|--------|-------------|
255
+ | `PayPluginSDK` | `@akta/sdk/wallet` | ALGO and ASA payments |
256
+ | `OptInPluginSDK` | `@akta/sdk/wallet` | Asset opt-ins |
257
+ | `AsaMintPluginSDK` | `@akta/sdk/wallet` | ASA creation and configuration |
258
+ | `DAOPluginSDK` | `@akta/sdk/wallet` | DAO governance operations |
259
+ | `SocialPluginSDK` | `@akta/sdk/wallet` | Social features (posts, follows, votes) |
260
+ | `StakingPluginSDK` | `@akta/sdk/wallet` | Staking operations |
261
+ | `StakingPoolPluginSDK` | `@akta/sdk/wallet` | Staking pool interactions |
262
+ | `MarketplacePluginSDK` | `@akta/sdk/wallet` | NFT marketplace operations |
263
+ | `AuctionPluginSDK` | `@akta/sdk/wallet` | Auction operations |
264
+ | `RafflePluginSDK` | `@akta/sdk/wallet` | Raffle participation |
265
+ | `PollPluginSDK` | `@akta/sdk/wallet` | Voting and polls |
266
+ | `RewardsPluginSDK` | `@akta/sdk/wallet` | Rewards distribution and claiming |
267
+ | `SubscriptionsPluginSDK` | `@akta/sdk/wallet` | Subscription management |
268
+ | `HyperSwapPluginSDK` | `@akta/sdk/wallet` | Token swaps |
269
+ | `GatePluginSDK` | `@akta/sdk/wallet` | Access control gates |
270
+ | `NFDPluginSDK` | `@akta/sdk/wallet` | NFD (NFDomains) integration |
271
+
272
+ ### Escrow Management
401
273
 
402
- ### Mixed ALGO and ASA Payments
274
+ Escrows are isolated spending pools within a wallet:
403
275
 
404
276
  ```typescript
405
- await wallet.usePlugin({
406
- global: true,
407
- calls: [
408
- payPlugin.pay({
409
- payments: [
410
- { receiver: recipient, asset: 0n, amount: 500_000n }, // ALGO
411
- { receiver: recipient, asset: assetId, amount: 50_000_000n }, // ASA
412
- ]
413
- }),
414
- ]
415
- });
416
- ```
277
+ // Create escrow by adding a plugin with an escrow name
278
+ await wallet.addPlugin({ client: asaMintPlugin, global: true, escrow: 'mint_account' })
417
279
 
418
- ### Caller-Specific Plugin Usage
280
+ // Query escrows
281
+ const escrows = await wallet.getEscrows()
282
+ const escrowInfo = await wallet.getEscrow('mint_account')
419
283
 
420
- ```typescript
421
- // Use plugin as specific caller (not global)
422
- await wallet.usePlugin({
423
- sender: userAddress,
424
- signer: userSigner,
425
- calls: [
426
- payPlugin.pay({
427
- payments: [{
428
- receiver: recipient,
429
- amount: paymentAmount,
430
- asset: 0n,
431
- }]
432
- })
433
- ]
434
- });
284
+ // Lock/unlock, opt-in, and reclaim funds
285
+ await wallet.toggleEscrowLock({ name: 'savings' })
286
+ await wallet.optinEscrow({ name: 'savings', assets: [assetId] })
287
+ await wallet.reclaimFunds({ name: 'savings', funds: [[0n, 1_000_000n, false]] })
435
288
  ```
436
289
 
437
- ### Minting Assets
290
+ ### Allowances
291
+
292
+ Fine-grained spending limits for escrow-based plugins:
438
293
 
439
294
  ```typescript
440
- import { AsaMintPluginSDK } from 'akita-sdk/wallet';
295
+ import { isFlatAllowance, isWindowAllowance, isDripAllowance } from '@akta/sdk/wallet'
441
296
 
442
- const asaMintPlugin = new AsaMintPluginSDK({
443
- factoryParams: { appId: ASA_MINT_PLUGIN_APP_ID },
444
- algorand,
445
- });
297
+ // Flat: one-time spending limit
298
+ await wallet.addPlugin({
299
+ client: payPlugin, global: true, escrow: 'budget',
300
+ allowances: [{ type: 'flat', asset: 0n, amount: 10_000_000n }],
301
+ })
446
302
 
447
- await wallet.addPlugin({ client: asaMintPlugin, global: true });
303
+ // Window: resets periodically
304
+ await wallet.addPlugin({
305
+ client: payPlugin, global: true, escrow: 'monthly',
306
+ allowances: [{ type: 'window', asset: 0n, amount: 10_000_000n, interval: 100n, useRounds: true }],
307
+ })
448
308
 
449
- const results = await wallet.usePlugin({
450
- global: true,
451
- calls: [
452
- asaMintPlugin.mint({
453
- assets: [{
454
- assetName: 'Test Akita',
455
- unitName: 'TAKTA',
456
- total: 1_000_000_000_000n,
457
- decimals: 6n,
458
- manager: wallet.client.appAddress.toString(),
459
- reserve: wallet.client.appAddress.toString(),
460
- freeze: ALGORAND_ZERO_ADDRESS_STRING,
461
- clawback: ALGORAND_ZERO_ADDRESS_STRING,
462
- defaultFrozen: false,
463
- url: 'https://akita.community',
464
- }]
465
- }),
466
- ]
467
- });
309
+ // Drip: continuous accrual
310
+ await wallet.addPlugin({
311
+ client: payPlugin, global: true, escrow: 'salary',
312
+ allowances: [{ type: 'drip', asset: 0n, rate: 1_000_000n, interval: 10n, max: 10_000_000n, useRounds: true }],
313
+ })
468
314
 
469
- const assetId = results.returns[1][0];
470
- expect(assetId).toBeGreaterThan(0n);
315
+ // Use with funds request
316
+ await wallet.usePlugin({
317
+ escrow: 'budget', global: true,
318
+ calls: [payPlugin.pay({ payments: [{ receiver, amount: 5_000_000n, asset: 0n }] })],
319
+ fundsRequest: [{ amount: 5_000_000n, asset: 0n }],
320
+ })
471
321
  ```
472
322
 
473
- ### Opting Into Assets
323
+ ### Cost Estimation
474
324
 
475
- ```typescript
476
- import { OptInPluginSDK } from 'akita-sdk/wallet';
325
+ Preview transaction costs before sending:
477
326
 
478
- const optInPlugin = new OptInPluginSDK({
479
- factoryParams: { appId: OPTIN_PLUGIN_APP_ID },
480
- algorand,
481
- });
482
-
483
- await wallet.addPlugin({ client: optInPlugin, global: true });
484
-
485
- await wallet.usePlugin({
327
+ ```typescript
328
+ const prepared = await wallet.prepare.usePlugin({
486
329
  global: true,
487
- calls: [optInPlugin.optIn({ assets: [assetId] })]
488
- });
489
-
490
- // Verify wallet now holds the asset
491
- const walletInfo = await algorand.account.getInformation(wallet.client.appAddress);
492
- expect(walletInfo?.assets?.length).toBe(1);
493
- ```
330
+ calls: [payPlugin.pay({ payments: [{ receiver, amount: 1_000_000n, asset: 0n }] })],
331
+ })
494
332
 
495
- ## Escrow Management
333
+ console.log('Network fees:', prepared.expectedCost.networkFees)
334
+ console.log('Total cost:', prepared.expectedCost.totalAlgo)
496
335
 
497
- Escrows are isolated spending pools within the wallet.
336
+ const result = await prepared.send()
337
+ ```
498
338
 
499
- ### Creating an Escrow with a Plugin
339
+ ### Execution Keys
500
340
 
501
- Escrows are auto-created when adding plugins with an escrow name:
341
+ Pre-authorize transaction batches for future execution:
502
342
 
503
343
  ```typescript
504
- const escrow = 'mint_account';
505
- const mbr = await wallet.getMbr({ escrow, methodCount: 0n, plugin: '', groups: 0n });
506
-
507
- await wallet.client.appClient.fundAppAccount({
508
- amount: microAlgo(mbr.plugins + mbr.newEscrowMintCost)
509
- });
510
-
511
- await wallet.addPlugin({
512
- client: asaMintPlugin,
344
+ const { lease, firstValid, lastValid, ids: groups, atcs } = await wallet.build.usePlugin({
345
+ sender: executorAddress, signer: executorSigner,
346
+ lease: 'my_lease', windowSize: 2000n,
513
347
  global: true,
514
- escrow, // Creates escrow if it doesn't exist
515
- });
348
+ calls: [payPlugin.pay({ payments: [{ receiver, amount: 1_000_000n, asset: 0n }] })],
349
+ })
350
+
351
+ await wallet.addExecutionKey({ lease, groups, firstValid, lastValid })
516
352
 
517
- // Get escrow info
518
- const escrowInfo = await wallet.getEscrow(escrow);
519
- const escrowAddress = getApplicationAddress(escrowInfo.id).toString();
353
+ // Third party executes later
354
+ await atcs[0].submit(algorand.client.algod)
520
355
  ```
521
356
 
522
- ### Using Plugins with Escrow
357
+ ### Profile and Admin
523
358
 
524
359
  ```typescript
525
- await wallet.usePlugin({
526
- escrow: 'mint_account',
527
- global: true,
528
- calls: [
529
- asaMintPlugin.mint({
530
- assets: [{
531
- assetName: 'Test Token',
532
- unitName: 'TEST',
533
- total: 1_000_000_000_000n,
534
- decimals: 6n,
535
- manager: escrowAddress,
536
- reserve: escrowAddress,
537
- freeze: ALGORAND_ZERO_ADDRESS_STRING,
538
- clawback: ALGORAND_ZERO_ADDRESS_STRING,
539
- defaultFrozen: false,
540
- url: 'https://test.token',
541
- }]
542
- }),
543
- ]
544
- });
360
+ await wallet.setNickname({ nickname: 'alice' })
361
+ await wallet.setAvatar({ avatar: avatarAssetId })
362
+ await wallet.setBanner({ banner: bannerAssetId })
363
+ await wallet.setBio({ bio: 'Hello world' })
364
+ await wallet.changeAdmin({ newAdmin: newAdminAddress })
545
365
  ```
546
366
 
547
- ### Other Escrow Operations
367
+ ---
368
+
369
+ ## Social
370
+
371
+ On-chain social features including posts, votes, follows, reactions, and user profiles.
548
372
 
549
373
  ```typescript
550
- // Get all escrows
551
- const escrows = await wallet.getEscrows();
552
-
553
- // Lock/unlock an escrow
554
- await wallet.toggleEscrowLock({ name: 'savings' });
555
-
556
- // Opt escrow into assets
557
- await wallet.optinEscrow({
558
- name: 'savings',
559
- assets: [assetId1, assetId2],
560
- });
561
-
562
- // Reclaim funds from escrow
563
- await wallet.reclaimFunds({
564
- name: 'savings',
565
- funds: [
566
- [0n, 1_000_000n, false], // [assetId, amount, closeOut]
567
- [assetId1, 500_000n, true], // Close out the asset position
568
- ],
569
- });
374
+ import { SocialSDK } from '@akta/sdk/social'
375
+
376
+ const social = new SocialSDK({ factoryParams: { appId: SOCIAL_APP_ID }, algorand })
377
+
378
+ // Read state
379
+ const fees = await social.getSocialFees()
380
+ const meta = await social.getMeta(userAddress)
381
+ const post = await social.getPost(postRef)
382
+ const isFollowing = await social.isFollowing(follower, user)
383
+ const impact = await social.getUserImpact(address)
384
+ const isBanned = await social.isBanned(account)
385
+
386
+ // Write (typically called through wallet.usePlugin with SocialPluginSDK)
387
+ // Direct calls for admin operations:
388
+ await social.ban({ address: spammer })
389
+ await social.unban({ address: spammer })
390
+ await social.flagPost({ ref: postRef })
570
391
  ```
571
392
 
572
- ## Allowances
393
+ Social actions (post, vote, follow, react) are typically performed through the wallet's plugin system using `SocialPluginSDK`.
573
394
 
574
- Allowances define spending limits for escrow-based plugins.
395
+ ---
575
396
 
576
- ### Flat Allowance
397
+ ## Rewards
577
398
 
578
- A one-time spending limit:
399
+ Create and manage reward disbursements with on-chain allocation tracking.
579
400
 
580
401
  ```typescript
581
- const escrow = 'flat_allowance';
582
- const mbr = await wallet.getMbr({ escrow, methodCount: 0n, plugin: '', groups: 0n });
402
+ import { RewardsSDK } from '@akta/sdk/rewards'
583
403
 
584
- const asset = 0n;
585
- const allowed = 10_000_000n; // 10 ALGO limit
404
+ const rewards = new RewardsSDK({ factoryParams: { appId: REWARDS_APP_ID }, algorand })
586
405
 
587
- await wallet.client.appClient.fundAppAccount({
588
- amount: microAlgo(allowed + mbr.plugins + mbr.newEscrowMintCost + mbr.allowances)
589
- });
406
+ // Read state
407
+ const state = await rewards.getState()
408
+ const disbursement = await rewards.getDisbursement(disbursementId)
409
+ const disbursements = await rewards.getDisbursements()
410
+ const allocation = await rewards.getUserAllocation(address, disbursementId, assetId)
411
+ const hasAlloc = await rewards.hasAllocation(address, disbursementId, assetId)
590
412
 
591
- await wallet.addPlugin({
592
- client: payPlugin,
593
- global: true,
594
- escrow,
595
- allowances: [{
596
- type: 'flat',
597
- asset,
598
- amount: allowed
599
- }]
600
- });
601
-
602
- // Use allowance with funds request
603
- const amount = 6_000_000n;
604
- await wallet.usePlugin({
605
- escrow,
606
- global: true,
607
- calls: [
608
- payPlugin.pay({
609
- payments: [{ receiver: recipient, amount, asset }]
610
- })
611
- ],
612
- fundsRequest: [{ amount, asset }]
613
- });
413
+ // Admin: create and manage disbursements
414
+ const id = await rewards.createDisbursement({ title: 'Q1 Rewards', note: '...' })
415
+ await rewards.createUserAllocations({ disbursementId: id, allocations: [...] })
416
+ await rewards.createAsaUserAllocations({ disbursementId: id, asset: assetId, allocations: [...] })
417
+ await rewards.finalizeDisbursement({ disbursementId: id })
614
418
 
615
- // Check allowance state
616
- const allowanceInfo = wallet.allowances.get({ asset, escrow });
617
- if (isFlatAllowance(allowanceInfo)) {
618
- expect(allowanceInfo.spent).toEqual(amount);
619
- }
419
+ // Claiming (typically done through wallet.usePlugin with RewardsPluginSDK)
620
420
  ```
621
421
 
622
- ### Window Allowance
422
+ ---
623
423
 
624
- Spending limit that resets periodically:
424
+ ## Auctions
625
425
 
626
- ```typescript
627
- import { isWindowAllowance } from 'akita-sdk/wallet';
426
+ Create and manage auctions with bidding, raffle, and prize claiming.
628
427
 
629
- const escrow = 'window_allowance';
630
- const mbr = await wallet.getMbr({ escrow, methodCount: 0n, plugin: '', groups: 0n });
428
+ ```typescript
429
+ import { AuctionSDK, AuctionFactorySDK } from '@akta/sdk/auction'
631
430
 
632
- const allowed = 10_000_000n;
431
+ const factory = new AuctionFactorySDK({ factoryParams: { appId: AUCTION_FACTORY_APP_ID }, algorand })
633
432
 
634
- await wallet.client.appClient.fundAppAccount({
635
- amount: microAlgo((allowed * 2n) + mbr.plugins + mbr.newEscrowMintCost + mbr.allowances)
636
- });
433
+ // Create an auction
434
+ const auction = await factory.new({ ...auctionParams })
637
435
 
638
- await wallet.addPlugin({
639
- client: payPlugin,
640
- global: true,
641
- escrow,
642
- allowances: [{
643
- type: 'window',
644
- asset: 0n,
645
- amount: allowed, // 10 ALGO per window
646
- interval: 100n, // 100 rounds per window
647
- useRounds: true
648
- }]
649
- });
650
-
651
- // First payment succeeds
652
- await wallet.usePlugin({
653
- escrow,
654
- global: true,
655
- calls: [payPlugin.pay({ payments: [{ receiver, amount: 6_000_000n, asset: 0n }] })],
656
- fundsRequest: [{ amount: 6_000_000n, asset: 0n }]
657
- });
658
-
659
- // Second payment exceeds window allowance - fails
660
- try {
661
- await wallet.usePlugin({
662
- escrow,
663
- global: true,
664
- calls: [payPlugin.pay({ payments: [{ receiver, amount: 6_000_000n, asset: 0n }] })],
665
- fundsRequest: [{ amount: 6_000_000n, asset: 0n }]
666
- });
667
- } catch (e) {
668
- // ERR_ALLOWANCE_EXCEEDED
669
- }
436
+ // Read state
437
+ const state = await auction.state()
438
+ const isLive = await auction.isLive()
439
+ const bid = await auction.getBid(bidId)
440
+ const minBid = await auction.getMinimumBidAmount()
670
441
 
671
- // After 100+ rounds, allowance resets and payment succeeds again
442
+ // Participate (typically through wallet plugin)
443
+ await auction.bid({ amount: 5_000_000n })
444
+ await auction.claimPrize()
672
445
  ```
673
446
 
674
- ### Drip Allowance
447
+ ---
675
448
 
676
- Continuous accrual of spending power:
449
+ ## DAO
677
450
 
678
- ```typescript
679
- import { isDripAllowance } from 'akita-sdk/wallet';
451
+ Governance proposals with voting and execution.
680
452
 
681
- const escrow = 'drip_allowance';
682
- const mbr = await wallet.getMbr({ escrow, methodCount: 0n, plugin: '', groups: 0n });
453
+ ```typescript
454
+ import { AkitaDaoSDK } from '@akta/sdk/dao'
683
455
 
684
- const max = 10_000_000n;
456
+ const dao = new AkitaDaoSDK({ factoryParams: { appId: DAO_APP_ID }, algorand })
685
457
 
686
- await wallet.client.appClient.fundAppAccount({
687
- amount: microAlgo((max * 2n) + mbr.plugins + mbr.newEscrowMintCost + mbr.allowances)
688
- });
458
+ const state = await dao.getGlobalState()
459
+ const proposal = await dao.getProposal(proposalId)
460
+ const cost = await dao.proposalCost({ actions: [...] })
689
461
 
690
- await wallet.addPlugin({
691
- client: payPlugin,
692
- global: true,
693
- escrow,
694
- allowances: [{
695
- type: 'drip',
696
- asset: 0n,
697
- rate: 1_000_000n, // 1 ALGO per interval
698
- interval: 10n, // Every 10 rounds
699
- max, // Maximum accumulation: 10 ALGO
700
- useRounds: true
701
- }]
702
- });
703
-
704
- // Spend some of the initial max allowance
705
- await wallet.usePlugin({
706
- escrow,
707
- global: true,
708
- calls: [payPlugin.pay({ payments: [{ receiver, amount: 6_000_000n, asset: 0n }] })],
709
- fundsRequest: [{ amount: 6_000_000n, asset: 0n }]
710
- });
711
-
712
- // Check drip state
713
- const allowanceInfo = wallet.allowances.get({ asset: 0n, escrow });
714
- if (isDripAllowance(allowanceInfo)) {
715
- expect(allowanceInfo.lastLeftover).toEqual(max - 6_000_000n); // 4 ALGO remaining
716
- }
717
-
718
- // After 20 rounds, 2 ALGO drips back (20 / 10 * 1_000_000)
719
- // Total available: 4 ALGO + 2 ALGO = 6 ALGO
462
+ await dao.newProposal({ title: '...', actions: [...] })
463
+ await dao.voteProposal({ proposalId, vote: true })
464
+ await dao.finalizeProposal(proposalId)
465
+ await dao.executeProposal(proposalId)
720
466
  ```
721
467
 
722
- ## Profile Management
468
+ ---
723
469
 
724
- Set wallet profile information stored on-chain:
470
+ ## Staking
471
+
472
+ Asset staking with escrow-based reward tracking.
725
473
 
726
474
  ```typescript
727
- await wallet.setNickname({ nickname: 'alice_wallet' });
728
- await wallet.setAvatar({ avatar: avatarAssetId });
729
- await wallet.setBanner({ banner: bannerAssetId });
730
- await wallet.setBio({ bio: 'My awesome wallet!' });
475
+ import { StakingSDK } from '@akta/sdk/staking'
476
+ import { StakingPoolSDK, StakingPoolFactorySDK } from '@akta/sdk/staking-pool'
477
+
478
+ const staking = new StakingSDK({ factoryParams: { appId: STAKING_APP_ID }, algorand })
479
+
480
+ const check = await staking.softCheck({ address, asset: assetId })
481
+ const timeLeft = await staking.getTimeLeft({ address, asset: assetId })
482
+ const stakeInfo = await staking.getInfo({ address, stake: stakeId })
731
483
  ```
732
484
 
733
- ## Advanced Features
485
+ ---
734
486
 
735
- ### Execution Keys (Pre-authorized Transactions)
487
+ ## Subscriptions
736
488
 
737
- Build and authorize transaction batches for future execution by third parties:
489
+ On-chain subscription services with recurring payment support.
738
490
 
739
491
  ```typescript
740
- // Fund wallet for execution key MBR
741
- const mbr = await wallet.getMbr({ escrow: '', methodCount: 0n, plugin: '', groups: 2n });
742
- const paymentAmount = 1_000_000n;
743
-
744
- await wallet.client.appClient.fundAppAccount({
745
- amount: microAlgo(mbr.plugins + mbr.executions + paymentAmount)
746
- });
492
+ import { SubscriptionsSDK } from '@akta/sdk/subscriptions'
747
493
 
748
- // Add plugin with execution key requirement
749
- await wallet.addPlugin({
750
- client: payPlugin,
751
- global: true,
752
- useExecutionKey: true,
753
- useRounds: true
754
- });
494
+ const subs = new SubscriptionsSDK({ factoryParams: { appId: SUBS_APP_ID }, algorand })
755
495
 
756
- // Build execution groups
757
- const { lease, firstValid, lastValid, ids: groups, atcs } = await wallet.build.usePlugin({
758
- sender: executorAddress,
759
- signer: executorSigner,
760
- lease: 'my_lease',
761
- windowSize: 2000n, // Valid for 2000 rounds
762
- global: true,
763
- calls: [
764
- payPlugin.pay({
765
- payments: [{
766
- receiver: recipient,
767
- amount: paymentAmount,
768
- asset: 0n,
769
- }]
770
- })
771
- ]
772
- });
773
-
774
- // Register the execution key
775
- await wallet.addExecutionKey({ lease, groups, firstValid, lastValid });
776
-
777
- // Third party can now execute the pre-built transaction
778
- await atcs[0].submit(algorand.client.algod);
779
-
780
- // Remove execution key when done
781
- await wallet.removeExecutionKey({ lease });
496
+ const serviceCost = await subs.newServiceCost()
497
+ const subCost = await subs.newSubscriptionCost({ asset: 0n, amount: 1_000_000n })
498
+ const isBlocked = await subs.isBlocked(address, blockedAddress)
782
499
  ```
783
500
 
784
- ### Prepared Transactions (Cost Estimation)
501
+ ---
785
502
 
786
- Preview costs before sending:
503
+ ## Other Modules
787
504
 
788
- ```typescript
789
- const prepared = await wallet.prepare.usePlugin({
790
- global: true,
791
- calls: [
792
- payPlugin.pay({
793
- payments: [{ receiver: recipient, amount: 1_000_000n, asset: 0n }],
794
- }),
795
- ],
796
- });
505
+ ### Marketplace
797
506
 
798
- console.log('Network fees:', prepared.expectedCost.networkFees);
799
- console.log('Inner txn fees:', prepared.expectedCost.innerTxnFees);
800
- console.log('Total cost:', prepared.expectedCost.total);
801
- console.log('Was simulated:', prepared.simulated);
507
+ NFT marketplace listings and sales.
802
508
 
803
- // Send when ready
804
- const result = await prepared.send();
509
+ ```typescript
510
+ import { MarketplaceSDK } from '@akta/sdk/marketplace'
805
511
  ```
806
512
 
807
- ### Admin Operations
513
+ ### Polls
514
+
515
+ On-chain voting polls.
808
516
 
809
517
  ```typescript
810
- // Change wallet admin
811
- await wallet.changeAdmin({ newAdmin: newAdminAddress });
518
+ import { PollSDK, PollFactorySDK } from '@akta/sdk/poll'
519
+ ```
520
+
521
+ ### Raffles
812
522
 
813
- // Get current admin
814
- const admin = await wallet.getAdmin();
523
+ Weighted raffle drawings.
815
524
 
816
- // Verify auth address is correct
817
- await wallet.verifyAuthAddress();
525
+ ```typescript
526
+ import { RaffleSDK, RaffleFactorySDK } from '@akta/sdk/raffle'
818
527
  ```
819
528
 
820
- ### Querying Wallet State
529
+ ### Prize Boxes
530
+
531
+ Prize storage and distribution containers.
821
532
 
822
533
  ```typescript
823
- // Get all global state
824
- const state = await wallet.getGlobalState();
825
- console.log('Admin:', state.admin);
826
- console.log('Nickname:', state.nickname);
827
- console.log('Controlled Address:', state.controlledAddress);
828
- console.log('Last User Interaction:', state.lastUserInteraction);
829
- console.log('Factory App:', state.factoryApp);
830
-
831
- // Get wallet balances
832
- const balances = await wallet.balance([0n, assetId1, assetId2]);
833
-
834
- // Get account information
835
- const walletInfo = await algorand.account.getInformation(wallet.client.appAddress);
836
- console.log('Balance:', walletInfo.balance.microAlgos);
837
- console.log('Min Balance:', walletInfo.minBalance.microAlgos);
838
- console.log('Assets:', walletInfo.assets?.length);
534
+ import { PrizeBoxSDK, PrizeBoxFactorySDK } from '@akta/sdk/prize-box'
839
535
  ```
840
536
 
841
- ## Available Plugins
537
+ ### Gates
842
538
 
843
- The SDK includes pre-built plugins for common operations:
844
-
845
- | Plugin | Description |
846
- |--------|-------------|
847
- | `PayPluginSDK` | Send ALGO and ASA payments |
848
- | `OptInPluginSDK` | Opt into assets |
849
- | `AsaMintPluginSDK` | Create and configure ASAs |
850
- | `DAOPluginSDK` | DAO governance operations |
851
- | `SocialPluginSDK` | Social features (posts, follows) |
852
- | `StakingPluginSDK` | Staking operations |
853
- | `StakingPoolPluginSDK` | Staking pool interactions |
854
- | `MarketplacePluginSDK` | NFT marketplace operations |
855
- | `AuctionPluginSDK` | Auction operations |
856
- | `RafflePluginSDK` | Raffle participation |
857
- | `PollPluginSDK` | Voting and polls |
858
- | `RewardsPluginSDK` | Rewards distribution |
859
- | `SubscriptionsPluginSDK` | Subscription management |
860
- | `HyperSwapPluginSDK` | Token swaps |
861
- | `GatePluginSDK` | Access control gates |
862
- | `NFDPluginSDK` | NFD (NFDomains) integration |
863
-
864
- ### Plugin SDK Pattern
865
-
866
- All plugins follow a consistent pattern:
539
+ Access control and token gating.
867
540
 
868
541
  ```typescript
869
- import { SomePluginSDK } from 'akita-sdk/wallet';
542
+ import { GateSDK } from '@akta/sdk/gates'
543
+ ```
870
544
 
871
- const plugin = new SomePluginSDK({
872
- factoryParams: { appId: PLUGIN_APP_ID },
873
- algorand,
874
- });
545
+ ### HyperSwap
875
546
 
876
- // Get method selector (for addPlugin method restrictions)
877
- const selector = plugin.someMethod();
547
+ Atomic asset swaps.
878
548
 
879
- // Execute method (for usePlugin calls)
880
- const call = plugin.someMethod({
881
- // method-specific args...
882
- });
549
+ ```typescript
550
+ import { HyperSwapSDK } from '@akta/sdk/hyper-swap'
883
551
  ```
884
552
 
885
- ## Configuration
553
+ ### Meta Merkles
886
554
 
887
- ### Network Detection
555
+ Merkle proof verification for airdrops and allowlists.
888
556
 
889
- The SDK automatically detects the network from:
557
+ ```typescript
558
+ import { MetaMerklesSDK } from '@akta/sdk/meta-merkles'
559
+ ```
890
560
 
891
- 1. Explicitly set network via `setCurrentNetwork()`
892
- 2. `ALGORAND_NETWORK` environment variable
893
- 3. AlgorandClient URL patterns
561
+ ---
894
562
 
895
- ```typescript
896
- import { setCurrentNetwork, getCurrentNetwork } from 'akita-sdk';
563
+ ## Akita Connect
897
564
 
898
- setCurrentNetwork('mainnet');
899
- const network = getCurrentNetwork(); // 'mainnet' | 'testnet' | 'localnet'
900
- ```
565
+ Protocol for cross-device agent installation and wallet connection.
901
566
 
902
- ### Environment Variables
567
+ ```typescript
568
+ import { encodeConnectUri, decodeConnectUri } from '@akta/sdk/connect'
569
+ import type { AkitaConnectUri, AgentInstallRequest, ConnectRequest, ConnectResponse } from '@akta/sdk/connect'
903
570
 
904
- Configure app IDs via environment variables:
571
+ // Encode a connect URI for QR codes
572
+ const uri = encodeConnectUri({ origin: 'https://signal.akita.community', requestId: 'uuid-here' })
905
573
 
906
- ```bash
907
- ALGORAND_NETWORK=mainnet
908
- WALLET_FACTORY_APP_ID=123456789
909
- WALLET_APP_ID=123456790
910
- PAY_PLUGIN_APP_ID=123456791
911
- OPTIN_PLUGIN_APP_ID=123456792
574
+ // Decode a scanned URI
575
+ const { origin, requestId } = decodeConnectUri(uri)
912
576
  ```
913
577
 
914
- ### Network-Specific App IDs
578
+ ### Agent Install Request
915
579
 
916
580
  ```typescript
917
- import { MAINNET_APP_IDS, TESTNET_APP_IDS, getNetworkAppIds } from 'akita-sdk';
918
-
919
- const appIds = getNetworkAppIds();
920
- console.log('Wallet Factory:', appIds.WALLET_FACTORY_APP_ID);
581
+ const request: AgentInstallRequest = {
582
+ type: 'agent-install',
583
+ v: 2,
584
+ agent: { name: 'My Agent', address: agentAddress },
585
+ network: 'mainnet',
586
+ escrowName: 'agent_escrow',
587
+ newAgentAccount: true,
588
+ plugins: [{ appId: '123', methods: ['pay'], global: true }],
589
+ allowances: [{ asset: '0', type: 'drip', amount: '1000000', interval: '100', useRounds: true }],
590
+ }
921
591
  ```
922
592
 
923
- ## API Reference
593
+ ---
924
594
 
925
- ### WalletFactorySDK
595
+ ## WalletSDK API Reference
926
596
 
927
- | Method | Description |
928
- |--------|-------------|
929
- | `new(params)` | Create a new wallet |
930
- | `get({ appId })` | Get existing wallet by app ID |
931
- | `cost()` | Get wallet creation cost |
597
+ ### Core
932
598
 
933
- ### WalletSDK
934
-
935
- #### Core Methods
936
599
  | Method | Description |
937
600
  |--------|-------------|
938
601
  | `register({ escrow })` | Register wallet with escrow factory |
939
602
  | `verifyAuthAddress()` | Verify wallet auth address |
940
603
  | `changeAdmin({ newAdmin })` | Change wallet admin |
941
604
  | `getMbr(params)` | Calculate MBR requirements |
605
+ | `getGlobalState()` | Get all global state |
606
+ | `getAdmin()` | Get admin address |
607
+ | `balance(assets)` | Get asset balances |
608
+
609
+ ### Plugins
942
610
 
943
- #### Plugin Management
944
611
  | Method | Description |
945
612
  |--------|-------------|
946
613
  | `addPlugin(params)` | Install a plugin |
947
614
  | `usePlugin(params)` | Execute plugin operations |
948
615
  | `removePlugin(params)` | Remove a plugin |
949
- | `getPlugins()` | Get all plugins |
616
+ | `getPlugins()` | Get all installed plugins |
950
617
  | `getPluginByKey(key)` | Get plugin by key |
951
618
  | `getNamedPlugins()` | Get named plugins map |
952
- | `getPluginByName(name)` | Get plugin by name |
619
+ | `canCall(params)` | Check if methods are callable |
620
+
621
+ ### Escrows
953
622
 
954
- #### Escrow Management
955
623
  | Method | Description |
956
624
  |--------|-------------|
957
625
  | `newEscrow({ name })` | Create new escrow |
@@ -961,7 +629,8 @@ console.log('Wallet Factory:', appIds.WALLET_FACTORY_APP_ID);
961
629
  | `optinEscrow({ name, assets })` | Opt escrow into assets |
962
630
  | `reclaimFunds({ name, funds })` | Reclaim funds from escrow |
963
631
 
964
- #### Allowance Management
632
+ ### Allowances
633
+
965
634
  | Method | Description |
966
635
  |--------|-------------|
967
636
  | `addAllowances({ escrow, allowances })` | Add spending allowances |
@@ -969,7 +638,8 @@ console.log('Wallet Factory:', appIds.WALLET_FACTORY_APP_ID);
969
638
  | `getAllowances()` | Get all allowances |
970
639
  | `getAllowance(key)` | Get specific allowance |
971
640
 
972
- #### Profile Management
641
+ ### Profile
642
+
973
643
  | Method | Description |
974
644
  |--------|-------------|
975
645
  | `setNickname({ nickname })` | Set wallet nickname |
@@ -977,48 +647,22 @@ console.log('Wallet Factory:', appIds.WALLET_FACTORY_APP_ID);
977
647
  | `setBanner({ banner })` | Set banner asset ID |
978
648
  | `setBio({ bio })` | Set bio text |
979
649
 
980
- #### Execution Keys
650
+ ### Execution Keys
651
+
981
652
  | Method | Description |
982
653
  |--------|-------------|
983
- | `addExecutionKey(params)` | Add execution key |
654
+ | `addExecutionKey(params)` | Register pre-authorized transactions |
984
655
  | `removeExecutionKey({ lease })` | Remove execution key |
985
656
  | `getExecutions()` | Get all executions |
986
657
  | `getExecution(lease)` | Get execution by lease |
987
658
 
988
- #### State Queries
989
- | Method | Description |
990
- |--------|-------------|
991
- | `getGlobalState()` | Get all global state |
992
- | `getAdmin()` | Get admin address |
993
- | `balance(assets)` | Get asset balances |
659
+ ### Advanced
994
660
 
995
- #### Advanced
996
661
  | Method | Description |
997
662
  |--------|-------------|
998
- | `prepare.usePlugin(params)` | Prepare with cost estimation |
999
- | `build.usePlugin(params)` | Build execution groups |
1000
-
1001
- ## Type Guards
1002
-
1003
- ```typescript
1004
- import { isFlatAllowance, isWindowAllowance, isDripAllowance } from 'akita-sdk/wallet';
1005
-
1006
- const allowance = wallet.allowances.get({ asset: 0n, escrow: 'my_escrow' });
1007
-
1008
- if (isFlatAllowance(allowance)) {
1009
- console.log('Spent:', allowance.spent, 'of', allowance.amount);
1010
- }
1011
-
1012
- if (isWindowAllowance(allowance)) {
1013
- console.log('Spent this window:', allowance.spent);
1014
- console.log('Window interval:', allowance.interval);
1015
- }
1016
-
1017
- if (isDripAllowance(allowance)) {
1018
- console.log('Leftover:', allowance.lastLeftover);
1019
- console.log('Drip rate:', allowance.rate, 'per', allowance.interval);
1020
- }
1021
- ```
663
+ | `prepare.usePlugin(params)` | Simulate and estimate costs |
664
+ | `build.usePlugin(params)` | Build execution groups for deferred execution |
665
+ | `group()` | Get a `WalletGroupComposer` for manual group building |
1022
666
 
1023
667
  ## License
1024
668