<?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 KagemniKarimu on Medium]]></title>
        <description><![CDATA[Stories by KagemniKarimu on Medium]]></description>
        <link>https://medium.com/@kagemnikarimu_3818?source=rss-c0bb8c66f36f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gIZxMlnhxHiH9OYL8USVfg.png</url>
            <title>Stories by KagemniKarimu on Medium</title>
            <link>https://medium.com/@kagemnikarimu_3818?source=rss-c0bb8c66f36f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 18:38:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kagemnikarimu_3818/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[The Living Blockchain Concept]]></title>
            <link>https://medium.com/@kagemnikarimu_3818/the-living-blockchain-concept-2ad8e1f173da?source=rss-c0bb8c66f36f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ad8e1f173da</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[developer-relations]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[KagemniKarimu]]></dc:creator>
            <pubDate>Mon, 23 Sep 2024 22:29:07 GMT</pubDate>
            <atom:updated>2024-09-23T22:29:57.690Z</atom:updated>
            <content:encoded><![CDATA[<p>In<a href="https://medium.com/@kagemnikarimu_3818/11-things-to-consider-about-ai-and-crypto-a-thought-piece-922e87ca9d0e"> my previous article</a>, I opined:</p><blockquote><em>There are AI projects which upload entire books, film scripts, or plays, and then allow a person to interact with the script as if it as a living entity. Imagine doing this with blockchains, EIPs, or Smart Contracts. A person could ask and have answered many questions about a protocol by interacting directly with its avatar. If and when training AI becomes simple and affordable, a concept like this will prove to be a gold mine.</em></blockquote><h4>Thus spoke Zarathustra: The Living Blockchain Concept</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*slOiUDBSQsjQxPUuK6xfBA.png" /></figure><h3>💬Hypothesis: Blockchains that Talk</h3><p>Let’s go hypothetical… Imagine a Developer Relations specialist’s job was simply to introduce new developers to the blockchain, <em>literally.</em> By which is meant, a DevRel onboards a developer, by literally setting up a group chat between the Living Blockchain and a new technical user.</p><p>The user is at first shocked, because they’re being passed off to an AI agent which introduces itself as the very Blockchain they’re trying to use. Initially, they try to test the AI — asking basic and facetious questions about the protocol. Yet, surprised and pleased at the wit and capability, the user decides to go deeper.</p><p>They begin asking protocol questions, for example use cases, where they can find certain resources, who’s who, and detailed information about on-chain data. For the most part, the AI supplies the requested information with flying colors — and the few times it sputters, the DevRel quickly steps in and provides context and as well as answers.</p><p>The result: the user has a positive orienting experience at no expense of the community. They quickly realize the responsiveness of the AI, combined with the nearby human presence of the devrel is a superior combination to standard documentation scouring and discord lurking. In other words, they transition from user to community member more quickly by conducting their own orientation using the AI as an interactive introductory interface.</p><h3>🧬Requirements for a Living Blockchain</h3><p>Under this hypothetical, a Living Blockchain Concept must minimally do the following:</p><ol><li><em>Be knowledgeable of its entire ledger </em>— such that it could service any request that a full (archival) node could answer. ✅</li><li><em>Be self-aware of its protocol capabilities </em>— such that it could explain itself using documentation as a first-class reference. ✅</li><li><em>Be familiar with its ecosystem</em> — such that it could direct a user to its supervisory foundation, discord community, discuss its roadmap, point out contributors, and invite to socials, commensurate with what a community manager would do. ✅</li><li><em>Learn and grow its off-chain “consciousness” from interactions with querents</em> — such that it could remember and reference past conversations in novel circumstances. ✅</li></ol><p>An AI which can pass this Turing-style test, has just passed into the magical land of Living Blockchains. Living Blockchains could lower the expense of onboarding new community members, give a fun way to learn new projects, and maybe even change the way DevRels and community managers spend their time. Instead of constantly pointing new technical users to existing documentation and examples, they could construct introductory prompts which feed the Living Blockchain a source of information for a unique starting point with each user. This seems like a very powerful application of GPT-style AI agents.</p><h3>🎉New Possibilities for Crypto</h3><p>Of course, there are even wilder use cases to imagine: Living Blockchains could be set to interact with each other, discussing their merits and differences or what opportunities for collaboration are possible within the context of their protocols. Imagine a debate between <a href="https://evmos.org/">Evmos</a> and <a href="https://www.axelar.network/">Axelar</a> or <a href="https://solana.com/">Solana</a> and <a href="https://ethereum.org/en/">Ethereum</a>? Could you imagine <a href="https://celestia.org/ecosystem/">Celestia</a> talking to <a href="https://near.org/">NEAR</a> about data availability trade-offs? The possibilities are priceless and almost mandate its creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/1*_UM4jXmwCjk1yOTavYF94g.png" /></figure><p>KagemniKarimu is the <strong>CDRO (Chief DevRel Officer)</strong> of Chainbase. He has worked as Developer Relations Engineer at Lava Network and also as Developer Relations at Skynet Labs. He’s now interested in empowering new web3 use cases.</p><p>Follow me on X! <a href="https://x.com/KagemniKarimu">https://x.com/KagemniKarimu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ad8e1f173da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[11 Things to Consider About AI and Crypto: A Thought-Piece]]></title>
            <link>https://medium.com/@kagemnikarimu_3818/11-things-to-consider-about-ai-and-crypto-a-thought-piece-922e87ca9d0e?source=rss-c0bb8c66f36f------2</link>
            <guid isPermaLink="false">https://medium.com/p/922e87ca9d0e</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[KagemniKarimu]]></dc:creator>
            <pubDate>Wed, 18 Sep 2024 20:17:18 GMT</pubDate>
            <atom:updated>2024-09-18T20:17:18.772Z</atom:updated>
            <content:encoded><![CDATA[<p>In the imagination of many, Cryptocurrency (Crypto) and Artificial Intelligence (AI) are two cutting-edge technologies that are destined for a magnificent intersection. Within the last quarter in both sectors, venture capitalists and angel investors regularly and eagerly involved themselves with projects that mentioned either of these because of the assumed earning potential of successful projects. A lot of consideration is given to each of these technologies separately, but there are many things to consider about what will happen when they finally intersect in a real way.</p><h3>Given this consideration, I outline eleven things to consider about AI and blockchain technology in the article that follows. Read along! 🚀</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rLyor_b3UIKWxlYcemu5Iw.jpeg" /></figure><h3>1. ⚙️ Amplified Developer Use Cases</h3><p>Artificial intelligence will empower new use cases for blockchain technology and crypto-currencies: developers already use tools like Github Copilot and GPT-4 to mock up common design patterns in web applications. In short order, the same improvements in workflow will be possible with LLMs which write smart contracts and dApps using crypto-native languages and SDKs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y1oxxDxjUwvPya2oeqZLqg.jpeg" /></figure><h3>2. 🧮Maximization of the Open Ledger</h3><p>The open ledger of a blockchain will make great training data for any AI agent. Large Language Models which ingest blockchain data can summarize, survey, and synthesize thoughts over the entire history of a chain. Theoretical upsides of the open, distributed ledger of blockchains will finally be made real by AIs which can gainfully use the information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IyzPQ_P-jbtE68kgXze82A.png" /></figure><h3>3. 💻New UI for TXs</h3><p>What’s a number one web3 complaint? UI/UX. Everyone dreads the … Almost certainly, AI agents will automate, simplify, and organize the process of conducting, evaluating, and processing transactions. Imagine autocompletion of frequently sent addresses, balance checks before and after, live tracking of chain updates, and gas projections on draft proposals presented to the end-user. Due to AI’s flexibility and intelligence, users may even be able to customize the set of steps that an AI agent takes before submitting any transaction, performing sanity checks, identity verifications, or any other desired steps for blockchain TXs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4z8o_9DeYlgIv1GXsvrSeg.png" /></figure><h3>4. 🔀Cross-chain , Cross-channel Interaction</h3><p>Dreams of interacting across differrent ecosystems with a single API or SDK may be accomplishable with AI. AI could collate requests, format them appropriately for different APIs, retrieve information, and report information to different channels seemlessly and simultaneously. This may be one of the best use cases for AI if someone is able to create a sophisticated enough agent that will live between worlds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dwsJoVcdFdbE6obgWsiQA.jpeg" /></figure><h3>5. 🦾The Living Blockchain Concept</h3><p>There are AI projects which upload entire books, film scripts, or plays, and then allow a person to interact with the script as if it as a living entity. Imagine doing this with blockchains, EIPs, or Smart Contracts. A person could ask and have answered many questions about a protocol by interacting directly with its avatar. If and when training AI becomes simple and affordable, a concept like this will prove to be a gold mine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BiAgo-OxwO1ovdgQsyHBTw.png" /></figure><h3>6. 🤖Mythical Trading Bots</h3><p>Preventable trading losses happen in large part due to the emotional volatility of traders. A trading bot which understands crypto trends, can ingest relevant news or social media, and which broadly comprehends a protocol and its history might be unstoppable. AI could empower a whole generation of high yield trading bots.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MnFC2x_dOlEfqCE2JGT0zw.png" /></figure><h3>7. 🗣️Natural Language Indexing</h3><p>A less glorious but equally important use case is the ability to access data using natural language as a sort of API. If an LLM is positioned as such, a person could write out their queries using natural language, for example, “Fetch all contract addresses on ETH Mainnet which have conducted TXs &gt; 1 ETH in the last 100 blocks” and receive a concise and well-formulated answer. A wise querent could even specify the output format — JSON, CSV, MarkDown Table are all easily achievable. For at least a certain species of API — this could eliminate the need for complicated querying languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9UPtDdJYZ-0OO6NS25BJSg.png" /></figure><h3>8. ☠️Dangerous Hallucinations</h3><p>AI can mistakenly lie about price, TX records, Smart Contracts, or any data outside of its reach. A wrong hallucination combined with a pre-determined workflow could have profound financial consequences for anyone involved. In general, the monetization of crypto could make the stakes of your average AI hallucination a bit higher.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yzimuaGkL_I-6vBN_hcTYQ.png" /></figure><h3>9. 🏴‍☠️Scammers Galore</h3><p>AI can also be programmed to lie in very nuanced ways. Unless AI efforts are open-source and audited, it is quite likely that some AIs will be used to collect information from unsuspecting users and exploit them. It’s easy to imagine the level of ransomware, and exploits that a malicious user of AI can come up with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQhZl69umiX1PCfNWOK1zQ.jpeg" /></figure><h3>10. 💳Pay-to-Play</h3><p>It’s hard to imagine that AI agents, which provide such high levels of utility and have immense training and maintenance costs, will be offered for free at scale. More than likely, payment schemas such as subscriptions if in common currency, or pay-as-you-go per-request charges will make the cost of AI agents sustainable for those who design and host them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZMopkBdDMEaiuWuGMTyZQg.png" /></figure><h3>11. 👥Road to Mass Adoption</h3><p>Artificial intelligence could provide an easy on-ramp to those interested in web3, but not enamored with its interfaces and ecosystems. Trusted AI agents could perform the work of onboarding retail users of crypto by walking them step-by-step through the creation of wallets, the maintenance of funds, sending a first transaction, and so on!</p><p>Dear Reader- What do you think? Am I accurate in my analysis? Leave a comment or contact eme and let me know. I’m eager to start the discussion around this, since its a hot topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/1*0-ICQx4B_msH7llVfLrxPA.png" /></figure><h3>About the Author</h3><p>KagemniKarimu is the <strong>CDRO (Chief DevRel Officer)</strong> of Chainbase. He has worked as Developer Relations Engineer at Lava Network and also as Developer Relations at Skynet Labs. He’s now interested in empowering new web3 use cases.</p><p>Follow me on X! <a href="https://x.com/KagemniKarimu">https://x.com/KagemniKarimu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=922e87ca9d0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accessing Evmos ipRPC — a Tutorial Guide to Using Lava’s Public RPC]]></title>
            <link>https://medium.com/@kagemnikarimu_3818/accessing-evmos-iprpc-a-tutorial-guide-to-using-lavas-public-rpc-ece3a0b3f8ab?source=rss-c0bb8c66f36f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ece3a0b3f8ab</guid>
            <dc:creator><![CDATA[KagemniKarimu]]></dc:creator>
            <pubDate>Thu, 14 Sep 2023 20:04:04 GMT</pubDate>
            <atom:updated>2023-09-14T20:25:29.687Z</atom:updated>
            <content:encoded><![CDATA[<h3>Accessing Evmos ipRPC — a Tutorial Guide to Using Lava’s Public RPC</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EXyVOnBa-dRrUpiSPP5U5g.jpeg" /></figure><h3>About Evmos</h3><p>Evmos is dedicated to making cross-chain connections between IBC and EVM. It’s an excellent platform for Solidity developers who want to launch apps that work with Cosmos chains, or for Cosmos developers who need reach beyond Tendermint’s capabilities.</p><p>Accessing Evmos is easier than ever with Lava. Now, with Lava supporting Evmos through incentivized Public RPC — endpoints are available as a public good to the entire developer community. A tutorial follows! 👇🏿</p><h3>ipRPC URLs</h3><p>Decentralized Public RPC endpoints are now available for Evmos through Lava. These are accessible across all interfaces and exposed in both Mainnet and Testnet!</p><h4>Mainnet (evmos-mainnet.public.lavanet.xyz) 🔧</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*KfYjeOghZWDlQcqRvG5V_A.png" /></figure><h4><strong>Testnet (</strong><a href="https://rest.evmos-testnet.public.lavanet.xyz/55132aed41ed20cea407a5f05a3a0a31/cosmos/base/tendermint/v1beta1/blocks/latest"><strong>evmos-testnet.public.lavanet.xyz</strong></a><strong>) 🧪</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*x_qOtiIP6AXYhM-sosscNA.png" /></figure><h3>Prerequisites</h3><p>The following are prerequisites for the completion of this tutorial:<br>- ✅Linux Machine or WSL<br>- ✅ Node.js (Node Package Manager)</p><h3>Access Evmos Direct ✨↗️</h3><p>You can create zero-dependency calls from a few lines of code using the available RPC endpoints! Get a complete list of Evmos APIs exposed over REST here: <a href="https://api.evmos.dev/">https://api.evmos.dev/</a></p><h4>Run an example (JS/TS) 🟢</h4><pre>async function latestBlock() {<br><br>const apiUrl = &#39;https://rest.evmos-mainnet.public.lavanet.xyz/cosmos/base/tendermint/v1beta1/blocks/latest&#39;;<br><br>const restOptions = {<br>      method: &#39;GET&#39;,<br>      headers: { &#39;Content-Type&#39;: &#39;application/json&#39; },<br>    };<br><br>const rawResult = await fetch(<br>  apiUrl,<br>  restOptions,<br>);<br><br>const result = await rawResult.json();<br><br>console.log(result);<br>}<br><br>(async () =&gt; {<br>    await latestBlock();<br>  })();</pre><p>nodeURL — This example uses our REST endpoint with the v1beta1/blocks/latest API. To learn more about how Lava implements APIs, check out our <a href="https://docs.lavanet.xyz/evmos#specification-?utm_source=accessing-evmos-iprpc&amp;utm_medium=website&amp;utm_campaign=evmos-iprpc">Evmos specification file</a>.</p><h4>Result 🏁</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MCsj80KY_Sr5VR3jDrsgwA.gif" /></figure><h3>Access through LavaSDK or Gateway 🌋</h3><p>Evmos ipRPC is offered to the entire community as a public good! For those whose needs exceed what is available via our amenable ipRPC endpoints, we recommend the use of Lava Gateway. Lava Gateway provides free-to-use endpoints with higher rate limits that offer all of the same benefits of the Lava network.</p><h4><strong>Sign Up &amp; Create Project</strong></h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fr94iTbU7p4c%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dr94iTbU7p4c&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fr94iTbU7p4c%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f19a7ebfaf191a9e4f9429911c939ca/href">https://medium.com/media/9f19a7ebfaf191a9e4f9429911c939ca/href</a></iframe><h4><strong>Decide whether you want to use Front End, Back End, or CLI 🚀</strong></h4><h4>Command-Line 🖥️</h4><ul><li>Retrieve your endpoint from the Gateway ↗️</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*wrijt8f5cxhV_jlweXsplw.png" /></figure><ul><li>A simple curl command can verify working parts! ☑️</li></ul><pre>curl -X GET -H “Content-Type: application/json” https://your_endpoint_here/cosmos/base/tendermint/v1beta1/blocks/latest</pre><h4>Backend 💿</h4><p>To run on the back end, use<strong><em> </em></strong>npm install @lavanet/lava-sdk dotenv</p><p>Then create a<em> .js </em>file with the following:</p><pre>const { LavaSDK } = require(&quot;@lavanet/lava-sdk&quot;)<br>require(&quot;dotenv&quot;).config();<br><br>async function useEvmosTestnet() {<br><br>  const evmosTestnet = await new LavaSDK({<br>    privateKey: process.env.PRIVATE_KEY,<br>    chainID: &#39;EVMOS&#39;,<br>    rpcInterface: &#39;rest&#39;<br>  });<br><br>  const evmosBlockResponse =  await evmosTestnet.sendRelay({<br>    method: &quot;GET&quot;,<br>    url: &quot;/node_info&quot;,<br>  });<br><br>  console.log(evmosBlockResponse);<br>}<br><br>(async () =&gt; {<br>    await useEvmosTestnet();<br>  })();</pre><p>🔍<strong>NOTE: </strong>This example makes use of dotenv to obscure a user’s private key in code. It is best practice to implement environmental variables rather than disclosing secrets in code 🤫(<em>process.env.PRIVATE_KEY</em>)‍</p><h4>Frontend 📀</h4><p>Usage on the front end requires the use of badges to obscure PrivateKeys! This is most easily accomplished through the <a href="https://gateway.lavanet.xyz/?utm_source=accessing-evmos-iprpc&amp;utm_medium=website&amp;utm_campaign=evmos-iprpc">Lava Gateway</a>!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FlClA7hGLts0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DlClA7hGLts0&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d4e3a393ca0878d4a135cc35cb20241/href">https://medium.com/media/4d4e3a393ca0878d4a135cc35cb20241/href</a></iframe><h3>Conclusion</h3><p>Lava aggregates and routes RPC requests to a network of node providers. Build with lightning fast, resilient connections to 20+ chains. Learn more about how Lava supports <a href="https://docs.lavanet.xyz/evmos?utm_source=accessing-evmos-iprpc&amp;utm_medium=website&amp;utm_campaign=evmos-iprpc">Evmos!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ece3a0b3f8ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial: How-to Cosmos Pt. 4- Building your first application with Cosmjs]]></title>
            <link>https://medium.com/lava-network/tutorial-how-to-cosmos-pt-4-building-your-first-application-with-cosmjs-87c5db9f3cdf?source=rss-c0bb8c66f36f------2</link>
            <guid isPermaLink="false">https://medium.com/p/87c5db9f3cdf</guid>
            <category><![CDATA[lava-network]]></category>
            <category><![CDATA[web3-development]]></category>
            <category><![CDATA[cosmos-hub]]></category>
            <category><![CDATA[cosmjs]]></category>
            <category><![CDATA[cosmos-network]]></category>
            <dc:creator><![CDATA[KagemniKarimu]]></dc:creator>
            <pubDate>Sun, 04 Jun 2023 11:54:05 GMT</pubDate>
            <atom:updated>2023-06-06T13:06:44.606Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>We return to our “How To Cosmos&quot; blog series. To see the previous installment in this series </em></strong><a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-3-sending-a-signed-tx-on-cosmos-hub-using-cosmjs-bd273381440d"><strong><em>click here</em></strong></a><strong><em>!</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EV76ybytYuUQaMC_tqJPug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*PVocc5dXGycM0G-X" /><figcaption>Check out the Github Repository with the complete version of this project: <a href="https://github.com/KagemniKarimu/cosmjs-master-app-template">KagemniKarimu/cosmjs-master-app-template</a></figcaption></figure><p>If you’ve been following these tutorials, you should have some base awareness of <a href="https://github.com/cosmos/cosmjs">Cosmjs</a> and its capabilities already. In addition to being considered an SDK of its own, Cosmjs can actually be considered a minimal JavaScript/TypeScript API for <a href="https://github.com/cosmos/cosmos-sdk/blob/v0.41.0/docs/intro/overview.md">CosmosSDK</a>. The main package we’ll use in this tutorial is @cosmjs/stargate , which is actually a client library of Cosmos SDK and our primary engine for driving transactions and reading blockchain data.</p><p>In this tutorial, we’ll build a small example app which checks TxHashes and Wallet Addresses and prints out results to the browser. We’ll start by cloning a <a href="https://react.dev/">React.js</a> web application built using <a href="https://mui.com/">MaterialUI</a> . From there, we will use Cosmjs to build a fully functioning web application with two primary features:</p><ul><li>check the balance on any wallet on the Cosmos Hub Testnet (COS5T)</li><li>give a description of any COS5T Transaction Hash (Tx Hash)</li></ul><blockquote>Before we begin, a note on this: This is a small step in the direction of dApp building. However, in the strictest sense, I hesitate to use the term dApp to describe what we build. Although our backend is technically RPC nodes on the blockchain which delivers our data, there is no use of smart contracts to execute our code — which is part and parcel of many definitions of dApps.</blockquote><p>In order to complete the following tutorial, you’ll need:<br> ✅ git [<a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">install guide</a>]<br> ✅ Node.js v18 + [<a href="https://nodejs.org/en/download">download</a>]<br> ✅ Cosmos Wallet with funds loaded on Cosmos Hub [<a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-1-building-a-cosmos-wallet-53155c94f737">guide</a>]<br> ✅ A completed transaction on Cosmos Hub Testnet (COS5T) [<a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-3-sending-a-signed-tx-on-cosmos-hub-using-cosmjs-bd273381440d">guide</a>]<br> ✅ COS5T RPC node URL [<a href="https://gateway.lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+4">accessible from Lava gateway</a>]</p><h3>1. Clone the Repo to Get Started</h3><p>For starters, we’re going to reference the git repository linked <a href="https://github.com/KagemniKarimu/cosmjs-master-app-template">here</a>. To save us time, I prepared a repo with all dependencies set up and a pre-configured React environment to save you several steps! Unfortunately, at of the time of this tutorial, Cosmjs has dependencies which are <a href="https://github.com/cosmos/cosmjs/issues/992">incompatible</a> with create-react-app. For fans of quick starts, this repo is about as good as it gets for now! Feel free to fork to track your own changes.</p><p>Let’s clone the repository:</p><pre>git clone https://github.com/KagemniKarimu/cosmjs-master-app-template.git</pre><p>The default branch main gives us the base application minus all the modifications we’ll make. It gives us React, Cosmjs, MaterialUI, and some boilerplate so we can get straight into making our application fully featureful.</p><p>The branch complete has our fully functional web application available. If you want to skip ahead to the end to see what we build you can use git checkout complete . Otherwise, at any point in this tutoiral, you can use the complete branch to investigate how your code should look!</p><p>Let’s go ahead and ensure all of our dependencies from our package files are installed. Ensure you’re in the directory of cosmjs-master-app-template and enact an install:</p><pre>npm install</pre><h3>2. Activate Stargate</h3><p>Let’s go ahead and uncomment Lines 2 and Lines 5-21 . Delete the // , /* and */ respectively.</p><pre><br>// UNCOMMENT THIS import { StargateClient } from &quot;@cosmjs/stargate&quot;<br><br>//UNCOMMENT BELOW<br>      useEffect(() =&gt; {<br>        connectStargate();<br>      }, []);<br><br><br>    const connectStargate = async () =&gt; {<br>        try {<br>            const stargateClient = await StargateClient.connect(<br>              &#39;RPC_ENDPOINT_URL_HERE&#39;<br>            );<br>            setClient(stargateClient);<br>            console.log(&quot;CosmJS Stargate Connected @&quot;,await stargateClient.getChainId());<br>          } catch (error) {<br>            console.error(&#39;Error connecting to Stargate:&#39;, error);<br>          }<br>      };<br><br></pre><p>On line 13 we need to replace RPC_ENDPOINT_URL_HERE with the URL to our RPC Node. It is important to use an RPC Endpoint which is both Cosmos Hub Testnet (COS5T) and TendermintRPC. Stargate expects a TendermintRPC endpoint and will throw errors if you try another type of endpoint. If you don’t have this handy, don’t worry! You can always get them easily from the <a href="https://gateway.lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+4">Lava Gateway</a>.</p><p>We now have an app that can connect to Cosmos Hub Blockchain and retrieve information! To test, simply run npm start . The app will launch in your browser hosted locally. You can inspect your browser console and verify that you see CosmJS Stargate Connected @ theta-testnet-001 logged. This lets you know that our connection was successful!</p><h3>3. Create the App Logic</h3><p>Once we have Stargate working and functioning, we’ll need to add some application logic to make our application actually do something!</p><p>The first thing is we need to import useState from React. Modify our Line 1 of App.js to look like this:</p><pre>import React, { useEffect, useState } from “react”;</pre><p>This allows us to pass around states from component to component once we’ve collected some user input. It will come in handy later. For now, let’s specify those states within our App const:</p><pre>    const [client, setClient] = useState();<br>    const [balances, setBalances] = useState([]);<br>    const [transactions, setTransactions] = useState([]);</pre><p>Staying within our App const , let’s create some async functions that call on our client to get balances and get tx info:</p><pre>      const handleGetBalance = async (address) =&gt; {<br>        if (client) {<br>          try {<br>            const balances = await client.getAllBalances(address);<br>            setBalances(balances);<br>          } catch (error) {<br>            console.error(&quot;Error retrieving balances:&quot;, error);<br>          }<br>        } else {<br>          console.log(&quot;Stargate client is not available&quot;);<br>        }<br>      };<br><br>      const handleGetTx = async (hash) =&gt; {<br>        if (client) {<br>          try {<br>            const tx = await client.getTx(hash);<br>            setTransactions([tx]);<br>          } catch (error) {<br>            console.error(&quot;Error retrieving transaction:&quot;, error);<br>          }<br>        } else {<br>          console.log(&quot;Stargate client is not available&quot;);<br>        }<br>      };</pre><p>These functions implement the basic logic of calling our initialized Stargate client to getAllBalancesand getTx . The outcome of these calls are stored in our balances and [tx] states, respectively. The functions themselves will be passed as props to our React components that are called whenever a button is pushed.</p><h3>4. Create the Necessary Components</h3><p>A component is a piece of the user interface which is rendered by React with its own logic and appearance. We need several components for the user to be able to input data. To learn more about how React works click <a href="https://react.dev/learn">here</a>.</p><p>We’re going to make two components!</p><ol><li>WalletAddressForm stored in WalletInput.js</li><li>TxHashForm stored in TxInput.js</li></ol><p>Let’s start by making the files! At our app’s root directory, let’s work:</p><pre>touch ./src/components/WalletInput.js<br>touch ./src/components/TxInput.js</pre><h4>WalletInput.js</h4><p>Copy and paste the following code into ./src/components/WalletInput.js</p><pre>import { TextField, Button } from &#39;@mui/material&#39;;<br>import React, { useState } from &#39;react&#39;;<br><br>const WalletAddressForm = ({ onGetBalance }) =&gt; {<br>  const [value, setValue] = useState(&quot;&quot;);<br><br>  const handleChange = (event) =&gt; {<br>    setValue(event.target.value);<br>  };<br><br>  const handleSubmit = (event) =&gt; {<br>    event.preventDefault();<br>    onGetBalance(value);<br>  };  <br>  <br>  <br>    return (<br>    &lt;center&gt;<br>      &lt;form onSubmit={handleSubmit}&gt;<br>        &lt;TextField<br>          label=&quot;cosmos address&quot;<br>          value={value}<br>          onChange={handleChange}<br>        /&gt;<br>        &lt;Button variant=&quot;contained&quot; type=&quot;submit&quot;&gt;<br>          Get Balance<br>        &lt;/Button&gt;<br>      &lt;/form&gt;<br>    &lt;/center&gt;<br>    );<br>  };<br><br>  export default WalletAddressForm;</pre><p>Let’s make sure this is accessible for when we build our UI; add this line to our imports at the top of App.js:</p><pre>import WalletAddressForm from &#39;./components/WalletInput.js&#39;</pre><h4>TxInput.js</h4><p>Copy and paste the following code into ./src/components/TxInput.js</p><pre>import { TextField, Button } from &#39;@mui/material&#39;;<br>import React, { useState } from &#39;react&#39;;<br><br><br>const TxHashForm = ({ onGetTx }) =&gt; {<br>    const [value, setValue] = useState(&#39;&#39;);<br>  <br>    const handleChange = (event) =&gt; {<br>      setValue(event.target.value);<br>    };<br><br>    const handleSubmit = (event) =&gt; {<br>      event.preventDefault();<br>      onGetTx(value);<br>    };<br>  <br>    return (<br>      &lt;form onSubmit={handleSubmit}&gt;<br>        &lt;TextField<br>          label=&quot;tx hash&quot;<br>          value={value}<br>          onChange={handleChange}<br>        /&gt;<br>        &lt;Button variant=&quot;contained&quot; type=&quot;submit&quot;&gt;<br>          Query Tx<br>        &lt;/Button&gt;<br>      &lt;/form&gt;<br>    );<br>  };<br><br>  export default TxHashForm;</pre><p>Once again, we need to make sure we import what we’ve just created for further use:</p><pre>import TxHashForm from &quot;./components/TxInput.js&quot;;</pre><h3>5. Furnish the UI</h3><p>We’re almost there. Let’s revisit the return statement in the App constof App.js. Here, we need to feed React some JSX that will help render the components we created so that they can be seen and interacted with via browser. This is really the final step in making our app functional.</p><p>First we need to add some instances of our components. On the underside of where it says &lt;h1&gt;The Beginning of a Masterful App!&lt;/h1&gt; insert the following:</p><pre>&lt;WalletAddressForm onGetBalance={handleGetBalance} /&gt;<br>&lt;br /&gt;<br>&lt;TxHashForm onGetTx={handleGetTx} /&gt;</pre><p>This gives us a way to collect our inputs! Specifically, it points the Forms at the handler functions we wrote in our application logic earlier. Now, we just need to display outputs.</p><p>First, let’s do balances:</p><pre>      &lt;div&gt;<br>        &lt;h2&gt;Balances:&lt;/h2&gt;<br>        &lt;ul&gt;<br>          {balances.map((balance, index) =&gt; (<br>            &lt;li key={index}&gt;<br>              {balance.amount} {balance.denom}<br>            &lt;/li&gt;<br>          ))}<br>        &lt;/ul&gt;<br>      &lt;/div&gt;</pre><p>This will effectively list all of our balances {amount, denom} on our browser page!</p><p>Next, let’s do transactions:</p><pre>      &lt;br /&gt;<br>      &lt;div&gt;<br>        &lt;h2&gt;Transactions:&lt;/h2&gt;<br>        &lt;ul&gt;<br>          {transactions.map((tx, index) =&gt; (<br>            &lt;li key={index}&gt;{JSON.stringify(tx)}&lt;/li&gt;<br>          ))}<br>        &lt;/ul&gt;<br>      &lt;/div&gt;</pre><p>This will prettify and print the JSON which is returned when we find a transaction! It still won’t be perfectly friendly to the human eye, but it’ll be good enough for our purposes!</p><p>Let’s enclose our entire operation in &lt;center&gt; &lt;/center&gt; tags if we haven’t already! We want to be neat after all. 😄</p><h3>6. Test</h3><p>Now, to the fruits of our many labors! Let’s see how this application runs and functions. If you don’t already have it running, restart the program:</p><pre>npm start</pre><p>Pull your cosmos address from any previous tutorial and give it a go. If you don’t remember your address and need Cosmos addresses to pull from try typing gaiad keys list | grep address into the command line. It should output a list of usable keys! If you don’t have gaiad installed, you can use an address from below:</p><pre>  address: cosmos15dgrn5rl8eah6s3lcjm5gjsn78w6kg5plmn6ml<br>  address: cosmos1qxpu7dc0vz2cha0rucdezevejvcwltw4ytqyd2</pre><p>You’ll also need to pull a transaction for your test! You can use either address above or one of your own choosing and type gaiad q txs — events ‘message.sender=&lt;address&gt;’ | grep txhash . Of course you’ll need to replace &lt;address&gt; with the actual address you’ll use. This will return you some txhashes (if they exist on the given address!). If you haven’t made any transactions yet, you can use one of mine!</p><pre>  txhash: 08E2A44573E9FB241FCD91F9E5C2951B812B0DBEC0C0D08D57E3787B5949BE64<br>  txhash: 496BCE70E3515503F25C964D33347BC9F217300DEF6DA1793804D249D05927BC<br>  txhash: 0F4843D34855FEB18B6DBC07396A97099D8B73A2E37EC1530391D4A44A9AEE72</pre><h3>🟢 Once you’ve tested both fields, your final screen should look like what’s displayed below!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iAXffr984Ldt_oYlIVWSUg.png" /></figure><p>✔️Success! That’s all on this one. If you had any struggles with this, don’t worry. It was a lot to follow! Check out the supplementary resources and don’t hesitate to reach out. Remember to git checkout complete if you want to compare your final product to mine!</p><p>Next time, we’ll be digging even deeper with more example functionality. Additionally, we’re inching our way towards working with CosmWASM :). Remember, there’s always a lot more you can do on this — see can you edit your application to send transactions as we did in the last tutorial!</p><h3>Further Resources</h3><p><strong>🚪</strong><a href="https://gateway.lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+4"><strong>https://gateway.lavanet.xyz</strong></a></p><p><strong>💻</strong><a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-1-building-a-cosmos-wallet-53155c94f737"><strong>How to Cosmos Part 1</strong></a><strong><br>💻</strong><a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-2-building-and-signing-a-tx-on-cosmos-hub-using-gaiad-c380fb73882c"><strong>How to Cosmos Part 2</strong></a><strong><br>💻</strong><a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-3-sending-a-signed-tx-on-cosmos-hub-using-cosmjs-bd273381440d"><strong>How to Cosmos Part 3</strong></a></p><p><strong>⚛️ </strong><a href="https://tutorials.cosmos.network/tutorials/7-cosmjs/"><strong>Official CosmJs Tutorial</strong></a><strong><br>⚛️ </strong><a href="https://cosmos.github.io/cosmjs/"><strong>Official CosmJs documentation</strong></a></p><h3>About the Author🧑🏿‍💻</h3><p><a href="https://twitter.com/KagemniKarimu">KagemniKarimu</a> is current Developer Relations Engineer for <a href="https://lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+4">Lava Network</a> and former Developer Relations at Skynet Labs. He’s a self-proclaimed Rubyist, new Rust learner, and friendly Web3 enthusiast who entertains all conversations about tech. Follow him on <a href="https://twitter.com/KagemniKarimu">Twitter</a> or say hi to him on Lava’s <a href="https://discord.gg/Tbk5NxTCdA">Discord</a> where he can be found lurking.</p><h3>About Lava 🌋</h3><p><a href="https://lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+4">Lava</a> is a decentralized network of top-tier API providers that developers can subscribe to for access to any blockchain. Providers are rewarded for their quality of service, meaning apps and users get maximum speed, data integrity and uptime. RPC requests are routed to multiple endpoints at once, meaning anyone can privately query or send transactions on-chain, while being matched to the most performant and reliable providers.</p><p>We help developers build web3 apps on any chain, with reliable, performant and decentralized node infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87c5db9f3cdf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-4-building-your-first-application-with-cosmjs-87c5db9f3cdf">Tutorial: How-to Cosmos Pt. 4- Building your first application with Cosmjs</a> was originally published in <a href="https://medium.com/lava-network">Lava Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial : How-to Cosmos Pt. 3- Sending a Signed Tx on Cosmos hub using Cosmjs]]></title>
            <link>https://medium.com/lava-network/tutorial-how-to-cosmos-pt-3-sending-a-signed-tx-on-cosmos-hub-using-cosmjs-bd273381440d?source=rss-c0bb8c66f36f------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd273381440d</guid>
            <category><![CDATA[web3-development]]></category>
            <category><![CDATA[cosmjs]]></category>
            <category><![CDATA[lava-network]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[cosmos-network]]></category>
            <dc:creator><![CDATA[KagemniKarimu]]></dc:creator>
            <pubDate>Mon, 29 May 2023 10:01:44 GMT</pubDate>
            <atom:updated>2023-05-29T10:01:44.238Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tutorial : How-to Cosmos Pt. 3- Sending a Signed Tx on Cosmos hub using Cosmjs</h3><p><strong><em>Hello Cosmonauts! ⚛️</em></strong></p><p><strong><em>We return to our blog series “Cosmos How-Tos.” To see the previous installment in this series </em></strong><a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-2-building-and-signing-a-tx-on-cosmos-hub-using-gaiad-c380fb73882c"><strong><em>click here!</em></strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tmx-r51HQG1jEH4H_IJp9g.png" /></figure><p>CosmJS is a modular TypeScript/JavaScript library of npm packages for developers to use in front end and back end dApp development. Cosmjs consists of 21 different <a href="https://www.npmjs.com/org/cosmjs?activeTab=packages">packages</a> which can be imported separately for individual use; it is highly modular and uses only a clean dependency tree. Although it is a part of the CosmosSDK — it is more geared towards users who will be building more ‘traditional’ web apps and dApps that would have front-ends written for the browser.</p><p>According to the documentation available on Cosmjs, the most commonly used packages are @cosmjs/stargate and @cosmjs/encoding, as many basic feats on a dApp can be accomplished using only these two packages. In practice, you’ll find that the packages you decide to import vary greatly depending on the needs of a given project. There is even variance amongst which packages are best to use to accomplish the same thing!</p><p>In this tutorial, I will walk you through the process of building and signing a transaction on the Cosmos Hub using Cosmjs. We assume you already have Node.js installed on your system. If not, please visit the Node.js website (<a href="https://nodejs.org/">https://nodejs.org/</a>) to download and install the appropriate version for your operating system. Also, it is assumed that you have some familiarity with the Cosmos ecosystem! Because of this, we highly recommend that you start from <a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-1-building-a-cosmos-wallet-53155c94f737">Part 1</a> or <a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-2-building-and-signing-a-tx-on-cosmos-hub-using-gaiad-c380fb73882c">Part 2</a> of this series before beginning this tutorial — but if you insist on continuing you must do so at your own risk!</p><p>Before beginning, there are a number of packages that you should be familiar with in Cosmjs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*AFBMw5ehvhOUNIRy7CIzkw.png" /></figure><p>A complete look at all the implemented methods and interfaces is available here: <a href="https://cosmos.github.io/cosmjs/">https://cosmos.github.io/cosmjs/</a></p><h4>You’ll need the following to continue</h4><p>✅ <a href="https://nodejs.dev/en/learn/how-to-install-nodejs/">node.js</a> installed on a Linux machine</p><p>✅ Familiarity with basic concepts such as those covered in v1 &amp; v2 of this series</p><p>✅ Access to a funded wallet/wallet(s) on Cosmos Hub Testnet</p><h3>1. Installing Cosmjs</h3><p>First, create a new directory for your project and navigate to it using the terminal:</p><pre>mkdir cosmos-sendtx<br>cd cosmos-sendtx</pre><p>Now, initialize a new Node.js project:</p><pre>npm init -y</pre><p>Next, install the required Cosmjs packages:</p><pre>npm install @cosmjs/stargate @cosmjs/proto-signing @cosmjs/encoding @cosmjs/amino</pre><p>You can investigate the package-lock.json file to learn more about the installed dependencies and their structure.</p><h3>2. Setup Your Environment</h3><p>From the command line within the created directory, create a new JavaScript file called cosmos-tx.js:</p><pre>touch cosmos-tx.js</pre><h4>Basic Requirements</h4><p>At the top of your file, make sure to require a couple of dependencies. We’re keeping it rather light and relying only on a few pieces from cosmjs/stargate, cosmjs/proto-signing, cosmjs/encoding, and cosmjs/amino. Add the following to the top of your cosmos-tx.js file:</p><pre>const { SigningStargateClient, coins, GasPrice } = require(‘@cosmjs/stargate’);<br>const { DirectSecp256k1Wallet } = require(‘@cosmjs/proto-signing’);<br>const { toBech32 } = require(‘@cosmjs/encoding’);<br>const { rawSecp256k1PubkeyToRawAddress } = require(“@cosmjs/amino”);</pre><p>SigningStargateClient coins and GasPrice will be used to formulate, sign and broadcast our transaction. DirectSecp256k1Wallet will be used to handle our keys. Finally, toBech32 and rawSecp256k1PubkeyToRawAddress are used simply to make our addresses human readable!</p><h4>Environmental Variables</h4><blockquote>It is very, very bad practice to load any part of your seed phrase/private key into your code plain text. If anyone is able to see your code for any reason(s), they will be able to easily snoop your keys and control your wallet. Remember 🔑 Not Your Key = Not Your Crypto ❗ As such, we will be avoiding this approach entirely and using an Environmental Variables combined with the dotenv package to accomplish the feat. Please note that extracting secrets from code is best practice, but you should be sure not to share the .env file we create with any collaborators and never push it to a public repository.</blockquote><p>First, we need to make sure dotenv is installed. If you’re unaware, <a href="https://www.npmjs.com/package/dotenv">dotenv</a> is a very useful zero-dependency module that can be used to load environment variables from a .env file and then make them available in your Node.js application through the [process.env]object. This can be particularly helpful when you want to keep sensitive information, such as seed phrases, API keys, or database passwords, out of your code and stored securely in a separate file. Let’s install it with the following command input to the terminal from our current directory:</p><pre> npm install dotenv</pre><p>At the top of cosmos-tx.js, just beneath your other requires, please add the following:</p><pre><br>require(‘dotenv’).config();</pre><p>This command initializes dotenv and causes your project to look for your .env file containing variables.</p><p>It should go without saying that we need to make our .env file now! Make sure you’re still in your proper project directory, then from the terminal enter the following:</p><pre>touch .env</pre><blockquote>🟢If you’ve completed the past tutorials, you’ll be able to easily use gaiad to get your pre-loaded wallet. You may need to verify that your wallet has a substantial balance if you’ve already done a large transaction and it’s best practice to use a wallet that has already been initialized / received funds on chain.</blockquote><p>Now that we’ve created our .env, you’ll use the following command to pull your private key from gaiad! Be careful, this is something that you cannot share anywhere — as it means instant and irrevocable access to your funds. 🔒</p><pre>gaiad keys export &lt;key_name&gt; --unarmored-hex --unsafe</pre><p>⚠️ If you’ve forgotten your key_name, don’t forget our trusty gaiad keys list command from previous tutorials. You also can check the balance to ensure this wallet has the funds necessary to send a transaction. Be sure your wallet has a balance by running gaiad query bank balances &lt;account&gt;.</p><p>When running the — unarmored-hex flag, gaiad will try to warn you that you’re doing an unsafe operation. Type y and press ENTER to continue. Once you have this export, copy and paste it into your .env file as shown below:</p><pre>PRIVATE_KEY=&lt;insert your pasted hex here&gt;</pre><p>Normally, within Cosmjs and broadly across Crypto ecosystems, people use the mnemonic to access their wallet but we’re going this route to illustrate how to still use your key, even without a mnemonic.</p><blockquote>🚧If you have not completed past tutorials, you’ll have to create a wallet within your code and get it funded through the Cosmos Hub Testnet faucet. This is a slightly different process than the route we took. You can use the method implemented <a href="https://github.com/b9lab/cosmjs-sandbox/blob/file-preparation/generate_mnemonic.ts">here</a>. For a simpler path to success, I again encourage you to revisit <a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-1-building-a-cosmos-wallet-53155c94f737">Part 1</a> and <a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-2-building-and-signing-a-tx-on-cosmos-hub-using-gaiad-c380fb73882c">Part 2</a> of this series.</blockquote><h4>Constants</h4><p>There are a few constants that are needed to build out your transaction (Tx).</p><p>First, let’s fetch an RPC endpoint from the <a href="https://accounts.lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+3">Lava gateway</a>. If you’ve followed our other tutorials, this step should be straight forward. If not, check out the <a href="https://docs.lavanet.xyz/gateway-getting-started?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+3">Getting Started with the Lava Gateway guide</a>. Make sure you go grab the RPC endpoint for the Cosmos Hub <em>Testnet</em>! The Stargate client always connects to a <em>Tendermint RPC</em> endpoint — so we also need to be sure to select that one, as well.</p><pre>//RPC info<br>const rpcEndpoint = “https://lavagatewaycosmoshubtestnetaddress/&quot;</pre><p>You’ll also need to add information about your sender and receiver. Who is sending to who? We will take this step to invoke our sender’s private key pulled from gaiad. All that’s needed is process.env.PRIVATE_KEY. Notice that our private key never appears in our code 😎👍🏿. This means all we have to do to change the sender is edit our .env file!</p><p>Of course, you’ll need a valid recipient in order to carry out this transaction. If you’re at a loss for who to send your tokens to — feel free to use my address cosmos15dgrn5rl8eah6s3lcjm5gjsn78w6kg5plmn6ml . 😄</p><pre>//Sender &amp; Receiver info<br>const receiver = “&lt;cosmos address&gt;”<br>const senderPrivateKey = process.env.PRIVATE_KEY;</pre><p>In addition to, who we’re sending to and from, we need a little more information about the transaction itself. That is, we need to determine a gasPrice and an amount to send!</p><pre>//Tx info <br>const amount = coins(‘100000’, “uatom”); <br>const gasPrice = GasPrice.fromString(“0.025uatom”); <br>const txOptions = { gasPrice };</pre><h3>3. Building, Signing and Sending the Tx</h3><p>Now, we can implement the major logic for our program. Unlike our use of gaiad we don’t really need to build the transaction. We can just spell it out in code!</p><pre>//Tx function<br>(async () =&gt; {<br> <br> //Acquire our Sender from the PrivateKey, Connect our Client, &amp; Get our Chain ID<br> const sender = await DirectSecp256k1Wallet.fromKey(Buffer.from(senderPrivateKey,&#39;hex&#39;));<br>  const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, sender, txOptions);<br> const chainID = await client.getChainId();<br><br> //Print Basic Tx Info to Console as a Sanity Check<br> console.log(&quot;Connected Chain_ID: &quot;, chainID);<br> console.log(&quot;From Sender: &quot;, toBech32(&quot;cosmos&quot;,rawSecp256k1PubkeyToRawAddress(sender.pubkey)));<br> console.log(&quot;To Receiver: &quot;, receiver);<br> console.log(&quot;Tx Amount &quot;, amount);<br><br> //Grab Account Information of Sender from Chain - should match From Sender:<br> const [senderAccount] = await sender.getAccounts();<br><br> // Send Tokens with Auto Gas Fees and Memo Text<br> const result = await client.sendTokens(senderAccount.address, receiver, amount,&quot;auto&quot;,&quot;sending a signedTx with Cosmjs&quot;);<br>  console.log(&#39;Transaction result:&#39;, result);<br>})();</pre><p>Let’s save and run our program to see what happens! Enter the following into the terminal:</p><pre>node cosmos-tx.js</pre><p>🟢If we’ve succeeded our output should look something like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZvdBGpc33bc7pA5iSoIztA.png" /><figcaption>Success!!</figcaption></figure><p>That’s it! You just sent your first transaction using Cosmjs. There’s so much more to explore! However, this is a great start which illustrates the possibilities. 🙂</p><p>Until next time, friends! Up next, we may delve further into Cosmjs with an example app or even take a peek at smart contract development! 👋🏿 Thanks for following along!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/64/0*PVocc5dXGycM0G-X" /><figcaption>Check out the Github Repository with the complete version of this project: <a href="https://github.com/KagemniKarimu/cosmjs-sendtx">KagemniKarimu/cosmjs-sendtx</a></figcaption></figure><h3>Further Resources</h3><p><strong>🚪</strong><a href="https://accounts.lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+3"><strong>https://gateway.lavanet.xyz</strong></a></p><p><strong>💻</strong><a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-1-building-a-cosmos-wallet-53155c94f737"><strong>How to Cosmos Part 1</strong></a></p><p><strong>💻</strong><a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-2-building-and-signing-a-tx-on-cosmos-hub-using-gaiad-c380fb73882c"><strong>How to Cosmos Part 2</strong></a></p><p><strong>⚛️ </strong><a href="https://tutorials.cosmos.network/tutorials/7-cosmjs/"><strong>Official CosmJs Tutorial</strong></a></p><p><strong>⚛️ </strong><a href="https://cosmos.github.io/cosmjs/"><strong>Official CosmJs documentation</strong></a></p><h3>About the Author🧑🏿‍💻</h3><p><a href="https://twitter.com/KagemniKarimu">KagemniKarimu</a> is current Developer Relations Engineer for <a href="https://lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+3">Lava Network</a> and former Developer Relations at Skynet Labs. He’s a self-proclaimed Rubyist, new Rust learner, and friendly Web3 enthusiast who entertains all conversations about tech. Follow him on <a href="https://twitter.com/KagemniKarimu">Twitter</a> or say hi to him on Lava’s <a href="https://discord.gg/Tbk5NxTCdA">Discord</a> where he can be found lurking.</p><h3>About Lava 🌋</h3><p><a href="https://lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+3">Lava</a> is a decentralized network of top-tier API providers that developers can subscribe to for access to any blockchain. Providers are rewarded for their quality of service, meaning apps and users get maximum speed, data integrity and uptime. RPC requests are routed to multiple endpoints at once, meaning anyone can privately query or send transactions on-chain, while being matched to the most performant and reliable providers.</p><p>We help developers build web3 apps on any chain, with reliable, performant and decentralized node infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd273381440d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-3-sending-a-signed-tx-on-cosmos-hub-using-cosmjs-bd273381440d">Tutorial : How-to Cosmos Pt. 3- Sending a Signed Tx on Cosmos hub using Cosmjs</a> was originally published in <a href="https://medium.com/lava-network">Lava Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial : How-to Cosmos Pt. 2- Building and Signing a Tx on Cosmos hub using Gaiad]]></title>
            <link>https://medium.com/lava-network/tutorial-how-to-cosmos-pt-2-building-and-signing-a-tx-on-cosmos-hub-using-gaiad-c380fb73882c?source=rss-c0bb8c66f36f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c380fb73882c</guid>
            <category><![CDATA[cosmos-network]]></category>
            <category><![CDATA[cosmos-hub]]></category>
            <category><![CDATA[lava-network]]></category>
            <category><![CDATA[web3-development]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <dc:creator><![CDATA[KagemniKarimu]]></dc:creator>
            <pubDate>Tue, 16 May 2023 08:19:02 GMT</pubDate>
            <atom:updated>2023-05-29T12:38:36.707Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tutorial : How-to Cosmos Pt. 2- Building and Signing a Tx on Cosmos hub using Gaiad</h3><p><strong><em>Hello Cosmonauts! ⚛️ <br>We return to our “Cosmos How-Tos” blog series 🎓🎓</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6BhBKIbTahvlEiXdj6I9vQ.png" /></figure><p>If you did not see our <a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-1-building-a-cosmos-wallet-53155c94f737">previous tutorial</a> in this series, it’s pretty essential that you go check it out. This series is intended to introduce someone to Cosmos with a hands-on approach. For those unaware and uninitiated, Cosmos is a network of interconnected appchains that focus on inter-blockchain communication with a common core. Popular projects such as <a href="https://junonetwork.io/">Juno</a>, <a href="https://osmosis.zone/">Osmosis</a>, <a href="https://celestia.org/">Celestia</a> and <a href="https://www.lavanet.xyz/">Lava</a> all use Cosmos. Proverbially, Cosmos is one of the ‘Big Four’ for building decentralized applications (dApps) and Smart Contracts with NEAR, Solana, and Ethereum (EVM).</p><p>What’s covered in this tutorial — sending a transaction or Tx — is one of the essential features of participation in the Cosmos ecosystem. Most users only ever accomplish this through the use of a web wallet or dapp UI. Today, we’ll show how to do it from the terminal using a CLI named gaiad. Doing it this way will provide you hands-on insights on how a blockchain works and how transactions on the Cosmos network are formed and verified.</p><p>You’ll need the following to continue</p><p>✅ adminstrator access to a Linux machine with <a href="https://github.com/cosmos/gaia/blob/main/docs/getting-started/installation.md">gaiad installed</a></p><p>✅ a private key which is loaded with <a href="https://discord.com/invite/cosmosnetwork">Testnet funds</a> and accessible via gaiad</p><p>Don’t worry! Both of these steps are well explained in <a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-1-building-a-cosmos-wallet-53155c94f737">Part 1 of this series</a>!</p><h3>1. Ensure your node is connected to an RPC Provider</h3><p>The first step is to <a href="https://accounts.lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+2">make sure you’re connected to RPC</a> — if you’ve done our previous tutorial recently. All you’ll need to do is check the status!</p><pre>gaiad status</pre><p>🟢 If things worked right, you should see output like below!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*H2T6ZXQljhRgOHqMijqOTw.png" /></figure><p>This means that your RPC endpoint is reachable from your gaiad installation. Having properly configured RPC is an essential step to sending our first transaction. You can move onto the next step!</p><blockquote>⚠️NOTE: if your RPC endpoint is unreachable, your terminal may hang. If so, press CTRL+C. You’ll need to return to the <a href="https://accounts.lavanet.xyz/register?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+2">Lava gateway</a> to get an RPC endpoint that you can use. Once you’ve retrieved a working <a href="https://accounts.lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+2">RPC endpoint for the Cosmos Hub</a> (Testnet), then you can continue onto the next step. Having a working RPC is essential to what we do next.</blockquote><blockquote>Once you’ve gotten your URL you can put it in gaiad with the following command, replacing the dummy URL with your own:</blockquote><blockquote>gaiad config node <a href="https://g.w.lavanet.xyz/gateway/cos5t/rpc-http/a43dd98c9ea68afa4f167969f48970bb">https://g.w.lavanet.xyz:443/gateway/cos5t/rpc-http/a43dd98c9ea68afa4f167969f48970bb</a></blockquote><blockquote>Then, type in the following command and see if your terminal hangs again.</blockquote><blockquote>gaiad status</blockquote><blockquote>After doing so, you should get input similar to what was displayed above(🟢) and you can now move onto our next step!</blockquote><h3>2. Verify your Cosmos Wallet address &amp; Balance from the Command Line</h3><p>As you may remember in the last tutorial, you will have created a Cosmos wallet using only command-line input.</p><p>An important step is to verify that this Cosmos wallet is still accessible from your machine. Type the following command:</p><pre>gaiad keys list</pre><p>This will list all the keys available to gaiad at the time of this command. You should get some output that displays your previous address by key_name. It should look like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*iUthLVg66Fi0xwaVkHaEZw.png" /></figure><blockquote>⚠️ If you did not get a print out of names, types, and addresses, please refer to the last tutorial which will guide you through the creation of a new address!</blockquote><p>Next, we need to verify the balance of our address. Copy and paste the string of characters after it says address: and input the following command replacing my address with your own! We’ll use the query bank balances command which will give us information on all the available balances on chain at that address. An example of this should look like:</p><pre>gaiad query bank balances cosmos15dgrn5rl8eah6s3lcjm5gjsn78w6kg5plmn6ml</pre><p>This will return input reporting the specified address’s balance. Behind the scenes gaiad is really asking the RPC node for the address - but that’s neither here nor there!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*d8dgBKDcNyoGYXdKh3TD3g.png" /></figure><p>As you can see, we verify that we have a uatom balance of 1000000 . If you recall, this is from when we used the CosmosHub Testnet faucet. Now that we have verified our balance, we can move onto sending our funds.</p><h3>3. Generate a Tx JSON</h3><p>It’s important to note that if you’re sending it — it must be going somewhere!</p><p>First, let’s make sure we’ve got the correct chain-id. This is akin to making sure we’re operating in the correct universe. You can check where gaiad is pointed using gaiad config chain-id. We want to identify the Theta testnet:</p><pre>gaiad config chain-id theta-testnet-001</pre><p>Our next step is to identify a sender and a receiver . We can use our pubkey address as the sender. If you don’t remember your address, you can always get it using the gaiad keys list command again. For a receiver, feel free to use my address cosmos15dgrn5rl8eah6s3lcjm5gjsn78w6kg5plmn6ml 😉. Of course, you’re always free to build a second key-pair using the same steps you made the first one. Once you have both a sender and receiver, build the transaction using the following format:</p><pre>gaiad tx bank send &lt;sender&gt; &lt;receiver&gt; &lt;amount&gt; --fees=200uatom --generate-only &gt; unsignedTx.json</pre><p>⭕ &lt;sender&gt; field will accept either your address. I use cosmos15dgrn5rl8eah6s3lcjm5gjsn78w6kg5plmn6mlwhich is the pubkey of my wallet titled test1.<br>⭕ &lt;receiver&gt; field is another public key address to send to. You can use cosmos15dgrn5rl8eah6s3lcjm5gjsn78w6kg5plmn6ml which is the public address I created at test1! I’ll use cosmos1qxpu7dc0vz2cha0rucdezevejvcwltw4ytqyd2 which is another address I created at test2.<br>⭕ amount field is parsed as number, then denomination, for short hand &lt;INTdenom&gt; i.e., 1000uatom.</p><p>With our --fees=&lt;amount&gt;tag, we need to specify the amount of fees that will be provided to cover the transaction we are building. It carries this same &lt;INTdenom&gt; format as the amount we send. We’ll choose 200 uatom, which should be sufficient to send at the time of this tutorial.</p><p>It is this --generate-only flag which is crucial. --generate-only let’s gaiad know that we only want to create some output for our transaction, not actually send it! We<strong> could send straightaway </strong>but this gives us a chance to inspect the transaction that we are performing. We use &gt; unSignedTx.json to dump the output into a JSON file in the current directory.</p><blockquote>If you drop the --generate-only tag, gaiad will prompt you to sign automatically, so you can move onto step 6.</blockquote><p>Otherwise, try to cat unSignedTx.json to ensure that the file has been generated by your command. It should contain tx info!</p><h3>4. Sign the TX JSON and validate the signature</h3><p>In order to verify that the transaction is coming from you, you will need to cryptographically sign the Tx JSON that we just generated — this is a fairly simple process which involves identifying the chain-id and the key that you wish to use. Note that if you used the key_name to build the transaction, you can simply double up here. My sign example is below</p><pre>gaiad tx sign --chain-id=&quot;theta-testnet-001&quot; --from=test1 unsignedTx.json &amp;&gt; signedTx.json</pre><p>This will take the unsignedTx.json and put it in a signedTx json signed by test1. gaiad will automatically validate the signatures after signing. After a short pause, go ahead and cat signedTx.json. You should get output similar to the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*v1jbZoEJv9_Qrz6w0YTi6w.png" /></figure><p>Look closely at this message. Notice that as opposed to before — our transaction indicates that there are signatures that have been directly signed. This is a crucial feature of a successful broadcast and one that it’s important to understand. Cryptographic signatures are the basis for a secure blockchain.</p><h3>5. Broadcast the TX JSON using RPC</h3><p>Now, the money!! Let’s send our transaction right away. 💸 Type the following:</p><pre>gaiad tx broadcast signedTx.json</pre><p>Once we do, somewhere in the backdrop, an RPC node (perhaps one served through the Lava gateway) is processing our request. gaiad will attempt to sync and return the txHash after your transaction broadcasts! Make sure you copy it into your clipboard. You will need it for the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*SVccZx4FLH4RJtiFFM9Jlg.png" /></figure><h3>6. Verify the transaction went through</h3><p>The final step is to check the receiver address we used in order to verify the funds went through. We do this to ensure the funds went exactly where we sent them!</p><p>This step is technically optional, as the broadcast command returns a CheckTx response by default. There are two ways we can accomplish this:</p><p>✅We can query the receiver address that we used earlier to see if the balance has changed. Note that blockchains take a moment to make consensus — our transaction may not post instantly.</p><pre>gaiad query bank balances &lt;receiver&gt;</pre><p>✅Secondarily, we can double-check the tx-hash to see if there is any information on chain about the exchange that took place. If we’re too hasty, we may get a tx not found error!</p><pre>gaiad query tx &lt;tx-hash&gt;</pre><p>Did the balance update? 😄You should be able to easily tell whether the transaction did indeed occur. Try comparing balances on both &lt;sender&gt; and &lt;receiver&gt; addresses. You can even try gaiad query account and see what else you might learn. Once you have verified, that’s it! You’ve just sent your first transaction on a blockchain from the command line.</p><p>😅For next time, we’ll show how to do this same process of building and sending a transaction, except programmatically using Cosmjs. We look forward to seeing you in Pt 3 of our series!</p><h3>Further Resources</h3><p>🚪<a href="https://accounts.lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+2">https://gateway.lavanet.xyz</a></p><p>📚 <a href="https://docs.lavanet.xyz/tutorials?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+2">https://docs.lavanet.xyz/tutorials</a></p><p>💻<a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-1-building-a-cosmos-wallet-53155c94f737">How to Cosmos Part 1</a></p><p><strong>⚛️</strong><a href="https://hub.cosmos.network/main/hub-tutorials/gaiad.html">gaiad tutorials</a></p><h3>About the Author🧑🏿‍💻</h3><p><a href="https://twitter.com/KagemniKarimu">KagemniKarimu</a> is current Developer Relations Engineer for <a href="https://lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Referral&amp;utm_campaign=RPC+Uptime+%26+Availability+in%C2%A0Web3">Lava Network</a> and former Developer Relations at Skynet Labs. He’s a self-proclaimed Rubyist, new Rust learner, and friendly Web3 enthusiast who entertains all conversations about tech. Follow him on <a href="https://twitter.com/KagemniKarimu">Twitter </a>or say hi to him on Lava’s <a href="https://discord.gg/Tbk5NxTCdA">Discord</a> where he can be found lurking.</p><h3>About Lava 🌋</h3><p><a href="https://lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Organic+Social&amp;utm_campaign=Cosmos+tutorials&amp;utm_content=Part+2">Lava</a> is a decentralized network of top-tier API providers that developers can subscribe to for access to any blockchain. Providers are rewarded for their quality of service, meaning apps and users get maximum speed, data integrity and uptime. RPC requests are routed to multiple endpoints at once, meaning anyone can privately query or send transactions on-chain, while being matched to the most performant and reliable providers.</p><p>We help developers build web3 apps on any chain, with reliable, performant and decentralized node infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c380fb73882c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lava-network/tutorial-how-to-cosmos-pt-2-building-and-signing-a-tx-on-cosmos-hub-using-gaiad-c380fb73882c">Tutorial : How-to Cosmos Pt. 2- Building and Signing a Tx on Cosmos hub using Gaiad</a> was originally published in <a href="https://medium.com/lava-network">Lava Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RPC Uptime & Reliability in Web3]]></title>
            <link>https://medium.com/lava-network/rpc-uptime-reliability-in-web3-4b13982352f?source=rss-c0bb8c66f36f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b13982352f</guid>
            <dc:creator><![CDATA[KagemniKarimu]]></dc:creator>
            <pubDate>Thu, 04 May 2023 22:02:12 GMT</pubDate>
            <atom:updated>2023-05-08T14:18:22.390Z</atom:updated>
            <content:encoded><![CDATA[<h4>Addressing the elephant in the server room</h4><blockquote>tl;dr — By standard tech industry measures of uptime, the availability of common web2 infra currently exceeds that of common web3 infrastructure like RPCs. Even a small difference in downtime is consequential in highly available production-grade systems. Increasing the availability of RPC will improve adoption of web3.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xUo5USVesCp-e9FMdl1uQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*UuAbCl1wotV-P4CP0Ub1eg.png" /><figcaption>Rise in traffic = collapse in RPC</figcaption></figure><h3>When Reliable RPC for Ethereum, Cosmos Hub and beyond?</h3><p>As mentioned in <a href="https://medium.com/lava-network/web3-developer-rpc-woes-1399be46678">Developer Web3 RPC Woes</a> and <a href="https://medium.com/lava-network/the-web3-rpc-problem-a-diary-reflection-on-cryptos-infrastructure-dilemma-8508a8d3de9f">The Web3 RPC Problem</a>, unreliable RPC is a major painpoint for web3 developers. Unreliable RPC endpoints lead to mission-critical unavailability incidents, poor user experience and usability, and existential-threat-level business risk. There are ample examples in web3 of RPC endpoints pining out or disappearing in the height of need.</p><p>Some examples abound:</p><ul><li>Following a bug in an earlier this year test net release, Solana Foundation’s RPC endpoints went offline. Although this did not impact the network’s ability to produce new blocks, it meant that users had to rely solely on private RPC providers, while public RPC was no longer available. <a href="https://www.theblock.co/post/200018/solana-foundation-rpc-endpoints-go-offline">https://www.theblock.co/post/200018/solana-foundation-rpc-endpoints-go-offline</a></li><li>RPC providers frequently run into catastrophic configuration issues, as for example, when providers on Ledgerwatch’s Erigon project recently experienced issues where their endpoints shut down and the HTTP endpoint URL closed permanently, as recorded in the project’s logs. <a href="https://github.com/ledgerwatch/erigon/issues/3247">https://github.com/ledgerwatch/erigon/issues/3247</a></li><li>An Optimsim airdrop saw the token losing 60% of its value due to a failed airdrop after the anticipatory traffic overloaded their public RPC. s<a href="https://decrypt.co/101768/optimism-token-plummets-hyped-airdrop">https://decrypt.co/101768/optimism-token-plummets-hyped-airdrop</a></li><li>Arbitrum Airdrop experienced a variety of issues due to its high traffic. Scammers, hackers, phishers took full advantage of the event and the main explorer, Arbiscan, began returning “RPC limit exceeded” errors. <a href="https://decrypt.co/124385/arbitrum-foundation-homepage-crashes-as-users-rush-to-claim-arb-tokens">https://decrypt.co/124385/arbitrum-foundation-homepage-crashes-as-users-rush-to-claim-arb-tokens</a></li></ul><p>Web3 is no stranger to these sorts of issues, and RPC is a major contributor to downtime in web3 at the moment. In the next section, we investigate uptime and the difference in scale made by even minute changes in downtime.</p><h3>The Scale of Uptime: 99% vs 99.9% vs 99.99%</h3><p>We define uptime as the amount of time a server or service stays operational and accessible to users measurable in units of time. downtime is therefore any measurable time that a service becomes offline and inaccessible to users for any reason. availabilityis calculated by subtracting the total amount of downtime from the ideal uptime; availabilityis usually calculated over longer periods of time where it is more observable. availability, here, is the ratio of uptime to downtime, represented as a percentage.</p><p>A simple pseudo-code example demonstrates this in terms of one month (or 43,860 minutes). A simple 60 minutes — a mere one hour — of monthly downtime knocks us all the way down below 99.9% availability:</p><pre>uptime = 43,830<br>downtime = 60<br><br>availability = (43,830 - 60) / 43,830 x 100<br>availability = 99.863%</pre><p>Here, we treat 99.9% (AKA “three nines”) as a minimal threshhold — something that we should look for as the bare minimum in any system we call ‘highly available.’ However, the real prize is at 99.999%.</p><p>The difference between 99.9% and 99.999% available might seem minimal to our non-computational eyes, but it can have a significant impact over a stretch of time on a highly available system. For instance, 99.9% availability corresponds to approximately 43 minutes of downtime per month, while 99.999% availability translates to only 26 seconds of downtime per month. That is quite different, after all! The compounding effects of an occasionally unavailable system are more apparent when they are projected over an entire year.</p><p>Let’s take a look at a simple chart which illustrates this more clearly below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*2rP36rZzGzEUTAE7kjiI_g.png" /></figure><p>As we can see, the effects compound quickly. Making a system more available by nine-hundredths of a percent results in a significant reduction in downtime. To put this into perspective, “five nines” (99.999% availability) means an app has likely less than 78 seconds of downtime per quarter. With only a few seconds of downtime every few months, our “five nines” figure is widely considered the hallmark of reliability measures.</p><p>Unfortunately, most of web3, and especially web3 RPC has not made it to this enshrined figure, major RPC service providers only offer 99.9% availability in their Service-Level Agreements (SLA). We know that downtime can be caused by hardware failure, infrastructure disruptions, and software glitches caused by configuration errors or bugs. Ironically and very importantly, a great deal of RPC downtime is simply caused by excessive traffic. With Centralized Service Providers offering a 99.9% availability SLA, we’re still off to the races to find a solution which reaches the height of RPC demand; with all this talk of centralization, redundancy, and distributed systems one would dream of a system experiencing zero downtime. It is a dream to be dream… Now, what about the various endpoints that are available publicly all over the place? Don’t they indicate ubiquitous blockchain uptime and availability?</p><h3>Public RPC is Not Enough</h3><p>Public RPC endpoints are a beautiful notion. They give an alternative to self-hosting and operation overnight dev ops. They provide ‘good enough’ RPC services to otherwise unserviced developers. They even prove the altruism of the open-source web3 community. Unfortunately, they alone are generally not enough to serve the needs of expanding applications and services. While, centralized RPC service providers offer a usable 99.9% SLA by standard, other public RPC endpoints offer no promise of availability or uptime. Centralization offers some benefit of surety but comes at a cost. And with regards to unpaid Public RPC — unfortunately, as the time-honored Robber-Baron-Age adage goes, “you get what you pay for!”</p><p>Public RPC can go down, be overwhelmed, or just up and disappear. In many or most cases, there is no SLA between users and operators. Once an application or service reaches scale beyond hobbyist or testing levels, RPC endpoints often fail due to insufficient resources. Paid, private RPC providers are generally prepared for this load and financially incentivized to upscale their resources, but unpaid, public RPC endpoints must do things to protect themselves — such as rate-limit users. Public RPC is great in many circumstances. However, when a project is production-grade, it requires a high level of uptime and reliability to ensure that it continuously delivers value to its users. Reaching ‘high availability’ is something that Public RPC alone cannot do.</p><h3>Addressing Uptime Requirements</h3><p>In discussing highly reliable RPC, it’s important that we note here that there are things that node operators and RPC providers can do to ensure maximizing up-time and increasing the availability of their service. Some of the most crucial are catalogued here:</p><ul><li><strong>DDos Protection:</strong> On today’s internet, Distributed Denial of Service (DDoS) protection is mandatory for any publicly exposed resource with an globally shared URL. Running a node without proper DDoS protection makes it vulnerable to spam traffic from malicious users and bots — a guaranteed recipe for downtime.</li><li><strong>Proactive monitoring:</strong> Regular and proactive monitoring of systems can help detect issues early on and address them before they lead to downtime. Setting acute alerts with Centreon, Prometheus, Grafana, or other tooling assists with letting operators know there is a problem before it becomes a problem for the end-user.</li><li><strong>Redundancy and fail-over:</strong> A backup and redundancy plan can minimize the risk of data loss and system downtime. RPC Providers ideally will build a robust system that allows smart detection of downed resources and a seamless roll-over of service. That means that RPC users will not have to go chasing new links and new providers if and when an outage occurs.</li><li><strong>Regular maintenance and updates:</strong> Regular maintenance and updates help ensure that systems are running efficiently and securely. This could include updating software and hardware, patching vulnerabilities, and upgrading systems regularly. Unfortunately in the real world, updates sometimes break things as often as they fix them — having a system whereby real-time rollbacks are possible can be crucial for keeping services online. And, of course, all of this should ideally be done with minimal interruptions of service.</li><li><strong>Malware protection:</strong> Malicious software can and will make its way to any publicly exposed resource on the web. Installing workable, lightweight security software which monitors processes on a given node can help tremendously in stopping both attacks and outages. Alternatively, creating a secure-by-design operating environment can do the trick.</li><li><strong>Security Best Practices:</strong> As mentioned, secure-by-design infrastructure is optimal. There are many vectors for attacking nodes — and its easy to forget that the humble RPC endpoint is a high value target for a hacker looking for an easy win. <a href="https://medium.com/lava-network/data-accuracy-in-web3-141f239ef2ca">Data reliability</a> is a major function of RPC, and an unsung priority that can be ensured by security best practices.</li><li><strong>Load balancing and scaling:</strong> Load balancing and scaling help distribute traffic and prevent system overload. This could include load balancing to distribute traffic or scaling up systems with more resources as traffic increases. In either case, node operators and RPC providers alike must have some sort of safeguards in place for when the hordes come for blockchain data. It is a sad irony that abundant use is a major killer of RPC endpoints.</li></ul><h3>Why Reliable RPC is Crucial for Web3</h3><p>This entire section can be summed up in a single word: adoption. Availability and uptime are crucial for adoption of web3 technology; they make dApps and services usable. <a href="https://medium.com/lava-network/the-web3-rpc-problem-a-diary-reflection-on-cryptos-infrastructure-dilemma-8508a8d3de9f">In our current situation</a>, we rely on the good graces of public RPC, maverick node runners, and the SLA of centralized providers to ensure our uptime. Perhaps, somewhat obvious to most, as more production-grade decentralized applications and services supplant hobby projects and enthusiast-driven development, the uptime statistics of our RPC available will need to improve with time.</p><p>Let’s agree to this: downtime hurts everyone. It hurts RPC providers who offer blockchain data, sometimes at a profit. It hurts end-users who are interested in seemless front-ends and good user experiences. And, finally, it hurts dApp builders and developers who want to build web3. Any significant amount of downtime leads to some loss in revenue and some cost for restoration for everyone involved. But what cannot be accounted for is the inevitable loss of reputation that happens when someone’s app or service goes down in the moment of greatest need. Availability is extremely crucial to consider in the scope of the various things web3 has to offer the world wide web economy.</p><h3>Solutions</h3><p>Fortunately, redundant, distributed and decentralized <a href="https://medium.com/lava-network">networks such as Lava</a> can ease the pain and awkwardness of implementing all of these by incentivizing independent RPC providers to offer service. It is our vision that the five-nine future is not far away…</p><h3>About the Author🧑🏿‍💻</h3><p><a href="https://twitter.com/KagemniKarimu">KagemniKarimu</a> is current Developer Relations Engineer for <a href="https://lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Referral&amp;utm_campaign=RPC+Uptime+%26+Availability+in%C2%A0Web3">Lava Network</a> and former Developer Relations at Skynet Labs. He’s a self-proclaimed Rubyist, new Rust learner, and friendly Web3 enthusiast who entertains all conversations about tech. Follow him on <a href="https://twitter.com/KagemniKarimu">Twitter </a>or say hi to him on Lava’s <a href="https://discord.gg/Tbk5NxTCdA">Discord</a> where he can be found lurking.</p><h3>About Lava 🌋</h3><p><a href="https://lavanet.xyz/?utm_source=Medium.com&amp;utm_medium=Referral&amp;utm_campaign=RPC+Uptime+%26+Availability+in%C2%A0Web3">Lava</a> is a decentralized network of top-tier API providers, where developers make one subscription to access any blockchain. Providers are rewarded for their quality of service, so your users can fetch data and send transactions with maximum speed, data integrity and uptime. Pairings are randomized, meaning your users can make make queries or transact in privacy.</p><p>We help developers build web3-native apps on any chain, while giving users the best possible experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b13982352f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lava-network/rpc-uptime-reliability-in-web3-4b13982352f">RPC Uptime &amp; Reliability in Web3</a> was originally published in <a href="https://medium.com/lava-network">Lava Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Accuracy in Web3 ]]></title>
            <link>https://medium.com/lava-network/data-accuracy-in-web3-141f239ef2ca?source=rss-c0bb8c66f36f------2</link>
            <guid isPermaLink="false">https://medium.com/p/141f239ef2ca</guid>
            <category><![CDATA[rpc-node]]></category>
            <category><![CDATA[alchemy]]></category>
            <category><![CDATA[blockchain-api]]></category>
            <category><![CDATA[infura]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[KagemniKarimu]]></dc:creator>
            <pubDate>Fri, 21 Apr 2023 16:10:52 GMT</pubDate>
            <atom:updated>2023-04-21T16:34:19.344Z</atom:updated>
            <content:encoded><![CDATA[<h4>How reliable is blockchain data?</h4><blockquote>tl;dr — Data accuracy is an overlooked nuiscance in Web3. It plagues RPC calls and all blockchain interactions. Incorrect data from blockchains can lead to incorrect token balances, erroneous smart contract execution, compromised reputations systems, failed transactions, and misleading price information on decentralized exchanges. The problem could be exacerbated by the rise of AI…</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9I_c62FkljqNu_vqwOdoag.jpeg" /></figure><p>According to <a href="https://hackernoon.com/web3s-hidden-problem-data-accuracy">Hackernoon</a>, “For the simple reason that they were giving their users <em>contradictory information</em>, a popular NFT team lost tens of thousands of subscribers.” The story is repeated elsewhere, as<a href="https://www.alchemy.com/blog/data-accuracy"> Alchemy’s data accuracy </a>article similarly exclaims that frontend bugs caused by unreliable data led to a whopping $2,000,000 loss!</p><p>By now, we hope that you know a little bit about RPC. In my previous article on <a href="https://medium.com/lava-network/web3-developer-rpc-woes-1399be46678."><em>Web3 RPC Developer Woes</em></a>, we talked about how RPC sometimes returns inaccurate, invalid, and wildly stale data. Now, I want to talk about how and why we ensure the data we receive is coming correctly from the blockchain- and the ways in which unreliable data can manifest into costly mistakes.</p><h3>Data Accuracy is a Hidden Nuisance in Web3 🐑 😎</h3><p>There are problems that everyone has but nobody thinks about and problems that few people have but everyone thinks about. One of the hidden nuisances when using RPC is data verifiability, which refers to the ability to ensure that the data being exchanged is authentic and accurate. It is a problem that few people think about, but everyone has experienced — in one way or another — and which can have profound consequences.</p><p>Because these issues do not generate error messages, it is difficult to catch them. Note that when they do happen, if you’re unclear about the source of the issue, you can spend hours debugging them — trying to pin down the cause of the undesired outputs of your calls. In the meantime, your application can go haywire — producing unexpected behavior.</p><p>Ultimately, this is caused because RPC is accomplished through peer-to-peer connections in the blockchain world, and as such, it is difficult to prove the veracity of the data received. In most cases, such data is <em>not</em> stored on chain, but metadata is. Therefore, in a majority of cases, only the metadata of a remote call can be verified.</p><p>Metadata, in this context, refers to data that provides information about the structure and properties of the actual data being exchanged. Most commonly, this includes a basic “who, what, and when” that excludes the content of the request.</p><p>Our fren <a href="https://twitter.com/balajis/status/1290326493076176896?s=20">Bajali</a> points out this is accomplished primarily by recording three factors on-chain: 1) digital signature of the authorizing parties, 2) a hash of high-visibility data exchanged, and 3) timestamp of the transaction. While metadata can provide some level of confidence in the data’s integrity, it alone is often not sufficient to ensure that the exchanged data itself has not been tampered with. The issue of data verifiability remains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*nk02b9ymwRb5DGpa2o4HJw.jpeg" /></figure><h3>The Consequences of Inaccurate Data 💣</h3><p>So what happens if data is inaccurate, you ask? Inaccurate data can be the cause of a ton of issues:</p><ol><li>Incorrect token balances: Inaccurate data may lead to users seeing incorrect token balances in their wallets, causing confusion and potential financial loss if they make transactions based on incorrect information.</li><li>Misleading price information: In decentralized finance (DeFi) platforms, inaccurate price data can result in users making poor trading decisions or executing transactions at unfavorable prices.</li><li>Erroneous smart contract execution: If inaccurate data is used as input for smart contracts, it can cause unintended consequences, such as the loss of funds, incorrect asset distribution, or the triggering of undesired actions.</li><li>Failed transactions: Inaccurate data can lead to failed transactions due to issues such as insufficient gas fees or incorrect nonce values, resulting in wasted time, effort, and potentially lost funds for users.</li><li>Blockchain reorgs: Inaccurate data may lead to blockchain reorganizations, where multiple competing chains temporarily exist. This can cause confusion, delayed transactions, and even loss of funds in some cases.</li><li>Misrepresentation of NFT ownership: Inaccurate data regarding NFT ownership can result in disputes, wrongful sales or transfers, and potential legal issues.</li><li>Incorrect voting results: In decentralized governance systems, inaccurate data can lead to incorrect voting outcomes, resulting in undesired changes to the protocol or unfair distribution of resources.</li><li>False alerts or missed security incidents: Inaccurate data can lead to false security alerts or the failure to detect actual security breaches, leaving networks vulnerable to attacks and exploitation.</li><li>Compromised reputation systems: In decentralized platforms that rely on reputation systems, inaccurate data can lead to users being unfairly penalized or malicious actors gaining unwarranted trust.</li><li>Cascading failures in interconnected systems: Inaccurate data can propagate through interconnected systems, causing cascading failures, loss of funds, and widespread disruptions in the Web3/crypto ecosystem.</li></ol><h3>Why Verifying Data Accuracy is Important ❗️</h3><p>Beyond avoiding the pitfalls listed above, there are second-order, ideological reasons why verifying data can be important:</p><h4>🔴Trustlessness</h4><p>One of the core principles of Web3 is the concept of trustlessness, which means that users and participants in the network do not need to rely on a central authority or trust any single entity in order to operate. Data verifiability plays a key role in ensuring trustlessness, as it allows users to independently validate the authenticity and accuracy of the data being exchanged within the network. This empowers users to have confidence in the system without having to rely on a centralized governing entity.</p><h4>🔴Security</h4><p>In a decentralized ecosystem like Web3, ensuring the security of data is of utmost importance, as it forms the basis of transactions, smart contracts, and other interactions between users and applications. Beyond this, users will not use an application that appears risky, has known exploits, or leaks critical data. Verifying data helps protect against malicious actors who may attempt to manipulate or tamper with the data to gain undue advantage, compromise the network, or conduct fraudulent activities.</p><h4>🔴Interoperability</h4><p>Web3 envisions a highly interconnected and interoperable landscape of decentralized applications, platforms, and protocols. Verifying data is crucial in enabling seamless communication and collaboration between different components in the Web3 ecosystem. Ensuring data verifiability allows developers to build reliable applications and services that can exchange data across various networks and platforms without compromising the integrity and accuracy of the information. This promotes greater innovation, efficiency, and user experience in the Web3 space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*_UkEih51inpUuMMiPSKDWQ.jpeg" /></figure><h3>How Data is Verified</h3><p>Many approaches are used at various layers to ensure accurate data. Data verifiability mechanisms, such as cryptographic signatures and consensus algorithms, help secure the network and protect users’ assets and information for anything kept on-chain. Elsewhere, ZKproofs, and optimistic sampling protocols are used to ensure data is what it’s supposed to be! Let’s look at a few of these closer:</p><ul><li><em>Cryptographic signatures</em>: These are digital signatures that rely on cryptographic algorithms to verify the authenticity and integrity of data. By signing data with a private key, the sender can prove that they are the legitimate source of the information and indicate that the data has not been altered during transmission. This method of verifying data is fairly abundant with ECDSA, ERC-725, JSON Web Tokens (JWT), Decentralized Identifiers (DID) and DAO voting. Smart contracts, frequently verify these signatures to authenticate senders and execute themselves.</li><li><em>On-chain consensus</em>: In blockchain-based systems, on-chain consensus mechanisms (e.g., Proof of Work, Proof of Stake) are used to ensure that all nodes in the network agree on the validity of transactions and data. These consensus algorithms are designed to be resistant to manipulation and to ensure that a single malicious node cannot control the network. Virtually all blockchain projects implement some form of consensus mechanism -and a good deal of them share similar consensus mechanisms schema (i.e. Cosmos appchains all use Tendermint BFT for the time being).</li><li><em>Optimistic sampling</em>: This is a technique used to verify data in distributed systems by randomly sampling a small subset of nodes and cross-validating their responses. If the sampled nodes provide consistent information, the data can be considered trustworthy. This method reduces the time and computational resources needed to verify data across the entire network. Networks such as Avalanche and IPFS which are highly distributed rely upon this method.</li><li><em>Zero-Knowledge Proofs (ZKPs)</em>: Zero-knowledge proofs are cryptographic techniques that enable one party to prove to another that they possess certain information without revealing the actual data. This allows for secure and privacy-preserving verification in Web3 systems. zk-SNARKs (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge) and zk-STARKs (Zero-Knowledge Scalable Transparent ARguments of Knowledge) are examples of ZKP implementations. These mechanisms are particularly useful in privacy-focused applications, such as anonymous transactions in cryptocurrencies (e.g., Zcash) or off-chain computations in decentralized systems, where data confidentiality is of paramount importance. By incorporating ZKPs, Web3 systems can achieve data verifiability while preserving privacy and reducing the trust required among participants.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*9VMxmTcqautGgAvR_MX_GA.jpeg" /></figure><h3>Data in the age of AI</h3><p>One last point — as we move towards a world increasingly dominated by artificial intelligence (AI), data verifiability will become even more critical. <a href="https://decrypt.co/123438/without-verifiable-data-ai-could-be-disastrous-space-time-cto">Some</a> have even said AI without verifiable data will be disastrous. Undoubtedly, the performance and reliability of AI systems depends on the quality and authenticity of the data they process. Ensuring data verifiability in AI-driven systems will be crucial to prevent biases, misinformation, and manipulation. Furthermore, lack of data accuracy can have profound impact on independent actors in monetized systems! That is to say, on web3 users in cryptonetworks!</p><p>Moreover, one must consider how profoundly different a world which has powerful AI will be from a data perspective. Basic tasks such as data entry and dummy data generation will be performed at unprecedented speeds. The sheer amount of data in interoperable systems will unavoidably increase. This creates new vectors for attack and new considerations for verifiability — if, for example, AI is clever enough to generate patterned data which appears “correct” to existing systems of verification. On the other foot, one must also consider that AI can be a valid tool for defense and can create more sophisticated visions of data verification technologies.</p><p>All this to say, there is a unique maelstrom of potential unleashed the moment AI meets trustless, permissionless decentralized networks and does its thing! Data verifiability, a mere nuisance now, will be significantly more important as time continues — and our methods for doing so in web3 will need to be cheaper, more robust and more performant!</p><p>That’s all for now… 💪🏿 In an upcoming article, we will delve deeper into the challenges and potential solutions for data verifiability in the age of AI. We will explore how cutting-edge technologies such as homomorphic encryption, ZeroKnowledge proofs, and other techniques can contribute to improving data verification. Sleep tight and don’t trust, verify 😉.</p><h3>About the Author🧑🏿‍💻</h3><p><a href="https://medium.com/u/c0bb8c66f36f?source=post_page-----1399be46678--------------------------------">KagemniKarimu</a> is current Developer Relations Engineer for Lava Network and former Developer Relations at Skynet Labs. He’s a self-proclaimed Rubyist, new Rust learner, and friendly Web3 enthusiast who entertains all conversations about tech. Follow him on <a href="https://twitter.com/KagemniKarimu">Twitter </a>or say hi to him on Lava’s <a href="https://discord.gg/Tbk5NxTCdA">Discord</a> where he can be found lurking.</p><h3>About Lava 🌋</h3><p><a href="https://medium.com/lava-network/what-is-lava-a-tripartite-explanation-e01788ae0af0">Lava</a> is a decentralized network of top-tier API providers, where developers make one subscription to access any blockchain. Providers are rewarded for their quality of service, so your users can fetch data and send transactions with maximum speed, data integrity and uptime. Pairings are randomized, meaning your users can make make queries or transact in privacy.</p><p>We help developers build web3-native apps on any chain, while giving users the best possible experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=141f239ef2ca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lava-network/data-accuracy-in-web3-141f239ef2ca">Data Accuracy in Web3 💻</a> was originally published in <a href="https://medium.com/lava-network">Lava Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web3 Developer RPC Woes]]></title>
            <link>https://medium.com/lava-network/web3-developer-rpc-woes-1399be46678?source=rss-c0bb8c66f36f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1399be46678</guid>
            <dc:creator><![CDATA[KagemniKarimu]]></dc:creator>
            <pubDate>Fri, 14 Apr 2023 16:16:43 GMT</pubDate>
            <atom:updated>2023-04-14T16:16:43.781Z</atom:updated>
            <content:encoded><![CDATA[<h4>Common RPC-related problems for Web3 developers</h4><blockquote>tl;dr — <em>Developers using RPC frequently encounter unreliable/unavailable endpoints, stale data, stale node lists, rate limits, missing and messy documentation, and are expected to self-host. Web3 must be liberated from this travesty.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7QiFQlckUDRdC0hJ3HMPDQ.png" /></figure><p>Lo and behold! As the world of blockchain technology and decentralized applications (dApps) continues to grow, new and intermediate Web3 devs are facing a variety of unprecedented web-based challenges. Indeed there are a slew of issues which plague us as we strive towards building the most cutting edge and awesome tech around. In this article, we will discuss the most common issues faced by web3 devs — which you may or may not know are related to RPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G64pxWYOltS-ewv-QIJgNg.jpeg" /></figure><h3>Unreliability &amp; Unavailability ☠️</h3><blockquote><strong><em>RPC endpoints go down during high traffic moments, and there is little accountability for centralized providers</em></strong></blockquote><p>A downed node is, well, a downed node 😐. At your moment of greatest need, you may find that your RPC endpoint suddenly ceases to function. In which case, you are likely in the middle of your first NFT mint or your big Airdrop to your loyal community following, who now thinks you’ve deceived them. The solution would be reliable and available RPC, alas, your once reliable and available endpoint has collapsed under the tremendous new demand generated by your landmark event 😭. This is the tragedy of the commons at warp speed! You want available, free, and fast RPC — and then you want to use it abundantly. But, in today’s web3, it’s difficult to get all of these.</p><h3>Self-Hosting a.k.a. Operation Overnight DevOps 🤳🏿</h3><blockquote><strong><em>Developers have to host their own nodes when required nodes are unreliable, unavailable, or insecure.</em></strong></blockquote><p>Welcome to Web3 where all the infrastructure is decentralized! Translation: you will have to run all of your own infrastructure if you care about decentralization and there is no obvious alternative! Many common chains have public RPC available for free for testing, but if you’re interested in creating a production grade application — you’re going to need reliable RPC endpoints. See <a href="https://medium.com/lava-network/the-web3-rpc-problem-a-diary-reflection-on-cryptos-infrastructure-dilemma-8508a8d3de9f">The Web3 RPC Problem</a> for an in depth evaluation of this issue.</p><p>Most developers have the tenacity to learn new skills and are willing to become skilled in deploying and maintaining a node — as one of many necessary evils required for sovereignty. Unfortunately, the process takes time away from coding, involves recurring expenses, requires a separate technical skillset than programming, and requires proper planning for future scaling. In short, Operation Overnight Devops 😝.</p><h3>Stale URL Lists⏳</h3><blockquote><strong>RPC URL lists are not always up-to-date and often contain old and dead links to down RPC endpoints.</strong></blockquote><p>Most commonly, RPC lists are stored in Discord server channels, on github repositories, on websites, and on websites whose source code is stored on github repositories! This means they must be updated by active maintainers who politely steward the list for the good of the community. As you can imagine, if you have ANY active side projects 😉, these lists can get a little neglected — and are often times fixed only after someone has complained that links are dead, nodes are unresponsive, or requests are timing out. Once this happens, someone (usually 😩) comes from the back of the shop and dusts them off only to return back into obscurity. You’ve normally moved on by then…</p><h3>Stale Data ⌛</h3><blockquote><strong><em>Occasionally, nodes are proven out of sync when they return data that was once correct but is no longer.</em></strong></blockquote><p>In a real-time environment — like blockchains with short consensus cycles — the need for up to date and accurate data is highly pertinent to the smooth functioning of applications. That stated, missing or inconsistent results as a result of old indexed data or out of sync nodes is an occasional nuisance. This is most obvious when you interact with a chain with a short blocktime and ask for the current blockheight, yet receive a blockheight slightly less than expected when compared against explorers or other nodes. For one reason or another, an endpoint may return a result that, though it was once correct, is no longer correct. OH well! On to another endpoint. So much for your dream of smart-contract enabled instantaneous ZK-proofs 😎.</p><h3>Rate limits! ⏱️</h3><blockquote><strong><em>To protect themselves from overuse and abuse, many public RPC endpoints are rate-limited.</em></strong></blockquote><p>Yes — your handy little app is robust and can theoretically process 10,000 transactions per second concurrently while queuing all outgoing requests and caching all incoming data 💪🏾. There’s just one thing you forgot about! RATE LIMITS. These put a hard governor cap on the performance of your application, limiting your ability, nay, your right to use RPC the way that you need. A rate limit says — STOP! you’re going too fast for my node to handle. As a reality, these prevent abuse and over-consumption of essential public goods, but as a nuisance, these obstruct rapid innovation.</p><h3>Missing/Messy Documentation 🔍</h3><blockquote><strong><em>Depending upon your use case, you may not find ample example code of what you’re trying to do.</em></strong></blockquote><p>You wanted to know how things are implemented, right? You wanted a clear and unambiguous single source of truth regarding the interfaces used, didn’t you? More often than not, these things can get a little tricky, especially as a pioneer in the web3 space. Web3 is populated with many young projects with maturing ecosystems; often times, documentation just isn’t keeping up with the rate of technological growth and advancement. At this level of adventure, there are often no maps. Do us all a favor &amp; fully document what you do as you do it ✍🏿. The trail of breadcrumbs you create will help guide future lost explorers.</p><h3>In Conclusion</h3><p>The waters are still trepidatious for burgeoning web3 developers. No doubt, much work must and can be done to provide a smoother dev experience in the landscape. It is not reasonable to deal with stale lists, stale data, missing docs, rate limits, and self-custody of infrastructure just to build simple working tools and utilities! The future of web3 requires a solution that enables beginner devs to have seamless experiences devoid of these sorts of issues and limitations. To learn more about how Lava is trying to solve the Web3 RPC problem, check out this <a href="https://medium.com/lava-network/how-lava-really-works-61338584fd08">article</a> for a breakdown of the protocol.</p><h3>About the Author🧑🏿‍💻</h3><p><a href="https://medium.com/u/c0bb8c66f36f">KagemniKarimu</a> is current Developer Relations Engineer for Lava Network and former Developer Relations at Skynet Labs. He’s a self-proclaimed Rubyist, new Rust learner, and friendly Web3 enthusiast who entertains all conversations about tech. Follow him on <a href="https://twitter.com/KagemniKarimu">Twitter </a>or say hi to him on Lava’s <a href="https://discord.gg/Tbk5NxTCdA">Discord</a> where he can be found lurking.</p><h3>About Lava 🌋</h3><p><a href="https://medium.com/lava-network/what-is-lava-a-tripartite-explanation-e01788ae0af0">Lava</a> is a decentralized network of top-tier API providers, where developers make one subscription to access any blockchain. Providers are rewarded for their quality of service, so your users can fetch data and send transactions with maximum speed, data integrity and uptime. Pairings are randomized, meaning your users can make make queries or transact in privacy.</p><p>We help developers build web3-native apps on any chain, while giving users the best possible experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1399be46678" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lava-network/web3-developer-rpc-woes-1399be46678">Web3 Developer RPC Woes</a> was originally published in <a href="https://medium.com/lava-network">Lava Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quality of Service(Part 1): How Lava Network keeps decentralized RPC fast, reliable and accurate]]></title>
            <link>https://medium.com/lava-network/quality-of-service-part-1-how-lava-network-keeps-decentralized-rpc-fast-reliable-and-accurate-82d2a3f7958e?source=rss-c0bb8c66f36f------2</link>
            <guid isPermaLink="false">https://medium.com/p/82d2a3f7958e</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[node-infrastructure]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[web3-developer]]></category>
            <category><![CDATA[rpc]]></category>
            <dc:creator><![CDATA[KagemniKarimu]]></dc:creator>
            <pubDate>Fri, 07 Apr 2023 15:42:59 GMT</pubDate>
            <atom:updated>2023-04-12T14:57:13.054Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rSkbHIJZ3qAxSRmSwNR8nQ.png" /></figure><h3>How can a decentralized network be fast and efficient?</h3><p><a href="https://lavanet.xyz/?utm_source=medium.com&amp;utm_medium=referral&amp;utm_campaign=Lava101&amp;utm_content=How+Lava+Network+keeps+decentralized+RPC+fast%2C+reliable+and%C2%A0accurate">Lava</a> connects apps to an aggregated network of top RPC providers. Developers use RPC calls to send and fetch data to and from blockchains. By incentivizing a permissionless, decentralized network of providers, Lava provides an open standard for blockchain APIs, allowing developers to reliably and easily connect their applications to multiple blockchains. You can get free RPC from <a href="https://gateway.lavanet.xyz/?utm_source=medium.com&amp;utm_medium=referral&amp;utm_campaign=Lava101&amp;utm_content=How+Lava+Network+keeps+decentralized+RPC+fast%2C+reliable+and%C2%A0accurate">our Gateway</a> today.</p><p>Unfortunately, it is common that people mistakenly associate decentralization with slowness, inefficiency, and even malfunction. By proxy, decentralized RPC is often dismissed as impractical, a relic of the infamous “mountain man” fantasy where nodes are owned everywhere by everyone.</p><p>Still, a decentralized network of RPC providers is an integral part of the modern web3 infrastructure. On Lava, each pairing between RPC provider and consumer is an essential interaction which could carry valuable and time-sensitive data that powers a blockchain. With consumers constantly paired to new providers, upholding the Quality of Service of each interaction is essential. This is primarily done by creating competition between providers, with the highest scored providers getting more service, thereby raising the overall service quality of the entire set of providers.</p><p>This article covers the basic features and characteristics of the aforementioned Quality of Service system. Other related articles have covered <a href="https://medium.com/lava-network/what-is-lava-a-tripartite-explanation-e01788ae0af0">What is Lava</a> and <a href="https://medium.com/lava-network/how-lava-really-works-61338584fd08">How Lava Works</a>, which may be great introductory reads to this article! If you’re lost in the weeds of what RPC is — start by educating yourself on <a href="https://medium.com/lava-network/a-developers-guide-to-accessing-blockchain-data-with-cosmos-rpc-examples-f86bc62e1f91">this article</a>.</p><p>What you must know is this: until recently, with exception of a few centralized entities which guarantee Service-Level Agreements (SLAs), most RPC providers have operated independently with no real accountability for the quality of service they provide. This has led to inconsistency in the uptime of providers, strict rate limits on requests, and even censorship and endpoint failure… You can get a detailed view of the types of issues this has brought and attempted solutions in my article titled <a href="https://medium.com/lava-network/the-web3-rpc-problem-a-diary-reflection-on-cryptos-infrastructure-dilemma-8508a8d3de9f">The Web3 RPC Problem</a>.</p><p>Lava has developed an innovative Quality of Service (QoS) system to monitor and incentivize providers that mitigates inconsistencies in RPC service; by doing so, Lava creates a reliable, multi-chain RPC service — the Lava bet is to offer RPC with less downtime, more accurate responses, and more privacy than you can get from a centralized provider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dSJUOxK8xwPbphDRGHLpzg.png" /><figcaption>an excerpt of Lava’s QoS functionality</figcaption></figure><h3>How is RPC Quality of Service measured?</h3><blockquote>Lava uses a Quality of Service scoring system per relay, to ensure a high service standard for consumers. This service is measured across latency, sync, and availability.</blockquote><p>Most generally, Quality of Service (QoS) is a measure of performance that evaluates the service quality of a given system. It considers many possible metrics, with some of the most relevant being: latency, availability, freshness, and accuracy. We’ll review all of them below to ensure we have a clear understanding of terms before digging into Lava.</p><p><strong>Latency</strong> — is the time it takes for data to travel from one point to another. A low latency connection is essential for quick transactions and data transfers — it ensures that dapps are responsive and that users have a smooth experience. When latency is high, dapps can glitch, hang, or just plain break. Decentralized exchanges relying on RPC with sudden latency spikes may cause transactions to time out and drop user buy and sell orders. This can result in a frustrating and costly experience for web3 users.</p><p><strong>Availability</strong> — refers to how often the RPC is available, or “up” — i.e., can it be used to access data or perform transactions on the blockchain? High availability ensures that there is never too much downtime for applications relying on the RPC connection. A downed RPC is tragic — comparable to the failure of travel infrastructure such as a major thoroughfare — everything using that node to interact with the blockchain just STOPS — until a new route is found. This is extremely undesirable and has been the cause of failed NFT mints, stifled airdrops, and dead-on-arrival blockchain events.</p><p><strong>Freshness </strong>— is whether the data is the most up-to-date data available. Freshness is akin to accuracy and often lumped together; data may arrive quickly and reliably, but may be stale, representing a true value at a previous state. When using a single RPC provider there is no easy way to check the freshness of data. One would need to probabilistically sample multiple RPC providers to find out. We’ll go into how Lava does this to prevent stale data in another article!</p><p>Finally, <strong>accuracy</strong> — is the measure of how reliable the RPC connection is — basically, it’s a measure of how often queries return the correct data. Accuracy is essential for dapps that rely on accurate information from the blockchain in order to function properly. Inaccurate results can lead to incorrect transactions, so it’s important that providers maintain a high degree of accuracy. As you can imagine, inaccurate results can mean the wrong amounts are transmitted for critical on-chain transactions, resulting in erroneous and irreversible losses of value to end users.</p><h3>Lava’s QoS Accountability System</h3><p>In order to ensure that RPC providers maintain a high level of service, Lava has developed an innovative Quality of Service (QoS) system. Consumers score the delivery of each provider in each geolocation and thereby incentivize them to offer a better service. To best understand this — you need to know the four metrics consumers rate providers across:</p><h4>1. Availability (uptime)</h4><p>In order to ensure that our system runs smoothly, there are several key factors that we need to consider. One of the most important of these is availability (uptime). We need to make sure that our system is up and running at all times, so that users can access data whenever they need to. Our <a href="https://docs.lavanet.xyz/access-sdk/?utm_source=medium.com&amp;utm_medium=referral&amp;utm_campaign=Lava101&amp;utm_content=How+Lava+Network+keeps+decentralized+RPC+fast%2C+reliable+and%C2%A0accurate">SDK</a> allows p2p access to Lava, meaning even higher availability.</p><h4>2. Performance (latency)</h4><p>Another crucial factor is performance, specifically latency. In order to provide a good user experience, we need to make sure that our system responds quickly to user requests. This means that we need to minimize the amount of time it takes for our system to process these requests.</p><h4>3. Sync (block height)</h4><p>We also need to consider sync, specifically block height. It’s important that all nodes on our network have the same copy of the blockchain, so that transactions can be validated and added to the blockchain in a timely manner. Assuring sync means data will be fresh and accurate.</p><h4>4. Reputation (excellence)</h4><p>In addition, we need to be aware of outliers and reputation. Though these are not handled by the protocol as a specific score — it is derived from clusters of scores. If a node on our network is consistently slow or unresponsive, we need to take action to address the issue. We also need to ensure that any provider which is listed has a good reputation, so that users can expect their transactions to be handled securely and efficiently. Providers which are unresponsive are unstaked from the network and do not appear to would-be Consumers, while those who are dishonest are punished.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*aJKi_SiCDzgbhfbNouzB8w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*4hwVIUUYDntiJLQOp0SyTA.png" /><figcaption>Latency, Sync, Availability, &amp; Excellence are all relevant</figcaption></figure><p>All of these work together to provide a fast and reliable RPC experience that retains decentralization and user-side control! With Lava, you get a decentralized, reliable, and configurable quality-assured RPC provider across multiple chians.</p><h3>But decentralized? You mean slow and complicated?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rL4eXAlFzzlNvND-6dhYHg.jpeg" /></figure><p>Certainly not! Decentralization is often associated with inefficiencies due to the nature of its design, which involves the distribution of control and decision-making across a network. However, the concept of Lava, as an aggregator of top providers, demonstrates that decentralization can still be efficient and effective. This can be achieved by leveraging the strengths of multiple providers and incorporating additional features that enhance privacy, censorship-resistance, and performance incentives.</p><h4><strong>- Aggregating top providers</strong>:</h4><p>By aggregating the best providers in the decentralized ecosystem, Lava creates a more efficient and robust network, as well as one which is highly redundant. This allows users to benefit from the expertise, resources, and infrastructure of multiple providers, leading to improved overall performance under conditions of fail-over.</p><p>As a result, the aggregated network can offer a higher level of service quality than individual providers operating in isolation.</p><h4><strong>- Privacy enhancement:</strong></h4><p>Lava incorporates privacy-preserving features that protect users’ data and transactions. By utilizing advanced cryptographic techniques and handling data exchange off-chain, Lava ensures that user information remains confidential while still allowing the network to function efficiently. This enhances the privacy aspect of decentralization, making it more attractive for users who care about data security.</p><h4><strong>- Censorship-resistance:</strong></h4><p>Decentralization inherently promotes censorship-resistance, as there is no central authority controlling the network! Lava is a peer-to-peer protocol which empowers RPC providers and RPC consumers to exchange with each other irrespective of data. These include handling transactions off-chain to obfuscate consumers’ data, making it more difficult for adversaries to target specific content or users.</p><h4><strong>- Performance incentives:</strong></h4><p>Optimal performance is guaranteed by competition amongst providers for servicing relays. Lava introduces incentive mechanisms that reward providers for delivering high-quality services as discussed in the previous section. These incentives are based on factors such as response time, uptime, and freshness.</p><p>Additional considerations such as geolocation are being worked in to future iterations. Pointedly, by actively incentivizing providers to compete against each other for better performance, Lava drives improvements in the efficiency and effectiveness of the decentralized network.</p><h3>What makes Lava a highly reliable RPC service?</h3><p>It’s simple: if one provider fails, the network will still be available.</p><p>The long of it: In the event that a provider fails, the network will remain available and any other provider will service outstanding RPC requests. This ensures that there is no downtime or interruption in the developer RPC experience. Each alternative provider, pulled at random, is subject to the same Quality of Service requirements as the primary provider. This redundancy is an important feature that ensures the reliability and stability of the network, especially in mission-critical environments where downtime can have serious consequences. With Lava, you can be assured that your application will always be available and functioning, no matter what happens to an individual RPC provider.</p><h3>Conclusion</h3><p>We have been living in a world where RPC was centralized, and the Quality of Service (QoS) was not guaranteed. Lava Network is changing that by providing developers with a reliable, open standard for blockchain APIs, allowing them to connect their applications to multiple blockchains with ease.</p><p>That’s it for now. :) Hopefully you are significantly more informed about teh Quality of Service assurances that Lava offers users of RPC… We’ll be revisiting this topic soon to learn more about how Lava ensures its providers are top tier in another article!</p><h3>Learn more 📚</h3><p>There are plenty of places to learn more about what Lava is building. Check us out below 👇</p><p>Discord: <a href="https://discord.gg/lavanetxyz">https://discord.gg/lavanetxyz</a><br>Twitter: <a href="http://twitter.com/lavanetxyz">twitter.com/lavanetxyz</a><br>Website: <a href="https://bit.ly/3nWZAyV">https://bit.ly/3nWZAyV</a><br>Litepaper: <a href="https://lavanet.xyz/assets/lava_litepaper_v0_1.pdf">https://lavanet.xyz/assets/lava_litepaper_v0_1.pdf</a><br>Docs: <a href="https://bit.ly/3m9umEB">https://bit.ly/3m9umEB</a><br>Github: <a href="http://github.com/lavanet">github.com/lavanet</a><br>Gateway: <a href="https://bit.ly/3GmyqIg">https://bit.ly/3GmyqIg</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82d2a3f7958e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lava-network/quality-of-service-part-1-how-lava-network-keeps-decentralized-rpc-fast-reliable-and-accurate-82d2a3f7958e">Quality of Service(Part 1): How Lava Network keeps decentralized RPC fast, reliable and accurate</a> was originally published in <a href="https://medium.com/lava-network">Lava Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>