<?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[SimpleID — Engagement and Retention - Medium]]></title>
        <description><![CDATA[Build relationships with users in a privacy preserving way by leveraging on-chain analytics for segmented notifications and emails. - Medium]]></description>
        <link>https://medium.com/simpleid-dev-tools?source=rss----fc8043ca5f65---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>SimpleID — Engagement and Retention - Medium</title>
            <link>https://medium.com/simpleid-dev-tools?source=rss----fc8043ca5f65---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 05:15:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/simpleid-dev-tools" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What Web3 Can Learn From Web2]]></title>
            <link>https://medium.com/simpleid-dev-tools/what-web3-can-learn-from-web2-e3c13a464ead?source=rss----fc8043ca5f65---4</link>
            <guid isPermaLink="false">https://medium.com/p/e3c13a464ead</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[decentralization]]></category>
            <dc:creator><![CDATA[Justin Hunter]]></dc:creator>
            <pubDate>Thu, 05 Mar 2020 15:08:03 GMT</pubDate>
            <atom:updated>2020-03-05T15:08:03.650Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fI0c55mTVDhempyEO-bBeg.jpeg" /></figure><p>The paradigm shift enabled by Web3, whether you define Web3 as blockchain-based or distributed-systems-based, is powerful. It tries to solve many of the problems Web2 created. Technology was the thing that was supposed to unlock power for everyone and connect the world. It has largely done that, but it also re-centralized problems.</p><p>Google, Facebook, and Amazon have <a href="https://www.quora.com/How-much-data-does-Google-have">hoarded data</a>, <a href="https://www.bbc.com/news/technology-46618582">sold data</a>, and exposed a major flaw in the way we interact with the web — <a href="https://www.cnet.com/how-to/have-amazon-echo-privacy-fears-heres-what-you-can-do/">lack of privacy</a>. As we rebuild the web through Web3, we don’t want to make the same mistakes as Web2. At the same time, it would be foolish not to understand and implement some of the things that made Web2 so freeing and so powerful. If we don’t, Web3 will essentially be built in a bunker that we can’t escape from.</p><p>The most important thing to avoid is isolation in the things built for Web3. What this means is that cool technology alone is never going to be adopted wide enough to solve the problems of Web2. It will only solve those problems for the select few already in the inner circle. How do we avoid that isolation, though? We do it by adopting something Web2 did very well, something humans have done since the dawn of mankind.</p><p><strong><em>Communicate.</em></strong></p><p>The first action ever taken on ARPANET in 1969, the infrastructure that would eventually become the internet that we know, <a href="https://www.edn.com/arpanet-establishes-1st-computer-to-computer-link-october-29-1969/">was to send a message</a>. To communicate. Since then, technology has advanced largely around enabling communication and connection. This is as true for technology before ARPANET as it has been for technology created in the last 15 years. The tools we have used over time to communicate have been refined, adapted, and improved. From carving petroglyphs on cave walls to painting entire stories on those same walls to writing text to printing text, communication has been at the core of many of the technological advances that helped shape humanity. This is not hyperbole. Apple would not be here today if it wasn’t for their ability to connect people. Social media, for all its flaws, rose from a desire to connect with other humans. Cell phones, text messaging, WiFi calling, video calls, remote conferences, and more are all examples of more recent technological advancements that were shaped around communication.</p><p>But even technology not specific to communication has long leveraged humanity’s desire to stay connected and be informed. eBay launched in 1995 as a tool to buy and sell goods. However, they soon realized they needed to be more than that to succeed. In 1998, they <a href="https://www.cs.brandeis.edu/~magnus/ief248a/eBay/history.html">restructured around the idea</a> that <strong><em>“eBay is a company that’s in the business of connecting people, not selling them things.”</em></strong></p><p>And this leads us back to Web3. The space is still young (though not THAT young), but that’s not an excuse to ignore the fundamental idea that helps propel almost all business forward: communication. Yet, that’s exactly what’s happened thus far. Web3 has built systems that enable privacy but it has also locked people out. For example, a decentralized finance application today is NOT in the business of connecting people. They are in the business of optimizing smart contract code to deliver financial results. That’s all well and good, but it’s not going to be the thing that drives mass adoption. As eBay realized early on, connecting people is the only real way to ensure growth and adoption. And connection happens through communication.</p><p>The ability to connect people is the one thing Web2 got really right. We need to replicate that in Web3 but shaped around the Web3 ethos. That’s exactly what SimpleID is doing. <a href="https://simpleid.xyz/">We hope you’ll join us</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3c13a464ead" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simpleid-dev-tools/what-web3-can-learn-from-web2-e3c13a464ead">What Web3 Can Learn From Web2</a> was originally published in <a href="https://medium.com/simpleid-dev-tools">SimpleID — Engagement and Retention</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interview With Alex Soong — Co-founder of Set Protocol]]></title>
            <link>https://medium.com/simpleid-dev-tools/interview-with-alex-soong-co-founder-of-set-protocol-a45c8a5b644f?source=rss----fc8043ca5f65---4</link>
            <guid isPermaLink="false">https://medium.com/p/a45c8a5b644f</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[open-finance]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Justin Hunter]]></dc:creator>
            <pubDate>Wed, 12 Feb 2020 11:49:11 GMT</pubDate>
            <atom:updated>2020-02-12T11:49:10.963Z</atom:updated>
            <content:encoded><![CDATA[<h3>Interview With Alex Soong — Co-founder of Set Protocol</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rsfunc1NIRFfdY6d.png" /></figure><p>This is part of a series of interviews with founders and builders in the Web3 space called the Web3 Growth Handbook. The official handbook will be released in the coming months, but you can read all of the other available interviews <a href="https://blog.simpleid.xyz/tag/web3-growth-series/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/0*9zxnSJcx7LdRYOTx.png" /><figcaption>Alex Soong, CTO of Set Protocol</figcaption></figure><blockquote>“We’ve developed internally the idea of environment management. I think when Web3 came up, there was this idea that you would only have a front end and set of smart contracts. The truth is, you need a backend that has the responsibility of reading data and state off the chain. You can’t go to the chain for everything, because it would make for an unusable app.”</blockquote><p>Automated asset management is not a new concept, but decentralized and open finance have provided an easier path to access the benefits of automated asset management. Permissionless finance is the driving force behind the entire DeFi movement, and <a href="https://www.tokensets.com/">Set Protocol</a> has been one of the biggest players. Their CTO, Alex Soong, understands that despite DeFi’s significant attention over the last year or so, there are problems that need to be overcome.</p><p>Set Protocol launched in November of 2017 and has since built out a suite of projects all geared towards moving DeFi forward. To date, the main customer-facing projects are TokenSets and Social Trader. TokenSet is the DeFi equivalent to index funds in traditional finance. By investing in a single asset, called a Set, the investor can have their money allocated across multiple financial products designed to provide the highest return without manually updating portfolio positions. Social Trader allows investors to match their investment strategy with the best traders on TokenSets. These products have helped Set Protocol secure a $2 million seed round in March of 2018.</p><p>We had the chance to sit down with Alex to talk about how Set Protocol manages the challenges of growing in Web3 while also making sure his company provides the right features for the existing customer base.</p><h3>How do you define growth?</h3><blockquote><em>One of the questions we get asked all the time is what is your plan for decentralization. I think that type of question is tightly coupled with growth. How do we build in mechanisms as the contract layer and the dapp layer to behave correctly? Right now, we get some of the features of open finance but not necessarily decentralized finances. We have mechanisms in place that prevents us from changing some of the controls, but it’s not completely decentralized. Governance does not equal decentralization.</em></blockquote><blockquote><em>So growth for us is designing mechanisms such as social trading so that people are incentivized to promote us. They go out and build their own following and promote us. Growth to us moving to be more decentralized.</em></blockquote><h3>What has been the most difficult part of growing your company so far?</h3><blockquote><em>It has to be the fact that there are problems in this space that are definitely under-appreciated in solving. People take for granted how difficult it is to build up a node network. You’re asking other people to run nodes for you. There isn’t a cron system on Ethereum, so it requires other people running nodes for you to process the data you need.</em></blockquote><blockquote><em>Liquidity is the other big second. Liquidity is not always there. Market makers will follow the money, but without enough precedent, they have no incentive to put their money on chain. That’s the main reason we built TokenSets, to bootstrap the network. We thought we could just put code out there and people would just build on top of us. But we had to provide a bootstrapping mechanism. Now we have people who are willing to be traders on the platform.</em></blockquote><h3>What tools do you wish were there to help you grow?</h3><blockquote><em>We’ve developed internally the idea of environment management. I think when Web3 came up, there was this idea that you would only have a front end and set of smart contracts. The truth is, you need a backend that has the responsibility of reading data and state off the chain. You can’t go to the chain for everything, because it would make for an unusable app.</em></blockquote><blockquote><em>Internally, we have three environments. We have a matrix of staging environments rather than just two environments like you’d see in Web2. If you don’t want to spend real gas, you’d use and environment dedicated to that. Tools that help with environment management would be helpful.</em></blockquote><h3>What are your predictions for Web3/Blockchain growth in 2020?</h3><blockquote><em>For 2020, I think we’ve made great strides in terms of UX. Teams like Zerion had made it really easy to parse information that’s on chain. We need to bridge the gap for fiat to crypto on-ramp. Wyre is tackling that. If we can solve that combined with the UX improvements, growth can explode. We will be a lot closer to being on par with Web2. Can we cut out the step of having to go on Coinbase and then move that money to a wallet to use the apps? If so, we will see a boom in usage.</em></blockquote><p>Set Protocol is innovating and powering the DeFi space. If you are an investor that wants to see their money earning the best rate at any given time, you should <a href="https://www.tokensets.com/">look into Set Protocol</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a45c8a5b644f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simpleid-dev-tools/interview-with-alex-soong-co-founder-of-set-protocol-a45c8a5b644f">Interview With Alex Soong — Co-founder of Set Protocol</a> was originally published in <a href="https://medium.com/simpleid-dev-tools">SimpleID — Engagement and Retention</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web3 Growth Series: Interview With Joe Lallouz From Bison Trails]]></title>
            <link>https://medium.com/simpleid-dev-tools/web3-growth-series-interview-with-joe-lallouz-from-bison-trails-cf1839ba41cc?source=rss----fc8043ca5f65---4</link>
            <guid isPermaLink="false">https://medium.com/p/cf1839ba41cc</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[customer-engagement]]></category>
            <category><![CDATA[infrastructure]]></category>
            <dc:creator><![CDATA[Justin Hunter]]></dc:creator>
            <pubDate>Thu, 23 Jan 2020 17:07:34 GMT</pubDate>
            <atom:updated>2020-01-23T17:07:34.356Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*tR68Px34jozRWBY0.jpg" /></figure><blockquote><em>“We have to continue doing the unscalable things and be patient during the early days of growth — it happens, but timing also matters. The most transformative technologies in the world didn’t happen overnight even though it feels like it now.”</em></blockquote><p>The future of blockchain is not one where a single blockchain rules all. At least, that’s the future Bison Trails sees. This is why the company focuses on making it easy to build across multiple blockchains. A founding member of the Facebook Libra Association, Bison Trails supports or is developing support for dozens of protocols. Their CEO, Joe Lallouz, is bullish on the future of blockchain, but he believes it will take a lot of patience to get to where the entire industry has scaled.</p><p><a href="https://blog.simpleid.xyz/2020/01/23/interview-with-joe-lallouz-bison-trails.html">Read the rest on the SimpleID blog.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf1839ba41cc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simpleid-dev-tools/web3-growth-series-interview-with-joe-lallouz-from-bison-trails-cf1839ba41cc">Web3 Growth Series: Interview With Joe Lallouz From Bison Trails</a> was originally published in <a href="https://medium.com/simpleid-dev-tools">SimpleID — Engagement and Retention</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethereum’s User Growth]]></title>
            <link>https://medium.com/simpleid-dev-tools/ethereums-user-growth-edfe596f8933?source=rss----fc8043ca5f65---4</link>
            <guid isPermaLink="false">https://medium.com/p/edfe596f8933</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Justin Hunter]]></dc:creator>
            <pubDate>Wed, 11 Dec 2019 21:57:37 GMT</pubDate>
            <atom:updated>2019-12-11T21:57:37.734Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*KEx6ppAiei2bsFTfqXndOg.png" /></figure><p>As the year comes to a close, we’ll see plenty of year in review articles. This is one of them, but with a very specific purpose. We have talked to dozens of companies as we began the process of building SimpleID. Through those conversations, we’ve learned a lot about where founders in the Web3 space think the market is, where they think it’s going, and what the biggest problems are. Today, we’re going to focus on the problems with growth. But first, let’s look at the raw numbers.</p><p>We’ve moved our blog to a self-hosted site. <a href="https://blog.simpleid.xyz/2019/12/11/ethereum-user-growth.html">Read the rest of the the story here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edfe596f8933" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simpleid-dev-tools/ethereums-user-growth-edfe596f8933">Ethereum’s User Growth</a> was originally published in <a href="https://medium.com/simpleid-dev-tools">SimpleID — Engagement and Retention</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Products That Solve Problems]]></title>
            <link>https://medium.com/simpleid-dev-tools/building-products-that-solve-problems-c0092d24fd58?source=rss----fc8043ca5f65---4</link>
            <guid isPermaLink="false">https://medium.com/p/c0092d24fd58</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[usability]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[product]]></category>
            <dc:creator><![CDATA[Justin Hunter]]></dc:creator>
            <pubDate>Fri, 20 Sep 2019 15:59:44 GMT</pubDate>
            <atom:updated>2019-09-20T15:59:44.556Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*qahjsPTGwJhZQYxo" /><figcaption>Photo via <a href="https://unsplash.com/@punttim">https://unsplash.com/@punttim</a></figcaption></figure><p>When writing software, it’s easy to assume whatever is shipped will solve problems. After all, that’s the whole idea of code — automate the solution of specific problems. But code doesn’t do this inherently. And when you productize code, it gets even more complicated. All of this applies doubly to code designed around new technologies. It’s incredibly easy to get excited about the technology and build solutions that people don’t actually want or need. Even if they do need the solution, it’s possible people don’t want it. In that case, your code has to solve the problem but also bridge that gap of need and want.</p><p>For my company, <a href="https://www.simpleid.xyz/?s=med?t=buidl">SimpleID — a developer tools suite for Web 3.0</a>, we fall into that last bucket. We need to solve a problem but we need to do it in a way that enables the ultimate end-users to adopt the solutions built via SimpleID en masse. We’re not alone in this problem. The issue applies to product creators across Web 2.0 and Web 3.0.</p><p>Let’s take a look at the market I’m working in: Web 3.0. Web 3.0 is essentially the decentralized web. The web where users control their data, not big tech companies. In the Web 3.0 space there are many solutions offering non-custodial, completely decentralized experiences. They are great, and they are needed. But to those solutions, the question we have to ask is:</p><h4>Who is the customer?</h4><p>If you are building a solution that applies to the slim minority of cypherpunks and developers who are willing to go through the complexities of using your solution, that’s great. But if you, like many in the Web 3.0 space, want to attract the wider internet user-base, you have to make your solution attractive to that market.</p><p>In other words, you have to bridge the gap.</p><p>The problems many of us in the Web 3.0 space are trying to solve are similar:</p><ul><li>Privacy</li><li>Security</li><li>Data Ownership</li><li>Identity Control</li></ul><p>The way those problems are solved is what differs. In almost all cases today, the tooling around building applications that satisfy the above needs place an unprecedented burden on users of the modern web. I say modern web here because surely someone somewhere will be able to point out a scenario in the very early days of the World Wide Web where people had extreme cognitive burden in order to use the new technology.</p><p>So, again, when building in the Web 3.0 space, ask yourself who are you building for. If you’re building for a future customer who will be willing to shoulder the additional burden of using the protocol or product, do that. That’s necessary. If you’re building for the developers who will eventually find a way to make the underlying protocol and tools convenient, do that. That’s also necessary. But if you’re building for enterprises and consumers today, consider the solution you’re offering.</p><p>Does it truly need to be non-custodial? Does it truly need to be trust-less? Is what you’re offering so much better that you can legitimately ask people to do more work AND pay you? Or, is there a way to give people enough decentralization and access to decentralized technologies to satisfy the problems in the bullet-points above?</p><h3>Dandelion Mane 🌸🦁 on Twitter</h3><p>The crypto space has massively over-indexed on trustlessness. We ape bitcoin, which *needs* to be trustless. But in many cases, trust-but-verify is sufficient. Trust is valuable, which means trustlessness is expensive. This is why our cool projects are mostly unusable. https://t.co/0ZKuOYY7xE</p><p>Whether it’s in the Web 3.0 space or the Web 2.0 space, it’s necessary to always ask yourself who your customers are. Build for them, not for yourself. Your ideals matter, but if you are trying to build for an audience, their ideals matter more.</p><p>Your product is only as good as the adoption is sees. Adoption, of course, is relative. But no matter what, you have to see that people are using it. Otherwise, it’s very possible you are not solving the problems your customers need you to solve.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0092d24fd58" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simpleid-dev-tools/building-products-that-solve-problems-c0092d24fd58">Building Products That Solve Problems</a> was originally published in <a href="https://medium.com/simpleid-dev-tools">SimpleID — Engagement and Retention</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Versioning System With IPFS and Blockstack]]></title>
            <link>https://medium.com/simpleid-dev-tools/build-a-versioning-system-with-ipfs-and-blockstack-5992e34b1bd2?source=rss----fc8043ca5f65---4</link>
            <guid isPermaLink="false">https://medium.com/p/5992e34b1bd2</guid>
            <category><![CDATA[blockstack]]></category>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Justin Hunter]]></dc:creator>
            <pubDate>Fri, 13 Sep 2019 20:13:19 GMT</pubDate>
            <atom:updated>2019-09-13T20:13:19.090Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*kXiYYKl3rt6KniZA" /><figcaption>Being able to see version history is like rewinding history</figcaption></figure><p>There are so many great use cases for versioning. Handling code deployments, document edits, and database snapshots are just a few immediate uses that come to mind. Normally, a versioning system is another segment within a database, but it can be so much more when you think of it through the lens of immutable data and DHT (distributed hash tables) technology. So, today, we’re going to build a stream of consciousness note-taking app with version history. This will be different than other notes apps as it will have just ONE note that the user can edit over time, removing information or adding information. But we’ll include versions so they can grab their history. We’ll do all that by using Blockstack and IPFS.</p><p><a href="https://blockstack.org/">Blockstack</a> is a decentralized application platform that lets users choose where there data is stored. For the similicity of this tutorial, we’re going to use the storage hub provided by Blockstack the company (it’s free and there’s no configuration needed). <a href="https://ipfs.io/">IPFS</a> a peer-to-peer network that allows data to be served based on its content, not its location. This means that when the data changes, it is represented by a different identifier (a hash), and the old version of the data still exists, unchanged. This is perfect for a versioning system. We’re going to build all of this by creating a new React project and installing just one dependency: <a href="https://www.simple.id.xyz/?s=med?t=vsys">SimpleID</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qTNxfO94yDZSAIvPRgMVog.png" /></figure><p><a href="https://www.simpleid.xyz/?s=med?t=vsys1">SimpleID</a> provides developer tools for the decentralized web. In a nutshell, SimpleID lets developers add decentralized authentication and storage to their apps without asking their users to go through the cumbersom process of generating seed phrases and managing those 12-word backups. Users get a traditional username/password authentication flow while still owning their identity and getting access to Web 3.0 technology.</p><p>To get started, visit SimpleID and <a href="https://www.simpleid.xyz/#app?s=med?t=ipfs_vs">sign up for a free developer account</a>. Once you verify your account, you’ll be able to create a project and select the Web 3.0 modules to include in your project. Let’s walk through that quickly:</p><p>1. Sign up for developer account</p><p>2. Click the verification link in your email</p><p>3. Once your account is verified, you’ll be on the Accounts page where you can create a new project</p><p>4. Give that new project a name and a URL where you may eventually host it (this can be a fake url for now as long as it’s https based)</p><p>5. Save and then click View Project</p><p>6. Copy down your API Key and Developer ID</p><p>7. Go to the Modules page and select Blockstack for your Authentication Module and both Blockstack and Pinata for your Storage Module</p><p>8. Click Save</p><p>That’s it! Now, you’re ready to work. Quick note about <a href="https://pinata.cloud/">Pinata</a>: They provide an IPFS pinning service, so SimpleID uses them behind the scenes to add content to the IPFS network and to pin said content to ensure it is always available. Read more about pinning <a href="https://docs.ipfs.io/guides/concepts/pinning/">here</a>.</p><p>Let’s build a project. My instructions will be from the MacOS perspective, but those of you on different systems should be able to use similar commands to get started. First, open up your terminal and create the new React project:</p><p>npx create-react-app ipfs-blockstack-versioning</p><p>When that’s done, change into the directory and then install the SimpleID dependency:</p><p>cd ipfs-blockstack-versioning</p><p>npm i simpleid-js-sdk</p><p>Ok, open the project up in your text editor of choice. We’re not going to spend time with complex folder structure. This is a very basic application designed to show off the power of Blockstack and IPFS. With that in mind, find the src folder and open App.js. At the top of that file add the following right below the import css statement:</p><pre>import { createUserAccount, login, pinContent, fetchPinnedContent } from &#39;simpleid-js-sdk&#39;;</pre><pre>const config = {<br>  apiKey: ${yourApiKey}, //found in your SimpleID account page<br>  devId: ${yourDevId}, //found in your SimpleID account page<br>  authProviders: [&#39;blockstack&#39;], //array of auth providers that matches your modules selected<br>  storageProviders: [&#39;blockstack&#39;, &#39;pinata&#39;], //array of storage providers that match the modules you selected<br>  appOrigin: &quot;https://yourapp.com&quot;, //This should match the url you provided in your dev account sign up<br>  scopes: [&#39;publish_data&#39;, &#39;store_write&#39;, &#39;email&#39;]  //array of permission you are requesting from the user<br>}</pre><p>Ok, now with the SimpleID package imported and this config object (which comes right from the<a href="https://docs.simpleid.xyz/"> SimpleID Docs</a>), you’re ready to get started. Let’s work on the user interface a bit. As I mentioned, this is going to be a really simple app, so let’s drop in an editor for handling our document. We’ll do this with a script tag in the index.html file rather than installing a dependency via NPM. You can use any WYSIWYG library, but I&#39;m going to use is called Medium Editor. You can find it <a href="https://github.com/yabwe/medium-editor">here</a>.</p><p>Your index.html file is located in the public folder. Find it and add this above the title tag:</p><pre>&lt;link rel=&quot;stylesheet&quot; href=&quot;//cdn.jsdelivr.net/npm/medium-editor@latest/dist/css/medium-editor.min.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; charset=&quot;utf-8&quot;&gt;<br>    &lt;script src=&quot;//cdn.jsdelivr.net/npm/medium-editor@latest/dist/js/medium-editor.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;title&gt;NoteStream&lt;/title&gt;</pre><p>You’ll note, I set the title of my app here since we were already editing the file. Feel free to use the same name or create your own. Now that we’ve added the stylesheet and the script we need, let’s move to our App.js file which is located in the src folder. We&#39;re going to clear everything out of this file and start mostly from scratch. So, update your App.js file to look like this:</p><pre>import React from &#39;react&#39;;<br>import &#39;./App.css&#39;;<br>import { createUserAccount, login, pinContent, fetchPinnedContent } from &#39;simpleid-js-sdk&#39;;</pre><pre>const config = {<br>  apiKey: ${yourApiKey}, //found in your SimpleID account page<br>  devId: ${yourDevId}, //found in your SimpleID account page<br>  authProviders: [&#39;blockstack&#39;], //array of auth providers that matches your modules selected<br>  storageProviders: [&#39;blockstack&#39;, &#39;pinata&#39;], //array of storage providers that match the modules you selected<br>  appOrigin: &quot;https://yourapp.com&quot;, //This should match the url you provided in your dev account sign up<br>  scopes: [&#39;publish_data&#39;, &#39;store_write&#39;, &#39;email&#39;]  //array of permission you are requesting from the user<br>}</pre><pre>class App extends React.Component {<br>  constructor(props) {<br>    super(props);<br>    this.state = {<br>      userSession,<br>      content: &quot;&quot;, <br>      versions: [],<br>      selectedVersionContent: &quot;&quot;, <br>      pageRoute: &quot;signup&quot;,<br>      versionPane: false, <br>      versionModal: false <br>    }<br>  }<br>  render() {<br>    return (<br>      &lt;div className=&quot;App&quot;&gt;</pre><pre>      &lt;/div&gt;<br>    );<br>  }<br>}</pre><pre>export default App;</pre><p>I’ve converted the function component to a class component, but you can do this as a function component with some minor changes to the way state is handled. You can see I have four state variable that I expect to use: userSession (which will be filled from our Blockstack authentication), content (which will be the actual streaming note), versions (which will be our history), selectedVersionContent (which will be used for displaying the actual content of past versions), pageRoute (which is for handling that is displayed on the screen), versionPane (which determines if the version pane is showing), and versionModal (which determines if the version modal is open or not).</p><p>I think the first thing we should do is get a signup and sign in screen rendering. Within the &lt;div&gt; with the className of “App”, add some conditional logic with form inputs like this:</p><pre>render() {<br>    const { pageRoute, userSession } = this.state;<br>    return (<br>      &lt;div className=&quot;App&quot;&gt;<br>        {<br>          pageRoute === &quot;signup&quot; &amp;&amp; !userSession.isUserSignedIn() ? <br>          &lt;div&gt;<br>            Sign Up<br>          &lt;/div&gt; : <br>          pageRoute === &quot;signin&quot; &amp;&amp; !userSession.isUserSignedIn() ?<br>          &lt;div&gt;<br>            Sign In<br>          &lt;/div&gt; : <br>          &lt;div&gt;<br>            App Content<br>          &lt;/div&gt;<br>        }<br>      &lt;/div&gt;<br>    );<br>  }</pre><p>We are obviously going to fill this in with actual content, but this should help illustrate what’s happening. If that pageRoute state is &quot;signup&quot; and the user is NOT logged in, we should show the signup form. If the pageRoute state is &quot;signin&quot; and the user is NOT logged in, we should show the sign in form. Otherwise, we should show the app.</p><p>Now, let’s build this out a little. Let’s start by handling the Blockstack userSession state. This is actually pretty simple. At the top of our App.js file, just add this below the import statements:</p><pre>import { UserSession } from &#39;blockstack&#39;;<br>import { AppConfig } from &#39;blockstack&#39;</pre><pre>const appConfig = new AppConfig([&#39;store_write&#39;, &#39;publish_data&#39;, &#39;email&#39;]);<br>const userSession = new UserSession({ appConfig });</pre><p>You should add this to the top of your actions.js file as well below the existing import statement. Blockstack comes installed with SimpleID, so you don&#39;t need to add anymore dependencies. Ok, now let&#39;s add the necessary sign in and sign up forms to our App.js file:</p><pre>class App extends React.Component {<br>  constructor(props) {<br>    super(props);<br>    this.state = {<br>      userSession,<br>      content: &quot;&quot;,<br>      versions: [],<br>      selectedVersionContent: &quot;&quot;,<br>      pageRoute: &quot;signup&quot;,<br>      versionPane: false,<br>      versionModal: false,<br>      username: &quot;&quot;,<br>      password: &quot;&quot;,<br>      email: &quot;&quot;,<br>      loading: false, <br>      error: &quot;    <br>    }<br>  }</pre><pre>  handleUsername = (e) =&gt; {<br>    this.setState({ username: e.target.value });<br>  }</pre><pre>  handlePassword = (e) =&gt; {<br>    this.setState({ password: e.target.value });<br>  }</pre><pre>  handleEmail = (e) =&gt; {<br>    this.setState({ email: e.target.value });<br>  }</pre><pre>  handleSignIn = (e) =&gt; {<br>    e.preventDefault();<br>  }</pre><pre>  handleSignUp = (e) =&gt; {<br>    e.preventDefault();<br>  }</pre><pre>render() {<br>  const { pageRoute, userSession, username, password, email, error } = this.state;<br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>    {<br>      pageRoute === &quot;signup&quot; &amp;&amp; !userSession.isUserSignedIn() ?<br>      &lt;div&gt;<br>        &lt;form onClick={this.handleSignIn} className=&quot;auth-form&quot;&gt;<br>          &lt;input placeholder=&quot;username&quot; id=&quot;username-sign-up&quot; type=&quot;text&quot; value={username} onChange={this.handleUsername} /&gt;<br>          &lt;input placeholder=&quot;password&quot; id=&quot;password-sign-up&quot; type=&quot;password&quot; value={password} onChange={this.handlePassword} /&gt;<br>          &lt;input placeholder=&quot;email&quot; id=&quot;password-sign-up&quot; type=&quot;email&quot; value={email} onChange={this.handleEmail} /&gt;<br>          &lt;button type=&quot;submit&quot;&gt;Sign In&lt;/button&gt;<br>        &lt;/form&gt;<br>        &lt;p&gt;Already have an account? &lt;button onClick={() =&gt; this.setState({ pageRoute: &quot;signin&quot; })} className=&quot;button-link&quot;&gt;Sign In.&lt;/button&gt;&lt;/p&gt;<br>        &lt;p&gt;{error}&lt;/p&gt;<br>      &lt;/div&gt; :<br>      pageRoute === &quot;signin&quot; &amp;&amp; !userSession.isUserSignedIn() ?<br>      &lt;div&gt;<br>        &lt;form onSubmit={this.handleSignUp} className=&quot;auth-form&quot;&gt;<br>          &lt;input placeholder=&quot;username&quot; id=&quot;username-sign-in&quot; type=&quot;text&quot; value={username} onChange={this.handleUsername} /&gt;<br>          &lt;input placeholder=&quot;password&quot; id=&quot;password-sign-in&quot; type=&quot;password&quot; value={password} onChange={this.handlePassword} /&gt;<br>          &lt;button type=&quot;submit&quot;&gt;Sign In&lt;/button&gt;<br>        &lt;/form&gt;<br>        &lt;p&gt;Need to sign up? &lt;button onClick={() =&gt; this.setState({ pageRoute: &quot;signup&quot; })} className=&quot;button-link&quot;&gt;Register.&lt;/button&gt;&lt;/p&gt;<br>        &lt;p&gt;{error}&lt;/p&gt;<br>      &lt;/div&gt; :<br>      &lt;div&gt;<br>        App Content<br>      &lt;/div&gt;<br>      }<br>    &lt;/div&gt;<br>    );<br>  }<br>}</pre><pre>export default App;</pre><p>There’s a lot we’ve added here, but it’s pretty simple to understand. We added the functions to handle the sign up and sign in flow. We added a form to handle each of those inputs as well. We added a state switcher so that someone on the sign in form could switch to the sign up form and vice versa. We also have a paragraph section ready in both the sign up form and the sign in form to handle any error that might happen during sign up or sign in.</p><p>With all of this in place, I think we can finally fire up our app and see how well it’s working. From the terminal run npm start.</p><p>Hopefully that worked for you. If it did you’ll see a god-awful ugly sign up form. You can switch to the sign in form and switch back as well.We’re not going to be touching much CSS in this tutorial, but we’ve got the start of a functioning app. You may have noticed earlier, I added a state variable called loading. We’re going to use that here in just a second as we actually sign a user up and log them in. We’ll start with the sign up process. And again, for this, we’ll be using the <a href="https://docs.simpleid.xyz/">SimpleID Docs</a>.</p><p>Find the handleSignUp function and fill it in like so:</p><pre>handleSignUp = async (e) =&gt; {<br>  e.preventDefault();<br>  this.setState({ loading: true, error: &quot;&quot; });<br>  const { username, password, email } = this.state;<br>  const credObj = {<br>    id: username,<br>    password: password,<br>    hubUrl: &#39;https://hub.blockstack.org&#39;, //This is the default Blockstack storage hub<br>    email: email<br>  }</pre><pre>  try {<br>    const account = await createUserAccount(credObj, config);<br>    localStorage.setItem(&#39;blockstack-session&#39;, JSON.stringify(account.body.store.sessionData));<br>    window.location.reload();<br>  } catch(err) {<br>    console.log(err);<br>    this.setState({ loading: false, error: &quot;Trouble signing up...&quot;})<br>  }<br>}</pre><p>We made our function asynchronous because we need to wait for the createUserAccount promise to resolve before we can do anything else. Other that that, we simply followed the docs and added a try/catch. If there’s an error, the error state will be updated and the loading state will be set back to false. The user should see the error message on the screen then. If there’s no error, the localStorage item Blockstack needs is updated and we refresh the window.</p><p>One last thing we should do before testing the sign up flow is add a loading indicator. This isn’t going to be anything special, but when signing up, the indicator will replace everything else on the screen. Let’s update our app code JSX to look like this:</p><pre>&lt;div className=&quot;App&quot;&gt;<br>  {<br>    loading ?<br>    &lt;div&gt;<br>    &lt;h1&gt;Loading...&lt;/h1&gt;<br>    &lt;/div&gt; :<br>    &lt;div&gt;</pre><pre>    {<br>      pageRoute === &quot;signup&quot; &amp;&amp; !userSession.isUserSignedIn() ?<br>      &lt;div&gt;<br>        &lt;div onSubmit={this.handleSignIn} className=&quot;auth-form&quot;&gt;<br>          &lt;input placeholder=&quot;username&quot; id=&quot;username-sign-up&quot; type=&quot;text&quot; value={username} onChange={this.handleUsername} /&gt;<br>          &lt;input placeholder=&quot;password&quot; id=&quot;password-sign-up&quot; type=&quot;password&quot; value={password} onChange={this.handlePassword} /&gt;<br>          &lt;input placeholder=&quot;email&quot; id=&quot;password-sign-up&quot; type=&quot;email&quot; value={email} onChange={this.handleEmail} /&gt;<br>          &lt;button type=&quot;submit&quot;&gt;Sign In&lt;/button&gt;<br>        &lt;/form&gt;<br>        &lt;p&gt;Already have an account? &lt;button onClick={() =&gt; this.setState({ pageRoute: &quot;signin&quot; })} className=&quot;button-link&quot;&gt;Sign In.&lt;/button&gt;&lt;/p&gt;<br>        &lt;p&gt;{error}&lt;/p&gt;<br>      &lt;/div&gt; :<br>      pageRoute === &quot;signin&quot; &amp;&amp; !userSession.isUserSignedIn() ?<br>      &lt;div&gt;<br>        &lt;form onSubmit={this.handleSignUp} className=&quot;auth-form&quot;&gt;<br>          &lt;input placeholder=&quot;username&quot; id=&quot;username-sign-in&quot; type=&quot;text&quot; value={username} onChange={this.handleUsername} /&gt;<br>          &lt;input placeholder=&quot;password&quot; id=&quot;password-sign-in&quot; type=&quot;password&quot; value={password} onChange={this.handlePassword} /&gt;<br>          &lt;button type=&quot;submit&quot;&gt;Sign In&lt;/button&gt;<br>        &lt;/form&gt;<br>        &lt;p&gt;Need to sign up? &lt;button onClick={() =&gt; this.setState({ pageRoute: &quot;signup&quot; })} className=&quot;button-link&quot;&gt;Register.&lt;/button&gt;&lt;/p&gt;<br>        &lt;p&gt;{error}&lt;/p&gt;<br>      &lt;/div&gt; :<br>      &lt;div&gt;<br>        App Content<br>      &lt;/div&gt;<br>     }<br>   &lt;/div&gt;<br>  }<br>&lt;/div&gt;</pre><p>Let’s test this out now. Go ahead and type a username, password, and email and then click sign up. Assuming that worked, you should have seen the loading screen and then after a few seconds, the user is logged in and the words “App Content” appear. Nice!</p><p>But now what? We haven’t handled sign in, and the user can’t sign out. Let’s handle sign out first since it’s really simple. In the section of your app where you have the words “App Content” add a button that calls the handleSignOut function:</p><pre>&lt;button onClick={this.handleSignOut}&gt;Sign Out&lt;/button&gt;</pre><p>Then make sure to add that function up with your other functions:</p><pre>handleSignOut = () =&gt; {<br>  localStorage.removeItem(&#39;blockstack-session&#39;);<br>  window.location.reload();<br>}</pre><p>Give that a try and the user should be signed out. Now, we can work on log in. I hope you remembered your username and password. Let’s wire up the handleSignIn function:</p><pre>handleSignIn = async (e) =&gt; {<br>  e.preventDefault();<br>  this.setState({ loading: true, error: &quot;&quot; });<br>  const { username, password } = this.state;<br>  const credObj = {<br>    id: username,<br>    password,<br>    hubUrl: &#39;https://hub.blockstack.org&#39; //This is the default Blockstack storage hub<br>  }<br>  const params = {<br>    credObj,<br>    appObj: config,<br>    userPayload: {} //this can be left as an empty object<br>  }<br>  try {<br>    const signIn = await login(params);<br>    if(signIn.message === &quot;user session created&quot;) {<br>      localStorage.setItem(&#39;blockstack-session&#39;, JSON.stringify(signIn.body.store.sessionData));<br>      window.location.reload();<br>    } else {<br>      this.setState({ loading: false, error: signIn.message })<br>    }<br>  } catch(err) {<br>    console.log(err);<br>    this.setState({ error: &quot;Trouble signing in...&quot;})<br>  }<br>}</pre><p>We are using the SimpleID Docs once more to sign in, and most of this code is re-used from the sign up function. We don’t need the email for sign in, and we have to create a params object, but other than that, it’s mostly the same. With that in place, let’s give this a shot.</p><p>You should have seen the loading indicator and then your user was signed in. Of course, we just have a sign out button now when a user in logged in. Let’s change that by dropping in our Medium-style editor.</p><p>Below your constructor in App.js and above your other functions, let’s add a componentDidMount method:</p><pre>componentDidMount() {<br>  var editor = new window.MediumEditor(&#39;.editable&#39;);<br>}</pre><p>This is using window to fetch the MediumEditor script we added to our index.html file. For us to see anything, we need to edit the App Contents section of our JSX. So in the area where you put your sign out button, let’s add something below that to handle the editor:</p><pre>&lt;div className=&quot;editor&quot;&gt;<br>  &lt;h1&gt;NoteStream&lt;/h1&gt;<br>  &lt;p&gt;Start where you left off or shove your thoughts in the middle somewhere. It&#39;s up to you!&lt;/p&gt;<br>  &lt;div className=&quot;editable&quot;&gt;&lt;/div&gt;<br>&lt;/div&gt;</pre><p>Without any css styling this is going to be too ugly to handle. So, let’s just drop a little in to fix that. In the same folder, but in the App.css file, add the following:</p><pre>.editor {<br>  max-width: 85%;<br>  margin: auto;<br>  margin-top: 100px;<br>}</pre><pre>.editable {<br>  max-width: 85%;<br>  margin: auto;<br>  border: 1px solid #282828;<br>  border-radius: 3px;<br>  min-height: 500px;<br>  padding: 15px;<br>  text-align: left;<br>}</pre><p>We can change this later, but it at least makes the application presentable. You should see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q3FEzjgqum_v69Ik5fzFQQ.png" /></figure><p>Not the prettiest thing, but it’ll do for now. We need to be able to handle the changes to the editor, so let’s start there before we even begin to save data. In our componentDidMount lifecycle event, let’s change things a bit:</p><pre>componentDidMount() {<br>  var editor = new window.MediumEditor(&#39;.editable&#39;);<br>  //We&#39;ll load our content here soon<br>  editor.subscribe(&#39;editableInput&#39;, (event, editable) =&gt; {<br>    this.setState({ content: editor.getContent(0) });<br>  });<br>}</pre><p>If you remember, we had created a state variable called content to hold the content of our note. We are setting that state on every change in the editor. That means when we are ready to save the note, we can just fetch our data from the content state. Let’s see how that looks by doing two things. We’ll add a save button and we’ll add a saveContent function.</p><p>Right where the sign out button is, add a save button below it:</p><pre>&lt;button onClick={this.handleSignOut}&gt;Sign Out&lt;/button&gt;<br>&lt;button onClick={this.saveContent}&gt;Save&lt;/button&gt;</pre><p>Then, with all your other functions, create the saveContent function:</p><pre>saveContent = () =&gt; {<br>  const { content, userSession } = this.state;<br>  console.log(content)<br>}</pre><p>We’re going to be using the userSession state in a minute, so I threw it in there. But with this, you should be able to open the developer console, type into the editor, and then hit save. You’ll see the html content.</p><p>That means you’re ready to save content and load that content back. Let’s thing this through first, though. We need to save the content to Blockstack’s storage system and IPFS. Blockstack’s storage system will be an overwrite function every time, but for IPFS, we’re going to store a new version to the network. We also need to be able to fetch the IPFS hashes, so we should store that to Blockstack as well. It sounds to me like we have two files to store on Blockstack: content and versions (hashes). But we have to first save to IPFS so that we have the hash result. Let’s start writing that out in our saveContent function.</p><pre>saveContent = async () =&gt; {<br>  const { content, userSession } = this.state;<br>  //First we save to IPFS<br>  const contentToPin = {<br>    pinnedContent: JSON.stringify(content)<br>  }</pre><pre>const params = {<br>    devId: config.devId, //your dev ID found in your SimpleID account page<br>    username: userSession.loadUserData().username, //you logged in user&#39;s username<br>    id: Date.now(), //an identifier you can use to reference your content later<br>    content: contentToPin, //the content we discussed previously<br>    apiKey: config.apiKey //the api key found in your SimpleID account page<br>  }</pre><pre>  const pinnedContent = await pinContent(params);<br>  console.log(pinnedContent);<br>}</pre><p>We’ve added the async keyword to the function and we’ve used the paramaters necessary to post the content to IPFS as given by the SimpleID docs. In some cases, a developer will need to query Pinata for content they previously posted to IPFS. that’s the whole point of the id field. In this case, we’ll be using Blockstack to manage all of our hashes, so we don’t really care what this identifier is except that it’s unique (thus, Date.now()).</p><p>Let’s test this out with console open and see how it goes before we move on. Add some content to your editor then hit Save. If all goes well, you should see something like this in the console:</p><pre>{ message: &quot;content successfully pinned&quot;, body: &quot;QmbRshi9gjQ2v5tK4B8czPqm3jEQ3zGzsuQJuQLyti4oNc&quot; }</pre><p>That body key in the object is an IPFS hash. We want to use that and store it as a version with Blockstack. So let’s tackle that next.</p><pre>saveContent = async () =&gt; {<br>  const { content, userSession } = this.state;<br>  //First we save to IPFS<br>  const contentToPin = {<br>    pinnedContent: JSON.stringify(content)<br>  }</pre><pre>const params = {<br>    devId: config.devId, //your dev ID found in your SimpleID account page<br>    username: userSession.loadUserData().username, //you logged in user&#39;s username<br>    id: Date.now(), //an identifier you can use to reference your content later<br>    content: contentToPin, //the content we discussed previously<br>    apiKey: config.apiKey //the api key found in your SimpleID account page<br>  }</pre><pre>  if(pinnedContent.message === &quot;content successfully pinned&quot;) {<br>    const newVersion = {<br>      timestamp: Date.now(),<br>      hash: pinnedContent.body<br>    }<br>    versions.push(newVersion);<br>    this.setState({ versions });<br>    const savedVersion = await userSession.putFile(&quot;version_history.json&quot;, JSON.stringify(versions), {encrypt: true});<br>    console.log(savedVersion);<br>  } else {<br>    console.log(&quot;Error saving content&quot;);<br>  }<br>}</pre><p>I’ve added a check to make sure the content pinning to IPFS was successful before trying to save the hash to Blockstack. We need to know the time of the version, so we’re building up a newVersion object with the timestamp and the hash itself and then we are pushing that into the versions array. We are then saving this to Blockstack, where something cool is happening.</p><p>You can see an object in the putFile call that says encrypt. We are able to encrypt data that easily. Don’t believe me? Here’s the file I used to test this section of the tutorial:</p><p><a href="https://gaia.blockstack.org/hub/13ygSWdUeU4gPHbqUzEBvmq1LP7TKNnbtx/version_history.json">https://gaia.blockstack.org/hub/13ygSWdUeU4gPHbqUzEBvmq1LP7TKNnbtx/version_history.json</a></p><p>That’s just encryption our version history, which is important, but wouldn’t it be cool to encrypt the content before sending it to IPFS too? Let’s do that before we tackle the last part of saving content. In your saveContent function, right about the contentToPin variable, add this:</p><pre>const encryptedContent = userSession.encryptContent(JSON.stringify(content), {publicKey: getPublicKeyFromPrivate(userSession.loadUserData().appPrivateKey)});</pre><p>We need to import the getPrivateKeyFromPublic function as well. So at the top of your App.js file with the other import statements, add:</p><pre>import { getPublicKeyFromPrivate } from &#39;blockstack/lib/keys&#39;;</pre><p>And update the contentToPin variable to look like this:</p><pre>const contentToPin = {<br>  pinnedContent: JSON.stringify(encryptedContent)<br>}</pre><p>We’ll see in a moment if this works. Let’s pick up after setting and saving the version history. So right after the savedVersions line, add this:</p><pre>const savedVersion = await userSession.putFile(&quot;version_history.json&quot;, JSON.stringify(versions), {encrypt: true});</pre><pre>const savedContent = await userSession.putFile(&#39;note.json&#39;, JSON.stringify(encryptedContent), {encrypt: false});<br>console.log(savedContent);</pre><p>Here’s what I get back in the console log by doing that: <a href="https://gaia.blockstack.org/hub/13ygSWdUeU4gPHbqUzEBvmq1LP7TKNnbtx/note.json">https://gaia.blockstack.org/hub/13ygSWdUeU4gPHbqUzEBvmq1LP7TKNnbtx/note.json</a></p><p>Looks like it worked! So, to recap, we are encrypting the content, storing it on IPFS, using the IPFS hash that’s returned to create a new entry in the versions array, saving that to Blockstack, then saving the current version of the note content to Blockstack.</p><p>Pretty cool stuff, but we need to be able to fetch content too, right? Initially, there are just two files we need to fetch when the application loads up: The current content (from note.json), and the versions file (from version_history.json). We should do that as soon as the app loads, so this will need to be added to our componentDidMount lifecycle event. Update the entire event like this:</p><pre>async componentDidMount() {<br>  const { userSession } = this.state;<br>  const content = await userSession.getFile(&#39;note.json&#39;, {decrypt: false});<br>  const decryptedContent = userSession.decryptContent(JSON.parse(content), {privateKey: userSession.loadUserData().appPrivateKey});<br>  this.setState({ content: JSON.parse(decryptedContent )});</pre><pre>  var editor = new window.MediumEditor(&#39;.editable&#39;);<br>  editor.subscribe(&#39;editableInput&#39;, (event, editable) =&gt; {<br>    this.setState({ content: editor.getContent(0) });<br>  });</pre><pre>  editor.setContent(JSON.parse(decryptedContent), 0);<br>}</pre><p>Save that and go back to your app. When it reloads, the content you had saved will now appear in the editor. We’re getting there. We have just a couple more things to do. We need to load the version history, so let’s do that next.</p><p>Right below the decryptContent variable, add the following:</p><pre>const versions = await userSession.getFile(&#39;version_history.json&#39;, {decrypt: true});</pre><pre>this.setState({ content: JSON.parse(decryptedContent), versions: JSON.parse(versions) });</pre><p>Now, we can start having fun with versions. Let’s make sure we can render our version history first. In the App Contents section of your JSX, below the editor, add the following:</p><pre>&lt;div className={versionPane ? &quot;versionPaneOpen&quot; : &quot;versionPaneClosed&quot;}&gt;<br>  &lt;ul&gt;<br>  {<br>    versions.map(v =&gt; {<br>     return(<br>       &lt;li key={v.timestamp}&gt;&lt;a href=&quot;#&quot; onClick={() =&gt; this.handleVersionModal(v.hash)}&gt;{v.timestamp}&lt;/a&gt;&lt;/li&gt;<br>     )<br>    })<br>  }<br>  &lt;/ul&gt;<br>&lt;/div&gt;</pre><p>We are creating a section to hold the version history. You’ll note the className is conditional on the state variable versionPane. This is because we want to be able to change that variable and open the version history rather than have it open all the time. Let’s add a button up with our sign out and save button called Version History.</p><pre>&lt;button onClick={() =&gt; this.setState({ versionPane: !versionPane })}&gt;Version History&lt;/button&gt;</pre><p>And let’s update our CSS one more time to handle the display of the pane:</p><pre>.versionPaneOpen {<br>  position: fixed;<br>  top: 0;<br>  right: 0;<br>  width: 250px;<br>  z-index: 999;<br>  border-left: 2px solid #282828;<br>  height: 100vh;<br>  background: #eee;<br>  display: inline;<br>}</pre><pre>.versionPaneOpen {<br>  display: none;<br>}</pre><p>Go ahead and test it out. You should have at least one version saved, so hit that Version History button to toggle the pane open and closed. It’s ugly, but it works.</p><p>The last thing we need to do is pop up a modal to show the content of a past version. Let’s get to work on that by adding a function called handleVersionModal.</p><pre>handleVersionModal = (hash) =&gt; {<br>  const { userSession } = this.state;<br>  this.setState({ selectedVersionContent: &quot;&quot;, versionModal: true });<br>  fetch(`https://gateway.pinata.cloud/ipfs/${hash}`)<br>  .then(function(response) {<br>    return response.json();<br>  })<br>  .then(function(myJson) {<br>    const encryptedContent = myJson.pinnedContent;<br><br>    const decryptedContent = userSession.decryptContent(JSON.parse(encryptedContent), {privateKey: userSession.loadUserData().appPrivateKey});<br>    this.setState({ selectedVersionContent: JSON.parse(decryptedContent)});<br>  });<br>}</pre><p>We are using the JavaScript native Fetch API to handle calling out to an IPFS gateway to fetch the content specific to the version we select in the version pane. That content is encrypted and needs to be parsed and decrypted properly to be accessible. But if you console log the decryptedContent variable, you’ll see the content of the version in question is properly being fetched. We are setting that content to the selectedVersionContent state variable and setting the versionModal to true.</p><p>Let’s put that all to use to render the past version on screen. Below the version page JSX you wrote earlier, add this:</p><pre>&lt;div className={versionModal ? &quot;versionModalOpen&quot; : &quot;versionModalClosed&quot;}&gt;<br>  &lt;span onClick={() =&gt; this.setState({versionModal: false})} id=&quot;version-close&quot;&gt;Close&lt;/span&gt;<br>  {<br>  selectedVersionContent ?<br>  &lt;div dangerouslySetInnerHTML={{__html: selectedVersionContent}} /&gt;:<br>  &lt;h3&gt;Loading content for selected version...&lt;/h3&gt;<br>  }<br>&lt;/div&gt;</pre><p>Now, we need to style that a bit to be manageable. In App.css, add this:</p><pre>.versionModalOpen {<br>  display: inline;<br>  position: fixed;<br>  text-align: left;<br>  left: 12.5%;<br>  top: 15%;<br>  width: 75%;<br>  min-height: 500px;<br>  margin: auto;<br>  z-index: 999;<br>  background: #eee;<br>  padding: 25px;<br>  border: 1px solid #282828;<br>  border-radius: 3px;<br>}</pre><pre>.versionModalClosed {<br>  display: none;<br>}</pre><pre>#version-close {<br>  position: relative;<br>  right: 10px;<br>  top: 10px;<br>  z-index: 1000;<br>  cursor: pointer;<br>}</pre><p>Let’ give this thing a try now. Open up the version history pane. Click on a past version. A modal should pop up with the content of that version for you to view.</p><p>That’s it! We made it. You can now have an endless stream of consciousness note taking system while retaining control of all past iterations via version history. And to top it all off, every version of the note is encrypted with a private key wholly under your control.</p><p>Take your new powers and build other cool things and propel Web 3.0 into the mainstream.</p><p>If you’d like to see the code for this tutorial, you can find it <a href="https://github.com/simplesecure/examples/tree/master/ipfs-blockstack-versioning">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5992e34b1bd2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simpleid-dev-tools/build-a-versioning-system-with-ipfs-and-blockstack-5992e34b1bd2">Build a Versioning System With IPFS and Blockstack</a> was originally published in <a href="https://medium.com/simpleid-dev-tools">SimpleID — Engagement and Retention</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Lens Intends to Make Data Ownership Mainstream]]></title>
            <link>https://medium.com/simpleid-dev-tools/how-lens-intends-to-make-data-ownership-mainstream-edecb8caef4?source=rss----fc8043ca5f65---4</link>
            <guid isPermaLink="false">https://medium.com/p/edecb8caef4</guid>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[dapps]]></category>
            <dc:creator><![CDATA[Justin Hunter]]></dc:creator>
            <pubDate>Thu, 12 Sep 2019 15:36:59 GMT</pubDate>
            <atom:updated>2019-09-12T15:36:59.455Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ucR2aJA6H4bbp4oQGj5YyQ.png" /><figcaption>Lens lets individual create truly owned data points and share (or revoke) those data points with enterprises</figcaption></figure><p>The web is largely broken. What was once an open communication tool has been walled off. Our data is used in ways we aren’t aware, don’t approve of, and are not comfortable with. There are many possible solutions floating around to help fix the web. These ideas all combine to form the concept of Web 3.0 — the user-centric web. Within this proposed new web, companies are not the stewards of the data we create. Instead, we own all our data, control who has access to said data, and can revoke access at any time. <a href="https://mylens.io/">Lens</a> is one company looking to leverage this new model in the Web 3.0 space to give users true control. And <a href="https://www.simpleid.xyz/?s=med?t=lens_cs_st">SimpleID</a> is helping them build an approachable solution.</p><p>Lens, founded by Mark Chavez and Cody Eilar, sees data as a fundamentally protected asset. At least, it should be. Many people have compared data to the oil in terms of its value, and if those comparisons hold true, the owners of the asset should have control of it. This is where Lens comes in.</p><blockquote>A couple years ago I asked myself: “Why is there not a single place where I can make a change to my data and everyone who needs that update gets it?” Lens was born!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/0*tUnKd1QBMcErOPLW.png" /></figure><p>When talking about the idea behind Lens, CEO and co-founder, Mark Chavez, said the idea was a simple subscription model that would let anyone update their data, provide access to their data, and revoke access. And it’s not an all or nothing proposition either.</p><p>Imagine you have medical data stored in some storage location you control. Keep in mind control could mean owning the storage hub and encrypting the data with your encryption keys or it could mean storing that data in a p2p network encrypted in a way that only you can decrypt it. Now, imagine being able to have a subscription access point that when you approve said subscription, the subscriber is now able to access and decrypt said data. But no one else is able to. This is the basic idea, but Lens does so much more.</p><p>The new data economy, in Lens’s eyes is one where data is not owned by companies but by the individuals producing the data:</p><blockquote>We are data company that owns no data. Each consumer (individual) owns and maintains their data and decentralization enables this core value. The solution enables better data relationships between enterprise and consumers for better outcomes. If the data is accurate, enterprises can provide better services. Currently enterprises spend billions doing data dialysis. Decentralization, access to a customer’s single source of truth, to maintain enterprise CRM data is the correct model. It’s how the internet was intended in the first place.</blockquote><p>Lens is built on <a href="https://blockstack.org/">Blockstack</a>’s decentralized application platform, thus making it one of the early decentralized applications trying to bridge the gap between the niche and the saturated. Peer-to-peer networks are not terribly new, but they represent a niche form of computing for people because of their complexities. Blockstack adds a layer on top of p2p computing that includes blockchain operations, identity, and user ownership of data. Lens has leveraged this technology to give users control in what may be a different way than some thing of data control.</p><p>Rather than operating under the assumption that users care about decentralization, data ownership, and even privacy, Lens has taken the approach of giving users all of those things without the users having to think about it. But, of course, that’s not a competitive advantage. Mark and Cody knew they needed to provide a value-add that would give users a reason to use Lens.</p><blockquote>We also have learned that individual’s are complacent about their data privacy. They really don’t care about being able to own their data. This is why our model is to solve a real world problem — creating a single source of data for consumers (that they own and control). We believe the real value to the consumer is not privacy, rather the ability to change their information in one place and everyone who needs the update automatically gets it. This saves them time! They no longer have to fill in forms, they approve subscriptions to the data they own.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*kqoenWS3gNNbzqDEH8WhVA.png" /></figure><p>In the decentralized web space, you’ll often hear conversations about not replicating what happens in Web 2.0 (the traditional web as we know it today), but instead providing new experiences. This is a brand new experience, and Lens believes users and enterprises will both benefit from such a model. But there was still a problem.</p><p>Using decentralized applications is cumbersome. It’s confusing, it puts a significant load on the end user that has traditionally been managed by the applications the users access. People expect to have a low barrier to entry for using an application. There are just simply too many apps out there to ask a user to A) use your app and B) go through a significantly more difficult process to use your app. While Blockstack’s protocol does offer an authentication solution, it’s difficult for users to understand and takes people out of the flow of using the app they intended to use. That’s where Lens turned to SimpleID for support.</p><blockquote>We had been losing too many consumers to the complex ID creation process. Simple ID removes that barrier and the consumer immediately can connect with the value we have built.</blockquote><p>Understanding both the technology behind this new world of Web 3.0 technology AND the consumers that need to adopt such technology is not foreign to either of Lens’s founders. Before Lens, Mark was CIO at Salesforce where he had to ensure the technology behind the solutions Salesforce implemented were consumer and enterprise friendly. Cody previously worked as a computer scientist with Sandia National Laboratories where he and his team focused on modernizing complex but legacy systems.</p><p>Lens is operational now. Users can sign up and start building out their data profiles. The next steps for Lens are bringing on enterprises who would like to subscribe to user data, allowing users to sell data to enterprises of their choice, and scaling all of it to a global market. If you’d like to give Lens a try, you can <a href="https://mylens.io/">sign up here</a>. You might get to be part of the data management economy of the future.</p><p>If you have a business that can benefit from adding user control of identity and data to your offering, SimpleID can help make that process simple for you and your users. <a href="https://www.simpleid.xyz/?s=med?t=lens_cs">Check out SimpleID today</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edecb8caef4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simpleid-dev-tools/how-lens-intends-to-make-data-ownership-mainstream-edecb8caef4">How Lens Intends to Make Data Ownership Mainstream</a> was originally published in <a href="https://medium.com/simpleid-dev-tools">SimpleID — Engagement and Retention</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial: How to Build an IPFS & Text Notification App]]></title>
            <link>https://medium.com/simpleid-dev-tools/tutorial-how-to-build-an-ipfs-text-notification-app-d7e1a89c784b?source=rss----fc8043ca5f65---4</link>
            <guid isPermaLink="false">https://medium.com/p/d7e1a89c784b</guid>
            <category><![CDATA[twilio]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Justin Hunter]]></dc:creator>
            <pubDate>Thu, 05 Sep 2019 15:39:46 GMT</pubDate>
            <atom:updated>2019-09-05T16:20:31.609Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*keRpS6JiyNSG8MHx" /><figcaption>Photo from <a href="https://unsplash.com/@hckmstrrahul">https://unsplash.com/@hckmstrrahul</a></figcaption></figure><p>The way new technology is best adopted is when it is paired with existing technology. Partnering with a known quantity makes the new thing so much more approachable to users. So, in that spirit, let’s marry Web 2.0 tech with Web 3.0 tech in this tutorial.</p><p>For this tutorial, you’re going to be making use of two third-party services: <a href="https://www.simpleid.xyz/?t=txt_tut">SimpleID</a> and <a href="https://www.twilio.com/">Twilio</a>.</p><p>We’re not going to be building a front-end for this application. Instead, we’ll set up a NodeJS server (which is recommended when using SimpleID and any other service in which you need to protect API Keys and secrets). This server-side app is going to allow users to create accounts, log in to those accounts, and post messages. But here’s the kicker: When each new message is posted, you’ll receive a text alert with the content of the message. You’ll also be able to query for messages posted.</p><p>This type of functionality can be used in a variety of ways. I can think of a forum as one example, comments on a blog as another, and so many others. How you ultimately use the functionality is up to you, but by the end of this tutorial, you’ll have a server that will do the following:</p><ul><li>Accept GET Requests</li><li>Accept POST Requests</li><li>Validate Requests</li><li>Create user sessions</li><li>Post data to IPFS tied to a specific user</li><li>Fetch data from IPFS</li><li>Send text alerts</li></ul><p>Here’s what you’re going to need to be able to follow along with this tutorial:</p><ul><li>Node installed</li><li>NPM installed</li><li>Text Editor</li></ul><p>Before diving in, let’s plan out this project a little more. We are going to need users to be able to post raw data (comments, text, whatever) that is associated with them but pooled with everyone else. We are going to need to be able to fetch all of this data. We are also going to need to send a text message to you, the developer, for each piece of content posted.</p><p>This isn’t terribly fancy. No threaded content. Just a raw feed.</p><p>Let’s get started. You’ll need to sign up for a SimpleID account, which you can do <a href="https://app.simpleid.xyz/">here</a>, and a <a href="https://www.twilio.com/">Twilio</a> account, which you can do here. Let’s walk through what’s needed for SimpleID first.</p><p>When you sign up for an account, you’ll be asked to verify your email address. Go ahead and do that. Once verified, you can create a project. Give it a name and a url where you might host this project. It will need to be an https url. This is a security restriction SimpleID has in place. When the project is created, go to your Modules page and select Ethereum for your authentication module and Pinata for your Storage module. Save your selections then return to the Account page. There, you can click on the View Project button to get the two items you’ll need for your project: apiKey and devId.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ols8dqQUoauwE0jkQ0NsrQ.png" /></figure><p>Now that that’s done, let’s get set up with Twilio. When you sign up, you’ll also need to verify your email with them. Do that and then you’ll need to verify your phone number for SMS. You should receive a verification text when you do this. Enter the code in the box on the Twilio screen. Now, Twilio is going to try to customize your onboarding. Go ahead and answer the questions, but we’ll get you where you need to go no matter how you answer. When you’re done with this process, you’ll land on your dashboard where you can get a Trial Number. Do that because it’s free. Record the number somewhere for now. You can also now record the Account SID and Auth Token.</p><p>Now, let’s build some stuff!</p><p>Go ahead and create a folder wherever you like to keep your development projects:</p><p>mkdir text-comments &amp;&amp; cd text-comments</p><p>Within that folder, let’s initialize our project by running npm init. You can accept all the defaults as this process runs. Once it’s done, we need to install some dependencies.</p><p>npm i express simpleid-node-sdk twilio body-parser</p><p>With that command, which might take a moment to run, you’ll be installing the three dependencies we need for this project:</p><ul><li>ExpressJS — for our server</li><li>SimpleID — for auth and IPFS storage</li><li>Twilio — for the texting</li><li>Body-Parser — for parsing json requests easily</li></ul><p>When everything is done installing, let’s create an index.js file. You can do this right from the command line with touch index.js. Then, open your project in your favorite text editor.</p><p>We’re going to need to get some boilerplate set up for our Express server. So add this to your index.js file:</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br>const port = 3000;<br>const bodyParser = require(&quot;body-parser&quot;);</pre><pre>app.use(bodyParser.json());</pre><pre>app.get(&#39;/content&#39;, (req, res) =&gt; {<br>  //this is where we will fetch the IPFS content<br>  res.send(&#39;Eventually content will be here&#39;)<br>})</pre><pre>app.post(&#39;/auth/create&#39;, async (req, res) =&gt; {<br>  //this is where we will create a user account<br>  res.send(&quot;Account Creation Here&quot;);<br>})</pre><pre>app.post(&#39;/auth/login&#39;, async (req, res) =&gt; {<br>  //this is where we will log a user in<br>  res.send(&quot;Log in Here&quot;);<br>})</pre><pre>app.post(&#39;/postContent&#39;, async (req, res) =&gt; {<br>  //this is where we will post the IPFS content<br>  res.send(&quot;IPFS Content Posted Here&quot;);<br>})</pre><pre>app.post(&#39;/sendText&#39;, async (req, res) =&gt; {<br>  //this is where we will trigger the outbound text<br>  res.send(&quot;Text sent here&quot;);<br>})</pre><pre>app.listen(port, () =&gt; console.log(`Example app listening on port ${port}!`))</pre><p>With that code, we can now test our server code by making some API calls. Let’s make it easy to start up our server by opening the package.json file and adding this in the scripts section:</p><pre>&quot;start&quot;: &quot;node index.js&quot;,</pre><p>With that, we can now run npm start from the command line to start our server. Give it a shot and you should see the command line print out:</p><pre>Example app listening on port 3000!</pre><p>You now have a working API you can test. You can use Postman or the command line to test this depending on what you’re comfortable with. I’ll be using cURL scripts to keep things simple. So, open a new tab or window in your terminal and run this:</p><pre>curl -X GET \<br>  <a href="http://localhost:3000/content">http://localhost:3000/content</a></pre><p>You should get back the response Eventually content will be here. Nice! Now try the post requests:</p><pre>curl -X POST \<br>  <a href="http://localhost:3000/auth/create">http://localhost:3000/auth/create</a></pre><pre>curl -X POST \<br>  <a href="http://localhost:3000/auth/login">http://localhost:3000/auth/login</a></pre><pre>curl -X POST \<br>  <a href="http://localhost:3000/postContent">http://localhost:3000/postContent</a></pre><pre>curl -X POST \<br>  <a href="http://localhost:3000/sendText">http://localhost:3000/sendText</a></pre><p>When you run each of those, you should get back the responses we typed out as placeholder. If that worked, we’re ready to start building this for real. We’re going to be taking material right from the SimpleID and Twilio docs to help us here. So, starting with the SimpleID configuration, we need to add this to the top of our index.js file:</p><pre>const simple = require(&#39;simpleid-node-sdk&#39;);<br>const config = {<br>  apiKey: ${yourApiKey}, //found in your SimpleID account page<br>  devId: ${yourDevId}, //found in your SimpleID account page<br>  authProviders: [&#39;ethereum&#39;], //array of auth providers that matches your modules selected<br>  storageProviders: [&#39;pinata&#39;], //array of storage providers that match the modules you selected<br>  appOrigin: &quot;https://yourapp.com&quot;, //even if using SimpleID on a server or as a desktop/mobile app, you&#39;ll need to pass an origin for reference<br>  scopes: [&#39;publish_data&#39;, &#39;store_write&#39;], //array of permission you are requesting from the user<br>  development: false<br>}</pre><p>With this configuration, you are ready to create an account for your users (just make sure you actually fill in the configuration with your own information). At the /auth/create endpoint you previously created, we are going to take a payload of username, email, password. We’re going to then combine that with our config settings to create a decentralized identifier for the user (we’ll return an ethereum address for them). With that, we will then be able to log the user in (note: creating an account automatically logs the user in and will return a user session object).</p><p>In the /auth/create endpoint, let’s replace the placeholder response and add the following:</p><pre>app.post(&#39;/auth/create&#39;, async (req, res) =&gt; {<br>  const { email, id, password } = req.body;<br>  const credObj = {<br>    email,<br>    id,<br>    password,<br>    hubUrl: &quot;https://hub.blockstack.org&quot; //this is for blockstack storage, but needs to be sent even when not in use<br>  }<br>  const account = await simple.createUserAccount(credObj, config);<br>  res.send(account);<br>})</pre><p>This comes straight from the <a href="https://docs.simpleid.xyz/">SimpleID docs</a>. We are taking the user credentials, combining them with our configuration object, and creating a user account. Let’s test this by sending a post request. First, we need to kill our server and restart it so it’s aware of our changes. Let’s fix that because this will get real annoying fast as we make changes to our code.</p><p>After you’ve killed the server (`ctrl + c or cmd+c), install nodemon like this: npm i -g nodemon. Then all we need to do is update our start script in package.json:</p><pre>...<br>&quot;scripts&quot;: {<br>  &quot;start&quot;: &quot;nodemon index.js&quot;<br>},<br>...</pre><p>Now, run npm start and we shouldn’t have to constantly kill and restart the server!</p><p>Let’s test our endpoint with some JSON data passed to it:</p><pre>curl -X POST \<br>  <a href="http://localhost:3000/auth/create">http://localhost:3000/auth/create</a> \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -d &#39;{<br> &quot;id&quot;: ${uniqueUserName}, <br> &quot;email&quot;: ${anyEmailAddress},<br> &quot;password&quot;: ${somePassword}<br>}&#39;</pre><p>If you fill in the uniqueUserName, anyEmailAddress, and somePassword with your own values, you should now be able to get a response from your server. If you chose a username that aready exists, you’ll get a response like this:</p><pre>{<br>  &quot;message&quot;: &quot;name taken&quot;,<br>  &quot;body&quot;: null<br>}</pre><p>Otherwise, the process will work all the way through to login and return the user session object like this:</p><pre>{<br>  &quot;message&quot;: &quot;user session created&quot;,<br>  &quot;body&quot;: {<br>    &quot;appConfig&quot;: {<br>    &quot;appDomain&quot;: &quot;https://yourapp.com&quot;,</pre><pre>...<br>}</pre><p>I truncated the response in my example because it’s too long for the sake of the tutorial. But congratulations! If you got a response like this, your user is now logged in.</p><p>But, what if we want that user to log in again? We don’t want them to create a new account. Let’s update our /auth/login endpoint now:</p><pre>app.post(&#39;/auth/login&#39;, async (req, res) =&gt; {<br>  const { id, password } = req.body;<br>  const credObj = {<br>    id,<br>    password,<br>    hubUrl: &quot;https://hub.blockstack.org&quot;<br>  }<br>  const params = {<br>    credObj,<br>    appObj: config<br>  }</pre><pre>  const loggedIn = await simple.login(params);</pre><pre>  res.send(loggedIn);<br>});</pre><p>Here, we are taking a post of JSON data that includes the user’s id and password. We are combining that in a credentials object and merging our config object into one parameters object. We send that to the login function to get our response. Let’s try it:</p><pre>curl -X POST \<br>  <a href="http://localhost:3000/auth/login">http://localhost:3000/auth/login</a> \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -d &#39;{<br> &quot;id&quot;: &quot;from_node_server_000&quot;, <br> &quot;password&quot;: &quot;super secure password&quot;<br>}&#39;</pre><p>If successful, you’ll see the same response you saw at the end of a successful account creation post. The message will be: user session created.</p><p>Ok, now we have authentication working which means we can start posting data to IPFS and associate it with the logged in user. Let’s start by setting up our /postContent endpoint. Because we’re not building a front-end for this app, there are a couple of approaches we could take. We could send a payload on login or account creation that includes the user credentials as well as the content to be posted. Or, we could take the response from account creation or log in, hold onto it somewhere and use it to tie a user to a post.</p><p>I think when an application like this is wired up to the front-end, the second option makes the most sense. So, let’s do that. In our /postContent endpoint, replace the placeholder with this:</p><pre>app.post(&#39;/postContent&#39;, async (req, res) =&gt; {<br>  const { id, ethAddr, content } = req.body;<br>  const contentToPin = {<br>    id,<br>    date: Date.now(),<br>    address: ethAddr, <br>    content  <br>  }</pre><pre>  const params = {<br>    devId: config.devId, //your dev ID found in your SimpleID account page<br>    username: id, //your logged in user&#39;s username<br>    id: &quot;ipfs-text&quot;, //an identifier you can use to reference your content later<br>    content: contentToPin, //the content we discussed previously<br>    apiKey: config.apiKey, //the api key found in your SimpleID account page<br>  }</pre><pre>  const postedContent = await simple.pinContent(params);</pre><pre>  res.send(postedContent);<br>})</pre><p>All we’ve done here is take the user’s id (you can grab this from any of the accounts you created in testing) and the user’s Ethereum address. The Ethereum address is returned in the user session object and can be access like this:</p><pre>//If logging in<br>loggedIn.body.store.sessionData.wallet.ethAddr</pre><pre>or</pre><pre>//If creating a new account<br>account.body.store.sessionData.wallet.ethAddr</pre><p>Let’s try to post some content:</p><pre>curl -X POST \<br>  <a href="http://localhost:3000/postContent">http://localhost:3000/postContent</a> \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -H &#39;Host: localhost:3000&#39; \<br>  -d &#39;{<br> &quot;id&quot;: ${username}, <br> &quot;ethAddr&quot;: ${ethereumAddress}, <br> &quot;content&quot;: &quot;This is the first post. What do you think?&quot;<br>}&#39;</pre><p>If that’s successful, you’ll get a response that indicates success and includes an IPFS hash. It should look like this:</p><pre>{<br>  &quot;message&quot;: &quot;content successfully pinned&quot;,<br>  &quot;body&quot;: &quot;QmNZqBFvZq24GuP9H8B3ae1YXAHd8VY8H56PwcWQhrs5Kc&quot;<br>}</pre><p>We can go check this content out on IPFS now. Since we use <a href="https://pinata.cloud/">Pinata</a> for pinning IPFS content (to ensure availability), we’ll use their IPFS gateway to fetch this example. You can see it <a href="https://gateway.pinata.cloud/ipfs/QmbE5xi75XSuZbGbp1Pr2nUWmmDPrrZ1qBvEvi2pVM8cL5">here</a>.</p><p>Pretty cool! Now, we need to send a text alert to you, the developer about the new content being posted. Enter Twilio.</p><p>At the top of your index.js file, add the following:</p><pre>const accountSid = ${yourAccountSID};<br>const authToken = ${yourAuthToken};<br>const client = require(&#39;twilio&#39;)(accountSid, authToken);</pre><p>Your accountSid and your authToken were generated earlier when you created your Twilio account. Just plug those in here and then we can focus on the /sendText endpoint. We need to take the content of a post and send it via text. Or send some version of it via text at least. Let’s fill out the endpoint code and then we can think about how we’ll post to that endpoint. Replace your placeholder code in the /sendText endpoint with:</p><pre>app.post(&#39;/sendText&#39;, async (req, res) =&gt; {<br>  const { content, from } = req.body;</pre><pre>  client.messages<br>  .create({<br>    body: `New post from ${from}: ${content}`,<br>  from: ${yourTwilioNumber,<br>  to: ${yourActualNumber<br>  })<br>  .then(message =&gt; res.send(message));<br>});</pre><p>So, this endpoint is now expecting a JSON payload that include the content of the post and the person it’s from. That information is then sent as the body of the Twilio text. You’ll need to grab that phone number you got as part of the free Twilio trial and plug it into the from field. And assuming you want to be the one to receive these messages, enter your phone number in the to field.</p><p>The question now is, how do we post to this endpoint? We want it to happen immediately after the IPFS content is posted. So, it would make sense to just call /sendText endpoint from in that endpoint’s response. But why even have a separate endpoint for /sendText? Couldn’t we just dump the Twilio code into the /postContent endpoint?</p><p>We could, but what if down the line we want to be able to send texts after some of the content has been manipulated in some way? Maybe on the client, there’s some interaction after the content is posted to IPFS and then we want to call the /sendText endpoint. By having it as a separate endpoint, we give ourselves flexibility, even if we won’t use that flexibility today.</p><p>To post to the /sendText endpoint from within the /postContent endpoint’s response, we’ll use the request module. We can install that by killing the server and running npm i request.</p><p>At the top of your index.js file, add:</p><pre>const request = require(&#39;request&#39;);</pre><p>Now, inside of our /postContent endpoint, let’s update the code right below const postedContent = await simple.pinContent(params):</p><pre>...<br>const postData = {<br>  from: params.username,<br>  content: params.content.content<br>}</pre><pre>var options = { <br>  method: &#39;POST&#39;, <br>  url: &#39;http://localhost:3000/sendText&#39;,<br>  headers: { <br>    Host: &#39;localhost:3000&#39;, <br>   &#39;Content-Type&#39;: &#39;application/json&#39; },<br>  body: postData,<br>  json: true };</pre><pre>request(options, function (error, response, body) {</pre><pre>if (error) throw new Error(error);<br>  console.log(body);<br>});</pre><pre>...</pre><p>Let’s try this now. If all goes well, content will be posted to IPFS and then we’ll receive a text. Here’s the curl command to post to IPFS again:</p><pre>curl -X POST \<br>  <a href="http://localhost:3000/postContent">http://localhost:3000/postContent</a> \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -H &#39;Host: localhost:3000&#39; \<br>  -d &#39;{<br> &quot;id&quot;: ${username}, <br> &quot;ethAddr&quot;: ${ethereumAddress}, <br> &quot;content&quot;: &quot;This is the first post. What do you think?&quot;<br>}&#39;</pre><p>You can change the content if you’d like. I’m leaving mine for simplicity. Give it a shot and you should receive a text that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*5MoExIHIvTvVTc3F5Fei9A.png" /></figure><p>Awesome! We just built a *very* basic notification system using a combination of web2 and web3 technology. One last thing we want to do is list all the posts for a given user. To do this, we can use the previously created GET endpoint /content. Find that in your index.js file and replace the placeholder with:</p><pre>app.get(&#39;/content&#39;, async (req, res) =&gt; {<br>  const username = req.query.username;<br>  const params = {<br>    devId: config.devId, //your dev ID found in your SimpleID account page<br>    username: ${username}, //you logged in user&#39;s username<br>    id: &quot;ipfs-text&quot;, //the identifier you used for reference of the pinned content<br>    apiKey: config.apiKey //the api key found in your SimpleID account page<br>  }</pre><pre>  const fetchedContent = await simple.fetchPinnedContent(params);<br>  res.send(fetchedContent);<br>});</pre><p>Make sure to pass in the username from whom you’d like to fetch posts, fill in your other parameters, and then let’s give it a shot:</p><pre>curl -X GET \<br>  &#39;<a href="http://localhost:3000/content?username=from_node_server_000&#39;">http://localhost:3000/content?username=${username}&#39;</a> \</pre><p>Notice that we’re passing in the username as a query string parameter. That’s being handled on the server with the line we added at the top of the /content endpoint:</p><pre>const username = req.query.username;</pre><p>You should get back a response like:</p><pre>{<br>  &quot;message&quot;: &quot;Found pinned content&quot;,<br>  &quot;body&quot;: &quot;{\&quot;id\&quot;:\&quot;from_node_server_000\&quot;,\&quot;date\&quot;:1567694211655,\&quot;address\&quot;:\&quot;0x91702078DeA9D1d9354467F58E0225AD2C8445Ab\&quot;,\&quot;content\&quot;:\&quot;This is the first post. What do you think?\&quot;}&quot;<br>}</pre><p>That’s it! We just built a server-side application that supports, Ethereum authentication, IPFS content storage and retreival, and text messaging. If you’d like to see the full source code, <a href="https://github.com/simplesecure/examples/tree/master/ipfs-text">that can be found here</a>.</p><p>With your newfound powers, you can now wire this up to a front-end application and put it to use creatively. There are enhancements you could and should ake to the server code as well. Right now, your server routes are unprotected. Anyone can make requests to them. You might want to throttle based on IP Address to help avoid DOS attacks. You might want to have some sort of bearer token you look for. There are a lot of things you can do to improve your code from here. But enjoy the fact that you built a sneakily complex app with very little actual complexity in its implementation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7e1a89c784b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simpleid-dev-tools/tutorial-how-to-build-an-ipfs-text-notification-app-d7e1a89c784b">Tutorial: How to Build an IPFS &amp; Text Notification App</a> was originally published in <a href="https://medium.com/simpleid-dev-tools">SimpleID — Engagement and Retention</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Give Users Control of Their Data by Giving Them Choice]]></title>
            <link>https://medium.com/simpleid-dev-tools/give-users-control-of-their-data-by-giving-them-choice-19e56c4ae2b0?source=rss----fc8043ca5f65---4</link>
            <guid isPermaLink="false">https://medium.com/p/19e56c4ae2b0</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[user-experience]]></category>
            <dc:creator><![CDATA[Justin Hunter]]></dc:creator>
            <pubDate>Wed, 04 Sep 2019 15:28:47 GMT</pubDate>
            <atom:updated>2019-09-04T15:28:47.082Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Ks3z8A2x3202MYfv" /><figcaption>Photo courtesy of <a href="https://unsplash.com/@burst">https://unsplash.com/@burst</a></figcaption></figure><p>Whether you are building in the blockchain space, the Web 3.0 space, the cloud computing space, or actual space, there is an increasing desire to give users more control over their data. Even the big tech companies are <a href="https://blogs.microsoft.com/eupolicy/2018/07/20/microsoft-facebook-google-and-twitter-introduce-the-data-transfer-project-an-open-source-initiative-for-consumer-data-portability/">forming data standards to help with data portability</a> (even if it may just be for appearances). While there are a variety of ways to approach user-controlled data, the Web 3.0 space (including Blockchain solutions) often focuses on non-custodial, complete control systems. These systems require a certain level of technical knowledge, they require users to step out of the normal flow of interacting with applications, and they require users take on a burden they are not used to taking on. This is totally fine if users want that. But what about the vast majority of users that want some sort of control of their data but don’t want the burden of extra responsibility?</p><p>Let’s first talk about the extra responsibility in question. For most proponents of decentralization, the idea of giving users control means giving users their encryption keys and identity information and telling them to manage it properly or lose everything. For some, that’s the right approach. There are those that want that level of control. But your mom and dad probably just want to know where their data is, how it’s being used, and how they can get it out if they want it. Should we be forcing them to take on the responsibility of managing their keys and generating wallets, and shoving pieces of paper in a safe so that they don’t lose access to everything? Probably not. But we also shouldn’t remove that as an option.</p><p>Giving users control comes in layers. One day, Mom and Dad might decide they do want to cut out the middleman, the convenience layer. If they make that decision, there should be a way for them to achieve this goal. There should be a way for them to say “I’m ready to manage my identity and encryption keys now, please.” Until they make that decision, though, there should be a way to help them manage their identity and encryption keys without asking them to jump through too many hoops. Without fully centralizing the solution. Because, if the solution is totally centralized, a failure of that solution will result in them losing access to their data which means they never actually had control at all.</p><p><a href="https://www.simpleid.xyz/?t=med_ch">SimpleID</a> acts as a convenience layer to the Web 3.0 identity space. If gives developers the tools to build apps with a traditional username/password interface for logging in while giving end-users access to Web 3.0 functionality like distribute storage, smart contracts, encryption, and more. When an account is created, the user is emailed their root keychain, encrypted with the password they selected. This means if SimpleID ever went away, these users do not lose access to their data as long as they have access to that email and remember their password. This is a significant step up from asking users to remember a 12-word seed phrase or writing down a private key and store it in a safe. But it is also just a stepping stone.</p><p>Developers that use SimpleID can and should provide full, non-custodial options also. You can see this is how <a href="https://app.graphitedocs.com/">Graphite</a> manages authentication. <a href="https://contact.mylens.io/">Lens</a> does too. Giving users choice is one of the pillars on which Web 3.0 is based. So, we should stop looking at the world of user-controlled data as an all or nothing solution. We should provide layers of decentralization. Choose what should be decentralized and when. Or, better yet, <strong>let the users decide</strong>.</p><p>If you’re interested in building apps that leverage Web 3.0 technologies and would like to give users the choice of using an authentication system they know and expect, SimpleID can help. Check out our <a href="https://www.simpleid.xyz/?t=med_ch_end">website</a>, <a href="https://www.simpleid.xyz/?t=med_ch_demo">demo app</a>, and <a href="https://docs.simpleid.xyz/">documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19e56c4ae2b0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simpleid-dev-tools/give-users-control-of-their-data-by-giving-them-choice-19e56c4ae2b0">Give Users Control of Their Data by Giving Them Choice</a> was originally published in <a href="https://medium.com/simpleid-dev-tools">SimpleID — Engagement and Retention</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial: Build an Encrypted Notes App on IPFS — Part II]]></title>
            <link>https://medium.com/simpleid-dev-tools/tutorial-build-an-encrypted-notes-app-on-ipfs-part-ii-3bdba2d867ad?source=rss----fc8043ca5f65---4</link>
            <guid isPermaLink="false">https://medium.com/p/3bdba2d867ad</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Justin Hunter]]></dc:creator>
            <pubDate>Tue, 03 Sep 2019 14:23:14 GMT</pubDate>
            <atom:updated>2019-09-03T16:10:57.547Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tutorial: Build a Zero Dependency Notes App on IPFS — Part II</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*r7N6F_0GRlxL-7Td" /></figure><p>In the <a href="https://medium.com/simpleid-dev-tools/tutorial-build-an-encrypted-notes-app-on-ipfs-part-i-39fb06fa95ce">first part of this tutorial</a>, we set up authentication for our application. We did so with no dependencies and just two files — index.html and main.js. In this second part of the tutorial, we’ll build out the application, which is a simple note-taking app with content stored on IPFS. Since we are using <a href="https://www.simpleid.xyz/?t=prt2">SimpleID</a>’s APIs, the IPFS content storage happens through the fantastic service provided by <a href="https://pinata.cloud/">Pinata</a>.</p><p>I think the best place to start is in the html. We already have a section ready to hold our application content. Find the section that looks like this:</p><pre>&lt;div style=&quot;display: none&quot; id=&quot;root-app&quot;&gt;<br>  &lt;button onclick=&quot;signOut()&quot;&gt;Sign Out&lt;/button&gt;<br>  &lt;h1&gt;This is the app&lt;/h1&gt;<br>&lt;/div&gt;</pre><p>The sign out button can stay, but we need to remove the This is the app text and replace it with what our actual application content will be. A couple of things, I’m thinking about already are:</p><ul><li>How do we switch between note-taking and viewing all existing notes?</li><li>How will all existing notes be rendered?</li></ul><p>Let’s set up our html content to support what will hopefully be decent answers to those questions:</p><pre>&lt;div style=&quot;display: none&quot; id=&quot;root-app&quot;&gt;<br>  &lt;button onclick=&quot;signOut()&quot;&gt;Sign Out&lt;/button&gt;<br>  &lt;div id=&quot;notes-collection&quot;&gt;<br>    &lt;ul id=&quot;notes-collection-items&quot;&gt;&lt;/ul&gt;<br>  &lt;/div&gt;<br>  &lt;div style=&quot;display: none;&quot; id=&quot;single-note&quot;&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>When we display the application content, we don’t want to display both the note-taking and the notes collection at once. We could, but I think it’d be cleaner to show the user’s collection of notes, and then on a button push or something, the note taking section will be rendered. So, we start with the notes-collection rendered and the single-note hidden.</p><p>You’ll note that within the notes collection, I’ve included a ul without any children li. That’s because we’re going to programmatically render those list-items as our notes collection is loaded.</p><p>Now that we have the skeleton of our application content, let’s jump back into our JavaScript file and start by fetching our notes-collection index file. This file will contain an array of identifiers, titles, and dates for all our notes. In main.js, we first need to add a new global variable at the top of the file. Below the loading variable add let notesCollection = [];. Now, add a new function called fetchCollection():</p><pre>async function fetchCollection() {</pre><pre>  const url = &quot;https://api.simpleid.xyz/fetchContent&quot;;</pre><pre>  const username = JSON.parse(localStorage.getItem(&#39;user-session&#39;)).username;<br>  const notesId = &quot;notesIndex&quot;;<br>  const data = `username=${username}&amp;devId=${config.devId}&amp;devSuppliedIdentifier=${notesId}&amp;development=true`;</pre><pre>  const pinnedContent = await postToApi(data, url);</pre><pre>  if(!pinnedContent.includes(&quot;ERROR&quot;)) {<br>    notesCollection = JSON.parse(pinnedContent);<br>  } else {<br>    notesCollection = [];<br>  }<br>}</pre><p>If you remember, we were smart and created a reusable function to posting to the SimpleID API that always returns a promise. Here’s we’re just specifying the url to post to and the data to include. The data we are sending has to include an identifier that will be used for finding the right file from the IPFS network. That’s the notesId. You might be asking how that identifier can be used with multiple users while still returning the correct content for each user. That’s where the username variable comes in. In the data we are posting, the username should be your logged in user’s username. Remember, this is stored in localStorage, so we can easily fetch that and include it.</p><p>When we make our request to the API, we need to account for any error that might arise, including a lack of content being stored previously. So, we check for the error, and if there is none, we set our notesCollection array with the response. Otherwise, we set the notesCollection to an empty array.</p><p>But this isn’t quite enough. We need to loop through that array and add a list-item for each note between our notes-collection-items ul. We can do that if there is no error. So in that if block add this below notesCollection = JSON.parse(pinnedContent) let’s add a call to a function called renderCollection(). Then we can create the renderCollection function like this:</p><pre>function renderCollection() {<br>  let list = document.getElementById(&#39;notes-collection-items&#39;);<br>  list.innerHTML = &quot;&quot;;<br>  for(const note of notesCollection) {<br>    let item = document.createElement(&#39;li&#39;);<br>    item.appendChild(document.createTextNode(note.title));<br>    item.appendChild(document.createTextNode(note.date));<br>    item.setAttribute(&quot;id&quot;, note.id);<br>    list.appendChild(item);<br>  }<br>}</pre><p>Here’s we’re just grabbing the ul we created, created children list-items beneath it and filling those list items with the note title and note date. We are also setting the note’s id as the element id. This will come in handy later when we want to display the actual content of the note.</p><p>This needs to be called once the user logs in and once the user signs up, so let’s wire that up:</p><pre>//in signin function</pre><pre>...<br>if(!userData.includes(&#39;ERROR&#39;)) {<br>  console.log(userData);<br>  let userSession = JSON.parse(userData);<br>  userSession.username = username;<br>  localStorage.setItem(&#39;user-session&#39;, JSON.stringify(userSession));<br>  loading = false;<br>  loggedIn = true;<br>  pageLoad();<br>  fetchCollection(); //call it here for sign in<br>} else {<br>  loading = false;<br>  loggedIn = false;<br>  pageLoad();<br>  console.log(&quot;Error&quot;);<br>}</pre><pre>//in sign up function</pre><pre>...<br>const keyData = `username=${username}&amp;password=${password}&amp;profile=${uriEncodedProfile}&amp;url=https%3A%2F%2Fthisisnew.com&amp;development=true&amp;devId=imanewdeveloper`;<br>const userData = await postToApi(keyData, urlAppKeys);</pre><pre>if(!userData.includes(&#39;ERROR&#39;)) {<br>  console.log(userData);<br>  let userSession = JSON.parse(userData);<br>  userSession.username = username;<br>  localStorage.setItem(&#39;user-session&#39;, JSON.stringify(userSession));<br>  loading = false;<br>  loggedIn = true;<br>  pageLoad();<br>  fetchCollection(); //call it here<br>} else {<br>  loading = false;<br>  loggedIn = false;<br>  pageLoad();<br>  console.log(&quot;Error&quot;);<br>}</pre><p>We also need to call fetchCollection on every page load because the user might refresh the screen. We should only do that if the user is logged in though. So right below the pageLoad() call toward the top of main.js add this:</p><pre>pageLoad();</pre><pre>if(localStorage.getItem(&#39;user-session&#39;)) {<br>  fetchCollection();<br>}</pre><p>Now, we already know there’s no content to display yet, so let’s think about how we want to enable new notes to be created. I mentioned creating a button before, and I kind of like that idea. Let’s add a few things to our application content:</p><pre>&lt;div style=&quot;display: none&quot; id=&quot;root-app&quot;&gt;<br>  &lt;button onclick=&quot;signOut()&quot;&gt;Sign Out&lt;/button&gt;<br>  &lt;div id=&quot;notes-collection&quot;&gt;<br>    &lt;div&gt;<br>      &lt;h3 id=&quot;notes-total&quot;&gt;&lt;/h3&gt;<br>      &lt;button onclick=&quot;newNote()&quot; id=&quot;create-note&quot;&gt;New Note&lt;/button&gt;<br>    &lt;/div&gt;<br>    &lt;ul id=&quot;notes-collection-items&quot;&gt;&lt;/ul&gt;<br>  &lt;/div&gt;</pre><pre>  &lt;div style=&quot;display: none;&quot; id=&quot;single-note&quot;&gt;<br>    &lt;button onclick=&quot;closeNote()&quot;&gt;Close&lt;/button&gt;<br>    &lt;ul id=&quot;toolbar&quot;&gt;<br>      &lt;li&gt;Bold&lt;/li&gt;<br>      &lt;li&gt;Italics&lt;/li&gt;<br>      &lt;li&gt;Underline&lt;/li&gt;<br>      &lt;li class=&quot;right&quot;&gt;Save&lt;/li&gt;<br>    &lt;/ul&gt;<br>    &lt;div&gt;<br>      &lt;input type=&quot;text&quot; id=&quot;title&quot; placeholder=&quot;note title&quot; /&gt;<br>    &lt;/div&gt;<br>    &lt;div id=&quot;note&quot; contenteditable=&quot;true&quot;&gt;&lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>We’ve done a few things here. We’ve added a button to let us create new notes and we’ve binded an event handler to it that calls newNote(). We’ll set up that function in a minute. We added a button to close the note screen once it’s open. It calls a function that will…well…close the note screen. We also added a toolbar to our single note section. This will be a simple note-taking app with simple functionality — bold, italics, underline. We also have a save button in our toolbar that we will wire up later. We need to give our notes a title, so we also added a title input field. Finally, we added a contenteditable div to hold our note and gave it an id we can reference later.</p><p>What now? Well, I think we should make the New Note button show our new note, right? Let’s do that in our main.js file. Open that up and add a function called newNote():</p><pre>function newNote() {<br>  document.getElementById(&#39;notes-collection&#39;).style.display = &quot;none&quot;;<br>  document.getElementById(&#39;single-note&#39;).style.display = &quot;block&quot;;<br>  document.getElementById(&#39;note-title&#39;).value = &quot;&quot;;<br>  document.getElementById(&#39;note&#39;).innerHTML = &quot;&quot;;<br>}</pre><p>In the newNote() function we are hiding the notes collection because we don’t need to see that while writing a new note. We are then showing the note taking screen. We are also setting the note title and note content to an empty string because every time New Note is pressed, it should be a fresh note with no pre-filled content.</p><p>While we’re here, let’s set up that closeNote() function as well:</p><pre>function closeNote() {<br>  document.getElementById(&#39;notes-collection&#39;).style.display = &quot;block&quot;;<br>  document.getElementById(&#39;single-note&#39;).style.display = &quot;none&quot;;<br>}</pre><p>This one is pretty simple. We’re hiding the note taking screen and showing the note collection screen again. Something to note (see what I did there?) here is that notes are only saved when the user clicks Save note. We haven’t set that up yet, but we will. This means, when the user clicks the close button, nothing is being saved. You’re welcome to wire this up differently.</p><p>I think the next two things we should do are handle changes to the content in our note taking section (when the user types, we want to track that) and handle the toolbar buttons. Let’s start with tracking content changes. For that, we’re going to add an event listener to our main.js file. You can do this above the first function but below the pageLoad() call like this:</p><pre>let editable = document.getElementById(&#39;note&#39;);<br>editable.addEventListener(&#39;input&#39;, function() {<br>  console.log(&#39;You are typing&#39;);<br>});</pre><p>Save that, then when signed into your app, go ahead and create a new note and type something. Open up the developer console, and you should see You are typing printed out. That’s cool! But it’s less than useful. We need to track the actual content so that when it’s time to save, we have a variable to use. To do that, let’s create a new global variable at the top of your main.js file right below the notesCollection variable:</p><pre>let noteContent = &quot;&quot;;</pre><p>Now, within the event listener, we can remove the console.log and replace it with the innerHTML of the contenteditable div that represents our note and set equal to the noteContent variable. It should look like this:</p><pre>let editable = document.getElementById(&#39;note&#39;);<br>editable.addEventListener(&#39;input&#39;, function() {<br>  noteContent = editable.innerHTML;<br>  console.log(noteContent);<br>});</pre><p>I added a console.log below that to make sure all is working. Do that if you want and test it by creating a new note, typing, and opening the developer console. If you do that, you should see the html representation of what you type out printed in the console.</p><p>Now, let’s make this text formatted! For our toolbar, we’ll need to add an onclick event handler for each item. When each toolbar button is clicked, it should apply the formatting specified. Thankfully, there’s some built-in JavaScript to support this. Let’s give it a shot:</p><pre>&lt;ul id=&quot;toolbar&quot;&gt;<br>  &lt;li onmousedown=&quot;event.preventDefault()&quot; onclick=&quot;document.execCommand(&#39;bold&#39;, false, null)&quot;&gt;Bold&lt;/li&gt;<br>  &lt;li onmousedown=&quot;event.preventDefault()&quot; onclick=&quot;document.execCommand(&#39;italic&#39;, false, null)&quot;&gt;Italics&lt;/li&gt;<br>  &lt;li onmousedown=&quot;event.preventDefault()&quot; onclick=&quot;document.execCommand(&#39;underline&#39;, false, null)&quot;&gt;Underline&lt;/li&gt;<br>  &lt;li class=&quot;right&quot;&gt;Save Note&lt;/li&gt;<br>&lt;/ul&gt;</pre><p>We’re using the built in <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand">execCommand</a> functionality in JavaScript to build a very simple WYSIWYG editor for our note-taking app. Pretty cool, huh? You’ll notice the onmousedown event handler. This is there because when you click the toolbar buttons, focus is taken away from the text that needs to be formatted, thus making it seem like the buttons don’t work. We prevent that with this event handler.</p><p>Ok, this is all working. Now, we need to wire up our Save Note button. Let’s think about what this needs to do:</p><ul><li>Create an object that holds the note title, the note content, and the note id (which we can generate pretty easily)</li><li>Add the new note to the existing notesCollection array</li><li>Save an index file that has all of the notesCollection array</li><li>Save the note file itself which includes the full content</li></ul><p>Let’s start by adding an event handler to our Save Note button in the toolbar:</p><pre>&lt;ul id=&quot;toolbar&quot;&gt;<br>  &lt;li onmousedown=&quot;event.preventDefault()&quot; onclick=&quot;document.execCommand(&#39;bold&#39;, false, null)&quot;&gt;Bold&lt;/li&gt;<br>  &lt;li onmousedown=&quot;event.preventDefault()&quot; onclick=&quot;document.execCommand(&#39;italic&#39;, false, null)&quot;&gt;Italics&lt;/li&gt;<br>  &lt;li onmousedown=&quot;event.preventDefault()&quot; onclick=&quot;document.execCommand(&#39;underline&#39;, false, null)&quot;&gt;Underline&lt;/li&gt;<br>  &lt;li onclick=&quot;saveNote()&quot; class=&quot;right&quot;&gt;Save Note&lt;/li&gt;<br>&lt;/ul&gt;</pre><p>Ok, now, let’s actually create that function in our main.js file:</p><pre>async function saveNote() {<br>  let note = {<br>    id: Date.now(),<br>    title: document.getElementById(&#39;note-title&#39;).value === &quot;&quot; ? &quot;Untitled&quot; : document.getElementById(&#39;note-title&#39;).value<br>  }<br>  console.log(note);<br>  notesCollection.push(note);<br>  console.log(notesCollection);<br>}</pre><p>We’re taking baby steps to make sure things work, but go ahead and test this out. Start a new note, write something, give it a title, then save it. In console, you should see the individual note and you should see the notesCollection array was updated. You’ll notice our note object does not include the content. That’s because the first thing we’re doing is updating our index of notes, which only requires basic meta data.</p><p>The next thing we should do is save the index file to IPFS. That’s right, you’ve waited all this time. Let’s save some content!</p><p>To test this, let’s update our saveNote() function:</p><pre>async function saveNote() {<br>  let note = {<br>    id: Date.now(),<br>    title: document.getElementById(&#39;note-title&#39;).value === &quot;&quot; ? &quot;Untitled&quot; : document.getElementById(&#39;note-title&#39;).value<br>  }<br>  notesCollection.push(note);</pre><pre>  const pinURL = &quot;https://api.simpleid.xyz/pinContent&quot;;</pre><pre>  const username = JSON.parse(localStorage.getItem(&#39;user-session&#39;)).username;</pre><pre>  const identifier = &quot;notesIndex&quot;;</pre><pre>  const content = encodeURIComponent(JSON.stringify(notesCollection));</pre><pre>  const data = `username=${username}&amp;devId=${config.devId}&amp;devSuppliedIdentifier=${identifier}&amp;contentToPin=${content}&amp;development=true`;</pre><pre>  const postedContent = await postToApi(data, pinURL);</pre><pre>  if(!postedContent.includes(&quot;ERROR&quot;)) {<br>    console.log(postedContent);<br>  } else {<br>    console.log(&quot;Error pinning content&quot;);<br>    console.log(postedContent);<br>  }<br>}</pre><p>Here, we are specifying the API endpoint, we are grabbing the logged-in user’s username, we’re URIEncoding the content, and then we are building up a from-data-compliant data string. That is all being sent to the postToApi() function. We check the response from that API call and look for an error. If there’s no error, we’re ready to move on. If there is, we console log it.</p><p>Now, this is only half of what we need to do. We also need to save the individual note with its content. So let’s do that. Inside, the if(!postedContent.indludes(&quot;ERROR&quot;) block, let’s add this:</p><pre>note.content = noteContent;<br>const noteIdentifier = JSON.stringify(note.id);<br>const saveNoteContent = encodeURIComponent(JSON.stringify(note));<br>const noteData = `username=${username}&amp;devId=${config.devId}&amp;devSuppliedIdentifier=${noteIdentifier}&amp;contentToPin=${saveNoteContent}&amp;development=true`;</pre><pre>const postedNote = await postToApi(noteData, pinURL);</pre><pre>console.log(postedNote);</pre><pre>if(!postedNote.includes(&quot;ERROR&quot;)) {<br>  document.getElementById(&#39;notes-collection&#39;).style.display = &quot;block&quot;;<br>  document.getElementById(&#39;single-note&#39;).style.display = &quot;none&quot;;<br>  renderCollection();<br>} else {<br>  console.log(&quot;Error posting note content&quot;);<br>  console.log(postedNote);<br>}</pre><p>We’re basically doing exactly what we did when saving the note collection index file, but we’re doing it for the individual note. See how we’re adding the noteContent variable to the note object? That’s because for the individual note, we want to load the full note, including content.</p><p>If all goes well, we are closing the note and showing the notes collection, but we’re also calling renderCollection to make sure we update the UI with the new note. It’s a good time to make a couple updates to our renderCollection function now, so let’s do that:</p><pre>function renderCollection() {<br>  let list = document.getElementById(&#39;notes-collection-items&#39;);<br>  list.innerHTML = &quot;&quot;;<br>  for(const note of notesCollection) {<br>    let item = document.createElement(&#39;li&#39;);<br>    item.appendChild(document.createTextNode(note.title));<br>    item.setAttribute(&quot;id&quot;, note.id);<br>    item.onclick = () =&gt; loadNote(note.id);<br>    item.style.cursor = &quot;pointer&quot;;<br>    list.appendChild(item);<br>  }<br>}</pre><p>We are adding a style attribute to our notes list-items so that when we hover over it, our mouse cursor turns to a pointer as if hovering over a link. We’re also adding an event listener that calls the loadNote function on click. This is pretty intuitive, I think, but we want to be able to click on the title of a note and load the full content of the note clicked.</p><p>Let’s stub out that loadNote function now:</p><pre>async function loadNote(id) {<br>  console.log(id);<br>}</pre><p>Let’s test before moving on. If you save and refresh your browser, you should see (if you have saved any notes), the list of notes saved appear in the form of an unordered list. Click on the title of one of the notes and check your developer console. You should see the note’s id printed out.</p><p>We are just about done! All we need to do now is load up a note with its actual content so that the user can view or make edits as needed. Let’s finish things up by doing that in our loadNote() function:</p><pre>async function loadNote(id) {<br>  const url = &quot;https://api.simpleid.xyz/fetchContent&quot;;<br>  const username = JSON.parse(localStorage.getItem(&#39;user-session&#39;)).username;<br>  const noteId = JSON.stringify(id);<br>  const data = `username=${username}&amp;devId=${config.devId}&amp;devSuppliedIdentifier=${noteId}&amp;development=true`;</pre><pre>  document.getElementById(&#39;notes-collection&#39;).style.display = &quot;none&quot;;<br>  document.getElementById(&#39;single-note&#39;).style.display = &quot;block&quot;;</pre><pre>  const pinnedContent = await postToApi(data, url);<br>  console.log(pinnedContent);</pre><pre>  if(!pinnedContent.includes(&quot;ERROR&quot;)) {<br>    noteContent = JSON.parse(pinnedContent).content;<br>    document.getElementById(&#39;note-title&#39;).value = JSON.parse(pinnedContent).title;<br>    document.getElementById(&#39;note&#39;).innerHTML = noteContent;<br>  } else {<br>    console.log(&quot;Couldn&#39;t load note&quot;)<br>  }<br>}</pre><p>Go ahead and test this now. Create a note, save it, open it. All seems to be working, but we forgot one thing. If we were to edit an existing note, it wouldn’t update the note in question, it would instead create a new note. Let’s fix that.</p><p>First, we need to make sure we set our individual note id to a global variable so that we can use it again when trying to save the updated note. So, at the top of your main.js file, add this global variable below noteContent = &quot;&quot;:</p><pre>let singleNoteId = null;</pre><p>Then, in your loadNote function, add this at the beginning:</p><pre>singleNoteId = id;</pre><p>Now, go to your saveNote() function and update the top of that function with this:</p><pre>let note = {<br>  id: singleNoteId ? singleNoteId : Date.now(),<br>  title: document.getElementById(&#39;note-title&#39;).value === &quot;&quot; ? &quot;Untitled&quot; : document.getElementById(&#39;note-title&#39;).value<br>}</pre><pre>let index = await notesCollection.map((x) =&gt; {return x.id }).indexOf(note.id);</pre><pre>if(index &lt; 0) {<br>  //This is a new note<br>  notesCollection.push(note);<br>} else if(index &gt; -1) {<br>  //The note exists and needs to be updated<br>  notesCollection[index] = note;<br>} else {<br>  console.log(&quot;Error with note index&quot;)<br>}</pre><p>This should now let us create new notes AND update existing notes. Let’s give it a try and make sure. Open an existing note, edit it, then click the Save button.</p><p>You did it! You just built a zero dependency application that lets you do the following:</p><ul><li>sign up</li><li>sign in</li><li>sign out</li><li>create notes</li><li>format notes</li><li>save to IPFS</li><li>fetch from IPFS</li></ul><p>In addition to this being a zero dependency application, the entire size of the app, unbundled and unminified and unzipped is just under 20kb. That’s pretty great.</p><p>This whole app is super ugly, and the css I provide isn’t going to make it all that much better, but you can grab <a href="https://github.com/simplesecure/zero-dependency-ipfs-notes/blob/master/style.css">this CSS</a> to make it at least look presentable. In fact, the entire project is loaded up <a href="https://github.com/simplesecure/zero-dependency-ipfs-notes">here</a> if you’d like to explore the repository or if you hit trouble along the way and need to review the code.</p><p>There’s a whole lot more you can do with this app, and your homework, if you choose to do it, is to try to add the following yourself:</p><ul><li>More formatting options (beginner)</li><li>Delete notes (intermediate)</li><li>Password protected share link (advanced)</li></ul><p>Something worth pointing out in this tutorial is that you are using an API key client-side. This is bad security practice. If you are concerned about others seeing your API key and using it, you should obscure this by standing up a server, making calls to that server, and using the SimpleID API functions on that server. You can protect your keys server-side. That’s well outside the scope of this tutorial though.</p><p>Thanks for sticking around for both parts of this tutorial. If you enjoyed this and want to use the simple authentication tools and simple IPFS tools, take a look at <a href="https://www.simpleid.xyz/?t=ipfs_end">SimpleID</a>. We’d love to see what you can build.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bdba2d867ad" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simpleid-dev-tools/tutorial-build-an-encrypted-notes-app-on-ipfs-part-ii-3bdba2d867ad">Tutorial: Build an Encrypted Notes App on IPFS — Part II</a> was originally published in <a href="https://medium.com/simpleid-dev-tools">SimpleID — Engagement and Retention</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>