<?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 Júlio Santos on Medium]]></title>
        <description><![CDATA[Stories by Júlio Santos on Medium]]></description>
        <link>https://medium.com/@julio_santos?source=rss-8da70c852bcc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KO329862JUv7bkGCc65NnA.jpeg</url>
            <title>Stories by Júlio Santos on Medium</title>
            <link>https://medium.com/@julio_santos?source=rss-8da70c852bcc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 02:33:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@julio_santos/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[Private by Design: Building the Web’s Identity Layer with Fractal Protocol]]></title>
            <link>https://medium.com/frctls/private-by-design-building-the-webs-identity-layer-with-fractal-protocol-e5b20527c948?source=rss-8da70c852bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5b20527c948</guid>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[adtech]]></category>
            <dc:creator><![CDATA[Júlio Santos]]></dc:creator>
            <pubDate>Wed, 03 Feb 2021 21:00:04 GMT</pubDate>
            <atom:updated>2021-02-04T09:41:18.534Z</atom:updated>
            <content:encoded><![CDATA[<p>A free and open Web is a cornerstone of contemporary democracy. And it is under threat — you know it in your bones, and so do we. That’s why we’re building the <a href="https://protocol.fractal.id/">Fractal Protocol</a>: to rebalance the incentives on the Web in order to help it remain free and open. In this introductory article I’ll cover:</p><ul><li>why it’s critical to keep the Web free and open;</li><li>how our current ad market threatens the Web as we know it;</li><li>how we can finally bridge the gap between data privacy and integrity;</li><li>what we are doing about it, how we’re approaching it, and what our next steps are.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8GsK0Gfo4RsWfNyCAim2g.png" /></figure><p>Today, more than ever, we understand that a functioning democratic society requires open communication, empathy, and equal opportunity — and the Web is a catalyst to all three.</p><p>Publishing — be it news or anything else—is no longer a <a href="https://stratechery.com/2021/publishing-is-back-to-the-future/">geographic monopoly</a> accessible only to wealthy network owners — anyone with an Internet connection can choose from literally hundreds of free services to make their voices heard. The <a href="https://ourworldindata.org/literacy">explosion of literacy</a> in the second half of the 20th century dovetailed neatly into the abundance of perspectives and distribution the Web brought us. This abundance helps expand our empathy circle immensely because, as <a href="https://www.theguardian.com/books/2011/nov/01/extract-better-angels-nature-steven-pinker">Steven Pinker</a> puts it, reading is a technology for perspective-taking.</p><p>The erosion of publishing monopolies, now geographically untethered, has opened up opportunities for everyone. Less gatekeepers means more participation: a content creator’s work no longer needs the approval of a newspaper executive, or to fit neatly into a cable news bundle, to make its way out into the world and into other people’s minds.</p><p>This new freedom isn’t particular to text. Entrepreneurs of any kind, from podcasters to industrialists, can use the open Web to reach their customer base, be they interested listeners or mask importers. The Web is helping to turn our World into an open market, which makes it easier for people to compete on quality, circumventing monopolies traditionally maintained by information asymmetries. It’s not only that everyone can be anybody’s audience: no matter how small a niche is, addressing it becomes possible at a global scale.</p><h3>This is why we can’t have nice things</h3><p>Online content creators deploy multiple strategies for monetizing their creation. Some established brands, individual or otherwise, see some success with subscription revenues, but all too often these don’t generate enough income to pay for their work — and it is itself a form of gatekeeping which often leaves out those that could benefit the most. The alternative, online advertising, has been a fixture of the Web almost since its inception.</p><p>What started as direct deals between advertisers and operators of early popular websites quickly evolved into the <a href="https://lumapartners.com/content/lumascapes/display-ad-tech-lumascape/">sprawling ecosystem</a> we call AdTech today. This evolution happened because it worked — online advertising successfully funds a universe of content that people wouldn’t otherwise be able to afford to produce nor consume.</p><p>But any market needs some regulation and, unfortunately, our regulatory pace hasn’t kept up with our technological advances. This left this market open for oligopolistic capture, which is, predictably, exactly what happened. Most online advertising is the province of Google and Facebook, two rent-seeking players that hold the market by the neck, and seed it with poor incentives which are creating a <a href="https://blogs.sciencemag.org/books/2021/01/11/subprime-attention-crisis/">subprime attention crisis</a>: the obscurity they introduce through data siloing, and the <a href="https://www.forbes.com/sites/augustinefou/2021/01/12/show-me-dont-tell-me-that-im-wrong-on-this/">mind-boggling amount of fraud</a> and wasted traffic (estimated by some to be <a href="https://www.youtube.com/watch?v=gZIXI-eY8OM">as high as 99%</a> of all traffic), makes it hard for buyers and sellers alike to agree on a fair price.</p><p>The industry relies heavily on tracking users throughout the web. Since the web is browsed anonymously, this tracking data is what’s used to infer a demographic profile of users as their behaviour is observed: what sites they choose to visit or purchases they choose to make. This tracking is pervasive, unconsented and intransparent — and even well-intended measures such as the GDPR and CCPA have the unintended consequence of <a href="https://whotracks.me/blog/gdpr-what-happened.html">concentrating tracking capabilities</a>. This is because the oligopolists, to add insult to injury, mediate not only advertisers and publishers, but users and the Web itself. In fact, most of the time people spend on the Web is through a browser or app the oligopolists control. If you wonder why the large AdTech companies seem so happy with our recent regulatory incursions, this is the reason: while they may be affected, their competition will be affected much more, which <a href="https://stratechery.com/2018/facebook-lenses/">helps consolidate their position</a>.</p><p>Ad blocking has been a way for users to push back against this sorry state of affairs. This has been driven by a general annoyance at advertising (remember pop-ups?) and a growing mindshare of privacy concerns in the zeitgeist. Browser extensions such as Adblock Plus and uBlock Origin are used by <a href="https://blockthrough.com/2020/02/06/2020-adblock-report-3/">hundreds of thousands of users</a> — and millions more use browsers which themselves started making third-party tracking more difficult or even offering ad blocking as a feature. But ad blocking, while effective against tracking, leaves content creators out in the cold, a fact many websites go to great lengths to inform the user of.</p><h3>Towards a better equilibrium</h3><p>We don’t blame any particular person or organization for this, but instead see the problem as an emerging property of the current market incentives. As such, the solution isn’t to replace the oligopolists, nor break them up, but to lay a new foundation of incentives on which a healthier market may develop.</p><p>We believe content creators should be paid for what they do, and that attention brokerage is the best solution we have to make that work at scale — not just for the long tail who can’t garner enough subscriptions or donations, but for everyone — because the Web should be open and free. We’re on a path to redesign how this attention is brokered, a path that stays clear from the <a href="https://www.theatlantic.com/technology/archive/2014/08/advertising-is-the-internets-original-sin/376041/">Web’s original sin</a>.</p><p>We’ve been working on the <a href="https://protocol.fractal.id/">Fractal Protocol</a>, an open source protocol designed to rebalance the incentives in this market. We believe we can build a new equilibrium that respects user privacy, rewards content creators, and protects advertisers from fraud. This is because, as I show below, we finally have the technology to get it done. Blockchain provides a trustless, shared source of truth for mechanism design. Zero-knowledge proofs and differential privacy help keep users safe. Decentralized identity and verifiable credentials brings people self-sovereignty over their own data.</p><p>The Fractal Protocol helps keep user data where it belongs: in the hands of the user. It does this by helping users collect, curate, verify and privately share data about themselves. It helps people be in control of their data, because Web browsers aren’t the true <a href="https://en.wikipedia.org/wiki/User_agent">user agents</a> that they were originally intended to be — they serve mostly the advertising oligopolists themselves, by mediating a person’s relationship with a Web in a way that works for the market they control, not the people they’re supposed to assist.</p><h3>Decentralized identity + privacy by design</h3><p>The content we see on the web adapts to who we are. This is because websites use data about us to customize what we are shown. In order to do so properly and confidently, it’s important that they can be certain of the data used for those decisions. Verified data commands an immense premium here — despite their size and invasiveness, the oligopolists can only make informed guesses about you. In fact, part of the reason for the ubiquity of tracking is that it gathers information by observing you, instead of directly asking who you are. By creating a market for verified data, the Fractal Protocol intends to incentivize its provisioning and verification, facilitating the emergence of a data commons where fair prices can be discovered.</p><p>Protecting personal and behavioral data, whether provided or observed, is of the utmost importance to us. In the past two years, we have verified over a hundred thousand identities that we protect with everything we have. As a KYC provider for many blockchain-based projects, we rapidly became experts in the field of identity and its verification, but we shouldn’t be the custodians of people’s data — people should do so themselves, and we want to help them. <a href="https://hackernoon.com/first-impressions-with-erc-725-and-erc-735-identity-and-claims-4a87ff2509c9">Decentralized identity and verifiable credentials</a> are not a novel idea, but are made possible with the help of blockchain technology. The concept works very much like in the physical world, where a person is given a physical credential by an authority (like a national ID issued by a government) and disclose it, voluntarily and without requiring government participation or knowledge, to a third party. By distributing these credentials to their legitimate owners, rather than centralizing them on our side, we can eliminate the security risk that any data honeypot poses while making sure users keep what’s theirs, regardless of what happens to us. We have <a href="https://medium.com/hackernoon/decentralized-identity-w3c-standards-and-the-ixo-keysafe-69d7e8d6fd7c">worked with these technologies in the past</a> with Sovrin and IXO, continue <a href="https://kilt-protocol.medium.com/fractal-kilt-protocol-and-polkadex-collaborate-to-provide-decentralised-kyc-solution-for-exchange-d9d0f8c18163">developing them today</a> with KILT, and they are critical to the Fractal Protocol.</p><p>There’s a little magic trick that physical credentials can’t do, called selective disclosure. Say I want to get into a place that restricts patronage by age: I might be asked for a recognized identity document in order to prove how old I am. For example, I might hand my driver’s license to a club bouncer, who inspects the document for authenticity and calculates my age from my date of birth. The problem with this is that I ended up having to share much more with the bouncer than I wanted: they now know my name and a series of other attributes that are irrelevant for what they are trying to do.</p><p>Coupling verifiable credentials with the privacy-preserving properties of <a href="https://www.wired.com/story/zero-knowledge-proofs/">zero-knowledge proofs</a> enables us to mathematically prove to any digital bouncer that we are over a certain age without revealing our name — or even our date of birth. Several technologies have proven successful in this regard, such as <a href="https://z.cash/technology/zksnarks/">zk-SNARKS</a>, <a href="https://docs.ethhub.io/ethereum-roadmap/layer-2-scaling/zk-starks/">zk-STARKS</a>, and <a href="https://crypto.stanford.edu/bulletproofs/">Bulletproofs</a>. By leveraging them, the Fractal Protocol enables people to share only the information they want to, and no more.</p><p>The Fractal Protocol does not ignore the privacy unraveling effect. Much like with the dynamics plaguing today’s market, it’s the incentives that are the problem, not necessarily the technology. The <a href="https://scholar.law.colorado.edu/articles/177/">unraveling effect</a> is an emerging property afflicting certain systems which incentivize data sharing poorly. Left unaddressed, it results in system participants being forced to share data against their will. This happens in scenarios where the choice to not disclose certain data is taken as prima facie evidence that these data are compromising for their owner. As a simplistic example, picture a health insurer who charges higher premiums to policyholders who smoke. In this scenario, a sufficient number of those choosing to offer evidence of their not smoking is bad news for those who choose not to follow suit. If a non-smoker isn’t willing to prove that fact about themselves, they’ll face a steeper bill — not because of any actual additional risk, but due to the health insurer assuming their silence is acquiescence.</p><p>Partial mitigation could be achieved through placing restrictions on the kinds of data being shared. We don’t believe this is a good solution, as we prefer the Fractal Protocol to be as flexible as possible in terms of data agnosticism. As such, we are working with experts on technical solutions such as <a href="https://en.wikipedia.org/wiki/Homomorphic_encryption">homomorphic encryption</a> and <a href="https://en.wikipedia.org/wiki/Differential_privacy">differential privacy</a>, both promising candidates for mitigating this issue. <a href="https://economics.princeton.edu/working-papers/bayesian-privacy/">Bayesian privacy</a> is particularly relevant, as it offers a mechanism for injecting noise into a dataset. The amount of noise is provable and does not significantly reduce the quality of the whole dataset. This would allow websites to keep leveraging the data the user chooses to share, without being able to tell, for a particular user, if the data is correct or not — all the while knowing, and being able to prove, the average level of correctness.</p><h3>The blockchain layer: why Polkadot?</h3><p>We are building the Fractal Protocol with the help of <a href="https://polkadot.network/">Polkadot</a>. They provide us with appropriate tools and infrastructure for successful development and deployment of the Protocol, without the compromises we would have to make with other platforms. Their vision is of a world with multiple blockchains, each tailor-built for a specific purpose. In order to deliver on this vision, Polkadot created <a href="https://substrate.dev/">Substrate</a> (an SDK for Polkadot-compatible blockchain building) and an infrastructure to connect and secure these unique blockchains</p><p>Building a unique blockchain is often the only way to get around issues of transaction costs and scalability of the currently available public infrastructure such as Ethereum. Securing a unique blockchain is no easy feat: they require the recruitment and continuous incentivization of validators in order to keep attackers at bay. Polkadot addresses this issue by offering a Relay Chain with its own validators, whose provisioned security is pooled and shared among the unique blockchains connected to it.</p><p>Polkadot is able to process 10,000 times more transactions per second than what Ethereum can currently offer. This is a staggering improvement to scalability, a critical requirement for projects like ours which anticipate and require high frequency blockchain usage. A consequence of this massive performance uplift is the corresponding decrease in competition for bandwidth. Together with the ability of unique chains to control their own transaction fees, this provides an environment in which scale isn’t only possible, but accessible.</p><p>We see Polkadot as a third-generation blockchain. By securing these purpose-built unique blockchains, they allow developers to focus on building the blockchain that’s fittest for their use case. By connecting them, they make it possible to leverage functionality available in other blockchains. Additionally, Polkadot is currently building bridging infrastructure to enable unique blockchains to communicate with other non-Substrate blockchains such as Bitcoin and Ethereum.</p><p>While this might sound complicated, Polkadot places a high premium on developer experience, and have invested significantly in building a growing ecosystem of tools for builders. In particular, Substrate and Cumulus make it easy to create a unique blockchain and connect it to their Relay Chain for security and interoperability guarantees.</p><h3>Looking ahead</h3><p>Protocol development should happen out in the open, and we’ll start publishing code and research as we finish designing and start building our MVP. We’re prototyping a browser-based data wallet that incentivizes users to provide their data and get it verified by an attester. The resulting credentials will be stored in the data wallet, and use blockchain-based verifiable credential infrastructure for validity checks and revocation. In order to help websites ask users for selective disclosure of these data, we’re building an SDK for publishers to use.</p><p>We’re growing our blockchain team — reach out to me at julio@fractal.id if you want to help us — and burrowing deeper into the Polkadot ecosystem by joining the <a href="https://www.substrate.io/builders-program/">Substrate Builders Program</a>. We’re also applying for a <a href="https://web3.foundation/grants/">Web3 foundation grant</a> and contributing code back to the community.</p><p>Please join us: the Protocol we are building is humble and open. It’s humble because we don’t propose to change the market overnight, but to listen, and progressively integrate into the ecosystem by identifying and delivering small components that can deliver value and generate traction on their own — starting with users and publishers. The Protocol is open because we will hold no control over it (anyone, from users to advertisers, can participate by design, regardless of what we think), and because we don’t seek rent (the protocol pays us no fees). More importantly, as any good and lasting standard, it must be conceived as an open source effort that can welcome, consider and leverage the participation of many different parties.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5b20527c948" width="1" height="1" alt=""><hr><p><a href="https://medium.com/frctls/private-by-design-building-the-webs-identity-layer-with-fractal-protocol-e5b20527c948">Private by Design: Building the Web’s Identity Layer with Fractal Protocol</a> was originally published in <a href="https://medium.com/frctls">Fractal ID</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Free KYC? Sign me up!]]></title>
            <link>https://medium.com/@julio_santos/free-kyc-sign-me-up-a6749e9bab4c?source=rss-8da70c852bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6749e9bab4c</guid>
            <category><![CDATA[identity]]></category>
            <category><![CDATA[onboarding]]></category>
            <category><![CDATA[kyc]]></category>
            <category><![CDATA[aml]]></category>
            <dc:creator><![CDATA[Júlio Santos]]></dc:creator>
            <pubDate>Tue, 05 Nov 2019 15:39:03 GMT</pubDate>
            <atom:updated>2019-11-05T15:39:03.180Z</atom:updated>
            <content:encoded><![CDATA[<p>At Fractal, we’ve been obsessing over customer onboarding for the past 2 years. We have assembled a brilliant and interdisciplinary team who successfully and meaningfully transformed the experiences of thousands upon thousands of users undergoing identity verification.</p><p>We realised very quickly that assuring compliance is increasingly costly for our clients, especially those working with a highly international user base. We also didn’t like what we see in this market: closed solutions, hidden pricing, a lack of developer friendliness and no clarity on how the product actually works.</p><p>So after this period of learning and extensive testing, we are now ready to offer the transformative solution the market is clamoring for: <strong>a fully-automated onboarding journey for identity verification and AML — plug and play, self-serve and for free.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*40BYd8tHnab-atT2o-JH5A.png" /></figure><h3>What is Fractal’s Free Tier?</h3><p>With Fractal ID’s basic free tier KYC/AML service, we aim to help new players overcome the cost of compliance, and make it easier for them to adhere to legal and regulatory guidelines within the ecosystem. We haven taken great care to design a user journey that is simple, fast and automated for immediate feedback, assuring maximum conversions and a happy user base.</p><p>Our free tier is an automated verification journey composed of four components:</p><ul><li>ID document verification (is the ID document authentic and valid?);</li><li>liveness detection (is this a real human, present right now?)</li><li>facial comparison (is this real human the same person as in the ID document?);</li><li>and PEP/Sanction Lists filtering.</li></ul><p>If any part of this automatic process fails, we don’t just automatically reject a user. Identities are as diverse as people, and we work hard to give every person every chance to get approved. Based on information collected from the user, as well as any required follow-up clarifications, our operations team analyses the case in order to make a manual deliberation.</p><p>Each of these components contributes to ensure that the claimed identification attributes exist and apply to the user claiming them. Check out <a href="https://free.fractal.id/">the product page</a> for more information.</p><p>On top of that, with Fractal, you don’t need to “call sales” — just use our self-serve Admin Dashboard to start verifying users.</p><h3>How do I get started?</h3><p>You just do: <a href="https://free.fractal.id/">we’re launching on November 1</a>.</p><p>All you need to do is head on over to our <a href="https://developer.fractal.id/">Admin Dashboard</a>, and follow our <a href="https://app.gitbook.com/@fractal-id/s/free-tier-product-description/simple-setup">simple instructions</a> to integrate your product with Fractal.</p><p>Please make sure to read our <a href="http://docs.developer.fractal.id/">Developer Documentation</a> for more information or troubleshooting.</p><h3>Why are we doing this?</h3><p>There is a whole new world of finance emerging. The massive crash of blockchain-based assets last year dissipated attention and investment, but the technology is no less promising than it was during the bull run. Relevant projects keep at it, decentralized finance is too far ahead to stop, and the global, borderless mentality of today’s builders isn’t going anywhere. However, these cross-border activities are making it increasingly difficult for companies and users to establish trusted and compliant business relationships. We want to see the open financial ecosystem thrive and are set to protect those pioneers that are leading innovation forwards. We want to support the emergence of a competitive, international, open financial landscape against the misuse of criminals and attacks from financial behemoths.</p><p>Requiring financial participants to make sure that their customers are no criminals is hopefully not going away. And this new world of open finance won’t exist without a standardized way to verify identity digitally and remotely, at a global scale. Today, where banks are enormous multi-billion dollar companies which operate nationally, identification is something they can handle themselves. In this new world, where a financial product can be offered by anyone to anyone, wherever they are, offering reliable identity verification as a service becomes paramount.</p><p>We believe Fractal can make a difference. New fintechs of the world, unite — and verify your users, with no hassle, for free.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6749e9bab4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Few Thoughts on Security Tokens]]></title>
            <link>https://medium.com/hackernoon/a-few-thoughts-on-security-tokens-d5a47f1fbd91?source=rss-8da70c852bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5a47f1fbd91</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[security-token]]></category>
            <category><![CDATA[token]]></category>
            <dc:creator><![CDATA[Júlio Santos]]></dc:creator>
            <pubDate>Fri, 07 Dec 2018 13:11:00 GMT</pubDate>
            <atom:updated>2018-12-07T13:11:00.836Z</atom:updated>
            <content:encoded><![CDATA[<h4>As understood by an engineer with no background in economics, finance or trading</h4><p>Our economy has evolved to consider and account for a variety of different assets: stocks, bonds, real estate, commodities, intellectual property, and many others. Trading some of these assets is constrained by their physicality, as it may be cumbersome to physically trade ownership, or even to subdivide the asset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7m50lvwhIO7BvmfDAy6Wsw.jpeg" /></figure><p>In order to help address this issue, we invented securitization. That’s the process of transforming ownership of an asset or a right into an easily tradable security. We predict that, with the emergence and maturity of blockchain technology, and the development of open standards, we will be enabled to expand on the concept and impact of securitization. We will do this through the tokenization of assets.</p><p>The digitization and standardization of securities trading has a long history already, but many of these systems remain walled gardens with no interoperability. They’re not open systems in which anyone, even with the right requirements, can participate at will. And they’re heavily intermediated by parties whose roles (providing trust and mitigating risk) could be made obsolete with the trustlessness, transparency and decentralized consensus of a blockchain system.</p><p>Now that we have the technological means to achieve it, tokenizing relatively illiquid assets and creating a market in which to trade these tokens is inevitable. Traditional, relatively illiquid assets stand to gain a substantial liquidity premium which, together with the slashing of fees due to disintermediation, represents an enormous market opportunity.</p><h3>Advantages of security tokens</h3><p>Tokenized securities are disruptive to modern financial markets because of their disintermediation potential, global exposure, and programmatic operation. A few advantages of security tokens are:</p><ul><li>lower fees</li><li>access to a global pool of capital</li><li>faster settlements</li><li>fractional ownership</li><li>24/7/365 markets</li><li>increased liquidity</li><li>no minimum investments</li><li>automated compliance</li><li>asset interoperability</li></ul><p>All these combined should lead to a greater market efficiency, and the programmatic nature of these tokens will open the floodgates for new financial technology. Building a standardized protocol on top of which quants and other developers can dream up new financial products and services is paramount, as it truly enables innovation to accelerate in the space. Critically, this innovation would be permissionless, as it wouldn’t be limited to the R&amp;D departments of the current large players in the financial space.</p><h3>Standardization and interoperability</h3><p>Standardization and interoperability are two crucial concepts in the movement for the opening up of financial markets.</p><p>Over the years the financial world has developed some standards, and it’s not a new idea. It would otherwise be impossible for your broker to hold shares in different companies using the same legal structure. Tokenization, however, enables us to take this concept to new heights by standardizing ownership in many different asset classes and making it possible for them to be held in the same wallet, used as collateral for loans, and straight up trading without the need for cash intermediation. I envision all asset classes to merge into a global pool of liquidity, interoperable through a common API.</p><h3>Automated compliance</h3><p>A great advantage of security tokenization is the potential for automated compliance. We’re experimenting with a token with embedded compliance: a compliance-native token if you will. This prevents the tokenized security from falling into the wrong hands, while maintaining disintermediation at the trading stage.</p><p>It’s easy to conceive of a naïve version of this technology. For those familiar with the ERC-20 standard, you can picture expanding on that contract with a restriction so that ownership transfers can only happen for addresses which have been registered as having undergone the proper level of financial due diligence (KYC/AML/CFT, capital markets regulations, investor accreditation).</p><p>These security tokens, with embedded compliance, should make the compliance process so seamless and auditable that I predict regulators will start demanding the tokenization of securities for these advantages alone. The enforcement of regulations will be that much simpler in this world. There’s good reason to believe this will happen, as <a href="https://www.sec.gov/info/edgar/regoverview.htm">we’ve seen regulators demanding technology adoption in the past</a>.</p><p>Regulation will, inevitably, have to evolve. Some countries regulate the form under which some ownership transfer has to take place, or demand a physical paper trail. We believe that competitive pressures brought about by pioneer local financial markets will push other regulators to embrace this new technology.</p><h3>A sample technical draft</h3><h4>Embedded compliance</h4><p>Picture, as described above, a token instantiation contract which requires buyers to have undergone some level of KYC. The buyer would have to submit themselves to a thorough registration by an identity provider, such as <a href="https://medium.com/frctls/introducing-fractal-id-gateway-to-the-web-3-0-8169b4291d45">Fractal ID</a>. Upon successful verification, Fractal ID could provide them with a cryptographically signed claim of such KYC verification, which they can use as an attestation for the token contract to prove their eligibility to buy. At that point, the contract will allow a sale, by allowing ownership in the tokens to be attributed to this buyer.</p><p>An interesting possibility of the mechanism devised above is that the token contract doesn’t need to know the identity of the buyer, only that they underwent a required level of KYC, provided the contract trusts Fractal’s claims.</p><h4>Automatic liquidity provisioning</h4><p>This is an example of what a smart contract / application network could look like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C5hQMV1eHZLKeHXSVtKO2A.png" /></figure><p>The example above provides the following functionality:</p><ul><li>Onboarding/tokenization of offline assets</li><li>Registration of tokenized assets</li><li>Price discovery</li><li>Automatic loan applications</li><li>Liquidity provisioning</li><li>Loan insurance</li><li>Credit/reputation scoring</li></ul><p>As an example, let’s assume a loan marketplace to which an investor has provided liquidity, to be provisioned for loans that meet certain acceptance criteria. For example, the loan must be collateralized by tokenized assets, insured by a third party, and only granted to individuals with a certain credit score. At this point, an individual can use their registered Cryptokitties, which are dynamically priced, as collateral for said automated loan. This loan is then managed by the escrow contract, which holds custody of the collateral and the provisioned liquidity. The user would make regular interest payments on the loan to this contract, which are passed on to the investor.</p><p><strong>Planning an ICO?</strong> At <a href="https://www.trustfractal.com/business/">Fractal</a>, we offer a hassle-free, user-friendly launchpad solution combined with a comprehensive customer identification service (KYC/AML) to successfully deploy your token launch with ease.</p><p><strong>Building an exchange?</strong> <a href="https://medium.com/frctls/introducing-fractal-id-gateway-to-the-web-3-0-8169b4291d45">Fractal ID</a>’s got you covered with user authentication, KYC &amp; AML. <a href="https://trustfractal.com/business/">Talk to us</a> or check out the <a href="https://github.com/FractalBlockchain/id-integration-docs">integration docs</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5a47f1fbd91" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/a-few-thoughts-on-security-tokens-d5a47f1fbd91">A Few Thoughts on Security Tokens</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[Decentralized identity: W3C standards and the ixo KeySafe]]></title>
            <link>https://medium.com/hackernoon/decentralized-identity-w3c-standards-and-the-ixo-keysafe-69d7e8d6fd7c?source=rss-8da70c852bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/69d7e8d6fd7c</guid>
            <category><![CDATA[ixo-keysafe]]></category>
            <category><![CDATA[w3c]]></category>
            <category><![CDATA[blockchain-identitiy]]></category>
            <category><![CDATA[decentralized-identity]]></category>
            <category><![CDATA[w3c-standards]]></category>
            <dc:creator><![CDATA[Júlio Santos]]></dc:creator>
            <pubDate>Fri, 10 Aug 2018 16:13:51 GMT</pubDate>
            <atom:updated>2018-08-10T16:13:51.460Z</atom:updated>
            <content:encoded><![CDATA[<h4>And how to provably associate a DID with a person</h4><p><a href="https://ixo.foundation/faqs/">ixo</a> is the blockchain for sustainable development impacts, aiming to help standardize the measurement and rewarding of impact. Through their protocol and native IXO tokens, ixo plans to incentivize the funding and tracking on impact projects through unlocking a new economy for collecting and verifying impact data.</p><p>It’s crucial for ixo to encourage data integrity. As such they’re highly involved in the decentralized identity space, because it’s important that the several network stakeholders are properly identified. ixo uses the W3C DID and Verifiable Claims standard drafts to facilitate this process.</p><p><em>(See also: on decentralized identity, I previously wrote about ERC 725 and ERC 735 in the context of implementing a simple KYC claim verification for a crowdsale, check it out below.)</em></p><p><a href="https://hackernoon.com/first-impressions-with-erc-725-and-erc-735-identity-and-claims-4a87ff2509c9">First impressions with ERC 725 and ERC 735 — identity and claims</a></p><h3>The W3C standards</h3><p>The W3C, always the trailblazer, has been hard at work on standards for <a href="https://w3c-ccg.github.io/did-spec/">Decentralized Identifiers</a> and <a href="https://www.w3.org/TR/verifiable-claims-data-model/">Verifiable Claims</a>.</p><p><em>(Note that the examples provided below are vastly simplified for clarity, and kind of butcher the well-crafted standards.)</em></p><h4>DIDs — Decentralized identifiers</h4><p>DID stands for <em>Decentralized Identifier</em>, and represents a new identifier for an identity that is detached from central control. From <a href="https://w3c-ccg.github.io/did-spec/">the horse’s mouth</a>:</p><blockquote>Decentralized Identifiers (DIDs) are a new type of identifier for verifiable, “self-sovereign” digital identity. DIDs are fully under the control of the DID subject, independent from any centralized registry, identity provider, or certificate authority.</blockquote><p>They had me at <em>self-sovereign</em>. Onwards:</p><blockquote>DIDs are URLs that relate a DID subject to means for trustable interactions with that subject. DIDs resolve to DID Documents — simple documents that describe how to use that specific DID.</blockquote><p>Here’s an example of what a DID Document could look like:</p><pre>{<br>  &quot;did&quot;: &quot;did:example:person-123456789&quot;,<br>  &quot;pubKey&quot;: &quot;DDoFgPQ4JyjrsBwqGg2yCoZdGk5x11k7nGXXeg3wokFy&quot;<br>}</pre><p>This simple document declares a DID and its corresponding public key (more complex documents can include other info, such as the location of associated personal data, or the DID owner’s agent). There isn’t much one can do with this in isolation. However, combining a DID with verifiable claims is quite powerful. <strong>Proving ownership of a DID on which a trusted claim has been made would grant you access to whatever the claim grants you access to</strong>. Let’s explore.</p><h4>Verifiable Claims</h4><p>Verifiable Claims are a method for trusted parties to provably issue a credential on a DID (c<em>laim</em> and <em>credential</em> are used interchangeably in this post). Again, the W3C:</p><blockquote>Driver’s licenses are used to claim that we are capable of operating a motor vehicle, university degrees can be used to claim our education status, and government-issued passports enable holders to travel between countries. This specification provides a standard way to express these sorts of claims on the Web in a way that is cryptographically secure, privacy respecting, and automatically verifiable.</blockquote><p>Think of a traditional driver’s license. It’s usually issued by a trusted party (your local motor vehicle authority) on a person identified by a government ID. They evaluate your driving skills and, if you pass muster, they’ll associate a claim with your government ID saying you’re fit to drive.</p><p>Verifiable claims are a more secure way to achieve the same result on DIDs. If my identifier with the motor vehicle authority is not my government-issued ID, but a DID, how would this work?</p><p>First, they’ll need to verify that the applicant owns the DID they claim to. This is done through the use of public-key cryptography, as will be described later in this post.</p><p>Once that verification is completed, the authority can issue a claim confirming the applicant’s ability to drive. This is what it could look like.</p><pre>{<br>  &quot;issuer&quot;: &quot;did:example:trusted-authority-123&quot;,<br>  &quot;issued&quot;: &quot;2010-01-01&quot;,<br>  &quot;claim&quot;: {<br>    &quot;id&quot;: &quot;did:example:person-123456789&quot;,<br>    &quot;canDrive&quot;: true<br>  },<br>  &quot;signature&quot;: &quot;g4j9UrpHM4...&quot;<br>  }<br>}</pre><p>This represents a claim by did:example:trusted-authority-123 that the DID did:example:person-123456789 can drive. Anyone could produce a similar document. What makes this claim verifiable is that it’s signed. That is, we know that the signature value could only be correctly produced by the owner of did:example:trusted-authority-123 (because cryptography). This means that, if we know that did:example:trusted-authority-123 indeed represents the authority it claims to be, we can trust this claim to be legitimate, and ascribe did:example:person-123456789 the ability to drive.</p><p>Here’s a use case. Suppose you’re stopped by your local transit authority for a random document check. All they really need to know is that you’re authorized to drive. However, a traditional driver’s license contains a lot of other unrelated data (such as your name and address), and all that data leaks in the document check process. Proving ownership of your DID and showing the associated claim will yield only the information required and no more.</p><h3>Identities and claims on the IXO blockchain</h3><p>In order to make it easier for people to register with ixo’s network, the ixo Foundation forked <a href="https://metamask.io/">MetaMask</a> and built KeySafe, a browser extension that simplifies the process for someone to create a decentralized identity. KeySafe generates a decentralized identifier (DID) on behalf of the user. From the <a href="http://ixo.foundation/wp-content/uploads/2017/12/The-ixo-Protocol-Draft-White-Paper-3.0-for-technical-review-12_8_2017.pdf">draft whitepaper</a>:</p><blockquote>Each participant in an Impact Exchange project […] is identified as an entity, using a Digital Identifier [DID]. Entities can refer to natural persons, organizations, software agents or devices. For instance, an Evaluation Agent could be an identified software agent that functions as a Smart Oracle, checking submitted claims data against external data references and performing algorithmic calculations, to arrive at a conclusion that verifies<br>the claim. These identifiers resolve back to verifiable identity credentials, such as a proof of skills qualification, that can be used to determine the eligibility of the entity to exchange their claim for funding.</blockquote><p>In order for someone to register with ixo, this DID needs to be ledgered on ixo’s blockchain.</p><h4>Setting up KeySafe</h4><p>Once installed, a user must set up KeySafe for the first time. This setup process will generate a DID for the user (more precisely, it generates a public/private key pair, and derives the DID from the public key), as seen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PEXvSbqBtbeGc7_h-V6Qqg.png" /><figcaption>Generating a DID with KeySafe (simplified journey)</figcaption></figure><p>Once the user has followed the journey and a DID is generated, it’s time to register the DID on the ixo blockchain.</p><h4>Ledgering the DID</h4><p>In order to ledger the DID on the ixo chain, ixo requires a proof of ledgering intent. In other words, ixo must know that the owner of the DID must have wanted this ledgering to occur. As such, whomever issues the request for ledgering (be it the DID owner or a third party) must prove this intent.</p><p>A way to verify that this is true is by requiring that the ledgering request payload contains a signature of said payload. This is what the payload looks like.</p><pre>{<br>  payload : [<br>    10,<br>    didDoc: {<br>      did: &quot;did:sov:person-123&quot;,<br>      pubKey: &quot;DDoFgPQ4JyjrsBwqGg2yCoZdGk5x11k7nGXXeg3wokFy&quot;,<br>      credentials: [],<br>    },<br>  ],<br>  signature: {<br>    signatureValue: [<br>      1,<br>      &quot;8B81986B9E458E3B6D55F...&quot;,<br>    ],<br>    created: &quot;2018-07-20T16:50:07.420Z&quot;,<br>  },<br>}</pre><p>That long hex inside signature is the result of signing the didDoc in the payload with the DID&#39;s private key. We first transform the didDoc into JSON:</p><pre>{&quot;didDoc&quot;:{&quot;did&quot;:&quot;did:sov:PRTxGnvgX7YGPCTkVfwevH&quot;,&quot;pubKey&quot;:&quot;DDoFgPQ4JyjrsBwqGg2yCoZdGk5x11k7nGXXeg3wokFy&quot;,&quot;credentials&quot;:[]}}</pre><p>And then have KeySafe prompt the user to sign it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*fQi7D-rNFVgJ7DNt34IuNA.png" /><figcaption>KeySafe prompting the user to sign the ledgering payload</figcaption></figure><p>When we submit this payload to the <a href="https://ixofoundation.github.io/mkdocs/api/#ixo-blockchain-api">ixo Blockchain API</a>, this signature will be verified before any ledgering occurs. Only a successful verification will result in ledgering. There are 2 steps to this verification.</p><p>The first step is to confirm that the supplied DID and public key match. Skipping this step would allow an attacker to supply a different public key, whose private key they control, and use it to generate a valid signature.</p><p>A DID can be matched to a public key because the DID itself is derived from the public key. We then simply have to check that the supplied DID is the same as the one derived from the supplied public key, as such.</p><pre>base58.encode(base58.decode(publicKey).slice(0, 16))</pre><p>The signature itself can be verified through an algorithm which takes the original message, the public key, and the signature as inputs. Only an agent in possession of the DID’s private key will be able to generate a signature that will pass this verification.</p><p>It’s important to note that this process doesn’t prove that the registrant is actually in possession of the DID’s private key. An attacker might have found this signed message elsewhere (in the ixo chain, for example). This isn’t much of a problem: the private key can not be calculated from a message+signature pair, so all the attacker can do is replay the ledgering, which is presumably an idempotent operation.</p><p>As such, this proof is enough for ixo. Since the only way for an attacker to successfully register this DID is having found this signature elsewhere already, we can assume ledgering has occurred already and that, when it did, it was done by the DID owner (since the correct signature could have only been produced by the owner of the private key).</p><h4>Provably associating a person with a DID</h4><p>ixo, however, cares about associating a DID with an actual person. As an identity provider, we at <a href="https://trustfractal.com/business/">Fractal</a> then need to conduct a KYC process on an individual to prove their identity. We must also prove their ownership of a DID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*5V1glyovL0rvVSGZHHUGBA.png" /><figcaption>Asking the user to sign a challenge nonce</figcaption></figure><p>As such, Fractal needs to subtly alter their KYC procedure for identity provisioning. Alongside the normal identity questions, we will ensure the user has KeySafe installed and configured.</p><p>Once this has been confirmed, Fractal can issue a cryptographic challenge: we ask the user to sign a message whose contents are plausibly unique (a <a href="https://en.wikipedia.org/wiki/Cryptographic_nonce">nonce</a>). This uniqueness guarantees that there’s little to no chance that such a message has been signed before, making it next to impossible for the attacker to supply a correct signature as a response to this challenge.</p><p>A way to make this message plausibly unique is to use a <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a>. If the user is able to produce a valid signature (as defined above), it must mean they are in possession of the DID’s private key.</p><p>Now that we have confirmed the association between a person and a DID, we’re ready to sign and issue a claim on their KYC status. We can then broadcast the following into the ixo blockchain.</p><pre>{<br>  &quot;issuer&quot;: &quot;did:sov:fractal-123&quot;,<br>  &quot;issued&quot;: &quot;2010-01-01&quot;,<br>  &quot;claim&quot;: {<br>    &quot;id&quot;: &quot;did:sov:person-123&quot;,<br>    &quot;kycLevels&quot;: [&quot;IdentityVerified&quot;, &quot;AccreditedInvestor&quot;]<br>  },<br>  &quot;signature&quot;: &quot;g4j9UrpHM4...&quot;<br>  }<br>}</pre><p>And boom — ixo can now rest assured that this DID does indeed match to a person, whose identity has been validated by Fractal.</p><p><strong>Planning an ICO?</strong> At <a href="https://www.trustfractal.com/business/">Fractal</a>, we offer a hassle-free, user-friendly launchpad solution combined with a comprehensive customer identification service (KYC/AML) to successfully deploy your token launch with ease.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69d7e8d6fd7c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/decentralized-identity-w3c-standards-and-the-ixo-keysafe-69d7e8d6fd7c">Decentralized identity: W3C standards and the ixo KeySafe</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[Blockchain 101 - Decentralization, Cryptoeconomics and ICOs]]></title>
            <link>https://medium.com/@julio_santos/blockchain-101-decentralization-cryptoeconomics-and-icos-eb56f20932dc?source=rss-8da70c852bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb56f20932dc</guid>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[ico]]></category>
            <category><![CDATA[cryptoeconomics]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Júlio Santos]]></dc:creator>
            <pubDate>Sun, 01 Jul 2018 08:01:23 GMT</pubDate>
            <atom:updated>2018-07-23T07:38:50.139Z</atom:updated>
            <content:encoded><![CDATA[<h3>Blockchain 101 — Decentralization, Cryptoeconomics and ICOs</h3><h4>My introductory talk at Commit Porto 2018</h4><p>I was invited by <a href="https://commitporto.com/">Commit Porto</a> to give an introductory talk about blockchain at their 2018 edition. Below is the video, the slides and the transcript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o3mikYXFLWAEatlYwIcu9g.jpeg" /><figcaption>Background: Photo by <a href="https://unsplash.com/photos/xsGApcVbojU?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Dmitry Ratushny</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Video recording</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FmMmA_PHGHvM%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DmMmA_PHGHvM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FmMmA_PHGHvM%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/5675af9bc27d69d575a13e6702d762b7/href">https://medium.com/media/5675af9bc27d69d575a13e6702d762b7/href</a></iframe><h3>Slides and transcript</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*vILTx-tz21-o6qu4oX4t0A.jpeg" /></figure><p>I’d like to start by clarifying what this talk is not about. I’m not about to mindlessly drone on about how some new shitcoin will disrupt disruption. I’m certainly not going to give anyone investment advice.</p><p>I’m going to explain why I believe blockchain technology is worth your time, and why I’m devoting myself to it for the years to come. I’ll start by covering the topic of decentralization, why it’s a good thing, and give you my perspective on why blockchain is uniquely positioned to help us go down that road.</p><p>I’ll also talk a bit Bitcoin and Ethereum in the context of cryptoeconomics, and wrap up with a short explanation of what ICOs are, and why they’re an exciting new form of financing the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*NTIvT5LzUzVl4yuFYZ8NWA.jpeg" /></figure><p>When people talk about decentralization, they’re coming mostly from cypherpunk or libertarian perspectives. They talk about censorship resistance. It’s simply beautiful that I can use the Bitcoin network to transfer value to anyone, or that I can use Ethereum to perform arbitrary computations, and that nobody can stop me from doing so.</p><p>This perspective is not wrong, and it’s very dear to my heart. But it’s incomplete. It misses a larger point.</p><p>Centralized services are inherently insecure, as they grow into hacker honeypots. A fitting analogy for blockchain security is that it’s easier to rob a bank than to rob every single one of its customers. We have to look no further than the current Equifax data breach, which exposed more than 100M people to identity theft and credit card fraud.</p><p>Secondly, and perhaps more importantly, the incentives of a centralized platform necessarily benefit the platform’s owner as it grows in size and scope, at the expense of other stakeholders. When these start out, they do everything they can to recruit users and third-party ecosystem participants like application developers. This is because the more users there are on the platform, the more valuable the platform becomes. The same goes for its ecosystem: the more vibrant it is, the more users the platform will be able to attract. As the platform’s adoption grows, so does its power over the very participants which enabled this growth.</p><p>Predictably, this power asymmetry quickly turns attraction into extraction, and cooperation into competition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*UCpQ7gXEHu17VAMwRFg-TQ.jpeg" /></figure><p>This chart by Andreesen Horowitz captures these dynamics neatly. Take Twitter as an example. When it started out, it offered a great service for free. It encouraged developers to build on its network, which caused an explosion of third-party apps that helped popularize the service and drive adoption. As it grew in users and power, it started extracting value from users, charging them for the service by introducing ads. It also started phasing out third-party apps, regarding them as competitors for eyeballs. More importantly, only Twitter had a say in the matter.</p><p>This is a common path for centralized networks. Developers are becoming wary of building on top of centralized services. Why wouldn’t they?</p><p>Users, too, tend to get the short end of the stick. They’re vulnerable to arbitrary decisions by a central authority. Which content and behaviors are allowed? Which features get developed? Which people are admitted and banned? Users are mostly unable to vote except with their feet. But, way too often, they don’t have anywhere else to turn to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*TxgcxAAfHA5VmEEM03hqXg.jpeg" /></figure><p>Blockchain technology holds the key to push back against this centralization. It promises to take back the internet from the incumbent juggernauts, and give everyone else a much fairer chance at participation.</p><p>It does this because it introduces a new feature into networks: trust. Trust between the users, developers, and other network stakeholders. This trust comes first and foremost from the way the blockchain is cryptographically secured. Additionally, and more interesting still, is how game theory can be used to develop token economies on top of this trust layer, which turn blockchains into incentive machines. This essentially makes it possible for us to trust the network, without having to trust any of its individual participants.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*PFjXzxE1eL-mnYMkuoOu1A.jpeg" /></figure><p>In order to get a better grasp of what is meant by incentive machines, let’s talk about Bitcoin.</p><p>The concept of a blockchain, as a cryptographically secured chain of blocks, emerged almost 30 years ago. About a decade ago, an entity named satoshi leveraged this data structure to create Bitcoin: a proof of concept for a fully decentralized currency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*fpMudQ-I9NoI4wDLPLTT5w.jpeg" /></figure><p>Say that Alice and Bob have an account at the same bank. Because of fractional reserve banking, where banks don’t need to keep everyone’s money at hand, their money is essentially just a number in a database. When Alice transfers €100 to Bob, the bank essentially subtracts 100 from Alice’s number, and adds 100 to Bob’s. Both of them are trusting the bank to do this properly. They have no choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*PKzWw97gL7nu1Qd_zuagfg.jpeg" /></figure><p>Bitcoin proposed to keep these balances differently. Instead of relying on a trusted third party, like a bank, it suggested decentralizing its upkeep to thousands of participants, who would maintain a common ledger. Every participant would keep a copy of every transaction, and help make sure that only valid transactions make it onto the common ledger. This way, there’s no single point of failure. It’s harder to hack thousands of computers than a single one, no matter how secure it is.</p><p>The important takeaway is this. The great innovation of Bitcoin wasn’t that it became the first large-scale application to use a blockchain. It’s that it found a way to incentivize these thousands of participants to contribute to the network our of their own self-interest. It did so by creating the very first blockchain token.</p><p>The mechanism is simple. In order to participate in the network, you become a miner. To do this, you run this open-source peer-to-peer software that is kind of like a lottery ticket. If you’re lucky, you could be rewarded with newly minted bitcoin.</p><p>This mechanism worked. Bitcoin today has thousands of nodes participating in its network. Every additional nodes makes it a bit harder for the network to be compromised, since it makes it increasingly difficult to orchestrate an attack.</p><p>Personally, I’m very skeptical of the notion of a single decentralized currency. Currencies with a large user base, like the Euro or the Dollar, tend to be managed by very smart people in response to economic conditions, and I don’t think Bitcoin will quite replace them. It happened to take off, and is now worth upwards of 100 Billion, but that’s not where my focus lies. I don’t care much for the currency use case. I used it as an example because it’s the best known project, and because it’s dead simple to explain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*b4P7PNCNk3MAWY5qD-ua3g.jpeg" /></figure><p>Let’s move on, and talk about Ethereum, a much more interesting platform.</p><p>A few years after Bitcoin came out, Vitalik Buterin, who had tried and failed to convince the bitcoin community that it needed to be upgraded to support more use cases, proposed Ethereum.</p><p>Bitcoin can’t do much else than value transfers. Ethereum, on the other hand, was to be a world computer, a platform for arbitrary computation and storage, on top of which distributed applications could be built. The building blocks for these applications are now called smart contracts. They are turing-complete pieces of code, stored on the blockchain, that network participants can deploy and interact with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*wqimXJFB1v2nJclidHb3cQ.jpeg" /></figure><p>Since Ethereum would support arbitrary computation and storage, and since every node would have to run said computation and store said storage in order to participate, running an Ethereum node could get expensive. In order to keep costs under control, Ethereum introduced the concept of gas: a network fee, which increases with the complexity of the computation and the size of storage.</p><p>This gas is paid in ether, a cryptocurrency native to Ethereum. Ether is more correctly denominated an “utility token”. It’s called that way because its whole purpose is to pay for network utility. Having to pay gas in ether incentivizes network users to place only as much strain on the network as necessary, and penalizes poorly constructed code and excessive storage. It also helps prevent denial of service attacks.</p><p>Ethereum rewards its network participants in a similar way to Bitcoin. It incentivizes them to run Ethereum software to validate transactions, and it rewards them with newly minted Ether as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*-Ez_rAUNXIjnbPxr2jrhJQ.jpeg" /></figure><p>Bitcoin and Ethereum are relatively simple examples of how the emerging field of cryptoeconomics works. As Vitalik himself puts it, cryptoeconomics is about using economic incentives to reward participants who further the system’s objectives, and penalize participants who harm the system’s objectives.</p><p>Ethereum has been instrumental to the recent explosion of the blockchain space. On top of it, a whole new class of decentralized applications are being built. People are experimenting with self-sovereign identity systems, voting, insurance contracts, supply chain tracking and financing, and much more.</p><p>The simple cryptoeconomic mechanics that Bitcoin and Ethereum pioneered are serving as an inspiration for a new class of solutions. Prediction markets help tap into humanity’s collective knowledge in order to help see the future, while incentivizing participants to remain honest. Token curated registries introduce a mechanism to guarantee reliable curation of lists. Social networks are using cryptoeconomics to get over the cold start problem. Dating apps are using token design to reduce spam and increase the quality of matches. And much more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*VKhKx-CRfxMsQ0CukMHkHA.jpeg" /></figure><p>I’d like to take a quick detour to talk about another use case for blockchain tech which I believe is really easy to understand: digital scarcity.</p><p>Digital scarcity is obviously implied when we speak of cryptocurrencies. After all, if there were infinite bitcoins, their value would drop to zero. A currency only has value if there’s a limited amount of it.</p><p>There are contexts other than currency in which scarcity plays a vital role. Fine art is a well understood case study on scarcity.</p><p>Why would I buy an original Picasso? It’s not because it looks better than a copy. It’s because I get to say I’m the one who owns it. Bragging rights have long been a reliable driver of economic activity.</p><p>Scarcity has been absent from the digital world. After all, information wants to be free, as it should. Creation and curation should be rewarded, but I don’t believe there should be barriers to consumption.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*P35EjW18ASZHZZC7SUHU5w.jpeg" /></figure><p>Digital artists have a hard time monetizing their work. Why would I pay you for a gif, if anyone else can copy it and get it for free? So they resort to platforms like Patreon, where content lovers gather to reward content creators. All a digital artist can do is ask their Instagram followers to go to Patreon and sponsor them. Which is amazing. I love Patreon, and I’m a contributor myself. But I think this model is incomplete, because it amounts to little more than charity.</p><p>Blockchain technology offers an alternative which is modeled on good old bragging rights. Instead of asking for donations, digital artists could sell the ownership of an original. This ownership is a permanent blockchain record, and serves as an inviolable proof that I am the person who owns the original. No matter how many times it is copied.</p><p>This isn’t the stuff of dreams, it’s already being built. Platforms like Azelo can even guarantee that the artist will always be paid a fee for every subsequent sale. I’m excited for what this could mean for the future of digital art.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*hH_Pn33MmtRSZKxM5sRX7Q.jpeg" /></figure><p>Let’s wrap up this talk with a short note on ICO, or token sales. ICO means Initial Coin Offering. It is a pun on IPO, or initial public offering, which is what happens when a company gets quoted on the stock market, and sells stock to the public for the first time.</p><p>ICOs are an innovative fundraising mechanism. What gets sold isn’t necessarily a share in a company, but rather tokens, which constitute a share in a network.</p><p>In order to understand how they work, let’s go back to Ethereum. In order to fund the development of their network, Ethereum conducted an ICO. They sold ether, their network token, in exchange for Bitcoin, part of which they converted to cash to fund their operations.</p><p>So far this is easy to grasp: having money to build things is good. But why would anyone participate in this? In short, for the same reason they would buy shares of a company’s stock.</p><p>People buy shares because they hope the company will go up in value, and so will their share. A share is a slice of a company’s metaphorical pie, and so when the pie grows in size so will each individual slice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*xJBJxwI4GaRsOBZ-liXyeA.jpeg" /></figure><p>The mechanics with ICOs are slightly different, even though the general principle remains the same. For example, with Ethereum, the expectation is that, as the value of the network increases, more people want to use it. In order to use it, they need to buy ether to pay for gas. Because the amount of ether is limited, more demand for ether exerts an upward pressure on its price, as per the law of supply and demand. As such, buying tokens in an ICO, or in general at an early stage of the network, could yield great returns as the network and consequently those tokens appreciate in value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*DlRVSxB4omQ1FNFw5xvuIg.jpeg" /></figure><p>Unfortunately, the ICO space has been rife with scams and bullshit. Even when there are honest intentions, people misunderstand the scope of applicable law and handwavily dismiss their legal responsibilities by calling the space “unregulated”. This is not true, and it’s a dangerous belief to hold. Raising money, and selling things in general, has a pretty tight legal grip. While it’s fair to complain that the law doesn’t address cryptocurrencies in particular, ICO issuers still have to abide by the spirit of capital markets and consumer protection regulations.</p><p>Time for a little shameless plug! Regulatory compliance is what my company Fractal does. We help companies conduct their ICOs in a globally compliant manner, respecting KYC, AML and capital markets regulations for almost any jurisdiction worldwide. Talk to us if you’re planning an ICO. Or if you’re a great developer looking to get into crypto.</p><p><strong>Planning an ICO?</strong> At <a href="https://www.trustfractal.com/business/">Fractal</a>, we offer a hassle-free, user-friendly launchpad solution combined with a comprehensive customer identification service (KYC/AML) to successfully deploy your token launch with ease.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb56f20932dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[First impressions with ERC 725 and ERC 735 — identity and claims]]></title>
            <link>https://medium.com/hackernoon/first-impressions-with-erc-725-and-erc-735-identity-and-claims-4a87ff2509c9?source=rss-8da70c852bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a87ff2509c9</guid>
            <category><![CDATA[erc725]]></category>
            <category><![CDATA[erc-735]]></category>
            <category><![CDATA[identity]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[standards]]></category>
            <dc:creator><![CDATA[Júlio Santos]]></dc:creator>
            <pubDate>Mon, 25 Jun 2018 12:26:01 GMT</pubDate>
            <atom:updated>2022-06-29T06:58:49.580Z</atom:updated>
            <content:encoded><![CDATA[<h4>Implementing a simple KYC claim verification for a crowdsale</h4><p><strong>ℹ️ This was published in early 2018. Since then, </strong><a href="https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-6-KeyManager.md"><strong>LSP-6</strong></a><strong> has superseded ERC-735. Be sure to </strong><a href="https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-6-KeyManager.md"><strong>check it out</strong></a><strong>!</strong></p><p>At <a href="https://www.trustfractal.com/business/">Fractal</a>, we’re focused on improving the ICO experience, from both a UX and a regulatory compliance perspective. One of the crucial bits of a successful ICO is proper participation eligibility verification (KYC, AML, CFT, capital markets regulations, etc). As such, we’re closely watching the identity space, following projects such as <a href="https://sovrin.org/">Sovrin</a>, <a href="https://www.taqanu.com/">Taqanu</a>, <a href="https://www.uport.me/">uPort</a>, and <a href="https://www.civic.com/">Civic</a>, and experimenting with potential integrations.</p><p><a href="https://medium.com/u/4b59b3ef14a2">Fabian Vogelsteller</a>, the creator of the <a href="https://github.com/ethereum/mist">Mist Browser</a> and <a href="https://github.com/ethereum/web3.js/">web3.js</a>, is working on a new identity standard for Ethereum, <a href="https://github.com/ethereum/EIPs/issues/725">ERC 725</a>. When used together with his other brainchild <a href="https://github.com/ethereum/EIPs/issues/735">ERC 735</a>, a standard for the management of identity claims, it is a very powerful tool for working with real identities on-chain.</p><p>Inspired by <a href="https://medium.com/u/917ab3f96fd7">Nick Poulden</a>, who took these standard drafts and created <a href="https://medium.com/originprotocol/managing-identity-with-a-ui-for-erc-725-5c7422b38c09">a great visual demonstration of how they can be combined</a>, I decided to put together a small write-up that’s more focused on code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fwvt1sbeHiz7HRMz7FIOPQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/OHnvp41aDzE?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">CMDR Shane</a> on <a href="https://unsplash.com/search/photos/fingerprint?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>An overview of the standards</h3><p>One of the best things about ERC 725 and 735 is that they’re open, community-driven, and participatory standards. They’re also quite simple to understand, as they’re small, targeted standards which do one thing each but do it really well: manage identities and claims on those identities.</p><h4>ERC 725: Identity</h4><blockquote>The following describes standard functions for a unique identity for humans, groups, objects and machines.<br>This identity can hold keys to sign actions (transactions, documents, logins, access, etc), and claims, which are attested from third parties (issuers) and self attested (<a href="https://github.com/ethereum/EIPs/issues/735">#ERC735</a>), as well as a proxy function to act directly on the blockchain.</blockquote><p>ERC 725 is a standard for publishing and managing an identity via a smart contract on an EVM-based blockchain, such as Ethereum. This identity is represented by its chain address.</p><p>We can associate several keys with this identity. These keys can have different purposes: the standard currently proposes MANAGEMENT, ACTION, CLAIM and ENCRYPTION. Keys are keccak256s of public addresses¹, and as such map to externally owned accounts (wallets) or smart contracts.</p><p>Another important concept is that an ERC 725 contract can be used as a proxy, through its execute / approve methods. If a third party recognizes the legitimacy of a given identity contract, its owner can call execute on it to transact with said third party, as we’ll see below in our KYC example.</p><p>Multiple keys are particularly useful in the context of privileged access. For example, suppose this identity is not for an individual, but an organization. Members holding less privileged keys can submit transactions to execute, but only those with access to higher-privilege keys can approve the execution of those transactions.</p><p>We can go even further down this rabbit hole. Since keys can also map to smart contracts instead of wallets, further access requirements could potentially be implemented. For example, having an ACTION key which maps to an AccessControl contract allows us to build arbitrarily complex access control levels in this contract. This is important because it keeps the standard itself simple, while simultaneously supporting every imaginable use case.</p><p>Another example has to do with revoking claims. If we’re using our identity to make claims on another identity, it can be useful to have several CLAIM keys — deleting any one of them would cause the associated claims to lose their validity.</p><p>For a real-world example, suppose Mozilla has an Identity contract. Aside from whatever else Mozilla chooses to do with that identity, The Firefox software team could hold one of the keys belonging to that identity, with which they’d sign software checksums upon release.</p><p>For our KYC use case, described below, we <a href="https://github.com/ethereum/EIPs/issues/725#issuecomment-398750048">proposed a change</a> to the standard which would make execute a payable method, allowing us to forward Ether with the transaction to execute. An alternate approach would be to use two separate transactions: send Ether to the contract first, and then move it with execute.</p><h4>ERC 735: Claim Holder</h4><blockquote>The following describes standard functions for adding, removing and holding of claims. These claims can attested from third parties (issuers) or self attested.</blockquote><blockquote>This standardised claim holder interface will allow Dapps and smart contracts to check the claims about a claim holder. Trust is here transfered to the issuers of claims.</blockquote><p>ERC 735 deals with the management of claims made about an ERC 725 identity. It facilitates an emergence of a web of trust, by relying on the claims of trusted third parties about a given identity.</p><p>These claims can be of several topics, from biometric data, to email account ownership. This is particularly useful for our KYC use case, described below. As ICO issuers, we can work with a <a href="https://www.trustfractal.com/business/">trusted KYC provider</a> to determine whether or not an investor is eligible for purchasing tokens.</p><p>In order for someone to add a claim to their identity, they must first request it of a relevant trusted third party. This third party (the claim issuer) will sign a message containing three items: the identity’s address, the claim topic, and optionally some data to go along with it (for example, a hash of the KYC data). The identity owner would then store this claim in their identity contract (alternatively, the claim issuer can also add the claim themselves, which would have to be approved by the identity owner).</p><p>Note that claims can also be self-attested, which can be enough for a lot of other use cases (email and name come to mind, for simple applications with no strict KYC requirements, like a regular news website).</p><h3>KYC claims for crowdsales</h3><h4>Entities</h4><p>This demo considers the following entities.</p><ul><li><a href="http://swansonquotes.com/quotes/season07/ep-01-2017-good-building-development-co/#.Wyt2hhIzZ24"><strong>Very Good</strong></a>, a construction company looking to upend the real estate development market.</li><li><strong>Fractal ID</strong>, an identity provider who performs KYC/AML checks.</li><li><strong>Investor</strong>, who needs to clear KYC to participate in a <strong>Very Good</strong>’s ICO.</li></ul><h4>Flow overview</h4><p>After compiling the contracts, our demonstration takes the following steps.</p><ol><li><strong>Fractal ID</strong> deploys its own identity contract.</li><li><strong>Fractal ID</strong> adds a CLAIM key to its identity contract.</li><li><strong>Investor</strong> deploys their identity contract.²</li><li>After <strong>Investor</strong> successfully undergoes KYC, <strong>Fractal ID</strong> signs a KYC claim for <strong>Investor</strong>.</li><li><strong>Investor</strong> adds <strong>Fractal ID</strong>’s signed KYC claim to their identity contract.³</li><li><strong>Very Good</strong> deploys their token and crowdsale contracts.</li><li><strong>Investor</strong> participates in <strong>Very Good</strong>’s ICO by making a transfer through their identity contract to <strong>Very Good</strong>’s crowdsale contract.</li><li><strong>Very Good</strong>’s crowdsale contract confirms that the <strong>Investor</strong>’s identity contract contains a KYC claim by <strong>Fractal ID</strong> before accepting the investment.</li></ol><h4>The smart contracts</h4><p>I took <a href="https://github.com/OriginProtocol/identity-playground/tree/master/contracts">Origin’s implementation</a> of the standards as a starting point for this work. I had to <a href="https://github.com/OriginProtocol/identity-playground/pull/11/files">slightly change</a> the way they worked: because of the payable issue described above, this implementation wasn’t prepared to relay value to the execution target. Here’s a simple inheritance diagram of the contracts, for clarity.</p><pre>+---------------+     +---------------+<br>|               |     |               |<br>|    ERC 725    |     |    ERC 735    |<br>|               |     |               |<br>+-------+-------+     +-------+-------+<br>        ^                     ^<br>        |                     |<br>+-------+-------+             |<br>|               |             |<br>|   KeyHolder   |             |<br>|               |             |<br>+-------+-------+             |<br>        ^                     |<br>        |                     |<br>+-------+-------+             |<br>|               |             |<br>|  ClaimHolder  +-------------+<br>|               |<br>+---------------+</pre><p>The token and crowdsale contracts were lifted out of <a href="https://github.com/OpenZeppelin/openzeppelin-solidity/">OpenZeppelin Solidity</a>.</p><p>In order to deploy and interact with these contracts, I used web3.js to put together a simple JS script. (here’s <a href="https://github.com/FractalBlockchain/erc725">the full repo</a> if you’re curious)</p><h4>Step 1/4 — Deploying the identity contracts</h4><p>Both <strong>Fractal ID</strong> and <strong>Investor</strong> need to deploy a ClaimHolder contract, in order to hold all their keys and claims⁴. This contract implements both ERC 725 and ERC 735.</p><p>After deployment, <strong>Fractal ID</strong> will create a CLAIM purpose key. This is the key associated with the signature of KYC claims.</p><pre>var fractalIdClaimsKey = web3.utils.keccak256(<br>  fractalIdClaimsAccount<br>);</pre><pre>fractalIdClaimHolder.methods.addKey(<br>  fractalIdClaimsKey,<br>  KEY_PURPOSES.CLAIM,<br>  KEY_TYPES.ECDSA,<br>).send({<br>  from: fractalIdAccount,<br>  gas: 4612388,<br>});</pre><p>As described above, the key is the keccak256 hash of the address of its controlling account. <strong>Fractal ID</strong> calls the addKey method on the ClaimHolder contract (ERC 725), passing it this key, the key’s purpose, and its keyType.</p><p>Finally, <strong>Very Good</strong> needs to deploy their token and crowdsale contracts, and transfer VeryGoodCoin’s ownership to the VeryGoodCrowdsale contract, so it can mint tokens as needed to reward contributions.</p><pre>veryGoodCoin.methods.transferOwnership(<br>  veryGoodCrowdsale.options.address,<br>).send({<br>  from: veryGoodAccount,<br>});</pre><h4>Step 2/4 — Signing a KYC claim</h4><p>After <strong>Investor</strong> goes through <strong>Fractal ID</strong>’s <a href="https://www.trustfractal.com/business/">online KYC process</a>, <strong>Fractal ID</strong> signs a KYC claim.</p><pre>var hexedData = web3.utils.asciiToHex(&quot;Investor is VBR V0 legit.&quot;);<br>var hashedDataToSign = web3.utils.soliditySha3(<br>  investorClaimHolder.options.address,<br>  CLAIM_TYPES.KYC,<br>  hexedData,<br>);<br>var signature = await web3.eth.sign(<br>  hashedDataToSign,<br>  fractalClaimsAccount,<br>);</pre><h4>Step 3/4 — Adding the KYC claim to the Investor contract</h4><p><strong>Fractal ID</strong> then facilitates this signed claim to <strong>Investor</strong>, who adds it to their identity contract³.</p><pre>var claimIssuer = fractalIdClaimHolder.options.address;<br>var addClaimABI = await investorClaimHolder.methods<br>  .addClaim(<br>    CLAIM_TYPES.KYC,<br>    CLAIM_SCHEMES.ECDSA,<br>    claimIssuer,<br>    signature,<br>    hexedData,<br>    &quot;<a href="https://www.trustfractal.com/business/">https://www.trustfractal.com/business/</a>&quot;,<br>  ).encodeABI();</pre><pre>investorClaimHolder.methods.execute(<br>  investorClaimHolder.options.address,<br>  0,<br>  addClaimABI,<br>).send({<br>  gas: 4612388,<br>  from: investorAccount,<br>});</pre><p>This is done through the addClaim method (ERC 735) on the ClaimHolder contract, which we feed a topic, a scheme, the issuer, the signature, the data, and a uri⁵.</p><p>The way execute works is as follows. We pass it a destination address, an Ether value, and a serialized method call. If we call it with a MANAGEMENT or ACTION key, the request gets approved and executes. If we call it with a key of any other purpose, a higher privilege key has to subsequently approve the execution.</p><h4>Step 4/4 — Participating in the ICO</h4><p>In order for <strong>Investor</strong> to participate in the ICO, we’ll also be making use of the execute method. The case here is much easier to understand: as <strong>Fractal ID</strong>’s identity claim is present on <strong>Investor</strong>’s identity contract, and <strong>Very Good</strong>’s crowdsale contract will be checking for a KYC claim on the message sender, this contract must necessarily be the caller.</p><pre>var investABI = veryGoodCrowdsale.methods.buyTokens(<br>  investorClaimHolder.options.address<br>).encodeABI();</pre><pre>var investmentAmount = web3.utils.toWei(&quot;1&quot;, &quot;ether&quot;);<br>investorClaimHolder.methods.execute(<br>  veryGoodCrowdsale.options.address,<br>  investmentAmount,<br>  investABI,<br>).send({<br>  gas: 4612388,<br>  from: investorAccount,<br>  value: investmentAmount,<br>});</pre><p>All checks should pass now, and <strong>Very Good</strong>’s crowdsale contract will mint new tokens and assign their ownership to <strong>Investor</strong>’s identity contract! 🎉</p><p><strong><em>Thanks</em></strong><em> to </em><a href="https://medium.com/u/4b59b3ef14a2"><em>Fabian Vogelsteller</em></a><em>, Hugo Peixoto and </em><a href="https://medium.com/u/22c33f1d4c05"><em>João Gradim</em></a><em> for reading drafts of this post.</em></p><p><strong>¹ </strong><em>More precisely, </em><em>keccak256 is only recommended by the standard for non-hex and keys longer than 32 bytes.</em></p><p><strong>² <em>Fractal ID</em></strong><em> could also do this on behalf of </em><strong><em>Investor.</em></strong></p><p><strong>³</strong><em> There’s another flow suggested by ERC 725, which is for </em><strong><em>Fractal ID</em></strong><em> to call </em><em>addClaim on the </em><strong><em>Investor</em></strong><em> contract. This claim could be accepted by the </em><strong><em>Investor</em></strong><em>’s identity contract immediately, or undergo an approval process first.</em></p><p><strong>⁴</strong><em> Technically, a </em><em>KeyHolder contract for </em><strong><em>Fractal ID</em></strong><em> would suffice.</em></p><p><strong>⁵</strong><em> Note that we’re using </em><em>encodeABI to serialize the </em><em>addClaim method call, and piping it through </em><em>execute. </em><strong><em>Investor</em></strong><em> could instead have called </em><em>addClaim directly, using the account mapping to the appropriate privileges.</em></p><p><strong>Planning an ICO?</strong> At <a href="https://www.trustfractal.com/business/">Fractal</a>, we offer a hassle-free, user-friendly launchpad solution combined with a comprehensive customer identification service (KYC/AML) to successfully deploy your token launch with ease.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a87ff2509c9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/first-impressions-with-erc-725-and-erc-735-identity-and-claims-4a87ff2509c9">First impressions with ERC 725 and ERC 735 — identity and claims</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[Alternatives to Ethereum in production (May 2018)]]></title>
            <link>https://medium.com/hackernoon/alternatives-to-ethereum-in-production-may-2018-91d132beb62?source=rss-8da70c852bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/91d132beb62</guid>
            <category><![CDATA[neo]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[qtum]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Júlio Santos]]></dc:creator>
            <pubDate>Thu, 31 May 2018 00:09:45 GMT</pubDate>
            <atom:updated>2018-05-31T00:09:45.049Z</atom:updated>
            <content:encoded><![CDATA[<h4>NEO and Qtum. Yes, that’s it.</h4><p><strong><em>tl;dr:</em></strong><em> This post covers the only two viable and live alternatives to Ethereum as a distributed application platform (NEO and Qtum) and explains my confidence in Ethereum’s dominance.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XsxhgaahoC64OQaNtatTWw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/v8vz-Roj8zo?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Dominik Scythe</a> on <a href="https://unsplash.com/search/photos/tools?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I just devoured <a href="https://medium.com/u/31a20b1e9c6a">Ed Posnak</a>’s ongoing series, <a href="https://medium.com/on-the-origin-of-smart-contract-platforms">On The Origin of Smart Contract Platforms</a>. It’s a well-argued collection of essays on several high-profile smart contract platforms — at the time of this writing, he’s covered <a href="https://medium.com/on-the-origin-of-smart-contract-platforms/on-the-origin-of-smart-contract-platforms-tezos-5eee6255c791">Tezos</a>, <a href="https://medium.com/on-the-origin-of-smart-contract-platforms/on-the-origin-of-dfinity-526b4222eb4c">DFINITY</a>, <a href="https://medium.com/on-the-origin-of-smart-contract-platforms/on-the-origin-of-neo-7f9817849af3">NEO</a>, <a href="https://medium.com/on-the-origin-of-smart-contract-platforms/on-the-origin-of-eos-c896281498ee">EOS</a>, <a href="https://medium.com/on-the-origin-of-smart-contract-platforms/on-the-origin-of-cardano-a6ce4033985c">Cardano</a>, <a href="https://medium.com/on-the-origin-of-smart-contract-platforms/on-the-origin-of-lisk-de1be29271be">Lisk</a>, <a href="https://medium.com/on-the-origin-of-smart-contract-platforms/on-the-origin-of-qtum-5f2e6daf798a">Qtum</a>, and <a href="https://medium.com/on-the-origin-of-smart-contract-platforms/on-the-origin-of-waves-7ede1725a732">Waves</a>.</p><p>As it turns out, there aren’t currently many alternatives to Ethereum when it comes to supporting arbitrarily complex distributed applications. The space holds a lot of promise, and I’m excited to see how projects like EOS and Cardano fare, but most of these aren’t nowhere near production.</p><p>In this short post, we’ll quickly look into the only two alternatives to Ethereum with a live mainnet: NEO, and Qtum.</p><p><em>Note: My focus lies mostly with public utility networks. It’s not that I don’t see value of permissioned networks (I do), but the allure of the impact of properly designed public blockchains is very hard to resist.</em></p><h3>Neo</h3><p><a href="https://neo.org/">Neo</a> claims to be a lot faster than Ethereum. From <a href="https://neo.org/">their website</a>:</p><blockquote>Consensus nodes use Byzantine Fault Tolerance Algorithm to reach consensus and ensure the finality of transactions. It also ensures that the system keeps its finality and availability as long as Byzantine fault occurs on less than 1/3 of the nodes.</blockquote><p>This allows them to boast some pretty healthy numbers, like 1,000 transactions per second, confirmed within 20 seconds. From <a href="http://docs.neo.org/en-us/">their whitepaper</a>:</p><blockquote>In the NEO dBFT consensus mechanism, taking about 15 to 20 seconds to generate a block, the transaction throughput is measured up to about 1,000TPS, which is excellent performance among the public chains. Through appropriate optimization, there is potential to reach 10,000TPS, allowing it to support large-scale commercial applications.</blockquote><p>There’s no free lunch, however. This comes at a cost of centralization in validator nodes, since BFT can only function at up to ⅓ of dishonest actors, and sees its performance heavily degraded the closer you get to that number. In practice, this means that NEO keeps a very close eye on who gets to run a validator node on their network. From <a href="https://github.com/neo-project/docs/blob/master/en-us/index.md">their whitepaper</a>:</p><blockquote>the bookkeepers can be a real name of the individual or institution. Thus, it is possible to freeze, revoke, inherit, retrieve, and ownership transfer due to judicial decisons on them. […] The NEO network plans to support such operations when necessary.</blockquote><p>From <a href="https://www.reddit.com/r/NEO/comments/6uuwyv/a_response_to_fake_matrix_article/">a post on Reddit by the NEO Council</a>:</p><blockquote>NEO is not decentralized enough as of today, and that is fully intentional. […] NEO Council is still holding 50% of the tokens […] the NEO Council want to ensure that all consensus nodes have honest, non-malicious intentions.</blockquote><p>While there might be great arguments for doing so, I believe this is anathema to the principle of decentralization.</p><p>If you think NEO is a great choice for you, you might be happy to know that smart contract development can currently and conveniently be done in C#, VB.Net, F#, Java, and Kotlin. From <a href="http://docs.neo.org/en-us/sc/introduction.html">their docs</a>:</p><blockquote>From the language point of view, the difference between NEO Smart Contract 2.0 and Ethereum is more intuitive: unlike the original Solidity language in Ethereum, the NEO smart contract can be used directly by almost any high-level programming language. The first supported languages ​​are C#, VB.Net, F#, Java, and Kotlin.</blockquote><p>However, before getting too excited, note that the price of deploying a smart contract is set at <a href="http://docs.neo.org/en-us/sc/introduction.html#charge-mode">500 gas</a> (well, 490, since <a href="http://docs.neo.org/en-us/sc/systemfees.html#smart-contract-fees">the first 10 are free</a>). At current mart prices ($19.15 at the time of writing), that’s $9,383.5.</p><h3>Qtum</h3><p><a href="https://qtum.org/">Qtum</a> promises 60–70 transactions per second, as per <a href="https://cointelegraph.com/news/scalability-privacy-and-governance-main-problems-for-dapps-says-qtum-co-founder">this Cointelegraph interview</a> with Jordan Earls, Qtum’s Co-Founder. That’s an order of magnitude higher than Ethereum in its current incarnation, and is achieved through the use of a faster <em>proof of stake</em> mechanism which generates a block every 16 seconds.</p><p><a href="https://cointelegraph.com/news/scalability-privacy-and-governance-main-problems-for-dapps-says-qtum-co-founder">Qtum claims</a> further transaction throughput is to be achieved through «a layered network or off-chain channels.» Since Qtum infrastructure is very close to Bitcoin and its UTXO model, this likely hints at their intention to make use of the <a href="http://lightning.network/">Lightning Network</a> for scalability improvements.</p><p>Some well-known projects such as <a href="https://datawallet.com/">DataWallet</a> and <a href="https://www.meetluna.com/">Luna</a> chose to deploy on Qtum, which lends some additional credibility to the network. This choice might have been informed by Qtum’s SPV (<a href="https://bitcoin.org/en/developer-guide#simplified-payment-verification-spv">Simple Payment Verification</a>) support, which makes interacting with the network lighter and thus more appropriate for mobile devices. While Ethereum’s development of a <a href="https://github.com/ethereum/wiki/wiki/Light-client-protocol">light client protocol</a> is underway, it’s not considered production-ready at the moment.</p><p>It’s also interesting (and promising) to note that <a href="https://qtum.org/en/nodemap">Qtum claims to have 6000+ nodes</a>, which is already half the number for Ethereum even though Qtum’s mainnet hasn’t been live for even a year.</p><p>As per <a href="https://qtum.org/uploads/files/a2772efe4dc8ed1100319c6480195fb1.pdf">their whitepaper</a>, Qtum implements the Ethereum virtual machine for smart contract execution, which means Solidity is currently the only language available for deployment. This should make it easy for Ethereum developers to give Qtum’s network a spin.</p><h3>What about Ethereum Classic?</h3><p><a href="https://ethereumclassic.org/">Ethereum Classic</a> resulted from the <a href="https://www.cryptocompare.com/coins/guides/the-dao-the-hack-the-soft-fork-and-the-hard-fork/">DAO fork</a>, where the community split over the decision to revert the DAO hack. Their team is still <a href="https://medium.com/@ClassicIsComing/emerald-project-f6744472109a">hard at work</a> implementing new facilities, and the platform seems to still see <a href="https://themerkle.com/4-ethereum-classic-icos-you-didnt-know-existed/">significant</a> <a href="https://www.reddit.com/r/EthereumClassic/comments/7y9iji/upcoming_etc_icos/">interest</a>.</p><p>There’s an argument to be made for using Ethereum Classic as a backup to Ethereum, should the latter become plagued by DDoS attacks, be forked out of existence, or otherwise face any other existential risk.</p><h3>Inevitable Ethereum maximalism</h3><p>Ethereum is currently the go-to smart contract platform. Contender claims abound, but most purported alternatives aren’t even close to being live.</p><p>Additionally, Ethereum’s hard at work addressing some of the issues these contenders see with its current version. If Ethereum — which is well-funded and has a thriving developer community — finds its way to scalability and better smart contract security before alternatives become popular, I believe it will remain the platform of choice.</p><p>The Ethereum community is <a href="https://media.consensys.net/the-state-of-scaling-ethereum-b4d095dbafae">exploring several solutions</a> which would bring about massive improvements to the platform.</p><ul><li>The adoption of <em>proof of stake</em> (<a href="https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ">Casper</a>) should dramatically reduce energy consumption and allow for a <a href="https://ethereum.stackexchange.com/a/5714">higher throughput</a> by decreasing the block time.</li><li><a href="https://github.com/ethereum/wiki/wiki/Sharding-FAQ">Sharding</a> should bring about an <a href="https://medium.com/@icebearhww/ethereum-sharding-and-finality-65248951f649">initial 100x improvement</a> to transition throughput.</li><li><a href="https://medium.com/l4-media/making-sense-of-ethereums-layer-2-scaling-solutions-state-channels-plasma-and-truebit-22cb40dcc2f4">Layer-2 solutions</a> (meaning they’re not core to Ethereum, but implemented on top of it) such as <a href="https://www.plasma.io/">Plasma</a>, <a href="https://raiden.network/">Raiden</a>, <a href="https://liquidity.network/">Liquidity Network</a> and <a href="https://truebit.io/">TrueBit</a> will compound the core scalability improvements by securely moving a lot of the heavy lifting off-chain.</li><li>Smart contract security is progressively increasing as the community doubles down on safer languages (like <a href="https://github.com/pirapira/bamboo">Bamboo</a>, <a href="https://github.com/ethereum/vyper">Vyper</a> and <a href="https://medium.com/axoni/axlang-formally-verifiable-smart-contracts-for-the-ethereum-ecosystem-6201203be4e8">AxLang</a>) and formal verification tools (like <a href="https://github.com/trailofbits/manticore">Manticore</a>, <a href="https://github.com/ConsenSys/mythril">Mythril</a>, <a href="https://github.com/melonproject/oyente">Oyente</a>, <a href="https://github.com/raineorshine/solgraph">Solgraph</a> and <a href="https://tool.smartdec.net/">SmartCheck</a>).</li></ul><p>Additionally, Ethereum’s community is incredibly vibrant, and I believe that ultimately the winning platforms will be the ones which garner the most developer support. This is not only because of the higher speed at which a platform with a lot of contributors evolves, but also because of the applications and use cases built on top of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*rm5wEcXefP5BaLLmxwAMhQ.gif" /></figure><p>Given Ethereum’s relative maturity, the strength of its community, and the amount of research committed to improve it, I don’t see a compelling reason to choose any other platform as of today.</p><p><strong>Planning an ICO?</strong> At <a href="https://www.trustfractal.com/business/">Fractal</a>, we offer a hassle-free, user-friendly launchpad solution combined with a comprehensive customer identification service (KYC/AML) to successfully deploy your token launch with ease.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91d132beb62" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/alternatives-to-ethereum-in-production-may-2018-91d132beb62">Alternatives to Ethereum in production (May 2018)</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[Getting intimate with Ethereum tokens]]></title>
            <link>https://medium.com/hackernoon/getting-intimate-with-ethereum-tokens-2a1779c4db7b?source=rss-8da70c852bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a1779c4db7b</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum-token]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptoeconomics]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Júlio Santos]]></dc:creator>
            <pubDate>Wed, 02 May 2018 15:58:04 GMT</pubDate>
            <atom:updated>2018-05-03T08:33:27.424Z</atom:updated>
            <content:encoded><![CDATA[<h4>Purpose, creation, distribution and usage of protocol and application tokens</h4><p><strong><em>tl;dr:</em></strong><em> This post attempts to shed some light on what Ethereum tokens are: what they’re for, as well as how they’re created, distributed, and used.<br>We’ll look into token economics, how a blockchain-based app works, and how this relates to value and ICOs.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e9xZLyReopougN3kd_Nl8Q.jpeg" /></figure><p>As with any disruptive technology, Ethereum is still hard to grasp for a lot of people. It always takes some time for folks to become accustomed to think within a new paradigm. We’re still in those early days where we haven’t settled on the appropriate metaphors to use, and too few people have been exposed to it for a common consciousness to begin to form.</p><p>Aside from this maturity, or consciousness criticality, there’s another aspect of blockchains that makes them particularly hard to understand. Blockchains are, as <a href="https://medium.com/u/f1cb98e196bc">Trent McConaghy</a> <a href="https://blog.oceanprotocol.com/can-blockchains-go-rogue-5134300ce790">brilliantly puts it</a>, <strong>incentive machines</strong>. This is a new concept, and one that makes this technology much more than just dumb infrastructure — but also tougher to grasp.</p><p>Blockchain is the second major construct on top of the Internet. The first one was the Web, which we can define as a collection of protocols and standards (HTTP, HTML, URIs) from which a global information and communication space emerges. Its infrastructure has allowed us to build all sorts of applications on top, all the way from blogs to shops to social networks.</p><blockquote>Blockchain introduces a tremendously powerful new feature — the ability to shape the behavior of its participants</blockquote><p>There’s a great many ways in which one can use the Web, but it is ultimately limited in what it can do. Comparatively, Blockchain introduces a tremendously powerful new feature — the ability to shape the behavior of its participants. That’s what Trent means with <em>incentive machines</em>.</p><p>In this sense, a blockchain acts very much like a good old economic system — without centralized gatekeepers. This too is a collection of rules from which a set of behavior-shaping incentives emerge, and it’s not new. What’s fascinating, however, is that Blockchain allows us to experiment with new economic systems without having to take over a country. You can prototype a new economy, deploy it on a blockchain, have some folks sign up, and watch people vote with their feet as a proxy for the adequacy of your design.</p><blockquote>Blockchain allows us to experiment with new economic systems without having to take over a country</blockquote><p>Think about it — the great innovation of Bitcoin wasn’t that it used a blockchain. It didn’t even invent it. Bitcoin’s genius move, which inspired a whole generation of blockchain-based economic designs, was to invent a way to incentivize folks to do its bidding: guaranteeing the security and widespread availability of its network. It does this by rewarding miners (people who run nodes and group transactions into blocks) for their work with newly minted Bitcoin.</p><p>Ethereum does the same with Ether. In order to use the network in any way, you need to pay <em>gas</em> — and gas is paid in Ether.</p><p>Similar incentive mechanics can be extended upwards into arbitrarily complex constructs. Ethereum-based protocols and apps, like <a href="https://gnosis.pm/">Gnosis</a>, often deploy their own tokens in order to build their economy on top of Ethereum’s economy.</p><p>Let’s take a look under the hood to get a better grasp of all this. We’ll start by presenting the concept for <strong>Meetcoin</strong>, a hypothetical blockchain-based dating app[1]. We’ll study its incentive structure, and then move on to explain how its tokens are created, distributed, and used.</p><h3>Meetcoin — blockchain-based dating</h3><p>Meetcoin is our hypothetical new dating app that attempts to align the incentives of both stakeholders in the dating facilitation game: the platform, and its users.</p><p>In creating a dating economy, we’re concerned about encouraging the emergence of desirable behavioral patterns, through the deployment of the right incentive mechanisms.</p><p>In order to better bring home the point about the incentives, consider a dating app that’s supported by advertising. Since the app makes money from showing you ads, it makes more money the more ads you see. This app is then counterproductively incentivized to find matches for users as poorly as possible. This is because, once a user finds a match, they’re more likely to stop using the app, which means it can’t make more money by showing them more ads.</p><p>It doesn’t take much to conceive of a perfect dating platform. It just needs to do one thing really well: <strong>produce great matches</strong> for its users while <strong>demanding the least possible amount of effort</strong>. In support of this optimization goal, Meetcoin has 4 killer features that use incentive design to encourage the emergence of a great dating economy. Meetcoin’s operation revolves around its limited-issue token, <strong>Ṃeet</strong>, which is required to use the app.</p><h4>Detailed user profiles</h4><p>Upon joining the app, the user is asked to complete their profile.</p><p>More complete profiles allows Meetcoin to produce better matches, so Meetcoin incentivizes the user to complete every field by rewarding them with some Ṃeet, so that they don’t need to spend any money in order to start using the app.</p><h4>Rich discovery tools</h4><p>Meetcoin makes available a thorough set of searching and filtering tools, in order to make it as efficient as possible for users to quickly find the date they’re looking for.</p><p>Since users are incentivized to provide detailed profiles, Meetcoin can leverage this data to produce automatic recommendations of matches, saving time in searching and filtering.</p><p>Once a user finds another user they like, they can send them a message. Every message costs a certain amount of Ṃeet to send, which disincentives spam and incentivizes targeted messages.</p><h4>Limited inbox and priority access</h4><p>Users can specify the maximum number of messages they’re open to receiving per day. If their daily inbox is full, new messages queue up until the next day. It’s possible, however, for senders to skip the queue by paying additional Ṃeet.</p><p>For example, say that my inbox limit is set to 3. I already have 3 messages there from Alice, Bob and Charlie. If Dave sends me a message, I’d only see it tomorrow. Knowing this, Dave can pay extra Ṃeet in order to skip the other users in my inbox queue. This incentivizes better matches, by having users demonstrate their conviction with the match quality by paying more (they’re putting their money where their mouth is).</p><p>Once I choose to reply to a message, there’s an open communication channel and no more Ṃeet is required to proceed.</p><p>Here’s how the Ṃeet flow happens here:</p><ul><li>If I ignore a message, the Ṃeet paid to send the message is refunded to the sender.</li><li>If I open a message but don’t choose to reply to it, I get to keep all of the Ṃeet paid to send the message.</li><li>If I open a message and reply to it, Meetcoin takes a a small percentage of the Ṃeet paid to send the message as a fee.</li></ul><p>Notice how this aligns incentives well. Meetcoin, the app, only gets rewarded if it actually produces a match (a match being represented here as a reply to a message).</p><h4>Date feedback</h4><p>Users can be rewarded with additional Ṃeet if they both report having gone on a date, and provide feedback about how the date went. This allows Meetcoin to further calibrate its AI, which is why it’s rewarding users for it.</p><h4>Incentive structure</h4><p>Meetcoin’s token economy generates a set of incentives that can be summarized as follows:</p><ul><li>Users are incentivized to provide detailed information about themselves and the dates they go on. This feeds into efficient search and recommendation systems, allowing for matches to be generated more efficiently.</li><li>Users are incentivized to only send messages when they’re relatively sure they’ll get a reply. Otherwise they’re spending Ṃeet for no reason.</li><li>Meetcoin in incentivized to produce the best possible matches, because it’s only rewarded when a match is made.</li></ul><p>This by itself should help make the “blockchain is an incentive machine” statement clearer now. We’ve shown how a set of properly assigned incentives can nudge the users to behave in a way that is beneficial to the network and everyone in it.</p><p>But we’re not done. You see, Ṃeet tokens are finite. Their scarcity is enforced by the underlying blockchain. As more users hear about the virtues of Meetcoin, they’ll want to join the app, and they’ll need to buy tokens to be able to use it. Since tokens are finite, someone will have to sell them for you to buy them. This puts upward pressure on the Ṃeet token price, driving its value on the open market further up, which rewards early adopters and investors who got or bought Ṃeet when it was cheaper.</p><h4>A cold-start rocket</h4><p>This is more than a welcome side-effect. This feature of blockchain-based social networks helps with solving the cold-start problem: it’s hard to attract people to an empty network. Given that many “free” networks exist (where users pay by granting the operating entity rights to their data, and being shown ads), it’s hard to create and populate new networks.</p><blockquote><strong>blockchain-backed scarcity</strong> allows for the deployment of a <strong>token economy</strong> which helps <strong>solve the cold-start problem</strong></blockquote><p>Enter blockchain. Since it’s possible to create a token economy, suddenly networks can be better than free — they can reward people for usage. This means it’ll be easier for developers to experiment with new networks, since they now have a tool that gives them a chance against existing ones.</p><p>I can’t stress this enough: <strong>blockchain-backed scarcity</strong> allows for the deployment of a <strong>token economy</strong> which helps <strong>solve the cold-start problem</strong>.</p><p>For Meetcoin in particular, this is great news. Since more attractive[2] users are more likely to make money from the app, they have an incentive to join. This is expected to incentivize online dating users to try Meetcoin in particular, since it’s now seeded with all these attractive folks.</p><h4>Meetcoin’s ICO</h4><p>This token economy, and its path to growth, is the justification for Meetcoin’s ICO. There’s many ways to conduct a token distribution, but Meetcoin decided to magically create 100M tokens and sell 20M of them, at a pronounced discount, during their ICO.</p><p>Tokens bought during the ICO will be significantly cheaper than what they’ll be worth when the network is running, and cheaper even than when the network is popular.</p><p>Put simply, that is why investors participate in ICOs.</p><h3>Ṃeet tokens under the hood</h3><p>Now that we have a grasp of Meetcoin’s token economy, let’s look into the tokens themselves.</p><p>Note that there are many ways to create, distribute and use tokens. Indeed, the examples below will be overly simplistic and do not represent an endorsement. Consider it an illustration for the sake of clarity.</p><h4>How tokens are created and distributed</h4><p>Meetcoin generated their token supply by creating a smart contract and deploying it on the Ethereum network. It was a very simple smart contract, that essentially does 3 things:</p><ol><li>It states “hi, I’m a smart contract, and I own 100M Ṃeet tokens”. By deploying this contract, <strong>Meetcoin magically wills 100M Ṃeet tokens into existence</strong>, and declares 20M of those to be up for sale. <em>That’s it. Really.</em></li><li>It allows Ethereum users to <strong>buy any number of those 20M tokens for a price of 0.01 Ether</strong> each. Assuming there are enough tokens left, anyone can send, say, 1 Ether to the contract, and the contract will now state “the address 0x123abc now owns 100 Ṃeet tokens”. <em>That’s it. Really.</em></li><li>It allows the owners of the contract to withdraw the Ether that has been deployed into it, so they can fund Meetcoin operations. <em>That’s it. Really.</em></li></ol><h4>How tokens show up in a wallet</h4><p>Meetcoin could choose to release their own wallet software, with which users could check their balance, make transfers, etc. However, they decided to go with the <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md">ERC20 standard</a>. Many Ethereum wallets already support this standard, which makes it straightforward for their users to work with the Ṃeet token as they please.</p><h4>How tokens are traded</h4><p>After their sale, tokens are usually not good for much. After all, Meetcoin is still in the concept phase, and the ICO proceeds will be used to develop what’s left of it.</p><p>As it often happens with token sales, Meetcoin will use some of the ICO proceeds to pay one or more blockchain exchanges (such as Bitfinex or Kraken) to list their Ṃeet token. This makes it easier for users to trade the Ṃeet token, and for people who didn’t manage to participate in the ICO to buy Ṃeet tokens afterwards.</p><p>Having the token specification follow a standard like ERC20 facilitates the listing on exchanges, since it amounts to less integration work on the part of the exchanges.</p><h4>How tokens are used</h4><p>Since Meetcoin is blockchain-based, the bulk of its implementation relies on one or a network of smart contracts, instead of a traditional application server. These smart contracts encode the application logic and token economy.</p><p>Interacting with these smart contracts is directly is still quite the nerdy process, so Meetcoin offers their users the possibility of ceding control of their token wallet to Meetcoin so that they can use a good old regular web interface to the application instead. Power users still have the choice to remain in control of their tokens.</p><p>Meetcoin thus builds a web front-end for their app, and allows the users who choose to do so to log in with a regular username/password combination. For these users, their Ṃeet token balance will be displayed in-app as a regular in-game currency balance would, and the Meetcoin app will handle all the token transfers behind the scenes.</p><p>For example, let’s say Alice sends a message to Bob. Here’s a breakdown of the potential logic happening behind the scenes:</p><ol><li>Meetcoin takes 1 Ṃeet token from Alice and puts it in escrow. It then delivers Alice’s message to Bob.</li><li>After a week, Meetcoin checks on what happened to the message.</li><li>If <em>Bob didn’t open the message</em>, Meetcoin will refund the 1 Ṃeet token to Alice.</li><li>If <em>Bob opened the message but didn’t reply</em>, Meetcoin will transfer this 1 Ṃeet token to Bob.</li><li>If <em>Bob opened the message and replied</em>, Meetcoin will transfer 0.9 Ṃeet tokens to Bob, and 0.1 to itself.</li></ol><p>This all happens through broadcasting transactions onto the Ethereum network. These transactions invoke functions on the smart contracts which encode Meetcoin’s functionality.</p><p>Note that these transactions, since they work with the Ethereum network, need to pay for gas in Ether. The simplest way to handle this is by requiring the user to keep an Ether balance, but there’s other ways that could make it simpler for users. For example, Meetcoin could automatically trade some of the user’s Ṃeet tokens, behind the scenes, for however much Ether is necessary to issue the transaction.</p><h3>Beyond the basics</h3><p>I hope that this simple example helps shed some light on token economics.</p><p>Token economies can indeed be a lot more complex and purposeful. Check out the <a href="https://oceanprotocol.com/">Ocean Protocol</a> and their <a href="https://oceanprotocol.com/#papers">whitepapers</a> for one of the best examples out there.</p><p>I’ll leave you with a few additional resources for further exploring:</p><ul><li>I’ve put together <a href="https://hackernoon.com/full-stack-smart-contract-development-fccdfe5176ce">a tutorial walkthrough</a> on writing, testing and deploying an Ethereum smart contract and its web interface</li><li>I’ve written a piece on <a href="https://hackernoon.com/smart-contracts-a-new-economic-era-e95f407d49ef">why smart contracts are so revolutionary</a></li><li><a href="https://medium.com/u/d446dafbe292">Preethi Kasireddy</a> has a <a href="https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369">great explainer</a> on how Ethereum works under the hood</li><li><a href="https://medium.com/u/9afbf877fa2f">Simon de la Rouviere</a> <a href="https://medium.com/@simondlr/introducing-curation-markets-trade-popularity-of-memes-information-with-code-70bf6fed9881">writes about curation markets</a></li><li><a href="https://medium.com/u/d12e43da4654">Vivek Singh</a> <a href="https://hackernoon.com/cryptoeconomics-in-context-6435ad6839be">gives crytoeconomics some context</a></li><li><a href="https://medium.com/u/4380e912132e">Mike Goldin</a> <a href="https://medium.com/@ilovebagels/token-curated-registries-1-0-61a232f8dac7">introduces token-curated registries</a></li><li><a href="https://medium.com/u/211d5b924366">BlockChannel</a> <a href="https://medium.com/blockchannel/a-crash-course-in-mechanism-design-for-cryptoeconomic-applications-a9f06ab6a976">wrote a crash course in mechanism design</a></li></ul><p><a href="https://hackernoon.com/ethereum/home">Ethereum - Hacker Noon</a></p><p><strong>Thinking of doing an ICO? </strong><a href="http://www.trustfractal.com/business/"><strong>Talk to us</strong></a><strong>.</strong></p><p>[1] This dating app concept is very much inspired by <a href="https://www.meetluna.com/">Luna</a>, an application that I chose for the simplicity of its cryptoeconomic model. I hold none of their tokens, and my choice to riff off them doesn’t constitute an endorsement.</p><p>[2] Attractive here refers to their ability to command attention on a dating platform, and doesn’t carry any judgement on my part.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a1779c4db7b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/getting-intimate-with-ethereum-tokens-2a1779c4db7b">Getting intimate with Ethereum tokens</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[Smart contracts: a new economic era]]></title>
            <link>https://medium.com/hackernoon/smart-contracts-a-new-economic-era-e95f407d49ef?source=rss-8da70c852bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/e95f407d49ef</guid>
            <category><![CDATA[cryptoeconomics]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[economics]]></category>
            <category><![CDATA[trust]]></category>
            <dc:creator><![CDATA[Júlio Santos]]></dc:creator>
            <pubDate>Mon, 11 Dec 2017 15:38:10 GMT</pubDate>
            <atom:updated>2017-12-13T08:28:55.907Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why are smart contracts so revolutionary?</h4><p><em>(If you’re new to blockchain technology, start with my short introduction: </em><a href="https://hackernoon.com/what-can-blockchain-do-for-you-746ed436a371"><em>What can Blockchain do for you?</em></a><em>)</em></p><p>Smart contracts are all the rage these days, and for good reason.</p><p>When Ethereum appeared in 2015, it took the blockchain community by storm by demonstrating that it was possible to do so much more with the technology than just digital currency. Suddenly, a whole new class of decentralized applications could be conceived of, and deployed onto a blockchain which could support them.</p><p>A smart contract is just a computer program on a blockchain: the basic unit of a dapp, a decentralized application. A dapp can be thought of as a collection of inter-related smart contracts, which together cause the emergence of high-level functionality — much like large IT systems are composed by multiple subsystems or modules working together to become more than the sum of their parts.</p><p>A dapp is implemented by deploying a collection of smart contracts onto a blockchain layer, and then interacting with these smart contracts. Examples:</p><ul><li>supply chain tracking and tracing solutions like <a href="https://www.provenance.org/">Provenance</a>, or <a href="https://www.forbes.com/sites/rogeraitken/2017/08/22/ibm-forges-blockchain-collaboration-with-nestle-walmart-for-global-food-safety/#7452c7143d36">IBM and Walmart’s pilot</a>;</li><li>prediction markets like <a href="http://augur.net/">Augur</a> or <a href="https://gnosis.pm/">Gnosis</a>;</li><li>decentralized organizations like <a href="https://en.wikipedia.org/wiki/The_DAO_(organization)">The DAO</a>;</li><li>ICOs / token sales;</li><li><a href="https://www.cryptokitties.co/">Cryptokitties</a>.</li></ul><p><a href="https://hackernoon.com/forever-on-the-chain-c755838dfc79">Blockchain is the technological revolution that commoditizes trust.</a> Smart contracts are the tools we use to realize this revolution.</p><p>This is a tricky concept to grasp, so let’s look at a simple game as an example.</p><h3>The number is right</h3><p>Let’s play a game. There’s three players: Alice, Bob and Charlie.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*T5LLBA88YSGsz7ZuBjYA-Q.jpeg" /><figcaption>Meet Alice, Bob, And Charlie. They’ll play our game.</figcaption></figure><p>Charlie thinks of a number. Alice and Bob have to try and guess a number as close to Charlie’s number as possible; they write it down in an envelope, along with a €5 bill, and hand their bets to Charlie. Charlie gives both €5 bills to whomever got closer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*mKYti-os5lET1s1st-RY_Q.jpeg" /><figcaption>Charlie thinks of a number. Alice and Bob write down their bets.</figcaption></figure><p>For example, if Charlie thought of 86, Alice guesses 10 and Bob guesses 90, Bob will win because he was closer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*FNJ5h0nyml9Wk1FR0rn15Q.jpeg" /><figcaption>Charlie compares the bets to the number he thought of.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*KFar7koSEoAYZXexaaYYXA.jpeg" /><figcaption>Bob had 90, which is closer to 90 than 10, so he wins!</figcaption></figure><p>As long as Alice, Bob and Charlie are trusted parties, this simple game works well. But these simple rules do, in fact, have some holes in them that may need to be addressed.</p><h4>Trust-related problems everywhere</h4><p>First of all, Charlie could just take the money and run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*STdgWlxhDPwo2bHA-krZxQ.jpeg" /><figcaption>Charlie absconds with the money!</figcaption></figure><p>Second, Charlie can conspire with one of the players, let’s say Bob, so that he always says Bob’s guess was closer. Alternatively, Charlie can try to disguise the cheating by just paying Bob a higher proportion of the times that Bob would have been entitled to by chance alone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*m3Jc7TsPj0ysMhONly5V4A.jpeg" /><figcaption>Bob and Charlie, ever the rascals, conspire.</figcaption></figure><p>Now, how do we work around this? We can make Charlie write his number down and, after the results are in, allow Alice and Bob to see each other’s bets. This way, we’re creating a trail that can be audited.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*MZth8W2RxXgL1Ipd1Ul_xQ.jpeg" /><figcaption>All players reveal their number for everyone else to see.</figcaption></figure><p>Alas, this is no longer fun, or profitable, for Charlie. He can’t be easily bribed by Bob any more. So, he decides to start charging Alice and Bob a percentage of the bets, as a fee for his services.</p><p>As such, Alice and Bob find themselves intermediated by a costly third party, but the problem is still unsolved. Charlie can still conspire with one of them to always generate numbers within a certain range, so that they’re easier to get closer to — even with an audit, no foul play could be proven.</p><p>This leaves Alice and Bob paying an insurance premium against cheating, to a corruptible third party, who could still find ways to cheat anyway.</p><h4>Smart contracts to the rescue</h4><p>This is where smart contracts can come in. If Charlie were not a real person, but a smart contract on a blockchain, both Alice and Bob could inspect its code and audit it to ensure its validity and impartiality. Charlie’s random number and the bets would be recorded for auditing, too.</p><p>Additionally, being a program and all, Charlie would have no notion of “fun” or “profit”, and wouldn’t need to charge any fees. It would have no agency. It would just mindlessly keep executing its instructions forever.</p><p>Forever.</p><p>This is an important word here, that brings me to my next point. <a href="https://hackernoon.com/forever-on-the-chain-c755838dfc79">Permanence and immutability are two core properties of blockchain technology.</a> In fact, and this is what makes this field so exciting, blockchain is the only way we know how to achieve permanence and immutability in digital records. Once a smart contract is deployed, it remains the same forever. And so, Alice and Bob can keep playing forever, confident that Charlie will never change, because a smart contract is like a digital tattoo: once deployed, it stays deployed, replicated and validated by thousands of nodes, unchanging and eternal.</p><p>This is why I like to say that blockchain technology is the revolution that commoditizes trust. This example was simple, but the principles illustrated work equally well at arbitrary levels of complexity. Once we finally appreciate the implications of this disintermediation power, I fully expect the transformation to be as or more profound than what we’ve seen with the Internet and the Web.</p><h3>Transformative implications</h3><p>So, what can we do with smart contracts? We can trust them. We can trust them to be true to their code, and do exactly as they were told.</p><p>This means that we can port a lot of current, real-world functionality into the blockchain and, scaling issues aside, this could bring our current systems an unprecedented level of transparency and confidence. Things like currencies, investment funds, and insurance contracts are premium candidates for migrating into a blockchain.</p><h4>Cryptoeconomics: a new paradigm</h4><p>What’s even more interesting, is that we can use smart contracts to develop and implement new cryptoeconomic paradigms. Cryptoeconomics is one of the most interesting approaches there are to trust. It combines cryptographical certainty with economic <a href="https://en.wikipedia.org/wiki/Mechanism_design">mechanism design</a> to incentivize a certain behaviour.</p><p>Cryptoeconomics is about using economic incentives to reward participants who further the system’s objectives, and penalize participants who harm the system’s objectives (<a href="https://www.youtube.com/watch?v=lYGOMGqz9zE">Vitalik Buterin has a great talk on this</a>).</p><p>This allows for new classes of systems, that weren’t really possible to implement before we had blockchain technology. Let’s look at another example: <a href="https://medium.com/@ilovebagels/token-curated-registries-1-0-61a232f8dac7">token-curated registries</a>.</p><h4>Building an economy around lists</h4><p>Token-curated registries are a mechanism to incentivize the production and curation of lists. It’s a cryptoeconomic protocol that embodies a virtuous economic cycle to keep its curation activity ongoing. BigchainDB’s upcoming <a href="https://oceanprotocol.com/">Ocean Protocol</a>, a data exchange, makes use of token-curated registries for tracking the reputation of their data sources.</p><p>Let’s imagine a simple list system: a list of best restaurants. There are three classes of participants in this system: consumers, candidates, and curators.</p><p>First, the list consumers. They don’t pay to use the system, but are the main drivers of its relevance, as their consumption of the list has implications in the real world, because they will go spend money at some restaurant they found on the list.</p><p>The second class of participant consists of candidates. If this list becomes popular it will, in turn, cause restaurants to want to be present on it. Therefore, they buy tokens of this ecosystem, and use them to apply to the list. Applications involve staked tokens (meaning that, to apply, you put some tokens in escrow), to prevent candidates spamming lists, and also to provide fees for curators.</p><p>Curators, the third class of participant, then vote. They buy tokens and use them to determine whether or not the application should pass, and the restaurant should come on to the list. If they reject it, the restaurant loses their tokens. If they accept it, the tokens are held in escrow. In any case, curation activity is rewarded by paying curators with a part of the tokens staked by the restaurants.</p><p>So, summary: curators are incentivized to produce the best possible list. This is because the best lists attract a lot of consumers, and in turn a lot of applicants wanting to attract the attention of those consumers. These applicants have to buy tokens of the system to apply, driving their value up.</p><h4>A peek into a new economic era</h4><p>What’s fascinating here is that this creates a whole new democratic microeconomy out of thin air. Anyone can participate in these systems by buying some tokens and becoming a curator, therefore standing to earn more tokens from curation activity. Tokens have to be liquid, otherwise people couldn’t buy them to apply to lists, and this means that token holders can also convert them to fiat or another cryptocurrency and cash out.</p><p>We invented some new magic internet money, secured it with cryptography, and designed the economic incentives such that this system will work by itself, with no supervision, governed by nothing else than game theory and the trust in the fact that people will always like money.</p><p>I’m excited to see what lies ahead.</p><p><strong>Thinking of exploring blockchain? </strong><a href="https://lifeonmars.pt/"><strong>Talk to us</strong></a><strong>. </strong>Life on Mars is an elite software consultancy now moving into the blockchain space.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e95f407d49ef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/smart-contracts-a-new-economic-era-e95f407d49ef">Smart contracts: a new economic era</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[Full-stack smart contract development]]></title>
            <link>https://medium.com/hackernoon/full-stack-smart-contract-development-fccdfe5176ce?source=rss-8da70c852bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/fccdfe5176ce</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum-smart-contracts]]></category>
            <category><![CDATA[full-stack]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Júlio Santos]]></dc:creator>
            <pubDate>Tue, 28 Nov 2017 16:16:09 GMT</pubDate>
            <atom:updated>2018-05-28T13:42:38.412Z</atom:updated>
            <content:encoded><![CDATA[<h4>Writing, testing and deploying an Ethereum smart contract and its web interface</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4GNg30Shnxd3JZysM75dFQ.jpeg" /></figure><p>This weekend I spent some time with my team looking into tooling and deployments particular to the Ethereum blockchain, and put together a little experiment: <a href="https://forever.lifeonmars.pt/">Forever on the Chain</a>.</p><p>It’s the equivalent of a digital tattoo: a smart contract that anyone can use for free (minus transaction costs) to leave a permanent message onto the Ethereum blockchain. This message is stored in the blockchain forever, etched into thousands upon thousands of computers, unchangeable and immortal.</p><p>Even though permanence is one of the core blockchain concepts, this still worried some folks, so I also wrote a <a href="https://hackernoon.com/forever-on-the-chain-c755838dfc79">non-technical post about the tool and some of the implications of blockchain technology</a>.</p><p>What follows is a smart contract tutorial. I’ll walk you through the creation and testing of the critical path of this tool.</p><p>This assumes you have an understanding of some Ethereum core concepts such as smart contracts, transactions, and gas. If you don’t, here’s an explainer to get you started.</p><p><a href="https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369">How does Ethereum work, anyway?</a></p><h3>The smart contract</h3><p>This smart contract is as simple as they come. Its only functionality is to log a message into the blockchain. This is achieved through the use of Events, as explained below.</p><h4>Code walkthrough</h4><p>The smart contract is written in Solidity. This is a statically typed language to write Ethereum smart contracts. From <a href="http://solidity.readthedocs.io/en/develop/index.html">the documentation</a>:</p><blockquote>Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript and it is designed to target the Ethereum Virtual Machine (EVM).</blockquote><p>Here’s what the implementation of our contract looks like.</p><pre>pragma solidity 0.4.24;</pre><pre>/**<br> * <a href="http://twitter.com/title">@title</a> Recorder — record a message into the blockchain<br> * <a href="http://twitter.com/dev">@a</a>uthor Life on Mars — https://lifeonmars.pt<br> */<br>contract Recorder{<br>  event Record(<br>    address _from,<br>    string _message<br>  );</pre><pre>  /**<br>   * <a href="http://twitter.com/dev">@n</a>otice Sends the contract a message<br>   * to record into the blockchain<br>   * <a href="http://twitter.com/param">@param</a> message  message to record<br>   */<br>  function record(string message) public {<br>    emit Record(msg.sender, message);<br>  }<br>}</pre><p>Let’s start by walking slowly through this code.</p><pre>pragma solidity 0.4.24;</pre><p>As per <a href="http://solidity.readthedocs.io/en/develop/layout-of-source-files.html#version-pragma">the documentation</a>:</p><blockquote>Source files can (and should) be annotated with a so-called version pragma to reject being compiled with future compiler versions that might introduce incompatible changes.</blockquote><p>This line ensures that your source file won’t be compiled by a compiler with a version different from 0.4.24.</p><p>It’s also possible to use less restrictive pragmas, for example through a caret range. Take ^0.4.24. In this case, your source will be compiled by any compiler later than 0.4.24, and earlier than 0.5.0. See the <a href="https://docs.npmjs.com/misc/semver">semver documentation for npm</a> for more information.</p><pre>contract Recorder {}</pre><p>contract is, as the name implies, the keyword one uses to define a contract. A contract is defined with a name written in <a href="https://en.wikipedia.org/wiki/PascalCase">PascalCase</a>.</p><pre>event Record(<br>  address _from,<br>  string _message<br>);</pre><p>Here, we’re defining an event. Events allow you write access to the Ethereum logging facilities. When called, the arguments they were invoked with get stored in the transaction’s log, which is a special data structure in the blockchain [<a href="http://solidity.readthedocs.io/en/develop/contracts.html#events">docs</a>]. These transaction logs can be used for storing information.</p><p>Compared to using contract storage (writing to a variable in a contract), using logs is much cheaper with regards to gas costs. However, this comes with a trade-off: contracts aren’t able to read from log data (<a href="https://media.consensys.net/technical-introduction-to-events-and-logs-in-ethereum-a074d65dd61e">see this great post by Consensys for more details</a>).</p><p>Since, for our use case, we don’t need contracts to read from these logs, we’re using events instead of storing an array of strings.</p><pre>function record(string message) public {<br>  Record(msg.sender, message);<br>}</pre><p>The record method is as simple as they come. It’s a public method, <a href="https://solidity.readthedocs.io/en/v0.4.24/contracts.html#visibility-and-getters">meaning it can be called externally</a>. It takes a string argument named message, and all it does is call the Record event with two parameters:</p><ul><li>msg.sender holds the address of the account which invoked the record function [<a href="http://solidity.readthedocs.io/en/develop/units-and-global-variables.html#block-and-transaction-properties">docs</a>];</li><li>message is just the argument record was invoked with.</li></ul><p>Interaction with this particular smart contract is possible in only one way: sending a transaction at it, along with a message parameter, which invokes the record method. When an account A invokes the record method, the Record event is called, which causes the tuple {A&#39;s address, message} to be stored in the respective transaction’s log.</p><h4>Compilation</h4><p>Solidity code can be compiled using solc, the solidity commandline compiler. We will see how to use <a href="http://truffleframework.com/">Truffle</a> for compilation and deployment later on, but bear with me for now. <a href="http://solidity.readthedocs.io/en/develop/installing-solidity.html"><strong>Install solc</strong></a><strong> if you want to follow along.</strong></p><p>Running solc allows us to output the binary representation of the contract. This is used for deploying the contract (again, Truffle will handle this for us later). Here’s what this contract’s binary output looks like (you can see it yourself with solc --bin Recorder.sol)</p><pre>6060604052341561000f57600080fd5b6101a28061001e6000396000f300606060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e51ace1614610046575b600080fd5b341561005157600080fd5b6100a1600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506100a3565b005b7fac0fdae5d3299ac82cf049834f149484c5cafb1584ffd1e2432597e4581b16a73382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561013857808201518184015260208101905061011d565b50505050905090810190601f1680156101655780820380516001836020036101000a031916815260200191505b50935050505060405180910390a1505600a165627a7a723058201b9ef174b2b5557ad31400e4eb1cd02dd02b8244eefbc97e9b75b01072cc706e0029</pre><p>Pretty exciting stuff.</p><p>As per the <a href="http://solidity.readthedocs.io/en/develop/abi-spec.html">official documentation</a>:</p><blockquote>The encoding is not self describing and thus requires a schema in order to decode.</blockquote><p>What this means is that, if we are to be able to understand and interact with a contract, we need to know its <a href="https://en.wikipedia.org/wiki/Application_binary_interface">ABI specification</a>. An ABI (Application Binary Interface) is the interface specification of a program.</p><p>Here’s what that specification looks like for this contract (you can see it yourself by solc --abi Recorder.sol).</p><pre>[<br>  {<br>    &quot;constant&quot;: false,<br>    &quot;inputs&quot;: [<br>      {<br>        &quot;name&quot;: &quot;message&quot;,<br>        &quot;type&quot;: &quot;string&quot;<br>      }<br>    ],<br>    &quot;name&quot;: &quot;record&quot;,<br>    &quot;outputs&quot;: [],<br>    &quot;payable&quot;: false,<br>    &quot;stateMutability&quot;: &quot;nonpayable&quot;,<br>    &quot;type&quot;: &quot;function&quot;<br>  },<br>  {<br>    &quot;anonymous&quot;: false,<br>    &quot;inputs&quot;: [<br>      {<br>        &quot;indexed&quot;: false,<br>        &quot;name&quot;: &quot;_from&quot;,<br>        &quot;type&quot;: &quot;address&quot;<br>      },<br>      {<br>        &quot;indexed&quot;: false,<br>        &quot;name&quot;: &quot;_message&quot;,<br>        &quot;type&quot;: &quot;string&quot;<br>      }<br>    ],<br>    &quot;name&quot;: &quot;Record&quot;,<br>    &quot;type&quot;: &quot;event&quot;<br>  }<br>]</pre><p>This ABI spec will become relevant later on.</p><h4>Natspec</h4><p>The compiler can also produce documentation based on your use of <a href="https://github.com/ethereum/wiki/wiki/Ethereum-Natural-Specification-Format">Ethereum’s Natural Specification Format, or Natspec</a>. This can be used by UIs to display additional information to users and/or developers. This contract has such comments for itself and also for its record method.</p><p>Here’s the compile output.</p><pre>“devdoc”: {<br>  “author”: “Life on Mars — <a href="https://lifeonmars.pt/">https://lifeonmars.pt</a>&quot;,<br>  “methods”: {<br>    “record(string)”: {<br>      “params”: {<br>        “message”: “ — message to record”<br>      }<br>    }<br>  },<br>  “title”: “Recorder — record a message into the blockchain”<br>},<br>“userdoc”: {<br>  “methods”: {<br>    “record(string)”: {<br>      “notice”: “Sends the contract a message to record into the blockchain”<br>    }<br>  }<br>}</pre><p>I wanted to show you these internals, but we’ll be using Truffle from now on. Truffle is a framework for Ethereum, with a few niceties that’ll make our life easier. In our case, it’ll help with compilation and testing.</p><p><strong>You’ll need Truffle in order to follow along the next sections, so please </strong><a href="http://truffleframework.com/docs/getting_started/installation"><strong>follow the instructions to install it</strong></a><strong>.</strong></p><h3>Deploying and testing the contract on a local network</h3><p>In order to test and deploy the contract, we’ll need an Ethereum client running. We’ll get started with <a href="https://github.com/trufflesuite/ganache-cli">Ganache CLI</a>, which simulates the behaviour of a real client (such as <a href="https://github.com/ethereum/go-ethereum/">geth</a>, which we’ll look into later on), but it’s much faster. This speed contributes to faster development and testing cycles.</p><p><strong>As per the instructions, install it with </strong><strong>npm install -g ganache-cli and run it with </strong><strong>ganache-cli.</strong></p><p>Now, create a new recorder directory, cd into it, and run truffle init. We’ll need to configure Truffle to connect to ganache-cli. Edit the truffle.js file as follows:</p><pre>ℹ️ truffle.js<br>-------------</pre><pre>module.exports = {<br>  networks: {<br>    development: {<br>      host: &quot;localhost&quot;,<br>      port: 8545,<br>      network_id: &quot;*&quot;,<br>      gas: 4712387,<br>    }<br>  }<br>};</pre><p>Next, create a contracts/Recorder.sol file where you’ll store the contract’s source code, shown above.</p><p>Then create the migrations/2_deploy_contracts.js as such:</p><pre>ℹ️ migrations/2_deploy_contracts.js<br>-----------------------------------</pre><pre>var Recorder = artifacts.require(&quot;./Recorder.sol&quot;);</pre><pre>module.exports = function(deployer) {<br>  deployer.deploy(Recorder);<br>};</pre><p>Now we’re ready to open the truffle console, where we’ll get Truffle to deploy the Recorder contract into the network through migrate --reset. Truffle will make sure to compile your contract automatically for you.</p><p>(By the way, --reset tells truffle to <a href="http://truffleframework.com/docs/getting_started/migrations">run all the migrations from the beginning</a>. For the purposes of this post, we’re not interested in using migrations for contract versioning, so we’ll always use it to start the process anew.)</p><p>Once the contract is deployed, we’re ready to use it! We’ll store a couple of records and then proceed to query them.</p><p>We can call methods on contracts by acquiring a contract reference and calling the method directly on it:</p><pre>ℹ️ truffle console<br>-----------------</pre><pre>truffle(development)&gt; recorder = Recorder.at(Recorder.address)<br>truffle(development)&gt; recorder.record(&quot;first message&quot;);<br>truffle(development)&gt; recorder.record(&quot;second message&quot;);</pre><p>Note the ganache-cli output. Among other things, it’ll tell you how much gas was used up to run this transaction.</p><pre>ℹ️ ganache-cli output<br>-----------------</pre><pre>eth_sendTransaction</pre><pre>Transaction: 0x118de578d3bcbd9474099e5385b0a883ad18eaa99319f710f641db1cc6b2e8fe<br>  Gas usage: 24577<br>  Block Number: 14<br>  Block Time: Fri Nov 10 2017 20:06:42 GMT+0000 (WET)</pre><pre>eth_getTransactionReceipt</pre><p>In order to read what was written earlier, we’ll need to run the following.</p><pre>ℹ️ truffle console<br>------------------</pre><pre>truffle(development)&gt; recorder<br>  .Record({}, {fromBlock: 0, toBlock: &quot;latest&quot;})<br>  .get((error,result) =&gt; (<br>    console.log(result.map(<br>      (result) =&gt; (result.args._message)<br>    )<br>  )))</pre><p>Note how we invoked Record({}, {fromBlock: 0, toBlock: &quot;latest&quot;}). The first argument is used for filtering the results, which is outside the scope of this post. The second one is how we specify which block span we’ll be looking for the transaction logs for Record.</p><p>The get method takes a callback, and we’re just mapping over the the returned result to get to theargs._message value of each result.</p><p>If this all worked out, you should see your console output the following.</p><pre>ℹ️ truffle console<br>------------------</pre><pre>truffle(development)&gt; [ &#39;first message&#39;, &#39;second message&#39;]</pre><p>And that’s it! Your contract is deployed, you’ve used it to write messages into the chain, and you then queried it to get those messages back.</p><h4>Testing</h4><p>Before we try this on real networks, let’s look into testing the contract first. Truffle uses the <a href="https://mochajs.org/">Mocha</a> testing framework, and <a href="http://chaijs.com/">Chai</a> for assertions. We’ll be using the following test.</p><pre>ℹ️ test/recorder.js<br>-------------------</pre><pre>var Recorder = artifacts.require(&quot;Recorder&quot;);</pre><pre>contract(&#39;Recorder&#39;, function(accounts) {<br>  it(&quot;records event&quot;, function(done) {<br>    Recorder.deployed().then(function (instance) {<br>      instance<br>        .Record({}, {fromBlock: 0, toBlock: &quot;latest&quot;})<br>        .get(function (error, events) {<br>          assert.equal(<br>            0,<br>            events.length,<br>            &quot;There should be no events at start.&quot;<br>          );<br>          instance.record(&quot;pokemon&quot;).then(function () {<br>            instance<br>              .Record({}, {fromBlock: 0, toBlock: &quot;latest&quot;})<br>              .get(function (error, events) {<br>                assert.equal(<br>                  1,<br>                  events.length,<br>                  &quot;There should be one event after recording.&quot;<br>                );<br>                done();<br>              });<br>          });<br>        });<br>    });<br>  });<br>});</pre><p>It looks ugly, but it’s pretty simple as far as tests go:</p><ul><li>Recorder.deployed() resolves when it gets a hold of the deployed Recorder instance</li><li>we use instance.Record(...).get() first, to get the list of messages written to it</li><li>we check that it has no messages, with assert.equal(0, events.length)</li><li>we then write one message with instance.record(&quot;pokemon&quot;)</li><li>and finally, we ensure the message was written, with assert.equal(1, events.length)</li></ul><p>Create a file in the tests directory called recorder.js and paste the test into it. You can run this test by exiting the console and simply typing truffle test into your shell. Note that truffle deploys the contract anew every time you run a test file. See <a href="http://truffleframework.com/docs/getting_started/javascript-tests">the documentation</a> for more details.</p><pre>ℹ️ truffle test output<br>----------------------</pre><pre>Using network &#39;development&#39;.</pre><pre>Contract: Recorder<br>    ✓ records event (101ms)</pre><pre>1 passing (115ms)</pre><p>Success!</p><h3>Connecting to a real network</h3><p>You can now legitimately say that <em>it works on my machine</em>. Not good enough? Let’s try and get this to work on an actual Ethereum network.</p><p>Before we deploy into the actual <em>mainnet</em>, let’s use a <em>testnet</em> first. A testnet is an Ethereum network analog, supported by real nodes, but used mostly for testing. As such, testnets aren’t used for anything serious and the Ether therein shouldn’t hold any value. We’ll be using the <a href="https://github.com/ethereum/ropsten">Ropsten testnet</a>. This will allow us to use a <a href="https://ropsten.etherscan.io/">block explorer</a> to dig for our contract and transactions on the network.</p><p><strong>Install geth as per </strong><a href="https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum"><strong>the instructions</strong></a><strong>.</strong> Then we’ll sync up with Ropsten (<a href="https://github.com/ethereum/ropsten">more instructions</a>).</p><pre>ℹ️ shell<br>--------</pre><pre>$ geth --testnet --fast --bootnodes &quot;enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@52.169.14.227:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@13.84.180.240:30303&quot; --rpc</pre><ul><li>--testnet tells geth to connect to the Ropsten testnet</li><li>--fast or --syncmode=&quot;fast&quot; makes the blockchain synchronization faster (see <a href="https://github.com/ethereum/go-ethereum/pull/1889">this PR</a> for more details);</li><li>--bootnodes=... tells geth which nodes to connect to in order to discover the rest of the network</li><li>--rpc tells geth to enable the HTTP-RPC server, allowing trufle and other RPC clients to connect to it</li></ul><p>We can use the console geth provides to interact with the network. geth attach should do the trick, but if it doesn’t, look for the following line in the geth output.</p><pre>ℹ️ geth output<br>--------------</pre><pre>INFO [11-13|14:45:16] IPC endpoint opened: /Users/pokemon/.rinkeby/geth.ipc</pre><p>And run geth attach /Users/pokemon/.rinkeby/geth.ipc accordingly. This should drop you right into the console. Geth should be hard at work syncing with the Ropsten chain, which should take anywhere from a few minutes to a few hours, depending on your hardware and network. Here’s how we can check progress.</p><pre>ℹ️ geth console<br>---------------</pre><pre>&gt; eth.blockNumber<br>0</pre><p>eth.blockNumber returns the number of the most recent block [<a href="https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethblocknumber">docs</a>]. It’ll display 0 until you’ve synced up with the network, which we can check with eth.syncing:</p><pre>ℹ️ geth console<br>---------------</pre><pre>&gt; eth.syncing<br>false</pre><p>Bummer. It seems we aren’t connected to any nodes yet. We’ll have to wait to see this in geth’s output before we can continue.</p><pre>ℹ️ geth output<br>--------------</pre><pre>INFO [11-13|15:26:26] Block synchronisation started<br>INFO [11-13|15:26:28] Imported new block headers               count=384 elapsed=951.820ms number=384 hash=d3d5d5…c79cf3 ignored=0</pre><p>Great! Let’s try the console again:</p><pre>ℹ️ geth console<br>---------------</pre><pre>&gt; eth.blockNumber<br>0<br>&gt; eth.syncing<br>{<br>  currentBlock: 775342,<br>  highestBlock: 2356143,<br>  knownStates: 167957,<br>  pulledStates: 162021,<br>  startingBlock: 0<br>}</pre><p>Much better. We’ll wait until eth.syncing returns false again before we interact with the blockchain. That 0 up there <a href="https://github.com/ethereum/go-ethereum/issues/14338">is ok, don’t worry.</a></p><p>Here’s a few other commands to keep you busy:</p><ul><li>net.listening tells us whether the node is actively listening for network connections or not [<a href="https://github.com/ethereum/wiki/wiki/JavaScript-API#web3netlistening">docs</a>]</li><li>net.peerCount returns the number of connected peers [<a href="https://github.com/ethereum/wiki/wiki/JavaScript-API#web3netpeercount">docs</a>]</li><li>admin.peers gives us insight into the peers we’re connected to [<a href="https://github.com/ethereum/go-ethereum/wiki/Management-APIs#admin_peers">docs</a>]</li></ul><p>Let’s try deploying our contract to the Ropsten network. We’ll let Truffle do the hard work for us, again. However, Ropsten being a genuine faux network, we’ll need to get some genuine faux Ether for one of our accounts.</p><p>Let’s head on over to geth and confirm we have 0 Ether first:</p><pre>ℹ️ geth console<br>---------------</pre><pre>&gt; eth.getBalance(eth.accounts[0])<br>0</pre><p>Yep. I tried using a <a href="http://faucet.ropsten.be:3001/">Ropsten Faucet</a> but it was down when I tried it. The <a href="https://gitter.im/ethereum/ropsten">Ropsten Gitter</a> recommended I use <a href="https://faucet.metamask.io/">MetaMask’s Ether Faucet</a>, which you need <a href="https://metamask.io/">MetaMask</a> to use, and it worked well for me.</p><p>I then used MetaMask to send Ether to my account in geth. First I had to find out its address.</p><pre>ℹ️ geth console<br>---------------</pre><pre>&gt; eth.accounts[0]<br>&quot;0xff7771583ee3944a9ef32cfcb54c0b0d688fa70a&quot;</pre><p>Then I used “Send” inside MetaMask to send funds to this address. The transfer shouldn’t take more than a couple of minutes (you can click the transfer in MetaMask to go check it out on Etherscan). Once it’s confirmed, you should be able to confirm this inside geth:</p><pre>ℹ️ geth console<br>---------------</pre><pre>&gt; eth.getBalance(eth.accounts[0])<br>1836311700000000000</pre><p>Let’s also use this account address to tell Truffle which account to use to interact with the blockchain. Update your truffle.js file to look like this:</p><pre>ℹ️ truffle.js<br>-------------</pre><pre>module.exports = {<br>  networks: {<br>    development: {<br>      host: &quot;localhost&quot;,<br>      port: 8545,<br>      network_id: &quot;*&quot;,<br>      from: /* YOUR ADDRESS HERE */,<br>      gas: 4000000,<br>    }<br>  }<br>};</pre><p>Because we’re sticklers, we’re running the tests again, now on Ropsten.</p><pre>ℹ️ shell<br>--------</pre><pre>$ truffle test</pre><pre>Using network &#39;development&#39;.</pre><pre>Error encountered, bailing. Network state unknown. Review successful transactions manually.<br>Error: authentication needed: password or unlock</pre><p>Oh, right. So, geth keeps this account locked for your protection. In order to use it, you need to unlock it. Back to geth: let’s keep the account unlocked as long as geth remains open [<a href="https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_unlockaccount">docs</a>].</p><pre>ℹ️ geth console<br>---------------</pre><pre>&gt; personal.unlockAccount(eth.accounts[0], &quot;password&quot;, 0)</pre><p>Great. Let’s try again now.</p><pre>ℹ️ shell<br>--------</pre><pre>$ truffle test</pre><pre>Using network &#39;development&#39;.</pre><pre>Contract: Recorder<br>    ✓ records event (54382ms)</pre><pre>1 passing (54s)</pre><p>It took a lot longer than with Ganache CLI, but the tests passed. Now let’s boot truffle console and try to deploy the contract. This time, Ganache CLI is not the target. Ropsten is.</p><pre>ℹ️ truffle console<br>------------------</pre><pre>truffle(development)&gt; migrate --reset<br>Using network &#39;development&#39;.</pre><pre>Running migration: 1_initial_migration.js<br>  Replacing Migrations...<br>  ... 0x2b330d5a4bac42ac3aea135c0f7090502f05e5349a6684c869db9a9591d02bd3</pre><p>Much better, but this will take a while to finish. Take the time to note something like this on geth’s output.</p><pre>ℹ️ geth output<br>--------------</pre><pre>INFO [11-22|11:05:50] Submitted contract creation              fullhash=0xfb92a0da5e5b7d13a155b1c57bb46ffeb672502842ffe744de30be068a4d5b4f contract=0xf7Ec3C971DFA6549e2c0aC4437068e86dC39b25F</pre><p>Neat, right? By the way, you can copy that transaction hash and contract address and go look for them in <a href="https://ropsten.etherscan.io/">Ropsten Etherscan</a>. It might take a minute for it to show up, but it will. We’re deploying contracts onto a real network now. Remember, you don’t own a server. This is nothing short of awesome.</p><p>In the meantime, Truffle keeps going.</p><pre>ℹ️ truffle console<br>------------------</pre><pre>Running migration: 1_initial_migration.js<br>  Replacing Migrations...<br>  ... 0x2b330d5a4bac42ac3aea135c0f7090502f05e5349a6684c869db9a9591d02bd3<br>  Migrations: 0xf1867e8ac0fe8c4dd26157c2e5123b9f5d63e0e0<br>Saving successful migration to network...<br>  ... 0x3c0364b133a07bed6f34c1e2b733f57cfee65ded088bdd452547bfba5eb3c18c<br>Saving artifacts...<br>Running migration: 2_deploy_contracts.js<br>  Deploying Recorder...<br>  ... 0x4c86ec2e5da57f734706257a86e7fff929538a68ed7a5265cc628b984613d822<br>  Recorder: 0x949d9ac08845f74ec7cd96337920b672fb31c017<br>Saving successful migration to network...<br>  ... 0x02c04fc250d3077c12eef7e3c580564f03791ee53de2a1dfcc82eb37deba3911<br>Saving artifacts...</pre><p>Sweet. We’re done. See this line?</p><pre>ℹ️ truffle console<br>------------------</pre><pre>Recorder: 0x949d9ac08845f74ec7cd96337920b672fb31c017</pre><p>Yea, <a href="https://ropsten.etherscan.io/address/0x949d9ac08845f74ec7cd96337920b672fb31c017">that’s us</a>. We’re live on the Ropsten testnet.</p><p>Let’s play with our contract. We know it works because it passes the tests, but still. Back to Truffle, so we can record a message and make sure it stays there.</p><pre>ℹ️ truffle console<br>------------------</pre><pre>truffle(development)&gt; recorder = Recorder.at(Recorder.address)<br>truffle(development)&gt; recorder.record(&quot;i dont even&quot;)</pre><p>This will take a couple of minutes, since we’re on Ropsten now. But then:</p><pre>ℹ️ truffle console<br>------------------</pre><pre>truffle(development)&gt; recorder.Record(<br>  {},<br>  {fromBlock: 0, toBlock: &quot;latest&quot;}<br>).get(function (error,result) {<br>  console.log(result.map((x)=&gt;(x.args._message)))<br>})<br>truffle(development)&gt; [&#39;i dont even&#39;]</pre><p>Perfect!</p><h3>Using the Ethereum mainnet</h3><p>Armed with all this knowledge, we can now easily deploy the same contract into the mainnet. For brevity, we’ll skip a few steps like testing, and get right to it.</p><p>Let’s restart geth and have it connect to the mainnet.</p><pre>ℹ️ shell<br>--------</pre><pre>$ geth --fast --cache=512</pre><p>We’ll need to wait for geth to sync up. Go get busy elsewhere, this will take some time now.</p><p>Once eth.syncing returns false again, let’s use truffle to get this deployed. Make sure that whichever account you’re using has funds in it. Real ether.</p><pre>ℹ️ shell<br>--------</pre><pre>$ truffle migrate --reset</pre><p>This will probably not go well at first. There’s two failure modes that you’re likely to run into. There’s this beauty:</p><pre>ℹ️ truffle migrate output<br>-------------------------</pre><pre>Running migration: 1_initial_migration.js<br>  Deploying Migrations...<br>  ... undefined<br>Error encountered, bailing. Network state unknown. Review successful transactions manually.<br>Error: insufficient funds for gas * price + value</pre><p>And this one too:</p><pre>ℹ️ truffle migrate output<br>-------------------------</pre><pre>Running migration: 1_initial_migration.js<br>  Deploying Migrations...<br>  ... undefined<br>Error encountered, bailing. Network state unknown. Review successful transactions manually.<br>Error: exceeds block gas limit</pre><p>So, this is geth telling truffle that your <a href="http://truffleframework.com/docs/advanced/configuration">gas settings</a> aren’t ideal. I recommend setting gas to a reasonably high value, like 1000000 (notice above how the contract deployment was using up about ~20K gas), and checking out <a href="https://ethgasstation.info/">ETH Gas Station</a> to figure out how much the value of gasPrice should be. Here’s what I see now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YhwulqooonC2gFrrgbIdNw.png" /></figure><p>So, 10 Gwei gets us a confirmation in 0.53 minutes. That’s pretty good. <a href="https://etherconverter.online/">Ethereum Converter</a> can helps us turn that into wei.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0jgBkIvri5aBqtnnemq4VQ.png" /></figure><p>So here’s what truffle.config should look like now.</p><pre>ℹ️ truffle.js<br>-------------</pre><pre>module.exports = {<br>  networks: {<br>    development: {<br>      host: &quot;localhost&quot;,<br>      port: 8545,<br>      network_id: &quot;*&quot;,<br>      from: &quot;0x13f53d42fc7cf4f1cf4ca8031a526f6a8528cdfa&quot;,<br>      gas: 1000000,<br>      gasPrice: 10000000000,<br>    }<br>  }<br>};</pre><p>This should have you well on your way!</p><h3>Building a web frontend</h3><p>Let’s move on to implementing a web frontend for this contract. Sure — it’s already public and available for anyone to use… kind of. Using geth isn’t the most user-friendly tool, plus you can’t easily interact with a contract you don’t have the ABI for. So, we’ll need to go the extra mile to make this available to the general public.</p><p>We’ll start by using <a href="https://github.com/ethereum/web3.js/">web3.js</a> and connecting it to our local node. What’s web3.js? From <a href="https://github.com/ethereum/web3.js/">the README</a>:</p><blockquote>This is the Ethereum compatible <a href="https://github.com/ethereum/wiki/wiki/JavaScript-API">JavaScript API</a> which implements the <a href="https://github.com/ethereum/wiki/wiki/JSON-RPC">Generic JSON RPC</a> spec.</blockquote><p>Let’s go back to Ganache CLI, since it’s faster than using a real network. Start it with ganache-cli. Re-adjust your truffle.js, and re-deploy your contract. Get its address.</p><p>Then get the first account address from the ganache-cli output.</p><pre>ℹ️ ganache-cli output<br>-----------------</pre><pre>Available Accounts<br>==================<br>(0) 0xa2dee6cd83d3d9cb6fb2d42899abcbdf04bf344f</pre><p>We can use Truffle to check the balance of this account. To do that, we’ll also use the web3 library, which is conveniently included in truffle. It tells us this account is loaded.</p><pre>ℹ️ truffle console<br>------------------</pre><pre>truffle(development)&gt; account = &quot;0xa2dee6cd83d3d9cb6fb2d42899abcbdf04bf344f&quot;<br>truffle(development)&gt; parseInt(web3.eth.getBalance(account))<br>&#39;99944815499999920000&#39;</pre><p>Great! Let’s double-check that in the browser. <a href="https://github.com/ethereum/web3.js/blob/develop/dist/web3.js">Download web3.js</a> and include it on an HTML file with a &lt;script&gt; tag. Open that file in your browser and throw this in the console.</p><pre>ℹ️ browser javascript console<br>-----------------------------</pre><pre>&gt; var host = &quot;<a href="http://localhost:8545/">http://localhost:8545</a>&quot;<br>&gt; var web3 = new Web3(new Web3.providers.HttpProvider(host))<br>&gt; var account = &quot;0xa2dee6cd83d3d9cb6fb2d42899abcbdf04bf344f&quot;<br>&gt; parseInt(web3.eth.getBalance(account))<br>&lt; 99944815499999920000</pre><p>Great. Now that we know we can connect our browser to Ganache CLI, let’s move on to better things. What we want to do is test writing to and reading from the contract. Here’s a start.</p><pre>ℹ️ browser javascript console<br>-----------------------------</pre><pre>&gt; var contractABI = JSON.parse(&#39;[{&quot;constant&quot;:false,&quot;inputs&quot;:[{&quot;name&quot;:&quot;message&quot;,&quot;type&quot;:&quot;string&quot;}],&quot;name&quot;:&quot;record&quot;,&quot;outputs&quot;:[],&quot;payable&quot;:false,&quot;stateMutability&quot;:&quot;nonpayable&quot;,&quot;type&quot;:&quot;function&quot;},{&quot;anonymous&quot;:false,&quot;inputs&quot;:[{&quot;indexed&quot;:false,&quot;name&quot;:&quot;_from&quot;,&quot;type&quot;:&quot;address&quot;},{&quot;indexed&quot;:false,&quot;name&quot;:&quot;_message&quot;,&quot;type&quot;:&quot;string&quot;}],&quot;name&quot;:&quot;Record&quot;,&quot;type&quot;:&quot;event&quot;}]&#39;);<br>&gt; var contractAddress = &quot;0x2680998ab6aa13fd092636ec974f5e305a8d9051&quot;;<br>&gt; var web3 = new Web3(new Web3.providers.HttpProvider(&quot;<a href="http://localhost:8545/">http://localhost:8545</a>&quot;));<br>&gt; web3.eth.defaultAccount = &quot;0xa2dee6cd83d3d9cb6fb2d42899abcbdf04bf344f&quot;;<br>&gt; var contract = web3.eth.contract(contractABI).at(contractAddress);</pre><p>Alright, we have a hold of a contract instance now. Let’s try and record something onto it.</p><pre>ℹ️ browser javascript console<br>-----------------------------</pre><pre>&gt; contract.record(&quot;hello from console&quot;);<br>&lt; &quot;0x09506da426e48b5b9a36cda4dd176767a1a3a1392c80299a4b3a16281f10ece3&quot;</pre><p>Oh look, it’s a transaction ID. This has got to be good. Let’s check that it worked, shall we?</p><pre>ℹ️ browser javascript console<br>-----------------------------</pre><pre>&gt; contract.Record({}, {fromBlock: 0, toBlock: &quot;latest&quot;}).get(function (error, results) {<br>  console.log(results.map((result) =&gt; (result.args._message)));<br>});<br>[&quot;hello from console&quot;]</pre><p>It seems to work! We’re now ready to move on.</p><h4>Using MetaMask</h4><p>Notice we’re setting web3.eth.defaultAccount above, and using one of the accounts Ganache CLI created for us. Now, this is fine for development, but when you throw this on the Web, you’d ideally like users to be the ones paying for the transactions.</p><p>Enter MetaMask. MetaMask is a Chrome extension serving as an in-browser Ethereum wallet. <strong>You’ll need it to continue, so </strong><a href="https://metamask.io/"><strong>go install it</strong></a><strong>.</strong></p><p>Additionally, to use MetaMask for development, you’ll need to have a local server running, as just opening the HTML file won’t cut it. Do that in any way you’d like. I like using python.</p><pre>ℹ️ shell<br>--------</pre><pre>$ python -m SimpleHTTPServer<br>Serving HTTP on 0.0.0.0 port 8000 ...</pre><p>Get rid of the &lt;script&gt; tag and head on over to localhost:8000 on your browser. If you type web3 into the console, you shouldn’t see undefined. If you do, make sure MetaMask is running.</p><p>Finally, ensure MetaMask is connected to your local node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*lb2PvNpzCIX8TMEPLXnfQw.png" /></figure><p>Let’s try this again, now without setting web3.eth.defaultAccount. Throw this in the console.</p><pre>ℹ️ browser javascript console<br>-----------------------------</pre><pre>&gt; var contractABI = JSON.parse(&#39;[{&quot;constant&quot;:false,&quot;inputs&quot;:[{&quot;name&quot;:&quot;message&quot;,&quot;type&quot;:&quot;string&quot;}],&quot;name&quot;:&quot;record&quot;,&quot;outputs&quot;:[],&quot;payable&quot;:false,&quot;stateMutability&quot;:&quot;nonpayable&quot;,&quot;type&quot;:&quot;function&quot;},{&quot;anonymous&quot;:false,&quot;inputs&quot;:[{&quot;indexed&quot;:false,&quot;name&quot;:&quot;_from&quot;,&quot;type&quot;:&quot;address&quot;},{&quot;indexed&quot;:false,&quot;name&quot;:&quot;_message&quot;,&quot;type&quot;:&quot;string&quot;}],&quot;name&quot;:&quot;Record&quot;,&quot;type&quot;:&quot;event&quot;}]&#39;);<br>&gt; var contractAddress = &quot;0x2680998ab6aa13fd092636ec974f5e305a8d9051&quot;;<br>var web3 = new Web3(web3.currentProvider);<br>var contract = web3.eth.contract(contractABI).at(contractAddress);</pre><pre>contract.Record({}, {fromBlock: 0, toBlock: &quot;latest&quot;}).get(function (error, results) {<br>  console.log(results.map((result) =&gt; (result.args._message)));<br>});<br>[&quot;hello from console&quot;]</pre><p>It works as expected. Let’s try and record another message and make sure we can read that one as well.</p><pre>ℹ️ browser javascript console<br>-----------------------------</pre><pre>&gt; contract.record(&quot;hello again&quot;)<br>Uncaught Error: The MetaMask Web3 object does not support synchronous methods like eth_sendTransaction without a callback parameter</pre><p>Uh-oh. This happens because MetaMask is a <a href="https://github.com/ethereum/wiki/wiki/Light-client-protocol">light Ethereum client</a>. This means that it doesn’t store all of the blockchain data, and depends on asking the network for the data it needs every time.</p><p>As such, we’ll need to use asynchronous methods to do the same thing we were doing before. Not too complicated, mind you.</p><pre>ℹ️ browser javascript console<br>-----------------------------</pre><pre>&gt; contract.record(&quot;hello again&quot;, (error, result) =&gt; (console.log(result)))</pre><p>Once you’ve done this, MetaMask should pop this up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*x7f-aZL2yGBwCYVsBuJs3A.png" /></figure><p>Note that it says your balance is insufficient. That makes sense. Let’s send some funds to this account that MetaMask created for us. First, get a hold of the account address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*h6Wg9VDgKoZqIvUhn-qakg.png" /></figure><p>Now, back to truffle.</p><pre>ℹ️ truffle console<br>------------------</pre><pre>truffle(development)&gt; web3.eth.sendTransaction({<br>  from: web3.eth.accounts[0],<br>  to: &quot;0x6a7eB27407a50a4eb9d015EA2B0F2e1BcC724461&quot;,<br>  value: 5000000000000000}<br>)</pre><p>Let’s try the same command again now.</p><pre>ℹ️ browser javascript console<br>-----------------------------</pre><pre>&gt; contract.record(&quot;hello again&quot;, (error, result) =&gt; (console.log(result)))</pre><p>This time, the popup should have no error messages. Click send. You should be able to see something like this on Ganache CLI.</p><pre>ℹ️ ganache-cli output<br>-----------------</pre><pre>eth_sendRawTransaction</pre><pre>Transaction: 0xfd78adcb6bd3aa86d6e67e5edc946ca3b53235553d4cc5a409c3566bdafb13f6<br>  Gas usage: 25025<br>  Block Number: 24<br>  Block Time: Wed Nov 22 2017 15:58:27 GMT+0100 (CET)</pre><p>Did it work? Well, let’s check it out!</p><pre>ℹ️ browser javascript console<br>-----------------------------</pre><pre>&gt; contract.Record({}, {fromBlock: 0, toBlock: &quot;latest&quot;}).get(function (error, results) {<br>  console.log(results.map((result) =&gt; (result.args._message)));<br>});<br>[&quot;hello from console&quot;, &quot;hello again&quot;]</pre><p>That’s 2 messages there. Success!</p><p>From here on out, you’d switch from Ganache CLI to Ropsten and then the Ethereum mainnet. I’ll spare you this duplication in this post.</p><h3>Final notes</h3><p>There’s a couple of extra things we had to do (aside from, well, building the website) in order to get <a href="https://forever.lifeonmars.pt/">Forever on the Chain</a> working as intended.</p><p>In order to have the “Saved messages” list update itself with new entries, we decided to make use of the <a href="https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-events">event watch method</a>. This sets up a listener which invokes your callback whenever an event, fitting of whichever criteria you like, lands on the chain. Here’s how we did it.</p><pre>contract.Record(<br>  {},<br>  {fromBlock: 4491369, toBlock: &quot;latest&quot;}<br>).watch(function (error, result) {<br>  // DO THINGS<br>});</pre><p>Note that 4491369 up there. Since we’re connecting to mainnet, sweeping all transactions from block 0 would be prohibitively slow. As such, we’re limiting our search to events starting at the block number of the block that the contract was deployed into. You can find that number by using Etherscan, but <a href="https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethgettransaction">web3 can also help you</a> if you know the transaction the contract was created in.</p><p>Even though this is pretty straightforward, <a href="https://github.com/MetaMask/metamask-extension/issues/2114">MetaMask wasn’t happy with this</a>, so we ended up deploying a light node on an EC2 instance instead.</p><p>The code for this project is <a href="https://github.com/lifeonmarspt/ethereum-eventer">available on GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fccdfe5176ce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/full-stack-smart-contract-development-fccdfe5176ce">Full-stack smart contract development</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>