<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andrei Anisimov on Medium]]></title>
        <description><![CDATA[Stories by Andrei Anisimov on Medium]]></description>
        <link>https://medium.com/@andrei.anisimov?source=rss-a8a0023996dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AjBPdyW4eQ1K47G3dtv6Zg.jpeg</url>
            <title>Stories by Andrei Anisimov on Medium</title>
            <link>https://medium.com/@andrei.anisimov?source=rss-a8a0023996dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 03:24:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@andrei.anisimov/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to build a TodoMVC app with React and 8base GraphQL API]]></title>
            <link>https://medium.com/free-code-camp/how-to-build-a-todomvc-app-with-react-and-8base-graphql-api-ea858952731b?source=rss-a8a0023996dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea858952731b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Andrei Anisimov]]></dc:creator>
            <pubDate>Fri, 22 Feb 2019 20:47:50 GMT</pubDate>
            <atom:updated>2019-04-23T20:44:35.822Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*2O1B3d5Pda95Isjc8OUN_w.png" /></figure><h3>Requirements</h3><ul><li><a href="https://git-scm.com/downloads">git</a></li><li><a href="https://www.npmjs.com/get-npm">npm</a> or <a href="https://yarnpkg.com/lang/en/docs/install/#mac-stable">yarn</a> (we use yarn here, but you can use npm if you prefer)</li><li>Familiarity with <a href="https://reactjs.org/">React.js</a></li></ul><h3>Introduction</h3><p>In this tutorial I’ll show you how to quickly create a GraphQL API using <a href="https://www.8base.com/?utm_source=freecodecamp&amp;utm_campaign=todomvc">8base</a> and connect to it from a React app. 8base is a Developer Acceleration Platform offering a plethora of features to help front-end developers build applications faster and simpler than ever before. With 8base, there is no need to rely on back-end developers or DevOps!</p><p>Using the 8base platform, you can build your GraphQL backend using a simple GUI that allows you to perform actions such as:</p><ul><li>Define your data schema: create tables/ table relationships</li><li>Upload files</li><li>Define roles</li><li>Manage various projects using “Workspaces”</li><li>Design GraphQL queries and mutations using the API explorer</li></ul><p>I believe that the best way to illustrate the utility of GraphQL is to show interested developers how it can be integrated with projects they are already working on. By connecting a simple Todo MVC app to a GraphQL backend, we’ll learn how to:</p><ul><li>Define data tables in 8base to create a GraphQL API</li><li>Write queries using GraphQL</li><li>Access your data from a React.js front-end</li></ul><h3>Intended Audience</h3><p>This tutorial is aimed mostly toward users who don’t have much prior experience with GraphQL. If you are familiar with GraphQL, connecting to your 8base backend should be a somewhat familiar process. We encourage you to follow this tutorial, and see how a static React application comes to life by connecting it to a dynamic GraphQL API.</p><h3>Preparing the Environment/ 8base UI</h3><p>In this tutorial, we will only use a few features offered by 8base, but I highly encourage you to explore the entirety of the platform and utilize other tools in the suite.</p><ol><li><strong>Create an accoun</strong>t on <a href="https://www.8base.com/?utm_source=freecodecamp&amp;utm_campaign=todomvc">8base</a> <em>(It’s free for small teams. You will be asked to verify your email and then redirected to the 8base UI).</em></li><li>Once you are in the 8base UI, simply <strong>navigate to “Data” and click on “New Table”</strong> to start building your backend. After your new table is loaded, you’ll be taken to the Schema in order to begin defining fields. Let’s take a look around and note a couple of things. On the left, you’ll see there are System Tables and Your Tables. Every new 8base workspace automatically comes prepackaged with a number of built-in Tables. These tables are used to handle things like Files, Settings, and Permissions and can all be accessed through the 8base GraphQL API. For now, the only system table that is exposed via the UI is Users, but you can find a complete list of 8base system tables by using the query tablesList in the API Explorer.</li><li>Go ahead and <strong>create a table</strong> Todo with fields text (field type: TEXT), completed (field type: SWITCH, format: Yes/No). <em>Switch is a particularly interesting field type. At first, it may seem like a boolean value, but the switch field is actually able to handle multiple options, and therefore allows for a lot of flexibility. However, for the sake of this project, we will simply be using Yes/No.</em></li><li>Next, <strong>copy the API endpoint URL </strong>(available on the bottom left) — this is your main line of communication between your front end and your 8base backend (you’ll need it later where it says 8BASE_API_URL).</li><li>Finally, for the purpose of this tutorial we’re going to <strong>allow open access to Guests</strong> by default so that dealing with authentication is optional. To allow guest access to your new Todo table, navigate to Settings &gt; Roles &gt; Guest and check the appropriate boxes under Todo. <em>All unauthenticated users who access your API endpoint are given the role of </em><em>Guest by default. Authentication is not covered in this tutorial. You can see how authentication should be handled in more detail </em><a href="https://docs.8base.com/docs/authentication"><em>here</em></a><em>.</em></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Kd0z58jTVcR2oyT-BBiNIQ.png" /><figcaption><em>Make sure your guest permissions for Todos match the ones above</em></figcaption></figure><p>Now that you’ve prepared your backend, let’s head over to the 8base <a href="https://github.com/8base-examples/todomvc">TodoMVC repo</a> to prepare our client application.</p><ul><li>Clone the TodoMVC repo and run git checkout workshop to switch into the workshop branch.</li></ul><p><em>The master branch contains the completed code for this project so you will be unable to follow along with the tutorial if you don’t complete this step.</em></p><ul><li>Install dependencies:</li></ul><p>yarn add @8base/app-provider graphql graphql-tag react-apollo &amp;&amp; yarn</p><ul><li>Test that the app works without backend: yarn start</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qvTFzoUgTA-anWaPb9cqPA.png" /></figure><ul><li>(Optional) Setup VS Code <a href="https://marketplace.visualstudio.com/items?itemName=apollographql.vscode-apollo">Apollo GraphQL</a> extension: Create the file apollo.config.js in the root of the project with the following content (replace 8BASE_API_URL with your API endpoint URL):</li></ul><pre>module.exports = {<br>  client: {<br>    service: {<br>      name: &#39;8base&#39;,<br>      url: &#39;8BASE_API_URL&#39;,<br>    },<br>    includes: [<br>      &quot;src/*.{ts,tsx,js,jsx}&quot;<br>    ]<br>  },<br>};</pre><p><em>The Apollo GraphQL extension for VS code provides validation and autocomplete for writing GraphQL queries.</em></p><h3>Connecting the Backend</h3><p>The application repo that we set up has the following code built in, so you can focus on understanding what’s going on. In instances where you have to add code, just uncomment what is specified. In instances where the code has to be removed, the specified code is appended by the comment //Remove this in the code base.</p><p><em>Note that all relevant code in this tutorial will be placed in the file src/App.js — this is not best practice using React but has been done this way to simplify the tutorial.</em></p><ol><li><strong>Import GraphQL-related dependencies</strong></li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3755e4fd90fee989493a4dd71fc3c99/href">https://medium.com/media/c3755e4fd90fee989493a4dd71fc3c99/href</a></iframe><p>You’ll see here not only are we importing gql and graphql, but we are also importing EightBaseAppProvider from the 8base SDK. The 8base SDK makes integration with 8base and GraphQL simple. We&#39;ve done this by taking a lot of the boilerplate/setup-code and packaging it inside the SDK, so all the developer needs to do is wrap their application in the &lt;EightBaseAppProvider&gt; tag and pass it the appropriate props to allow data access to all the child components. EightBaseAppProvider uses <a href="https://www.apollographql.com/docs/react/">Apollo Client</a>, so if you are familiar with it already, there is nothing new to learn.</p><p><strong>2. Initialize </strong><strong>EightBaseAppProvider</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb6a856d4ffdbe62aaf2acceac3675b9/href">https://medium.com/media/bb6a856d4ffdbe62aaf2acceac3675b9/href</a></iframe><p>You need to provide a function as a child of EightBaseAppProvider that will tell React what we want to render. We can use the loading property to display a loader while the application is being initialized. During the initialization, EightBaseAppProvider loads the 8base table schema which gives you access to all properties of the data model inside your front end code. We&#39;ll touch on this feature more in-depth in a future tutorial.</p><p><strong>3. Add a Query to Fetch todos</strong></p><ul><li>Query and HOC</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5137371da5101a2498a33598231f422/href">https://medium.com/media/c5137371da5101a2498a33598231f422/href</a></iframe><p>In the code above, we are creating a <a href="https://reactjs.org/docs/higher-order-components.html">Higher-Order Component</a> (HOC) using the graphql() function provided by <a href="https://www.apollographql.com/docs/react/">react-apollo</a>.</p><blockquote><em>From </em><a href="https://www.apollographql.com/docs/react/api/react-apollo.html#graphql"><em>react-apollo</em></a><em> — The graphql() function is the most important thing exported by react-apollo. With this function you can create higher-order components that can execute queries and update reactively based on the data in your Apollo store. The graphql() function returns a function which will “enhance” any component with reactive GraphQL capabilities. This follows the React higher-order component pattern which is also used by react-redux’s </em><em>connect function.</em></blockquote><p>Essentially, by using graphql() we are able to write the code to query our backend in one place and inject this functionality into multiple components rather than writing it everywhere we want to be able to use it.</p><p>The graphql function takes a query as its first parameter, config as the second, and the return value is a HOC that should be executed with the desired component as an argument. Note that in our example, we use the config parameter ingraphql() to specify that our data will be accessible as props.todos rather than props.data.todosList.items.</p><p>As for our TODO_LIST_QUERY, we&#39;ve already given you the appropriate syntax, but typically we might design our queries in the <em>8base API Explorer</em>. If you navigate to the API Explorer and copy/paste the TODO_LIST_QUERY, you can see what data will be returned. Experiment with this query and see other ways that data can be returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*WtuMwVMPyfXCgubcEw2c4Q.png" /><figcaption><em>8base API Explorer</em></figcaption></figure><ul><li>Wrap Main and Footer into withTodos</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00e02a685a92e6fd6d1d274953b33519/href">https://medium.com/media/00e02a685a92e6fd6d1d274953b33519/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f449c0b09a586f603453f746928b612/href">https://medium.com/media/2f449c0b09a586f603453f746928b612/href</a></iframe><p>Ultimately in our example, we want to display all the data from our 8base backend in the Main component and the Footer component. In the code above we are using the compose() function provided by the lodash library to chain multiple Higher-Order Components together, giving our target components the functionality from each HOC. You can read more about how the compose() function works <a href="https://redux.js.org/api/compose">here</a>.</p><ul><li>Remove the code that passes down the todos prop to the Main and Footer components</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97863c937c1ae74a22ff17c9632939d5/href">https://medium.com/media/97863c937c1ae74a22ff17c9632939d5/href</a></iframe><p>When we first set up our application, all Todos were held in state because we were not connected to a backend. Our components still need to access the todos props, but we no longer have to pass it down explicitly because they are provided by withTodos.</p><p><strong>4. Add a Query to Create a todo</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7fe1211d10e68c12363ff7bc06b8ad81/href">https://medium.com/media/7fe1211d10e68c12363ff7bc06b8ad81/href</a></iframe><p>Here we are repeating the process we took previously to query our 8base backend. But this time we are using GraphQL mutation to create a Todo and then calling refetchQueries to update the state of our application with our newly added data. This will allow new data to populate throughout the application without having to make a separate request to our backend.</p><ul><li>Wrap Header</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c041b7ab65e11c33c610dcad7106590/href">https://medium.com/media/8c041b7ab65e11c33c610dcad7106590/href</a></iframe><p>The syntax above illustrates the enhancement of the Header component using our HOC. Note that withCreateTodo acts as a function, the Header component is passed to the function as an argument and the enhanced component is then set to the variable Header to be used in our application.</p><ul><li>Remove createTodo from Header</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2945c863eb8964eba8bf1aae34042532/href">https://medium.com/media/2945c863eb8964eba8bf1aae34042532/href</a></iframe><p><strong>5. Add a Query to update todos</strong></p><ul><li>Mutation and HOC</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d14769eead8304d7e837d0c8ba84d64/href">https://medium.com/media/3d14769eead8304d7e837d0c8ba84d64/href</a></iframe><ul><li>Wrap Main in withToggleTodo</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/150dd15da16e1e397ed91dd96665f01b/href">https://medium.com/media/150dd15da16e1e397ed91dd96665f01b/href</a></iframe><ul><li>Remove toggleTodo from Main</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3abf0715f7cd70a22e4c1d971b1b98d7/href">https://medium.com/media/3abf0715f7cd70a22e4c1d971b1b98d7/href</a></iframe><p>Above we’ve repeated the previous pattern to add functionality to the Main component. This will give the user the ability to toggle Todos as complete or incomplete.</p><p><strong>6. Add a Query to mark all todos as complete</strong></p><ul><li>We only need a new HOC, we can reuse the mutation. All mutations in the loop will be batched in a single request.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6e4e6edffd44344286724e8d1761d36/href">https://medium.com/media/a6e4e6edffd44344286724e8d1761d36/href</a></iframe><ul><li>Wrap Main in withToggleAllTodos</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9049403e8e6dd89a43834038f0b4342f/href">https://medium.com/media/9049403e8e6dd89a43834038f0b4342f/href</a></iframe><ul><li>Remove toggleAllTodos from Main</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0454f3cfdbcc6d775b5cd1095f00c72a/href">https://medium.com/media/0454f3cfdbcc6d775b5cd1095f00c72a/href</a></iframe><p><strong>7. Add a Query to delete todos</strong></p><ul><li>Mutation and HOC</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9958f8cbf8fc3b19aceda2d038da490d/href">https://medium.com/media/9958f8cbf8fc3b19aceda2d038da490d/href</a></iframe><ul><li>Wrap Main in withRemoveTodo</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47ac9d75a63fa6144748de9440ff085b/href">https://medium.com/media/47ac9d75a63fa6144748de9440ff085b/href</a></iframe><ul><li>Remove removeTodo from Main</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/960501d0557a875029850cc7c89efd33/href">https://medium.com/media/960501d0557a875029850cc7c89efd33/href</a></iframe><p>As you can see, once you understand the basic pattern of enhancing components using the graphql() HOC, it becomes fairly simple to write new queries that can be easily accessed throughout your application.</p><p>Finally, test that your application works properly by navigating to the root directory and running yarn start.</p><p>You should now be able to create, update and destroy Todos that are persisted to the database.</p><ul><li>To see 8base working in action, open up your 8base workspace in a separate tab and open the <em>Data Viewer</em> on the Todos table. You should see all the data from your application in this window. Create new Todos in your application and refresh the page to see them in your database!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*kYA02Tq9ob9pIkD8cdA43w.png" /><figcaption>8base Data Viewer</figcaption></figure><p>8base is currently working on implementations using other frameworks and libraries. We currently have examples using <a href="https://github.com/8base/app-example">React</a> and <a href="https://github.com/8base/react-native-app-example">React-Native</a> as well as more <a href="https://docs.8base.com/docs/connecting-to-your-frontend">simple examples</a> using CURL, Node, and Vanilla JS. Feel free to visit our <a href="https://docs.8base.com/">Docs</a>, send a message on our <a href="https://8base.com/?utm_source=freecodecamp&amp;utm_campaign=todomvc">website</a>, or reach out to me personally with feedback on your experience with 8base.</p><p>Completed example with 8base backend connected can be found in the <a href="https://github.com/8base/todomvc">master</a> branch.</p><p>To get started with 8base or simply learn more information, visit <a href="https://www.8base.com/?utm_source=freecodecamp&amp;utm_campaign=todomvc"><strong>www.8base.com</strong></a>, <a href="https://docs.8base.com/?utm_source=freecodecamp&amp;utm_campaign=todomvc"><strong>docs.8base.com</strong></a>, follow us on Twitter at <strong>@</strong><a href="https://twitter.com/8baseinc"><strong>8baseinc</strong></a>, or email us directly at <strong><em>info@8base.com</em></strong><em>.</em></p><p><em>Originally published at </em><a href="https://blog.8base.com/tutorial-building-todomvc-with-8base-and-graphql-34a33357b784"><em>blog.8base.com</em></a><em> on February 22, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea858952731b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/free-code-camp/how-to-build-a-todomvc-app-with-react-and-8base-graphql-api-ea858952731b">How to build a TodoMVC app with React and 8base GraphQL API</a> was originally published in <a href="https://medium.com/free-code-camp">We’ve moved to freeCodeCamp.org/news</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Whether You Love or Hate Facebook, GraphQL is Awesome]]></title>
            <link>https://medium.com/hackernoon/whether-you-love-or-hate-facebook-graphql-is-awesome-bbf67f33fe10?source=rss-a8a0023996dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbf67f33fe10</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[low-code]]></category>
            <dc:creator><![CDATA[Andrei Anisimov]]></dc:creator>
            <pubDate>Thu, 24 Jan 2019 17:58:45 GMT</pubDate>
            <atom:updated>2019-02-05T13:41:00.882Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*8gJ4njeOI4lYObngZvBgCA.png" /></figure><p>Let’s time travel a bit. Imagine you’re a developer back in the mid-2000s. You’re working on building a web application, and you are solving for the desktop Internet browser because it’s the only platform available. It’s easier to keep your server and client codebase integrated and let the framework abstract away the client-server communication.</p><p>Fast forward a few years — browsers have now matured to support HTML5 and JavaScript, permitting richer client-side capabilities. At this point in time, the front-end developer emerged. Although developers began to diverge in their roles and responsibilities to keep up with evolving technological advancements, monolithic frameworks such as PHP, Ruby-on-Rails, and ASP.NET continued to dominate the developer ecosphere thanks to their simplicity, cost-effectiveness, and pervasive legacy use.</p><p>However, in many ways, these monolithic architectures have become a massive liability now that applications need to support many forms of devices and 3rd-party API connections. Due to these factors, the dependency on monolithic frameworks began to shift in favor of the API-first architecture.</p><h4>The API-First Approach</h4><p>To accommodate the emerging trend, a new ‘API-first’ approach was adopted: instead of monolithic, single-tier applications, back-end developers could now build a robust API that a variety of rich native or 3rd party client applications can connect to. Due to its simplicity and elegance, REST became the de facto standard for API implementations in the majority of today’s modern web and mobile applications. Meanwhile, developers began strongly gravitating towards either back-end or front-end with expanding divergence of career paths and technology stacks.</p><p>However, REST is not perfect, especially when it comes to complex data-driven applications. It skews the balance of power towards the back-end, leaving front-end developers with a set of rigid, opaque endpoints and at the mercy of their back-end counterparts to implement all data sources required in the client app in a timely manner. Issues like <a href="https://stackoverflow.com/questions/44564905/what-is-over-fetching-or-under-fetching">over/under-fetching</a> of data and lack of strong typing make the experience with REST suboptimal for many front-end and mobile development projects.</p><p>To address these issues, a new standard called GraphQL was developed by Facebook in 2012 and released to the public in 2015. GraphQL enables a query language for APIs. It has been increasingly adopted by many <a href="https://graphql.org/users/">prominent development teams</a> in companies such as AirBnB, Stripe, GitHub, Pinterest, Shopify, and Intuit.</p><h4>The GraphQL Takeover</h4><p>Unlike REST, every GraphQL API provides a schema containing information of input and output types, their fields, and relationships between objects. This allows an API to express rich, connected domain models and define flexible queries and mutations (manipulations on data) that are independent of client-side presentation. GraphQL also requires client-side developers to explicitly define the data to be returned, including querying related objects in the same request, eliminating data over- and under-fetching as well as reducing the number of API calls.</p><h4>GraphQL Vs. REST</h4><p>Let’s compare GraphQL and REST using a simple example: building an online blog. When rendering an individual blog article screen we need to show the post’s content, author’s avatar and name, list of comments, and name and avatar of each comment author.</p><p>With REST we’d have to program the following API calls:</p><ol><li><em>GET /articles/:id to get post’s content</em></li><li><em>GET /users/:id to get the author’s avatar URL and name</em></li><li><em>GET /articles/:id/comments to get the list of comments — hopefully, backend developers incorporated comment author name and avatar. Otherwise, we’ll have to do (4)</em></li><li><em>GET /users/:id for each comment to get comment author’s avatar URL and name</em></li></ol><p>Note that the under-fetching (when a single request doesn’t give us all data we need) and over-fetching (e.g. /users/:id call returns more info than we need to display), as well as increased complexity of front-end code, are required to orchestrate a series of dependent API calls.</p><p>With GraphQL, all information can be received in a single request given that the API developers expressed relationships between posts, users, and comments in the GraphQL API schema. In addition, only requested fields are included in the response, reducing its size. Below is an example of a GraphQL query that gives us all information in a single request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*hpkopWoJtKwTapbf3NFNgw.gif" /><figcaption>GraphQL API allows you to get all data in a single request</figcaption></figure><p>Achieving this with REST would require back-end developers to implement a custom API endpoint that returns this information. However, it would have to be done for every similar case and the API requires an update every time a front-end developer needs more fields.</p><p>This example illustrates how GraphQL changes the balance of power in favor of front-end developers, giving them the flexibility to query the data they need while allowing back-end developers to implement the API in a way that is representative of the business domain as a whole and not particular client-side views.</p><p>Together with a vibrant ecosystem of libraries and tools, this elevates the front-end developer experience to the next level — making GraphQL the preferred way to access and manipulate data across a growing number of development teams. This also streamlines the software development team’s process, significantly reducing the number of inefficient hand-offs between developers, likely resulting in lower development team staffing and costs.</p><h4>Using GraphQL with 8base</h4><p>One of the cons of the GraphQL API is that unlike REST, it is not that easy to implement. Exposing business data in a way that is convenient to use in a variety of client applications requires extensive back-end development. Implementing CRUD operations, relationships, filters, sorting, and pagination for each data type is tedious. Data permissions and the ability to attach files to data objects are also necessary, but not easy to build.</p><p><a href="https://blog.8base.com/how-8base-works-serverless-graphql-cli-and-more-328e534fc022"><strong>8base’s GraphQL API</strong></a> solves this problem automatically by giving front-end and mobile developers tools to configure a powerful GraphQL backend that makes building applications infinitely faster. For each table defined in your workspace, 8base automatically generates the following GraphQL operations:</p><ul><li><strong>Get a single object by id or any unique field</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*9_SDSLWgl8zJkfDojN1JQg.gif" /></figure><ul><li><strong>Get a list of objects based on filters, sorting, pagination and full-text search criteria</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*NzLZAm2CJaSj8AOeed24Cw.gif" /></figure><ul><li><strong>Create, update, delete an object</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*IGoCJBrUHmJyN0DC6Cfpww.gif" /></figure><ul><li><strong>Subscribe to real-time data events</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*lpgLyHhhJf1qrfr_LpqZxA.gif" /><figcaption>Subscribe to server-side data events via WebSockets</figcaption></figure><p><strong>All of these operations work really well with object relationships allowing developers to query, create and update child objects along with their parents:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*05XlBFGIyBRFY-32zW02mQ.gif" /><figcaption>Create child objects together with parent</figcaption></figure><p><strong>Access to each data table and field can be controlled via role-based security:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*4pacpwiiJr5cpCEZr23vjg.png" /><figcaption>8base Role-Based Security</figcaption></figure><h4>What About Files?</h4><p>Neither GraphQL or REST offer any help when it comes to working with files. Modern apps require developers to store and share files in a permissioned manner as well as linking files to data objects. Amongst other tasks, resizing images, generating thumbnails, and serving them through a Content Distribution Network (CDN) also encounter difficulties.</p><p>8base GraphQL API provides native file-management capability that makes it easy to work with files of any type. 8base Data Builder allows users the ability to define a <em>File type </em>field on any table to be able to store and work with files just like regular data. Through a native Filestack integration, 8base offers a variety of tools for working with files and documents: robust client-side file picker, fast content ingestion, image operations, thumbnail generation, in-document search, optical character recognition (OCR), facial recognition and more.</p><p><strong>Here’s how you’d query a user avatar information using 8base GraphQL API:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*_4LY7UA8x0AUlyGSNh6ARA.gif" /></figure><h4>Try It Yourself</h4><p>8base gives front-end developers the power to build and run modern web and mobile applications without being dependent on large cross-functional teams of backend developers and DevOps staff. But don’t take our word for it, try it yourself by completing the <a href="https://docs.8base.com/docs/quickstart"><strong>Quickstart Guide</strong></a><strong> </strong>to launch a demo React app in under 10 minutes.</p><p>To get started with 8base or simply learn more information, visit <a href="https://www.8base.com/?utm_source=8base_blog&amp;utm_medium=How%208base%20Works"><strong>www.8base.com</strong></a>, <a href="https://docs.8base.com/docs"><strong>docs.8base.com</strong></a>, follow us on Twitter at @<a href="http://www.twitter.com/8baseinc"><strong>8baseinc</strong></a>, or email us directly at <strong><em>info@8base.com</em></strong><em>.</em></p><p><em>Originally published at </em><a href="https://blog.8base.com/why-is-graphql-incorporated-into-8base-so-prominently-525750c8a280"><em>blog.8base.com</em></a><em> on January 24, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbf67f33fe10" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/whether-you-love-or-hate-facebook-graphql-is-awesome-bbf67f33fe10">Whether You Love or Hate Facebook, GraphQL is Awesome</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On-chain derivatives: solving $500T problem and getting prize at Consensus 2018 Hackathon]]></title>
            <link>https://medium.com/hackernoon/on-chain-derivatives-solving-500t-problem-and-getting-prize-at-consensus-2018-hackathon-fa04b8d3c632?source=rss-a8a0023996dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa04b8d3c632</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[on-chain-derivatives]]></category>
            <category><![CDATA[derivatives]]></category>
            <category><![CDATA[consensus]]></category>
            <dc:creator><![CDATA[Andrei Anisimov]]></dc:creator>
            <pubDate>Fri, 01 Jun 2018 10:16:01 GMT</pubDate>
            <atom:updated>2018-06-01T10:16:01.456Z</atom:updated>
            <content:encoded><![CDATA[<h3>On-chain derivatives: solving $500T problem and winning prize at Consensus 2018 Hackathon</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gJwa-cBDt6FNjmHJcVhwaw.png" /></figure><p>In early May, a few of us from 8base, Evgeny Semushin, Gabe Kelly and myself, decided to take on the challenge of competing for the AlphaPoint prize at the <a href="https://consensus2018-blockchain.devpost.com/">Consensus 2018 Hackathon</a> in New York City. There was a total of 33 participating teams at the hackathon, and there were some big-name sponsors such as CoinDesk, Microsoft, IBM, Hyperledger and Quorum.</p><p>The contenders in the AlphaPoint challenge had to build an application tied into a digital asset exchange and we thought that my hedge fund experience should give us an edge. We didn’t want to simply build a front-end to an existing blockchain solution. Instead, we wanted to focus on solving a real problem in a way that only blockchain architecture can enable, combining our expertise in smart contract development with knowledge of internal mechanics of finance.</p><p>We built a set of smart contracts on the Ethereum network that allows creation of decentralized derivatives with on-chain collateral management. Our solution enables anyone to underwrite a put or call option contract on any ERC20 asset without a 3rd party managing the exercise and collateral requirements. We were honored to win first prize.</p><p>Below we’ll describe the implementation detail of this project.</p><h3>Problem</h3><p>Derivatives are a big deal. Global derivatives are estimated to have at least ~$500 trillion market capitalization. Compare this to ~$0.4T crypto at the time of writing, ~$40T liquid money and ~$70T global stock markets, and it becomes clear how significant the role derivatives play in the global economy. Nothing shows this better than <a href="http://money.visualcapitalist.com/worlds-money-markets-one-visualization-2017/">this infographic</a>. Derivatives, such as options, futures and swaps are useful tools employed by banks, funds and companies to manage risk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TqOjkzR8EDDOIdVxTJXwgA.png" /><figcaption>Market cap of various asset classes</figcaption></figure><p>The key complexity of derivative agreements stems from the fact that they are usually leveraged — meaning that potential risks exceed the amount of funds counterparties to the agreement have in their accounts. This leads to a complex system of settlement, maintenance margin and margin calls designed for counterparties to keep a level of collateral, such that it is always more expensive to walk away from an agreement than to honor it.</p><p>This system failed in 2008. Entangled in a complex web of derivative agreements, Wall Street players couldn’t efficiently unwind or net them out. This triggered a domino effect of margin calls and subsequent defaults leading to the collapse of Lehman Brothers and other players. The US government had to step in and bail out Wall Street to help unwind staggering amounts of defaulted derivative agreements. We all know the rest…</p><h3>Solution</h3><p><a href="https://devpost.com/software/blocksigma">BlockSigma</a> is a set of smart contracts that enable creation and management of derivative agreements for crypto assets. The collateral management is done on-chain and doesn’t require an intermediary to ensure that the funds locked inside of a smart contract satisfy the maintenance margin requirements.</p><p>The core innovation is fully on-chain margin management that requires no central party or oracle price feed. We achieve this by integrating with <a href="https://about.bancor.network/">Bancor</a> protocol. Bancor protocol is being adopted at a significant rate and already facilitating millions of dollars of daily trading activity. Bancor uses a deterministic price formula that is calculated based on supply and demand of an asset. As such, we can get the underlying token price directly on-chain, which allows us to calculate the maintenance margin requirement and trigger a margin call if necessary.</p><p>The smart contract logic is designed in a way that enables an option buyer to force-liquidate the position as soon as the collateral held inside of the smart contract drops below the mandatory margin requirement. The maintenance margin formula includes excess reserves, providing economic incentives for the option buyer to closely watch the position and grab the reserve (including the excess amount) by force-liquidating the position if the maintenance margin level is not satisfied. At the same time, it incentivizes the option seller (underwriter) to timely add more collateral if the trade goes against them, otherwise they risk losing the excess reserve.</p><h3>Implementation</h3><p>The full source code of the solution can be found in the <a href="https://github.com/andrei-anisimov/blocksigma/tree/master/solidity/contracts">GitHub repo</a>.</p><p>There are three main solidity files: BlockSigmaBase.sol, BlockSigmaCall.sol, BlockSigmaPut.sol. BlockSigmaBase implements the common logic, while BlockSigmaCall and BlockSigmaPut inherit it and implement the logic specific to call or put contracts.</p><p>Let’s look at the contract’s interface:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b41d4bcc0e3d98c52bab874b21dac5f/href">https://medium.com/media/5b41d4bcc0e3d98c52bab874b21dac5f/href</a></iframe><p>Now let’s walk through the key workflows of a put contract. For example, let’s consider a put contract on EOS token denominated in DAI, which effectively allows one to hedge his/her EOS holdings against the US dollar. The lifecycle of the contract is as follows:</p><ol><li>Anyone can deploy the BlockSigmaPut contract corresponding to a specific<a href="https://www.investopedia.com/terms/o/optionseries.asp"> option series</a>. During the deployment we specify: (1) underlying token, (2) currency token, (3) expiration date, (4) strike, (5) address of an issuer that has the right to underwire contracts in this series and (6) the minimum reserve requirement per contract. Example: EOS put expiring Jul 1st 2018 at 10 DAI strike with a minimum reserve of 2 DAI. Such a contract gives the buyer the right to sell EOS to the underwriter for 10 DAI any time before July 1st 2018. The maintenance margin requirement per contract in this case will be calculated as 2 + max(0, 10 - current EOS price).</li><li>A designated issuer underwrites a certain number of contracts by depositing the required reserve of the currency token. Continuing with the example above, if the current EOS market price is $12 the issuer will have to deposit 2 + max(0, 10 - 12) = 2 DAI in order to issue 1 option contract. Once issued, the contracts can be treated as regular ERC20 tokens and can be moved to an exchange and sold to buyers.</li><li>Once the buyer wishes to exercise the contract they need to give an allowance to transfer EOS into the option smart contract and then call the ‘exercise’ method. Once the exercise is initiated the seller has 24 hours to deliver the payment in a form of the currency token. In our example, for each EOS token, the seller has to deliver 10 DAI.</li><li>The issuer gives allowance to transfer DAI tokens from their account into the option smart contract and calls the ‘deliver’ method. Once done, the smart contract automatically settles the transaction by distributing DAI and EOS to the buyer and the seller(issuer) and returning the reserve to the seller.</li><li>(Optional) If the seller doesn’t deliver within 24 hours the buyer can call the ‘forceLiquidate’ method to receive the deposited EOS back together with the reserve to cover the seller’s default.</li></ol><p>Now let’s look at how the collateral management is done. In our example, the EOS price was at $12 at the time of option contract issuance. Let’s say now it went down to $9. The required reserve becomes 2 + max(0, 10 - 9) = 3. This means the seller needs to deposit additional 1 DAI for each contract they had underwritten. If the seller fails to do so, the buyer has an economic incentive to force the liquidation:</p><ul><li>If the buyer simply exercises the option, they receive 10 - 9 = 1 DAI payoff per contract (acquiring EOS in the market for $9 and selling it to the issuer for $10).</li><li>If, on the other hand, the buyer forces a liquidation they receive the entire reserve, which in our example is 2 DAI per contract.</li></ul><p>This motivates the buyer to force-liquidate as soon as they can as it produces an instant profit.</p><h3>Challenges</h3><p>This solution is by no means production ready. Its main purpose is to demonstrate the groundbreaking capabilities of blockchain and smart contracts in automating settlement and collateral management of option contracts. Traditionally these services are performed by an intermediary, require manual work and cost fees.</p><p>While our solution shows great promise, there are several potentially significant challenges that we see:</p><ul><li>Bancor protocol is not battle tested. It uses a deterministic price formula that converges to exchange prices via arbitrage. It is not clear how this mechanism will work in times of great volatility and/or price gaps.</li><li>The collateral management mechanism is not immune to violent price gaps. It is theoretically possible that a writer’s liability can become greater than the reserve, in which case they can be motivated to default, and the buyer will not be fully compensated. This can be mitigated by increasing the minimum reserve. Alternatively, as it’s done in traditional finance, users of such a system can contribute to a shared “insurance pool” that is used to automatically cover reserve shortfalls under extreme scenarios.</li><li>Since Bancor uses a deterministic price formula it can be manipulated in order to provide a better payoff for one party in the option contract at the expense of the other. This is feasible only if the Bancor converter reserve is low (i.e. its price sensitivity is high) relative to the size of the options position. In this case the cost of manipulating the Bancor price can be lower than the payoff from options achieved by such a manipulation. However, this problem is not specific to crypto and exists in traditional markets (e.g. burning a house to collect insurance).</li><li>Regulatory uncertainty. We haven’t done any research into the regulatory side as we have no plans to pursue this other than as a research project as of now.</li></ul><p>If you see other issues not listed here, please let us know in comments.</p><h3>Summing it up</h3><p>The described solution gives a preview into the scope of the fundamental change that blockchain will bring to finance industry in the coming years. Not only will it make settlement and collateral management more efficient, it can provide transparent, self-enforcing rules that are applied to all market participants in the same way.</p><p><em>At </em><a href="https://www.8base.com/"><em>8base</em></a><em> we’re not focusing on specific niche solutions or protocols as described in this article. We anticipate an explosion of similar disruptive technologies in the coming years as we continue to ride the wave of digital transformation. Instead, we focus on building the next layer of infrastructure that gives business users easy access to these technologies and the ability to incorporate them in enterprise software to drive business results.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa04b8d3c632" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/on-chain-derivatives-solving-500t-problem-and-getting-prize-at-consensus-2018-hackathon-fa04b8d3c632">On-chain derivatives: solving $500T problem and getting prize at Consensus 2018 Hackathon</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reduce redundancy in server app development with Serverless Chassis]]></title>
            <link>https://medium.com/@andrei.anisimov/reduce-redundancy-in-server-app-development-with-serverless-chassis-633db4f55ac9?source=rss-a8a0023996dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/633db4f55ac9</guid>
            <category><![CDATA[low-code]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Andrei Anisimov]]></dc:creator>
            <pubDate>Wed, 25 Apr 2018 16:55:50 GMT</pubDate>
            <atom:updated>2018-04-25T16:55:50.391Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yxXuMMRoFys62XwXnT3ELA.png" /></figure><p>The X-as-a-Service trend continues! In this article, I go over Serverless Chassis, a backend-as-a-service that delivers all of the computing resources and application infrastructure developers need to run and scale applications.</p><p>Recent trends in web application architecture clearly separate a monolithic application into a back-end API and a front-end single-page application. As such, building the front-end piece is significantly easier against a robust, developer-friendly, stable back-end.</p><p>AWS and other cloud providers offer a variety of infrastructure products to cover the needs of most business applications. While the infrastructure deployment can be fully automated, setting this up requires expert cloud infrastructure engineers.</p><p>These recent developments make a strong case for an application layer that sits on top of traditional cloud providers (e.g. AWS) and provides a curated preconfigured set of “best practice” infrastructure solutions. This application layer is easy to configure and hosts a production-ready, scalable API.</p><h3>The problems of 30-year-old plumbing</h3><p>Much of the problem with the current scope of building enterprise applications is that a significant amount of work goes toward common items not directly related to the business needs: setting up the execution environment (hosting), database, email gateway, authentication, role-based security, message bus, data backups, scaling schemes, and more. The list goes on and on. Setting up this “plumbing” requires a high degree of expertise and is often more complex than developing the actual business logic that solves a business problem.</p><p>Just think about the following. Currently, it possible that thousands of developers in the world are implementing user login, even though we all know it looks and works the same. Doesn’t this seem weird to you? This is an expensive, error prone, and time-consuming endeavor, not only during the initial setup but also during the ongoing maintenance.</p><p>Another big problem is security. Most engineers don’t necessarily always have deep security expertise. This can lead to weak security and data leaks. A high degree of engineer turnover in custom software shops can often lead to the inability to provide ongoing service, e.g. an engineer leaves the company and nobody knows exactly what he or she built and how. From the developer’s perspective, the job becomes boring because so much time is spent re-implementing the same things over and over again.</p><p>Next, we have emerging technologies such as Blockchain or AI. There is a shortage of developers capable of implementing complex integrations to provide regular users with access to these technologies. The technology is still so new that finding developers is not only difficult but expensive.</p><h3>Streamlining through Serverless Chassis</h3><p>One solution to these problems is the <a href="https://www.8base.com/#section-1">Serverless Chassis</a>. This backend-as-a-service delivers all of the computing resources and application infrastructure developers need to run and scale applications. Serverless Chassis is a solution that drastically reduces the complexity of developing, hosting and maintaining a back-end API.</p><p>The Serverless Chassis also integrates most of the common capabilities of modern software into a set of consumable and configurable services. Rather than create the same capabilities over and over again in each software product, <a href="https://www.8base.com/faq">8base </a>makes these available to developers in a hardened, scalable software chassis. Serverless Chassis works atop AWS, along with other cloud providers and decentralized execution networks in the future, to allow developers to quickly configure data model, role-based security, authentication and other common items.</p><p>Serverless Chassis comes with automated backups, auto-scaling, client-side subscriptions and other useful tools. Once the data model is configured, the Serverless Chassis automatically generates a CRUD (create, read, update, delete) GraphQL API, the next-generation API format developed by Facebook. It gives transparency to the API schema and makes it easier to perform complex data queries and mutations.</p><p>In addition to auto-generated CRUD API, the Serverless Chassis is fully extensible. Developers can use the command-line tool to develop custom “functions” in their favorite IDE. These functions can be exposed through the API or triggered in response to an event. For example, if users want to persist some data in the Ethereum blockchain, they can write a custom function that will be triggered every time a new object is added to the database and write its hash to Ethereum. This enables the building of back-end applications of any complexity very quickly and without spending time setting up the infrastructure. The end-product is a scalable, production-ready API.</p><h3>Private beta rollout</h3><p>We at 8base are excited to announce a rollout of the Serverless Chassis private Beta program. We’re accepting early partners that we will work closely with our core team to build solutions on top of our platform. These success stories will be documented and later publicized to showcase the usage of the product accross different solution areas.</p><p>If you are interested in becoming our early Beta partner, go to <a href="https://8base.com/">8base.com</a> and click “Join Us” in the top right and/or send me an email at andrei@8base.com.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=633db4f55ac9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Utility Token: a new value-capture mechanism]]></title>
            <link>https://medium.com/hackernoon/utility-token-a-new-value-capture-mechanism-495caef81839?source=rss-a8a0023996dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/495caef81839</guid>
            <category><![CDATA[token]]></category>
            <category><![CDATA[utility-tokens]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[value-capture-mechanism]]></category>
            <dc:creator><![CDATA[Andrei Anisimov]]></dc:creator>
            <pubDate>Sat, 07 Apr 2018 17:47:26 GMT</pubDate>
            <atom:updated>2018-04-10T15:53:25.383Z</atom:updated>
            <content:encoded><![CDATA[<p>The concept of pooling public capital to fund ambitious projects is not new. Back in the 17th century, the Dutch stock market was already quite developed. Utility tokens, on the other hand, are a totally new and untested phenomenon. The purpose of this article is to compare equity shares and utility tokens, and to explore the question:</p><blockquote>Does equity represent tokenization through bureaucracy, while utility token is an attempt to capture value closer to where it’s created?</blockquote><p>Let’s start with a quick high-level examination of how the equity market works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E0YTHtkSRdKjth9dmHNSLA.jpeg" /></figure><h3>Equities</h3><p>From an economic standpoint, equity ownership entitles one to a share of future profits and a payout if the company gets bought, plus voting. As such, equity can be valued and sold to bring in cash to finance a project. In other words, the future value can be “captured” and sold to investors.</p><p>A distinct property of equity as a tradable asset is the fact that its price tends to be a function of a company’s expected profits, as well as the value of the items on the balance sheet. We’ll examine how this process works shortly.</p><p>The equity market can be loosely described as a pipeline, with distinct segments based on the maturity of the business and whether there is a public market for the company’s equity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u7ofmqwTPq6CaO4U7waxpg.png" /><figcaption>Equity pipeline</figcaption></figure><p>Let’s focus for a moment on public equities. Usually if a company is doing great, its stock price goes up, and vice versa. Let’s examine how this link works.</p><p>The most common technique used to value financial instruments, including equities, is discounted cash flow (DCF) analysis. As a claim on the future earnings, equity value is the net present value of all future earnings.¹ If one can project the revenue and expenses to estimate earnings for each quarter in the future, they can discount the earnings back to today to arrive at the “fair” company’s market cap.²</p><p>Every quarter, companies issue an earnings report accompanied by a conference call with a presentation and a Q-and-A session. There’s a constant race for analysts to update their models to reflect all the available information. They plug in the latest reported numbers and projections into the models. The models spit out new target prices causing traders to adjust their positions accordingly, moving the market until a new equilibrium price is reached. This process ensures that over a long term, equity price tracks the company’s business performance allowing investors to capture the upside.</p><p>I believe it is fair to call this process a <strong>tokenization through bureaucracy</strong>. The future company’s earnings are tokenized and the value of the token (i.e. the share) is linked back to the business performance by virtue of a highly manual, bureaucratic process</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eiJHD-G3qa3PQH9tsmgbsQ.png" /><figcaption>Equity value capture</figcaption></figure><p>It is easy to see that such mechanism is far from perfect:</p><ul><li>Information gaps. Companies issue earnings quarterly. In between quarters, the speculation is rampant. Market manipulation and insider trading occasionally take place.³</li><li>Although there are accounting standards, such as GAAP, companies still have ways to tweak the numbers to present them more favorably. An extreme case of this was <a href="https://en.wikipedia.org/wiki/Enron_scandal">Enron</a>. More recently, <a href="http://fortune.com/2015/10/31/valeant-scandal/">Valeant</a> raised many questions.</li><li>Accounting and regulatory burden. Public companies spend millions of dollars to produce documents required by regulators such as forms 10-Q, 10-K, and audits. Occasionally, there are misstatements that need to be corrected, triggering even more expenses and information distortion.</li></ul><p>Private companies don’t have to deal with many of the items above. However, from the investor’s point of view, private equity is an illiquid asset with murky fundamentals, since there are no reporting requirements. This leads to increased risk premiums, which in turn significantly reduces valuations. Coupled with the lack of liquidity, this causes less capital to be deployed to drive innovation and growth.</p><h3>The new way</h3><p>More and more companies are getting built using peer-to-peer network models: Uber, Airbnb, Upwork, Amazon Seller Central and many others. Virtually any business, together with its value chain and customers, can be expressed as a network of participants.</p><p>Traditionally in such networks, monetization happens via a company inserted in between participants. The company provides valuable services and collects fees on activities inside the network. Investors capture value through buying equity shares in the company with returns tied to the future fees collected. For example, when Uber goes public many people will cash out big time.</p><p>Now, what if there was a way to create an asset with value directly linked to the network fundamentals in real-time, not through bureaucracy? There’s a chance blockchain already gave us one — the Utility Token.</p><p>But first, let’s define Utility Token for the purpose of this article:</p><p><strong>Utility Token is a scarce asset that serves as a gateway for cash flows that come in and out of a network.</strong></p><p>In other words, as long as the network requires all or some internal transactions to be conducted in its native token, the token can be designed in such a way as to tie its value to the growth of the network. I highly recommend research on this topic by Vitalik Buterin (<a href="https://vitalik.ca/general/2017/10/17/moe.html">On Medium-of-Exchange Token Valuations</a>) and Kyle Samani (<a href="https://multicoin.capital/2017/12/08/understanding-token-velocity/">Understanding Token Velocity</a> and <a href="https://multicoin.capital/2018/02/13/new-models-utility-tokens/">New Models For Utility Tokens</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Vm2YPNODB63a6GtqBPoTw.png" /><figcaption>Utility token value capture</figcaption></figure><p>In such a network, the token can be fully obfuscated if it affects user experience, unless there is some benefit in interacting with it. For example, holding tokens can allow users to perform work for the network and earn payouts for various actions or services. Token design is a highly creative and complex process, especially in its intersection with user experience. The process includes elements of UX, game theory and economics. We’re looking forward to seeing solutions that’ll become tokenomics primitives, such as <a href="https://medium.com/@ilovebagels/token-curated-registries-1-0-61a232f8dac7">Token Curated Registry</a>.</p><p>A comprehensive token design achieves two objectives. First, it creates a game-theoretic system in which participants are naturally motivated to perform actions that are, on average, valuable for the network as a whole. Second, it objectively ties the token price to the network’s total transaction value. This effectively solves not only its current monetization, but the future value capture (more on this below).</p><p>It’s important to note that for such a network to provide user experience not inferior to traditional centralized competitors, many complex problems need to be solved first, such as:</p><ul><li>Blockchain scaling problems — speed/cost.</li><li>Licensed, low-cost service providers that allow seamless, token-to-fiat conversion and market making. This includes <a href="https://vitalik.ca/general/2017/06/22/marketmakers.html">on-chain market makers</a> such as Bancor.</li><li>Ideally, blockchain-powered fiat money such that all conversions are fully automated and on-chain settled (e.g. atomic swaps).</li></ul><h3>Effects of forward-looking</h3><p>We never discussed the effect of projections on a utility token. After all, equity price is modeled based on not only the current, but the future earnings — the main reason why equity prices are positive even for companies currently losing money. In the utility token’s case, future projections can be modeled-in in two ways.</p><p>First, the token design itself can make the token a function of future cash flows (e.g. a “work” token that allows holders to perform work for the network, and therefore serves as a gateway to a future cash-flow stream). Second, investors in the utility token make their investment decisions based on forecasts of future growth, implicitly baking it into the current market price. However, unlike equities, where forecast updates happen infrequently, utility token models can “learn” instantly by observing the real-time network dynamics.</p><p>Taking into account the fact that historical transaction data is stored on blockchain and is available for everyone it becomes possible to train models unlike any in the equities world, where internal workings of companies are invisible and only sometimes slip through via financial reports. By observing historical token activity, as well as the token design, more accurate, real-time forecasting models can be built.</p><h3>Summarizing benefits</h3><p>This new model brings some advantages vs. the traditional equity model:</p><ul><li>The price of the token is directly linked to the network activity in real time.</li><li>The network activity itself is on the blockchain, publicly available for anyone to see. This reduces risks of information distortion, misinterpretation and market manipulation, as well as removes the information delay.</li><li>The granularity of data allows us to build and continuously train more sophisticated and accurate predictive models.</li><li>The lack of a pervasive centralized entity should lead to overall reduction in fees for participants. The access to the network for new entrants can be governed by a democratic, market-based approach vs arbitrary discretion of a central authority. Although I do believe that for a network to succeed in the early days it needs clear leadership and the ability to innovate fast.</li></ul><h3>What about costs?</h3><p>A common argument against a separate utility token for conducting payments (as opposed to using a more liquid coin such as ETH) is that the bid/ask spread on the token-to-fiat conversion represents a significant cost. This is true, especially in the early days of the network when liquidity is low and the bid/ask spread as a percentage of token price must be quite high in order to be profitable for market makers.</p><p>This cost, however, in percentage terms is a decreasing function of the transaction volume if we assume that liquidity increases as the transaction volume grows (economies of scale).⁴ Ultimately though, this comes down to total costs and benefits of operating a utility token vs equity.</p><h3>Conclusion</h3><p>It is easy to think of digital transformation as a linear process that makes something faster, cheaper, more efficient, easier-to-use, etc., while keeping core mechanics the same: mail =&gt; fax, bank =&gt; online bank, equity =&gt; security token. However, the reality is that advances in technology often bring paradigm shifts enabling totally new mechanics that were previously impossible: TV networks =&gt; YouTube, taxi =&gt; Uber, PayPal =&gt; Bitcoin.</p><p>Can Equity =&gt; Utility Token be one of them?</p><p>Footnotes:</p><p>[1] Real models usually use a better proxy for cashflows than earnings, such as “free cashflow” or other metrics. Such metrics are designed to neutralize accounting tricks that artificially inflate earnings.</p><p>[2] It’s important to note that the discount rate is not constant. It depends on the overall rates (opportunity cost) and investor’s appetite for risk. Hence we can see how during times of uncertainty investors appetite for risk goes down, they require higher rate of return on their investments, this increases the discount rate and therefore decreases the price even if no fundamentals change.</p><p>[3] I bet some people on Wall Street consider this a feature, not a bug. Entire business models are built around filling the information gaps with forecasts, ratings and recommendations. This <a href="https://medium.com/foursquare-direct/right-on-target-foursquare-accurately-predicts-iphone-sales-4140c450a396">example</a> is pretty cool.</p><p>[4] I dare to assume that it is also a decreasing function of technological and business progress.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=495caef81839" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/utility-token-a-new-value-capture-mechanism-495caef81839">Utility Token: a new value-capture mechanism</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing private blockchain tech: Hyperledger Composer]]></title>
            <link>https://medium.com/hackernoon/choosing-private-blockchain-tech-hyperledger-composer-6ed61ea0dbc1?source=rss-a8a0023996dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ed61ea0dbc1</guid>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[private-blockchain]]></category>
            <category><![CDATA[hyperledger]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[enterprise]]></category>
            <dc:creator><![CDATA[Andrei Anisimov]]></dc:creator>
            <pubDate>Sat, 10 Feb 2018 20:56:37 GMT</pubDate>
            <atom:updated>2018-06-18T18:56:23.726Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i-AljiziyuoQSy-SCtvbZg.png" /><figcaption>Hyperledger Composer architecture</figcaption></figure><p>Welcome, to part two of the “Choosing private blockchain tech” series (<a href="https://hackernoon.com/choosing-private-blockchain-tech-quorum-d33221d40b54">part1 is here</a>). In each article we implement a simple use case to give an overview of what an existing technology does and how it can be useful in businesses.</p><p>Originally, this article was meant to be about Hyperledger Fabric, but after learning about Hyperledger Composer, it became clear that it would be beneficial to write about it first. This will allow us to get a higher-level view of what type of business applications can be built on top of Hyperledger Fabric blockchain and make it easier to understand the purpose of Fabric itself.</p><h3><strong>The business use case</strong></h3><p>Let’s start with the artificially simple use case from the finance industry defined in <a href="https://hackernoon.com/choosing-private-blockchain-tech-quorum-d33221d40b54">part1</a>. Here are the parties in this scenario:</p><ul><li><strong>Non-custodial asset manager (hedge fund):</strong> makes investment decisions (trades). Non-custodial means they don’t actually hold a client’s money. Instead, after a trade is executed they send directions to a custodian that moves the money appropriately.</li><li><strong>Custodian</strong>: Usually a large and trusted finance institution that holds a client’s money and executes transfers on behalf of the hedge fund. A custodian needs to know about each trade to distribute payments to counterparties.</li><li><strong>Client(s)</strong>: Invests into the hedge fund. Each client needs to view trades in their own account, but not other clients’ accounts.</li></ul><p>Let’s see how we can use Hyperledger Composer to define all participants in this scenario and enable them to share appropriate information.</p><h3><strong>What is Hyperledger Composer?</strong></h3><p>Hyperledger Composer is a higher-level toolset and framework made to quickly build and run applications on top of Hyperledger Fabric blockchain. If Fabric is network-level, Composer is application-level. It allows us to define the data model, business logic and access control lists for an application that can be deployed and executed inside of a <a href="http://hyperledger-fabric.readthedocs.io/en/release/channels.html">Fabric channel</a>. Users of such applications don’t have to run a local node and can interact with a remote node through an RPC or HTTP REST if needed.</p><p>Composer comes with a nice <a href="https://composer-playground.mybluemix.net/">web playground</a> which allows users to prototype applications in browser without setting up a local network. We’ll use the playground to implement and test our use case. In a future article, we will export the resulting ‘business network definition’ and deploy to a real Hyperledger Fabric blockchain.</p><h3><strong>Solution</strong></h3><p>The full code of the solution can be found <a href="https://github.com/andrei-anisimov/hyperledger-composer-example">here</a>. Bellow we’ll see how to configure each piece step-by-step using the <a href="https://composer-playground.mybluemix.net/">Composer Playground</a>.</p><h4><strong>1. Create network</strong></h4><p>Select ‘Deploy a new business network’ and fill out the required info. In my case, the name of the network is ‘hedge-fund-network’ and admin card name is admin@hedge-fund-network. Select the ‘empty-business-network’ template and hit Deploy. This will create an empty business network and an admin identity that has full control over it. After the business network is created we can connect to it by pressing ‘Connect Now’.</p><h4><strong>2. Configure object model</strong></h4><p>Composer has its own object modeling language that is very straightforward and easy to use. There are 4 types of resources that can be defined:</p><ul><li><strong>Assets</strong>. Things that are being tracked in the application. In our case we track Lots — traded blocks of securities.</li><li><strong>Participants.</strong> Entities that interact with the network. Each has their own permissions.</li><li><strong>Transactions</strong> are sent to update an asset or a participant as well as to execute a custom-defined logic.</li><li><strong>Events</strong> can be emitted from the transaction logic and subscribed to by participants.</li></ul><p>Now, let’s create a model file named ‘org.acme.mynetwork.cto’ and add the following code. The file defines 3 participant types (Trader, Client, Custodian), Lot asset, Trade transaction and NewTrade event.</p><pre>/**<br> * My commodity trading network<br> */<br>namespace org.acme.mynetwork</pre><pre>asset Lot identified by lotId {<br>    o String lotId<br>    o String securityName<br>    o Double quantity<br>    o Double price<br>    --&gt; Client owner<br>}</pre><pre>participant Client identified by clientId {<br>    o String clientId<br>    o String description<br>}</pre><pre>participant Custodian identified by custodianId {<br>    o String custodianId<br>    o String description<br>}</pre><pre>participant Trader identified by traderId {<br>    o String traderId<br>    o String name<br>}</pre><pre>transaction Trade {<br>    --&gt; Trader trader<br>    --&gt; Client client<br>    --&gt; Lot lot<br>}</pre><pre>event NewTradeEvent {<br>    --&gt; Lot lot<br>}</pre><h4><strong>3. Configure transaction logic</strong></h4><p>Next, we’ll implement a custom logic that gets executed every time a Trade transaction is sent. Create a new script file called script.js with the code below. Composer knows to execute this code for each Trade transaction based on the @param annotation in the comment. This code does 2 things: changes the owner of a Lot and emits a NewTrade event on success.</p><pre>/**<br>* Track the trade<br>* <a href="http://twitter.com/param">@param</a> {org.acme.mynetwork.Trade} trade — the trade to be processed<br>* <a href="http://twitter.com/transaction">@transaction</a><br>*/<br>function tradeCommodity(trade) {<br>  var factory = getFactory();<br>  trade.lot.owner = trade.client;<br>  var result = getAssetRegistry(‘org.acme.mynetwork.Lot’)<br>  .then(function (assetRegistry) {<br>    return assetRegistry.update(trade.lot);<br>  });<br>  if (result) {<br>    var newTradeEvent = factory.newEvent(‘org.acme.mynetwork’, ‘NewTradeEvent’);<br>    newTradeEvent.lot = trade.lot;<br>    emit(newTradeEvent);<br>  }<br>  return result;<br>}</pre><h4><strong>4. Access control list (ACL)</strong></h4><p>Lastly, we need to define an access control list governing what each participant type can do and see. Here we specify that traders can execute trades, clients can view their own trades, and custodians can view all trades.</p><pre>/* Admin */</pre><pre>rule NetworkAdminUser {<br>    description: &quot;Grant business network administrators full access to user resources&quot;<br>    participant: &quot;org.hyperledger.composer.system.NetworkAdmin&quot;<br>    operation: ALL<br>    resource: &quot;**&quot;<br>    action: ALLOW<br>}</pre><pre>rule NetworkAdminSystem {<br>    description: &quot;Grant business network administrators full access to system resources&quot;<br>    participant: &quot;org.hyperledger.composer.system.NetworkAdmin&quot;<br>    operation: ALL<br>    resource: &quot;org.hyperledger.composer.system.**&quot;<br>    action: ALLOW<br>}</pre><pre>/* Common */</pre><pre>rule CommonReadTransactionRegistry {<br>    description: &quot;Allow all participants to read transaction registry&quot;<br>    participant: &quot;org.hyperledger.composer.system.Participant&quot;<br>    operation: READ<br>    resource: &quot;org.hyperledger.composer.system.TransactionRegistry&quot;<br>    action: ALLOW<br>}</pre><pre>rule CommonReadParticipantRegistry {<br>    description: &quot;Allow all participants to read participant registry&quot;<br>    participant: &quot;org.hyperledger.composer.system.Participant&quot;<br>    operation: READ<br>    resource: &quot;org.hyperledger.composer.system.ParticipantRegistry&quot;<br>    action: ALLOW<br>}</pre><pre>rule CommonReadAssetRegistry {<br>    description: &quot;Allow all participants to read asset registry&quot;<br>    participant: &quot;org.hyperledger.composer.system.Participant&quot;<br>    operation: READ<br>    resource: &quot;org.hyperledger.composer.system.AssetRegistry&quot;<br>    action: ALLOW<br>}</pre><pre>rule CommonReadNetwork {<br>    description: &quot;Allow all participants to read network&quot;<br>    participant: &quot;org.hyperledger.composer.system.Participant&quot;<br>    operation: READ<br>    resource: &quot;org.hyperledger.composer.system.Network&quot;<br>    action: ALLOW<br>}</pre><pre>/* Trader */</pre><pre>rule TraderManageClient {<br>    description: &quot;Allow traders to read all clients&quot;<br>    participant: &quot;org.acme.mynetwork.Trader&quot;<br>    operation: ALL<br>    resource: &quot;org.acme.mynetwork.Client&quot;<br>    action: ALLOW<br>}</pre><pre>rule TraderManageOwnTrades {<br>    description: &quot;Allow traders to manage their trades&quot;<br>    participant(t): &quot;org.acme.mynetwork.Trader&quot;<br>    operation: ALL<br>    resource(tt): &quot;org.acme.mynetwork.Trade&quot;<br>    condition: (tt.trader.getIdentifier() == t.getIdentifier())<br>    action: ALLOW<br>}</pre><pre>rule TraderManageLots {<br>    description: &quot;Allow traders to read and create lots&quot;<br>    participant: &quot;org.acme.mynetwork.Trader&quot;<br>    operation: READ, CREATE<br>    resource: &quot;org.acme.mynetwork.Lot&quot;<br>    action: ALLOW<br>}</pre><pre>rule TraderUpdateLots {<br>    description: &quot;Allow traders to update lots via Trade transaction&quot;<br>    participant: &quot;org.acme.mynetwork.Trader&quot;<br>    operation: UPDATE<br>    resource: &quot;org.acme.mynetwork.Lot&quot;<br>    transaction: &quot;org.acme.mynetwork.Trade&quot;<br>    action: ALLOW<br>}</pre><pre>rule TraderReadOwnTrader {<br>    description: &quot;Allow traders to read their own info&quot;<br>    participant(t): &quot;org.acme.mynetwork.Trader&quot;<br>    operation: READ<br>    resource(tt): &quot;org.acme.mynetwork.Trader&quot;<br>    condition: (tt.getIdentifier() == t.getIdentifier())<br>    action: ALLOW  <br>}</pre><pre>rule TraderAddAsset {<br>    description: &quot;Allow traders to add assets to registry&quot;<br>    participant: &quot;org.acme.mynetwork.Trader&quot;<br>    operation: CREATE<br>    resource: &quot;org.hyperledger.composer.system.AddAsset&quot;<br>    action: ALLOW  <br>}</pre><pre>rule TraderCreateHistorianRecord {<br>    description: &quot;Allow traders to create historian record&quot;<br>    participant: &quot;org.acme.mynetwork.Trader&quot;<br>    operation: CREATE<br>    resource: &quot;org.hyperledger.composer.system.HistorianRecord&quot;<br>    action: ALLOW  <br>}</pre><pre>rule TraderReadOwnHistorianRecord {<br>    description: &quot;Allow traders to read their own historian record&quot;<br>    participant(t): &quot;org.acme.mynetwork.Trader&quot;<br>    operation: READ<br>    resource(hr): &quot;org.hyperledger.composer.system.HistorianRecord&quot;<br>    condition: (hr.transactionType == &quot;org.acme.mynetwork.Trade&quot; &amp;&amp; hr.participantInvoking.getIdentifier() == t.getIdentifier())<br>    action: ALLOW<br>}</pre><pre>/* Client */</pre><pre>rule ClientReadOwnTrades {<br>    description: &quot;Allow clients to view their trades&quot;<br>    participant(c): &quot;org.acme.mynetwork.Client&quot;<br>    operation: READ<br>    resource(t): &quot;org.acme.mynetwork.Trade&quot;<br>    condition: (t.client.getIdentifier() == c.getIdentifier())<br>    action: ALLOW<br>}</pre><pre>rule ClientReadOwnEvents {<br>    description: &quot;Allow clients to subscribe to NewTrade events&quot;<br>    participant(c): &quot;org.acme.mynetwork.Client&quot;<br>    operation: READ<br>    resource(e): &quot;org.acme.mynetwork.NewTradeEvent&quot;<br>    condition: (e.lot.owner.getIdentifier() == c.getIdentifier())<br>    action: ALLOW<br>}</pre><pre>rule ClientReadOwnLots {<br>    description: &quot;Allow clients to view lots they own&quot;<br>    participant(c): &quot;org.acme.mynetwork.Client&quot;<br>    operation: READ<br>    resource(s): &quot;org.acme.mynetwork.Lot&quot;<br>    condition: (s.owner.getIdentifier() == c.getIdentifier())<br>    action: ALLOW  <br>}</pre><pre>rule ClientReadOwnClient {<br>    description: &quot;Allow clients to view their info&quot;<br>    participant(c): &quot;org.acme.mynetwork.Client&quot;<br>    operation: READ<br>    resource(cc): &quot;org.acme.mynetwork.Client&quot;<br>    condition: (cc.getIdentifier() == c.getIdentifier())<br>    action: ALLOW  <br>}</pre><pre>rule ClientReadTraders {<br>    description: &quot;Allow clients to view traders&quot;<br>    participant: &quot;org.acme.mynetwork.Client&quot;<br>    operation: READ<br>    resource: &quot;org.acme.mynetwork.Trader&quot;<br>    action: ALLOW<br>}</pre><pre>rule ClientReadHistorianRecord {<br>    description: &quot;Allow clients to view their historian records&quot;<br>    participant(c): &quot;org.acme.mynetwork.Client&quot;<br>    operation: READ<br>    resource(hr): &quot;org.hyperledger.composer.system.HistorianRecord&quot;<br>    condition: (hr.transactionType == &quot;org.acme.mynetwork.Trade&quot; &amp;&amp; hr.transactionInvoked.client.getIdentifier() == c.getIdentifier())<br>    action: ALLOW<br>}</pre><pre>/* Custodian */</pre><pre>rule CustodianReadAllTrades {<br>    description: &quot;Allow custodian to view all trades&quot;<br>    participant: &quot;org.acme.mynetwork.Custodian&quot;<br>    operation: READ<br>    resource: &quot;org.acme.mynetwork.Trade&quot;<br>    action: ALLOW<br>}</pre><pre>rule CustodianReadAllLots {<br>    description: &quot;Allow custodian to view all lots&quot;<br>    participant: &quot;org.acme.mynetwork.Custodian&quot;<br>    operation: READ<br>    resource: &quot;org.acme.mynetwork.Lot&quot;<br>    action: ALLOW<br>}</pre><pre>rule CustodianReadAllClients {<br>    description: &quot;Allow custodian to view all clients&quot;<br>    participant: &quot;org.acme.mynetwork.Custodian&quot;<br>    operation: READ<br>    resource: &quot;org.acme.mynetwork.Client&quot;<br>    action: ALLOW<br>}</pre><pre>rule CustodianReadAllEvents {<br>    description: &quot;Allow custodian to subscribe to NewTrade events&quot;<br>    participant: &quot;org.acme.mynetwork.Custodian&quot;<br>    operation: READ<br>    resource: &quot;org.acme.mynetwork.NewTradeEvent&quot;<br>    action: ALLOW<br>}</pre><pre>rule CustodianReadAllTraders {<br>    description: &quot;Allow custodian to view all traders&quot;<br>    participant: &quot;org.acme.mynetwork.Custodian&quot;<br>    operation: READ<br>    resource: &quot;org.acme.mynetwork.Trader&quot;<br>    action: ALLOW<br>}</pre><pre>rule CustodianReadOwnCustodian {<br>    description: &quot;Allow custodian to view their info&quot;<br>    participant(c): &quot;org.acme.mynetwork.Custodian&quot;<br>    operation: READ<br>    resource(cc): &quot;org.acme.mynetwork.Custodian&quot;<br>    condition: (cc.getIdentifier() == c.getIdentifier())<br>    action: ALLOW  <br>}</pre><pre>rule CustodianReadHistorianRecord {<br>    description: &quot;Allow custodian to view all trade historian records&quot;<br>    participant(t): &quot;org.acme.mynetwork.Custodian&quot;<br>    operation: READ<br>    resource(hr): &quot;org.hyperledger.composer.system.HistorianRecord&quot;<br>    condition: (hr.transactionType == &quot;org.acme.mynetwork.Trade&quot;)<br>    action: ALLOW<br>}</pre><p>After all steps are completed, we can deploy the application by clicking <strong>Update</strong> on the left.</p><h3><strong>How to test in Playground</strong></h3><p>Now that we have the complete definition of our application, we can test it using the Composer Playground Test module (click <strong>Test</strong> at the top).</p><h4><strong>1. Create participants</strong></h4><p>First, let’s seed our application with some participants. We can create 2 clients: a custodian and a trader.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GfkKLsqEqKj8xTzF." /></figure><h4><strong>2. Create identities for each participant</strong></h4><p>In order to be able to interact with the business network a participant needs an associated identity. Identities can be created in the ID registry (open the user dropdown on the top right). We’ll create an identity for each participant by specifying its name and pointing to an instance of the participant created in the previous step. At a minimum, we need 4 identities: 2 clients, 1 trader, and 1 custodian.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*APxgcxGL8FFBq9b5." /></figure><h4><strong>3. Login as Trader</strong></h4><p>We can now login using the newly created identities by clicking “Use now” next to each identity in the list. First, we login as a trader and create a new Lot that doesn’t belong to any client (client ID is null).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fe9gMlODm9P9Zvdl." /></figure><p>Then, we assign the ownership of this lot to client 1 via a Trade transaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1dMIQYEau8Q5R6VX." /></figure><p>Now, let’s create one more lot and assign it to client 2 via another Trade.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x30kPa_AjThz0v0G." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zYH2rlHvyD1kxB3W." /></figure><h4><strong>4. Login as Client</strong></h4><p>Then, we’ll login as client 1 and client 2 to check if we can see our Lots.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0x6ksvtDwo877JcH." /><figcaption>Client 1 lots</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Pgs8WFwywKVamX7R." /><figcaption>Client 2 lots</figcaption></figure><p>As you can see, each client sees only lots that they have ownership of and they are not aware of trades for other clients.</p><h4><strong>5. Login as Custodian</strong></h4><p>Let’s login as a custodian to check that we can view all trades. Indeed, both trades are visible, as you can see below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MDNockX3XeOrS3zd." /></figure><p>Custodian can also view history of all trades:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*15Zp_tUbZjv9jHtZ." /></figure><h3><strong>Note on decentralization</strong></h3><p>Keep in mind that when a transaction is broadcasted to the Hyperledger Fabric network, each configured peer is independently executing the custom transaction processing logic which ensures the correctness of the blockchain update. That’s a major architectural difference and — in many cases — an advantage over the traditional centralized, client-server approach. In the traditional approach a single organization would be responsible for managing the data and exposing it to other participants, forcing others to trust it and making it a potential single point of failure.</p><p>In the blockchain approach, each peer is responsible for managing and reconciling their own copy of the data. This makes the entire network more resilient and decentralized. However, it is not completely simple to configure. There are additional privacy implications to consider since the data is now hosted in many places which creates a potentially larger threat surface.</p><h3><strong>Conclusion</strong></h3><p>Hopefully this has given you a better understanding of what Hyperledger Composer is and how it can be useful in sharing information and keeping track of assets and other concepts among multiple participants. Feel free to export the .bna file of your network and follow the tutorial <a href="https://hyperledger.github.io/composer/tutorials/developer-tutorial">here</a> to deploy the application to a local Hyperledger Fabric network. We’d love to hear your thoughts on Hyperledger Composer. Please, leave any questions or comments below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ed61ea0dbc1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/choosing-private-blockchain-tech-hyperledger-composer-6ed61ea0dbc1">Choosing private blockchain tech: Hyperledger Composer</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing private blockchain tech: Quorum]]></title>
            <link>https://medium.com/hackernoon/choosing-private-blockchain-tech-quorum-d33221d40b54?source=rss-a8a0023996dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/d33221d40b54</guid>
            <category><![CDATA[private-blockchain-tech]]></category>
            <category><![CDATA[consortium]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[private-blockchain]]></category>
            <category><![CDATA[quorum]]></category>
            <dc:creator><![CDATA[Andrei Anisimov]]></dc:creator>
            <pubDate>Fri, 01 Dec 2017 18:24:01 GMT</pubDate>
            <atom:updated>2018-06-18T18:57:10.172Z</atom:updated>
            <content:encoded><![CDATA[<p>More and more companies have become interested in blockchain technology. The promise of this technology is big: increased transparency, reduced dependence on intermediaries, reduced fraud and many others. There are a multitude of articles on the future of blockchain; however, they tend to be too abstract. In my view, there is not enough down-to-earth, specific use cases with concrete implementation examples. After all, when we choose a database technology, for example, all we really care about is how it can improve our business, not how it could disrupt the entire fabric of society.</p><p>In the following series of articles, I will look at different blockchain products in the context of a single use case. The use case assumes implementation of a private blockchain by a group of organizations to store and share data.</p><p>Private blockchains are not nearly as immutable and trustless as public ones (e.g. Bitcoin and Ethereum). However, this doesn’t mean there are no benefits to running a private blockchain, because sharing and replication of data is a common need in an enterprise setting. So here we’ll explore some of the most popular solutions enabling this and their benefits and drawbacks. But first, we’ll start with a look at our use case.</p><h3>Use case</h3><p>For the sake of ease and clarity, let’s consider an oversimplified version of a real life scenario from the finance industry. Once this simple use case is understood it is easy to extrapolate it to more complex scenarios.</p><p>Here are the parties in this scenario:</p><ul><li><strong>Non-custodial asset manager </strong>(<strong>hedge fund</strong>) makes investment decisions (trades). Non-custodial means they don’t actually hold a client’s money. Instead, after a trade is executed they send directions to a custodian that moves the money appropriately.</li><li><strong>Custodian</strong>. Usually a large and trusted finance institution that holds a client’s money and executes transfers on behalf of the hedge fund. Custodian needs to know about each trade to distribute payments to counterparties.</li><li><strong>Client(s)</strong>. Invests into the hedge fund. Each client needs to view trades in their own account, but not other clients’ accounts.</li></ul><p>It’s easy to see how there is a need to share transaction data among these 3 parties. We intentionally don’t consider moving actual money using the blockchain, since this is a well known use case. Instead, we’ll focus on a simple use case of transmitting data objects with the following fields:</p><ul><li>TradeID</li><li>Trade Timestamp</li><li>Trader Name</li><li>Trade Size</li><li>Trade Price</li><li>Counterparty Name</li><li>ClientID</li><li>Other metadata can be added as well, including other fields specific to that trade type, e.g. option expiration date, etc.</li></ul><h3>Requirements</h3><p>There are several requirements to this information flow:</p><ol><li><strong>Deliverability</strong>: Each trade, without exception, should be reported to the custodian. Non-delivery of instructions to the custodian can trigger serious adverse consequences (e.g. a default on a trade).</li><li><strong>Validity</strong>: It is important that only valid information is delivered to the custodian.</li><li><strong>Immutability</strong>: The log of trades should be preserved at all times and never altered.</li><li><strong>Security</strong>: Only authorized parties should be able to view and send trade data.</li></ol><p>In the following series we’ll explore how different blockchain technologies allow for implementation of this scenario and whether or not there are any advantages over traditional approaches. However, to have something to compare against, let’s first look at some of the conventional approaches to solve this.</p><h3>Conventional approach</h3><p>Currently, such a scenario could be implemented in many different ways. Here is a non-exhaustive list of solutions from simplest to more sophisticated:</p><ul><li>The hedge fund could manually send trade info in an email. An employee of the custodian then reads these emails and inputs the data into the custodian’s database.</li><li>The hedge fund uploads a file with trades to the custodian’s secure FTP where it gets picked up by a script which then imports them into the database.</li><li>The hedge fund executes the custodian’s secure API call to submit trade data.</li></ul><h3>Blockchain approach</h3><p>Since blockchain is essentially a distributed ledger with the inherent ability to sync data among nodes, at first glance it makes sense to use it for this use case. In short, it looks like this: each party runs a local blockchain node (an application running in the background) that is synced with other nodes and is able to send and/or receive trade data in near real-time. Such a setup is called a “private blockchain”, since this network is run by a limited number of entities that have exclusive access to it.</p><p>In the first part of the series we’ll look at Quorum, a blockchain solution developed by JP Morgan. In the future articles we’ll look at Hyperledger Fabric, BigchainDB, Tendermint and others.</p><h3>Quorum</h3><p>Quorum is a fork of Ethereum code base that adds a different consensus protocol, encrypted storage and permissioned access to a standard set of Ethereum features, such as distributed ledger and Smart Contracts. In addition, it provides Constellation protocol to exchange encrypted messages. Why not just use private Ethereum chain? For this purpose, Ethereum has 2 major drawbacks: a) anyone can connect to the network; b) all data inside smart contracts is visible to all nodes. Quorum solves these, albeit at a cost of moving some data transfer and storage off-chain.</p><p>You can find implementation details in Quorum’s <a href="https://github.com/jpmorganchase/quorum/wiki">wiki</a>. In short, the private transactions work as follows: each node has both a public and a private key. When party A sends a private transaction to party B it goes through these steps (I omit some implementation details for the sake of simplicity):</p><ol><li>Generate a new symmetric key and encrypt the transaction using this key.</li><li>Generate SHA3–512 hash from the encrypted transaction.</li><li>Encrypt the symmetric key from (1) using party B’s public key.</li><li>Transmit the hash from (2) on-chain, then transmit the transaction and the symmetric key (both encrypted) to party B off-chain.</li><li>Party B decrypts the symmetric key using party B’s private key then generates a hash of the encrypted transaction, confirms that it matches the on-chain hash — to make sure that transaction data is correct.</li><li>Party B fully decrypts the transaction using the symmetric key from (5).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8u975H_KNrz81VdWNoUboA.png" /><figcaption>Private transactions in Quorum</figcaption></figure><p>The reason why we can’t store the full transaction on-chain is because, by definition, each node has an exact copy of the blockchain. Therefore, if we store it on-chain it will be visible to everyone. The workaround is storing only the hash on-chain and the rest off-chain. Hash doesn’t allow us to reconstruct the transaction data; however, it allows us to validate that transaction data is correct (if data is changed — its hash will be different and will not match the on-chain hash). This is how we get immutability and privacy at the same time.</p><h3>Implementation</h3><p>Full example code can be seen in the <a href="https://github.com/andrei-anisimov/quorum-example">github repo</a>. The solution is quite simple and has the following components: Smart Contract, Private Transactions and New Trade Notifications. Let’s look at each of them.</p><h4>Smart Contract</h4><p>Smart Contracts is a feature of Ethereum that allows you to publish a program on blockchain. You can then execute its code by issuing a transaction. A smart contract can store data “inside of itself” and have a logic determining who can modify and view its data along with other functions. When nodes receive a transaction referencing a smart contract’s method they execute it and record data changes, if any, in the blockchain.</p><p>Below is the shortened version of the TradeData smart contract code. The contract has the following features:</p><ul><li>Ability to add a new trade using the <em>addTrade</em> method. Only the owner of the contract, in our case the Hedge Fund, is allowed to add new trades.</li><li>Ability to retrieve Trade object by ID.</li><li>Ability to receive a notification when a new trade is added.</li></ul><pre>contract TradeData is mortal {</pre><pre>struct Trade {<br>    string internalTradeID;<br>    uint utcTimestamp;<br>    string traderName;<br>    int sizeBig;<br>    uint priceBig;<br>    string counterparty;<br>    string client;<br>  }</pre><pre>event NewTradeEvent(uint tradeID);</pre><pre>function addTrade(string internalTradeID, uint utcTimestamp, string traderName, int sizeBig, uint priceBig, string counterparty, string client) public returns(uint) {...}</pre><pre>function getTradeByID(uint tradeID) public constant returns  (string, uint, string, int, uint, string, string) {...}</pre><pre>function getLastTradeID() public constant returns (uint retVal) {...}</pre><pre>}</pre><p>(you can view complete contract code <a href="https://github.com/8base/quorum-example/blob/master/contracts/TradeData.sol">here</a>)</p><h4>Private Transactions</h4><p>As discussed earlier, unlike the pure Ethereum implementation, Quorum allows users to send private transactions. This includes transactions that modify a contract’s state. This is done by adding <em>privateFor: [“RECEPIENT_PUBLIC_KEY”]</em> parameter to the transaction payload. A state that is added via a private transaction is only visible to parties specified in <em>privateFor</em>. This makes it easy to share trades with just one client and not all clients.</p><h4>New trade event</h4><p>Nodes can subscribe to be notified as soon as new trades appear in the blockchain. A node only receives a notification if it is allowed to view the corresponding trade. That’s how the custodian can monitor when a new trade comes in and can process it.</p><h3>Conclusion</h3><p>Although Quorum doesn’t appear to be fully production-ready at the time of writing, its architecture is quite simple and makes sense. Being based on Ethereum, it inherits all its nice features such as smart contracts, Solidity contract language, wide developer adoption, and easy-to-use JavaScript API.</p><p>Given that it is a free open-source technology, it is easy to see how in the future it could become a compelling alternative to traditional proprietary data sharing solutions. Such solutions can often be expensive, error prone, hard to maintain and scale. An open-source standard implementation would facilitate data sharing among companies without the need for multiple custom integrations.</p><p>Now that we’ve displayed a real-life application of private blockchain technology, we’ll take the same use case and look at HyperLedger Fabric implementation in the next article. Comments, questions or suggestions? Feedback is welcome and appreciated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d33221d40b54" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/choosing-private-blockchain-tech-quorum-d33221d40b54">Choosing private blockchain tech: Quorum</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>