Auto-launch a token
Prerequisites
Step 1: Mine the salt
import { getCreate2Address, keccak256, encodePacked } from 'viem'
import { randomBytes } from 'crypto'
const FIRE_LAUNCH = '0x69FE0908F1211dE66F7067021998f28A5693ABbD' // mainnet
const WETH = '0x4200000000000000000000000000000000000006'
// FireToken creation code hash - read once from a deployed FireToken or compute from its bytecode.
// Trust this from the launchpad repo's `forge build` output: keccak256(FireToken.creationCode + abi.encode(...constructorArgs))
function tokenAddrFor(salt: `0x${string}`): `0x${string}` {
const initCodeHash = computeFireTokenInitCodeHash(/* args identical across launches */)
return getCreate2Address({
from: FIRE_LAUNCH,
salt,
bytecodeHash: initCodeHash,
})
}
let salt: `0x${string}` | null = null
let tokenAddr: `0x${string}` | null = null
for (let i = 0; i < 10_000; i++) {
const candidate = `0x${randomBytes(32).toString('hex')}` as `0x${string}`
const addr = tokenAddrFor(candidate)
if (BigInt(addr) < BigInt(WETH)) {
salt = candidate
tokenAddr = addr
break
}
}
if (!salt) throw new Error('salt mining exhausted - try more attempts')Step 2: Call ignite
Step 3 (optional): Buy at launch
Step 4 (optional): Attach off-chain metadata
Watching the launch lifecycle
Triggering graduation
Common pitfalls
Where to next
Last updated