0CHAIN
Search…
ZWallet CLI
ZWallet is a Go-based command line interface (CLI) tool used for transferring tokens between 0Chain services and Wallet. Built using 0Chain's GoSDK, the Zbox CLI tool provides an interactive way to use your ZCN tokens for 0Chain blockchain, storage, and smart contracts.
ZWallet is bundled with lots of of features built to enhance your 0Chain service experience. With ZWallet, users can have full control over their funds and receive, send, store and exchange ZCN between various wallets.
ZWallet CLI also supports seamless interaction with other 0Chain services and provides self-explaining commands to manage ZCN tokens, and fetch information about 0chain components(miners, sharders, and blobbers).

Features‌

Safe & Secure

ZWallet is designed with the absolute necessity of user security. The funds are kept safe with encrypted private keys and none of the personal data is collected or stored.

Decentralized

ZWallet is a decentralized wallet which ultimately means you have complete freedom over private keys and funds. More importantly, no one has access to your crypto even 0Chain cannot even see how much tokens you have stored with them.

No Downtimes

ZWallet uses 0chain decentralized cloud which provides a fast and easily scalable blockchain for the different type of applications.

Multisig Wallet Management

ZWallet supports splitting of permissions to spend tokens between several wallets. A wallet is automatically created if no wallet is present.

Free to use

ZWallet is completely free and do not require any download fees. You are only obliged to pay the minimal blockchain network transaction charges and similar fees.

Staking

ZWallet supports the staking of ZCN tokens to earn hassle free rewards. Staking holds funds in ZWallet to support the security and operations of a 0chain network.

Get Started

This section covers ZWallet CLI concepts, repository configuration, and installation.

Concepts

Wallet
A wallet is required to hold the tokens. It comes with private and public keys including a secret mnemonic key.‌
MultiSignature Wallet
A Multisignature Wallet is a wallet for which any transaction from this wallet needs to be voted by T(N) associated signer wallets. To create a Multisignature Wallet, you need to specify the number of signers (N) you want on that wallet and minimum number of votes (T) it needs for a transaction to be approved.
dStorage
Its distributed storage where all the data files are stored.‌

System requirements

To properly build components, you must have a Machine setup with the following requirements:‌
  • Windows,Linux ,Mac OS (Linux with ubuntu 18.04 preferred)
  • 4 vCPU, 8 Gb Memory at minimum
  • 50 GB of space to store the ZWallet build components. ‌
We will be building and describing Zbox CLI capabilities on Ubuntu Linux. So If you want to build Zbox CLI on other platforms.
Follow this guide for Windows and other Platforms and move straight to the Creating a Wallet section.

Prerequisites

Installing and running the ZWallet requires deployment-specific dependencies to be preinstalled‌.

GoLang Binaries

Linux built-in Wget tool is used to fetch the golang archive from the google server using the command
1
wget https://go.dev/dl/go1.17.3.linux-amd64.tar.gz
2
Copied!
The tar command is used to extract the group of files into a usr/local directory.
1
tar -C /usr/local -xzf go1.17.3.linux-amd64.tar.gz
Copied!
Path Variable is set to usr/local directory using
1
export PATH=$PATH:/usr/local/go/bin
Copied!

Build-Essential

The build-essential package is required to build and make Zbox application. It includes the necessary GCC/g++ compilers and other essential critical libraries and utilities.
Run apt update command to update the packages.
1
sudo apt update
Copied!
Get Build-essential package.
1
sudo apt-get install build-essential
Copied!

Git

Git is required to retrieve and clone the Zbox repository. Install Git by using the command
1
sudo apt install git
Copied!

Building ZWallet

1. Clone the Zbox Repository using the command
1
git clone https://github.com/0chain/zwalletcli.git
Copied!
2. Navigate into Zboxcli directory using
1
cd zwalletcli
Copied!
3. Use the make install command to compile the source code.
1
make install
Copied!
This might take couple of minutes. Sample output after successful compiling:

Configure ZWallet network

Configuration for the 0chain network by default is stored in network/one.yaml file of the zwallet github repo which we will copy to a new config.yaml file in our local system . The config.yaml file and all the other 0chain components information will be stored in a .zcn folder located in the home directory of the file system.
1.Make a new .zcn folder in the home Linux directory using
1
mkdir $HOME/.zcn
Copied!
2. Copy the content from one.yaml to a new config.yaml file using
1
cp network/one.yaml $HOME/.zcn/config.yaml
Copied!
3. To verify whether the config.yaml exists and network configuration is stored properly. Check the config.yaml details using the command
1
nano config.yaml
Copied!
Response :
1
---
2
block_worker: https://one.devnet-0chain.net/dns
3
signature_scheme: bls0chain
4
min_submit: 50
5
min_confirmation: 50
6
confirmation_chain_length: 3
7
max_txn_query: 5
8
query_sleep_time: 5
9
# # OPTIONAL - Uncomment to use/ Add more if you want
10
# preferred_blobbers:
11
# - http://one.devnet-0chain.net:31051
12
# - http://one.devnet-0chain.net:31052
Copied!

Change ZWallet network

  1. 1.
    Open the config.yaml file located at $HOME/.zcn path of your system. The config.yaml file contents should be similar to the code snippet below :
1
---
2
block_worker: https://one.devnet-0chain.net/dns
3
signature_scheme: bls0chain
4
min_submit: 50
5
min_confirmation: 50
6
confirmation_chain_length: 3
7
max_txn_query: 5
8
query_sleep_time: 5
9
# # OPTIONAL - Uncomment to use/ Add more if you want
10
# preferred_blobbers:
11
# - http://one.devnet-0chain.net:31051
12
# - http://one.devnet-0chain.net:31052
13
# - http://one.devnet-0chain.net:31053
Copied!
Zwallet connects to the 0Chain network using the block_worker field. These network details are automatically fetched from the blockWorker's network API. Preferred Blobbers are also present which you can uncomment for using specified storage providers for handling your files.
2. Change the block_worker field for the desired network. In this case we will change it to beta.0chain.net. After changes it should look similar to the file below:
1
---
2
block_worker: https://beta.0chain.net/dns
3
signature_scheme: bls0chain
4
min_submit: 50
5
min_confirmation: 50
6
confirmation_chain_length: 3
7
max_txn_query: 5
8
query_sleep_time: 5
9
# # OPTIONAL - Uncomment to use/ Add more if you want
10
# preferred_blobbers:
11
# - http://beta.0chain.net:31051
12
# - http://beta.0chain.net:31052
13
# - http://beta.0chain.net:31053
Copied!

Starting ZWallet

