@ar.io/sdk 3.19.0-alpha.9 → 3.20.0-alpha.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 CHANGED
@@ -2086,6 +2086,27 @@ const processId = await ANT.spawn({
2086
2086
  description: 'My custom ANT token',
2087
2087
  },
2088
2088
  });
2089
+
2090
+ // Using a custom module ID
2091
+ const processId = await ANT.spawn({
2092
+ signer: new ArweaveSigner(jwk),
2093
+ module: 'FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE', // Custom module ID
2094
+ state: {
2095
+ name: 'My Custom Module ANT',
2096
+ ticker: 'CUSTOM',
2097
+ description: 'ANT using a specific module version',
2098
+ },
2099
+ });
2100
+ ```
2101
+
2102
+ **CLI Usage:**
2103
+
2104
+ ```bash
2105
+ # Spawn ANT with default (latest) module
2106
+ ar.io spawn-ant --wallet-file wallet.json --name "My ANT" --ticker "MYANT"
2107
+
2108
+ # Spawn ANT with custom module ID
2109
+ ar.io spawn-ant --wallet-file wallet.json --module FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE --name "My Custom ANT" --ticker "CUSTOM"
2089
2110
  ```
2090
2111
 
2091
2112
  **Parameters:**
@@ -2204,6 +2225,15 @@ const state = await ant.getState();
2204
2225
  "transactionId": "2rMLb2uHAyEt7jSu6bXtKx8e-jOfIf7E-DOgQnm8EtU",
2205
2226
  "ttlSeconds": 3600
2206
2227
  },
2228
+ "alice": {
2229
+ "transactionId": "kMk95k_3R8x_7d3wB9tEOiL5v6n8QhR_VnFCh3aeE3f",
2230
+ "ttlSeconds": 900,
2231
+ "owner": "alice-wallet-address-123...",
2232
+ "displayName": "Alice's Portfolio",
2233
+ "logo": "avatar-tx-id-456...",
2234
+ "description": "Personal portfolio and blog",
2235
+ "keywords": ["portfolio", "personal", "blog"]
2236
+ },
2207
2237
  "whitepaper": {
2208
2238
  "transactionId": "lNjWn3LpyhKC95Kqe-x8X2qgju0j98MhucdDKK85vc4",
2209
2239
  "ttlSeconds": 900
@@ -2273,11 +2303,19 @@ const records = await ant.getRecords();
2273
2303
  "transactionId": "UyC5P5qKPZaltMmmZAWdakhlDXsBF6qmyrbWYFchRTk",
2274
2304
  "ttlSeconds": 3600
2275
2305
  },
2306
+ "alice": {
2307
+ "transactionId": "kMk95k_3R8x_7d3wB9tEOiL5v6n8QhR_VnFCh3aeE3f",
2308
+ "ttlSeconds": 900,
2309
+ "owner": "alice-wallet-address-123...",
2310
+ "displayName": "Alice's Portfolio",
2311
+ "logo": "avatar-tx-id-456...",
2312
+ "description": "Personal portfolio and blog",
2313
+ "keywords": ["portfolio", "personal", "blog"]
2314
+ },
2276
2315
  "zed": {
2277
2316
  "transactionId": "-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI",
2278
2317
  "ttlSeconds": 900
2279
2318
  },
2280
-
2281
2319
  "ardrive": {
2282
2320
  "transactionId": "-cucucachoodwedwedoiwepodiwpodiwpoidpwoiedp",
2283
2321
  "ttlSeconds": 900
@@ -2329,9 +2367,9 @@ const { id: txId } = await ant.removeController(
2329
2367
  );
2330
2368
  ```
2331
2369
 
2332
- #### `setBaseNameRecord({ transactionId, ttlSeconds })`
2370
+ #### `setBaseNameRecord({ transactionId, ttlSeconds, owner?, displayName?, logo?, description?, keywords? })`
2333
2371
 
2334
- Adds or updates the base name record for the ANT. This is the top level name of the ANT (e.g. ardrive.ar.io)
2372
+ Adds or updates the base name record for the ANT. This is the top level name of the ANT (e.g. ardrive.ar.io). Supports undername ownership delegation and metadata.
2335
2373
 
2336
2374
  _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2337
2375
 
@@ -2339,17 +2377,30 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2339
2377
  // get the ant for the base name
2340
2378
  const arnsRecord = await ario.getArNSRecord({ name: 'ardrive' });
2341
2379
  const ant = await ANT.init({ processId: arnsName.processId });
