# Worker Self Staking

VideoCoin workers can participate in transcode mining by self staking a minimum amount of their tokens. The transcoding work is distributed to workers in proportion to the total stake on each worker. The total stake of a worker includes the self stake and delegated stake by one or more delegators. The self stake can be withdrawn. However the VID tokens are transferred to the holder's account after expiry of the unbonding time which is currently set at 21 days. <br>

Staking and withdraw can be performed through a command line tool that is currently supported on Linux platforms. Follow the below steps:

* Download the command line tool *staker* (Contact VideoCoin support for the download link)
* Sets up a configuration file in the format of Ethereum key store file that contains private key and public key (password protected).&#x20;
* Run the self stake or withdraw commands as shown in the following sections.

## Setup

The staker tool needs to communicate with the Ethereum mainnet to access VID tokens.\
You can use a free or paid subscription from Infura to access Ethereum through  web interace. Please visit the Infura website (<https://infura.io/product>) and obtain a your ID and make it available to the staker tool using an environment variable as follows.

```
export ETH_RPC_URL=https://mainnet.infura.io/v3/<Your Project ID>
```

Prepare an Ethereum key file that contains your private key in encrypted form. Following is a sample key file

```
{'address': 'fd41a83c713bd0d612c0ca0fd078ec6cc5d37cfb',
 'crypto': {'cipher': 'aes-128-ctr',
            'cipherparams': {'iv': '47db6518e4ecc7e8c5800722f173e214'},
            'ciphertext': '2d09d0c77a4a00cfb59fe5cbe0cf867c32b04e725ccacca52e96d3c1bb70a067',
            'kdf': 'scrypt',
            'kdfparams': {'dklen': 32,
                          'n': 4096,
                          'p': 6,
                          'r': 8,
                          'salt': '2f1790fe23a3a1957b75d73f1be8d4814129e512b9e9956687774b4471c3be7f'},
            'mac': '008c38f40bdb4c0d5faaa30f9e55c4798974447fdd9c7f8535914e323c2268d8'},
 'id': '23f7b36d-ff7b-4a9d-954e-06ed3fa7a1fa',
 'version': 3}

```

## Self Staking Process <a href="#delegation-process" id="delegation-process"></a>

Before using the staker tool to self-stake the VID tokens, first step is to move  erc-20 VID tokens form Ethereum main net to VideoCoin network. Then you can stake VID tokens as as described below.\
&#x20;\
Use the following command to transfer VID tokens from Ethereum main net to VideoCoin network to use as transaction fee/gas:

```
$ staker fund <amount> -k <key file> -s <password>
```

| Option | Description                        |
| ------ | ---------------------------------- |
| amount | VID token amount to be transferred |

Use the following command to self stake VID tokens:

```
$ staker stake add <amount> -k <key file> -s <password>
```

| Option | Description                     |
| ------ | ------------------------------- |
| amount | Amount of VID  for self staking |

### Example usage of the commands

Transfer VID tokens from Ethereum main net to VideoCoin network

```
$ staker fund 100 -k worker-0.json -s ""
```

Self stake VID

```
$ staker stake add 333000 -k worker-0.json -s ""
```

## Withdraw Process <a href="#withdraw-process" id="withdraw-process"></a>

Currently withdraw is two step process. The fist step is issue a withdraw request(unbonding request). The second step is wait for unbonding period to elapse and issue a command to complete withdraw. Then native VID from VideoCoin network and trnasfer to ERC-20 VID tokens on Ethereum main net.&#x20;

Use the following command to issue withdraw request:

```bash
$ staker stake withdraw <amount> -k <key file> -s <password>
```

| Option | Description                   |
| ------ | ----------------------------- |
| amount | Amount of stake  to  withdraw |

{% hint style="info" %}
The withdrawn stake is deposited to worker's account only after expiry of unbonding period
{% endhint %}

Use the following command to complete pending unbonding request that transfer staked tokens to native VID:

```
$ staker stake withdraw complete -k <key file> -s <password>
```

Use the following command to check the staking balance

```
$ staker stake  -k <key file>
```

Transfer native VID from VideoCoin network  to ERC-20 VID tokens on Ethereum main net.

```
staker withdraw <amount> -k <key file> -s <password>
```

| Option |   | Description                                                                  |
| ------ | - | ---------------------------------------------------------------------------- |
| amount |   | Amount of VID  to be transferred to Ethereum main net from VideoCoin network |


---

# 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.vividlabs.com/staking-vid-token/worker-self-staking.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.
