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.
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.
The setup is pretty straightforward:
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.
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
Provide Posting Key: The script needs the posting WIF (private key) for your main account. You can provide it in one of three ways:
accounts.yaml
file (under the wif:
key, see example above).--wif
command-line argument when running the script.POSTING_WIF
.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.
Here's a quick look at the script running normally:
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:
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!
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
More excellent tools! I didn't even know that posting authority could be granted to another account, super cool, and you even made a too for that too! I'm really glad that I started following you, as I find and learn so much great stuff! 😁 🙏 💚 ✨ 🤙
very cool bud... very cool.