<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ decentralized apps - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ decentralized apps - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Thu, 21 May 2026 16:11:44 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/decentralized-apps/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ What is Web3? The Decentralized Internet of the Future Explained ]]>
                </title>
                <description>
                    <![CDATA[ By Nader Dabit If you’re reading this then you are a participant in the modern web. The web we are experiencing today is much different than what it was just 10 years ago. How has the web evolved, and more importantly – where is it going next? Also, ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/what-is-web3/</link>
                <guid isPermaLink="false">66d4604be39d8b5612bc0dd0</guid>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ decentralization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ decentralized apps ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web3 ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 08 Sep 2021 21:09:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/05/web3-future-of-web.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Nader Dabit</p>
<p>If you’re reading this then you are a participant in the modern web. The web we are experiencing today is much different than what it was just 10 years ago. How has the web evolved, and more importantly – where is it going next? Also, why do any of these things matter?</p>
<p>If history has taught us anything, these changes will matter a lot. </p>
<p>In this article, I will lay out how the web has evolved, where's it going next, and why this matters.</p>
<p>Think about how the internet affects your life on a daily basis. Consider how society has changed as a result of the internet. Social media platforms. Mobile apps. And now the internet is going through another paradigm shift as we speak.</p>
<h2 id="heading-the-evolution-of-the-web"><strong>The Evolution of the Web</strong></h2>
<p>The web has evolved a lot over the years, and the applications of it today are almost unrecognizable from its most <a target="_blank" href="https://en.wikipedia.org/wiki/History_of_the_Internet">early days</a>. The evolution of the web is often partitioned into three separate stages: Web 1.0, Web 2.0, and Web 3.0.</p>
<h3 id="heading-what-is-web-10"><strong>What is Web 1.0?</strong></h3>
<p>Web 1.0 was the first iteration of the web. Most participants were consumers of content, and the creators were typically developers who build websites that contained information served up mainly in text or image format. Web 1.0 lasted approximately from 1991 to 2004.</p>
<p>Web 1.0 consisted of sites serving static content instead of dynamic HTML. Data and content were served from a static file system rather than a database, and sites didn't have much interactivity at all.</p>
<p>You can think of Web 1.0 as the read-only web.</p>
<h3 id="heading-what-is-web-20"><strong>What is Web 2.0?</strong></h3>
<p>Most of us have primarily experienced the web in its current form, commonly referred to as <a target="_blank" href="https://en.wikipedia.org/wiki/Web_2.0#top">web2</a>. You can think of web2 as the interactive and social web.</p>
<p>In the web2 world, you don’t have to be a developer to participate in the creation process. Many apps are built in a way that easily allows anyone to be a creator.</p>
<p>If you want to craft a thought and share it with the world, you can. If you want to upload a video and allow millions of people to see it, interact with it, and comment on it, you can do that too.</p>
<p>Web2 is simple, really, and because of its simplicity more and more people around the world are becoming creators.</p>
<p>The web in its current form is really great in many ways, but there are some areas where we can do a lot better.</p>
<h3 id="heading-web-20-monetization-and-security"><strong>Web 2.0 Monetization and Security</strong></h3>
<p>In the web2 world, many popular apps are following a common pattern in their life cycles. Think of some of the apps that you use on a daily basis, and how the following examples might apply to them.</p>
<h4 id="heading-monetization-of-apps"><strong>Monetization of Apps</strong></h4>
<p>Imagine the early days of popular applications like Instagram, Twitter, LinkedIn, or YouTube and how different they are today. The process usually goes something like this:</p>
<ol>
<li>Company launches an app</li>
<li>It onboards as many users as possible</li>
<li>Then it monetizes its user base</li>
</ol>
<p>When a developer or company launches a popular app, the user experience is often very slick as the app continues rising in popularity. This is the reason they are able to gain traction quickly in the first place.</p>
<p>At first, many software companies do not worry about monetization. They strictly focus on growth and on locking in new users – but eventually they have to start turning a profit.</p>
<p>They also need to consider the role of outside investors. Often the constraints of taking on things like venture capital negatively affect the life cycle, and eventually the user experience, of many applications that we use today.</p>
<p>If a company building an application takes in venture capital, its investors often expect a return on investment in the order of magnitude of tens or hundreds of what they paid in.</p>
<p>This means that, instead of going for some sustainable model of growth that they can sustain in a somewhat organic manner, the company is often pushed towards two paths: advertisements or selling personal data.</p>
<p>For many web2 companies like Google, Facebook, Twitter, and others, more data leads to more personalized ads. This leads to more clicks and ultimately more ad revenue. The exploitation and centralization of user data is core to how the web as we know and use it today is engineered to function.</p>
<h4 id="heading-security-and-privacy"><strong>Security and privacy</strong></h4>
<p>Web2 applications repeatedly experience <a target="_blank" href="https://en.wikipedia.org/wiki/List_of_data_breaches">data breaches</a>. There are even <a target="_blank" href="https://haveibeenpwned.com/">websites</a> dedicated to keeping up with these breaches and telling you when your data has been compromised.</p>
<p>In web2, you don’t have any control over your data or how it is stored. In fact, companies often track and save user data without their users' consent. All of this data is then owned and controlled by the companies in charge of these platforms.</p>
<p>Users who live in countries where they have to worry about the negative consequences of free speech are also at risk.</p>
<p>Governments will often shut down servers or seize bank accounts if they believe a person is voicing an opinion that goes against their propaganda. With centralized servers, it is easy for governments to intervene, control, or shut down applications as they see fit.</p>
<p>Because banks are also digital and under centralized control, governments often intervene there as well. They can shut down access to bank accounts or limit access to funds during times of volatility, extreme inflation, or other political unrest.</p>
<p>Web3 aims to solve many of these shortcomings by fundamentally rethinking how we architect and interact with applications from the ground up.</p>
<h2 id="heading-what-is-web-30"><strong>What is Web 3.0?</strong></h2>
<p>There are a few fundamental differences between web2 and web3, but decentralization is at its core.</p>
<p>Web3 enhances the internet as we know it today with a few other added characteristics. web3 is:</p>
<ul>
<li>Verifiable</li>
<li>Trustless</li>
<li>Self-governing</li>
<li>Permissionless</li>
<li>Distributed and robust</li>
<li>Stateful</li>
<li>Native built-in payments</li>
</ul>
<p>In web3, developers don't usually build and deploy applications that run on a single server or that store their data in a single database (usually hosted on and managed by a single cloud provider).</p>
<p>Instead, web3 applications either run on blockchains, decentralized networks of many peer to peer nodes (servers), or a combination of the two that forms a <a target="_blank" href="https://thegraph.com/blog/modeling-cryptoeconomic-protocols-as-complex-systems-part-1">cryptoeconomic protocol</a>. These apps are often referred to as dapps (decentralized apps), and you will see that term used often in the web3 space.</p>
<p>To achieve a stable and secure decentralized network, network participants (developers) are incentivized and compete to provide the highest quality services to anyone using the service.</p>
<p>When you hear about web3, you'll notice that cryptocurrency is often part of the conversation. This is because cryptocurrency plays a big role in many of these protocols. It provides a financial incentive (tokens) for anyone who wants to participate in creating, governing, contributing to, or improving one of the projects themselves.</p>
<p>These protocols may often offer a variety of different services like compute, storage, bandwidth, identity, hosting, and other web services commonly provided by cloud providers in the past.</p>
<p>People can make a living by participating in the protocol in various ways, in both technical and non-technical levels.</p>
<p>Consumers of the service usually pay to use the protocol, similarly to how they would pay a cloud provider like AWS today. Except in web3, the money goes directly to the network participants.</p>
<p>In this, like in many forms of decentralization, you'll see that unnecessary and often inefficient intermediaries are cut out.</p>
<p>Many web infrastructure protocols like <a target="_blank" href="https://filecoin.io/blog/filecoin-circulating-supply/">Filecoin</a>, <a target="_blank" href="https://livepeer.com/">Livepeer</a>, <a target="_blank" href="https://www.arweave.org/">Arweave</a>, and <a target="_blank" href="https://thegraph.com/blog/the-graph-grt-token-economics">The Graph</a> (which is what I work with at Edge &amp; Node) have issued utility tokens that govern how the protocol functions. These tokens also reward participants at many levels of the network. Even native blockchain protocols like <a target="_blank" href="https://ethereum.org/en/">Ethereum</a> operate in this manner.</p>
<h3 id="heading-native-payments"><strong>Native payments</strong></h3>
<p>Tokens also introduce a native payment layer that is completely borderless and frictionless. Companies like Stripe and Paypal have created billions of dollars of value in enabling electronic payments.</p>
<p>These systems are overly complex and still do not enable true international interoperability between participants. They also require you to hand over your sensitive information and personal data in order to use them.</p>
<p>Crypto <a target="_blank" href="https://everest.link/category/0xc00f480db7754ce2e0f992a1080598e53fc511a0/">wallets</a> like <a target="_blank" href="https://metamask.io/">MetaMask</a> and <a target="_blank" href="https://toruswallet.io/">Torus</a> enable you to integrate easy, anonymous, and secure international payments and transactions into web3 applications.</p>
<p>Networks like Solana offer several hundred digit millisecond latency and transaction costs of a small fraction of a penny. Unlike the current financial system, users do not have to go through the traditional numerous, friction-filled steps to interact with and participate in the network. All they need to do is download or install a wallet, and they can start sending and receiving payments without any gatekeeping.</p>
<h3 id="heading-a-new-way-of-building-companies"><strong>A new way of building companies</strong></h3>
<p>Tokens also brings about the idea of tokenization and the realization of a <a target="_blank" href="https://www.oreilly.com/library/view/what-is-the/9781492072973/ch01.html">token economy</a>.</p>
<p>Take, for example, the current state of building a software company. Someone comes up with an idea, but in order to start building they need money in order to support themselves.</p>
<p>To get the money, they take on venture capital and give away a percentage of the company. This investment immediately introduces mis-aligned incentives that will, in the long run, not align well with building out the best user experience.</p>
<p>Also, if the company ever does become successful, it will take a very long time for anyone involved to realize any of the value, often leading to years of work without any real return on investment.</p>
<p>Imagine, instead, that a new and exciting project is announced that solves a real problem. Anyone can participate in building it or investing in it from day one. The company announces the release of x number of tokens, and give 10% to the early builders, put 10% for sale to the public, and set the rest aside for future payment of contributors and funding of the project.</p>
<p>Stakeholders can use their tokens to vote on changes to the future of the project, and the people who helped build the project can sell some of their holdings to make money after the tokens have been released.</p>
<p>People who believe in the project can buy and hold ownership, and people who think the project is headed in the wrong direction can signal this by selling their stake.</p>
<p>Because blockchain data is all completely public and open, purchasers have complete transparency over what is happening. This is in contrast to buying equity in private or centralized businesses where many things are often cloaked in secrecy.</p>
<p>This is already happening in the web3 space.</p>
<p>One example is the app <a target="_blank" href="https://radicle.xyz/blog/introducing-rad.html">Radicle</a> (a decentralized GitHub alternative) which allows stakeholders to participate in the <a target="_blank" href="https://everest.link/category/0x46aff9a161267c2c01f5ce1b6e3b717a77f21480/">governance</a> of their project. <a target="_blank" href="https://gitcoin.co/">Gitcoin</a> is another that allows developers to get paid in cryptocurrency for jumping in and working on Open Source issues. <a target="_blank" href="https://docs.yearn.finance/faq#governance">Yearn</a> allows stakeholders to participate in decision making and voting on proposals. <a target="_blank" href="https://uniswap.org/blog/uni/">Uniswap</a>, <a target="_blank" href="https://superrare.com/rare">SuperRare</a>, <a target="_blank" href="https://thegraph.com/blog/the-graph-grt-token-economics">The Graph</a>, <a target="_blank" href="https://audius.co/">Audius</a>, and countless other protocols and projects have issued tokens as a way to enable ownership, participation, and governance.</p>
<p><a target="_blank" href="https://linda.mirror.xyz/Vh8K4leCGEO06_qSGx-vS5lvgUqhqkCz9ut81WwCP2o">DAOs</a> (Decentralized Autonomous Organizations), which offer an alternative way to build what we traditionally thought of as a company, are gaining tremendous momentum and investment from both traditional developers and venture capital firms. </p>
<p>These types of organizations are tokenized and turn the idea of organizational structure on its head, offering real, liquid, and equitable ownership to larger portions of stakeholders and aligning incentives in new and interesting ways. </p>
<p>For example, <a target="_blank" href="https://www.fwb.help/">Friends with Benefits</a> is a DAO of web3 builders and artists, is about a year old, has a market cap of around $125 million as of this writing, and recently received <a target="_blank" href="https://tittlepress.com/crypto/1146487/">a $10 million round</a> of investment from <a target="_blank" href="https://a16z.com/">a16z</a>. </p>
<p>DAOs could encompass an entire post in and of themselves, but for now I'll just say that I think that they are the future of building products and (what we in the past thought of as) companies. <a target="_blank" href="https://coopahtroopa.mirror.xyz/_EDyn4cs9tDoOxNGZLfKL7JjLo5rGkkEfRa_a-6VEWw">Here is a good post</a> outlining the current DAO landscape.</p>
<h3 id="heading-how-identity-works-in-web3"><strong>How Identity Works in Web3</strong></h3>
<p>In web3, <a target="_blank" href="http://sinahab.com/identity-and-reputation-in-web-3/">Identity</a> also works much differently than what we are used to today. Most of the time in web3 apps, identities will be tied to the wallet address of the user interacting with the application.</p>
<p>Unlike web2 authentication methods like OAuth or email + password (that almost always require users to hand over sensitive and personal information), wallet addresses are completely anonymous unless the user decides to tie their own identity to it publicly.</p>
<p>If the user chooses to use the same wallet across multiple dapps, their identity is also seamlessly transferable across apps, which lets them build up their reputation over time.</p>
<p>Protocols and tools like <a target="_blank" href="https://ceramic.network/">Ceramic</a> and <a target="_blank" href="https://idx.xyz/">IDX</a> already allow developers to build self-sovereign identity into their applications to replace traditional authentication and identity layers. The Ethereum foundation also has <a target="_blank" href="https://notes.ethereum.org/@djrtwo/sign-in-with-ethereum-RFP">a working RFP</a> for defining a specification for "Sign in with Ethereum" which would help provide a more streamlined and documented way to do this going forward. <a target="_blank" href="https://twitter.com/BrantlyMillegan/status/1402388133086367751">This</a> is also a good thread that outlines some of the ways that this would enhance traditional authentication flows.</p>
<h2 id="heading-how-to-build-on-web3"><strong>How to Build on Web3</strong></h2>
<p>I'm a developer who recently transitioned into the web3 space from a traditional development background. So I wanted to start building to get a sense of what the development experience felt like. And I wanted to get an understanding of the types of apps that we can build today.</p>
<p>I dove right in and decided to document some of the things I was doing in a couple of blog posts.</p>
<p><a target="_blank" href="https://www.freecodecamp.org/news/breaking-into-ethereum-crypto-web3-as-a-developer/">How to Get Into Ethereum, Crypto, and Web3 as a Developer</a> – This is an introduction to the space in general, coming from a developer, for developers looking to break into the industry.</p>
<p><a target="_blank" href="https://www.freecodecamp.org/news/full-stack-ethereum-development/">The Complete Guide to Full Stack Ethereum Development</a> – This is a tutorial that teaches you how to build out your first dapp.</p>
<p><a target="_blank" href="https://dev.to/dabit3/the-complete-guide-to-full-stack-solana-development-with-react-anchor-rust-and-phantom-3291">The Complete Guide to Full Stack Solana Development with React, Anchor, Rust, and Phantom</a> - This guide dives into Solana to show you how to build a full stack dapp.</p>
<p>If you are interested in learning more about web3 in general, you can check out these posts:</p>
<p><a target="_blank" href="https://dev.to/dabit3/the-new-creator-economy-daos-community-ownership-and-cryptoeconomics-lnl">The New Creator Economy - DAOs, Community Ownership, and Cryptoeconomics</a></p>
<p><a target="_blank" href="https://www.notboring.co/p/the-value-chain-of-the-open-metaverse">The Value Chain of the Open Metaverse</a></p>
<p><a target="_blank" href="https://coopahtroopa.mirror.xyz/gWY6Kfebs9wHdfoZZswfiLTBVzfKiyFaIwNf2q8JpgI">The Rise of Micro-Economies</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to architect a DApp using Nuxt.js and Nebulas ]]>
                </title>
                <description>
                    <![CDATA[ By Honey Thakuria There is ever-increasing interest in and demand for Decentralized application (DApp) development. Therefore, I have decided to come up with a tutorial to help you get started with developing & architecting a modular DApp. We’ll use ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/architecting-dapp-using-nuxt-js-nebulas-fc00712ae341/</link>
                <guid isPermaLink="false">66d45f31230dff016690580d</guid>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ decentralized apps ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 14 Jul 2018 19:15:59 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*1LSHpbDThueykKQQeCkAug.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Honey Thakuria</p>
<p>There is ever-increasing interest in and demand for Decentralized application (DApp) development. Therefore, I have decided to come up with a tutorial to help you get started with developing &amp; architecting a modular DApp. We’ll use one of the most popular and widely adopted languages of the 21st century: JavaScript.</p>
<p>We will be working with the following technologies in this tutorial:</p>
<ol>
<li><a target="_blank" href="https://nebulas.io/"><strong>Nebulas</strong></a>: a BlockChain Platform which allows us to write Smart Contracts in JavaScript. Signup <a target="_blank" href="https://incentive.nebulas.io/signup.html?invite=1L9eA"><strong>here</strong></a> to get the referral benefit.</li>
<li><a target="_blank" href="https://nuxtjs.org/"><strong>Nuxt.JS</strong></a>: a framework built on the top of <strong>Vue.JS</strong>.</li>
<li><a target="_blank" href="https://github.com/nebulasio/nebPay"><strong>NebPay</strong></a><strong>:</strong> Nebulas Payment JavaScript API. Both for PC and Mobile.</li>
<li><a target="_blank" href="https://github.com/nebulasio/WebExtensionWallet"><strong>WebExtensionWallet</strong></a>: Used to interact with the Smart Contract for payment purposes.</li>
</ol>
<p>I will be explaining the DApp creation process with the help of an existing DApp, <a target="_blank" href="http://distributedstoriesupdated.s3-website-eu-west-1.amazonaws.com/">Distributed Stories</a>. It qualified for the new DApp reward on season 1 of the incentive program on the <a target="_blank" href="https://nebulas.io/"><strong>Nebulas Platform</strong></a>.</p>
<p>You can find the source code for the frontend of the DAapp <a target="_blank" href="https://github.com/honey93/distributed_stories">here</a>. The Smart Contract code can be found in the PayloadData <a target="_blank" href="https://explorer.nebulas.io/#/tx/63cede0eabc488c093064cc37a14ec8c991ac96d39be93db378802313c4486ef">here</a>.</p>
<p>It’s not always enough to know about creating a simple to-do app. Sometimes we must also understand how to architect big modular applications.</p>
<p>Focusing on such an app, I will give you a high level overview of structuring a big modular DApp using Nuxt.js and Nebulas. You can get more in-depth by exploring and debugging the code shared above.</p>
<h4 id="heading-what-are-we-going-to-build">What are we going to build?</h4>
<p>We are going to create a short <strong>story</strong>/<strong>poem</strong> collaboration platform, Distributed Stories. It will allow a user to create a new story by adding a line to an existing story and sharing the story on Twitter. Here’s a demo <a target="_blank" href="http://distributedstoriesupdated.s3-website-eu-west-1.amazonaws.com/">link</a>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/FkrFJyNuZvkesZjjHSR7KB5JPfBGkrPxnMKP" alt="Image" width="800" height="419" loading="lazy"></p>
<p>I will be explaining the <strong>Smart Contract</strong> and <strong>Frontend Architecture</strong> in the upcoming lines.</p>
<h3 id="heading-the-smart-contract-codehttpsexplorernebulasiotx63cede0eabc488c093064cc37a14ec8c991ac96d39be93db378802313c4486ef"><strong>The <a target="_blank" href="https://explorer.nebulas.io/#/tx/63cede0eabc488c093064cc37a14ec8c991ac96d39be93db378802313c4486ef">Smart Contract Code</a></strong></h3>
<p>The DApp Frontend communicates with the SmartContract in order to fetch and write the data. It is then the BlockChain Platform which syncs this smart contract data across multiple nodes in order to meet the decentralization and security needs. This syncing process needs a little time, and that’s why the write process costs time and money in the form of NAS.</p>
<h4 id="heading-story-initialization"><strong>Story</strong> Initialization</h4>
<p>In the below section, I will explain to you the part of the smart contract which defines the Story Object:</p>
<pre><code><span class="hljs-meta">"use strict"</span>;
<span class="hljs-comment">/*
Story Constructor which will create the story by providing the necessary field fetched from the frontend using nebpay API explained at the end of this blog:
*/</span>

<span class="hljs-keyword">var</span> Story = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">text, image_url</span>) </span>{
    <span class="hljs-built_in">this</span>.title = text;
    <span class="hljs-built_in">this</span>.address = Blockchain.transaction.from;
    <span class="hljs-built_in">this</span>.hash = Blockchain.transaction.hash;
    <span class="hljs-built_in">this</span>.image_url = image_url;
    <span class="hljs-built_in">this</span>.lines = [];
    <span class="hljs-built_in">this</span>.votes = [];
};
<span class="hljs-comment">/*  
Init function is used once while deploying the smart contract to 
initialize the parameters if required:  
*/</span>
Story.prototype = {
    <span class="hljs-attr">init</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{

    }
};
</code></pre><p>As mentioned above, every story will have the following fields, out of which text and image_url need to be provided as an argument from the user. For the Address field, the hash can be obtained using the BlockChain APIs explained in depth <a target="_blank" href="https://medium.com/nebulasio/how-to-build-a-dapp-on-nebulas-part-2-5424789f7417"><strong>here</strong></a>.</p>
<h4 id="heading-data-structure-and-storage-used-in-the-dapp"><strong>Data Structure</strong> and <strong>Storage</strong> used in the DApp</h4>
<p>The storage module enables the data storage on Nebulas. It enables the permanent storage of data variables on Nebulas when a payment is made. You can read in depth about it <a target="_blank" href="https://medium.com/nebulasio/how-to-build-a-dapp-on-nebulas-part-2-5424789f7417">here</a>.</p>
<pre><code><span class="hljs-comment">/*
With the help of the Storage Module, we are defining following maps and index property, which will help us to keep track of multidimensional data obtained from users. Nebulas recommend the capturing of multiple data points, which may help in improving Nebulas Rank and Search Feature.
*/</span>
<span class="hljs-keyword">var</span> Data = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
    LocalContractStorage.defineMapProperty(<span class="hljs-built_in">this</span>, <span class="hljs-string">"favourite_stories"</span>);
    LocalContractStorage.defineMapProperty(<span class="hljs-built_in">this</span>, <span class="hljs-string">"my_stories"</span>);
    LocalContractStorage.defineProperty(<span class="hljs-built_in">this</span>, <span class="hljs-string">"s_index"</span>);
    LocalContractStorage.defineMapProperty(<span class="hljs-built_in">this</span>, <span class="hljs-string">"stories_data"</span>);
};
</code></pre><h4 id="heading-saving-and-retrieving-story"><strong>Saving</strong> and <strong>Retrieving</strong> Story</h4>
<p>Now we’ll look at two of the most important functions used for writing and getting the story on the Platform with the help of Story Constructor and Storage declared in the Data constructor above.</p>
<pre><code><span class="hljs-comment">/*
stories_data hash map will contain every story stored against its unique index on the Platform storage module.
Every story index added by a particular user will be stored in a hash map my_stories, in the form of an array.
*/</span>

