> ## Documentation Index
> Fetch the complete documentation index at: https://scaffoldstacks.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SIP standards

> SIP-010 fungible tokens and SIP-009 NFTs in Scaffold Stacks — stacksdapp add templates, impl-trait rules, and Stacks token standards.

Scaffold Stacks ships starter contracts for fungible tokens (SIP-010) and NFTs (SIP-009). This guide maps the specs to `stacksdapp add` templates, Clarity functions, and generated frontend hooks.

## Contents

* [Official specifications](#official-specifications)
* [Scaffold commands](#scaffold-commands)
* [impl-trait rules](#impl-trait-rules)
* [SIP-010 fungible tokens](#sip-010-fungible-tokens)
* [SIP-009 NFTs](#sip-009-nfts)
* [End-to-end workflow](#end-to-end-workflow)
* [Customizing templates](#customizing-templates)

## Official specifications

| Standard                     | Spec                                                                                                          | Stacks docs                                                                                  |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| **SIP-010** (fungible token) | [GitHub SIP-010](https://github.com/stacksgov/sips/blob/main/sips/sip-010/sip-010-fungible-token-standard.md) | [Create a fungible token](https://docs.stacks.co/get-started/create-a-token/fungible-tokens) |
| **SIP-009** (NFT)            | [GitHub SIP-009](https://github.com/stacksgov/sips/blob/main/sips/sip-009/sip-009-nft-standard.md)            | [Create an NFT](https://docs.stacks.co/get-started/create-a-token/non-fungible-tokens)       |
| Clarity Book (FT)            | [SIP010 chapter](https://book.clarity-lang.org/ch10-03-sip010-ft-standard.html)                               | —                                                                                            |
| Clarity Book (NFT)           | [SIP009 chapter](https://book.clarity-lang.org/ch10-01-sip009-nft-standard.html)                              | —                                                                                            |

Metadata: [SIP-016](https://github.com/stacksgov/sips/blob/main/sips/sip-016/sip-016-metadata-schema.md) · [SIP-019 metadata updates](https://github.com/stacksgov/sips/blob/main/sips/sip-019/sip-019-token-metadata-update-notifications.md)

## Scaffold commands

```bash theme={null}
stacksdapp add my-token --template sip010
stacksdapp add my-nft --template sip009
stacksdapp add legacy-token --template sip010 --clarity-version 5   # if needed
```

**Do not** hand-write a token from blog snippets. Use the template — it includes SIP-compatible functions, tests, requirements, and hooks.

Each command creates:

* `contracts/contracts/<name>.clar` with all required SIP functions
* `contracts/tests/<name>.test.ts` (if no test file exists)
* `[contracts.<name>]` entry in `Clarinet.toml` with correct epoch
* `[[project.requirements]]` for the mainnet trait (Clarinet simnet type-checking)
* Regenerated hooks in `frontend/src/generated/hooks.ts`

## impl-trait rules

### Common mistake

```
VM Error: use of undeclared trait <sip-010-trait>
```

**Cause:** `(impl-trait 'sip-010-trait)` — a short name with no full `SP…` contract path.

<Warning>
  Never use bare trait names like `(impl-trait 'sip-010-trait)`. Use the full mainnet path or omit for testnet.
</Warning>

### Network rules

| Network            | `impl-trait` in token contract  | Notes                                                                                                           |
| ------------------ | ------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| **Testnet**        | **Omit** `(impl-trait …)`       | No standard trait contract deployed on testnet. Templates ship without `impl-trait` so testnet deploy succeeds. |
| **Mainnet**        | **Required** for wallet listing | Uncomment the mainnet line in the template before deploy                                                        |
| **Simnet / tests** | Omit (template default)         | Clarinet requirement pulls mainnet trait for type-checking only                                                 |

### Mainnet trait addresses

| Standard | `impl-trait` (mainnet only)                                                          | `[[project.requirements]]` (scaffold default)                         |
| -------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |
| SIP-010  | `'SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard.sip-010-trait` | `SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard` |
| SIP-009  | `'SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.nft-trait`                               | `SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.nft-trait`                 |

Scaffold templates include a **comment** with the exact mainnet `impl-trait` line to uncomment before mainnet deploy.

## SIP-010 fungible tokens

Seven functions wallets and apps expect:

| Function                                    | Purpose               |
| ------------------------------------------- | --------------------- |
| `transfer(amount, sender, recipient, memo)` | Move tokens           |
| `get-name`                                  | Token name            |
| `get-symbol`                                | Ticker                |
| `get-decimals`                              | Display decimals      |
| `get-balance(who)`                          | Balance of principal  |
| `get-total-supply`                          | Circulating supply    |
| `get-token-uri`                             | Optional metadata URI |

The scaffold template also includes:

| Function                  | Access | Notes                                 |
| ------------------------- | ------ | ------------------------------------- |
| `mint(amount, recipient)` | public | Owner-only; initial supply            |
| `set-token-uri(value)`    | public | Owner-only; emits SIP-019-style print |

Default: **6 decimals**, owner = deployer at deploy time.

### Frontend hooks

```tsx theme={null}
import { useMyToken_GetBalance, useMyToken_Transfer, useMyToken_Mint } from '@/generated/hooks';
import { Cl } from '@stacks/transactions';

// read:  useMyToken_GetBalance().call([Cl.principal('ST…')])
// write: useMyToken_Transfer().call([Cl.uint(100), Cl.principal(sender), Cl.principal(recipient), Cl.none()])
```

Hook naming: `use{ContractPascal}_{FunctionPascal}`. See [Frontend guide](/frontend) for parsing `get-balance` results.

## SIP-009 NFTs

Four functions for NFT interoperability:

| Function                                | Purpose             |
| --------------------------------------- | ------------------- |
| `get-last-token-id`                     | Highest minted id   |
| `get-token-uri(token-id)`               | Metadata URI for id |
| `get-owner(token-id)`                   | Current owner       |
| `transfer(token-id, sender, recipient)` | Change owner        |

The scaffold template also includes:

| Function              | Access   | Notes                                     |
| --------------------- | -------- | ----------------------------------------- |
| `mint(recipient)`     | public   | Owner-only; auto-increments id            |
| `set-base-uri(value)` | public   | Owner-only; metadata template with `{id}` |
| `COLLECTION_LIMIT`    | constant | Default cap u1000                         |

### Frontend hooks

```tsx theme={null}
import { useMyNft_GetOwner, useMyNft_Mint, useMyNft_Transfer } from '@/generated/hooks';

// useMyNft_GetOwner().call([Cl.uint(1)])
// useMyNft_Transfer().call([Cl.uint(1), Cl.principal(sender), Cl.principal(recipient)])
```

## End-to-end workflow

```bash theme={null}
stacksdapp add my-token --template sip010
stacksdapp check && stacksdapp generate && stacksdapp test
stacksdapp deploy --network testnet --contract my-token --yes   # no impl-trait needed
# For mainnet: uncomment impl-trait line in .clar first, then deploy
stacksdapp dev --network testnet
```

Same flow for `--template sip009`.

## Customizing templates

| Goal                               | Edit in `.clar`                                                   |
| ---------------------------------- | ----------------------------------------------------------------- |
| Change decimals / collection limit | constants at top                                                  |
| Restrict mint                      | `asserts!` on `tx-sender`                                         |
| Royalties / marketplace            | add functions; keep trait fns compatible                          |
| Metadata                           | `set-token-uri` / `set-base-uri`; consider SIP-016 off-chain JSON |
| Mainnet wallet listing             | Uncomment/add mainnet `impl-trait` line before mainnet deploy     |

After edits: `check` → `generate` → `test` → `deploy`.

Trait errors: [Troubleshooting](/troubleshooting)
