Skip to main content

Introduction

This section gives overview of the most comman use cases. Read Getting Started and Guides sections for a detailed documentation.

Overview

WasmKit is a development framework for building CosmWasm contracts. The aim of the project is to make contracts development process simple, efficient and scalable. User can focus on logic of contract and not much on further steps in the development.

It facilitates features such as initiating project repository from contract templates, easy compilation of contracts, deployment, interacting with contracts using schema and a contract testing framework.

Initialize a project


wasmkit init <project-name>

This will create a directory <project-name> inside current directory with boiler-plate code. The contracts/ directory has all the rust files for the contract logic. scripts/ directory contains .ts scripts that user can write according to the use case, a sample script has been added to give some understanding of how a user script should look like. test/ directory contains .ts scripts to run tests for the deployed contracts.

Listing Tasks

To see the possible tasks (commands) that are available, go to project's folder and try:


wasmkit help

This is the list of built-in tasks. This is your starting point to find out what tasks are available to run.

Compile the project

To compile the contracts, go to project directory:


cd <project-name>
wasmkit compile

This command will generate compiled .wasm files in artifacts/contracts/ dir and schema .json files in artifacts/schema/ dir.

Cleanup Artifacts

To clear artifacts data, use


wasmkit clean

This will remove the artifacts directory completely. To clean artifacts for only one contract, use


wasmkit clean <contract-name>

This will remove specific files related to that contract.

Running user scripts

User scripts are a way to define the flow of interacting with contracts on some network in form of a script. These scripts can be used to deploy a contract, query/transact with the contract. A sample script scripts/sample-script.ts is available in the boilerplate. To run a script:


wasmkit run scripts/<script-name>

Run the sample script:


wasmkit run scripts/sample-script.ts # runs the sample script

Testing contracts

Tests for the contract logic can be written in Typescript and are placed in test/ directory. These tests deploy the contracts to a network and tests against the deployed contract. To run the tests:


wasmkit test # runs all tests in test/ directory

Run a single test:


wasmkit test test/<test-name>

Run the sample test:


wasmkit test test/sample-test.ts # runs the sample test