Skip to main content

Advanced

Advanced topics build on the core contract-authoring guides. Use this page as a map: each section links to the guide that covers the pattern in depth.

If you have not finished the core path yet, start with Basics, Built-in Functions, Script Context, and Stateful Contracts.

Composition and reuse

  • Composition — pure helper functions, method.named(...), and reusable library() helpers.
  • Examples — reference contracts that show multi-branch and threshold-style policies.

Composition is the default way to keep contracts readable. Prefer small TypeScript helpers that return ExprNode predicates, then wire them into method(...) or method.named(...) declarations.

Output covenants and payouts

  • Output CovenantsassertOutputs(...), terminal { outputs, check? } shapes, and payout commitments.
  • Script Contextctx.value, ctx.hashOutputs, and native state-output layout.

Output covenants let a spend commit to the transaction outputs, not just the unlocking predicate on the current UTXO.

Transaction context, sighash, and timelocks

  • Script Context — focused TxContextExpr fields and auto-filled runtime context.
  • Sighash Types — how stateless, successor-state, and terminal paths choose sighash modes.
  • Stateful Contracts{ next, check? }, { outputs, check? }, and branches(...).

Timelocks and sequence checks belong in method predicates (checkLocktime, checkSequence) or in trailing context parameters when the method needs the committed transaction fields.

Providers, signers, and deployment

Lambit does not hide network transport behind a single global SDK entry point. Keep provider and signer selection explicit so local tests and live testnet flows stay interchangeable.

Debugging and verification

Start debugging at the smallest reproducible layer. Most failures are visible in the artifact or in offline BVM verification before you involve wallet funding or broadcast.

Inline opcodes and low-level escape hatches

Reach for raw opcode helpers only when the typed DSL surface does not express the policy you need. Prefer composable helpers and built-ins first.