clanker-sdk 3.9.9 ā 4.0.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.
- package/README.md +103 -158
- package/dist/cli/cli.js +2942 -460
- package/dist/cli/create-clanker.js +2790 -433
- package/dist/index.d.ts +1574 -92
- package/dist/index.js +2688 -321
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Clanker SDK
|
|
2
2
|
|
|
3
|
-
The official TypeScript SDK for deploying tokens using Clanker.
|
|
3
|
+
The official TypeScript SDK for deploying tokens on Base using Clanker.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -11,69 +11,60 @@ yarn add clanker-sdk viem
|
|
|
11
11
|
# or
|
|
12
12
|
pnpm add clanker-sdk viem
|
|
13
13
|
```
|
|
14
|
+
npm run create-clanker
|
|
15
|
+
node --loader ts-node/esm examples/deploy.ts
|
|
14
16
|
|
|
15
|
-
##
|
|
17
|
+
## Quick Start
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
There are two ways to deploy tokens using the Clanker SDK:
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
npx clanker-sdk
|
|
21
|
-
```
|
|
21
|
+
### 1. Using the CLI
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Run the following command to use our interactive CLI tool:
|
|
24
24
|
```bash
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
To start token creation:
|
|
29
|
-
```bash
|
|
30
|
-
npx clanker-sdk --create
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Before running the CLI, create a `.env` file in your current directory with:
|
|
34
|
-
|
|
35
|
-
```env
|
|
36
|
-
# Required
|
|
37
|
-
PRIVATE_KEY=your_private_key_here
|
|
38
|
-
FACTORY_ADDRESS=factory_contract_address_here
|
|
39
|
-
|
|
40
|
-
# Optional
|
|
41
|
-
RPC_URL=your_custom_rpc_url
|
|
25
|
+
npm run create-clanker
|
|
42
26
|
```
|
|
43
27
|
|
|
44
|
-
|
|
45
|
-
- Token name and symbol
|
|
46
|
-
- Quote token selection (WETH, USDC, or custom)
|
|
47
|
-
- Initial market cap
|
|
48
|
-
- Token image (IPFS URI)
|
|
49
|
-
- Optional creator buy amount
|
|
50
|
-
- Optional vault configuration
|
|
51
|
-
- Token description and social links
|
|
28
|
+
This will guide you through the token deployment process step by step.
|
|
52
29
|
|
|
53
|
-
|
|
30
|
+
### 2. Using the TypeScript SDK
|
|
54
31
|
|
|
55
32
|
1. Create a `.env` file with your configuration:
|
|
56
33
|
```env
|
|
57
34
|
PRIVATE_KEY=your_private_key_here
|
|
35
|
+
FACTORY_ADDRESS=factory_contract_address_here
|
|
58
36
|
```
|
|
59
37
|
|
|
60
38
|
2. Create a deployment script:
|
|
61
39
|
```typescript
|
|
62
40
|
import { Clanker } from 'clanker-sdk';
|
|
63
|
-
import { createPublicClient, createWalletClient, http } from 'viem';
|
|
41
|
+
import { createPublicClient, createWalletClient, http, PublicClient } from 'viem';
|
|
64
42
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
65
43
|
import { base } from 'viem/chains';
|
|
44
|
+
import * as dotenv from 'dotenv';
|
|
45
|
+
|
|
46
|
+
// Load environment variables
|
|
47
|
+
dotenv.config();
|
|
48
|
+
|
|
49
|
+
// Validate environment variables
|
|
50
|
+
const PRIVATE_KEY = process.env.PRIVATE_KEY as `0x${string}`;
|
|
51
|
+
const FACTORY_ADDRESS = process.env.FACTORY_ADDRESS as `0x${string}`;
|
|
52
|
+
const RPC_URL = process.env.RPC_URL;
|
|
53
|
+
|
|
54
|
+
if (!PRIVATE_KEY || !FACTORY_ADDRESS) {
|
|
55
|
+
throw new Error("Missing required environment variables. Please create a .env file with PRIVATE_KEY and FACTORY_ADDRESS");
|
|
56
|
+
}
|
|
66
57
|
|
|
67
58
|
// Initialize wallet with private key
|
|
68
|
-
const account = privateKeyToAccount(
|
|
59
|
+
const account = privateKeyToAccount(PRIVATE_KEY);
|
|
69
60
|
|
|
70
61
|
// Create transport with optional custom RPC
|
|
71
|
-
const transport = http();
|
|
62
|
+
const transport = RPC_URL ? http(RPC_URL) : http();
|
|
72
63
|
|
|
73
64
|
const publicClient = createPublicClient({
|
|
74
65
|
chain: base,
|
|
75
66
|
transport,
|
|
76
|
-
});
|
|
67
|
+
}) as PublicClient;
|
|
77
68
|
|
|
78
69
|
const wallet = createWalletClient({
|
|
79
70
|
account,
|
|
@@ -88,57 +79,69 @@ const clanker = new Clanker({
|
|
|
88
79
|
});
|
|
89
80
|
|
|
90
81
|
async function deployToken() {
|
|
91
|
-
console.log("
|
|
82
|
+
console.log("\nš Deploying Token\n");
|
|
92
83
|
|
|
93
|
-
// Deploy the token
|
|
94
|
-
const
|
|
95
|
-
name: "
|
|
96
|
-
symbol: "
|
|
84
|
+
// Deploy the token with full configuration
|
|
85
|
+
const tokenConfig = {
|
|
86
|
+
name: "My Token",
|
|
87
|
+
symbol: "TKN",
|
|
97
88
|
image: "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
|
|
98
|
-
|
|
89
|
+
metadata: {
|
|
90
|
+
description: "Token with custom configuration including vesting and rewards",
|
|
91
|
+
socialMediaUrls: [
|
|
92
|
+
"https://twitter.com/mytoken",
|
|
93
|
+
"https://t.me/mytoken",
|
|
94
|
+
],
|
|
95
|
+
auditUrls: ["https://example.com/audit"],
|
|
96
|
+
},
|
|
97
|
+
context: {
|
|
98
|
+
interface: "Clanker SDK",
|
|
99
|
+
platform: "Clanker",
|
|
100
|
+
messageId: "Deploy Example",
|
|
101
|
+
id: "TKN-1",
|
|
102
|
+
},
|
|
103
|
+
pool: {
|
|
104
|
+
quoteToken: "0x4200000000000000000000000000000000000006", // WETH on Base
|
|
105
|
+
initialMarketCap: "10", // 10 ETH initial market cap
|
|
106
|
+
},
|
|
107
|
+
vault: {
|
|
108
|
+
percentage: 10, // 10% of tokens vested
|
|
109
|
+
durationInDays: 30, // 30-day vesting period
|
|
110
|
+
},
|
|
111
|
+
devBuy: {
|
|
112
|
+
ethAmount: "0", // No initial buy
|
|
113
|
+
},
|
|
114
|
+
rewardsConfig: {
|
|
115
|
+
creatorReward: 75, // 75% creator reward
|
|
116
|
+
creatorAdmin: account.address,
|
|
117
|
+
creatorRewardRecipient: account.address,
|
|
118
|
+
interfaceAdmin: "0x1eaf444ebDf6495C57aD52A04C61521bBf564ace",
|
|
119
|
+
interfaceRewardRecipient: "0x1eaf444ebDf6495C57aD52A04C61521bBf564ace",
|
|
120
|
+
},
|
|
121
|
+
};
|
|
99
122
|
|
|
100
|
-
|
|
101
|
-
|
|
123
|
+
try {
|
|
124
|
+
const tokenAddress = await clanker.deployToken(tokenConfig);
|
|
125
|
+
|
|
126
|
+
console.log("Token deployed successfully!");
|
|
127
|
+
console.log("Token address:", tokenAddress);
|
|
128
|
+
console.log("View on BaseScan:", `https://basescan.org/token/${tokenAddress}`);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (error instanceof Error) {
|
|
131
|
+
console.error("Deployment failed:", error.message);
|
|
132
|
+
} else {
|
|
133
|
+
console.error("Deployment failed with unknown error");
|
|
134
|
+
}
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
102
137
|
}
|
|
103
138
|
|
|
104
139
|
deployToken().catch(console.error);
|
|
105
140
|
```
|
|
106
141
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
```typescript
|
|
112
|
-
import { Clanker } from 'clanker-sdk';
|
|
113
|
-
import { createPublicClient, http } from 'viem';
|
|
114
|
-
import { base } from 'viem/chains';
|
|
115
|
-
|
|
116
|
-
// Initialize SDK without wallet for frontend use
|
|
117
|
-
const publicClient = createPublicClient({
|
|
118
|
-
chain: base,
|
|
119
|
-
transport: http(),
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const clanker = new Clanker({
|
|
123
|
-
publicClient,
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// In your component/hook:
|
|
127
|
-
async function prepareTokenDeployment() {
|
|
128
|
-
// Get transaction data
|
|
129
|
-
const tx = await clanker.prepareDeployToken({
|
|
130
|
-
name: "Clanker Test Token",
|
|
131
|
-
symbol: "TEST",
|
|
132
|
-
image: "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// Use with OnchainKit
|
|
136
|
-
return {
|
|
137
|
-
to: tx.to,
|
|
138
|
-
data: tx.data,
|
|
139
|
-
value: tx.value, // For dev-buy (0 if none)
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
+
3. Run the deployment script:
|
|
143
|
+
```bash
|
|
144
|
+
node --loader ts-node/esm examples/deploy.ts
|
|
142
145
|
```
|
|
143
146
|
|
|
144
147
|
## Configuration Options
|
|
@@ -146,92 +149,34 @@ async function prepareTokenDeployment() {
|
|
|
146
149
|
### Basic Token Configuration
|
|
147
150
|
- `name`: Token name
|
|
148
151
|
- `symbol`: Token symbol
|
|
149
|
-
- `
|
|
150
|
-
- `
|
|
151
|
-
- `
|
|
152
|
-
- `metadata`: IPFS hash for token metadata
|
|
153
|
-
- `context`: Deployment context string
|
|
154
|
-
- `originatingChainId`: Chain ID where token is deployed (8453 for Base)
|
|
155
|
-
|
|
156
|
-
### Advanced Configuration Options
|
|
157
|
-
|
|
158
|
-
For more advanced deployments, you can use additional configuration options as shown below:
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
const tokenAddress = await clanker.deployToken({
|
|
162
|
-
// Basic configuration (required)
|
|
163
|
-
name: "Test Token",
|
|
164
|
-
symbol: "TEST",
|
|
165
|
-
|
|
166
|
-
// Optional configuration with validation
|
|
167
|
-
salt: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", // Must be 0x + 64 hex chars
|
|
168
|
-
creatorReward: 60, // Must be between 0-80, defaults to 80
|
|
169
|
-
|
|
170
|
-
// Metadata configuration
|
|
171
|
-
metadata: {
|
|
172
|
-
description: "Test token deployment",
|
|
173
|
-
socialMediaUrls: [],
|
|
174
|
-
auditUrls: [],
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
// Deployment context
|
|
178
|
-
context: {
|
|
179
|
-
interface: "Clanker SDK Test",
|
|
180
|
-
platform: "Clanker",
|
|
181
|
-
messageId: "Test Deploy",
|
|
182
|
-
id: "TEST-1",
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
// Pool configuration with custom quote token
|
|
186
|
-
pool: {
|
|
187
|
-
quoteToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
|
|
188
|
-
initialMarketCap: "100", // Note: For custom quote tokens, market cap should be >$100 USD for better routing
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
// Vesting configuration
|
|
192
|
-
vault: {
|
|
193
|
-
percentage: 10, // 10% of tokens vested
|
|
194
|
-
durationInDays: 30, // 30-day vesting period
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
// Initial buy configuration
|
|
198
|
-
devBuy: {
|
|
199
|
-
ethAmount: "0.00001", // Initial buy amount in ETH
|
|
200
|
-
maxSlippage: 5, // Maximum 5% slippage
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
```
|
|
152
|
+
- `image`: IPFS URI for token image
|
|
153
|
+
- `metadata`: Token metadata (description, social links, etc.)
|
|
154
|
+
- `context`: Deployment context information (interface, platform, etc.)
|
|
204
155
|
|
|
205
156
|
### Pool Configuration
|
|
206
|
-
-
|
|
207
|
-
- Initial market cap in
|
|
208
|
-
- Paired with WETH on Base (`0x4200000000000000000000000000000000000006`)
|
|
209
|
-
- Custom quote tokens supported (e.g., USDC)
|
|
210
|
-
- **Important**: When using custom quote tokens, set initial market cap >$100 USD to ensure better routing options
|
|
211
|
-
- Lower market caps may limit trading to direct quote token pairs only
|
|
212
|
-
|
|
213
|
-
### Vault Configuration
|
|
214
|
-
- `percentage`: Percentage of tokens to be vested
|
|
215
|
-
- `durationInDays`: Duration of the vesting period in days
|
|
157
|
+
- `pool.quoteToken`: Quote token address (defaults to WETH on Base)
|
|
158
|
+
- `pool.initialMarketCap`: Initial market cap in quote token units
|
|
216
159
|
|
|
217
160
|
### Dev Buy Configuration
|
|
218
|
-
- `ethAmount`: Amount of ETH for initial buy
|
|
219
|
-
- `maxSlippage`: Maximum allowed slippage percentage for the initial buy
|
|
220
|
-
|
|
221
|
-
## Examples
|
|
161
|
+
- `devBuy.ethAmount`: Amount of ETH for initial buy
|
|
222
162
|
|
|
223
|
-
|
|
163
|
+
### Vault Configuration
|
|
164
|
+
- `vault.percentage`: Percentage of tokens to be vested (0-30%)
|
|
165
|
+
- `vault.durationInDays`: Duration of the vesting period in days
|
|
224
166
|
|
|
225
|
-
|
|
167
|
+
### Rewards Configuration
|
|
168
|
+
- `rewardsConfig.creatorReward`: Creator reward percentage (0-80)
|
|
169
|
+
- `rewardsConfig.creatorAdmin`: Creator admin address
|
|
170
|
+
- `rewardsConfig.creatorRewardRecipient`: Creator reward recipient address
|
|
171
|
+
- `rewardsConfig.interfaceAdmin`: Interface admin address
|
|
172
|
+
- `rewardsConfig.interfaceRewardRecipient`: Interface reward recipient address
|
|
226
173
|
|
|
227
|
-
|
|
228
|
-
Deploys a new token with the specified configuration. Requires a wallet to be configured.
|
|
174
|
+
## Examples
|
|
229
175
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
- `
|
|
233
|
-
- `
|
|
234
|
-
- `value`: ETH value to send (for dev-buy, 0 if none)
|
|
176
|
+
See the [examples](./examples) directory for more deployment scenarios:
|
|
177
|
+
- `deploy-token-simple.ts`: Basic token deployment
|
|
178
|
+
- `deploy-token.ts`: Advanced token deployment with all options
|
|
179
|
+
- `deploy-full-sdk.ts`: Full SDK usage example
|
|
235
180
|
|
|
236
181
|
## Development
|
|
237
182
|
|