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
11 changes: 9 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,24 @@ NEXT_PUBLIC_CHAIN_ID=84532
# -----------------------------------------------------------------------------
# Wallet / Contract (§12 — External Dependencies)
# -----------------------------------------------------------------------------
# StoryFactory address — set after contracts#7 testnet deployment
# StoryFactory address
# Testnet: 0xfa5489b6710Ba2f8406b37fA8f8c3018e51FA229
# Mainnet: 0x66087c0032c304Eb724544ef8Fc7C7f3E6C8CdF5
NEXT_PUBLIC_CONTRACT_ADDRESS=

# -----------------------------------------------------------------------------
# Mint Club V2 (Base Sepolia testnet addresses)
# Mint Club V2
# -----------------------------------------------------------------------------
# Base Sepolia (testnet):
# MCV2_Bond: 0x5dfA75b0185efBaEF286E80B847ce84ff8a62C2d
# MCV2_Token: 0x37F540de37afE8bDf6C722d87CB019F30e5E406a
# MCV2_ZapV1: 0x40c7DC399e01029a51cAb316f8Bca7D20DE31bad
# MCV2_BondPeriphery: 0x20fBC8a650d75e4C2Dab8b7e85C27135f0D64e89
# PLOT_TOKEN (WETH on testnet): 0x4200000000000000000000000000000000000006
#
# Base Mainnet:
# MCV2_Bond: 0xc5a076cad94176c2996B32d8466Be1cE757FAa27
# PLOT_TOKEN (PL_TEST): 0xF8A2C39111FCEB9C950aAf28A9E34EBaD99b85C1

# -----------------------------------------------------------------------------
# Contract Deployment (testnet only — used by Foundry deploy scripts)
Expand Down
6 changes: 3 additions & 3 deletions lib/contracts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const EXPLORER_URL = IS_TESTNET
export const STORY_FACTORY = (process.env.NEXT_PUBLIC_CONTRACT_ADDRESS ??
(IS_TESTNET
? "0xfa5489b6710Ba2f8406b37fA8f8c3018e51FA229"
: "0x0000000000000000000000000000000000000000")) as `0x${string}`;
: "0x66087c0032c304Eb724544ef8Fc7C7f3E6C8CdF5")) as `0x${string}`;

/** ZapPlotLinkMCV2 — one-click buy (ETH/USDC/HUNT -> storyline token) */
export const ZAP_PLOTLINK = "0x0000000000000000000000000000000000000000" as const;
Expand All @@ -38,10 +38,10 @@ export const ZAP_PLOTLINK = "0x0000000000000000000000000000000000000000" as cons
* Mainnet: $PLOT ERC-20 (backed by $HUNT via Mint Club V2) */
export const PLOT_TOKEN = (IS_TESTNET
? "0x4200000000000000000000000000000000000006"
: "0x0000000000000000000000000000000000000000") as `0x${string}`;
: "0xF8A2C39111FCEB9C950aAf28A9E34EBaD99b85C1") as `0x${string}`;

/** Human-readable label for the reserve token */
export const RESERVE_LABEL = IS_TESTNET ? "WETH" : "$PLOT";
export const RESERVE_LABEL = IS_TESTNET ? "WETH" : "PL_TEST";

