Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Candid encoding example

Two canisters demonstrating Candid-encoded arguments and replies.

The callee accepts a Candid-encoded text name and returns a record { greeting: text }. The caller uses CandidCallFuture-style encoding to make a typed inter-canister call and forwards the result.

Prerequisites

Build

zig build

This produces zig-out/bin/callee.wasm and zig-out/bin/caller.wasm.

Deploy

icp network start --background
icp deploy callee
CALLEE=$(icp canister status -i callee)
icp canister create caller
icp canister install caller --args-format hex --args "$(echo -n $CALLEE | xxd -p)"

Test

Query the callee directly (returns record { greeting = "hello, world!" }):

icp canister call callee greet '("world")' -o auto

Make the caller call into the callee:

icp canister call caller call_greet --args-format hex "" -o auto

Rebuild and upgrade

zig build callee
icp canister install callee --mode upgrade

zig build caller
icp canister install caller --mode upgrade

Or rebuild and upgrade everything:

icp deploy --upgrade-unchanged