Inter-Covenant Communication (ICC)

How independent L1 covenants compose atomically in one transaction through co-spending, mutual inspection, shared interfaces, and dynamic dispatch.

On an account-based chain, contracts compose through imperative calls: contract A invokes a method on contract B, and the VM executes B's code inline. Kaspa's L1 covenant model works differently.

On Kaspa, independent covenants compose through Inter-Covenant Communication (ICC) — co-spending in the same atomic transaction. Every input script in the transaction executes and must succeed, or the entire transaction is rejected. Neither covenant runs the other's code; instead, each covenant validates its own transition and inspects the transaction to verify what its peer covenant is doing alongside it.

flowchart LR
    classDef a fill:#eef9ef,stroke:#4d9f5b,color:#132016
    classDef b fill:#f7f1ff,stroke:#8b68ca,color:#1d162b
    classDef tx fill:#f4f7fb,stroke:#8794a8,color:#172033
    classDef chk fill:#fff7e8,stroke:#c58b2a,color:#1f1b12

    subgraph TX["One atomic v1 transaction"]
        direction LR
        IA["Covenant A<br/>in: state_0"]:::a
        IB["Covenant B<br/>in: state_0"]:::b
        PL["Optional bus<br/>sigscript / payload"]:::tx

        CHK["Co-spent validation<br/>mutual state/bus<br/>inspection<br/>all scripts must pass"]:::chk

        OA["Covenant A<br/>out: state_1"]:::a
        OB["Covenant B<br/>out: state_1"]:::b

        IA --> CHK
        IB --> CHK
        PL -. "slice" .-> CHK
        CHK --> OA
        CHK --> OB
    end

Four L1 primitives make this work cleanly without assuming any single covenant owns the whole transaction:

  • All-or-nothing transaction atomicity: If any input script fails, none of the state transitions take effect.
  • Scoped family identity (covenant_id): KIP-20 tags inputs and outputs by covenant family, and OpCovInput* / OpCovOutput* let each script locate a peer covenant's exact slice of the transaction even when unrelated fee, change, or third-party covenant inputs are present.
  • Cross-input and output introspection: Any input script can read other inputs' outpoints, script public keys, and signature scripts (OpTxInputScriptSigSubstr), inspect outputs' values, scripts, and covenant bindings (OpOutputCovenantId, OpOutputAuthorizingInput), and verify preimages against P2SH hashes.
  • Shared transaction payload: Every input script can also inspect the transaction's payload via OpTxPayloadLen and OpTxPayloadSubstr.
Note

The main text on this page stays language-agnostic and describes L1 transaction mechanics directly. Color-coded snippet boxes illustrate each pattern across three tiers: Silverscript · L1 Opcodes (raw L1 script calls), Argent · Implemented (working Argent syntax today), and Argent · Proposed Syntax (design prototypes not yet implemented in the compiler).

Four ICC patterns

Most cross-covenant interactions on Kaspa fall into four patterns, distinguished by what the caller binds to on its peer:

PatternWhat the caller binds toTypical use cases
1. Presence-only co-spendPeer covenant_id onlyCovenant-owned custody (KCC-2), mint proxies, delegated authority
2. State observation (closed & open)Peer's fixed state layout (template_hash pinned at compile time or in state)Controller/asset pairs, permissionless DEXs, asset-agnostic vaults
3. Dynamic dispatch (computed reads)Peer covenant_id + statement interface (no shared state layout)Dynamic fee/policy hooks, shared oracle/KIP-21 verification, routers
4. Genesis-spawn compositionRecomputed KIP-20 genesis covenant_id of newly created child outputsFactories, pair registries, market creators launching sub-apps

1. Presence-only co-spend (delegated authority)

The lightest form of composition is a presence check: covenant A stores the covenant_id of an authority covenant B, and allows a privileged transition whenever at least one valid input belonging to B participates in the same transaction (OpCovInputCount(B) > 0).

This gives a clean one-way dependency: A does not need to know B's bytecode, state layout, or upgrade path. A simply delegates authorization to whoever can validly spend B. That is the exact mechanism behind KCC-2's covenant-id/v1 authority scheme, which lets a vault, order book, or DEX take custody of a KCC-20 token UTXO.

Warning

Presence is not authorization scope. Knowing that B was validly spent in the same transaction does not by itself tell A what B intended to authorize. If B has an unrelated spend path (for example, a routine fee rebalance, heartbeat, or admin action) that does not inspect A, an attacker can piggyback a spend of A onto that unrelated transaction of B. Sound delegation couples both sides: B must either inspect A's transition, require a transaction-binding signature covering the spend, or restrict itself to a single dedicated authorization role.

2. State observation (closed and open)

When covenant A needs to inspect or constrain how covenant B's state changes, A reads B's input and output group via OpCovInput* and OpCovOutput* and authenticates B's script against a 32-byte template_hash (committing to the non-state prefix and suffix of B's redeem script). At spend time, B's foreign template bytes arrive as an untrusted witness checked against that template_hash — A never embeds B's full bytecode or executes B's logic. Instead, A decodes B's input state from the script preimage, checks its rules, and verifies that B's successor outputs match the resulting P2SH commitments.

