BagsFactory directly. A single transaction deploys the token, its bonding curve, and its fee-share contract, mints the fixed supply to the curve, and registers everything on-chain. You can optionally include an atomic initial buy in the same transaction.
Prerequisites
Before starting, make sure you have:- Completed the Environment Setup (
chain.ts,addresses.ts,clients.ts, and the ABIs). - Read the Overview for the token lifecycle and fee model.
- ETH in your wallet to cover the creation fee (default 0.02 ETH — read it live), any initial buy, and gas.
1. How Launching Works
BagsFactory exposes two launch entry points:
Both take the same arguments:
partnerFeeBps (default 2500) is snapshotted into the launch, and the partner is paid from the protocol half of trading fees — it never reduces the claimers’ share. See section 6.
With createAndBuy, the factory spends the entire surplus above creationFee on an atomic buyFor(msg.sender, 1) — there is no front-run window, and if the buy would cross the graduation threshold the excess is auto-refunded.
2. Fee Claimers Rules
Theclaimers / bps arrays configure who earns the creator half (1%) of trading fees. The factory enforces:
- 1 to 100 claimers, with
claimers.length == bps.length. - Each claimer address is valid, non-zero, and unique, and not equal to the
partner. - Each
bpsis auint16, and allbpssum to exactly10000(100%). The factory enforces only the sum — individual shares of0are accepted on-chain. The client validator below additionally requires each share to be>= 1as a sensible default (a0-bps claimer would never earn).
10000 bps. Validate client-side before signing — an on-chain revert still costs gas.
When splitting a percentage across claimers, have the last claimer absorb any rounding remainder so the total lands on exactly
10000.3. Prepare Metadata
metadataURI should point to a JSON document describing the token (name, symbol, description, image, socials), typically hosted on IPFS. Upload it however you like and pass the resulting URI (e.g. https://ipfs.io/ipfs/...). This guide assumes you already have a metadataURI.
4. The Launch Script
Save this aslaunch-token.ts. It validates claimers, reads the live creation fee, simulates, sends, and parses the receipt.
launch-token.ts
5. Run Your Script
token address — it’s the identifier you’ll use everywhere else.
6. Splitting Fees Among Multiple Claimers
To share the creator side with additional wallets, list each with its bps. The example below gives the creator 50%, and two collaborators 30% and 20%:partner address. The partner’s cut comes from the protocol half of trading fees, not from the claimers: the factory’s global partnerFeeBps (default 2500 = 25% of the protocol half = 0.25% of volume) is snapshotted at launch, the partner accrues that share in the token’s BagsFeeShare, and the vault receives the remainder. The claimers always split the full creator half regardless of partner. The partner must not also appear in claimers. See the Partner Program guide for the full partner workflow (tracking tokens, reading earnings, claiming).
7. What Happens Next
After launch, the token trades on its bonding curve. Buyers send ETH to the curve to receive tokens; the creator side of every trade fee accrues to thefeeShare contract. When enough ETH is raised, the token graduates to a Uniswap v4 pool.
- To trade the token, see Trade Tokens.
- To read live state (price, bonding progress, migration status), see Read State & Discover Tokens.
- To claim accrued fees, see Claim Creator Fees.
Troubleshooting
BagsFactory_InsufficientCreationFee— you sent less thancreationFee(). Read the fee live and setvalueaccordingly.BagsFactory_NoClaimers— theclaimersarray is empty. Pass at least one claimer.BagsFactory_InvalidClaimers— the config failed a rule in section 2:claimers.length != bps.length, a duplicate or zero address, a claimer equal to thepartner, more than 100 claimers, orbpsthat don’t sum to10000.BagsFactory_BuyFailed(curve, value)— the atomic initial buy increateAndBuyreverted (e.g. slippage or curve state). Lower the buy value, or callcreateand buy separately.BagsFactory_NoBuyValue— you calledcreateAndBuywithvalue == creationFee(nothing left to buy with). Either add buy value or callcreate.- Simulation reverts before sending — the decoded custom error tells you exactly which rule failed; fix the inputs and retry. Simulating first means you never waste gas on a doomed launch.
