Other Chain·Bitcoin · Stacks
Stacks
Bitcoin L2 for smart contracts using Clarity, anchored to Bitcoin via Proof of Transfer (PoX) and the Nakamoto release. Powers sBTC and the Bitcoin DeFi ecosystem.
- 01Bitcoin smart contracts
- 02Clarity dApps
- 03sBTC integrations
- 04BTC-secured DeFi
- 05PoX stacking
- pnpm add @stacks/transactions @stacks/network @stacks/connect
- npm i -g @hirosystems/clarinet-cli
| Variable | Scope | Description |
|---|---|---|
| NEXT_PUBLIC_STACKS_NETWORK | Client | Network identifier: 'mainnet' or 'testnet'. |
| STACKS_API_URL | Client | Stacks API base URL (e.g. https://api.mainnet.hiro.so). |
Use Stacks for Bitcoin-anchored smart contracts written in Clarity. Scaffold contracts with `clarinet new` and unit-test via `clarinet test`. From the browser, use `@stacks/connect` `showConnect()` for wallet auth and `openContractCall({ contractAddress, contractName, functionName, functionArgs })` to invoke functions. Build raw transactions server-side with `makeContractCall` from `@stacks/transactions` using `STACKS_MAINNET` or `STACKS_TESTNET` from `@stacks/network`. Read on-chain state via `callReadOnlyFunction` against the Hiro API.
- ⚑Clarity is decidable and intentionally non-Turing-complete — no loops, no reentrancy in the EVM sense, but post-conditions must be set on every transfer or funds may move unexpectedly.
- ⚑Stacks block finality follows Bitcoin: even after Nakamoto, deep finality is ~150 BTC blocks (~25 hours) — design UX around fast Stacks confirmations and slow BTC-final settlement.
- ⚑Microblocks are deprecated in Nakamoto; use the new fast blocks model and verify your indexer supports it.
- ⚑Address formats differ: SP/ST prefixes for Stacks vs. legacy/segwit for Bitcoin — never mix them when constructing contract args.
- ⚑PoX stacking locks STX for cycles measured in Bitcoin blocks; account for early-unlock impossibility in product flows.