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.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.
How it works
- First party submits: Platform A sends an instruction without a
trade_reference. KeyStone generates one (format:KS-{uuid}). - Share the reference: Platform A shares the trade reference with Platform B through their own channels (email, chat, API, etc.).
- Second party submits: Platform B sends an instruction with the same
trade_reference. KeyStone finds the matching pending instruction. - 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. Leavetrade_reference null to have KeyStone generate one.
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.What matching validates
Both instructions must agree on:| Field | Validation |
|---|---|
template_slug | Must be identical |
role | Must be different (one seller, one buyer) |
| Instruments | Same set of instrument_id values |
| Quantities | Must match per instrument |
| Directions | Must be complementary (seller delivers what buyer receives) |
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
| Field | Description |
|---|---|
fee_mode | Override the default fee allocation for this settlement. Options: seller_pays, buyer_pays, split. Defaults to the platform environment setting. |
settlement_category | Set to repo_open for repo opening legs. See Tokenised Repo. |
maturity_at | Required for repo_open - when the closing leg should trigger. |
repayment_amount | Required for repo_open - exact closing leg payment amount. |
repo_rate | Optional interest rate for repo (informational, stored in metadata). |
Cancellation
Cancel a pending instruction if it was submitted in error or the trade is no longer needed: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 assingle_platform type. This is useful when your platform intermediates trades between its own users.
Cross-Chain Settlement
How bilateral instructions enable cross-chain DvP.
Escrow Deposits
How parties deposit to escrow using commitment secrets.