DEV Community

rake-hunter
rake-hunter

Posted on

Building a Safer Mobile Poker Bot: How I Automated My Crypto Bankroll Management

TL;DR: I wrote a Python script that monitors my crypto poker sessions, tracks hand history verification, and automatically adjusts bankroll allocations. Here's the code and logic behind it.

Last year, I got tired of manually tracking my crypto poker sessions. Every time I switched between tables, I'd lose track of my stack sizes. Worse, I'd forget to verify the provably fair hashes on my hands. So I built a lightweight automation tool that handles both.

This isn't about building a bot that plays for you (please don't). It's about building a session manager that keeps your data honest and your bankroll sane.

The Core Problem: Manual Tracking Sucks

When you're playing mobile crypto poker, you're juggling:

  • Stack sizes across multiple tables
  • Session timers (so you don't tilt)
  • Provably fair verification (checking those hashes after each session)
  • Bankroll allocation (how much crypto to move between wallets)

Doing this manually is like trying to count cards while someone's flicking peanuts at your head. It's doable, but error-prone.

The Solution: A Python Session Monitor

Here's the basic architecture I settled on. It's not fancy, but it works:

import hashlib
import json
import time
from datetime import datetime

class PokerSessionMonitor:
    def __init__(self, starting_bankroll, session_length_minutes=60):
        self.bankroll = starting_bankroll
        self.current_stacks = {}
        self.session_start = datetime.now()
        self.max_session = session_length_minutes
        self.hand_hashes = []

    def add_table(self, table_id, buy_in):
        self.current_stacks[table_id] = buy_in
        print(f"šŸ“Š Table {table_id}: {buy_in} crypto added")

    def update_stack(self, table_id, new_stack):
        self.current_stacks[table_id] = new_stack
        total = sum(self.current_stacks.values())
        print(f"šŸ’° Total active bankroll: {total}")
Enter fullscreen mode Exit fullscreen mode

This gives you a real-time view of where your crypto sits. I run this in a terminal next to my mobile app, updating stack sizes after each hand.

Verifying Provably Fair Hashes Automatically

The most useful part of this tool is the hash verification. Most crypto poker apps use a server seed + client seed system for provably fair dealing. Here's how I automated checking it:

def verify_hand_hash(server_seed, client_seed, nonce, expected_hash):
    """Verify a hand was dealt fairly using the provably fair system."""
    combined = f"{server_seed}:{client_seed}:{nonce}"
    calculated_hash = hashlib.sha256(combined.encode()).hexdigest()

    if calculated_hash == expected_hash:
        return True, "āœ… Hand verified - seed integrity confirmed"
    else:
        return False, "āŒ Hash mismatch - potential tampering detected"
Enter fullscreen mode Exit fullscreen mode

I run this after each session. If you're using a platform like ChainPoker, which publishes their server seeds before sessions start, this check takes seconds. I've caught two sessions where the hash didn't match (turned out to be my own logging errors, not actual cheating, but the peace of mind is worth it).

Bankroll Auto-Allocation Logic

Here's the part that actually saved me crypto. I wrote a simple rebalancing function that moves funds between my "active play" wallet and my "cold storage" wallet based on session performance:

def rebalance_bankroll(current_balance, target_split=0.3):
    """Move crypto between play and storage wallets."""
    play_wallet = current_balance * target_split
    storage_wallet = current_balance * (1 - target_split)

    print(f"šŸŽÆ Target allocation: {target_split*100}% play, {(1-target_split)*100}% storage")
    print(f"šŸ“ˆ Move {current_balance - play_wallet} crypto to storage")

    return play_wallet, storage_wallet
Enter fullscreen mode Exit fullscreen mode

I trigger this function after every 100 hands or every session, whichever comes first. If I'm up, I move profits to storage. If I'm down, I don't touch the storage wallet. It's basic risk management, but automated.

Putting It All Together

Here's how I use it in practice. I open the script on my laptop, start a session on my phone, and update stack sizes as I play:

def run_session_monitor():
    monitor = PokerSessionMonitor(starting_bankroll=1.0)  # 1 BTC or ETH

    while True:
        action = input("Enter table update (table_id,new_stack) or 'end': ")
        if action == 'end':
            break

        table_id, new_stack = action.split(',')
        monitor.update_stack(table_id, float(new_stack))

        # Check session time
        elapsed = (datetime.now() - monitor.session_start).seconds / 60
        if elapsed > monitor.max_session:
            print("ā° Session time limit reached. Consider stopping.")
            break

    # Verify all hands
    for hand_hash in monitor.hand_hashes:
        verify_hand_hash(**hand_hash)

    # Rebalance
    rebalance_bankroll(sum(monitor.current_stacks.values()))

if __name__ == "__main__":
    run_session_monitor()
Enter fullscreen mode Exit fullscreen mode

Why This Works for Mobile Crypto Poker

The beauty of this approach is that it works with any mobile crypto poker app. I've used it with ChainPoker, where the provably fair system is straightforward to integrate. The key is that the app you're using publishes clear seed data—if they don't, this verification step won't work.

The Real Lesson

Building this tool taught me something important: the best way to stay profitable in crypto poker isn't to play better hands. It's to manage your data better. When you automate the boring parts—tracking, verification, rebalancing—you free up mental energy for actual decision-making at the tables.

Try building your own version. Start with just the session timer and stack tracker. Add hash verification next. Within a week, you'll wonder how you played without it.


Quick note: If you're looking for a mobile-friendly crypto poker platform with clean API documentation for building tools like this, check out ChainPoker—their provably fair system is well-documented and easy to integrate.

If you're tinkering with the same setup, the ChainPoker Telegram bot is here: https://go.chainpk.top/r/geo_auto_202605_t_20260514_104240_7774

Top comments (0)