Launching a token
The ABIs are those of the verified contracts on the explorer. The snippets read the addresses from
window.AGI_CONFIG, which every page of this site loads; elsewhere, take them from Addresses.
Model V2
ethers v6 · AgiV2LaunchFactory
const FACTORY = window.AGI_CONFIG.contracts.launchpad.v2.factory;
const factory = new ethers.Contract(FACTORY, FACTORY_ABI, signer);
// 1. Pick a config and a quote asset. address(0) = native ETH.
const configId = 0n;
const pairToken = ethers.ZeroAddress;
const cfg = await factory.getLaunchConfig(configId); // supply, curveFeeBps, phantomQuote,
// graduationThreshold, poolFee,
// tickSpacing, enabled
if (!cfg.enabled) throw new Error('launch config disabled');
// 2. Pin the terms you were quoted. Zero waives the check.
const economics = await factory.previewLaunchEconomics(configId, pairToken);
const params = {
name: 'My Token',
symbol: 'MYT',
logo: 'https://.../logo.webp',
description: 'What it is.',
socials: { twitter: '', telegram: '', discord: '', website: '', farcaster: '' },
creatorFeeRecipient: await signer.getAddress(),
creatorTaxBps: 100, // 1%; ceiling is factory.maxCreatorTaxBps()
buybackEnabled: false, // always false on the AGI Launchpad
expectedEconomics: economics,
salt: ethers.hexlify(ethers.randomBytes(32)),
};
// 3. Optional: know the addresses before you send.
const deployer = await factory.launchDeployer();
// AgiV2LaunchDeployer.predictLaunchAddresses(deployment) -> (token, curve)
// 4. Send. msg.value must equal launchFee() exactly.
const fee = await factory.launchFee();
const tx = await factory['launchToken((string,string,string,string,(string,string,string,string,string),address,uint16,bool,bytes32,bytes32),uint256,address,address[])'](
params, configId, pairToken, [], // up to 32 snipe-tax exemptions
{ value: fee }
);
const receipt = await tx.wait(); // TokenLaunched(token, curve, deployer, ...)
The three-argument overload without the exemption list works the same way; the launching account and its
fee recipient are always exempt. Common reverts: LaunchFeeNotPaid (the value must equal the
fee), NotWhitelisted (only if launching is closedlaunching is closed: only whitelisted wallets can launch),
CreatorTaxTooHigh, LaunchEconomicsMismatch (the terms changed after your preview)
and PairTokenNotApproved.
Model V1
ethers v6 · AgiLaunchFactory
const FACTORY = window.AGI_CONFIG.contracts.launchpad.v1.factory;
const factory = new ethers.Contract(FACTORY, FACTORY_V1_ABI, signer);
const fee = await factory.launchFee();
const openingBuy = ethers.parseEther('0.05'); // anything above the fee is spent buying
const params = {
name: 'My Token',
symbol: 'MYT',
logo: 'https://.../logo.webp',
description: 'What it is.',
socials: { twitter: '', telegram: '', discord: '', website: '', farcaster: '' },
feeWallet: await signer.getAddress(), // receives LP fees and the opening buy
};
const tx = await factory.launchToken(
params,
0n, // launchConfigId
0n, // dexId
ethers.hexlify(ethers.randomBytes(32)), // salt
{ value: fee + openingBuy }
);