بنقرة واحدة
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 المهني
| 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/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".