Data.prototype = {

<span class="hljs-comment">/* 
Initializing the index on Smart Contract. As soon as people will keep on adding a new story, s_index will keep on increasing. 
*/</span>

<span class="hljs-attr">init</span>: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-built_in">this</span>.s_index = <span class="hljs-keyword">new</span> BigNumber(<span class="hljs-number">1</span>);
      },
<span class="hljs-attr">save_story</span>: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">name, image_url</span>) </span>{
<span class="hljs-keyword">var</span> id = <span class="hljs-built_in">this</span>.s_index;
<span class="hljs-keyword">if</span> (name.length &gt; <span class="hljs-number">25</span>) {
          <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Story Length error"</span>);
        }
<span class="hljs-keyword">if</span> (name == <span class="hljs-string">""</span>) {
          <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"empty story title"</span>);
        }
<span class="hljs-keyword">var</span> story = <span class="hljs-keyword">new</span> Story(name, image_url);
<span class="hljs-built_in">this</span>.stories_data.put(<span class="hljs-keyword">new</span> BigNumber(id).toNumber(), <span class="hljs-built_in">JSON</span>.stringify(story));
<span class="hljs-keyword">var</span> my_stories_local = <span class="hljs-built_in">this</span>.my_stories.get(Blockchain.transaction.from) || [];
my_stories_local.push(<span class="hljs-built_in">this</span>.s_index);
<span class="hljs-built_in">this</span>.my_stories.put(Blockchain.transaction.from, my_stories_local);
<span class="hljs-built_in">this</span>.s_index = <span class="hljs-keyword">new</span> BigNumber(id).plus(<span class="hljs-number">1</span>);
},

