@bufinance/kawaii
v0.1.0
Published
Canonical Kawaii Punk NFT contract config + holder-aware redirect resolver for BU.FI apps. Decides where to send a user: their punk page, the mint page, or the secondary market when sold out.
Maintainers
Readme
@bufinance/kawaii
Canonical Kawaii Punk NFT contract config + holder-aware redirect resolver for BU.FI apps. The single source of truth for "where do I send this user?":
- holder → their punk page
- non-holder, mints open → the mint page
- non-holder, sold out → the secondary market(s)
Two live collections, both on Avalanche C-Chain (43114):
- main — the current production collection (v3, live 2026-06-23).
- beta — the former collection (v2), now the dev+staging TEST contract.
Zero runtime dependencies. Reads env via an override-first reader
(process.env → globalThis.__BU_ENV__), so it runs in Node, Cloudflare
Workers, edge runtimes, and the browser (defaults only).
Install
npm i @bufinance/kawaiiPure core — @bufinance/kawaii
import {
getKawaiiPunkContract,
resolveKawaiiRedirect,
getKawaiiRedirectTargets,
kawaiiCollectionAddress,
} from "@bufinance/kawaii";
getKawaiiPunkContract("main");
// → { address: "0x3ce4f5…", chainId: 43114, rpcUrl: "https://api.avax.network/…" }
// Pure decision — you supply holder + sold-out status:
resolveKawaiiRedirect({ isHolder: false, soldOut: false });
// → { kind: "mint", url: "https://fx.bu.finance/en/kawaii-preview", alternatives: [] }
resolveKawaiiRedirect({ isHolder: true, soldOut: false, punkAddress: "0xabc" });
// → { kind: "punk", url: "https://fx.bu.finance/en/punk/0xabc", alternatives: [] }
resolveKawaiiRedirect({ isHolder: false, soldOut: true });
// → { kind: "secondary", url: "https://joepegs.com/…", alternatives: [Joepegs, OpenSea] }Pass appBaseUrl: "" for same-origin (relative) in-app links in the browser;
secondary-market links are always absolute.
With live state — @bufinance/kawaii/client
Resolves holder + sold-out from the BU.FI Kawaii HTTP APIs
(/api/kawaii/status, /api/kawaii/curve/price), then picks the destination:
import { resolveKawaiiDestination, fetchKawaiiState } from "@bufinance/kawaii/client";
const dest = await resolveKawaiiDestination({ walletAddress: "0xabc" });
// → { kind, url, alternatives }Env overrides
| Var | Default |
|---|---|
| KAWAII_PUNK_CONTRACT_MAIN | 0x3ce4f5fde5c8aae5b4b10f6b647fdcca1349cd4f |
| KAWAII_PUNK_CONTRACT_BETA | 0x301faf452906d0d8e701d3e4c5ed9f2a023e48ee |
| KAWAII_PUNK_CHAIN_ID_MAIN / _BETA | 43114 |
| KAWAII_PUNK_RPC_MAIN / _BETA / AVAX_RPC_URL | https://api.avax.network/ext/bc/C/rpc |
| KAWAII_APP_URL / NEXT_PUBLIC_APP_URL | https://fx.bu.finance |
| KAWAII_MINT_PATH | /kawaii-preview |
| KAWAII_PUNK_PATH | /punk/{address} |
| KAWAII_SECONDARY_MARKETS (JSON [{label,url}]) | Joepegs + OpenSea (derived) |
| KAWAII_DEFAULT_LOCALE | en |
License
MIT
