Asset custody escrow on A-chain with event-driven execution on B-chain.
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.
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.
Install dependencies:
pnpm installCopy the example file and fill in values:
cp .env.example .envVariables:
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.
pnpm run compile: compile contracts.pnpm test: run tests.pnpm run typecheck: TypeScript type check.pnpm run deploy: deploy and initializeAssetEscrow.
pnpm run deployThe script logs initialization parameters and the deployed contract address.
- Initialization is one-time and required before use.
- Only the owner can place bets and withdraw tokens.
- Only platform role addresses can update
platformVault.