Start the Zbox by navigating back to ZWalletcli directory using
1
cd zwalletcli
Copied!
and type
1
./zwallet
Copied!
On a successful run you will see a help section like this:
1
Use Zwallet to store, send and execute smart contract on 0Chain platform.
2
Complete documentation is available at https://0chain.ne t
3
4
Usage:
5
zwallet [command]
6
7
Available Commands:
8
createmswallet create multisig wallet
9
faucet Faucet smart contract
10
getbalance Get balance from sharders
11
getblobbers Get registered blobbers from sharders
12
getid Get Miner or Sharder ID from its URL
13
getlockedtokens Get locked tokens
14
help Help about any command
15
lock Lock tokens
16
lockconfig Get lock configuration
17
ls-miners Get list of all active miners fro Miner SC
18
ls-sharders Get list of all active sharders fro Miner SC
19
mn-config Get miner SC global info.
20
mn-info Get miner/sharder info from Miner SC.
21
mn-lock Add miner/sharder stake.
22
mn-pool-info Get miner/sharder pool info from Miner SC.
23
mn-unlock Unlock miner/sharder stake.
24
mn-update-settings Change miner/sharder settings in Miner SC.
25
mn-user-info Get miner/sharder user pools info from Miner SC.
26
recoverwallet Recover wallet
27
register Registers the wallet with the blockchain
28
send Send ZCN tokens to another wallet
29
unlock Unlock tokens
30
verify verify transaction
31
version Prints version information
32
vp-add Add a vesting pool
33
vp-config Check out vesting pool configurations.
34
vp-delete Delete a vesting pool
35
vp-info Check out vesting pool information.
36
vp-list Check out vesting pools list.
37
vp-stop Stop vesting for one of destinations and unlock tokens not vested
38
vp-trigger Trigger a vesting pool work.
39
vp-unlock Unlock tokens of a vesting pool
40
41
Flags:
42
--config string config file (default is config.yaml)
43
--configDir string configuration directory (default is $HOME/.zcn)
44
-h, --help help for zwallet
45
--network string network file to overwrite the network details (if req uired, default is network.yaml)
46
--verbose prints sdk log in stderr (default false)
47
--wallet string wallet file (default is wallet.json)
48
49
Use "zwallet [command] --help" for more information about a command.
Copied!

Creating a Wallet

As you can see from the help menu, ZWallet CLI provides a long list of commands to use. Lets begin with creation of wallet on 0Chain decentralized network.
For creating a wallet using ZWallet. Simply run any zwallet command and it will create a wallet if none exist yet.
Here is a sample with faucet command which will create a wallet with test tokens at default location~/.zcn/wallet.json
1
./zwallet faucet --methodName pour --input "new wallet"
Copied!
Verify the content of wallet using cat command:
1
cat ~/.zcn/wallet.json
Copied!

Checking the wallet balance

To check whether the wallet is successfully created, verify the token balance in ZWallet using
1
./zwallet getbalance
Copied!
Note that by default ZWallet checks balance for the wallet specified in wallet.json file located in the zcn folder in linux home directory.
Successful Response for ./zwallet getbalance command:
1
Balance: 1 (1.17 USD)
2
Copied!

Getting tokens into the wallet

If getting Get balance failed.error when running ./zwallet getbalance command. Run the ./zwallet faucet --methodName pour --input "{Pay day}" command and then check the balance again.
The faucet command will get test tokens into the wallet for transactional purposes and make the wallet usable. Successful Response of the faucetcommand:
1
Execute faucet smart contract success
Copied!
Now you have a wallet with available ZCN tokens, which can be used with 0chain blockchain and decentralized storage services.

Zwallet Operations

Global Parameters

zwallet can accept the following global parameters to override default configuration and can be used with any command.
1
Flags:
2
--config string config file (default is config.yaml)
3
--configDir string configuration directory (default is $HOME/.zcn)
4
-h, --help help for zwallet
5
--network string network file to overwrite the network details (if required, default is network.yaml)
6
--verbose prints sdk log in stderr (default false)
7
--wallet string wallet file (default is wallet.json)
8
9
Copied!
The --network and --config flags are used to specify yaml file for network configuration used by zbox, by default files are stored in .zcn directory are used.
Global specifiers like --verbose provide additional details as to what the particular Zbox command is doing.
Sample Command:
1
./zwallet <command> --verbose
Copied!
*It is recommended to use --verbose by default with all ZWallet commands as it helps provide level of detail that can be helpful for troubleshooting problems.
Lastly, the global wallet specifiers-wallet are useful when you are using multiple wallets and want to specify a second wallet.
Sample Command:
1
./zwallet <command> --wallet wallet2.json
Copied!

Creating a MultiSignature Wallet

For creating a multi signature wallet you need to make use of ./zwallet createmswallet command. Parameters/ flags which can be added with the command syntax can be viewed using ./zwallet createmswallet --help
Output for ./zwallet createmswallet --help command:
1
Usage:
2
zwallet createmswallet [flags]
3
4
Flags:
5
-h, --help help for createmswallet
6
--numsigners int Number of signers
7
--testn test Multiwallet with all signers. Default is false
8
--threshold int Threshold number of signers required to sign the propos al
9
10
Global Flags:
11
--config string config file (default is config.yaml)
12
--configDir string configuration directory (default is $HOME/.zcn)
13
--network string network file to overwrite the network details (if req uired, default is network.yaml)
14
--verbose prints sdk log in stderr (default false)
15
--wallet string wallet file (default is wallet.json)
16
Copied!
As the ./zwallet createmswalletcommand demonstrates in the help section above, it will create a ms (multi-signature) wallet using mandatory flags numsigners threshold .testn flag can also be used but by default it is set to false.
  • numsigners flag in the createmswallet command specify the the number of accounts that can sign the vote for the transaction. The variable passed is an integer
  • threshold flag in the createmswallet command specify the minimum number of votes required for the transaction to pass. The variable passed is an integer.
  • testn is an optional flag and if set to true will test ending votes from all signer accounts. When not specified it is set to false and votes from only threshold number of signer accounts is used.