The same underlying L1 mechanism operates in two binding modes:

A. Closed observation (compile-time bound)

When A and B are designed as known peers — for instance, a dedicated issuance controller paired with a token's mint proxy — A knows B's concrete implementation at compile time, pins B's template_hash directly in its script, and reads B's full concrete state layout. Both covenants remain in separate covenant families with independent covenant_ids while enforcing one joint atomic transition.

B. Open observation and state capsules (runtime-bound)

When a protocol — such as a DEX, lending pool, or auction house — needs to work uniformly with many independently written contracts unknown at compile time, it cannot pin one concrete template_hash in script. Instead, the observer fixes only an agreed, fixed-width public state layout and stores each supported peer's (covenant_id, template_hash) pair in runtime state. One compiled observer can then interact with any conforming peer without recompiling.

Because inspecting foreign state in Kaspa Script relies on fixed byte offsets inside [prefix][state][suffix], open observation immediately requires a way for different implementations (a fixed-supply token, a mintable token, a vesting token) to carry different private state without changing the public state shape. The solution is a state capsule:

  • Every conforming implementation exposes the exact same fixed-width public fields (for example, owner, owner_kind, amount).
  • Any implementation-specific private state (arbitrarily structured or variable-sized) is compressed into a fixed 32-byte digest slot (such as a virtual field in Argent's AssetCapsule, or extension_commitment in KCC-20's 112-byte KCC20State).
  • The observer parses the uniform capsule fields and preserves that opaque 32-byte digest unchanged, while each concrete contract expands and validates its own preimage internally.

C. Operation receipts (note fields)

When observing an entire multi-input, multi-output transition would be verbose or expensive to reconstruct, a convention can include a designated operation receipt (or note) field inside the agreed state layout. Instead of iterating over every peer input and output to deduce what happened, the peer covenant writes a concise standardized digest of the operation it just verified (for example, committing to "transferred X units from A to B"), and the observer checks that single receipt field on the peer's successor output.

3. Dynamic dispatch (computed reads)

Even open state observation is still like a raw storage read: the observer inspects the peer's serialized state directly, so it remains statically bound to a fixed on-chain state structure (the agreed capsule layout).

Often, a covenant wants a computed read instead — it does not write to the peer or care how the peer serializes state, it just wants a result computed by the peer's own logic for this transaction: what fee rate applies to this swap? What is the authenticated oracle price or KIP-21 block timestamp? Is this withdrawal authorized under current policy? Two peer covenants can even hold identical state yet return different answers under different logic.

On a UTXO chain with no runtime call stack, dynamic dispatch works through propose-then-verify over an ephemeral per-transaction message bus:

  • Propose the statement, verify from both sides: The transaction composer attaches one or more structured statement records — (method, arguments, proposed result) — to the service input's message bus for this transaction. Both sides verify the same bytes independently:
    • The caller resolves the service input (for example, the leader of a stored covenant_id), reads the statement record from that service input's bus, checks that the method and arguments match what it intended, and uses the proposed result.
    • The callee (service) verifies every statement on its bus against whatever internal state, witnesses, and rules it chooses — it can use any state layout it wants, or recreate its UTXO unchanged. Crucially, every non-serving entrypoint and non-serving actor in the service's covenant family must enforce an empty bus, so an admin or unrelated spend can run cleanly while rejecting any transaction that claims it served a call.
  • Shared verification across callers: Because a statement belongs to the service input, one service input can verify expensive data once (a signed oracle report, a KIP-21 sequencing commitment opening, or shared policy parameters) and serve the authenticated result to several co-spent caller inputs in the same transaction.

Under the hood: where does the message bus live?

The details below are a low-level look at the transport options under active discussion — meant to give you an idea of what L1 makes possible and how the tooling and conventions are evolving, rather than plumbing you are expected to hand-wire for every app.

Two main places in a v1 transaction can carry a service input's statement bus:

Option 1 — First push of the service input's signature_script (per-input bus):

Because every input already owns its own signature_script (readable by peer inputs via OpTxInputScriptSigSubstr), placing the bus there avoids any global namespace contention with based apps, messaging, or metadata protocols, needs no transaction-wide directory, and keeps ephemeral call transcripts with witness data (outside txid).

Using signature_script does require care around Script framing and aliasing:

  • In P2SH, the final push must be the redeem script, so the bus belongs at offset 0 (the very first push).
  • Standard Script push opcodes change header length across size thresholds, and if a non-serving entry or non-serving actor in the same covenant family left offset 0 unconstrained, an attacker could craft a normal witness argument to byte-alias a serving statement.

A clean compiler-managed scheme addresses both: reserve the first push at offset 0 across all generated Silverscript entrypoints of the covenant family (hidden by high-level Argent code and accessed only through serve/interface syntax), give the bus a fixed-length layout bounded by compile-time known limits so callers read predictable offsets directly via OpTxInputScriptSigSubstr(service_in, ...), and have every non-serving entrypoint and non-serving actor enforce bus.length == 0.

Option 2 — Shared transaction payload (tx.payload):

