Overview
The CLI is used to generate bindings for a .did file.
Installation
Section titled “Installation”As a dev dependency for your project:
npm install -D @icp-sdk/bindgenOr as a global command:
npm install -g @icp-sdk/bindgenSuppose you have a ./canisters/hello_world.did file, and you want to output the generated bindings for your Vite app in the src/bindings/ folder.
You can generate the bindings with the following command:
icp-bindgen --did-file ./canisters/hello_world.did --out-dir ./src/bindingsFor an explanation of the generated files, see the Bindings Structure page.
Usage without installation
Section titled “Usage without installation”npx @icp-sdk/bindgen --did-file ./canisters/hello_world.did --out-dir ./src/bindingsOptions
Section titled “Options”--did-file <path>: Path to the.didfile to generate bindings from--out-dir <dir>: Directory where the bindings will be written--actor-interface-file: If set, generates a<service-name>.d.tsfile that contains the same types of the<service-name>.tsfile. Has no effect if--actor-disabledis set. (default:false)--actor-disabled: If set, skips generating the actor file (<service-name>.ts). (default:false)--force: If set, overwrite existing files instead of aborting. (default:false)