<?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: Waleed</title>
    <description>The latest articles on DEV Community by Waleed (@waleed_7c).</description>
    <link>https://dev.to/waleed_7c</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3838229%2F861f4a76-93b1-49ef-bf53-713cc7e6a0ed.png</url>
      <title>DEV Community: Waleed</title>
      <link>https://dev.to/waleed_7c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/waleed_7c"/>
    <language>en</language>
    <item>
      <title>I built a multiplayer crypto price prediction game using Pyth Network oracles</title>
      <dc:creator>Waleed</dc:creator>
      <pubDate>Sun, 22 Mar 2026 10:45:37 +0000</pubDate>
      <link>https://dev.to/waleed_7c/i-built-a-multiplayer-crypto-price-prediction-game-using-pyth-network-oracles-84c</link>
      <guid>https://dev.to/waleed_7c/i-built-a-multiplayer-crypto-price-prediction-game-using-pyth-network-oracles-84c</guid>
      <description>&lt;p&gt;A few weeks ago I started wondering, what if you could turn live crypto price data into a competitive multiplayer game? No wallets, no tokens, no risk. Just raw price feeds and your instincts.&lt;br&gt;
That became Price Royale.&lt;br&gt;
&lt;strong&gt;What it is&lt;/strong&gt;&lt;br&gt;
Price Royale is a free-to-play PvP game where players predict whether ETH, BTC, or SOL will go UP or DOWN within a configurable time window (15–90 seconds). Multiple players join the same room, everyone locks in their prediction, and a live Pyth oracle price feed settles the outcome when time runs out.&lt;br&gt;
The thing I'm most proud of: your entry price is recorded at the exact moment you click,`` not the round start price. So if you wait 20 seconds before committing, you're betting from a different baseline than someone who clicked immediately. It creates real strategy around timing.&lt;br&gt;
&lt;strong&gt;Why Pyth specifically&lt;/strong&gt;&lt;br&gt;
I needed price feeds that were:&lt;/p&gt;

&lt;p&gt;Fast enough to update during a 60-second game round&lt;br&gt;
Accurate enough that players would trust the settlement&lt;br&gt;
Easy to integrate without blockchain complexity&lt;/p&gt;

&lt;p&gt;Pyth's Hermes REST API fit perfectly. Three feeds, one endpoint, polling every 3 seconds:&lt;br&gt;
&lt;code&gt;jsconst res = await axios.get(&lt;br&gt;
  &lt;/code&gt;&lt;a href="https://hermes.pyth.network/v2/updates/price/latest?ids%5B%5D=$%7BfeedId%7D%60%7B%" rel="noopener noreferrer"&gt;https://hermes.pyth.network/v2/updates/price/latest?ids[]=${feedId}`{%&lt;/a&gt; endraw %}&lt;br&gt;
);&lt;br&gt;
const price = res.data.parsed[0].price.price * Math.pow(10, expo);{% raw %}&lt;code&gt;&lt;br&gt;
But the feature I didn't expect to love: the confidence interval. Every Pyth price comes with a conf value representing the spread of oracle reports. I use this as a score multiplier — when the CI is wide (market is uncertain/volatile), a correct prediction earns up to 1.5× points. Players who time their commits during high-volatility moments get rewarded more.&lt;br&gt;
&lt;/code&gt;jsconst confBps = (conf / price) * 10000;&lt;br&gt;
let ciMultiplier = 1.0;&lt;br&gt;
if (confBps &amp;gt;= 50)      ciMultiplier = 1.5;&lt;br&gt;
else if (confBps &amp;gt;= 25) ciMultiplier = 1.25;&lt;br&gt;
else if (confBps &amp;gt;= 10) ciMultiplier = 1.1;`&lt;br&gt;
It's a small touch but it makes the game feel genuinely connected to real market conditions.&lt;br&gt;
&lt;strong&gt;The architecture&lt;/strong&gt;&lt;br&gt;
Backend is Node.js + Express + Socket.io. Frontend is Vite + React. No blockchain, no wallet connection required — just username/password or Discord OAuth.&lt;br&gt;
The real-time game loop runs entirely over WebSockets:&lt;/p&gt;

&lt;p&gt;Host creates a room, shares the 6-letter code&lt;br&gt;
Players join and see the live price ticker&lt;br&gt;
Host starts, a 30-second commit window opens&lt;br&gt;
Each player picks UP or DOWN (their personal entry price is snapped at that moment)&lt;br&gt;
Chart keeps running after commit window closes&lt;br&gt;
At round end, Pyth settles, result screen shows who was right, with CI/speed/streak bonuses&lt;/p&gt;

&lt;p&gt;Three game modes: custom rooms, Quick Royale (auto-start when 2+ join), and Tournament (bracket elimination, 4–32 players).&lt;br&gt;
&lt;strong&gt;Hardest bug I hit&lt;/strong&gt;&lt;br&gt;
The scariest moment was discovering that socket.join() in Socket.io v4 is async, it returns a Promise. I wasn't awaiting it. So when a player's socket reconnected and I transferred their room membership to the new socket before disconnecting the old one, the join hadn't actually completed yet. The game:starting broadcast fired, but the new socket wasn't in the room channel. Players would click Start and just... sit there. Spent way too long on this one.&lt;br&gt;
Fix was two lines:&lt;br&gt;
&lt;code&gt;jsawait socket.join(prevSocket.currentRoomId);&lt;/code&gt;&lt;br&gt;
*&lt;em&gt;Stack&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Frontend: React 18 (Vite), Socket.io-client, TradingView Lightweight Charts&lt;br&gt;
Backend: Node.js, Express, Socket.io&lt;br&gt;
Database: MongoDB Atlas&lt;br&gt;
Oracle: Pyth Network Hermes REST API&lt;br&gt;
Auth: JWT + Discord OAuth2&lt;br&gt;
Deployed: Railway (backend), Vercel (frontend)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it&lt;/strong&gt;&lt;br&gt;
Live: &lt;a href="https://price-royale.vercel.app" rel="noopener noreferrer"&gt;https://price-royale.vercel.app&lt;/a&gt;&lt;br&gt;
Code: &lt;a href="https://github.com/waleedbhattiii/price-royale" rel="noopener noreferrer"&gt;https://github.com/waleedbhattiii/price-royale&lt;/a&gt;&lt;br&gt;
Would love feedback, especially if you find edge cases in the tournament bracket logic. That part was its own adventure.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>cryptocurrency</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
