Creates Clarity smart contracts for Stacks blockchain. Use when writing Clarity contract code, implementing SIP009 NFTs, SIP010 fungible tokens, defining traits, or working with Clarinet for testing and deployment. Don't use for Solidity, Rust, or general blockchain development outside Stacks.
Step 1: Project Setup
clarinet --version. If not installed, direct the user to install from https://github.com/hirosystems/clarinet.clarinet new <project-name> to initialize the project structure..clar files.references/clarinet.md for detailed Clarinet commands and usage.Step 2: Syntax & Structure
assets/contract-template.clar as a starting point for basic contracts.(function-name arg1 arg2 ...);;) to document code, but remember: code is visible on-chain.Step 3: Type System
references/types.md to understand primitive types (int, uint, bool, principal), sequence types (list, tuple, buffer, string), and composite types (response, optional, trait).Step 4: Data Storage
(define-constant NAME value).(define-data-var NAME TYPE initial-value).(define-map NAME KEY_TYPE VALUE_TYPE).references/keywords.md for full keyword syntax.Step 5: Functions
(define-public (name (arg type)) ...) - must return a response type.(define-private (name (arg type)) ...).(define-read-only (name (arg type)) ...).ok. Returning err rolls back all changes.Step 6: Control Flow & Error Handling
(asserts! condition (err code)) to validate conditions.(try! expression) to handle response types.(unwrap! value default), (unwrap-panic value), (unwrap-err! ...).(if condition true-expr false-expr) for conditional logic.references/best-practices.md for coding style tips.Step 7: Traits (Interfaces)
references/keywords.md to understand trait syntax.(define-trait NAME ((function-name (arg-types) (return-type)))).(impltrait CONTRACT.TRAIT).Step 8: Token Standards
references/sip009-nft.md and implement the SIP009 interface.references/sip010-ft.md and implement the SIP010 interface.Step 9: Practice Projects
references/practice-projects.md for detailed implementations of:
fold)Step 10: Building a Marketplace
references/marketplace.md for NFT marketplace implementation.Step 11: Runtime Cost Analysis
references/cost-analysis.md to understand execution costs.clarinet check for cost analysis.npm run test:report for detailed cost reports.Step 12: Best Practices
references/best-practices.md for:
Step 13: Working with sBTC
references/sbtc.md for sBTC integration.SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-tokenStep 14: Testing & Validation
clarinet check to analyze contracts for type errors and runtime costs.clarinet test to execute unit tests.clarinet console for interactive debugging.::get_assets_maps to check balances.::advance_chain_tip to simulate block progression.clarinet check fails with type errors, read references/types.md to verify type signatures.(ok value) or (err value) wrapper.err unexpectedly, check that all state modifications are inside functions that return ok.references/cost-analysis.md for optimization techniques.references/best-practices.md section on contract upgradability.references/links.md