<span class="hljs-comment">/* 
get_stories method will be used to retrieve all the stories stored on the platform.
*/</span>
<span class="hljs-attr">get_stories</span>: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{

        <span class="hljs-keyword">var</span> stories = [];
        <span class="hljs-keyword">var</span> total = <span class="hljs-keyword">new</span> BigNumber(<span class="hljs-built_in">this</span>.s_index).toNumber();
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">1</span>; i &lt; total; i++) {
          stories.push(<span class="hljs-built_in">JSON</span>.parse(<span class="hljs-built_in">this</span>.stories_data.get(i)));
        }
        <span class="hljs-keyword">return</span> stories;
},

<span class="hljs-comment">/* 
Remaining Functions can be found out in the Smart Contract Code here.
*/</span>
};
<span class="hljs-built_in">module</span>.exports = Data;
</code></pre><p>This completes the major parts of the Smart Contract. In the next section, I will be explaining the structure of the Frontend Code in Nuxt.js.</p>
<h3 id="heading-frontend-architecture-design"><strong>Frontend Architecture Design</strong></h3>
<p>As the project grows, and more functionalities get added, a proper architecture set up from the beginning can help us achieve our goal by making debugging easier.</p>
<p>The below approach is a good way to go about it:</p>
<pre><code><span class="hljs-comment">/*
Go to the root directory in the source code here and find out the below-mentioned files. This Architecture helps in creating a big modular App/Dapp.
*/</span>
pages/

 about / index.vue  : Static About us PAge

 contact / index.vue : Static Contact us Page

 create / index.vue : Page to Create the Story.

 favourite / index.vue : Stories Liked by you will be here.

 mystory / index.vue : My Stories Page.

 index.vue / index.vue : All Stories Page

