<?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 Rishikesh Kale on Medium]]></title>
        <description><![CDATA[Stories by Rishikesh Kale on Medium]]></description>
        <link>https://medium.com/@rvk_rishikesh?source=rss-798ccf6d44d6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Rq8UWAWHituQ8F33n3KDBw.jpeg</url>
            <title>Stories by Rishikesh Kale on Medium</title>
            <link>https://medium.com/@rvk_rishikesh?source=rss-798ccf6d44d6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 23:05:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rvk_rishikesh/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[How to ideate and build your own dApp Store ?]]></title>
            <link>https://medium.com/@rvk_rishikesh/how-to-ideate-and-build-your-own-dapp-store-f9fca213c235?source=rss-798ccf6d44d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9fca213c235</guid>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[create]]></category>
            <category><![CDATA[store]]></category>
            <dc:creator><![CDATA[Rishikesh Kale]]></dc:creator>
            <pubDate>Wed, 26 Jul 2023 17:20:43 GMT</pubDate>
            <atom:updated>2023-07-26T17:28:28.554Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to ideate and build your own dApp Store ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*m-28mK3mf5BuEGsd" /><figcaption>dApp Store</figcaption></figure><p>Before getting started it’s important to understand the underline concept of dApp Store Kit. If you’re new to the concept of a dApp store, you may find it helpful to read about it <a href="https://medium.com/@rvk_rishikesh/what-is-dapp-store-kit-c279d3f6f4dc">here</a>.</p><blockquote><a href="https://medium.com/@rvk_rishikesh/what-is-dapp-store-kit-c279d3f6f4dc">This resource</a> will provide you with valuable insights and information about dApp stores, their purpose, and how they function in the world of decentralized applications. It’s an excellent starting point to grasp the significance and potential of dApp stores in the rapidly evolving blockchain landscape.</blockquote><h3><strong>Wooohhh !! It’s time to build and build it big 🚀</strong></h3><p>In this tutorial, we will take you through the essential steps to create your dApp store from scratch. Let’s dive in and bring your dApp store idea to life.</p><h4><strong>dApp Store Imaginarium 💡</strong></h4><p>Let’s explore the diverse markets and industries that can benefit from having their own dApp Store.</p><p><strong>Wallets</strong> 💰</p><p>Assume you are building a crypto wallet you and quickly add a new functionality by incorporating a discovery tab or dApp section. You can showcase exciting dApps all in one place and take ownership of the experience by recommending dApps that truly matter to your users. This will help you elevate the user experience with seamless access to a wide array of decentralized applications.</p><p><strong>NFT and Marketplace 🎢</strong></p><p>If you are someone who earlier built an NFT collection or a NFT trading platform you can bring an immersive experience to the NFT owners with a custom dApp store experience that showcases all relevant dApps. Enable users to engage, develop new partnerships, and explore innovative monetization models. You can showcase the relevant dApps where your NFT can be trade or utilized.</p><p><strong>Gaming Studios and Guilds 🎮</strong></p><p>The blockchain based gaming platforms need a better UX you can provide a unified gamer experience, connecting multiple games and asset trading platform all at one place. Imagine a game contains a NFT or tokens you can build a custom in-app dApp store which would help the user to quickly navigate to the right platform to buy or sell their assets and enhance their gaming experience.</p><p><strong>Content Publishers and Creators 📙</strong></p><p>Imagine you are a content creator or publisher or run a newsletter. You would be already having a good user base and would want to grab the opportunity to monetize the user base by providing the dApps with the existing user base and onboard dApps on your dApp store. Along with it here is the chance to expand your reach and attract more quality creators with your own dApp store, you can transform content distribution and revolutionize the creator community.</p><p><strong>Web3 Social 🛸</strong></p><p>Build thriving communities with embedded chats, forums, quests, and light games powered by dApps. Foster engagement and communication with your users through an all-in-one social platform. Seamlessly integrate loyalty points or tokens to craft a seamless and sticky user experience. Imagine you build a web3 social application where you facilitate interaction with the dApps and their users which enables the dApps to get prompt feedback and grow.</p><p>As you can see, the possibilities with building your own dApp store are boundless. Let us now get a bit technical and build our dApp Store.</p><h3>Getting started with Meroku protocol</h3><p>We would be utilizing the World’s first decentralised app store protocol — <a href="https://meroku.org/">Meroku Protocol</a>.</p><blockquote>The complete documentation can we found here : <a href="https://docs.meroku.org/hub/the-ecosystem/meroku-protocol">Meroku Protocol — Meroku Knowledge Hub</a></blockquote><p>We will implement essential features that would be commonly found in every dApp store, ensuring a user-friendly experience for all dApp enthusiasts. These features include:</p><ol><li><strong>Discoverability </strong>: Easily explore a diverse collection of dApps aligned with your interests.</li><li><strong>Search</strong> : Quickly find specific dApps using search option.</li><li><strong>Categorizing</strong> : Categorize dApps under various categories and sub-categories.</li><li><strong>App Details</strong>: Access comprehensive information about each dApp, including descriptions, banner, logo, app screenshots etc.</li></ol><p><strong>STEP I : Fetching all dApps</strong></p><p>Let’s start with fetching all apps directly from dApp registry.</p><p>The API,</p><pre>https://api.meroku.store/api/v1/dapp?page=0</pre><p>allows you to retrieve the first 10 apps listed in the dApp registry. To fetch the next set of 10 apps, simply increment the page number accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kc-4Mtt2pC5R6yDgK639bw.png" /></figure><p>Once you receive the data from the aforementioned API, you have the flexibility to display or rearrange it based on your preferences. For reference, take a look at the template below to see how you can arrange the data on your homepage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JGrMDU6m_6LQUBbZljuaTA.png" /></figure><p>By customizing the arrangement of data on your homepage, you can create a user-friendly and visually appealing experience for your users, making it easier for them to explore and engage with the dApps on your platform.</p><p><strong>STEP II : Fetching Individual dApp details</strong></p><p>If you wish to handpick a specific set of dApps and feature them on your dApp store, you have the capability to achieve this by querying the API with the following call:</p><pre>https://api.meroku.store/api/v1/dapp/search/{appID}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-uzxRq63PF3rf0HWndBTfw.png" /></figure><p>By utilizing this API call and providing the desired dApp IDs, you can fetch and list your selected dApps on your dApp store, offering a curated collection tailored to your users’ interests and preferences.</p><p>If we closely have a look at response data it provides us with all the necessary information like the name, logo, banner, screenshots, description of the dApp along with other details like which chains the dApp support and some crucial details like for which age category is this dApp suitable and under which category and subcategory does the dApp fall under.</p><p>We can make use of the above details to build a screen which might look like an example suggested below which highlights the individual dApp information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_3wjUKdfEQRRCv1zNIW_Hg.png" /></figure><p><strong>STEP III : Fetching dApp categories</strong></p><p>Now is the time to play around with categories. Meroku Protocol provides a API using which you can get list of all the various categories and sub-categories. Let’s pull the data.</p><pre>https://api-a.meroku.store/dapp/categories</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-nIC7QFpgGx3uTbuvH9CpA.png" /></figure><p>This take us to next step wherein we can showcase which categories does our dApp store is focused on.</p><p>We can now display those categories and subcategories either in drop down format or showcase them in grid format as suggested below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ar3a9lJHCFbnVWou7zNWQA.png" /></figure><p><strong>STEP IV : Adding search bar feature</strong></p><p>Let us now add the search bar on the top for allowing the users to easily search for any dApp.</p><p>You can do so using the autocomplete search API where the user can enters a relevant name of a dApp and it would return all the dApps which contains similar string value in their name.</p><pre>https://api.meroku.store/api/v1/dapp/autocomplete?search={search value} </pre><p>Example:</p><p>If the user search for “Open” it would return relevant dApps like Open Sea, Open Lake, Open fabric etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TDyl0iWpO8RvRP6x03TB5g.png" /></figure><p>You can build the search bar like the example showcased below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WX5YFfUtDrIJ3cVinsBubQ.png" /></figure><p>With the completion of the basic version of a dApp Store, the possibilities for expansion are limitless. Now, you have the freedom to unleash your creativity and build your unique version of a dApp Store that truly stands out.</p><p>You can explore various avenues to enhance the user experience, add new features, and integrate advanced functionalities. Consider implementing features like user authentication, user profiles, personalized recommendations, social sharing, and user reviews. You could also incorporate a rating system for dApps using <a href="https://docs.meroku.store/#/">other APIs provided by Meroku Protocol</a>, allowing users to provide feedback and contribute to the community.</p><p>Additionally, think about catering to specific niches or industries, such as gaming, finance, art, or education. By curating specialized categories, you can attract dedicated user bases and build a vibrant community around your dApp Store.</p><p>So, let your imagination run wild, and go ahead — create the dApp Store of your dreams.</p><p><em>Find me on </em><a href="https://www.linkedin.com/in/rishikeshkale/"><em>LinkedIn</em></a><em> and </em><a href="https://twitter.com/0xrishikesh"><em>Twitter</em></a><em>, I would love to hear from you!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9fca213c235" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is dApp Store Kit?]]></title>
            <link>https://medium.com/@rvk_rishikesh/what-is-dapp-store-kit-c279d3f6f4dc?source=rss-798ccf6d44d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c279d3f6f4dc</guid>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[dapp-store]]></category>
            <category><![CDATA[app-store]]></category>
            <category><![CDATA[polygon]]></category>
            <dc:creator><![CDATA[Rishikesh Kale]]></dc:creator>
            <pubDate>Wed, 26 Jul 2023 14:18:20 GMT</pubDate>
            <atom:updated>2023-07-26T17:21:08.045Z</atom:updated>
            <content:encoded><![CDATA[<p>This article contains essential information that will help all builders comprehend the dApp Store Kit initiative led by <a href="https://meroku.org/">Meroku</a> and gain insights into its workings. It serves as a comprehensive guide for anyone interested in learning about it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aTgUSFaMhWj7YZ_ad-d7qA.png" /><figcaption>dApp Store Kit</figcaption></figure><h3>Empowering the dApp Ecosystem: Introducing the dApp Store Kit</h3><p>The dApp Store Kit represents an open-source, community-driven technology stack that caters to three primary groups:</p><h4><strong>dApp Builders</strong></h4><p>dApp builders or owners can easily register their dApp within the registry to enhance its distribution and discoverability.</p><p>Adding your dApp to the dApp registry comes with a range of compelling benefits. For a new platform, acquiring the first users and early adopters can be challenging. However, with the dApp registry, you gain access to a vast ocean of potential users. Here’s why you should consider being a part of it:</p><ol><li><strong>Showcase to a Wider Audience:</strong> By listing your dApp in the registry, you get the chance to present your application to a diverse and extensive user base. This exposure provides an excellent opportunity to advertise your dApp and share valuable insights about its functionalities.</li><li><strong>Attract New Users:</strong> The registry acts as a hub for users seeking exciting and innovative dApps. Being part of it increases your chances of attracting new users to your platform. It serves as a powerful onboarding channel for expanding your user base.</li></ol><p>Joining the dApp registry is a strategic move that can significantly enhance a dApp’s visibility, user acquisition, and overall success in the competitive market.</p><blockquote><a href="https://polygon.technology/blog/how-to-add-your-application-to-merokus-dapp-store-registry">How to Add Your Application to Meroku’s DApp Store Registry (polygon.technology)</a></blockquote><h4><strong>dApp Store Builders</strong></h4><p>This presents and excellent opportunity for the developers and web3 based platforms to create personalized dApp stores with the freedom to set your own rules for distribution, curation, and governance.</p><p>Enjoy complete control over branding and monetization. Whether you’re a new or established project, this open-source code base can give your platform a head start with innovative storefront solutions.</p><p>You might have missed the bus to create the biggest NFT marketplace or a DeFi platform so here’s your chance to become the biggest dApp distributor platform.</p><blockquote><a href="https://medium.com/@rvk_rishikesh/how-to-ideate-and-build-your-own-dapp-store-f9fca213c235">How to ideate and build your own dApp Store</a></blockquote><h4><strong>Contributors</strong></h4><p>Collaborate and contribute to building a comprehensive dApp-SDK, which includes messaging, analytics, payments, and more. By doing so, you’ll expedite the go-to-market process for dApp and dApp store developers, fostering growth and innovation within the ecosystem.</p><blockquote>The <a href="https://github.com/merokudao/dApp-sdk">dApp SDK</a>, is one-stop solution for creating decentralized applications (dApps) with ease.</blockquote><h3><strong>Why dApp Stores Matter</strong></h3><p>The dApp Store Kit offers a multitude of benefits to enhance the dApp store experience:</p><ol><li><strong>Discoverable</strong>: Enable users to easily find dApps that resonate with them. Curate personalized experiences, making it simple for your users to explore and access relevant dApps.</li><li><strong>Customizable</strong>: Tailor your dApp store to your liking. Set your own rules for monetization, distribution, curation, and governance, providing a unique and engaging platform.</li><li><strong>Secure</strong>: Prioritize user safety and trust. Offer a stable and reliable market to prevent fraud, scams, and hacks, ensuring a secure environment for users and developers alike</li></ol><blockquote>Let’s get ready to embark on this remarkable journey, powered by the dApp Store Kit — where possibilities are limitless, and success knows no boundaries. Start building, curating, and contributing today, and together, let’s shape the future of decentralized app development and distribution.</blockquote><p><em>Find me on </em><a href="https://www.linkedin.com/in/rishikeshkale/"><em>LinkedIn</em></a><em> and </em><a href="https://twitter.com/0xrishikesh"><em>Twitter</em></a><em>, I would love to hear from you!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c279d3f6f4dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zero Knowledge and Identity]]></title>
            <link>https://medium.com/buildbear/zero-knowledge-and-identity-7a7a5ace544a?source=rss-798ccf6d44d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a7a5ace544a</guid>
            <category><![CDATA[identity]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <category><![CDATA[digital-identity-solution]]></category>
            <dc:creator><![CDATA[Rishikesh Kale]]></dc:creator>
            <pubDate>Sat, 07 Jan 2023 05:01:04 GMT</pubDate>
            <atom:updated>2023-01-08T08:34:23.243Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0A-UUFJlPh_y4QV5gGVsvA.jpeg" /></figure><p>ZK is anticipated as one of the technologies that will undoubtedly change Web3. When it comes to ensuring the privacy, security and integrity of blockchain applications ZK looks quite promising.</p><p>Trust is backbone of Blockchain and ZK would be helpful in securing user identity and data, so that they can authenticate themselves in a trustless world.</p><p>In today’s world privacy is the main point of concern. An individual won’t want to reveal his complete identity to get a small job done, but at the same time the verifier also needs the information to confirm if the things are fine to proceed. The answer to this scenario is Zero Knowledge.</p><h3>Understanding Zero Knowledge with an example</h3><p>The classic <a href="https://en.wikipedia.org/wiki/Zero-knowledge_proof#The_Ali_Baba_cave">Ali Baba cave</a> example gives deeper insights about the ZK concept. But for beginners it might be confusing and unclear to get started with understanding the concept of ZK. So let’s discuss another interesting example.</p><p>When you visit to a club, at the entry you are asked to show a proof that you are 18+ in age. Normally you share your ID card which contains your photo, date of birth and other private details like your residential address or your work place details. It’s not desired that just to verify an individual’s age all other private details would also be revealed. Now what’s the solution to this ?</p><p>The answer is ZK proofs. In the above scenario, the individual can generate a ZK proof that he/she is 18+ in age which can be stored as a claim. Now any organisation or individual who wants to verify the claim can do so easily without having a need to look at ID card and check the date of birth. It’s a win-win situation for both the parties as the prover don’t need to reveal his ID card and the verifier can verify is the prover is 18+ in age or not.</p><p>Now, for the online world a user has his/her identity too. Many platform demands for the gmail authentication and unnecessary access to mails and other details. Same is the case with web3 platforms, once the user connects his wallet to the platform, indirectly his entire on-chain data is revealed to that platform via his blockchain wallet address.</p><h3>Existing ZK and Identity Solutions and Tools</h3><p><strong>Polygon ID</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*33P-TV1G3GucwLLYs66yQQ.png" /></figure><p><a href="https://0xpolygonid.github.io/tutorials/">Polygon ID</a> is the first ever to be powered by zero-knowledge (ZK) cryptography, a privacy and blockchain scaling technology. It provides Blockchain-based ID for decentralized and self-sovereign models backed by zero-knowledge native protocols for ultimate user privacy.</p><p><strong>trinsic</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s_s6unuog5hMNuql2hfePQ.png" /></figure><p>You can leverage ZK proofs using t<a href="https://studio.trinsic.id/SignUp">rinsic</a> platform to build your end-to-end identity solution. Trinsic’s API makes it easy to build identity products that helps users manage their data and identity.</p><p><strong>iden3</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*-JOyY94G-I_6FkL0OSWW2A.png" /></figure><p><a href="https://iden3.io/">iden3</a> is a next-generation private access control based on self-sovereign identity, designed for decentralised and trust-minimised environments. The main idea of the iden3 protocol is that each identity is self-soverign and can issue claims on another identity. The iden3 protocol is based on <a href="https://docs.circom.io/">Circom</a> circuits which is the backbone of the protocol.</p><p><strong>Semaphore</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gciYByk6g_3qYFScxzvp3g.png" /></figure><p><a href="https://semaphore.appliedzkp.org/docs/introduction">Semaphore</a> consists of a smart contract and zero-knowledge proof components which work in tandem. The on-chain proof verification and identity state is maintained and handled by smart contract. The zero-knowledge components work off-chain to create identities, manage groups and generate proofs.</p><h3>Conclusion</h3><p>The above discussion would have established a curiosity and a fundamental understanding of zero knowledge proofs and related tools and platforms built over it.</p><p><em>Find me on following socials, I would love to hear from you!</em></p><p>LinkedIn : <a href="https://www.linkedin.com/in/rishikeshkale">https://www.linkedin.com/in/rishikeshkale</a></p><p>Twitter : <a href="https://twitter.com/0xrishikesh">Rishikesh Kale (@0xrishikesh) / Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a7a5ace544a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/buildbear/zero-knowledge-and-identity-7a7a5ace544a">Zero Knowledge and Identity</a> was originally published in <a href="https://medium.com/buildbear">BuildBear Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build your first DataDAO on Filecoin]]></title>
            <link>https://medium.com/@rvk_rishikesh/build-your-first-datadao-on-fvm-6ed38b940103?source=rss-798ccf6d44d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ed38b940103</guid>
            <category><![CDATA[dao]]></category>
            <category><![CDATA[filecoin-foundation]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[filecoin-network]]></category>
            <category><![CDATA[filecoin]]></category>
            <dc:creator><![CDATA[Rishikesh Kale]]></dc:creator>
            <pubDate>Fri, 25 Nov 2022 20:22:05 GMT</pubDate>
            <atom:updated>2023-01-25T19:48:17.442Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide will enable you to program the Filecoin deal market and to make FVM Data DAOs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XIwQygoSeCZl13o-.png" /></figure><p>Before moving ahead let us get a quick insight on how the cycle between storage provider, storage, client and marketplace revolves.</p><p>Storage deals refer to the stored data that is picked up by a Storage Provider in the Filecoin network. A deal is initiated with the Storage Client to store the data. The deal’s details and metadata of the stored data is then uploaded onto the Filecoin blockchain. FVM/FEVM allows interaction with this metadata, effectively computing over state.</p><h3>Coding Data DAO contract</h3><p>This article would be based on this <a href="https://github.com/rk-rishikesh/client-contract/blob/data-dao-example/src/DataDAOExample.sol">repo</a>. You can clone it and get started.</p><pre>git clone <a href="https://github.com/rk-rishikesh/client-contract/tree/data-dao-example">https://github.com/rk-rishikesh/client-contract/blob/data-dao-example</a></pre><p>Well you must have gone through the example Data DAO contract. Let’s deploy it and understand the flow.</p><p>Time to head over to <a href="https://remix.ethereum.org/">Remix IDE</a>.</p><p>Once your are done with compiling the contract, deploy the Data DAO contract on <a href="https://wallaby.network/">Wallaby- Testnet for Filecoin</a>. You can find the contract at this path : /src/DataDAOExample.sol</p><p>This contract enables the storage provider to add the CID inorder to store data with the Filecoin builtin deal market. The process of adding the CID has to go through policy check where the CID needs to be approved by DAO members via voting mechanism.</p><p>Let’s us now go step by step. The storage provider can create a proposal to add his CID using <strong>createAddCIDProposal</strong> function.</p><p>As FEVM is pre-launch to Filecoin’s main net, FEVM actors today cannot yet interact easily with storage deals on the Filecoin network.</p><p>To simulate this for the hack, we have a sample CID related data. These deals are built into the Wallaby test network and your actor is able to interact with them.</p><pre>Sample Test Data<br><br>testCID = &quot;0x000181E2039220206B86B273FF34FCE19D6B804EFF5A3F5747ADA4EAA22F1D49C01E52DDB7875B4B&quot;;<br>testSize = 2048<br>testProvider = &quot;0x0066&quot;;<br>testmessageAuthParams = &quot;0x8240584c8bd82a5828000181e2039220206b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b190800f4420068420066656c6162656c0a1a0008ca0a42000a42000a42000a&quot;;</pre><p>Let us create a add CID proposal, using the above test data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*Z7OCvk6ouRCOsUwkLw5zKA.png" /></figure><p>Once you have created the proposal, you would be able to see all the basic data related to that proposal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*oaA7j9yNtoXePm-7wZcDHg.png" /></figure><p>Now, its time for the DAO members to vote on that proposal before the voting period ends. If the total count of upvotes is greater than the total count of downvotes then the proposal would be passed else it would be considered as rejected. This contract uses a simple DAO mechanism, you can frame and implement your own rules and make its more interesting and secure.</p><blockquote>Note : Only members apart from the storage provider would be able to cast a vote and each member can vote only once.</blockquote><p>Enough said. It’s time to vote ! To keep it simple, I would be upvoting and passing this proposal. You can always play around with this.</p><p>If you go back and check the details of the proposal the count of upvotes would have been incremented to 1 whereas the downvotes would be still zero.</p><blockquote>Note : This voting process should be completed with 5 minutes from creation of the proposal. You can make changes in the contract and increase the timer accordingly.</blockquote><p>Okay. All done with voting part !!</p><p>Now since we have passed the proposal, now its time to publish our deal. Incase the DAO failed the proposal, the storage provider won’t be able to publish his deal.</p><p>We have a mock marketplace contract, lets deploy that first. This contract takes the contract address of our DAO contract i.e the client contract inside its constructor.</p><p>Let us publish the deal, this function takes two inputs the message auth param which you can get from the test data and the respective proposal ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*cIZ73WGoALajdnylXriUlA.png" /></figure><p>If the proposal was passed this function would get executed successfully else, it would fail.</p><p>That’s it ! This was a quick guide as in how you can play around with the <a href="https://github.com/lotus-web3/client-contract/blob/main/src/DealClient.sol">basic client contract</a>.</p><p>If you wanna learn more about Filecoin and storage deals. Check <a href="https://medium.com/@rvk_rishikesh/filecoin-storage-basics-68be5062e423">this</a> out.</p><p><em>Find me on following socials, I would love to hear from you!</em></p><p>LinkedIn : <a href="https://www.linkedin.com/in/rishikeshkale">https://www.linkedin.com/in/rishikeshkale</a></p><p>Twitter : <a href="https://twitter.com/0xrishikesh">Rishikesh Kale (@0xrishikesh) / Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ed38b940103" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Filecoin Storage Basics]]></title>
            <link>https://medium.com/@rvk_rishikesh/filecoin-storage-basics-68be5062e423?source=rss-798ccf6d44d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/68be5062e423</guid>
            <category><![CDATA[filecoin-miner]]></category>
            <category><![CDATA[fvm]]></category>
            <category><![CDATA[filecoin]]></category>
            <category><![CDATA[filecoin-mining]]></category>
            <category><![CDATA[filecoin-network]]></category>
            <dc:creator><![CDATA[Rishikesh Kale]]></dc:creator>
            <pubDate>Tue, 22 Nov 2022 14:23:39 GMT</pubDate>
            <atom:updated>2022-11-22T14:23:39.546Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s start with a basic question — What is Filecoin ?</p><figure><img alt="Filecoin" src="https://cdn-images-1.medium.com/max/1024/0*uKgXPorf6WLW7B-5.png" /></figure><p>Filecoin is a blockchain managed distributed system, wherein the data is not stored on blockchain but accounting for that data is managed over blockchain.</p><p>Filecoin Blockchain has its own native cryptocurrency, known as FIL. Now Now … What a minute !! If Filecoin got its own native cryptocurrency how is it mined ?</p><p>Well we got the miners here too but the role of miners here is quite different from what miners do in proof of stake. Filecoin miners offers storage to the market and that is how the FIL is mined.</p><p>The miners pack the data in batches and freeze it for predefined period of time and during this period they need to continuously prove that they hold the data, and this proof is based on the zero knowledge cryptographic algorithm. Which means in-order to prove that a miner holds that data, the data is not revealed to the chain.</p><h3>Storage Basic</h3><p>Miners continuously seal new storage sectors, which have pre-specified lifetime, upto 18 months and a minimum of 6 months, as preferred by miners. This affects the storage deals, for example if you want to store your data foe 100 years you would have to renew the storage deals in order to store data for longer period of time.</p><p>Count of sealed sectors a miner possess is directly proportional to the miner’s power. Power increase a miner’s chances of winning block rewards from the chain and that is how they earn FIL from blockchain and not just from deals.</p><p>Theres an interesting concept called as Committed Capacity sectors. Let’s know more about it.</p><p>Sectors containing no deal data are called as committed capacity sectors. They contribute to the total network capacity without storing any kind of useful data. But why do we need such sectors ? CC sectors remove the incentive to fake deals where miners pretend to have deal data to increase the power. With CC sectors the miners don’t need to pretend in such a manner as they can still earn for storing no data as it contributes to total network capacity signalling the users that there is a real hardware in the network that has the capability to store data.</p><h3>Proving Storage</h3><p>As mentioned earlier, miners have to continuously prove that they retain each of their sectors as they were frozen. They have to submit “Proof of Space Time” (PoST) at regular intervals during each dat of the sector’s lifetime. Management of the deadlines to submit these proofs is done via submission windows which are managed by the chain. This concept is termed as Window PoST.</p><p>What if a miner failed to prove the possession of sealed sectors ? Ofcourse they are penalised if they miss consecutive proving deadlines.</p><p>Hmm … are you questioning the same ? What if there are some minor chain problems or any kind of outage ? Nothing to worry here. Filecoin got this covered as well. The chain is heavily optimised for always been available and always able to prove the existence of data.</p><p>Incase the sectors are not proven over a period of 14 consecutive days they are terminated and a penalty is applied. If a miner goes down clients who have deals associated with the terminated sector get portion of their funds returned to them.</p><h3>Collateral</h3><p>Collateral is an important aspect of the incentive system. Miners have to lock up an amount of FIL as collateral when they seal sectors, the amount is determined by the chain state at time of sealing.</p><p>Wait that’s not it.</p><p>Deals can also be customised and negotiated wherein the client can raise additional collateral requirement if the data is super important to be sure that the miner is serious about storing that data. They miner is also rewarded accordingly when he gets back his collateral.</p><h3>Making Deals</h3><h4>Regular Deals</h4><p>Deals can be made in a live market by a client contacting a miner directly and querying different deal conditions like price per GiB per epoch, min size and max size from various miners. After evaluating the various price rate the client proposes a deal. When proposing deal, the client must have FIL provably locked up in the Filecoin “market” to make the deal.</p><blockquote>This is what <a href="https://docs.filecoin.io/fvm/basics/introduction/">FEVM</a> unlocks — smart contract on FVM as a deal client, that interacts with the Filecoin built-in storage market.</blockquote><p>Miners have complete freedom as to which deals they want to accept or reject even if whether it matches their capability or not.</p><p>Once the miner accepts a deal, the client transfers the data to the miner. Thereafter, the miner includes the data into the sector they are committing to the chain. After deal confirmation is place on chain the data is pointed top its location in the sector. Then the sector is sealed and the replica proof is placed on chain.</p><p>All the process is so well managed that once the deal is confirmed the exchange of data and funds happen smoothly and none of the two can backout. Upon successful deal and seal, funds are locked in escrow.</p><h4>Filecoin Plus Deals</h4><p>Filecoin Plus is a way as in how storage providers can engage with verified clients. It adds a layer of social trust to the Filecoin network to incentivize useful storage and facilitate deals with verified clients.</p><p>The core mechanism of how FIL+ works is — Root key holders, notaries, clients, and storage providers interact through the allocation and spending of DataCap.</p><p>Notaries apply through community governance and work with the root key holders to get a grant of DataCap, which they can then allocate out to clients. Those clients are then able to deploy DataCap to the storage providers in deals.</p><h3>Enter FVM</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kBHD2vuBFI5K9uY-.png" /></figure><p>Now with the introduction of <a href="https://fvm.filecoin.io/">FVM</a> a wide range of possibilities have opened up. The builtin storage market actor can delegate authorization of a deal proposal to an arbitrary FVM contract. This allows any Filecoin contract to act as a client of the storage market. This concept acts a support pillar for data DAOs and other programmable storage projects.</p><p>If you are looking at more such possible ideas want to get started building around it head towards this <a href="https://github.com/lotus-web3/client-contract">repo</a> and get started.</p><p>An exciting journey awaits you !</p><p><em>Find me on following socials, I would love to hear from you!</em></p><p>LinkedIn : <a href="https://www.linkedin.com/in/rishikeshkale">https://www.linkedin.com/in/rishikeshkale</a></p><p>Twitter : <a href="https://twitter.com/0xrishikesh">Rishikesh Kale (@0xrishikesh) / Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68be5062e423" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying your first smart contract on FVM]]></title>
            <link>https://medium.com/@rvk_rishikesh/deploying-your-first-smart-contract-on-fvm-bc4c33e63cf0?source=rss-798ccf6d44d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc4c33e63cf0</guid>
            <dc:creator><![CDATA[Rishikesh Kale]]></dc:creator>
            <pubDate>Wed, 19 Oct 2022 09:07:02 GMT</pubDate>
            <atom:updated>2022-10-19T09:07:02.578Z</atom:updated>
            <content:encoded><![CDATA[<p>Filecoin Virtual Machine is execution environment for Actors on the Filecoin blockchain. Actors are the Filecoin-equivalent of what the industry calls “smart contracts”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o6YSJHwhwAgu_h0qoDDwng.png" /></figure><p>Let’s create and deploy our first actor on FVM.</p><h3>Getting Started</h3><p>We would be using the official hardhat boiler plate for deploying the actors on FVM.</p><p>You can find the starter kit <a href="https://github.com/filecoin-project/FEVM-Hardhat-Kit">here</a>.</p><h3>Clone the Repo</h3><pre>git clone https://github.com/filecoin-project/FEVM-Hardhat-Kit</pre><p>This will clone the hardhat starter kit on your local device. Next enter the FEVM-Hardhat-Kit directory and install the dependencies.</p><pre>cd FEVM-Hardhat-Kit <br>yarn install</pre><h3>Set up your private key</h3><p>The private key for your FIL address would remain same as for your ETH address. You can get a private key for yourself from wallet provider like Metamask.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MzbPMekegv1-T5T7ON29xQ.png" /></figure><p>You can store your private key inside dot env file as an environment variable.</p><p>It is recommended, that you store the private key in dot env file and make sure that you don’t commit and push any changes to .env files.</p><h3>Fetching Deployer’s address</h3><p>To get the deployer’s address i.e the FIL address from which the contract would be deployed execute the following command on command prompt.</p><pre>yarn hardhat get-address</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9qXE1VWZZ0Jdawn9qQOrLw.png" /></figure><p>Now there is a possibility that you get the above error, this is because your FIL address has not received Filecoin yet. Let’s get them.</p><h3>Fund the deployer address</h3><p>You can get faucet for wallaby test network from <a href="https://wallaby.network/#faucet">here</a>.</p><p>Copy the f1 address generated above and paste it to get 5K FIL on your deployer account address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YOOCQuao1_9B61DXUPU90Q.png" /></figure><p>Let us check the balance on <a href="https://explorer.glif.io/">blockchain explorer by glif.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6FPBRQoIMcK0olOGB06IRQ.png" /></figure><p>Make sure you change the network to Wallabynet, since we received the faucets on Wallaby network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2zHi7BhikUCZZ6s3En_YQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*otbxG__l8tv0EfKVrZCnqQ.png" /></figure><h3>Deploy the actor on Wallaby Network</h3><pre>yarn hardhat deploy</pre><p>Executing the above command should compile and deploy the actor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ihzx4qObxhS5lRbzzRv73A.png" /></figure><p>Oh nooo !! We were going all good but we got one last error on our way to deploy the actor.</p><p>Well nothing to worry about. This is just because the nonce value is zero. You can expect in the later version of the starter-kit this issue would be fixed. But what to do for now ??</p><p>I got you covered. As we all know the nonce is<strong> the number of transactions sent from</strong> a given address. So inorder to make it non-zero all we need to do is carry out a transaction from our FIL address. You might be wondering how should we do that, can we do it from Metamask ? Umm no! So do we have a wallet for wallaby network ? Yes, <a href="https://wallet.glif.io/?network=wallabynet">here</a> it is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bchJcgeCNWoX0IsvF_1_hg.png" /></figure><p>First let us import our account into the wallet using Private Key.</p><blockquote>Note : Private key need to be an instance of Buffer or a base64 string.</blockquote><pre>echo hex_private_key | xxd -r -p | base64</pre><p>You can convert your private key to base64 using the above command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxcNniJPdG4GoXy05-49cA.png" /></figure><p>Now you can send some amount of FIL to some another wallet and carry out your first transaction. You can refer the “<em>Fetching Deployer’s address”</em> section to generate the FIL address using another private key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v2HpWEVGVlhrkslRvgh5pA.png" /></figure><p>Let’s check the transaction history on the explorer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d0A6ryRk08p1WG8DatAoFA.png" /></figure><p>Cool! We have successfully carried out the first transaction.</p><p>It’s now time for the final deploy 🚀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qXRPlZuPUq5gArxHxPdqLg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oqkRifycQ1Bgyt-K7Rt0cQ.png" /></figure><p>Yay !! 🥳 We have successfully deployed our first actor on FVM.</p><p><em>Find me here on following socials, I would love to hear from you!</em></p><p>LinkedIn : <a href="https://www.linkedin.com/in/rishikeshkale">https://www.linkedin.com/in/rishikeshkale</a></p><p>Twitter : <a href="https://twitter.com/0xrishikesh">Rishikesh Kale (@0xrishikesh) / Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc4c33e63cf0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up MetaMask Mobile application on Android device]]></title>
            <link>https://medium.com/@rvk_rishikesh/setting-up-metamask-mobile-application-on-android-device-da279f2c30f1?source=rss-798ccf6d44d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/da279f2c30f1</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[metamask-mobile]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[getting-started]]></category>
            <category><![CDATA[metamask]]></category>
            <dc:creator><![CDATA[Rishikesh Kale]]></dc:creator>
            <pubDate>Fri, 04 Sep 2020 18:03:15 GMT</pubDate>
            <atom:updated>2020-09-04T18:18:22.746Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*PVaCaz5Vi0L5aGnhFv1fYA.jpeg" /><figcaption>MetaMask</figcaption></figure><p>It’s great that you’re here, because in this tutorial I’m gonna discuss about how we can set up the MetaMask mobile application in an Android device, just enough for you to get started with the application.</p><h3><strong>Introduction to MetaMask Mobile</strong></h3><p>The interaction with blockchain-based applications is now eased with MetaMask Mobile app, without compromising the security or ease of use that makes MetaMask the most trusted Ethereum wallet. The users will now be able to perform all the transactions directly from their mobile.</p><p>This mobile application also allows people to explore the Web3 as easily as any mobile web browser, as it introduces its security capability to web browsing.</p><h3>How can I download it on my mobile?</h3><p><strong>Step 1</strong>: Go to the Android Play Store, and search MetaMask in the search bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*P4fzz7kH2ZkLHLnMz7Ncog.png" /></figure><p><strong>Step 2</strong>: Install the mobile application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*14ZoSlOKUTpAB-eQx3Li-w.png" /></figure><p>Yay!! You have successfully installed the MetaMask on your mobile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*c0qGedxvEvAYFwWKJa-9BQ.png" /></figure><p>The application provides you three choices to get started with -</p><ol><li>Import using seed phrase</li><li>Sync with MetaMask extension</li><li>Create a new wallet</li></ol><p>Let’s discuss all three methods one by one.</p><h4>Importing using seed phrase</h4><p>To import your wallet account using this method follow the following steps:</p><p><strong>Step 1</strong>: Enter your seed phrase in the given field.</p><p><strong>Step 2</strong>: Enter New Password of your choice and confirm by entering it again in the later field.</p><p>MetaMask mobile allows you to sign in into the account with Fingerprint scanner instead of entering your password every time you access your account.</p><p>This method is used mostly to recover your wallet if you get locked out of the app or get a new device.</p><h4>Sync with MetaMask extension</h4><p>You can opt for this method, if you are already logged in to your account on your desktop via desktop extension. Follow the following steps to sync your account on your mobile with MetaMask extension of your desktop.</p><p><strong>Step 1</strong>: Open the extension on desktop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O09C_u6USye430R0CXUAcg.png" /></figure><p><strong>Step 2</strong>: Go to Settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3rph1WV7ecbfZx4aXdV0CQ.png" /></figure><p><strong>Step 3</strong>: Click on Sync with mobile option under advanced Settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xW1SuJmMezDa9fIFs3Xh_A.png" /></figure><p><strong>Step 4</strong>: Enter the password of your account and click next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wBpb1JyYTvXUPPM1NUHZ5w.png" /></figure><p><strong>Step 5</strong>: Scan the QR code displayed on your desktop screen using your mobile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Milr98IELOQCSINzUwonPw.png" /></figure><p>Your account is now successfully synced on your mobile and your entire transaction history will also sync within seconds.</p><h4>Create a new wallet</h4><p>If you are using MetaMask for the first time then this option is for you. Follow the following steps to create your new wallet.</p><p><strong>Step 1</strong>: Create Password. Enter a strong password and confirm it by entering it again in the respective field. Read the instruction written which states that MetaMask cannot recover this password, so you need to remember this password. Check the box and proceed to next step by clicking on ‘Create password’ button.</p><p><strong>Step 2</strong>: In this step you have to secure your wallet, by storing a unique seed phrase. A seed phrase is unique to every account and it provides the only way to recover your wallet by importing your account using the seed phrase.</p><p><strong>Step 3</strong>: To proceed click on ‘Start’ button on the bottom of your screen. The next screen explains the importance of seed phrase and how you can safely store it.</p><blockquote><strong><em>NOTE: NEVER SHARE YOUR SEED PHARSE WITH ANYONE.</em></strong></blockquote><p>To proceed again click on ‘Start’ button on the bottom of your screen after reading the instructions.</p><p><strong>Step 4</strong>: Now confirm your password and then click on View. Make sure nobody else is around you observing your screen. The screen would now display ordered 12 words which forms a seed phrase. Remember the seed phrase in the given order or write it down at a safe place and click ‘Continue’.</p><p><strong>Step 5</strong>: Now enter the seed phrase words in the order as it was displayed before. After you complete it hit the ‘Complete Backup’ button.</p><p>Your account has now been successfully created.</p><p>You are now ready to rock and explore the MetaMask mobile application!!🎉</p><p><em>Please check me out on </em><a href="http://www.linkedin.com/in/rishikeshkale"><em>LinkedIn</em></a><em> as well, I would love to hear from you!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da279f2c30f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Super Over Smart Contract 3.0 in Solidity]]></title>
            <link>https://medium.com/@rvk_rishikesh/the-super-over-smart-contract-3-0-in-solidity-6278877e181e?source=rss-798ccf6d44d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6278877e181e</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[events]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[solidity-tutorial]]></category>
            <category><![CDATA[require]]></category>
            <dc:creator><![CDATA[Rishikesh Kale]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 18:26:03 GMT</pubDate>
            <atom:updated>2020-08-27T14:42:55.874Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>This is the third article in a series of articles about constructing a Smart Contract in Solidity. Let’s head towards Super Over Smart Contract Version 3.0.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lhSq2kRPonK9iHHzcyYn0A.jpeg" /></figure><p>In the last two versions we learned to apply the <a href="https://medium.com/@rvk_rishikesh/getting-started-with-solidity-using-remix-ide-7da204336515">basic concepts</a>, <a href="https://medium.com/@rvk_rishikesh/control-structures-and-data-structures-in-solidity-791ec18cdd58">control structures and data structures </a>in solidity programming language.</p><p><strong>1. IN THIS ARTICLE …</strong></p><p>What’s new in the third version? Till the last version, we witnessed multiple if- else statements, however there was no provision to display a message by the smart contract if either of the if statements fails. The display statements are useful to identify the errors as well as to know why the transaction failed. However solidity does not provide printf statements unlike in other programming languages.</p><p>We can communicate with smart contract using require function. It is mostly used to ensure valid conditions or that the contract state variables are met. It can be potentially used to replace most of the if statements from our previous version of the smart contract.</p><p>Solidity provides another function known as function modifier. We’re going to create a modifier that will allow only the authorized person<strong> </strong>to access a specified function.</p><p>Events are the way to inform external monitoring entities about the certain activities in the smart contracts they can also be used as a log in the system. It is another way to display the data stored in blockchain.</p><p>Let’s move on towards writing the smart contract:</p><p><strong>2. RECONSTRUCTING THE CONSTRUCTOR</strong></p><p>Till the previous version we initialized only the account address of the umpire at the time of deployment through the constructor and the account address of the two teams participating in the match were initialized later in the smart contract. However since the participating teams are declared before the match we can initialize their account address in the constructor itself as stated below.</p><pre>constructor(address addTeamA,address addTeamB) public<br>    {<br>        umpire = msg.sender;<br>        TeamA  = addTeamA;<br>        TeamB  = addTeamB;<br>        stage  = Stage.RegTeams;<br>    }</pre><p><strong>3. USING FUNCTION MODIFIERS AND REQUIRE STATMENTS</strong></p><p><strong>Syntax of</strong> require <strong>statement</strong></p><pre>require(condition, &quot;Message to be displayed&quot;);</pre><p><strong>Syntax of </strong>function modifier</p><pre>modifier functionModifierName()<br>    {<br>        require(condition, &quot;Message to be displayed&quot;);<br>        _;<br>    }</pre><p>In our smart contract we want to restrict the access of few functions only to the umpire. The another restriction we would add is to restrict the number of runs scored in one ball.</p><pre>modifier onlyUmpire()<br>    {<br>        require(msg.sender == umpire, &quot;You are not an Umpire&quot;);<br>        _;<br>    }</pre><p>The function modifier -onlyUmpire would allow only the umpire to access the function to which this modifier is added. Incase, a person other than the umpire tries to access that function the smart contract would display the message- “You are not an Umpire” thereby restricting the access.</p><pre>    modifier onlyTeamA()<br>    {<br>        require(msg.sender == TeamA, &quot;Only TeamA is authorised to access this function&quot;);<br>        _;<br>    }<br>    <br>    modifier onlyTeamB()<br>    {<br>        require(msg.sender == TeamB, &quot;Only TeamB is authorised to access this function&quot;);<br>        _;<br>    }</pre><p>The above two function modifiers makes sure that only TeamA and TeamB respectively is able to access a function to which these modifiers are added.</p><p>The following function modifier -vaildRun verifies if the data entry of the runs scored by a batsman on a particular ball is valid or not.</p><p>For simplicity we would consider -0, 1, 2, 3, 4, 6 runs as valid runs.</p><pre>modifier vaildRun(uint runs)<br>    {<br>        require(runs &gt; 0 &amp;&amp; runs &lt;=6 &amp;&amp; runs!=5 , &quot;Invalid entry of runs&quot;);<br>        _;<br>    }</pre><p>Incase of invalid data entry of runs the smart contract would display the message - “Invalid entry of runs”.</p><p>Now let’s add these function modifiers to the functions of our smart contract.</p><p>We want only TeamA and TeamB be able to register themselves so that no other third party in the blockchain network would be able to practice any illegal activity. We do this by adding the function modifer to the following functions.</p><pre>function registerTeamA(string memory nameTeamA) onlyTeamA() public<br>    {<br>        require(stage == Stage.RegTeams,&quot;Not a right stage | Expected Stage : RegTeams&quot;);<br>        teamdata[TeamA].name = nameTeamA;<br>        stage = Stage.RegTeams;<br>    }<br>    <br>function registerTeamB(string memory nameTeamB) onlyTeamB() public<br>    {<br>        require(stage == Stage.RegTeams,&quot;Not a right stage | Expected Stage : RegTeams&quot;);<br>        teamdata[TeamB].name = nameTeamB;<br>        stage = Stage.inningsTeamA;<br>    }</pre><p><strong>Syntax:</strong></p><pre>function functionName(parameters) functionModifier()<br>{<br>  //function body <br>}</pre><p>To allow only the umpire to update the scores of the team we will be using onlyUmpire function modifier. And to restrict the runs scored in a single ball we will add validRun function modifier.</p><pre>function maintainScoreTeamA(uint runs) onlyUmpire() vaildRun(runs) public<br>    {<br>        require(stage == Stage.inningsTeamA,&quot;Not a right stage | Expected Stage : inningsTeamA&quot;);<br>        if(teamdata[TeamA].balls &gt; 6) <br>            return;<br>        teamdata[TeamA].score += runs;<br>        teamdata[TeamA].balls++;<br>        if(teamdata[TeamA].balls == 6 ) <br>            { stage =   Stage.inningsTeamB; }<br>    }<br>    <br>function maintainScoreTeamB(uint runs) onlyUmpire() vaildRun(runs) public<br>    {<br>        require(stage == Stage.inningsTeamB,&quot;Not a right stage | Expected Stage : inningsTeamB&quot;);<br>        if(teamdata[TeamB].balls &gt; 6) <br>            return;<br>        teamdata[TeamB].score += runs;<br>        teamdata[TeamB].balls++;<br>        if(teamdata[TeamB].balls == 6 ) <br>            { stage = Stage.AnnounceResult; }<br>    }</pre><blockquote><strong>NOTE</strong> : We have replaced the if-statements from the previous version of the smart contract with require statements in the above functions to validate the state.</blockquote><blockquote>It is recommended to carefully analyze the function and understand its working line-by-line.</blockquote><p><strong>3. USING EVENTS</strong></p><p>Lastly we have winner function which declares the winner of the match. We will make use of event to display the winner of the match.</p><p><strong>Syntax:</strong></p><pre>event eventName(comma seperated parameters);</pre><p>The events are declared outside the functions as stated above and are triggered to emit the values inside the function as stated below.</p><pre>emit eventName(comma separated value of the parameters);</pre><p>Let’s implement this in our winner function.</p><p>Declaring the event:</p><pre>event Message(string message);</pre><p>Triggering the event inside the function:</p><pre>function winner() public  <br>    {<br>        require(stage == Stage.AnnounceResult,&quot;Not a right stage | Match is yet to be finished | Expected Stage : AnnounceResult&quot;); <br>        if(teamdata[TeamA].score &gt; teamdata[TeamB].score) <br>            emit Message(teamdata[TeamA].name);<br>        if(teamdata[TeamA].score == teamdata[TeamB].score) <br>            emit Message(&quot;Trophy is Shared&quot;);<br>        else emit Message(teamdata[TeamB].name);<br>    }</pre><p>By the time you reach here your code would be looking like this :</p><pre>pragma solidity ^0.5.9;</pre><pre>contract SuperOver{<br>    <br>    address public umpire;<br>    address public TeamA ;<br>    address public TeamB ;<br>    <br>    struct Team{<br>        string name;<br>        uint score;<br>        uint balls ;<br>    }<br>    <br>    mapping(address =&gt; Team) teamdata;<br>    <br>    enum Stage { Init , RegTeams , inningsTeamA , inningsTeamB , AnnounceResult }<br>    Stage public stage = Stage.Init;<br>    <br>    constructor(address addTeamA,address addTeamB) public<br>    {<br>        umpire = msg.sender;<br>        TeamA = addTeamA;<br>        TeamB = addTeamB;<br>        stage = Stage.RegTeams;<br>    }<br>    <br>    modifier onlyUmpire()<br>    {<br>        require(msg.sender == umpire, &quot;You are not an Umpire&quot;);<br>        _;<br>    }<br>    <br>    modifier onlyTeamA()<br>    {<br>        require(msg.sender == TeamA, &quot;Only TeamA is authorised to access this function&quot;);<br>        _;<br>    }<br>    <br>    modifier onlyTeamB()<br>    {<br>        require(msg.sender == TeamB, &quot;Only TeamB is authorised to access this function&quot;);<br>        _;<br>    }<br>    <br>    modifier vaildRun(uint runs)<br>    {<br>        require(runs &gt;0 &amp;&amp; runs &lt;=6 &amp;&amp; runs!=5 , &quot;Invalid entry of runs&quot;);<br>        _;<br>    }<br>    <br>    event Message(string message);<br>        <br>    function registerTeamA(string memory nameTeamA) onlyTeamA() public<br>    {<br>        require(stage == Stage.RegTeams,&quot;Not a right stage | Expected Stage : RegTeams&quot;);<br>        teamdata[TeamA].name = nameTeamA;<br>        stage = Stage.RegTeams;<br>    }<br>    <br>    function registerTeamB(string memory nameTeamB) onlyTeamB() public<br>    {<br>        require(stage == Stage.RegTeams,&quot;Not a right stage | Expected Stage : RegTeams&quot;);<br>        teamdata[TeamB].name = nameTeamB;<br>        stage = Stage.inningsTeamA;<br>    }<br>    <br>    function maintainScoreTeamA(uint runs) onlyUmpire() vaildRun(runs) public<br>    {<br>        require(stage == Stage.inningsTeamA,&quot;Not a right stage | Expected Stage : inningsTeamA&quot;);<br>        if(teamdata[TeamA].balls &gt; 6) <br>            return;<br>        teamdata[TeamA].score += runs;<br>        teamdata[TeamA].balls++;<br>        if(teamdata[TeamA].balls == 6 ) <br>            { stage =   Stage.inningsTeamB; }<br>    }<br>    <br>    function maintainScoreTeamB(uint runs) onlyUmpire() vaildRun(runs) public<br>    {<br>        require(stage == Stage.inningsTeamB,&quot;Not a right stage | Expected Stage : inningsTeamB&quot;);<br>        if(teamdata[TeamB].balls &gt; 6) <br>            return;<br>        teamdata[TeamB].score += runs;<br>        teamdata[TeamB].balls++;<br>        if(teamdata[TeamB].balls == 6 ) <br>            { stage = Stage.AnnounceResult; }<br>    }<br>    <br>    function winner() public  <br>    {<br>        require(stage == Stage.AnnounceResult,&quot;Not a right stage | Match is yet to be finished | Expected Stage : AnnounceResult&quot;); <br>        if(teamdata[TeamA].score &gt; teamdata[TeamB].score) <br>            emit Message(teamdata[TeamA].name);<br>        if(teamdata[TeamA].score == teamdata[TeamB].score) <br>            emit Message(&quot;Trophy is Shared&quot;);<br>        else emit Message(teamdata[TeamB].name);<br>    }<br>    <br>}</pre><h3>Compiling the Solidity Smart Contract using Remix IDE</h3><p>Copy paste the code into <a href="https://remix.ethereum.org/">Remix IDE</a> in the newly created file.</p><p>Now let’s execute it and see it running.</p><p>We begin with deploying the Smart Contract. Here we initialize the account address of umpire(the address at which the smart contract is deployed), Team A and Team B.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*uLV2M9LOGxXyiTmZt3wAGg.jpeg" /><figcaption>Deploying the Smart Contract</figcaption></figure><p>After you compile and deploy the code you will be able to see the buttons of the functions we created along with the public variables we had declared in our Smart Contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*1Edn2Vzi1a_Noj8YdozL_Q.jpeg" /></figure><p>Let’s set up the game by registering both the teams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*sSK8aEhaZ2HdAeBJvLI_ng.jpeg" /><figcaption>Registration of Team A</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*uAT-E87iLKrCbxlO-KZD7g.jpeg" /><figcaption>Registration of Team B</figcaption></figure><p>Note : While registering a team make sure that the account selected is that of the team which you are registering. If this requirement is not met the condition of the function modifier fails and so does the transaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dinAcOJJo3iQaSZjQvUQMQ.jpeg" /></figure><p>Let the match begin !!</p><p>Team A would be batting first and would set target for Team B.</p><p>As we did in previous two versions of our smart contract we will enter the runs ball-by-ball as per the score timeline given below.</p><p>For Team A :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*AcowRRF-dMbFJlk3_I93zQ.jpeg" /><figcaption>Team A score timeline</figcaption></figure><p>For Team B :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*GqU4YVuulEOyk2qAiuf-qw.jpeg" /><figcaption>Team B score timeline</figcaption></figure><blockquote><em>Note : After entering runs after each ball you need to transact it to add the runs to teams total score.</em></blockquote><p><em>Refer </em><a href="https://medium.com/@rvk_rishikesh/the-super-over-smart-contract-using-solidity-b31a93f002f8"><em>version 1</em></a><em> and </em><a href="https://medium.com/@rvk_rishikesh/the-super-over-smart-contract-2-0-in-solidity-c18394e5b2f7"><em>version 2</em></a><em> for detailed explanation.</em></p><h3>Its time to announce the winner</h3><p>And the winner is …</p><p>The name of the winner is emitted when the winner function is called and is visible under logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*icbKXmXt7LxWy1cMjtf3VQ.jpeg" /><figcaption>Winner</figcaption></figure><p>With two magnificent strokes in the last two balls Team B have emerged winners.</p><blockquote><em>Congratulations!! 🎉<br>You successfully designed and deployed the Super Over Smart Contract 3.0 .</em></blockquote><p><em>That wraps up the step-by-step article for now.</em></p><p>Other articles in this series:</p><ul><li><a href="https://medium.com/@rk.rtistic/the-super-over-smart-contract-using-solidity-b31a93f002f8">Part 1: Super Over Smart Contract Version1.0</a></li><li><a href="https://medium.com/@rvk_rishikesh/the-super-over-smart-contract-2-0-in-solidity-c18394e5b2f7">Part 2: Super Over Smart Contract Version 2.0</a></li></ul><p><em>Please check me out on </em><a href="http://www.linkedin.com/in/rishikeshkale"><em>LinkedIn</em></a><em> as well, I would love to hear from you!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6278877e181e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blockchain in a nutshell]]></title>
            <link>https://medium.com/@rvk_rishikesh/blockchain-in-a-nutshell-3d058f846d50?source=rss-798ccf6d44d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d058f846d50</guid>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[use-cases]]></category>
            <category><![CDATA[basics]]></category>
            <category><![CDATA[decentralized]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Rishikesh Kale]]></dc:creator>
            <pubDate>Thu, 04 Jun 2020 18:15:54 GMT</pubDate>
            <atom:updated>2020-06-04T18:29:03.663Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Decentralized Network" src="https://cdn-images-1.medium.com/max/1024/1*uJyv8ynHOdFHFOhB9Qbplg.png" /></figure><h3><strong>1. Basics of Blockchain</strong></h3><h4>1. 1 What is Blockchain ?</h4><p>Blockchain is a decentralized ledger of all transactions across a peer-to-peer network using this technology, participants can confirm transactions without the need for a central certifying authority.</p><h4>1.2 Background of Blockchain</h4><ul><li>The concept of <strong>blockchain</strong> was first introduced in a white paper published by a person. A group of people known by the name Satoshi Nakamoto in 2008.</li><li>This paper proposed the term ‘chain of blocks’. Later, the term ‘chain of blocks’ evolved into the word blockchain.</li><li><strong>Blockchain</strong> is a distributed, decentralized database(ledger) in which transactions can be added as blocks through consensus mechanisms.</li></ul><h4>1.3 Blockchain Architecture</h4><p>The basic architectural components of a blockchain are <br>- nodes <br>- transactions <br>- blocks<br>- consensus mechanism.</p><p>Blocks are collections of transactions that are bundled together to be added to the blockchain. Blocks are created by the process of <strong>Mining.</strong></p><p>A block is divided into two parts, a <strong>block header</strong> containing the metadata used for verifying the block and the <strong>transactions</strong> to be added to the blockchain.</p><pre>Block Header consists of following components :<br> <strong>1. Previous block hash</strong><br>  a hash representing the address of the previous block<br> <strong>2. Timestamp</strong><br>  represents the time when the block created<br> <strong>3. Merkel tree Hash</strong><br>  a cryptographic hash of all of the transactions included in this<br>  block<br> <strong>4. Nonce</strong> <br>  a random value that is added to a hashed block that, when <br>  rehashed, meets the difficulty level restrictions</pre><h3><strong>2. Ledger : A system of records</strong></h3><h4>2.1 What is a ledger ?</h4><p>Ledger is used to record <strong>monetary transfer</strong> between pairs of two individuals in an organization. Businesses have <strong>multiple ledgers</strong> for multiple business networks in which they participate.</p><h4>2.2 Problem in traditional ledger system</h4><p>It is difficult to monitor asset ownership and transfer in a trusted business network. In addition to this its is inefficient, expensive and vulnerable as well as mutable.</p><h4>2.3 Solution</h4><p>Set up a shared ledger which has distributed network system where each node in the system would have its copy of the shared ledger. Each copy of ledger is guaranteed by protocol to be exact same.</p><p>In this system of shared ledger single version of Trust is achieved by :<br><strong>1. Consensus :</strong><br> Fault-tolerant mechanism is used in blockchain systems to achieve the necessary agreement on a single data value or a single state.<br><strong>2. Smart Contracts :</strong><br> Self-enforcing piece of software that is managed by a P2P network of computers<br><strong>3. Immutable :</strong><br> Since the data in blockchain cannot be altered the shared ledgers are immutable.<br><strong>4. Trustless :</strong><br> Blockchain does not actually eliminate trust. Protocol is defined using various rules that automatically encourage patrons on the basis of the rules followed.</p><h3>3. Progression in field of Blockchain</h3><p><strong>B-money</strong> was an early proposal created by <a href="https://en.bitcoin.it/wiki/Wei_Dai">Wei Dai</a> for an “anonymous, distributed electronic cash system” in 1998. <a href="https://en.bitcoin.it/wiki/Satoshi_Nakamoto">Satoshi Nakamoto</a> referenced b-money when creating <a href="https://en.bitcoin.it/wiki/Bitcoin">Bitcoin</a>.</p><p><strong>Bitcoin</strong> was invented in 2008 by an unknown person or group of people using the name <a href="https://en.wikipedia.org/wiki/Satoshi_Nakamoto">Satoshi Nakamoto</a><a href="https://en.wikipedia.org/wiki/Bitcoin#cite_note-whoissn-20">[15]</a> and started in 2009. Bitcoin introduced the world with decentralized ledger and proof-of-work.</p><p><a href="https://en.wikipedia.org/wiki/Ethereum"><strong>Ethereum</strong></a><strong> </strong>is the second largest <a href="https://en.wikipedia.org/wiki/Cryptocurrency">cryptocurrency</a> platform by market capitalization, behind <a href="https://en.wikipedia.org/wiki/Bitcoin">Bitcoin</a>. Ethereum was proposed in late 2013 by <a href="https://en.wikipedia.org/wiki/Vitalik_Buterin">Vitalik Buterin</a>, a cryptocurrency researcher and programmer. Ethereum’s key innovation is that it is much more than just a currency or a record of transactions. It introduced smart contracts and non-transactional applications of the blockchain. It’s specification can actually run computation using the Ethereum Virtual Machine, or the world computer, the EVM allows for <br>what are called smart contracts, or programs that can be deployed onto the blockchain, letting developers create decentralized applications that are housed, distributed on the chain itself.</p><p>Later in 2016, <strong>Quorum</strong> - a permissioned network came into existence which supports private transactions and transaction encryption - a permissioned blockchain network.</p><h3>4. Where to use Blockchain ?</h3><ul><li>If your use case do not require a database, you don’t need a blockchain.</li><li>Does it require shared right access? If you don’t need to share this access with multiple people or groups, you don’t need a blockchain.</li><li>If any intermediaries are needed for your use case then blockchain is not the solution.</li><li>If you are looking for replacement for transaction processing or databases, you don’t need a blockchain.</li><li>If you are looking for a decentralized system with multiple stake holders and distributed ledger, blockchain is ideal solution to your use case.</li></ul><h3><strong>5. Use Cases</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*b9JUTZj4k7JOJCpMvjit_A.jpeg" /><figcaption>Health Care Records Management</figcaption></figure><h4>Use Case 1 : Health Care Records Management</h4><p>Disparate record-keeping systems can result in patient consent forms and medical histories that are incomplete, conflicting or ambiguous. With blockchain, the health care provider and patient would have access to the same information and could be involved in a cooperative, educated discussion of research-based treatment.</p><h4>Use Case 2 : Covid19 Contract Tracing</h4><p>Using blockchain to maintain the records of corona infected patients would help for proper analysis of data and accurate information can be communicated across all nodes.</p><h4>Use Case 3 : Insurance Service Providers</h4><p>Blockchain would help to connect multiple stakeholders with a secured, single-insurance platform. It is also capable of automated triggering of claim processing through smart contracts and blockchain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*pbktxPxGFikF5vGg0w100w.jpeg" /><figcaption>Voting Management</figcaption></figure><h4>Use Case 4 : Voting Management</h4><p>A decentralized and immutable system can bring more transparency in the process of voting eliminating any kind of fraud or false votes.</p><h4>Use Case 5 : Payments</h4><p>Cross border payment transactions are costly and take days to complete. With blockchain, banks can create secure, low-cost cross-border payments with reduced risk.</p><h4>Use Case 6 : Vehicle Registration and Maintenance</h4><p>As blockchain provides service of immutable ledger which can be shared among all the nodes in blockchain, it would prove beneficial in the process of vehicle registration and maintenance. Providing service to customers as well as tracking vehicles and their owner would become more easy.</p><h3>6. Skills Needed</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*VKxHHhPjjYNskyvFb2WVww.jpeg" /><figcaption>Blockchain Technology skillset</figcaption></figure><p>The <strong>core skills</strong> for a Blockchain developer includes :<br>1. Encryption/Decryption, Digital Signature<br>2. Distributed Apps<br>3. Smart Contracts using Solidity or Go programming language<br>4. Understanding Dapps and how to deploy them<br>5. Consensus<br>6. Transaction Management</p><p>The <strong>supporting skills </strong>includes :<br>1. Cloud<br>2. Java and enterprise languages<br>3. CI / CD<br>4. Understand and Challenge Business Flow<br>5. UI — ReactJS, Angular etc.</p><p><em>Please check me out on </em><a href="http://www.linkedin.com/in/rishikeshkale"><em>LinkedIn</em></a><em> as well, I would love to hear from you!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d058f846d50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Super Over Smart Contract 2.0 in Solidity]]></title>
            <link>https://medium.com/@rvk_rishikesh/the-super-over-smart-contract-2-0-in-solidity-c18394e5b2f7?source=rss-798ccf6d44d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c18394e5b2f7</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[cricket]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Rishikesh Kale]]></dc:creator>
            <pubDate>Wed, 29 Apr 2020 20:18:41 GMT</pubDate>
            <atom:updated>2020-08-27T14:41:42.896Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>This article is the second one in a series of articles about constructing a Smart Contract in Solidity. Let’s head towards Super Over Smart Contract Version 2.0.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*NI4OVleS6GvKEe5qpAWCdg.jpeg" /></figure><blockquote><em>Recommended : </em><a href="https://medium.com/@rk.rtistic/the-super-over-smart-contract-using-solidity-b31a93f002f8"><em>Read previous version -Super Over Smart Contract 1.0</em></a></blockquote><blockquote>“ Change is the only constant in life. ”</blockquote><p>To update our Smart Contract its important to know the drawbacks of <a href="https://medium.com/@rk.rtistic/the-super-over-smart-contract-using-solidity-b31a93f002f8">Super Over Smart Contract 1.0</a>. Let’s discuss them.</p><p>The previous version had two functions maintainscore and winner, which updated the score of individual teams and declared the winner respectively.<br>However these two functions can be called in any order. There are no rules such as both the teams should have completed their batting quota and winning team can be decided only after both the teams have registered there respective score.<br>Also there is no restriction over cross updation of team score, which means that the second team’s score can be updated before completion of the innings of the first team and vice versa.</p><p>The previous version had two functions maintainscore and winner, which updated the score of individual teams and declared the winner respectively.<br>However these two functions can be called in any order. There are no rules such as both the teams should have completed their batting quota and winning team can be decided only after both the teams have registered there score.<br>Also there is no restriction over cross upadtion of team score, which means that the second team’s score can be updated before completion of the innings of the first team and vice versa.</p><p>To over come these drawbacks let us add the stages to the version one. <br>We add the enum for the stages and logic for modifying the stages within the functions. We will compile and run it and make sure it works as expected. Let’s define the stage as enum datatype.</p><pre>enum Stage { Init , RegTeams , inningsTeamA , inningsTeamB ,   AnnounceResult }</pre><p>Stage is four distinct stages, Init, RegTeams, inningsTeamA, inningsTeamB and AnnounceResult.</p><pre>Stage Init           : The stage when program is compiled<br>                       and deployed.<br>Stage regTeams       : The stage where both the teams are registered <br>                       for the match.<br>Stage inningsTeamA   : The stage at which TeamA is batting.<br>Stage inningsTeamA   : The stage at which TeamB is batting.<br>Stage Announceresult : The stage when both teams have completed <br>                       there batting quota and the winner <br>                       is to be declared.</pre><p>1. The stage is initialized to Init at the time of deployment of the Smart Contract. <br>2. Then, in the constructor, the Init is changed to RegTeam stage. <br>3. After both the teams are registered, the stage changes to inningsTeamA. <br>4. After the batting quota of TeamA ends, the stage is set to inningsTeamB. <br>5. After the batting quota of TeamB ends, the stage is set to AnnounceResult.</p><p>Lets now move towards the programming part</p><pre>pragma solidity ^0.5.9;<br>contract SuperOver{<br>    <br>    address public umpire;<br>    address public TeamA ;<br>    address public TeamB ;<br>    <br>    struct Team{<br>        string name;<br>        uint score;<br>        uint balls ;<br>    }<br>    <br>    mapping(address =&gt; Team) teamdata;</pre><p>Similar to previous version we have a struct Team, which stores the variables for storing team data. Along with the address variable umpire we have two additional variables of type address which stores the address of the teams.</p><p>Next we have a mapping that holds the data of the team for given address.</p><pre>enum Stage { Init , RegTeams , inningsTeamA , inningsTeamB , AnnounceResult }</pre><pre>Stage public stage = Stage.Init;</pre><p>As stated above, to remove the mentioned drawbacks we add the enum for the stages and logic for modifying the stages within the functions. The variable stage is defined to be of this enum stage type, and it has been initialized to the Init stage. Actually Init is 0, RegTeams is 1, inningsTeamA is coded as 2, inningsTeamB is coded as 3 and AnnounceResult is coded as 4. Remember that when we are looking at the outputs in the web interface.</p><pre>constructor() public<br>    {<br>        umpire = msg.sender;<br>        stage = Stage.RegTeams;<br>    }</pre><p>Here in the constructor we have variable which stores the address value is initialized to msg.sender and stage is set to RegTeams.</p><pre>function registerTeams(address addTeamA,string memory nameTeamA ,address addTeamB,string memory nameTeamB ) public<br>    {<br>        if (stage != Stage.RegTeams) return;<br>        if(msg.sender != umpire) return;<br>        TeamA = addTeamA;<br>        teamdata[TeamA].name = nameTeamA;<br>        TeamB = addTeamB;<br>        teamdata[TeamB].name = nameTeamB;<br>        stage = Stage.inningsTeamA;<br>    }</pre><p>In this version we are adding a new function registerTeams which registers the teams for the match. The first line of the function checks whether is it the regTeams stage or not. If stage is not regTeams then it prevents registration of any additional team thus preventing a new registration in between an ongoing match. After both the teams are registered the stage is set to inningsTeamA , which states that the first team can come out to bat.</p><p>Next we have the following two functions which maintains the scores of individual teams. The first line of both the functions checks if we are in the appropriate stage to update the date and the last line of the functions directs the code towards next stage if the batting quota of respective team is finished.</p><pre>function maintainScoreTeamA(uint runs) public<br>    {<br>        if (stage != Stage.inningsTeamA) return;<br>        if(msg.sender != umpire || teamdata[TeamA].balls &gt; 6) <br>            return;<br>        teamdata[TeamA].score += runs;<br>        teamdata[TeamA].balls++;<br>        if(teamdata[TeamA].balls == 6 ) <br>            { stage =   Stage.inningsTeamB; }<br>    }<br>    <br>function maintainScoreTeamB(uint runs) public<br>    {<br>        if (stage != Stage.inningsTeamB) return;<br>        if(msg.sender != umpire || teamdata[TeamB].balls &gt; 6) <br>            return;<br>        teamdata[TeamB].score += runs;<br>        teamdata[TeamB].balls++;<br>        if(teamdata[TeamB].balls == 6 ) <br>            { stage = Stage.AnnounceResult; }<br>    }</pre><p>Lastly we have winner function which declares the winner of the match. The function first checks whether the match is completed or not by checking the current stage thus preventing any absurd result.</p><pre>function winner() public view returns(string memory)<br>    {<br>        if (stage != Stage.AnnounceResult) <br>             return &quot;Match is yet to be finished&quot;;<br>        if(teamdata[TeamA].score &gt; teamdata[TeamB].score) <br>            return teamdata[TeamA].name;<br>        if(teamdata[TeamA].score == teamdata[TeamB].score) <br>            return &quot;Trophy is Shared&quot;;<br>        else return teamdata[TeamB].name;<br>    }</pre><blockquote><em>Its recommended to carefully analyze the function and understand its working line-by-line.</em></blockquote><p>By the time you reach here your code must look like this :</p><pre>pragma solidity ^0.5.9;<br>contract SuperOver{<br>    <br>    address public umpire;<br>    address public TeamA ;<br>    address public TeamB ;<br>    <br>    struct Team{<br>        string name;<br>        uint score;<br>        uint balls ;<br>    }<br>    <br>    mapping(address =&gt; Team) teamdata;<br>    <br>    enum Stage { Init , RegTeams , inningsTeamA , inningsTeamB , AnnounceResult }<br>    Stage public stage = Stage.Init;<br>    <br>    constructor() public<br>    {<br>        umpire = msg.sender;<br>        stage = Stage.RegTeams;<br>    }<br>    <br><br>    function registerTeams(address addTeamA,string memory nameTeamA ,address addTeamB,string memory nameTeamB ) public<br>    {<br>        if (stage != Stage.RegTeams) return;<br>        if(msg.sender != umpire) return;<br>        TeamA = addTeamA;<br>        teamdata[TeamA].name = nameTeamA;<br>        TeamB = addTeamB;<br>        teamdata[TeamB].name = nameTeamB;<br>        stage = Stage.inningsTeamA;<br>    }<br>    <br>    function maintainScoreTeamA(uint runs) public<br>    {<br>        if (stage != Stage.inningsTeamA) return;<br>        if(msg.sender != umpire || teamdata[TeamA].balls &gt; 6) <br>            return;<br>        teamdata[TeamA].score += runs;<br>        teamdata[TeamA].balls++;<br>        if(teamdata[TeamA].balls == 6 ) <br>            { stage =   Stage.inningsTeamB; }<br>    }<br>    <br>    function maintainScoreTeamB(uint runs) public<br>    {<br>        if (stage != Stage.inningsTeamB) return;<br>        if(msg.sender != umpire || teamdata[TeamB].balls &gt; 6) <br>            return;<br>        teamdata[TeamB].score += runs;<br>        teamdata[TeamB].balls++;<br>        if(teamdata[TeamB].balls == 6 ) <br>            { stage = Stage.AnnounceResult; }<br>    }<br>    <br>    function winner() public view returns(string memory)<br>    {<br>        if (stage != Stage.AnnounceResult) <br>             return &quot;Match is yet to be finished&quot;;<br>        if(teamdata[TeamA].score &gt; teamdata[TeamB].score) <br>            return teamdata[TeamA].name;<br>        if(teamdata[TeamA].score == teamdata[TeamB].score) <br>            return &quot;Trophy is Shared&quot;;<br>        else return teamdata[TeamB].name;<br>    }<br>    <br>}</pre><h3>Compiling the Solidity Smart Contract using Remix IDE</h3><p>Copy paste the code into <a href="https://remix.ethereum.org/">Remix IDE</a> in the newly created file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rWm-P7csAowPoaEaQSw7vw.jpeg" /></figure><p>So let’s execute it and see it running.</p><p>After you compile and deploy the code you will be able to see the buttons of the functions we created along with the public variables we had declared in our Smart Contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*T3wfWVryGjwb-8mw5CLT1A.jpeg" /></figure><p>Let’s analyze them one by one. On clicking the umpire button we should get the address of the account in which the Smart Contract was deployed.</p><blockquote>Only umpire has the right to update the scores thus always make sure that the selected account belongs to umpire.</blockquote><p>Let’s try checking if the contract shows any random result when we check the winner to verify if the contract have overcame the drawbacks or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*lQUMfxgNG5V-r8lFXHx8Pg.jpeg" /></figure><p>Perfect!! We got the desired result. Now we can move towards team registration but before that we need to check in which stage we are.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*aOrERwnkpSngdKPIiaTY3w.jpeg" /></figure><p>We are progressing correctly. So its Stage 1, that means we can register the teams. Let’s do that.</p><h3>Stage 1 : Team Registration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*WRTKd01VgMGa0XG8Oe62Rw.jpeg" /><figcaption>Select new address for the teams from here.</figcaption></figure><p>Enter the account address for both the teams by copy pasting one of the address from the available address and the enter the name of the teams as done below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*UeVzNB9dFX_Bf84Gqdq4gw.jpeg" /></figure><blockquote>Before transacting make sure you get back to umpire’s address account.</blockquote><p>Since the teams are now registered, the stage should be upgraded to next stage. You can check it by clicking the stage button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*NH1SwX43DOxZ8tH72FhCQw.jpeg" /></figure><p>Great!! We are on right path.</p><h3>Stage 2 : Its time for Team A to set the target for Team B</h3><p>As we did in <a href="https://medium.com/@rk.rtistic/the-super-over-smart-contract-using-solidity-b31a93f002f8">previous version</a> we will enter the runs ball-by-ball as per the score timeline given below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*nX-Ew4-M-7GBiFro1bDY7w.jpeg" /><figcaption>Score Card of Team A</figcaption></figure><blockquote>Note : After entering runs after each ball you need to transact it to add the runs to teams total score.</blockquote><p>You can check the stage before proceeding towards next step.</p><h3>Stage 3 : Can Team B chase the target set by Team A ?</h3><p>Enter the runs for Team B as per the scoreboard below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*1NVrDEPkT25Pg5T1BBrI6g.jpeg" /><figcaption>Score Card of Team B</figcaption></figure><h3>Stage 4 : Its time to announce the winner</h3><p>Before proceeding make sure you have entered the final stage.</p><p><em>And the winner is …..</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*NuVvSFuqF_EpdNUdrBxoKw.jpeg" /></figure><blockquote><em>Congratulations!! 🎉<br>You successfully designed and deployed the Super Over Smart Contract 2.0 which resolved the drawbacks of Super Over Smart Contract 1.0 to obtain the accurate result.</em></blockquote><p><em>That wraps up the step-by-step article for now.</em></p><p>Other articles in this series:</p><ul><li><a href="https://medium.com/@rk.rtistic/the-super-over-smart-contract-using-solidity-b31a93f002f8">Part 1: Super Over Smart Contract Version 1.0</a></li><li><a href="https://medium.com/@rvk_rishikesh/the-super-over-smart-contract-3-0-in-solidity-6278877e181e">Part 3: Super Over Smart Contract Version 3.0</a></li></ul><p><em>Please check me out on </em><a href="http://www.linkedin.com/in/rishikeshkale"><em>LinkedIn</em></a><em> as well, I would love to hear from you!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c18394e5b2f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>