8. Distribute Rewards

0. Why?

Are you baking on behalf of others? Do you have accounts delegated to your baking address? No longer solo-baking? If yes, then you need a process to distribute rewards every cycle. The best way is with the following, TRD:

Tezos Reward Distributor : Run & Forget

TRD is a software for distributing staking rewards of delegators introduced in detail in this Medium article. This is not a script but a full scale application which can continuously run in the background as a Linux service. It can track cycles and make payments. However it does not have to be used as a service, but it can also be used interactively. The documentation can be found here

🚧
1. Installing TRD

1. Install python 3.
1
sudo apt-get update
2
sudo apt-get -y install python3-pip
Copied!
2. Clone repo and install modules.
1
cd
2
git clone https://github.com/habanoz/tezos-reward-distributor
3
cd tezos-reward-distributor
4
pip3 install -r requirements.txt
Copied!

💸
2. Setup your payout configuration

  • By default, payment configuration is stored in ~/pymnt/cfg/
1
# create directory
2
mkdir -p ~/pymnt/cfg/
3
cp tezos-reward-distributor/examples/tz1boot1pK9h2BVGXdyvfQSv8kd1LQM6H889.yaml ~/pymnt/cfg/
4
nano ~/pymnt/cfg/<tz1_yourBakerAddress>.yaml
Copied!
Example contents of <tz1_yourBakerAddress>.yaml
1
version : 1.0
2
baking_address : tz1_yourBakerAddress
3
payment_address : myPaymentAddress
4
service_fee : 15
5
founders_map : {tz1_yourBakerAddress: 1}
6
owners_map : {tz1_yourBakerAddress: 1}
7
specials_map : {}
8
supporters_set : {}
9
min_delegation_amt : 100
10
reactivate_zeroed : True
11
delegator_pays_xfer_fee : True
12
delegator_pays_ra_fee : True
13
rules_map:
14
mindelegation: TOB
15
tz1_yourBakerAddress: TOB
Copied!
TOB means to balance. Review the detailed configuration help documentation here.

🧨
3. Setup and configure a new Rewards Payment Address

1. Generate a new tz1 account namedmyPaymentAddress. Add a passphrase to protect it.
1
cd ~/tezos
2
./tezos-client gen keys myPaymentAddress
3
4
# Enter passphrase to encrypt your key:
5
# Confirm passphrase:
Copied!
2. Verify that the account was created successfully.
1
./tezos-client list known addresses
Copied!
3. You should see your myPaymentAddress along with it's public address starting with tz1. See below for example.
myPaymentAddress: t1420a9zkodJpP5xtbwez651YxRKJtxVmqe (encrypted sk known)
4.
VERY IMPORTANT STEP: Backup the secret key and your passphrase. Save this somewhere safe.
1
./tezos-client show address myPaymentAddress -S
Copied!
Example output:
Secret Key: encrypted:edesk1<randomCharacters>
Reminder: Backup your secret key and passphrase, carefully and correctly.

🎇
4. Setup Tezos Client and Signer

  1. 1.
    Update and run the following command with your secret key that you backed up earlier.
1
cd ~/tezos
2
./tezos-signer import secret key myPaymentAddress encrypted:edesk1<randomCharacters>
Copied!
2. Start the signer process which will sign payment transactions generated fromTRD.
1
./tezos-signer launch socket signer -a 127.0.0.1 -p 22000 -W
Copied!
3. Add the payment address to tezos-client. Make sure to update <tz1_myPaymentAddress> with your payment address public key.
1
./tezos-client import secret key myPaymentAddress tcp://127.0.0.1:22000/<tz1_myPaymentAddress> -f
Copied!

🏃♀
5. Running Tezos Reward Distributor

To run TRD, execute the following command.
1
cd ~/tezos-reward-distributor
2
python3 src/main.py -O 60 -E ~/tezos --do_not_publish_stats -P tzstats
Copied!
Want to double check everything and do a dry run before sending rewards? Add -D to the command line.
-O means delay the payment for 60 blocks from the start of a cycle. -P is the rpc provider of the data used to calculate the rewards.
That's it! Every cycle or ~3 days, reward payments can automatically be distributed from myPaymentAddress. Just make sure to transfer enough tez from your baker address to this payment address.

📂
6. Reviewing payment reports

  • ~/pymnt/reports/ contains CSV files detailing calculations, failed/done payments.

🤖
7. Updating Tezos Reward Distributor

1
git fetch origin #fetches new branches
2
git status #see the changes
3
git pull
Copied!
Check the change logs and review the new fixes/updates for potentially breaking changes requiring attention. Use git log command.