Skip to content

Launch a token on Sepolia

Deploy the contracts, then create a token with one viem call.

This quickstart follows the repository's own deployment path (contracts/script/Deploy.s.sol, docs/DEPLOYMENT.md): test locally, deploy both launch contracts to Sepolia, point the app at them, then launch a token with createToken. If the contracts are already deployed for your build (see the table below), skip to step 4.

NetworkContractAddressDeploy block
Ethereum 1StargazeLaunchFactoryNot deployed yet—
Ethereum 1StargazeFairLaunchNot deployed yet—
Sepolia 11155111StargazeLaunchFactoryNot deployed yet—
Sepolia 11155111StargazeFairLaunchNot deployed yet—

Prerequisites

  • Foundry (forge, cast).
  • A funded Sepolia account imported as a keystore — the deploy flow never needs a raw private key in a file.
  • A Sepolia RPC URL and, to verify the contracts, an Etherscan API key.

1. Build and test

terminal
cd contractsforge install foundry-rs/forge-std OpenZeppelin/openzeppelin-contracts@v5.1.0 --no-commitforge buildforge test -vv   # unit, fuzz and invariant tests

2. Deploy to Sepolia

Deploy.s.sol reads its configuration from the environment and deploys StargazeLaunchFactory and StargazeFairLaunch in one broadcast.

VariableRequiredMeaning
UNISWAP_V2_ROUTERyesUniswap V2 Router02. Sepolia: 0xeE567Fe1712Faf6149d80dA1E6934E354124CfE3
FEE_RECIPIENTyesReceives launch fees and fair-launch platform fees
FACTORY_OWNERnoOwner of both contracts (defaults to FEE_RECIPIENT)
LAUNCH_FEE_WEInoInstant-launch fee, default 0, max 0.05 ETH
FAIR_LAUNCH_FEE_BPSnoFair-launch platform fee, default 100 (1 %), max 500
ALLOW_MAINNET_DEPLOYmainnet onlyThe script refuses chain id 1 unless this is true
terminal
cast wallet import deployer --interactiveexport SEPOLIA_RPC_URL=...  ETHERSCAN_API_KEY=...export UNISWAP_V2_ROUTER=0xeE567Fe1712Faf6149d80dA1E6934E354124CfE3export FEE_RECIPIENT=0xYourTreasury  FACTORY_OWNER=0xYourMultisigexport LAUNCH_FEE_WEI=0  FAIR_LAUNCH_FEE_BPS=100forge script script/Deploy.s.sol --rpc-url sepolia --account deployer --broadcast --verify

The script logs the chain id, both addresses and the deploy block.

3. Point the app at the deployment

.env.local
NEXT_PUBLIC_LAUNCH_FACTORY_SEPOLIA=0x...NEXT_PUBLIC_FAIR_LAUNCH_SEPOLIA=0x...NEXT_PUBLIC_DEPLOY_BLOCK_SEPOLIA=<block>

These are NEXT_PUBLIC_ variables, inlined when the app is built: restart next dev or rebuild. stargazeContracts[11155111] then exposes them, and event indexing starts at the deploy block.

4. Launch a token with viem

This mirrors what the /launch wizard does: check bytecode at the configured address, read launchFee, simulate, sign, wait for the receipt, and read the token address from the TokenLaunched event — never assume it.

launch-sepolia.ts
import "viem/window";import { createPublicClient, createWalletClient, custom, http, parseEther, parseEventLogs, parseUnits, zeroAddress } from "viem";import { sepolia } from "viem/chains";import { launchFactoryAbi } from "@/lib/web3/abis";import { stargazeContracts } from "@/lib/config/chains"; const factory = stargazeContracts[11155111].launchFactory;if (!factory) throw new Error("Set NEXT_PUBLIC_LAUNCH_FACTORY_SEPOLIA first"); const publicClient = createPublicClient({ chain: sepolia, transport: http("https://ethereum-sepolia-rpc.publicnode.com") });const wallet = createWalletClient({ chain: sepolia, transport: custom(window.ethereum!) });const [account] = await wallet.requestAddresses(); // 1. the contract really exists on this chainconst code = await publicClient.getCode({ address: factory });if (!code || code === "0x") throw new Error("No contract at the configured factory address"); // 2. msg.value = launchFee + ETH for the poolconst launchFee = await publicClient.readContract({ address: factory, abi: launchFactoryAbi, functionName: "launchFee" });const liquidityEth = parseEther("0.02"); // 3. simulate — reverts surface before the wallet promptconst { request } = await publicClient.simulateContract({  account,  address: factory,  abi: launchFactoryAbi,  functionName: "createToken",  value: launchFee + liquidityEth,  args: [{    name: "Sepolia Star",    symbol: "SSTAR",    decimals: 18,    totalSupply: parseUnits("1000000", 18),    metadataURI: "",    creatorBps: 2_000,    communityBps: 0,    liquidityBps: 8_000,           // must sum to 10_000    communityWallet: zeroAddress,  // only required when communityBps > 0    burnLiquidity: true,    deadline: BigInt(Math.floor(Date.now() / 1000) + 20 * 60),  }],}); // 4. sign, then wait for the receiptconst hash = await wallet.writeContract(request);const receipt = await publicClient.waitForTransactionReceipt({ hash });if (receipt.status !== "success") throw new Error("Deployment transaction reverted"); // 5. the real addresses come from the eventconst [ev] = parseEventLogs({  abi: launchFactoryAbi,  eventName: "TokenLaunched",  logs: receipt.logs.filter((l) => l.address.toLowerCase() === factory.toLowerCase()),});console.log("token:", ev.args.token, "pair:", ev.args.pair, "LP burned:", ev.args.liquidityBurned);

5. Verify

  • isStargazeToken(token) on the factory returns true.
  • GET /api/token/11155111/{token} returns the on-chain name, symbol, decimals and supply, with stargaze set.
  • GET /api/launches?chainId=11155111 lists it within the 30-second index cache.
  • Trade it in the app on /trade — the V2 pool exists as soon as the transaction confirms.