Skip to content

Launch a token

5 minutes · Node 20+ · a wallet with test BNB

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.

A launch needs three things: a name, a ticker and an opening market cap.

  1. Get test BNB. Make a new wallet for this (never one holding real funds) and fund it from the BNB Chain testnet faucet.

  2. Install ethers in an empty folder:

    Terminal window
    npm init -y && npm pkg set type=module && npm i ethers
  3. Save the file below as launch.mjs.

  4. Run it on testnet:

    Terminal window
    MM_API=https://marketmayhem.co/api/v1 PRIVATE_KEY=0x… NAME=Moth SYMBOL=MOTH node launch.mjs

    It prints what it will do, then a link to your new token’s page.

launch.mjs
// Launch a token: a name, a ticker and an opening market cap. That's all it needs.
// PRIVATE_KEY=0x… node launch.mjs
import { 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.

Each of these is a field you add to the same request. Use any, all, or none.

Buy some of your own token inside the launch itself, so nobody can buy before you. Here, 0.05 BNB:

firstBuy: '0.05',

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 },
],

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 },
],

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:

AddThe royalty goes
nothingall to you
royaltyTo: '0xOtherWallet'all to another wallet
burnPct: 50half buys back and burns the token, half to you (any 1–99)
burnPct: 100all of it buys back and burns the token, for ever

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 MB
description: 'What the token is about.',
website: 'https://example.com', x: 'https://x.com/example', telegram: 'https://t.me/example',

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.