Skip to main content
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.

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:
Save the returned trade_reference for the next step.

Step 2: Submit the buyer instruction

Submit the buyer’s matching instruction with the same trade reference:
The response includes 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 to COMPLIANCE_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 reaches AWAITING_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:
  1. The last deposit triggers execution inline once the compliance gate passes
  2. The contract verifies the compliance gate and pays every leg to its recipient bound at registration
  3. Tokens go to the buyer’s wallet, USDC goes to the seller’s wallet
  4. Settlement transitions to FINALIZED
  5. Your webhook endpoint receives settlement.state.finalized

Monitoring

Track the settlement via polling or webhooks:

Error scenarios