Quickstart
Quick start using Zwallet (pre-config - build - run)
Pre-requisites
Before you start, make sure the following is installed on your machine:
Golang (1.21+)
Make (the
make
command)
Clone the repo
You need to clone the zwalletcli repo:
git clone https://github.com/0chain/zwalletcli.git
This will clone the repo on your local machine in zwalletcli
in your working directory.
Install dependencies
Move to the zwalletcli
directory and run the install command
cd zwalletcli
make install
This installs the dependencies for the zwalletcli tool and then builds the tool binary.
Run the binary
Now the binary is in your zwalletcli directory, you can run it like this:
❯ ./zwallet
Use Zwallet to store, send and execute smart contract on 0Chain platform.
Complete documentation is available at https://docs.zus.network/guides/zwallet-cli
Usage:
zwallet [command]
Available Commands:
bridge-burn-bnt burn bnt tokens
bridge-burn-eth burn eth tokens
bridge-burn-eurc burn eurc tokens
bridge-burn-usdc burn usdc tokens
bridge-burn-wzcn burn wzcn tokens
bridge-burn-zcn burn zcn tokens
bridge-get-wzcn-burn get confirmed burn ticket for ethereum burn transaction
bridge-get-zcn-burn get the confirmed burn ticket for zcn burn transaction
bridge-import-account Import Ethereum account to local key storage (default $HOME/.zcn/wallets)
bridge-list-accounts List Ethereum account registered in local key chain
bridge-list-auth List authorizers
bridge-mint-wzcn mint WZCN tokens using the hash of ZCN burn transaction
bridge-mint-zcn mint zcn tokens using the hash of Ethereum burn transaction
bridge-verify verify ethereum transaction
collect-reward Pay accrued rewards for a stake pool.
completion Generate the autocompletion script for the specified shell
create-wallet Create wallet and logs it into stdout (pass --register to register wallet to blockchain)
getbalance Get balance from sharders
getblobbers Get registered blobbers from sharders
getid Get Miner or Sharder ID from its URL
getnonce Get nonce from sharders
global-config Show global configurations.
help Help about any command
ls-miners Get miners from Miner SC
ls-sharders Get sharders from Miner SC
mn-info Get miner/sharder info from Miner SC.
mn-kill kill miner
mn-lock Add miner/sharder stake.
mn-pool-info Get miner/sharder pool info from Miner SC.
mn-unlock Unlock miner/sharder stake.
mn-update-settings Change miner/sharder settings in Miner SC.
mn-user-info Get miner/sharder user pools info from Miner SC.
recoverwallet Recover wallet
reset-user-nonce Reset user minted nonce
sc-config Show storage SC configuration.
send Send ZCN tokens to another wallet
sh-kill kill sharder
verify verify transaction
version Prints version information
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)
Use "zwallet [command] --help" for more information about a command.
This output means the tool is installed successfully. It also shows the help text for the tools with the available commands and the global flags (flags applied with any command).
To show the help of any command, run the following:
./zwallet <command> --help
Running some basic commands
Let's try two of the simplest commands in zwalletcli:
1. Listing miners command ls-miners
ls-miners
This command lists the information of all the miners:
./zwallet ls-miners
Output:
0chain-core-sdk [INFO] 2024/06/03 21:27:05.935222 wallet_base.go:331: ******* Wallet SDK Version:v1.12.1-3-gbc68f654 ******* (SetLogFile)
0box-sdk [INFO] 2024/06/03 21:27:05.935429 sdk.go:99: ******* Storage SDK Version: v1.12.1-3-gbc68f654 *******
0chain-core-sdk [INFO] 2024/06/03 21:27:06.457046 transaction_base.go:143: ******* Wallet SDK Version:v1.12.1-3-gbc68f654 ******* (InitZCNSDK)
0chain-core-sdk [DEBUG] 2024/06/03 21:27:06.824472 transaction_query.go:268: https://dev3.zus.network/sharder01/v1/screst/6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d9/getMinerList?active=true&limit=20&offset=0&stakable=false 200 OK
0chain-core-sdk [DEBUG] 2024/06/03 21:27:06.824525 transaction_query.go:269: {"Nodes":[{"simple_miner":{"id":"8f9a15b9551f8552a19cf4750ef14bff3bbac83bc1decd4d5a013a7f36f7ef71","n2n_host":"dev2.zus.network","host":"dev2.zus.network","port":7071,"path":"miner01","public_key":"a93743137c318274bf375e32c00b91439c18c0c0432eac550b2c1a54d909fa0f6669408c3208e5f68fab5aa6c36c91e1978670f17118d3fb75b854d68c1c740f","short_name":"dev2@gmail.com","build_tag":"fd7bd5317876c4064120948bf2355369e8331b8c","total_stake":0,"delete":false,"node_type":"miner","last_health_check":1717436961,"last_setting_update_round":0,"round_service_charge_last_updated":0,"is_killed":false},"stake_pool":{"pools":null,"rewards":0,"settings":{"delegate_wallet":"","num_delegates":10,"min_stake":0,"service_charge":0.1},"minter":0},"total_reward":0},{"simple_miner":{"id":"96b96df7631e00d339f9a25131927c43cba9f130b075f4af09e8934c21173341","n2n_host":"dev3.zus.network","host":"dev3.zus.network","port":7071,"path":"miner01","public_key":"171fbdcbd536fc64f4bcf7f2730731a1c9468210a377e4efcc83f0e3a072560231ea028c56ae6e956f74463ab6438bd375ab4d8f877dadd42914c6488cb9621b","short_name":"dev3@gmail.com","build_tag":"fd7bd5317876c4064120948bf2355369e8331b8c","total_stake":0,"delete":false,"node_type":"miner","last_health_check":1717436967,"last_setting_update_round":0,"round_service_charge_last_updated":0,"is_killed":false},"stake_pool":{"pools":null,"rewards":0,"settings":{"delegate_wallet":"","num_delegates":10,"min_stake":0,"service_charge":0.1},"minter":0},"total_reward":0},{"simple_miner":{"id":"c3227e496fdf3c9aa604f3470a2bbd1249f00142150bc067996cd0d6ffcd77ea","n2n_host":"dev1.zus.network","host":"dev1.zus.network","port":7071,"path":"miner01","public_key":"0e33db4984e356e7cf5963d3b83fbf6273c5d309f68f95f5dc985c7d4368bc182d6be685dd3eefdbfc3652b1c914b4a862d07ac2c0197ae68fac62c2ed4a7093","short_name":"dev1@gmail.com","build_tag":"fd7bd5317876c4064120948bf2355369e8331b8c","total_stake":0,"delete":false,"node_type":"miner","last_health_check":1717431572,"last_setting_update_round":0,"round_service_charge_last_updated":0,"is_killed":false},"stake_pool":{"pools":null,"rewards":0,"settings":{"delegate_wallet":"","num_delegates":10,"min_stake":0,"service_charge":0.1},"minter":0},"total_reward":0}]}
0chain-core-sdk [DEBUG] 2024/06/03 21:27:06.824651 transaction_query.go:268: https://dev1.zus.network/sharder01/v1/screst/6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d9/getMinerList?active=true&limit=20&offset=0&stakable=false 200 OK
0chain-core-sdk [DEBUG] 2024/06/03 21:27:06.824667 transaction_query.go:269: {"Nodes":[{"simple_miner":{"id":"8f9a15b9551f8552a19cf4750ef14bff3bbac83bc1decd4d5a013a7f36f7ef71","n2n_host":"dev2.zus.network","host":"dev2.zus.network","port":7071,"path":"miner01","public_key":"a93743137c318274bf375e32c00b91439c18c0c0432eac550b2c1a54d909fa0f6669408c3208e5f68fab5aa6c36c91e1978670f17118d3fb75b854d68c1c740f","short_name":"dev2@gmail.com","build_tag":"fd7bd5317876c4064120948bf2355369e8331b8c","total_stake":0,"delete":false,"node_type":"miner","last_health_check":1717436961,"last_setting_update_round":0,"round_service_charge_last_updated":0,"is_killed":false},"stake_pool":{"pools":null,"rewards":0,"settings":{"delegate_wallet":"","num_delegates":10,"min_stake":0,"service_charge":0.1},"minter":0},"total_reward":0},{"simple_miner":{"id":"96b96df7631e00d339f9a25131927c43cba9f130b075f4af09e8934c21173341","n2n_host":"dev3.zus.network","host":"dev3.zus.network","port":7071,"path":"miner01","public_key":"171fbdcbd536fc64f4bcf7f2730731a1c9468210a377e4efcc83f0e3a072560231ea028c56ae6e956f74463ab6438bd375ab4d8f877dadd42914c6488cb9621b","short_name":"dev3@gmail.com","build_tag":"fd7bd5317876c4064120948bf2355369e8331b8c","total_stake":0,"delete":false,"node_type":"miner","last_health_check":1717436967,"last_setting_update_round":0,"round_service_charge_last_updated":0,"is_killed":false},"stake_pool":{"pools":null,"rewards":0,"settings":{"delegate_wallet":"","num_delegates":10,"min_stake":0,"service_charge":0.1},"minter":0},"total_reward":0},{"simple_miner":{"id":"c3227e496fdf3c9aa604f3470a2bbd1249f00142150bc067996cd0d6ffcd77ea","n2n_host":"dev1.zus.network","host":"dev1.zus.network","port":7071,"path":"miner01","public_key":"0e33db4984e356e7cf5963d3b83fbf6273c5d309f68f95f5dc985c7d4368bc182d6be685dd3eefdbfc3652b1c914b4a862d07ac2c0197ae68fac62c2ed4a7093","short_name":"dev1@gmail.com","build_tag":"fd7bd5317876c4064120948bf2355369e8331b8c","total_stake":0,"delete":false,"node_type":"miner","last_health_check":1717431572,"last_setting_update_round":0,"round_service_charge_last_updated":0,"is_killed":false},"stake_pool":{"pools":null,"rewards":0,"settings":{"delegate_wallet":"","num_delegates":10,"min_stake":0,"service_charge":0.1},"minter":0},"total_reward":0}]}
0chain-core-sdk [DEBUG] 2024/06/03 21:27:06.864411 transaction_query.go:268: https://dev2.zus.network/sharder01/v1/screst/6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d9/getMinerList?active=true&limit=20&offset=0&stakable=false 200 OK
0chain-core-sdk [DEBUG] 2024/06/03 21:27:06.864480 transaction_query.go:269: {"Nodes":[{"simple_miner":{"id":"8f9a15b9551f8552a19cf4750ef14bff3bbac83bc1decd4d5a013a7f36f7ef71","n2n_host":"dev2.zus.network","host":"dev2.zus.network","port":7071,"path":"miner01","public_key":"a93743137c318274bf375e32c00b91439c18c0c0432eac550b2c1a54d909fa0f6669408c3208e5f68fab5aa6c36c91e1978670f17118d3fb75b854d68c1c740f","short_name":"dev2@gmail.com","build_tag":"fd7bd5317876c4064120948bf2355369e8331b8c","total_stake":0,"delete":false,"node_type":"miner","last_health_check":1717436961,"last_setting_update_round":0,"round_service_charge_last_updated":0,"is_killed":false},"stake_pool":{"pools":null,"rewards":0,"settings":{"delegate_wallet":"","num_delegates":10,"min_stake":0,"service_charge":0.1},"minter":0},"total_reward":0},{"simple_miner":{"id":"96b96df7631e00d339f9a25131927c43cba9f130b075f4af09e8934c21173341","n2n_host":"dev3.zus.network","host":"dev3.zus.network","port":7071,"path":"miner01","public_key":"171fbdcbd536fc64f4bcf7f2730731a1c9468210a377e4efcc83f0e3a072560231ea028c56ae6e956f74463ab6438bd375ab4d8f877dadd42914c6488cb9621b","short_name":"dev3@gmail.com","build_tag":"fd7bd5317876c4064120948bf2355369e8331b8c","total_stake":0,"delete":false,"node_type":"miner","last_health_check":1717436967,"last_setting_update_round":0,"round_service_charge_last_updated":0,"is_killed":false},"stake_pool":{"pools":null,"rewards":0,"settings":{"delegate_wallet":"","num_delegates":10,"min_stake":0,"service_charge":0.1},"minter":0},"total_reward":0},{"simple_miner":{"id":"c3227e496fdf3c9aa604f3470a2bbd1249f00142150bc067996cd0d6ffcd77ea","n2n_host":"dev1.zus.network","host":"dev1.zus.network","port":7071,"path":"miner01","public_key":"0e33db4984e356e7cf5963d3b83fbf6273c5d309f68f95f5dc985c7d4368bc182d6be685dd3eefdbfc3652b1c914b4a862d07ac2c0197ae68fac62c2ed4a7093","short_name":"dev1@gmail.com","build_tag":"fd7bd5317876c4064120948bf2355369e8331b8c","total_stake":0,"delete":false,"node_type":"miner","last_health_check":1717431572,"last_setting_update_round":0,"round_service_charge_last_updated":0,"is_killed":false},"stake_pool":{"pools":null,"rewards":0,"settings":{"delegate_wallet":"","num_delegates":10,"min_stake":0,"service_charge":0.1},"minter":0},"total_reward":0}]}
- ID: 8f9a15b9551f8552a19cf4750ef14bff3bbac83bc1decd4d5a013a7f36f7ef71
- Host: dev2.zus.network
- Port: 7071
- ID: 96b96df7631e00d339f9a25131927c43cba9f130b075f4af09e8934c21173341
- Host: dev3.zus.network
- Port: 7071
- ID: c3227e496fdf3c9aa604f3470a2bbd1249f00142150bc067996cd0d6ffcd77ea
- Host: dev1.zus.network
- Port: 7071
As you can see, the output shows all the miners, each with the id, Host and Port.
2. Listing sharders command ls-sharders
ls-sharders
This command lists all the sharders registered in the network
./zwallet ls-sharders
Output:
0chain-core-sdk [INFO] 2024/06/03 21:28:24.672113 wallet_base.go:331: ******* Wallet SDK Version:v1.12.1-3-gbc68f654 ******* (SetLogFile)
0box-sdk [INFO] 2024/06/03 21:28:24.672311 sdk.go:99: ******* Storage SDK Version: v1.12.1-3-gbc68f654 *******
0chain-core-sdk [INFO] 2024/06/03 21:28:24.995260 transaction_base.go:143: ******* Wallet SDK Version:v1.12.1-3-gbc68f654 ******* (InitZCNSDK)
0box-sdk [INFO] 2024/06/03 21:28:24.997096 node.go:194: Query from https://dev3.zus.network/sharder01/v1/block/get/latest_finalized_magic_block
0box-sdk [INFO] 2024/06/03 21:28:24.997111 node.go:194: Query from https://dev2.zus.network/sharder01/v1/block/get/latest_finalized_magic_block
0box-sdk [INFO] 2024/06/03 21:28:24.997130 node.go:194: Query from https://dev1.zus.network/sharder01/v1/block/get/latest_finalized_magic_block
0chain-core-sdk [DEBUG] 2024/06/03 21:28:25.384780 transaction.go:1136: https://dev2.zus.network/sharder01/v1/block/get/latest_finalized_magic_block200 OK
0chain-core-sdk [DEBUG] 2024/06/03 21:28:25.397079 transaction.go:1136: https://dev1.zus.network/sharder01/v1/block/get/latest_finalized_magic_block200 OK
0chain-core-sdk [DEBUG] 2024/06/03 21:28:25.425058 transaction.go:1136: https://dev3.zus.network/sharder01/v1/block/get/latest_finalized_magic_block200 OK
MagicBlock Sharders
ID: afa396409ef1a78dff132f586c1f55e4725ccdc8554a727a525fcab44b3bcb16
- N2NHost: dev3.zus.network
- Host: dev3.zus.network
- Port: 7171
ID: e3cc90b550e7c5e906583897648dea5bc0cd61ae2127edb044892203384a1f33
- N2NHost: dev1.zus.network
- Host: dev1.zus.network
- Port: 7171
ID: 371a09c9eec259d9d3ba794ecccdd392ecdeec4c35565ccc5977fba44e20217d
- N2NHost: dev2.zus.network
- Host: dev2.zus.network
- Port: 7171
As you can see, the output shows all the sharders, each with the id, host and port.
All the commands related to your own data will require a wallet. Use the "Configure your wallet" guide to create or specify a wallet to the command.
Next steps
Here are some useful guides and references for Zwalletcli:
Commands Reference in the Github README.
Last updated