Deploy and Use an Applet via CLI
Once an Applet is deployed to the WeilChain, its methods may invoked by any user of the chain, using the CLI or a DApp or, in some cases, the Wallet.
In this tutorial we'll see how to upload an Applet to the chain and invoke its methods using the Weilliptic CLI.
Preparations
This tutorial assumes that
- You have access to the testnet WeilChain.
- You have completed the Basic Applet Creation tutorial, as we will use the Applet created there.
- You have installed the Weilliptic CLI binary (wcli)
Launching the wcli
Setup the environment
The Weilliptic CLI is a very simple Wallet and to use it you will need a private key. In this tutorial, we will use an example key that you should never use in your production environment. To generate a new key, follow the Install the Web-Wallet how-to.
To use a private key, you need to point the CLI to a file containing only the key. To use the example key, execute the following steps:
mkdir ~/.weilliptic
echo 2763659f3ecb397ffee175e8cc62182c75df0398c78ec17d21041e2b72f62ce1 > ~/.weilliptic/private_key.wc
Execute the wcli
Assuming that the Weilliptic CLI binary is in the PATH
, execute the following:
WC_PATH=~/.weilliptic WC_PRIVATE_KEY=~/.weilliptic wcli
Once wcli is launched, load your private key and you will be greeted with prompt Weilliptic$$$>
.
Simply hit :return: or execute command help
to see a list of all commands available in the CLI.
Weilliptic$$$>
quit Quit the Weilliptic CLI
connect Connect.
deploy Deploy Weil Applet.
execute Execute Weil Applet.
get_contract_details Get WIDL Details.
get_txn_status Retrieve Transaction Status given a ticket.
list_weilpods List all the commands in Weilliptic
setup_wallet Sets up a Wallet
help Print this message or the help of the given subcommand(s)
To learn about each command, execute help <COMMAND>
, e.g.
Weilliptic$$$> help help
Print this message or the help of the given subcommand(s)
Usage: help [COMMAND]...
Arguments:
[COMMAND]... Print help for the subcommand(s)
The first command in the list, connect
, is used to connect to the Sentinel node, where the CLI will learn about other nodes.
Connecting is a requirement for most other commands.
Weilliptic$$$> help connect
Connect.
Usage: connect --host <host> --port <port>
Options:
-h, --host <host> Hostname to which we wish to connect.
-p, --port <port> Port number to which we wish to connect.
-H, --help-all Print help information
The host
refers to the Sentinel node, whose name or address will be published based on whether it is connected to the test-net or main-net.
Execute command connect -h <sentinel-node>
The following response should be seen.
{"message":"Connected successfully to <sentinel-node>.","status":"Ok"}
Deploying Smart Contracts
Once successfully connected to the Sentinel host, one can deploy their Applet using the deploy command by providing the contract body (path to the .wasm file) and its definition (path to the .widl file).
To deploy the Counter Applet, execute the following in the CLI:
- Rust
- Go
- AssemblyScript
- CPP
deploy --file-path path-to-project/target/wasm32-unknown-unknown/release/counter.wasm --widl-file path-to-widl-file
deploy --file-path path-to-project/target/wasi/counter_go.wasm --widl-file path-to-widl-file
deploy --file-path path-to-project/target/wasi/counter.wasm --widl-file path-to-widl-file
deploy --file-path path-to-project/build/counter.wasm --widl-file path-to-widl-file
A response equivalent to the following should be returned, here shortened and pretty-printed to facilitate the reading:
{
"batch_author": "<pod-id>",
"batch_id": "7618487ecb89ea5b11f0bb9fa5878e0ed0210106c8558796c826f62fd0b81674",
"block_height": 330,
"contract_address": "7b2...27d",
"creation_time": "2025-03-17T05:39:32Z",
"status": "Finalized",
"tx_idx": 0,
"txn_result": "{\"Ok\":\"null\"}",
"txn_ticket": "000000029eb1827e922c39afbbeab36a35d3750afe4d49505d91a67d24f2b05b46f193e6"
}
Note the contract_address
field. You will need to use its value in the next call, which retrieves the value of the counter using the execute
command.
execute --name 7b2...27d --method get_count
The address is given in the --name
parameter, in its full form, not shortened as shown above.
The result should be the following
{
"batch_author":"<pod-id>",
"batch_id":"",
"block_height":0,
"creation_time":"",
"status":"Finalized",
"tx_idx":0,
"txn_result":"{\"Ok\":\"0\"}"
}
The field txn_result
indicates that the value of the counter is 0. Let's increment it using the increment
method:
execute -n 7b2...27d --method increment
{
"batch_author":"<pod-id>",
"batch_id":"4f50b5754765124e077e352b8f27fec83f349a88581c91cb7e2c2469b8796fe8",
"block_height":11739,
"creation_time":"2024-09-30T20:48:28Z",
"status":"Finalized",
"tx_idx":0,
"txn_result":"{\"Ok\":\"null\"}"
}
followed by another call to get_count
execute -n 7b2...27d --method get_count
{
"batch_author":"<pod-id>",
"batch_id":"",
"block_height":0,
"creation_time":"",
"status":"Finalized",
"tx_idx":0,
"txn_result":"{\"Ok\":\"1\"}"
}
Observe that this time txn_result
has value 1
.
Next steps
Congratulations! You should have deployed an Applet and used it. Next you should modify the Applet to include a method that receives parameters, as in Pass parameters to Applets methods.