Every input can also read tx.payload via OpTxPayloadLen and OpTxPayloadSubstr. That gives raw contiguous bytes with no Script push-opcode framing and commits the call transcript into v1 txid via PayloadDigest. However, because tx.payload is a single transaction-wide field shared with based apps, messaging, and metadata conventions, independent contracts cannot pick ad-hoc offsets without breaking composability — using tx.payload for open dynamic dispatch would require a shared payload-framing KCC (a versioned envelope prefix plus a fixed-width per-input section directory, as explored in Kas-Smiths #171).

4. Genesis-spawn composition (atomic sub-app creation)

Factories, pair registries, and prediction-market creators often need to launch a brand-new child covenant family atomically inside a parent transition — and record the child's newly derived covenant_id in the parent's state.

As noted in Covenant State, auth and covenant output groups (OpAuthOutput*, OpCovOutput*) exclude genesis outputs. Instead of scanning the entire transaction, the parent script accepts the global output indices of the child's initial outputs as untrusted witnesses, recomputes the KIP-20 genesis covenant_id preimage on-chain from its own outpoint plus those outputs' values and scripts, and checks that hash against OpOutputCovenantId on the first spawned output. Because consensus derives that output's covenant_id from the complete ordered genesis output group, hash collision resistance proves in one check that no extra or altered outputs snuck into the spawned child family.

Worked example: shared service covenants and upgradable ZK routers

Choosing between state observation (raw read) and dynamic dispatch (computed read) shows up clearly in a real L1 problem: how an immutable covenant can delegate an evolving cryptographic dependency to an opt-in shared covenant.

Consider an application covenant that verifies BN254 Groth16 proofs via OpZkPrecompile(0x20) (for example, a RISC Zero Groth16 verifier whose wrapper parameters can change after a prover SDK upgrade such as GHSA-g6qg-9j8p-7j87). Hardcoding a verifying key or control root directly into every user UTXO forces a manual migration whenever proving parameters rotate.

Simpler default: a key-registry router (state observation)

If the router only acts as a registry of the currently active verifying key (storing active_vk_hash in its UTXO state), it does not need dynamic dispatch or a message bus — a straightforward state read (Pattern 2) is both simpler and safer:

flowchart TB
    classDef app fill:#eef9ef,stroke:#4d9f5b,color:#132016
    classDef router fill:#f7f1ff,stroke:#8b68ca,color:#1d162b

    RTR["Key-registry router<br/>state: active_vk_hash<br/>witness spend or rotate"]:::router
    APP["App covenant input<br/>1. read active_vk_hash<br/>2. check blake3(vk)<br/>3. run OpZkPrecompile"]:::app

    APP -. "reads active_vk_hash" .-> RTR
  1. Key-registry router (shared service, holds no user funds): Stores active_vk_hash in its state and exposes a permissionless witness spend that recreates itself unchanged, plus a governed rotation path to swap in patched keys.
  2. App covenant (immutable, holds user funds): Stores the router's (router_cov_id, router_template_hash). On spend, it observes the co-spent router input, reads active_vk_hash directly from the router's authenticated state, checks blake3(verifying_key) == active_vk_hash, and runs OpZkPrecompile(0x20).

Because the app reads active_vk_hash straight from the router's spent input state rather than relying on presence-only co-spend, there is no risk of piggybacking on an unvalidated admin spend — even during a governance transaction, the router's spent input still carries only the previously authorized key hash.

When dynamic dispatch makes sense

Pattern 3 (computed read over a message bus) becomes useful when a plain registry read is no longer enough — for example, when multiple co-spent app inputs want to share one large verifying key without repeating it in every signature script, when the router verifies a proof once and serves the result to several callers, or when you do not want the interface to statically commit to the router's state layout and template at all (abstracting the router's internal representation).

Operational invariants for shared routers

  • Revocation across parallel replicas (all routers): A single router UTXO serializes spends to one per block (~10/s), so busy routers will typically split into parallel replicas (the same expand-and-contract pattern used by PublicMint and TokenSeed). When revoking compromised parameters, governance must either replace every live replica or enforce epoch/time-bounded validity so stale replicas cannot remain spendable.
  • No unvalidated spend paths (service-bus / presence routers): Whenever callers rely on co-spend presence plus a message bus instead of reading the router's state directly, every non-serving entrypoint and non-serving actor preserving the router's covenant_id must enforce an empty bus (bus.length == 0) so admin or housekeeping spends cannot be piggybacked.

How the stack supports these patterns

Because every pattern above is built from native L1 transaction rules, you can adopt them at whichever layer fits your project:

LayerWhat it gives you
SilverscriptDirect access to OpCov*, OpOutput*, OpTxInputScriptSigSubstr, OpTxPayloadSubstr, and validateOutputState
KCCsStandardized state layouts (KCC-1, KCC-20) and co-spend authority schemes (covenant-id/v1, KCC-2)
ArgentChecked source-level abstractions for .co_spent(), closed/open observes, actor_type<State> capsules, and spawns

Continue with Inline ZK for direct in-script proof verification, or inspect working open-ICC and multi-app demos in argent-lang/argent-playground.