clanker-sdk 3.1.4 → 3.1.6

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,121 +1,165 @@
1
- # Clanker SDK v3.1.0
1
+ # Clanker SDK
2
2
 
3
- A lightweight TypeScript SDK for deploying tokens using Clanker v3.1.0. This SDK provides a simple interface for deploying tokens with configurable market caps, vaulting, and reward distributions.
3
+ The official TypeScript SDK for deploying tokens using Clanker v3.1.6.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install clanker-sdk viem
8
+ npm install clanker-sdk viem dotenv
9
9
  ```
10
10
 
11
- ## Usage
11
+ ## Quick Start
12
12
 
13
+ 1. Create a `.env` file with your configuration:
14
+ ```env
15
+ PRIVATE_KEY=your_private_key_here
16
+ FACTORY_ADDRESS=clanker_factory_address_here
17
+ RPC_URL=your_rpc_url_here # Optional
18
+ ```
19
+
20
+ 2. Create a deployment script:
13
21
  ```typescript
14
- import { createWalletClient, http } from 'viem';
22
+ import { createWalletClient, http, parseEther } from 'viem';
15
23
  import { privateKeyToAccount } from 'viem/accounts';
16
24
  import { base } from 'viem/chains';
17
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();
44
+ const wallet = createWalletClient({
45
+ account,
46
+ chain: base,
47
+ transport
48
+ });
49
+
50
+ // Initialize Clanker SDK
51
+ const clanker = new Clanker({
52
+ wallet,
53
+ factoryAddress: FACTORY_ADDRESS as `0x${string}`,
54
+ chainId: base.id
55
+ });
56
+
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
+ }
18
100
 
19
- // Initialize wallet
20
- const account = privateKeyToAccount('0x...');
21
- const wallet = createWalletClient({
22
- account,
23
- chain: base,
24
- transport: http()
25
- });
26
-
27
- // Initialize Clanker SDK
28
- const clanker = new Clanker({
29
- wallet,
30
- factoryAddress: '0x2A787b2362021cC3eEa3C24C4748a6cD5B687382', // Clanker factory address on Base
31
- chainId: base.id
32
- });
33
-
34
- // Deploy a token
35
- const tokenAddress = await clanker.deploy({
36
- tokenConfig: {
37
- name: 'My Token',
38
- symbol: 'MTK',
39
- salt: '0x...', // bytes32 for address customization
40
- image: 'ipfs://...',
41
- metadata: 'ipfs://...',
42
- context: 'Deployed via SDK',
43
- originatingChainId: BigInt(base.id)
44
- },
45
- poolConfig: {
46
- pairedToken: '0x4200000000000000000000000000000000000006', // WETH on Base
47
- initialMarketCapInPairedToken: BigInt(10) * BigInt(10)**BigInt(18) // 10 WETH initial mcap
48
- },
49
- // Optional: Lock tokens in vault
50
- vaultConfig: {
51
- vaultPercentage: 30, // 30% of supply
52
- vaultDuration: BigInt(30 * 24 * 60 * 60) // 30 days in seconds
53
- },
54
- // Optional: Perform initial buy with ETH
55
- initialBuyConfig: {
56
- pairedTokenPoolFee: 3000, // 0.3% fee tier for ETH -> pairedToken swap
57
- pairedTokenSwapAmountOutMinimum: BigInt('1000000000000000000') // 1 ETH
58
- },
59
- rewardsConfig: {
60
- creatorReward: BigInt(80), // 80% of remaining rewards (after 20% team cut)
61
- creatorAdmin: '0x...', // Address to manage creator's locked tokens
62
- creatorRewardRecipient: '0x...', // Address to receive creator's trading fees
63
- interfaceAdmin: '0x...', // Address to manage interface's trading fees
64
- interfaceRewardRecipient: '0x...' // Address to receive interface's trading fees
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');
65
106
  }
107
+ process.exit(1);
66
108
  });
