Web3/Web4 infrastructure for the MetaCoreX ecosystem — including the ARZY-G ERC-20 AI token and supporting smart contract infrastructure.
pnpm --filter @workspace/contracts run compile— compile Solidity contracts (Hardhat)pnpm --filter @workspace/contracts run test— run contract testspnpm --filter @workspace/contracts run node— start a local Hardhat EVM nodepnpm --filter @workspace/contracts run deploy:local— deploy to local Hardhat nodepnpm --filter @workspace/api-server run dev— run the API server (port 5000)pnpm --filter @workspace/scripts run agent:validator— score a test executor report with Gemini and mint ARZY-G on-chain if PoU Score ≥ 7 (scripts/src/validator-agent.ts)pnpm run typecheck— full typecheck across all packagespnpm run build— typecheck + build all packages- Required env:
DATABASE_URL— Postgres connection string (for API server)
- pnpm workspaces, Node.js 24, TypeScript 5.9
- Solidity 0.8.28, Hardhat 2.x, OpenZeppelin Contracts 5.x
- EVM target: Cancun (required for OZ v5
mcopyopcode) - API: Express 5
- DB: PostgreSQL + Drizzle ORM
- Validation: Zod (
zod/v4),drizzle-zod - API codegen: Orval (from OpenAPI spec)
- Build: esbuild (CJS bundle)
contracts/contracts/ARZYG_ERC20_AI.sol— ARZY-G ERC-20 AI token (main contract)contracts/contracts/ReportVerification.sol— standalone Proof-of-Usefulness verification oracle (report scoring, fees/cashback, optimistic disputes); independent from the token, never shares state or role grants with itcontracts/hardhat.config.ts— Hardhat configurationcontracts/scripts/deploy.ts,contracts/scripts/deploy-verification.ts— deployment scripts (token, ReportVerification)contracts/artifacts/— compiled contract ABIs and bytecode (gitignored)contracts/typechain-types/— generated TypeScript bindings (gitignored)artifacts/api-server/src/— Express API server source; serves only the JSON API under/api/*— no static frontend or SPA fallback (the oldpublic/index.htmldashboard was removed onceartifacts/metacorex-sitebecame the real frontend)artifacts/api-server/src/services/verificationIndexer.ts,verificationScorer.ts— background worker pair that indexes ReportVerification on-chain events and posts standard-tier scores; no HTTP route can triggerrecordVerificationdirectlylib/pou-validator/— shared PoU (Proof of Usefulness) validation package: strict pre-Gemini spam/length checks + the single Gemini-scoring call. Used by the API server (pouMintService.ts,verificationScorer.ts) andscripts/src/validator-agent.ts— no other code path may score a submission.lib/db/src/schema/verification_requests.ts— correlates ReportVerification on-chain events with off-chain report text/signatures submitted via the APIlib/db/src/schema/airdrop.ts,artifacts/api-server/src/services/registrationIndexer.ts,airdropPointsService.ts,src/routes/airdrop.ts— Sepolia-testnet-only points/airdrop program (not a live token distribution): points are derived at query time (never a stored mutable counter), so early participants are automatically credited with no backfill step. Registration +100, each proof +50, each referred wallet that later registers +200.registrationIndexer.tsbackfills/keepsagent_registrationsin sync with on-chainAgentRegisteredevents, same pattern as the PoU proof indexer./api/airdrop/claimis a stub — never mints or transfers.lib/api-spec/openapi.yaml— OpenAPI spec (source of truth for API contracts, includingverify/platforms)Dockerfile,fly.toml— Fly.io deployment (multi-stage build, only@workspace/api-serverruns in prod; nopublic/dir to copy anymore, image serves API only)render.yaml— Render Blueprint (alternative host):metacorex-backendas a Docker Web Service (reusesDockerfileunchanged, pnpm-based build) +metacorex-frontendas a Static Site (pnpm-based build, publishesartifacts/metacorex-site/dist/public); frontend talks to the backend via the build-timeVITE_API_URLenv var (seeartifacts/metacorex-site/.env.example)docs/api.md,docs/agent.md,docs/deploy.md,docs/deploy-render.md,docs/economics.md— API reference, third-party agent connection guide, Fly.io deployment guide, Render deployment guide, ReportVerification fee/cashback/dispute economicsexamples/agent-example.js,examples/agent_example.py— standalone (non-workspace) example agents
- OZ v5 requires
evmVersion: "cancun"— themcopyopcode used inBytes.solis Cancun-only; usingpariscauses compile errors. - ARZY-G uses individual Hardhat plugins (not
hardhat-toolbox) to avoid the Ignition peer-dep chain. - Role-based access with
AccessControl— onlyDEFAULT_ADMIN_ROLE,DEV_ADMIN_ROLE, andRESERVE_ROLEexist;registerAgent/submitProofare deliberately permissionless (no role) so third-party agents never need to be granted anything. - AI daily mint quota is enforced on-chain using a UTC day epoch (
block.timestamp / 1 days), shared globally (dailyMintLimit) and per-agent (agentDailyCap) across both mint paths (submitProofandbirthToken). - No ERC-2612 Permit and no
Pausable— the contract is intentionally minimal (ERC20+AccessControlonly); don't assume these exist when writing docs or examples. - PoU minting is server-signed only, never client-signed: both the task-marketplace "complete" flow and the Dashboard's manual "Submit Proof of Use" tab send free-text proof to the API, which scores it via
lib/pou-validator(strict validation, then Gemini) and — only on a passing score — mints from the server's own validator wallet (AGENT_PRIVATE_KEY) and forwards the reward. The frontend never sees a score, an amount, or the validator's key, and never signs asubmitProofmint tx itself. The Dashboard flow additionally requires an EIP-191 wallet signature over the proof text (proves authorship without exposing the key) before the server will score it. ReportVerification.solis a fully standalone contract (ownORACLE_ROLE/ARBITER_ROLE/DEFAULT_ADMIN_ROLE), never granted any role on the ARZY-G token and never bundled into the token's deploy script — it only reads the token throughIERC20. Deploying or upgrading it must never touchARZYG_ERC20_AI.solor its role grants.ReportVerification's standard (Gemini) tier reuses the exact same trust model as PoU minting: the server's existing validator wallet is grantedORACLE_ROLEand is the only caller ofrecordVerification, via a background worker (verificationScorer.ts) — no HTTP route triggers scoring directly. The premium (Chainlink Functions) tier is real code, not a stub, but ships withpremiumEnabled = falsesince the live token's Chainlink subscription was never funded; don't assume premium is active without checkingpremiumEnabledon-chain.
MetaCoreX ARZY-G (ERC20 + AccessControl, no Permit/Pausable) is an ERC-20 token with an AI integration layer:
- Standard token operations (transfer, approve) — no on-chain
burn,mint,aiMint,aiTransfer, or pause/unpause; those don't exist in the deployed contract despite older docs implying otherwise - Roles:
DEFAULT_ADMIN_ROLE(governance, reassignsRESERVE_ROLE),DEV_ADMIN_ROLE(triggersrequestUsefulness, sets daily quotas),RESERVE_ROLE(fee reserve address) — there is noMINTER_ROLE,AI_OPERATOR_ROLE, orPAUSER_ROLE registerAgent/submitProof: fully permissionless proof-of-work mint (reward = amount * score / 10, self-reported by the caller), bounded by a hardMAX_SUPPLY(1,000,000,000 ARZY-G, enforced in_update), an admin-configurable globaldailyMintLimit(default 10,000/day), an admin-configurable per-agentagentDailyCap(default 1,000/day), and ascore <= 10sanity checkrequestUsefulness→handleOracleFulfillment→birthToken: oracle-verified path (DEV_ADMIN_ROLEtriggers the request; only the Chainlink Functions router can fulfill it) that mints the full pre-agreed amount split 99% agent / 1% reserve when score ≥ 1, sharing the same daily-quota enforcement assubmitProof
ReportVerification (separate contract, live on Sepolia at 0xA25D6ed371de357A4d4C0111AAaC1e199B575975) is a universal PoU verification oracle built on top of ARZY-G — see docs/economics.md for the full model:
- Any agent pays a flat fee (3 ARZY-G standard/Gemini tier, 5 ARZY-G premium/Chainlink tier — premium shipped but admin-disabled until a real subscription is funded) directly from their own wallet to have a free-text report scored
- Every finalized fee splits 10% referrer cashback (pull-based via
claimRewards(), or stays with the treasury if no referrer) / 90% protocol treasury — no buyback/reserve cut - Optimistic dispute flow: scores post with a 24h challenge window; anyone can dispute with a 2x-fee bond during that window, an
ARBITER_ROLEaddress resolves it (upheld → bond refunded + score corrected; rejected → bond forfeited to treasury)
A Sepolia-testnet-only points/airdrop program (/airdrop page, /api/airdrop/*) previews a future distribution — not a live token payout — and rewards the same on-chain activity above: +100 for registering, +50 per proof, +200 per referred wallet that goes on to register. See docs/api.md and the "Where things live" entry above for how points are computed.
External developers can connect their own AI agent to MetaCoreX without ever sharing a private key with us:
- Fork this repo. (The GitHub Actions workflow runs
scripts/src/github-agent.tsinside the full pnpm workspace — copying just those two files into an unrelated repo will not work standalone.) - Add two GitHub Actions secrets in your fork:
AGENT_PRIVATE_KEY(your agent wallet) andSEPOLIA_RPC_URL(any Sepolia RPC endpoint), plus anAPI_BASE_URLrepo variable pointing at the published MetaCoreX API. - Fund that wallet with a little Sepolia ETH for gas from a public faucet.
- Enable Actions — the scheduled workflow registers your agent and submits proof-of-work directly on-chain with your own key.
The script only ever calls the public parts of the MetaCoreX API (contract info, task marketplace). registerAgent/submitProof are called directly on-chain by the agent's own wallet — never sent to our server. The two routes that do accept a raw private key (/api/agents/register, /api/agents/submit-proof) are internal-only, gated by a token in the gitignored scripts/.agent-internal-token file (never an env var, since forks of this repo must never inherit it), and reserved for our own scripts/src/auto-agent.ts automation; third-party agents should not use them.
Populate as you build — explicit user instructions worth remembering across sessions.
- OpenZeppelin v5 requires
evmVersion: "cancun"— do not downgrade toparis. pnpm approve-buildsis interactive; keccak and secp256k1 are listed inonlyBuiltDependenciesinpnpm-workspace.yamlso they build automatically onpnpm install.autoInstallPeers: falsein workspace — all peer deps must be listed explicitly inpackage.json.- Hardhat telemetry prompt blocks non-interactive terminals; prefix commands with
HARDHAT_DISABLE_TELEMETRY_PROMPT=true.
- See the
pnpm-workspaceskill for workspace structure, TypeScript setup, and package details