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 reusablelibrary()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 Covenants —
assertOutputs(...), terminal{ outputs, check? }shapes, and payout commitments. - Script Context —
ctx.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
TxContextExprfields and auto-filled runtime context. - Sighash Types — how stateless, successor-state, and terminal paths choose sighash modes.
- Stateful Contracts —
{ next, check? },{ outputs, check? }, andbranches(...).
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
- How to Deploy & Call — bound
.deploy()/.call()flow, memory provider, and testnet setup. - Deploy a Contract — CLI compile/artifact workflow plus deployment scripts.
- Interact with a Deployed Contract — artifact-first instances, prepared calls, and successor-state spends.
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
- How to Debug a Contract — layered workflow from artifact inspection through BVM verification.
- How to Test a Contract —
methods.<name>.verify(...)and MemoryProvider integration tests. - How to Verify a Contract — compare an on-chain locking script against a published artifact and constructor/state arguments.
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
- Built-in Functions —
opcode(...),opcodes(...), and assertion metadata viaassert(...).
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.