v4.0.0
Clanker v4.0.0 SDK User Guide
Quick Start
npm install clanker-sdk viem
Basic Usage
import { Clanker } from 'clanker-sdk/v4';
import { createWalletClient, createPublicClient, privateKeyToAccount, http } from 'viem';
// Viem setup
const account = privateKeyToAccount(process.env.PRIVATE_KEY);
const client = createPublicClient({ chain: base, transport: http() });
const wallet = createWalletClient({ account, chain: base, transport: http() });
// Initialize the SDK
const clanker = new Clanker({
publicClient: client,
wallet: walletClient,
});
// Deploy a token
const { txHash, waitForTransaction, error } = await clanker.deploy({
name: "My Token",
symbol: "MTK",
tokenAdmin: account.address,
// Optional parameter. This will make a call to Clanker's vanity-address
// service to generate a salt so the token deploys with the "b07" suffix.
vanity: true,
});
// The `deploy` function attempts to not throw and instead return an error
// for you to decide how to handle
if (error) throw error;
// It also returns a function `waitForTransaction` that you may use to wait
// for the full token deployment. This also may return an error, or the address
// of the token on success.
const { address } = await waitForTransaction();
console.log(`Deployed token to ${address}`);
Advanced Configuration
Token Configuration
Adding an image, metadata, and context to your token.
const token: ClankerTokenV4 = {
name: "My Token",
symbol: "MTK",
tokenAdmin: account.address,
image: 'ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi',
metadata: {
description: 'My new token.',
socialMediaUrls: [],
auditUrls: [],
},
context: {
interface: 'Clanker SDK',
// Platform related to the deployment. For example "farcaster".
platform: '',
// Id of the message on the platform. For example, a "cast id" for farcaster.
messageId: '',
// Id of the user for the platform. For example, a "fid" for farcaster.
id: '',
}
};
Pool Configuration
To customize the paired token and starting market cap, use the pool
field. The pool is configured to use WETH
as the paired token by default with a 10 eth starting market cap.
If a custom starting market cap is used, custom positions must be used as well.
// To switch between preset position options, PoolPositions.Standard (meme)
// and PoolPositions.Project:
const token: ClankerTokenV4 = {
// ... other configuration ...
positions: POOL_POSITIONS.Standard,
}
// To use a custom paired token, market cap, and liquidity positions
const token: ClankerTokenV4 = {
// ... other configuration ...
pool: {
pairedToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
tickIfToken0IsClanker: -60000,
positions: [
{
tickLower: -60000,
tickUpper: -20000,
positionBps: 8000
},
{
tickLower: -20000,
tickUpper: 100000,
positionBps: 2000
}
],
}
}
Fee Configuration
To customize the fees on the deployed Uniswap v4 pool, define a new fees
field on the token.
If no fee configuration is provided, the SDK configures a static pool with 1% fees for both token inputs.
// To use Static Fee with custom fee settings:
const tokenConfig: ClankerTokenV4 = {
// ... other configuration ...
fees: {
type: "static",
// Both fees are in bps
clankerFee: 100,
pairedFee: 100,
},
};
// Using a Dynamic Fee basic preset
const token: ClankerTokenV4 = {
// ... other configuration ...
fees: FEE_CONFIGS.DynamicBasic,
};
Rewards Configuration
To customize the reward recipients, use the rewards
field. The admin
receives no rewards but may change the recipient
which does get the rewards. They may be set to the same address. The sum of all bps
must be 100%.
If no reward configuration is provided, the tokenAdmin
receives all of the LP rewards.
// To input custom reward recipients, with up to 7 recipients:
const token: ClankerTokenV4 = {
// ... other configuration ...
rewards: {
recipients: [
{
recipient: CREATOR_REWARD_ADDRESS,
admin: CREATOR_ADMIN_ADDRESS,
// In bps. 80% of reward
bps: 8_000,
},
{
recipient: INTERFACE_REWARD_ADDRESS,
admin: INTERFACE_ADMIN_ADDRESS,
// In bps. 20% of reward
bps: 2_000,
},
]
},
};
Vesting Vault
To vault and optionally vest a portion of the token supply, use the vault
field.
// To vault a portion of the token supply at launch
const token: ClankerTokenV4 = {
// ... other configuration ...
vault: {
// 10% of token supply, up to 90%
percentage: 10,
// 30 days in seconds, min of 7 days
lockupDuration: 2592000,
// 30 days in seconds, can be 0
vestingDuration: 2592000,
},
};
Initial Dev Buy
To include a initial purchase on the pool, use the devBuy
field.
For dev buys with non-weth pairs, you must provide a Uniswap v4 PoolKey for a WETH/ETH<>Paired swap.
// To perform a dev buy when WETH is the paired token
const token: ClankerTokenV4 = {
// ... other configuration ...
devBuy: {
// Decimal amount of eth to spend
ethAmount: 0.0001,
},
};
// To perform a dev buy when the paired token is not WETH
const token: ClankerTokenV4 = {
// ... other configuration ...
devBuy: {
// Decimal amount of eth to spend (on PairedToken)
ethAmount: 0.0001,
// pool key to swap from WETH -> PairedToken
poolKey: {
currency0: '0x0000000000000000000000000000000000000000',
currency1: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
fee: 500,
tickSpacing: 10,
hooks: '0x0000000000000000000000000000000000000000',
},
// minimum amount out from WETH -> PairedToken swap
amountOutMin: 0.0000001,
},
};
Complete Example
import { Clanker } from 'clanker-sdk/v4';
import { createWalletClient, createPublicClient, http } from 'viem';
// Prepare viem: account, publicClient, and wallet.
// Initialize the SDK
const clanker = new Clanker({ publicClient, wallet });
// Deploy the token
const { waitForTransaction } = await clanker.deploy({
name: "My Cool Project Coin",
symbol: "MCPC",
tokenAdmin: account.address,
image: 'ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi',
metadata: {
description: 'Token with custom configuration including vesting and rewards',
},
context: {
interface: 'Clanker SDK',
},
pool: {
positions: POOL_POSITIONS.Project,
},
fees: FEE_CONFIGS.DynamicBasic,
rewards: {
recipients: [
{
recipient: MY_EOA,
admin: MY_MULTISIG,
// In bps. 80% of reward
bps: 8_000,
},
{
recipient: FRIEND_EOA,
admin: FRIEND_MULTISIG,
// In bps. 20% of reward
bps: 2_000,
},
]
},
vault: {
percentage: 10, // 10% of token supply, up to 90%
lockupDuration: 2592000, // 30 days in seconds, min of 7 days
vestingDuration: 2592000, // 30 days in seconds, can be 0
},
devBuy: {
ethAmount: 0.1,
},
});
const { address } = await waitForTransaction();
console.log(`Token deployed at: ${address}`);
console.log(`View on Clanker World: https://clanker.world/clanker/${address}`);
Last updated