clanker-sdk 3.1.7 → 3.1.9

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
@@ -1,11 +1,11 @@
1
1
  # Clanker SDK
2
2
 
3
- The official TypeScript SDK for deploying tokens using Clanker v3.1.4.
3
+ The official TypeScript SDK for deploying tokens using Clanker v3.1.9.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install clanker-sdk viem dotenv
8
+ npm install clanker-sdk viem
9
9
  ```
10
10
 
11
11
  ## Quick Start
@@ -13,99 +13,44 @@ npm install clanker-sdk viem dotenv
13
13
  1. Create a `.env` file with your configuration:
14
14
  ```env
15
15
  PRIVATE_KEY=your_private_key_here
16
- FACTORY_ADDRESS=clanker_factory_address_here
17
- RPC_URL=your_rpc_url_here # Optional
18
16
  ```
19
17
 
20
18
  2. Create a deployment script:
21
19
  ```typescript
22
- import { createWalletClient, http, parseEther } from 'viem';
23
- import { privateKeyToAccount } from 'viem/accounts';
24
- import { base } from 'viem/chains';
25
- import { Clanker } from 'clanker-sdk';
26
- import * as dotenv from 'dotenv';
27
- import { randomBytes } from 'crypto';
28
-
29
- // Load environment variables
30
- dotenv.config();
31
-
32
- const PRIVATE_KEY = process.env.PRIVATE_KEY;
33
- const FACTORY_ADDRESS = process.env.FACTORY_ADDRESS;
34
- const RPC_URL = process.env.RPC_URL;
35
-
36
- if (!PRIVATE_KEY || !FACTORY_ADDRESS) {
37
- throw new Error('Missing required environment variables');
38
- }
39
-
40
- async function main(): Promise<void> {
41
- // Initialize wallet
42
- const account = privateKeyToAccount(`0x${PRIVATE_KEY}`);
43
- const transport = RPC_URL ? http(RPC_URL) : http();
20
+ // Initialize wallet with private key
21
+ const account = privateKeyToAccount(PRIVATE_KEY);
22
+
23
+ // Create transport with optional custom RPC
24
+ const transport = http();
25
+
26
+ const publicClient = createPublicClient({
27
+ chain: base,
28
+ transport,
29
+ });
30
+
44
31
  const wallet = createWalletClient({
45
32
  account,
46
33
  chain: base,
47
- transport
34
+ transport,
48
35
  });
49
36
 
50
37
  // Initialize Clanker SDK
51
38
  const clanker = new Clanker({
52
39
  wallet,
53
- factoryAddress: FACTORY_ADDRESS as `0x${string}`,
54
- chainId: base.id
40
+ publicClient,
41
+ });
42
+
43
+ console.log("Starting token deployment...");
44
+
45
+ // Deploy the token
46
+ const tokenAddress = await clanker.deployToken({
47
+ name: "Clanker Test Token",
48
+ symbol: "TEST",
49
+ image: "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
55
50
  });
56
51
 
57
- try {
58
- const deployConfig = {
59
- tokenConfig: {
60
- name: 'Test Token',
61
- symbol: 'TEST',
62
- salt: `0x${randomBytes(32).toString('hex')}`,
63
- image: 'ipfs://your_image_hash',
64
- metadata: 'ipfs://your_metadata_hash',
65
- context: 'Your deployment context',
66
- originatingChainId: BigInt(8453) // Base chain ID
67
- },
68
- poolConfig: {
69
- pairedToken: '0x4200000000000000000000000000000000000006' as `0x${string}`, // WETH on Base
70
- initialMarketCapInPairedToken: parseEther('5') // 5 WETH initial mcap
71
- },
72
- vaultConfig: {
73
- vaultPercentage: 30, // 30% vault
74
- vaultDuration: BigInt(60 * 24 * 60 * 60) // 60 days vault duration
75
- },
76
- initialBuyConfig: {
77
- pairedTokenPoolFee: 10000, // 1% fee tier (fixed)
78
- pairedTokenSwapAmountOutMinimum: parseEther('0.001') // 0.001 WETH initial buy
79
- },
80
- rewardsConfig: {
81
- creatorReward: BigInt(40), // 40% creator reward
82
- creatorAdmin: account.address,
83
- creatorRewardRecipient: account.address,
84
- interfaceAdmin: account.address,
85
- interfaceRewardRecipient: account.address
86
- }
87
- } as const;
88
-
89
- const tokenAddress = await clanker.deploy(deployConfig);
90
- console.log('Token deployed successfully at:', tokenAddress);
91
- } catch (error) {
92
- if (error instanceof Error) {
93
- console.error('Deployment failed:', error.message);
94
- } else {
95
- console.error('Deployment failed with unknown error');
96
- }
97
- process.exit(1);
98
- }
99
- }
100
-
101
- main().catch((error) => {
102
- if (error instanceof Error) {
103
- console.error('Deployment failed:', error.message);
104
- } else {
105
- console.error('Deployment failed with unknown error');
106
- }
107
- process.exit(1);
108
- });
52
+ console.log("Token deployed successfully!");
53
+ console.log("Token address:", tokenAddress);
109
54
  ```
110
55
 
111
56
  ## Configuration Options
@@ -120,29 +65,10 @@ main().catch((error) => {
120
65
  - `originatingChainId`: Chain ID where token is deployed (8453 for Base)
121
66
 
122
67
  ### Pool Configuration
123
- - Pool fee tier is fixed at 1% (10000) for optimal performance
124
- - Initial market cap in WETH (e.g., 5 WETH)
68
+ - Pool fee tier is fixed at 1%
69
+ - Initial market cap in WETH (e.g., 10 WETH)
125
70
  - Paired with WETH on Base (`0x4200000000000000000000000000000000000006`)
126
71
 
127
- ### Vault Configuration (Optional)
128
- - `vaultPercentage`: Percentage of tokens to lock (0-100)
129
- - `vaultDuration`: Duration of the lock in seconds (e.g., 60 days = 5184000 seconds)
130
-
131
- ### Initial Buy Configuration
132
- - Pool fee tier is fixed at 1% (10000)
133
- - Initial buy amount in WETH (e.g., 0.001 WETH)
134
-
135
- ### Rewards Configuration
136
- - `creatorReward`: Percentage of rewards for creator (e.g., 40)
137
- - Creator and interface admin/recipient addresses
138
-
139
- ## Important Notes
140
-
141
- 1. The pool fee tier is fixed at 1% (10000) for optimal performance
142
- 2. Initial market cap and buy amounts should be specified using `parseEther()`
143
- 3. Vault duration should be specified in seconds
144
- 4. All addresses should be properly formatted as `0x${string}`
145
- 5. Error handling is included for better debugging
146
72
 
147
73
  ## Examples
148
74
 
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ __export(index_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(index_exports);
26
26
  var import_viem = require("viem");
27
+ var import_actions = require("viem/actions");
27
28
 
28
29
  // src/constants.ts
29
30
  var WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
@@ -626,7 +627,7 @@ var Clanker = class {
626
627
  interfaceRewardRecipient: rewardsConfig.interfaceRewardRecipient
627
628
  }
628
629
  };
629
- const { request } = await this.publicClient.simulateContract({
630
+ const { request } = await (0, import_actions.simulateContract)(this.publicClient, {
630
631
  address: this.factoryAddress,
631
632
  abi: Clanker_v3_1_abi,
632
633
  functionName: "deployToken",
@@ -635,16 +636,19 @@ var Clanker = class {
635
636
  chain: this.publicClient.chain,
636
637
  account: this.wallet.account
637
638
  });
638
- const hash = await this.wallet.writeContract(request);
639
+ const hash = await (0, import_actions.writeContract)(this.wallet, request);
639
640
  const receipt = await this.publicClient.waitForTransactionReceipt({
640
641
  hash
641
642
  });
642
- const deployEvent = receipt.logs[0];
643
- if (!deployEvent?.topics[1]) {
643
+ const [log] = (0, import_viem.parseEventLogs)({
644
+ abi: Clanker_v3_1_abi,
645
+ eventName: "TokenCreated",
646
+ logs: receipt.logs
647
+ });
648
+ if (!log) {
644
649
  throw new Error("No deployment event found");
645
650
  }
646
- const tokenAddress = `0x${deployEvent.topics[1].slice(-40)}`;
647
- return tokenAddress;
651
+ return log.args.tokenAddress;
648
652
  } catch (error) {
649
653
  this.handleError(error);
650
654
  }
package/dist/index.mjs CHANGED
@@ -3,8 +3,10 @@ import {
3
3
  getContract,
4
4
  parseEther,
5
5
  stringify,
6
- erc20Abi
6
+ erc20Abi,
7
+ parseEventLogs
7
8
  } from "viem";
9
+ import { simulateContract, writeContract } from "viem/actions";
8
10
 
9
11
  // src/constants.ts
10
12
  var WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
@@ -607,7 +609,7 @@ var Clanker = class {
607
609
  interfaceRewardRecipient: rewardsConfig.interfaceRewardRecipient
608
610
  }
609
611
  };
610
- const { request } = await this.publicClient.simulateContract({
612
+ const { request } = await simulateContract(this.publicClient, {
611
613
  address: this.factoryAddress,
612
614
  abi: Clanker_v3_1_abi,
613
615
  functionName: "deployToken",
@@ -616,16 +618,19 @@ var Clanker = class {
616
618
  chain: this.publicClient.chain,
617
619
  account: this.wallet.account
618
620
  });
619
- const hash = await this.wallet.writeContract(request);
621
+ const hash = await writeContract(this.wallet, request);
620
622
  const receipt = await this.publicClient.waitForTransactionReceipt({
621
623
  hash
622
624
  });
623
- const deployEvent = receipt.logs[0];
624
- if (!deployEvent?.topics[1]) {
625
+ const [log] = parseEventLogs({
626
+ abi: Clanker_v3_1_abi,
627
+ eventName: "TokenCreated",
628
+ logs: receipt.logs
629
+ });
630
+ if (!log) {
625
631
  throw new Error("No deployment event found");
626
632
  }
627
- const tokenAddress = `0x${deployEvent.topics[1].slice(-40)}`;
628
- return tokenAddress;
633
+ return log.args.tokenAddress;
629
634
  } catch (error) {
630
635
  this.handleError(error);
631
636
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "clanker-sdk",
3
- "version": "3.1.7",
4
- "description": "SDK for deploying tokens using Clanker v3.1.3",
3
+ "version": "3.1.9",
4
+ "description": "SDK for deploying tokens using Clanker v3.1.9",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",