Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Counter canister in WebAssembly

This example demonstrates a counter application written directly in WebAssembly Text Format (WAT). The compiled Wasm module is only 389 bytes.

It can be a good way to learn and experiment with the IC System API.

Prerequisites

  • icp-cli: npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
  • WABT (for wat2wasm): brew install wabt

Deploy and test

icp network start -d
icp deploy
bash test.sh
icp network stop

Manual testing

icp canister call --query counter get '()'
# (0 : int64)

icp canister call counter inc '()'
icp canister call --query counter get '()'
# (1 : int64)

icp canister call counter set '(42 : int64)'
icp canister call --query counter get '()'
# (42 : int64)