justitita wasm contract development kit
Running it then should be as simple as:
$ make all
$ make test
We use docker
so that wasm-cdt
command can run on any type system. You can compile from the source code or directly use pre-build binary to build docker image.
-
Make build directory, structure:
-\ -llvm\ -misc\ -Dockerfile -wasm-cdt
llvm: llvm binary files
misc: base header files
Dockerfile: Docker build file
wasm-cdt: go build binary file.
-
Start Building:
$ docker build -t wasm-cdt . $ docker run –rm -it wasm-cdt --help (verify your image)
-
For your
C
file must haveinvoke
method, andinvoke
is the only entry point of the contract.invoke
method format:$ char *invoke(int argc, char *argv[])
-
You can use justitia.h in your contract to get info relate to chain:
#include <stdio.h> #include <string.h> #include "justitia.h"
-
demo.c is our demo contract, you get some detail to write wasm contract.
-
To deploy a contract, you can use our
deploy
command.docker run --rm -it -v ${local_workspace}:/workspace wasm-cdt deploy -f ${wasm_file} -ac ${deploy_account} -ep ${endpoint_address}
-
To call wasm contract, you can use our rpc api wasm-call and wasm-transaction.