2380
+
2381
+ // Basic usage
2342
2382
  const { id: txId } = await ant.setBaseNameRecord({
2343
2383
  transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
2344
2384
  ttlSeconds: 3600,
2345
2385
  });
2346
2386
 
2347
- // ardrive.ar.io will now resolve to the provided 432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM transaction id
2387
+ // With ownership delegation and metadata
2388
+ const { id: txId } = await ant.setBaseNameRecord({
2389
+ transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
2390
+ ttlSeconds: 3600,
2391
+ owner: 'user-wallet-address-123...', // delegate ownership to another address
2392
+ displayName: 'ArDrive', // display name
2393
+ logo: 'logo-tx-id-123...', // logo transaction ID
2394
+ description: 'Decentralized storage application',
2395
+ keywords: ['storage', 'decentralized', 'web3'],
2396
+ });
2397
+
2398
+ // ardrive.ar.io will now resolve to the provided transaction id and include metadata
2348
2399
  ```
2349
2400
 
2350
- #### `setUndernameRecord({ undername, transactionId, ttlSeconds })`
2401
+ #### `setUndernameRecord({ undername, transactionId, ttlSeconds, owner?, displayName?, logo?, description?, keywords? })`
2351
2402
 
2352
- Adds or updates an undername record for the ANT. An undername is appended to the base name of the ANT (e.g. dapp_ardrive.ar.io)
2403
+ Adds or updates an undername record for the ANT. An undername is appended to the base name of the ANT (e.g. dapp_ardrive.ar.io). Supports undername ownership delegation and metadata.
2353
2404
 
2354
2405
  _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2355
2406
 
@@ -2358,6 +2409,8 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2358
2409
  ```typescript
2359
2410
  const arnsRecord = await ario.getArNSRecord({ name: 'ardrive' });
2360
2411
  const ant = await ANT.init({ processId: arnsName.processId });
