Skip to content

Latest commit

 

History

History
433 lines (363 loc) · 12.3 KB

File metadata and controls

433 lines (363 loc) · 12.3 KB

Kernel Package v0 Schema

Updated: 2026-06-17.

kaspascript kernel package <contract.ks> emits one JSON object that combines the compiled txscript artifact with the KaspaScript kernel package.

The package is meant for wallets, indexers, SDKs, and review tools. It is not a replacement for node, wallet, or consensus validation.

Generate A Package

cargo run -p kaspascript-cli -- kernel package tests/contracts/escrow.ks \
  --target verified-tn12 \
  --output /tmp/escrow.kernel.json \
  --compute-grams 1000 \
  --tx-bytes 400

Without --output, the CLI writes beside the source with a .kernel.json extension.

Root Object

{
  "schema_version": "kaspascript.kernel.package.v0",
  "package_target": "verified-tn12",
  "source_snapshots": [],
  "artifact": {},
  "bytecode_hex": "...",
  "bytecode_asm": "...",
  "kernel": {},
  "fee_estimate": {}
}
Field Type Notes
schema_version string Current value: kaspascript.kernel.package.v0.
package_target string Package target selected by the CLI.
source_snapshots array Pinned upstream source snapshots used by the package evidence set.
artifact object Compiler artifact summary.
bytecode_hex string Hex-encoded compiled txscript bytes.
bytecode_asm string Human-readable txscript assembly.
kernel object Wallet, indexer, readiness, blueprint, and fee policy metadata.
fee_estimate object Fee estimate using the selected package assumptions.

Package targets:

  • verified-tn12
  • tn10-toccata
  • toccata-preview
  • future-mainnet

Source Snapshots

{
  "upstream_repo": "https://github.com/kaspanet/rusty-kaspa",
  "tag": "v2.0.1",
  "commit": "cfafeb4c093fa37a303f1b9f19c58f986b870ce3",
  "audit_date": "2026-06-17"
}

The v0 package pins Rusty Kaspa snapshots for v2.0.1, v2.0.0, v1.3.0-toc.5, and tn10-toc3. v2.0.1 is the current Toccata upgrade release at this audit date. v2.0.0 remains the baseline activation release, with activation scheduled for DAA score 474,165,565, roughly June 30, 2026 at 16:15 UTC; both releases are still treated as pre-activation evidence at this audit date. Consumers should treat snapshots as evidence metadata, not as a replacement for node validation.

Artifact Summary

{
  "backend": "kaspa-txscript",
  "target": "verified-tn12",
  "compiler_version": "0.1.0",
  "bytecode_bytes": 76,
  "finality_depth": 10,
  "kip_requirements": [10],
  "contracts": ["Escrow"],
  "spends": ["Escrow.release", "Escrow.refund"]
}
Field Type Notes
backend string Current value: kaspa-txscript.
target string Compiler target label such as verified-tn12.
compiler_version string Compiler crate version.
bytecode_bytes number Compiled bytecode length in bytes.
finality_depth number or null Contract finality depth if declared.
kip_requirements array KIPs required by the compiled bytecode or guarded features.
contracts array Contract names found in the artifact.
spends array Fully qualified spend path names.

Kernel Object

{
  "schema_version": "kaspascript.kernel.package.v0",
  "blueprint": {},
  "readiness": {},
  "capabilities": {},
  "wallet_previews": [],
  "indexer_schema": {},
  "fee_policy": {
    "sompi_per_unit": 100
  },
  "application": {}
}
Field Type Notes
schema_version string Current value: kaspascript.kernel.package.v0.
blueprint object Contract state-machine model.
readiness object Evidence-based readiness report.
capabilities object Machine-readable contract capability profile for wallets, SDKs, indexers, and agents.
wallet_previews array Wallet-facing transition previews.
indexer_schema object Suggested indexer tables and columns.
fee_policy.sompi_per_unit number Toccata pre-activation minimum fee unit.
application object Canonical kaspascript.application.v0 model shared with the compiler artifact and SDK.

