<?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 Olaf Tomalka on Medium]]></title>
        <description><![CDATA[Stories by Olaf Tomalka on Medium]]></description>
        <link>https://medium.com/@ritave?source=rss-e8ead5f8ec6a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hE-Gyv9kuvrif1nhNkhWHg.png</url>
            <title>Stories by Olaf Tomalka on Medium</title>
            <link>https://medium.com/@ritave?source=rss-e8ead5f8ec6a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 06:27:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ritave/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[Quick Byte: Easy Sharing of Custom TypeScript @types Across Monorepo Packages]]></title>
            <link>https://medium.com/join-civil/quick-byte-easy-sharing-of-custom-typescript-types-across-monorepo-packages-8e252eb24968?source=rss-e8ead5f8ec6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e252eb24968</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[civil-developer-news]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Olaf Tomalka]]></dc:creator>
            <pubDate>Fri, 29 Jun 2018 16:25:22 GMT</pubDate>
            <atom:updated>2018-10-16T22:06:03.023Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xAFAiAxqZVrOVLBTo9tf6w.jpeg" /><figcaption>Photo courtesy of Émile Perron</figcaption></figure><p>At <a href="http://civil.co/">Civil</a>, transparency is as important for the the developers who are interested in our <a href="https://github.com/joincivil/Civil">code</a> as it is for the journalists who publish on our platform. As we began working with the Ethereum DApps stack, we decided to implement a monorepo in to deploy parts of our codebase independently, while standardizing linting, tests, and coverage. This has increased productivity across the entire Civil development team.</p><p>This has resulted in Civil’s developer team being able to reuse code patterns, such as internal packages and public NPM packages that are used by multiple other projects. However, we have realized that even with the monorepo structure, the TypeScript typings are extremely cumbersome, because each package requires a manual edit of each tsconfig.json file.</p><p>Many packages in the Ethereum ecosystem are written in pure JavaScript and don’t have any typings in the first place, and quite a few of those packages, such as web3, have broken typings. For us, this meant that we had to create our own typings for multiple external dependencies, such as web3, ethereumjs-abi and ethereumjs-util. This was particularly problematic because we were at a stage in which speed and iteration were of utmost importance. DefinitelyTyped and working directly with open-source projects to get pull requests would be great long-term solutions, but they were too slow and we didn’t account for those developers who had no interest in supporting TypeScript.</p><p>Our first solution was to have a <em>.d.ts</em> file with common definitions being copied to packages or manually sourced in every <em>tsconfig.json</em> file. However, this meant that we ended up with a lot of duplication and hard-to-maintain configuration files. After more than 3 packages in our monorepo that solution also stopped being viable.</p><p>Fortunately, TypeScript has an option to override the <a href="http://twitter.com/types">@types</a> folder in its configuration, which works perfectly with the monorepo pattern.</p><p>Each of our packages has its own <em>tsconfig.json</em>, which extends the repository’s root <em>tsconfig.json</em>. The top-most one has all the basics as well as overridden <em>typesRoots</em> location. <em>typeRoots</em> takes an array of folders and searches them for package names on the first-come-first served basis. By setting our own typings first, we could handle broken packages with outdated or unfinished typings.</p><p>Example project structure:</p><pre>.<br>├ tsconfig.json<br>│ (“typeRoots”: [“packages/typescript-typings/types”, “node_modules/@types”])<br>└ packages<br>  ├ typescript-typings<br>  │ └ types<br>  ├ web3<br>  │ ├ ethjs-util<br>  │ └ …<br>  ├ package_1<br>  │ └ tsconfig.json<br>  │   (“extends”: “../../tsconfig”)<br>  ├ package_2<br>  │ └ tsconfig.json<br>  │   (“extends”: “../../tsconfig”)<br>  └ …</pre><p>Civil is creating an open-source project to support sustainable journalism. We’re working to make a better onramp for developers who want to start building on web3 infrastructure. Visit <a href="https://github.com/joincivil/Civil/tree/master/packages/typescript-typings">Civil’s GitHub</a> to learn more, and check out the open issues if you want to contribute.</p><p>Or, if you want to reach out to me with additional feedback, email me <a href="/service/mailto:olaf@civil.co">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e252eb24968" width="1" height="1" alt=""><hr><p><a href="https://medium.com/join-civil/quick-byte-easy-sharing-of-custom-typescript-types-across-monorepo-packages-8e252eb24968">Quick Byte: Easy Sharing of Custom TypeScript @types Across Monorepo Packages</a> was originally published in <a href="https://medium.com/join-civil">Civil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Applying Ethereum Smart Contracts to Journalism: a Technical How To (video)]]></title>
            <link>https://medium.com/join-civil/applying-ethereum-smart-contracts-to-journalism-a-technical-how-to-video-f92a195ef13d?source=rss-e8ead5f8ec6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f92a195ef13d</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[journalism]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Olaf Tomalka]]></dc:creator>
            <pubDate>Wed, 24 Jan 2018 16:41:18 GMT</pubDate>
            <atom:updated>2018-10-16T21:49:16.399Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FmmjcDBSObws%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DmmjcDBSObws&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FmmjcDBSObws%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba13111a04f4761051d1d98aa621ebb8/href">https://medium.com/media/ba13111a04f4761051d1d98aa621ebb8/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UWkL4QRmHnvLiIoXPoU2qA.jpeg" /><figcaption>Image courtesy of Ilya Pavlov</figcaption></figure><p>I lead a regular Ethereum developer meet up in Warsaw. Civil co-sponsored our most recent event, and I had the opportunity to speak about how we’re applying a smart contract model to journalism. If you’re an engineer curious about how Ethereum can be uniquely applied to journalism (or just generally curious, and have an affinity for Javascript!), take a look at the above video and feel <a href="/service/mailto:olaf@joincivil.com">free reach out to me</a> with any questions or comments. <br> <br> As I mention in the video, Civil is hiring! We’re looking for front end engineers, back end engineers and smart contract engineers. Think you’re a good fit? <a href="/service/mailto:dan@joincivil.com">Reach out to our head of engineering, Dan</a>. He’ll take care of you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f92a195ef13d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/join-civil/applying-ethereum-smart-contracts-to-journalism-a-technical-how-to-video-f92a195ef13d">Applying Ethereum Smart Contracts to Journalism: a Technical How To (video)</a> was originally published in <a href="https://medium.com/join-civil">Civil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with Getline.ts]]></title>
            <link>https://medium.com/getline-in/getting-started-with-getline-ts-ded8a957d1eb?source=rss-e8ead5f8ec6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ded8a957d1eb</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ico]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[p2p-lending]]></category>
            <category><![CDATA[fintech]]></category>
            <dc:creator><![CDATA[Olaf Tomalka]]></dc:creator>
            <pubDate>Wed, 22 Nov 2017 04:32:44 GMT</pubDate>
            <atom:updated>2017-11-22T04:32:44.802Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*2gFcSS8G4JpWy2OOlUJDwg.png" /></figure><p>The <a href="https://medium.com/getline-in/getline-whitepaper-article-series-introduction-aim-our-idea-f16ba9b676f5">Getline Network</a> and decentralized lending is a huge undertaking that we aim to improve over the next few years. Our first step to the huge vision written down in our <a href="https://landing.getline.in/whitepaper.pdf">whitepaper</a> was to release a Typescript library called <a href="https://github.com/Getline-Network/getline/tree/master/getline.ts">getline.ts</a>. With it you can create your own applications interfacing directly with the decentralized Getline Network, without fighting with all the details such as managing web3.js, versioning smart contracts, hard coding ABIs, etc.</p><p>With the first iteration of the library you can now easily:</p><ul><li>Access the latest Smart Contract version and it’s ABI without hardcoding</li><li>Get the cached off-chain metadata about a specific loan such as it’s description</li><li>Deploy and read loans straight to and from the Ethereum blockchain</li></ul><p>Here’s <a href="https://github.com/Getline-Network/getline/blob/master/getline.ts/src/example.ts">an example</a> showing the basic functionality, and <a href="https://getline-network.github.io/getline/getline.ts/doc/">documentation right here</a> if you want to get your hands dirty right away.</p><blockquote><em>My goal with this post is to expand on the example, explain the architecture of how the whole current ecosystem works together, and allow you to make your first application working with the Getline Network.</em></blockquote><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*xfAjdkMComTTesAwhQXGIQ.png" /></figure><p>Compared to many other decentralized ecosystems on Ethereum, the Getline Network, doesn’t really have a central Smart Contract. This means you’ll be deploying a new contract for each loan — to avoid bugs and hackers you’ll want to always have the newest version with latest patches and security. For making the developers’ job easier we’re providing a so-called metabackend service as well as it’s public endpoint — <a href="http://0.api.getline.in/">0.api.getline.in</a>. The metabackend serves the latest ABIs and Loan-Smart-Contract bytecode, additionally it holds cached meta-data about the loans themselves for a way to find loans without scraping the whole blockhain. Data such as the loan description and it’s address. It communicates using <a href="https://github.com/google/protobuf">protobufs</a> and <a href="https://github.com/improbable-eng/grpc-web">gRPCWeb</a>. We’re providing the endpoint for you convenience, but there’s nothing stopping you from deploying your own metabackend in your own controlled environment.</p><p><a href="https://github.com/Getline-Network/getline/tree/master/getline.ts">Getline.ts</a> abstracts most of the metabackend functionality, <a href="https://github.com/Getline-Network/getline/tree/master/getline.ts">requiring only it’s endpoint to be provided during initialization</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/484f03a771690f3d14483b464722acdc/href">https://medium.com/media/484f03a771690f3d14483b464722acdc/href</a></iframe><p>After getting the data from the metabackend, Getline.ts works directly with the Ethereum node provided by the user, through means of Web3. It deploys and talks directly with the loans already existing on the blockchain.</p><p>Both of those services are abstracted so that you, the user of <a href="https://github.com/Getline-Network/getline/tree/master/getline.ts">Getline.ts</a>, can think and work with only abstract loan objects and promises, without the need of working with the services themselves.</p><h3>Loan object</h3><p>Loans themselves work on <a href="https://theethereum.wiki/w/index.php/ERC20_Token_Standard">ERC20 Tokens</a>. To work they need two tokens, one is collateral which the borrower leaves on the table for the investors to take should they fail to repay the loan, and then there’s the lent token itself. This enables mix and match of what both the borrower and the loaner want to do, for example: the loaner might have long-term options in a startup, but needs a short-term money loan, so he requests Euro Stable Coin and in return freezes his options in the startup. Additional features of the network such as a community of credit scoring and regulatory entities will require the use of GET tokens as collateral in the future, but for the basic functionality, such as a direct 1 to 1 loan, any token can work.</p><p>All the money and logic of the loan itself are handled in the blockchain, so that you can trust that (except for the bugs), no one can cheat either party out of the agreed-on contract. Additional information, such as a long description are held outside of the blockchain (preferably in the metabackend) to save on fees.</p><h4>Repayment</h4><p>Currently the loans are an all-or-nothing scenario. We’ve been experimenting with credit lines in the past (GetLine, get it?), but we’ve reached a conclusion that there’s a bigger need for simplified loans with a simple repayment option. This means that the borrower needs to repay the loan in full before the default date, otherwise the loan is marked as failed and the collateral is lost.</p><h4><strong>Deadlines</strong></h4><p>Currently the loans on the blockchain estimate fundraising and default dates by counting elapsed blocks in the blockchain, we’re currently moving into time-stamps, and so we’ve abstracted any block counting in the getline.ts itself, and decided to work with dates instead, converting into an estimated number of blocks internally for the time being. Just keep in mind the deadline might float a bit from what you expected until we change the deadline methods.</p><h4>API</h4><p>Whole <a href="https://github.com/Getline-Network/getline/tree/master/getline.ts">Getline.ts</a> APIs are Promise-based. We’re using native Promises of Typescript and ES6 so if your environment doesn’t support them, you’ll need to polyfill them back in.</p><p>We’re strong advocates of async and await coding style, and that’s what we’re using in most situations, both internally and in our examples.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34c9dee238811b57b2df16a979ae50b1/href">https://medium.com/media/34c9dee238811b57b2df16a979ae50b1/href</a></iframe><h4>Creating a new loan</h4><p>Currently we’re in a demo phase, meaning we’re explicitly not allowing you to use any other tokens and network from the infinite-supply of Test tokens and the Rinkeby network. This is for your own safety as the code might still be unstable and the tokens might be lost in the process.</p><p>Getting a new loan is very simple. You need to specify it’s description, how much tokens you want to borrow, on what kind of percentage, and how long will you be waiting for investors, and how long will they be waiting for you to pay the loan back. Additionally there is a second step in the process, transferring collateral requires setting allowance on the token itself and then notifying the loan, and since those are two additional transactions in the blockchain, we’ve decided to explicitly make it a second operation in code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09f1a1f8e6e81c7e7b102f1619468f39/href">https://medium.com/media/09f1a1f8e6e81c7e7b102f1619468f39/href</a></iframe><h4>Getting user loans</h4><p>Now, we’ve created the loan, we would like to get a list of all the loans of a user. Since each loan is a separate contract, it’s hard to find the list without scrapping the blockchain, so we hold that data in the metabackend for easy access.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ac1dd9b2b63b4f952e17e4e28446ec5/href">https://medium.com/media/9ac1dd9b2b63b4f952e17e4e28446ec5/href</a></iframe><p>As you can see <a href="https://getline-network.github.io/getline/getline.ts/doc/classes/_loan_.loan.html">in the documentation</a>, the loan object has multiple properties allowing you to understand the state of the loan. If the object is newly created, accessing any of the properties will reload the state from the blockchain, taking some time, and afterwards, each access to the property will be instant due to caching in the client side. If you want to separate the loading or need to reload for UX reasons or due to other external events, we’re providing you with an explicit updateStateFromBlockchain() call that reloads the cache.</p><h3>Future</h3><p>Currently the API is usable, but it’s not stable yet — we will be changing it for better usability in the near future. Additionally we’re also working on a small front-end for the library, allowing any user to click-through their own loans without the need to understand development. The front-end works as our test-bed for <a href="https://github.com/Getline-Network/getline/tree/master/getline.ts">getline.ts</a>, allowing us to pinpoint major things that require improvements.</p><h4>Getting involved</h4><p>We’ll be happy to get to know you, understand your use case, and help you with any development work you’re doing in the Getline Network. You can reach the dev team in three ways:</p><ul><li>Talk with us in the <a href="https://rocket.getline.in/channel/dev">Getline’s RocketChat</a> in the #dev channel. I can be found there as @ritave</li><li>Report any issues and suggestions you might have in the main repository on <a href="https://github.com/Getline-Network/getline/issues">Github</a></li><li>For more business related inquires, we’re also monitoring the <a href="/service/mailto:hello@getline.in">hello@getline.in</a> e-mail account. Development inquires sent there will take longer than any other channel though.</li></ul><blockquote>If you enjoy our articles, please like and follow us on <a href="https://www.facebook.com/GetlineNetwork/">Facebook </a>and <a href="https://twitter.com/getlinein">Twitter</a>. <br>Also, join our <a href="https://rocket.getline.in/">Rocket chat </a>if you’re interested in contributing to our platform.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ded8a957d1eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/getline-in/getting-started-with-getline-ts-ded8a957d1eb">Getting started with Getline.ts</a> was originally published in <a href="https://medium.com/getline-in">Getline.in</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with your Boson app]]></title>
            <link>https://medium.com/boson-me/getting-started-with-your-boson-app-185f87aa0095?source=rss-e8ead5f8ec6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/185f87aa0095</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[social-network]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[identity]]></category>
            <dc:creator><![CDATA[Olaf Tomalka]]></dc:creator>
            <pubDate>Thu, 26 Oct 2017 16:07:41 GMT</pubDate>
            <atom:updated>2017-10-26T19:46:10.955Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5SBPWwkx6m_jWsT0VB6r6w.png" /></figure><p>The aim of this tutorial is to allow you to start verifying the identity of your users using OAuth2 APIs <strong>fast</strong>.</p><h4>What is Boson?</h4><p>Boson is a storage of verified identity claims for it’s users. For example, a user may claim that they own a specific Facebook account and they are a citizen of Poland, or link their Ethereum address to their social account. We take those claims and verify their truthfulness to the best of our abilities, while at the same time providing easy APIs to external businesses and applications (meaning <strong>you</strong>) to know and require status of specific claims, so you can decrease the fraud and satisfy legal requirements such as Know-Your-Customer and Anti-Money-Launder legislations without the need to manually and costly verify users on your side.</p><h4>1. Create application definition</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*_xYIktm1NkE1GXPVGojysw.png" /><figcaption>Example filling of your company registration information</figcaption></figure><p>After <a href="https://app.boson.me/register">creating an account on Boson</a> go into <a href="https://app.boson.me/user/settings">settings</a> and into <a href="https://app.boson.me/oauth2/app">API access</a>. Since you’ll be working with sensitive user data and so we need more details about you/your company, please fill them out and afterwards create a new OAuth app.</p><ul><li>The name, description and homepage will be visible to users when they use your application</li><li>After you ask your user to verify their data using Boson they will be redirected back to you using the Redirect URIs</li><li>Scopes are data that you request to get from the system. User will explicitly be told what data you want and will have to confirm their decision</li></ul><p>For this example, we want to connect user’s telephone number to their social profile — Facebook. Let’s choose require:phone and require:facebook scopes and press <em>create</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*UZtwSAvTKUriiok81Qxl4A.png" /></figure><p>Your <em>Client ID</em> and <em>Client Secret</em> will be needed in your code, keep the tab open.</p><h4>2. Create minimal website</h4><p>We’ll be using <a href="https://nodejs.org/en/">NodeJS</a> + <a href="https://expressjs.com/">Express</a> for the website routing + <a href="http://lelylan.github.io/simple-oauth2/">simple-oauth2</a> library for connection with Boson. OAuth is a protocol working on HTTP and thus independent on the programming language, similar OAuth2 libraries exist in your language too.</p><p>Let’s think of the user flow we want to have:</p><ol><li>User enters your website, sees a link asking them to verify</li><li>When clicked, user is redirected to Boson’s website asking him to verify/confirm status that phone/Facebook are verified</li><li>User is redirected back to your website, data is saved into a session, user is redirected back to starting page</li><li>Now their status is always shown until the user deletes session cookies</li></ol><p>Your website needs 2 routes, GET method is enough.</p><ul><li>/_oauth2/boson — This is the redirect URI you entered on Boson.me, if you change it, you need to do so in both places</li><li>/ — The main route, this what will greet the user when he enters your website</li></ul><p>Let’s create the routes</p><pre>const express = require(&#39;express&#39;)</pre><pre>const app = express()</pre><pre>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.send(&quot;Main page&quot;)<br>});</pre><pre>app.get(&#39;/_oauth2/boson&#39;, (req, res) =&gt; {<br>  res.redirect(&#39;/&#39;)<br>  res.end()<br>});</pre><p><strong>3. Add OAuth2 authorization</strong></p><p>Now we’re going to add simple-oauth2 into the mix. OAuth endpoints can vary between server implementations, that’s why our’s can be <a href="http://boson.me/apidraft">found in the documentation</a>.</p><p>They are:</p><ul><li>https://app.boson.me/oauth2/authorize — where the user is redirected after starting the login process</li><li>https://app.boson.me/oauth2/token — which is called <strong>your server-side</strong> after getting a login code in the callback from the authorized user</li></ul><p>A more thorough, but still understandable explanation of OAuth2 <a href="https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2">can be found here</a>.</p><pre>...<br>const host = &#39;https://app.boson.me/&#39;</pre><pre>const oauth2 = require(&#39;simple-oauth2&#39;).create({<br>  client: {<br>    id: &#39;&lt;YOUR APP ID&gt;&#39;,<br>    secret: &#39;&lt;YOUR SECRET ID&gt;&#39;<br>  },<br>  auth: {<br>    tokenPath: &#39;/oauth2/token&#39;,<br>    authorizePath: &#39;/oauth2/authorize&#39;,<br>    tokenHost: host,<br>  }<br>});</pre><pre>const authorizationUri = oauth2.authorizationCode.authorizeURL({<br>  redirect_uri: &#39;https://&lt;YOUR WEBSITE&gt;/_oauth2/boson&#39;,<br>  scope: &#39;require:facebook require:phone&#39;<br>})</pre><pre>...</pre><pre>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  return res.send(&#39;&lt;a href=&quot;&#39; + authorizationUri + &#39;&quot;&gt;Verify!&lt;/a&gt;&#39;)<br>})</pre><p>Now after the user authorizes, and the callback gets called, let’s get the user’s status and save it in Express-Session so we can reload it whenever we want</p><pre>...<br>const session = require(&#39;express-session&#39;)<br>const request = require(&#39;request&#39;)<br>...<br>const app = express()<br>app.use(session({<br>  secret: &#39;this should be a better secret&#39;,<br>  resave: false,<br>  saveUninitialized: true<br>}))<br>...<br>app.get(&#39;/_oauth2/boson&#39;, (req, res) =&gt; {<br>  oauth2.authorizationCode.getToken(<br>    {code: req.query.code},<br>    (err, result} =&gt; {<br>      if (err) {<br>        console.log(&#39;getToken err: &#39;, err.message)<br>        return res.json(&#39;Authentication failed&#39;)<br>      }<br>      request(<br>        host: host + &#39;/api/v1/user/me&#39;,<br>        { headers: {<br>            Authorization: `Bearer ${result.access_token}`<br>        }},<br>        (err, response, body) =&gt; {<br>          if (err) {<br>            console.log(&#39;user/me err: &#39;, err.message)<br>            return res.json(&#39;Getting data failed&#39;)<br>          }<br>          req.session.me_data = body<br>          res.redirect(&#39;/&#39;)<br>          return res.end()<br>        }<br>      )<br>    }<br>  )<br>})</pre><p>As you can see we’re doing two server-side GET requests to Boson in the callback, first to get the token for the user, and second to get the user’s data and save it into their’s session.</p><p>The cherry on top is displaying that data to the user:</p><pre>...<br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  if (req.session.me_data) {<br>    res.write(&#39;Your data:&#39;)<br>    res.write(JSON.stringify(req.session.me_data))<br>    return res.end()<br>  } else {<br>    return res.send(&#39;&lt;a href=&quot;&#39; + authorizationUri + &#39;&quot;&gt;Verify!&lt;/a&gt;&#39;)<br>  }<br>})<br>...</pre><p>And voila, your app is now getting useful data from Boson</p><ul><li>You can find more examples on our <a href="https://github.com/Boson-Identities/app-examples/">Github repo</a></li><li>And read <a href="https://app.boson.me/apidraft/">the documentation</a></li></ul><blockquote>Now go ahead and <a href="https://app.boson.me/oauth2/app">create your own app</a>!</blockquote><p><em>If you have any additional questions, go ahead and e-mail </em><a href="/service/mailto:hello@boson.me"><em>hello@boson.me</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=185f87aa0095" width="1" height="1" alt=""><hr><p><a href="https://medium.com/boson-me/getting-started-with-your-boson-app-185f87aa0095">Getting started with your Boson app</a> was originally published in <a href="https://medium.com/boson-me">Boson.me</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Case Study: Ethereum Dapp & More For Crowdfunded Loans]]></title>
            <link>https://medium.com/getline-in/case-study-ethereum-dapp-more-for-crowdfunded-loans-shortened-from-original-b2a74a8d6b30?source=rss-e8ead5f8ec6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2a74a8d6b30</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[loans]]></category>
            <category><![CDATA[p2p-lending]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[fintech]]></category>
            <dc:creator><![CDATA[Olaf Tomalka]]></dc:creator>
            <pubDate>Thu, 12 Oct 2017 13:50:12 GMT</pubDate>
            <atom:updated>2017-10-12T16:57:54.465Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Case Study: Ethereum Dapp &amp; More For Crowdfunded Loans (Shortened From Original)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*r7YBxpz6oI1tKftzPnJc9Q.png" /></figure><p><strong><em>See original extended article </em></strong><a href="https://medium.com/tomalka-me/ethereum-dapp-for-crowdfunded-loans-case-study-7903155c780d"><strong><em>here</em></strong></a><strong><em>.</em></strong></p><p><strong>What We Set Out To Do:<br></strong>We set out to gain a completely working Ethereum application prototype for crowdfunded loans. It had to have both a back-end (Smart Contract) and a front-end (Dapp). The end goal being a way to validate the market and understand the technology stack for further development. For the website to work you need to have the <a href="https://metamask.io/">Metamask</a> plugin with an unlocked wallet (other Ethereum nodes that inject Web3 API should also work) and be on Ethereum’s test network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*HQBkhFLR5QFQh2gEA55PFQ.png" /></figure><p><strong>Here’s how a loan works in the system now:</strong></p><ol><li>Request a loan by providing the funding goal, the investment period, the payback period, and the goal interest rate.</li><li>The loan is created and listed starting with an investment period.</li><li>During the investment period, investors can put out money for the loan. That amount can’t yet be taken out by either party.</li><li>If the funding goal is not reached, the investors should be able to withdraw their money and the Loan should fail.</li><li>Otherwise the debtor can withdraw the loan and the payback period begins.</li><li>If the debt is not paid, then the loan is defaulted and has failed.</li><li>If the debt is paid back, then the loan has been successful.</li><li>After the payback period is finished and the loan was successful, the investors can withdraw their investment.</li></ol><p><strong>What’s A Dapp?</strong><br>A Dapp is just a normal website that can be hosted anywhere. By using Ethereum Javascript Web3 API you can interact with an Ethereum node installed either on your client’s computer, or any other public Node set-up on the internet. That Node acts as a gateway to the Ethereum network and allows you to talk to the deployed smart contracts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*wYUbGZ5-rpkfr9fngMPDig.png" /></figure><p><strong>The Dapp’s Back End:</strong></p><p>In a Dapp, the back-end instead of living on some company owned server is your smart contract living on the blockchain. They’re written in Solidity (there are other Contract languages, but this one is a lot more popular and nowadays the preferred way to write contracts). While you still need to write Ethereum Contracts directly, frameworks such as <a href="http://truffleframework.com/">Truffle</a> or <a href="https://github.com/iurimatias/embark-framework">Embark</a> provide additional value with easy deployments on networks, migrations for updating existing contracts, and on-chain and off-chain unit testing. We ended up using Truffle supplemented with <a href="https://github.com/ethereumjs/testrpc">TestRPC</a> Node.</p><p><strong>The Dapp’s Front End:</strong></p><p>As for the front-end itself we decided on using <a href="https://angular.io/">Angular 2</a>. A lot of the community uses <a href="https://www.meteor.com/">Meteor.js</a> since it nicely fits into the Dapp model.</p><p><strong>Smart Contracts:</strong></p><p>A Smart Contracts’ code is immutable. Once you deploy something, it’s going to live in it’s current form on the blockchain forever. Contracts are modeled after Object Oriented Programming, and thus their internal state can be changed by calling their methods. Such method calls are a blockchain transaction, they are mined and the Contract state is changed for every participating Ethereum client, and so they need to run on every computer.</p><p><strong>Sending Ether From A Smart Contract:</strong></p><p>Sending Ether from a Smart Contract is a tricky beast. Since the address to which we send money to can also be a Smart Contract, it’s methods also need to be run when money is received, and they run midway through the execution of the first Smart Contract’s method, and so the second Smart Contract can also call the first Smart Contract during its execution. This is a property called reentrancy. This means that if the Contract is written wrong, it’s state might not be what you expect when a method is called. One scenario where this can be exploited is when the Smart Contract updates its state only after sending money. It’s not hard to imagine an attacker who writes a Smart Contract which calls ReceivePayment() each time it receives money, the execution would loop and all funds of the Loan contract could be siphoned out. That’s why it’s a good pattern to update the state beforehand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*BM2EtynKPuGmimuVOBarcw.png" /></figure><p><strong>Testing Our Loans:</strong></p><p>The biggest problem in testing was the ability to test the deadlines of our Loans — you can’t speed up time, and TestRPC doesn’t allow jumping the block.numberconstant upwards. We ended up sidestepping the problem by exploiting the inner workings of TestRPC — a single block is mined for every single transaction. We simply pushed as many empty transactions as needed to reach the blocks we needed to move forward. This solution doesn’t work on real networks though. We don’t think there’s actually any way to test deadlines on a real network without inventing time travel, or testing a real loan with real time.</p><p>We also wanted to get all existing loans and refresh the data after something interesting happened on the blockchain. Fortunately Web3 allows for event watching.</p><p><strong>Improvements For Next Iterations:</strong></p><p>Right now the loan works on deadlines and before doing any operations, the Smart Contract checks on which range of deadlines it is. This is error prone (especially to one-off block errors), introduces some duplication, and is hard to read. The next iteration should make use of <a href="http://solidity.readthedocs.io/en/develop/common-patterns.html#state-machine">state machine pattern</a> which is very easy to write and understand using Solidity’s modifiers, which would allow to only make an operation if in the proper state.</p><p>We’ve run out of time so not all functionality of the smart contract is visible on the Dapp front-end. Withdrawing funds by investors and contract owners still needs to be done manually using Web3 APIs.</p><p>While the loans refreshes on the front-end properly when something interesting happens, such as an investment, or a payback, it can’t detect when a period ends and refreshes. This is because the contract only runs on demand instead of being online all the time. There are some on-chain solutions such as the <a href="http://www.ethereum-alarm-clock.com/">Ethereum Alarm Clock</a>, but the cheapest and easiest way would be to have Javascript timers on the front-end estimate when the period should end and refresh the loan then. One technical problem with that is that the block mining time is variable on Ethereum, so we can only estimate the time when the deadline block is mined. This problem wouldn’t be visible to the user though. We could check the contract again after the timer ends behind the scenes, and adjust timers accordingly.</p><p>To increase security, in the next iteration we would like to separate each loan into it’s own separate Contract. Currently if there’s a bug in withdrawal methods, the attacker can siphon all the funds of each loan. If the loans were separate, only the affected loan funds could be stolen. We would design it by having a global aggregation Contract which would also deploy Loans. This design would also allow for the Loan code to be updateable in a sensible way — current loans would stay the same, guaranteeing the owner couldn’t meddle, but the new loans could have a newer version deployed during creation.</p><p><strong>Conclusions:</strong></p><p>Programming on the Ethereum blockchain is very unusual work, breaking lots of normal conventions. Smart Contracts allow you to think of your web application in terms of events based infrastructure and not worry about providing a back-end. On the other hand, writing contracts is a lot harder than normal back-end. You need to have quite a lot more in mind — starting with security, and thinking in terms of function reentrancy, through immutability needed for better planning up-front, and ending with having explicit costs to each action you do, and trying to avoid dynamic loops, and try to make everything work in a constant amount of time.</p><blockquote>This article has been largely reduced from it’s original length and detail, and has been slightly edited. If you’d like to read the whole original article, with far more details, it’s available on <a href="https://medium.com/@ritave">Olaf’</a>s profile <a href="https://medium.com/tomalka-me/ethereum-dapp-for-crowdfunded-loans-case-study-7903155c780d">here</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2a74a8d6b30" width="1" height="1" alt=""><hr><p><a href="https://medium.com/getline-in/case-study-ethereum-dapp-more-for-crowdfunded-loans-shortened-from-original-b2a74a8d6b30">Case Study: Ethereum Dapp &amp; More For Crowdfunded Loans</a> was originally published in <a href="https://medium.com/getline-in">Getline.in</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Acceleration Programmes And The Grit In Their Sandbox]]></title>
            <link>https://medium.com/@ritave/acceleration-programmes-and-the-grit-in-their-sandbox-10bbd2eb5a4d?source=rss-e8ead5f8ec6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/10bbd2eb5a4d</guid>
            <category><![CDATA[accelerationism]]></category>
            <category><![CDATA[venture-capital]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Olaf Tomalka]]></dc:creator>
            <pubDate>Mon, 09 Oct 2017 13:45:04 GMT</pubDate>
            <atom:updated>2017-10-09T13:45:04.665Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_JvCivx7m7O7Fwmj19PQCQ.jpeg" /></figure><p>A year ago from today I was finishing up my tenure as an Microsoft intern, and even though I got the offer to stay there for the next 5 years, I was more than hungry to choose my own path and become an entrepreneur. I didn’t have any experience, either in practice nor from books. My network was composed of mostly die-hard programmers, and lacked in any sustenance of a business thought. This last year though, was a never-ending stream of knowledge, experience, emotions and progress flooding me at a speed faster than light itself. <strong>That year I took part in two acceleration programmes targeted to kick-start young founders. </strong>A perfect sandboxes in which I could fall and stand-up and fall again and get up ad-infinum until my sand-castle’s ready.</p><p>Both <a href="http://reaktorx.com/">ReaktorX</a> and <a href="http://hugething.vc/">Huge Thing</a> this year had a very rare virtue in common. <strong>That is, they didn’t take any equity. </strong>This was, and still is an incredibly controversial decision, as the acceleration owners had no direct way of monetizing the work and money they put in growing a new generation of business-owners, relying only the ability to recoup investments in possible later financing rounds and not-quantifiable networking goodwill. (In particular, Huge Thing had a clause stating the right to participate in any investment rounds in the next 2 years). I’m incredibly grateful for that choice, because <strong>having external investors breeds expectations</strong>. Expectations of return-on-investment and thus maximizing growth at the cost of maximizing risk. It’s not your company anymore, you get locked-in in the business model of your investors. It’s not a bad thing in general and is perfectly ideal situation if you know what you’re doing, because most of the time, the incentives are the same — create something huge and world-changing. However when you put inexperienced founders in the mix, it’s going contradict with the natural need to stumble around into walls, because <strong>some mistakes can only be learned on your own skin</strong>. This lucky roll of a dice allowed me to maintain the complete ability to learn at my own pace and in the direction that I needed at that time. Following expectations could lead to a company, growing too big and going in a direction that the founders can’t follow, burning them out and in the end actually decreasing any chances of any sensible gains from the investment.</p><p>Even with the freedom of your own choices in the company, don’t expect to be able to make due with a stable job on your back too. It’s not about the time management, it’s about the physical state of your mind, you’re not going to go all in and take risks if you always can come back to the old style of living, it’s about the mind-share of where your brain goes. No matter how little you work for somebody else in terms of allocated time — it’s gonna seep through the cracks and take your own mind’s processing time, to think about your-other-work-problems. <strong>You’re not living of the safety net anymore, you’re creating it, get used to the idea</strong>. You eat what you sow.</p><p>Coming back to what expect from the experience of taking part in acceleration — the biggest thing that hit me right in my expectations was <em>The What</em> and <em>The How</em> of the provided knowledge.</p><p><em>The What</em> was extremely geared towards creating unicorns, meaning investments, meaning pitches and most of all - growth, much less about proper revenue streams, accounting, clients or management. Those parts existed, but I think they were given much less thought, which thinking about the goals of acceleration programmes makes sense — the goal is to prepare the founders for an outside investment, not to create stable companies.</p><p><em>The How</em> is also worth noting. If you’re going to make a proper company, you’re going to want to filter and get as much properly-selected knowledge poured into you as possible, one of the best ways is to read books. A lot of them. My goal is to read one a week. But then you enter a workshop geared towards 10 companies, each with 3 to 4 people listening and you get this extreme feeling of déjà vu, that you heard this information beforehand, that you’re not learning anything new. See, with that many people listening to the mentor speaking, the only thing that can be passed down ends up being the same kind of knowledge the is written down in books, and at a much slower pace too. Without the ability to gear what you’re teaching to specific individuals you end up making blanket statements that are true in any situations. And this is a tragedy, because you signed an agreement in which you have to attend those workshops, 4 times a week for 6 hours a day. What ended up happening was that our company suffered because I didn’t have the time to manage it properly. Ironically it wouldn’t exist without the acceleration programmes, so there’s that. Don’t get me wrong — there’s a lot of good knowledge flying around, but if it’s not geared towards your company, it’s going to be useless, because it doesn’t account for what you know and what your current problems are. I ended up cherishing those days where I had meetings set-up for 1:1s, in which I could pester the mentor with an unending stream of questions and back-and-forth. An hour of that was sometimes worth more than a few weeks of workshops.</p><p>And here I’m finally getting to the core of this article. I once heard a statement which deeply resonated with me: “This place is a sandbox, but only you decide what you build in it”, and I believe this is a goal for which acceleration programmes should strive for. They gather smart people, the adventurous ones, the ones that are willing to choose their own path, and end up forcing them into a stream of consciousness that is not their own. It’s now obvious to me that this is going to be a pain point. And yet, I’m very grateful to have been part in both of those programmes. Why? Because of the resources that I could, but was not forced to use, because they provided me with a place to exchange ideas, a place in which I could go to my mentor and get information that I needed <strong>at that time</strong>. Because they opened doors and allowed to quickly increase the size of my network.</p><p>We live in <a href="https://www.amazon.com/Technopoly-Surrender-Technology-Neil-Postman/dp/0679745408">Technopoly</a>, in never-ending stream of information that is trying to enter your head, most of it useless. High quality institutions, such as Universities, such as good Acceleration Programmes should be and end up being information filters. They should help you find the information that you’re looking for, the book that you need, the person that knows the answers to your question, not force it down your throat. The best managers know when to back-off and allow you to do your job, they become the invisible hand that solves outside problems so you can be productive, this is my wish for the perfect acceleration.</p><p>If I had to choose whether to partake again, I would still say yes, without even a flinch. But nothing’s in life perfect, is it? My goal was to provide a more sensible side to the highly-marketed ecosystem of VCs and Accelerations, so that you can make your decision with all the facts. You got the other side, now go ahead and sign up, take the plunge and enjoy it down to the bones. It’s a lot of fun.</p><blockquote>Currently we’re marketing <a href="http://getline.in/">Getline.in </a>— global-wide Peer-to Peer-lending on Ethereum network, catch me <a href="https://getlineslack.herokuapp.com/">on our slack</a> as @ritave and let’s get talking!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10bbd2eb5a4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Actually Disrupt Banks And P2P Lending]]></title>
            <link>https://medium.com/getline-in/optimizing-contracts-for-security-associated-costs-eba4f07562ad?source=rss-e8ead5f8ec6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/eba4f07562ad</guid>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[news]]></category>
            <category><![CDATA[p2p-lending]]></category>
            <category><![CDATA[loans]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Olaf Tomalka]]></dc:creator>
            <pubDate>Wed, 27 Sep 2017 10:52:53 GMT</pubDate>
            <atom:updated>2017-11-04T07:59:34.267Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*i69sKQPlL2ZpD9be1kaiew.png" /></figure><p>Many hodlers believe that Bitcoin will actually replace banks — but right now Bitcoin and Ethereum are seen largely as investing assets. Every economy needs capital to start new companies and to boost the growth of existing ones.</p><p>One of the biggest priorities of the GetLine Network is the safety of the loans active in the system. To do that, one good practice is to decouple each loan into a separate Ethereum contract, so that a bug in one loan can’t endanger all the others. This also provides immutability for the loaner and the borrower. Once deployed, both parties know exactly the terms on which the loan is given. New loans can be taken with new bug-fixes and improvements, but the old ones stay the same — everybody accepts the same terms without the fear of the smart contract changing at a later date to someone’s disadvantage. This kind of security is used for example in some 2-Factor Authentication USBs — once created, the USB device is<a href="https://www.yubico.com/support/knowledge-base/categories/articles/possible-upgrade-yubikey-firmware/"> not upgradable by design</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*YasDtTGX-Xzl0b0KFEXkdQ.png" /><figcaption>Each contract between Lender and Borrower can have different terms and version</figcaption></figure><p>The GetLine Network additionally will confirm the version of the loan contract in the Application layer, meaning that each contract must match byte-for-byte with the official version that the GetLine company releases before they are trusted. This provides two-fold safety for the users. First of all, you’ll know which smart contracts are trustworthy and aren’t a trick by a hacker to steal your money, and secondly — should bugs be discovered in the smart contract code, all previous loans will show up with a warning and participants will be notified optionally. In that way you’ll always be knowledgeable about the state of your transactions, as well as that of your wallet; You’ll also be able to make more informed decisions in which listed loans to invest your money in.</p><p>Decoupling comes at a price though — literally. Since each loan is a decoupled entity, each one has to hold everything connected with the process, including the code, which doesn’t really change from loan to loan. So now each loan is duplicating a lot of data, and each user would have to pay dollars for that duplication during deployment. Each deployed loan that has the same version will have the same code, duplicated multiple times throughout the blockchain. Each one costing a sizable fee in Ether.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*ACZ3i8-b6Qy9nsCvCsUMDw.png" /><figcaption>Each Loan not only holds the information for the specific Loan, but also code that could be shared by all of the Loans</figcaption></figure><p>But, thankfully Ethereum has a nifty solution to that problem — Libraries. Libraries are contracts that are deployed once for each version of the code. Meaning there will be a Library for V1, for V2, for V3, etc. Each loan with the same version shares the same code with each other loan, while at the same time it’s state and information concerning specific loan terms is still completely separated from all the others.</p><p>Here’s an example technical flow:</p><ol><li>Programmers write a new version of a loan.</li><li>They deploy the Loan Library once, paying a fee for the deployment, let’s assume $6.</li><li>The loan itself is linked to the already deployed Loan Library code.</li><li>So now the price of the loan contract has decreased, for example, from $6 to $1, meaning that you, as a user, save $5 on each loan.</li><li>When somebody calls a function in the loan contract, the function is delegated straight to the Loan Library (through the <em>DELEGATECALL </em>Ethereum opcode)</li><li>The Library doesn’t hold any state nor information, all information is still being held by the loan contract itself.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*zrMcKgVbw-odImHex-U8ww.png" /><figcaption>Now, all the Loans can share the same code, making each Loan cheaper</figcaption></figure><h3>Small sample</h3><p>Here’s a small sample in Solidity that showcases how Libraries work from the developer’s point of view. I’ll be using<a href="http://truffleframework.com/"> Truffle Framework</a> as it provides an easy way to link smart contracts together. We’re going to create a simple escrow service. The creator of the contract shall put money into the escrow and designate a receiver of that money. The creator won’t ever be able to get their money out without giving it to the recipient.</p><h4>Flow Of Escrow Service</h4><ol><li>Owner creates the contract, designates recipient and puts money into the contract.</li><li>Some service is provided off-chain by the recipient.</li><li>Owner confirms that the service was rendered and releases funds in the smart-contract.</li><li>The recipient then withdraws the funds.</li></ol><p>The interface is quite simple:</p><pre>contract Escrow {<br>    function Escrow(address recipient) payable;<br>    function confirmComplete();<br>    function widthdraw();<br>}</pre><p>The confirmComplete() can be only called by the creator of the contract, while the widthdraw() only by the recipient, and only after the owner confirmed the service.</p><p>Now we’re going to create a library with the actual functionallity:</p><pre>library EscrowLib {<br>  function init(address owner, address recipient, uint amount) internal returns (EscrowData data) {<br>    data.owner = owner;<br>    data.recipient = recipient;<br>    data.amount = amount;<br>  }</pre><pre>  function confirmComplete(EscrowData storage data, address sender) internal {<br>    require(data.owner == sender);<br>    require(data.wasConfirmed == false);<br>    require(data.isWithdrawn == false);<br>    data.wasConfirmed = true;<br>  }<br>    <br>  function withdraw(EscrowData storage data, address sender) internal {<br>    require(data.recipient == sender);<br>    require(data.wasConfirmed == true);<br>    require(data.isWithdrawn == false);<br>    data.isWithdrawn = true;<br>    data.recipient.transfer(data.amount);<br>  }</pre><pre>  struct EscrowData {<br>    address owner;<br>    address recipient;<br>    uint amount;<br>    bool wasConfirmed;<br>    bool isWithdrawn;<br>  }<br>}</pre><p>First of all the Escrow contracts needs to hold the data on which the Library can operate. Remember — libraries can’t hold any data, only code.</p><pre>contract Escrow {<br>  using EscrowLib for EscrowLib.EscrowData;<br>  EscrowLib.EscrowData data;<br>  function Escrow(address recipient) payable {<br>    data = EscrowLib.init(msg.sender, recipient, msg.value);<br>  }<br>}</pre><p>As you can see, the functionality is now decoupled from where the data is actually being held. Now the functions in the Escrow contract now only need to pass the data along.</p><pre>contract Escrow {<br>  ...<br>  function confirmComplete() {<br>   data.confirmComplete(msg.sender);<br>  }</pre><pre>  function withdraw() {<br>   data.withdraw(msg.sender);<br>  }<br>}</pre><p>You’ve probably noticed a caveat here, we need to pass the sender to the Library. Since libraries are separate contracts in blockchain, their msg.sender is actually the Escrow contract, and not the one who’s calling it.</p><p>This example is pretty simple, but in bigger smart contracts it can be a powerful weapon, for security, readability, and reducing costs.</p><p>You can read more about libraries in the<a href="http://solidity.readthedocs.io/en/develop/contracts.html#libraries"> official Solidity documentation</a> and get access to the<a href="https://github.com/Getline-Network/getline-samples/tree/master/medium-articles/library-demo"> whole sample in our Github repository</a>.</p><blockquote><em>Got questions? Hit me up on </em><a href="https://rocket.getline.in/"><em>Getline’s Rocket Chat </em></a><em>where I’m @ ritave</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eba4f07562ad" width="1" height="1" alt=""><hr><p><a href="https://medium.com/getline-in/optimizing-contracts-for-security-associated-costs-eba4f07562ad">How To Actually Disrupt Banks And P2P Lending</a> was originally published in <a href="https://medium.com/getline-in">Getline.in</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flow Of The P2P Lending Protocol]]></title>
            <link>https://medium.com/getline-in/flow-of-the-p2p-lending-protocol-bfff3767dc18?source=rss-e8ead5f8ec6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfff3767dc18</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[loans]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[all-posts]]></category>
            <dc:creator><![CDATA[Olaf Tomalka]]></dc:creator>
            <pubDate>Wed, 13 Sep 2017 13:12:44 GMT</pubDate>
            <atom:updated>2017-09-21T13:50:31.357Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*chk-yPqbsLaFSfDdiu1sCg.png" /></figure><p>The <a href="https://medium.com/getline-in/what-is-the-getline-network-924ba4ad788e">GetLine Network</a> is a vast undertaking that will take a considerable amount of time and resources to jump-start, nevertheless we really want to show users a glimpse of the future we’re building. That’s why we’re creating a technical demo that showcases an example flow for the borrower. The architecture is similar, yet simplified, and thus I believe that I should explain how it works and the differences.</p><p>The first obvious thing is there aren’t any common GET tokens yet that could be used as collateral, we need placeholder tokens. For that reason, we created 3 demo tokens with infinite supplies. One that is used for collateral of demo loans, and two others for loaning, so that people can test out how it works without the fear of losing any assets. We distribute them with the help of a central printing authority contract, which when asked nicely will print a set amount of each token for the recipient. Since we know exactly which tokens you’re getting we can easily show them in the application interface and allow you to understand your assets at a glance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*SaXobE1BE0wWNKaQC9b7Pg.png" /><figcaption>Ethereum flow of how tokens are printed</figcaption></figure><p>Demo loans don’t provide proper security for the investors and so any other ERC20 tokens won’t be supported.</p><p>After you have enough tokens to do anything we’ll take you through the process of actually requesting the loan. Pretty standard stuff, like the title, description, how much you want to borrow, and what kind of token, what’s your collateral amount, how much of a percentage you’re willing to pay to the investors, etc. Afterwards the loan is created, listed, and a week of fundraising begins in which the investors would be able to see and invest in the loan itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wbw3ap7DDbM6qpQN39i5fw.png" /><figcaption>The parameters of the loan you want to take</figcaption></figure><p>An interlude is in order. See, because putting data on-chain is expensive (explicitly expensive, each character put on block-chain costs actual money, and with the current exchange rates it’s cents per one actually). Because of this we’ve opted to save the title and description in a centralized backend. While the deployed Loan contract has all the data it needs to conduct a proper loan in terms of the math, we’re holding the data needed for a user-readable listing of such a loan. Putting that data on blockchain wouldn’t be useful at all, since the virtual machine doesn’t provide any listings of active loans. That is the responsibility of the Getline Network’s application layer. With the help of <a href="https://github.com/ethereum/web3.js/">web3 APIs</a> we can additionally link listed loans to a specific wallet that created them, and so, if you have any supported Ethereum wallet installed, the next time you come back, you’ll be greeted with all the loans that you created. How? Because we’re saving each loan’s metadata in a centralized backend. We’re using <a href="https://www.meteor.com/">Meteor</a> as well as the included <a href="https://www.mongodb.com/">MongoDB</a> instance.</p><p><strong>What metadata is saved?</strong></p><ul><li><em>Loan’s status</em><br>Is it deployed on Ethereum already, or does it need deploying yet</li><li><em>Loan’s parameters<br></em>If the user stops midway through the process (for example if they reject the transaction in Metamask), we need to be able to reinstate the request for deployment, even if they refresh the page</li><li><em>Loan’s Ethereum address<br></em>After it’s deployed we need an easy way to access it again</li><li><em>Loan’s owner’s wallet address<br></em>Useful to list all your loans at once without searching the whole blockchain</li></ul><p>Now, that the interlude’s finished, you’re in the the fundraising phase of the Loan. Since there is no demo for the investors yet, we opted to have an automatic investor contract which puts out the money itself.</p><p>The frontend, after you’ve clicked the final button, on your behalf will ask the auto-investor to invest in the loan you created (and with your approval through Metamask). The auto-investor then prints additional tokens and puts them into your loan contract, enough to fulfill the fundraising phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*yEOOjRyDrrKP7LtAV8fOpw.png" /><figcaption>Blockchain flow of the auto-investor</figcaption></figure><p>Now you’re left with your newly-borrowed capital and lenders to be repaid at a later date of your choosing (you did set a reasonable pay-back date during the loan’s creation, didn’t you?). If you miss the date, the loan’s gonna default, investor’s gonna get your collateral, and it’s gonna forever leave a mark on the blockchain, better not to do that. Fortunately, this is a demo, you can just print more tokens, but if that were not the case, your collateral would be gone and your credit score would decrease.</p><p>In the upcoming weeks, we’re going to describe details of the Loan contract itself, credit scoring and defaults. Stay tuned!</p><blockquote><em>Got questions? Hit me up on </em><a href="https://getlineslack.herokuapp.com/"><em>Getline’s public Slack</em></a><em> where I’m @ Olaf Tomalka</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfff3767dc18" width="1" height="1" alt=""><hr><p><a href="https://medium.com/getline-in/flow-of-the-p2p-lending-protocol-bfff3767dc18">Flow Of The P2P Lending Protocol</a> was originally published in <a href="https://medium.com/getline-in">Getline.in</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Case Study: Ethereum Dapp For Crowdfunded Loans]]></title>
            <link>https://medium.com/@ritave/ethereum-dapp-for-crowdfunded-loans-case-study-7903155c780d?source=rss-e8ead5f8ec6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7903155c780d</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Olaf Tomalka]]></dc:creator>
            <pubDate>Fri, 24 Mar 2017 23:54:54 GMT</pubDate>
            <atom:updated>2017-03-26T14:50:34.590Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QBnzoXUikVrbxyYOj1c5gg.jpeg" /><figcaption>Thanks to <a href="https://stocksnap.io/author/35828">Stephanie Ecate</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CShbJaQOxL0zz_EfJY1MLA.png" /><figcaption>Screenshot from the end product</figcaption></figure><h3>Abstract</h3><p><a href="https://getline.in/">Getline.in</a> reached out to me asking to provide them with a completely working Ethereum application prototype for crowdfunded loans. The task was to create both back-end (Smart Contract) and front-end (Dapp). The end goal being a way to validate the market and understand the technology stack for further development. Since this was supposed to be quick and dirty we set-up a deadline of a week — what we build is what we end up with, no extensions. We ended up spending ~20 hours and the end-product can be seen on <a href="http://etherloans.netlify.com/">etherloans.netlify.com</a>. For the website to work you need to have the <a href="https://metamask.io/">Metamask</a> plugin with an unlocked wallet (other Ethereum nodes that inject Web3 API should also work) and be on Ethereum’s test network.</p><p>First of all, what should be the high-level flow of such a loan?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*pglLZR0L3VE9vmj4A10Wmw.png" /></figure><ol><li>Request the loan by providing the funding goal, the investment period, the payback period and the goal interest rate</li><li>The loan is created and listed starting with an investment period</li><li>During the investment period, investors can put money for the loan. That amount can’t be yet taken out by either party</li><li>If the funding goal is not reached, the investors should be able to withdraw their money and the Loan should fail</li><li>Otherwise the debtor can withdraw the loan and the payback period begins</li><li>If the debt is not paid the loan is defaulted and has failed</li><li>If the dept is paid back the loan is successful</li><li>After the payback period finished and the loan was successful the investors can withdraw their investment</li></ol><h3>Tech Stack</h3><p>After we had the basics planned we could start thinking about what technologies to use.</p><p>A quick explanation what a Dapp really is: Dapp is just a normal website that can be hosted anywhere. By using Ethereum Javascript Web3 API you can interact with an Ethereum node installed either on your client’s computer, or any other public Node set-up on internet. That Node acts as a gateway to the Ethereum network and allows you to talk to the deployed smart contracts. Since non-local Nodes don’t have information about the client’s wallet we couldn’t use cloud ones to allow investments and withdrawals and opted for requiring a Node installed on the user’s computer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*P8ZLWbSfyCr_Agto_tChGg.png" /></figure><p>In Dapp the back-end instead of living on some company owned server is your smart contract living on the blockchain. They’re written in Solidity (there are other Contract languages, but this is one is a lot more popular and nowadays the preferred way to write contracts). While you still need write Ethereum Contracts directly, frameworks such as <a href="http://truffleframework.com/">Truffle</a> or <a href="https://github.com/iurimatias/embark-framework">Embark</a> provide additional value with easy deployments on networks, migrations for updating existing contracts and on-chain and off-chain unit testing. We ended up using Truffle supplemented with <a href="https://github.com/ethereumjs/testrpc">TestRPC</a> Node. TestRPC allows faking of the whole blockchain, it simulates all transactions locally and in a speedy way. It’s perfect for testing before real deployment.</p><p>As for the front-end itself we decided on <a href="https://angular.io/">Angular 2</a>. Alot of the community uses <a href="https://www.meteor.com/">Meteor.js</a> since it nicely fits into the Dapp model, but we were time-constrained and opted for something we knew better.</p><h3>Smart contract</h3><p>Smart Contracts’ code is immutable by design. Once you deploy something, it’s going to live in it’s current form on blockchain forever. Contracts are modeled after Object Oriented Programming, and thus their internal state can be changed by calling their methods. Such method calls are a blockchain transactions, they are mined and the Contract state is changed for every participating Etherum client, and so they need to run on every computer. This is costly and due to, by-design, Turing-completeness, we can’t know if they ever finish. Ethereum solves this problem by defining that every run instruction costs some amount of Ether (for simplicity sake, there’s abit more complex abstraction called <a href="https://ethereum.gitbooks.io/frontier-guide/content/costs.html">Gas</a>).</p><p>But Contracts also support pure functions, ones that don’t change the state of the Contract, which are not run on the blockchain, only on the Dapp-used Node instead. Such pure functions are used to get data and information about the Contract, for example to display it to the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*gxArH7BvkbU_N5GUhlW6Jg.png" /><figcaption>Difference between calling a method vs a pure function</figcaption></figure><p>In our case each loan was a self-contained struct that can accessed by providing it a unique ID in the list of all the loans.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1e76a770f1052648819e72cf8b480e0/href">https://medium.com/media/f1e76a770f1052648819e72cf8b480e0/href</a></iframe><p>There are a few interesting tidbits here:</p><ul><li>Structs are only a part of Solidity language, not the underlying virtual machine, so each property of a struct required it’s own additional getter Contract pure function</li><li>Ethereum VM doesn’t support neither floating nor fixed precision numbers, so we resorted to using <a href="https://en.wikipedia.org/wiki/Per_mille">per mils</a> to keep track of fractions</li><li>There exists <em>block.timestamp</em> constant but it can be forced to drift from real time by the miners so secure contracts shouldn’t rely on it all that much</li><li>On the other hand, blocks can’t be easily mined faster or slower than needed and so setting up deadlines by getting the <em>block.number</em> constant is a better solution</li><li>You can’t iterate over <em>mapping,</em> an alternative to get all loans was needed</li></ul><p>Ethereum natively supports events, which can be emitted when some interesting thing happens in the contract. Moreover, those events can be watched by the front-end, which allowed us to automatically refresh loan data when needed, instead of polling the blockchain.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0eff074f46ed61565f5566c0f970c2c1/href">https://medium.com/media/0eff074f46ed61565f5566c0f970c2c1/href</a></iframe><p>Ethereum also strongly supports atomicity, if there’s any error, or throw, or your code runs out of gas — the state of the contract is not changed. This is often used to check for needed preconditions. For example you shouldn’t be able to invest in a loan after the investment period or if the goal was already met, and no Ether will be transferred.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4127a2105f17e1c232abb8406c3388ff/href">https://medium.com/media/4127a2105f17e1c232abb8406c3388ff/href</a></iframe><p>Even though the money was returned, miners had to run the program up to the point of a throw, and so Gas used to run the method is used up, and not returned to the caller. Also notice that only methods with a <em>payable</em> modifier can receiver Ether.</p><p>Sending Ether from a Contract is a tricky beast. Since the address to which we send money can also be a Contract, it’s methods also need to be run when money is received, and they run midway execution of the first Contract’s method, and so the second Contract can also call first Contract during it’s execution. This is a property called reentrancy. This means that if the Contract is written wrong, it’s state might be not be what you expect when a method is called. One scenario where this can be exploited is when the Contract updates it’s state only after sending money. It’s not hard to imagine an attacker who writes a Contract which calls <em>ReceivePayment()</em> each time it receives money, the execution would loop and all funds of the Loan contract could be siphoned out. That’s why it’s a good pattern to update the state beforehand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*__GNaHmOW-dcp_W8cb-gMg.png" /><figcaption>Contract 2 attacks Contract 1 by constructing a recursive loop</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99be2e01082b16a02b3d9d3dd8579307/href">https://medium.com/media/99be2e01082b16a02b3d9d3dd8579307/href</a></iframe><p>Another way to handle reentrancy is to outright create a mutex on each method run — if any function is reentrantly called the Contract will throw. Also notice that the receiving contract can also fail during execution, so we propagate the error upwards not to sacrifice any Ether.</p><h3>Testing</h3><p>Truffle allows to write automated tests for Smart Contracts. First it deploys the contract to the provided network. In most cases to a fake one simulated by TestRPC, but the tests can also be run on real networks (and should, at least once before deployment).</p><p>You then interact with the Contract the same way as a Dapp would — in Javascript with Web3 APIs. Truffle has also a minor sugar abstraction layer on top — wrapping each call in a promise.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99b29b4c002bf96e07979008a9b631bd/href">https://medium.com/media/99b29b4c002bf96e07979008a9b631bd/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5b13d4fb14c24d0e53110905724307d/href">https://medium.com/media/c5b13d4fb14c24d0e53110905724307d/href</a></iframe><p>The biggest problem in testing was the ability to test deadlines of our Loans — you can’t speed up time, and TestRPC doesn’t allow jumping the <em>block.number</em> constant upwards. We ended up sidestepping the problem by exploiting inner workings of TestRPC — a single block is mined for every single transaction. We simply pushed as many empty transactions as many blocks we needed to move forward. This solution doesn’t work on real networks though. I don’t think there’s actually any way to test deadlines on a real network without inventing time travel.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e61bda8f3380ed6eec4ff5cd4c46ebfd/href">https://medium.com/media/e61bda8f3380ed6eec4ff5cd4c46ebfd/href</a></iframe><h3>Front-end</h3><p>Front-end was surprisingly pretty straightforward. A normal Angular 2 application with just a different way of getting data inside the Services (Or known as a Model in other frameworks/patterns).</p><p>Here again Truffle helped out — when compiling and deploying contracts it emits a JSON file with all the data needed to work with the contract through Web3. Since Webpack allows directly importing JSON files inside Javascript we could just get them from the compile directory, separating Truffle compilation and front-end compilation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2dd9c3d079ea311cfdb2accfc558a094/href">https://medium.com/media/2dd9c3d079ea311cfdb2accfc558a094/href</a></iframe><p>We wanted to get all existing loans and refresh the data after something interesting happens on the blockchain. Fortunately Web3 allows for event watching</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9afe8641c5b6114822572a5e069b055/href">https://medium.com/media/c9afe8641c5b6114822572a5e069b055/href</a></iframe><h3>Deployment</h3><p>This part was the trickiest, I wanted to avoid spending the night downloading the whole blockchain, which weighs 50+gb. Light clients would allow us to deploy the contract without downloading everything. Most are in the works though. Only one right now is Metamask but it’s a Chrome plugin, which means it’s sandboxed and doesn’t listen for normal RPC commands. The only way to talk to it is through Web3 API on a website. Truffle can’t communicate with it to deploy and emit the JSON needed for the front-end!</p><p>What we ended up doing was to deploy to TestRPC Node and then open a new Chrome tab, manually deploy the compiled bytecode through Web3 and update the JSON to proper values, and recompile front-end.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/913c6b7f82ff3ac01d93861b681dff92/href">https://medium.com/media/913c6b7f82ff3ac01d93861b681dff92/href</a></iframe><p>There were two things that needed changing for the Front-end to work with the JSON. Network ID and Contract address. Network ID is easy enough: <em>web3.version.network</em> returns <em>“3”</em> for the test network. Contract deployment was a longer process to read through and understand how to do it properly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70a00291dfb9881fea235d039bc6f6e1/href">https://medium.com/media/70a00291dfb9881fea235d039bc6f6e1/href</a></iframe><p>Afterwards Contract’s address could be easily gotten from it’s instance and updated into the JSON.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*BEqgUweLjmvFp0aHG3Vk5g.png" /><figcaption>Chrome’s Dev Tools are impressive, but not my favorite IDE</figcaption></figure><h3>Improvement for next iterations</h3><p>Right now the loan works on deadlines and before doing any operations, the Contract checks on which range of deadlines it is. This is error prone (especially to one-off block errors), introduces some duplication and is hard to read. Next iteration should make use of <a href="http://solidity.readthedocs.io/en/develop/common-patterns.html#state-machine">state machine pattern</a> which is very easy to write and understand using Solidity’s modifiers, which would allow to only make an operation if in proper state instead.</p><p>We’ve run out of time so not all functionality of the smart contract is visible on the Dapp front-end. Withdrawing funds by investors and contract owner still needs to be done manually using Web3 APIs.</p><p>While the loans refreshes on the front-end properly when something interesting happens, such as an investment, or payback, it can’t detect when a period ends and refresh then. This is because the contract only runs on demand instead of being online all the time. There are some on-chain solutions such as <a href="http://www.ethereum-alarm-clock.com/">Ethereum Alarm Clock</a>, but the cheapest and easiest way would be to have Javascript timers on the front-end estimate when the period should end and refresh the loan then. One technical problem with that is the block mining time is variable on Ethereum, so we can only estimate the time when the deadline block is mined. This problem wouldn’t be visible to the user though. We could check the contract again after the timer ends behind the scenes and adjust timers accordingly.</p><p>To increase security, in the next iteration I would like to separate each loan into it’s own separate Contract. Currently if there’s a bug in withdrawal methods the attacker can siphon all the funds of each loan. If the loans were separate, only the affected’s loan funds could be stolen. I would design it by having a global aggregation Contract which would also deploy Loans. This design would also allow for the Loan code to be updateable in a sensible way — current loans would stay the same, guaranteeing the owner couldn’t meddle, but the new loans could have a newer version deployed during creation.</p><h3>Conclusions</h3><p>Programming on Ethereum blockchain is a very unusual work, breaking lots of normal conventions. Smart Contracts allow you to think of your web application in terms of events based infrastructure and not worry about providing a back-end. On the other hand, writing contracts is a lot harder than normal back-end. You need to have quite a lot more in mind — starting with security and thinking in terms of function reentrancy, through immutability needing for better planning up-front, and ending with having explicit costs to each action you do and trying to avoid dynamic loops and try to make everything work in a constant amount of time.</p><p>It was a lot of fun though!</p><blockquote>So you’re really interested in Ethereum, huh? If you have a project in mind please do say hello@tomalka.me, and we’ll see what we can build together!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7903155c780d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Hopeless Life-cycle of Third Party APIs]]></title>
            <link>https://medium.com/@ritave/the-hopeless-life-cycle-of-third-party-apis-793cc51cbb62?source=rss-e8ead5f8ec6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/793cc51cbb62</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[venture-capital]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Olaf Tomalka]]></dc:creator>
            <pubDate>Wed, 01 Mar 2017 01:00:56 GMT</pubDate>
            <atom:updated>2017-03-01T01:00:56.179Z</atom:updated>
            <content:encoded><![CDATA[<p>A client asked us to write Xamarin.iOS application that signs in and shows 10 user connections from LinkedIn as a way to check if they want to cooperate further. LinkedIn has a working iOS SDK on their website and documentation. Shouldn’t be a problem right? <strong>Yeah, that’s not going to happen.</strong></p><p>First thing I noticed reading documentation is that pretty much whole LinkedIn is locked behind a request form for <a href="https://developer.linkedin.com/partner-programs">Partner Programs</a>. <strong>Zero data can leave LinkedIn without their permission.</strong> The approval process takes around 15 days and you need a really sensible reason written down. Which of course is not the case with a demo show-off application. So what could we do without being in the program? <a href="https://apigee.com/console/linkedin">Not much</a>. Sign-in the user, manage company pages and share stuff on your own page. <a href="http://stackoverflow.com/questions/40907567/ui-of-sign-in-with-linkedin-sdk-is-broke">But even the login itself has been broken and not fixed for at least 3 months</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*OQhOAmZWxFFTKM9vW1t7aA.png" /><figcaption>Expected and real state of the LinkedIn sign-in process, on a good day</figcaption></figure><p>It’s not the first time a company exposes ability to integrate with their data and services while growing, and closes it down after stabilization. Oops, <strong>why give data away for free when it can be monetized.</strong> So why does it happen again and again? Because Venture Capitalist backed companies have the need to grow as big as possible, to allow investors to have those 10x returns on their big deposits. Investors are looking for products that can <em>synergize</em> and create their own ecosystem. When you’re as big as Salesforce, or Facebook, or Jira, or Unity3D, companies start popping up with their only sole way of income being creating plugins for that ecosystem. This is a very comfortable position to be in, because, by creating plugins, someone else pays the money for your growth, so of course they create APIs muttering about “openness”. And when the company controls the market, it dictates the terms. But the growth of those behemoth companies is not natural,<strong> more often than not third party integrations have more profit than the company whose data they use</strong> (Is Twitter on plus yet?). The maniac craze of finding a way to get money from all those users and all this data begins. Before it flops and they won’t be able to get more money from investors due to a <a href="http://www.investopedia.com/terms/d/downround.asp">down round</a>.</p><p>The lowest hanging fruit to monetize is the huge amount of data this company has (hey, Google and Facebook are doing pretty well on that front). Close the gates! Close the APIs behind 7 locks! The “openness” has boosted the companies to the billion valuation position and has outgrown it’s usefulness. Who cares about all those other companies, money and time invested to create plugins for the product.</p><p>Don’t get me wrong, I’m not trying to make behemoths into big bad baddies. Those small companies leeching data aren’t innocent either. It’s just a cost of doing business. But I would really appreciate if we could find some kind of middle ground, instead of jumping to extremes, because in the end the users and experiences suffer the consequences. Quite a few people are tired of trying new Google services, the probability of them getting taken down is high, why bother? Google’s Allo/Duo (hopefully you even heard of those) can’t live together with Hangouts, one will be taken down - it’s only a matter of time.</p><p>With the current state of things, how should we approach using new APIs?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=793cc51cbb62" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>