Copy async function launchTokenWithGovernance() {
// 1. Define your token parameters
const tokenName = "Community Token";
const tokenSymbol = "COMM";
const totalSupply = parseEther("1000000"); // 1M tokens
const numTokensToSell = parseEther("700000"); // 700k for sale
// 2. Set up beneficiaries for the 10% locked liquidity
const beneficiaries: BeneficiaryData[] = [
{
beneficiary: addresses.airlock, // Protocol: 5%
shares: BigInt(0.05e18), // 5% in WAD (1e18 = 100%)
},
{
beneficiary: '0x123...', // REPLACE with your integrator address: 5%
shares: BigInt(0.05e18), // 5% in WAD (1e18 = 100%)
},
{
beneficiary: '0x456...', // REPLACE with team/treasury address: 90%
shares: BigInt(0.9e18), // 90% in WAD (1e18 = 100%)
}
];
// 3. Sort beneficiaries (required by contract)
const sortedBeneficiaries = factory.sortBeneficiaries(beneficiaries);
// 4. Configure V4 migrator
const v4Config: V4MigratorData = {
fee: 3000, // 0.3% pool fee
tickSpacing: 60, // Standard for 0.3% pools
lockDuration: 180 * 24 * 60 * 60, // 180 days lock
beneficiaries: sortedBeneficiaries
};
// 5. Encode migrator data
const liquidityMigratorData = factory.encodeV4MigratorData(v4Config);
// 6. Configure vesting (optional)
const vestingRecipients = [
'0x789...', // Team member 1
'0xabc...', // Team member 2
];
const vestingAmounts = [
parseEther("50000"), // 50k tokens
parseEther("50000"), // 50k tokens
];
// 7. Build complete configuration
const { createParams, hook, token } = await factory.buildConfig({
// Token details
name: tokenName,
symbol: tokenSymbol,
totalSupply: totalSupply,
numTokensToSell: numTokensToSell,
tokenURI: "https://api.example.com/token/metadata",
// Timing
blockTimestamp: Math.floor(Date.now() / 1000),
startTimeOffset: 1, // Start in 1 day (NOTE: Currently not used by SDK - uses fixed 30 second offset)
duration: 30, // 30 day sale
epochLength: 3600, // 1 hour epochs
// Price configuration
priceRange: {
startPrice: 0.0001, // Starting price in ETH
endPrice: 0.01 // Maximum price in ETH
},
tickSpacing: 60,
fee: 3000, // 0.3%
// Sale parameters
minProceeds: parseEther("10"), // Minimum 10 ETH
maxProceeds: parseEther("1000"), // Maximum 1000 ETH
// Vesting
yearlyMintRate: parseEther("100000"), // 100k tokens/year inflation
vestingDuration: BigInt(4 * 365 * 24 * 60 * 60), // 4 years
recipients: vestingRecipients,
amounts: vestingAmounts,
// Migration
liquidityMigratorData: liquidityMigratorData,
// Integrator
integrator: '0x123...', // REPLACE with your actual integrator address to receive fees
}, addresses, {
useGovernance: true // Standard governance (default)
});
// 8. Log deployment details
console.log("Token will be deployed at:", token);
console.log("Hook will be deployed at:", hook);
console.log("Sale will start at:", new Date((Math.floor(Date.now() / 1000) + 86400) * 1000));
// 9. Create the pool
const tx = await factory.create(createParams);
console.log("Transaction hash:", tx);
// 10. Wait for confirmation
const receipt = await publicClient.waitForTransactionReceipt({ hash: tx });
console.log("Pool created in block:", receipt.blockNumber);
return { token, hook, tx };
}