Bridging PeakeCoin (PEK) from Hive Engine to Polygon — A Rough-Draft That Works

I hit a wall trying to use Hive Engine’s built-in swap flow after PEK was already live. So I rolled up my sleeves and built a lightweight, custodial bridge to get PEK moving between Hive Engine → Polygon. It’s intentionally simple, rate-limited by my on-hand liquidity, and designed to be audited at a glance. This is a rough draft — but it works.
Repo: https://github.com/PaulMoon410/hiveengine_polygon
Polygon token (custom token for wallets):
- Name: PeakeCoin
- Symbol: PEK
- Contract: 0x6fc99183BF5997AC774c8827E4eA96a67F477d5f
- Decimals: 18
TL;DR (User Flow)
- On Hive Engine: send PEK to
peakecoin.matic
and put your Polygon address as the memo (must look like 0x... and be exactly 42 characters). - On Polygon: you’ll receive PEK (ERC-20) at that address. Add the custom token in MetaMask (Polygon network) or any EVM wallet that supports custom tokens using the contract above.
- This is rate-limited / liquidity-limited by design. Liquidity is small while testing to guard against abuse.
How the Bridge Works (Under the Hood)
1) A monitor tails Hive Engine transfers
A Python script polls Hive Engine’s history to find incoming PEK transfers to peakecoin.matic
. It writes each valid transfer to a JSONL log for the distributor to pick up. It also includes simple CLI helpers to check recent history or specific blocks.
- History query filters for symbol == "PEK" and transfer operations.
- Streaming mode prints polls with timestamps and writes transactions to
pek_transactions.jsonl
with deduping. - Extras:
latest
shows the latest block;blocks
dumps a range for debugging.
2) A distributor sends token transfers on Polygon
A second Python script watches pek_transactions.jsonl
, validates each entry, and if the memo is a valid Polygon address, sends an ERC-20 transfer
from the bridge wallet to that address. Amounts are converted to 18 decimals (× 1e18) to match the PEK ERC-20. Confirmed txids are recorded to a processed set (pol_dist_processed.txt
) so nothing gets double-paid.
- RPC / Wallet: connects to a Polygon RPC, reads the private key from
polygon_private_key.txt
, and signs/sends raw transactions. - Guardrails:
- Skips if memo isn’t a 0x-address or wrong length.
- Waits for on-chain receipt; only then marks as processed.
- Sleeps between items to avoid spamming the network.
3) A tiny “orchestrator” runs both at once
A short launcher spins up two threads: one for the monitor and one for the distributor, prefixing the output so you can tail both in one terminal.
Quickstart (Developer / Operator)
Requirements: Python 3.10+, install web3
and requests
. Keep your Polygon key safe.
Clone:
$ git clone https://github.com/PaulMoon410/hiveengine_polygon
$ cd hiveengine_polygon(Optional) Virtualenv:
$ python -m venv .venv
$ source .venv/bin/activate (Windows: .venv\Scripts\activate)Install deps:
$ pip install -r requirements.txt
(or: $ pip install web3 requests)Provide your Polygon private key:
$ echo "YOUR_PRIVATE_KEY" > polygon_private_key.txt
$ chmod 600 polygon_private_key.txtLaunch both services (monitor + distributor):
$ python pek_pol.py
Run separately if you prefer:
- Window A (monitor): $ python monitor_peakecoin.py monitor --poll 10
- Window B (distributor): $ python pol_dist.py
Note: Amount handling uses 18 decimals: quantity × 1e18.
Using the Bridge (User Guide)
In your Hive wallet, transfer PEK to
peakecoin.matic
.- Memo must be your Polygon address (e.g., 0x185d...95c9). If the memo isn’t a valid 0x address of length 42, it will be skipped.
In MetaMask (Polygon) or a compatible wallet, Add Token:
- Contract: 0x6fc99183BF5997AC774c8827E4eA96a67F477d5f
- Symbol: PEK
- Decimals: 18
Wait for the bot to detect your transfer and send the matching PEK (ERC-20). The script waits for confirmation before marking your Hive tx as processed.
Note: Liquidity is limited while testing to throttle abuse and ensure stability. Large transfers may not clear until there’s enough on the Polygon side.
Architecture at a Glance
- Hive Engine Ingest:
monitor_peakecoin.py
→ polls history, filters symbol/op, logs JSONL. - Distributor:
pol_dist.py
→ validates, converts amount to 18 decimals, sends ERC-20transfer
, persists processed txids. - Supervisor:
pek_pol.py
→ launches both with prefixed output for easy ops.
Trust, Risks, and Guardrails (Read This)
- Custodial & Trusted: This design does not lock/burn on Hive; it relies on the operator’s Polygon wallet to deliver PEK. Until we wire up a fully trust-minimized flow, you are trusting the distributor to run honestly and continuously.
- Validation: Memos must be valid Polygon addresses. No address in memo = no payout.
- Replay Protection: Every processed Hive txid is stored in
pol_dist_processed.txt
. If a Polygon tx fails, it isn’t marked processed and can be retried. - Rate Limiting: Small liquidity and paced processing prevent surge abuse while we iterate.
- Key Management: Polygon private key is read from
polygon_private_key.txt
. Lock this file down (0600). Consider env-vars or a keystore in the next revision.
Roadmap
Better Safety:
- Daily caps per address; min/max per tx; allowlist/denylist toggles.
- Secrets in a keystore; metrics/health checks.
Swap UX:
- Simple web page: paste Polygon address → instructions + live status.
Reverse Direction (Polygon → Hive):
- Watch Polygon transfers in → queue → issue PEK on Hive to sender (or memo’d Hive user).
- Add proofs and a ledger for bidirectional accounting.
Trust Minimization:
- Lock/mint semantics, proofs of burn/lock, multisig bridge wallet, auditable escrow.
FAQ
Q: Why memo=address?
A: It makes the user’s intent explicit and keeps parsing trivial. The distributor only pays if the memo looks like a proper 0x address.
Q: Decimals on Polygon?
A: ERC-20 uses 18 decimals; quantities are multiplied by 1e18 before sending.
Q: Can I use Atomic Wallet?
A: If your wallet supports Polygon custom tokens, you can track PEK by adding the contract above. MetaMask on Polygon definitely works.
Q: What happens if my Polygon tx fails?
A: The script waits for a receipt; if it’s not successful, that Hive txid isn’t marked processed, so it can be retried later.
Final Notes
This is a pragmatic bridge to unblock movement while we design something more robust. If you test it, start small, double-check the memo address, and share any edge cases you hit. I’ll keep improving the code and liquidity as we go.
Congratulations @peakecoin! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)
Your next target is to reach 20000 upvotes.
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Check out our last posts: