Worker Self Staking

Worker Self Staking

Tutorial on using VideoCoin staker tool
VideoCoin workers can participate in transcode mining by self staking a minimum amount of their VID 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.
Staking and withdrawal can be performed through a command line tool that is wrapped under a docker image. Follow the below steps:

  • Download the command line docker image of staker
    https://hub.docker.com/r/videocoinnetwork/staker

  • Set up a configuration file in the format of Ethereum key store file that contains private key and public key associated with your VID (erc-20 token on Ethereum Mainnet). Same account is used on the VideoCoin network also.

  • 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 a web interface. Please visit the Infura website (https://infura.io/product) and obtain your ID and make it available to the staker tool. Replace the <ethereum_mainnet_rpc_url> with the url (along with product id) in the staker commands listed below.

Prepare an Ethereum key file that contains your private key in encrypted form. Following is a sample key file for reference. Supply this file to the staker tool. This file name can be used to replace in the staker commands.

{'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

Self-staking is a two step process. Tthe first step is to move erc-20 VID tokens from Ethereum main net to VideoCoin network. Then you can stake VID tokens as described below. Use the following command to transfer VID tokens from Ethereum main net to VideoCoin network. You need to use transfer an amount slightly higher than the self-stake amount to cover the transaction fee/gas on VideoCoin Network:

$ docker run --rm -it --env="ETH_RPC_URL=<ethereum_mainnet_rpc_url>" -v $PWD:/tmp videocoinnetwork/staker fund <amount> -k /tmp/<worker-key-file> -s <secret>
Option Description
amount ERC-20 VID token amount to be transferred to VideoCoin Network

Use the following command to self stake native VID coins:

$ docker run --rm -it --env="ETH_RPC_URL=<ethereum_mainnet_rpc_url>" -v $PWD:/tmp videocoinnetwork/staker stake add <amount> -k /tmp/<worker-key-file> -s <secret>
Option Description
amount Amount of VID for self staking

Example usage of the commands

Transfer VID tokens from Ethereum main net to VideoCoin network

$ docker run --rm -it --env="ETH_RPC_URL=https://mainnet.infura.io/v3/11112222333" -v $PWD:/tmp videocoinnetwork/staker stake fund 50001 -k /tmp/worker.json -s "mypasswd"

Self-stake VID coins

$ docker run --rm -it --env="ETH_RPC_URL=https://mainnet.infura.io/v3/11112222333" -v $PWD:/tmp videocoinnetwork/staker stake add 50000 -k /tmp/worker.json -s "mypasswd"

Withdraw Process

Currently, withdrawal is a two step process. The first step is to issue a withdrawal request(unbonding request). The second step is to wait for the unbonding period to elapse and issue a command to complete withdrawal. Then native VID from VideoCoin network and transfer to ERC-20 VID tokens on Ethereum main net.
Use the following command to issue withdraw request:

$ docker run --rm -it --env="ETH_RPC_URL=<ethereum_mainnet_rpc_url>" -v $PWD:/tmp videocoinnetwork/staker stake withdraw <amount> -k /tmp/<worker-key-file> -s <password>
Option Description
amount Amount of stake to withdraw

The withdrawn stake is deposited to worker’s account only after expiry of unbonding period.
Use the following command to complete pending unbonding request that transfer staked tokens to native VID:

$ docker run --rm -it --env="ETH_RPC_URL=<ethereum_mainnet_rpc_url>" -v $PWD:/tmp videocoinnetwork/staker stake withdraw complete -k /tmp/<worker-key-file> -s <password>

Use the following command to check the staking balance any time.

$ docker run --rm -it --env="ETH_RPC_URL=<ethereum_mainnet_rpc_url>" -v $PWD:/tmp videocoinnetwork/staker stake  -k /tmp/<worker-key-file> -s <password>

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

$ docker run --rm -it --env="ETH_RPC_URL=<ethereum_mainnet_rpc_url>" -v $PWD:/tmp videocoinnetwork/staker withdraw <amount> -k /tmp/<worker-key-file> -s <password>
Option Description
amount Amount of VID to be transferred to erc-20 on Ethereum main net from VideoCoin network

There is an error in the example usage of the “staker fund” command, It should be “staker fund …” instead of “staker stake fund …”
Correct usage example is:

$ docker run --rm -it --env="ETH_RPC_URL=https://mainnet.infura.io/v3/11112222333" -v $PWD:/tmp videocoinnetwork/staker  fund 50001 -k /tmp/worker.json -s "mypasswd"