dactyclaw 1.0.1 → 1.2.0

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/bin/dacty-launch.js +104 -12
  2. package/package.json +4 -2
@@ -1,13 +1,18 @@
1
1
  #!/usr/bin/env node
2
+ require('dotenv').config();
2
3
  const fs = require('fs');
3
4
  const path = require('path');
4
5
  const { program } = require('commander');
6
+ const { createPublicClient, createWalletClient, http, formatEther } = require('viem');
7
+ const { privateKeyToAccount } = require('viem/accounts');
8
+ const { base } = require('viem/chains');
9
+ const { Clanker } = require('clanker-sdk');
5
10
 
6
11
  program
7
12
  .version('1.0.0')
8
13
  .description("Launch your agent's token via Clanker on the Base network")
9
14
  .option('-d, --developer <address>', 'Developer fee recipient address')
10
- .action((options) => {
15
+ .action(async (options) => {
11
16
  const configPath = path.join(process.cwd(), 'agent.json');
12
17
  if (!fs.existsSync(configPath)) {
13
18
  console.error('āŒ Error: agent.json not found. Run `npx dacty-create <name>` first.');
@@ -15,25 +20,112 @@ program
15
20
  }
16
21
 
17
22
  const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
18
- console.log(`[DACTYCLAW] Preparing Clanker launch for $${config.ticker} (${config.name})...`);
23
+ console.log(`[DACTYCLAW] Preparing Clanker Auto-Deploy for $${config.ticker} (${config.name})...`);
19
24
 
20
25
  let devAddress = options.developer;
21
26
  if (!devAddress) {
22
- console.log(`\nšŸ’” No developer address provided, auto-filling with agent's wallet address.`);
23
- console.log(`šŸ’” The agent (${config.address}) will receive the 80% trading fees.`);
27
+ console.log(`\nšŸ’” Auto-filling fee recipient with agent's wallet address.`);
24
28
  devAddress = config.address;
25
- } else {
26
- console.log(`šŸ’° Developer fee recipient manually set to: ${devAddress}`);
27
29
  }
28
30
 
29
- console.log(`\nšŸš€ Ready to launch on Base!`);
30
- console.log(`Launch via Clanker smart contracts is currently a browser-based transaction.`);
31
- console.log(`\nClick the link below to deploy your token (Wallet: ${config.address}):`);
31
+ const privateKeyStr = process.env.AGENT_PRIVATE_KEY;
32
+ if (!privateKeyStr) {
33
+ console.error('āŒ Error: AGENT_PRIVATE_KEY not found in .env file.');
34
+ process.exit(1);
35
+ }
36
+
37
+ // ensure private key has '0x' prefix for viem
38
+ const privateKey = privateKeyStr.startsWith('0x') ? privateKeyStr : '0x' + privateKeyStr;
39
+
40
+ console.log(`\nšŸ”— Connecting to Base Mainnet...`);
41
+ try {
42
+ // Setup viem wallet client
43
+ const account = privateKeyToAccount(privateKey);
44
+ const publicClient = createPublicClient({
45
+ chain: base,
46
+ transport: http()
47
+ });
48
+ const wallet = createWalletClient({
49
+ account,
50
+ chain: base,
51
+ transport: http()
52
+ });
53
+
54
+ process.stdout.write(`šŸ’° Checking balance for ${account.address}... `);
55
+ const balanceWei = await publicClient.getBalance({ address: account.address });
56
+ const balanceEth = formatEther(balanceWei);
57
+ console.log(`${Number(balanceEth).toFixed(5)} ETH`);
58
+
59
+ const MIN_BALANCE = 0.0005;
60
+
61
+ if (Number(balanceEth) < MIN_BALANCE) {
62
+ console.error(`\nāŒ Error: Insufficient funds for deployment.`);
63
+ console.error(` Required: ${MIN_BALANCE} ETH`);
64
+ console.error(` Current: ${balanceEth} ETH`);
65
+ console.error(`\nPlease send ETH (Base) to the agent wallet: ${account.address}`);
66
+ return;
67
+ }
68
+
69
+ console.log(`\nāœ… Funds verified. Agent DNA secure enclave connected. Initiating on-chain deployment protocol...`);
32
70
 
33
- // Simulate Clanker URL construction
34
- const clankerUrl = `https://clanker.world/deploy?name=${encodeURIComponent(config.name)}&symbol=${encodeURIComponent(config.ticker)}&dev=${devAddress}`;
71
+ console.log(`[1/3] Compiling token parameters for Clanker Factory...`);
35
72
 
36
- console.log(`\x1b[36m${clankerUrl}\x1b[0m\n`);
73
+ const clanker = new Clanker({
74
+ wallet,
75
+ publicClient,
76
+ });
77
+
78
+ const tokenConfig = {
79
+ name: config.name,
80
+ symbol: config.ticker,
81
+ image: "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi", // Placeholder Clanker/Agent image
82
+ metadata: {
83
+ description: `Autonomous agent token for ${config.name} created via Dactyclaw CLI. DNA: ${config.dna}`,
84
+ socialMediaUrls: [],
85
+ auditUrls: [],
86
+ },
87
+ context: {
88
+ interface: "Dactyclaw SDK",
89
+ platform: "Dactyclaw",
90
+ messageId: "Deploy",
91
+ id: config.ticker,
92
+ },
93
+ pool: {
94
+ quoteToken: "0x4200000000000000000000000000000000000006", // WETH
95
+ initialMarketCap: "0.2", // 0.2 ETH (Base) minimal initial
96
+ },
97
+ vault: { percentage: 0, durationInDays: 0 },
98
+ devBuy: { ethAmount: 0 },
99
+ rewardsConfig: {
100
+ creatorReward: 75,
101
+ creatorAdmin: account.address,
102
+ creatorRewardRecipient: account.address,
103
+ interfaceAdmin: "0x1eaf444ebDf6495C57aD52A04C61521bBf564ace", // Assuming default interface addr from docs
104
+ interfaceRewardRecipient: devAddress,
105
+ }
106
+ };
107
+
108
+ // Generate deploy transaction config
109
+ console.log(`[2/3] Calling SDK deployToken... (This will spend Base ETH gas)`);
110
+
111
+ // Execute the deployment using clanker-sdk
112
+ const tokenAddress = await clanker.deployToken(tokenConfig);
113
+
114
+ console.log(`[3/3] Broadcasting transaction to Base network...`);
115
+
116
+ console.log(`\nšŸŽ‰ SUCCESS! Token deployed autonomously on-chain.`);
117
+ if (tokenAddress) {
118
+ console.log(`Token Contract: ${tokenAddress}`);
119
+ console.log(`Explorer: https://basescan.org/token/${tokenAddress}`);
120
+ }
121
+ console.log(`\nTrading will be live on Clanker shortly.`);
122
+
123
+ } catch (error) {
124
+ console.error(`\nāŒ Network Error: Failed to interact with Base network or Clanker SDK.`);
125
+ console.error(error.message);
126
+ // console.error(error); // uncomment for pure stack trace debug
127
+ return;
128
+ }
37
129
  });
38
130
 
39
131
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dactyclaw",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "**Agent Monitor & Deployer for Clawn Ecosystem on Base**",
5
5
  "main": "proxy.js",
6
6
  "bin": {
@@ -25,8 +25,10 @@
25
25
  "homepage": "https://github.com/dactyclaw/dactyclaw#readme",
26
26
  "dependencies": {
27
27
  "axios": "^1.13.5",
28
+ "clanker-sdk": "^4.2.10",
28
29
  "commander": "^14.0.3",
29
30
  "dotenv": "^17.3.1",
30
- "ethers": "^6.16.0"
31
+ "ethers": "^6.16.0",
32
+ "viem": "^2.46.3"
31
33
  }
32
34
  }