Skip to content

Getting Started

Prerequisites

  • Rust (stable) with the wasm32-wasip2 target:

    rustup target add wasm32-wasip2
    
  • Docker (for running a local devnet)

  • chainctl (the Wasichain CLI, built from packages/cli in the chain repo):

    cargo install --path packages/cli
    

Quick path: counter contract

1. Start a local devnet

chainctl devnet up

This launches a single-node dev chain via Docker Compose. RPC is available at http://127.0.0.1:26657 and the admission service at http://127.0.0.1:8081.

2. Build the contract

chainctl code build packages/contracts/counter

This runs cargo build --target wasm32-wasip2 --release inside the contract directory.

3. Deploy in one step

The dev deploy command builds, uploads, waits for activation, and instantiates:

chainctl dev deploy packages/contracts/counter \
  --from 0x<YOUR_ADDRESS> \
  --msg '{"initial_value": 0}'

4. Or deploy step-by-step

# Upload the compiled Wasm to the admission service
chainctl code upload target/wasm32-wasip2/release/counter.wasm --node http://127.0.0.1:8081

# Announce code to the chain
chainctl code announce --hash 0x<CODE_HASH> --blob-size <SIZE> --from 0x<YOUR_ADDRESS>

# Wait for validators to compile and activate the code
chainctl code wait --hash 0x<CODE_HASH> --until activated

# Instantiate the contract
chainctl contract instantiate --code-id <ID> --msg '{"initial_value": 0}' --from 0x<YOUR_ADDRESS>

5. Interact with the contract

# Increment the counter
chainctl contract exec --address 0x<CONTRACT_ADDR> --msg '{"Increment":{}}' --from 0x<YOUR_ADDRESS>

# Query the current value
chainctl contract query --address 0x<CONTRACT_ADDR> --msg '{"GetCount":{}}'

Next steps