The application model is defined in KASPASCRIPT_PROGRAM_MODEL.md and has a machine-readable schema at schemas/kaspascript.application.v0.schema.json. The complete compiled package schema is schemas/kaspascript.kernel.package.v0.schema.json.

Blueprint

{
  "name": "Escrow",
  "network": "Tn12",
  "state": [],
  "transitions": [],
  "evidence": []
}
Field Type Notes
name string Contract or package name.
network enum string Mainnet, Tn10, Tn12, Simnet, Devnet, or Unknown.
state array State fields derived from contract params or blueprint state.
transitions array Spend/state transition definitions.
evidence array Source evidence attached to package claims.

State field:

{
  "name": "buyer",
  "ty": "PublicKey",
  "description": "compiled parameter from contract Escrow"
}

Current ty values are PublicKey, Signature, Sompi, DaaScore, BlockHeight, CovenantId, Hash, Bool, U64, and Bytes.

Transition:

{
  "name": "release",
  "kind": "Spend",
  "consumes": ["Escrow compiled locking state"],
  "creates": ["transaction outputs selected by the spend path"],
  "signers": ["sig_a", "sig_b"],
  "requirements": [],
  "proof": {
    "verifier": "None",
    "public_inputs": [],
    "payload_hint": "no proof payload"
  },
  "wallet_warnings": []
}

Compiled transitions also carry an internal link to their canonical transition model. The link is used to build wallet previews and capability summaries but is not duplicated inside serialized blueprint transitions.

Current kind values are Deposit, Spend, Timeout, Recover, Close, or {"Custom": "label"}.

Requirement:

{
  "feature": "BaseScript",
  "minimum_evidence": "BranchCode",
  "reason": "compiled artifact emitted verified Kaspa txscript bytecode"
}

Current feature values are BaseScript, TransactionIntrospection, CovenantIds, SequencingCommitments, ZkVerification, FeePolicy, WalletPreview, and IndexerLineage.

Current evidence levels are Unknown, ResearchSignal, DocsSignal, BranchCode, MergedKip, MergedCode, TestnetActivation, MainnetPreActivation, and MainnetActivation.

Evidence:

{
  "label": "KaspaScript compiled artifact",
  "url": "tests/contracts/escrow.ks",
  "audit_date": "2026-06-17T13:00:00Z",
  "network": "Tn12",
  "level": "BranchCode",
  "features": ["BaseScript", "WalletPreview", "IndexerLineage"],
  "note": "local compiler artifact verified before kernel package emission"
}

Wallet Previews

{
  "contract": "Escrow",
  "transition": "release",
  "network": "Tn12",
  "classification": "CovenantStateTransition",
  "consumes": ["Escrow compiled locking state"],
  "creates": ["transaction outputs selected by the spend path"],
  "signers": ["sig_a", "sig_b"],
  "proof": {
    "verifier": "None",
    "public_inputs": [],
    "payload_hint": "no proof payload"
  },
  "warnings": []
}

Compiled wallet previews include semantics, which is the selected canonical transition model. It exposes signing requirements, classified source constraints, referenced input/output indexes, exact-count limitations, monetary responsibility, output bindings, and continuation posture.

Current classification values are OrdinaryPayment, CovenantStateTransition, and ProofBearingTransition.

Current proof verifier values are None, Groth16, Risc0Succinct, or {"External": "label"}.

Wallets should treat warnings as sign-time copy and should not render CovenantStateTransition as a plain payment.

Indexer Schema

{
  "contract": "Escrow",
  "network": "Tn12",
  "tables": [
    {
      "name": "covenant_lineage",
      "columns": [
        {
          "name": "covenant_id",
          "ty": "bytes32",
          "required": true
        }
      ]
    }
  ]
}

