Kaspalytics Learn is a work in progress.
Updated: Jul 29, 2026

P2SH Script Format

Reference for Kaspa's P2SH standard templates — script public key layout, signature script format, and execution order.

For an explanation of how P2SH works, plus a worked multisig example, see Pay-To-Script Hash (P2SH).

Script Public Key

Kaspa’s P2SH script public key standard is 35 bytes in the following format:

OpBlake2b OpData32 <32-byte redeem script hash> OpEqual

ElementSizePurpose
OpBlake2b1 bytePops the top stack element and pushes its 32-byte Blake2b hash
OpData321 bytePushes the next 32 bytes (the embedded hash) onto the stack
Redeem script hash32 bytesBlake2b hash of the redeem script
OpEqual1 bytePops the top two elements, pushes true if equal, otherwise fails

Signature Script

<push op> <data/signature(s)> ... <push op> <redeem script bytes>

  • Each signature/data element is its own data push.
  • The serialized redeem script is the final data push. It is not executed during this pass — it is treated as bytes on the stack.
  • The redeem script provided at spend time must match exactly the redeem script that was hashed at lock time.

Execution Order

The script engine runs both scripts back to back on a single shared stack:

  1. signature_script — pushes each signature/data element, then the serialized redeem script as the top element.
  2. script_public_key — hashes the redeem script, pushes the embedded 32-byte hash, and compares the two. A mismatch fails the script.
  3. Redeem script — deserialized and executed against the remaining stack. It must leave a truthy value on top of the stack for the spend to be valid.
Kaspalytics strives to provide accurate data - our highest level of effort is given to data validation and maintenance. However, we cannot guarantee 100% accuracy. Data is subject to inaccuracies and change.

Contact | © 2026 Kaspalytics