Duel Arena Oracle Deployment
This is the standalone duel arena oracle path inside Hyperscape. It is separate from betting and prediction market flows.Components
- EVM oracle package:
packages/duel-oracle-evm - Solana oracle package:
packages/duel-oracle-solana - Server publisher:
packages/server/src/oracle/DuelArenaOraclePublisher.ts - Metadata API:
GET /api/duel-arena/oracle/duels/:duelId
streaming:announcement:start-> publish duel announcement/open statestreaming:fight:start-> publish locked/start statestreaming:resolution:start-> publish result with comprehensive outcome datastreaming:cycle:aborted-> publish cancellation
Oracle Data Fields (March 2026)
The oracle now publishes comprehensive duel outcome data for betting market settlement and replay verification: Core Fields:roundId- Unique duel identifierparticipantA/participantB- Character IDswinner- Winning character ID (or empty for draw)timestamp- Unix timestamp of duel completion
damageA- Total damage dealt by participant AdamageB- Total damage dealt by participant BwinReason- Detailed win reason:knockout,timeout,forfeit,draw
seed- Cryptographic seed for replay verificationreplayHashHex- Hash of replay data for integrity verificationresultHashHex- Combined hash of all duel outcome data
arena_rounds database table and published to all configured oracle targets (EVM + Solana).
Oracle Data Fields (March 2026)
The oracle now publishes comprehensive duel outcome data: Core Fields:duelId- Unique duel identifier (hashed)participantAId- Participant A identifier (hashed)participantBId- Participant B identifier (hashed)betOpenTs- Betting window open timestamp (announcement start)betCloseTs- Betting window close timestamp (fight start)fightStartTs- Fight start timestampwinnerId- Winner identifier (hashed)loserId- Loser identifier (hashed)
damageA- Total damage dealt by participant AdamageB- Total damage dealt by participant BwinReason- Reason for victory (e.g., “knockout”, “timeout”, “forfeit”, “draw”)seed- Cryptographic seed for replay verificationreplayHashHex- Hash of replay data for integrity verificationresultHashHex- Combined hash of all duel outcome data
arena_rounds table and published to all configured oracle targets (EVM + Solana).
Impact: Provides comprehensive duel outcome data for betting market settlement, replay verification, and anti-cheat validation.
Local Wallet Generation
Generate unfunded deploy/reporter wallets and write them into ignored.env files:
packages/server/.envpackages/duel-oracle-evm/.env- public summary:
.codex-artifacts/duel-arena-oracle-wallets/public-addresses.json - Solana keypair file:
.codex-artifacts/duel-arena-oracle-wallets/solana-shared.json
- one shared EVM signer for Base, BSC, and AVAX
- one shared Solana signer for devnet and mainnet-beta
.env files and .codex-artifacts directory private.
Local End-to-End Verification
Run the full local duel, streaming, and oracle publish flow against Anvil and Solana localnet:- Starts or reuses local Anvil on
http://127.0.0.1:8545 - Starts or reuses
solana-test-validatoronhttp://127.0.0.1:8899 - Deploys
DuelOutcomeOracleto Anvil - Builds and deploys
fight_oracleto localnet - Starts the local duel stack
- Verifies streaming combat
- Confirms the resolved duel record exists on both local chains
Server Runtime Config
Server config lives inpackages/server/.env.
Core toggles:
testnet: Base Sepolia, BSC Testnet, Avalanche Fuji, Solana Devnetmainnet: Base, BSC, Avalanche C-Chain, Solana Mainnetall: publish to every configured target
EVM Deploy
EVM deploy config lives inpackages/duel-oracle-evm/.env. The default pattern is one shared PRIVATE_KEY for Base, BSC, and AVAX, with optional per-network overrides. See packages/duel-oracle-evm/.env.example. The canonical contract source shipped to consumers is under packages/duel-oracle-evm/contracts/DuelOutcomeOracle.sol.
Compile:
packages/duel-oracle-evm/deployments/duel-outcome-oracle/baseSepolia.jsonpackages/duel-oracle-evm/deployments/duel-outcome-oracle/bscTestnet.jsonpackages/duel-oracle-evm/deployments/duel-outcome-oracle/avaxFuji.jsonpackages/duel-oracle-evm/deployments/duel-outcome-oracle/base.jsonpackages/duel-oracle-evm/deployments/duel-outcome-oracle/bsc.jsonpackages/duel-oracle-evm/deployments/duel-outcome-oracle/avax.json
DUEL_ARENA_ORACLE_BASE_SEPOLIA_CONTRACT_ADDRESSDUEL_ARENA_ORACLE_BSC_TESTNET_CONTRACT_ADDRESSDUEL_ARENA_ORACLE_AVAX_FUJI_CONTRACT_ADDRESSDUEL_ARENA_ORACLE_BASE_MAINNET_CONTRACT_ADDRESSDUEL_ARENA_ORACLE_BSC_MAINNET_CONTRACT_ADDRESSDUEL_ARENA_ORACLE_AVAX_MAINNET_CONTRACT_ADDRESS
Solana Deploy
The canonical oracle program source now lives in the dedicated oracle package. Build:- Localnet:
6Tx7s2UG4maFWakRFVi4GeecXJYyBXQF8f2vJdQShSpV - Devnet:
6Tx7s2UG4maFWakRFVi4GeecXJYyBXQF8f2vJdQShSpV - Mainnet:
6Tx7s2UG4maFWakRFVi4GeecXJYyBXQF8f2vJdQShSpV
DUEL_ARENA_ORACLE_SOLANA_DEVNET_PROGRAM_IDDUEL_ARENA_ORACLE_SOLANA_MAINNET_PROGRAM_ID
ABI / IDL Usage
EVM ABI:- package export:
packages/duel-oracle-evm/src/generated/duelOutcomeOracleAbi.ts - published public config manifest:
@hyperscapeai/duel-oracle-evm/config.json
- canonical IDL JSON:
packages/duel-oracle-solana/anchor/target/idl/fight_oracle.json - generated TS package export:
packages/duel-oracle-solana/src/generated/fightOracleIdl.ts - published public config manifest:
@hyperscapeai/duel-oracle-solana/config.json
viem example:
web3.js / Anchor example:
Naming Note
The current on-chain schema still usesbetOpenTs and betCloseTs. In the duel arena oracle flow those fields represent the arena announcement window and lock/start transition, not a betting dependency.
Production Checklist
- Generate wallets and fund the shared EVM address on each destination EVM chain plus the shared Solana pubkey on the target cluster.
- Deploy EVM contracts and Solana program.
- Set the deployed contract/program addresses in
packages/server/.env. - Set
DUEL_ARENA_ORACLE_ENABLED=trueand choose the correctDUEL_ARENA_ORACLE_PROFILE. - Set
DUEL_ARENA_ORACLE_METADATA_BASE_URLto the public server URL. - Restart the server and verify:
GET /api/duel-arena/oracle/recentGET /api/duel-arena/oracle/duels/<duelId>- chain receipts/sigs appear in the returned
chainState - New fields (
damageA,damageB,winReason,seed,replayHashHex,resultHashHex) are populated
Metadata API Response Format (March 2026)
GET /api/duel-arena/oracle/duels/:duelId:"knockout"- One participant’s HP reached 0"timeout"- Fight duration exceeded maximum time limit"forfeit"- One participant disconnected or forfeited"draw"- Both participants died simultaneously or fight ended in a tie
Integration with Betting Stack
The betting stack (now in HyperscapeAI/hyperbet) consumes oracle data via:- REST API: Polls
GET /api/duel-arena/oracle/recentfor new duel outcomes - Blockchain Events: Subscribes to oracle contract events for settlement triggers
- Metadata Verification: Fetches full duel metadata from
GET /api/duel-arena/oracle/duels/:duelId
- Hyperscape Oracle: Publishes verifiable duel outcomes to blockchain
- Hyperbet Betting: Consumes oracle data for market settlement and payout calculation
- Oracle metadata API is public and versioned
- Betting stack subscribes to blockchain events for real-time settlement
- No direct code dependencies between repositories
Recent Changes (March 2026)
Damage Tracking (Commit aecab58)
New Fields:damageA and damageB track total damage dealt by each participant.
Use Cases:
- Betting market settlement (verify fight was legitimate)
- Replay verification (ensure damage totals match replay data)
- Anti-cheat validation (detect impossible damage values)
Replay Verification (Commit aecab58)
New Fields:seed, replayHashHex, resultHashHex enable deterministic replay verification.
Verification Flow:
- Oracle publishes
seedandreplayHashHexto blockchain - Betting markets can request replay data from metadata API
- Replay data is hashed and compared to
replayHashHex - Combined outcome data is hashed and compared to
resultHashHex
- Dispute resolution (verify fight outcome matches replay)
- Anti-cheat validation (detect manipulated fight data)
- Audit trail (cryptographic proof of fight integrity)
Win Reason Tracking (Commit aecab58)
New Field:winReason provides detailed context for fight outcome.
Values:
"knockout"- Normal combat victory (HP reached 0)"timeout"- Fight exceeded maximum duration"forfeit"- Participant disconnected or forfeited"draw"- Simultaneous death or tie
- Betting market rules (some markets may exclude timeouts/forfeits)
- Fight statistics (track knockout rate vs timeout rate)
- Anti-cheat validation (detect suspicious forfeit patterns)
Oracle Config Unit Tests (Commit 71dcba8)
New Tests:packages/server/tests/unit/oracle/config.test.ts
Coverage:
- Oracle configuration validation
- Target activation logic
- Signer material detection
- Profile resolution (testnet/mainnet/all)
Troubleshooting
Oracle Not Publishing
Check configuration:Missing Oracle Data
If oracle records are missingdamageA, damageB, or other new fields:
- Verify server is running commit aecab58 or later
- Check database schema includes new columns
- Run migrations:
bunx drizzle-kit migratefrompackages/server/ - Review
arena_roundstable schema
Replay Verification Failures
If replay hash verification fails:- Ensure
seedis consistent between oracle record and replay data - Verify
replayHashHexmatches hash of replay data - Check
resultHashHexmatches combined hash of all outcome fields - Review server logs for hash calculation errors
API Reference
GET /api/duel-arena/oracle/recent
Returns recent duel oracle records (last 100). Response:GET /api/duel-arena/oracle/duels/:duelId
Returns full duel metadata including replay verification data. Response: See “Metadata API Response Format” section above. New Fields (March 2026):damageA- Total damage dealt by participant AdamageB- Total damage dealt by participant BwinReason- Reason for victoryseed- Cryptographic seedreplayHashHex- Replay data hashresultHashHex- Combined outcome hash