Zwallet Operations

Global Parameters

zwallet can accept the following global parameters to override default configuration and can be used with any command.

Flags:
      --config string      config file (default is config.yaml)
      --configDir string   configuration directory (default is $HOME/.zcn)
      --fee float          transaction fee for the given transaction (if unset, it will be set to blockchain min fee)
  -h, --help               help for zwallet
      --network string     network file to overwrite the network details (if required, default is network.yaml)
      --silent             Do not print sdk logs in stderr (prints by default)
      --wallet string      wallet file (default is wallet.json)
      --withNonce int      nonce that will be used in transaction (default is 0)

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.

Sample Command:

./zwallet <command> --wallet wallet2.json​

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:

Response:

The second wallet will also be saved in .zcn directory. To check its contents use:

Sample Response:

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

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:

Response:

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:

Response:

Verify whether it is the same wallet using:

The contents in the json file should be same as User A computer .\

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.

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:

Sample Response:

By default ZWallet checks balance and send tokens from wallet specified in wallet.json file. To send tokens use:

Response:

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.

Note: To use a different wallet as a sender, use --wallet global parameter.

Last updated