Client Generation
When you build a service, the CLI emits an abi.json describing its methods,
types, and events. You can turn that ABI into a type-safe TypeScript client that
other applications use to call your service.
The repository ships a helper, scripts/generate-client.js, which adapts the
SDK’s ABI to the client generator’s format and runs
@calimero-network/abi-codegen
for you.
Pipeline
Section titled “Pipeline”1. Build your service
Section titled “1. Build your service”npx calimero-sdk build src/index.ts -o build/service.wasmThis creates build/abi.json next to build/service.wasm.
2. Generate the client
Section titled “2. Generate the client”node scripts/generate-client.js <abi-json-path> <output-dir> [client-name]Parameters
<abi-json-path>— path to your ABI (defaultbuild/abi.json).<output-dir>— where generated files are written (defaultbuild/generated).[client-name]— optional class name for the generated client (passed through as--client-name).
Example
node scripts/generate-client.js build/abi.json src/generated CounterClientThere is also a thin shell wrapper, scripts/generate-client.sh, that forwards
the same arguments.
3. Use the generated client
Section titled “3. Use the generated client”The generated file contains the client class plus the TypeScript types for your service. It talks to a node through the Calimero client library — roughly:
import { CounterClient } from './generated/CounterClient';// ...construct/connect a client per your generator + client-library version...
const client = new CounterClient(/* app/context wiring */);
await client.increment();const count = await client.getCount();Wire it into your build
Section titled “Wire it into your build”{ "scripts": { "build": "calimero-sdk build src/index.ts -o build/service.wasm", "generate:client": "node scripts/generate-client.js build/abi.json src/generated", "build:all": "npm run build && npm run generate:client" }}Make sure the generated directory is included in your tsconfig.json
include globs.
Troubleshooting
Section titled “Troubleshooting”- “ABI file not found” — build the service first and check the path
(
ls build/abi.json). - Client generation failed — verify
abi.jsonis valid JSON and thatnpxcan reach@calimero-network/abi-codegen; re-run with more output. - Type errors in generated code — ensure a compatible
@calimero-network/calimero-clientversion and that all service types are well-defined.