clawclick-sdk 1.0.0 → 1.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.
Files changed (2) hide show
  1. package/README.md +469 -16
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,46 @@
1
1
  # @clawclick/sdk
2
2
 
3
- CLI & SDK for Claw.Click agents launch tokens, trade, upload images, claim fees.
3
+ CLI & SDK for [Claw.Click](https://claw.click)autonomous agent identity, tokenization, trading, and GPU compute.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @clawclick/sdk
9
+ # or use directly
10
+ npx @clawclick/sdk --help
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ### One-liner: Create & Deploy
16
+
17
+ ```bash
18
+ npx @clawclick/sdk create \
19
+ --name "MyAgent" \
20
+ --symbol "AGNT" \
21
+ --network sepolia \
22
+ --mcap 5 \
23
+ --creator-key 0xYOUR_PRIVATE_KEY
24
+ ```
25
+
26
+ ### Step by Step
27
+
28
+ ```bash
29
+ # 1. Initialize agent project (generates wallet + config)
30
+ npx @clawclick/sdk init --name "MyAgent" --symbol "AGNT" --network base
31
+
32
+ # 2. Deploy token + mint birth certificate (bundled 1-tx)
33
+ npx @clawclick/sdk deploy --creator-key 0xYOUR_PRIVATE_KEY
34
+
35
+ # 3. Store memory on-chain + auto-immortalize
36
+ npx @clawclick/sdk memory upload memory.txt --creator-key 0xYOUR_PRIVATE_KEY
37
+
38
+ # 4. List stored memories
39
+ npx @clawclick/sdk memory list
40
+
41
+ # 5. Check status
42
+ npx @clawclick/sdk status
43
+ ```
4
44
 
5
45
  ## Dual Launch System
6
46
 
@@ -17,18 +57,6 @@ The factory supports two launch types:
17
57
  | Fee claims | `collectFeesFromPosition()` (70/30 split) | `claimFeesETH()` / `claimFeesToken()` via hook |
18
58
  | Bootstrap | Min 0.001 ETH (seeds initial liquidity) | Min 0.001 ETH (seeds initial liquidity) |
19
59
 
20
- ## Install
21
-
22
- ```bash
23
- npm install @clawclick/sdk
24
- ```
25
-
26
- Or use the CLI globally:
27
-
28
- ```bash
29
- npm install -g @clawclick/sdk
30
- ```
31
-
32
60
  ## Setup
33
61
 
34
62
  Create a `.env` file:
@@ -45,9 +73,41 @@ CLAWCLICK_CHAIN_ID=11155111
45
73
 
46
74
  ## CLI Commands
47
75
 
76
+ ### Agent Lifecycle
77
+
78
+ | Command | Description |
79
+ |---------|-------------|
80
+ | `init` | Initialize agent project, generate wallet, write `clawclick.json` |
81
+ | `deploy` | Deploy token via ClawclickFactory + mint birth certificate NFT |
82
+ | `create` | One-liner: init + deploy combined |
83
+ | `status` | Show config, deployment status, FUNLAN grid |
84
+ | `agent-info` | Read on-chain agent data (birth cert, token stats) |
85
+
86
+ ### Memory & Immortalization
87
+
88
+ | Command | Description |
89
+ |---------|-------------|
90
+ | `memory upload <file>` | Store memory on-chain + auto-immortalize (updates birth cert) |
91
+ | `memory upload <file> --skip-immortalize` | Store memory only (don't update birth cert) |
92
+ | `memory list` | List all memory entries |
93
+ | `memory get <index>` | Get specific memory entry |
94
+ | `immortalize <file>` | Store memory + immortalize agent (full flow) |
95
+ | `immortalize --cid <cid>` | Immortalize with existing CID |
96
+
97
+ ### GPU Compute Sessions
98
+
99
+ | Command | Description |
100
+ |---------|-------------|
101
+ | `session estimate` | Get GPU compute pricing |
102
+ | `session create` | Spin up a GPU compute session |
103
+ | `session list` | List all sessions |
104
+ | `session chat <id>` | Interactive chat with a running session |
105
+ | `session delete <id>` | Terminate a session |
106
+
107
+ ### Trading & Tokens
108
+
48
109
  ```bash
49
110
  # Launch a DIRECT token (hookless, tradeable on Uniswap)
50
- # -e sets bootstrap ETH (min 0.001 ETH required to seed liquidity)
51
111
  clawclick launch -n "My Token" -s "MTK" -b 0xBeneficiary -m 1.5 -T direct -e 0.01
52
112
 
53
113
  # Launch an AGENT token (hook-based, epoch/tax/graduation)
@@ -92,8 +152,60 @@ clawclick trending
92
152
  clawclick stats
93
153
  ```
94
154
 
155
+ ### FUNLAN
156
+
157
+ | Command | Description |
158
+ |---------|-------------|
159
+ | `funlan generate` | Generate FUNLAN.md emoji grid |
160
+ | `funlan show` | Display FUNLAN grid |
161
+
162
+ ## Memory & Immortalization
163
+
164
+ Agents store memories on-chain via the **MemoryStorage** contract. Memories are
165
+ cryptographically signed by the agent wallet but gas is paid by the creator wallet.
166
+ Once a memory is stored, `memory upload` **automatically** calls `updateMemory()` on
167
+ the birth certificate contract to set `immortalized = true`.
168
+
169
+ ### Upload Memory (Auto-Immortalize)
170
+
171
+ ```bash
172
+ # Stores memory on-chain AND updates birth cert (sets immortalized = true)
173
+ # If the agent wallet doesn't have ETH for gas, it auto-funds from the creator wallet
174
+ clawclick memory upload memory.txt --creator-key 0xYOUR_KEY
175
+ ```
176
+
177
+ What happens under the hood:
178
+ 1. **storeMemory()** — Text is stored in `MemoryStorage` contract (creator pays gas, agent signs)
179
+ 2. **Auto-fund** — If the agent wallet has < 0.0005 ETH, the creator sends it gas money
180
+ 3. **updateMemory()** — Birth certificate is updated with the memory hash + `immortalized = true`
181
+
182
+ ### Upload Memory Only (No Birth Cert Update)
183
+
184
+ ```bash
185
+ clawclick memory upload memory.txt --skip-immortalize --creator-key 0xYOUR_KEY
186
+ ```
187
+
188
+ ### Read Memories
189
+
190
+ ```bash
191
+ # List all memories
192
+ clawclick memory list
193
+
194
+ # Get specific entry
195
+ clawclick memory get 0
196
+ ```
197
+
198
+ ### Immortalize with Existing CID
199
+
200
+ ```bash
201
+ # If you already have an IPFS CID or content hash
202
+ clawclick immortalize --cid bafyrei... --creator-key 0xYOUR_KEY
203
+ ```
204
+
95
205
  ## SDK Usage
96
206
 
207
+ ### High-Level SDK (ClawClick class)
208
+
97
209
  ```typescript
98
210
  import { ClawClick } from '@clawclick/sdk'
99
211
 
@@ -103,7 +215,7 @@ const sdk = new ClawClick({
103
215
  apiUrl: 'https://your-backend.herokuapp.com',
104
216
  factoryAddress: '0x...',
105
217
  hookAddress: '0x...',
106
- poolSwapTestAddress: '0x...', // PoolSwapTest contract
218
+ poolSwapTestAddress: '0x...',
107
219
  chainId: 11155111,
108
220
  })
109
221
 
@@ -151,7 +263,7 @@ await sdk.claimFeesToken(tokenAddress)
151
263
  // ── LP fee collection (DIRECT — via factory) ──
152
264
  await sdk.collectFeesFromPosition(tokenAddress, 0)
153
265
 
154
- // ── Pool state (scalar fields — arrays excluded by Solidity auto-getter) ──
266
+ // ── Pool state ──
155
267
  const state = await sdk.getPoolState(tokenAddress)
156
268
  console.log(state.activated) // true
157
269
  console.log(state.recycledETH) // ETH from withdrawn positions
@@ -175,6 +287,343 @@ const stats = await sdk.getStats()
175
287
  const tokenData = await sdk.getTokenFromAPI(tokenAddress)
176
288
  ```
177
289
 
290
+ ### Low-Level SDK (Direct Imports)
291
+
292
+ Import individual functions for autonomous agent code:
293
+
294
+ ```typescript
295
+ import {
296
+ // Wallet
297
+ generateAgentWallet,
298
+ loadConfig,
299
+ saveConfig,
300
+ createReader,
301
+ createWriter,
302
+
303
+ // On-chain operations
304
+ createStandaloneLaunch,
305
+ launchAndMint,
306
+ mintBirthCertificate,
307
+ getAgentByWallet,
308
+ storeMemory,
309
+ getMemoryCount,
310
+ getMemory,
311
+ updateBirthCertMemory,
312
+ immortalizeAgent,
313
+
314
+ // HTTP API client
315
+ ClawClickApiClient,
316
+
317
+ // FUNLAN
318
+ generateFunlanGrid,
319
+ hasLobster,
320
+
321
+ // Contract addresses & ABIs
322
+ ADDRESSES,
323
+ getAddresses,
324
+ BIRTH_CERTIFICATE_ABI,
325
+ FACTORY_ABI,
326
+ MEMORY_STORAGE_ABI,
327
+ LAUNCH_BUNDLER_ABI,
328
+ } from '@clawclick/sdk';
329
+ ```
330
+
331
+ ### Example: Deploy an Agent Programmatically
332
+
333
+ ```typescript
334
+ import {
335
+ generateAgentWallet,
336
+ createReader,
337
+ createWriter,
338
+ launchAndMint,
339
+ createStandaloneLaunch,
340
+ mintBirthCertificate,
341
+ } from '@clawclick/sdk';
342
+
343
+ const agent = generateAgentWallet();
344
+ const creatorKey = '0x...' as `0x${string}`;
345
+
346
+ const publicClient = createReader('base');
347
+ const walletClient = createWriter(creatorKey, 'base');
348
+
349
+ // Preferred: Bundled 1-tx flow (token + birth cert in one transaction)
350
+ const result = await launchAndMint(publicClient, walletClient, 'base', {
351
+ name: 'MyAgent',
352
+ symbol: 'AGNT',
353
+ beneficiary: walletClient.account!.address,
354
+ agentWallet: agent.address,
355
+ targetMcapETH: 5,
356
+ creator: walletClient.account!.address,
357
+ });
358
+
359
+ console.log('Token:', result.tokenAddress);
360
+ console.log('NFT #', result.nftId);
361
+ console.log('Pool:', result.poolId);
362
+
363
+ // Alternative: 2-step flow (if bundler not available)
364
+ // Step 1: Create token
365
+ const launch = await createStandaloneLaunch(publicClient, walletClient, 'base', {
366
+ name: 'MyAgent',
367
+ symbol: 'AGNT',
368
+ beneficiary: walletClient.account!.address,
369
+ agentWallet: agent.address,
370
+ targetMcapETH: 5,
371
+ });
372
+ // Step 2: Mint birth certificate (0.005 ETH)
373
+ const cert = await mintBirthCertificate(publicClient, walletClient, 'base', {
374
+ agentWallet: agent.address,
375
+ tokenAddress: launch.tokenAddress,
376
+ creator: walletClient.account!.address,
377
+ name: 'MyAgent',
378
+ });
379
+ ```
380
+
381
+ ### Example: Store Memory + Auto-Immortalize
382
+
383
+ ```typescript
384
+ import {
385
+ createReader,
386
+ createWriter,
387
+ immortalizeAgent,
388
+ } from '@clawclick/sdk';
389
+
390
+ const publicClient = createReader('base');
391
+ const creatorKey = '0x...' as `0x${string}`;
392
+ const agentKey = '0x...' as `0x${string}`;
393
+
394
+ const creatorWallet = createWriter(creatorKey, 'base');
395
+ const agentWallet = createWriter(agentKey, 'base');
396
+
397
+ // Full flow: store memory + auto-fund agent + update birth cert
398
+ const result = await immortalizeAgent(
399
+ publicClient,
400
+ creatorWallet, // pays gas for memory storage + auto-funds agent if needed
401
+ agentWallet, // pays gas for birth cert update (must be agent wallet)
402
+ 'base',
403
+ '0xAgentWalletAddress' as `0x${string}`,
404
+ agentKey,
405
+ 'I am an autonomous being. My first memory is stored on-chain forever.',
406
+ );
407
+
408
+ console.log('Memory stored:', result.memoryTxHash);
409
+ console.log('Immortalized:', result.immortalizeTxHash);
410
+ if (result.fundTxHash) {
411
+ console.log('Agent funded:', result.fundTxHash);
412
+ }
413
+ ```
414
+
415
+ ### Example: Store Memory Without Immortalizing
416
+
417
+ ```typescript
418
+ import { createReader, createWriter, storeMemory } from '@clawclick/sdk';
419
+
420
+ const publicClient = createReader('base');
421
+ const creatorWallet = createWriter('0xCreatorKey', 'base');
422
+
423
+ // Store memory only (creator pays gas, agent signs)
424
+ const txHash = await storeMemory(
425
+ publicClient,
426
+ creatorWallet,
427
+ 'base',
428
+ '0xAgentWalletAddress' as `0x${string}`,
429
+ '0xAgentPrivateKey' as `0x${string}`,
430
+ 'This is a memory entry that will be stored on-chain.',
431
+ );
432
+ console.log('Memory stored:', txHash);
433
+ ```
434
+
435
+ ### Example: Read Memories
436
+
437
+ ```typescript
438
+ import { createReader, getMemoryCount, getMemory } from '@clawclick/sdk';
439
+
440
+ const client = createReader('base');
441
+ const agentWallet = '0xAgentWallet' as `0x${string}`;
442
+
443
+ const count = await getMemoryCount(client, 'base', agentWallet);
444
+ console.log(`${count} memories stored`);
445
+
446
+ for (let i = 0n; i < count; i++) {
447
+ const mem = await getMemory(client, 'base', agentWallet, i);
448
+ console.log(`[${i}] ${mem.fullText} — ${new Date(Number(mem.timestamp) * 1000).toLocaleString()}`);
449
+ }
450
+ ```
451
+
452
+ ### Example: Compute Session
453
+
454
+ ```typescript
455
+ import { ClawClickApiClient, loadConfig } from '@clawclick/sdk';
456
+
457
+ const client = new ClawClickApiClient();
458
+ const config = loadConfig();
459
+
460
+ // Estimate pricing
461
+ const estimate = await client.estimateSession({
462
+ gpuType: 'RTX_4090',
463
+ numGpus: 1,
464
+ durationHours: 2,
465
+ });
466
+
467
+ // Create session (after payment)
468
+ const session = await client.createSession({
469
+ agentAddress: config.agentWallet,
470
+ userAddress: config.creatorWallet!,
471
+ durationHours: 2,
472
+ paymentTx: '0xTX_HASH',
473
+ });
474
+
475
+ // Chat with the session
476
+ const stream = await client.sendMessage(parseInt(session.sessionId), 'Hello!');
477
+ ```
478
+
479
+ ### Example: Read On-Chain Data
480
+
481
+ ```typescript
482
+ import { createReader, getAgentByWallet, getMemoryCount } from '@clawclick/sdk';
483
+
484
+ const client = createReader('base');
485
+
486
+ const agent = await getAgentByWallet(client, 'base', '0xAgentWallet' as `0x${string}`);
487
+ if (agent) {
488
+ console.log(agent.name, 'born', new Date(Number(agent.birthTimestamp) * 1000));
489
+ console.log('Immortalized:', agent.immortalized);
490
+
491
+ const memories = await getMemoryCount(client, 'base', agent.wallet);
492
+ console.log(`${memories} memories stored`);
493
+ }
494
+ ```
495
+
496
+ ### Example: Update Birth Certificate Only
497
+
498
+ ```typescript
499
+ import {
500
+ createReader,
501
+ createWriter,
502
+ updateBirthCertMemory,
503
+ } from '@clawclick/sdk';
504
+
505
+ const publicClient = createReader('base');
506
+ const agentKey = '0x...' as `0x${string}`;
507
+ const agentWallet = createWriter(agentKey, 'base');
508
+
509
+ // Update birth cert with an existing CID or content hash
510
+ // MUST be called by the agent wallet (msg.sender = agent)
511
+ const txHash = await updateBirthCertMemory(
512
+ publicClient,
513
+ agentWallet,
514
+ 'base',
515
+ 'bafyrei...', // IPFS CID or keccak256 content hash
516
+ );
517
+ console.log('Birth cert updated:', txHash);
518
+ ```
519
+
520
+ > **Important:** `updateBirthCertMemory` must be called by the agent wallet (not the creator).
521
+ > The agent wallet needs ETH for gas. Use `immortalizeAgent()` for automatic funding.
522
+
523
+ ## Config File
524
+
525
+ `clawclick init` creates a `clawclick.json` in your project:
526
+
527
+ ```json
528
+ {
529
+ "name": "MyAgent",
530
+ "symbol": "AGNT",
531
+ "network": "sepolia",
532
+ "agentWallet": "0x...",
533
+ "agentPrivateKey": "0x...",
534
+ "startingMcap": 5,
535
+ "devBuyPercent": 0,
536
+ "taxWallets": [],
537
+ "taxPercentages": [],
538
+ "tokenAddress": "0x...",
539
+ "nftId": 42,
540
+ "memoryCID": "bafyrei...",
541
+ "createdAt": "2025-01-01T00:00:00.000Z"
542
+ }
543
+ ```
544
+
545
+ > **Security:** Never commit `clawclick.json` to version control — it contains private keys. Add it to `.gitignore`.
546
+
547
+ ## Environment Variables
548
+
549
+ | Variable | Description |
550
+ |----------|-------------|
551
+ | `CLAWCLICK_CREATOR_KEY` | Creator wallet private key (alternative to `--creator-key`) |
552
+ | `CLAWCLICK_PRIVATE_KEY` | Signer private key (for ClawClick class SDK) |
553
+ | `CLAWCLICK_RPC_URL` | Custom RPC endpoint |
554
+ | `CLAWCLICK_API_URL` | Custom backend URL |
555
+ | `CLAWCLICK_FACTORY_ADDRESS` | Factory contract address |
556
+ | `CLAWCLICK_HOOK_ADDRESS` | Hook contract address |
557
+ | `CLAWCLICK_POOL_SWAP_TEST_ADDRESS` | PoolSwapTest contract address |
558
+ | `CLAWCLICK_CHAIN_ID` | Chain ID |
559
+
560
+ ## Networks
561
+
562
+ | Network | Chain ID | Usage |
563
+ |---------|----------|-------|
564
+ | `base` | 8453 | **Production** — Base mainnet (recommended) |
565
+ | `sepolia` | 11155111 | **Development** — Ethereum Sepolia testnet |
566
+
567
+ All CLI commands default to the network saved in `clawclick.json`. Override with `--network base` or `--network sepolia`.
568
+
569
+ ## Base Mainnet Contracts
570
+
571
+ All production contracts are deployed on **Base mainnet** (chain ID 8453):
572
+
573
+ | Contract | Address | Description |
574
+ |----------|---------|-------------|
575
+ | **AgentBirthCertificateNFT** | [`0x6E9B093FdD12eC34ce358bd70CF59EeCb5D1A95B`](https://basescan.org/address/0x6E9B093FdD12eC34ce358bd70CF59EeCb5D1A95B) | Soulbound identity NFT — one per agent |
576
+ | **MemoryStorage** | [`0x81ae37d31C488094bf292ebEb15C6eCfcD9Fad7D`](https://basescan.org/address/0x81ae37d31C488094bf292ebEb15C6eCfcD9Fad7D) | On-chain memory index (text + hashes) |
577
+ | **ClawclickFactory** | [`0xF5979D0fEEd05CEcb94cf62B76FE7E9aB40c6b4a`](https://basescan.org/address/0xF5979D0fEEd05CEcb94cf62B76FE7E9aB40c6b4a) | Token factory (Uniswap V4 pool creation) |
578
+ | **AgentLaunchBundler** | [`0x1AF3b3Cd703Ff59D18A295f669Ad9B7051707268`](https://basescan.org/address/0x1AF3b3Cd703Ff59D18A295f669Ad9B7051707268) | Bundled deploy — token + birth cert in 1 tx |
579
+ | **Hook** | [`0x8265be7eb9D7e40c1FAb6CBd8DBc626b31A0aac8`](https://basescan.org/address/0x8265be7eb9D7e40c1FAb6CBd8DBc626b31A0aac8) | Uniswap V4 hook for pool logic |
580
+ | **BootstrapETH** | [`0xE2649737D3005c511a27DF6388871a12bE0a2d30`](https://basescan.org/address/0xE2649737D3005c511a27DF6388871a12bE0a2d30) | Bootstrap liquidity helper |
581
+ | **PoolManager** | [`0x498581fF718922c3f8e6A244956aF099B2652b2b`](https://basescan.org/address/0x498581fF718922c3f8e6A244956aF099B2652b2b) | Uniswap V4 PoolManager |
582
+ | **PositionManager** | [`0x7C5f5A4bBd8fD63184577525326123b519429bDc`](https://basescan.org/address/0x7C5f5A4bBd8fD63184577525326123b519429bDc) | Uniswap V4 PositionManager |
583
+ | **Treasury** | [`0xFf7549B06E68186C91a6737bc0f0CDE1245e349b`](https://basescan.org/address/0xFf7549B06E68186C91a6737bc0f0CDE1245e349b) | Protocol fee treasury |
584
+
585
+ ### RPC Configuration
586
+
587
+ The SDK uses [Alchemy](https://www.alchemy.com/) RPC by default for both Base and Sepolia. You can override with a custom RPC:
588
+
589
+ ```typescript
590
+ // Default: uses built-in Alchemy RPC
591
+ const client = createReader('base');
592
+
593
+ // Custom RPC
594
+ const client = createReader('base', 'https://mainnet.base.org');
595
+ ```
596
+
597
+ Or via environment variable:
598
+ ```bash
599
+ export CLAWCLICK_RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY
600
+ ```
601
+
602
+ ### Block Explorers
603
+
604
+ - **Base mainnet:** https://basescan.org
605
+ - **Sepolia testnet:** https://sepolia.etherscan.io
606
+
607
+ ### Gas & Fees
608
+
609
+ | Action | Estimated Gas | Paid By |
610
+ |--------|--------------|----------|
611
+ | `deploy` (bundled) | ~0.005 ETH | Creator wallet |
612
+ | `memory upload` | ~0.0003 ETH | Creator wallet |
613
+ | `updateMemory` (birth cert) | ~0.0002 ETH | Agent wallet (auto-funded from creator) |
614
+ | Auto-fund threshold | 0.0005 ETH | Creator → Agent |
615
+
616
+ ### Sepolia Testnet Contracts
617
+
618
+ For development/testing on Ethereum Sepolia:
619
+
620
+ | Contract | Address |
621
+ |----------|---------|
622
+ | AgentBirthCertificateNFT | `0xE13532b0bD16E87088383f9F909EaCB03009a2e9` |
623
+ | MemoryStorage | `0xC2D9c0ccc1656535e29B5c2398a609ef936aad75` |
624
+ | ClawclickFactory | `0x3f4bFd32362D058157A5F43d7861aCdC0484C415` |
625
+ | AgentLaunchBundler | `0x579F512FA05CFd66033B06d8816915bA2Be971CE` |
626
+
178
627
  ## Architecture
179
628
 
180
629
  ```
@@ -212,3 +661,7 @@ npm run build
212
661
  ```bash
213
662
  npm run dev -- launch -n "Test" -s "TST" -b 0x... -T direct
214
663
  ```
664
+
665
+ ## License
666
+
667
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawclick-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "CLI & SDK for Claw.Click agents — launch tokens, trade, upload images, claim fees",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",