Build bots, indexers, and frontends on hoodstar.fun with @hoodstar/sdk — typed reads and writes, exact quote math, and event streaming.
@hoodstar/sdk is the official TypeScript SDK for the hoodstar.fun protocol. It’s a thin, fully-typed layer over viem — its only peer dependency — covering the entire protocol surface: launching tokens, trading the curve, quoting, migration, fee claims, and event streaming.
npm install @hoodstar/sdk viem
The package is ESM-only. All amounts are bigint wei values — use viem’s parseEther / formatEther helpers.
You can quote on-chain (source of truth) or client-side — the SDK’s math module is a bit-exact mirror of the contract’s rounding, so quotes match to the wei with zero RPC round-trips:
import { quoteBuy, quoteSell, currentPrice, curveProgressBps, ethToGraduate } from "@hoodstar/sdk";const state = await hood.read.getCurveState(token);const { totalFeeBps } = await hood.read.getFees();// Instant, local, exactconst q = quoteBuy(state, totalFeeBps, parseEther("1"));// → { tokensOut, fee, ethUsed, graduates } graduates=true → this buy finishes the curveconst price = currentPrice(state); // wei per whole tokenconst progress = curveProgressBps(state); // 0–10000 (10000 = graduated)const remaining = ethToGraduate(state, totalFeeBps); // gross ETH to buy out the curve// Or ask the contract directly — identical resultsconst onchain = await hood.read.quoteBuy(token, parseEther("1"));
createToken deploys the ERC-20 and opens its curve. Recover the token address from the TokenCreated event in the receipt:
import { parseEventLogs } from "viem";import { hoodLaunchpadAbi } from "@hoodstar/sdk";const hash = await hood.write.createToken({ name: "My Star", symbol: "MSTAR", metadataURI: "ipfs://Qm…", // image + description, pinned to IPFS devBuyEth: parseEther("0.5"), // optional first buy at the public price});const receipt = await publicClient.waitForTransactionReceipt({ hash });const [created] = parseEventLogs({ abi: hoodLaunchpadAbi, logs: receipt.logs, eventName: "TokenCreated",});const token = created.args.token;
Every hood.write.* method simulates first (so reverts are decoded before you spend gas) and returns the transaction Hash — await the receipt yourself with publicClient.waitForTransactionReceipt.
const q = quoteBuy(state, totalFeeBps, parseEther("8"));if (q.graduates) { // This buy will finish the curve; ethUsed < input and the remainder is refunded on-chain}// After graduation, anyone can migrate — permissionless and freeawait publicClient.waitForTransactionReceipt({ hash: await hood.write.migrate(token) });// Inspect the resulting Uniswap v3 poolconst pool = await hood.read.getPool(token); // zero address until pool existsconst { sqrtPriceX96, liquidity } = await hood.read.getPoolState(pool);const positionId = await hood.read.positionOf(token); // locked LP NFT id (0 = not migrated)
// Accrued but unclaimed creator fees for a token (in wei)const owed = await hood.read.creatorFeesOwed(token);// Claims are permissionless — funds always go to the registered recipientawait hood.write.claimCreatorFees(token);await hood.write.claimProtocolFees(); // pays the treasury// Harvest locked-LP swap fees for a graduated token (50/50 creator/treasury)const locker = await hood.read.locker();await hood.write.collectFees(locker, token);// Redirect your creator fee stream (only the current recipient can call this)await hood.write.setFeeRecipient(token, "0xNewRecipient…");
The watch layer polls eth_getLogs over HTTP (Robinhood Chain’s public RPC has no websocket), delivers events at least once in (blockNumber, logIndex) order, and gives you a cursor for crash-safe resumption: