Züs
Search…
⌃K

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)
-h, --help help for zwallet
--network string network file to overwrite the network details (if required, default is network.yaml)
--verbose prints sdk log in stderr (default false)
--wallet string wallet file (default is wallet.json)
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:
./zwallet <command> --verbose
*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:
./zwallet <command> --wallet wallet2.json

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:
Usage:
zwallet createmswallet [flags]
Flags:
-h, --help help for createmswallet
--numsigners int Number of signers
--testn test Multiwallet with all signers. Default is false
--threshold int Threshold number of signers required to sign the propos al
Global Flags:
--config string config file (default is config.yaml)
--configDir string configuration directory (default is $HOME/.zcn)
--network string network file to overwrite the network details (if req uired, default is network.yaml)
--verbose prints sdk log in stderr (default false)
--wallet string wallet file (default is wallet.json)
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:
./zwallet createmswallet --numsigners 4 --threshold 2
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:
No wallet in path /root/.zcn/wallet.json found. Creating wallet...
ZCN wallet created!!
Creating related read pool for storage smart-contract...
Read pool created successfully
registering 5 wallets
Successfully registered group wallet
Successfully registered signer wallet number 1
Successfully registered signer wallet number 2
Successfully registered signer wallet number 3
Successfully registered signer wallet number 4
Multisig wallet SC registration requested. verifying status
MultisigSC wallet SC registration request success
testing voteRecipient test wallet:
{"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"}
Activating group wallet by pouring test tokens
submitted transaction
Pour request success
Balance: 1
Activating signer wallet 1 by pouring test tokens
submitted transaction
Pour request success
Balance: 1
Activating signer wallet 2 by pouring test tokens
submitted transaction
Pour request success
Balance: 1
Activating signer wallet 3 by pouring test tokens
submitted transaction
Pour request success
Balance: 1
Activating signer wallet 4 by pouring test tokens
submitted transaction
Pour request success
Balance: 1
Checking balance on group wallet with clientID ddc02106fb9de5efd792c6a95c300205890147b37226dae054bc01f5f2308b77 before the vote
Balance: 1
Created Vote#1 from signer #0:
{"proposal_id":"testing MSVoting","transfer":{"from":"ddc02106fb9de5efd792c6a95c300205890147b37226dae054bc01f5f2308b77","to":"baaf3b0528829b321dd958bd3dc22236144f8df8ce846a2c9a16e0dd14656864","amount":1000000000},"signature":"10a33a7e511ec9a67a194cccb99e7fa428c914a1d9caa34ebedddb79d9ed7c04"}
Multisig Vote registration requested. verifying status
Multisig Voting success
Created Vote#2 from signer #1:
{"proposal_id":"testing MSVoting","transfer":{"from":"ddc02106fb9de5efd792c6a95c300205890147b37226dae054bc01f5f2308b77","to":"baaf3b0528829b321dd958bd3dc22236144f8df8ce846a2c9a16e0dd14656864","amount":1000000000},"signature":"bc59d6148a8a7557aa8a53354ada3d82cea82115b83c7040b4eed72b92900a85"}
Multisig Vote registration requested. verifying status
Multisig Voting success
Checking balance on group wallet ddc02106fb9de5efd792c6a95c300205890147b37226dae054bc01f5f2308b77 after the vote
Balance: 0.9
Checking balance on recipient wallet after the vote
Balance: 0.1
Creating and testing a multisig wallet is successful!

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:
./zwallet faucet --methodName pour --input "new wallet" --wallet new_wallet.json
Response:
No wallet in path /root/.zcn/new_wallet.json found. Creating wallet...
ZCN wallet created!!
Creating related read pool for storage smart-contract...
Read pool created successfully
Execute faucet smart contract success with txn : 802db9633fc77417d4adc421209a0a8d9967886222b01bb0f4a7f4c754de5d6c
The second wallet will also be saved in .zcn directory. To check its contents use:
cat ~/.zcn/new_wallet.json
Sample Response:
{"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"}

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
Usage:
zwallet recoverwallet [flags]
Flags:
-h, --help help for recoverwallet
--mnemonic string mnemonic
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:
cat ~/.zcn/wallet.json
Response:
{"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#
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:
./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"
Response:
No wallet in path /root/.zcn/recovered_wallet.json found. Creating wallet...
ZCN wallet created!!
Creating related read pool for storage smart-contract...
Read pool created successfully
Wallet recovered!!
Verify whether it is the same wallet using:
cat ~/.zcn/recovered_wallet.json
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:
./zwallet register
Command for registering a specific or 2nd wallet:
./zwallet register --wallet wallet2.json
Response:
Wallet registered

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.
Usage:
zwallet send [flags]
Flags:
--desc string Description
--fee float Transaction Fee
-h, --help help for send
--to_client_id string to_client_id
--tokens float Token to send
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:
./zwallet getbalance
Sample Response:
Balance: 0.6 (0.69 USD)
By default ZWallet checks balance and send tokens from wallet specified in wallet.json file. To send tokens use:
./zwallet send --to_client_id 26e5b70fcba3f72a475ef1dbc66e454d3b458b950d62c6ec218cc3425e3b621f --tokens .2 --desc "gift" --fee 0.1
Response:
Send tokens success
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.
Balance: 0.4 (0.45199999999999996 USD)
Note: To use a different wallet as a sender, use --wallet global parameter.
./zwallet send --to_client_id 26e5b70fcba3f72a475ef1dbc66e454d3b458b950d62c6ec218cc3425e3b621f --tokens .1 --desc "gift" --fee 0.1 --wallet another_wallet.json