clanker

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Clanker SDK

Clanker SDK

Deploy production-ready ERC20 tokens with built-in liquidity pools using the official Clanker TypeScript SDK.
使用官方Clanker TypeScript SDK部署带有内置流动性池的生产级ERC20代币。

Overview

概述

Clanker is a token deployment protocol that creates ERC20 tokens with Uniswap V4 liquidity pools in a single transaction. The SDK provides a TypeScript interface for deploying tokens with advanced features like vesting, airdrops, and customizable reward distribution.
Clanker是一个代币部署协议,可在单笔交易中创建带有Uniswap V4流动性池的ERC20代币。该SDK提供TypeScript接口,支持部署带有归属、空投和可自定义奖励分配等高级功能的代币。

Quick Start

快速开始

Installation

安装

bash
npm install clanker-sdk viem
bash
npm install clanker-sdk viem

or

or

yarn add clanker-sdk viem
yarn add clanker-sdk viem

or

or

pnpm add clanker-sdk viem
undefined
pnpm add clanker-sdk viem
undefined

Environment Setup

环境设置

Create a
.env
file with your private key:
bash
PRIVATE_KEY=0x...your_private_key_here
创建一个
.env
文件并填入你的私钥:
bash
PRIVATE_KEY=0x...your_private_key_here

Basic Token Deployment

基础代币部署

typescript
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);
typescript
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);

Core Capabilities

核心功能

1. Token Deployment

1. 代币部署

Deploy tokens with full customization including metadata, social links, and pool configuration.
Basic deployment:
  • Token name, symbol, and image (IPFS)
  • Description and social media links
  • Vanity address generation
  • Custom pool configurations
Reference: references/deployment.md
部署可完全自定义的代币,包括元数据、社交链接和流动性池配置。
基础部署包含:
  • 代币名称、符号和图片(IPFS地址)
  • 描述和社交媒体链接
  • Vanity地址生成
  • 自定义流动性池配置
参考文档: references/deployment.md

2. Vault (Token Vesting)

2. 金库(代币归属)

Lock a percentage of tokens with lockup and vesting periods:
typescript
vault: {
  percentage: 10,           // 10% of token supply
  lockupDuration: 2592000,  // 30 days cliff (in seconds)
  vestingDuration: 2592000, // 30 days linear vesting
  recipient: account.address,
}
Reference: references/vesting.md
锁定一定比例的代币,并设置锁仓期和归属期:
typescript
vault: {
  percentage: 10,           // 代币供应量的10%
  lockupDuration: 2592000,  // 30天锁仓 cliff(以秒为单位)
  vestingDuration: 2592000, // 30天线性归属
  recipient: account.address,
}
参考文档: references/vesting.md

3. Airdrops

3. 空投

Distribute tokens to multiple addresses using Merkle tree proofs:
typescript
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
}
Reference: references/airdrops.md
使用默克尔树(Merkle tree)证明向多个地址分发代币:
typescript
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天
}
参考文档: references/airdrops.md

4. Rewards Configuration

4. 奖励配置

Configure trading fee distribution:
typescript
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',
    },
  ],
}
配置交易手续费分配:
typescript
rewards: {
  recipients: [
    {
      recipient: account.address,
      admin: account.address,
      bps: 5000,      // 手续费的50%
      token: 'Both',  // 接收两种代币
    },
    {
      recipient: '0x...',
      admin: '0x...',
      bps: 5000,      // 手续费的50%
      token: 'Both',
    },
  ],
}

Token Type Options

代币类型选项

Choose which tokens each recipient receives from trading fees:
Token TypeDescription
'Clanker'
Receive only the deployed token
'Paired'
Receive only the paired token (e.g., WETH)
'Both'
Receive both tokens
选择每个接收方从交易手续费中获得的代币类型:
代币类型描述
'Clanker'
仅接收部署的代币
'Paired'
仅接收配对代币(如WETH)
'Both'
接收两种代币

Default Bankr Interface Fee

默认Bankr接口手续费

When deploying via Bankr, use this default rewards configuration with 20% interface fee:
typescript
// 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)
    },
  ],
}
Reference: references/rewards.md
通过Bankr部署时,使用以下默认奖励配置,包含20%的接口手续费:
typescript
// 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)
    },
  ],
}
参考文档: references/rewards.md

5. Dev Buy

5. 开发者购买

Include an initial token purchase in the deployment:
typescript
devBuy: {
  ethAmount: 0.1,           // Buy with 0.1 ETH
  recipient: account.address,
}
在部署过程中包含初始代币购买:
typescript
devBuy: {
  ethAmount: 0.1,           // 用0.1 ETH购买
  recipient: account.address,
}

