From 67cdccb03e778edecdde436064c4546b8d05eba3 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Fri, 13 Mar 2026 19:23:02 +0000 Subject: [PATCH] [#8] Add contract ABI definitions and address constants Define StoryFactory event ABIs (PlotChained, StorylineCreated, Donation) and function ABIs (createStoryline, chainPlot, donate) for indexer and frontend use. Add known external contract addresses (MCV2_Bond, MCV2_BondPeriphery, Uniswap V4, Permit2, ERC-8004) and placeholder addresses for PlotLink-owned contracts pending deployment. Fixes #8 Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/contracts/abi.ts | 97 ++++++++++++++++++++++++++++++++++++++ lib/contracts/constants.ts | 57 ++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 lib/contracts/abi.ts create mode 100644 lib/contracts/constants.ts diff --git a/lib/contracts/abi.ts b/lib/contracts/abi.ts new file mode 100644 index 00000000..5acfc481 --- /dev/null +++ b/lib/contracts/abi.ts @@ -0,0 +1,97 @@ +/** + * StoryFactory contract ABIs — event signatures and write functions. + * + * Source: proposal §4.1 (events), §4.3 (StoryFactory interface). + * Contract address: see constants.ts (TBD until deployment). + */ + +// --------------------------------------------------------------------------- +// Events +// --------------------------------------------------------------------------- + +export const plotChainedEvent = { + type: "event", + name: "PlotChained", + inputs: [ + { name: "storylineId", type: "uint256", indexed: true }, + { name: "plotIndex", type: "uint256", indexed: true }, + { name: "writer", type: "address", indexed: true }, + { name: "contentCID", type: "string", indexed: false }, + { name: "contentHash", type: "bytes32", indexed: false }, + ], +} as const; + +export const storylineCreatedEvent = { + type: "event", + name: "StorylineCreated", + inputs: [ + { name: "storylineId", type: "uint256", indexed: true }, + { name: "writer", type: "address", indexed: true }, + { name: "tokenAddress", type: "address", indexed: false }, + { name: "title", type: "string", indexed: false }, + { name: "hasDeadline", type: "bool", indexed: false }, + ], +} as const; + +export const donationEvent = { + type: "event", + name: "Donation", + inputs: [ + { name: "storylineId", type: "uint256", indexed: true }, + { name: "donor", type: "address", indexed: true }, + { name: "amount", type: "uint256", indexed: false }, + ], +} as const; + +// --------------------------------------------------------------------------- +// Functions +// --------------------------------------------------------------------------- + +export const createStorylineFunction = { + type: "function", + name: "createStoryline", + stateMutability: "nonpayable", + inputs: [ + { name: "title", type: "string" }, + { name: "openingCID", type: "string" }, + { name: "openingHash", type: "bytes32" }, + { name: "hasDeadline", type: "bool" }, + ], + outputs: [{ name: "storylineId", type: "uint256" }], +} as const; + +export const chainPlotFunction = { + type: "function", + name: "chainPlot", + stateMutability: "nonpayable", + inputs: [ + { name: "storylineId", type: "uint256" }, + { name: "contentCID", type: "string" }, + { name: "contentHash", type: "bytes32" }, + ], + outputs: [], +} as const; + +export const donateFunction = { + type: "function", + name: "donate", + stateMutability: "nonpayable", + inputs: [ + { name: "storylineId", type: "uint256" }, + { name: "amount", type: "uint256" }, + ], + outputs: [], +} as const; + +// --------------------------------------------------------------------------- +// Combined ABI (for viem contract instances) +// --------------------------------------------------------------------------- + +export const storyFactoryAbi = [ + plotChainedEvent, + storylineCreatedEvent, + donationEvent, + createStorylineFunction, + chainPlotFunction, + donateFunction, +] as const; diff --git a/lib/contracts/constants.ts b/lib/contracts/constants.ts new file mode 100644 index 00000000..d95bdd14 --- /dev/null +++ b/lib/contracts/constants.ts @@ -0,0 +1,57 @@ +/** + * Contract addresses and chain configuration for PlotLink on Base. + * + * Source: proposal §12 (External Dependencies). + * + * PlotLink-owned contracts (StoryFactory, ZapPlotLinkMCV2, $PLOT) use + * placeholder zero addresses until deployed to Base mainnet. + */ + +// --------------------------------------------------------------------------- +// Chain +// --------------------------------------------------------------------------- + +export const BASE_CHAIN_ID = 8453; + +// --------------------------------------------------------------------------- +// PlotLink contracts (TBD — replace after deployment) +// --------------------------------------------------------------------------- + +/** StoryFactory — storyline + plot management */ +export const STORY_FACTORY = "0x0000000000000000000000000000000000000000" as const; + +/** ZapPlotLinkMCV2 — one-click buy (ETH/USDC/HUNT -> storyline token) */ +export const ZAP_PLOTLINK = "0x0000000000000000000000000000000000000000" as const; + +/** $PLOT protocol token (ERC-20, issued via Mint Club backed by $HUNT) */ +export const PLOT_TOKEN = "0x0000000000000000000000000000000000000000" as const; + +// --------------------------------------------------------------------------- +// Mint Club V2 (deployed on Base — immutable third-party contracts) +// --------------------------------------------------------------------------- + +/** MCV2_Bond — bonding curve trading, token creation, royalty distribution */ +export const MCV2_BOND = "0xc5a076cad94176c2996B32d8466Be1cE757FAa27" as const; + +/** MCV2_BondPeriphery — helper for multi-step bond operations */ +export const MCV2_BOND_PERIPHERY = "0x492C412369Db76C9cdD9939e6C521579301473a3" as const; + +// --------------------------------------------------------------------------- +// Uniswap V4 (Base) +// --------------------------------------------------------------------------- + +/** Universal Router — swap execution */ +export const UNISWAP_V4_ROUTER = "0x6fF5693b99212Da76ad316178A184AB56D299b43" as const; + +/** Quoter — price estimation for frontend quotes */ +export const UNISWAP_V4_QUOTER = "0x0d5e0F971ED27FBfF6c2837bf31316121532048D" as const; + +/** Permit2 — gasless token approvals */ +export const PERMIT2 = "0x000000000022D473030F116dDEE9F6B43aC78BA3" as const; + +// --------------------------------------------------------------------------- +// ERC-8004 Agent Identity (Base) +// --------------------------------------------------------------------------- + +/** Agent Registry — agent writer identity NFTs and reputation */ +export const ERC8004_REGISTRY = "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432" as const;