So if you want to create a multi-signature wallet with 4 signers and a minimum votes transaction pass value of 2. The sample command would be:
1
./zwallet createmswallet --numsigners 4 --threshold 2
Copied!
In Successful Response, ZWallet will automatically create a wallet, a read pool and register 4 signer wallets.
The wallet information will be stored in wallet.json located in the zcn folder in linux home directory.
Test ZCN tokens will be automatically added into these wallets and vote testing for 2(threshold value) signer accounts is done. You can specify testing for all 4 signer accounts by specifying the testn flag and setting it to true.
Output:
1
No wallet in path /root/.zcn/wallet.json found. Creating wallet...
2
ZCN wallet created!!
3
Creating related read pool for storage smart-contract...
4
Read pool created successfully
5
registering 5 wallets
6
7
Successfully registered group wallet
8
Successfully registered signer wallet number 1
9
Successfully registered signer wallet number 2
10
Successfully registered signer wallet number 3
11
Successfully registered signer wallet number 4
12
13
14
Multisig wallet SC registration requested. verifying status
15
MultisigSC wallet SC registration request success
16
17
18
testing voteRecipient test wallet:
19
{"client_id":"baaf3b0528829b321dd958bd3dc22236144f8df8ce846a2c9a16e0dd14656864","client_key":"b535aededba36af2ea2b7f8f6a51a0d98ab190c4d7527d268e0c659f02b00424e595a2dc1a2cfa5dd4a80d3048ba1c6c881db6d95169d0df62d1896f8296bb1e","keys":[{"public_key":"b535aededba36af2ea2b7f8f6a51a0d98ab190c4d7527d268e0c659f02b00424e595a2dc1a2cfa5dd4a80d3048ba1c6c881db6d95169d0df62d1896f8296bb1e","private_key":"e9b1ac2a672ec583e8b8da5abbbf4fc1177521aea7f4c394647fa95288c5720b"}],"mnemonics":"another december aim miracle umbrella liar wide polar fitness little minute brown error easy cloud super symbol orient mammal relief feel lake blue street","version":"1.0","date_created":"2021-05-05 22:32:34.195573161 +0000 UTC m=+8.244895754"}
20
21
Activating group wallet by pouring test tokens
22
submitted transaction
23
Pour request success
24
Balance: 1
25
26
Activating signer wallet 1 by pouring test tokens
27
submitted transaction
28
Pour request success
29
Balance: 1
30
31
Activating signer wallet 2 by pouring test tokens
32
submitted transaction
33
Pour request success
34
Balance: 1
35
36
Activating signer wallet 3 by pouring test tokens
37
submitted transaction
38
Pour request success
39
Balance: 1
40
41
Activating signer wallet 4 by pouring test tokens
42
submitted transaction
43
Pour request success
44
45
Balance: 1
46
Checking balance on group wallet with clientID ddc02106fb9de5efd792c6a95c300205890147b37226dae054bc01f5f2308b77 before the vote
47
Balance: 1
48
49
Created Vote#1 from signer #0:
50
{"proposal_id":"testing MSVoting","transfer":{"from":"ddc02106fb9de5efd792c6a95c300205890147b37226dae054bc01f5f2308b77","to":"baaf3b0528829b321dd958bd3dc22236144f8df8ce846a2c9a16e0dd14656864","amount":1000000000},"signature":"10a33a7e511ec9a67a194cccb99e7fa428c914a1d9caa34ebedddb79d9ed7c04"}
51
52
Multisig Vote registration requested. verifying status
53
Multisig Voting success
54
55
Created Vote#2 from signer #1:
56
{"proposal_id":"testing MSVoting","transfer":{"from":"ddc02106fb9de5efd792c6a95c300205890147b37226dae054bc01f5f2308b77","to":"baaf3b0528829b321dd958bd3dc22236144f8df8ce846a2c9a16e0dd14656864","amount":1000000000},"signature":"bc59d6148a8a7557aa8a53354ada3d82cea82115b83c7040b4eed72b92900a85"}
57
58
Multisig Vote registration requested. verifying status
59
Multisig Voting success
60
61
62
Checking balance on group wallet ddc02106fb9de5efd792c6a95c300205890147b37226dae054bc01f5f2308b77 after the vote
63
Balance: 0.9
64
65
Checking balance on recipient wallet after the vote
66
Balance: 0.1
67
68
Creating and testing a multisig wallet is successful!
69
Copied!

Creating a Second Wallet

The wallet by default gets saved at the location~/.zcn/wallet.json. To create a second or multiple wallets wallet you must use the --wallet flag and create a new json file. Here is a command for creating a second wallet with some test tokens. The configuration for second wallet is saved in new_wallet.json file:
1
./zwallet faucet --methodName pour --input "new wallet" --wallet new_wallet.json
Copied!
Response:
1
No wallet in path /root/.zcn/new_wallet.json found. Creating wallet...
2
ZCN wallet created!!
3
Creating related read pool for storage smart-contract...
4
Read pool created successfully
5
Execute faucet smart contract success with txn : 802db9633fc77417d4adc421209a0a8d9967886222b01bb0f4a7f4c754de5d6c
Copied!
The second wallet will also be saved in .zcn directory. To check its contents use:
1
cat ~/.zcn/new_wallet.json
Copied!
Sample Response:
1
{"client_id":"0a145e6df5d9c0e8307bdec84a73b01e9ea0dc10a8c09128253935d7a10d6f13","client_key":"272b168ed806d09b2937f90185093d5c68130479f3afeb7c5ec91394d011ac1289adcf093a2c3121de5f0549e6863a8f946758367847bb27fdb93e48d505fa94","keys":[{"public_key":"272b168ed806d09b2937f90185093d5c68130479f3afeb7c5ec91394d011ac1289adcf093a2c3121de5f0549e6863a8f946758367847bb27fdb93e48d505fa94","private_key":"e699ba95136a6cffe8cd4e8e008ef5e76e4d6cadcd8f9399da407585bfaedf10"}],"mnemonics":"mask whip cotton crunch motor range solar path impose race certain pole swim decide cross donkey dove source essay update rebuild lesson chicken income","version":"1.0","date_created":"2021-05-17 20:27:27.110948873 +0000 UTC m=+0.137667608"}
Copied!

Recovering a wallet

./zwallet recoverwallet command can be used to restore your lost wallet or loading your wallet on a different computer.
Parameters required for recovering your wallet can be viewed using ./zwallet recoverwallet --help command
Here are the Parameters
1
Usage:
2
zwallet recoverwallet [flags]
3
4
Flags:
5
-h, --help help for recoverwallet
6
--mnemonic string mnemonic
7
Copied!
A mnemonic string is required to recover and recreate your wallet. The mnemonic string is generated when you have first created your wallet and it is stored by default in wallet.json file located in .zcn directory until specified.
It is advised to safely store and copy the mnemonic string at some other location in your computer as it is used for many ZWallet functionaities.
For demonstrating the recover wallet functionality, we will find the mnemonic string for the wallet on UserA computer and recover it on UserB computer.
To find mnemonic in wallet file use cat command with the wallet file name on user A computer:
1
cat ~/.zcn/wallet.json
Copied!
Response:
1
{"client_id":"26e5b70fcba3f72a475ef1dbc66e454d3b458b950d62c6ec218cc3425e3b621f","client_key":"9a463e83d67586b661187ee757187d17623205764f2a7584b7aa1383a4159c0f158090b0168ad6e3b7eaf7e5fe107eb4e71d280dc46c60d8b2b21d4eae8e711f","keys":[{"public_key":"9a463e83d67586b661187ee757187d17623205764f2a7584b7aa1383a4159c0f158090b0168ad6e3b7eaf7e5fe107eb4e71d280dc46c60d8b2b21d4eae8e711f","private_key":"4bf7ee2873b0a0c29766a72bc5ccc74f167159266c67556fa0ca87286f7a2218"}],"mnemonics":"penalty sound feed follow come paddle rule brand shift embrace olive expire bundle join churn actress chief venue picnic old tower cover lake zebra","version":"1.0","date_created":"2021-05-11 18:22:52.339539274 +0000 UTC m=+0.075234202"}[email protected]:~/zboxcli/zwalletcli#
2
Copied!
Here mnemonics string is penalty sound feed follow come paddle rule brand shift embrace olive expire bundle join churn actress chief venue picnic old tower cover lake zebra
Now let's recover the wallet by using this mnemonic on UserB computer. The name we will specify for the wallet would be recovered_wallet.json
Sample Command:
1
./zwallet recoverwallet --wallet recovered_wallet.json --mnemonic "penalty sound feed follow come paddle rule brand shift embrace olive expire bundle join churn actress chief venue picnic old tower cover lake zebra"
Copied!
Response:
1
No wallet in path /root/.zcn/recovered_wallet.json found. Creating wallet...
2
ZCN wallet created!!
3
Creating related read pool for storage smart-contract...
4
Read pool created successfully
5
Wallet recovered!!
Copied!
Verify whether it is the same wallet using:
1
cat ~/.zcn/recovered_wallet.json
Copied!
The contents in the json file should be same as User A computer .

