C2wasm-Cli

C 2 Wasm Cli

Learn how to get the c2wasm-cli set up in your project.


Quick start

c2wasm-cli is a powerful command-line tool that allows developers to compile C code into WebAssembly (Wasm) modules. In this guide, we will walk you through the steps required to set up c2wasm-cli in your project.

Installing dependencies

To install c2wasm-cli, you'll need to have Node.js and Yarn installed on your system. Once you have these dependencies installed, you can install c2wasm-cli globally using the following command:

npm install -g c2wasm-cli

Setting up the Contracts Folder

To compile your C code into Wasm modules, you'll need to set up a folder named contracts that holds the C code files. This folder will contain the necessary code for your contracts.

Building the Contracts

To build the contracts and generate the Wasm modules, you can use the following command:

c2wasm-cli contracts build

This command will compile the C code files in the contracts folder and save the resulting Wasm modules to the build directory. If you have nested contracts, they will also be built.

ALWAYS `build`

Please dont change the output directory. The hooks-toolkit uses this directory. We will make the adjustment and allow any output directory soon.

Building a Single Contract

To build a specific contract, you can use the following command:

c2wasm-cli contracts/base.c build

This command will compile the base.c C code file and save the resulting Wasm module to the build directory.

ALWAYS `build`

Please dont change the output directory. The hooks-toolkit uses this directory. We will make the adjustment and allow any output directory soon.

Now you have c2wasm-cli set up in your project and can start compiling your C code into Wasm modules.

Previous
Standalone Environment