<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kenny</title>
    <description>The latest articles on DEV Community by Kenny (@kennyrei).</description>
    <link>https://dev.to/kennyrei</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4275259%2F6d1c7491-4c7f-4167-9fce-e5849b802e71.png</url>
      <title>DEV Community: Kenny</title>
      <link>https://dev.to/kennyrei</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kennyrei"/>
    <language>en</language>
    <item>
      <title>Building a Duel System: The Engineering Challenges of Real-Time PvP in Crypto Gaming</title>
      <dc:creator>Kenny</dc:creator>
      <pubDate>Thu, 03 Dec 2026 16:00:21 +0000</pubDate>
      <link>https://dev.to/kennyrei/building-a-duel-system-the-engineering-challenges-of-real-time-pvp-in-crypto-gaming-4497</link>
      <guid>https://dev.to/kennyrei/building-a-duel-system-the-engineering-challenges-of-real-time-pvp-in-crypto-gaming-4497</guid>
      <description>&lt;p&gt;Most crypto gaming platforms are single-player experiences. You play against the house. The house doesn't have a name. The house doesn't make decisions. The house just... is there.&lt;br&gt;
Kampus added duels. And that changes the engineering problem entirely.&lt;br&gt;
I've been playing Kampus for 3 weeks. I've done about 40 duels. And I got curious: what does it actually take to build a real-time PvP system on top of a crypto gaming platform? Not the math. Not the house edge. The engineering. The infrastructure. The "how do you actually make this work" stuff.&lt;br&gt;
Here's what I think is happening under the hood, based on what I've observed playing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The matchmaking problem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When I click "Duel," I'm not instantly connected to another player. It takes 3-8 seconds depending on the time of day. That's the matchmaking phase.&lt;/p&gt;

&lt;p&gt;The system needs to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find another player who's also looking for a duel&lt;/li&gt;
&lt;li&gt;Match us on the same game (I want Crash, they want Crash)&lt;/li&gt;
&lt;li&gt;Match us on a similar bet amount (I'm betting $5, they're betting $5)&lt;/li&gt;
&lt;li&gt;Lock both of us in&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is a classic player matchmaking problem. In theory, it's simple: "find another user with the same game and similar bet." In practice, it's not. Because the pool of active players is small.&lt;br&gt;
During peak hours (18:00-24:00 UTC-3 in Argentina), the pool is bigger. I get matched in 3-4 seconds. During off-peak (00:00-06:00), the pool is tiny. I get matched in 8-10 seconds, or I don't get matched at all.&lt;br&gt;
**&lt;br&gt;
The synchronization problem.**&lt;/p&gt;

&lt;p&gt;In a duel, both players are playing the same round. The same Crash multiplier. The same Dice spin. But we're on different devices, in different locations, with different network conditions.&lt;br&gt;
How do you make sure we both see the same result?&lt;br&gt;
From what I've observed: the server is the source of truth. I don't "play" the round. The server plays the round. I send my decision (cash out at 2.1x, or hold). The server records my decision. The server records the other player's decision. The server determines the winner.&lt;/p&gt;

&lt;p&gt;This is important. It means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I can't "cheat" by modifying my client&lt;/li&gt;
&lt;li&gt;The other player can't "cheat" by modifying their client&lt;/li&gt;
&lt;li&gt;The server sees both decisions and makes the call&lt;/li&gt;
&lt;li&gt;If my connection drops mid-round, the server still records the other player's decision and resolves the round&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the round&lt;br&gt;
I've experienced a connection drop mid-duel once. I was at 1.8x, the multiplier was going up, and my screen froze. When it came back, the round was already resolved. The other player cashed out at 2.3x. I was still "holding." I lost. The server made the call. My frozen screen didn't matter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fairness problem (in PvP specifically).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In a single-player game, "fairness" means "the result is provably random." In PvP games, "fairness" means "both players got the same conditions."&lt;/p&gt;

