# Execution architecture

The system divides operations between two distinct layers. Execution happens off-chain in the VM. Settlement lives on Bitcoin, where you anchor definitions and every call's commitment so anyone can replay your contract's history.

> Part of the SQRL documentation, section "Protocol".
> Rendered page: https://docs.sqrl.tech/protocol/architecture

The contract gets compiled once, with its commitment hash anchored to Bitcoin in a single transaction. Every subsequent call is itself committed on Bitcoin as a protocol stamp. Validators process state changes off-chain in Bitcoin block order, using those commitments and Bitcoin context as reference points, combining performance with verifiability.

## Execution layer

Off-chain processing occurs within the SCL VM. Node operators run the VM, load contract bytecode, enforce rules, and maintain local state. The VM is deterministic: if another node replays the same payload, it gets the same result.

Execution is bounded: 100k instructions per call (shared across nested cross-contract calls), 1024 stack depth, 64 call depth, and a 64 KB storage quota per contract. Every frame of every call runs under the same ceilings.

## Settlement layer

Upon deployment, the compiled bytecode receives a hash representing the contract's commitment. This hash is embedded in a Bitcoin transaction. Each contract call is then anchored the same way: a compact **protocol stamp** in an `OP_RETURN` output carries the hash of the signed call envelope and the contract it targets.

The envelope is bound to its anchoring transaction: the transaction must spend the exact outpoint the envelope names. Confirmation in a Bitcoin block orders calls, and they become final as the block gains confirmation depth; nodes process them block by block and publish a **state root** at each height.

## Validators and replay

Every node performs identical operations: watch Bitcoin for protocol stamps, validate each stamp's anchor binding, derive context, and replay the VM execution. If a payload doesn't match, it fails, deterministically, on every honest node. On the canonical ledger, accredited validator seats also co-sign the resulting state roots under a t-of-n quorum. That signature set is an accountability record layered over a verdict any observer can reproduce. See [Validators and the canonical ledger](/protocol/network/validators).

Nodes gossip pending payloads to each other ahead of confirmation and sync state via Merkle diffing, so the network converges on the same history without any coordination beyond Bitcoin itself.
