0Chain
Search…
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!