store/
 index.js : Vuex code used to make API calls to Smart Contract

 neb_init.js : Importing nebpay and initializing Smart Contract     
               Address here, which gets used throughout the app.
layouts/
 <span class="hljs-keyword">default</span>.vue: Every page follows an architecture where Header and   
              Footer are same. So setting up the <span class="hljs-keyword">default</span> 
              architecture here.
components/

 Header.vue: Header component which is getting used <span class="hljs-keyword">in</span> <span class="hljs-keyword">default</span>.vue
 Footer.cue: Footer component which is getting used <span class="hljs-keyword">in</span> <span class="hljs-keyword">default</span>.vue
 ....
</code></pre><h4 id="heading-making-api-calls-to-the-smart-contract">Making API calls to the Smart Contract</h4>
<p>I will be explaining one of the API call using <strong>nebpay</strong> to interact with the Smart Contract and get all the stories’ data for the landing page.</p>
<p>Initialize Nebpay, to be used across the app in <strong>store/neb_init.js</strong>:</p>
<pre><code><span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> NebPay <span class="hljs-keyword">from</span> <span class="hljs-string">'nebpay.js'</span>;
<span class="hljs-comment">/*
Contract Address can be obtained after deploying the code on Nebulas Platform using their Web Wallet.
It needs to be the Mainnet Address.
*/</span>
<span class="hljs-keyword">var</span> contractAddress = <span class="hljs-string">"n1pQHv...................Pm1"</span>;
<span class="hljs-keyword">var</span> nebPay = <span class="hljs-keyword">new</span> NebPay();
<span class="hljs-keyword">export</span> { contractAddress, nebPay, result,NebPay };
</code></pre><p>The below <strong>API call</strong> code can be found in the <strong>store/index.js</strong> file:</p>
<pre><code><span class="hljs-comment">/*
nebPay API's can be used to interact with the Smart Contract and Chrome extension to perform read and write operations. More details about nebpay API's can be found out here.
*/</span>
<span class="hljs-attr">call</span>: <span class="hljs-function">(<span class="hljs-params">store</span>) =&gt;</span> {
<span class="hljs-comment">// args needs to be sent in below format.</span>
<span class="hljs-keyword">var</span> args = <span class="hljs-string">"[]"</span>;
nebPay.simulateCall(contractAddress, <span class="hljs-number">0</span>, <span class="hljs-string">"get_stories"</span>, args, {
 <span class="hljs-attr">listener</span>: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">data</span>) </span>{
  <span class="hljs-keyword">if</span> (data.result != <span class="hljs-literal">null</span>) {
    store.commit(<span class="hljs-string">"all_data"</span>, <span class="hljs-built_in">JSON</span>.parse(data.result));
  }
 }
});
}
</code></pre><p>The above code is getting called from <strong>component/Allstories.vue</strong>.</p>
<pre><code><span class="hljs-comment">/*
As soon as the Allstories component gets mounted, it dispatches the call action mentioned in the above lines, which then fills the Vuex Store all_data array and gets rendered in the All Stories Component.
*/</span>
mounted() {
  <span class="hljs-built_in">this</span>.$store.dispatch(<span class="hljs-string">"call"</span>);
}
</code></pre><p>Like this, you can go around every section in the source code and understand the complete architecture of the DApp.</p>
<p>I hope this tutorial helped you in getting started with DApp development. For any queries, feel free to reach out to me.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Decentralize your application with Google Cloud Platform ]]>
                </title>
                <description>
                    <![CDATA[ By Simeon Kostadinov When first starting a new software project, you normally choose a certain programming language, a specific framework and libraries. Then you begin coding. After 2 - 3 months you end up with a nicely working single application. Bu... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/decentralize-your-application-with-google-cloud-platform-7149ec6d0255/</link>
                <guid isPermaLink="false">66c348c0a7aea9fc97bdfaf2</guid>
                
                    <category>
                        <![CDATA[ decentralized apps ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Flask Framework ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Google Cloud Platform ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Microservices ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software architecture ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 21 Dec 2017 22:57:25 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*Z68F4SMRusBjJ7Q8ox4Waw.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Simeon Kostadinov</p>
<p>When first starting a new software project, you normally choose a certain programming language, a specific framework and libraries. Then you begin coding. After 2 - 3 months you end up with a nicely working single application.</p>
<p><strong>But, as the project grows and more functionalities are added, you quickly realize the disadvantages of a centralized system.</strong> Difficult to maintain and unscalable are some of the reasons which will make you search for a better solution. Here is where Microservices come in help.</p>
<h4 id="heading-what-are-microservices">What are Microservices?</h4>
<p>Microservices are independently built systems, each running in their own process and often communicating with REST API. Representing different parts of your application, they are separately deployable and each part can be written in any language.</p>
<p>You can easily see how, by dealing with the problems of a monolithic system, Microservices have become a requirement for any state-of-the-art software.</p>
<p>I strongly recommend reading <a target="_blank" href="https://martinfowler.com/articles/microservices.html">Microservices (by James Lewis)</a> and <a target="_blank" href="https://dev.otto.de/2015/09/30/on-monoliths-and-microservices/">On Monoliths and Microservices</a> if you want to understand more in depth what are the key concepts in this architectural style.</p>
<h4 id="heading-what-are-you-going-to-build">What are you going to build?</h4>
<p>This article will walk you through the process of implementing a Microservice using <a target="_blank" href="https://cloud.google.com/">Google Cloud Platform</a>.</p>
<p>Imagine you’re developing an application that accepts a text input from a user and determine the category of the key words within the input.</p>
<p>We’ll use an example to illustrate the functionality of the App. Consider the sample text below from the <a target="_blank" href="https://cloud.google.com/natural-language/">GCP Cloud Natural Language API website</a>:</p>
<blockquote>
<p>“Google, headquartered in Mountain View, unveiled the new Android phone at the Consumer Electronic Show. Sundar Pichai said in his keynote that users love their new Android phones.”</p>
</blockquote>
<p>Our web App would accept the text above as input, and return the category that the key words belong to, as in the figure below:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*SAeCcBhjaEY-JqaRzOaskA.png" alt="Image" width="800" height="587" loading="lazy">
_Source: [GCP Cloud Natural Language API website](https://cloud.google.com/natural-language/" rel="noopener" target="<em>blank" title=")</em></p>
<p>This feature is quite likeable and people use it hundreds of times each day. Now, if you’re going to offer this functionality as a service that receives a high amount of daily traffic, you want to respond with a stable and reliable system.</p>
<p>That’s why we’ll build a lightweight Flask App, hosted on <a target="_blank" href="https://cloud.google.com/appengine/docs/flexible/python/">Google App Engine</a>. Integrating it with <a target="_blank" href="https://cloud.google.com/pubsub/docs/">Google Cloud Pub/Sub</a> will help us handle all the asynchronous requests we receive and help us assure that users don’t wait too long for a response.</p>
<h4 id="heading-create-and-deploy-the-application">Create and deploy the application</h4>
<p>Let’s first start with the Flask app (you can also choose Django, Node.js, Go or anything used to build server-side applications). If you’re not very familiar with developing a Flask App, this <a target="_blank" href="https://damyanon.net/post/flask-series-environment/">Flask Series</a> can show you step-by-step how to set up an application.</p>
<p>For the purpose of this tutorial we will use this simple example:</p>
<p><strong>This embed is from an external site and no longer seems to be available</strong></p>
<p>First you need to install the dependencies <code>pip install Flask gunicorn</code>. You will be using <code>**gunicorn**</code> to run the application on Google App Engine. For local access you can run <code>python text.py</code> in the console and find the app on port 8080.</p>
<p>To deploy the app to Google App Engine, you need to take these steps:</p>
<ul>
<li>Create a project (follow the <a target="_blank" href="https://cloud.google.com/appengine/docs/flexible/python/quickstart">‘Before you begin’ instructions from the documentation</a>). <strong>Save the project id for later.</strong></li>
<li>Create <code>app.yaml</code> file (shown below), which is used by the Google App Engine to recognize the application.</li>
<li>Run <code>gcloud app deploy</code> in the console.</li>
</ul>
<p>The <code>app.yaml</code> file looks like this:</p>
<p><strong>This embed is from an external site and no longer seems to be available</strong></p>
<p>Line 3 is important, where you use <code>**gunicorn**</code> to tell Google App Engine to run the application <code>**app**</code> from a file called <code>text.py</code> (the Flask app)<em>.</em> You can learn more about the <code>.yaml</code> file structure <a target="_blank" href="https://cloud.google.com/appengine/docs/standard/python/config/appref">here</a>. After deployment you should be able to access your project from <code>https://[YOUR_PROJECT_ID].appspot.com</code>.</p>
<p>When building production ready applications, you often want to test your code before pushing it live. One way to do this is to run your App within a server locally. A better approach is to have a development version of the app which can be tested not only from your local machine but also from a hosted environment. You can use <a target="_blank" href="https://cloud.google.com/appengine/docs/admin-api/deploying-apps">Google App Engine versions</a> for this.</p>
<p>Just deploy your App with <code>gcloud app deploy -v textdev</code> (for development) or <code>gcloud app deploy -v textprod</code> (for production).</p>
<p>Then navigate to <code>https://textdev.[YOUR_PROJECT_ID].appspot.com</code> or <code>https://textprod.[YOUR_PROJECT_ID].appspot.com</code> to access the specific version.</p>
<h4 id="heading-scale-to-infinity">Scale to infinity</h4>
<p>So far so good. You have a working application, hosted on the Google Cloud Platform. Now you need to add <a target="_blank" href="https://cloud.google.com/pubsub/docs/">Google Cloud Pub/Sub</a> and <a target="_blank" href="https://cloud.google.com/natural-language/">Google Natural Language API</a>.</p>
<p>But first, let’s explain the architecture.</p>
<p>Once a request is received, the Flask app will publish a message with the text to a topic (created below). Then a subscriber (Python script) will pull this message and apply the Google Natural Language API to each text. Finally, the result will be saved to a database.</p>
<p>For multiple requests, the app asynchronously publishes them to the topic and the subscriber starts executing the first one. When ready, it picks the second one and so on.</p>
<p>Now you need to modify <code>text.py</code> file:</p>
<p><strong>This embed is from an external site and no longer seems to be available</strong></p>
<p>The code on line 15 and 16 creates the publisher. On line 18 it publishes a message containing the user email and text input.</p>
<p>You only need to fill in the <code>project_id</code> and <code>topic_id</code> (line 6 and 7).</p>
<p>Since the <code>project_id</code> was used earlier, just add it here.</p>
<p>For the <code>topic_id</code> you need to do the following:</p>
<ul>
<li><a target="_blank" href="https://console.cloud.google.com/apis/dashboard">Enable Google Cloud Pub/Sub API</a></li>
<li><a target="_blank" href="https://console.cloud.google.com/cloudpubsub/topicList">Go to the Pub/Sub page of your project</a></li>
<li>Create a topic and a subscription</li>
<li>Use the topic name as your <code>topic_id</code></li>
<li>Keep the subscription name for later.<br>You will need it as your <code>subscription_id</code></li>
</ul>
<p>Wonderful! Now you have a working publisher.</p>
<p>Let’s jump into setting up the subscriber. There are two files that need to be created: <code>worker.py</code> and <code>startup-script.sh</code>.</p>
<p>The <code>worker.py</code> looks like this:</p>
<p><strong>This embed is from an external site and no longer seems to be available</strong></p>
<p>The file is slightly larger but we will examine it step-by-step, starting from the bottom.</p>
<p>When the file is executed, the code on line 44 runs <code>main()</code>. This function sets the subscriber with your <code>project_id</code> and <code>subscription_id</code> and assigns a callback to it.</p>
<p>The <code>callback</code> (initialized on line 7) is going to receive all messages and perform the required task (to determine the category of a text). If you follow the code from the <code>callback</code>, you can easily see how the Google Natural Language API is being used.</p>
<p>The interesting line is 11 where <code>message.ack()</code> acknowledges the current message. You can see this is as if the worker is saying: “I am done with this message and ready to handle the next one”.</p>
<p>Now, you need to implement <code>startup-script.sh</code>.</p>
<p>This is a shell script with several commands:</p>
<p><strong>This embed is from an external site and no longer seems to be available</strong></p>
<p>Before explaining the code above, I need to clarify the process.</p>
<p>Basically, <a target="_blank" href="https://console.cloud.google.com/compute">Google Cloud Compute Engine</a> gives you the ability to scale an application by providing as many virtual machines (VM) as needed to run several workers simultaneously.</p>
<p>You just need to add the code for the worker, which you already have, and set the configurations of the VM. Together with the <code>worker.py</code>, you also need to add a <code>startup-script.sh</code> which will run every time a new VM boots up.</p>
<p>New VM instances are booted up to prevent delay in responses when a high number of messages is received.</p>
<p>For a deeper and more technical explanation of this process check out the <a target="_blank" href="https://cloud.google.com/compute/docs/">documentation</a>.</p>
<p>Now, let me walk you through the script:</p>
<ul>
<li><strong>Line 1</strong>: means that the script should always be run with bash, rather than another shell.</li>
<li><strong>Lines 2 and 3</strong>: creates and enters into a new directory where all of the files will be stored.</li>
<li><strong>Line 4</strong>: copies the <code>worker.py</code> file from <a target="_blank" href="https://cloud.google.com/storage/docs/">Google Cloud Storage</a> into the VM (I will explain how to upload your files to the storage below).</li>
<li><strong>Line 5</strong>: here you need to specify a JSON string of your key so that Google can verify your credentials. In order to get this string you need to <a target="_blank" href="https://console.cloud.google.com/iam-admin/iam/project">create a service account</a>. Select <code>**Furnish a new private key**</code> and for <code>**Key type**</code> use <code>JSON</code>. A file will be downloaded to your computer. Copy the content and turn it into a JSON string (using <code>JSON.stringify(key_in_json_format)</code> in a browser console). Paste it instead of <code>SERVICE_ACCOUNT_KEY</code><em>.</em></li>
<li><strong>Line 6</strong>: exports the key as an <a target="_blank" href="https://developers.google.com/identity/protocols/application-default-credentials">environment variable</a> which will be used by the Google APIs to verify your credentials.</li>
<li><strong>Lines 7 - 12</strong>: sets up configurations and installs the python libraries.</li>
<li><strong>Line 15</strong>: runs the worker.</li>
</ul>
<p>Now you need to upload <code>worker.py</code> and <code>startup-script.sh</code> to your storage and set up the VM. To upload the files just go <a target="_blank" href="https://console.cloud.google.com/storage/">here</a> and create a new bucket with the same name as your project id. Create a folder called <em>workers</em> and upload the scripts inside. <strong>Make sure to change the <code>worker.py</code> to a ‘Public link<em>’</em> and edit the permissions of the <code>_startup-script.sh_</code></strong> <strong>to</strong> have your service account as an owner.</p>
<h4 id="heading-configurations-and-testing">Configurations and testing</h4>
<p>The final step is to set up the configurations of the VM and test the system. Just follow the <a target="_blank" href="https://cloud.google.com/solutions/media-processing-pub-sub-compute-engine">‘Create an instance template’ instructions from the documentation</a> and you are good to go!</p>
<p>Once the VM boots up, you can try sending requests to your application and examine how it reacts by checking the <a target="_blank" href="https://console.cloud.google.com/logs/viewer">logs</a>.</p>
<h4 id="heading-final-thoughts">Final thoughts</h4>
<p>Going through Google’s documentation may help you a lot. Also check out this <a target="_blank" href="https://cloud.google.com/solutions/media-processing-pub-sub-compute-engine">tutorial</a> - you may find it useful while implementing some of the steps above.</p>
<p>I want to express my gratefulness to <a target="_blank" href="https://www.freecodecamp.org/news/decentralize-your-application-with-google-cloud-platform-7149ec6d0255/undefined">Logan Allen</a> for helping me better understand this process. I hope you find it useful.</p>
<p>Leave any questions or suggestions in the comment section.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
