Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions lib/contracts/abi.ts
Original file line number Diff line number Diff line change
@@ -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;
57 changes: 57 additions & 0 deletions lib/contracts/constants.ts
Original file line number Diff line number Diff line change
@@ -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;
Loading