Templates are the blueprint for how a settlement behaves. They define the state machine, required roles, required leg types, gates, and compliance configuration. Templates are global - they are owned by KeyStone, not individual platforms. All platforms share the same set of templates and settlement workflows. Templates are created and managed by KeyStone administrators. Platform users can browse available templates and reference them when submitting instructions via the API.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.
The contract does not know about templates. Templates are an off-chain convenience that packages the state machine rules, gates, and compliance configuration into a reusable definition. When a settlement is created on-chain, the template’s rules are extracted and stored directly on the SettlementCoordinator.
Template configuration
A template’sconfig object defines the complete workflow:
Key sections
States and transitions
states- All possible states in the workflowinitial_state- Where every settlement startsterminal_states- Success end states (e.g.FINALIZED)failure_states- Failure end states (e.g.ROLLED_BACK,TIMED_OUT)transitions- Allowed state changes. The contract only permits transitions defined here.
Actions
Each state can have an action that the engine executes when entering that state:| Field | Description |
|---|---|
type | The action handler to invoke (e.g. compliance_check, noop, finalize) |
provider | Which provider handles it (internal) |
resolution | How the action completes: immediate, webhook, poll, or manual |
Gates (derived from actions)
Gates are on-chain preconditions derived from the template’s action configuration. When a settlement is created on-chain, the relevant gates are stored on the SettlementCoordinator:| Template Action | Derived Gate | On-Chain Check |
|---|---|---|
compliance_check action | COMPLIANCE_CLEARED gate | ComplianceRegistry.areAllPartiesCleared(settlementId) |
| Deposit-related state | ALL_DEPOSITS_CONFIRMED gate | Escrow.allLegsDeposited(settlementId) |
Validation rules
required_roles- Every settlement must include parties covering all required rolesrequired_leg_types- Every settlement must include legs covering all required types
Slugs
Every template has a uniqueslug - a short, human-readable identifier (e.g. dvp-standard, repo-bond-usdc). Slugs provide a stable reference that does not change across template versions.
When submitting an instruction, you reference a template by its slug. Slugs are particularly useful in integration code where hardcoding UUIDs is fragile.
Versioning
Templates are versioned. When you update a template, the version is auto-incremented. Existing settlements continue using the template version they were created with.Different settlement types, same engine
The template system is generic by design. Different transaction types are just different templates:| Transaction Type | Template Differences |
|---|---|
| DvP | 2 legs (asset + payment), buyer/seller roles |
| Tokenised Repo | Two linked DvP settlements (opening + closing), maturity_at triggers closing leg with reversed parties. See Tokenised Repo. |
| Securities Lending | Securities + collateral + fee legs |
| Netting | N legs across multiple counterparties |