StargazeLaunchFactory, StargazeFairLaunch and StargazeToken.
Stargaze launches are executed by two Solidity 0.8.24 contracts in contracts/src, all Ownable2Step, ReentrancyGuard and Pausable (OpenZeppelin v5). Every token they create is a StargazeToken: a fixed-supply ERC-20 with permit and no owner. TypeScript ABIs ship in lib/web3/abis.ts (launchFactoryAbi, fairLaunchAbi) and the configured addresses in stargazeContracts from lib/config/chains.ts.
Addresses come from NEXT_PUBLIC_LAUNCH_FACTORY_{MAINNET|SEPOLIA}, NEXT_PUBLIC_FAIR_LAUNCH_{MAINNET|SEPOLIA} and NEXT_PUBLIC_DEPLOY_BLOCK_{MAINNET|SEPOLIA}, read when the app is built. A network without an address has not been deployed for this build.
Network
Contract
Address
Deploy block
Ethereum 1
StargazeLaunchFactory
Not deployed yet
—
Ethereum 1
StargazeFairLaunch
Not deployed yet
—
Sepolia 11155111
StargazeLaunchFactory
Not deployed yet
—
Sepolia 11155111
StargazeFairLaunch
Not deployed yet
—
addresses.tsTypeScript
1import{stargazeContracts}from"@/lib/config/chains";23const{launchFactory,fairLaunch,deployBlock}=stargazeContracts[11155111];4// launchFactory / fairLaunch are undefined when the env var is unset or not a valid address
1functioncreateToken(LaunchParamscalldatap)2externalpayablenonReentrant3returns(addresstoken,addresspair);45structLaunchParams{6stringname;// 1–64 bytes7stringsymbol;// 1–16 bytes8uint8decimals;// <= 189uint256totalSupply;// raw units (already scaled by decimals), 1..type(uint112).max10stringmetadataURI;// e.g. ipfs://CID — stored once on the token11uint16creatorBps;12uint16communityBps;13uint16liquidityBps;// creatorBps + communityBps + liquidityBps == 10_00014addresscommunityWallet;// required when communityBps > 015boolburnLiquidity;// true => LP tokens to 0x…dEaD16uint256deadline;// unix seconds17}
Send msg.value = launchFee + liquidityEth. Everything above launchFee is paired with the liquidity allocation.
communityAmount = totalSupply × communityBps / 10_000, liquidityTokenAmount = totalSupply × liquidityBps / 10_000; the creator (msg.sender) receives the remainder, so rounding dust goes to the creator and supply is conserved exactly.
Liquidity is added with amountTokenMin = liquidityAmt and amountETHMin = liquidityEth: the brand-new pool must open exactly at the configured ratio.
LP tokens go to 0x…dEaD when burnLiquidity is true, otherwise to the creator. pair is the zero address when liquidityBps == 0.
Any unused ETH or tokens are returned to the creator; the launch fee is forwarded to feeRecipient. The factory retains nothing.
Revert
Condition
Expired()
block.timestamp > deadline
InvalidName()
name empty or longer than 64 bytes
InvalidSymbol()
symbol empty or longer than 16 bytes
InvalidDecimals()
decimals > 18
InvalidSupply()
totalSupply == 0 or > type(uint112).max (Uniswap V2 reserve bound)
InvalidAllocation()
the three bps values do not sum to exactly 10_000
InvalidCommunityWallet()
communityBps > 0 and communityWallet == address(0)
1eventTokenLaunched(2addressindexedtoken,3addressindexedcreator,4addressindexedpair,5stringname,6stringsymbol,7uint8decimals,8uint256totalSupply,9uint256creatorAmount,10uint256communityAmount,11uint256liquidityTokenAmount,12uint256liquidityEthAmount,// ETH actually used by the router13boolliquidityBurned,// burnLiquidity && liquidityAmt > 014stringmetadataURI15);
1import"viem/window";2import{createPublicClient,createWalletClient,custom,http,parseEther,parseEventLogs,parseUnits,zeroAddress}from"viem";3import{sepolia}from"viem/chains";4import{launchFactoryAbi}from"@/lib/web3/abis";5import{stargazeContracts}from"@/lib/config/chains";67constfactory=stargazeContracts[11155111].launchFactory;8if(!factory)thrownewError("StargazeLaunchFactory is not deployed on Sepolia for this build");910constpublicClient=createPublicClient({chain:sepolia,transport:http("https://ethereum-sepolia-rpc.publicnode.com")});11constwallet=createWalletClient({chain:sepolia,transport:custom(window.ethereum!)});12const[account]=awaitwallet.requestAddresses();1314constlaunchFee=awaitpublicClient.readContract({address:factory,abi:launchFactoryAbi,functionName:"launchFee"});15constliquidityEth=parseEther("0.05");1617// simulate first: InvalidAllocation, Expired, InsufficientFee… surface before the wallet prompt18const{request}=awaitpublicClient.simulateContract({19account,20address:factory,21abi:launchFactoryAbi,22functionName:"createToken",23value:launchFee+liquidityEth,24args:[{25name:"Nebula",26symbol:"NEB",27decimals:18,28totalSupply:parseUnits("1000000000",18),29metadataURI:"ipfs://…",30creatorBps:1_000,// 10 %31communityBps:0,32liquidityBps:9_000,// 90 % seeds the pool33communityWallet:zeroAddress,34burnLiquidity:true,35deadline:BigInt(Math.floor(Date.now()/1000)+20*60),36}],37});3839consthash=awaitwallet.writeContract(request);40constreceipt=awaitpublicClient.waitForTransactionReceipt({hash});41if(receipt.status!=="success")thrownewError("createToken reverted");4243const[launched]=parseEventLogs({44abi:launchFactoryAbi,45eventName:"TokenLaunched",46logs:receipt.logs.filter((l)=>l.address.toLowerCase()===factory.toLowerCase()),47});48console.log("token",launched.args.token,"pair",launched.args.pair);
"Fair launch": a uniform-price batch auction. During [startTime, endTime) anyone commits ETH; everyone pays the same clearing price totalRaised / saleTokens. The whole supply is held by the contract until finalisation, so nobody can pre-seed a pool at a manipulated price.
1functioncreateSale(SaleConfigcalldatac)2externalnonReentrant// not payable3returns(uint256saleId,addresstoken);45structSaleConfig{6stringname;// 1–64 bytes7stringsymbol;// 1–16 bytes8uint256totalSupply;// raw units, 18 decimals, 1..type(uint112).max9stringmetadataURI;10uint256saleTokens;// > 0, sold to committers11uint256liquidityTokens;// > 0, reserved for the pool; unused part is burned12uint16liquidityEthBps;// share of raised ETH paired into the pool13uint256reserveEth;// minimum raise for success (wei)14uint256maxCommitPerWallet;// 0 = unlimited15uint64startTime;// >= block.timestamp16uint64endTime;// startTime + [1 hour, 30 days]17uint64claimDelay;// <= 7 days after endTime18boolburnLiquidity;// true => LP tokens to 0x…dEaD19}
Tokens always have 18 decimals. The creator's allocation is totalSupply − saleTokens − liquidityTokens, paid out at a successful finalisation. The current platformFeeBps is snapshotted into the sale at creation, so later fee changes never affect it. Every validation failure reverts with InvalidConfig():
name / symbol length outside 1–64 / 1–16 bytes; totalSupply is 0 or above type(uint112).max
functionfinalize(uint256saleId)externalnonReentrant;// permissionless, never pausable
Reverts NotEnded() before endTime and AlreadyFinalized() on a second call. Anyone can call it, so funds can never be stuck behind the creator.
Failure (totalCommitted < reserveEth or nothing committed): the whole supply returns to the creator; participants refund.
Success: fee = raised × feeBps / 10_000 goes to feeRecipient; raised × liquidityEthBps / 10_000 ETH is paired with min(liquidityTokens, ethForLiquidity × saleTokens / raised) tokens so the pool opens at the clearing price; unused liquidity tokens are sent to 0x…dEaD; the creator receives the creator allocation and the remaining ETH.