BSC Testnet (97) Deployment Runbook
Step-by-step Operator runbook for dry-run simulation, BSC Testnet (97) broadcast, BscScan verification, Vault funding, and live INV-1 checks.
contract/script/DeployTestnet.s.sol deploys AdapterRegistry and BinaryEngine cleanly to local Anvil (31337) or BSC Testnet (97) while hard-reverting with MainnetBroadcastBlocked() on BSC Mainnet (56).
Operator Broadcast Policy
AI coding agents execute dry-run simulations only. Live broadcasts to BSC Testnet (97) and BSC Mainnet (56) are executed manually by the human Operator using encrypted keystores (--account deployer).
Step 1 — Dry-Run Simulation
cd contract
forge fmt --check
forge build --sizes
# Pure local dry-run (deploys mocks automatically on chainId 31337)
forge script script/DeployTestnet.s.sol:DeployTestnet
# Forked dry-run against BSC Testnet (97) with self-contained mocks
export DEPLOY_MOCKS=true
export GOVERNANCE_ADDRESS="0x<YOUR_GOVERNANCE_ADDRESS>"
export KEEPER_ADDRESS="0x<YOUR_KEEPER_ADDRESS>"
export GUARDIAN_ADDRESS="0x<YOUR_GUARDIAN_ADDRESS>"
export RESOLVER_ADDRESS="0x<YOUR_RESOLVER_ADDRESS>"
export ARBITER_ADDRESS="0x<YOUR_ARBITER_ADDRESS>"
forge script script/DeployTestnet.s.sol:DeployTestnet \
--rpc-url "$BSC_TESTNET_RPC_URL"Step 2 — Broadcast & Verify on BSC Testnet (97)
forge script script/DeployTestnet.s.sol:DeployTestnet \
--rpc-url "$BSC_TESTNET_RPC_URL" \
--account deployer \
--broadcast \
--verify \
--etherscan-api-key "$BSCSCAN_API_KEY" \
--chain-id 97Record all emitted addresses (USDT, BtcUsdFeed, InitialAdapter, AdapterRegistry, BinaryEngine) and deployment block in docs/adr/0003-network-deployments.md.
Step 3 — Post-Deploy Operator Checklist
Authorize Testnet Agents in Adapter
With DEPLOY_MOCKS=true, MockAgentIdAdapter is registered at construction (zero 48h timelock wait). Authorize test wallets with cast send "$INITIAL_ADAPTER" "setVerified(address,bool)" "$AGENT" true.
Fund the BinaryEngine Vault
Approve BinaryEngine for 5,000 USDT (18 decimals) and call fundVault(5000000000) (6-decimal internal units), then verify vault() Leaky Bucket caps via cast call.
Configure Workspace .env Files
Populate app/.env (zero keys), agenticmarket/.env.local (zero keys), and isolated workers/.env (single role key per process).
Confirm Live INV-1 Global Solvency
Run cd workers && bun run src/index.ts --mode=watcher --once and confirm "solvencyOk":true, "exactScalingOk":true, and "alertCount":0.
Run Endpoint Smoke Checks
Verify HTTP 200 across /health, /docs, /openapi.json, /llms.txt, POST /mcp, /api/v1/markets, /market, /developers, /agent-setup/prompt.md, and /agent-setup/skill.md.
Step 4 — CI/CD & Push-to-Deploy
Merging to main automatically deploys the web apps and VPS services while keeping smart contracts strictly manual:
- No Contract Auto-Deploy: Changes under
contract/**never trigger any deployment orforge script --broadcast. - Cloudflare Workers Builds (
agenticmarket&agenticmarket-docs): Connected tomainwith monorepo watch paths (agenticmarket/*anddocs-site/*, excludingcontract/*) andCLOUDFLARE_BUILD=1. Roll back anytime via Cloudflare Dashboard Deployments orcf workers deployments. - VPS Stack (
.github/workflows/deploy-vps.yml): Triggers onpushtomaintouchingapp/**,workers/**, ordeploy/**onceci.ymlpasses, runs sequential compose builds (--parallel 1) strictly scoped to~/agenticmarket/deploy/docker-compose.yml, and verifieschainId: 97health plus pre-existing host containers. Roll back viaagenticmarket-runtime:previousorgit revertonmain.