Welcome to the Cookbook
Bite-sized code recipes, cooked and ready to serve.

The Cookbook contains detailed coding snippets known as recipes. Recipes are focused and reusable. They are designed to be referenced, copied, and adapted. They are not meant to be read end-to-end.
Prepped snippets for when you just need the ingredients.
Who is the Cookbook for?
For developers beyond the exploratory phase who require a specific, concrete code solution quickly for an existing application.This section provides focused, reusable Clarity and Stacks.js code snippets that solve common problems or demonstrate specific patterns—designed to be referenced, copied, and adapted rather than read end-to-end.
If you’re still learning core concepts, start with the main guides in the Build section. Come back here when you know what you’re trying to build.
What you’ll find here
Minimal, working Clarity snippets.
Minimal, working Stacks.js snippets.
Small patterns you can reuse across apps and contracts.
Notes on gotchas, tradeoffs, and safe defaults.
How to use the recipes
Pick the closest recipe to your goal.
Copy the snippet into your project.
Replace placeholders like
SP…, contract names, and network settings.Add your app’s error handling and UX.
Recipes optimize for clarity and speed. They may omit production concerns like retries, logging, and input validation.
Jump right in
Conventions and placeholders
Addresses use
SP…(mainnet) andST…(testnet) unless noted.Contract identifiers use
SP….contract-name.Replace
NETWORK/STACKS_API_URLwith your environment.Prefer explicit versions in your app.
Want to contribute a recipe?
Head to the Stacks Docs Github repo and submit a PR. Add a new page under the closest section. Keep it short and sweet. Use the same structure: Title, Byline, Code, Description, Use Cases, Key Concepts.
Be sure to also include a byline of your Github or Twitter handle at the top of the page.
Last updated
Was this helpful?