This guide walks through a complete single-platform DvP settlement where both buyer and seller are on your platform. After compliance, the contracts handle everything autonomously.Documentation Index
Fetch the complete documentation index at: https://docs.keystoneos.xyz/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Authenticated with M2M token (Authentication)
- A DvP settlement template available (browse via
GET /v1/settlement-templates)
Flow overview
Step 1: Submit the seller instruction
Provide the seller’s party details and their legs:trade_reference for the next step.
Step 2: Submit the buyer instruction
Submit the buyer’s matching instruction with the same trade reference:status: "matched" and a settlement_id. The settlement is created on-chain and the engine begins processing.
Step 3: Compliance screening
The engine automatically screens all parties through LSEG World-Check (entity) and CipherOwl (wallet). Results are attested to the ComplianceRegistry on-chain. In ~95% of cases, this completes automatically and the settlement advances toCOMPLIANCE_CLEARED.
If a party is flagged, the settlement pauses. Submit a compliance decision to continue:
Step 4: Parties deposit to escrow
Once compliance clears, the settlement reachesAWAITING_DEPOSITS. Both parties deposit their assets directly to the escrow smart contract on-chain using their deposit_secret (included in the settlement response for each leg). Your platform calls depositLeg(settlementId, legIndex, depositSecret) via its custody provider (such as MPC wallets or any signing infrastructure).
KeyStone is not involved in the deposit step. The escrow contract verifies keccak256(depositSecret) == depositKey to authorize each deposit.
Step 5: Contracts auto-execute and finalize
When all deposits are confirmed, the contracts take over autonomously:- The escrow contract detects all deposits are complete and notifies the SettlementCoordinator
- The coordinator verifies the atomicity gate and calls
executeSettlementwith recipient addresses (revealed at this point) - Tokens go to the buyer’s wallet, USDC goes to the seller’s wallet
- Settlement transitions to
FINALIZED - Your webhook endpoint receives
settlement.state.finalized
Monitoring
Track the settlement via polling or webhooks:Error scenarios
| Scenario | Result |
|---|---|
| Compliance rejection | Settlement -> ROLLED_BACK |
| Deposit timeout | Settlement -> TIMED_OUT, deposits returned (permissionless on-chain) |
| Execution failure | Settlement -> ROLLED_BACK, deposits returned |