67
-
68
- console.log('Token deployed at:', tokenAddress);
69
109
  ```
70
110
 
71
- ## Features
111
+ ## Configuration Options
72
112
 
73
- - Deploy tokens with customizable parameters
74
- - Calculate initial token price based on desired market cap in paired token
75
- - Support for token vaulting with configurable duration and percentage
76
- - Configure reward distribution between creator and interface
77
- - Support for initial token buys with ETH
78
- - Super-chain compatibility for cross-chain deployments
79
-
80
- ## Configuration
81
-
82
- ### TokenConfig
113
+ ### Token Configuration
83
114
  - `name`: Token name
84
115
  - `symbol`: Token symbol
85
- - `salt`: Address salt value for token address customization
86
- - `image`: Token image URI
87
- - `metadata`: Token metadata URI
88
- - `context`: Additional deployment context
89
- - `originatingChainId`: Chain ID where token supply is deployed
116
+ - `salt`: Randomly generated bytes32 value
117
+ - `image`: IPFS hash for token image
118
+ - `metadata`: IPFS hash for token metadata
119
+ - `context`: Deployment context string
120
+ - `originatingChainId`: Chain ID where token is deployed (8453 for Base)
121
+
122
+ ### Pool Configuration
123
+ - Pool fee tier is fixed at 1% (10000) for optimal performance
124
+ - Initial market cap in WETH (e.g., 5 WETH)
125
+ - Paired with WETH on Base (`0x4200000000000000000000000000000000000006`)
126
+
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)
90
130
 
91
- ### PoolConfig
92
- - `pairedToken`: Token to pair with (e.g., WETH)
93
- - `initialMarketCapInPairedToken`: Desired initial market cap in paired token units
131
+ ### Initial Buy Configuration
132
+ - Pool fee tier is fixed at 1% (10000)
133
+ - Initial buy amount in WETH (e.g., 0.001 WETH)
94
134
 
95
- ### VaultConfig (Optional)
96
- - `vaultPercentage`: Percentage of supply to lock (max 30)
97
- - `vaultDuration`: Lock duration in seconds (min 30 days)
135
+ ### Rewards Configuration
136
+ - `creatorReward`: Percentage of rewards for creator (e.g., 40)
137
+ - Creator and interface admin/recipient addresses
98
138
 
99
- ### InitialBuyConfig (Optional)
100
- - `pairedTokenPoolFee`: Fee tier for ETH -> pairedToken swap
101
- - `pairedTokenSwapAmountOutMinimum`: Minimum amount of paired tokens to receive
139
+ ## Important Notes
102
140
 
103
- ### RewardsConfig
104
- - `creatorReward`: Creator's percentage of remaining rewards after team cut (max 80)
105
- - `creatorAdmin`: Address to manage creator's locked tokens
106
- - `creatorRewardRecipient`: Address to receive creator's trading fees
107
- - `interfaceAdmin`: Address to manage interface's trading fees
108
- - `interfaceRewardRecipient`: Address to receive interface's trading fees
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
109
146
 
110
- ## Super-chain Compatibility
147
+ ## Examples
111
148
 
112
- The SDK supports deploying tokens that are compatible with the super-chain architecture. When deploying a token:
149
+ See the [examples](./examples) directory for more deployment scenarios.
113
150
 
114
- 1. Set `originatingChainId` to the chain ID where the token's supply should be minted
115
- 2. Deploy the token on other super-chain networks using the same parameters
116
- 3. Use the super-chain's bridge to migrate tokens between networks
151
+ ## Development
117
152
 
118
- Note: Tokens can only be minted with supply on the originating chain. Make sure the target chains are part of the same super-chain cluster.
153
+ ```bash
154
+ # Install dependencies
155
+ npm install
156
+
157
+ # Build
158
+ npm run build
159
+
160
+ # Test
161
+ npm test
162
+ ```
119
163
 
120
164
  ## License
121
165
 
package/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
- import { Address, WalletClient, Account } from 'viem';
1
+ import { WalletClient, PublicClient, Address } from 'viem';
2
2
 
3
3
  interface TokenConfig {
4
4
  name: string;
5
5
  symbol: string;
6
6
  salt: `0x${string}`;
7
7
  image: string;
8
- metadata: string;
9
- context: string;
8
+ metadata: IClankerMetadata;
9
+ context: IClankerSocialContext;
10
10
  originatingChainId: bigint;
11
11
  }
12
12
  interface VaultConfig {
@@ -18,7 +18,7 @@ interface PoolConfig {
18
18
  initialMarketCapInPairedToken: bigint;
19
19
  }
20
20
  interface InitialBuyConfig {
21
- pairedTokenPoolFee: number;
21
+ pairedTokenPoolFee: 10000;
22
22
  pairedTokenSwapAmountOutMinimum: bigint;
23
23
  }
24
24
  interface RewardsConfig {
@@ -28,6 +28,23 @@ interface RewardsConfig {
28
28
  interfaceAdmin: Address;
29
29
  interfaceRewardRecipient: Address;
30
30
  }
31
+ interface ClankerConfig {
32
+ wallet: WalletClient;
33
+ publicClient: PublicClient;
34
+ factoryAddress?: Address;
35
+ }
36
+ interface SimpleTokenConfig {
37
+ name: string;
38
+ symbol: string;
39
+ image?: string;
40
+ salt?: `0x${string}`;
41
+ vault?: {
42
+ percentage: number;
43
+ durationInDays: number;
44
+ };
45
+ metadata?: IClankerMetadata;
46
+ context?: IClankerSocialContext;
47
+ }
31
48
  interface DeploymentConfig {
32
49
  tokenConfig: TokenConfig;
33
50
  vaultConfig?: VaultConfig;
@@ -35,18 +52,54 @@ interface DeploymentConfig {
35
52
  initialBuyConfig?: InitialBuyConfig;
36
53
  rewardsConfig: RewardsConfig;
37
54
  }
38
- interface ClankerConfig {
39
- wallet: WalletClient & {
40
- account: Account;
55
+ interface DeploymentConfig {
56
+ tokenConfig: {
57
+ name: string;
58
+ symbol: string;
59
+ salt: `0x${string}`;
60
+ image: string;
61
+ metadata: IClankerMetadata;
62
+ context: IClankerSocialContext;
63
+ originatingChainId: bigint;
64
+ };
65
+ poolConfig: {
66
+ pairedToken: Address;
67
+ initialMarketCapInPairedToken: bigint;
68
+ };
69
+ vaultConfig?: {
70
+ vaultPercentage: number;
71
+ vaultDuration: bigint;
72
+ };
73
+ initialBuyConfig?: {
74
+ pairedTokenPoolFee: 10000;
75
+ pairedTokenSwapAmountOutMinimum: bigint;
76
+ };
77
+ rewardsConfig: {
78
+ creatorReward: bigint;
79
+ creatorAdmin: Address;
80
+ creatorRewardRecipient: Address;
81
+ interfaceAdmin: Address;
82
+ interfaceRewardRecipient: Address;
41
83
  };
42
- factoryAddress: Address;
43
- chainId: number;
84
+ }
85
+ interface IClankerMetadata {
86
+ description?: string;
87
+ socialMediaUrls?: {
88
+ platform: string;
89
+ url: string;
90
+ }[];
91
+ auditUrls?: string[];
92
+ }
93
+ interface IClankerSocialContext {
94
+ interface: string;
95
+ platform?: string;
96
+ messageId?: string;
97
+ id?: string;
44
98
  }
45
99
 
46
100
  declare class Clanker {
47
101
  private readonly wallet;
48
102
  private readonly factoryAddress;
49
- private readonly chainId;
50
103
  private readonly publicClient;
51
104
  private readonly Q96;
52
105
  private readonly TICK_BASE;
@@ -66,7 +119,14 @@ declare class Clanker {
66
119
  */
67
120
  private log1000196;
68
121
  private calculateTick;
122
+ private handleError;
69
123
  deploy(config: DeploymentConfig): Promise<Address>;
124
+ /**
125
+ * Simplified token deployment method for easier user experience
126
+ * @param config Simple configuration for token deployment
127
+ * @returns Deployed token address
128
+ */
129
+ deployToken(config: SimpleTokenConfig): Promise<Address>;
70
130
  }
71
131
 
72
- export { Clanker, type ClankerConfig, type DeploymentConfig, type InitialBuyConfig, type PoolConfig, type RewardsConfig, type TokenConfig, type VaultConfig };
132
+ export { Clanker, type ClankerConfig, type DeploymentConfig, type IClankerMetadata, type IClankerSocialContext, type InitialBuyConfig, type PoolConfig, type RewardsConfig, type SimpleTokenConfig, type TokenConfig, type VaultConfig };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { Address, WalletClient, Account } from 'viem';
1
+ import { WalletClient, PublicClient, Address } from 'viem';
2
2
 
3
3
  interface TokenConfig {
4
4
  name: string;
5
5
  symbol: string;
6
6
  salt: `0x${string}`;
7
7
  image: string;
8
- metadata: string;
9
- context: string;
8
+ metadata: IClankerMetadata;
9
+ context: IClankerSocialContext;
10
10
  originatingChainId: bigint;
11
11
  }
12
12
  interface VaultConfig {
@@ -18,7 +18,7 @@ interface PoolConfig {
18
18
  initialMarketCapInPairedToken: bigint;
19
19
  }
20
20
  interface InitialBuyConfig {
21
- pairedTokenPoolFee: number;
21
+ pairedTokenPoolFee: 10000;
22
22
  pairedTokenSwapAmountOutMinimum: bigint;
23
23
  }
24
24
  interface RewardsConfig {
@@ -28,6 +28,23 @@ interface RewardsConfig {
28
28
  interfaceAdmin: Address;
29
29
  interfaceRewardRecipient: Address;
30
30
  }
31
+ interface ClankerConfig {
32
+ wallet: WalletClient;
33
+ publicClient: PublicClient;
34
+ factoryAddress?: Address;
35
+ }
36
+ interface SimpleTokenConfig {
37
+ name: string;
38
+ symbol: string;
39
+ image?: string;
40
+ salt?: `0x${string}`;
41
+ vault?: {
42
+ percentage: number;
43
+ durationInDays: number;
44
+ };
45
+ metadata?: IClankerMetadata;
46
+ context?: IClankerSocialContext;
47
+ }
31
48
  interface DeploymentConfig {
32
49
  tokenConfig: TokenConfig;
33
50
  vaultConfig?: VaultConfig;
@@ -35,18 +52,54 @@ interface DeploymentConfig {
35
52
  initialBuyConfig?: InitialBuyConfig;
36
53
  rewardsConfig: RewardsConfig;
37
54
  }
38
- interface ClankerConfig {
39
- wallet: WalletClient & {
40
- account: Account;
55
+ interface DeploymentConfig {
56
+ tokenConfig: {
57
+ name: string;
58
+ symbol: string;
59
+ salt: `0x${string}`;
60
+ image: string;
61
+ metadata: IClankerMetadata;
62
+ context: IClankerSocialContext;
63
+ originatingChainId: bigint;
64
+ };
65
+ poolConfig: {
66
+ pairedToken: Address;
67
+ initialMarketCapInPairedToken: bigint;
68
+ };
69
+ vaultConfig?: {
70
+ vaultPercentage: number;
71
+ vaultDuration: bigint;
72
+ };
73
+ initialBuyConfig?: {
74
+ pairedTokenPoolFee: 10000;
75
+ pairedTokenSwapAmountOutMinimum: bigint;
76
+ };
77
+ rewardsConfig: {
78
+ creatorReward: bigint;
79
+ creatorAdmin: Address;
80
+ creatorRewardRecipient: Address;
81
+ interfaceAdmin: Address;
82
+ interfaceRewardRecipient: Address;
41
83
  };
42
- factoryAddress: Address;
43
- chainId: number;
84
+ }
85
+ interface IClankerMetadata {
86
+ description?: string;
87
+ socialMediaUrls?: {
88
+ platform: string;
89
+ url: string;
90
+ }[];
91
+ auditUrls?: string[];
92
+ }
93
+ interface IClankerSocialContext {
94
+ interface: string;
95
+ platform?: string;
96
+ messageId?: string;
97
+ id?: string;
44
98
  }
45
99
 
46
100
  declare class Clanker {
47
101
  private readonly wallet;
48
102
  private readonly factoryAddress;
49
- private readonly chainId;
50
103
  private readonly publicClient;
51
104
  private readonly Q96;
52
105
  private readonly TICK_BASE;
@@ -66,7 +119,14 @@ declare class Clanker {
66
119
  */
67
120
  private log1000196;
68
121
  private calculateTick;
122
+ private handleError;
69
123
  deploy(config: DeploymentConfig): Promise<Address>;
124
+ /**
125
+ * Simplified token deployment method for easier user experience
126
+ * @param config Simple configuration for token deployment
127
+ * @returns Deployed token address
128
+ */
129
+ deployToken(config: SimpleTokenConfig): Promise<Address>;
70
130
  }
71
131
 
72
- export { Clanker, type ClankerConfig, type DeploymentConfig, type InitialBuyConfig, type PoolConfig, type RewardsConfig, type TokenConfig, type VaultConfig };
132
+ export { Clanker, type ClankerConfig, type DeploymentConfig, type IClankerMetadata, type IClankerSocialContext, type InitialBuyConfig, type PoolConfig, type RewardsConfig, type SimpleTokenConfig, type TokenConfig, type VaultConfig };