6. Custom Market Cap

6. 自定义市值

Set initial token price/market cap:
typescript
import { getTickFromMarketCap } from 'clanker-sdk';

const customPool = getTickFromMarketCap(5); // 5 ETH market cap

pool: {
  ...customPool,
  positions: [
    {
      tickLower: customPool.tickIfToken0IsClanker,
      tickUpper: -120000,
      positionBps: 10_000,
    },
  ],
}
Reference: references/pool-config.md
设置初始代币价格/市值:
typescript
import { getTickFromMarketCap } from 'clanker-sdk';

const customPool = getTickFromMarketCap(5); // 5 ETH市值

pool: {
  ...customPool,
  positions: [
    {
      tickLower: customPool.tickIfToken0IsClanker,
      tickUpper: -120000,
      positionBps: 10_000,
    },
  ],
}
参考文档: references/pool-config.md

7. Anti-Sniper Protection

7. 防抢跑保护

Configure fee decay to protect against snipers:
typescript
sniperFees: {
  startingFee: 666_777,    // 66.6777% starting fee
  endingFee: 41_673,       // 4.1673% ending fee
  secondsToDecay: 15,      // 15 seconds decay
}
配置手续费衰减以防止抢跑者:
typescript
sniperFees: {
  startingFee: 666_777,    // 初始手续费66.6777%
  endingFee: 41_673,       // 最终手续费4.1673%
  secondsToDecay: 15,      // 15秒衰减时间
}

Contract Limits & Constants

合约限制与常量

ParameterValueNotes
Token Supply100 billionFixed at 100,000,000,000 with 18 decimals
Max Extension BPS9000 (90%)Max tokens to extensions, min 10% to LP
Max Extensions10Maximum number of extensions per deployment
Vault Min Lockup7 daysMinimum lockup duration for vesting
Airdrop Min Lockup1 dayMinimum lockup duration for airdrops
Max LP Fee10%Normal trading fee cap
Max Sniper Fee80%Maximum MEV/sniper protection fee
Sniper Fee Decay2 minutes maxMaximum time for sniper fee decay
Max Reward Recipients7Maximum fee distribution recipients
Max LP Positions7Maximum liquidity positions
参数数值说明
代币供应量1000亿固定为100,000,000,000,精度为18位小数
最大扩展比例(BPS)9000(90%)分配给扩展功能的最大代币比例,至少10%分配给流动性池
最大扩展数量10每次部署最多支持10个扩展功能
金库最小锁仓期7天归属的最小锁仓时长
空投最小锁仓期1天空投的最小锁仓时长
最大LP手续费10%常规交易手续费上限
最大防抢跑手续费80%MEV/防抢跑保护手续费的最大值
防抢跑手续费衰减时长最长2分钟防抢跑手续费衰减的最大时长
最大奖励接收方数量7手续费分配的最大接收方数量
最大LP头寸数量7最大流动性头寸数量

Supported Chains

支持的链

ChainChain IDNative TokenStatus
Base8453ETH✅ Full support
Ethereum1ETH✅ Full support
Arbitrum42161ETH✅ Full support
Unichain-ETH✅ Full support
Monad-MON✅ Static fees only
链ID原生代币状态
Base8453ETH✅ 完全支持
Ethereum1ETH✅ 完全支持
Arbitrum42161ETH✅ 完全支持
Unichain-ETH✅ 完全支持
Monad-MON✅ 仅支持静态手续费

Post-Deployment Operations

部署后操作

Claim Vaulted Tokens

领取金库代币

typescript
const claimable = await clanker.getVaultClaimableAmount({ token: TOKEN_ADDRESS });

if (claimable > 0n) {
  const { txHash } = await clanker.claimVaultedTokens({ token: TOKEN_ADDRESS });
}
typescript
const claimable = await clanker.getVaultClaimableAmount({ token: TOKEN_ADDRESS });

if (claimable > 0n) {
  const { txHash } = await clanker.claimVaultedTokens({ token: TOKEN_ADDRESS });
}

Collect Trading Rewards

收取交易奖励

typescript
// 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,
});
typescript
// 检查可用奖励
const availableFees = await clanker.availableRewards({
  token: TOKEN_ADDRESS,
  rewardRecipient: FEE_OWNER_ADDRESS,
});

// 领取奖励
const { txHash } = await clanker.claimRewards({
  token: TOKEN_ADDRESS,
  rewardRecipient: FEE_OWNER_ADDRESS,
});