Column ty is a descriptive storage type. The current package emits covenant lineage, covenant transition, and wallet preview audit table suggestions.

Readiness Report

{
  "contract": "Escrow",
  "network": "Tn12",
  "level": "verified",
  "ready": true,
  "blockers": [],
  "features": []
}

Readiness levels:

  • verified: every transition requirement is satisfied for a non-preview target network.
  • preview: evidence is sufficient for analysis, but the package target is intentionally preview-scoped.
  • blocked: at least one blocker prevents the package from being treated as ready.

Feature readiness line:

{
  "transition": "release",
  "feature": "BaseScript",
  "required": "BranchCode",
  "best": "BranchCode",
  "level": "verified",
  "satisfied": true,
  "source_label": "KaspaScript compiled artifact"
}

ready is true only when every transition requirement is satisfied by the available evidence for the package network. Mainnet packages remain blocked until MainnetActivation evidence exists for required mainnet features.

Capabilities

{
  "schema_version": "kaspascript.kernel.package.v0",
  "contract": "Escrow",
  "network": "Tn12",
  "readiness_level": "verified",
  "ready": true,
  "execution_model": "kaspa-utxo-state-machine",
  "scope": [
    "compile-to-kaspa-txscript",
    "wallet-preview",
    "indexer-lineage",
    "fee-estimate",
    "readiness-report"
  ],
  "features": [],
  "transition_profiles": [],
  "wallet_requirements": [],
  "indexer_requirements": [],
  "policy_limits": []
}

The capability profile is a compact contract digest for app tooling. It does not add consensus behavior. It describes what the package can support and what external systems must still verify or render.

Field Type Notes
execution_model string Current value: kaspa-utxo-state-machine.
scope array Package surfaces currently emitted by the kernel.
features array KaspaScript/Kaspa features required by the transition set with readiness and evidence.
transition_profiles array Per-spend digest with kind, signers, proof verifier, required features, and wallet effect.
wallet_requirements array Sign-time wallet duties derived from the package.
indexer_requirements array Indexer duties derived from emitted schema tables.
policy_limits array Hard boundaries, including the fact that packages do not replace node or consensus validation.

Feature capability:

{
  "feature": "TransactionIntrospection",
  "level": "verified",
  "best_evidence": "MergedCode",
  "description": "spend logic can inspect selected transaction inputs or outputs"
}

Transition profile:

{
  "transition": "release",
  "kind": "Spend",
  "signer_count": 2,
  "signers": ["sig_a", "sig_b"],
  "proof_verifier": "None",
  "required_features": [
    "BaseScript",
    "WalletPreview",
    "IndexerLineage",
    "TransactionIntrospection"
  ],
  "wallet_effect": "Consumes Escrow compiled locking state and creates transaction outputs selected by the spend path."
}

Compiled transition profiles additionally include:

  • constraint_kinds
  • transaction_shape
  • monetary_policy
  • continuation

Fee Estimate

{
  "policy": "toccata-rpc-minimum-standard-fee",
  "source": "https://github.com/kaspanet/rusty-kaspa/blob/v2.0.1/docs/toccata-guide.md",
  "compute_grams": 1000,
  "transaction_bytes": 400,
  "minimum_standard_fee_sompi": 100000,
  "assumption": "caller-provided fee estimate inputs"
}

The current formula is:

100 sompi * max(compute_grams, 2 * transaction_bytes)

When --tx-bytes is omitted, the CLI uses compiled bytecode length as a lower bound for transaction_bytes. When --compute-grams is omitted, it uses 0.

Compatibility Notes

  • Enum strings are serialized as Rust variant names, for example Tn12 and BaseScript.
  • Readiness levels are serialized as lowercase v0 labels: verified, preview, and blocked.
  • The schema is additive while the CLI is pre-1.0. Consumers should ignore unknown fields and require the root fields listed above.
  • Machine-readable JSON Schemas are published for the application model, compiled kernel package, and stable CLI reports.