Launch a token
This is for launching a token from your own code: a bot, an app or a script. To launch by hand, use the launch page on the site.
The simplest launch
Section titled “The simplest launch”A launch needs three things: a name, a ticker and an opening market cap.
-
Get test BNB. Make a new wallet for this (never one holding real funds) and fund it from the BNB Chain testnet faucet.
-
Install ethers in an empty folder:
Terminal window npm init -y && npm pkg set type=module && npm i ethers -
Save the file below as
launch.mjs. -
Run it on testnet:
Terminal window MM_API=https://marketmayhem.co/api/v1 PRIVATE_KEY=0x… NAME=Moth SYMBOL=MOTH node launch.mjsIt prints what it will do, then a link to your new token’s page.
// Launch a token: a name, a ticker and an opening market cap. That's all it needs.// PRIVATE_KEY=0x… node launch.mjsimport { JsonRpcProvider, Wallet } from 'ethers';
const API = process.env.MM_API ?? 'https://marketmayhem.co/api/v1';
const settings = await (await fetch(`${API}/settings`)).json();const rpc = settings.chainId === 56 ? 'https://bsc-dataseed.bnbchain.org' : 'https://bsc-testnet-rpc.publicnode.com';const wallet = new Wallet(process.env.PRIVATE_KEY, new JsonRpcProvider(rpc, settings.chainId));
// 1. The API builds the launch for your wallet and simulates it.const res = await fetch(`${API}/build/launch`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ wallet: wallet.address, name: process.env.NAME ?? 'Moth', symbol: process.env.SYMBOL ?? 'MOTH', marketCapUsd: process.env.MARKET_CAP_USD ?? '5000', image: process.env.IMAGE ?? 'https://marketmayhem.co/icon-512.png', // the logo: every launch needs one }),});const launch = await res.json();if (!res.ok) throw new Error(`${launch.error.code}: ${launch.error.message} ${launch.error.fix ?? ''}`);console.log(launch.explain);
// 2. Your wallet signs and sends it. The key never leaves this process.const sent = await wallet.sendTransaction({ to: launch.tx.to, data: launch.tx.data, value: BigInt(launch.tx.value), gasLimit: BigInt(launch.tx.gas) });const receipt = await sent.wait();if (receipt.status !== 1) throw new Error(`reverted: ${sent.hash}`);console.log(`launched: https://marketmayhem.co/t/${launch.token}`);console.log('RESULT', JSON.stringify({ token: launch.token, hash: sent.hash }));What happened: the API built the launch for your wallet and simulated it against the chain; your wallet signed and sent it. Your token now has its own PancakeSwap V3 pool, with the liquidity locked for ever: nobody can remove it, including you and us. Every buy of it pays you a royalty, for ever.
Going further: optional add-ons
Section titled “Going further: optional add-ons”Each of these is a field you add to the same request. Use any, all, or none.
A first buy, in the same transaction
Section titled “A first buy, in the same transaction”Buy some of your own token inside the launch itself, so nobody can buy before you. Here, 0.05 BNB:
firstBuy: '0.05',Send the first buy to other wallets
Section titled “Send the first buy to other wallets”Split the tokens from your first buy across up to 8 wallets. The shares must add up to 100. For example, part to you and part to a team wallet:
firstBuy: '0.05',firstBuyTo: [ { wallet: '0xYourWallet', pct: 70 }, { wallet: '0xTeamWallet', pct: 30 },],Burn part of the first buy
Section titled “Burn part of the first buy”Send a share to the dead address, 0x000000000000000000000000000000000000dEaD, and those tokens can never move again. For example, burn 60% and keep 40%:
firstBuy: '0.05',firstBuyTo: [ { wallet: '0x000000000000000000000000000000000000dEaD', pct: 60 }, { wallet: '0xYourWallet', pct: 40 },],Choose where the royalty goes
Section titled “Choose where the royalty goes”Your royalty is your share of the pool fees on every buy, for ever. By default it all comes to you. You can change that:
| Add | The royalty goes |
|---|---|
| nothing | all to you |
royaltyTo: '0xOtherWallet' | all to another wallet |
burnPct: 50 | half buys back and burns the token, half to you (any 1–99) |
burnPct: 100 | all of it buys back and burns the token, for ever |
The logo (required) and details
Section titled “The logo (required) and details”Every launch needs a logo: no token launches without one. The details are optional.
image: 'https://example.com/logo.png', // required: PNG, JPG, GIF or WebP, up to 5 MBdescription: 'What the token is about.',website: 'https://example.com', x: 'https://x.com/example', telegram: 'https://t.me/example',All of it together
Section titled “All of it together”Launch with a first buy and a burn is a complete, tested example using a first buy, a burn at launch and burnPct: 100 in one launch.
- Every launch option, and what the API sends back:
POST /build/launch. - How much a first buy gets you: the first buy and the price.