New Tool: Claim Hive Rewards for Multiple Accounts Easily!

2 comments

thecrazygm552.132 days agoPeakD4 min read

Had an interesting little side job this morning helping a Hive user out. They needed to claim their pending HIVE/HBD rewards across a whole bunch of different accounts they manage, and it got me thinking about the hassle involved. Logging in and out of multiple accounts, even if it's just via Keychain clicks, solely to click 'Claim Rewards' can be a real headache, especially if you manage several accounts.

So, that little task inspired me to put together a more generic tool to streamline this process: introducing claim-rewards, a Python script designed to let you claim pending rewards for multiple Hive accounts using the posting authority of just one main account.

How Does It Work? (Leveraging Posting Authority)

The magic behind this script relies on Hive's flexible account authority system. Let's say you manage several accounts: alt-account1, alt-account2, alt-account3, etc., but you primarily use your-main-account. You need to grant posting authority from each of those alt accounts (alt-account1, alt-account2, etc.) to your-main-account. A straightforward way to manage these account authorities is by using our Hive Account Authority tool, which you can find right here:
https://thecrazygm.com/hivetools/account/authority

Once you've used the tool to grant the necessary posting authorities on the Hive blockchain, your-main-account gains the ability to perform posting-level actions – including claiming rewards! – on behalf of those other accounts. This script leverages that. You provide the posting key for your-main-account, and a list of all the accounts (your-main-account, alt-account1, alt-account2, etc.), and it iterates through, claiming rewards for each using your-main-account's granted authority.

Setup and Usage

The setup is pretty straightforward:

  1. Grant Authorities: Before running the script, you must grant posting authority from your alt accounts to your main account on the Hive blockchain. The script relies on these permissions being set correctly.

  2. Create accounts.yaml: Create a YAML file (by default, the script looks for accounts.yaml in the same directory, but you can specify a path using --accounts). This file lists all the accounts you want to process. Important: List your main account (the one whose posting key you'll use) first.

    # Example accounts.yaml
    # The first account is the authority account whose WIF will be used.
    # Ensure this account has been granted posting authority by the other accounts below.
    accounts:
      - your-main-account # WIF for this account is needed
      - alt-account1
      - alt-account2
      - some-other-account-you-manage
    # Optional: You can put the WIF here instead of using --wif or ENV var
    # wif: 5JYourPostingPrivateKeyHere
    
  3. Provide Posting Key: The script needs the posting WIF (private key) for your main account. You can provide it in one of three ways:

    • Add it directly to the accounts.yaml file (under the wif: key, see example above).
    • Pass it using the --wif command-line argument when running the script.
    • Set it as an environment variable named POSTING_WIF.
  4. Run the Script: Execute the script. Since it uses the uv run --script shebang, if you have uv installed, it should handle the dependencies (hive-nectar, pyyaml) automatically. Otherwise, you might need to install them manually first.

Seeing it in Action

Here's a quick look at the script running normally:

https://files.peakd.com/file/peakd-hive/thecrazygm/Eo44H4KmHixkf2n147vSNcRd8TvVkoSEbVCVztFSNnfmFRDT1xZeRk4ZhYuzksWp3rf.png

And here's an example with the --debug flag enabled for more verbose output, showing which accounts are being processed and what rewards are found:

https://files.peakd.com/file/peakd-hive/thecrazygm/23tRrM22rd2dEnCJ6ExGHjZ61MnMv21QaxzMraBSPhq2mK2Hzoc3FYKSQrZJwgZjZ2vkQ.png

Technical bit

For those curious about the code using hive-nectar, the core action happens with something like main_account.claim_reward_balance(account=target_account_name), where main_account is the Account object instantiated with your main account's WIF. Now I can put this bad boy in a cron job and never have to worry about the other accounts again!

Get the Tool!

The complete code, along with more detailed setup instructions and usage examples (including the handy --dry-run option to see what it would do without actually broadcasting anything), is available on GitHub:
https://github.com/TheCrazyGM/claim-rewards

Hopefully, this little utility saves some fellow Hive users the repetitive strain of clicking "Claim Rewards" across many accounts! Let me know if you find it useful!

As always,
Michael Garcia a.k.a. TheCrazyGMr

Comments

Sort byBest