Selenium/Hive-Nectar Turning Ecency Points into PeakePoints

Well, well... I had a little chat with @enginewitty about a few things that would make Hive as a whole a little more cohesive. So again I'm onto @thecrazygm and the Hive-Nectar (@nectarflower) API over the older BEEM API, which is great by the way and works just the same, it's just a little dated. I do however use Beem API on an older PC that I have difficulties upgrading Python to 3.12 on...fuckin' Raspberry Pi's "I tell ya what..."

My whole concept was that I'm an active @Ecency user, and if you're not familiar with it, you get points for utilizing the platform, which is super neat. Those are, however, only used on the Ecency Platform. So my thoughts were, what do we do to be able to make those things an actual asset for Hive's chain? I'm literally sitting here coding a headless interface that allows users to transfer Ecency Points for @PeakeCoin as well as the reverse.
I am using an alt account of @Peakecoin.bnb that I use for most coding inquiries as to not shall we say "screw the pooch"... I hope that's not your thing. I have not yet put this code into use. I am trying to secure a free server for some of this stuff, and I believe I have found one, so we'll see how that goes after I get it up and running.
import time
import csv
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from nectar.hive import Hive
from nectar.account import Account
from nectar.transactionbuilder import TransactionBuilder
from nectarbase.operations import Custom_json
# ---- CONFIG ---- #
HIVE_NODES = ["https://api.hive.blog", "https://anyx.io"]
HIVE_ACCOUNT = "peakecoin.bnb"
ACTIVE_KEY = "your_active_key_here" # <-- INSERT YOUR ACTIVE KEY HERE
PEK_TOKEN = "PEK"
SWAP_RATE = 0.001
ECENCY_POINTS_URL = "https://ecency.com/@peakecoin.bnb/points"
CHECK_INTERVAL = 60 # seconds between page checks
# ---- SETUP ---- #
# Setup Hive connection
hive = Hive(node=HIVE_NODES, keys=[ACTIVE_KEY])
account = Account(HIVE_ACCOUNT, blockchain_instance=hive)
# Setup Headless Chromium on Raspberry Pi
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--window-size=1920x1080")
chromedriver_path = "/usr/lib/chromium-browser/chromedriver"
driver = webdriver.Chrome(service=Service(chromedriver_path),
options=chrome_options)
# Ensure swap log exists
LOG_FILE = "swap_log.csv"
try:
with open(LOG_FILE, "x", newline="") as f:
writer = csv.writer(f)
writer.writerow(["timestamp", "username", "points", "pek_sent"])
except FileExistsError:
pass # File already exists
# Load processed usernames to avoid double swaps
processed = set()
with open(LOG_FILE, newline="") as f:
reader = csv.reader(f)
next(reader, None) # skip header
for row in reader:
if len(row) > 1:
processed.add(row[1])
# ---- FUNCTIONS ---- #
def send_pek(to_account, points_amount):
pek_amount = points_amount * SWAP_RATE
payload = {
"contractName": "tokens",
"contractAction": "transfer",
"contractPayload": {
"symbol": PEK_TOKEN,
"to": to_account,
"quantity": str(round(pek_amount, 8)),
"memo": "Ecency Points Swap"
}
}
tx = TransactionBuilder(blockchain_instance=hive)
op = Custom_json(
required_auths=[HIVE_ACCOUNT],
required_posting_auths=[],
id="ssc-mainnet-hive",
json=payload
)
tx.appendOps(op)
tx.appendSigner(HIVE_ACCOUNT, "active")
tx.sign()
tx.broadcast()
print(f"✅ Sent {pek_amount} {PEK_TOKEN} to {to_account}")
return pek_amount
def monitor_swaps():
print("🚀 Starting Ecency Points Swap Bot...")
while True:
try:
driver.get(ECENCY_POINTS_URL)
time.sleep(5) # let the page load
notifications = driver.find_elements(By.CLASS_NAME, "items-center")
for note in notifications:
text = note.text.lower()
if "points" in text and "peakecoin transfer" in text:
# Extract username and points
try:
parts = text.split(" ")
from_index = parts.index("from")
username = parts[from_index + 1].lstrip("@").strip()
points = int([p for p in parts if p.isdigit()][0])
if username not in processed:
print(f"🔍 Swap found: {username} sent {points} Points")
pek_sent = send_pek(username, points)
with open(LOG_FILE, "a", newline="") as f:
writer = csv.writer(f)
writer.writerow([time.strftime("%Y-%m-%d %H:%M:%S"), username, points, pek_sent])
processed.add(username)
except Exception as e:
print(f"⚠️ Error parsing notification: {e}")
except Exception as e:
print(f"❌ Error during page check: {e}")
time.sleep(CHECK_INTERVAL)
# ---- RUN ---- #
if __name__ == "__main__":
monitor_swaps()
I'm not overly familiar with how a headless Chromium and Selenium's API will work if at all. This is the closest I have gotten, and it seems like it should logically work. As always, I'm looking for critiques.
I appreciate all views, votes, shares, and forks of the code.
Honestly, tokenizing a broker-coin for ecency points is an amazing idea!!! Talk about utility, these can be used for HP delegations!
In terms of tokenomics, are you going to take like a 1% fee / "value rake" on these in and outs? Free work doesnt work, long term - it never does.
I really haven't even gotten there yet. I have only debugged the code, I've yet to implement it. A fee would probably be charged, something that can't be built and maintained for free. It's just like you say, anything can be done for free... but it's going to maintain a lower quality effort.
Hmm. What do you want to do with the Peakecoin compared to Ecency Points?
!pakx
Can you be more concise?
What version of python is on the raspberry pi? I only set it to 3.12 as that is the standard stable version of python at the moment, but I do not believe it's making use of anything specific to the later versions. I could drop the requirement version if you think that's the only thing stopping it from working right, I do think even 3.10 is still considered "in play" as in not depreciated.
I have an older Pi that doesn't like it. The Pis operate on 3.10 basically.
I'll bump the requirements down to 3.10 for version 0.0.7 (which should be in the next day or so, as soon as i'm done bug testing) so you should be able to use it on the pi after that.
Word