&lt;p&gt;This is a different problem. It's not about the math. It's about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Did both players see the same multiplier at the same time?&lt;/li&gt;
&lt;li&gt;Did both players have the same "cash out" window?&lt;/li&gt;
&lt;li&gt;Did one player get an advantage from lower network latency (faster reaction)?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From what I've observed, Kampus handles this by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The server broadcasts the multiplier to both players simultaneously&lt;/li&gt;
&lt;li&gt;The "cash out" window is the same for both (you can cash out at any point before the crash)&lt;/li&gt;
&lt;li&gt;The server records the timestamp of each player's decision&lt;/li&gt;
&lt;li&gt;If there's a tie (both cash out at the same multiplier), the server breaks it by timestamp (whoever clicked first wins)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I've had one tie. Both of us cashed out at 2.1x. The server gave the win to the other player. Their timestamp was 3ms earlier. I didn't argue. 3ms is 3ms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The state management problem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A duel has states:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Matching — Looking for an opponent&lt;/li&gt;
&lt;li&gt;Pre-round — Both players confirmed, game selected, bet set&lt;/li&gt;
&lt;li&gt;In-round — The game is playing, both players can make decisions&lt;/li&gt;
&lt;li&gt;Resolved — The round is over, winner determined&lt;/li&gt;
&lt;li&gt;Post-round — Results shown, KP awarded, "rematch?" prompt&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each state transition needs to be atomic. If I'm in "In-round" and the other player disconnects, the system needs to handle that gracefully. It can't just "crash." It needs to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mark the other player as "disconnected"&lt;/li&gt;
&lt;li&gt;Continue the round (or auto-resolve it)&lt;/li&gt;
&lt;li&gt;Award the win to the remaining player (or split the pot)&lt;/li&gt;
&lt;li&gt;Update both players' state&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I've seen this happen. The other player disconnected mid-Crash. The round continued. I cashed out at 1.5x. I won. The other player's "disconnected" status was shown on my screen. No drama. No "wait, what happened?" Just a clean resolution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The anti-cheat problem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In a single-player game, anti-cheat means "the server generates the result, not the client." In a PvP game, anti-cheat means "neither player can influence the other player's experience."&lt;/p&gt;

