Skip to main content
Bilateral instruction submission is the primary way to initiate settlements in KeyStone. Both counterparties independently submit their side of the trade. When both instructions arrive, KeyStone automatically matches them and creates a settlement on-chain.

How it works

  1. First party submits: Platform A sends an instruction without a trade_reference. KeyStone generates one (format: KS-{uuid}).
  2. Share the reference: Platform A shares the trade reference with Platform B through their own channels (email, chat, API, etc.).
  3. Second party submits: Platform B sends an instruction with the same trade_reference. KeyStone finds the matching pending instruction.
  4. Automatic matching: KeyStone validates that both instructions are compatible and creates a settlement on-chain with both parties confirmed.

Step 1: Submit the first instruction

The first party submits their side of the trade. Leave trade_reference null to have KeyStone generate one.
Response:

Step 2: Share the trade reference

The trade reference (KS-abc123...) is shared between counterparties through their own communication channels. KeyStone does not handle this exchange - it is an out-of-band coordination step. Common methods:
  • Platform-to-platform API integration
  • Pre-agreed trade reference via OTC desk
  • Shared trade confirmation system

Step 3: Submit the matching instruction

The second party submits their instruction with the trade reference from Step 1.
If the instructions match, the response includes the settlement:

What matching validates

Both instructions must agree on: If validation fails, the second instruction is still saved as pending_match. It will not be automatically paired with the first instruction. The submitting platform can cancel it and resubmit with corrected details.

Optional fields

Cancellation

Cancel a pending instruction if it was submitted in error or the trade is no longer needed:
Only instructions with status: pending_match can be cancelled. Matched or expired instructions cannot be cancelled.

Expiry

Instructions have a default 24-hour time-to-live. After expiry, they are no longer eligible for matching. This prevents stale instructions from accidentally matching with new ones submitted days later.

Listing instructions

View your platform’s instructions:

Single-platform use

Bilateral instructions work for single-platform settlements too. When both instructions come from the same platform, the settlement is created as single_platform type. This is useful when your platform intermediates trades between its own users.

Escrow Deposits

How parties deposit into the settlement contract with commitment secrets.

Escrow Deposits

How parties deposit to escrow using commitment secrets.