Registering a wallet `

./zwallet register command can be used to register a wallet to a blockchain in case of a blockchain network reset or change. The wallet which gets registered on the new blockchain network by default is the wallet located in ~/.zcn/wallet.json file
Command:
1
./zwallet register
Copied!
Command for registering a specific or 2nd wallet:
1
./zwallet register --wallet wallet2.json
Copied!
Response:
1
Wallet registered
Copied!

Sending tokens to another wallet

./zwallet send command is used to transfer tokens from one wallet to another. Parameters for send command can be viewed using ./zwallet send --help.
1
Usage:
2
zwallet send [flags]
3
4
Flags:
5
--desc string Description
6
--fee float Transaction Fee
7
-h, --help help for send
8
--to_client_id string to_client_id
9
--tokens float Token to send
10
Copied!
Here with --desc flag the reason for sending tokens can be specified,--fee flag specifies the cost to send the certain amount of tokens(the fee is specified by the miner and gets deducted from senders wallet), client id for the reciever wallet is required and can be fetched by viewing the contents of their wallet.json file. Lastly number of tokens which has to be send to another wallet has to be specified.
Note: The desc, client id and tokens flag are required flags for send command. The command wont work without them.fee flag is optional.
For demonstration, let's send 0.1 tokens with a fee of 0.1 from our wallet to a specified client ID as a gift.
Before sending lets check our wallet balance using:
1
./zwallet getbalance
Copied!
Sample Response:
1
Balance: 0.6 (0.69 USD)
Copied!
By default ZWallet checks balance and send tokens from wallet specified in wallet.json file. To send tokens use:
1
./zwallet send --to_client_id 26e5b70fcba3f72a475ef1dbc66e454d3b458b950d62c6ec218cc3425e3b621f --tokens .2 --desc "gift" --fee 0.1
Copied!
Response:
1
Send tokens success
Copied!
To verify whether tokens are sent to the receiver, check the wallet balance. The tokens specified in send command and transaction fee should be deducted from your wallet balance.
1
Balance: 0.4 (0.45199999999999996 USD)
Copied!
Note: To use a different wallet as a sender, use --wallet global parameter.
1
./zwallet send --to_client_id 26e5b70fcba3f72a475ef1dbc66e454d3b458b950d62c6ec218cc3425e3b621f --tokens .1 --desc "gift" --fee 0.1 --wallet another_wallet.json
Copied!

Locking Tokens using ZWallet

ZWallet allows locking of tokens for a period of time to earn interest as additional ZCN tokens. The locking of tokens happens through an Interest Pool self executing contract.
There is a minimum amount of tokens which has to be locked for a minimum lock period for earning interest. The configuration for locking tokens can be viewed using the ./zwallet lockconfigcommand.

Getting lock config

./zwallet lockconfig shows the global configuration for locking tokens for interest such as minimum token and minimum lock period (duration).
Command:
1
./zwallet lockconfig
Copied!
Response:
1
Configuration:
2
{"ID":"cf8d0df9bd8cc637a4ff4e792ffe3686da6220c45f0e1103baa609f3f1751ef4","simple_global_node":{"max_mint":40000000000000000,"total_minted":6747913274207,"min_lock":10,"apr":0.1},"min_lock_period":60000000000}
3
Copied!

Locking tokens

./zwallet lock command is used to lock tokens for interest. The tokens are deducted from the wallet balance and are available back in the wallet by unlocking. Unlocking of tokens is only possible when the lock duration has passed.
Parameters for lock command can be viewed using ./zwallet lock --help
1
Usage:
2
zwallet lock [flags]
3
4
Flags:
5
--durationHr int Duration Hours to lock
6
--durationMin int Duration Mins to lock
7
--fee float Transaction Fee
8
-h, --help help for lock
9
--tokens float Number to tokens to lock
10
Copied!
Here, lock duration for locking tokens in hours or minutes are required and has to be specified. Transaction fee is optional flag but can be specified depending upon the miner. Some might charge a minimum transaction fee. Lastly number of tokens to lock is a required flag.
The following command locks 0.2 token for 5 minutes with a transaction fee of 0.1.
1
./zwallet lock --durationHr 0 --durationMin 5 --tokens 0.2 --fee 0.1
Copied!
Output:
1
Tokens (0.200000) locked successfully
Copied!
Check your wallet balance using
1
./zwallet getbalance
Copied!
On a successful lock, 0.3 ZCN tokens should be deducted from your wallet.
To understand better how the tokens are locked for earning interest you can check our video demonstration here.

Getting locked tokens

./zbox getlockedtokens command is used to know the amount of locked tokens and how much interest is gained over time through locking.
Command:
1
./zwallet getlockedtokens
Copied!
Response:
1
Locked tokens:
2
{"stats":[{"pool_id":"121053df2f2508a640111b338d4d3b18914c7a27f864b74c7fd86820d0638527","start_time":1620859478,"duration":300000000000,"time_left":-745398808346,"locked":false,"apr":0.1,"tokens_earned":1897,"balance":2000000000}]}
3
Copied!
The response will specify whether tokens are locked through a locked variable which uses a boolean. time_left variable has a negative value which means lock duration has not passed. Tokens earned through locking and locked tokens balance is also specified.
Note: Don't forget to copypool_id at a safer place as it is required to unlock tokens at a later time.

Unlocking tokens

Once the lock duration has passed ,you can unlock tokens using ./zwallet unlockcommand. Parameters for unlock command can be viewed using ./zwallet unlock --help.
1
Flags:
2
--fee float Transaction Fee
3
-h, --help help for unlock
4
--pool_id string Pool ID - hash of the locked transaction
5
Copied!
Here,--pool_id is a required flag whereas --fee flag is optional. For demonstration lets unlock the tokens we locked in the lock tokens section. The pool_id can be viewed using the./zwallet getlockedtokenscommand.
To unlock tokens use:
1
./zwallet unlock --pool_id 121053df2f2508a640111b338d4d3b18914c7a27f864b74c7fd86820d0638527
Copied!
Response:
1
Unlock tokens success
Copied!
On a successful unlock, your wallet balance will include the tokens you earned as interest plus the amount of tokens you locked initially.

Staking on miners and sharders

0chain miner smart contract allows staking on the miner and sharder nodes to validate transactions and earn rewards. To start staking on miner and sharder nodes, miner and sharder ID's are required which can be fetched using below commands.

Listing all miners

./zwallet ls-miners list the miners retrieved using the Miner smart contract. Parameters can be viewed using ./zwallet ls-miners --help flag.
1
Get list of all active miners from Miner SC
2
3
Usage:
4
zwallet ls-miners [flags]
5
6
Flags:
7
-h, --help help for ls-miners
8
--json as JSON
9
Copied!
--jsonflag can be passed to retrieve miners as JSON data.
Command:
1
./zwallet ls-miners
Copied!
Sample Output:
1
- ID: cdb9b5a29cb5f48b350481694c4645c2db24500e3af210e22e2d10477a68bad2
2
- Host: one.devnet-0chain.net
3
- Port: 31203
4
- ID: 3d9a10dac6fb3903d4a5283a42ae07b29d8e5d228afcce9bfc14e3e9dbc82748
5
- Host: one.devnet-0chain.net
6
- Port: 31201
7
- ID: aaa721d5fbf4ca83e20c8c40874ebcb144b86f57173633ff1702968677c2fa98
8
- Host: one.devnet-0chain.net
9
- Port: 31202
Copied!

Listing all sharders

./zwallet ls-sharders list the sharders retrieved using the Miner smart contract. Parameters can be viewed using ./zwallet ls-sharders --help flag.
1
Get list of all active sharders from Miner SC
2
3
Usage:
4
zwallet ls-sharders [flags]
5
6
Flags:
7
--all include all registered sharders
8
-h, --help help for ls-sharders
9
--json as JSON
10
11
Copied!
--all flag can be passed to retrieve all the available sharders where as --jsonflag will retrieve sharders as JSON data.
Command:
1
./zwallet ls-sharders
Copied!
Sample output:
1
MagicBlock Sharders
2
ID: 5421a8d0c9302af3cc79ac7e79d0c35eb09e7a25cb555fb3d6de9ab9dfcbc21c
3
- N2NHost: five.devnet-0chain.net
4
- Host: five.devnet-0chain.net
5
- Port: 31102
6
ID: d438037cd4ca7acf3d7e40823a661a747a3fe1724921a98b4d90657d5a056195
7
- N2NHost: five.devnet-0chain.net
8
- Host: five.devnet-0chain.net
9
- Port: 31101
10
Copied!

Get the staking configuration

To find out the number of delegates and the minimum and maximum tokens that can be staked, query the config using ./zwallet mn-config command.
./zwallet mn-config command displays the configuration and current requirements for staking.
Command:
1
./zwallet mn-config
Copied!
Response:
1
view_change: 0
2
max_n: 8
3
min_n: 2
4
max_s: 3
5
min_s: 1
6
t_percent: 0.51
7
k_percent: 0.75
8
last_round: 4758531
9
max_stake: 100
10
min_stake: 0
11
interest_rate: 5.55e-07
12
reward_rate: 1
13
share_ratio: 0.8
14
block_reward: 0.21
15
max_charge: 0.5
16
epoch: 15000000
17
reward_decline_rate: 0.1
18
interest_decline_rate: 0.1
19
max_mint: 4000000
20
minted: 999303.9977045408
21
max_delegates: 200
22
Copied!
According to the response the max delegates allowed are 200, where as the minimum and maximum number of tokens that can be staked are 0 and 100.
Get the miner or sharder info for staking
./zwallet mn-info command can be used to get staking info for a particular sharder or miner.
Parameters for mn-info command can be viewed using ./zwallet mn-info --help
1
Usage:
2
zwallet mn-info [flags]
3
4
Flags:
5
-h, --help help for mn-info
6
--id string miner/sharder ID to get info for
7
Copied!
Here,--id flag requires a particular miner and sharder ID which can be fetched using the ls-minersor ls-sharders command. For demonstration we are using a particular miner id fetched using ls-miners command.
Command:
1
./zwallet mn-info --id 68ed8f16e1d50e3217425b3e98fb7a39e5d7201fe4b1dccfe8477b5c54761b24
2
Copied!
Response:
1
{
2
"simple_miner":{
3
"id":"68ed8f16e1d50e3217425b3e98fb7a39e5d7201fe4b1dccfe8477b5c54761b24",
4
"n2n_host":"five.devnet-0chain.net",
5
"host":"five.devnet-0chain.net",
6
"port":31102,
7
"path":"sharder02",
8
"public_key":"458170c28496333426f9866989f7b335564d13d00f50db503275e7ec50a008031764ba5df42c20c85d76e7fe7eda43f39afdb650b8ffa9ed340e6fc50c35ae22",
9
"short_name":"localhost.s02",
10
"build_tag":"50fb047353c4c3d268c0e0ebfd8e63f1d10c6813",
11
"total_stake":0,
12
"delegate_wallet":"68ed8f16e1d50e3217425b3e98fb7a39e5d7201fe4b1dccfe8477b5c54761b24",
13
"service_charge":0.1,
14
"number_of_delegates":10,
15
"min_stake":0,
16
"max_stake":1000000000000,
17
"stat":{
18
"sharder_rewards":1160553450000000
19
},
20
"node_type":"sharder",
21
"last_health_check":1619554377
22
},
23
"pending":{
24
"01978379a586de2882638345e215baaf8382093609d910da5ac1a833e2814f6f":{
25
"stats":{
26
"delegate_id":"133807913c66ec0b4342612f23fecd1852b456152433b8380cd2abcd411d4c07",
27
"high":0,
28
"low":-1,
29
"interest_paid":0,
30
"reward_paid":0,
31
"number_rounds":0,
32
"status":"PENDING"
33
},
34
"pool":{
35
"pool":{
36
"id":"01978379a586de2882638345e215baaf8382093609d910da5ac1a833e2814f6f",
37
"balance":10000000000
38
},
39
"lock":{
40
"delete_view_change_set":false,
41
"delete_after_view_change":0,
42
"owner":"ff12c78ee4a985b4fc2ac52ec8a24e9df2bd912636da15437b0eb7707b99abf4"
43
}
44
}
45
}
46
}
47
}
Copied!

Locking a stake on a node

Staking tokens on a miner or sharder nodes helps earning additional tokens over time. Tokens locked for staking can be unlocked anytime but you have to wait for the next view change cycle.
Note: If a node becomes offline, all stake pools are automatically unlocked and tokens are returned to wallets.
Stalking tokens can be locked using the ./zwallet mn-lock command. Parameters for locking the tokens can be viewed using the ./zwallet mn-lock --help.
1
Flags:
2
-h, --help help for mn-lock
3
--id string miner/sharder ID to lock stake for
4
--tokens float tokens to lock
5
Copied!
Here, miner /sharder id with the required number of tokens to be locked are required.
Command for locking 0.2 tokens:
1
./zwallet mn-lock --id cdb9b5a29cb5f48b350481694c4645c2db24500e3af210e22e2d10477a68bad2 --tokens 0.2
Copied!
Response:
1
locked with: b488738546d84aed9d3dcb2bbe24c161bc4338638669e64e814631efd430fd85
Copied!
Note: If the locking of stakes is failing, verify the following.
  1. 1.
    Wallet has enough tokens
  2. 2.
    Node ID is valid
  3. 3.
    Node has available delegates

Getting the stake pools of a wallet

A stake pool allows multiple stakeholders (miners/sharders) to contribute to a blockchain in a manner that it increase their chances of earning staking rewards. Every stakeholder stakes tokens through its wallet in the stake pool.
To get the stake pool information of a particular wallet,./zwallet mn-user-info command can be used. Parameters for the ./zwallet mn-user-infocan be viewed using the --help tag.
1
Flags:
2
--client_id string get info for user, if empty, current user used, optional
3
-h, --help help for mn-user-info
4
--json as JSON
5
Copied!
Here, Client ID for a particular user is required which can be fetched from the wallet located in the .zcn directory. As mentioned above --client_id flag is optional and if you do not specify a particular wallet client_id. It will find the stake pool related to wallet config in default wallet.json file.
Command:
1
./zwallet mn-user-info
Copied!
Response:
1
- node: 110b07984a6592ae67f1830366f47c835f6f5f262be19ee4aedd1b9acf870aee (miner)
2
- pool_id: 77f7006f3ef89b5bc88016fbf9bc636cdb9c38425fa0e88940e4f99ddcf5be57
3
balance: 0.2
4
interests paid: 0.000000444
5
rewards paid: 59.5728
6
status: active
7
stake %: 100 %
8
Copied!
On a successful response, you will see the staked miner/sharder nodes and the amount of tokens locked with that particular wallet. The response output can also be formatted in JSON data using the --json flag.

Getting the stake pool info

./zwallet mn-pool-info command can be used to get stake pool info for a particular miner/sharder. Parameters can be viewed using the ./zwallet mn-pool-info --help
1
Flags:
2
-h, --help help for mn-pool-info
3
--id string miner/sharder ID to get info for
4
--pool_id string pool ID to get info for
5
Copied!
--id flag requires miner/sharder ID which can be fetched using ls-miners or ls-sharders command,pool_id is generated when you lock stake tokens for a miner/sharder node, you can copy the pool_id from the response text or can view it using mn-user-info command.
Command:
1
./zwallet mn-pool-info --id 110b07984a6592ae67f1830366f47c835f6f5f262be19ee4aedd1b9acf870aee --pool_id 77f7006f3ef89b5bc88016fbf9bc636cdb9c38425fa0e88940e4f99ddcf5be57
Copied!
Formatted Response:
1
{
2
"stats":{
3
"delegate_id":"822700aa95b6719281999c66d49764e6a258ff3bf259b83a62353615fd904829",
4
"high":0,
5
"low":-1,
6
"interest_paid":0,
7
"reward_paid":0,
8
"number_rounds":0,
9
"status":"PENDING"
10
},
11
"pool":{
12
"pool":{
13
"id":"b488738546d84aed9d3dcb2bbe24c161bc4338638669e64e814631efd430fd85",
14
"balance":10000000000
15
},
16
"lock":{
17
"delete_view_change_set":false,
18
"delete_after_view_change":0,
19
"owner":"822700aa95b6719281999c66d49764e6a258ff3bf259b83a62353615fd904829"
20
}
21
}
22
}
Copied!

Unlocking a stake on node

Staking tokens can be unlocked using the ./zwallet mn-unlock command. Parameters for locking the tokens can be viewed using the ./zwallet mn-unlock --help
1
Usage:
2
zwallet mn-unlock [flags]
3
4
Flags:
5
-h, --help help for mn-unlock
6
--id string miner/sharder ID to unlock pool of
7
--pool_id string pool ID to unlock
Copied!
Here, miner /sharder id with the pool ID to unlock the stake are required. Miner/sharder id can be fetched using ls-miners or ls-sharders command whereaspool_id is generated when you lock stake tokens for a miner/sharder node ,you can view it using mn-user-info command.
Command for unlocking would be:
1
./zwallet mn-unlock --id 110b07984a6592ae67f1830366f47c835f6f5f262be19ee4aedd1b9acf870aee --pool_id 77f7006f3ef89b5bc88016fbf9bc636cdb9c38425fa0e88940e4f99ddcf5be57
Copied!
Output:
1
tokens will be unlocked next VC
Copied!
Note: Tokens are released on the next view change cycle or at the next reward round.

Updating staking config of a node

./zwallet mn-update-settings command is used to update the staking config of a node. Parameters for the command can be viewed using --help flag.
1
Flags:
2
-h, --help help for mn-update-settings
3
--id string miner/sharder ID to update
4
--max_stake float max stake allowed
5
--min_stake float min stake allowed
6
--num_delegates int max number of delegate pools
7
Copied!
Miner/Sharder ID of the node is a required flag and can be fetched using ls-minersor ls-sharders command. Variables that can be updated are max stake, min stake and number of delegate pools.
Before updating the configuration lets get the default staking configuration for miner/sharder node using :
1
./zwallet mn-info --id 110b07984a6592ae67f1830366f47c835f6f5f262be19ee4aedd1b9acf870aee
Copied!
Response:
1
{
2
"simple_miner":{
3
"id":"110b07984a6592ae67f1830366f47c835f6f5f262be19ee4aedd1b9acf870aee",
4
"n2n_host":"five.devnet-0chain.net",
5
"host":"five.devnet-0chain.net",
6
"port":31202,
7
"path":"miner02",
8
"public_key":"7f7a0515ae68eadee6eac5915519802911c7c7341d1ef23d913728aed47dc8090548a56031732d16916e203c4e41c2a32d022fe56758ba3956cc73b112f0961c",
9
"short_name":"localhost.m02",
10
"build_tag":"40058cb8b6aeeb95e61229702f29de4c7118ebaf",
11
"total_stake":0,
12
"delegate_wallet":"110b07984a6592ae67f1830366f47c835f6f5f262be19ee4aedd1b9acf870aee",
13
"service_charge":0.1,
14
"number_of_delegates":10,
15
"min_stake":0,
16
"max_stake":1000000000000,
17
"stat":{
18
"generator_rewards":187795440000000
19
},
20
"node_type":"miner",
21
"last_health_check":1620947267
22
}
23
}
Copied!
In the above configuration min stake, max stake, number of delegate pools are 0,1000000000000 and 10 respectively. Lets update the miner/sharder node for 25 delegate pools, min and max stake for 1000,100000 using mn-update-settings.
1
./zwallet mn-update-settings --id 110b07984a6592ae67f1830366f47c835f6f5f262be19ee4aedd1b9acf870aee --max_stake 100000 --min_stake 1000 --num_delegates 5
Copied!
Note: Staking config can only be updated by the node's delegate wallet.

Vesting tokens using ZWallet

Vesting pool allows the transfer of locked tokens to desired destination after a certain period of time. For every vesting pool configuration there is a minimum lock demand, maximum number of transfers, minimum and maximum duration of locking.

Checking vesting pool config

ZWallet allows vesting of tokens through a Vesting Pool smart contract config which can be viewed using vp-config command.
Sample Command:
1
./zwallet vp-config
Copied!
Sample Response:
1
min_lock: 0.01
2
min_duration: 2m0s
3
max_duration: 2h0m0s
4
max_destinations: 3
5
max_description_length: 20
Copied!
In the above response you can see all the constraints(lock demand, lock duration, and transfer limits) for a particular ZWallet vesting pool config.

Creating a vesting pool

Creating a new vesting pool through ZWallet can be done using the ./zwallet vp-add command which require specific parameters. To view parameters use the --helpflag.
1
Add a vesting pool.
2
3
Usage:
4
zwallet vp-add [flags]
5
6
Flags:
7
--d strings list of colon separated 'destination:amount' values,
8
use -d flag many times to provide few destinations, for example 'dst:1.2'
9
--description string pool description, optional
10
--duration duration vesting duration till end, required
11
--fee float transaction fee, optional
12
-h, --help help for vp-add
13
--lock float lock tokens for the pool, optional
14
--start_time int start_time, Unix seconds, default is now
15
Copied!
Here, descriptions for the vesting pool is optional ,while the --ddestination flag by which certain amount of tokens gets transferred to receiver's wallet requires values in the form of wallet client_id: amount of tokens. The destination--dparameter has to be repeated for transferring to more than one destination whereas lock duration and minimum locked tokens for the vesting pool is required and has to match specified vesting pool config limit. Also, the number of tokens locked should match or more than the sum of destination amounts specified to create a read pool.
Here is a sample command for transferring 1 token to a single destination wallet after 10 minutes:
1
./zwallet vp-add --duration 10m --d 48965bc485e6d42c02c2d53548ad90b79cc9cb2b26f6cfd3331bb0e5f10c7a14:1 --lock 2
Copied!
Command for transferring tokens to multiple destination wallets after 5minutes:
1
./zwallet vp-add --duration 5m --lock 5 --d af6c894e2f5dd76b6df1329e924b4177e58692d165090f52b0cc11c639b3bb92:1 --d 8c4e3623964442e7ff9b9f52e5e7a5d8248a85856cf369f71149b7b922653396:2
Copied!
Response:
1
Vesting pool added successfully: 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:3464e71dd1c6e03ce4c81eb793dec97b36f28ff63380c3923db482280b302c6e
Copied!
On a successful response the pool id is generated in form of a vesting pool. The pool by default will transfer the tokens after 10 minutes from the time it is created. If you want the transfer at a later time you have to specify the --start_time flag.
Note: The destination wallets should be registered on the blockchain before creating a read pool.

Checking vesting pool list for a wallet

./zwallet vp-list command is used to display the vesting pool list for a given wallet. Parameters can be viewed using --help flag.
1
Usage:
2
zwallet vp-list [flags]
3
4
Flags:
5
--client_id string client_id, default is current client
6
-h, --help help for vp-list
7
8
Copied!
Here, client_id for a particular wallet can be fetched using cat command. If not specified it will use the wallet at ~/.zcn/wallet.json
Sample Command:
1
./zwallet vp-list
Copied!
Sample Output:
1
2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:31057638b65c3a8334c11ba3035e36316de046869f39c5f28a14a05df78edaa1
2
- 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:3464e71dd1c6e03ce4c81eb793dec97b36f28ff63380c3923db482280b302c6e
3
- 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:6021c16f7dcfd1926cce021e2f3af419509a56e32f6025514125528596c34a3c
4
Copied!
Note: There can be empty finalized block error during the execution of vp-info command. Check the troubleshooting section for solution.

Checking vesting pool info

./zwallet vp-info can be used to view information for a particular vesting pool. Parameters can be viewed using the ./zwallet vp-info --help
1
Usage:
2
zwallet vp-info [flags]
3
4
Flags:
5
-h, --help help for vp-info
6
--pool_id string pool identifier
7
8
Copied!
Here, pool_id is required to fetch information for a particular vesting pool. Users can view pool_id by using the vp-list command.
Sample command:
1
./zwallet vp-info --pool_id 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:d16baced7162edb84536c95aa8de895a9494bf39a43a4f591350db98f0329886
2
Copied!
Response:
1
pool_id:
2
2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:d16baced7162edb84536c95aa8de895a9494bf39a43a4f591350db98f0329886
3
balance: 5
4
can unlock: 2 (excess)
5
sent: 0 (real value)
6
pending: 3 (not sent, real value)
7
vested: 3 (virtual, time based value)
8
description:
9
start_time: 2021-05-08 00:06:00 +1000 AEST
10
expire_at: 2021-05-08 00:11:00 +1000 AEST
11
destinations:
12
- id: af6c894e2f5dd76b6df1329e924b4177e58692d165090f52b0cc11c639b3bb92
13
vesting: 1
14
can unlock: 1 (virtual, time based value)
15
sent: 0 (real value)
16
pending: 1 (not sent, real value)
17
vested: 1 (virtual, time based value)
18
last unlock: 2021-05-08 00:06:00 +1000 AEST
19
- id: 8c4e3623964442e7ff9b9f52e5e7a5d8248a85856cf369f71149b7b922653396
20
vesting: 2
21
can unlock: 2 (virtual, time based value)
22
sent: 0 (real value)
23
pending: 2 (not sent, real value)
24
vested: 2 (virtual, time based value)
25
last unlock: 2021-05-08 00:06:00 +1000 AEST
26
client_id: e6bca3f65f3ac102cd972ee2a85c4ee8318fd63cce91f14a76e81d024451213e
Copied!
In the response, you will see the total tokens locked (5) and total tokens that can be unlocked (tokens that are not vested). According to the above response three tokens are vested and still has to be transferred(pending) to two different destination wallets after expiration time.
Note: There can be empty finalized block error during the execution of vp-info command. Check the troubleshooting section for resolution.

Triggering a vesting pool

./zwallet vp-trigger command is used to instantly transfer vesting tokens to destination wallets before expiration time. Parameters can be viewed using the ./zwallet vp-trigger --help command.
1
Usage:
2
zwallet vp-trigger [flags]
3
4
Flags:
5
-h, --help help for vp-trigger
6
--pool_id string pool identifier, required
7
Copied!
Here, pool_id is required to trigger a particular vesting pool, pool_id can be viewed using the vp-list command. To demonstrate the vp-triggerfunctionality we will consider a vesting pool which has some vested tokens to transfer to destination wallets. Here is vp-infoof a vesting pool before triggering.
1
pool_id: 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:31057638b65c3a8334c11ba3035e36316de046869f39c5f28a14a05df78edaa1
2
balance: 2
3
can unlock: 1 (excess)
4
sent: 0 (real value)
5
pending: 1 (not sent, real value)
6
vested: 0.2166666666 (virtual, time based value)
7
description:
8
start_time: 2021-05-18 21:15:16 +0000 UTC
9
expire_at: 2021-05-18 21:25:16 +0000 UTC
10
destinations:
11
- id: 48965bc485e6d42c02c2d53548ad90b79cc9cb2b26f6cfd3331bb0e5f10c7a14
12
vesting: 1
13
can unlock: 0.2166666666 (virtual, time based value)
14
sent: 0 (real value)
15
pending: 1 (not sent, real value)
16
vested: 0.2166666666 (virtual, time based value)
17
last unlock: 2021-05-18 21:15:16 +0000 UTC
18
Copied!
As you can see, 1 token will be transferred to the destination after expire time . Lets use the vp-triggeron this pool and transfer the tokens right away.
Command:
1
./zwallet vp-trigger --pool_id 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:31057638b65c3a8334c11ba3035e36316de046869f39c5f28a14a05df78edaa1
Copied!
Response:
1
Vesting triggered successfully.
Copied!
Verify by using the vp-info command the Vesting pool info should not show tokens in sent.
1
pool_id: 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:31057638b65c3a8334c11ba3035e36316de046869f39c5f28a14a05df78edaa1
2
balance: 1.3816666667
3
can unlock: 1 (excess)
4
sent: 0.6183333333 (real value)
5
pending: 0.3816666667 (not sent, real value)
6
vested: 0.7266666666 (virtual, time based value)
7
description:
8
start_time: 2021-05-18 21:15:16 +0000 UTC
9
expire_at: 2021-05-18 21:25:16 +0000 UTC
10
destinations:
11
- id: 48965bc485e6d42c02c2d53548ad90b79cc9cb2b26f6cfd3331bb0e5f10c7a14
12
vesting: 1
13
can unlock: 0.1083333333 (virtual, time based value)
14
sent: 0.6183333333 (real value)
15
pending: 0.3816666667 (not sent, real value)
16
vested: 0.7266666666 (virtual, time based value)
17
last unlock: 2021-05-18 21:21:27 +0000 UTC
18
Copied!

Unlocking tokens of a vesting pool

.zwallet vp-unlock command can be used to unlock tokens from a vesting pool by both the owner and destination wallets. Note that owner can only unlock tokens which are not yet vested while receiver can only unlock vested tokens.
Parameters can be viewed using the ./zwallet vp-unlock --help.
1
Usage:
2
zwallet vp-unlock [flags]
3
4
Flags:
5
-h, --help help for vp-unlock
6
--pool_id string pool identifier, required
7
Copied!
Here, pool_id is a required flag to unlock the particular vesting pool from the destination or owner wallet side. To show vp-unlock functionality we will do unlocking of tokens from owner wallet side then the destination side.

Unlocking tokens from owner wallet

First let's unlock the vesting pool from owner wallet which has some tokens yet to be vested. The wallet balance and vesting pool info before unlocking are as follows:
1
Balance: 1.3039999999 (1.1422844399124015 USD)
Copied!
1
pool_id: 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:074de87c15855db511352491131f31ddc79f35ef2c912137e12a8f5aeb2fee81
2
balance: 3
3
can unlock: 1 (excess)
4
sent: 0 (real value)
5
pending: 2 (not sent, real value)
6
vested: 0.1433333333 (virtual, time based value)
7
description:
8
start_time: 2021-05-18 21:55:53 +0000 UTC
9
expire_at: 2021-05-18 22:15:53 +0000 UTC
10
destinations:
11
- id: 48965bc485e6d42c02c2d53548ad90b79cc9cb2b26f6cfd3331bb0e5f10c7a14
12
vesting: 2
13
can unlock: 0.1433333333 (virtual, time based value)
14
sent: 0 (real value)
15
pending: 2 (not sent, real value)
16
vested: 0.1433333333 (virtual, time based value)
17
last unlock: 2021-05-18 21:55:53 +0000 UTC
18
client_id: 48965bc485e6d42c02c2d53548ad90b79cc9cb2b26f6cfd3331bb0e5f10c7a14
19
Copied!
There is a single token which yet has to be vested and is available to unlock in the can unlock variable above. Use vp-unlock to unlock that.
Command:
1
./zwallet vp-unlock --pool_id 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:074de87c15855db511352491131f31ddc79f35ef2c912137e12a8f5aeb2fee81
Copied!
Response:
1
Tokens unlocked successfully
Copied!
Wallet balance after unlocking:
1
Balance: 2.3039999999 (2.0208453119122893 USD)
Copied!

Unlocking tokens from destination wallet

Tokens can only be unlocked when they are vested. Here is a vesting pool info and a wallet balance of receiver wallet before unlocking of vesting tokens:
1
Balance: 2.3039999999 (1.99410739191345 USD)
Copied!
1
pool_id: 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:ddc459b2f186719020ec999dd377e097347e1204f95ee0674cd1a454c384260e
2
balance: 2
3
can unlock: 1 (excess)
4
sent: 0 (real value)
5
pending: 1 (not sent, real value)
6
vested: 1 (virtual, time based value)
7
description:
8
start_time: 2021-05-18 22:13:16 +0000 UTC
9
expire_at: 2021-05-18 22:15:16 +0000 UTC
10
destinations:
11
- id: 48965bc485e6d42c02c2d53548ad90b79cc9cb2b26f6cfd3331bb0e5f10c7a14
12
vesting: 1
13
can unlock: 1 (virtual, time based value)
14
sent: 0 (real value)
15
pending: 1 (not sent, real value)
16
vested: 1 (virtual, time based value)
17
last unlock: 2021-05-18 22:13:16 +0000 UTC
18
client_id: 48965bc485e6d42c02c2d53548ad90b79cc9cb2b26f6cfd3331bb0e5f10c7a14
Copied!
From the above vesting pool information one vested token is available to unlock in destinations section. Let's unlock that token from receiver's wallet.
Command:
1
./zwallet vp-unlock --pool_id 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:ddc459b2f186719020ec999dd377e097347e1204f95ee0674cd1a454c384260e
Copied!
Response:
1
Tokens unlocked successfully.
Copied!
Receiver's Wallet balance after unlocking:
1
Balance: 3.3039999999 (2.9055805519120583 USD)
Copied!

Stopping vesting for a destination

./zwallet vp-stopcommand is used to stop transferring of tokens to a destination wallets. The owner can stop vesting for a destination and unlock the rest of tokens not yet vested.
Parameters can be viewed using./zwallet vp-stop --help command.
1
Usage:
2
zwallet vp-stop [flags]
3
4
Flags:
5
--d string destination to stop vesting, required
6
-h, --help help for vp-stop
7
--pool_id string pool identifier, required
8
Copied!
Here, pool_id with --d(client _id of the destination wallet) is required. Both can be fetched using the vp-infocommand.
For showing the vp-stop functionality we are considering the vesting pool which has some tokens vested for destinations. Here is a vp-infofor that pool.
1
pool_id: 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:6cf68385b9200419a6f1e54ea7809a2859298e19b567cbbe9d69736b9ee61c44
2
balance: 2
3
can unlock: 1 (excess)
4
sent: 0 (real value)
5
pending: 1 (not sent, real value)
6
vested: 0.1 (virtual, time based value)
7
description:
8
start_time: 2021-05-18 22:35:17 +0000 UTC
9
expire_at: 2021-05-18 22:45:17 +0000 UTC
10
destinations:
11
- id: 48965bc485e6d42c02c2d53548ad90b79cc9cb2b26f6cfd3331bb0e5f10c7a1 4
12
vesting: 1
13
can unlock: 0.1 (virtual, time based value)
14
sent: 0 (real value)
15
pending: 1 (not sent, real value)
16
vested: 0.1 (virtual, time based value)
17
last unlock: 2021-05-18 22:35:17 +0000 UTC
18
client_id: 48965bc485e6d42c02c2d53548ad90b79cc9cb2b26f6cfd3331bb0e5f10c7a14
Copied!
Lets use the vp-unlock command to stop vesting for destinations, --dflag would be the client_id mentioned in the vp-info output.
Command:
1
./zwallet vp-stop --d 48965bc485e6d42c02c2d53548ad90b79cc9cb2b26f6cfd3331bb0e5f10c7a14 --pool_id 2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead:vestingpool:6cf68385b9200419a6f1e54ea7809a2859298e19b567cbbe9d69736b9ee61c44
Copied!
Response:
1
Stop vesting for 48965bc485e6d42c02c2d53548ad90b79cc9cb2b26f6cfd3331bb0e5f10c7a14.
Copied!
To verify whether vesting to destinations has sto