@icp-sdk/bindgen
v0.2.1
Published
Generate TypeScript bindings for Candid
Readme
ICP JS SDK Bindgen
Generate modern TypeScript bindings for Internet Computer (IC) canisters from Candid .did files.
The tool can be used in three ways:
Note: Generated code references
@icp-sdk/core(agents, candid, principals). Install it in your app if you plan to compile/run the generated code. See js.icp.build/core.
Install
npm i -D @icp-sdk/bindgenQuick start (Vite)
Generate bindings from a hello_world.did file into src/bindings:
// vite.config.ts
import { defineConfig } from 'vite';
import { icpBindgen } from '@icp-sdk/bindgen/plugins/vite';
export default defineConfig({
plugins: [
icpBindgen({
didFile: './hello_world.did',
outDir: './src/bindings',
}),
],
});Use the generated client:
import { createActor } from './bindings/hello_world';
const actor = createActor('your-canister-id');
const greeting = await actor.greet('World');For more info, see the docs.
Contributing
Contributions are welcome! Please see the contribution guide for more information.
License
This project is licensed under the Apache-2.0 license.
