Skip to content

YoubetDao/keyopinion-contract

Repository files navigation

KeyOpinion Contract

Asset custody escrow on A-chain with event-driven execution on B-chain.

Architecture

Architecture Diagram

Smart Contract Architecture

The system separates custody and execution with a clean, event-driven boundary:

Custody & Intent Emission

AssetEscrow (A-chain): Holds user funds and emits a deterministic BetPlaced event per intent.

PlatformVault (A-chain): Receives spend assets to keep custody on the origin chain.

Event Relay & Execution

Listener Service: Consumes BetPlaced events and triggers execution workflows.

B-chain Vault: Executes Polymarket operations on behalf of users.

Governance & Control

Platform Role: Authorized actors can update vault configuration.

Owner Access: Only the owner can place bets and withdraw tokens.

This design keeps assets anchored on A-chain while enabling cross-chain execution, delivering stronger safety guarantees with operational scalability.

Contracts

  • AssetEscrowBase: abstract base with state, events, and access control.
  • AssetEscrow: concrete implementation with initialize, role management, bet placement, and withdrawals.
  • MockERC20: test token based on OpenZeppelin ERC20.

Setup

Install dependencies:

pnpm install

Environment

Copy the example file and fill in values:

cp .env.example .env

Variables:

  • RPC_URL: RPC endpoint for the target network.
  • PRIVATE_KEY: deployer private key.
  • PLATFORM_VAULT: platform vault address on A-chain.
  • PLATFORM: platform role address.

Scripts

  • pnpm run compile: compile contracts.
  • pnpm test: run tests.
  • pnpm run typecheck: TypeScript type check.
  • pnpm run deploy: deploy and initialize AssetEscrow.

Deployment

pnpm run deploy

The script logs initialization parameters and the deployed contract address.

Notes

  • Initialization is one-time and required before use.
  • Only the owner can place bets and withdraw tokens.
  • Only platform role addresses can update platformVault.

About

Non-Custodial Prediction Market Aggregator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors