Skip to content
V-Sum

Stacks

Stacks Technical Briefing

Published December 14, 2021

Stacks Technical Briefing thumbnail

Supported by IowaEDA , Finix and Numary

Overview

Marvin Janssen, technical lead at the Stacks Foundation, gives a hands-on tour of Stacks — a Bitcoin L2 blockchain that anchors every block to the Bitcoin chain via proof-of-transfer, inheriting Bitcoin's security while adding smart-contract capability. The briefing centers on writing a SIP-009 NFT in Clarity, Stacks' non-Turing-complete Lisp-based smart-contract language. Marvin uses Clarinet — the Stacks analogue of Truffle plus Ganache — to scaffold the project, opens the Clarinet console for a REPL tour of Clarity (strongly typed, with distinct signed vs unsigned integer literals), then implements the SIP-009 NFT trait (Stacks' ERC-721 equivalent) using NFT primitives baked into the language (nft-mint, nft-burn, nft-transfer) — the correct balance-sheet semantics come for free. The ownership model is user-defined: Marvin asserts that sender equals tx-sender (Clarity's msg.sender) before transferring. A closing clarinet-console session mints two NFTs, checks owners, and transfers one between principals in the local Clarity VM.

0:00 Introduction to Stacks

Marvin Janssen, technical lead at the Stacks Foundation, introduces Stacks — a Bitcoin L2 blockchain that anchors every block to the Bitcoin chain via proof-of-transfer, inheriting Bitcoin's security and exposing smart-contract capability that Bitcoin itself lacks.

1:00 Clarinet — local Stacks development toolkit

Clarinet is the Stacks analogue of Truffle + Ganache: it scaffolds projects, runs a local Clarity VM, and supports writing, testing, and debugging smart contracts without ever hitting a real node. One command (clarinet new) creates the starter project structure.

1:30 Clarity — non-Turing-complete, Lisp-based, strongly typed

Clarity is Stacks' smart-contract language. Deliberately non-Turing-complete (so you can reason about contracts statically) and Lisp-based, with strong typing — walk-through of the unsigned vs. signed integer distinction in a live REPL.

4:00 NFT primitives built into Clarity

Unlike Solidity, Clarity has native NFT primitives — nft-mint, nft-burn, nft-transfer, and the matching balance-sheet plumbing — baked into the language. No standard-template copy-paste; the correct semantics come for free.

5:00 The SIP-009 NFT trait

SIP-009 is Stacks' NFT standard (analogous to ERC-721). Clarity traits define a contract's public interface; implement the trait and you have an NFT that works with the rest of the ecosystem.

6:30 Implementing the SIP-009 trait

Walk-through of clarinet check catching missing trait functions, then pasting a reference SIP-009 NFT implementation: get-last-token-id, get-token-uri, get-owner, transfer, and a convenience mint.

10:00 Principals and the tx-sender ownership check

Clarity's "principal" primitive captures both standard addresses and contract addresses. The transfer function asserts that the sender argument equals tx-sender (Clarity's equivalent of msg.sender) — without that check, anyone could transfer anyone's NFT.

12:30 Clarinet console — local VM REPL

clarinet console opens an in-process Clarity VM REPL. Deployed contracts are introspectable, standard wallets are pre-funded, and calls like contract-call? ... mint, get-owner, and transfer fire instantly and emit events just like mainnet would.

Presented by Marvin Janssen and Friedger Müffke Stacks · website

Topics: Blockchain & DLT, NFTs, Developer Tools

More from V-Sum Ten