Fixed Supply Token - Clarity Typing CST Test
Loading…
Fixed Supply Token — Clarity Code
A simple fixed-supply token with balances and transfer.
(define-constant total-supply u1000000)
(define-map balances principal uint)
(define-public (init user)
(begin
(map-set balances user total-supply)
(ok true)))
(define-public (transfer to amount)
(let ((bal (default-to u0 (map-get? balances tx-sender))))
(if (>= bal amount)
(begin
(map-set balances tx-sender (- bal amount))
(map-set balances to (+ (default-to u0 (map-get? balances to)) amount))
(ok true))
(err u1))))Clarity Language Guide
Clarity is a decidable smart contract language used on the Stacks blockchain. It enables predictable and secure smart contracts without gas estimation or unpredictable behavior.
Primary Use Cases
- ▸Building secure DeFi protocols on Stacks
- ▸NFT minting and trading
- ▸On-chain governance contracts
- ▸Bitcoin-integrated smart contracts
- ▸Deterministic financial applications
Notable Features
- ▸Decidable language - predictable execution
- ▸No gas estimation needed
- ▸Strong static typing
- ▸Direct Bitcoin integration
- ▸Lisp-like syntax with functional constructs
Origin & Creator
Clarity was created by Blockstack PBC (now Hiro Systems) around 2018 to provide secure, predictable smart contracts that integrate with Bitcoin.
Industrial Note
Clarity is used in projects where security and predictability are paramount, such as DeFi protocols on Bitcoin, NFT platforms, and on-chain governance solutions.