| name | create-template |
| description | Use when scaffolding a new FHEVM workspace -- contracts, Next.js frontend, or Vite frontend. Copies the canonical bundled template (project/ or templates/frontend-{next,vite}/) into a target directory and customizes package metadata, env-var defaults, and the Sepolia RPC URL via an interactive AskUserQuestion wizard. |
/create-template
Scaffold a fresh FHEVM workspace from one of the bundle's canonical templates.
Core principle: Templates are the source of truth. The wizard copies, then patches — it never invents.
Sources
| Variant | Source path | Produces |
|---|
contracts | project/ | Hardhat workspace with the three flagships |
frontend-next | templates/frontend-next/ | Next.js 16 App Router app wired against ConfidentialVoting |
frontend-vite | templates/frontend-vite/ | Vite + React app wired against ConfidentialVoting |
both | project/ + templates/frontend-{next,vite}/ (chosen) | Parent dir containing contracts/ and frontend/ as sibling workspaces |
Wizard flow
Step 1 — pick the variant
Use AskUserQuestion (single-select):
- Question: "Which workspace do you want to scaffold?"
- Options:
contracts — Hardhat workspace with ConfidentialCounter, ConfidentialToken, ConfidentialVoting.
frontend-next — Next.js 16 reference app for ConfidentialVoting.
frontend-vite — Vite reference app for ConfidentialVoting.
both — fullstack: contracts + frontend (Next or Vite, chosen in step 2D) as siblings under one parent.
Branch on the answer to one of the four step-2 paths below.
Step 2A — contracts sub-questions
Use a single AskUserQuestion call with up to 4 questions:
- Target directory (header
"Target dir"): default ./contracts. Reject answers that already exist as a non-empty directory — re-ask with a different default.
- Package name (header
"Pkg name"): default the basename of the target dir (e.g. contracts).
- Sepolia RPC provider (header
"RPC provider"):
Alchemy (default) — keep the URL template from project/hardhat.config.ts verbatim.
Infura — rewrite the URL template to https://sepolia.infura.io/v3/${RPC_KEY}.
Public RPC — rewrite to https://ethereum-sepolia-rpc.publicnode.com (constant; no key needed; user can still override per-deploy).
- Include the wrap/unwrap mock + token wrapper test? (header
"Wrap test"): default Yes. If No, drop contracts/mocks/, test/ConfidentialToken.ts's ConfidentialTokenWrapper describe block, and MockERC20/ERC7984ERC20WrapperMock typechain bindings.
Step 2B — frontend-next sub-questions
- Target directory (default
./frontend-next).
- Package name (default basename).
- Contract address env var name (default
NEXT_PUBLIC_CONFIDENTIAL_VOTING_ADDRESS). If a non-default name is chosen, rewrite every app/page.tsx and lib/*.ts reference.
Step 2C — frontend-vite sub-questions
- Target directory (default
./frontend-vite).
- Package name (default basename).
- Contract address env var name (default
VITE_CONTRACT_ADDRESS). Same rewrite rule as the Next variant.
Step 2D — both sub-questions (contracts + frontend in one parent)
Use a single AskUserQuestion call with up to 4 questions:
- Frontend variant (header
"Frontend"): Next.js (frontend-next) or Vite (frontend-vite).
- Parent directory (header
"Parent dir"): default ./my-app. Reject answers that already exist as a non-empty directory.
- Sepolia RPC provider (header
"RPC provider"): Alchemy (default) / Infura / Public RPC — applied to the contracts side only.
- Include the wrap/unwrap mock + token wrapper test? (header
"Wrap test"): default Yes — same semantics as the contracts variant.
Derived defaults (no question needed):
- Contracts package name:
<parent-basename>-contracts
- Frontend package name:
<parent-basename>-frontend
- Contract address env var:
NEXT_PUBLIC_CONFIDENTIAL_VOTING_ADDRESS (Next) or VITE_CONTRACT_ADDRESS (Vite)
The wizard creates this layout:
<parent>/
├── contracts/ # from project/
└── frontend/ # from templates/frontend-{next,vite}/ (variant chosen above)
Step 3 — copy
Resolve <repo-root> to the directory containing CLAUDE.md and architecture.md. Resolve <source> to the source path from the table above (<repo-root>/project or <repo-root>/templates/<variant>).
Use cp -r (NOT git clone) and skip the listed paths via rsync or two-step copy:
| Variant | Skip paths |
|---|
contracts | node_modules, artifacts, cache, types, deployments, coverage, dist, fhevmTemp |
frontend-next | node_modules, .next, dist |
frontend-vite | node_modules, dist |
both | Run two copies: <parent>/contracts/ from project/ (same skip list as contracts), then <parent>/frontend/ from templates/frontend-{next,vite}/ (same skip list as the chosen frontend variant). |
Concretely:
rsync -a \
--exclude=node_modules \
--exclude=artifacts \
--exclude=cache \
--exclude=types \
--exclude=deployments \
--exclude=coverage \
--exclude=dist \
--exclude=fhevmTemp \
"$SOURCE/" "$TARGET/"
(Adapt the --exclude list per variant. For both, run this twice with different $SOURCE/$TARGET pairs.)
Step 4 — patch
Apply the user's customizations to the copy, never to the source.
Always (every variant):
- Edit
<target>/package.json:
- Replace
"name": ... with the user's package name.
- Set
"version": "0.1.0".
- Drop the bn-bounty-specific
"homepage" and "repository" fields (or leave them up to the user — print a TODO).
- Edit
<target>/README.md if it references this repo by name; replace with a generic placeholder.
Contracts variant only:
- If user picked Infura, rewrite the
sepolia.url line in <target>/hardhat.config.ts from the Alchemy URL template to https://sepolia.infura.io/v3/${RPC_KEY}.
- If user picked Public RPC, rewrite the same line to
https://ethereum-sepolia-rpc.publicnode.com and drop the RPC_KEY interpolation. Add a comment noting that public RPCs are rate-limited.
- If user said No to wrap test:
- Delete
<target>/contracts/mocks/.
- In
<target>/test/ConfidentialToken.ts, delete the second describe("ConfidentialTokenWrapper", ...) block.
Frontend variants only:
- If user picked a non-default contract address env var name, rewrite every reference in
<target>/app/page.tsx, <target>/src/App.tsx (Vite), <target>/lib/wagmi.ts, etc.
- Update the README's "Setup" section to use the new env var name.
Step 5 — confirm and print next steps
Summarize what was done. Print the next-step commands the user should run, customized to the variant:
Contracts:
cd <target>
npm install
npx hardhat vars set MNEMONIC
npx hardhat vars set RPC_KEY
npm run compile
npm test
Frontend (Next):
cd <target>
npm install
echo "NEXT_PUBLIC_CONFIDENTIAL_VOTING_ADDRESS=0x..." > .env.local
npm run dev
Frontend (Vite):
cd <target>
npm install
echo "VITE_CONTRACT_ADDRESS=0x..." > .env.local
npm run dev
Both (fullstack):
cd <parent>/contracts
npm install
npx hardhat vars set MNEMONIC
npx hardhat vars set RPC_KEY
npm run compile && npm test
cd ../frontend
npm install
echo "NEXT_PUBLIC_CONFIDENTIAL_VOTING_ADDRESS=0x..." > .env.local
npm run dev
Edge cases
- Target directory already exists and is non-empty. Re-ask via
AskUserQuestion with a different default. Never overwrite without explicit user confirmation.
- Source not present. If
<repo-root>/project or <repo-root>/templates/<variant> doesn't exist, abort and explain — likely the user is invoking the skill outside the bundle.
rsync not available. Fall back to cp -r plus a follow-up rm -rf <target>/{node_modules,...}.
- Hardhat workspace must compile after copy. Run
npm install && npm run compile in the target as a smoke test if the user opts in.
What this wizard does NOT do
- Generate net-new contracts. To add a new flagship, use
fhevm-contracts / fhevm-erc7984 / fhevm-decryption skills directly.
- Deploy to Sepolia. The user runs
npx hardhat deploy --network sepolia themselves after hardhat vars set.
- Modify files inside the source templates (
project/, templates/frontend-{next,vite}/). The wizard is one-way — copy and patch.
- Invent contract patterns. If the user asks for "a confidential auction" or "a confidential ERC-721", refuse and route to the relevant skill — the bundle ships only the three audited flagships.
When to Use
- "Scaffold a new FHEVM contracts project."
- "Build a confidential voting dapp using FHEVM in Next.js / Vite."
- "Make me an FHEVM workspace."
- The user is starting a new repository or new sub-project that needs the bundle's conventions.
When NOT to Use
- Adding a new contract to an existing workspace →
fhevm-contracts.
- Migrating an existing project to
@zama-fhe/sdk@3.0.0 → fhevm-decryption + fhevm-frontend directly.
- Bug fix or feature work on the bundle's own templates → edit
project/ or templates/<variant>/ in place; do not invoke this wizard.
Cross-references