This Python project automates the management of delegations and rewards on the Hive blockchain. It collects information from delegators, calculates rewards, processes payments, and generates detailed reports, in addition to sending notifications to Telegram and Discord.
The purpose of this project is to facilitate the management of Hive Power (HP) delegations for the Nexo Digital community, calculate HP rewards, automatically process payments, and generate reports. The script can be configured to run daily at a specific time and sends notifications with the payment status. It can also be adapted and used by any curation community on the Hive Blockchain.
-
Clone the repository and navigate to the project folder:
git clone https://github.com/sousafrc/payment-delegators-nexo-digital.git cd payment-delegators-nexo-digital
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\Activate`
-
Install the dependencies:
pip install -r requirements.txt
Edit the .env-example
file at the root of the project to configure the environment variables. After that, save and rename it to .env
. Below is a configuration example:
RECEIVER_ACCOUNT=nexo.voter
PARTNER_ACCOUNTS=nexo.digital,nexo.witness,nexo.token
TOKEN_NAME=NEXO
TOKEN_FIXED_PRICE=0.1
HIVE_DEDUCTION_MULTIPLIER=2
ACTIVATE_PAYMENTS=True
PAYMENT_ACCOUNT=nexo.pool
HIVE_ENGINE_ACTIVE_PRIVATE_KEY=
HIVE_ENGINE_POSTING_PRIVATE_KEY=
IGNORE_PAYMENT_ACCOUNTS=
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=
DISCORD_BOT_TOKEN=
DISCORD_CHANNEL_ID=
- Ensure that the environment variables in the
.env
file are correctly configured. - Run the script:
python main.py
The script will run daily at the specified time if automation is enabled (AUTO_RUN=True
). It will process payments, generate reports, and send notifications to Telegram and Discord.
- fetch_delegators: Fetches information about delegations made to the specified account.
- get_account_info: Retrieves the Hive Power (HP) of the receiver account.
- get_partner_accounts: Retrieves partner accounts.
- get_ignore_payment_accounts: Retrieves accounts to be ignored in payments.
- calculate_earnings: Calculates the HP earnings of the receiver account compared to the previous period.
- calculate_additional_columns: Calculates percentages and HIVE deductions based on specific rules.
- process_payments: Processes reward payments for each eligible delegator.
- process_payment_for_delegator: Processes payment for a specific delegator.
- save_delegators_to_xlsx: Generates an XLSX file with detailed information about delegators and rewards.
- generate_status_message: Generates a detailed message about the payment status.
- send_telegram_file: Sends notifications with the log file to Telegram.
- send_discord_file: Sends notifications with the generated XLSX file to Discord.
- check_env_variables: Checks if all necessary environment variables are configured.
payment-delegators-nexo-digital/
├── data/
│ ├── log/
│ └── ...
├── modules/
│ ├── account_info.py
│ ├── calculations.py
│ ├── config.py
│ ├── discord_utils.py
│ ├── fetch_delegators.py
│ ├── logger.py
│ ├── memo_utils.py
│ ├── partners_info.py
│ ├── payments.py
│ ├── process_payment.py
│ ├── save_to_xlsx.py
│ ├── telegram_utils.py
│ ├── transaction.py
│ ├── utils.py
│ └── wallet_utils.py
├── .env
├── LICENSE.md
├── main.py
├── README.md
└── requirements.txt
- Fork the repository.
- Create a branch for your feature (
git checkout -b feature/new-feature
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature/new-feature
). - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for more details.
If you find this project useful, consider supporting the developer by donating any amount to the @sousafrc account on the Hive Blockchain!