Skip to main content

Compiling your contracts

Compiling contracts can be done using the command wasmkit compile.

Compile all contracts


wasmkit compile

It compiles all the contracts in the contracts/ directory. For each contract compiled, corresponding .wasm file is stored in the artifacts/contracts directory created in project's root directory.

Compile specific contract

To compile only one contract or a subset of all contracts in the contract/ directory, use:


wasmkit compile <sourcePaths>

Compile one contract:


wasmkit compile contracts/counter

Compile multiple contracts:


wasmkit compile contracts/counter contracts/cw20

Schema generation

Schema is also generated alongside the compiled .wasm file for each of the contract compiled using wasmkit compile command. Schema files are .json files stored inside artifacts/schema/ directory.

In the typescript_schema directory of artifacts/, the typescript classes for each of the contracts' client object which can be imported into scripts and tests (.ts) as seen in the samples.

Single contract artifacts/ directory structure:


artifacts
├── contracts
│   └── counter.wasm
├── schema
│   └── counter
│   ├── execute_msg.json
│   ├── instantiate_msg.json
│   └── query_msg.json
└── typescript_schema
└── CounterContract.ts
5 directories, 5 files

To skip schema generation while compiling, use:


wasmkit compile --skip-schema