&lt;p&gt;Specifically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I can't see the other player's "intended" cash-out point before they make it&lt;/li&gt;
&lt;li&gt;I can't see the other player's bet amount before the round starts (or can I? From what I've seen, I can see their bet before the round starts. That's fair. It's part of the "matching" — we agreed on the same bet)&lt;/li&gt;
&lt;li&gt;I can't "lag" my cash-out to make it look like I cashed out later than I did (the server records the timestamp of my request, not the timestamp of my screen)&lt;/li&gt;
&lt;li&gt;The other player can't "rubber band" their connection to make it look like they were "holding" when they were actually "cashed out"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From what I've observed, the server is the only entity that knows the "true" state of the round. Both players are just receiving updates. Neither player has "more truth" than the other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The scaling problem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Kampus has a small player base. Duels work because the pool is small. Matching takes 3-8 seconds because there are enough people online.&lt;br&gt;
But what happens when the player base grows 10x? 100x?&lt;br&gt;
The matching pool gets bigger. Matching gets faster. But the server load increases. Every duel is a real-time connection between two players. That's a WebSocket connection. That's state that needs to be maintained. That's a server process that's "alive" for the duration of the round.&lt;br&gt;
At 100 concurrent duels, that's 100 WebSocket connections. At 1,000 concurrent duels, that's 1,000. At 10,000, that's 10,000.&lt;br&gt;
The infrastructure needs to scale. Not just "more servers." It needs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Regional servers (so a player in Buenos Aires is matched with another player in Buenos Aires, not a player in Tokyo)&lt;/li&gt;
&lt;li&gt;Load balancing (so one server isn't handling 500 duels while another handles 50)&lt;/li&gt;
&lt;li&gt;State management (so if a server dies mid-duel, the round isn't lost)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I don't know what Kampus is doing on this front. I don't have access to their architecture. But I know that the current system works for ~50-100 concurrent players. And that's the right scale for a small platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I'd want to see (as a player):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A "duel history" page. Not just "you won/lost." But: "You played 42 duels. 24 wins. 18 losses. Win rate: 57%. Most played game: Crash. Longest winning streak: 4."&lt;/li&gt;
&lt;li&gt;A "rematch" button that actually works. I lose a duel. I want to rematch. The other player wants to rematch. We should be able to click "Rematch" and be back in the lobby in 2 seconds. Not 8 seconds. Not "wait for matching."&lt;/li&gt;
&lt;li&gt;A "spectate" mode. I'm not in a duel. I want to watch one. I want to see the multiplier going up. I want to see both players' decisions. I want to feel the tension without betting.&lt;/li&gt;
&lt;li&gt;A "duel streak" indicator. "You're on a 3-0 streak." "You're on a 0-3 streak." Not for ego. For the "I'm on a roll" feeling. And for the "I'm due for a win" feeling (which is irrational, but real).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The bottom line:&lt;br&gt;
Building a duel system is not "add a PvP button." It's a real-time infrastructure problem. It's matchmaking, synchronization, state management, anti-cheat, and scaling. All at once. All in real-time. All with a small player base that can't afford to have the system "feel" slow.&lt;br&gt;
Kampus pulled it off. Not perfectly. Matching takes 3-8 seconds. There's no spectate mode. There's no duel history. But the core works. Two players play the same round. The server makes the call. The result is fair.&lt;br&gt;
And that's enough. For now. For a small platform. For 40 duels in 3 weeks.&lt;br&gt;
It's not a perfect system. But it's a real system. And that's more than the other 5 platforms I tested can say.&lt;/p&gt;

&lt;p&gt;Resources:&lt;br&gt;
Kampus: kampus.gg&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>gamedev</category>
      <category>infrastructure</category>
    </item>
    <item>
      <title>How Provably Fair Actually Works: A Developer's Breakdown (With Real Examples from 2 Platforms)</title>
      <dc:creator>Kenny</dc:creator>
      <pubDate>Wed, 02 Dec 2026 09:39:52 +0000</pubDate>
      <link>https://dev.to/kennyrei/how-provably-fair-actually-works-a-developers-breakdown-with-real-examples-from-2-platforms-ghm</link>
      <guid>https://dev.to/kennyrei/how-provably-fair-actually-works-a-developers-breakdown-with-real-examples-from-2-platforms-ghm</guid>
      <description>&lt;p&gt;I've been playing crypto gaming platforms for 3 weeks and decided to actually look at how the "provably fair" claim works under the hood. Most articles just say "it's SHA-256 hashing." That's not how it works in practice. Here's the real breakdown.&lt;br&gt;
The commit-reveal scheme using the SHA256 hash function (simplified):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Server generates: server_seed (random 64-byte string)&lt;/li&gt;
&lt;li&gt;Server computes: server_seed_hash = SHA256(server_seed)&lt;/li&gt;
&lt;li&gt;Server publishes: server_seed_hash (before the round)&lt;/li&gt;
&lt;li&gt;User provides: client_seed (user-controlled string)&lt;/li&gt;
&lt;li&gt;Result = f(server_seed, client_seed, game_params)&lt;/li&gt;
&lt;li&gt;After round: Server reveals server_seed&lt;/li&gt;
&lt;li&gt;User verifies: SHA256(server_seed) == server_seed_hash ✓
The problem most crypto gaming platforms have:
The math is sound. The UX is not.
On Stake, step 7 requires:
Navigating to a separate "Fairness" page
Finding the specific round (by ID or timestamp)
Copying the hash
Pasting it into a verification tool
Comparing the result
That's 4+ clicks and ~45 seconds. In practice, &amp;lt;5% of users ever do this.
What Kampus does differently:
The server_seed_hash is displayed in the game UI before each round
After the round, a "Verify" button is visible
One click → verification result shown
Total time: ~8 seconds
The cryptographic implementation is identical to Stake. The difference is friction.
Why friction matters (from a security perspective):
A provably fair system that 95% of users never verify is functionally equivalent to a non-verifyable system. The trust model depends on users actually checking. If the verification UX is bad, the "provably fair" claim is marketing, not a feature.
What I'd recommend if you're building this:
Show the hash in-game, not on a separate page
Make verification 1 click, not 4
Show the verification result in plain language ("✓ This result is fair" / "✗ Mismatch")
Log verification history so users can go back and check old rounds
Let users set their own client seed (don't auto-generate it)
TL;DR: The math is the same everywhere. The UX is where platforms differ. If you can't verify a result in under 10 seconds, it's not a feature, it's a checkbox.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Resources:&lt;br&gt;
Kampus: kampus.gg &lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>crypto</category>
      <category>security</category>
      <category>web3</category>
    </item>
  </channel>
</rss>
