import random
import time
from beem import Hive
from beem.account import Account
from beem.exceptions import VoteWeightTooSmall
Configure the Hive node you want to connect to
hive_node = 'https://api.hive.blog' # Replace with the desired Hive node URL
Set your account credentials
account_name = 'your_account_name' # Replace with your Hive account name
private_key = 'your_private_posting_key' # Replace with your Hive private posting key
Set the voting parameters
voting_power_threshold = 90 # Minimum voting power required to vote (in percentage)
vote_delay = 30 # Delay between each vote in seconds
def random_vote():
# Connect to the Hive node
hive = Hive(node=hive_node)
# Instantiate your account
account = Account(account_name, hive=hive)
# Get the current voting power of your account
voting_power = account.get_voting_power()
# Check if voting power is above the threshold
if voting_power >= voting_power_threshold:
# Get a random post from the blockchain
post = random.choice(account.history_reverse(filter_by="comment"))
# Get the author and permlink of the post
author = post['author']
permlink = post['permlink']
try:
# Vote on the post
account.vote(weight=random.randint(1, 100), identifier=f"@{author}/{permlink}")
# Print the successful vote
print(f"Voted on post by @{author}/{permlink}")
except VoteWeightTooSmall:
# Print an error message if the vote weight is too small
print("Vote weight is too small")
else:
# Print a message if voting power is below the threshold
print("Voting power is below the threshold")
# Delay between each vote
time.sleep(vote_delay)
Execute the script indefinitely
while True:
random_vote()