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:
During stacksdapp dev, the file watcher already regenerates bindings on save.
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 during dev
- Monitors
.clar files
- Debounces rapid edits
- Runs code generation
- Triggers Next.js hot reload
Do not edit files under frontend/src/generated/ by hand. They are overwritten on the next generate.