/** * Mint the "original" Arweave-era tokens on a test creator, so the Sepolia * rehearsal starts from the same state mainnet is in: tokens 1..N owned by you, * each pointing at its Arweave metadata. * * FROM_ID=1 TO_ID=5 npx hardhat run scripts/seed-originals.js --network sepolia * * Env: * CREATOR creator contract (default: the one in deployments/.json) * TO_ADDRESS who receives the originals (default: the signer) * ARWEAVE_BASE metadata prefix (default: the real COLORGASM one) * FROM_ID / TO_ID token range, default 1..100 * * Refuses to run on mainnet. */ import { addressFor, connect, creatorAt, main, tokenRange } from "./_lib.js"; const ARWEAVE_BASE = process.env.ARWEAVE_BASE ?? "https://arweave.net/2ydrm9ZHH7qxYrybOI4XeY9elm2JjpwSVXjcBhaZL6k/"; main(async () => { const { ethers, net, signer } = await connect(); if (net === "mainnet") throw new Error("the originals already exist on mainnet"); const creatorAddress = addressFor("creator", net); const creator = creatorAt(ethers, creatorAddress, signer); const to = process.env.TO_ADDRESS ?? signer.address; const ids = tokenRange(); console.log(`creator ${creatorAddress}\nminting #${ids[0]}..#${ids.at(-1)} to ${to}\n`); // Manifold assigns ids sequentially, so minting into a contract that already // has tokens shifts everything — check before adding more. const existing = await creator.ownerOf(ids[0]).catch(() => null); if (existing !== null) { throw new Error( `#${ids[0]} already exists on ${creatorAddress} (owner ${existing}). ` + `Ids are assigned sequentially, so minting now would not produce #${ids[0]}..#${ids.at(-1)}.`, ); } // Batches of 20 keep each tx small and the failure blast radius smaller. for (let i = 0; i < ids.length; i += 20) { const batch = ids.slice(i, i + 20); const uris = batch.map((id) => `${ARWEAVE_BASE}${id}`); const tx = await creator.mintBaseBatch(to, uris); await tx.wait(); console.log(` #${batch[0]}..#${batch.at(-1)} ${tx.hash}`); } console.log(`\nminted ${ids.length} token(s) — balanceOf(${to}) = ${await creator.balanceOf(to)}`); console.log(`tokenURI(${ids[0]}) ${await creator.tokenURI(ids[0])}`); console.log(`tokenURI(${ids.at(-1)}) ${await creator.tokenURI(ids.at(-1))}`); });