<?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 Md Amaan on Medium]]></title>
        <description><![CDATA[Stories by Md Amaan on Medium]]></description>
        <link>https://medium.com/@md.amaan.cse25?source=rss-475a86c0d053------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lrjLhR8oZ56gyxLSF3FzsA.png</url>
            <title>Stories by Md Amaan on Medium</title>
            <link>https://medium.com/@md.amaan.cse25?source=rss-475a86c0d053------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 22:58:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@md.amaan.cse25/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[Design Patterns in System Design(LLD)]]></title>
            <link>https://medium.com/@md.amaan.cse25/design-patterns-in-system-design-lld-deb2f24bcc95?source=rss-475a86c0d053------2</link>
            <guid isPermaLink="false">https://medium.com/p/deb2f24bcc95</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[lld]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Md Amaan]]></dc:creator>
            <pubDate>Wed, 15 Jan 2025 16:49:55 GMT</pubDate>
            <atom:updated>2025-01-16T17:35:46.229Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Heartfelt thanks to Shreyansh and his videos for providing me this knowledge.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*yj4q698apL5ixPWuur9qDA.jpeg" /></figure><p>This is a blog where you can get an overview about different types of design patterns, most common ones asked in interviews of famous companies.</p><p>Design Patterns discussed in this blog are :-</p><ol><li><strong>Strategy Design pattern</strong></li><li><strong>Observer Design pattern</strong></li><li><strong>Decorator Design pattern</strong></li><li><strong>Factory Design pattern</strong></li><li><strong>Adapter Design pattern</strong></li></ol><h4>Strategy Design Pattern</h4><p>The <strong>Strategy Design Pattern</strong> is a behavioral design pattern that allows you to define a family of algorithms, encapsulate each one as a separate class, and make them interchangeable. This pattern enables you to select an algorithm’s behavior at runtime without altering the context in which it is used.<br>Imagine a travel app where users can choose how to get from point A to point B — car, bus, or bike. Each travel method is a strategy.</p><p>So we can make a parent class such that we have a dynamic context class whose constructor can take any strategy passed into it like bus, car or bike just few special functions in each one which is why instead of writing if — else condition for each one we can use strategy design pattern.<br>For reference, watch <a href="https://www.youtube.com/watch?v=u8DttUrXtEw&amp;list=PL6W8uoQQ2c61X_9e6Net0WdYZidm7zooW&amp;index=4">this</a></p><h4><strong>Observer Design pattern</strong></h4><p>In this pattern we have two types of objects observable and observer and whenever the state of observable changes it updates all the observers with the state change. This allows for a one-to-many relationship where multiple observers can react to changes in the subject without being tightly coupled to it.</p><p>In this pattern we have functions like Add(), Remove() and notifySubscribers() and we can have a list of observer objects and we can add new observers via Add() and remove as well and whenever a state change happen we can call Notifysubscriber() which is nothing but a loop which will call notify() on each observer in the list.</p><p>Example — We have various channels on Yt where we have our notification on when ever a new video is uploaded we are notified about it.</p><h4>Decorator Design pattern</h4><p>The <strong>Decorator Design Pattern</strong> is a structural design pattern that allows you to dynamically add new behavior or responsibilities to an object without altering its structure. It achieves this by “wrapping” the object in a series of decorator classes, each providing additional functionality.</p><p>In here we create an abstract base class and multiple classes can extend it and add extra functionality on top of its base classes by overriding it.</p><p>Example — A base class pizza and we can have multiple toppings and different types of pizzas.</p><h4>Factory Design pattern</h4><p>The <strong>Factory Design Pattern</strong> is a <strong>creational design pattern</strong> that provides a way to create objects without exposing the creation logic to the client. Instead of instantiating objects directly using the new keyword, the pattern delegates the responsibility to a specialized factory class.</p><h4>How It Works:</h4><ul><li>The client requests an object from the factory.</li><li>The factory determines which class to instantiate and returns an instance to the client.</li><li>The client only interacts with the interface or base class, not the concrete class.</li></ul><h4>Adapter Design pattern</h4><p>The <strong>Adapter Design Pattern</strong> is a <strong>structural design pattern</strong> that allows two incompatible interfaces to work together by providing a bridge between them. It acts as a middle layer that converts the interface of one class into another interface expected by the client.</p><p>Example : Like we use our charger which has two ends, our phone doesn’t have charging end which is able to directly connect with the plug, so charger has two types of ends which fits both phone (client) and the plug (target) noninterchangeably.</p><h4>Facade Design pattern</h4><p>The <strong>Facade Design Pattern</strong> is a <strong>structural design pattern</strong> that provides a simplified, unified interface to a complex subsystem of classes, making it easier for clients to interact with the subsystem without worrying about its intricacies. It abstracts away the complexity and shields the client from internal details of the subsystem.<br>Example : We have remote in our hand, and we dial any channel no and boom we see the video, no need to know the internal processes happening to make it happen.</p><h4>Singleton Design pattern</h4><p>The <strong>Singleton Design Pattern</strong> is a <strong>creational design pattern</strong> that ensures a class has only <strong>one instance</strong> while providing a global access point to it. This pattern is commonly used when exactly one object is needed to coordinate actions across the system.</p><p>So this was all the most common design pattern observed in most companies and asked in interviews as well.<br>Hope you learnt something new from this blog.<br>Connect with me : <a href="https://x.com/0xmdamaan">Twitter</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t7yy3_ZfreHuIGfPMXSbTg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=deb2f24bcc95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Concurrency Control in Distributed Systems]]></title>
            <link>https://medium.com/@md.amaan.cse25/concurrency-control-in-distributed-systems-4227aa7490e1?source=rss-475a86c0d053------2</link>
            <guid isPermaLink="false">https://medium.com/p/4227aa7490e1</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[lld]]></category>
            <dc:creator><![CDATA[Md Amaan]]></dc:creator>
            <pubDate>Wed, 15 Jan 2025 08:41:49 GMT</pubDate>
            <atom:updated>2025-01-15T08:49:18.819Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*KNCYCuUwO7rW8tXmBAr4Rw.png" /><figcaption>Crowd entering a door(credits — shutterstock)</figcaption></figure><blockquote>Firstly, let me thank <a href="https://www.linkedin.com/in/jainshrayansh/">Shreyansh </a>Yt channel (<a href="https://www.youtube.com/@ConceptandCoding">Concepts &amp; Coding</a>) for providing me the knowledge.</blockquote><p>Let&#39;s learn about why we are interested in learning about concurrency obviously because it is asked in interviews but still why exactly is it needed in our jobs…<br> Imagine you’re building a web app, and a single user sends multiple requests — like uploading a file, refreshing their dashboard, and sending a message — all at the same time. Without concurrency, your app might freeze or become super slow, waiting to finish one task before starting another.(relatable).</p><p>Now multiply that by hundreds or thousands of users doing the same thing! Concurrency ensures your app can handle these tasks efficiently, keeping everything running smoothly. It’s also crucial for leveraging modern multicore processors, so your app makes the best use of hardware.</p><p>So really, it’s about building systems that are not just functional but also fast, responsive, and capable of scaling up when needed.</p><p>Before diving into concurrency, let’s learn a few basic terms.</p><h3>Transaction</h3><p>A <strong>Transaction</strong> is a sequence of one or more operations (like reading, writing, or updating data) that are treated as a single unit of work. A transaction must satisfy the <strong>ACID</strong> properties to ensure data consistency and reliability, even when multiple transactions occur concurrently.</p><h3>ACID</h3><p><strong>Atomicity</strong>: All-or-nothing; either all operations in a transaction succeed, or none are applied.<br><em>Example</em>: Money transfer either debits and credits both accounts, or does nothing.<br><strong>Consistency</strong>: Ensures the database moves from one valid state to another, maintaining rules.<br><em>Example</em>: Total bank balance remains consistent after a transaction.</p><p><strong>Isolation</strong>: Transactions don’t affect each other.<br><em>Example</em>: Two users editing the same row won’t interfere with each other.</p><p><strong>Durability</strong>: Committed changes are permanent, even after a crash.<br><em>Example</em>: Saved orders persist despite server failure.</p><h3>Database Locking</h3><p>Database Locking is the easiest solution for avoiding transaction collision and dirty read problem arising due to concurrent transactions.</p><p>So one could possibly think of a solution to this by locking the db for each transaction to avoid the issue of concurrent db modification before that we know there are mainly two types of transaction for db one is reading and other is writing data for most of the scenarios there is no issue in concurrent reading but only issue if concurrent writing because we don&#39;t like to read stale data from db which could happen if multiple users modify db we want to get latest data from db.</p><p>There are two types of locks :-</p><h4>Shared Locking (SL)</h4><ul><li>Allows multiple transactions to read the same resource simultaneously but prevents any transaction from modifying it.</li><li>Typically used for <strong>read-only</strong> operations.</li><li>Multiple transactions can hold a shared lock on the same resource concurrently.</li><li><strong>Example</strong>: Two users viewing the same product details can both hold shared locks.</li></ul><h4>Exclusive Locking (EL)</h4><ul><li>Prevents any other transaction from reading or modifying the locked resource.</li><li>Typically used for <strong>write</strong> operations to ensure no other transaction interferes.</li><li>Only one transaction can hold an exclusive lock on a resource at a time.</li><li><strong>Example</strong>: While a user is updating product details, no one else can view or modify them.</li></ul><p>There is an interesting table for granting these locks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nvQUOtBJWzmzRsA8rASHSw.png" /><figcaption>Table</figcaption></figure><p>To explain this in simple terms, pretty intuitive thought you put a shared lock on a piece of data and both you and your friend are reading from it would you like anyone to modify that part then what’s the point of shared lock also when you have put an exclusive lock for yourself, and you are editing that piece would you like to anyone else read or write your work, and then you might discard that too, so this table says can’t put an exclusive lock on a shared lock or the other way around and can’t put exclusive lock on a previously exclusive locked data makes sense right.</p><p>Let’s discuss some common problems with database concurrency.</p><h3>Dirty Read Problem</h3><p>A <strong>Dirty read</strong> occurs when a transaction reads data that has been modified by another uncommitted transaction. If the modifying transaction is rolled back, the data read by the first transaction becomes invalid or inconsistent, leading to potential errors.</p><h3>Non-Repeatable Read Problem</h3><p>This occurs when let say transaction A is doing a repetitive read operation on Var X = 10 and meanwhile transaction B modifies its value to 11 and then again when read happens on A reads X as 11 which is inconsistent data wrt transaction A and if transaction B now rollback then transaction A read data will be invalid now.</p><h3>Phantom Read Problem</h3><p>A similar issue of data inconsistency may happen when a transaction reads a set of rows that meet a condition, but another transaction inserts, updates, or deletes rows that alter the result of the original query during the transaction. This leads to inconsistent results within the same transaction.</p><p>There are 4 levels of Isolation (low-high) :-</p><ol><li>Uncommitted — Allows transactions to read uncommitted changes from other transactions.</li><li>Committed — Only committed data is visible to transactions; uncommitted changes are not readable.</li><li>Repeatable Read — Ensures that if a transaction reads the same data twice, the result is consistent. It prevents changes to rows being read by applying lock till the end of the transaction.</li><li>Serializable — The highest isolation level. Transactions are executed as if they are serialized (one after another), preventing any interference also applies rules of repeatable read plus range lock on the section to be changed say you query data from 1 to 5 Sl No in database it puts a lock on DB in this section till the end of the transaction.</li></ol><p>Based on the above Isolation levels, we have two types of concurrency control :-</p><h4>Optimistic Concurrency Control</h4><p>Optimistic Concurrency Control is a concurrency management strategy used in databases and applications. It assumes that conflicts between transactions are rare and allows transactions to proceed without locking resources. Before committing, it checks if any conflict occurred. If a conflict is detected, the transaction is rolled back and retried. This mostly assumes Isolation level Read Committed means if something is committed you are able to read it and if we put an exclusive lock we keep it till the end of the transaction. It solves the concurrency issue using versioning of each row in the db whenever we modify a data its version is changed and which is what helps to identify the modification of data during a transaction. GitHub uses similar concurrency control mechanism.</p><h4>Pessimistic Concurrency Control</h4><p>Pessimistic Concurrency Control assumes that conflicts between transactions are likely to occur and prevents them by locking resources. Transactions must acquire locks on data before reading or writing, ensuring no other transaction can modify or access the same data until the lock is released. But this arises the issue of deadlocks (Risk of transactions getting stuck while waiting for locks held by each other).</p><p>So this was all about concurrency control and other concepts regarding concurrency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YUF8mtwwX1Kl2Biu0lDsJA.png" /><figcaption>Thanks for reading</figcaption></figure><p>Connect with me : <a href="https://www.linkedin.com/in/md-amaan-305010229/">LinkedIn </a>| <a href="https://x.com/0xmdamaan">Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4227aa7490e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polynomial Trade : The Derivative Trading Decentralized CEX]]></title>
            <link>https://medium.com/@md.amaan.cse25/polynomial-trade-the-derivative-trading-decentralized-cex-6c6714b2804c?source=rss-475a86c0d053------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c6714b2804c</guid>
            <dc:creator><![CDATA[Md Amaan]]></dc:creator>
            <pubDate>Fri, 14 Jun 2024 21:25:12 GMT</pubDate>
            <atom:updated>2024-06-14T21:25:12.849Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDwbjZz7vBmtB-4gLAlQEA.jpeg" /></figure><h3>Polynomial Trade : The Derivative Trading Decentralized CEX</h3><p>Let&#39;s dive into what it is and how it works and how can you make the most out of it. There are lots of traders who are multiplying their tokens through perpetual trading using polynomial trade which is a decentralized derivatives exchange uses the Synthetix protocol on the Optimism network. This platform focuses on perpetual futures trading, letting users bet on price changes of various assets without expiration dates. Polynomial’s perpetual futures use a funding rate mechanism to keep contract prices in line with the underlying asset prices.</p><h4>What is Perpetual Futures ?🤔</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ayFzcinQFIyeXNvxuKQDVg.png" /></figure><p>Perpetual futures, also called perpetual swaps, are a type of contract that lets traders bet on the price of an asset without worrying about an expiration date. This means you can keep the contract as long as you want and decide when to close it.</p><p>Let’s understand it with an example, imagine you think the price of Bitcoin will go up. You buy a perpetual future contract for Bitcoin. If the price goes up, you can sell the contract for a profit whenever you choose. If the price goes down, you can sell it to cut your losses. There’s no set date when the contract ends, so you have the flexibility to hold onto it as long as you like.</p><h4>There are two types of Positions in Perpetual futures</h4><h3>Long Position</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*0adaI7ryebbWgli6bcC6Mw.png" /></figure><p>It’s basically when you are bullish on some token, and you think that it’s price is gonna go up then they bet for its price to rise up to a certain limit and if it indeed reaches that limit then they close their position at a higher price and making a profit on their investment and if it doesn’t you get a loss.</p><h3>Short Position</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*Obxce6fExkDXVHcLLvJeVQ.png" /></figure><p>As the name suggests it’s opposite to the long position, it’s when a trader thinks that the price of the underlying asset is gonna go eventually go down then trader closes their position and then when it actually goes down then buy back the asset making profit on their asset when it comes back to normal. You can take an analogy in stock market Options trading.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FqX6ErdMY3GmhGSTiMIS3g.png" /></figure><h3>Funding Rate</h3><p>The funding rate in a perpetual futures contract is a fee exchanged between traders to keep the contract price in line with the underlying spot price. Paid at regular intervals, usually every eight hours, this fee depends on the difference between the futures and spot prices.</p><h3>Funding Rate Variation(a.k.a FundRate Velocity)</h3><p>This is a mechanism due to which funding rates continuously changes on a block-by-block basis, based on uncorrected position imbalances. As a result, funding rates vary while smoothing out funding rate trajectories.</p><p>If the futures price is higher, long traders (expecting a price rise) pay short traders (expecting a price drop) to bring the futures price down. If the futures price is lower, short traders pay long traders to bring the futures price up.</p><p>This mechanism ensures the contract price stays aligned with the spot price, allowing traders to hold positions indefinitely without an expiration date.<br>You also earn profit using certain techniques of funding rate arbitrages <a href="https://docs.trade.polynomial.fi/strategies-and-tools/funding-rate-arbitrage-101"><strong>check out the tips</strong></a><strong> and tricks.</strong></p><h4>High Leverage to earn more profit</h4><p>Polynomial Trade allows 50x leverage on their platform which means if you have $10000 in your pocket you can enter the market at $500000 which is huge and now if you make 10% profit its $50000 instead of $1000.</p><p>But remember to use max leverage, you need to have a decent collateral in your account for liquidation (refers to the process of selling off an investor’s assets to repay their debts or obligations).</p><p>Disclaimer ! : This blog post doesn’t promote any sort of investment plans, just for traders who know what they are doing, with their eyes open to both profit and Loss on their decisions.</p><p>All the decision taken on your asset is always your call, all the protocols are just a medium to maximize your profit based on your understanding of the market. No Platform can make you rich, it&#39;s always your experience and strategies that can earn you profit.</p><p>There are ways how you can minimize your loss Like <strong>Setting appropriate stop-loss orders, maintaining a sufficient margin balance, diversifying their portfolio, staying informed</strong> <strong>about market condition and much more.</strong></p><p>You can research on each topic on your own or<a href="https://docs.trade.polynomial.fi/trade/perp/liquidation"> <strong>read this.</strong></a></p><h3><strong>Smart Wallets</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*aDMpuQFRZ3yMTNgDITgyig.png" /></figure><p>Smart wallets are the latest innovation in blockchain area from account abstraction which means it&#39;s no more a simple EOA (Externally Owned Account) like Metamask, etc. It’s a smart contract which executes your commands and is on chain deployed, so censorship resistant, secure and transparent.</p><p>Smart contract wallets can help Polynomial trade to provide advanced orders like limit orders, stop loss orders, SL, TP, and more.</p><h3><strong>Types of Orders</strong></h3><h4>Standard Orders</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_GxjNXSzIx6chEtG6qkWOA.png" /></figure><p>A market order is executed at the current market price as quickly as possible when a user places the order.</p><p>The order will be placed directly after the trader places it, and a keeper bot will execute it.</p><h4>Advanced Orders v2</h4><p><a href="https://docs.trade.polynomial.fi/trading-guide/limit-orders"><strong>Limit/Stop orders</strong></a></p><p><a href="https://docs.trade.polynomial.fi/trading-guide/take-profit-stop-loss"><strong>Take Profit / Stop Loss Orders</strong></a></p><p><strong>Closing a Position<br></strong>To close a trade position with a TP/SL order, the process is the same as well as you want to add it later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*XQGP7yqtjw-9ktOEcB8E-g.png" /></figure><p>Users can simply click the <strong>Add</strong> button in the Position tab to set the trigger prices for the closure.</p><p>The profit/loss will be credited to the wallet address after collecting all fees by exchange, and no fees will be deducted from the portfolio after the final transaction.</p><p>So this was all from my side today, gave you a High overview of Polynomial Trade.<br>Check out <a href="https://trade.polynomial.fi/"><strong>Polynomial Trade</strong></a><strong> </strong>and enjoy the high profit % on your assets using perpetual trading strategies and leverage based on your reputation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*-vhqcrhhWPVxJSsGw84lXQ.png" /></figure><p>Thank you for reading till the very end, have a nice day.<br>Follow me<br>Twitter:<a href="https://x.com/0xmdamaan">https://x.com/0xmdamaan</a><br>LinkedIn- <a href="https://www.linkedin.com/in/md-amaan-305010229/">https://www.linkedin.com/in/md-amaan-305010229/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c6714b2804c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KZG Polynomial Commitment Scheme]]></title>
            <link>https://medium.com/@md.amaan.cse25/kzg-polynomial-commitment-scheme-9faaaefa1713?source=rss-475a86c0d053------2</link>
            <guid isPermaLink="false">https://medium.com/p/9faaaefa1713</guid>
            <dc:creator><![CDATA[Md Amaan]]></dc:creator>
            <pubDate>Fri, 24 May 2024 09:03:50 GMT</pubDate>
            <atom:updated>2024-05-24T09:03:50.896Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A6dSnaUIvQcECc9z9dU6Ig.jpeg" /></figure><p>This is a introductory blog post aimed to give a brief intro to what kzg commitment scheme is all about based on my understanding I will try my best to explain the mathematical part as well but goal is to build the foundational idea about polynomial commitment schemes with focus on kzg commitment scheme.</p><p>Firstly KZG basically stands for <strong>Kate-Zaverucha-Goldberg the name of the cryptographers who introduced the polynomial commitment scheme.</strong></p><h3>Advantage of Kzg Over Merkle Proofs</h3><p>To understand the advantages of polynomial commitments, it is helpful to compare them with Merkle trees. Merkle trees are vector commitments where the commitment is the Merkle root of a vector. A Merkle proof involves providing sibling paths to prove membership at a specific position, requiring a linear amount of work relative to the depth of the tree.</p><p>For polynomial commitments, consider a polynomial f(x) of degree d with coefficients committed using a Merkle tree. A proof of evaluation at point a would involve revealing all coefficients and recomputing the polynomial, which is inefficient. In contrast, the Kate scheme commits to the polynomial in a way that proofs of evaluation require only a constant-size proof, independent of the polynomial’s degree.</p><p><strong>Basically this scheme is divided into three parts <br>1.Trusted Setup</strong></p><p><strong>2. Commitment to polynomial</strong></p><p><strong>3. Opening the polynomial on challenge point.</strong></p><p><strong>4. Verifying the proof.</strong></p><h4>Trusted Setup</h4><p>A trusted setup is necessary to generate a common reference string (CRS). This setup typically involves a secure multiparty computation (MPC) to produce a secret s. In MPC each contributor contributes to the ceremony by providing their share of random string and this provides guarantees of security until and unless any single party is honest which is quite practical.</p><pre>pub fn setup(&amp;mut self, secret: E::ScalarField) {<br>    for i in 0..self.degree+1 {<br>        self.crs_g1.push(self.g1.mul(secret.pow(&amp;[i as u64])));<br>        self.crs_g2.push(self.g2.mul(secret.pow(&amp;[i as u64])));<br>    }<br>    self.g2_tau = self.g2.mul(secret);<br>}</pre><h4>Committing a Polynomial</h4><p>To commit to a polynomial f(x)=a0+a1x+a2x^2+…+adx^d ., the coefficients {a0,a1,…,ad} are used with the CRS to produce the commitment: C=a0G1+a1G1^s+a2G1^s2+…+adG1^(s^d) . This commitment C is a single group element of an elliptic curve, making it compact (e.g., 48 bytes with BLS12–381).</p><pre>pub fn commit(&amp;self, poly: &amp;[E::ScalarField]) -&gt; E::G1 {<br>    let mut commitment = self.g1.mul(E::ScalarField::ZERO);<br>    for i in 0..self.degree+1 {<br>        commitment += self.crs_g1[i] * poly[i];<br>    }<br>    commitment<br>}</pre><h4>Opening a Point</h4><p>To prove that f(a)=y for some point a, the prover computes the quotient polynomial q(x)=( f(x)−y )/(x−a) ​. The proof is the commitment to q(x): π=q(G1​). The prover sends π along with the claimed value y to the verifier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*eAmZeHxIiWF302Ma-8qALA.png" /><figcaption>We use square brackets to denote commitments, meaning the quotient must be multiplied by the common reference string generated during the trusted setup. The number one signifies that the common reference string was generated using the G1 group element.</figcaption></figure><pre>pub fn open(&amp;self, poly: &amp;[E::ScalarField], point: E::ScalarField) -&gt; E::G1 {<br>    // evaluate the polynomial at point<br>    let value = evaluate(poly, point);<br><br>    // initialize denominator<br>    let denominator = [-point, E::ScalarField::ONE];<br><br>    // initialize numerator<br>    let first = poly[0] - value;<br>    let rest = &amp;poly[1..];<br>    let temp: Vec&lt;E::ScalarField&gt; = std::iter::once(first).chain(rest.iter().cloned()).collect();<br>    let numerator: &amp;[E::ScalarField] = &amp;temp;<br><br>    // get quotient by dividing numerator by denominator<br>    let quotient = div(numerator, &amp;denominator).unwrap();<br><br>    // calculate pi as proof (quotient multiplied by CRS)<br>    let mut pi = self.g1.mul(E::ScalarField::ZERO);<br>    for i in 0..quotient.len() {<br>        pi += self.crs_g1[i] * quotient[i];<br>    }<br><br>    // return pi<br>    pi<br>}</pre><h4>Verification</h4><p>The verifier checks the proof using a bilinear pairing: e(π,G2s−a)=e(C−yG1,G2) Here, e denotes the pairing function, G2​ is a generator of another elliptic curve group, and s is the secret from the trusted setup. This equation verifies that the polynomial f(x) evaluated at a indeed equals y.</p><pre>pub fn verify(<br>    &amp;self,<br>    point: E::ScalarField,<br>    value: E::ScalarField,<br>    commitment: E::G1,<br>    pi: E::G1<br>) -&gt; bool {<br>    let lhs = E::pairing(pi, self.g2_tau - self.g2.mul(point));<br>    let rhs = E::pairing(commitment - self.g1.mul(value), self.g2);<br>    lhs == rhs<br>}</pre><h3>Multiproofs and Efficiency</h3><p>A significant advantage of the KZG scheme is its ability to combine proofs for multiple evaluations into a single proof. Using the interpolation polynomial L(x) for points {a1,a2,…,ak}, and the zero polynomial Z(x)=(x−a1​)(x−a2​)…(x−ak​), the combined proof is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/233/1*aSllIBE-yrRWdd_o0a-4SA.png" /></figure><p>​ Verification involves checking the pairing for the combined proof:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*KZVYg98DzfvXFuaNuBzrTg.png" /></figure><p>This allows efficient batch verification of multiple evaluations, maintaining a constant proof size.</p><h3>KZG as a Vector Commitment</h3><p>Beyond polynomial commitments, the KZG scheme can also serve as an efficient vector commitment. Given a vector v, one can construct a polynomial f(x) such that f(i)=vi​ for i=0,1,…,n−1. The commitment to the polynomial f(x) acts as a commitment to the vector v, allowing compact proofs of individual vector elements.</p><h3>Conclusion</h3><p>The KZG polynomial commitment scheme provides a robust and efficient method for polynomial commitments. By leveraging elliptic curve pairings and secure setups, it ensures both compactness and security, making it highly suitable for zero-knowledge proof systems and other cryptographic applications. The ability to provide constant-size proofs and support efficient batch verification highlights its advantages over traditional methods like Merkle trees, making it a versatile tool in modern cryptography.</p><h3>Further Reading</h3><p><a href="https://dankradfeist.de/ethereum/2020/06/16/kate-polynomial-commitments.html">Dakrad Feist</a> Blog on Kzg Polynomial commitment is a great explainer.</p><p>All the code written above is taken from <a href="https://kaijuneer.medium.com/explaining-kzg-commitment-with-code-walkthrough-216638a620c9">Kai Jun Eer blog</a>. Can also check that out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9faaaefa1713" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Launching into the World of Launchpads ]]></title>
            <link>https://medium.com/@md.amaan.cse25/launching-into-the-world-of-launchpads-29d73cb9b60a?source=rss-475a86c0d053------2</link>
            <guid isPermaLink="false">https://medium.com/p/29d73cb9b60a</guid>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[the-graph-protocol]]></category>
            <category><![CDATA[launchpad]]></category>
            <category><![CDATA[indexer]]></category>
            <dc:creator><![CDATA[Md Amaan]]></dc:creator>
            <pubDate>Mon, 16 Oct 2023 05:51:27 GMT</pubDate>
            <atom:updated>2023-10-16T06:16:16.053Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3QGEs4anA6-_gdhViJYTg.png" /><figcaption>What is Launchpad ?</figcaption></figure><p>“Welcome to the continuation of our blog series, which began with an introduction to The Graph Protocol, Subgraph Development, Substreams, and Firehose. Throughout this series, we’ve simplified complex and confusing terms with practical examples and analogies.</p><p>In this blog, my aim is to provide you with a brief introduction to the concept of a ‘launchpad’ and explain why indexers use it to scale and automate the indexing process through the lens of DevOps.</p><p>So, let’s dive right in 🌊.</p><h4>PREREQUISITES FOR THIS ARTICLE</h4><ol><li>Knowledge of Subgraphs ?</li><li>How does Indexing works ?</li><li>Basics of Networking,DNS,Storage fundamental,Basic system administration ,SSH and authentication.</li><li>A little about Kubernetes cluster is an advantage still no issues.</li></ol><h4>Just Kidding Guys ,No prerequisites this is the reason I am here for you guys.</h4><h4>And yes you are good to go 💯</h4><p>Just do one thing if you are new to my articles just give <a href="https://medium.com/@md.amaan.cse25/beginner-guide-to-query-and-display-subgraph-data-from-subgraph-studio-7cf66a974135"><strong>this</strong> </a>a go. <br>Try it out once and if you have done it then do give the official <a href="https://thegraph.com/docs/en/"><strong>website </strong></a>a go.</p><h3>Table of Content</h3><ol><li><strong>Basics needed to move further.</strong></li><li><strong>What is Graph Ops ?</strong></li><li><strong>What is a launchpad ?</strong></li><li><strong>Why do we need launchpads ?</strong></li><li><strong>How can an indexer configure his launchpad?</strong></li><li><strong>Key Takeaways from this article</strong>.</li></ol><h4>Brief Intro to Kubernetes</h4><p><strong>Kubernetes</strong>, often abbreviated as <strong>K8s</strong>, is a container orchestration platform that can be a bit complex to grasp, especially for someone with basic knowledge of web development. Let’s break it down in simpler terms:</p><p>So, imagine you’re a web developer building a website:</p><ul><li><strong>Without Kubernetes</strong>: You might develop your web app on your local machine, and when it’s ready, you’d manually deploy it to a web server. If your website becomes popular, you’d need to manually add more servers to handle the traffic. This can be error-prone and time-consuming.</li><li><strong>With Kubernetes</strong>: You package your web app and all its dependencies into containers (like Docker containers). Then, you describe how many instances of your app you want, how it should scale, and how it should recover from failures in a Kubernetes configuration (usually written in YAML files). Kubernetes takes care of starting containers, distributing traffic to them, and replacing failed ones automatically.</li></ul><h4>Why use Launchpad for Indexing Data ?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yv6WyXfN9lyloZsQn6TJ7Q.png" /></figure><ol><li><strong>Containers</strong>: Containers are lightweight, isolated environments where you can run applications and all their dependencies (like libraries and configuration). They ensure that the application runs consistently across different environments.</li><li><strong>Orchestration</strong>: This means managing and automating the deployment, scaling, and operation of containers. Instead of manually starting, stopping, and scaling containers, Kubernetes does this for you.</li><li><strong>Kubernetes</strong> can play a valuable role in query processing services, particularly when it comes to indexing blockchain data and delivering it to consumers efficiently. Here’s how Kubernetes can help in this context:</li><li><strong>Scaling</strong>: Indexing blockchain data can be resource-intensive, especially when dealing with a large volume of transactions. Kubernetes can automatically scale your indexing service based on the workload. When the demand for queries increases, Kubernetes can spin up additional containers to handle the load, ensuring that your consumers get their queries processed without delays.</li><li><strong>High Availability</strong>: Blockchain data is often considered critical, and consumers rely on it for various purposes. Kubernetes can distribute your indexing service across multiple nodes, ensuring high availability. If one node fails or experiences issues, Kubernetes can automatically redirect traffic to healthy instances, minimizing downtime.</li><li><strong>Resource Management</strong>: Kubernetes allows you to define resource limits and requests for each container in your service. This ensures that your indexing service doesn’t consume all available resources, preventing it from starving other essential services running on the same cluster.</li><li><strong>Load Balancing</strong>: Kubernetes provides built-in load-balancing mechanisms. This helps evenly distribute incoming query requests to different instances of your indexing service, optimizing resource usage and ensuring responsive query processing.</li><li><strong>Rolling Updates</strong>: When you need to update your indexing service, Kubernetes supports rolling updates. This means you can roll out new versions of your indexing code while keeping the service available. Kubernetes will gradually replace old containers with new ones, ensuring minimal disruption to consumers.</li><li><strong>Storage Management</strong>: Kubernetes also helps manage storage for your indexing service. You can use Kubernetes Persistent Volumes (PVs) and Persistent Volume Claims (PVCs) to ensure that your indexed data is stored reliably and can be accessed by your containers even if they are rescheduled to different nodes.</li><li><strong>Monitoring and Logging</strong>: Kubernetes integrates well with various monitoring and logging solutions. You can set up monitoring tools like Prometheus and Grafana to keep an eye on the health and performance of your indexing service, making it easier to detect and resolve issues.</li><li><strong>Secrets Management</strong>: Managing sensitive information, such as API keys or authentication credentials, is crucial in query processing services. Kubernetes offers Secret resources that allow you to store and manage these secrets securely.</li><li><strong>Customization</strong>: Kubernetes is highly customizable. You can define your service’s deployment configurations, including environment variables, resource constraints, and networking policies, to suit the specific needs of your blockchain data indexing service.</li></ol><p>Due to the above benefits, Kubernetes provide indexer can scale their indexing services with the help of the Kubernetes cluster and this is provided by GraphOps via Launchpad.</p><h3>What is Launchpad ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gpSK8H8r31l30XhvsD4qdA.jpeg" /><figcaption>Infrastructure as a code</figcaption></figure><p>Launchpad is an Iac (Infrastructure as code) for launching your indexing services to new heights and automating the indexing process using DevOps.</p><p>Now, you might be wondering how this all works. It’s quite simple. Each query follows a specific process: it begins by being taken up by an indexer. The indexer then carries out the query, directing it to the appropriate subgraph, fetching the required data, and ultimately sending the results back to the consumer. This is how a query is resolved</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T4GIBuLpHSOzq9pd0ft5Cw.png" /><figcaption>Indexing in The Graph Protocol</figcaption></figure><p>To simplify the process, we can start by creating a container that houses all the necessary indexing tools. This way, if there are multiple queries, you can easily generate multiple toolkits for querying the data.</p><p>When it comes to querying a specific subgraph, you usually require a curated set of tools and dependencies within your container. These tools enable you to interact with and retrieve data from the specific subgraph you’re interested in. While Launchpad streamlines the deployment and management of your indexing infrastructure, the exact tools within your container may vary based on the blockchain and the specific subgraph you’re working with.</p><h4>Let’s take an Interesting Example 😎💯</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*46avmBqVGEEH3CCfjQd_GQ.jpeg" /><figcaption>Investigator with his tools</figcaption></figure><p>Think of Launchpad as your toolbox, like the one a handyman uses.” Indexers are like investigators, and they want to understand what’s happening in different neighborhoods. Launchpad helps them by providing a toolbox with all the tools they need in one place. It’s like having a toolbox with a map, a magnifying glass, and a notebook. With these tools, they can quickly go to different neighborhoods (blockchains) and figure out what’s happening there. So, Launchpad simplifies the process and makes it easier for investigators (indexers) to do their job.</p><p>In essence, Launchpad is a helpful set of tools that indexers use to make sense of information from various blockchains, just like an investigator uses a toolbox to understand different neighborhoods. It brings everything together and makes the process more efficient and organized.</p><h4>How Does Kubernetes come into the picture 🤔</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*vlmx0kE_87C1yqab37P-UA.png" /><figcaption>Kubernetes cluster</figcaption></figure><ol><li><strong>Kubernetes as the Manager:</strong> Imagine Kubernetes as a manager for the investigators. It makes sure that the investigators have access to all the tools they need and that they can work together efficiently.</li><li><strong>Containerization as Toolboxes:</strong> Each investigator has a toolbox (container) that contains their tools, such as a map, magnifying glass, and notebook. Containers are like these specialized toolboxes that can be easily transported.</li><li><strong>Launchpad as the Toolkit:</strong> Launchpad provides a standard toolkit to all investigators. It’s like the warehouse where all the tools are stored. This toolkit includes things like maps, notebooks, and magnifying glasses. Launchpad ensures that all investigators have access to the same tools.</li><li><strong>Efficient Investigation:</strong> With Kubernetes coordinating everything, investigators (indexers) can quickly move between different neighborhoods (blockchains) and use their tools (containers) to make sense of what’s happening. Kubernetes ensures that there are enough investigators and toolboxes available to handle the workload efficiently.</li></ol><p>To query from a specific subgraph, you typically need a set of tools and dependencies within your container. These tools allow you to interact with and retrieve data from that particular subgraph. While Launchpad helps with the deployment and management of your indexing infrastructure, the specific tools within your container may depend on the blockchain and subgraph you are working with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*EqUiQ6Y_CuTiNhPLDs1lFg.jpeg" /><figcaption>Detective tool-kit</figcaption></figure><p><strong>Tools in the Container:</strong></p><ul><li><strong>Subgraph Code:</strong> Your container should contain the code for the subgraph you want to query. This code defines how to retrieve, process, and index data from the blockchain. It’s like a script that understands the language of the blockchain.</li><li><strong>Query Engine:</strong> You may need a query engine or tool to run specific queries against the subgraph. Think of this as a search tool that helps you find and retrieve the information you’re interested in from the subgraph.</li><li><strong>Dependencies:</strong> Your container might have dependencies like libraries or software that the subgraph code and query engine rely on. These are like the additional tools and resources that help you understand and work with the data.</li></ul><p><strong>Launchpad Automation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Aoe_HRNbc0JAr-oNRLP0tA.png" /></figure><ul><li>Launchpad automates many aspects of managing and deploying your subgraph and the associated tools. It helps you set up the infrastructure, create Kubernetes resources, and ensure that everything is running smoothly. It’s like having a project manager who handles logistics and keeps everything organized.</li><li>Launchpad can also help in deploying and configuring the subgraph code and related components in a standardized way. It ensures that the subgraph is ready for querying by setting up the right environment.</li></ul><p>So, while Launchpad doesn’t directly provide the tools within your container, it streamlines the process of managing your infrastructure and deploying the subgraph, making it easier for you to query data from a specific subgraph. It’s like having a project manager who ensures that the investigators (indexers) have the right tools and resources to do their job efficiently. The specific tools and code you need in your container depend on the subgraph you’re working with, and Launchpad helps automate the setup and management of that environment.</p><p>Launchpad provides various components, including Launchpad Starter and Launchpad Namespaces, to simplify the process of managing and deploying multichain indexing infrastructure. Let’s break down these components and how they help in the process:</p><h3><strong>Launchpad Starter</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JdWVO6ne9-pWdDnbKaT5wQ.png" /><figcaption>LaunchPad Starter</figcaption></figure><p><a href="https://github.com/graphops/launchpad-starter"><strong>Launchpad Starter</strong></a> is like the foundation of your infrastructure setup. It’s a starting point for setting up everything you need to index data from multiple blockchains.</p><h4><strong>Features</strong></h4><ul><li><strong>Infrastructure Setup:</strong> It helps you set up the basics, like configuring your environment, tools, and connections.</li><li><strong>Git Repository:</strong> It creates a Git repository to store the configurations and code you’ll use for indexing.</li><li><strong>Version Control:</strong> It encourages you to keep track of changes and updates, making it easier to manage your setup over time.</li></ul><p>Launchpad Starter is like laying the groundwork for your indexing project. It ensures that you have a solid foundation to build upon.</p><h3><strong>Launchpad Charts</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4L--ewu_KcQLQbYvR4TvGg.png" /><figcaption>LaunchPad Charts</figcaption></figure><p><a href="https://github.com/graphops/launchpad-charts"><strong>Launchpad Charts</strong></a> are like instruction manuals for setting up different parts of your indexing infrastructure. They are based on Helm Charts, which are packages of pre-configured Kubernetes resources.</p><h4><strong>Features</strong></h4><ol><li><strong>Preconfigured Deployment:</strong> Launchpad Charts come with pre-set configurations that ensure the software is deployed in the right way. This includes settings for databases, monitoring, and more.</li><li><strong>Software Packages:</strong> Each chart focuses on a specific software or service, such as a database or monitoring tool. It defines what version to install and how to configure it.</li><li><strong>Consistency:</strong> Using charts ensures that each instance of a particular software is set up in the same way, creating a consistent and reliable infrastructure.</li></ol><p>Launchpad Charts simplify the deployment of various components in your indexing infrastructure by providing predefined configurations and instructions. Here are a few examples of how they can be helpful:</p><ul><li><strong>Database Chart:</strong> If you need a database to store indexed data, you can use the Database Chart. It provides the instructions and configuration settings to deploy a database that’s compatible with your indexing setup.</li><li><strong>Monitoring Chart:</strong> For keeping an eye on the health of your indexing infrastructure, you can use the Monitoring Chart. It sets up monitoring tools and dashboards to help you track the performance of your system.</li><li><strong>Ingress Chart:</strong> If you want to manage how external traffic gets to your indexing system, you can use the Ingress Chart. It configures rules for routing traffic and managing connections.</li></ul><p>In your overall infrastructure, you may combine different Launchpad Charts to set up and configure various components, ensuring that everything works harmoniously in the multichain indexing process.</p><p>In essence, Launchpad Charts provide a set of standardized templates to simplify the deployment and configuration of various software components in your multichain indexing infrastructure, ensuring consistency and reliability.</p><h3><strong>Launchpad Namespaces</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q3FEO3lkbK98MYKZCBd94Q.png" /><figcaption>LaunchPad Namespaces</figcaption></figure><p><a href="https://github.com/graphops/launchpad-namespaces"><strong>Launchpad Namespaces</strong></a> are like predefined spaces where you can organize and deploy different components of your indexing infrastructure.</p><h4><strong>Features</strong></h4><ol><li><strong>Helm Charts:</strong> Launchpad Namespaces come with Helm Charts. Helm is like a package manager for Kubernetes. These charts define what software should be installed and how it should be configured.</li><li><strong>Pre-configured Setup:</strong> Each Namespace comes preconfigured for specific use cases, like storage, monitoring, or ingress. It means you don’t have to start from scratch; you can use these setups as a starting point.</li></ol><p>Launchpad Namespaces simplifies the setup of your infrastructure by providing pre-configured templates. They help you deploy the necessary software and configurations for different components of your indexing project.</p><h3><strong>Taskfile</strong></h3><p>A Taskfile is like a list of instructions for automated tasks. It helps you manage and automate various operations in your indexing setup.</p><p>Taskfiles include commands for automating tasks like setting up dependencies, managing releases, and updating configurations.</p><p>Taskfiles make it easy to automate routine tasks, ensuring that your infrastructure remains up-to-date and operates smoothly.</p><h3>Kubernetes Cluster</h3><p><strong>Kubernetes</strong> manages the orchestration of your infrastructure, ensuring that all components work together harmoniously. It deploys and scales your applications, and Kubernetes also interfaces with Helm for software deployments.</p><p>Containers are like self-contained units that house specific tools and dependencies required for tasks. They’re deployed within your Kubernetes environment and run the code that interacts with blockchain data.</p><h3>Summary of the Blog .😌👌</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z_aY5oO6EuR6kEhIWpv_oQ.png" /></figure><p>Launchpad is an infrastructure-as-code (IaC) tool that plays a crucial role in automating the indexing process in The Graph Protocol ecosystem. It simplifies the deployment and management of indexing tools and services using DevOps principles. Launchpad utilizes Kubernetes to streamline the process of setting up, configuring, and managing indexing infrastructure. It provides predefined templates (Launchpad Charts and Namespaces) for consistent and reliable deployment. Additionally, it offers automation tools (Taskfile) to perform routine tasks and ensures efficient orchestration of components within a Kubernetes cluster. Overall, Launchpad simplifies the complex process of indexing blockchain data, making it more efficient and accessible for indexers.</p><h4>Thank you for reading</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lzSNHQZEQCUjHAAH5GvVmA.jpeg" /></figure><p>I hope guys learned some cool new stuff about Launchpad and how indexers scale their services using Launchpad. Now you can further read their documentation for doing a hands-on and using it for your own indexing services if you are an indexer.</p><h3>Quote of the Day</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*1QABgH5T2ZvXobQq6dxUXQ.jpeg" /></figure><p>So Go ahead and check out their <a href="https://docs.graphops.xyz/launchpad/intro"><strong>docs here.</strong></a></p><p>And create automate your services as well and scale like anything🚀. <br>Rest Sky is the limit 🌃</p><p>Follow me 🙏 for more and do give it a clap👏 as a gesture of appreciation 😌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29d73cb9b60a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Common Terminologies for Blockchain and the Graph Protocol for Newbies.]]></title>
            <link>https://medium.com/@md.amaan.cse25/beginnerdemystifying-common-terminologies-for-blockchain-and-the-graph-protocol-for-newbies-612e8388a4dc?source=rss-475a86c0d053------2</link>
            <guid isPermaLink="false">https://medium.com/p/612e8388a4dc</guid>
            <category><![CDATA[blockchain-technology]]></category>
            <dc:creator><![CDATA[Md Amaan]]></dc:creator>
            <pubDate>Sat, 02 Sep 2023 17:52:13 GMT</pubDate>
            <atom:updated>2023-09-13T19:46:18.072Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*6IFQWaGRVCtwWr7StthkZw.jpeg" /><figcaption>Basic terms of blockchains</figcaption></figure><blockquote>I have seen many folks trying to read about blockchain and learn about blockchain, but they face difficulty learning from the documents and other resources because the terms that are used in them are too technical for them.</blockquote><p>This blog is mainly focused on newbies who know nothing about blockchain and its terms and terminologies and want to get a glimpse of it and then explore as much as possible. I will keep adding more terms to this in the future as well, based on your doubts.</p><p>This blog is a bit lengthy as I want it to be a one-stop resource for all things, so if you are always good to skip to the part you want to learn</p><p>— — Lets Learn the language of web3 folks — —</p><p>For people who know these terms, feel free to give your feedback to me for improvement in this blog content, and let’s make it a dictionary for newbies and ease their journey of learning blockchain development.</p><h4>Table of Content</h4><ol><li><a href="#363c">Blockchain</a></li><li><a href="#9c6c">Difference between Blockchain and Database</a></li><li><a href="#07a9">Nodes</a></li><li><a href="#d8b7">Mempool</a></li><li><a href="#d8d5">Smart Contracts</a></li><li><a href="#4aeb">Testnet</a></li><li><a href="#e260">Events</a></li><li><a href="#2de2">Public and Private Blockchain</a></li><li><a href="#17b8">IPFS</a></li><li><a href="#1df8">Oracle</a></li><li><a href="#eebc">Consensus Algorithm</a></li><li><a href="#eb30">Pos and PoW</a></li><li><a href="#3543">Indexer</a></li><li><a href="#48f5">Polling</a></li><li><a href="#c762">Curator</a></li><li><a href="#4964">Signal</a></li><li><a href="#f282">Delegator</a></li><li><a href="#e571">Consumer</a></li><li><a href="#3dc3">Graph Node</a></li><li><a href="#af35">Dao</a></li><li><a href="#4ca4">Subgraph</a></li><li><a href="#18a1">Dapps</a></li><li><a href="#18a1">Firehose</a></li><li><a href="#f885">Substreams</a></li><li><a href="#9839">Substream Powered Subgraph</a></li></ol><h4>What is Blockchain ?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*eyGBp-brSGJO8HfOHEDRAg.png" /><figcaption>Blockchain node stored data</figcaption></figure><p>Technical Definition :-</p><p>A blockchain is “a distributed database” or an immutable ledger that maintains a continuously growing list of ordered records, called blocks. These blocks are linked using cryptography. Each block contains a cryptographic hash (a hash generated by a prewritten algorithmic function) of the previous block, a timestamp, and transaction data.</p><p>If you have learned about linked list data structures in college, this is going to be easy for you to understand. Basically, this is a linked list-like data structure where each node points to its previous block instead of the next one, but pointers point to the cryptographic hash of the previous block.</p><p>It seems overwhelming, but don’t worry, I am here to make it relatable in a super fun way. Let’s<strong> </strong>think of the blockchain as a magical book that everyone in a big group uses to write down important things they want to remember. But here’s the amazing part: once something is written in this book, it can never be erased or changed! (Immutable). Everyone in the group has a copy of the same book (Peer-to-Peer Architecture), and they all agree on what’s written in it.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>Difference between Blockchain and Database</h4><ul><li>Centralized storage of data -&gt; decentralized storage of data</li><li>The database administrator manages the stored data. There is no special permission for anyone; everyone has the same amount of authority and permission.</li><li>Administrators can modify the data or give permission to modify the data. Modifying data can be done by anyone and everyone, but only before adding it to the blockchain; no changes can be made after deployment.</li><li>Databases can be hacked and manipulated by hackers; blockchains can never be hacked by anyone; it’s practically impossible to do it.</li></ul><p>(<a href="#524e">Back to top</a>)👆</p><h4>Nodes</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IDVVvYmLcryzTKc_kFow9Q.png" /><figcaption>Nodes executing transactions</figcaption></figure><p>Nodes are like computers in a network. They are distributed across the network and are owned and operated by various individuals, organizations, or entities. These computers work together to maintain the blockchain, validate it, mine it, and earn rewards in exchange.</p><p>Also following the consensus mechanism like PoW,PoS , PoA etc. (consensus algorithms discussed later), which is like a bouncer outside the club who checks every one’s ID to ensure that no malicious activities happen inside the club and maintain the peace.</p><p>There are different types of Blockchain nodes few of them are :-</p><ol><li>Full Node</li><li>Light Node</li><li>Archival Node</li><li>Lightning Node</li><li>Staking Node</li><li>Mining Node</li></ol><p>A website you can refer to is <a href="https://www.analyticsinsight.net/top-10-different-types-of-blockchain-nodes-you-need-to-know/"><strong>this</strong></a>.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>Mempool</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1vCp8dUiXxKiCI8VxToxPw.png" /><figcaption>Mempool</figcaption></figure><p>Mempool is a temporary storage area for unconfirmed transactions in a blockchain network. Transactions wait there to be verified by network nodes and then selected by miners to be added to the blockchain. As you know, it takes some time to validate each block, so when transactions go to the miners, they select the transaction based on the gas fee. The higher the gas fee, the faster the transaction will get mined (block added to the blockchain with your transaction details).</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>Smart Contracts</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*8D1nTK_kp0PcfQvitUgzMg.jpeg" /><figcaption>Smart Contracts</figcaption></figure><p>In simple terms, it is code that executes automatically once you deploy it and run it; in other words, it is a contract that is smart enough to run on its own without the need of any one in between. You can customize it as per your requirements, but remember that once it is deployed, it is immutable. We need this because in our normal lives, every transaction can be turned into a contract: If I give you this much money, you will provide that much goods. But in every contract, we need to trust the other party to be honest and not violate the rules. What if all the rules are set in such a way that no one can violate them?</p><p><strong>Example</strong></p><p>Let’s say if you wrote a smart contract that if Amaan and Satyam are doing a trade, if Amaan gives his tokens to Satyam, instead of them going directly to Satyam, they go into the smart contract and hold tokens for the time being. In return, Satyam also does his part of sending the token into the smart contract. If logic is written in the code to give Amaan Satyam’s tokens and give Satyam Amaan’s tokens, there is no way either of them can cheat in this transaction, and this goes on seamlessly without any third party interaction.</p><p>For the very first time, code has the ability to store funds so that corruption cannot happen in between, which is amazing in itself.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>Testnet</h4><p>Testnet is basically for developers like you and me who don’t want to test things in the mainnet where each error costs lots of bucks and want to see how code is running and check its efficiency. We use testnet, which is a mock version of the mainnet, and we can get native tokens for free and experience the mainnet experience without paying anything. Funds here are worth nothing, so no worries of any financial loss.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>Events</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z4je8MSFIZ2ujjcq5JsO1A.jpeg" /><figcaption>Events in smart contract</figcaption></figure><p>Events <strong>enable smart contracts to share details of activity taking place on the chain. </strong>They can be thought of as log statements inserted into smart contracts by developers to share information about the results of transactions taking place. You can think of it as a special moment for a smart contract, like the minting of NFT, the sending of funds, the transfer of funds, etc.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>Public and Private Blockchains</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwL5ZMaFC5TN3AQvoWYDog.png" /><figcaption>All the blockchain nodes encrypted .</figcaption></figure><p>Public blockchains offer transparency, with all permissions visible to the public, enabling anyone to access transaction records. In contrast, private blockchains prioritize security and are often adopted by companies. They ensure confidentiality on sensitive data matters such as executive salaries, mitigating potential issues that could arise from transparency. Private blockchain users possess limited, user-specific data access permissions, enhancing data confidentiality and integrity. Also, organizations decide who can join the private blockchain; it’s not permissionless like the public blockchain, and transactions can be kept private.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>IPFS</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KI_bXIfnByBQZXE-AfyICg.jpeg" /><figcaption><em>Ipfs</em></figcaption></figure><p>InterPlanetary File System (Ipfs): this is a decentralized way of storing data in a p2p (peer to peer) network, and a specific hash is generated for a specific image or document, which is called the CID (Content Identifier) of that data, and it is unique, so it can be identified as a separate entity. The CID is generated based on the input, which currently uses SHA-256 (encryption hash) by default, which produces a 256 bit (32 byte) output, and that output is encoded with Base58 (convert byte to alphanumeric form) to generate the CID, like this QmYyDcEbTzTZRqHYJ6wYvsgBYvsgBYvsgBYvsgBYvsgBYvsgBYvsgBYvsgBY8BTwcf6w</p><p>When you add a gateway url to IPFS before its CID (like: <a href="https://ipfs.io/ipfs/QmYyDcEbTzTZRqHYJ6wYvsgBY8BTwcf6wErrg8r9BSstcc),">https://ipfs.io/ipfs/QmYyDcEbTzTZRqHYJ6wYvsgBY8BTwcf6wErrg8r9BSstcc),</a> you can see the image on the browser.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>Oracle</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NN1_dprmAHDE4uCbHHTd4g.png" /></figure><p>These are connections to outside world data like the current price of USDT, data about dynamic NFT that changes randomly with time, on-chain health insurance contracts, and other data that is not within our blockchain world and is volatile. These are maintained in a decentralized manner.</p><p>For example, because we need random numbers in many places, for example, in a lottery application, if the lucky number is somehow predicted and someone is able to figure out the algorithm behind that, it’s a big issue for everyone, so we need something that is changing with time and is random as a seed for generating random numbers, which Oracle solves. There are tons of things that we can do with the use of oracles like chainlink (the most famous), Oracle, etc.</p><p>(<a href="#524e">Back to top</a>)👆</p><h3>Consensus Algorithm</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*wtnaFB4vluJ_i_wd7vqhfA.jpeg" /></figure><p>This is, in simple terms, the law and order of the blockchain world for the safety and security of legit users and filtering out malicious ones. As we all know, the blockchain world is known for its democracy; literally anyone can become a node; there is no barrier in that no caste, creed, religion, country, or color is taken into consideration, so there must be some standard rules for everyone to follow in order to maintain peace. But unlike our government, no corruption can be done because the compiler is emotionless and doesn’t respect even Vitalik. If he refuses to follow the rules, he will get himself slashed.</p><p>Think of it like bouncers outside the party who stop people who are not invited to the party, and thus maintaining the decorum of the party means they also remove people who do anti-social activities inside the party. Similarly, in blockchain, if someone tries to do some malicious activity, we remove or slash that particular node.</p><p>(<a href="#524e">Back to top</a>)👆</p><h3><strong>PoS and PoW</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8iK9S45A7iEjVK4HUcI9vw.jpeg" /></figure><p>PoS stands for proof of stake, which means in order to become a node, you must stake a decent amount of the native token or currency of that blockchain (like btc for bitcoin) as collateral and if you do any malicious activity, you will lose the funds staked, which is a significant amount in most cases, just as they won’t benefit from doing fraudulent activity. This makes them aware of the consequences. And gives security to legit users like us. This approach is followed by many blockchains and protocols like Ethereum 2.0, Polygon, Tezos, Solana, etc., and protocols like the graph protocol use PoS as their consensus for indexers to do indexing.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>DAO</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*02UMxAY7wGNW-gj2Aj1TjA.jpeg" /></figure><p>Decentralized autonomous organizations (DAOs) revolutionize participation by members in every decision of the organization, regardless of their position in the organization. If they are a part of the community and have their governance tokens, they can also give their input in decisions of the DAO. Through voting, token burning, and modifications in the rules, DAOs encourage active engagement and a sense of ownership among their members. This approach amplifies transparency and inclusivity, fostering stronger connections between members and the organization. DAOs embody the potential of decentralized technology to reshape how we perceive organizational governance, making every voice count.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>Indexer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*7IhrAPKXmF8qB_nmCMncfA.png" /></figure><p>Indexers are node operators in the Graph Network that stake Graph Tokens (GRT PoS) in order to provide indexing and query processing services. Indexers earn query fees and indexing rewards for their services. They also earn query fees that are rebated according to an exponential rebate function.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>Polling</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OMhE9T_tuC0pUoZyWKWSnQ.png" /><figcaption>Request for data from Graph Api</figcaption></figure><p>Polling is a request that is made to the indexer for fetching data from the subgraph that the indexer is indexing.</p><h4>Curator</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*-V2xS9t0eFiKzErB6RI-EA.png" /></figure><p>The curator is the person who signals a subgraph based on the quality of data the indexer is providing and helps the delegator and consumer see which subgraph is better and should be used for better quality data.</p><h4>Signal</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wne7K_-B7L-IOZzgn9oXGg.png" /><figcaption>Ratings</figcaption></figure><p>It is a rating that is given by a curator to the specific subgraph on the basis of the quality of data the indexer is providing, thus helping in filtering out the untrusted subgraph and preventing the consumer from spending their funds.</p><h4>Delegator</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GdWpUyRaCQKTDpDhvy-jaw.jpeg" /><figcaption>Investors for Indexers</figcaption></figure><p>A delegator is a person who provides liquidity to the indexer (lending group) who is unable to stake the required number of tokens for PoS and then gets returns by taking a fixed percentage from the query fees from the indexer.</p><h4>Consumer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*SfA7-53zjbXX8_G1IE9Qwg.jpeg" /></figure><p>Consumers are mostly webapps or developers who need data fetching API services from graphs and do queries from subgraphs using cli or subgraph playgrounds.</p><h4><a href="https://medium.com/@md.amaan.cse25/a-beginners-guide-to-graph-protocol-and-advocates-program-8209c07b227b">The Graph Protocol</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uhKrbFZUSMQtAEdc4XipJA.jpeg" /></figure><p>It is a block-agnostic indexing and querying protocol that is used by developers to fetch transaction history spread out in different nodes in a blockchain, which is then ordered in a meaningful manner and can be queried later using graphql. The data is fetched by the subgraph, which works on the specific events triggered from your smart contract, and it acts as a catcher that catches the event-triggered data and maps it based on defined mappings in mapping. ts file is coded by subgraph developers and stores it according to the schema defined by subgraph developers. The graph node does the job of monitoring events mentioned by the subgraph and then syncs it into the subgraph for indexing and querying.</p><h4>Graph Node</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*pelH_mwQK8FZ7avRnl9tyw.png" /><figcaption>Graph Node working architecture</figcaption></figure><p>In a blockchain system, smart contracts emit events when things happen. A “manifest” mentioned in subgraph.yaml file selects events emitted of our interest. These events are watched, and their data is extracted. A “schema” defined on how the data should be structured. The “graph node” processes and stores the data in a graph format. This structured data can be queried using GraphQL, a flexible querying language. This process helps decentralized applications efficiently gather and present data from blockchain events.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>Subgraph</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0wM4DkKzpdaM-Xd5TXvM5g.png" /><figcaption>Subgraphs</figcaption></figure><p>A subgraph is <strong>a custom API built on blockchain data</strong>. Subgraphs are queried using the GraphQL query language and are deployed to a Graph Node using the Graph CLI. Its easy to create and deploy one of your own also have a <a href="https://medium.com/@md.amaan.cse25/beginner-guide-to-query-and-display-subgraph-data-from-subgraph-studio-7cf66a974135"><strong>blog</strong></a> on it.</p><h4>Dapps</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*uK2DzxIUMBm7AqUQaT90ug.png" /><figcaption>Dapps</figcaption></figure><p>Webapps made with a backend that is interacting with the blockchain and changing the state of the blockchain, and all the transactions are done on the blockchain only, are called DAPPs, or decentralized applications.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4><strong>ETL Pipeline</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZiyyv2fHvYQT34y90wuRw.png" /><figcaption>ETL Pipeline</figcaption></figure><p>Extract Transform Load Pipeline means that when we are fetching data from another data source into your database, we need to extract the data from that data source, transform that raw data into a database-compatible form, and then load that data into your database.</p><h4>Firehose</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y3fRNi-SXRI0HfEeYAlO-Q.jpeg" /><figcaption>Firehose</figcaption></figure><p>This is the extraction layer part, which helps in extracting data from blockchain nodes at a real high extraction speed with parallel streaming of data in a highly scalable way.</p><h4>Substreams</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0mkWcCXpnF243fW0ovxasg.png" /><figcaption>Substreams</figcaption></figure><p>Substreams are the data transformation layer that is used to process blockchain data with advanced technology, making the processing of data super fast and efficient.Used in real-time analytics and monitoring. Benefits include efficient data extraction and reduced latency, outperforming competitors by enabling focused data analysis and streamlined processing of complex data sets.</p><h4>Substream powered subgraph</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7muszzjPb3o1Kmx-sWJWpw.png" /><figcaption>Substreams enabled Subgraph</figcaption></figure><p>The subgraph that leverages the power of substreams into it for indexing of data is a recent improvement done in the subgraph, and due to this, the syncing of data that used to take months is done within a day. Also its sink is compatible to different types of databases like Postgres,MongoDB,Kafka,Flat files,Google sheets.Which can be used for further analysis over the data or keep it for record.</p><p>(<a href="#524e">Back to top</a>)👆</p><h4>Thanks for Reading</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*DFQjD0NuHax4kSyrDKK4sA.jpeg" /><figcaption>Thanks for reading</figcaption></figure><p>I hope you guys learned a lot of cool new stuff and the keywords commonly used by web3 devs. Now you can relate to their jokes, make memes on your own, read the documentation, and most importantly, keep searching for more. Just a drop of water in the ocean.</p><h4>Quote Of the Day</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*dCA41CVIp1EVbFOk3-29WA.png" /><figcaption>Immutable memories of life</figcaption></figure><p>Remember, just like blockchain, life is a chain of events that build upon each other. Embrace the challenges, the funny moments, and the not-so-great professors — they’re all part of your unique and unforgettable story! 🎓🚀.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=612e8388a4dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Firehose : Navigating the World of Real-Time Data Streams]]></title>
            <link>https://medium.com/@md.amaan.cse25/introduction-to-firehose-navigating-the-world-of-real-time-data-streams-3be1b31f3b35?source=rss-475a86c0d053------2</link>
            <guid isPermaLink="false">https://medium.com/p/3be1b31f3b35</guid>
            <category><![CDATA[subgraph]]></category>
            <category><![CDATA[the-graph-protocol]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[streamingfast]]></category>
            <category><![CDATA[firehose]]></category>
            <dc:creator><![CDATA[Md Amaan]]></dc:creator>
            <pubDate>Thu, 17 Aug 2023 18:28:28 GMT</pubDate>
            <atom:updated>2023-08-30T18:59:08.068Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to Firehose: <strong>Navigating the World of Real-Time Data Streams</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*Sv1QrN6keRz8vNDhrtakbg.jpeg" /></figure><blockquote>We are going to learn more about Firehose and Firehose-enabled blockchain nodes and their other advantages over subgraphs in indexing blockchain data.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q_DLYz2ZDGd2c7E8ZAUJ2g.jpeg" /></figure><h3>Table of content</h3><ol><li><strong>What is Firehose ?</strong></li><li><strong>Why is it relevant and what are its benefits?</strong></li><li><strong>How does it work internally ?</strong></li><li><strong>Bursting some common myths about Firehoses.</strong></li><li><strong>Conclusion</strong></li><li><strong>Some resources to Learn more :)</strong></li></ol><h3>What is Firehose?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UsywdGFoMxyTN37h8i20Gg.jpeg" /></figure><p>Firehose is an extremely efficient blockchain data indexing solution. Rich data is extracted from blockchain nodes and saved to simple flat files, providing capture and processing speeds previously thought to be impossible.</p><p>Firehose is primarily written in the Go programming language and takes full advantage of the parallel computing aspects available. Firehose makes paramount improvements in the speed and performance of data availability.</p><h3><strong>What are the advantages of using Firehoses ?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7muszzjPb3o1Kmx-sWJWpw.png" /></figure><p>Firehose was created to increase the speed and performance of blockchain data extraction by solving problems encountered in deployed, real-world applications.</p><h4>Firehose Prevents Downtime</h4><p>Companies experienced up to three week-long periods of downtime due to the linear reprocessing of blockchain data. Firehose was designed for highly efficient parallelized node data processing at a massively large scale to avoid these unwanted and problematic downtimes.</p><h4>Unreal Blockchain Data Processing Speeds</h4><p>Firehose was designed to process blockchain at speeds that were previously unseen and <em>thought to be impossible</em>.</p><h4>Resolving Slow JSON-RPC Responses</h4><p>Another factor that heavily contributed to the design of Firehose is the brittleness and slow response times of, often inconsistent, JSON-RPC systems due to its request response mechanism.</p><p>Firehose treates REQUEST AND RESPONSE separate operation one thing at a time only load data, and it does that in most advanced mechanism that is designed by streaming fast team.</p><h4>Cursors</h4><p>The Firehose cursor points to a specific position in the stream of events emitted by ForkDB and the blockchain itself. The ForkDB cursor contains information that is required to reconstruct an equivalent forked or canonical instance. Consumer requests for historical blocks are fetched from persistent Firehose storage. The historical blocks are passed inside a ForkDB and sent with a cursor uniquely identifying the block and its position in the blockchain.</p><p>Now, to understand the above mechanism, let’s take a real-life example. Imagine you’re watching a TV show. The episodes are like events in a blockchain, and you have a remote control (the cursor) that lets you pause, rewind, and fast-forward through the episodes. You’re also joined by a friend (<strong>ForkDB Cursor),</strong> who is also watching the show with you.</p><p>Along with that, you have the show’s episodes downloaded on your TV, and with your remote control <strong>(Firehose Cursor),</strong> you can change the episodes to whatever episode you want. If you want to go back to the first episode (Genesis Block), you can do that with your remote control. If, by any chance, you went to drink water and came back and missed some part of the show (events), you have a friend who can give you a briefing of what happened in your absence.</p><p>In a TV show, even if you miss some episodes, it’s not a big deal, but if you are monitoring blockchain data, even if you go offline for a second or two, lots of things can happen in your absence. But with Firehose, all the transactions are being captured in your Firehose cursor and FORKDB cursor; these are like your bookmarks, which keep an eye on the blockchain in your place, and you can continue from that event and even load the missed blocks until the current block.</p><h4>Low Latency Racing Speed</h4><p>Placing multiple Reader components side by side and confronted by one or more Relayers allows for highly available setups. A relayer connected to multiple readers will reduplicate incoming streams and push the first block downstream. Two reader components will even race to push the data out first. Firehose is designed to leverage this racing reader feature to the benefit of the end-user by producing the lowest latency possible.</p><p>Substreams uses Firehose (developed by streaming fast) to extract data and also does parallel data streaming with firehose, which makes it horizontally scalable ,i.e., we can increase its efficiency with increase in machine power and number of firehoses running parallelly for storing and loading data making its indexing performance go as high as needed . The sky 🪂is the limit.</p><h3>Customizable</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FTszU7kax-WaWAp86IfxAw.png" /></figure><p>Use code to customize extraction, do transformation-time aggregations, and model your output for multiple sinks.</p><h3>Leverages flat files</h3><p>Blockchain data is extracted into flat files, the cheapest and most optimized computing resource available.</p><h3><strong>How does it work Internally</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*odBO5fk6TThi3tjaiPC_Ag.png" /></figure><h4><strong>Firehose Component Family</strong></h4><p>The Firehose system comprises several key components that work together to provide your desired functionality.</p><ol><li><a href="https://firehose.streamingfast.io/architecture/components/firehose-enabled-node"><strong>Firehose-enabled Node</strong></a></li><li><a href="https://firehose.streamingfast.io/architecture/components/reader"><strong>Reader component</strong></a></li><li><a href="https://firehose.streamingfast.io/architecture/components/merger"><strong>Merger component</strong></a></li><li><a href="https://firehose.streamingfast.io/architecture/components/relayer"><strong>Relayer component</strong></a></li><li><a href="https://firehose.streamingfast.io/architecture/components/grpc-server"><strong>Firehose gRPC Server component</strong></a></li></ol><p>The Firehose gRPC Server component provides the data to the end consumer of Firehose through remote method calls to the server.</p><h3>Why it matters for Indexers, Delegator and Curator and Subgraph developers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s4bZ03vBaNqDt1RMUdhRiA.jpeg" /></figure><p>In the dynamic world of the Graph ecosystem, the integration of Firehose technology extending its benefits not only to indexers, curators, and delegators but also to the realm of subgraph developers. As Firehose accelerates data indexing and synchronization, subgraph developers find themselves in a realm of expedited development cycles. With fast data availability, developers can fine-tune and optimize subgraphs with greater agility, resulting in a more refined end product. The speed of data indexing and syncing propelled by Firehose’s process translates to lightning-fast processing. For indexers, this means a surge in efficiency, enabling them to execute a multitude of queries in record time. Consequently, curators find their work more satisfying as their curated data becomes available for querying almost instantly. The seamless synergy between Firehose and the Graph ecosystem transforms the experience for delegators as well. With rapid data extraction and processing, indexers are better positioned to generate query fees, thereby enhancing the returns for delegators through the percentage earned from these fees. As Firehose technology joins hands with the Graph ecosystem, it sets in motion a ripple effect of efficiency, satisfaction, and financial gains, cascading benefits across the spectrum.</p><h3><strong>Bursting some common Myths about Firehose</strong></h3><p><strong>Does Firehose work with GraphQL?</strong></p><p>Firehose seamlessly interfaces with the data flow by complementing GraphQL APIs indirectly. While subgraphs utilize GraphQL for data querying, substreams act as the bridge to populate these subgraphs. Firehose dynamically extracts data from blockchain nodes, feeding it to substreams as their lifeblood. In the intricate dance of data, substream sinks expertly transport this wealth of information to storage engines, enabling diverse avenues of access. The synergy of Firehose, substreams, and subgraphs orchestrates a harmonious ecosystem where raw blockchain data evolves into structured insights, powering the next generation of decentralized applications with unparalleled efficiency and accessibility.</p><p><strong>How much does Firehose cost?</strong></p><p>Firehose is made available as an open-source project, published under the Apache 2.0 license. As such, there are no direct fees involved. Running the Firehose and serving live blockchain data is a service that is offered by StreamingFast and other providers, with the goal of being served directly on the Graph network.</p><p><strong>Do Subgraphs work with Firehose?</strong></p><p>In a way, the graph-node software, which powers Subgraphs, can connect directly to Firehose for Ethereum and Cosmos and power the traditional Subgraphs there. Substreams can also be used directly to power Subgraphs, in which case Firehose is not directly involved (only as an implementation detail within Substreams).</p><h3><strong>Conclusion</strong></h3><p>Firehose is basically making our process of extraction of data from the blockchain node into flat files really fast, making querying seamlessly from the blockchain node with its awesome parallelization power and programmable modules and packages super customizable, and fetching deterministic data from the events triggered from your smart contract code to maintain your app’s database, making it cheaper and more reliable for you and providing a better user experience for the customer or consumer. And gives so much power to you.</p><h3><strong>Some resources to learn more about FireHose :)</strong></h3><p>Docs of <a href="https://firehose.streamingfast.io/integrate-new-chains/integration-overview"><strong>StreamingFast</strong></a><strong> </strong>Firehose for further deep dive, go ahead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*jajdixUdYBnVuK7KvDVo9Q.jpeg" /></figure><p>My Socials : <a href="https://www.linkedin.com/in/md-amaan-305010229/"><strong>LinkedIn</strong> </a><a href="https://twitter.com/0xmdamaan"><strong>| Twitter</strong></a></p><p>Hope you got to learn much more about Firehose and you will build something awesome using it.</p><p>Have a good day 🫡❣️😎</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3be1b31f3b35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Substreams (blockchain data transformation layer)]]></title>
            <link>https://medium.com/@md.amaan.cse25/introduction-to-substreams-blockchain-data-transformation-layer-c564f90caa75?source=rss-475a86c0d053------2</link>
            <guid isPermaLink="false">https://medium.com/p/c564f90caa75</guid>
            <category><![CDATA[for-begginers]]></category>
            <category><![CDATA[subgraph]]></category>
            <category><![CDATA[streamingfast]]></category>
            <category><![CDATA[substream]]></category>
            <category><![CDATA[the-graph-protocol]]></category>
            <dc:creator><![CDATA[Md Amaan]]></dc:creator>
            <pubDate>Sun, 13 Aug 2023 07:35:03 GMT</pubDate>
            <atom:updated>2023-08-22T18:15:21.299Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g9S8wCfr8e4TCs55b46H_A.jpeg" /></figure><blockquote>We are going to learn about substreams and indexing of data with more advanced technology than subgraphs and their other plus points over ordinary indexing of blockchain data.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GzYzuDru5aZ8L-sB3lx0qg.jpeg" /></figure><h3>Table of content</h3><ol><li><strong>What is substream ?</strong></li><li><strong>Why is it relevant and its advantages over subgraphs ?</strong></li><li><strong>How does it work internally ?</strong></li><li><strong>Bursting some common myths about substream and subgraph.</strong></li><li><strong>Conclusion</strong></li><li><strong>Some resources to Learn more :)</strong></li></ol><h3>What is Substreams ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8zcNFmssS9f8_YjQZ6gOOg.png" /></figure><p>So you must be confused by the above diagram 🤔.</p><p>Let me demystify it for you 🪄 and make it super juicy to digest.</p><p>So Basically when we build Decentrailised applications such as DEX or Nft marketplace,etc.</p><p>All the transactions are done on the blockchain.But to get the data regarding the transaction it takes a lot of time to get indexed specially if it is a bigger company like uniswap.</p><p>For example when we use GPay(Google Pay ) to pay someone and then immediately after transaction is done within seconds a “Success” message appears on the page, Money transfer is done user is satisfied .</p><p>You can see the transaction receipt and other details regarding the transaction, and anyone can see it on the app and have it as proof for further requirements. This happens seamlessly without any delay whatsoever, but the issue with blockchains here is that to sync data from the blockchain index to the app, it takes a lot of time and is done in a linear fashion, block by block, but we need the transaction details to display in our app.</p><p>As well, a lot of complexity gets in between because before substreams and firehoses, we used to index blockchain data to the network via the JSON-RPC API and use the geth node in Ethereum to get data extracted and transported from the network. But here as well, we fail to make it as fast as the substream has achieved now, which is almost realtime.</p><p>This is the pain point that the streaming fast team recognized and moved forward to solve, and they made Firehose, which does the extraction of data in a parallelized way, which is a really robust architecture and is really handy for developers as it extracts it to flat files.</p><p>Alexandre Bourget (the founder of streaming fast) said in his presentation that nothing can be faster than immediately” which is what there USP is indexing blockchain data as fast as possible to do further analysis on that data.</p><p>It’s trying to make querying and indexing of data as fast and efficient as possible. No matter how old the block is, it will sync it and fetch all the details super quickly, and it is also horizontally scalable.</p><p>Now that you’ve got the context, let’s now discuss the flow of what’s happening.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-pFSfg5PWke94pK6GouZQ.png" /></figure><p>Firstly, there is a firehose-enabled Blockchain nodes are created using Firehose, which is a blockchain-agnostic way of storing and retrieving data and helps in extracting any data you need from blockchain nodes into flat files. Then this data is passed to the Substream Tier 1 user interface service, which has the ability to store and process blockchain data using advanced parallelization techniques, making the processed data available for various types of data stores or real-time systems. It saves time and money by horizontally scaling and increasing efficiency by reducing processing time and wait time.</p><h4><strong>Prerequisites before moving further</strong></h4><p>What is ETL pipeline ?</p><p>ETL stands for Extract,Transform and Load which means before even starting to work on data coming from other sources, you need to<strong> extract </strong>raw data from there and <strong>transform</strong> it to be compatible with your database ,and <strong>load</strong> it into your database, such as <strong>Postgres</strong>,<strong>MongoDb</strong> etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6S3k4g5HVfebbG8mPx41rQ.png" /></figure><p>Now that you know a little bit about ETL pipeline, you must have gotten the hint that same thing most <strong>Dapps</strong> have to do with blockchain data is extract txn data from Blockchain Node, process it and sink it to the corresponding database.</p><h3><strong>Why was Substream invented ?</strong></h3><blockquote>Before knowing what Substreams do and its inner functioning, let&#39;s discuss why they were invented ?</blockquote><p><em>Did you know Subgraphs have a linear indexing model using assembly sccripts mapping event data into graph nodes for processing blockchain data (i.e. they process events one at a time, in order)? It does that via API calls to Ethereum clients which is expensive.</em></p><p>API calls take a lot of time to push the data to the subgraph since they are doing it linearly, but <strong>Firehose</strong> comes into the picture 😎 and replaced it with its advanced indexing techniques of syncing and indexing data into the subgraph using its parallel processing of data.</p><p>But still, this alone was not enough until StreamingFast created a prototype called Sparkle, which helped decrease sync time on that subgraph from weeks to around six hours. Now, StreamingFast has evolved Sparkle’s capabilities and created substreams that can scale across all subgraphs on all chains, which is a huge achievement in itself for the team.</p><blockquote>The Graph Foundation Awards $60 Million Grant to StreamingFast to Join The Graph as a core developer team.</blockquote><h3>Now the question is ,what does it do ? and Why does it matters so much to subgraph developers ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-CUfNkBox0_mkcCjVoP8w.png" /></figure><p>Well, it makes indexing of data into subgraphs more efficient and seamless by syncing the latest block, and if needed, you can sync older blocks as well, super fast, or you can import other substream packages and get loaded data.</p><p>Substreams uses Firehose enabled blockchain node (developed by StreamingFast) to extract data and also does parallel data streaming with Firehose, which makes it horizontally scalable ,i.e., we can increase its power by increasing the number of nodes working in parallel for storing and indexing of data indexing. And incease its processing speed as much as needed ; the sky 🪂is the limit.</p><p>Substreams log-based architecture through Firehose allows developers to send custom code for streaming and ad hoc querying of the available data.</p><p><strong>The data indexing pipeline of the subgraph can be broken down into four stages:</strong></p><ul><li><strong>Extract</strong> (via Firehose)</li><li><strong>Transform</strong> (via Substreams and Subgraphs)</li><li><strong>Load </strong>(to the Postgres database)</li><li><strong>Query </strong>(serving queries to users)</li></ul><p>Databases and flat files are standard storage types; however, you can pipe substream data into other locations required by a new or existing application or architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nTzuu866wPiBfPM-TJiw9A.png" /></figure><p>The Sink reads the specific protobuf-based data being sent out .</p><p>Protobufs are designed to be used for transferring data out of substreams into the data sink. Protobufs aren’t tied to any particular technology stack or language, enabling you to capture, further process, use, and store data provided by substreams in different capacities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zAIutD5igEjCqbtDHbU9VQ.png" /></figure><p>Existing modules can also be leveraged, which developers can adapt, allowing end users to take advantage of composability without paying a performance penalty for indexing.Which means just import modules and can query data from it .</p><p>As you can see in the above diagram “imports…” you can import any existing substream package out there and get all the synced blocks from that substream, use only imported packages, or customize the whole file as a mix of both. So highly composable.</p><p>Developers can iterate upon existing modules and reuse the most efficient processes without needing to rebuild a new subgraph.</p><h3><strong>Some Major benefits of Substreams are :-</strong></h3><h4><strong>High indexing Power</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xtDmg6v8jxOLWsUbvkF81g.png" /></figure><p>Orders of magnitude faster indexing through large-scale clusters of parallel operations (think BigQuery), which was not possible in a normal subgraph without the use of substreams.</p><h3><strong>Customizable</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5_CFOqQonCVAafkL2HZ0gA.png" /></figure><p>Use code to customize the extraction of substream packages, do transformation-time aggregations, and model your output for multiple sinks with that data.</p><h3>Leverages flat files</h3><p>Blockchain data is extracted by firehose into flat files, the cheapest and most optimized computing resource available. And can be further processed to sink it to any other database like Postgres,MongoDB, or other databases.</p><h3><strong>Sink anywhere</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ij8OfgMTOX45O3ZGxfUT9Q.png" /></figure><p>You can sync data from substreams to anywhere you want: PostgreSQL, MongoDB, Kafka, subgraphs, flat files, or even Google Sheets. And do later mining over that, getting analytics on the data, and other tasks.</p><h3><strong>Programmable</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*51e2YaSajCk2wsvtOV9VCw.png" /></figure><p>You can code to customize and automate extraction, transformation-time aggregations, and modeling your output for multiple platforms, as mentioned earlier.</p><h3><strong>How does it work internally ?</strong></h3><p>The process of using substreams includes choosing a blockchain to capture and process data from identifying interesting smart contract addresses (like DEXs or interesting wallet addresses).</p><ul><li>Identify the data and defining and creating <a href="https://developers.google.com/protocol-buffers"><strong>protobuf</strong></a><strong>s.</strong></li><li>Find already-built <a href="https://thegraph.com/docs/en/substreams/developers-guide/modules/writing-module-handlers/"><strong>Substreams modules</strong></a> and consume their streams</li><li>Write <a href="https://thegraph.com/docs/en/substreams/developers-guide/modules/writing-module-handlers/">Rust Substreams</a> module handler functions.</li><li>Update the Substreams manifest to reference the protobufs and module handlers.</li><li>Use the <a href="https://thegraph.com/docs/en/substreams/reference-and-specs/command-line-interface/">substreams CLI</a> to send commands and view results from substreams.</li></ul><h3>Different parts of Substream architecture</h3><h4>1. <a href="https://thegraph.com/docs/en/substreams/reference-and-specs/command-line-interface/">The Substreams engine</a></h4><h4>2. <a href="https://thegraph.com/docs/en/substreams/reference-and-specs/manifests/">Substreams module communication</a></h4><h4>3. <a href="https://en.wikipedia.org/wiki/Directed_acyclic_graph">Substreams DAG</a></h4><h4>4.<a href="https://developers.google.com/protocol-buffers"> Protobufs for Substreams</a></h4><h4>5. <a href="https://thegraph.com/docs/en/substreams/developers-guide/modules/writing-module-handlers/">Substreams Rust modules</a></h4><h3>Can I run subgraph code on substream’s engine ?</h3><p>— &gt; One cannot take a subgraph’s code and run it on a substream’s engine; they are incompatible. You write your substreams in Rust, while subgraphs are written in Assembly Script.</p><h4><strong><em>Other Differences between Substreams and Subgraphs</em></strong></h4><ul><li>Substreams are “stateless” request through gRPC while Subgraphs are persistent deployment</li><li>Substreams offers you the chain’s specific full block while in Subgraph, you define “triggers” that will invoke your code.</li><li>Substreams are consumed through a gRPC connection where you control the actual output message, while subgraphs are consumed through GraphQL.</li><li>Substreams have neither long-term storage nor a database (they have transient storage) while Subgraph stores data persistently in Postgres.</li><li>Substreams can be consumed in real-time with a fork aware model, while Subgraph can only be consumed through GraphQL and polling for “real-time”.</li></ul><blockquote>Substreams offer quite a different model when compared to subgraph; just Rust alone is a big shift for someone used to write Subgraphs in Assembly Script. Substreams is working a lot also with Protobuf models also.</blockquote><p>One of the benefits of substreams is that the persistent storage solution is not part of the technology directly, so you are free to use the database of your choice, which enables a lot of analytics use cases that were not possible (or harder to implement) today using subgraphs, like persistently storing your transformed data in BigQuery, Clickhouse, Kafka, etc. Also, the live-streaming feature of Substreams enables further use cases and super quick reactivity that will benefit a lot of users.</p><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NpVcNH9ONHnnlPFUyAhAYA.png" /></figure><p>Substreams are basically making our data processed and sinking it into some other forms really fast. They use Firehose as a caching memory for querying seamlessly from the blockchain node with its awesome parallel streaming of data through Firehose, and then composable and programmable modules and Substream packages make it super customizable and process deterministic data from Firehose into your database.</p><h3>Use Cases of Substreams</h3><p>It mainly focuses on blockchains like Ethereum, Solana, Flow, Polkadot, Cosmos, Polygon, Binance Smart Chain, Optimism, Arbitrum, and other high-throughput blockchains. The team was led by investors such as Multicoin Capital, Intel Capital, Diagram Ventures, White Star Capital, Panache Ventures, and BoxOne, with a growing community in Asia and North America.</p><h4>Some Resources to get started</h4><p>Docs of <a href="https://substreams.streamingfast.io/"><strong>StreamingFast</strong></a> for further deep dive go ahead.</p><p>My Socials : <a href="https://www.linkedin.com/in/md-amaan-305010229/"><strong>LinkedIn</strong> </a><a href="https://twitter.com/0xmdamaan"><strong>| Twitter</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*lJM7Ic7WTUaX2kJbxzzhKg.jpeg" /><figcaption>Keep exploring something new :)</figcaption></figure><h4>Thnks for Reading 🫡hope it was Great Learning Experience for you :)</h4><h4>Follow for more ❣️😎</h4><p><a href="https://www.linkedin.com/in/md-amaan-305010229/"><strong>— — — — — — — — — — — — — — </strong></a><strong>— — — — — — — — — — — — — — — — —</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c564f90caa75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beginner guide to query and display subgraph data from Subgraph Explorer]]></title>
            <link>https://medium.com/@md.amaan.cse25/beginner-guide-to-query-and-display-subgraph-data-from-subgraph-studio-7cf66a974135?source=rss-475a86c0d053------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cf66a974135</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[subgraph]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[uniswap-v3]]></category>
            <category><![CDATA[the-graph-protocol]]></category>
            <dc:creator><![CDATA[Md Amaan]]></dc:creator>
            <pubDate>Wed, 09 Aug 2023 18:27:03 GMT</pubDate>
            <atom:updated>2023-09-26T17:48:10.732Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*db23KxYN2uMD1uPPG3iV9g.jpeg" /></figure><h3>Beginner guide to query and display subgraph data from Subgraph Studio</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0wM4DkKzpdaM-Xd5TXvM5g.png" /></figure><blockquote>In this blog, I am going to show you step-by-step guide on how are we going to fetch data from our subgraph by querying from uniswap subgraph and display it on the frontend of our Web Application.</blockquote><h4>Table of Content</h4><ol><li><strong>Create the front end for querying</strong>.</li><li><a href="#3904"><strong>Set up for querying from the uniswap subgraph</strong>.</a></li><li><a href="#700f"><strong>Displaying the data on the front end</strong> </a>.</li></ol><h3>Step 1 : Create a Sample React App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vpnZjSyJZjm_-Yj2idrmzg.png" /><figcaption><strong>Vite app</strong></figcaption></figure><p>Create a new folder on your pc and name it whatever you like to say, in my case, Let&#39;s name it “Subgraph”.</p><pre>npm create vite@latest &lt;projectName&gt;</pre><p>Replace the Project Name with your desired project name of your own choice, then write the following commands :-</p><pre>cd client</pre><pre>npm install</pre><pre>npm run dev</pre><p>We will also need to install graphql to query the data and urql which is a highly customizable and versatile GraphQL client for React.</p><pre>npm install graphql urql@3.0.3</pre><p>Inside the directory, go to the src/App.jsx and replace the existing code with</p><pre>import { useState, useEffect } from &#39;react&#39;;<br>import &#39;./App.css&#39;;<br><br>function App() {<br>  return (<br>    &lt;&gt;<br>      &lt;div&gt;<br><br>      &lt;/div&gt;<br>    &lt;/&gt;<br>  )<br>}<br><br>export default App;</pre><p>We are going to make use of the Uniswap subgraph for this demo application.</p><h3>Step 2: Set up for Subgraph on Subgraph Explorer</h3><p>Go to <a href="https://thegraph.com/explorer/subgraphs/ELUcwgpm14LKPLrBRuVvPvNKHQ9HvwmtKgKSH6123cr7?view=Overview&amp;chain=mainnet"><strong>Uniswap subgraph</strong></a> on subgraph studio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vk5aRBv3AxUvpRiuzHy2Eg.png" /><figcaption><strong>Look at the Query button</strong></figcaption></figure><p>Click on the Query button on the right and copy the Query URL to access the subgraph.</p><p>Go back to our App.jsx and store the URL in a variable inside the App function.</p><pre>const QueryURL = &quot;https://gateway.thegraph.com/api/[api-key]/subgraphs/id/ELUcwgpm14LKPLrBRuVvPvNKHQ9HvwmtKgKSH6123cr7&quot;</pre><p>You need an API Key to query the data. Under the Query URL, you can see the option to Manage API Keys. Click on that and it will take you to create it. You can also create it using <a href="https://thegraph.com/studio/apikeys/">this</a> link.</p><p>First connect your Metamask wallet by clicking on connect button.</p><p>After which you will see something like this :-)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sx-EuiJIPNY67VRmRw5nbQ.png" /></figure><p>In my case I have created on API key but in your case this will be empty and you have to create for your app.</p><ul><li>Click on Create API Key and enter a name, example: subgraph-uniswap.</li><li>You get 1,000 free queries for the API key. Enter your email address and claim your queries.</li><li>Copy the generated API key that you have generated and paste it into our QueryURL variable inside your App.jsx.</li><li>Add the data you want to query below the QueryURL variable using GraphQL language provided below, or you can write your custom query if you know GraphQL.</li><li>Here we will write a query to get the data about the first 5 token details of Uniswap Subgraph.</li></ul><pre>const query = `{<br>  tokens(first: 5) {<br>    id<br>    name<br>    symbol<br>    decimals<br>  }<br>}`</pre><p>Create a client to access Uniswap. We will make of urql for this. Add the following import statement at the top of the app.js like this-:</p><pre>import { createClient } from &#39;urql&#39;;</pre><p>To create the client, add the following code after the query variable.</p><pre>const client = createClient({<br>  url: QueryURL<br>})</pre><p>We will make use of useEffect and useState to track the state. Add the following code inside the App function.</p><pre>const [tokens, setTokens] = useState([]);</pre><p>After that, we are going to create a function named getTokens which will use the client that we imported on the top and used a query function inbuilt inside that and passed our query which we wrote in the query variable.</p><pre>useEffect(() =&gt; {<br>  const getTokens = async () =&gt; {<br>    const { data } = await client.query(query).toPromise();<br>    console.log(data);<br>    setTokens(data.tokens);<br>  }<br>  getTokens();<br>}, [])</pre><h4>To Display the data on the frontend, we will return the following jsx code.</h4><pre>return (<br>    &lt;&gt;<br>      &lt;div&gt;<br>        &lt;h1&gt;Tokens Information&lt;/h1&gt;<br>        {tokens !== null &amp;&amp; tokens.length &gt; 0 &amp;&amp; tokens.map((token) =&gt; {<br>          return (<br>            &lt;div key={token.id}&gt;<br>              &lt;div&gt;{token.id}&lt;/div&gt;<br>              &lt;div&gt;{token.name}&lt;/div&gt;<br>            &lt;/div&gt;<br>          );<br>        })}<br>      &lt;/div&gt;<br>    &lt;/&gt;<br>  );</pre><p>By setting token we got the data of the five tokens as an array in token which we are displaying using a loop and displaying the token id, token name of the first five tokens.</p><p>Your final App.jsx should look like this more or less -:</p><pre>import { useEffect, useState } from &#39;react&#39;;<br>import { createClient } from &#39;urql&#39;;<br>import &#39;./App.css&#39;;<br><br>function App() {<br>  const [tokens, setTokens] = useState([]);<br><br>  const QueryURL = &quot;https://gateway.thegraph.com/api/[api-key]/subgraphs/id/ELUcwgpm14LKPLrBRuVvPvNKHQ9HvwmtKgKSH6123cr7&quot;;<br><br>  const client = createClient({<br>    url: QueryURL<br>  });<br><br>  const query = `{<br>    tokens(first: 5) {<br>      id<br>      name<br>      symbol<br>      decimals<br>    }<br>  }`<br><br>  useEffect(() =&gt; {<br>    const getTokens = async () =&gt; {<br>      const { data } = await client.query(query).toPromise();<br>      setTokens(data.tokens);<br>    };<br>    getTokens();<br>  }, []);<br><br>  return (<br>    &lt;&gt;<br>      &lt;div&gt;<br>        &lt;h1&gt;Tokens Information&lt;/h1&gt;<br>        {tokens !== null &amp;&amp; tokens.length &gt; 0 &amp;&amp; tokens.map((token) =&gt; {<br>          return (<br>            &lt;div key={token.id}&gt;<br>              &lt;div&gt;{token.id}&lt;/div&gt;<br>              &lt;div&gt;{token.name}&lt;/div&gt;<br>            &lt;/div&gt;<br>          );<br>        })}<br>      &lt;/div&gt;<br>    &lt;/&gt;<br>  );<br>}<br><br>export default App;</pre><ul><li>Run npm run dev to view the frontend.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bcbx09jKIxbRNVYVhiS2lw.png" /><figcaption><strong>Mine one looks like this match yours if you followed along with me.</strong></figcaption></figure><ul><li>Voilà ! You did it. 🥳 Congratulations! You have successfully queried from a famous subgraph and successfully displayed the data on the frontend of your app from the blockchain world.</li><li>Make use of The Graph Playground in the dashboard of the graph studio to use different queries from any subgraph and display that data on the front end seamlessly.</li><li>This is how uniswap as well fetches the token price of the tokens inside the pool and is able to tell the user about the updates happening off chain.</li></ul><p>My Socials :-)</p><p><a href="https://www.linkedin.com/in/md-amaan-305010229/"><strong>LinkedIn</strong></a><strong> | </strong><a href="https://twitter.com/0xmdamaan"><strong>Twitter</strong></a><strong> | Discord ID :- mdamaan.</strong></p><p>Thanks for giving your time, Hope you learned something valuable from this blog ;)</p><p>See you in the next one, where we will be creating our own subgraph using the <a href="https://thegraph.com/studio"><strong>Subgraph Studio</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cf66a974135" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner’s Guide to Graph Protocol and Advocates Program]]></title>
            <link>https://medium.com/@md.amaan.cse25/a-beginners-guide-to-graph-protocol-and-advocates-program-8209c07b227b?source=rss-475a86c0d053------2</link>
            <guid isPermaLink="false">https://medium.com/p/8209c07b227b</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[for-begginers]]></category>
            <category><![CDATA[the-graph-protocol]]></category>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[community-building]]></category>
            <dc:creator><![CDATA[Md Amaan]]></dc:creator>
            <pubDate>Sat, 05 Aug 2023 11:51:29 GMT</pubDate>
            <atom:updated>2023-08-05T17:28:32.573Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Beginner’s Guide to Graph Advocate Program</h3><blockquote><strong>About Me</strong> : I am a Graph Advocate in The Graph Protocol and part of Graph India Community.</blockquote><p>So Before We start, Let’s Discuss What are the topics we are going to be covering in this Blog :-)</p><ol><li>What is <a href="https://thegraph.academy/"><strong>The Graph Protocol</strong></a> ?</li><li>Why Should you contribute, and What are the perks and advantages of being a Graph Advocates Program ?</li><li>What are the ways you can contribute to the community ?</li><li>Lastly, the process to apply for <a href="https://thegraph.com/ecosystem/advocacy/"><strong>Graph advocate</strong></a> ?</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*puUZF2v_-4t4cmlyv-q7DA.png" /></figure><h3><strong>What is the Graph Protocol ?</strong></h3><p>The Graph Network is a decentralized indexing protocol for querying data from blockchains. The protocol is blockchain agnostic and has integrated with numerous L1 and L2 Blockchains such as Ethereum, IPFS, Polkadot, Fantom and many more. Developers can create open APIs (so-called subgraphs) and deploy it on graph <a href="https://thegraph.com/studio/">studio</a> to make its data easily accessible.</p><p>The Graph is a decentralized protocol for indexing and querying data from blockchains.</p><p>If you are familiar with blockchain, then you might know that it is an opposite linked List where each node points to its previous node instead of pointing to the next one.</p><p>Projects with complex smart contracts like Bored Ape store data on the Ethereum blockchain, making it really difficult to read anything other than basic data directly from the blockchain.</p><p>You might argue why do we need an API for just getting data about a NFT we already have etherscan for searching that with its txId ,But if you go to <a href="https://etherscan.io/">etherscan </a>you will see that you have all the data about the particular nft minted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hOvdMjnF99Wrv_kOkxPk_A.png" /></figure><p>Data like who minted which nft and when and how much gas fees paid on which platform it was minted and much more.</p><p>But my question is do we really need all of this data when we are building an application.</p><p>In the case of Bored Ape Yacht Club, we can perform basic read operations on smart contract like getting the owner of a certain Ape, getting the content URI of an Ape based on their ID, or the total supply, as these read operations are programmed directly into the smart contract.</p><p>But more advanced real-world queries and operations like aggregation, search, relationships, and non-trivial filtering are not possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eD1h4O-8wQ5XNuag_cCZFg.png" /></figure><p>For example, if we wanted to query for apes that are owned by a certain address, and filter by one of its characteristics, we would not be able to get that information by interacting directly from etherscan.</p><p>To get this data, you would have to process every single transfer event ever emitted, read the metadata from IPFS using the Token ID and IPFS hash, and then aggregate it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*S7DCjB_eq7fqtHbrWTix-Q.jpeg" /></figure><p>Even for these types of relatively simple questions, it would take <strong>hours or even days</strong> for a decentralized application (dapp) running in a browser to get an answer for a query.</p><p>You could also build out your own server, process the transactions there, save them to the app’s database, and build an API endpoint on top of it all in order to query the data. However, this option is resource intensive, needs maintenance, presents a single point of failure, and breaks important security properties required for decentralization.</p><p>The Graph solves this problem with a decentralized protocol that indexes and enables the performant and efficient querying of blockchain data.</p><p>These APIs (indexed “subgraphs”) can then be queried with a standard GraphQL API using GraphQL query language.</p><p>You can think of it as a Google for querying blockchain data, but the difference is that this is not owned by a central authority this is decentralized and permissionless.</p><h3><strong>How can you contribute and Why Should you do so !</strong></h3><p>Now that you know so much about the protocol and the problem it is solving, you must be interested to know what’s advocate program is all about.</p><p>So, like any other project, graph protocol also does want to grow as a company and spread its services to most of the companies.</p><p>And for making it possible it demands us to use it and be familiar with the technology and through which it will expand itself and do more advancement in it.</p><p>So we as an advocate it is our duty to spread the knowledge to as many devs as possible and for that we need a community which will act as a place for collaboration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uhKrbFZUSMQtAEdc4XipJA.jpeg" /></figure><p>Also graph has a Dao for advocates names as advocatesdao where they incentivize people who contribute to the community in their own ways they have a grants program going on where you can simply write a detail description about your work and initiative towards the growth of protocol and then members give their approval or disapproval based on their perspective also they ask questions to the applicant about the budget and if majority vote towards its happening it is granted to the person.</p><p>But as an advocate you don’t need to apply for only grant which is a big process also can contribute with small contribution, and they have different roles like content creator, event evangelist, text translation, community care details about which you can get from their <a href="https://docs.graphadvocates.com/">notion page</a>.</p><p>Now let&#39;s talk about another big community under graph protocol that in based in India is the <a href="https://thegraphindia.notion.site/Teamspace-Home-Welcome-aboard-c6b11aaa093e4a9e99d72ca2e3ccaca1">Graph India community</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZfHfMkFFxbE8RbEHsVOofw.jpeg" /><figcaption>The Graph Ecosystem</figcaption></figure><p>In this community you have people from India itself who are already an advocate and contributing to the cause according to their roles.</p><p>And you can fill the contribution form and submit it to the Dao to get approved but only if you are selected as an advocate and cleared the interviews which is not much tougher just checks your basic understanding of protocol and how are you gonna be a useful part of the organization.</p><p>But most importantly, you don&#39;t get paid in fiat, they incentivize their members with their native cryptocurrency that is GRT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*9pdXTp9ozSx8XqqlF_NQKw.jpeg" /><figcaption><a href="https://etherscan.io/token/0xc944e90c64b2c07662a292be6244bdf05cda44a7"><strong>Grt tokens</strong></a></figcaption></figure><p>And for further details, you can read the <a href="https://docs.graphadvocates.com/community-grants/getting-grant-paid"><strong>notion page </strong></a>in the receiving grant application page on how to ramp it off into fiat.</p><p>At the end, Important Links for you to take action upon :)</p><p><a href="https://t.me/TheGraph_India"><strong>Telegram</strong></a> | <a href="https://discord.gg/WCmCzGZM6f"><strong>Discord </strong></a>|<strong> </strong><a href="https://twitter.com/TheGraphIndia"><strong>Twitter</strong></a> | <a href="https://www.youtube.com/@GraphProtocol"><strong>YouTube</strong></a> | <a href="https://thegraph.com/blog/"><strong>Technical Blogs</strong></a></p><h3>Additional Resources to get started</h3><p>Kshitij Srivastava<a href="https://www.youtube.com/watch?v=bGblDvlyNwc"><strong> Video</strong></a> on Graph Protocol.</p><p><a href="https://github.com/TheGraphIndia/Graph-A-Thon"><strong>Graphathon Challenges </strong></a><strong>: A Step-by-step detailed process of building a subgraph and deploying it in subgraph studio on mumbai testnet.</strong></p><p><a href="https://twitter.com/TheGraphIndia/status/1663023379987722241?s=20%20Graph%20Linkedin%20:https://www.linkedin.com/company/thegraphindia/?original_referer="><strong>Thread</strong></a> on Twitter about Advocate program, this is where I started off.</p><p>That&#39;s all for this blog, hope you got to learn something new and insightful and if you have any doubts feel free to contact me.</p><p>My Socials :-</p><p><a href="https://www.linkedin.com/in/md-amaan-305010229/"><strong>linkedin</strong></a><strong> | </strong><a href="https://twitter.com/0xmdamaan"><strong>Twitter</strong></a><strong> | Discord Id :-mdamaan.</strong></p><p>Thanks for reading so far Have a good day :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8209c07b227b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>