一键导入
canton-sdk-generator
Generate TypeScript API from Daml smart contracts. Use when user mentions "generate canton SDK".
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate TypeScript API from Daml smart contracts. Use when user mentions "generate canton SDK".
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Design and generate themed PlantUML activity diagrams for Daml workflows and choice flows. Use this skill whenever the user asks to diagram a Daml choice, visualize a multi-party workflow, draw swim lanes for parties or templates, render an exercise flow, or sketch a contract interaction — even if "PlantUML" is not named explicitly. Currently covers activity/workflow diagrams only; not yet transaction trees or contract lifecycle graphs.
Decision framework for choosing between on-ledger Daml/Canton logic and off-ledger backend code. Use whenever the user is designing Daml templates, choices, or interfaces; deciding what should live in a smart contract vs an operator backend; weighing Canton throughput or contention concerns; integrating oracles, KYC, or any external data with Daml; refactoring an on-ledger component because it's too heavy; or asking variations of "should this be a Daml choice?", "where does this logic go?", "is this on-ledger?", or "should the backend handle this?". Default the user toward off-ledger and require explicit justification for putting anything on-ledger.
Generate TypeScript tests from Daml scripts. Use when user mentions "generate tests", "create tests for canton", or "generate canton tests".
Generate a React webapp for Canton ledger. Use when user mentions "generate webapp", "create webapp", or "build frontend".
| name | canton-sdk-generator |
| description | Generate TypeScript API from Daml smart contracts. Use when user mentions "generate canton SDK". |
| allowed-tools | Bash, Read, Write, Edit, Glob, Grep, AskUserQuestion |
Generate a clean, developer-friendly TypeScript API from Daml smart contracts.
Look for Daml project configuration:
multi-package.yaml in workspace root - if exists, parse to find all project pathsdaml.yaml in workspace root - single project setup**/daml.yaml - scan for projects in subdirectoriesFor each project found, extract:
name: field in daml.yaml)If multiple projects are found, use AskUserQuestion to ask the user:
"Which Daml project should I generate the API for?"
Options should list all discovered project names.
cd <project-path> && daml build
If build fails, report error and stop.
After successful build, find all DAR files needed for codegen:
<project-path>/.daml/dist/<project-name>-*.dar.lib/: <project-path>/.lib/*.darBuild the codegen command dynamically with all discovered DARs.
Run daml codegen js with all discovered DAR files:
cd <project-path> && daml codegen js -o <sdk-path>/daml-js <all-dar-files>
Where:
<sdk-path> defaults to <project-path>/sdk - the SDK output directory<all-dar-files> is the space-separated list of all DARs from Step 3The generator script produces ALL SDK code including:
cd <sdk-path> && npx ts-node <path-to-skill>/scripts/generate-canton-api.ts daml-js . <project-name>
Where:
<path-to-skill> is the absolute path to this skill's directory<sdk-path> defaults to <project-path>/sdk<project-name> is the name discovered in Step 1cd <sdk-path> && npx tsc --noEmit
Fix any errors before proceeding.
Run the React hooks generator:
cd <sdk-path> && npx ts-node <path-to-skill>/scripts/generate-canton-react.ts . <project-name>
Generates:
react/context/LedgerContext.tsx - React context providerreact/context/useLedger.ts - Context hookreact/hooks/core.ts - Generic hooks (useContractQuery, useChoiceMutation)react/hooks/queries.ts - Typed query hooks for each templatereact/hooks/mutations.ts - Typed create + choice mutation hooks (action-first naming) and grouped actions per templatereact/hooks/keys.ts - Query key factories aligned with core query keys (so invalidation works)react/index.ts - Barrel exportRead prompts/enhance-api.md for validation checklist:
docs/SDK.md documentation (required)This step validates generated code and creates user documentation.
If you manually call the JSON API (e.g. with curl) and see:
missing Authorization header with OAuth 2.0 Bearer Token
Remember:
Authorization: Bearer <JWT>.The generated SDK README includes a copy‑pasteable curl + token snippet.
Report when complete:
<project-name><project-path><sdk-path>After SDK generation is complete, suggest:
"SDK generated successfully! To generate integration tests, run the
canton-test-generatorskill."
The test generator will:
daml/Scripts/tests/