@stacks/connect v8 + @stacks/transactions v7.
After stacksdapp generate and stacksdapp deploy, the frontend calls deployed contracts via reusable generated hooks.
Contents
- Full-stack checklist
- Architecture
- Generated hooks
- deployments.json
- Network config
- Signing model
- Using hooks
- Parsing read-only data
- Failed to fetch errors
- Building Clarity arguments
- Wallet integration
- Custom UI workflow
- Common mistakes
Full-stack checklist
<DebugContracts /> on the home page while building. It validates hooks work before you ship custom UI.
Architecture
generated/*. Build custom UI in components/ and import from @/generated/hooks.
Generated hooks
Each public/read-only function gets one hook infrontend/src/generated/hooks.ts:
Naming:
use + {ContractPascalCase} + _ + {FunctionPascalCase}.
Hook return values
deployments.json
Contract calls resolve addresses fromfrontend/src/generated/deployments.json:
- Written by
stacksdapp deploy - If missing, calls log a warning and return
undefined - After redeploy with auto-versioning (
counter-v2), runstacksdapp generateif bindings drift
Network config
Driven byfrontend/.env.local:
stacksdapp dev --network testnet updates .env.local automatically.
Import scaffoldConfig from @/scaffold.config for network, nodeUrl, isDevnet, isTestnet, and getReadOnlyNetwork().
Signing model
Do not expect Leather/Xverse to sign devnet writes. Devnet uses template burner mnemonics from
contracts/settings/Devnet.toml.
Using hooks
Read-only hooks resolve oncall() — no txid polling. Public hooks poll the node until success or abort.
Parsing read-only data
Read-only hooks return cvToValue output, not plain JavaScript numbers. SIP-010get-balance typically returns:
Cannot convert [object Object] to a BigInt):
10**decimals for human display.
Failed to fetch errors
TypeError: Failed to fetch on read-only calls means the HTTP request to the node failed — not a Clarity revert.
Agent rule: After
stacksdapp deploy --network testnet, run stacksdapp dev --network testnet (not bare stacksdapp dev which defaults to devnet).
Pre-flight:
Building Clarity arguments
UseCl from @stacks/transactions:
Check the generated debug UI or contract ABI for exact field names.
Wallet integration
Custom UI workflow
- Edit contracts →
stacksdapp check && stacksdapp generate && stacksdapp test - Deploy →
stacksdapp deploy --network testnet --yes - Create component in
frontend/src/components/with"use client"and hook imports - Add to
app/page.tsxor a new route - Run
stacksdapp dev --network testnet
Common mistakes
Live reload
stacksdapp dev(devnet): file watcher regenerates bindings on.clarchangesstacksdapp dev --network testnet: runstacksdapp generate --watchin a second terminal- After regenerate, refresh hook imports in your components