Thank you for your interest in contributing to the Zama SDK! This guide will help you get started.
- Node.js >= 22
- pnpm >= 10
- Foundry >= 1.0.0
# Clone the repository
git clone https://github.com/zama-ai/sdk.git
cd sdk
# Install dependencies
pnpm install
# Build all packages (order matters: sdk first)
pnpm build
# Run tests
pnpm test:runpackages/
sdk/ # Core SDK
react-sdk/ # React hooks
test-nextjs/ # E2E test app (Playwright + Hardhat)
Use descriptive branch names:
feat/add-batch-transferfor featuresfix/credential-expirationfor bug fixesdocs/update-readmefor documentationrefactor/signer-interfacefor refactoring
- Create a feature branch from
main - Make your changes
- Ensure all checks pass:
pnpm typecheck # Type checking
pnpm lint # ESLint
pnpm format:check # Prettier formatting
pnpm test:run # Unit tests
pnpm build # Build output- Open a pull request
# All tests (watch mode)
pnpm test
# Single run
pnpm test:run
# Specific file
pnpm test:run -- packages/sdk/src/token/__tests__/token.test.ts
# With coverage
pnpm test:coverage
# E2E tests (requires build first; auto-starts hardhat + next dev)
pnpm e2e:test- ESM-only — all packages use
"type": "module" - Prettier + ESLint — enforced via pre-commit hooks (Husky + lint-staged)
- Unused variables — prefix with
_(e.g.,_unused) - Tests — place in
__tests__/directories adjacent to source files, use vitest withvi.fn()for mocks - React SDK — all source files use
"use client"directive
- Keep PRs focused — one feature or fix per PR
- Add tests — new features and bug fixes should include tests
- Update types — if you change public APIs, update TypeScript types accordingly
- Run all checks — ensure
pnpm typecheck && pnpm lint && pnpm test:run && pnpm buildpasses - Use a Conventional Commit PR title — examples:
fix: handle signer timeout,feat(react-sdk): add cached token balance hook
We use semantic-release for automated versioning and publishing.
Release behavior:
- PR titles are validated against Conventional Commits.
- Squash-merging into a release branch (
mainorprerelease) preserves that title as the release signal. - semantic-release computes the next version (
patch/minor/major) from merged commits. @zama-fhe/sdkand@zama-fhe/react-sdkare versioned and published together in lockstep.mainpublishes stable versions to npmlatest, whileprereleasepublishes prerelease versions to npmalpha.- GitHub release notes and tags are generated automatically.
Release workflows:
Release(.github/workflows/release.yml): automatic publish on push tomainandprerelease, gated byVitestandPlaywright.Release (Manual)(.github/workflows/release-manual.yml): manual publish restricted tomainandprerelease, with the sameVitest+Playwrightgates before publishing. Shares a concurrency group withReleaseto prevent simultaneous publishes on the same ref.Release Preview(.github/workflows/release-preview.yml): manual dry-run restricted tomainandprerelease(pnpm release:dry-run), no publish side effects.
Install channels:
- Stable:
npm i @zama-fhe/sdk - Prerelease:
npm i @zama-fhe/sdk@alpha
Maintainer requirements:
- Configure branch protection on
mainto require bothVitestandPlaywrightchecks before merge. - Configure branch protection on
prereleasewith the same required checks. - Configure npm trusted publishers for
@zama-fhe/sdkand@zama-fhe/react-sdkpointing to this repository'srelease.ymlandrelease-manual.ymlworkflows.
- Framework-agnostic core —
sdkdefines theGenericSignerinterface; library-specific adapters (viem, ethers, wagmi) implement it - Contract call builders — pure functions returning
ContractCallConfigobjects, composed by library-specific sub-paths - Error hierarchy — all SDK errors extend
TokenErrorwith typed error codes; use specific subclasses (EncryptionFailedError,SigningRejectedError, etc.)
- Implement the
GenericSignerinterface in a new file underpackages/sdk/src/<library>/ - Add a corresponding entry point in
package.jsonexports - Configure tsup to build the new entry point
- Add tests
- Provider-based hooks go in
packages/react-sdk/src/token/orsrc/relayer/ - Library-specific hooks go in
packages/react-sdk/src/<library>/ - Export from the appropriate
index.ts
Use GitHub Issues for bug reports and feature requests. Please include:
- Steps to reproduce
- Expected vs actual behavior
- SDK version and environment details
By contributing, you agree that your contributions will be licensed under the BSD-3-Clause-Clear License.