Update Token Metadata

更新代币元数据

typescript
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,
});
typescript
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,
});

Update Token Image

更新代币图片

typescript
const { txHash } = await clanker.updateImage({
  token: TOKEN_ADDRESS,
  image: 'ipfs://new_image_hash',
});
typescript
const { txHash } = await clanker.updateImage({
  token: TOKEN_ADDRESS,
  image: 'ipfs://new_image_hash',
});

Common Workflows

常见工作流

Simple Memecoin Launch

简单迷因币(memecoin)发行

  1. Prepare token image (upload to IPFS)
  2. Deploy with basic config (name, symbol, image)
  3. Enable vanity address for memorable contract
  4. Share contract address
  1. 准备代币图片(上传至IPFS)
  2. 使用基础配置部署(名称、符号、图片)
  3. 启用vanity地址以获得易记的合约地址
  4. 分享合约地址

Community Token with Airdrop

带空投的社区代币

  1. Compile airdrop recipient list
  2. Create Merkle tree with
    createAirdrop()
  3. Deploy token with airdrop extension
  4. Register airdrop with Clanker service
  5. Share claim instructions
  1. 整理空投接收方列表
  2. 使用
    createAirdrop()
    创建默克尔树
  3. 部署带有空投扩展的代币
  4. 在Clanker服务中注册空投
  5. 分享领取说明

Creator Token with Vesting

带归属的创作者代币

  1. Deploy with vault configuration
  2. Set lockup period (cliff)
  3. Set vesting duration
  4. Claim tokens as they vest
  1. 部署时配置金库
  2. 设置锁仓期(cliff)
  3. 设置归属时长
  4. 随着归属期推进领取代币

Full Deployment Config

完整部署配置

typescript
// 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,
  },
};
typescript
// 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,
  },
};

Best Practices

最佳实践

Security

安全

  1. Never expose private keys - Use environment variables
  2. Test on testnet first - Verify configs before mainnet
  3. Simulate transactions - Use
    *Simulate
    methods before execution
  4. Verify addresses - Double-check all recipient addresses
  1. 切勿暴露私钥 - 使用环境变量存储
  2. 先在测试网测试 - 主网部署前验证所有配置
  3. 模拟交易 - 执行前使用
    *Simulate
    方法模拟
  4. 验证地址 - 仔细检查所有接收方地址

Token Design

代币设计

  1. Choose meaningful names - Clear, memorable token identity
  2. Use quality images - High-res, appropriate IPFS images
  3. Configure vesting wisely - Align with project timeline
  1. 选择有意义的名称 - 清晰、易记的代币标识
  2. 使用高质量图片 - 高分辨率、可访问的IPFS图片
  3. 合理配置归属 - 与项目时间线对齐

Gas Optimization

Gas优化

  1. Use Base or Arbitrum - Lower gas fees
  2. Batch operations - Combine when possible
  3. Monitor gas prices - Deploy during low-traffic periods
  1. 使用Base或Arbitrum - 手续费更低
  2. 批量操作 - 尽可能合并操作
  3. 监控Gas价格 - 在低流量时段部署

Troubleshooting

故障排除

Common Issues

常见问题

  • "Missing PRIVATE_KEY" - Set environment variable
  • "Insufficient balance" - Fund wallet with native token
  • "Transaction reverted" - Check parameters, simulate first
  • "Invalid image" - Ensure IPFS hash is accessible
  • "Missing PRIVATE_KEY" - 设置环境变量
  • "Insufficient balance" - 给钱包充值原生代币
  • "Transaction reverted" - 检查参数,先模拟交易
  • "Invalid image" - 确保IPFS哈希可访问

Debug Steps

调试步骤

  1. Check wallet balance
  2. Verify chain configuration
  3. Use simulation methods
  4. Check transaction on block explorer
  5. Review error message details
  1. 检查钱包余额
  2. 验证链配置
  3. 使用模拟方法
  4. 在区块浏览器上查看交易
  5. 查看错误消息详情

Resources

资源


💡 Pro Tip: Always use the
vanity: true
option for memorable contract addresses.
⚠️ Security: Never commit private keys. Use
.env
files and add them to
.gitignore
.
🚀 Quick Win: Start with the simple deployment example, then add features like vesting and rewards as needed.

💡 专业提示:始终启用
vanity: true
选项以获得易记的合约地址。
⚠️ 安全提醒:切勿提交私钥。使用
.env
文件并将其添加到
.gitignore
中。
🚀 快速上手:从简单部署示例开始,之后再添加归属、奖励等功能。