# Lock and Unlock Tokens

* [Lock and Unlock Tokens](/guides/zbox-cli/lock-and-unlock-tokens.md)
  * [Challenge pool information](#challenge-pool-information)
  * [Create read pool](#create-read-pool)
  * [Collect rewards](#collect-rewards)
  * [Read pool info](#read-pool-info)
  * [Lock tokens into read pool](#lock-tokens-into-read-pool)
  * [Unlock tokens from read pool](#unlock-tokens-from-read-pool)
  * [Storage SC configurations](#storage-sc-configurations)
  * [Stake pool info](#stake-pool-info)
  * [Lock tokens into stake pool](#lock-tokens-into-stake-pool)
  * [Unlock tokens from stake pool](#unlock-tokens-from-stake-pool)
  * [Stake pools info of user](#stake-pools-info-of-user)
  * [Write pool info](#write-pool-info)
  * [Lock tokens into write pool](#lock-tokens-into-write-pool)
  * [Unlock tokens from write pool](#unlock-tokens-from-write-pool)

### **Challenge pool information**

Use `cp-info` command to get the challenge pool brief information.

| Parameter  | Required | Description                 | default | Valid values |
| ---------- | -------- | --------------------------- | ------- | ------------ |
| allocation | yes      | allocation id               |         | string       |
| json       | no       | print result in json format | false   | boolean      |

Example:

```
./zbox cp-info --allocation 8695b9e7f986d4a447b64de020ba86f53b3b5e2c442abceb6cd65742702067dc
```

Response:

```
POOL ID: 6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d7:challengepool:8695b9e7f986d4a447b64de020ba86f53b3b5e2c442abceb6cd65742702067dc
    BALANCE    |             START             |            EXPIRE             | FINIALIZED
+--------------+-------------------------------+-------------------------------+------------+
  0.0000002796 | 2021-04-17 00:27:23 +0700 +07 | 2021-05-24 00:29:23 +0700 +07 | false
```

Balance is the current challenge pool balance. Start,Expire time and the finalization are allocations related.

### **Create Read Pool**

Use `rp-create` to create a read pool, `rp-create` has no parameters.

```
./zbox rp-create
```

### **Collect rewards**

Use `collect-reward` to transfer reward tokens from a stake pool in which you have invested to your wallet.

You earn rewards for: Blobbers

* File space used by allocation owners and associates.
* A min lock demand for each allocation.
* Block rewards. Each block a reward gets paid out to blobber stakeholders in the form of a random lottery. Validators
* Payment for validating blobber challenge responses.

The stake pool keeps an account for all stakeholders to maintain accrued rewards. These rewards can be accessed using this `collect-reward` command.

| Parameter      | Required | Description          | default | Valid values |
| -------------- | -------- | -------------------- | ------- | ------------ |
| provider\_type | no       | blobber or validator | blobber | string       |

```
./zbox collect-reward --provider_type blobber
```

### **Read pool info**

Use `rp-info` to get read pool information.

| Parameter | Required | Description                 | default | Valid values |
| --------- | -------- | --------------------------- | ------- | ------------ |
| json      | no       | print result in json format | false   | boolean      |

```
./zbox rp-info
```

### **Lock tokens into read pool**

Lock some tokens in read pool. ReadPool is not linked to specific allocations anymore. Each wallet has a singular, non-expiring, untethered ReadPool. Locked tokens in ReadPool can be unlocked at any time and returned to the original wallet balance.

* If the user does not have a pre-existing read pool, then the smart-contract creates one.

Locked tokens can be used to pay for read access to file(s) stored with different allocations. To use these tokens the user must be the allocation owner, collaborator or have an auth ticket.

| Parameter | Required | Description     | default | Valid values |
| --------- | -------- | --------------- | ------- | ------------ |
| fee       |          | transaction fee | 0       | int          |
| tokens    | yes      | tokens to lock  |         | int          |

```
./zbox rp-lock --tokens 1
```

### **Unlock tokens from read pool**

Use `rp-unlock` to unlock tokens from \`read pool by ownership.

| Parameter | Required | Description     | default | Valid values |
| --------- | -------- | --------------- | ------- | ------------ |
| fee       | no       | transaction fee | 0       | float        |

Unlocked tokens get returned to the original wallet balance.

### **Storage SC configurations**

Show storage SC configuration.

| Parameter  | Required | Description                 | default | Valid values |
| ---------- | -------- | --------------------------- | ------- | ------------ |
| allocation | yes      | allocation id               |         | string       |
| json       | no       | print result in json format | false   | boolean      |

```
./zbox sc-config
```

### **Stake pool info**

Use `sp-info` to get your stake pool information and settings.

| Parameter   | Required | Description                                                                                                                         | default        | Valid values |
| ----------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- | -------------- | ------------ |
| blobber\_id | yes      | id of blobber. Can be retrieved using [List Blobbers](/guides/zbox-cli/creating-and-managing-allocations.md#list-blobbers) command. | current client | string       |
| json        | no       | print result in json format                                                                                                         | false          | boolean      |

```
./zbox sp-info --blobber_id <blobber_id>
```

### **Lock tokens into stake pool**

Lock creates delegate pool for current client and a given provider (blobber or validator). The tokens locked for the provider stake can be unlocked any time, excluding times when the tokens held by opened offers. These tokens will earn rewards depending on the actions of the linked provider.

`sp-lock` returns the id of the new stake pool, this will be needed to reference to stake pool later.

| Parameter     | Required | Description     | default | Valid values |
| ------------- | -------- | --------------- | ------- | ------------ |
| blobber\_id   |          | id of blobber   | n/a     | string       |
| validator\_id |          | id of validator | n/a     | string       |
| fee           | no       | transaction fee | 0       | float        |
| tokens        | yes      | tokens to lock  |         | float        |

To stake tokens for blobbers:

```
./zbox sp-lock --blobber_id <blobber_id> --tokens 1.0
```

To stake tokens for validators:

```
./zbox sp-lock --validator_id <validator_id> --tokens 1.0
```

### **Unlock tokens from stake pool**

Unlock a stake pool by pool owner. If the stake pool cannot be unlocked as it would leave insufficient funds for opened offers, then `sp-unlock` tags the stake pool to be unlocked later. This tag prevents the stake pool affecting blobber allocation for any new allocations.

| Parameter     | Required | Description     | default | Valid values |
| ------------- | -------- | --------------- | ------- | ------------ |
| blobber\_id   |          | id of blobber   | n/a     | string       |
| validator\_id |          | id of validator | n/a     | string       |
| fee           | no       | transaction fee | 0       | float        |

To unstake blobber tokens:

```
./zbox sp-unlock --blobber_id <blobber_id>
```

To unstake validator tokens:

```
./zbox sp-unlock --validator_id <validator_id> --pool_id <pool_id>
```

### **Stake pools info of user**

Get information about all stake pools of current user.

| Parameter | Required | Description                 | default | Valid values |
| --------- | -------- | --------------------------- | ------- | ------------ |
| json      | no       | print result in json format | false   | boolean      |

```
./zbox sp-user-info
```

### **Write pool info**

Write pool information. Use allocation id to filter results to a singe allocation.

| Parameter     | Required | Description                 | default | Valid values |
| ------------- | -------- | --------------------------- | ------- | ------------ |
| allocation id | no       | allocation id               |         | string       |
| json          | no       | print result in json format | false   | boolean      |

For all write pools.

```
./zbox wp-info
```

Filtering by allocation.

```
./zbox wp-info --allocation <allocation_id>
```

### **Lock tokens into write pool**

`wp-lock` can be used to lock tokens in a write pool associated with an allocation. All tokens will be divided between allocation blobbers depending on their write price.

* Uses two different formats, you can either define a specific blobber to lock all tokens, or spread across all the allocations blobbers automatically.
* If the user does not have a pre-existing read pool, then the smart-contract creates one.

Anyone can lock tokens with a write pool attached an allocation. These tokens can be used to pay for the allocation updates and min lock demand as needed. Any tokens moved into the challenge pool to underwrite blobbers' min lock demands return to the allocation's owner on closing the allocation.

| Parameter     | Required | Description                       | default | Valid values |
| ------------- | -------- | --------------------------------- | ------- | ------------ |
| allocation id | no       | allocation id                     |         | string       |
| blobber       | no       | blobber id                        |         | string       |
| duration      | yes      | duration for which to lock tokens |         | duration     |
| fee           | no       | transaction fee                   | 0       | float        |
| tokens        | yes      | number of tokens to lock          |         | float        |

```
./zbox wp-lock --allocation <allocation_id> --duration 40m --tokens 1
```

### **Unlock tokens from write pool**

`wp-unlock` unlocks an expired write pool. An expired write pool, associated with an allocation, can be locked until allocation finalization even if it's expired. It possible in cases where related blobber doesn't give their min lock demands. The finalization will pay the demand and unlock the pool.

| Parameter | Required | Description     | default | Valid values |
| --------- | -------- | --------------- | ------- | ------------ |
| fee       | no       | transaction fee | 0       | float        |

```
./zbox wp-unlock
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-old.zus.network/guides/zbox-cli/lock-and-unlock-tokens.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
