CLI-Tools
go-zli
zli is a command-line tool based on the Zilliqa Golang SDK.
Source Code
The Github repository can be found at https://github.com/Zilliqa/zli
Getting zli
Run the following to clone the repository to your local machine
Installation
Build
Run the following command to generate the zli
binary:
Install
Option 1: Install the zli
binary by specifying the output path during the build:
Option 2: Run the installation script:
Commands
Run zli -h
to see the help message along with the list of available commands:
zli
works by storing account information in a wallet configuration file in ~/.zilliqa
.
Run zli [command] --help
to see the usage details for each available command. Here are some commonly used commands:
Wallet
zli wallet init
: Generate a new wallet (configuration file) forzli
to use. A default account (using randomly generated private key) is created inside the wallet.zli wallet echo
: Print out the contents of the wallet (i.e., the configuration file).zli wallet from [flags]
: Generate a new wallet from a specific private key.
Contract
zli contract deploy [flags]
: Deploy a new contract.zli contract call [flags]
: Call an existing contract.zli contract state [flags]
: Get the state data for a specific smart contract.
Account
zli account generate [flags]
: Generate a random private key.
Transfer
zli transfer [flags]
: Transfer Zilliqa tokens to a specific account.
RPC
zli rpc transaction [flags]
: Get the transaction details for a specific transaction ID.
Examples
Executing Corner-Case Tests on a Tiny Contract
- Prepare the wallet (configuration file
~/.zilliqa
) by runningzli wallet init
orzli wallet from -p [private_key]
:
Deploy a tiny contract by running
sh scripts/deploy-tiny-contract.sh
Run
zli testsuit tiny -a [contract_address]
orsh scripts/test-tiny-contract.sh
to execute the tests. If the receipt of any transaction returnsfalse
, execution stops and the remaining tests are aborted.
Invoking a Contract
Prepare the wallet similar to the previous example.
Run the following command to invoke a smart contract:
For instance:
note
zli
supports passing the private key as a parameter to the zli contract deploy
or zli contract call
command. Just use the -k [private key]
option to switch to a different private key for sending transactions.
Running zli Inside a Docker Container
An alternative to running zli
as a native binary is to build (or download) the go-zli
Docker image, and to run zli
from inside the container. This option requires prior installation of Docker (refer to the Docker installation page).
- Build the
go-zli
Docker image:
- Run
zli
inside a container environment: