Giter VIP home page Giter VIP logo

zli's Introduction

zli

zli is a command line tool based on the Zilliqa Golang SDK.

Requirements

Golang (minimum version: go.1.12):

Installation

Dependencies

A go module is used to manage dependencies. Run the following command to download all dependencies according to the module file go.mod:

go get ./...

Build

Run the following command to generate the zli binary:

go build -o zli main/main.go

Install

Option 1: Install the zli binary by specifying the output path during the build:

go build -o $GOPATH/bin/zli main/main.go

Option 2: Run the installation script:

sh install.sh

Commands

Run zli -h to see the help message along with the list of available commands:

A convenient command line tool to generate accounts, run integration testings or run http server .etc

Usage:
  zli [flags]
  zli [command]

Available Commands:
  account     Generate or load multiple accounts
  contract    Deploy or call zilliqa smart contract
  help        Help about any command
  rpc         readonly json rpc of zilliqa
  transfer    Transfer zilliqa token to a specific account
  version     Print the version number of zli
  wallet      Init a new wallet or get exist wallet info

Flags:
  -h, --help   help for zli

Use "zli [command] --help" for more information about a command.

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) for zli 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

  1. Prepare the wallet (configuration file ~/.zilliqa) by running zli wallet init or zli wallet from -p [private_key]:
{
	"api": "https://ipc-ud-api.dev.z7a.xyz",
	"chain_id": 2,
	"default_account": {
		"private_key": "227159779c78c9a920cba73086cf73fb3ee15cdd95380aa3b93757669e345300",
		"public_key": "0324cdd72db3de0e9f570d550631438d581056fb0d9c4daddbad2928eaf49f54ee",
		"address": "31f33d13ad6aa724cde1f3d12d75fb344a1df9de",
		"bech_32_address": "zil1x8en6yadd2njfn0p70gj6a0mx39pm7w7lz3kpm"
	},
	"accounts": [{
		"private_key": "227159779c78c9a920cba73086cf73fb3ee15cdd95380aa3b93757669e345300",
		"public_key": "0324cdd72db3de0e9f570d550631438d581056fb0d9c4daddbad2928eaf49f54ee",
		"address": "31f33d13ad6aa724cde1f3d12d75fb344a1df9de",
		"bech_32_address": "zil1x8en6yadd2njfn0p70gj6a0mx39pm7w7lz3kpm"
	}]
}
  1. Deploy a tiny contract by running sh scripts/deploy-tiny-contract.sh

  2. Run zli testsuit tiny -a [contract_address] or sh scripts/test-tiny-contract.sh to execute the tests. If the receipt of any transaction returns false, execution stops and the remaining tests are aborted.

Invoking a contract

  1. Prepare the wallet similar to the previous example.

  2. Run the following command to invoke a smart contract:

zli contract call -a <smart contract address> -t <transition name> -r <parameter>

For instance:

zli contract call -a 305d5b3acaa2f4a56b5e149400466c58194e695f -t SubmitTransaction -r "[{\"vname\":\"recipient\",\"type\":\"ByStr20\",\"value\":\"0x381f4008505e940ad7681ec3468a719060caf796\"},{\"vname\":\"amount\",\"type\":\"Uint128\",\"value\":\"10\"},{\"vname\":\"tag\",\"type\":\"String\",\"value\":\"a\"}]"

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).

  1. Build the go-zli Docker image:
sh build_docker_image.sh
  1. Run zli inside a container environment:
docker run --rm -it -v ~/contract:/contract docker.pkg.github.com/zilliqa/zli/zli bash

zli's People

Contributors

ansnunez avatar bb111189 avatar charlieysc avatar renlulu avatar snowsledge avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.