← Theory library
Clarity theory
Stacks' decidable, non-Turing-complete contract language and sBTC.
Practise in the Code Lab →Easy
- 1. Introduction to ClarityA decidable language for Stacks.
- 2. LISP SyntaxParentheses and prefix notation.
- 3. Decidability and SafetyEliminating re-entrancy and runtime panics.
- 4. Clarity PrincipalsStandard and contract principals.
- 5. Booleans and Logictrue, false, and logical operators.
- 6. Integers: uint and int128-bit signed and unsigned integers.
- 7. Strings and BuffersASCII, UTF-8 strings, and raw buffers.
- 8. Optionals (some, none)Handling values that may be missing.
- 9. Response Types (ok, err)Standardized success and rollback error types.
- 10. ListsBounded ordered collections of a single type.
- 11. TuplesNamed key-value structures.
- 12. Constants (define-constant)Immutable values bound at deployment.
- 13. Data Variables (define-data-var)Single mutable storage variables.
- 14. Maps (define-map)Key-value storage for collections.
- 15. Public Functions (define-public)Callable entry points for transactions.
- 16. Read-Only Functions (define-read-only)Query state without execution fees.
- 17. Private Functions (define-private)Internal helper logic.
- 18. Guarding with asserts!Short-circuit error returns.
- 19. Conditional Expressions (if)Branching logic with expressions.
- 20. Sequence Execution (begin)Grouping sequential expressions.
Medium
- 21. Unwrapping: unwrap! and unwrap-panicExtracting inner values from optionals and responses.
- 22. Block Context & Nakamoto Fast BlocksChain metadata, block-height, and fast block execution.
- 23. Contract Identity: as-contractExecuting actions as the contract principal.
- 24. Inter-Contract Calls: contract-call!Interacting with external deployed contracts.
- 25. Stacks Post-ConditionsUser asset protection at the transaction level.
- 26. Introduction to TraitsInterface specifications in Clarity.
- 27. Implementing Traits (impl-trait)Verifying contract interface compliance.
- 28. Dynamic Trait Dispatch: use-traitPassing contracts as parameters.
- 29. STX Transfers (stx-transfer?)Transferring native Stacks cryptocurrency.
- 30. Native Fungible Tokens (define-fungible-token)Built-in supply tracking for custom tokens.
- 31. Native Non-Fungible Tokens (define-non-fungible-token)Built-in unique asset primitives (SIP-009).
- 32. Map Insert, Set & DeleteManaging map entries safely.
- 33. List Operations: map, filter, and foldFunctional list transformations in Clarity.
- 34. Bitwise OperationsManipulating binary representations.
- 35. Cryptographic Hashingsha256, keccak256, and hash160.
- 36. ECDSA Signature Verificationsecp256k1 signature verification.
- 37. Time-Locks and VestingBlock-height based authorization.
Hard
- 38. Advanced Maps with Composite Tuple KeysMulti-index and allowance tracking.
- 39. sBTC & Decentralized Bitcoin PegTrust-minimized 1:1 Bitcoin on Stacks.
- 40. Static Cost Analysis & Execution LimitsPredictable gas costs and runtime safety.
- 41. Formal Verification & check_checkerMathematical proofs of contract safety.
- 42. BNS (Bitcoin Name System)Decentralized naming on Stacks.
- 43. Proof of Transfer (PoX) ConsensusMining with BTC and earning Bitcoin yield.
- 44. Safe Math & Arithmetic OverflowBuilt-in checked arithmetic.
- 45. Access Control: tx-sender vs contract-callerPreventing intermediate phishing attacks.
- 46. Multi-Signature Vault ArchitecturesM-of-N threshold authorization in Clarity.
- 47. DAO Governance & Token-Weighted VotingDecentralized autonomous organizations.
- 48. Contract Upgradability & Router PatternsManaging immutable contracts.
- 49. Bitcoin Finality and Reorg ResistanceBitcoin-backed transaction security.
- 50. Capstone: Building a Secure Bitcoin-DeFi EscrowEnd-to-end Clarity smart contract application.