一键导入
canton-webapp-generator
Generate a React webapp for Canton ledger. Use when user mentions "generate webapp", "create webapp", or "build frontend".
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate a React webapp for Canton ledger. Use when user mentions "generate webapp", "create webapp", or "build frontend".
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generate TypeScript API from Daml smart contracts. Use when user mentions "generate canton SDK".
Generate TypeScript tests from Daml scripts. Use when user mentions "generate tests", "create tests for canton", or "generate canton tests".
| name | canton-webapp-generator |
| description | Generate a React webapp for Canton ledger. Use when user mentions "generate webapp", "create webapp", or "build frontend". |
| allowed-tools | Bash, Read, Write, Edit, Glob, Grep, AskUserQuestion |
Generate a React webapp that interfaces with a Canton ledger running Daml smart contracts.
Tech Stack: React 18, Vite, TanStack Query, React Router v6, Tailwind CSS
Every feature MUST be fully implemented. Do not:
Every component, hook, and feature you create must be complete and functional. If a feature requires data from the Daml model, implement the actual query. If a button should exercise a choice, wire it up completely.
The generated scaffolding provides working base code. When customizing for the Daml model, maintain the same standard: working code only, no placeholders.
This skill requires a pre-generated SDK. Before running:
<project-path>/sdk<project-name>-api.ts with TemplateIds exportLook for Daml project configuration:
daml.yaml in workspace - extract project name<project-path>/sdk<project-name>-api.ts to discover available templatesIf SDK not found, stop and instruct user to generate SDK first.
Run the webapp generator script:
cd <project-path> && npx ts-node <path-to-skill>/scripts/generate-webapp.ts <project-path> <project-name>
Where:
<path-to-skill> is the absolute path to this skill's directory<project-path> is the Daml project root<project-name> is from daml.yamlThis creates <project-path>/webapp/ with:
cd <project-path>/webapp && npm install
Read prompts/customization.md for detailed patterns, then:
CRITICAL: Read the SDK's <project-name>-api.ts and extract ALL available choices for each template. Look for:
// In the SDK, each template namespace exports choice functions:
export namespace MyModule_MyTemplate {
export interface Payload { ... }
export function create(...): Command<Payload>;
export function Accept(contractId: ContractId<Payload>): Command<...>; // <- Choice
export function Transfer(contractId: ContractId<Payload>, args: {...}): Command<...>; // <- Choice
}
Every exported function (except create) is an exercisable choice. You MUST create hooks for ALL of them.
In src/hooks/useContracts.ts, create hooks for each template AND each choice:
import { TemplateIds, MyTemplate } from '@sdk/<project-name>-api';
import { useContractQuery, useExerciseChoice } from './useLedger';
// Query hook for template
export function useMyContracts() {
return useContractQuery<MyTemplate.Payload>(TemplateIds.MyModule_MyTemplate);
}
// Hook for EVERY choice discovered in SDK
export function useAcceptMyContract() {
return useExerciseChoice(TemplateIds.MyModule_MyTemplate, 'Accept');
}
export function useTransferMyContract() {
return useExerciseChoice(TemplateIds.MyModule_MyTemplate, 'Transfer');
}
// ... create a hook for EACH choice found in the SDK
For each major template, create in src/features/:
<TemplateName>List.tsx - List view with query hook<TemplateName>Detail.tsx - Detail view with ALL choice actions from SDKCreate<TemplateName>.tsx - Form to create new contractsImportant: The Detail view must include buttons for ALL choices discovered in the SDK, not just a subset.
Update src/App.tsx with routes for new features:
<Route path="/my-contracts" element={<MyContractList />} />
<Route path="/my-contracts/:id" element={<MyContractDetail />} />
<Route path="/create-my-contract" element={<CreateMyContract />} />
Add links to src/components/layout/Sidebar.tsx for new features.
Start the development server:
cd <project-path>/webapp && npm run dev
Verify:
If the Daml model has role-specific contracts (admin, operator, etc.):
useAuth.tsx by querying role-indicator contractssrc/features/admin/Report when complete:
<project-name><project-path>/webappBefore reporting success, verify ALL of the following:
useContracts.tsuseContracts.ts