Launch a token with a revenue token
From the launch floor or a script: predictToken, every royalty pointed at it, then tokenize with the encoded launch in one transaction.
On this page
A new Hookr launch can mint a revenue token in the same transaction: the tokenizer launches the family through the launcher, locks it, and mints a token whose income is the pools' LP fees, arb recapture, royalty and the Hook Block takes that name it.
In the app
- Set up the launch on the launch floor as usual: the token, its pools and their Hook Blocks.
- On the Revenue step, under Creator income, switch on Hookr Multi-stream Revenue Tokenizer. The row lists the pools that will pay the revenue token, then its terms: name, ticker and supply, the term, the release period of 1 to 14 days, who receives the minted tokens, who can add streams later, and the market at mint, which starts off.
- The Review step spells out every choice the revenue token fixes. Sign: the ERC-20 budgets are approved to the tokenizer, then one transaction to the tokenizer launches, locks and mints.
- Once the launch lands, the launched screen offers the liquidity lock first, then time shares for the new revenue token, then sending some of it to the launched token's top holders, then a pool of the launched token quoted in the revenue token, opened with the launched token alone.
For a new Hookr pool of a token that already trades, open the New pool tab on /tokenize: it opens the launch floor on that token with the revenue token switched on.
The calls
- Build the launch's
LaunchParamsexactly as for the launcher'slaunchFamily: the launcher guide andhookr-sdk'sbuildLaunchFamilycover every field, andbuildLaunchFamilygives the value that call would carry. - Fix the token's terms, then
predictToken(creator, t)gives the revenue token's address before it exists. - Point the launch at Rules the tokenizer admits: any Rules Hookr's registry admits on the root, as
isAdmittedRules(rules)answers, the core among them.rootis the tokenizer's own,root(). A new token's salt starts with the creator's address, so no one else can launch the token you predicted through the tokenizer first. Every pool'sroyaltyTois the revenue token whereroyaltyBpsis above zero and zero where it is not. A pool binding Tax + Conversion names the token, or zero, as its creator recipient. Any other Hook Block with a Hook Block take in the quote pays it to its own recipient, and the tokenizer reports it withAdvisoryPayeeUnchecked. tokenize(t, s, m)with the encodedLaunchParamsins.launchParamsand the family's term ins.unlockBlock: a parent-chain block at least 50,400 past the current one, or the largestuint64for good. The value is the launch's plus the launcher'slaunchFee()once more when the market opens. ERC-20 budgets are pulled from the creator, approved to the tokenizer rather than the launcher.- The tokenizer lists the ERC-20 quote of each pool with a royalty or a Hook Block, since the token claims those in that quote. With
s.listAssetsset it also lists the launched token, which the pools' LP fees pay in too, while there is room; without it, that side of the fees reaches holders through the drop box. - The receipt's
Tokenizednames the token, andStreamAddednames the family door and the Rules ledger the pools' royalties are paid through.
At the end of a term the family goes back to the creator, and each pool's royalty keeps paying the token: Terms and endings.
In code
With client.ts and abis.ts:
import { concat, encodeAbiParameters, keccak256, parseEventLogs, parseUnits, slice, toHex, zeroAddress, type Account, type WalletClient } from "viem";
import type { AbiParametersToPrimitiveTypes } from "abitype"; // viem's own type package
import { client, parentBlock, RULES, TOKENIZER } from "./client";
import { launchFeeAbi, launchParamsAbi, tokenizerAbi } from "./abis";
type LaunchParams = AbiParametersToPrimitiveTypes<typeof launchParamsAbi>[0];
// `p` is the LaunchParams you would send to the launcher's launchFamily, and `launchValue` that call's value:
// build both with hookr-sdk's buildLaunchFamily, as the launcher guide shows.
export async function launchWithRevenueToken(wallet: WalletClient, creator: Account, p: LaunchParams, launchValue: bigint) {
const supply = parseUnits("100000000", 18);
const seed = parseUnits("1000000", 18);
const terms = {
name: "Example Launch Revenue",
symbol: "rLAUNCH",
supply,
streamSeconds: 86_400,
tipBps: 100,
assets: [],
recipients: [creator.address],
amounts: [supply - seed], // Hookr's leg comes from income, never from the supply
termsHash: keccak256(toHex("rLAUNCH: 100,000,000 supply, locked 28 days")),
streamManager: creator.address,
openStreams: false,
};
// 1. The revenue token's address, before anything exists.
const revenueToken = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "predictToken", args: [creator.address, terms] });
// 2. The launch on the tokenizer's root, a new token's salt starting with the creator's address, every royalty at the token.
const root = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "root" });
const fresh = p.token.existing === zeroAddress;
const params = {
...p,
root,
token: fresh ? { ...p.token, salt: concat([creator.address, slice(p.token.salt, 20)]) } : p.token,
members: p.members.map((m) => ({ ...m, rules: { ...m.rules, royaltyTo: m.rules.royaltyBps > 0 ? revenueToken : zeroAddress } })),
};
// 3. The term, in parent-chain blocks: 28 days. MIN_TERM_BLOCKS is 50,400, seven days.
const unlockBlock = (await parentBlock()) + 4n * 50_400n;
// 4. The market at mint against ETH on the tokenizer's own terms, and the launch fee once more for it.
const sqrt = (n: bigint) => {
let x = n;
let y = (x + 1n) / 2n;
while (y < x) [x, y] = [y, (y + n / y) / 2n];
return x;
};
const market = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "defaultMarket", args: [RULES, revenueToken, zeroAddress, sqrt(10_000_000n << 192n), seed] });
const launcher = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "launcher" });
const [launchFee] = await client.readContract({ address: launcher, abi: launchFeeAbi, functionName: "launchFee" });
// 5. One call launches, locks and mints. ERC-20 budgets are approved to the tokenizer, not the launcher.
const streams = {
launchParams: encodeAbiParameters(launchParamsAbi, [params]),
families: [],
rules: [],
feebs: [],
positionIds: [],
positionPermits: [],
v3PositionIds: [],
v3Permits: [],
revenueTokens: [],
sources: [],
unlockBlock, // the launch's family and the market's
unlockAt: 0n, // no door with a term in seconds here
listAssets: true, // list the launched token too, while there is room
};
const { request } = await client.simulateContract({
account: creator,
address: TOKENIZER,
abi: tokenizerAbi,
functionName: "tokenize",
args: [terms, streams, market],
value: launchValue + launchFee,
});
const receipt = await client.waitForTransactionReceipt({ hash: await wallet.writeContract(request) });
return parseEventLogs({ abi: tokenizerAbi, eventName: "Tokenized", logs: receipt.logs })[0].args;
}defaultMarket gives the tokenizer's own market terms on the Rules you pass, the core in RULES; the app pairs the revenue token's own market with HOOKR by default, or with ETH when the creator picks it. Either way the tokenizer points the market's royalty at the token itself.
Fee
A launch's pools are on the Hookr hook and pay Hookr through it, so their streams carry no leg, and neither does the market. The recipients' amounts are the supply less the market's seed.