<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Prapti Sharma on Medium]]></title>
        <description><![CDATA[Stories by Prapti Sharma on Medium]]></description>
        <link>https://medium.com/@praptii?source=rss-6dd421fa5cdb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2S52a2DiNCpOv4Enxu4PAQ.jpeg</url>
            <title>Stories by Prapti Sharma on Medium</title>
            <link>https://medium.com/@praptii?source=rss-6dd421fa5cdb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 06:31:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@praptii/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Understanding DAMM v2: Solana’s Next-Gen Automated Market Maker]]></title>
            <link>https://medium.com/@praptii/understanding-damm-v2-solanas-next-gen-automated-market-maker-8106608e3967?source=rss-6dd421fa5cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8106608e3967</guid>
            <category><![CDATA[damm]]></category>
            <category><![CDATA[uniswap]]></category>
            <category><![CDATA[meteora]]></category>
            <category><![CDATA[solanas]]></category>
            <category><![CDATA[amm]]></category>
            <dc:creator><![CDATA[Prapti Sharma]]></dc:creator>
            <pubDate>Thu, 16 Oct 2025 10:45:52 GMT</pubDate>
            <atom:updated>2025-10-16T10:45:52.310Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a_a6mwhLJQ41C5L78G3mNg.png" /></figure><p>If one is familiar with decentralized exchanges like Uniswap, she/he knows how Automated Market Makers (AMMs) work. Solana’s <strong>DAMM v2</strong> (Dynamic Automated Market Maker v2) takes this concept to the next level, giving liquidity providers more control, efficiency, and rewards.</p><p>In this post, we’ll break down everything you need to know about DAMM v2 in a simple, easy-to-understand way. But before that, Let’s learn about DAMM v1. Let’s go.</p><h3>Understanding DAMM v1 -The Foundation of Dynamic Liquidity</h3><h4>1. Introduction</h4><p><strong>Meteora’s DAMM v1 (Dynamic Automated Market Maker)</strong> redefines how liquidity works on Solana.<br>Unlike traditional AMMs (like Uniswap v2), DAMM v1 adds a <strong>dynamic yield layer</strong> that makes idle liquidity productive by lending it out automatically — all while maintaining on-chain price discovery.</p><p>In short:</p><blockquote><strong><em>DAMM v1 = AMM + Yield Optimization via Dynamic Vaults</em></strong></blockquote><p>Liquidity Providers (LPs) can earn not just from trading fees, but also from the <strong>extra yield</strong> generated when idle funds are lent out to external lending protocols like <strong>Kamino</strong>, <strong>Solend</strong>, and <strong>MarginFi</strong>.</p><h3>2. How DAMM v1 Works</h3><p>At its core, DAMM v1 uses the <strong>constant product formula, </strong>the same one that powers Uniswap v2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/1*7DN5DT8ut8t_2G3uoKog6A.png" /><figcaption>Pretty basic, I know lol</figcaption></figure><p>Where:</p><ul><li><strong>x</strong> = amount of Token A</li><li><strong>y</strong> = amount of Token B</li><li><strong>k</strong> = constant product (the invariant)</li></ul><p>This formula ensures that whenever a trade happens, the product of the two token reserves remains constant.<br> As a trader swaps one token for another, the pool automatically adjusts the price to maintain equilibrium.</p><p>For example, if we swap USDC → SOL:</p><ul><li>USDC in the pool increases</li><li>SOL decreases<br> → The price of SOL rises to maintain <em>k</em> constant.</li></ul><h3>3. Liquidity Invariant (D)</h3><p>Another important metric used in DAMM v1 is the <strong>liquidity invariant (D)</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*ugWO-zdOmmflEVvGoNqvqA.png" /></figure><h4><strong>What It Means</strong></h4><p>This equation represents the <em>depth</em> of the pool’s liquidity.<br>If either token’s reserve drops drastically, the overall D value (liquidity depth) drops — meaning higher slippage for traders.</p><p>So:</p><ul><li><strong>Higher D → Deeper liquidity → Lower price impact</strong></li><li><strong>Lower D → Shallow liquidity → Higher price impact</strong></li></ul><p>This helps LPs visualize how balanced or unbalanced a pool is.</p><h3>4. Stable Pools Explained</h3><p><strong>Stable Pools</strong> in DAMM v1 are designed for <strong>stable assets</strong>, like:</p><ul><li>USDC–USDT</li><li>USDS–USDC</li></ul><p>Because these assets usually trade near a 1:1 ratio, DAMM v1 uses a <strong>StableSwap curve</strong> (inspired by Curve Finance) instead of the regular constant-product curve.</p><p>This StableSwap formula allows:</p><ul><li><strong>Low slippage swaps</strong></li><li><strong>Efficient trading near 1:1</strong></li><li><strong>Stable liquidity balance</strong></li></ul><p>Essentially, Stable Pools keep the pool ratio close to 1:1, ensuring we don’t lose value when swapping between stablecoins.</p><h3>5. AMP Factor, Amplification Explained</h3><p>Within stable pools, we’ll see something called <strong>AMP (Amplification factor)</strong>.</p><h4>Definition:</h4><p>The <strong>AMP factor</strong> controls <em>how concentrated</em> the liquidity is around the 1:1 price range.</p><ul><li><strong>High AMP</strong> → Liquidity is very concentrated near 1:1 (great for stablecoins).<br> → We get <em>very low slippage</em> for trades close to equal ratios.</li><li><strong>Low AMP</strong> → Liquidity spreads out more, like a normal AMM (better for volatile tokens).</li></ul><p>AMP helps the pool adjust how sensitive prices are to imbalance.<br>When the ratio starts drifting too far from 1:1, the curve charges <strong>more for unbalancing trades</strong> and <strong>less for rebalancing trades, </strong>keeping the pool stable and efficient.</p><h3>6. Dynamic Vaults-Where Yield Comes From</h3><p>Here’s where DAMM v1 gets its “Dynamic” name.</p><p>Each DAMM pool connects to <strong>Dynamic Vaults</strong>, a yield optimization layer that allocates idle liquidity into lending protocols like:</p><ul><li><strong>Kamino</strong></li><li><strong>Solend</strong></li><li><strong>MarginFi</strong></li></ul><p>An off-chain keeper named <strong>Hermes</strong> rebalances funds every minute across these protocols to maximize yield and reduce risk.</p><p><strong>How it works:</strong></p><ol><li>Suppose a pool has $1M in USDC/SOL liquidity.</li><li>Not all funds are needed for active swaps at every moment.</li><li>Hermes lends the <strong>idle part</strong> (say 30–40%) to lending protocols to earn extra yield.</li><li>If a large trade or withdrawal happens, funds are automatically pulled back.</li></ol><p>So LPs earn:</p><ul><li><strong>Swap Fees</strong> (like any AMM)</li><li><strong>Lending Yield</strong> (from idle liquidity)</li><li><strong>Optional Farming Rewards</strong></li></ul><p>This turns DAMM v1 into a <em>multi-yield engine</em>.</p><h3>7. Lock Liquidity and Still Earn Fees</h3><p>Projects can <strong>permanently lock liquidity</strong> for trust and transparency — ensuring rug-free pools — but still <strong>claim trading fees</strong> anytime.</p><p>Example:</p><ul><li>Suppose a memecoin locks its liquidity on DAMM.</li><li>The LP tokens are locked, but fees continue accumulating on-chain.</li><li>The project owner (or LP) can claim those fees anytime, without unlocking the base liquidity.</li></ul><p>This allows tokens to prove they’re safe while still generating ongoing yield.</p><h3>8. Core Metrics: APY, APR, and TVL</h3><p>Term Definition Explanation <strong>TVL (Total Value Locked)</strong> Total USD value of all assets deposited in a pool or protocol. Measures how much liquidity exists. Higher TVL = more trust. <strong>APY (Annual Percentage Yield)</strong> The <em>compounded</em> annual return, including both swap fees and vault yield. Shows actual growth rate if returns are reinvested. <strong>APR (Annual Percentage Rate)</strong> The <em>simple</em> annualized rate (no compounding). Often used for farming rewards.</p><h4>Formula 1: Base APY</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*P4IhLyzNBx9FmH_Ux_hPPQ.png" /></figure><p><strong>Explanation:</strong></p><ul><li>“Virtual Price” represents the value of an LP token share in the pool.</li><li>If the LP token’s value grows over time, that means the pool is generating returns.</li><li>This formula annualizes that growth.</li></ul><p>Example:<br>If LP token grows 1.5% in 7 days → Base APY ≈ 1.5 × (365/7) ≈ 78% annualized.</p><h4>Formula 2: Fee-to-TVL Ratio (Annualized)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*2e7czMSXJRbon50d0PVKmA.png" /></figure><p><strong>Explanation:</strong><br>This measures how much the pool earns in fees relative to its total liquidity over a year.<br>A higher ratio means higher yield efficiency.</p><h4>Formula 3: Liquidity Mining APR</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*bZQWuODcBwvoo-egAIk0zQ.png" /></figure><p><strong>Explanation:</strong><br>When LP tokens are staked in farming programs, this formula calculates annual reward rate assuming no compounding.</p><p>Example:<br>If daily reward = 0.1 USDC per 100 USDC → LM APR ≈ 36.5%</p><h3>9. LST (Liquid Staking Token) Pools</h3><p><strong>Liquid Staking Tokens (LSTs)</strong> represent staked assets plus their staking yield — e.g., mSOL, jitoSOL, bSOL.<br>Their value slowly rises because staking rewards are continuously added.</p><p>Traditional AMMs suffer <strong>Impermanent Loss (IL)</strong> when one token’s price rises faster than the other.<br><strong>DAMM v1 LST Pools</strong> solve this issue by:</p><ul><li>Tracking the <strong>xSOL price directly on-chain</strong> (no oracle dependency)</li><li>Using <strong>Stable Curve logic</strong> for better balance</li><li>Lending idle liquidity via <strong>Dynamic Vaults</strong></li><li>Requiring <strong>no active management</strong> (set and forget)</li></ul><p><strong>Result:</strong><br>LST liquidity stays sustainable, earns yield, and minimizes IL risk.</p><h3>10. Farming Programs</h3><p>While DAMM v1 integrates yield at the pool level, we can also stake LP tokens in <strong>permissioned farms</strong> for extra rewards.</p><p><strong>Farm Structure:</strong></p><ol><li>Stake LP tokens</li><li>Earn up to <strong>two reward tokens</strong></li><li>Claim or unstake anytime</li><li>Multiple farms per pool are possible</li></ol><p>How amazing, lol. For creating new farms, teams can contact <strong>Meteora Labs via Discord</strong>.</p><h3>11. Putting It All Together</h3><p>Let’s visualize the full flow</p><p><strong>Deposit → Swap → Fee Generation → Vault Lending → Yield Accrual → Claim or Farm Rewards</strong></p><p>Every step compounds liquidity efficiency.<br>LPs earn automatically, no rebalancing or active management required.</p><h3>12. Summary</h3><p>Feature Purpose <strong>Constant Product Formula</strong> Enables price discovery across full range <strong>Stable Pools + AMP</strong> Low-slippage swaps for 1:1 assets <strong>LST Pools</strong> Reduces Impermanent Loss, earns staking yield <strong>Dynamic Vaults</strong> Lends idle liquidity for extra yield <strong>Liquidity Locking</strong> Builds project trust while still earning fees <strong>APY/APR Metrics</strong> Tracks real yield performance <strong>Hermes Rebalancer</strong> Optimizes yield across lending markets</p><h3>In Short</h3><blockquote><strong><em>DAMM v1</em></strong><em> transforms the basic AMM into a </em><strong><em>multi-yield liquidity machine </em></strong><em>earning from swaps, lending, and staking simultaneously.</em></blockquote><p>It set the foundation for <strong>DAMM v2</strong>, which brings even more modularity and capital efficiency to Solana’s DeFi landscape.</p><p>Now let’s understand DAMM v2. Let’s go.</p><h3>1. What is DAMM v2?</h3><p>DAMM v2 is a <strong>constant-product AMM</strong>, similar to Uniswap, but with advanced features designed for token launches, trading efficiency, and better LP experiences.</p><p>Here’s what makes DAMM v2 unique:</p><ul><li><strong>Liquidity Concentration</strong>: We can place our liquidity in <strong>specific price ranges</strong> instead of the whole range. This increases efficiency and ensures our capital is productive.</li><li><strong>Dynamic Fees</strong>: Fees automatically adjust based on market volatility. Higher volatility → higher fees → better returns for LPs.</li><li><strong>Position NFTs</strong>: Our liquidity positions are now represented as <strong>NFTs</strong>, which can be transferred to other wallets if needed.</li><li><strong>Liquidity Locking</strong>: Lock our liquidity <strong>temporarily or permanently</strong>, while still claiming trading fees.</li><li><strong>Single-Sided Liquidity</strong>: We can launch a pool with just one token — no need for traditional token pairs.</li></ul><p>In short, DAMM v2 is a <strong>flexible, next-gen AMM</strong> optimized for Solana projects.</p><h3>2. Key Features Simplified</h3><p>Here’s a breakdown of DAMM v2’s most useful features:</p><ul><li><strong>SPL &amp; Token 2022 Support</strong>: Works with all Solana token types.</li><li><strong>Dynamic Fees</strong>: Fees adjust in real-time depending on market activity.</li><li><strong>Anti-Sniper Suite</strong>: Prevents bots from front-running our token launch.</li><li><strong>Flexible LP Fee Claiming</strong>: LPs can claim fees separately from liquidity withdrawals.</li><li><strong>Position NFTs</strong>: Liquidity positions are transferable NFTs.</li><li><strong>Concentrated Liquidity</strong>: Focus on our liquidity in efficient price ranges.</li><li><strong>Single-Sided Liquidity Launch</strong>: Launch pools with only one token.</li><li><strong>Built-in Farming</strong>: Earn additional rewards without a separate farming contract.</li><li><strong>Cost Efficiency</strong>: Creating a DAMM v2 pool is cheap (~0.022 SOL).</li><li><strong>Custom Start Time</strong>: Launch our pool at an exact time.</li></ul><h3>3. How Fees Work in DAMM v2</h3><p>LPs earn fees from every trade. The <strong>total fee</strong> has two parts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*mnsqqd9e7z8NUQ3dLpyQEA.png" /></figure><ul><li><strong>Base Fee (f_b)</strong>: Can be fixed or scheduled to decay over time.</li><li><strong>Variable Fee (f_v)</strong>: Changes based on market volatility.</li></ul><p>The variable fee (<em>fv</em>​) is a function of real-time price volatility. The fee rate will be applied to the swap amount in each liquidity bin and distributed proportionally to the LPs in that bin.LPs can claim these fees whenever they are available.</p><p><strong>Variable Fee Calculation</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*3lk7RQPr-rxKEcfH3fZ8yg.png" /></figure><p>Where:</p><ul><li>(v_a) = recent price volatility</li><li>(s) = price granularity</li><li>C = fee magnitude control</li></ul><p>Dynamic fees adjust automatically, capped at 20% of the base fee by default.</p><h3>4. Adding Liquidity and LP Positions</h3><p>Here’s where DAMM v2 truly shines — <strong>capital efficiency</strong>.</p><p>When adding liquidity, LPs define a price range — for example, 25–35 SOL per xSOL.<br>The protocol then calculates how much of each token is needed for that range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*ZmLhs4imWQHUbV4VEADysg.png" /></figure><ul><li>(\Delta L) = liquidity we add</li><li>P = current price</li><li>P_min / P_max = price range of our liquidity</li></ul><p><strong>LP Tokens</strong>: Our LP tokens represent our share of the pool and can be calculated based on the liquidity we provide.</p><p>This math ensures your liquidity only works within your chosen range — maximizing fee earnings per dollar deployed.</p><p>Each position gets minted as an <strong>NFT</strong>, which records:</p><ul><li>Price range</li><li>Liquidity amount</li><li>Fees earned</li><li>Rewards accumulated</li></ul><p>So your liquidity isn’t just a “number”, it’s an asset with history and yield.</p><h3>5. Farming Rewards</h3><p>DAMM v2 includes <strong>built-in farming</strong>, meaning we earn extra rewards on top of trading fees, without deploying a separate contract.</p><p><strong>Reward formula</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*U72MB45ntfxfG94shL8xTQ.png" /></figure><ul><li>The longer our liquidity stays in the pool, the more rewards we earn.</li><li>Rewards accumulate automatically based on our <strong>Position NFT</strong>.</li></ul><h3>6. Price Impact</h3><p>Price impact measures how much a swap changes the pool price:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*H2W7oOfiMVwfm2G8eAvLGQ.png" /></figure><ul><li>Bigger trades → higher price impact</li><li>Using <strong>concentrated liquidity</strong> can reduce price impact in our targeted price ranges.</li></ul><h3>Summary</h3><p>DAMM v2 is a <strong>next-generation AMM</strong> with features like:</p><ul><li>Dynamic fees for LP returns</li><li>Concentrated liquidity for capital efficiency</li><li>Transferable Position NFTs</li><li>Built-in farming rewards</li><li>Single-sided token launches</li><li>Anti-sniper protection</li></ul><p>It’s a <strong>powerful tool for Solana token launches</strong> and makes providing liquidity a lot more flexible and rewarding.</p><p>Thank you for reading, hope you found it useful, let me know for any doubts, here: <a href="https://x.com/praptichilling">https://x.com/praptichilling</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8106608e3967" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding DLMM: The Smarter Way of Providing Liquidity]]></title>
            <link>https://medium.com/@praptii/understanding-dlmm-the-smarter-way-of-providing-liquidity-e9ffd3f6b136?source=rss-6dd421fa5cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9ffd3f6b136</guid>
            <category><![CDATA[solanas]]></category>
            <category><![CDATA[clmm]]></category>
            <category><![CDATA[meteora]]></category>
            <category><![CDATA[amm]]></category>
            <category><![CDATA[dlmm]]></category>
            <dc:creator><![CDATA[Prapti Sharma]]></dc:creator>
            <pubDate>Sun, 31 Aug 2025 19:06:45 GMT</pubDate>
            <atom:updated>2025-08-31T19:07:50.934Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*aBR73EdVueeG2eRhkAGIHg.png" /></figure><p>I have tried to explain things in a simpler way, in the blog:</p><p>Decentralized finance (DeFi) has come a long way from the early days of automated market makers (AMMs). AMMs opened the door for trading tokens without relying on traditional order books, but they also came with problems like capital inefficiency, slippage, and impermanent loss.</p><p>A new model called <strong>DLMM (Dynamic Liquidity Market Maker)</strong> is changing how liquidity works on blockchains like Solana. It offers more control, less waste, and higher earning potential for liquidity providers. Let’s break it down in a way that makes sense for all of us.</p><h3>The Problem with Old AMMs</h3><p>Traditional AMMs work by spreading liquidity evenly across a wide range of prices, even in areas where no trading is happening. Think of it as filling a huge swimming pool but only a small corner is actually being used. The rest of the water just sits there, not helping anyone.</p><p>This leads to:</p><ul><li><strong>Capital inefficiency</strong>: money gets locked in unused price ranges.</li><li><strong>Slippage</strong>: trades may not execute at the expected price.</li><li><strong>Impermanent loss</strong>: the value of provided tokens can drop compared to simply holding them.</li></ul><h3>Enter DLMM: Dynamic Liquidity Market Maker</h3><p>DLMM solves these issues by allowing liquidity providers to focus their liquidity where trading is actually happening. Instead of spreading liquidity thinly across the entire pool, it is concentrated in specific <strong>bins</strong>.</p><h3>What is a Bin?</h3><p>A <strong>bin</strong> is like a small container that holds liquidity at one specific price. Every trade happens inside these bins. If trading demand moves away from one price level, the active bin shifts to the next one.</p><p>Because trades happen within bins, there is <strong>zero slippage</strong> as long as the swap stays inside the same bin. That’s a huge upgrade compared to older models.</p><h3>Why DLMM is Profitable</h3><p>DLMM brings several advantages that directly improve profitability for liquidity providers:</p><ol><li><strong>Better Capital Efficiency</strong><br> Liquidity is placed exactly where the market trades the most. This means less capital is wasted and the same amount of liquidity supports higher trading volumes.</li><li><strong>Higher Fee Earnings</strong><br> Since trades are concentrated around active bins, more volume flows through those bins. That translates into higher fee collection compared to spreading liquidity across unused price ranges.</li><li><strong>Flexibility with Strategies</strong><br> DLMM allows liquidity providers to choose strategies:</li></ol><ul><li><strong>Spot</strong>: spread liquidity evenly across a range.</li><li><strong>Curve</strong>: place more liquidity in the center (good for stable or less volatile markets).</li><li><strong>Bid-Ask</strong>: position liquidity at the edges of a range (better for volatile markets).</li></ul><p>This flexibility lets providers adapt to market conditions instead of being stuck with one fixed setup.</p><p><strong>4. Reducing Impermanent Loss</strong><br>Impermanent loss happens when the price of tokens changes and the pool ends up holding more of the lower-value token. DLMM helps offset this by ensuring that fees collected in high-activity bins can balance out the potential losses.</p><h3>Example in Simple Terms</h3><p>Imagine a marketplace with fruit sellers. In a traditional AMM, sellers spread fruit stalls evenly across the entire street even in empty alleys where no one walks. Most stalls get ignored, and fruit goes bad.</p><p>In DLMM, sellers set up stalls only where the crowd actually gathers. More fruit gets sold, sellers make more money, and buyers don’t face sudden changes in price.</p><h3>Meteora’s DLMM on Solana</h3><p>Link to explore(be careful though):<a href="https://app.meteora.ag/pools#dlmm">https://app.meteora.ag/pools#dlmm</a></p><p>One of the most popular DLMM implementations is built by <strong>Meteora</strong> on Solana. It uses the bin model to provide deep liquidity and zero-slippage trading. Each bin holds a pair of tokens (like SOL and USDC) and moves as demand shifts. This system makes Solana’s DeFi ecosystem more efficient and sustainable.</p><h3>Why DLMM Matters</h3><p>By focusing liquidity where it’s needed, DLMM makes DeFi more efficient for both traders and liquidity providers. It reduces waste, increases earnings, and creates a smoother trading experience. In many ways, it represents the next evolution of automated market making.</p><h3>Closing Thoughts</h3><p>DLMM is not just another improvement, it’s a fundamental upgrade to how liquidity works. With bins ensuring zero slippage, flexible strategies, and better fee collection, it offers a smarter way to participate in DeFi.</p><p>As projects like Meteora continue to refine this model, DLMM could become the backbone of liquidity provision on Solana and beyond.</p><p>To know more on how meteora works, refer to <a href="https://medium.com/@innocentnweke/why-and-how-to-use-dlmm-dynamic-liquidity-market-maker-9c97a41321b6">https://medium.com/@innocentnweke/why-and-how-to-use-dlmm-dynamic-liquidity-market-maker-9c97a41321b6</a></p><p>Thank you for reading ❤.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9ffd3f6b136" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Indexing on Solana: A Complete Guide to Deposits, Withdrawals, Memos, and Security]]></title>
            <link>https://medium.com/@praptii/indexing-on-solana-a-complete-guide-to-deposits-withdrawals-memos-and-security-4ecb2d2f3f69?source=rss-6dd421fa5cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ecb2d2f3f69</guid>
            <category><![CDATA[indexer]]></category>
            <category><![CDATA[solanas]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[solana-indexer]]></category>
            <category><![CDATA[memo]]></category>
            <dc:creator><![CDATA[Prapti Sharma]]></dc:creator>
            <pubDate>Sat, 23 Aug 2025 17:14:31 GMT</pubDate>
            <atom:updated>2025-08-24T19:30:27.453Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AzZ9aKREOlrlva5TggJN2Q.png" /></figure><p>Building payment infrastructure on Solana requires understanding how to properly index blockchain data for centralized applications. Whether we’re building a centralized exchange (CEX), crypto gateway, or e-commerce platform, indexing is the foundation that enables us to track user deposits, process withdrawals securely, and maintain accurate balances.</p><p>This comprehensive guide covers everything we need to know about Solana indexing, from basic concepts to advanced security considerations for production systems.</p><h3>What is Indexing?</h3><p>Indexing means copying over the state of a blockchain to a Web2 system. In the context of Solana, it involves extracting specific transaction data from the high-throughput blockchain and storing it in traditional databases like PostgreSQL or MongoDB.</p><p>The goal isn’t to copy the entire blockchain — that would be expensive and unnecessary. Instead, we focus on indexing specific addresses or transactions relevant to our application. For example, we might want to track:</p><ul><li>All transactions to our exchange’s deposit address</li><li>Activity on specific liquidity pools</li><li>Transactions involving particular token contracts</li><li>User deposits and withdrawals</li></ul><p>The Solana blockchain processes hundreds of transactions per second since Genesis, generating terabytes of data. Our indexing system needs to efficiently filter this stream to capture only the transactions we care about.</p><h3>How to Index: Yellowstone &amp; Geyser</h3><p>The most robust approach to Solana indexing is using <strong>Yellowstone</strong>, built on top of the <strong>Geyser plugin</strong>. These tools allow us to subscribe to real-time blockchain events as they happen.</p><h3>Understanding the Architecture</h3><p>When validators on the Solana network receive transactions and create blocks, they can run additional processes (plugins) that extract and forward specific transaction data. Yellowstone provides a gRPC interface to these plugins, enabling us to:</p><ul><li>Subscribe to specific accounts or programs</li><li>Filter transactions based on our criteria</li><li>Receive real-time updates as transactions are confirmed</li></ul><h3>Available RPC Providers</h3><p>Several providers offer Yellowstone services:</p><ul><li><strong>Triton</strong>: Created Yellowstone, offers premium indexing services</li><li><strong>Helios</strong>: Competitor with their own indexing tools</li><li><strong>Quicknode</strong>: Provides RPC and indexing infrastructure</li><li><strong>Alchemy</strong>: Web3 infrastructure provider</li></ul><h3>Pricing and Access</h3><p>Free Yellowstone servers exist (like parafi.tech) but with limitations—typically only allowing subscriptions to predefined accounts like the vote program. For production use, expect to pay:</p><ul><li><strong>Shift.io</strong>: ~$200/month for one connection</li><li><strong>Titan</strong>: ~$1000/month for premium access</li><li><strong>Custom validators</strong>: Exchanges often run their own validators with Geyser plugins</li></ul><h3>The Problem with Naive Payment Flows</h3><p>Before diving into proper indexing solutions, let’s understand why simple payment flows fail. Consider a basic e-commerce site selling t-shirts for 0.5 SOL:</p><h3>Broken Flow:</h3><ol><li>User sends 0.5 SOL to our address</li><li>User’s client gets transaction signature</li><li>Client forwards signature to our backend</li><li>Backend verifies signature and ships product</li></ol><h3>Critical Problems:</h3><p><strong>1. Lack of Atomicity (Client Crash)</strong> If the user’s client crashes after step 1 but before step 3, the money is sent but our backend never knows. The user loses their SOL with no product shipped.</p><p><strong>2. Transaction Sniping (Impersonation)</strong> An attacker can monitor our payment address, grab any transaction signature, and claim it with their own session cookie before the real user can. Our backend has no way to verify who actually sent the payment.</p><h3>The Solution: Memo Program + Indexing</h3><p>Solana’s Memo Program (MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr) provides the solution. This program logs arbitrary strings on-chain, allowing us to attach identifiers to transactions.</p><h3>Secure Architecture:</h3><ol><li><strong>Frontend</strong> requests to make a purchase</li><li><strong>Web2 Backend</strong> generates unique identifier (random number or user ID) and returns it</li><li><strong>Frontend</strong> constructs transaction with TWO instructions: <br>system_program::transfer to send SOL to our address<br>memo_program call with the unique identifier</li><li>User signs and sends this atomic transaction</li><li><strong>Indexer</strong> (Yellowstone client) sees the transaction and parses the memo</li><li><strong>Processor</strong> uses the identifier to credit the correct user</li></ol><h3>Implementation Example:</h3><pre>import {<br>  Connection,<br>  Keypair,<br>  LAMPORTS_PER_SOL,<br>  SystemProgram,<br>  Transaction,<br>  sendAndConfirmTransaction<br>} from &quot;@solana/web3.js&quot;;<br>import { createMemoInstruction } from &quot;@solana/spl-memo&quot;;<br><br>// Connect to Solana cluster<br>const connection = new Connection(&quot;http://localhost:8899&quot;, &quot;confirmed&quot;);<br><br>// Create keypair for the fee payer<br>const feePayer = Keypair.generate();<br><br>// Request airdrop<br>const airdropSignature = await connection.requestAirdrop(<br>  feePayer.publicKey,<br>  LAMPORTS_PER_SOL<br>);<br><br>// Confirm airdrop<br>const { blockhash, lastValidBlockHeight } = <br>  await connection.getLatestBlockhash();<br>await connection.confirmTransaction({<br>  signature: airdropSignature,<br>  blockhash,<br>  lastValidBlockHeight<br>});<br><br>// Create transaction with transfer and memo<br>const memoInstruction = createMemoInstruction(&quot;Hello, World!&quot;);<br>const sendSolana = SystemProgram.transfer({<br>  fromPubkey: feePayer.publicKey,<br>  toPubkey: Keypair.generate().publicKey,<br>  lamports: 0.5 * 1000_000_000<br>});<br><br>const transaction = new Transaction()<br>  .add(sendSolana)<br>  .add(memoInstruction);<br><br>// Sign and send<br>const transactionSignature = await sendAndConfirmTransaction(<br>  connection,<br>  transaction,<br>  [feePayer]<br>);<br>console.log(&quot;Transaction Signature: &quot;, transactionSignature);</pre><h3>Why This Works:</h3><ul><li><strong>Solves Atomicity</strong>: The indexer runs independently and will always see confirmed transactions</li><li><strong>Prevents Sniping</strong>: Payment and user identifier are locked together in one atomic transaction</li><li><strong>Cost Effective</strong>: We can use simple RPC polling instead of expensive Yellowstone for single-address indexing</li></ul><h3>Required Memo Extension for Token Accounts</h3><p>For enhanced security with token transfers, Solana offers the Required Memo extension. This ensures all incoming token transfers must include a memo.</p><h3>Creating Token Account with Required Memo:</h3><pre>import {<br>  TOKEN_2022_PROGRAM_ID,<br>  getAccountLen,<br>  ExtensionType,<br>  createInitializeAccountInstruction,<br>  createEnableRequiredMemoTransfersInstruction,<br>} from &quot;@solana/spl-token&quot;;<br><br>export async function createTokenWithMemoExtension(<br>  connection: Connection,<br>  payer: Keypair,<br>  tokenAccountKeypair: Keypair,<br>  mint: PublicKey,<br>): Promise&lt;string&gt; {<br>  // Create account instruction<br>  const accountLen = getAccountLen([ExtensionType.MemoTransfer]);<br>  const lamports = await connection.getMinimumBalanceForRentExemption(accountLen);<br><br>  const createAccountInstruction = SystemProgram.createAccount({<br>    fromPubkey: payer.publicKey,<br>    newAccountPubkey: tokenAccountKeypair.publicKey,<br>    space: accountLen,<br>    lamports,<br>    programId: TOKEN_2022_PROGRAM_ID,<br>  });<br><br>  // Initialize account instruction<br>  const initializeAccountInstruction = createInitializeAccountInstruction(<br>    tokenAccountKeypair.publicKey,<br>    mint,<br>    payer.publicKey,<br>    TOKEN_2022_PROGRAM_ID,<br>  );<br><br>  // Enable required memo transfers instruction<br>  const enableRequiredMemoTransfersInstruction =<br>    createEnableRequiredMemoTransfersInstruction(<br>      tokenAccountKeypair.publicKey,<br>      payer.publicKey,<br>      undefined,<br>      TOKEN_2022_PROGRAM_ID,<br>    );<br><br>  // Send transaction<br>  const transaction = new Transaction().add(<br>    createAccountInstruction,<br>    initializeAccountInstruction,<br>    enableRequiredMemoTransfersInstruction,<br>  );<br><br>  return await sendAndConfirmTransaction(<br>    connection,<br>    transaction,<br>    [payer, tokenAccountKeypair],<br>  );<br>}</pre><h3>Transferring to Required Memo Account:</h3><pre>const message = &quot;Hello, Solana&quot;;<br><br>const transaction = new Transaction().add(<br>  new TransactionInstruction({<br>    keys: [{ pubkey: payer.publicKey, isSigner: true, isWritable: true }],<br>    data: Buffer.from(message, &quot;utf-8&quot;),<br>    programId: new PublicKey(&quot;MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr&quot;),<br>  }),<br>  createTransferInstruction(<br>    sourceAccount,<br>    destinationAccount,<br>    payer.publicKey,<br>    transferAmount,<br>    undefined,<br>    TOKEN_2022_PROGRAM_ID,<br>  ),<br>);<br><br>await sendAndConfirmTransaction(connection, transaction, [payer]);const message = &quot;Hello, Solana&quot;;<br><br>const transaction = new Transaction().add(<br>  new TransactionInstruction({<br>    keys: [{ pubkey: payer.publicKey, isSigner: true, isWritable: true }],<br>    data: Buffer.from(message, &quot;utf-8&quot;),<br>    programId: new PublicKey(&quot;MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr&quot;),<br>  }),<br>  createTransferInstruction(<br>    sourceAccount,<br>    destinationAccount,<br>    payer.publicKey,<br>    transferAmount,<br>    undefined,<br>    TOKEN_2022_PROGRAM_ID,<br>  ),<br>);<br><br>await sendAndConfirmTransaction(connection, transaction, [payer]);</pre><h3>Deposit Architecture Patterns</h3><h3>Pattern 1: Memo-Based Deposits (Recommended)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*diqm86pQecmxj51JMdyqFg.png" /></figure><p>All users send funds to a single address with unique memo identifiers:</p><p><strong>Advantages:</strong></p><ul><li>Simple to implement and maintain</li><li>Cost-effective indexing (can use simple RPC polling)</li><li>No private key management complexity</li><li>Perfect for most applications</li></ul><p><strong>Process:</strong></p><ol><li>User requests deposit</li><li>Backend generates unique seed/nonce, stores in database as ‘pending’</li><li>Frontend creates transaction with transfer + memo containing seed</li><li>Indexer monitors single address and processes transactions</li><li>Processor matches memo to database record and updates user balance</li></ol><h3>Pattern 2: Unique Deposit Addresses (Binance-Style)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IsF51mgkke1mRyXo_rvhQg.png" /></figure><p>Every user gets their own unique deposit address:</p><p><strong>Advantages:</strong></p><ul><li>Familiar to users from traditional exchanges</li><li>Clear separation of user funds</li><li>Easy to track individual user activity</li></ul><p><strong>Disadvantages:</strong></p><ul><li>Complex private key management for millions of addresses</li><li>Requires fund consolidation (“sweeper”) process</li><li>Higher gas costs for moving funds between addresses</li><li>More complex indexing (must monitor many addresses)</li></ul><h3>The Sweeper Problem</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7TgcANvGIWiC-Vr-nqI8uA.png" /></figure><p>When using unique deposit addresses, funds get scattered across thousands of wallets. A <strong>sweeper</strong> process must periodically consolidate these funds:</p><ol><li><strong>Monitor</strong> all user deposit addresses for incoming funds</li><li><strong>Calculate</strong> gas fees needed to move funds from each address</li><li><strong>Send</strong> SOL to addresses that need gas for token transfers</li><li><strong>Sweep</strong> funds from deposit addresses to main treasury</li><li><strong>Timing</strong> sweeps during low gas periods for cost efficiency</li></ol><p>This complexity makes memo-based deposits preferable for most applications.</p><h3>Withdrawal Architecture and Security</h3><p>Withdrawals are the most critical and dangerous operations in any centralized crypto platform. Once funds leave our control, they cannot be recovered, making security paramount.</p><h3>The Withdrawal Problem</h3><p>When a user wants to withdraw 100 SOL from their 400 SOL balance:</p><ul><li>The database shows 400 SOL belongs to the user</li><li>The actual SOL sits in our centralized “hot wallet”</li><li>We must atomically reduce the user’s database balance AND send blockchain transaction</li><li>Any failure in this process can result in lost funds or double-spending</li></ul><h3>Naive Withdrawal Flow (DANGEROUS):</h3><pre>app.post(&#39;/withdraw&#39;, (req, res) =&gt; {<br>  // 1. Check user&#39;s balance (400 SOL)<br>  // 2. REDUCE balance in DB (set to 300 SOL)<br>  db.balances.update({ userId: 1, currency: &#39;SOL&#39; }, { $inc: -100 });<br>// 3. Get MPCs to sign withdrawal transaction<br>  const signature = MPC1.sign() + MPC2.sign() + MPC3.sign();<br>  // 4. Send transaction to blockchain<br>  connection.sendTransaction(signature);<br>});</pre><h3>Critical Problems:</h3><p><strong>1. Database Before Blockchain</strong> If we reduce the balance first but the blockchain transaction fails (network issues, old blockhash), the user loses their funds in the database but the money never leaves our wallet.</p><p><strong>2. Blockchain Before Database</strong><br> If the blockchain transaction succeeds but the database update fails (DB crash), the user receives their 100 SOL but still has 400 SOL in their account — they can withdraw again (double-spend).</p><p><strong>3. Race Conditions</strong> Multiple simultaneous withdrawal requests could all check the same balance, all see sufficient funds, and all proceed — allowing withdrawal of more funds than available.</p><h3>Robust Withdrawal Implementation</h3><h3>Queue-Based Processing</h3><p>The solution is using a message queue system (like Kafka) for sequential processing:</p><ol><li><strong>API Endpoint</strong> validates request and places it in withdrawal queue</li><li><strong>Single Worker</strong> process pulls requests one by one:</li></ol><ul><li>Checks and locks user’s balance</li><li>Creates and signs transaction</li><li>Sends transaction to blockchain</li><li>Updates database on confirmation</li><li>Acknowledges queue message</li></ul><h3>Idempotent Withdrawals</h3><p>To handle worker crashes, we must make withdrawals idempotent (safe to retry):</p><p><strong>Critical Insight: Store signature BEFORE broadcasting</strong></p><pre>async function processWithdrawal(withdrawalRequest) {<br>  // 1. Create withdrawal transaction<br>  const transaction = createWithdrawalTx(withdrawalRequest);<br>  <br>  // 2. Get MPC signatures<br>  const signature = await getMPCSignatures(transaction);<br>  <br>  // 3. STORE signature in database BEFORE broadcasting<br>  await db.withdrawals.update(withdrawalRequest.id, { <br>    signature: signature,<br>    status: &#39;signed&#39;<br>  });<br>  <br>  // 4. NOW broadcast to blockchain<br>  await connection.sendTransaction(signature);<br>  <br>  // 5. Wait for confirmation and update status<br>  await confirmTransaction(signature);<br>  await db.withdrawals.update(withdrawalRequest.id, { status: &#39;completed&#39; });<br>  await updateUserBalance(withdrawalRequest);<br>}</pre><p>If the worker crashes after storing the signature, a new worker can:</p><ol><li>Check if signature exists in database</li><li>Query blockchain to see if transaction was confirmed</li><li>If confirmed: just update database status</li><li>If not confirmed: safely create new transaction</li></ol><h3>Advanced Security: Defending Against Insider Threats</h3><h3>Attack Vector 1: Stolen JWT Secrets</h3><p><strong>Threat</strong>: Malicious insider or hacker obtains JWT secret key, can forge user cookies and call withdrawal API.</p><p><strong>Mitigation</strong>: <strong>Multi-Factor Authentication (MFA)</strong></p><ul><li>Withdrawal API requires valid OTP sent to user’s email/phone</li><li>Even with stolen cookies, attacker needs access to user’s communication channels</li></ul><h3>Attack Vector 2: Internal System Bypass</h3><p><strong>Threat</strong>: Malicious developer with server access bypasses public API entirely, directly calls internal MPC functions.</p><p><strong>Mitigation</strong>: <strong>Cryptographic Handshake Between Browser and MPCs</strong></p><ol><li><strong>Key Generation</strong>: Upon login, user’s browser generates ephemeral public/private key pair</li><li><strong>Key Registration</strong>: Using MFA, browser registers public key directly with each MPC server</li><li><strong>Request Signing</strong>: For withdrawals, browser signs request with private key</li><li><strong>Verification</strong>: MPCs verify signature against registered public key before signing blockchain transaction</li></ol><p>This ensures that even with full backend access, attackers cannot forge withdrawal requests without the user’s private key (which never leaves the browser).</p><h3>Implementation Example:</h3><pre>// Browser-side: Generate and register keys<br>const keyPair = await crypto.subtle.generateKey(<br>  {<br>    name: &quot;ECDSA&quot;,<br>    namedCurve: &quot;P-256&quot;,<br>  },<br>  true,<br>  [&quot;sign&quot;, &quot;verify&quot;]<br>);<br>// Register public key with MPCs (after MFA verification)<br>const publicKeyJWK = await crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.publicKey);<br>await registerKeyWithMPCs(publicKeyJWK, otpToken);<br>// Sign withdrawal request<br>const withdrawalRequest = { amount: 100, address: &quot;...&quot;, userId: 12345 };<br>const signature = await crypto.subtle.sign(<br>  { name: &quot;ECDSA&quot;, hash: &quot;SHA-256&quot; },<br>  keyPair.privateKey,<br>  new TextEncoder().encode(JSON.stringify(withdrawalRequest))<br>);<br>// Send signed request to backend<br>await fetch(&#39;/withdraw&#39;, {<br>  method: &#39;POST&#39;,<br>  body: JSON.stringify({ request: withdrawalRequest, signature: signature })<br>});</pre><h3>Multi-Party Computation (MPC) for Fund Security</h3><p>Modern exchanges secure their hot wallets using MPC clusters instead of single private keys:</p><h3>MPC Architecture:</h3><ul><li><strong>3–5 MPC nodes</strong> each hold a “share” of the private key</li><li><strong>Threshold signing</strong> requires majority (e.g., 3 of 5) to sign transactions</li><li><strong>No single point of failure</strong> — compromising one node doesn’t expose funds</li><li><strong>Geographic distribution</strong> of nodes for additional security</li></ul><h3>MPC Workflow:</h3><ol><li>Withdrawal request validated and placed in queue</li><li>Worker process creates unsigned transaction</li><li>Transaction sent to MPC cluster for signing</li><li>Each MPC node validates request and provides signature share</li><li>Shares combined to create final transaction signature</li><li>Signed transaction broadcast to blockchain</li></ol><h3>Proof of Reserves: Building Trust</h3><p>Leading exchanges are implementing Proof of Reserves to demonstrate they hold sufficient funds to cover user balances. As highlighted by Backpack’s recent announcement, this involves:</p><h3>Core Components:</h3><ol><li><strong>Daily Balance Attestations</strong>: Cryptographic proofs of all user balances</li><li><strong>Merkle Tree Inclusion Proofs</strong>: Users can verify their balance is included in the total</li><li><strong>External Audits</strong>: Third-party verification of reserve calculations</li><li><strong>Real-time Reconciliation</strong>: Continuous monitoring of asset vs. liability balance</li></ol><h3>Implementation Considerations:</h3><ul><li><strong>Physical Balances Only</strong>: Include assets that can be “touched” on-chain (available balances, open orders, unborrowed lends)</li><li><strong>Margin Risk Management</strong>: Over-collateralized borrows must be factored into reserve calculations</li><li><strong>Fiat Complications</strong>: Traditional bank deposits require special handling (deposit tokens)</li><li><strong>Perpetual Futures</strong>: Real-time PnL settlement automatically included in reserves</li></ul><h3>Cost Optimization Strategies</h3><h3>Cheap Indexing for Single Address</h3><p>For applications using memo-based deposits, we can avoid expensive Yellowstone subscriptions:</p><pre>// Simple polling indexer<br>async function pollForTransactions() {<br>  const signatures = await connection.getSignaturesForAddress(<br>    ourDepositAddress,<br>    { limit: 50 }<br>  );<br>  <br>  for (const sig of signatures) {<br>    if (!processedSignatures.has(sig.signature)) {<br>      const transaction = await connection.getTransaction(sig.signature);<br>      processMemoTransaction(transaction);<br>      processedSignatures.add(sig.signature);<br>    }<br>  }<br>}<br>// Run every 20 seconds<br>setInterval(pollForTransactions, 20000);</pre><p>This approach costs nearly nothing compared to $200–1000/month Yellowstone subscriptions.</p><h3>When to Use Expensive Indexing</h3><p>Reserve Yellowstone/Geyser for scenarios requiring:</p><ul><li><strong>Multiple address monitoring</strong> (unique deposit addresses)</li><li><strong>Real-time processing</strong> (high-frequency trading, liquidations)</li><li><strong>Program-wide monitoring</strong> (DeFi protocol indexing)</li><li><strong>Cross-chain arbitrage</strong> (sub-second transaction processing)</li></ul><h3>Production Deployment Checklist</h3><h3>Infrastructure Requirements:</h3><ul><li>Message queue system (Kafka/Redis) for withdrawal processing</li><li>Database with proper indexing on user_id, transaction signatures</li><li>MPC cluster for secure transaction signing</li><li>Monitoring and alerting for all critical processes</li><li>Geographic redundancy for indexing infrastructure</li></ul><h3>Security Measures:</h3><ul><li>MFA required for all withdrawal operations</li><li>Browser-MPC cryptographic handshake implemented</li><li>Regular security audits and penetration testing</li><li>Incident response procedures documented</li><li>Key rotation procedures for MPC nodes</li></ul><h3>Operational Procedures:</h3><ul><li>Daily proof of reserves generation</li><li>User balance reconciliation monitoring</li><li>Withdrawal queue monitoring and alerting</li><li>Regular sweeper execution (if using unique addresses)</li><li>Gas fee optimization for blockchain operations</li></ul><h3>Conclusion</h3><p>Building robust indexing infrastructure on Solana requires careful consideration of security, cost, and operational complexity. The memo-based deposit approach provides an excellent balance of simplicity and security for most applications, while proper withdrawal architecture with MPC security and queue-based processing ensures funds remain safe.</p><p>Key takeaways for implementation:</p><ol><li><strong>Use memo-based deposits</strong> unless we have specific requirements for unique addresses</li><li><strong>Implement proper withdrawal queues</strong> with idempotent processing</li><li><strong>Secure hot wallets with MPC clusters</strong> and cryptographic handshakes</li><li><strong>Consider proof of reserves</strong> for building user trust</li><li><strong>Optimize costs</strong> by avoiding expensive indexing when simple polling suffices</li></ol><p>The landscape of centralized crypto infrastructure continues evolving toward more transparent, verifiable, and secure systems. By implementing these patterns correctly, we can build applications that provide the user experience of centralized systems with the security guarantees that approach decentralized protocols.</p><p>Written with ❤ by <a href="https://x.com/praptichilling">Prapti</a> for solana community!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ecb2d2f3f69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Diving into Lazy Accounts on Solana: My PR to the Solana Ecosystem]]></title>
            <link>https://medium.com/@praptii/diving-into-lazy-accounts-on-solana-my-pr-to-the-solana-ecosystem-4be306b64d56?source=rss-6dd421fa5cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/4be306b64d56</guid>
            <category><![CDATA[lazyaccount]]></category>
            <category><![CDATA[solanas]]></category>
            <category><![CDATA[superteamdao]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solana-blockchain]]></category>
            <dc:creator><![CDATA[Prapti Sharma]]></dc:creator>
            <pubDate>Tue, 12 Aug 2025 14:12:48 GMT</pubDate>
            <atom:updated>2025-08-12T14:12:48.794Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*O4KiEgSpo_jB9d_b749DxQ.png" /></figure><p>When working on Solana programs in Anchor, one common performance bottleneck is <strong>loading more account data than you actually need</strong>.<br>I recently tackled this in my own code by switching from Account to LazyAccountand the results were pretty great.</p><p>Here’s a deep dive into <strong>what LazyAccount is, why it’s useful, and exactly how I implemented it in my </strong><a href="https://github.com/SolanaCore/pump/pull/63"><strong>PR</strong></a>. For issue- <a href="https://github.com/SolanaCore/pump/issues/62">click here</a>.</p><h3>The “Normal” Way Anchor Loads Accounts</h3><p>Normally, in Anchor, when we write:</p><pre>#[account]<br>pub struct MyAccount {<br>    pub authority: Pubkey,<br>    pub data: Vec&lt;u8&gt;,<br>    pub counter: u64,<br>}</pre><p>And then use it in our instruction like this:</p><pre>pub my_account: Account&lt;&#39;info, MyAccount&gt;</pre><p>Anchor <strong>reads the entire account data</strong> from Solana’s storage and <strong>deserializes it fully</strong> into our MyAccount struct <strong>even if you only needed </strong><strong>authority</strong>.</p><h3>Why is that a problem?</h3><ol><li><strong>Wasted compute units</strong> — Deserializing large accounts costs compute, which is limited per transaction.</li><li><strong>Wasted memory</strong> — We’ve got ~4KB stack limit, large accounts fill that quickly.</li><li><strong>Slower programs</strong> — More bytes read = more processing time.</li></ol><h3>LazyAccount — The “Only Take What You Need” Trick</h3><p>Think of your account as a <strong>pizza</strong> 🍕.</p><p>With Account, you always take the <strong>whole pizza out of the box</strong> before eating… even if you just want 1 slice.</p><p>With LazyAccount, you only <strong>pull out the slices you need</strong>.</p><p><strong>Normal:</strong></p><pre>let my_account_data = ctx.accounts.my_account; // loads everything<br>msg!(&quot;{:?}&quot;, my_account_data.authority);</pre><p><strong>Lazy:</strong></p><pre>let authority = ctx.accounts.my_account.load_authority()?; // loads ONLY authority</pre><h3>Why it’s called “lazy”</h3><p>Because it <strong>waits until you ask for a specific field</strong> before deserializing it.</p><h3>When should you use LazyAccount?</h3><p>✅ If your account is <strong>big</strong> and you don’t always need all the fields<br>✅ If your account is <strong>read-only</strong> most of the time</p><p>❌ If you always need to mutate the account — you’ll still end up loading everything<br>❌ If your account is tiny — the benefit is small</p><h3>My Real Implementation in PR</h3><p>In my recent PR, I changed some accounts to use LazyAccount and added selective field reading.</p><h4><strong>Step 1: Enable the </strong><strong>lazy-account feature in Cargo.toml</strong></h4><pre>anchor-lang = { version = &quot;0.31.1&quot;, features = [&quot;init-if-needed&quot;, &quot;lazy-account&quot;] }</pre><p>This tells Anchor to include the extra APIs for partial account loading.</p><h4><strong>Step 2: Use LazyAccount in your instruction context</strong></h4><pre>#[account(mut)]<br>pub bonding_curve: LazyAccount&lt;BondingCurve&gt;,</pre><p>Now, bonding_curve won’t be fully deserialized unless I explicitly load a field.</p><h4><strong>Step 3: Create a trait for selective access</strong></h4><p>In global_config.rs:</p><pre>pub trait GlobalConfigLoader {<br>    fn get_virtual_token_reserve(&amp;self) -&gt; Result&lt;u64&gt;;<br>    fn get_virtual_sol_reserve(&amp;self) -&gt; Result&lt;u64&gt;;<br>}</pre><h4>Step 4: Implement partial field reading</h4><pre>impl&lt;&#39;info&gt; GlobalConfigLoader for LazyAccount&lt;&#39;info, GlobalConfig&gt; {<br>    fn get_virtual_token_reserve(&amp;self) -&gt; Result&lt;u64&gt; {<br>        let account_info = self.to_account_info();<br>        let data = account_info.try_borrow_data()?;<br>        let bytes = &amp;data[24..32]; // offset for virtual_token_reserve<br>        Ok(u64::from_le_bytes(bytes.try_into().unwrap()))<br>    }<br><br>fn get_virtual_sol_reserve(&amp;self) -&gt; Result&lt;u64&gt; {<br>        let account_info = self.to_account_info();<br>        let data = account_info.try_borrow_data()?;<br>        let bytes = &amp;data[32..40]; // offset for virtual_sol_reserve<br>        Ok(u64::from_le_bytes(bytes.try_into().unwrap()))<br>    }<br>}</pre><p>Instead of loading the entire GlobalConfig, I <strong>read only 8 bytes</strong> for each field I need.</p><h4>Step 5: Use the new lazy getters</h4><p>Before:</p><pre>let virtual_sol_reserve = ctx.accounts.global_config.virtual_sol_reserve;</pre><p>After:</p><pre>let virtual_sol_reserve = ctx.accounts.global_config.get_virtual_sol_reserve()?;</pre><p>Same for token_reserve:</p><pre>let token_reserve = ctx.accounts.global_config.get_virtual_token_reserve()?;</pre><h3>Why This Is Better</h3><p>By using:</p><ul><li>LazyAccount</li><li>Manual byte-offset reads</li><li>Traits for field-specific getters</li></ul><p>…my program:</p><ul><li><strong>Loads only what’s needed</strong> (less memory)</li><li><strong>Reduces compute cost</strong> (fewer CPU cycles)</li><li><strong>Runs faster</strong> for common read-only operations</li></ul><h3>Quick Analogy Recap</h3><p>Solana accounts are <strong>sealed mystery boxes</strong>.</p><ul><li>Account = rip the box open and dump everything on the table</li><li>LazyAccount = cut a small hole, take out just what you need</li></ul><p>Less mess, faster cleanup — unless you poke so many holes you might as well open the box, hehe.</p><p><strong>Tip:</strong> If you want to measure the improvement, log your transaction’s compute units before and after the change, you’ll see the savings.</p><p>Thank you for reading, connect with me, here: <a href="https://x.com/praptichilling">https://x.com/praptichilling</a> ❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4be306b64d56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solana Account Model & PDAs Explained]]></title>
            <link>https://medium.com/@praptii/solana-account-model-pdas-explained-754319582462?source=rss-6dd421fa5cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/754319582462</guid>
            <category><![CDATA[pda]]></category>
            <category><![CDATA[solana-network]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solana-account-model]]></category>
            <category><![CDATA[solana-blockchain]]></category>
            <dc:creator><![CDATA[Prapti Sharma]]></dc:creator>
            <pubDate>Thu, 24 Jul 2025 15:02:27 GMT</pubDate>
            <atom:updated>2025-07-24T15:04:28.491Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*AJM3x0UAv3GmAOrUoOlzxQ.png" /></figure><p><strong>Okay, so you want to build on Solana like I?</strong> Cool. You need to understand <strong>Accounts</strong> and <strong>PDAs. Read this slow, give it time and understand everything.</strong></p><p>I’m writing this because if you’re like me, someone trying to <em>actually</em> build things and not just vibe with memes on crypto Twitter, you need a clean, chill explanation of what the heck is going on with Solana accounts.</p><h3>First of all, what even is an Account?</h3><p>In Solana, <strong>everything is an account</strong>.</p><ul><li>Programs? Accounts.</li><li>Tokens? Accounts.</li><li>NFTs? You guessed it- Accounts.</li></ul><p>But Solana accounts are <em>not</em> like Ethereum accounts where you just store your balance. They’re more like files in a file system. An account in Solana can store <strong>data</strong> and <strong>own tokens, etc.</strong></p><blockquote><strong><em>Ethereum</em></strong><em>: Code owns storage.<br></em><strong><em>Solana</em></strong><em>: Storage owns code.<br></em>Let that sink in lol.</blockquote><h3>Types of Accounts in Solana:</h3><p>I learnt about these types from Harkirat.</p><ul><li><strong>Program Accounts</strong> — These store compiled executable code.They are like proxy.</li><li><strong>Program Data Accounts</strong> — Store data associated with the program (like state). Ruust code is stored here.</li><li><strong>User Accounts</strong> — Wallets controlled by users, usually holding SOL.</li><li><strong>Data Accounts</strong> — Used to store any arbitrary data, usually controlled by a program. Here we can dump data, bunch of bytes.</li><li><strong>Program Derived Addresses (PDAs)</strong> — Special accounts deterministically derived and only signable by programs.</li></ul><p>Usually, we divide in 3: program, user and data. but I have divided them further, it’s the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fEgFSReRu9DSPbdX5xTD2Q.png" /></figure><blockquote>Each account has some key fields:</blockquote><ul><li><strong>owner</strong> — Each account on Solana has an <strong>owner, </strong>it can either be the <strong>system program</strong> (like Phantom wallet accounts) or a <strong>custom program</strong>.</li><li><strong>executable</strong> —An account can be: <br><strong>Executable</strong>: stores program logic (bytecode)<br><strong>Non-executable</strong>: used for storing state/data or SOL</li><li><strong>rent_epoch</strong> — On Solana, storing data costs <strong>rent</strong> in SOL. Creating an account is just depositing enough SOL to cover rent so the network tracks it — just like paying for SSDs and hardware, lol.<br>We <strong>don’t pay rent every epoch</strong> anymore. Instead, we prepay rent for a long time (often ~2 years). Epochs are ~2 days (or ~2–5 hours for fast testnet) and act like checkpoints for:<br>- network upgrades<br>- stake rewards<br>- validator rotation (leader schedule)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*GY4TDhSv_Zi2AryZz4CjZA.png" /><figcaption>We can calculate rent too, like this.</figcaption></figure><ul><li><strong>lamports</strong> — smallest unit of SOL (10⁻⁹ SOL)</li><li><strong>data</strong> — actual stored bytes (done via <strong>serialization</strong> using macros, I discussed macros in another blog, you can check on my profile).<br>Also serialization is covered in my last blog — basically, it means converting Rust data into bytecode, like:<br>integer value: 42 → 73 6f 6c 61 6e 61 5f 62<br>This bytecode runs at kernel-level, which connects software and hardware and is super performant, see image:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*OiJR73oN29oGDpezFVJkVQ.png" /></figure><h3>Understanding Accounts via Images</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HUClh1yDyVdBrMC1A2Tzjg.png" /></figure><p>This is a <strong>user account</strong> — it holds SOL, no data, and is non-executable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rsw_Vffu0yVmYY0iRs3UCA.png" /></figure><p>This one is a <strong>program account</strong> — owned by the BPF loader, is executable, and holds bytecode (the logic).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-RTlX3lmCCQ7dhMRW_poMg.png" /></figure><p>This is a <strong>data account</strong>, non-executable, owned by a program. It holds just enough SOL to stay rent-exempt and contains the max u64 value in its data.</p><h3>Account Lifecycle in Code</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L5_vStARxkumRgwvVZyXCQ.png" /></figure><p>Let’s look at how to create a simple account from the Solana Cookbook:</p><pre>use solana_client::nonblocking::rpc_client::RpcClient;<br>use solana_sdk::{<br>    commitment_config::CommitmentConfig, native_token::LAMPORTS_PER_SOL, signature::Keypair,<br>    signer::Signer, system_instruction::create_account as create_account_ix,<br>    system_program::ID as SYSTEM_PROGRAM_ID, transaction::Transaction,<br>};<br><br>#[tokio::main]<br>async fn main() -&gt; anyhow::Result&lt;()&gt; {<br>    let client = RpcClient::new_with_commitment(<br>        String::from(&quot;http://localhost:8899&quot;),<br>        CommitmentConfig::confirmed(),<br>    );<br><br>    let from_keypair = Keypair::new(); // payer<br>    let new_account_keypair = Keypair::new();<br>    let data_len = 0;<br>    let rent_exemption_amount = client<br>        .get_minimum_balance_for_rent_exemption(data_len)<br>        .await?;<br><br>    let create_acc_ix = create_account_ix(<br>        &amp;from_keypair.pubkey(),        // payer<br>        &amp;new_account_keypair.pubkey(), // new account<br>        rent_exemption_amount,         // rent exemption fee<br>        data_len as u64,               // space reseved for new account<br>        &amp;SYSTEM_PROGRAM_ID,            // assigned program address<br>    );<br><br>    let transaction_signature = client<br>        .request_airdrop(&amp;from_keypair.pubkey(), 1 * LAMPORTS_PER_SOL)<br>        .await?;<br>    loop {<br>        if client.confirm_transaction(&amp;transaction_signature).await? {<br>            break;<br>        }<br>    }<br><br>    let mut transaction =<br>        Transaction::new_with_payer(&amp;[create_acc_ix], Some(&amp;from_keypair.pubkey()));<br>    transaction.sign(<br>        &amp;[&amp;from_keypair, &amp;new_account_keypair],<br>        client.get_latest_blockhash().await?,<br>    );<br><br>    match client.send_and_confirm_transaction(&amp;transaction).await {<br>        Ok(signature) =&gt; println!(&quot;Transaction Signature: {}&quot;, signature),<br>        Err(err) =&gt; eprintln!(&quot;Error sending transaction: {}&quot;, err),<br>    }<br><br>    Ok(())<br>}</pre><h4>Line-by-line breakdown:</h4><ul><li>RpcClient: connects to a local Solana cluster.</li><li>Keypair::new(): generates a new keypair for payer and account.</li><li>get_minimum_balance_for_rent_exemption: calculates rent exemption amount for an empty account.</li><li>create_account_ix: creates an instruction to initialize a new account.</li><li>request_airdrop: gets some SOL for the payer.</li><li>confirm_transaction: waits until the airdrop transaction is finalized.</li><li>Transaction::new_with_payer: constructs a transaction with the payer.</li><li>transaction.sign: signs using both payer and new account’s keypair.</li><li>send_and_confirm_transaction: broadcasts and confirms the transaction on-chain.</li></ul><p>Now, here’s the thing — with the above setup, the new account is <strong>linked to a keypair</strong>. That means <strong>you’ll need to remember the private key</strong> to ever read/write to that account. Not ideal!</p><p>That’s where <strong>PDAs</strong> come in. These are <strong>Program Derived Addresses</strong> — and we’ll discuss them next 👇</p><h3>PDAs — Program Derived Addresses</h3><p>Now here’s something cool — in Solana, <strong>you can generate public keys without needing private keys</strong>. Yeah, seriously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*fq0yZAHi1j95XGKQ9W4j3g.png" /></figure><p>This is made possible using the <strong>ed25519 elliptic curve</strong>, which (for those who care) allows us to deterministically generate public keys from seeds. Think of it like a <strong>hash map</strong> — if you know the seed, you know where the address is going to land.</p><p>To get a valid address <strong>off the curve</strong>, we use something called a <strong>bump</strong> — a byte that helps us move off the curve to ensure uniqueness and avoid collisions.</p><blockquote><strong><em>So, why use PDAs?</em></strong><em><br> Here’s why:</em></blockquote><ul><li>No need to manage private keys</li><li>Deterministic and reproducible addresses</li><li>Only programs (not users) can control them</li><li>Fully trustless</li><li>Used for <strong>CPIs</strong> (cross-program invocations)</li><li>All logic handled <strong>on-chain</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RflpgOQU-KbaL4qCHc3uwQ.png" /></figure><h3>Creating PDA Accounts with Anchor</h3><p>Let’s walk through how to <strong>create a PDA</strong> and use it to initialize an account.</p><p>We’re using the <strong>Anchor framework</strong> here. This example program has a single initialize instruction, which:</p><ul><li>creates a PDA account</li><li>stores the user’s public key</li><li>stores the bump used in the PDA derivation</li></ul><h3>Rust Program</h3><pre>use anchor_lang::prelude::*;<br><br>declare_id!(&quot;75GJVCJNhaukaa2vCCqhreY31gaphv7XTScBChmr1ueR&quot;);<br><br>#[program]<br>pub mod pda_account {<br>    use super::*;<br><br>    pub fn initialize(ctx: Context&lt;Initialize&gt;) -&gt; Result&lt;()&gt; {<br>        let account_data = &amp;mut ctx.accounts.pda_account;<br>        // store the address of the user<br>        account_data.user = *ctx.accounts.user.key;<br>        // store the canonical bump<br>        account_data.bump = ctx.bumps.pda_account;<br>        Ok(())<br>    }<br>}</pre><h3>Context and Account Definitions</h3><pre>#[derive(Accounts)]<br>pub struct Initialize&lt;&#39;info&gt; {<br>    #[account(mut)]<br>    pub user: Signer&lt;&#39;info&gt;,<br><br>    #[account(<br>        init,<br>        // define the seeds to derive the PDA<br>        seeds = [b&quot;data&quot;, user.key().as_ref()],<br>        // use the canonical bump<br>        bump,<br>        payer = user,<br>        space = 8 + DataAccount::INIT_SPACE<br>    )]<br>    pub pda_account: Account&lt;&#39;info, DataAccount&gt;,<br>    pub system_program: Program&lt;&#39;info, System&gt;,<br>}<br><br>#[account]<br>#[derive(InitSpace)]<br>pub struct DataAccount {<br>    pub user: Pubkey,<br>    pub bump: u8,<br>}</pre><p>Let’s break this down line-by-line.</p><h3>Seeds + PDA logic</h3><pre>#[account(<br>    init,<br>    seeds = [b&quot;data&quot;, user.key().as_ref()],<br>    bump,<br>    payer = user,<br>    space = 8 + DataAccount::INIT_SPACE<br>)]</pre><ul><li>init: Tells Anchor to create this account.</li><li>seeds: How we derive the PDA. We’re using a fixed seed b&quot;data&quot; and the user’s public key.</li><li>bump: Used to get off the ed25519 curve and create a valid PDA.</li><li>payer: The user pays the rent (like always).</li><li>space: Memory reserved — 8 bytes for the discriminator + the space defined by DataAccount.</li></ul><p>Anchor handles the PDA derivation and CPI (Cross-Program Invocation) to the system program automatically.</p><h3>TypeScript Tests</h3><h3>Derive PDA</h3><pre>const [PDA] = PublicKey.findProgramAddressSync(<br>  [Buffer.from(&quot;data&quot;), user.publicKey.toBuffer()],<br>  program.programId<br>);</pre><p>We use the same seeds and program ID to get the PDA address off-chain. The same logic is used by the on-chain program.</p><h3>Invoke the Instruction</h3><pre>it(&quot;Is initialized!&quot;, async () =&gt; {<br>  const transactionSignature = await program.methods<br>    .initialize()<br>    .accounts({<br>      user: user.publicKey<br>    })<br>    .rpc();<br><br>  console.log(&quot;Transaction Signature:&quot;, transactionSignature);<br>});</pre><p>You don’t even have to manually pass the pda_account — Anchor can infer it using seeds and bumps!</p><h3>Fetch the PDA Account</h3><pre>it(&quot;Fetch Account&quot;, async () =&gt; {<br>  const pdaAccount = await program.account.dataAccount.fetch(PDA);<br>  console.log(JSON.stringify(pdaAccount, null, 2));<br>});</pre><p>This lets you retrieve the account on-chain using the PDA address we derived earlier.</p><h3>⚠️ One Seed = One Account</h3><p>Important thing to remember — <strong>we can’t reuse the same seeds</strong> to initialize more than once. If we try to call initialize() again with the same user seed, it will fail — because an account <strong>already exists at that PDA</strong>.</p><p>Now at last…<br>Let’s talk about <strong>what CPIs really are coz I mentioned them above, if you noticed, lol.</strong></p><h3>Cross-Program Invocations or CPIs</h3><p>CPIs are what allow <em>Solana programs</em> to talk to each other on-chain. Imagine I’ve written a <strong>token program</strong>, and you’ve written a <strong>swap program</strong> — with CPIs, they can interact. They can share accounts.<br>For example, <strong>associated token accounts</strong> (yes, the ATA everyone talks about) are used across programs. It’s like having <em>shared memory</em>, but for Solana programs 😄.</p><p>So my token program can say:<br> “Hey, I see you’ve got some USDC in your ATA, I’mma let your swap program use it — securely and trustlessly.”</p><p>That’s CPIs.</p><p>There’s way more to this though — like how this whole thing still beautifully ties back into <strong>ed25519 curves</strong>, how validation still works, and what kinds of constraints we can apply when sharing accounts.<br>But maybe let’s save that deep-dive for next time ✨</p><p>In the <strong>next blog</strong>, I’m planning to cover(as taught in superdev fellowship):</p><ul><li>How to <strong>build a storage program</strong> on Solana</li><li>How to <strong>write tests</strong> for it</li><li>And then — how to <strong>do the same using Anchor.</strong></li></ul><p>This post was already <strong>a dense ride</strong>, and if you followed till here, I genuinely appreciate you.</p><p>🫶 Written with love and understanding, by <strong>Prapti</strong></p><p>Feel free to write a comment, drop a clap, or connect with me here:<br> 🔗 <a href="https://x.com/praptichlling">https://x.com/praptichlling</a></p><p>I’ll probably build a GitHub repo for that storage program and its Anchor implementation too, here:<br> 🐙 <a href="https://github.com/praptisharma28">https://github.com/praptisharma28</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=754319582462" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building the Real World Web: How Solana Powers the DePIN Revolution]]></title>
            <link>https://medium.com/@praptii/building-the-real-world-web-how-solana-powers-the-depin-revolution-ba2c5f9e93cb?source=rss-6dd421fa5cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba2c5f9e93cb</guid>
            <category><![CDATA[solana-network]]></category>
            <category><![CDATA[depin]]></category>
            <category><![CDATA[solana-depin]]></category>
            <category><![CDATA[hivemapper]]></category>
            <category><![CDATA[solana-blockchain]]></category>
            <dc:creator><![CDATA[Prapti Sharma]]></dc:creator>
            <pubDate>Tue, 22 Jul 2025 10:21:56 GMT</pubDate>
            <atom:updated>2025-07-22T10:21:56.547Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1g9P01dXSFmkKdlQwrUn6Q.png" /><figcaption>Inspiration source: Messari</figcaption></figure><h3>What is DePIN?</h3><p>Imagine combining physical infrastructure — like WiFi hotspots, mapping sensors, or GPU servers — with blockchain incentives. That’s exactly what a <strong>Decentralized Physical Infrastructure Network (DePIN)</strong> does: it rewards individuals for contributing real‑world resources through tokens, instead of relying on big corporations. These rewards encourage deployment, maintenance, and participation in systems ranging from wireless networks to computing hubs (<a href="https://phantom.com/learn/crypto-101/depin-decentralized-physical-infrastructure-networks?utm_source=chatgpt.com">Phantom</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oTzTPK9s7b1EfJ6u" /><figcaption><strong>Solana DePIN Ecosystem (June 2025), s<em>ource:</em></strong><em> Syndica, June 2025 Ecosystem Report. </em><strong><em>For a detailed analysis, see: </em></strong><a href="https://blog.syndica.io/state-of-depin-june-2025"><em>https://blog.syndica.io/state-of-depin-june-2025</em></a></figcaption></figure><h3>Why Solana Is the Go-To Blockchain for DePIN</h3><p>Solana checks the key boxes for DePIN:</p><ul><li><strong>High throughput and ultra‑low fees</strong>: Thousands of transactions per second with micro‑dollar costs (<a href="https://medium.com/%40hrknsinst/why-every-major-depin-project-is-migrating-to-solana-and-what-this-reveals-about-the-a3269ea431a7?utm_source=chatgpt.com">Medium</a>).</li><li><strong>Fast finality (&lt; 1 sec)</strong>: Ensures real‑time validation critical for sensor networks or IoT gateways (<a href="https://www.bitget.com/news/detail/12560604693435?utm_source=chatgpt.com">Bitget</a>).</li><li><strong>Developer ecosystem</strong>: Rich tooling and mature RPC infrastructure streamline DePIN deployment (<a href="https://www.gate.com/learn/articles/a-de-pin-empire-is-quietly-emerging-on-solana/9644?utm_source=chatgpt.com">Gate.com</a>).</li></ul><p>These features let physical devices — like Helium hotspots or GPU rigs — interact seamlessly with the chain, without bottlenecks or wallet-draining fees (<a href="https://academy.swissborg.com/en/learn/solana-depin?utm_source=chatgpt.com">SwissBorg Academy</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nyKlAqGOBxJGoXgX_fWySA.png" /><figcaption>From early 2023 to June 2025, Solana DePIN more than tripled the number of connected devices amongst their networks, reaching a count of 2.3M.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gUNy5kX9Wt_cUuo46XAQww.png" /><figcaption>Since 2022, Solana has captured the bulk of significant DePIN token launches, hosting 9 of the last 20 with at least a $10M market cap, replacing Ethereum as the DePIN chain. <a href="https://x.com/solana">Solana</a> has become the hub for new DePIN protocols since 2022.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/0*rIhf_CLvBh08AxQK" /><figcaption><strong>State of Solana DePIN 2025</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/0*BOSQsumRi9mrjUxb" /><figcaption>When excluding standalone Layer 1 chains operated by some projects, the <strong>total DePIN on-chain market cap</strong> stands at approximately <strong>$7.1 billion</strong>. Of that total, <strong>Solana leads with $3.25 billion</strong>, positioning it as the most valuable DePIN platform by blockchain market share.</figcaption></figure><h3>Solana DePIN in Action: 3 Standout Projects</h3><p>Here are three vibrant DePIN projects built on Solana, each from a distinct vertical:</p><h4>1. Helium Network (Wireless IoT &amp; 5G)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aEDmzUZTDgeS4qOJ" /><figcaption>By assembling these tools, Helium was able to rebuild a fully operational DePIN on Solana in a fraction of the time.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*Tq0qJTe4omfUTbBY" /><figcaption>Over <strong>1 million mobile devices </strong>now rely on Helium Mobile in the U.S., including <strong>300,000+ active subscribers</strong>.</figcaption></figure><ul><li>Powering decentralized 5G and IoT networks.</li><li><strong>176,000+ mobile subscribers</strong>, <strong>69,000+ active nodes</strong>.</li><li><strong>$2.3M/month</strong> on-chain revenue.</li><li>In April 2025, Helium hit <strong>1.1M daily users</strong> and <strong>36 TB/day</strong> of mobile traffic.</li><li>Originally its own chain but migrated to Solana in April 2023 for scale (<a href="https://solanacompass.com/projects/category/rwa/depin?utm_source=chatgpt.com">Solana Compass</a>, <a href="https://medium.com/%40hrknsinst/why-every-major-depin-project-is-migrating-to-solana-and-what-this-reveals-about-the-a3269ea431a7?utm_source=chatgpt.com">Medium</a>).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*_klu2utgAIoxyG66" /><figcaption>Helium achieved a <strong>new all-time high (ATH) of $323K in on-chain revenue</strong>, according to <strong>Syndica’s recent report</strong>.</figcaption></figure><h4>2. Render Network (Distributed GPU Rendering)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/0*8b7y74fE3VRBpZBb" /><figcaption>3,800+ active GPU providers as of April 2025.</figcaption></figure><ul><li>Turns idle GPUs into rendering power.</li><li><strong>3,800+ active GPU nodes</strong> (July 2025).</li><li>Users burned <strong>121M+ RNDR tokens</strong> for compute.</li><li>Weekly revenue: peaked at <strong>$300K</strong>, stabilized near <strong>$70K</strong>.</li><li>Offers artists a cheaper alternative to centralized render farms (<a href="https://solanacompass.com/projects/category/rwa/depin?utm_source=chatgpt.com">Solana Compass</a>, <a href="https://academy.swissborg.com/en/learn/solana-depin?utm_source=chatgpt.com">SwissBorg Academy</a>).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*xev0Gg-VOnqKzOYR" /><figcaption>Currently, users have burned over 121 million RENDER tokens by utilizing GPU resources, while more than 2.4 million tokens have been minted as rewards for node operators.</figcaption></figure><h4>3. Hivemapper (Decentralized Mapping)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*1yAuj7pXcS9Qz4JW" /><figcaption>Hivemapper’s model is faster, cheaper, and more scalable than traditional mapping approaches</figcaption></figure><ul><li>Turns dashcam footage into decentralized map data.</li><li><strong>77,000+ contributor nodes</strong> (as of April 2025).</li><li>Mapped <strong>20M+ km</strong> of roads across <strong>100+ countries</strong>.</li><li>Enterprise clients: <strong>Lyft</strong>, <strong>Trimble</strong>, <strong>TomTom</strong>, <strong>NBC</strong>.</li><li>The network pays contributors in <strong>HONEY</strong> tokens.</li><li>Monetization: burns 75% of HONEY tokens paid in Map Credits.</li><li>Over 2.4M miles of roads mapped; governance and payments happen on Solana (<a href="https://atomicwallet.io/academy/articles/best-depin-projects-on-solana?utm_source=chatgpt.com">Atomic Wallet</a>).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n4GdicEtYtDuoDPeHOrtFA.png" /><figcaption>In June, demand measured in USD burned increased 81% to $27k, bringing in a total of $114k in revenue so far this year.</figcaption></figure><h3>DePIN vs Web2: Why It’s a Game-Changer</h3><p>Feature Web2 Model Solana DePIN Model Ownership Centralized corporations Community-owned Cost &amp; Efficiency High infrastructure costs Low marginal cost via token incentives Scalability Slow, cap-ex expansion Global, user-driven growth Incentive Alignment Top-down salaries Direct rewards for contributors Transparency Opaque operations and pricing On-chain, verifiable, open-source</p><p>DePINs democratize access to infrastructure. Instead of centralized firms controlling networks, users across the globe contribute and benefit directly aligning incentives and reducing waste.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DGeqSDeVI5n_9zEzd-MF2g.png" /><figcaption>Web2 vs Solana DePIN</figcaption></figure><h3>Building the DePIN Ecosystem</h3><ol><li><strong>Deploy your hardware</strong>: Set up a hotspot, GPU node, or sensor.</li><li><strong>On-chain rewards</strong>: Smart contracts manage payouts based on data or service delivery.</li><li><strong>Network growth</strong>: More nodes = stronger coverage and value.</li><li><strong>Re-invest or cash out</strong>: Rewards allow scaling or earning.</li></ol><p>This creates a <strong>flywheel</strong> of participation, where success drives further adoption — without traditional overhead (<a href="https://en.wikipedia.org/wiki/Decentralized_physical_infrastructure_network?utm_source=chatgpt.com">en.wikipedia.org</a>, <a href="https://solana.com/solutions/depin?utm_source=chatgpt.com">Solana</a>, <a href="https://solanacompass.com/projects/category/rwa/depin?utm_source=chatgpt.com">Solana Compass</a>, <a href="https://medium.com/%40rkmonarch/how-depin-projects-are-leveraging-solana-to-build-the-decentralized-physical-network-c129db29db48?utm_source=chatgpt.com">Medium</a>, <a href="https://atomicwallet.io/academy/articles/best-depin-projects-on-solana?utm_source=chatgpt.com">Atomic Wallet</a>, <a href="https://phantom.com/learn/crypto-101/depin-decentralized-physical-infrastructure-networks?utm_source=chatgpt.com">Phantom</a>, <a href="https://aetsoft.net/blog/what-is-depin-crypto/?utm_source=chatgpt.com">Aetsoft</a>).</p><h3>Why We Should Care</h3><ul><li><strong>Community empowerment</strong>: Anyone with hardware can join the network.</li><li><strong>Cost and efficiency</strong>: Eliminates middlemen and overhead.</li><li><strong>Rapid scaling</strong>: Real-world coverage grows faster than in corporate models.</li><li><strong>Real-world impact</strong>: Better maps, cheaper compute, global wireless coverage.</li></ul><p>Innovators, hardware enthusiasts, and developers all have a role in this ground-up revolution.</p><h3>Final Thoughts:</h3><blockquote>“Solana is the mecca of DePIN… Render’s node operator count has grown 12× over six months… Helium hotspot supply multiplied rapidly since migrating to Solana.” <br>— said <a href="https://x.com/Syndica_io/status/1801327991856722192">Syndica_io</a> on x.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VSnuk0w-IIiBBLlSHXIDug.jpeg" /><figcaption>Source: <a href="https://x.com/Syndica_io">@Syndica_io</a> on x.com</figcaption></figure><p>Solana’s unmatched speed, affordability, and developer tools create a foundation for DePIN to flourish. Projects like Helium, Render, and Hivemapper are just the beginning — Solana’s DePIN ecosystem already hosts dozens of initiatives across wireless, compute, storage, energy, and more (<a href="https://solanacompass.com/projects/category/rwa/depin?utm_source=chatgpt.com">Solana Compass</a>, <a href="https://www.gate.com/learn/articles/a-de-pin-empire-is-quietly-emerging-on-solana/9644?utm_source=chatgpt.com">Gate.com</a>).</p><p>DePIN is ushering in a new infrastructure paradigm — community-owned, token-powered, and built for real-world impact. If you’re a developer, builder, or tech enthusiast looking for the next frontier, Solana’s DePIN wave is one to ride.</p><p>Made with love and research for me, you and the <a href="https://x.com/Solana">solana</a> community by <a href="https://x.com/praptichilling">Prapti</a>. Thanks. ❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba2c5f9e93cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Diving Deep into Solana and Blockchain]]></title>
            <link>https://medium.com/@praptii/diving-deep-into-solana-and-blockchain-539546473cf6?source=rss-6dd421fa5cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/539546473cf6</guid>
            <category><![CDATA[solana-blockchain]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[superteamdao]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solana-network]]></category>
            <dc:creator><![CDATA[Prapti Sharma]]></dc:creator>
            <pubDate>Thu, 17 Jul 2025 16:08:33 GMT</pubDate>
            <atom:updated>2025-07-18T16:24:53.813Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*A9DDyorGxGEthXWxUqSteg.png" /></figure><p>This blog post will cover the fundamental concepts of Solana and blockchain, drawing directly from our comprehensive introductory lecture by <a href="https://ackee.xyz/">AckeeBlockchain</a>, school of solana- season 7.</p><h3><strong>Introduction to Solana</strong></h3><p>Many of us might know Solana primarily for its token, but our focus here is on understanding its underlying technology and developing on it.</p><p>Solana was founded in 2017 by <strong>Anatoly Yakovenko</strong>, a former Qualcomm engineer. The testnet launched in 2018, and the mainnet beta went live in March 2020. For those unfamiliar, a testnet is a testing network for developers, where assets have no real value, allowing us to experiment before deploying to the mainnet, where assets hold real value.</p><p>Solana is a <strong>Layer 1 blockchain</strong>, similar to Ethereum or Bitcoin, but specifically designed for smart contracts like Ethereum. Unlike Bitcoin, which primarily focuses on storing value, Solana and Ethereum enable complex decentralized applications. Solana is also a <strong>Proof-of-Stake (PoS)</strong> network, where validators stake their assets to validate and create new blocks, earning rewards or facing penalties for malicious behavior. This contrasts with Proof-of-Work (PoW) networks like Bitcoin, which rely on miners solving cryptographic puzzles.</p><h4>Solana: A Decentralized Globally Synchronized State Machine</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aU9SRq1rxo7cBqsyfmF6UA.png" /><figcaption>Solana is decentralized, globally secure state machine</figcaption></figure><p>This image represents the Solana architecture with outer layers for applications/users, a middle layer for RPCs, and the core layer for validators.</p><ul><li><strong>Outer Layer</strong>: This includes our computers, mobile phones, and web applications (like Phantom wallet).</li><li><strong>Middle Layer (RPCs)</strong>: These are nodes that serve as data storage and communication points. When our web application needs to know an account’s balance, it communicates with an RPC node, not directly with a validator.</li><li><strong>Core Layer (Validators)</strong>: These are computers running Solana software, striving to maintain a globally synchronized state with all other validators. If one validator changes its software state (e.g., records a transaction), this change must be propagated and synchronized across all other validators. This core principle that Solana is a <strong>decentralized, globally synchronized state machine</strong> is key to understanding its operation.</li></ul><p>For a dynamic visualization of Solana’s validators, we can explore <a href="https://validators.app/">validators.app</a> and <a href="https://solanabeach.io/">solanabeach.io</a>.</p><h4>Innovations in Solana’s Ecosystem</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZXha4BYZ3_8ixHYzz3MtAA.png" /></figure><p>We often hear about Solana’s unique innovations, and we want to understand what each term means. These include:</p><ul><li><strong>Proof of History (PoH)</strong></li><li><strong>Turbine</strong></li><li><strong>Gulf Stream</strong></li><li><strong>Sealevel</strong></li><li><strong>Pipelining</strong></li><li><strong>Cloudbreak</strong></li><li><strong>Archivers</strong></li></ul><p><strong>Current State of Solana (as of the lecture):</strong></p><ul><li><strong>Nakamoto Coefficient</strong>: Currently around 20–22. This refers to the minimum number of validators needed to cooperatively halt the network. It’s a measure of decentralization, focusing on the ability to stop the network, not necessarily to produce malicious information (which would require a much higher stake, around 66%).</li><li><strong>True TPS (Transactions Per Second)</strong>: Approximately 1,000–1,300. This excludes vote transactions between validators, offering a clearer picture of actual user/bot transactions. This performance is continuously improving as we increase bandwidth and reduce latency.</li><li><strong>Block Times</strong>: 400 milliseconds. A new block is created every 400ms, significantly faster than Bitcoin’s ~10 minutes.</li><li><strong>Time to Finality</strong>: Approximately 12 seconds. After this period, it’s highly unlikely that a block containing our transaction will be invalidated due to a fork. F<strong>inality</strong> refers to the guarantee that transactions, once recorded on the blockchain, cannot be changed, reversed, or altered. Once a transaction reaches finality, it is considered irreversible and permanent.</li><li><strong>Validators</strong>: Approximately 1,200 validators. Solana value geographical distribution over sheer numbers for better decentralization.</li><li><strong>Multiple Validator Clients</strong>: Solana benefits from multiple implementations of its software (e.g., Jito, Firedancer, Agave), enhancing decentralization. If one client has a bug, others can continue operating, ensuring network resilience.</li></ul><h4>How Solana Achieves High Performance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VUsTJ_ZoHa1x4Xf_KLoCsA.png" /><figcaption>This image illustrates the transaction flow from a user’s wallet/dApp to an RPC, and then to a validator, from there to block building, then to turbine, verification and consensus.</figcaption></figure><p>The core philosophy behind Solana’s speed is maximizing bandwidth and minimizing latency. Let’s break down the key components involved in transaction processing.</p><p><strong>User Interaction to Transaction Broadcast:</strong><br>When we use a dApp (decentralized application) or wallet like Phantom to transfer funds (e.g., USDC), here’s what happens:</p><ol><li>We initiate a transfer in the dApp.</li><li>Our wallet signs the transaction with our private key.</li><li>The signed transaction is sent from the dApp to an RPC node.</li><li>From the RPC node, the transaction is forwarded to a validator.</li></ol><p><strong>Transaction Processing in a Validator (Block Building):</strong></p><p>Once a validator receives a transaction, the following steps occur:</p><ol><li><strong>Network Interface</strong>: Transactions (as packets) are received.</li><li><strong>Signature Verification</strong>: Invalid signatures are filtered out early.</li><li><strong>Banking Stage (Parallel Processing)</strong>: Valid transactions enter the banking stage, where they are processed in parallel.</li></ol><ul><li><strong>Accounts DB</strong>: On Solana, smart contracts don’t have built-in storage. Instead, they use <strong>accounts</strong> — key-value pairs stored in the Accounts DB across validators. Our wallet balances, for example, are stored in SPL token accounts.</li><li>Each instruction in a smart contract specifies the accounts it needs to interact with and whether those accounts will be mutable (modified) or read-only.</li><li>A <strong>scheduler</strong> analyzes these account dependencies. If multiple transactions try to modify the <em>same</em> account simultaneously, it creates a sequential order to prevent conflicts (like “write after write” hazards). However, if transactions affect different accounts or only read from them, they can be processed in parallel. This parallel execution of non-conflicting transactions is a major reason for Solana’s speed.</li></ul><p>4.<strong> Proof of History (PoH) Service</strong>: This is a synchronization mechanism, <em>not</em> a consensus mechanism like PoS. It ensures the correct sequence of transactions within a block.</p><ul><li>Imagine it like a newspaper photograph: a photo of an apple must have been created <em>before</em> the newspaper. Similarly, PoH creates a verifiable, sequential record of events.</li><li>As transactions are processed, the validator generates a unique <strong>hash (checkpoint)</strong> after each one. This hash becomes an input for the next hash, creating a linked chain. If the transaction order is changed, the hashes become incorrect, ensuring data integrity.</li><li>Crucially, PoH sequence <em>creation</em> is sequential, but its <em>validation</em> by other validators can be done in parallel. This is because once the full sequence of hashes is broadcasted, other validators can simultaneously verify different parts of the chain, making the validation process extremely fast.</li></ul><h4>Gulf Stream: Transaction Forwarding</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pj7Zo5rCl-iIPy7RmW5z3g.png" /></figure><p>Unlike other blockchains with mempools (pools of unconfirmed transactions where validators pick based on fees), Solana uses <strong>Gulf Stream</strong>.</p><ul><li>Solana pre-computes a <strong>leader schedule</strong> for the next epoch (approximately two days). Every validator knows which validator will be the leader for each slot (400ms block time).</li><li>Instead of transactions waiting in a mempool, they are <strong>directly forwarded to the designated leader</strong> for the current slot. This reduces latency and increases efficiency.</li></ul><h4><strong>Stake-Weighted Quality of Service (QoS)</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jNznkx4ew_gjY19VWhGDRQ.png" /></figure><p>During times of network congestion (like in early 2024), bots and spammers could overwhelm leaders. To mitigate this, <strong>Stake-Weighted QoS</strong> was introduced:</p><ul><li>Leaders prioritize connections from validators with higher staked weight. For example, 80% of connections might be dedicated to highly staked, trustworthy validators, and 20% to non-paired RPCs or less-staked entities.</li><li>This ensures that transactions from more “trustworthy” sources (those with significant stake) have a higher likelihood of reaching the leader, preventing network spam from low-stake entities.</li><li>Additionally, trusted validators can delegate their connection priority to specific RPCs, allowing those RPCs to directly forward transactions to the leader.</li></ul><h4><strong>Network Layer (QUIC)</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mda_AERsE2bHzmYjvs6AHA.png" /></figure><p>Solana utilizes QUIC, a transport layer protocol similar to UDP but with improvements for performance. QUIC has a shorter handshake and can reuse connection information, contributing to Solana’s high speed, especially compared to the more strict and sequential TCP.</p><h4>Processing Transactions: Building Blocks on Solana</h4><p>Now, let’s dive into what happens inside the validator as it processes transactions and builds blocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Sd4jvVnmsCEwcltBsTTRQ.png" /><figcaption>This image depicts the validator’s internal process, including signature verification, parallel processing (banking stage), Proof of History, and Accounts DB.</figcaption></figure><ol><li><strong>Network Interface &amp; Signature Verification</strong>: Incoming packets are received, and transactions within them are immediately verified for valid signatures. Invalid transactions are filtered out, saving processing power.</li><li><strong>Banking Stage: Parallel Processing with Sealevel</strong></li></ol><ul><li>Once signatures are verified, transactions enter the “banking stage.” This is where Solana’s parallel processing capabilities truly shine, thanks to its <strong>Sealevel</strong> runtime.</li><li><strong>Accounts DB</strong>: On Solana, smart contracts don’t have built-in storage. Instead, they interact with <strong>accounts</strong> — key-value pairs stored in a vast database known as the Accounts DB, which is replicated across validators. Our wallet balances, for example, are stored in SPL token accounts, which are a type of data account.</li><li><strong>Rust &amp; Accounts</strong>: When we write Solana smart contracts (programs) in Rust, each instruction we define must explicitly declare the accounts it intends to use and whether it needs read or write (mutable) access to them.</li><li>For example, a transaction to transfer 20 USDC from our wallet to a friend’s wallet would require <em>both</em> our wallet account and our friend’s wallet account to be marked as mutable because their balances will change.</li><li><strong>The Scheduler</strong>: Solana uses a scheduler that analyzes these account dependencies. If multiple transactions try to modify the <em>same</em> account concurrently, the scheduler ensures they are processed sequentially to prevent data corruption (known as hazards like “write-after-write”). However, if transactions affect different accounts or only read from them, they can be executed in parallel. This intelligent scheduling allows Solana to process thousands of transactions simultaneously without conflicts, leading to its high throughput. Reading from the same account by multiple instructions in parallel is perfectly fine as it doesn’t change the state.</li></ul><h4><strong>3. Proof of History (PoH) Service</strong>:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B6RZzHkQwQUR_Z-bDT_u3w.png" /></figure><p>This is a critical component for maintaining chronological order and is a synchronization mechanism, <em>not</em> a consensus mechanism like Proof of Stake.</p><ul><li>PoH creates a verifiable, sequential record of events. Imagine it like a cryptographic timestamp: a photograph of an apple must have been created <em>before</em> the newspaper that contains its photograph was printed. Similarly, PoH generates a unique <strong>hash (checkpoint)</strong> after each transaction is processed. This hash becomes an input for the next hash, creating a linked, verifiable sequence.</li><li>If the order of transactions within a block were changed, the resulting hashes would be incorrect, allowing other validators to detect tampering and verify the integrity of the sequence.</li><li>Crucially, the PoH sequence <em>creation</em> by the leader is sequential (each hash depends on the previous one). However, its <em>validation</em> by other validators can be done in parallel. Once the full sequence of hashes is broadcasted along with the block, other validators can use multiple threads to simultaneously verify different parts of the chain. This parallel validation significantly speeds up the verification process across the network.</li></ul><p><strong>4. Broadcast Stage (Turbine)</strong>: Once the transactions are processed, and the block is created with its PoH sequence, the block is broadcasted to other validators. Solana’s <strong>Turbine</strong> protocol uses a decentralized, tree-like structure for block propagation. The leader broadcasts the block to its “neighbors,” who then propagate it further, ensuring efficient dissemination across the network.</p><p><strong>5. Block Validation and Consensus</strong>: Each receiving validator executes the transactions within the block to ensure their local state remains synchronized with the leader’s. They then vote on the validity of the block, and once a supermajority (typically 66% of staked weight) is reached, consensus is achieved.</p><h4>Accounts: Solana’s Storage Model Revisited</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_wu2VHe_ZkxG5jcddTl30g.png" /></figure><p>To reiterate and clarify the accounts concept:</p><ul><li>Accounts are simply <strong>key-value pairs</strong>, similar to a HashMap in programming.</li><li>The <strong>key</strong> is usually a public key (like your wallet address).</li><li>The <strong>value</strong> is the content of the account, stored as bytes.</li></ul><p>An <strong>SPL Token Account</strong> is a common example. It holds your balance of a specific token (e.g., USDC). Its data, stored in bytes, includes fields like the token’s mint (address), the account&#39;s owner (your wallet public key), and the amount of tokens held.</p><p>The crucial takeaway is that Solana smart contracts (programs) <strong>do not have dedicated storage directly embedded within them</strong>. Instead, they interact with and modify data stored in separate <strong>data accounts</strong>. When we develop smart contracts, we explicitly define which accounts our instructions will interact with, whether for reading or writing. We will experience this firsthand in our upcoming programming lessons.</p><h4>Alpenglow: The Future of Solana</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1wZHYC1gbemz_HHdxFtSlg.png" /></figure><p><strong>Alpenglow</strong>, an upcoming major upgrade to Solana’s architecture, expected to be released around 2026. While still largely conceptual, it aims to significantly enhance network performance and decentralization:</p><ul><li><strong>Reduced Time to Finality</strong>: Alpenglow targets a drastic reduction in time to finality, from the current ~12 seconds to an astonishing 150 milliseconds.</li><li><strong>No More On-Chain Vote Transactions</strong>: Currently, validators’ votes on blocks are recorded as on-chain transactions, incurring fees. Alpenglow aims to remove these, reducing validator expenses and improving network efficiency</li><li><strong>Proof of History (PoH) in Consensus Removed</strong>: It’s anticipated that PoH’s role in consensus will be removed, potentially simplifying the consensus mechanism.</li></ul><p><strong>New Components: Rotor and Votor</strong>: These are two key innovations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p29uiO11PZpK5_UpaFuYqQ.png" /><figcaption>This image would visually represent the Rotor concept, showing leader -&gt; relayer -&gt; validators.</figcaption></figure><ul><li><strong>Rotor</strong>: An evolution of Turbine (block propagation). Instead of a multi-level tree structure for block propagation, Rotor proposes a more direct model where the leader sends the block to “relayers,” which then distribute it to other validators. This aims for even faster block propagation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lK7EwXS35tDtlarGexKOUg.png" /><figcaption>This image would visually represent the Votor concept, showing validators -&gt; aggregator (off-chain voting) -&gt; BLS certificate -&gt; next leader (on-chain)</figcaption></figure><ul><li><strong>Votor</strong>: This will revolutionize consensus. Instead of validators sending individual on-chain vote transactions, they will send off-chain “vote messages” to an aggregator. Once 80% of the staked weight has voted “yes,” a single, aggregated BLS certificate (a combined signature) will be created and included in the next block. This “fast finalization” happens off-chain, with only the final certificate on-chain. If 80% is not reached, a slower, two-round finalization process (requiring 60% in two rounds) will occur.</li></ul><p>Alpenglow represents a significant leap forward in Solana’s evolution, focusing on minimizing overhead and maximizing throughput. We encourage everyone to read more about Alpenglow on the Helius blog for deeper insights</p><h4>Conclusion</h4><p>[YouTube Video <a href="https://www.youtube.com/watch?v=vrO6cjdPUOs">Link</a>]<br>If there’s any correction or addition to be done, ping me <a href="https://x.com/praptichilling">here</a>.</p><p>Thank you, keep learning! ❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=539546473cf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Traits and Macros in Rust  : The Complete Beginner-to-Advanced Guide]]></title>
            <link>https://medium.com/@praptii/traits-and-macros-in-rust-the-complete-beginner-to-advanced-guide-49426e97019f?source=rss-6dd421fa5cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/49426e97019f</guid>
            <category><![CDATA[fellowship]]></category>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[solana-blockchain]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[solana-ecosystem]]></category>
            <dc:creator><![CDATA[Prapti Sharma]]></dc:creator>
            <pubDate>Tue, 15 Jul 2025 19:30:48 GMT</pubDate>
            <atom:updated>2025-07-16T09:41:06.484Z</atom:updated>
            <content:encoded><![CDATA[<h3>Traits and Macros in Rust 🦀 : The Complete Beginner-to-Advanced Guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5-UwtRWqDKBJIoDJzTUJQ.png" /><figcaption>Image is straight from Harkirat’s lecture for superdev week-1</figcaption></figure><h3>⚠️ Disclaimer</h3><p>If you’re new to Rust, this blog may feel overwhelming. It assumes you’re already familiar with the basics — like structs, enums, functions, and ownership. I recommend brushing up on those concepts first before diving in. There are excellent beginner-friendly YouTube videos and the <a href="https://doc.rust-lang.org/book/">official Rust Book</a> to help you get started.</p><p>For the code, see this repo- <a href="https://github.com/praptisharma28/superdev-solana-fellowship">https://github.com/praptisharma28/superdev-solana-fellowship</a></p><h3>Traits in Rust</h3><p><strong>Reference</strong>: <a href="https://doc.rust-lang.org/book/ch10-02-traits.html">The Rust Programming Language Book — Traits</a></p><p>Traits in Rust are conceptually similar to <strong>interfaces</strong> in languages like Java or TypeScript. They define a blueprint or <strong>shape</strong> for behavior that types can implement.</p><h3>Defining a Trait</h3><pre>trait Shape {<br>    fn area(&amp;self) -&gt; f32;<br>}</pre><h3>Implementing a Trait for a Struct</h3><pre>struct Rect {<br>    width: f32,<br>    height: f32<br>}<br><br><br>impl Shape for Rect {<br>    fn area(&amp;self) -&gt; f32 {<br>        return self.width * self.height;<br>    }<br>}</pre><h3>Using Traits in Functions</h3><p>We can define a function that accepts any type that implements a trait:</p><pre>fn get_area(shape: impl Shape) -&gt; f32 {<br>    return shape.area();<br>}</pre><p>Or using generics:</p><pre>fn get_area_2&lt;T: Shape&gt;(shape: T) -&gt; f32 {<br>    return shape.area();<br>}</pre><p>Or using a where clause:</p><pre>fn get_area_3&lt;T&gt;(shape: T) -&gt; f32<br>where T: Shape {<br>    return shape.area();<br>}</pre><p>This allows for abstraction and polymorphism in a type-safe way, similar to how interfaces work in object-oriented programming languages.</p><h3>Macros in Rust</h3><p><strong>Reference</strong>: <a href="https://doc.rust-lang.org/book/ch20-05-macros.html">Rust Book — Macros</a></p><p>Macros in Rust are a powerful feature used for <strong>metaprogramming</strong>: writing code that writes other code.</p><p>We’ve likely already used macros like println! and vec!. These expand into more verbose Rust code during compilation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FSrOr-drZSSSi1Wv9tGHlw.png" /><figcaption>Here’s a screenshot to let us know how a macro expands.</figcaption></figure><h3>Macros vs Functions</h3><p>While functions operate on values and types at runtime, macros operate on source code at compile time. Macros can do things functions cannot, like:</p><ul><li>Accepting a variable number of arguments</li><li>Creating new syntax</li><li>Generating boilerplate code</li></ul><h3>Types of Macros</h3><p>There are four broad types of macros in Rust:</p><ul><li><strong>Declarative Macros</strong> (e.g., println!, vec!)</li><li><strong>Custom Derive Macros</strong></li><li><strong>Attribute-like Macros</strong></li><li><strong>Function-like Procedural Macros</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BS9voHdysR-04rgpvlDtpg.png" /><figcaption>Banger image containing all types of macros</figcaption></figure><h3>Declarative Macros</h3><p>Declarative macros use macro_rules! and resemble pattern matching.</p><h3>Example: Evaluating an Expression</h3><pre>macro_rules! eval {<br>    ($expr: expr) =&gt; {<br>        $expr<br>    };<br>}<br><br>fn main() {<br>    let ans = eval!(2 + 3 * 5);<br>    println!(&quot;{}&quot;, ans);<br>}</pre><h3>Example: Creating a Vector</h3><pre>macro_rules! vector {<br>    ( $( $x:expr ),* ) =&gt; {<br>        {<br>            let mut temp_vec = Vec::new();<br>            $(<br>                temp_vec.push($x);<br>            )*<br>            temp_vec<br>        }<br>    };<br>}<br><br>fn main() {<br>    let ans = vector!(1, 2, 3);<br>    println!(&quot;{}&quot;, ans[0]);<br>}</pre><h3>Custom Derive Macros</h3><p>Used to automatically generate common trait implementations. For example:</p><h3>Example: Using borsh</h3><pre>use borsh::{BorshSerialize, BorshDeserialize};<br><br>#[derive(BorshSerialize, BorshDeserialize)]<br>struct User {<br>    num: u32,<br>    pub_key: PubKey<br>}</pre><h3>Example: Debug Trait</h3><pre>#[derive(Debug)]<br>struct User {<br>    name: String,<br>    num: u32,<br>}<br><br>fn main() {<br>    let u = User {<br>        name: String::from(&quot;harkirat&quot;),<br>        num: 10,<br>    };<br>    println!(&quot;{:?}&quot;, u);<br>}</pre><p>This automatically implements the Debug trait, which allows structs to be printed using {:?}.</p><blockquote><em>Note: </em><em>Display is not automatically derived because it&#39;s meant for end-user formatting, not debugging.</em></blockquote><h3>Copy and Clone Traits</h3><h3>Copy Trait</h3><ul><li>Implicit duplication.</li><li>Works for types that can be bitwise copied.</li></ul><pre>#[derive(Copy, Clone)]<br>struct Point {<br>    x: i32,<br>    y: i32,<br>}<br><br>let p1 = Point { x: 1, y: 2 };<br>let p2 = p1; // p1 is copied, not moved<br>println!(&quot;{}, {}&quot;, p1.x, p2.x);</pre><h3>Clone Trait</h3><ul><li>Explicit duplication using .clone()</li><li>Can define custom logic</li></ul><pre>#[derive(Clone)]<br>struct Person {<br>    name: String,<br>    age: u32,<br>}<br><br>let p1 = Person {<br>    name: &quot;Alice&quot;.to_string(),<br>    age: 30,<br>};<br>let p2 = p1.clone();</pre><h3>Attribute-like Macros</h3><p>Used to annotate code and change its behavior, commonly used with serialization libraries like serde.</p><h3>Setup</h3><pre>[dependencies]<br>serde = { version = &quot;1.0&quot;, features = [&quot;derive&quot;] }<br>serde_json = &quot;1.0&quot;</pre><h3>Code</h3><pre>use serde::{Deserialize, Serialize};<br><br>#[derive(Serialize, Deserialize, Debug)]<br>struct User {<br>    name: String,<br>    age: u32,<br>}<br><br>#[derive(Serialize, Deserialize, Debug)]<br>struct Person {<br>    #[serde(rename = &quot;full_name&quot;)]<br>    name: String,<br>    #[serde(skip_serializing_if = &quot;Option::is_none&quot;)]<br>    email: Option&lt;String&gt;,<br>    #[serde(skip)]<br>    password: String,<br>}<br>#[derive(Serialize, Deserialize, Debug)]<br>enum Status {<br>    Active,<br>    Inactive,<br>    Pending,<br>}<br>fn main() -&gt; Result&lt;(), serde_json::Error&gt; {<br>    let user = User {<br>        name: &quot;Alice&quot;.to_string(),<br>        age: 30,<br>    };<br>    let json = serde_json::to_string(&amp;user)?;<br>    println!(&quot;JSON: {}&quot;, json);<br>    let back: User = serde_json::from_str(&amp;json)?;<br>    println!(&quot;Back to struct: {:?}&quot;, back);<br>    let person = Person {<br>        name: &quot;Bob&quot;.to_string(),<br>        email: None,<br>        password: &quot;secret&quot;.to_string(),<br>    };<br>    let json = serde_json::to_string(&amp;person)?;<br>    println!(&quot;Person JSON: {}&quot;, json);<br>    let status = Status::Active;<br>    let status_json = serde_json::to_string(&amp;status)?;<br>    println!(&quot;Status: {}&quot;, status_json);<br>    Ok(())<br>}</pre><h3>Function-like Macros</h3><p>These macros look like functions but are more powerful as they operate on <strong>token streams</strong> and can parse/transform code at compile time.</p><pre>sqlx::query!(&quot;SELECT * FROM users&quot;).exec();</pre><p>Function-like procedural macros are used for:</p><ul><li>Code generation</li><li>Building DSLs (domain-specific languages)</li><li>Transforming AST</li></ul><p>They give full control over the structure and meaning of the input, unlike declarative macros which rely on pattern matching.</p><h3>Final Notes</h3><ul><li>Traits are the foundation for polymorphism and abstraction in Rust, just like interfaces in Java.</li><li>Macros, both declarative and procedural, are what make Rust powerful and expressive.</li><li>When implementing traits like Display, we must manually define the format logic.</li><li>Derived macros like Debug, Clone, Copy, etc., help reduce boilerplate in common patterns.</li><li>In macros, we can pass multiple arguments — even complex data structures or code snippets like HTML (yes, really).</li></ul><h3>📚 Classroom Notes &amp; Mental Models: What I Really Took Away</h3><blockquote><strong><em>- Traits are like interfaces in Java</em></strong><em> — this clicked instantly. Traits let us define a shared shape or contract that our types agree to implement.</em></blockquote><blockquote><em>- To print a struct, us need to implement the </em><em>Display trait manually — because Rust doesn’t give us that by default like it does with </em><em>Debug. Why? Because </em><em>Display is meant for user-facing formatting, and Rust doesn’t assume our formatting logic.</em></blockquote><blockquote><em>- However, </em><em>Debug can be derived because it’s for debugging — that’s why </em><em>#[derive(Debug)] exists. We can simply print using </em><em>{:?} and get internal representation quickly.</em></blockquote><blockquote><em>- Traits are not just about abstracting logic — they’re the </em><strong><em>stepping stone to understanding and using macros</em></strong><em>.</em></blockquote><blockquote><em>- Rust forces us to </em><strong><em>explicitly derive behaviors</em></strong><em> — we must opt-in to features like </em><em>Debug, </em><em>Clone, </em><em>Copy. Nothing happens behind the scenes without our say.</em></blockquote><blockquote><em>- </em><em>Rect::shape() in Rust is like calling a static method in JavaScript. Rust’s syntax often draws clear parallels with JS/OOP — once we see it, we can’t unsee it.</em></blockquote><blockquote><em>- One cool realization: </em><strong><em>when input gets vague</em></strong><em>, like variable input length or unknown types — we don’t use a function, we use a </em><strong><em>macro</em></strong><em>. Because macros expand during compile time and don’t care about strict types like functions do.</em></blockquote><blockquote><em>- Macros aren’t called at runtime — they’re expanded at compile time. That’s why we won’t find them in our call stack — they already turned into raw Rust code!</em></blockquote><blockquote><strong><em>- Macro expansion pipeline</em></strong><em>: Our macro expression → turns into raw Rust code → turns into binary → runs. That middle step is where the real metaprogramming happens.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0YTAeh7Fp18t0O0anJBr-A.png" /><figcaption>See this is what happens behind the scenes.</figcaption></figure><blockquote><em>- Macros are </em>magic<em>. We can pass </em>any number of arguments<em>, even HTML tags or full blocks of code, and macros will parse it all as a token stream. We could literally pass a </em><em>&lt;div&gt; into a macro for fun — and it’ll accept it. Wild.</em></blockquote><blockquote><em>- We even wrote a custom macro like </em><em>vector!(1, 2, 3) that expands to a </em><em>Vec. Macros are not just fancy — they&#39;re </em><strong><em>real tools that cut boilerplate</em></strong><em>.</em></blockquote><blockquote><em>- The difference between declarative and procedural macros? Declarative macros (</em><em>macro_rules!) are like pattern-matchers — they expand based on syntax rules. Procedural macros get the </em><strong><em>entire AST (Abstract Syntax Tree)</em></strong><em> as input and return generated code, allowing </em><strong><em>custom syntax</em></strong><em> and deeper codegen. Think </em><em>sqlx::query!.</em></blockquote><blockquote><em>- The final image slide showed </em><strong><em>all macros in one view</em></strong><em> — if we understand that, we basically get all flavors of metaprogramming in Rust.</em></blockquote><blockquote><em>- Login with Google? One day we’ll do it </em><strong><em>on-chain with </em></strong><a href="https://www.privy.io/">privy</a><strong><em>-style identity systems</em></strong><em> — decentralization is the future.</em></blockquote><blockquote><em>- Token creation is </em><strong><em>the biggest money-maker right now</em></strong><em> — we don’t just write code, we create economies. Every macro and trait we write can get us one step closer to deployment.</em></blockquote><blockquote><em>- Welcome to </em><strong><em>Internet Capital Markets</em></strong><em>: we can earn remotely if we’re able to deploy from our laptop. Whether through token launches, bounties, gigs, grand funding, or venture capital — the laptop is our new office, and GitHub is our resume.</em></blockquote><p>Every bit of Rust metaprogramming — from trait to macro_rules! to #[derive(...)] to sqlx::query! — is built to help us write <strong>more with less</strong>, <strong>safely and predictably</strong>.</p><p>This blog walked through every essential detail. No shortcuts. No skips. This is the solid foundation for writing idiomatic, macro-powered Rust.<br>If you didn’t understand consider going through some rust concepts before reading this blog.</p><p>— Written with love by Prapti 🦀, debugged with {:?}, and inspired by <a href="https://x.com/kirat_tw">Harkirat Singh</a>’s teachings, hehe.<br> If you need more help or if there’s a correction to be done in this blog- tag me <a href="https://x.com/praptichilling">here</a>. Thanks ❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49426e97019f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why choose Rust over Javascript?]]></title>
            <link>https://medium.com/@praptii/why-choose-rust-over-javascript-d86fb250a4cc?source=rss-6dd421fa5cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d86fb250a4cc</guid>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[rustlang]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Prapti Sharma]]></dc:creator>
            <pubDate>Tue, 01 Jul 2025 19:18:32 GMT</pubDate>
            <atom:updated>2025-07-01T19:18:32.149Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*MG6TULJKHQjYcrUAn8ovOw.png" /><figcaption>Rust</figcaption></figure><blockquote>“JavaScript lets bugs sneak in.<br> Rust wrestles them at compile time, hehe. ”</blockquote><p>Are you someone who’s been living in the dynamic world of JavaScript and suddenly stumbled into the land of Rust, wondering why devs are so obsessed with it?</p><p>Let’s explore why <strong>Rust</strong> might just be the upgrade we didn’t know we needed. 🦀</p><h3>Type Safety — No More Guessing Games</h3><p>In JavaScript, we can do this:</p><pre>let x = 1;<br>x = &quot;prapti&quot;; // Totally legal 🤷‍♀️<br>console.log(x);</pre><p>And JS happily runs it. It doesn’t complain. Ever.</p><p>But in Rust:</p><pre>fn main() {<br>    let x = 1;<br>    x = &quot;prapti&quot;; // ❌ Compile-time error!<br>}</pre><p>Rust says: “Hold on! We can’t change an integer into a string mid-program!”<br> <strong>That’s type safety at work.</strong></p><blockquote><em>💡 </em>TypeScript was literally invented to fix this problem in JS.</blockquote><h3>Rust = Systems Language</h3><p>JavaScript was made to power websites.<br> Rust? It’s made to power <strong>browsers, compilers, operating systems</strong>, and everything <em>under the hood</em>.</p><p>Here’s what Rust is built for:</p><p>Writing <strong>compilers, </strong>Building <strong>browsers</strong> (Yes, even Firefox uses it!), Working <strong>closer to hardware</strong> and the OS</p><p>If we want <strong>control and performance</strong>, Rust is our buddy.</p><h3>Speed — Compile Once, Run Fast</h3><h3>In Rust:</h3><pre>Rust code -&gt; build &amp; optimize -&gt; binary -&gt; super-fast execution 🚀</pre><h3>In JavaScript:</h3><pre>JS code -&gt; interpreted by engine (JIT) -&gt; slower, dynamic runtime 🐢</pre><p>Rust compiles our code into optimized machine code before running it.<br> JS compiles Just-In-Time, meaning… it figures things out while running. That’s cool, but slower.</p><h3>Concurrency — Fearless Multithreading</h3><p>Rust is built for concurrency. It handles <strong>multi-threading safely</strong>, without those terrifying data races.</p><p>JavaScript?<br> It’s mostly <strong>single-threaded</strong>. Async/await is nice, but real multithreading is <em>tricky</em> and rarely used.</p><p>So if we dream of building apps that run tasks <strong>in parallel</strong> — like a boss — Rust’s got us covered.</p><h3>Memory Safety — Without a Garbage Collector!</h3><p>JavaScript relies on a Garbage Collector 🗑️ to clean up memory.</p><p>Rust doesn’t.<br> Instead, it gives us: Ownership, Borrowing, Lifetimes</p><p>This might sound complex, but it makes our program <strong>predictable</strong>, <strong>safe</strong>, and <strong>crazy fast</strong>.</p><blockquote><em>💡 </em>Rust doesn’t hide the complexity — it teaches us how to manage it like a pro.</blockquote><h3>Real-World Rust Use</h3><p>So who actually uses Rust in production?</p><ul><li><strong>Firefox</strong>: Parts of the browser like the CSS engine are now written in Rust.</li><li><strong>Dropbox</strong>: Uses Rust for performance-critical parts of its backend.</li><li><strong>Cloudflare</strong>: Uses Rust for secure and high-performance networking.</li><li><strong>Amazon &amp; Microsoft</strong>: Both have invested in Rust internally for safer systems programming.</li></ul><blockquote><em>💬 “Rust is the future of systems programming.” — from real production engineers.</em></blockquote><h3>When NOT to Use Rust</h3><p>Let’s be real — Rust isn’t always the right tool.</p><p>Here are some cases where it might <em>not</em> be needed :</p><ul><li>We’re building a <strong>simple front-end</strong> or MVP.</li><li>We need access to a massive UI ecosystem (like <strong>React</strong>, <strong>Vue</strong>, etc).</li><li>We’re prioritizing <strong>speed of development</strong> over performance/safety.</li></ul><p>Rust is powerful, but <strong>comes with a learning curve</strong>. It shines when safety, speed, and control really matter.</p><h3>Bonus: Code Playground</h3><p>Try Rust <strong>right now</strong>, no setup needed:<br>👉 Rust <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2024">Playground</a></p><h3>Example:</h3><pre>fn main() {<br>    println!(&quot;Hello from Rust!&quot;);<br>}</pre><p>Go ahead — tweak it, run it, and see the magic.</p><h3>Final Thoughts</h3><p>JavaScript is incredible for what it does — web UIs, fast prototyping, and flexibility.<br>But if we’re looking to:</p><ul><li>Build something performance-critical</li><li>Learn about memory management</li><li>Play close to the metal</li></ul><p>Then Rust is a game-changer.</p><blockquote><em>⚡ </em><strong><em>Try this challenge:</em></strong><em> Rewrite a small Node.js program in Rust. Feel the power of the compiler!</em></blockquote><p>Happy coding! 🦀✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d86fb250a4cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Journey in Open Source: From Small Programs to GSoC with OpenWISP ]]></title>
            <link>https://medium.com/@praptii/my-journey-in-open-source-from-small-programs-to-gsoc-with-openwisp-fd6f6fb43849?source=rss-6dd421fa5cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd6f6fb43849</guid>
            <category><![CDATA[gsoc2024]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[google-summer-of-code]]></category>
            <category><![CDATA[kietgroupofinstitutions]]></category>
            <category><![CDATA[openwisp]]></category>
            <dc:creator><![CDATA[Prapti Sharma]]></dc:creator>
            <pubDate>Sat, 01 Jun 2024 17:36:49 GMT</pubDate>
            <atom:updated>2025-07-01T19:43:21.519Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*x15x7Klzg_5TwoszGlwlOg.png" /></figure><p>Hii everyone! I’m writing this blog to help 1st and 2nd-year students navigate the world of open source. I started my journey as a part of a technical club, and it gave me a start in my technical journey ahead- only a start though. So, it doesn’t matter if you belong to a club or not; you can still do everything. 😊</p><p>I slowly started to learn about GitHub. Initially, I had problems, but eventually, I caught on. By the end of my first year, I started contributing by making streaks on my <a href="https://github.com/praptisharma28"><em>github</em></a>, just like we do on LeetCode. Contributing to projects taught me a lot about open source. 💻</p><p>I used to watch a lot of videos on open source programs. I’d like to mention that I once attended a speaker session where I was made to sit forcefully. That day, I learned that somebody in our college had cleared GSoC in his initial years, though, not lying, I was very uninterested in the session. 😅But I started knowing about open source from that day, saw hell lot of videos tbh. My YouTube history is filled with such videos.</p><p>Then came October; I took part in Hacktoberfest and sailed through, merging 10 PRs instead of 4. Then I took part in several hackathons where I often had the responsibility to speak and handle my team in pitches. Though I never won a single one, but those hackathons shaped me. 💪</p><p>I am somebody who keeps doing something or the other, always trying new things, big or small. Grabbing opportunities is an art, guys. 🎨</p><p>One video that I watched, which is a complete documentary to give you an idea and motivation too, is by Devansh Dixit. Go search for it on YouTube and watch it right now! 📺</p><p>In October, right after Hacktoberfest, I started investing my time into GSoC. I wrote down some organizations in my favorite notebook and kept it close to me on my bed to write down everything I suddenly remembered or planned at midnight. In 10 days, a PR was merged, and it gave a boost to my confidence. I then started looking for more issues, and before writing the proposal, I merged 4 PRs, which were the most done by anybody there as a new contributor for GSoC 24 speficially. 🚀</p><p>In January, I was less active with openWISP and started contributing to IWoC (Innogeeks Winter of Code) and won it, merging 54 PRs there, which again boosted my confidence. 🎉 I also became the first AWS Cloud Captain from my college in March. You can join my group using this <a href="https://www.meetup.com/aws-cloud-club-at-kiet-group-of-institutions/"><em>link</em></a><em> . </em>We will be having our first offline event on 21st June.</p><p>Coming back, then came a list of projects by OpenWISP on Feb 10th . I was looking for the one where I could learn the most because I knew Django to some extent and didn’t want to go for any frontend project. So, I went for a <a href="https://openwisp.io/docs/developer/gsoc-ideas-2024.html#add-more-timeseries-database-clients-to-openwisp-monitoring"><em>backend project</em></a> that had a new tech stack like <a href="https://openwisp.io/docs/developer/gsoc-ideas-2024.html#add-more-timeseries-database-clients-to-openwisp-monitoring"><em>Elasticsearch</em></a> and <a href="https://www.influxdata.com/"><em>InfluxDB</em></a>. I first researched it, tried to understand it and then made up my mind to go for that one. I wrote the proposal, but I was already late, not lying — I forgot the date as I was enjoying my vacations at home after exams. 😅</p><p>I panicked when I saw the last date was near. I had a good idea of my project, so I started drafting the proposal ASAP. I got it checked by 2 seniors, one from my college and one from a previous year’s OpenWISP contributor.</p><p>I sent it to my mentor, and the first feedback was harsh. It made me feel that they would never select me, and I lost hope. I didn’t know that they were just correcting me to help me. I submitted it, mailed it to my mentors, and got a reply that it was acknowledged, and that’s it. Nothing more than that. So, I was very unsure of my selection.</p><p>I did my work and the hard work that was needed. The proposal was done, and I had my time to relax for a few days. Then I went on their dev server again and had a chat.</p><p>I knew that on 1st May, the results would be announced, and it was a big day for me. Whether I was selected or not, I decided I would continue my journey in GSoC. If I wasn’t selected, I would have been heartbroken, but that’s okay because there are bigger things in life, and I was just in my second year and would try again. This is what I told myself.</p><p>I am somebody who doesn’t keep many expectations; instead, I keep trying because, as they say, expectations kill.</p><p>Then came the results at midnight, 12:27 AM on 2nd May. I kept waiting for it the whole day. I told my parents that big news would show up tomorrow; if it was positive, I would tell them, otherwise I wouldn’t because it wouldn’t matter then.</p><p>I was sleeping when I got a call from a senior who is a GSoCer too. He said, “Congratulations!” He was checking the results, and yes, I was selected. Then I called my siblings. I didn’t sleep the whole night just to tell my parents at 5 AM because I didn’t want to disturb their sleep at night. When I called them, they didn’t get it much. My father even said, “So this stipend is for all as a group?” and I was like, “What group, Papa? There is no group; it’s an individual thing.” Haha. He kept thinking that I was in a hackathon or something. 😂 Told my good friends too, they were happier than me.</p><p>Now with OpenWISP, the journey is on. It’s not smooth though; it’s a rollercoaster of ups and downs. I write daily updates there, sometimes getting a positive response, sometimes negative, but I am learning for sure. Until now, I didn’t know how to roll back a migration, yes, lol. But you will never know everything because you are not reading a book while you learn any tech; you are just following brief docs or watching tutorials, that’s all. Nobody teaches you everything, and GSoC projects are done in big orgs, so you learn a lot as the database is big and very complex.</p><p>OpenWISP itself is a very complex org too. Initially, it takes time to understand it well. But if you are interested in Django or computer networks, I can guarantee it is the org for you. Go ahead, find your interest, and if I can be here, you too can. 😊</p><h3><strong>My Experience with OpenWISP</strong></h3><p>Now that I have been selected, let me tell you about my experience with <a href="https://openwisp.org/"><em>OpenWISP</em></a><em> </em>. My mentors, <a href="https://github.com/nemesifier"><em>Federico</em></a> and <a href="https://github.com/pandafy"><em>Gagandeep</em></a>, have been working hard with me to help me understand and learn OpenWISP monitoring.</p><p>As a newbie and a second-year undergrad, it’s more of a learning process for me. Working on such a complex and big database is clearly a new thing for me. Leaving academics aside, I have been trying to solve issues on GitHub. 🛠️</p><p>During the community bonding period, I worked on an enhancement issue for OpenWISP monitoring. As the name suggests, <a href="https://github.com/openwisp/openwisp-monitoring"><em>OpenWISP-monitoring</em></a> monitors different devices using their IP and MAC addresses. It can monitor a lot of things like Wi-Fi, hotspots, VPNs, routers, etc.</p><p>My <a href="https://github.com/openwisp/openwisp-monitoring/issues/576"><em>issue</em></a> was related to the health status of connected devices. For example, if the device’s internet connection is in a critical condition, the status would show “critical.” If it’s fine, the health status would show “ok.” If the device is deleted or disabled, it should show “unknown,” which it was not showing. So I had to correct that, and it took me a lot of time — more than one could expect from me. My mentors helped me a lot — when I say a lot, I mean it. Finally, it was solved and the PR was merged. 😊</p><p>I learned a lot from that particular PR. I wrote a migration file manually for the second time and learned a lot about Django tests and how they work in large databases. I was inexperienced with writing Django tests.</p><p>I solved other issues too. The point is, when your PRs merge in such big organizations, it’s a source of happiness and motivation for you. 🎉</p><p>Hence, the bonding period was good. Right now, I am working on version support upgradation for InfluxDB 2.0 while keeping the older version too. It includes working with and handling Docker 🐳 and Ansible too. So again, it’s a cool thing. I deliberately chose a backend project so that I could dive deep into Django this time because I always wanted to, after learning that framework. I was determined to choose something that could make me better.</p><p>So, this was about my journey till now. I will write another blog when I complete my project or maybe when I am halfway done with it. Until then, keep learning new stuff. Try to disturb your mentor less, hehe. Don’t be like me. Pay more attention and code.</p><p>Code your way to success. 💻✨</p><p>Thank you! 🙏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd6f6fb43849" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>