# Welcome to the Cookbook

<div data-with-frame="true"><figure><img src="https://2420193188-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuholC0CdufHxYs050O3V%2Fuploads%2FNKfYBS961GghukK4UJEh%2Fstacksdocs-cookbook.png?alt=media&#x26;token=e728dd97-738d-4b12-a89b-0f89d7a4f60f" alt=""><figcaption></figcaption></figure></div>

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.*

<details>

<summary><strong>Who is the Cookbook for?</strong></summary>

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.

{% hint style="info" %}
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.
{% endhint %}

</details>

### 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

1. Pick the closest recipe to your goal.
2. Copy the snippet into your project.
3. Replace placeholders like `SP…`, contract names, and network settings.
4. Add your app’s error handling and UX.

{% hint style="warning" %}
Recipes optimize for clarity and speed. They may omit production concerns like retries, logging, and input validation.
{% endhint %}

### Jump right in

<table data-view="cards"><thead><tr><th>Recipes</th><th data-card-target data-type="content-ref">Browse</th></tr></thead><tbody><tr><td><strong>Stacks.js</strong><br>Transactions, reads, auth, and app integration.</td><td><a href="stacks.js">stacks.js</a></td></tr><tr><td><strong>Clarity</strong><br>Common contract patterns and implementation snippets.</td><td><a href="clarity">clarity</a></td></tr><tr><td><strong>Example Contracts</strong><br>Curated examples of notable mainnet contracts and reference implementations.</td><td><a href="clarity/example-contracts">example-contracts</a></td></tr></tbody></table>

### Conventions and placeholders

* Addresses use `SP…` (mainnet) and `ST…` (testnet) unless noted.
* Contract identifiers use `SP….contract-name`.
* Replace `NETWORK` / `STACKS_API_URL` with your environment.
* Prefer explicit versions in your app.

<details>

<summary>Want to contribute a recipe?</summary>

Head to the [Stacks Docs Github repo](https://github.com/stacks-network/docs) 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**.&#x20;

Be sure to also include a byline of your Github or Twitter handle at the top of the page.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stacks.co/cookbook/readme.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