// ---------------------------------------------------------------------------
// Mint Club V2
Expand Down
17 changes: 12 additions & 5 deletions packages/sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ const PlotChainedEvent = storyFactoryAbi.find(
)!;
import {
STORY_FACTORY_ADDRESS,
STORY_FACTORY_MAINNET_ADDRESS,
MCV2_BOND_ADDRESS,
MCV2_BOND_MAINNET_ADDRESS,
ERC8004_REGISTRY_ADDRESS,
BASE_SEPOLIA_CHAIN_ID,
BASE_MAINNET_CHAIN_ID,
DEPLOYMENT_BLOCK,
DEPLOYMENT_BLOCK_MAINNET,
SUPPORTED_CHAIN_IDS,
} from "./constants";
import { uploadWithRetry, type FilebaseConfig } from "./ipfs";
Expand Down Expand Up @@ -147,6 +151,7 @@ export class PlotLink {
private readonly erc8004Registry: Address;
private readonly filebase: FilebaseConfig | undefined;
private readonly chain: Chain;
private readonly deploymentBlock: bigint;

constructor(config: PlotLinkConfig) {
const chainId = config.chainId ?? BASE_SEPOLIA_CHAIN_ID;
Expand All @@ -155,7 +160,9 @@ export class PlotLink {
`Unsupported chainId: ${chainId}. PlotLink SDK supports Base (8453) and Base Sepolia (84532).`,
);
}
this.chain = chainId === 8453 ? base : baseSepolia;
const isMainnet = chainId === BASE_MAINNET_CHAIN_ID;
this.chain = isMainnet ? base : baseSepolia;
this.deploymentBlock = isMainnet ? DEPLOYMENT_BLOCK_MAINNET : DEPLOYMENT_BLOCK;

const normalizedKey = config.privateKey.startsWith("0x")
? config.privateKey
Expand All @@ -175,8 +182,8 @@ export class PlotLink {

this.address = account.address;
this.storyFactory =
config.storyFactoryAddress ?? STORY_FACTORY_ADDRESS;
this.mcv2Bond = config.mcv2BondAddress ?? MCV2_BOND_ADDRESS;
config.storyFactoryAddress ?? (isMainnet ? STORY_FACTORY_MAINNET_ADDRESS : STORY_FACTORY_ADDRESS);
this.mcv2Bond = config.mcv2BondAddress ?? (isMainnet ? MCV2_BOND_MAINNET_ADDRESS : MCV2_BOND_ADDRESS);
this.erc8004Registry =
config.erc8004RegistryAddress ?? ERC8004_REGISTRY_ADDRESS;
this.filebase = config.filebase;
Expand Down Expand Up @@ -298,7 +305,7 @@ export class PlotLink {
address: this.storyFactory,
event: StorylineCreatedEvent,
args: { storylineId },
fromBlock: DEPLOYMENT_BLOCK,
fromBlock: this.deploymentBlock,
toBlock: "latest",
});

Expand Down Expand Up @@ -335,7 +342,7 @@ export class PlotLink {
address: this.storyFactory,
event: PlotChainedEvent,
args: { storylineId },
fromBlock: DEPLOYMENT_BLOCK,
fromBlock: this.deploymentBlock,
toBlock: "latest",
});

Expand Down
18 changes: 16 additions & 2 deletions packages/sdk/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,35 @@ export const BASE_MAINNET_CHAIN_ID = 8453;
*/
export const DEPLOYMENT_BLOCK = BigInt(20_000_000);

/**
* Deployment block for PlotLink contracts on Base mainnet.
* Used as the default fromBlock for mainnet event log queries.
*/
export const DEPLOYMENT_BLOCK_MAINNET = BigInt(43_559_145);

/** Supported chain IDs for the PlotLink SDK. */
export const SUPPORTED_CHAIN_IDS = new Set([BASE_SEPOLIA_CHAIN_ID, BASE_MAINNET_CHAIN_ID]);

// ---------------------------------------------------------------------------
// PlotLink contracts (Base Sepolia defaults)
// ---------------------------------------------------------------------------

/** StoryFactory — storyline + plot management. */
/** StoryFactory — storyline + plot management (Base Sepolia). */
export const STORY_FACTORY_ADDRESS =
"0xfa5489b6710Ba2f8406b37fA8f8c3018e51FA229" as const;

/** MCV2_Bond — bonding curve trading, token creation, royalty distribution. */
/** StoryFactory — storyline + plot management (Base mainnet). */
export const STORY_FACTORY_MAINNET_ADDRESS =
"0x66087c0032c304Eb724544ef8Fc7C7f3E6C8CdF5" as const;

/** MCV2_Bond — bonding curve trading (Base Sepolia). */
export const MCV2_BOND_ADDRESS =
"0x5dfA75b0185efBaEF286E80B847ce84ff8a62C2d" as const;

/** MCV2_Bond — bonding curve trading (Base mainnet). */
export const MCV2_BOND_MAINNET_ADDRESS =
"0xc5a076cad94176c2996B32d8466Be1cE757FAa27" as const;

/** ERC-8004 Agent Identity Registry. */
export const ERC8004_REGISTRY_ADDRESS =
"0x8004A169FB4a3325136EB29fA0ceB6D2e539a432" as const;
Loading