<?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 Manuel Araoz on Medium]]></title>
        <description><![CDATA[Stories by Manuel Araoz on Medium]]></description>
        <link>https://medium.com/@maraoz?source=rss-71b7575196fd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sm_9GadAsNu-YWD1XZC6lQ.png</url>
            <title>Stories by Manuel Araoz on Medium</title>
            <link>https://medium.com/@maraoz?source=rss-71b7575196fd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 01:46:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maraoz/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[Why I’m Building Zeppelin]]></title>
            <link>https://maraoz.medium.com/why-im-building-zeppelin-3b8576605d2a?source=rss-71b7575196fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b8576605d2a</guid>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Manuel Araoz]]></dc:creator>
            <pubDate>Fri, 28 Dec 2018 12:01:00 GMT</pubDate>
            <atom:updated>2018-12-28T17:18:42.102Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KtCReJXRqWjgRvoYpl-lSA.png" /></figure><p>The purpose of this post is to update my personal vision of Zeppelin and Zeppelin’s projects, as their founder and CTO. This is my own personal perspective, and some Zeppelin team members may not be aligned with my views. However, several people told me it would be helpful if they could read my understanding of this topic as a base for further discussions, to inform long-term planning and product design. If nothing else, it has been useful to write it as a personal log.</p><h4>Zeppelin (the Company)</h4><p>As an organization and team, we work to <strong>build technology that helps bring freedom to the world</strong>. I believe in the power of technology to change the world by enabling new ways of doing things and opening new doors. I see a unique opportunity today to empower people who have very few resources: writing code is almost free, and it can have a huge impact in the world.</p><p>Personally, I don’t agree with how many things in the legacy world are done. Some old traditions, institutions, and ideas are being carried over from the days before we invented the Internet, and they bring injustice and suffering to millions.</p><ul><li>People die of hunger in a world of abundance.</li><li>Nations force people to pick up guns and kill strangers for reasons they don’t understand.</li><li>People are forced to waste time in unnecessary and meaningless processes.</li><li>People are forced to pay for things they don’t want (e.g., war).</li><li>Many have lost trust in the elites that govern us and watch over the “common good”.</li><li>Our education system prepares kids for an industrial world that no longer exists.</li></ul><p>These are all consequences of a system that was the most efficient way of doing things at one point in time. A world based in paper, industry, and big institutions that take care of our needs and worries. But the world has changed now, and its systems need an update. We have more efficient technologies and better tools for deciding for ourselves. This will affect how we choose to spend our time, how we grow personally and professionally, and <a href="https://blog.zeppelin.solutions/an-open-standard-for-value-creation-b5faa98f2851?utm_campaign=zep-vision-why-im-building-zeppelin&amp;utm_medium=blog&amp;utm_source=medium">how we create value for others</a>. I think we’ll see many major changes in how the world operates, and I want Zeppelin to be a big part of that, accelerating, leading, shepherding, and enabling the changes we’re most aligned with.</p><p>One such change I personally align with strongly is enhancing the empowerment the Internet has brought to humanity. Roughly 1.2 million <em>new</em> users connect to the Internet for the first time <em>every day</em>, instantly gaining access to most of human knowledge and the biggest human tribe. We still haven’t seen the full potential of this wonder realized.</p><h4>OpenZeppelin</h4><p>Our flagship and most-loved project, which made us rename the company from Smart Contract Solutions to Zeppelin Solutions — and later Zeppelin, because everyone called us “the Zeppelin guys.”</p><p>The vision of this project is to be <a href="https://blog.zeppelin.solutions/zeppelin-a-new-standard-for-secure-blockchain-applications-47449420fb6a?utm_campaign=zep-vision-why-im-building-zeppelin&amp;utm_medium=blog&amp;utm_source=medium">a community-built standard of secure smart contracts</a>.</p><p>We launched the project two years ago, just before DEVCON2 in Shanghai, as a very ambitious and (what at the time seemed crazy) initiative: smart contract development in 2016 was very chaotic and fragmented, and major hacks happened every month. We managed to get initial community support because we were new to the Ethereum space, but brought in <a href="https://www.coindesk.com/blockchain-veterans-unveil-secure-smart-contracts-framework/">some successes from the early Bitcoin days</a> on our shoulders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bk5AU3yr1aQI3xuh" /><figcaption>(Source: <a href="https://npm-stat.com/)">https://npm-stat.com/)</a></figcaption></figure><p>After two years of existence, I think we have achieved the original goal of becoming the community standard for smart contract development. We have 150+ contributors from all over the world, independent and working for different companies, 2,000+ forks, ~6000 stars, and we’ve been on top of industry’s needs, so much so that it’s now seen as the place to look for reference implementations of <a href="https://github.com/ethereum/EIPs">EIPs</a>.</p><p>We recently launched <a href="https://github.com/OpenZeppelin/openzeppelin-solidity/releases/tag/v2.0.0-rc.1">the 2.0 release</a>, which stabilizes the API, is audited, and has 100% test coverage. This allows us to maintain our hard-earned position guiding the work of our amazing community.</p><h4>Zeppelin Research</h4><p>We started performing security audits as a way to push the industry to grow and mature. By helping key projects achieve their goals without being hacked, we also built our team’s technical understanding of smart contract development and learned valuable lessons to guide OpenZeppelin development.</p><p>Audits were a great strategy to achieve profitability as a company (which means ensuring our long-term survival and achievement of goals) and to grow our network of allies in the space. Many big names such as the Ethereum Foundation, Augur, and DFINITY became close with us after we worked with them on audits, because they loved our work style, values, and output.</p><p>In general, consulting (audits are a specific form of consulting) is a great way to make a company viable in a nascent industry. Given the uncertainty of the pace at which a new technology will grow, consulting means getting paid to build expertise and ride the wave. In our case, audits were key to making Zeppelin what we are today: technical thought leaders, one of the most respected teams in the industry, and a beloved brand.</p><h4>ZeppelinOS</h4><p>The need for and idea of ZeppelinOS originated from our audit and OpenZeppelin work. By working with our clients, we discovered that the fear of being hacked or of contracts being buggy was the main reason they were paying us good money for our audits and using OpenZeppelin’s community-vetted contracts.</p><p>By working closely with <a href="https://medium.com/@SolidStamp/solidstamp-smart-contract-auditor-report-july-2018-edition-dd4d64406fc8">more than 50 projects</a> (the link reports only the public audits we did) in the space in our audits and developing OpenZeppelin, we found that smart contract development had lots of pain beyond standardization and security (which we tackled quite successfully with OZ). We discovered that all smart contract developers shared the same pain points:</p><ul><li>Smart contract DX is hell.</li><li>Lack of proper development and testing tooling.</li><li>Understanding smart contract tech is hard (few good education resources).</li><li>It’s very hard to maintain and operate a production smart contract.</li><li>Any bugs found in production are very costly to fix (via redeployment and state migrations): <a href="https://blog.zeppelin.solutions/augur-rep-token-critical-vulnerability-disclosure-3d8bdffd79d2?utm_campaign=zep-vision-why-im-building-zeppelin&amp;utm_medium=blog&amp;utm_source=medium">see, for example, Augur’s REP token migration</a>, which cost ~$20k in gas and extra money in consulting fees to us, and both teams worked full time on it for 10 days.</li><li>Each contract is built separately and monolithically with no interaction or shared code.</li></ul><p>Given that at Zeppelin we’ve been working with smart contracts since they were a nascent technology (early smart contract work we did dates to 2012), we’re not afraid of its rough edges. We’ve been working with smart contracts on different platforms (bitcoin scripting, off-chain bitcoin transactions, and now ethereum) and are ready to work on whatever the industry is using.</p><p>Additionally, our experience playing with smart contracts since the early days makes us very well positioned to tackle these problems head-on and as our main focus. That’s why we decided to create ZeppelinOS, an initiative to make secure smart contract development a breeze.</p><p>Since we started thinking about it almost a year ago, we announced it, gathered some community interest behind us (in the form of enthusiasm and investment), and launched the MVP version at <a href="https://ethbuenosaires.com/?utm_campaign=zep-vision-why-im-building-zeppelin&amp;utm_medium=blog&amp;utm_source=medium">ETHBuenosAires</a>, which tackled the two most pressing needs: smart contract maintainability through an upgradeability system, and proper code reusability.</p><p>The following steps for ZeppelinOS, tackled in v2, which we recently announced at DEVCON4, are decentralizing the trust by which on-chain code is made secure by:</p><ol><li>supporting multiple dependencies in the form of <a href="https://blog.zeppelinos.org/open-source-collaboration-in-the-blockchain-era-evm-packages/?utm_campaign=zep-vision-why-im-building-zeppelin&amp;utm_medium=blog&amp;utm_source=medium">EVM packages</a>, and</li><li>paving the road for <a href="https://blog.zeppelinos.org/announcing-the-zep-token-private-beta/?utm_campaign=zep-vision-why-im-building-zeppelin&amp;utm_medium=blog&amp;utm_source=medium">a secure code ecosystem where experts can share their analysis of existing code</a>.</li></ol><h3>What Our 2019 Will Look Like</h3><p>We’re in a privileged position in the blockchain space: we have a strong brand, an amazing team, a healthy business model, and we’re tackling real problems of real people who are willing to pay money for our solutions.</p><p>So 2019 will be a very important year for us: the financial downturn of cryptoassets will make many companies in the space go out of business, and the focus of conversations will go back to building. For us, this means focusing even more strongly on working with the best projects in the space (those that will most likely survive) and continuing to be sustainable (profitable) while investing in long-term development of the core technologies that will realize our vision.</p><ul><li>For Zeppelin the company, we’ll stay lean and continue having the highest standards for hiring, both in terms of vision alignment and culture (our work values). Staying lean will make us survive, and keeping our standards high is our long-term investment.</li><li>For OpenZeppelin, we’ll consolidate the project’s community and learning resources for it to become not only the standard in code quality but also in documentation and contributor experience. This will help bring more developers into the space and will serve as an example of how to build other great EVM packages.</li><li>For Zeppelin Research, we’ve recently created a dedicated team (previously, the whole technical team took turns auditing), and we’re looking to find a sustainable working methodology that combines audits and open-ended research. This will allow us to continue working with strategic projects in the space, helping them be safe from errors and attacks, while learning and exploring new technologies that will nurture our other projects.</li><li>For ZeppelinOS, after v2 release, we’re working with our <a href="https://blog.zeppelinos.org/announcing-the-zep-token-private-beta/?utm_campaign=zep-vision-why-im-building-zeppelin&amp;utm_medium=blog&amp;utm_source=medium">private beta partners</a> to test our initial implementation of the ZEP token mechanics, while giving support to our current users of upgradeability mechanisms and EVM packages, aiming to become the standard in smart contract upgradeability and code reuse. Next, we’ll work on turning ZeppelinOS into the best smart contract development and operation platform out there. This will reduce the barriers of entry to blockchain technology, allowing more people to bring their ideas to production dapps.</li></ul><p>It’s going to be fun! If what you just read resonates with you, contact us to <a href="https://zeppelin.solutions/jobs/?utm_campaign=zep-vision-why-im-building-zeppelin&amp;utm_medium=blog&amp;utm_source=medium">explore working together</a>. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b8576605d2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Global Coordination Machine]]></title>
            <link>https://maraoz.medium.com/the-global-coordination-machine-ed5aba8f6456?source=rss-71b7575196fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed5aba8f6456</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Manuel Araoz]]></dc:creator>
            <pubDate>Fri, 12 Oct 2018 12:59:29 GMT</pubDate>
            <atom:updated>2019-02-13T20:50:30.395Z</atom:updated>
            <content:encoded><![CDATA[<p>Few applications need blockchains. Distributed consensus makes <a href="https://twitter.com/SarahJamieLewis/status/1041589971709321216">each computational step very expensive</a>. Only apps for which users are willing to pay such a cost will make sense in the new decentralized paradigm. But what makes an app <em>need</em> a blockchain?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F6Wdd7YefEUPSRezvds57g.png" /></figure><h3>A Brief History of Computer Innovation</h3><p>The first such app was bitcoin, the first free currency. Why are <a href="https://www.bitcoinmarketjournal.com/how-many-people-use-bitcoin/">the ~20M bitcoin users</a> willing to pay the price of running a currency on top of a costly, slow platform such as a blockchain? Let’s explore the answer by analogy.</p><p>In 1982, why did my dad spend $150 at an obscure computer store in Buenos Aires to buy <a href="https://en.wikipedia.org/wiki/Timex_Sinclair_1000">a Timex Sinclair 1000</a>? He wanted to experiment with programming. He was buying the ability to process information quickly and on his own terms.</p><p>In 1995, why did nerds spend thousands of dollars to connect to other computers around the globe? They wanted to read and post messages on online bulletin boards. They were buying access to information.</p><p>In 2007, why did so many people choose to <a href="https://en.wikipedia.org/wiki/IPhone_(1st_generation)#Release">spend $500</a> to carry around a small computer with a tiny screen, few apps, and very bad specs? They wanted a computer on-the-go. They were buying mobility.</p><p>Each step in the history of computation brought many inefficiencies, but also a new key feature. Early adopters were willing to pay the cost of switching to a new platform in order to get a taste of something different. Most times even <em>they</em> didn’t understand it fully.</p><p>So, what are early adopters buying when they use blockchain-based apps? They want to participate in a global, open, permissionless, stateful playground. They are buying <strong>access to global coordination</strong>. They get to participate in ground-up, large-scale human coordination experiments.</p><p>The time was ripe for such doors to open. We saw the world transition from paper-based systems (e.g., nations) to closed machine-based systems (e.g., corporations) to open digital-based systems (e.g., internet communities). A mere 10 years ago, only nation-states and huge multinational corporations such as Exxon, Google, and Apple could coordinate efforts globally. The cost of doing so was simply unbearable for anyone except them, given how slowly information flowed back then. Some such pre-blockchain experiments were the US dollar, capitalism, socialism, feudalism, the World Trade Center, and the International Space Station. Only huge centralized institutions could withstand the costs of such projects. That’s why they control the data, the money, and the terms on which we interact.</p><p>However, since Satoshi released a solution to <a href="https://en.wikipedia.org/wiki/Byzantine_fault_tolerance#Byzantine_Generals&#39;_Problem">the Byzantine Generals’ Problem</a> to the world in 2008, the internet turned into a global coordination machine. This enabled us to create a global currency without relying on huge institutions as trust anchors. Not only did this enable bitcoin, but it drastically lowered the material barriers to innovation in the global coordination space by bringing it to the digital space. Kids around the world can now run experiments on global coordination from their mom’s basement at almost no cost. What’s best is that when they <a href="https://en.bitcoin.it/wiki/Block_size_limit_controversy">disagree on which direction the experiments should take</a>, they can part ways and <a href="https://en.wikipedia.org/wiki/Bitcoin_Cash">try their different ideas by forking the protocols</a>. Some such experiments have been:</p><ul><li>A globally shared virtual computer, <a href="https://ethereum.org/">Ethereum</a>.</li><li>Thousands of <a href="https://techcrunch.com/2017/05/23/wtf-is-an-ico/">privately issued application-specific currencies</a>.</li><li>A <a href="https://lightning.network/">cheap, fast, and scalable payment network</a>.</li><li>Many globally available financial products such as <a href="https://0xproject.com/">decentralized exchanges</a>.</li></ul><p>Think about how hard it would have been for anyone to create a new stateful global coordination mechanism (such as the USD for global commerce) 10 years ago. It was virtually impossible unless they had a strong physical presence, collaboration agreements with multiple world regions, huge amounts of capital at their disposal, and lots of people to operate those components. Blockchains turned the internet into a <a href="https://tplprotocol.org/?utm_source=zeppelin&amp;utm_medium=blog&amp;utm_campaign=global-coordination-machine">digital jurisdiction</a> where we can all run our global coordination experiments by using code and incentives, instead of paper and coercion.</p><h3>Next Steps in Global Coordination</h3><p>However, having a global playground for coordination experiments doesn’t come without its challenges. Nation-states and multinational companies have polished their methods over hundreds of years. We’re starting anew. Just like when online content creators had to rethink how to entertain and inform better than mainstream media. Just like when thinkers in the year 1500 reinvented how to express ideas after the Church lost its monopoly on the creation of books.<strong> Our challenge today is to achieve global coordination over the internet using a new perspective, not imitating what nation-states and multinationals did.</strong></p><p>Some of the pressing challenges that the new playground blockchain technology has created are as follows:</p><ul><li>It’s a new paradigm: few people know how to use the technology, and there are few good tools to work with it.</li><li>Code runs in a public realm, exposing apps to a global community of very incentivized attackers. This makes improving security practices a top priority.</li><li>As happened in the early days of the web or mobile platforms, there are no blockchain-specific UX patterns, jeopardizing user adoption.</li></ul><p>As with every new technology, the first ones to use it are the creative individuals whose imagination pushes them to build a better world. For blockchain, this means hackers: those fluent in managing information at scale. Today, the basic components for solving these problems already exist but are not readily available to developers. What’s missing is a polished and integrated experience to bring experimentation to the next level. A sort of “Operating System” for this new playground. A platform that brings network effects to hackers who are building the revolution by sharing tools and code.</p><p>This is why at <a href="https://zeppelin.solutions/?utm_source=zeppelin&amp;utm_medium=blog&amp;utm_campaign=global-coordination-machine">Zeppelin</a> we <a href="https://blog.zeppelinos.org/introducing-zeppelinos/?utm_source=zeppelin&amp;utm_medium=blog&amp;utm_campaign=global-coordination-machine">recently decided to focus on ZeppelinOS</a>. We want to tackle those problems head-on, and we believe we can do it. We’re creating tools for hackers to rethink how a new global society should work. And we believe in the transformative power of giving tools long kept only for a few to the masses to experiment with. We’ve all seen the amazing improvements that opening a space to permissionless innovation brought to <a href="http://sethbannon.com/biotech-in-the-garage">biotech</a>, <a href="https://en.wikipedia.org/wiki/History_of_free_and_open-source_software">computing</a>, <a href="https://www.youtube.com/watch?v=21eFwbb48sE">content creation</a>, and the <a href="http://www.kurzweilai.net/how-to-launch-your-own-homemade-satellite">satellite industry</a>. It’s time to take global human coordination projects into our own hands!</p><p>Help us build this future together!</p><h3><strong>Be part of the community</strong></h3><ul><li>Continue the discussion on our <a href="https://forum.zeppelin.solutions/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">forum</a></li><li>Join our <a href="http://zpl.in/telegram">Telegram group</a></li><li>Follow us on <a href="https://twitter.com/ZeppelinOrg">Twitter</a></li><li>Even better, <a href="https://zeppelin.solutions/jobs/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">join the team</a> 🚀</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed5aba8f6456" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Join Zeppelin’s CTF hacking game to celebrate Devcon3]]></title>
            <link>https://maraoz.medium.com/join-zeppelins-ctf-hacking-game-to-celebrate-devcon3-8ad2c01a0103?source=rss-71b7575196fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ad2c01a0103</guid>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Manuel Araoz]]></dc:creator>
            <pubDate>Tue, 31 Oct 2017 19:06:41 GMT</pubDate>
            <atom:updated>2019-02-13T20:56:08.718Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iWUr2rZiOvRYu9wAeP8m1g.png" /></figure><p>Zeppelin is proud to be sponsoring Devcon3. To celebrate, we are releasing a <a href="https://ctftime.org/ctf-wtf/">CTF</a> hacking game at the start of the conference, on November 1st.</p><p>The contest includes multiple stages consisting of security challenges and puzzles designed to test your smart contract hacking skills. Each consecutive stage increases in difficulty. <strong>Prizes totaling $10,000 USD</strong> will be distributed equally in ETH to the first five participants who successfully complete all challenges.</p><p>These are the kind of challenges our teams work on every day. Because we’re looking to grow the Zeppelin team, anyone who successfully completes all stages will be granted priority review for our current position openings.</p><h4><strong>How do you participate?</strong></h4><p>On November 1st, we’ll be tweeting a link from our <a href="https://twitter.com/ZeppelinOrg">official Twitter account</a> that you can use to access the competition. Don’t worry if you couldn’t make it to Devcon3, everyone can participate.</p><p>Happy hacking!</p><h3>Be part of the community</h3><ul><li>Continue the discussion on our <a href="https://forum.zeppelin.solutions/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">forum</a></li><li>Join our <a href="http://zpl.in/telegram">Telegram group</a></li><li>Follow us on <a href="https://twitter.com/ZeppelinOrg">Twitter</a></li><li>Even better, <a href="https://zeppelin.solutions/jobs/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">join the team</a> 🚀</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ad2c01a0103" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Technical Details of zeppelinOS]]></title>
            <link>https://maraoz.medium.com/technical-details-of-zeppelinos-d3cf4da591f7?source=rss-71b7575196fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3cf4da591f7</guid>
            <category><![CDATA[zeppelin]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Manuel Araoz]]></dc:creator>
            <pubDate>Wed, 02 Aug 2017 17:10:34 GMT</pubDate>
            <atom:updated>2019-02-13T20:57:08.406Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week, we announced <a href="https://blog.zeppelin.solutions/introducing-zeppelinos-the-operating-system-for-smart-contract-applications-82b042514aa8">zeppelinOS, the operating system for smart contract applications</a>.</p><p>We highlighted that “<em>the rate of innovation in building decentralized applications is limited by the manual and duplicative efforts developers must make to ensure basic usability and security.”</em></p><p>zeppelinOS aims to solve this problem. Based on our experience working to secure dozens of projects in the space, we are now building an open-source, decentralized platform of tools and services on top of the EVM to help developers rapidly deploy, upgrade and manage secure smart contracts.</p><p>We have classified the features of the OS into 4 categories of services:</p><ul><li>the zeppelinOS Kernel Standard Libraries,</li><li>Smart Contract Development Tools,</li><li>Smart Contract Interaction Tools,</li><li>Off-Chain Tools.</li></ul><p>Let’s dive into each of these.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBQflJbWqI6qGTmkIabKyg.png" /></figure><h3><strong>Kernel Standard Libraries</strong></h3><p>The Kernel is the foundational layer of zeppelinOS: an on-chain set of upgradeable standard libraries offering common functionality and services that developers can call from within their smart contracts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_YdKI1Rt3b-U6uUNhAo-fA.png" /></figure><h4>Common Functionality</h4><p>The goal for the zeppelinOS Kernel is to provide a set of functions for the smart contracts that run on top of it, requesting services from the OS rather than re-implementing them from scratch.</p><p>These functions will be available as an on-chain standard library of reusable contracts and functions, heavily inspired by <a href="https://openzeppelin.org/">OpenZeppelin</a>, and held to the same security standards.</p><p>These libraries will enable developers to do the following (and more):</p><ul><li>Create and customize your own ERC20 Token.</li><li>Create a capped, refundable, and/or whitelisted crowdsale contract.</li><li>Create a trustless bug bounty.</li><li>Create pausable, ownable, and balance-limited contracts.</li><li>Set up a token vesting or token locking contract.</li></ul><h4>Security Patches and Continuous Improvement</h4><p>As a secure base layer that smart contracts communicate with on-chain, we open up the possibility of delivering opt-in upgrades to our users. This enables ZeppelinOS core developers to roll out optional security mitigations and patches as soon as a vulnerability is found, instantly protecting all users of the smart contracts that sit atop the OS.Through the same mechanism, zeppelinOS will always be in a state of continuous development and improvement: the OS will be upgraded based on <a href="https://blog.zeppelin.solutions/proxy-libraries-in-solidity-79fbe4b970fd">the proxy library pattern</a>, which we’ve developed through experiments with <a href="https://aragon.one/">the Aragon team</a>.</p><p>This is how it works: users will be incentivized to review patches and vouch for their correctness. This is necessary to avoid the possibility of a single party upgrading (i.e. changing) all contracts in the OS without control from the community, while providing a mechanism of fast response in the event of a critical security issue acknowledged by the majority. Given the sensitivity of upgrades in the context of smart contracts, we will enable developers to choose between automatic upgrades and manually activated ones on a per-contract basis.</p><h4>Shared bug bounties</h4><p>Bug bounties have become a standard practice for smart contract development, as a means to attract auditors to inspect critical code. By having a layer of code shared between applications, users of the OS can place collective bounties on common critical kernel modules. This will be implemented by a decentralized governance bounty pooling mechanism, to be explained in a future post. In this way, security researchers are incentivized to look at the code in a cost-effective manner. This won’t require every smart contract developer to individually disburse large prizes or get their own researchers to have their code audited.</p><h3><strong>Contract Development</strong></h3><p>Besides a set of common libraries, the OS will also provide tools aimed at making smart contract development and maintenance easier for developers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qnhd93G8GD9YaGk9LLF8tA.png" /></figure><h4>Attack Management</h4><p>Experience has shown that bugs will always be present in a codebase. As smart contracts become more complex, the probability of bugs appearing increases, becoming more attractive targets for attacks.</p><p>zeppelinOS will provide an emergency toolbox for dealing with attacks. Triggering an emergency pause, reverting to a previous uncompromised state, or forking a contract are some of the tools we have been working on. This work was part of OpenZeppelin and we’ll continue improving on it for the OS.</p><h4>Upgrade Management</h4><p>In addition to having upgrades of the zeppelinOS Kernel itself, the underlying implementation will be made available to users of the OS to enable upgradeability of their own smart contracts. This allows rolling out contract-specific security patches, as well as the progressive deployment of features, using whichever update governance mechanism developers see fit.</p><h4>Thin Deployments</h4><p>By enabling the usage of on-chain libraries through proxies instead of repeatedly including common bytecode, deployments will be smaller in size and cost less gas. This will also lead to an improved smart contract development experience.</p><h3><strong>Smart Contract Interaction Tools</strong></h3><p>One of the key points of zeppelinOS is to provide a shared environment where distributed applications can easily interact and interchange services. This is akin to an operating system where processes can cooperate by sending and receiving messages, leveraging the power of an ecosystem of shared services. The OS will provide various mechanisms for inter-contract communication and networking, such as publish-subscribe messaging, message queues, and shared storage. This will enable decentralized application developers to plug-and-play third-party building blocks, like <a href="https://ifttt.com/">IFTTT recipes</a> for smart contracts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jS5m2tmxUe3jVUUqDLSpzw.png" /></figure><h4>Scheduling</h4><p>Contract code execution is synchronous and linear, allowing the possibility to call other contracts but restrained to a single execution thread. To support more complex operations, applications require off-chain infrastructure.</p><p>As a means to support richer execution models, the OS will provide a smart contract async execution scheduler, where different parties can offer to execute async operations and securely call back into the contract to resume its operations.</p><p>Async execution helps solve an inherent problem of the Ethereum execution model: a transaction that spans multiple actions by a smart contract is paid by the user who initiates it. For example, a function execution protected by a multisig contract is funded entirely by the last user to approve it. By allowing anyone else to execute the function in exchange for a bounty, we can decouple the user who requests the action from the one who pays for its gas costs.</p><p>The OS will define the required standards and provide reference implementations, for both the scheduler clients and the providers.</p><h4>Marketplace</h4><p>Much as traditional mobile app marketplaces act as central hubs for mobile users to browse and purchase available services, one of the central features of zeppelinOS is a marketplace for contracts, where services can be purchased, sold, and integrated into applications.</p><p>Developers will be able to register new services in the marketplace, which will be discovered and accessed by client smart contracts. We envision multiple payment models, such as pay-per-call, one-time fees, or subscriptions for fixed periods of time, all of which can be managed through common payment interfaces.</p><p>This will be not only a central key in fostering collaboration between smart contracts, but also a way of allowing contracts to have off-chain interactions. Marketplace apps can be a mix between on and off chain implementations, providing services such as file storage, mail sending, push notifications, off-chain intensive computation, or machine-learning services.</p><h4>State Channel Support</h4><p>Blockchain transactions are limited by block mining times and fees. This caused the development of alternative off-chain transaction exchange protocols that could be consolidated back to the blockchain after multiple operations. State Channels is one of such proposals, designed specifically for the EVM.</p><p>The OS will incorporate state channel support through common protocol specs and reference implementations, plus all the on-chain infrastructure necessary for discovery, arbitration and finalization of state channels. Besides providing a cheaper communication mechanism, this also opens the door for integration with off-chain payment networks in the platform.</p><h4>Blockchain Information Provider</h4><p>The OS will provide trusted ways to access information on the blockchain currently unavailable from smart contracts, such as current ETH price, gas price, transaction pool size, average mining block times, etc. This will be implemented either as an oracle providing updated information per request, or as calls to Kernel contracts which are continuously updated by a trusted external source.</p><h3>Off-Chain Tools</h3><p>As an addition to the on-chain services offered by zeppelinOS, the platform will provide a set of off-chain tools aimed at simplifying the development, debugging, testing, deployment, and monitoring of decentralized applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x2ygEN6lcun-1MXziUoMXg.png" /></figure><h3>Analytics &amp; Monitoring</h3><p>Contract transactions and events provide invaluable insight on the usage of a deployed application, analogous to end-user actions and events performed on a web page. The OS will provide an off-chain analytics dashboard to aggregate on-chain generated contracts events and transactions for insight on their usage. It will also help monitoring the health of each contract, by keeping record of the transaction error rate and failure-associated events, triggering alerts through user-defined rules.</p><h3>Platform as a Service</h3><p>One of the current major challenges is not in contract development itself, but in the deployment and management stages that come once the code is ready. The OS will provide an easy to use interface for this, including:</p><ul><li>Triggering automated testing and security analysis of contracts.</li><li>Deploying the contracts to the blockchain, and optionally managing upgrades.</li><li>Providing user-friendly web interfaces for reading data and managing the contracts once deployed.</li><li>Providing secure and reliable connections to the Ethereum network, via infrastructure providers such as <a href="https://infura.io/">Infura</a>.</li></ul><p>The Platform as a Service approach also includes acting as a one-stop platform for integration with other contracts, providing a user interface for the discovery and management of marketplace-offered services.</p><h4>Continuous Integration for Contracts</h4><p>Automated testing through continuous integration providers has become an industry standard, as a means to increase the confidence on the project health by checking its tests in a separate environment at every stage of development. However, this requires a testing environment with conditions as similar as possible as production. As such, zeppelinOS shall provide the required services, including replaying previous transactions using the updated codebase to compare generated outcomes.</p><h4>Automated Code Analysis</h4><p>Static analysis is a long-running research field in academia, with occasional ports to industry-level tools. These techniques can yield enormous benefits towards the identification of potential bugs and vulnerabilities. As such, and given the high security requirements of decentralized applications, applying these strategies to smart contracts code is a must.</p><p>Having access to the code powering the smart contracts applications, zeppelinOS will offer automated code analysis services with increasingly powerful rules and techniques, preventing inadvertently deploying unsafe code, and alerting owners of existing running contracts of newly found vulnerabilities.</p><h4>Developer Tools</h4><p>Developer experience for smart contract developers is really bad. The tools are immature, break often, and debugging is very frustrating. Part of the off-chain tools the zeppelinOS platform will provide are debugging, testing and infrastructure frameworks to make smart contract developers’ lives happier. We’ll also contribute to existing toolchains such as <a href="https://github.com/ethereum/pyethereum">pyethereum</a>, <a href="http://truffleframework.com/">truffle/testrpc</a> and <a href="https://github.com/ethereum/web3.js/">web3.js</a>.</p><h3>Next steps</h3><p>We hope this post has helped clarify some of the more technical questions around the different components of zeppelinOS, and how they will enhance smart contract development and management process. This is an ambitious endeavor and we’ll need your help to make it happen, so please join our <a href="http://slack.openzeppelin.org/">Slack</a> and share your feedback with us..</p><p>If you are looking for ways to contribute to zeppelinOS, the best starting point is to help with the development of the <a href="https://openzeppelin.org/?utm_source=medium&amp;utm_medium=post&amp;utm_campaign=TechOS">OpenZeppelin</a> framework, as it will be the basis from which the zeppelinOS Kernel Standard Libraries will be built.</p><p>During the upcoming days we’ll be releasing more information about zeppelinOS, stay tuned!</p><blockquote><em>Subscribe to the </em><a href="http://zeppelinos.org/?utm_source=medium&amp;utm_medium=post&amp;utm_campaign=TechOS"><em>zeppelinOS newsletter</em></a><em> to learn more details about the project, and stay up-to-date with the next stages.</em></blockquote><h3>Be part of the community</h3><ul><li>Continue the discussion on our <a href="https://forum.zeppelin.solutions/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">forum</a></li><li>Join our <a href="http://zpl.in/telegram">Telegram group</a></li><li>Follow us on <a href="https://twitter.com/ZeppelinOrg">Twitter</a></li><li>Even better, <a href="https://zeppelin.solutions/jobs/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">join the team</a> 🚀</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3cf4da591f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing zeppelinOS: the operating system for smart contract applications]]></title>
            <link>https://maraoz.medium.com/introducing-zeppelinos-the-operating-system-for-smart-contract-applications-82b042514aa8?source=rss-71b7575196fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/82b042514aa8</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[operating-systems]]></category>
            <dc:creator><![CDATA[Manuel Araoz]]></dc:creator>
            <pubDate>Thu, 27 Jul 2017 15:02:34 GMT</pubDate>
            <atom:updated>2019-02-13T20:57:21.364Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nXJkCA53nsrL8Am0VPBzyQ.png" /></figure><p><em>Last week, we saw </em><a href="https://blog.zeppelin.solutions/on-the-parity-wallet-multisig-hack-405a8c12e8f7"><em>one of the biggest hacks</em></a><em> in the history of smart contract applications. ~30M USD were lost due to a simple programmer error, leaving critical functions open for anyone to call. It’s high time we get serious about writing secure contracts, if we want decentralized applications to reach their full potential.</em></p><p>In the early days of computing, writing code into machines was a difficult and inefficient endeavor. There were few tools and resources available for programmers, and specialized magazines were the <a href="https://en.wikipedia.org/wiki/Type-in_program">main distribution media for software</a>. Major operating systems were not yet available, so each computer model required machine-specific knowledge to be programmed. <strong>This is what it feels like to work with smart contracts in 2017.</strong></p><h4>The State of Smart Contract Programming</h4><p>Ethereum changed the world by creating <a href="https://github.com/ethereum/wiki/wiki/Ethereum-Development-Tutorial#introduction">a distributed global shared virtual machine</a> known as the EVM. Anyone can now use this virtual machine to run programs that handle real money and formalize contractual relationships via code. The promise is huge: <strong>we’re creating a new global and natively-digital economy based on software.</strong></p><p>Still, the tools developers are using to build towards this fantastic vision are very rudimentary. Once a contract is deployed, there’s no way to upgrade it, even for security reasons, which means applications can’t easily upgrade with new features and fixes; instead of calling standard libraries, application developers are copy/pasting code with each deployed contract, increasing deployment costs and margin for error; and, last but not least, debugging a contract’s failing function calls is hell with current tools.</p><p>Overall, the rate of innovation in building decentralized applications is limited by the manual and duplicative efforts projects must make to ensure basic usability and security.</p><p>Much like in the early days of computing, where operating systems enabled the development of feature-rich applications, the same is needed for the development of complex smart contract applications. We need an OS for the EVM.</p><h4>What is zeppelinOS exactly</h4><p>zeppelinOS is an open-source, distributed platform of tools and services on top of the EVM to develop and manage smart contract applications securely.</p><p>What would an EVM operating system look like? We thought about four main components, but other functions may arise in the future, as the industry evolves:</p><ul><li><strong>zeppelinOS Kernel</strong>: an upgradeable and community-governed core of functionality provided by an on-chain smart contract library that developers can call for standard and common functions in their applications. The initial version of this is <a href="https://openzeppelin.org/">the current OpenZeppelin framework</a>, migrated to library form. Shared code for smart contract applications to use, with curated opt-in security updates based on <a href="https://blog.zeppelin.solutions/proxy-libraries-in-solidity-79fbe4b970fd#.c829x6ga8">the proxy library pattern</a>.</li><li><strong>zeppelinOS Scheduler</strong>: Every transaction on the Ethereum network is initiated and paid by a user. This places a limitation on the kinds of things a smart contract can do and sometimes creates unfair situations. For example, when executing a transaction via a standard multisig contract, the last owner to confirm it will trigger the actual call and pay for its gas costs. Or, if a crowdsale has some finalization logic when the cap is reached, the last token buyer will pay the gas cost of executing that. The zeppelinOS Scheduler will enable async execution on the EVM where a contract can request asynchronous execution of a function and anyone can pay the gas costs and be rewarded for it.</li><li><strong>zeppelinOS Marketplace</strong>: To catalyze exponential growth among decentralized applications, smart contracts must be able to interact with each other in a standard way. Imagine if <a href="https://augur.net/">Augur</a> could talk to <a href="https://0xproject.com/">0x</a> to enable prediction market forecasting in any currency, all done using an <a href="http://aragon.one/">Aragon</a> company. This kind of interoperability would accelerate progress across the space, helping developers take the ecosystem mainstream, faster. Our proposed solution is to build a marketplace of inter-contract services natively inside the OS.</li><li><strong>zeppelinOS off-chain tools:</strong> As an addition to the on-chain services offered by zeppelinOS, the platform will provide a set of off-chain tools aimed at simplifying the development, debugging, testing, deployment, and monitoring of decentralized applications.</li></ul><p>At <a href="https://zeppelin.solutions/">Zeppelin Solutions</a>, all of our efforts are focused on solving the technical challenges of smart contract application development. We’ve worked with dozens of projects on <a href="https://blog.zeppelin.solutions/tagged/security">security audits</a>, <a href="https://blog.zeppelin.solutions/proxy-libraries-in-solidity-79fbe4b970fd">smart contract upgradability</a>, contributed to improve and test <a href="https://github.com/trufflesuite/truffle">development</a> <a href="https://www.ethpm.com/">tools</a>, and enabled interoperability through <a href="https://github.com/OpenZeppelin/zeppelin-solidity/tree/master/contracts">our OpenZeppelin standards</a> and <a href="https://blog.zeppelin.solutions/onward-with-ethereum-smart-contract-security-97a827e47702">security patterns</a>. We are developers ourselves. <strong>We believe we know how to make the smart contract development process better, easier and more robust.</strong></p><p>We invite you to help us make this happen.</p><blockquote>Subscribe to the <a href="http://zeppelinos.org/?utm_source=medium&amp;utm_medium=post&amp;utm_campaign=IntroOS">zeppelinOS newsletter</a> to learn more details about the project, and stay up-to-date with the next stages.</blockquote><h3>Be part of the community</h3><ul><li>Continue the discussion on our <a href="https://forum.zeppelin.solutions/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">forum</a></li><li>Join our <a href="http://zpl.in/telegram">Telegram group</a></li><li>Follow us on <a href="https://twitter.com/ZeppelinOrg">Twitter</a></li><li>Even better, <a href="https://zeppelin.solutions/jobs/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">join the team</a> 🚀</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82b042514aa8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Storj Token Audit]]></title>
            <link>https://maraoz.medium.com/storj-token-audit-32a9af082797?source=rss-71b7575196fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/32a9af082797</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[storj]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[audit]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Manuel Araoz]]></dc:creator>
            <pubDate>Fri, 23 Jun 2017 18:11:22 GMT</pubDate>
            <atom:updated>2019-02-13T19:39:59.755Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WCA2rkMWJxGELYy5ZxKG_A.png" /></figure><p>The Storj team asked us to review and audit their new Storj Token (STORJ) code. We looked at their contracts and now publish our results.</p><p>The audited contracts can be found in <a href="https://github.com/Storj/storj-contracts/tree/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39">their storj-contracts repo</a>. The version used for this report is commit 2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39.</p><p>Code quality is very good. Functionality is properly modularized, and most lines of code and nearly all functions have accompanying comments stating their purpose and/or reasoning.</p><p>Here’s our assessment and recommendations, in order of importance.</p><p><strong>EDIT</strong>: Most problems were addressed in <a href="https://github.com/Storj/storj-contracts/commits/master">the latest version of the code</a>.</p><h3>Severe</h3><h4>Problems with PaymentForwarder’s pay function</h4><p>pay function in <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/PaymentForwarder.sol#L44">line 44 of PaymentForwarder.sol</a> has two severe problems.</p><p>1) The <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/PaymentForwarder.sol#L44-L66">pay</a> function accepts zero-valued payments. This is not desirable, per se, but in this case it brings a greater problem.</p><p>The code assumes that all payments are nonzero in the calculation of the variable customerCount (see <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/PaymentForwarder.sol#L53-L55">lines 53 to 55</a>). If two calls are made to pay with the same customerId and the first one has msg.value == 0, customerCount will be incremented both times because weiAmount will be 0 in <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/PaymentForwarder.sol#L57">line 57</a>.</p><p>Add a precondition to ensure msg.value != 0.</p><p><strong>EDIT</strong>: Addressed in <a href="https://github.com/Storj/storj-contracts/commit/40b8dd82ec58ad795c21b1f37e11ebccdb10a6c8">https://github.com/Storj/storj-contracts/commit/40b8dd82ec58ad795c21b1f37e11ebccdb10a6c8</a></p><p>2) Anyone will be able to call the pay function with arbitrary data. We don’t have access to the rest of the crowdsale code and couldn’t determine what the desired behavior is here. For example, who should be allowed to call the pay function is not clear. Consider making the function only callable from a specific address if that’s the intended behavior.</p><p><strong>EDIT:</strong> This was intended behavior.</p><h3>Potential problems</h3><h4>Lack of safeguards in PaymentForwader</h4><p>For such an important component, PaymentForwarder is lacking in safety measures. All math operations are unchecked for overflows. The comments state: “We trust Ethereum amounts cannot overflow uint256”. Although this seems to be true, it’s better to be safe than sorry. An overflow could leave the contract in an inconsistent state, and removing the possibility is worth the cost. This is part of what we call security in depth. Consider making all math operations safe by using SafeMath as with other contracts.</p><p><strong>EDIT</strong>: SafeMath added in <a href="https://github.com/Storj/storj-contracts/commit/40b8dd82ec58ad795c21b1f37e11ebccdb10a6c8">https://github.com/Storj/storj-contracts/commit/40b8dd82ec58ad795c21b1f37e11ebccdb10a6c8</a></p><h4>PaymentForwarder can be unhalted</h4><p>The <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/Haltable.sol">Haltable contract</a> is designed for the use case of halting a working contract in case of an emergency. This can be used, for example, to fix something manually before resuming normal operation.</p><p>The functionality required by PaymentForwarder (<a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/PaymentForwarder.sol#L11">as documented</a>), on the other hand, is to completely finalize the processing of payments at the end of the crowdsale. We recommend to remove the unhalt feature so that the contract can’t resume receiving payments after finalization, and to use more appropriate variable and modifier names.</p><p><strong>EDIT</strong>: This was intended behavior.</p><h4>Anyone can burn tokens</h4><p>CentrallyIssuedToken inherits from BurnableToken, which provides <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/BurnableToken.sol">a function</a> allowing anyone to burn a certain token amount, destroying them and reducing totalSupply. Storj needs this to burn part of their token holdings, according to their crowdsale plans, but as a side effect anyone can burn their tokens.</p><p>Please make sure this is expected, or consider making the burn function only callable from a Storj address. Note that any ERC20 token allows owners to burn tokens by transferring them to the zero address or any random one, but this doesn’t modify the totalSupply.</p><p><strong>EDIT</strong>: This was intended behavior.</p><h4>Discrepancy between comment and code</h4><p>CentrallyIssedToken has a constructor parameter named _owner, which is used as the upgradeMaster. The comment in <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/CentrallyIssuedToken.sol#L29">line 29</a> states an intent to allocate the initial balance to the <em>owner</em>; however, the balance is allocated to msg.sender. If it’s an error, use the owner variable; otherwise, update the comment.</p><h4>Shadowing of inherited state variable</h4><p>The state variable originalSupply is <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/UpgradeAgent.sol#L11">declared</a> in the <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/UpgradeAgent.sol">UpgradeAgent contract</a>, and <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/test/TestMigrationTarget.sol#L14">redeclared</a> in TestMigrationTarget (which inherits from the former). This is a case of variable shadowing that’ll cause problems: functions implemented in UpgradeAgent will use their own state variable of the same name. Remove the declaration in TestMigrationTarget.</p><h3>Warnings</h3><h4>Use safe math</h4><p>There are many unchecked math operations in the code. It’s always better to be safe and perform checked operations. Consider using <a href="https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/SafeMath.sol#L6">OpenZeppelin’s safe math library</a>, or performing pre-condition checks on any math operation.</p><p><strong>EDIT</strong>: SafeMath added in <a href="https://github.com/Storj/storj-contracts/commit/40b8dd82ec58ad795c21b1f37e11ebccdb10a6c8">https://github.com/Storj/storj-contracts/commit/40b8dd82ec58ad795c21b1f37e11ebccdb10a6c8</a></p><h4>Use the latest version of the Solidity compiler</h4><p>Current code is written for older versions of solc (some contracts specify 0.4.6, others 0.4.8). We recommend changing the solidity version pragma to the latest version (pragma solidity ^0.4.11) to enforce the use of an up to date compiler.</p><h4>Undocumented interface of UpgradeAgent</h4><p>Compared to the rest of the code, <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/UpgradeAgent.sol">UpgradeAgent contract</a> is lacking in documentation and clarity. Since this is intended to be used by future developers, we believe it’s specially important that it be very well documented.</p><p>Our understanding is that a future upgraded token contract should implement an upgradeFrom function that receives a token owner and an amount of tokens (within the owner’s balance) as parameters to transfer from the older to the new token. This function is called by the older token as seen in <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/UpgradeableToken.sol#L72">line 72 of UpgradeableToken.sol</a>.</p><p>Consider renaming the parameters to owner and amount, which are more representative of their meaning. Also, consider declaring upgradeFrom as an external function, as it seems to be meant only callable from the old token.</p><h4>Program against interfaces when appropriate</h4><p>The token state variable in <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/Issuer.sol#L25">Issuer</a> is declared of type StandardToken, which is a concrete implementation of an ERC20 token. Although it makes no difference in the generated code, consider changing the variable’s type to ERC20.</p><h4>Overloading of the Transfer event</h4><p>The BurnableToken contract uses both <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/BurnableToken.sol#L21">a Burned event</a> and <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/BurnableToken.sol#L25">the Transfer event</a> (with a <em>to</em> field set to the zero address) to log the burning of tokens. The latter is overloading the semantics of the Transfer event of the ERC20 standard, which might not be a good idea as other software (such as wallets or exchanges) could be relying on these semantics. This is <a href="https://github.com/ethereum/EIPs/pull/621">an ongoing discussion</a> in the ERC20 standardization process, but our stance on it is that <a href="https://github.com/OpenZeppelin/zeppelin-solidity/blob/609869f08732fce8cd946996d326c15889e441c8/contracts/token/MintableToken.sol#L20">a different event</a> should be used.</p><p>A comment in the code says the use of the Transfer event is to “keep exchanges happy”. We’re not aware of any exchange that relies on this behavior, but if this were the case, please note that there are balance modifications not logged as Transfers <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/UpgradeableToken.sol#L65">when upgrading tokens</a>. If Transfer needs to be used in this way, be sure to be consistent about it.</p><p><strong>EDIT</strong>: This was done for EtherScan.io compatibility. Unfortunately, this could not be addressed very well in a standard-compliant manner, as there is no standard behavior for this.</p><h4>Types are not checked on runtime</h4><p>Although the check in <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/UpgradeableToken.sol#L95">line 95 of UpgradeableToken.sol</a> is a good idea, and will potentially catch errors when upgrading a token, we’d like to clarify that it’s not enough to ensure that the upgradeAgent address corresponds to a contract inheriting from UpgradeAgent.</p><p>Solidity types are only checked/enforced on compile time. Once the contract is deployed, and transactions are executed, there’s no guarantees that types will be correct. A malicious upgradeMaster could potentially call the setUpgradeAgent function with a contract that has an implementation of isUpgradeAgent and no implementation of upgradeFrom.</p><p>We have no recommendations here, but wanted to clarify on the matter.</p><h3>Additional information and notes</h3><ul><li>Good job using OpenZeppelin!</li><li>There are no modifiers defined or used in the code written by Storj, but we think they could be helpful for improved code clarity. At this stage of the development process, however, it might be safer not to undergo such a refactoring.</li><li>The comment in <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/UpgradeableToken.sol#L77">line 77 of UpgradeableToken.sol</a> is incomplete.</li><li>The comment in <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/BurnableToken.sol#L10">line 10 of BurnableToken.sol</a> is incomplete.</li><li>The comment in <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/UpgradeableToken.sol#L124">line 124 of UpgradeableToken.sol</a> has a typo: says “begun” instead of “begin”.</li><li>The comment in <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/PaymentForwarder.sol#L60-L61">line 60 of PaymentForwarder.sol</a> explains the rationale for the paymentsByBenefactor state variable: being able to “construct contributions solely based on blockchain data”. It should be noted, though, that events are <em>also</em> “blockchain data”, and the emitted PaymentForwarded event would be sufficient to reconstruct all contributions. Consider removing paymentsByBenefactor.</li><li>The contract <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/Issuer.sol">Issuer.sol</a> seems to be unnecessary, as it can be implemented in an off-chain script with a database.</li><li>The throwing fallback function in <a href="https://github.com/Storj/storj-contracts/blob/2bdeb27c0216d2f0889b6e7363d8a84b54cd7f39/contracts/test/TestMigrationTarget.sol#L41-L43">line 41 of TestMigrationTarget.sol</a> is not needed in Solidity ≥0.4.0. If a payable fallback function is not declared, payments to the fallback function are rejected.</li></ul><h3>Conclusions</h3><p>One severe security issue was found, along with recommendations on how to fix it. Some additional changes were proposed to follow best practices and reduce potential attack surface.</p><p><strong>EDIT</strong>: Most problems were addressed in <a href="https://github.com/Storj/storj-contracts/commits/master">the latest version of the code</a>.</p><p><em>Note that as of the date of publishing, the above review reflects the current understanding of known security patterns as they relate to the STORJ Token contract. We have not reviewed the related Storj project. The above should not be construed as investment advice or an offering of tokens. For general information about smart contract security, check out our thoughts </em><a href="https://medium.com/zeppelin-blog/onward-with-ethereum-smart-contract-security-97a827e47702"><em>here</em></a><em>.</em></p><h3>Be part of the community</h3><ul><li>Continue the discussion on our <a href="https://forum.zeppelin.solutions/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">forum</a></li><li>Request a <a href="https://zeppelin.solutions/security-audits/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">security audit</a></li><li>Even better, <a href="https://zeppelin.solutions/jobs/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">join the team</a> 🚀</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32a9af082797" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic Attention Token (BAT) Audit]]></title>
            <link>https://maraoz.medium.com/basic-attention-token-bat-audit-88bf196df64b?source=rss-71b7575196fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/88bf196df64b</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[audit]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Manuel Araoz]]></dc:creator>
            <pubDate>Mon, 22 May 2017 18:24:37 GMT</pubDate>
            <atom:updated>2019-02-13T19:40:23.028Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JorJ0dXOx7nbEi0Z89bd6w.png" /></figure><p>The Brave team asked us to review and audit their new BAT Token contract code. We looked at their contracts and now publish our results.</p><p>The audited contracts can be found in <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/tree/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts">their basic-attention-token-crowdsale repo</a>. The version used for this report is commit <strong>17a5f8440a256a6dc5d8dd894b9615182c2901b2</strong>.</p><p>Here’s our assessment and recommendations, in order of importance.</p><p><strong>Update</strong>: Brave team followed most of our recommendations <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/commit/09a1038c2ac0148b93876057fc056ae2a872fb88">in the latest version of their code</a>.</p><h3>Severe</h3><h4>Brave can get an unfair refund if tokenCreationMin is not reached</h4><p>A fixed 300 million BAT tokens are assigned to Brave (specifically to the batFundDeposit address) <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L44">when the crowdsale contract is deployed</a>. If the contract doesn’t reach the minimum amount of tokens (tokenCreationMin), though, it goes into a state where investors can request a refund and receive their ether back.</p><p>In this situation, Brave would also be able to request a refund for the 300 million tokens it holds, taking ether that should be available for investors.</p><p>Fix this by checking that funds aren’t sent to batFundDeposit in the refund function.</p><p><strong>Update</strong>: fixed in commit <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/commit/09a1038c2ac0148b93876057fc056ae2a872fb88">09a1038c2ac0148b93876057fc056ae2a872fb88</a>.</p><h3>Potential problems</h3><h4>Correctness of start and end block numbers</h4><p>Brave has decided to <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L19-L20">use block numbers</a> instead of timestamps to determine the start and end of the crowdsale, which is a good security practice. However, preconditions about them are missing in the contract constructor.</p><p>For example, consider checking fundingStartBlock comes before fundingEndBlock, and that both are in the future (greater than block.number).</p><h4>Use of Transfer event to log token creation</h4><p>The crowdsale contract <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L58">uses the Transfer event</a> to log the creation of tokens, with a <em>from</em> field set to the zero address. This is overloading the semantics of the Transfer event of the ERC20 standard, which might not be a good idea as other software (such as wallets or exchanges) could be relying on these semantics. This is <a href="https://github.com/ethereum/EIPs/pull/621">an ongoing discussion</a> in the ERC20 standardization process, but our stance on it is that <a href="https://github.com/OpenZeppelin/zeppelin-solidity/blob/609869f08732fce8cd946996d326c15889e441c8/contracts/token/MintableToken.sol#L20">a different event</a> should be used.</p><p><strong>Update</strong>: fixed in commit <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/commit/09a1038c2ac0148b93876057fc056ae2a872fb88">09a1038c2ac0148b93876057fc056ae2a872fb88</a>.</p><h4>Avoid duplicate code</h4><p>The contracts Token, StandardToken, and SafeMath are very similar to OpenZeppelin library contracts ERC20Token, StandardToken, and SafeMath, respectively. Consider avoiding code repetition, which can bring regression problems and <a href="https://medium.com/zeppelin-blog/hackergold-bug-analysis-68d893cad738">introduce unexpected bugs</a>. Consider using the standard modules from <a href="https://github.com/OpenZeppelin/zeppelin-solidity">OpenZeppelin</a>.</p><p>Several conditional checks, such as block.number &lt; fundingEndBlock, are repeated throughout the code (<a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L51">line 51</a>, <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L68">line 68</a>, <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L79">line 79</a>). Consider extracting these to reusable internal functions with declarative names (for example isWithinFundingPeriod) for better code readability.</p><h4>Use SafeMath in all math operations</h4><p>Most math operations are safe, but there’s still a few that are unchecked (<a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L84-L85">these two</a>, for instance). It’s always better to be safe and perform checked operations.</p><p><strong>Update</strong>: fixed in commit <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/commit/09a1038c2ac0148b93876057fc056ae2a872fb88">09a1038c2ac0148b93876057fc056ae2a872fb88</a>.</p><h4>Burn of token assignment to BAT fund is not implemented</h4><p>The amount of BAT assigned to Brave is fixed at deploy time. This seems to be inconsistent with the process document we received that states: “In event of a non-sell out, contract will ‘burn’ BAT kept in multisig wallet down to a 3/10 ratio of total BAT.”. Consider implementing this in the contract, as the specification states, so that the Brave team doesn’t have to do this manually after the token sale.</p><h3>Warnings</h3><h4>Magic constants in token amounts</h4><p>A few constants in the contract which denote BAT amounts (<a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L21">batFund</a>, <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L23">tokenCreationCap</a>, <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L24">tokenCreationMin</a>) are written assuming 18 decimals. This is a hidden case of a magic constant. These amounts should be parameterized by the number of decimals (<em>e.g.</em> batFund = 300 * 10**6 * 10**decimals).</p><p><strong>Update</strong>: fixed in commit <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/commit/09a1038c2ac0148b93876057fc056ae2a872fb88">09a1038c2ac0148b93876057fc056ae2a872fb88</a>.</p><h4>Refactor confusing finalization precondition</h4><p>The condition in <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L68-L70">line 68</a>, is expressed in a very confusing way. It should be split into two conditional expressions: totalSupply &lt; tokenCreationMin and block.number &lt;= fundingEndBlock &amp;&amp; totalSupply != tokenCreationCap, each of which throws when true.</p><p><strong>Update</strong>: fixed in commit <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/commit/09a1038c2ac0148b93876057fc056ae2a872fb88">09a1038c2ac0148b93876057fc056ae2a872fb88</a>.</p><h4><em>isFunding</em> variable name is not accurate</h4><p>The variable isFunding declared in <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L18">line 18</a> doesn’t really reflect whether the contract is <em>funding</em> or not. This fact depends on other conditions, such as being within the funding period. The variable marks the finalization by the contract owners, so a good name would be <strong>isFinalized </strong>(note that this new name reverses the meaning: isFinalized == !isFunding).</p><p>There’s a comment in <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L18">line 18</a> that says the variable is “no longer important”, but it is actually a key part of the crowdsale process. Consider removing that comment.</p><p><strong>Update</strong>: fixed in commit <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/commit/09a1038c2ac0148b93876057fc056ae2a872fb88">09a1038c2ac0148b93876057fc056ae2a872fb88</a>.</p><h4><strong>Avoid using var to define variables</strong></h4><p>There’s <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L81">two</a> <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L85">uses</a> of var, where the type of the variable is inferred from the expression on the right hand of the definition. <a href="https://medium.com/zeppelin-blog/onward-with-ethereum-smart-contract-security-97a827e47702#c528">We recommend avoiding this feature</a> because in some cases it might infer a smaller integer type than the developer might think. It is best to be explicit regarding types.</p><p><strong>Update</strong>: fixed in commit <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/commit/09a1038c2ac0148b93876057fc056ae2a872fb88">09a1038c2ac0148b93876057fc056ae2a872fb88</a>.</p><h4>Solidity version</h4><p>All of the contracts require version 0.4.10 of Solidity. It should also be noted that 0.4.11 was released a few days ago. Consider changing the solidity version pragma to the latest version (pragma solidity ^0.4.11;) to enforce latest compiler version to be used.</p><p>As an additional note, since the contracts are compiled with a recent version of Solidity, it’s possible to use the new <a href="https://github.com/ethereum/solidity/blob/develop/Changelog.md#0410-2017-03-15">transfer</a> method instead of send<em> </em>(<a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L73">here</a>, and <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L87">here</a>).</p><h3>Additional information and notes</h3><ul><li>The comment in <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L64">line 64</a> is outdated since the finalize function no longer issues BAT tokens to the User Growth Fund. These tokens seem to be issued in the constructor.</li><li>The state variable batFund in <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L21">line 21</a> is only set at deploy time, and never changed, so it could be declared constant.</li><li>Consider being consistent in the use of whitespace for a more polished code style. For example see how whitespace is used differently in <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L78-L79">lines 78 and 79</a>.</li><li>The operational process document appears to be outdated. The Finalization section states that the finalize function can be called from any account, but this is neither what <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L67">the code</a> does, nor what the review document says.</li><li>Consider removing commented code in <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/SafeMath.sol#L6-L10">lines 6–10 from SafeMath.sol</a>.</li><li>Very interesting addition of contract version as part of the token contract in <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L11">line 11</a>.</li><li>Remove excessive condition from SafeMath (see <a href="https://github.com/OpenZeppelin/zeppelin-solidity/pull/190">this pull request</a> in OpenZeppelin).</li><li>Use of send is always risky and should be analyzed in detail. These contracts use it safely, by checking the return value, and calling it only at the end of functions.</li><li>Good job using block numbers instead of timestamps.</li><li>Consider choosing a fail-first approach for precondition in <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L55">line 55</a>: revert the condition and throw in the <em>then</em> branch, instead of the <em>else</em> branch.</li><li>Consider reusing the tmpSupply variable instead of recalculating the sum on <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/blob/17a5f8440a256a6dc5d8dd894b9615182c2901b2/contracts/BAToken.sol#L56">line 56</a>.</li></ul><h3>Conclusions</h3><p>One severe security issue was found and explained, along with recommendations on how to fix it. Some additional changes were proposed to follow best practices and reduce potential attack surface.</p><p><strong>Update</strong>: Brave team followed most of our recommendations <a href="https://github.com/brave-intl/basic-attention-token-crowdsale/commit/09a1038c2ac0148b93876057fc056ae2a872fb88">in the latest version of their code</a>.</p><p><em>Thanks to Francisco Giordano for helping write this report.</em></p><p><em>Note that as of the date of publishing, the above review reflects the current understanding of known security patterns as they relate to the BAT Token contract. We have not reviewed the related Brave project. The above should not be construed as investment advice or an offering of tokens. For general information about smart contract security, check out our thoughts </em><a href="https://medium.com/zeppelin-blog/onward-with-ethereum-smart-contract-security-97a827e47702"><em>here</em></a><em>.</em></p><h3>Be part of the community</h3><ul><li>Continue the discussion on our <a href="https://forum.zeppelin.solutions/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">forum</a></li><li>Request a <a href="https://zeppelin.solutions/security-audits/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">security audit</a></li><li>Even better, <a href="https://zeppelin.solutions/jobs/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">join the team</a> 🚀</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88bf196df64b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moeda Token Audit]]></title>
            <link>https://maraoz.medium.com/moeda-token-audit-ac72944caa6f?source=rss-71b7575196fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac72944caa6f</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[audit]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Manuel Araoz]]></dc:creator>
            <pubDate>Tue, 16 May 2017 12:49:22 GMT</pubDate>
            <atom:updated>2019-02-13T19:40:42.920Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aR_m9S2QaS7pJuTy0e2TlA.png" /></figure><p>The Moeda team asked us to review and audit their new Moeda Token code. We looked at their contracts and now publish our results.</p><p>The audited contracts can be found in <a href="https://github.com/erkmos/moeda/tree/b2bf23119d563e251b6f16b29b642bac43e76a64">their moeda repo</a>. The version used for this report is commit <strong>b2bf23119d563e251b6f16b29b642bac43e76a64</strong>. The main contracts are <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/MoedaToken.sol">MoedaToken.sol</a> and <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol">Crowdsale.sol</a>.</p><p>Overall the code is good and has only minor issues. Here’s our assessment and recommendations, in order of importance.</p><p><strong>Update:</strong> The Moeda team implemented most of our recommendations in <a href="https://github.com/erkmos/moeda/tree/784f4192d0851b9470d2c9dd2e90d7310b642832">the latest version of their code</a>.</p><h3>Severe</h3><p>We haven’t found any severe security problems with the code.</p><h3>Potential problems</h3><h4>Unnecessary complexity calculating token amount</h4><p>The formula used to calculate the token amount in <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L116-L117">line 116</a> is unnecessarily complicated. It could be replaced by a multiplication by the amount of tokens bought with one <a href="https://forum.ethereum.org/discussion/304/what-is-wei">wei</a> for each given tier. Consider making this change by replacing <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L28-L30">the token creation rates</a> by 1 ether divided by the current values. This has a number of benefits:</p><ol><li>Numbers are exact and there is no precision lost (current version has loss of precision due to chained integer operations).</li><li>There is less risk of overflow.</li><li>It’s simpler, which is always preferable. When code is irreducibly complex, consider using temporary variables to improve readability.</li></ol><p><strong>Update</strong>: Fixed in <a href="https://github.com/erkmos/moeda/commit/a894b2cccef0236e90326b84a0b3dde485e78cd1">https://github.com/erkmos/moeda/commit/a894b2cccef0236e90326b84a0b3dde485e78cd1</a></p><h4>Conditions for finalization</h4><p>The crowdsale can be finalized at any moment, in particular before endBlock is reached. Please double check that this is the desired behavior.</p><p><strong>Update</strong>: Now requiring that either cap or end block has been reached. Fixed in <a href="https://github.com/erkmos/moeda/commit/5eb52c0648d1af0db11f5eb883379d6c8054e2c0">https://github.com/erkmos/moeda/commit/5eb52c0648d1af0db11f5eb883379d6c8054e2c0</a> and refactored in <a href="https://github.com/erkmos/moeda/commit/9edf6fe6e23aec7f6fcba6d0921436e435336048">https://github.com/erkmos/moeda/commit/9edf6fe6e23aec7f6fcba6d0921436e435336048</a></p><h4>Use of Transfer event to log token creation</h4><p>The crowdsale contract <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/MoedaToken.sol#L55">uses the Transfer event</a> to log the creation of tokens, with a <em>from</em> field set to the zero address. This is overloading the semantics of the Transfer event of the ERC20 standard, which might not be a good idea as other software (such as wallets or exchanges) could be relying on these semantics. This is <a href="https://github.com/ethereum/EIPs/pull/621">an ongoing discussion</a> in the ERC20 standardization process, but our stance on it is that <a href="https://github.com/OpenZeppelin/zeppelin-solidity/blob/609869f08732fce8cd946996d326c15889e441c8/contracts/token/MintableToken.sol#L20">a different event</a> should be used.</p><p><strong>Update: </strong>Created a new event, fixed in <a href="https://github.com/erkmos/moeda/commit/68ff6544976c2bfa655cae28e69ab09d813dbc46">https://github.com/erkmos/moeda/commit/68ff6544976c2bfa655cae28e69ab09d813dbc46</a></p><h3>Warnings</h3><h4>Use latest version of Solidity</h4><p>The contracts are written for an old version of the Solidity compiler (0.4.8). We recommend changing the solidity version pragma to the <a href="https://github.com/ethereum/solidity/releases/tag/v0.4.10">latest version</a> (pragma solidity ^0.4.11;) to enforce the use of an up to date compiler. (Please note that there has been a recent update to <a href="http://truffleframework.com/">the Truffle framework</a> to make it compatible with 0.4.11.)</p><p><strong>Update: </strong>fixed in <a href="https://github.com/erkmos/moeda/commit/befe14a5769a7f5c3dcd964c1d042408ba4356e4">https://github.com/erkmos/moeda/commit/befe14a5769a7f5c3dcd964c1d042408ba4356e4</a></p><h4>Unexpected throw</h4><p>When the ether received adds up to exactly TIER3_CAP, getLimitAndRate <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L91">throws</a> when the comment says it shouldn’t. Consider changing all the comparisons in this function to inclusive ones (e.g. totalReceived &lt;= TIER3_CAP), which is the standard behavior in these cases.</p><h4>Redundant return value</h4><p>processBuy function in <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L126">line 126</a> is declared to return a boolean but never returns false. Instead, it always throws in case of error. Consider sticking to one error signaling convention. We recommend throwing to <a href="https://medium.com/zeppelin-blog/onward-with-ethereum-smart-contract-security-97a827e47702#14aa">fail as early and loudly as possible</a>, ensuring the propagation of the error. Same thing with unlock function in <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/MoedaToken.sol#L40">line 40 of MoedaToken.sol</a>.</p><h4>Enforce all preconditions</h4><p>processBuy function in <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L126">line 126</a> has a precondition written in the comments which is not enforced in the code: it’s only usable while the crowdsale is active. In the current state of the contract, the function is internal and only called from the fallback function, which is properly guarded with the onlyDuringSale modifier. However, it’s best to enforce preconditions independently on a function-by-function basis.</p><p>Consider using the onlyDuringSale modifier at the beginning of processBuy. Furthermore, since processBuy is only used once, and is the only thing the fallback function does, consider removing it altogether, moving the code inside the fallback function.</p><p><strong>Update: </strong>The function has merged with the fallback function, was fixed in <a href="https://github.com/erkmos/moeda/commit/d4c8f85809ecd33852924aa71b0a233f4dbc2318">https://github.com/erkmos/moeda/commit/d4c8f85809ecd33852924aa71b0a233f4dbc2318</a></p><h4>Naming suggestions</h4><ul><li>The boolean locked variable in <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/MoedaToken.sol#L16">line 16 of MoedaToken.sol</a> is not descriptive of its actual use. Consider a name like saleActive.<br><strong>Update: </strong>Was renamed to saleActive in <a href="https://github.com/erkmos/moeda/commit/8e9b6861d7b735c1ef49c7594dfc5e0cc777fbc6">https://github.com/erkmos/moeda/commit/8e9b6861d7b735c1ef49c7594dfc5e0cc777fbc6</a></li><li>PRESALE_TOKEN_AMOUNT variable is not really referring to presale amount in <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L22">line 22</a>. Consider using a name referring to “developer allocation” such as DEVELOPER_TOKEN_ALLOCATION or something similar.<br><strong>Update</strong>: This has been renamed to PRESALE_TOKEN_ALLOCATION (it is actually referring to an allocation for a previous sale), fixed in <a href="https://github.com/erkmos/moeda/commit/7ed3d1d78d8f8da7705e0b93351659f058860a4c">https://github.com/erkmos/moeda/commit/7ed3d1d78d8f8da7705e0b93351659f058860a4c</a></li><li>The word “rate” is ambiguous (<a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L28-L30">lines 28–30</a>). consider calling it “price”. Bear in mind that if the changes suggested in “Unnecessary complexity calculating token amount” are implemented, the name “price” would no longer be correct.</li><li>The Buy event in <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L37">line 37</a> of Crowdsale.sol could have a better name. In general, events have nouns or past-tense verbs as names. Consider changing it to Purchase or TokenBought.<br><strong>Update</strong>: Event renamed to Purchase in <a href="https://github.com/erkmos/moeda/commit/4858c60cef148bbbdaed87dbc3965f58a0787ab5">https://github.com/erkmos/moeda/commit/4858c60cef148bbbdaed87dbc3965f58a0787ab5</a></li></ul><h4>Use SafeMath in all math operations</h4><p>Most math operations are safe, except a sum in the token contract at <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/MoedaToken.sol#L51">line 51</a>. It’s always better to be safe and perform checked operations.<br><strong>Update: </strong>The place it was missing has been fixed in <a href="https://github.com/erkmos/moeda/commit/5e1ccfb7b4f934c0588c84196e435e21f46c7de5">https://github.com/erkmos/moeda/commit/5e1ccfb7b4f934c0588c84196e435e21f46c7de5</a></p><h3>Additional Information and Notes</h3><ul><li>There are MLO tokens assigned to the wallet address <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L152">in line 152 of Crowdsale.sol</a>. Please make sure the wallet contract is capable of holding and managing tokens.<br><strong>Update: </strong>included the wallet contract in <a href="https://github.com/erkmos/moeda/commit/86cf3a632b73ba8993c1477b103f760a13a785fc">https://github.com/erkmos/moeda/commit/86cf3a632b73ba8993c1477b103f760a13a785fc</a></li><li>Contracts use “ether” units to specify token amounts (see <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L22">Crowdsale.sol, line 22</a>, <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/MoedaToken.sol#L13">MoedaToken.sol, line 13</a>). This is okay but slightly confusing and you should be careful.<br><strong>Update: </strong>Changed to named constants in <a href="https://github.com/erkmos/moeda/commit/ef08e24c44a0f6144d6e41d77f5daae4f6272928">https://github.com/erkmos/moeda/commit/ef08e24c44a0f6144d6e41d77f5daae4f6272928</a></li><li>Good job validating preconditions for the constructor parameters.</li><li>presaleWallet in <a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L19">line 19 of Crowdsale.sol</a> is never used and should be removed.<br><strong>Update</strong>: Was removed in <a href="https://github.com/erkmos/moeda/commit/171959dda8ed7a3ff10d80bbf65044298d06a46d">https://github.com/erkmos/moeda/commit/171959dda8ed7a3ff10d80bbf65044298d06a46d</a></li><li>getTokenAmount is a recursive function. As far as we can tell it terminates for all valid inputs (the recursion depth is never greater than 3).</li><li>The fallback function is redundant since it only calls the processBuy function.<br><strong>Update:</strong> Was fixed in <a href="https://github.com/erkmos/moeda/commit/d4c8f85809ecd33852924aa71b0a233f4dbc2318">https://github.com/erkmos/moeda/commit/d4c8f85809ecd33852924aa71b0a233f4dbc2318</a></li><li>The totalTokensSold variable is only written to, and never read. Moreover, it’s redundant because the information is already available in the totalSupply state variable of the token contract. Consider removing it; redundancy can be a source of problems.</li><li>A call of send isn’t the last expression in the function (<a href="https://github.com/erkmos/moeda/blob/b2bf23119d563e251b6f16b29b642bac43e76a64/contracts/Crowdsale.sol#L129">line 129</a> of Crowdsale.sol). We haven’t found any problem with this, but it has been a source of issues in the past. Consider <a href="https://medium.com/zeppelin-blog/onward-with-ethereum-smart-contract-security-97a827e47702#3d17">moving the </a><a href="https://medium.com/zeppelin-blog/onward-with-ethereum-smart-contract-security-97a827e47702#3d17">send call to the end of the function</a>.<br><strong>Update: </strong>fixed in <a href="https://github.com/erkmos/moeda/commit/5a5ec164e6ccb601f4da19d897522e8ca3bcfc01">https://github.com/erkmos/moeda/commit/5a5ec164e6ccb601f4da19d897522e8ca3bcfc01</a> (along with some more redundant booleans being removed)</li><li>All tests run correctly and pass. ✔</li></ul><h3>Conclusions</h3><p>No severe security issues were found. Some additional changes were proposed to follow best practices and reduce potential attack surface.</p><p><strong>Update:</strong> The Moeda team implemented most of our recommendations in <a href="https://github.com/erkmos/moeda/tree/784f4192d0851b9470d2c9dd2e90d7310b642832">the latest version of their code</a>.</p><p>Overall the code is good and has only minor issues.</p><p><em>Thanks to Francisco Giordano for helping write this report.</em></p><p><em>Note that as of the date of publishing, the above review reflects the current understanding of known security patterns as they relate to the Moeda Token contract. We have not reviewed the related Moeda project. The above should not be construed as investment advice or an offering of tokens. For general information about smart contract security, check out our thoughts </em><a href="https://medium.com/zeppelin-blog/onward-with-ethereum-smart-contract-security-97a827e47702"><em>here</em></a><em>.</em></p><h3>Be part of the community</h3><ul><li>Continue the discussion on our <a href="https://forum.zeppelin.solutions/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">forum</a></li><li>Request a <a href="https://zeppelin.solutions/security-audits/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">security audit</a></li><li>Even better, <a href="https://zeppelin.solutions/jobs/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">join the team</a> 🚀</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac72944caa6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[External audit of OpenZeppelin]]></title>
            <link>https://maraoz.medium.com/external-audit-of-openzeppelin-2ea50404ba7b?source=rss-71b7575196fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ea50404ba7b</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[audit]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Manuel Araoz]]></dc:creator>
            <pubDate>Thu, 11 May 2017 16:36:28 GMT</pubDate>
            <atom:updated>2019-02-13T20:38:42.586Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4uAvPw_6G6iQ29gy6cD_NQ.png" /></figure><p>As you may know from reading <a href="https://medium.com/zeppelin-blog/">our blog</a>, we do <a href="https://smartcontractsolutions.com/security-audits">lots of security audits for blockchain-based projects</a>. All projects in the space need someone external to take a fresh, unbiased, and skeptic look at their code.</p><p><a href="https://openzeppelin.com/">OpenZeppelin</a> is an open repository of reusable smart contract modules. <a href="https://medium.com/zeppelin-blog/zeppelin-framework-proposal-and-development-roadmap-fdfa9a3a32ab">Since we started the project</a>, we committed to <a href="https://medium.com/zeppelin-blog/onward-with-ethereum-smart-contract-security-97a827e47702">the highest standard of security</a> and peer-review. This means performing external audits on our code too. That’s why we asked the New Alchemy team to perform a formal security audit of <a href="https://github.com/OpenZeppelin/zeppelin-solidity">OpenZeppelin’s codebase</a>, following the 1.0.0 release of the framework.</p><p>Projects using OpenZeppelin just need to upgrade to <a href="https://github.com/OpenZeppelin/zeppelin-solidity/releases/tag/v1.0.5">the latest release (v1.0.5)</a> to include the bugfixes coming from this audit. We’re also working on a <a href="https://medium.com/zeppelin-blog/proxy-libraries-in-solidity-79fbe4b970fd">mechanism for on-chain upgradeability</a> to enable already-deployed projects to receive security fixes.</p><p><a href="https://github.com/OpenZeppelin/zeppelin-solidity/blob/38a450460d8c501980932b136c8e7c99f6071902/audit/ZeppelinAudit.md">The full audit can be found on GitHub</a>, but this is a list of the most noteworthy findings and how we addressed them:</p><ul><li>Upgrade to latest Solidity version in all contracts. Fixed <a href="https://github.com/maraoz/zeppelin-solidity/commit/e8fc7f6671da82678d8d5a6e065d96084be10ad5">here</a>.</li><li>Prefer throw vs return false. This is in line with our <a href="https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/CONTRIBUTING.md#g2---code-that-fails-early">fail early and loudly guideline</a>. Fixed <a href="https://github.com/maraoz/zeppelin-solidity/commit/896d742f6aa268389dabe026bb586232f6be5e64">here</a>.</li><li>Create a cancellable pull payment helper class. Issue opened <a href="https://github.com/OpenZeppelin/zeppelin-solidity/issues/196">here</a>.</li><li>Create a version of PullPayment that checks the contract has enough balance to send. Issue opened <a href="https://github.com/OpenZeppelin/zeppelin-solidity/issues/197">here</a>.</li><li>Several problems with Shareable, some fixed <a href="https://github.com/maraoz/zeppelin-solidity/commit/feb63dca56f014e9cb13c51aecf88be89e2b6dca">here</a> and and <a href="https://github.com/OpenZeppelin/zeppelin-solidity/issues/199">an issue opened</a> to improve code quality.</li><li>Recursive Call attack to resetSpentToday in MultisigWallet. Issue opened <a href="https://github.com/OpenZeppelin/zeppelin-solidity/issues/200">here</a>.</li><li>ERC20 approve problem, as described in EDCON. Issue opened <a href="https://github.com/OpenZeppelin/zeppelin-solidity/issues/168">here</a>.</li><li>Create a simpler version of MultisigWallet. Issue opened <a href="https://github.com/OpenZeppelin/zeppelin-solidity/issues/201">here</a>.</li></ul><p>Most of the recommendations were implemented in <a href="https://github.com/OpenZeppelin/zeppelin-solidity/pull/169">this pull request</a>. Other less urgent things were transformed into GitHub issues.</p><p>As always, we’re committed to improving the security standards of the blockchain industry. This is a step forward in consolidating <a href="https://openzeppelin.com/">OpenZeppelin</a> as a collection of reusable and secure modules anyone can use and extend.</p><p>If you’re interested in discussing smart contract security, <a href="https://medium.com/zeppelin-blog">follow us on Medium</a>, or <a href="https://smartcontractsolutions.com/about#jobs">apply to work with us</a>! We’re also available for smart contract security development and auditing work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ea50404ba7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WingsDAO Token Audit]]></title>
            <link>https://maraoz.medium.com/wingsdao-token-audit-f39f800a1bc1?source=rss-71b7575196fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/f39f800a1bc1</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[audit]]></category>
            <dc:creator><![CDATA[Manuel Araoz]]></dc:creator>
            <pubDate>Wed, 10 May 2017 17:37:16 GMT</pubDate>
            <atom:updated>2019-02-13T19:41:07.766Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kxuJ8VYht5qdZuqpFjA6VA.png" /></figure><p><a href="https://wings.ai/">The Wings team</a> asked us to review and audit their new <a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol">Token</a> contract code. We looked at their code and now publish our results.</p><p>The audited contract is at <a href="https://github.com/WingsDao/contracts/tree/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae">their contracts GitHub repo</a>. The version used for this report is commit 1b308105a31c5b005c21fbbda3b1ff5b3fac9bae. The main contract file is <a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol">Token.sol</a>.</p><p>Code quality is good. We’re very happy to audit a project using <a href="https://openzeppelin.org/">OpenZeppelin</a>.</p><p>Here’s our assessment and recommendations, in order of importance:</p><p><strong>Update</strong>: The Wings team implement most recommendations <a href="https://github.com/WingsDao/contracts/commits/master">in their master branch</a>.</p><h3>Severe</h3><p>We haven’t found any severe security problems with the code.</p><h3>Potential problems</h3><h4>Be careful with types</h4><p>Avoid declaring variables using <em>var</em> if possible. The type-deduction system <a href="https://medium.com/zeppelin-blog/onward-with-ethereum-smart-contract-security-97a827e47702#c528">can bring some surprises if you don’t think about types very carefully</a>. For example, for ints, it will choose the smallest type that is required to hold assigned constants. This can lead to endless loops and gas depletion. Better use the explicit type <em>uint </em>for no surprises and higher limits. Consider replacing all occurrences of var with a specific type.</p><p><strong>Fixed: </strong><a href="https://github.com/WingsDao/contracts/blob/master/contracts/Token.sol#L222">https://github.com/WingsDao/contracts/blob/master/contracts/Token.sol#L222</a></p><h4>Timestamp usage</h4><p>There’s a problem with using timestamps and <strong>now</strong> (alias for <strong>block.timestamp</strong>) for contract logic, based on the fact that miners can perform some manipulation. In general, <a href="https://github.com/ConsenSys/smart-contract-best-practices#timestamp-dependence">it’s better not to rely on timestamps for contract logic</a>. The solutions is to use <strong>block.number</strong> instead, and approximate dates with expected block heights and time periods with expected block amounts.</p><p>The Token.sol contract uses timestamps <a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L212">in line 212</a>. The risk of miner manipulation, though, is really low. The potential damage is also limited: miners could only slightly manipulate when each preallocation can be done. We recommend the team to consider the potential risk of this manipulation and switch to <strong>block.number</strong> if necessary.</p><p>For more info on this topic, see <a href="https://ethereum.stackexchange.com/questions/413/can-a-contract-safely-rely-on-block-timestamp">this stack exchange question</a>.</p><h3>Warnings</h3><h4>Usage of magic constants</h4><p>There are several <a href="https://en.wikipedia.org/wiki/Magic_number_%28programming%29">magic constants</a> in the contract code. Some examples are:</p><ul><li><a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L94">https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L94</a></li><li><a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L150-L151">https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L150-L151</a></li></ul><p>Use of magic constants reduces code readability and makes it harder to understand code intention. We recommend extracting magic constants into contract constants.</p><p><strong>Fix:</strong> <a href="https://github.com/WingsDao/contracts/blob/master/contracts/Token.sol#L53">https://github.com/WingsDao/contracts/blob/master/contracts/Token.sol#L53</a></p><h4>Bug Bounty</h4><p>Formal security audits are not enough to be safe. We recommend implementing <a href="https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/Bounty.sol">an automated contract-based bug bounty</a> and setting a period of time where security researchers from around the globe can try to break the contract’s invariants. For more info on how to implement automated bug bounties with OpenZeppelin, <a href="https://zeppelin-solidity.readthedocs.io/en/latest/bounty.html">see this guide</a>.</p><h4>Avoid duplicated code</h4><p>Duplicate code makes it harder to understand the code’s intention and thus, auditing the code correctly. It also increases the risk of introducing hidden bugs when modifying one of the copies of some code and not the others.</p><p>The logic in <a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L116">transfer</a>, <a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L123">transferFrom</a>, and <a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L133">approve</a> is very similar to the provided methods in StandardToken and could be refactored to avoid repetition. There is no need to rewrite the parent’s contract logic: consider using the <a href="https://ethereum.stackexchange.com/questions/12920/what-does-the-keyword-super-in-solidity-do">super keyword</a> to access StandardToken implementation of methods, like so:</p><pre>function transfer(address _to, uint _value) whenAllocation(false) returns (bool success) {<br>  return super.transfer(_to, _value);<br>}</pre><p>Fixed in <a href="https://github.com/WingsDao/contracts/blob/master/contracts/Token.sol#L131">https://github.com/WingsDao/contracts/blob/master/contracts/Token.sol#L131</a></p><h4>Naming suggestions</h4><ul><li>All references to premine (Preminer, PreminerAdded, PremineAllocationAdded, PremineRelease, etc.) are confusing. There is no mining of these tokens. Consider using another name like “initial assignment”.</li><li><strong>checkUserAllocation</strong> and <strong>checkPreminerAllocation</strong> are not very good names, as they don’t clearly indicate what they are supposed to do. Consider renaming it for example to<strong> whenHasntAllocated(user)</strong>.</li><li><strong>monthlyPayment uint </strong>field of Preminer struct is confusing. It’s name implies it’s a monthly payment but there’s nothing enforcing the payment is only done monthly. Consider renaming the field or adding time checks.</li></ul><p>Fixed in <br><a href="https://github.com/WingsDao/contracts/blob/master/contracts/Token.sol#L86">https://github.com/WingsDao/contracts/blob/master/contracts/Token.sol#L86</a></p><h4>Use latest version of Solidity</h4><p><a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L1">Current code</a> is written for old versions of solc (0.4.2). With <a href="https://blog.ethereum.org/2016/11/01/security-alert-solidity-variables-can-overwritten-storage/">the storage overwriting vulnerability</a> found on versions of solc prior to 0.4.4, there’s a risk this code can be compiled with vulnerable versions. We recommend changing the solidity version pragma for the latest version (pragma solidity ^0.4.10;) to enforce latest compiler version to be used.</p><p>Fixed in <a href="https://github.com/WingsDao/contracts/blob/master/contracts/Token.sol#L1">https://github.com/WingsDao/contracts/blob/master/contracts/Token.sol#L1</a></p><h3>Additional Information and Notes</h3><ul><li><a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L8">Comment on line 8</a> has a typo: should say “Campaign” instead of “Campagin”.</li><li><a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L27">Comment on line 27</a> has a typo: should say “structure” instead of “scturcture”.</li><li>Same in <a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L39">line 39</a>: “perminers”.</li><li>Same in <a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L202">line 202</a>: “monthes”.</li><li>Same in <a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L140">line 140</a>: “functional<strong>ity</strong>”.</li><li>No uses of send and call.value.</li><li>Good work using <a href="https://openzeppelin.org/">OpenZeppelin</a>! :)</li><li>Good work using safe math.</li><li><a href="https://github.com/WingsDao/contracts/blob/1b308105a31c5b005c21fbbda3b1ff5b3fac9bae/contracts/Token.sol#L94">Why is totalSupply assigned a fixed magic number</a>?</li></ul><h3>Conclusions</h3><p>No severe security issues were found. Some changes were recommended to follow best practices and reduce potential attack surface.</p><p>Code quality is good. We’re very happy to audit a project using <a href="https://openzeppelin.org/">OpenZeppelin</a>.</p><p><strong>Update</strong>: The Wings team implement most recommendations <a href="https://github.com/WingsDao/contracts/commits/master">in their master branch</a>.</p><p><em>Note that as of the date of publishing, the above review reflects the current understanding of known security patterns as they relate to the Wings Token contract. We have not reviewed the related Wings project. The above should not be construed as investment advice or an offering of Wings tokens. For general information about smart contract security, check out our thoughts </em><a href="https://medium.com/zeppelin-blog/onward-with-ethereum-smart-contract-security-97a827e47702"><em>here</em></a><em>.</em></p><h3>Be part of the community</h3><ul><li>Continue the discussion on our <a href="https://forum.zeppelin.solutions/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">forum</a></li><li>Request a <a href="https://zeppelin.solutions/security-audits/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">security audit</a></li><li>Even better, <a href="https://zeppelin.solutions/jobs/?utm_campaign=zep&amp;utm_medium=blog&amp;utm_source=medium">join the team</a> 🚀</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f39f800a1bc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>