Skip to main content
stacksdapp generate parses Clarity contract ABIs and writes type-safe TypeScript bindings plus a debug UI under frontend/src/generated/.

Contents

Generate once

When package-lock.json exists under contracts/ or frontend/, generate runs npm ci before exporting ABIs.

Watch mode

Regenerate on every .clar change without the full dev supervisor:
stacksdapp generate --watch regenerates bindings when you save a contract. stacksdapp dev does not.

How it works

1. Parse

Extract ABIs from all contracts using initSimnet():
ABIs are cached in contracts/.cache/. Unchanged sources skip redundant initSimnet runs.

2. Normalize

3. Render

Tera templates produce three files under frontend/src/generated/:
  • contracts.ts: typed call wrappers
  • hooks.ts: React hooks
  • DebugContracts.tsx: live debug panel

4. Write

SHA-256 hashing writes only when content changes. This keeps Next.js hot reload fast.

Generated files

contracts.ts

hooks.ts

DebugContracts.tsx

deployments.json

Contract addresses written by stacksdapp deploy.

Using hooks in your UI

Hiro API key (optional)

For higher rate limits on read-only Stacks calls, set in frontend/.env.local:
The template passes this through getReadOnlyNetwork (@stacks/network v7).

Stale deployments

If on-chain addresses in deployments.json no longer match your contracts, redeploy:

File watcher

stacksdapp dev does not watch contracts. Run this in another terminal:
The watcher:
  1. Monitors .clar files
  2. Debounces rapid edits
  3. Runs code generation
  4. Lets Next.js hot reload pick up the new bindings
Do not edit files under frontend/src/generated/ by hand. They are overwritten on the next generate.