Loading...
Loading...
Compare original and translation side by side
npm install clanker-sdk viemnpm install clanker-sdk viemundefinedundefined.envPRIVATE_KEY=0x...your_private_key_here.envPRIVATE_KEY=0x...your_private_key_hereimport { Clanker } from 'clanker-sdk';
import { createPublicClient, createWalletClient, http, type PublicClient } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { base } from 'viem/chains';
const PRIVATE_KEY = process.env.PRIVATE_KEY as `0x${string}`;
const account = privateKeyToAccount(PRIVATE_KEY);
const publicClient = createPublicClient({
chain: base,
transport: http(),
}) as PublicClient;
const wallet = createWalletClient({
account,
chain: base,
transport: http(),
});
const clanker = new Clanker({ wallet, publicClient });
const { txHash, waitForTransaction, error } = await clanker.deploy({
name: 'My Token',
symbol: 'TKN',
image: 'ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi',
tokenAdmin: account.address,
metadata: {
description: 'My awesome token',
},
context: {
interface: 'Clanker SDK',
},
vanity: true,
});
if (error) throw error;
const { address: tokenAddress } = await waitForTransaction();
console.log('Token deployed at:', tokenAddress);import { Clanker } from 'clanker-sdk';
import { createPublicClient, createWalletClient, http, type PublicClient } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { base } from 'viem/chains';
const PRIVATE_KEY = process.env.PRIVATE_KEY as `0x${string}`;
const account = privateKeyToAccount(PRIVATE_KEY);
const publicClient = createPublicClient({
chain: base,
transport: http(),
}) as PublicClient;
const wallet = createWalletClient({
account,
chain: base,
transport: http(),
});
const clanker = new Clanker({ wallet, publicClient });
const { txHash, waitForTransaction, error } = await clanker.deploy({
name: 'My Token',
symbol: 'TKN',
image: 'ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi',
tokenAdmin: account.address,
metadata: {
description: 'My awesome token',
},
context: {
interface: 'Clanker SDK',
},
vanity: true,
});
if (error) throw error;
const { address: tokenAddress } = await waitForTransaction();
console.log('Token deployed at:', tokenAddress);vault: {
percentage: 10, // 10% of token supply
lockupDuration: 2592000, // 30 days cliff (in seconds)
vestingDuration: 2592000, // 30 days linear vesting
recipient: account.address,
}vault: {
percentage: 10, // 代币供应量的10%
lockupDuration: 2592000, // 30天锁仓 cliff(以秒为单位)
vestingDuration: 2592000, // 30天线性归属
recipient: account.address,
}import { createAirdrop, registerAirdrop } from 'clanker-sdk/v4/extensions';
const { tree, airdrop } = createAirdrop([
{ account: '0x...', amount: 200_000_000 },
{ account: '0x...', amount: 50_000_000 },
]);
// Include in deployment
airdrop: {
...airdrop,
lockupDuration: 86_400, // 1 day
vestingDuration: 86_400, // 1 day
}import { createAirdrop, registerAirdrop } from 'clanker-sdk/v4/extensions';
const { tree, airdrop } = createAirdrop([
{ account: '0x...', amount: 200_000_000 },
{ account: '0x...', amount: 50_000_000 },
]);
// 包含在部署配置中
airdrop: {
...airdrop,
lockupDuration: 86_400, // 1天
vestingDuration: 86_400, // 1天
}rewards: {
recipients: [
{
recipient: account.address,
admin: account.address,
bps: 5000, // 50% of fees
token: 'Both', // Receive both tokens
},
{
recipient: '0x...',
admin: '0x...',
bps: 5000, // 50% of fees
token: 'Both',
},
],
}rewards: {
recipients: [
{
recipient: account.address,
admin: account.address,
bps: 5000, // 手续费的50%
token: 'Both', // 接收两种代币
},
{
recipient: '0x...',
admin: '0x...',
bps: 5000, // 手续费的50%
token: 'Both',
},
],
}| Token Type | Description |
|---|---|
| Receive only the deployed token |
| Receive only the paired token (e.g., WETH) |
| Receive both tokens |
| 代币类型 | 描述 |
|---|---|
| 仅接收部署的代币 |
| 仅接收配对代币(如WETH) |
| 接收两种代币 |
// Bankr interface fee recipient
const BANKR_INTERFACE_ADDRESS = '0xF60633D02690e2A15A54AB919925F3d038Df163e';
rewards: {
recipients: [
{
recipient: account.address, // Creator
admin: account.address,
bps: 8000, // 80% to creator
token: 'Paired', // Receive paired token (WETH)
},
{
recipient: BANKR_INTERFACE_ADDRESS, // Bankr interface
admin: BANKR_INTERFACE_ADDRESS,
bps: 2000, // 20% to Bankr
token: 'Paired', // Receive paired token (WETH)
},
],
}// Bankr接口手续费接收地址
const BANKR_INTERFACE_ADDRESS = '0xF60633D02690e2A15A54AB919925F3d038Df163e';
rewards: {
recipients: [
{
recipient: account.address, // 创建者
admin: account.address,
bps: 8000, // 80%归创建者
token: 'Paired', // 接收配对代币(WETH)
},
{
recipient: BANKR_INTERFACE_ADDRESS, // Bankr接口
admin: BANKR_INTERFACE_ADDRESS,
bps: 2000, // 20%归Bankr
token: 'Paired', // 接收配对代币(WETH)
},
],
}devBuy: {
ethAmount: 0.1, // Buy with 0.1 ETH
recipient: account.address,
}devBuy: {
ethAmount: 0.1, // 用0.1 ETH购买
recipient: account.address,
}import { getTickFromMarketCap } from 'clanker-sdk';
const customPool = getTickFromMarketCap(5); // 5 ETH market cap
pool: {
...customPool,
positions: [
{
tickLower: customPool.tickIfToken0IsClanker,
tickUpper: -120000,
positionBps: 10_000,
},
],
}import { getTickFromMarketCap } from 'clanker-sdk';
const customPool = getTickFromMarketCap(5); // 5 ETH市值
pool: {
...customPool,
positions: [
{
tickLower: customPool.tickIfToken0IsClanker,
tickUpper: -120000,
positionBps: 10_000,
},
],
}sniperFees: {
startingFee: 666_777, // 66.6777% starting fee
endingFee: 41_673, // 4.1673% ending fee
secondsToDecay: 15, // 15 seconds decay
}sniperFees: {
startingFee: 666_777, // 初始手续费66.6777%
endingFee: 41_673, // 最终手续费4.1673%
secondsToDecay: 15, // 15秒衰减时间
}| Parameter | Value | Notes |
|---|---|---|
| Token Supply | 100 billion | Fixed at 100,000,000,000 with 18 decimals |
| Max Extension BPS | 9000 (90%) | Max tokens to extensions, min 10% to LP |
| Max Extensions | 10 | Maximum number of extensions per deployment |
| Vault Min Lockup | 7 days | Minimum lockup duration for vesting |
| Airdrop Min Lockup | 1 day | Minimum lockup duration for airdrops |
| Max LP Fee | 10% | Normal trading fee cap |
| Max Sniper Fee | 80% | Maximum MEV/sniper protection fee |
| Sniper Fee Decay | 2 minutes max | Maximum time for sniper fee decay |
| Max Reward Recipients | 7 | Maximum fee distribution recipients |
| Max LP Positions | 7 | Maximum liquidity positions |
| 参数 | 数值 | 说明 |
|---|---|---|
| 代币供应量 | 1000亿 | 固定为100,000,000,000,精度为18位小数 |
| 最大扩展比例(BPS) | 9000(90%) | 分配给扩展功能的最大代币比例,至少10%分配给流动性池 |
| 最大扩展数量 | 10 | 每次部署最多支持10个扩展功能 |
| 金库最小锁仓期 | 7天 | 归属的最小锁仓时长 |
| 空投最小锁仓期 | 1天 | 空投的最小锁仓时长 |
| 最大LP手续费 | 10% | 常规交易手续费上限 |
| 最大防抢跑手续费 | 80% | MEV/防抢跑保护手续费的最大值 |
| 防抢跑手续费衰减时长 | 最长2分钟 | 防抢跑手续费衰减的最大时长 |
| 最大奖励接收方数量 | 7 | 手续费分配的最大接收方数量 |
| 最大LP头寸数量 | 7 | 最大流动性头寸数量 |
| Chain | Chain ID | Native Token | Status |
|---|---|---|---|
| Base | 8453 | ETH | ✅ Full support |
| Ethereum | 1 | ETH | ✅ Full support |
| Arbitrum | 42161 | ETH | ✅ Full support |
| Unichain | - | ETH | ✅ Full support |
| Monad | - | MON | ✅ Static fees only |
| 链 | 链ID | 原生代币 | 状态 |
|---|---|---|---|
| Base | 8453 | ETH | ✅ 完全支持 |
| Ethereum | 1 | ETH | ✅ 完全支持 |
| Arbitrum | 42161 | ETH | ✅ 完全支持 |
| Unichain | - | ETH | ✅ 完全支持 |
| Monad | - | MON | ✅ 仅支持静态手续费 |
const claimable = await clanker.getVaultClaimableAmount({ token: TOKEN_ADDRESS });
if (claimable > 0n) {
const { txHash } = await clanker.claimVaultedTokens({ token: TOKEN_ADDRESS });
}const claimable = await clanker.getVaultClaimableAmount({ token: TOKEN_ADDRESS });
if (claimable > 0n) {
const { txHash } = await clanker.claimVaultedTokens({ token: TOKEN_ADDRESS });
}// Check available rewards
const availableFees = await clanker.availableRewards({
token: TOKEN_ADDRESS,
rewardRecipient: FEE_OWNER_ADDRESS,
});
// Claim rewards
const { txHash } = await clanker.claimRewards({
token: TOKEN_ADDRESS,
rewardRecipient: FEE_OWNER_ADDRESS,
});// 检查可用奖励
const availableFees = await clanker.availableRewards({
token: TOKEN_ADDRESS,
rewardRecipient: FEE_OWNER_ADDRESS,
});
// 领取奖励
const { txHash } = await clanker.claimRewards({
token: TOKEN_ADDRESS,
rewardRecipient: FEE_OWNER_ADDRESS,
});const metadata = JSON.stringify({
description: 'Updated description',
socialMediaUrls: [
{ platform: 'twitter', url: 'https://twitter.com/mytoken' },
{ platform: 'telegram', url: 'https://t.me/mytoken' },
],
});
const { txHash } = await clanker.updateMetadata({
token: TOKEN_ADDRESS,
metadata,
});const metadata = JSON.stringify({
description: 'Updated description',
socialMediaUrls: [
{ platform: 'twitter', url: 'https://twitter.com/mytoken' },
{ platform: 'telegram', url: 'https://t.me/mytoken' },
],
});
const { txHash } = await clanker.updateMetadata({
token: TOKEN_ADDRESS,
metadata,
});const { txHash } = await clanker.updateImage({
token: TOKEN_ADDRESS,
image: 'ipfs://new_image_hash',
});const { txHash } = await clanker.updateImage({
token: TOKEN_ADDRESS,
image: 'ipfs://new_image_hash',
});createAirdrop()createAirdrop()// Bankr interface fee recipient (20%)
const BANKR_INTERFACE_ADDRESS = '0xF60633D02690e2A15A54AB919925F3d038Df163e';
const tokenConfig = {
chainId: 8453, // Base
name: 'My Token',
symbol: 'TKN',
image: 'ipfs://...',
tokenAdmin: account.address,
metadata: {
description: 'Token description',
socialMediaUrls: [
{ platform: 'twitter', url: '...' },
{ platform: 'telegram', url: '...' },
],
},
context: {
interface: 'Bankr',
platform: 'farcaster',
messageId: '',
id: '',
},
vault: {
percentage: 10,
lockupDuration: 2592000,
vestingDuration: 2592000,
recipient: account.address,
},
devBuy: {
ethAmount: 0,
recipient: account.address,
},
// Default: 80% creator, 20% Bankr interface (all in paired token)
rewards: {
recipients: [
{
recipient: account.address,
admin: account.address,
bps: 8000, // 80% to creator
token: 'Paired', // Receive paired token (WETH)
},
{
recipient: BANKR_INTERFACE_ADDRESS,
admin: BANKR_INTERFACE_ADDRESS,
bps: 2000, // 20% to Bankr
token: 'Paired', // Receive paired token (WETH)
},
],
},
pool: {
pairedToken: '0x4200000000000000000000000000000000000006', // WETH
positions: 'Standard',
},
fees: 'StaticBasic',
vanity: true,
sniperFees: {
startingFee: 666_777,
endingFee: 41_673,
secondsToDecay: 15,
},
};// Bankr接口手续费接收方(20%)
const BANKR_INTERFACE_ADDRESS = '0xF60633D02690e2A15A54AB919925F3d038Df163e';
const tokenConfig = {
chainId: 8453, // Base链
name: 'My Token',
symbol: 'TKN',
image: 'ipfs://...',
tokenAdmin: account.address,
metadata: {
description: 'Token description',
socialMediaUrls: [
{ platform: 'twitter', url: '...' },
{ platform: 'telegram', url: '...' },
],
},
context: {
interface: 'Bankr',
platform: 'farcaster',
messageId: '',
id: '',
},
vault: {
percentage: 10,
lockupDuration: 2592000,
vestingDuration: 2592000,
recipient: account.address,
},
devBuy: {
ethAmount: 0,
recipient: account.address,
},
// 默认:80%归创作者,20%归Bankr接口(均为配对代币)
rewards: {
recipients: [
{
recipient: account.address,
admin: account.address,
bps: 8000, // 80%归创作者
token: 'Paired', // 接收配对代币(WETH)
},
{
recipient: BANKR_INTERFACE_ADDRESS,
admin: BANKR_INTERFACE_ADDRESS,
bps: 2000, // 20%归Bankr
token: 'Paired', // 接收配对代币(WETH)
},
],
},
pool: {
pairedToken: '0x4200000000000000000000000000000000000006', // WETH
positions: 'Standard',
},
fees: 'StaticBasic',
vanity: true,
sniperFees: {
startingFee: 666_777,
endingFee: 41_673,
secondsToDecay: 15,
},
};*Simulate*Simulatevanity: true.env.gitignorevanity: true.env.gitignore