Which transaction fields can a Kaspa script read using introspection opcodes?

KIP-0017 introduces five opcodes that let a Kaspa script read specific fields from its own transaction at validation time. In most scripting systems, a script runs in isolation and cannot see the transaction it lives in. These opcodes break that wall: OpTxVersion reads the transaction's version number, OpTxLockTime reads the locktime field, OpTxSubnetId returns the subnetwork ID as raw bytes, OpTxGas returns the gas field, and OpTxPayloadSubstr returns a slice of the transaction's payload between a start and end index. For a beginner, this matters because it means Kaspa scripts can enforce rules based on real transaction data — for example, requiring a specific subnetwork or checking the gas limit — which is a foundational capability for building smart-contract-style logic on Kaspa.

Learn more ›