2412
+
2413
+ // Basic usage
2361
2414
  const { id: txId } = await ant.setUndernameRecord(
2362
2415
  {
2363
2416
  undername: 'dapp',
@@ -2368,7 +2421,23 @@ const { id: txId } = await ant.setUndernameRecord(
2368
2421
  { tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
2369
2422
  );
2370
2423
 
2371
- // dapp_ardrive.ar.io will now resolve to the provided 432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM transaction id
2424
+ // With ownership delegation and metadata
2425
+ const { id: txId } = await ant.setUndernameRecord(
2426
+ {
2427
+ undername: 'alice',
2428
+ transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
2429
+ ttlSeconds: 900,
2430
+ owner: 'alice-wallet-address-123...', // delegate ownership to Alice
2431
+ displayName: "Alice's Site", // display name
2432
+ logo: 'avatar-tx-id-123...', // avatar/logo transaction ID
2433
+ description: 'Personal portfolio and blog',
2434
+ keywords: ['portfolio', 'personal', 'blog'],
2435
+ },
2436
+ { tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
2437
+ );
2438
+
2439
+ // dapp_ardrive.ar.io will now resolve to the provided transaction id
2440
+ // alice_ardrive.ar.io will be owned by Alice and include metadata
2372
2441
  ```
2373
2442
 
2374
2443
  #### `removeUndernameRecord({ undername })`
@@ -2616,6 +2685,121 @@ console.log(`Failed to reassign names: ${result.failedReassignedNames}`);
2616
2685
 
2617
2686
  **Returns:** `Promise<{ forkedProcessId: string, reassignedNames: Record<string, AoMessageResult>, failedReassignedNames: Record<string, { id?: string; error: Error }> }>`
2618
2687
 
2688
+ #### `transferRecord({ undername, recipient })`
2689
+
2690
+ Transfers ownership of a specific record (undername) to another address. This enables delegation of control for individual records within an ANT while maintaining the ANT owner's ultimate authority. The current record owner or ANT owner/controllers can transfer ownership.
2691
+
2692
+ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2693
+
2694
+ ```typescript
2695
+ const { id: txId } = await ant.transferRecord({
2696
+ undername: 'alice', // the subdomain/record to transfer
2697
+ recipient: 'new-owner-address-123...', // address of the new owner
2698
+ });
2699
+
2700
+ // alice_ardrive.ar.io is now owned by the new owner address
2701
+ // The new owner can update the record but not other records in the ANT
2702
+ ```
2703
+
2704
+ **CLI Usage:**
2705
+
2706
+ ```bash
2707
+ # Transfer ownership of a record using the CLI
2708
+ ar.io transfer-record \
2709
+ --process-id "ANT_PROCESS_ID" \
2710
+ --undername "alice" \
2711
+ --recipient "new-owner-address-123..." \
2712
+ --wallet-file "path/to/wallet.json"
2713
+ ```
2714
+
2715
+ ### Understanding Record Ownership
2716
+
2717
+ ANTs support ownership of undernames:
2718
+
2719
+ 1. **ANT Owner** - Has full control over the ANT and all records
2720
+ 2. **Controllers** - Can manage records but cannot transfer ANT ownership
2721
+ 3. **Record Owners** - Can only update their specific delegated records
2722
+
2723
+ **Record Owner Permissions:**
2724
+
2725
+ - ✅ Update their own record's `transactionId`, `ttlSeconds`, and metadata
2726
+ - ✅ Transfer ownership of their record to another address
2727
+ - ❌ Modify other records in the ANT
2728
+ - ❌ Add/remove controllers or transfer ANT ownership
2729
+
2730
+ <!-- prettier-ignore-start -->
2731
+ > [!CAUTION]
2732
+ > **Important:** When a record owner updates their own record, they **MUST** include their own address in the `owner` field. If the `owner` field is omitted or set to a different address, the record ownership will be transferred or renounced.
2733
+ <!-- prettier-ignore-end -->
2734
+
2735
+ #### Record Owner Workflow Examples
2736
+
2737
+ **Checking Record Ownership:**
2738
+
2739
+ ```typescript
2740
+ const record = await ant.getRecord({ undername: 'alice' });
2741
+ console.log(`Record owner: ${record.owner}`);
2742
+ console.log(`Transaction ID: ${record.transactionId}`);
2743
+ ```
2744
+
2745
+ **Record Owner Updating Their Own Record:**
2746
+
2747
+ ```typescript
2748
+ // Alice (record owner) updating her own record
2749
+ const aliceAnt = ANT.init({
2750
+ processId: 'ANT_PROCESS_ID',
2751
+ signer: new ArweaveSigner(aliceJwk), // Alice's wallet
2752
+ });
2753
+
2754
+ // ✅ CORRECT: Alice includes her own address as owner
2755
+ const { id: txId } = await aliceAnt.setUndernameRecord({
2756
+ undername: 'alice',
2757
+ transactionId: 'new-content-tx-id-456...',
2758
+ ttlSeconds: 1800,
2759
+ owner: 'alice-wallet-address-123...', // MUST be Alice's own address
2760
+ displayName: 'Alice Updated Portfolio',
2761
+ description: 'Updated personal portfolio and blog',
2762
+ });
2763
+
2764
+ // ❌ WRONG: Omitting owner field will renounce ownership
2765
+ const badUpdate = await aliceAnt.setUndernameRecord({
2766
+ undername: 'alice',
2767
+ transactionId: 'new-content-tx-id-456...',
2768
+ ttlSeconds: 1800,
2769
+ // Missing owner field - this will renounce ownership!
2770
+ });
2771
+
2772
+ // ❌ WRONG: Setting different owner will transfer ownership
2773
+ const badTransfer = await aliceAnt.setUndernameRecord({
2774
+ undername: 'alice',
2775
+ transactionId: 'new-content-tx-id-456...',
2776
+ ttlSeconds: 1800,
2777
+ owner: 'someone-else-address-789...', // This transfers ownership to someone else!
2778
+ });
2779
+ ```
2780
+
2781
+ **What Happens When Record Ownership is Renounced:**
2782
+
2783
+ If a record owner updates their record without including the `owner` field, the record becomes owned by the ANT owner/controllers again:
2784
+
2785
+ ```typescript
2786
+ // Before: alice record is owned by alice-wallet-address-123...
2787
+ const recordBefore = await ant.getRecord({ undername: 'alice' });
2788
+ console.log(recordBefore.owner); // "alice-wallet-address-123..."
2789
+
2790
+ // Alice updates without owner field
2791
+ await aliceAnt.setUndernameRecord({
2792
+ undername: 'alice',
2793
+ transactionId: 'new-tx-id...',
2794
+ ttlSeconds: 900,
2795
+ // No owner field = renounces ownership
2796
+ });
2797
+
2798
+ // After: record ownership reverts to ANT owner
2799
+ const recordAfter = await ant.getRecord({ undername: 'alice' });
2800
+ console.log(recordAfter.owner); // undefined (controlled by ANT owner again)
2801
+ ```
2802
+
2619
2803
  ### Configuration
2620
2804
 
2621
2805
  ANT clients can be configured to use custom AO process. Refer to [AO Connect] for more information on how to configure the AO process to use specific AO infrastructure.