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).
./zwallet lockconfig

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
zwallet lock [flags]
--durationHr int Duration Hours to lock
--durationMin int Duration Mins to lock
--fee float Transaction Fee
-h, --help help for lock
--tokens float Number to tokens to lock
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.
./zwallet lock --durationHr 0 --durationMin 5 --tokens 0.2 --fee 0.1
Tokens (0.200000) locked successfully
Check your wallet balance using
./zwallet getbalance
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.
./zwallet getlockedtokens
Locked tokens:
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.
--fee float Transaction Fee
-h, --help help for unlock
--pool_id string Pool ID - hash of the locked transaction
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:
./zwallet unlock --pool_id 121053df2f2508a640111b338d4d3b18914c7a27f864b74c7fd86820d0638527
Unlock tokens success
On a successful unlock, your wallet balance will include the tokens you earned as interest plus the amount of tokens you locked initially.
Copy link
On this page
Getting lock config
Locking tokens
Getting locked tokens
Unlocking tokens