<?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:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[the klevoya blog]]></title><description><![CDATA[The klevoya blog is dedicated to helping you become a better blockchain developer. Thoughts on EOS blockchain development, dApps and more.]]></description><link>https://klevoya.com/blog/</link><image><url>https://klevoya.com/blog/favicon.png</url><title>the klevoya blog</title><link>https://klevoya.com/blog/</link></image><generator>Ghost 3.22</generator><lastBuildDate>Fri, 18 Oct 2024 21:02:05 GMT</lastBuildDate><atom:link href="https://klevoya.com/blog/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Finding Missing Auth bugs in EOSIO Smart Contracts]]></title><description><![CDATA[We look at the EOSIO smart contract Missing Authorisation vulnerability and how to use static analysis to discover it.]]></description><link>https://klevoya.com/blog/finding-missing-auth-bugs-in-eosio-smart-contracts/</link><guid isPermaLink="false">60466b4a6a749903ed802aa7</guid><category><![CDATA[Inspect]]></category><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Mon, 08 Mar 2021 18:31:37 GMT</pubDate><media:content url="https://klevoya.com/blog/content/images/2021/03/Blog_Header-Missing_Auth_Bugs.png" medium="image"/><content:encoded><![CDATA[<img src="https://klevoya.com/blog/content/images/2021/03/Blog_Header-Missing_Auth_Bugs.png" alt="Finding Missing Auth bugs in EOSIO Smart Contracts"><p>This is a series of blog posts in which I’ll cover some common EOSIO smart contract vulnerabilities and then explain how we can use our EOSIO vulnerability scanner, <a href="https://klevoya.com/inspect/">Inspect</a>, to perform static analysis to uncover these vulnerabilities.</p><p>This week, I look at Missing Authorisations.</p><h2 id="the-vulnerability">The vulnerability</h2><p>In EOSIO, a developer can use two functions to control authorisation of smart contract actions by checking whether the declared authorisation of the action equals the account that should be able to run the action. These are:</p><ul><li>require_auth(account [, permission])</li><li>has_auth(account)</li></ul><p>Due to missing authorisation controls, a vulnerable smart contract grants authorisation to untrusted accounts such as malicious parties, to:</p><ul><li>access/modify privileged smart contract resources e.g. smart contract tables,</li><li>Call functions of other contracts on behalf of the vulnerable contract, or</li><li>Perform mission-critical contract actions e.g. token withdrawals.</li></ul><p><br>Let’s look at an example of where a smart contract is setup such that it is paying for EOSIO RAM (which is what EOSIO calls the on chain database) storage costs, in such a scenario every write to the database should be checked to ensure that the entity calling the action that contains the database write has the proper authorisation to do so. Otherwise incorrect data may be written, or a RAM filling attack (see severity below) may occur.</p><p>In the action code below, despite there being a require_auth() call prior to the emplace call (which writes data to the _users table), the user is not the RAM payer, allowing any user to write to the database using the contract account's own RAM making the contract vulnerable to a RAM filling attack.</p><figure class="kg-card kg-code-card"><pre><code class="language-C++">ACTION emplaceself1(name username, const std::string &amp;display_name) {
 // unsafe
 require_auth(username);
 // contract is paying for RAM, requires checking get_self() auth, otherwise RAM filling attack
 _users.emplace(get_self(), [&amp;](auto &amp;new_user) {
   new_user.username = username;
   new_user.display_name = display_name;
 });
}
</code></pre><figcaption>Unsafe smart contract action.</figcaption></figure><p>Modifying the action so that the user pays for RAM, makes the action immune to a RAM filling attack (as the user is no longer using the contract’s resources for RAM):</p><figure class="kg-card kg-code-card"><pre><code class="language-C++">ACTION emplaceself2(name username, const std::string &amp;display_name) {
 require_auth(username);
 // safe
 _users.emplace(username, [&amp;](auto &amp;new_user) {
   new_user.username = username;
   new_user.display_name = display_name;
 });
}
</code></pre><figcaption>Smart contract action modified to make it safe.</figcaption></figure><h2 id="severity">Severity</h2><p>The impact of this type of vulnerability is that a hacker could:</p><ul><li>Write/modify/delete any data stored in RAM that is not adequately guarded by an appropriate authorisation check,</li><li>Call functionality that should ostensibly be reserved only for the smart contract’s administrators/privileged users,</li><li>In EOSIO RAM is not free so a hacker can fill up a smart contract’s RAM with spurious data and exhaust the dAPP’s resources leading to a denial of service for legitimate users.</li></ul><h2 id="finding-the-vulnerability-with-inspect">Finding the vulnerability with Inspect</h2><p>Inspect employs a technique called Static analysis. Static analysis is performed by reasoning about a computer program’s source-code, or some intermediate representation, without actually executing it.</p><p>With Inspect we perform static analysis on the WASM binary code, this is decompiled and then lifted into a proprietary intermediate representation (IR). Inspect then takes the IR, represents it in a database which we can mine for patterns of known vulnerabilities.</p><p>Running Inspect on a smart contract containing the above smart contract actions gives the following result:</p><pre><code>Auth Violation: ✘
Action: emplaceself1    Insn: ($fel) = db_store_i64($feb, $fec, $fef, $feh, $fej, $fek)</code></pre><p>The first action is correctly flagged as violating the Authorisation check. As Inspect operates on the WASM byte code, it reports the violation occurring at the EOSIO intrinsic, db_store_i64(), that corresponds to the emplace() call.</p><p>The second action is not reported as it is safe.</p><p>In a real analysis scenario, the next step would be to correlate this result with the source code and confirm that this is truly a vulnerability.</p><p>What else? What vulnerabilities would you like me to cover next?</p>]]></content:encoded></item><item><title><![CDATA[Klevoya brings the power of automated vulnerability analysis to EOSIO smart contracts]]></title><description><![CDATA[To catch smart contract bugs early in the development cycle, we are announcing the open availability of Inspect, our automated smart contract analysis tool.]]></description><link>https://klevoya.com/blog/inspect-smart-contract-automated-analysis/</link><guid isPermaLink="false">6037e2dd6a749903ed802a2b</guid><category><![CDATA[Press Release]]></category><category><![CDATA[Inspect]]></category><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Thu, 25 Feb 2021 18:27:46 GMT</pubDate><media:content url="https://klevoya.com/blog/content/images/2021/02/Inspect.png" medium="image"/><content:encoded><![CDATA[<img src="https://klevoya.com/blog/content/images/2021/02/Inspect.png" alt="Klevoya brings the power of automated vulnerability analysis to EOSIO smart contracts"><p>The growth of blockchain applications has resulted in increasing amounts of value being controlled by smart contracts. Making smart contracts very lucrative targets for bad actors looking to exploit any vulnerabilities for quick profit. A successful smart contract exploit can have a disastrous effect on the value of the application's token.</p><p>To help developers catch smart contract bugs early in the development cycle, we are pleased to announce the open availability of Inspect, our automated smart contract analysis tool. Inspect performs static analysis of EOSIO WASM bytecode, mining the smart contract binaries for security bugs and flagging them to the developer before they find their way into production.</p><p>If you're in charge of securing your blockchain applications security then you'll want to take a look at:</p><ul><li>The Inspect <a href="https://docs.klevoya.com/inspect/about/getting-started">Getting started document</a> with examples of usage</li><li>The open-source <a href="https://github.com/klevoya/eosio-wcr-registry">database of common EOSIO vulnerabilities</a>, many of which Inspect automatically identifies</li></ul><p>Sign up for Inspect <a href="https://klevoya.com/inspect/">here</a>.</p><p>For further details and questions about Inspect then <a href="https://t.me/klevoya">join the discussion</a>.</p>]]></content:encoded></item><item><title><![CDATA[Announcing faster Hydra test execution and support for LiquidApps vRAM]]></title><description><![CDATA[Announcing Hydra Advanced which can give you a 3-5x speed-up test time. Plus vRAM support.]]></description><link>https://klevoya.com/blog/announcing-hydra-support-for-liquidapps-vram/</link><guid isPermaLink="false">60367a5d6a749903ed8029a3</guid><category><![CDATA[Press Release]]></category><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Wed, 24 Feb 2021 16:36:37 GMT</pubDate><media:content url="https://klevoya.com/blog/content/images/2021/02/Hydra---Advanced.png" medium="image"/><content:encoded><![CDATA[<img src="https://klevoya.com/blog/content/images/2021/02/Hydra---Advanced.png" alt="Announcing faster Hydra test execution and support for LiquidApps vRAM"><p>At Klevoya we already provide a free version of our Hydra EOSIO smart contract test environment. Hydra allows you to quickly run unit tests, without requiring a local development node and easily integrate your tests within a CI/CD environment. Developers using Hydra have seen a significant improvement in the time they need to develop their smart contract test suites.</p><h2 id="speed-improvement">Speed improvement</h2><p>But what if your current Hydra test suite takes too long to execute? </p><p>To solve that we now offer a premium service; Hydra Advanced which (depending on your location) can give you a 3-5x speed-up in the time to execute your tests.</p><p>You can sign-up for Hydra Advanced <a href="https://klevoya.com/hydra/">here</a>.</p><h2 id="vram-support">vRAM support</h2><p><a href="https://liquidapps.io/vRam">vRAM by LiquidApps</a> is an alternative memory solution for EOSIO developers building blockchain dApps that is RAM-compatible, decentralized, and enables storing &amp; retrieving of potentially unlimited amounts of data affordably and efficiently.</p><p>Developing and testing of vRAM enabled smart contracts is not easy as it requires setting up and running a local DSP node which is even more complicated than running a regular EOSIO node.</p><p>Today we are pleased to announce that Hydra supports vRAM, all through the same easy interface that developers are used to.</p><p>To see how you can integrate vRAM into your smart contract tests check out <a href="https://docs.klevoya.com/hydra/liquidapps/vram">these examples</a> in the Hydra documentation.</p><p>For further details and support with these features then <a href="https://t.me/klevoya">join the discussion</a>.</p>]]></content:encoded></item><item><title><![CDATA[11 things you should do before publicly deploying your smart contract]]></title><description><![CDATA[Deploying your contract to production is a big step with a lot at stake and can be a scary task. That’s why we’ve put together a checklist on things you should do before releasing your smart-contracts.]]></description><link>https://klevoya.com/blog/11-things-you-should-do-before-publicly-deploying-your-smart-contract/</link><guid isPermaLink="false">5f1b1de9dfdaa90472593971</guid><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Mon, 27 Jul 2020 15:53:13 GMT</pubDate><media:content url="https://klevoya.com/blog/content/images/2020/07/11-things-to-do-before-deploying-your-smart-contract.png" medium="image"/><content:encoded><![CDATA[<img src="https://klevoya.com/blog/content/images/2020/07/11-things-to-do-before-deploying-your-smart-contract.png" alt="11 things you should do before publicly deploying your smart contract"><p>You’ve just finished the development of your EOSIO smart contract and you’re ready to release it for the whole world to use. But before you do, take a step back and make sure you have all the bases covered. Deploying your contract to production is a big step with (literally) a lot at stake and can be a scary and daunting task. Especially in the blockchain world, where one regularly reads about smart contract hacks involving millions of stolen funds.</p><p>That’s why we’ve put together a checklist on things you should do before releasing your smart-contracts.</p><h3 id="1-follow-coding-best-practices">1) Follow coding best practices </h3><p>Make sure that your contract follows coding best practices. This usually leads to cleaner code which in return leads makes spotting bugs easier.</p><h3 id="2-compile-production-build">2) Compile production build</h3><p>If your contract has certain code paths that are only used for testing make sure they are removed or turned off by defining C++ macros for production builds.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://klevoya.com/blog/content/images/2020/07/depressed-developer-34.png" class="kg-image" alt="11 things you should do before publicly deploying your smart contract" srcset="https://klevoya.com/blog/content/images/size/w600/2020/07/depressed-developer-34.png 600w, https://klevoya.com/blog/content/images/size/w1000/2020/07/depressed-developer-34.png 1000w, https://klevoya.com/blog/content/images/2020/07/depressed-developer-34.png 1410w" sizes="(min-width: 720px) 720px"><figcaption>Don't leave testing parts in your production build.</figcaption></figure><h3 id="3-implement-a-safety-switch">3) Implement a safety switch</h3><p>You never know if and when something will go wrong with your contract. Therefore (depending on your project) it may make sense to add a pause button that will stop all your other actions from executing.</p><figure class="kg-card kg-image-card"><img src="https://klevoya.com/blog/content/images/2020/07/emergency_switch.png" class="kg-image" alt="11 things you should do before publicly deploying your smart contract" srcset="https://klevoya.com/blog/content/images/size/w600/2020/07/emergency_switch.png 600w, https://klevoya.com/blog/content/images/2020/07/emergency_switch.png 800w" sizes="(min-width: 720px) 720px"></figure><h3 id="4-thoroughly-unit-test-your-contract">4) Thoroughly unit-test your contract </h3><p>Code rarely works perfectly the first time. The best way to catch bugs early is by writing unit tests while developing your smart contract. For EOSIO smart contracts our tool <a href="https://klevoya.com/hydra">Hydra </a>can help you with this.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://klevoya.com/blog/content/images/2020/07/unit-test.jpg" class="kg-image" alt="11 things you should do before publicly deploying your smart contract" srcset="https://klevoya.com/blog/content/images/size/w600/2020/07/unit-test.jpg 600w, https://klevoya.com/blog/content/images/2020/07/unit-test.jpg 640w"><figcaption>Unit-testing, it's not magic!</figcaption></figure><h3 id="5-beta-test-on-a-testnet">5) Beta-test on a testnet </h3><p>Before deploying your smart contracts to production on a main-net, roll them out to beta testers on a test-net. You'll get valuable feedback that isolated unit tests cannot provide.</p><h3 id="6-run-automated-vulnerability-scanners">6) Run automated vulnerability scanners </h3><p>Running automated vulnerability scanners on your smart contract code doesn’t require much effort and results in a fast security check that can detect common vulnerabilities.</p><h3 id="7-code-audit">7) Code audit </h3><p>If you are building a decentralized finance application or any other application that manages a lot of user funds, receiving a security audit by a team of professional security auditors is highly recommended.</p><h3 id="8-check-account-permissions-and-secure-private-keys">8) Check account permissions and secure private keys </h3><p>EOSIO account permissions can be complex. Double-check that your desired permission structure is set up on all the accounts and that you used fresh private keys.</p><h3 id="9-sufficient-resources">9) Sufficient resources? </h3><p>Make sure your smart contract accounts have enough CPU/RAM available. Consider borrowing resources from EOS Rex or automated resource management like <a href="https://twitter.com/ChintaiEOS">@ChintaiEOS</a> ARM.</p><h3 id="10-keep-track-of-smart-contract-versions">10) Keep track of smart contract versions </h3><p>When working on a new feature or maintaining the contract, its very important to know the exact code that is currently deployed. So tag the contract version in git.</p><h3 id="11-be-careful-when-you-deploy">11) Be careful when you deploy </h3><p>It’s advisable to deploy early in your workday so that there’s enough time to test your system on production and fix potential problems that might occur.</p><h2 id="final-thoughts">Final thoughts</h2><p>Pushing the button to deploy your smart contracts to production doesn't have to be a scary task as long as you are sensible and follow pre-deployment best practices.</p><p>For a more in-depth look into the pre-deployment best practices <a href="https://klevoya.ck.page/11-things-before-deploying-smartcontracts">download the PDF version here</a>.</p>]]></content:encoded></item><item><title><![CDATA[Which test environment? Hydra or nodeos+cleos?]]></title><description><![CDATA[You can run tests without directly connecting to an existing nodeos node. Hydra allows you to quickly get started writing unit tests.]]></description><link>https://klevoya.com/blog/hydra-vs-nodeos-cleos/</link><guid isPermaLink="false">5f031a246a815916fa258bd0</guid><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Thu, 02 Jul 2020 12:38:00 GMT</pubDate><media:content url="https://klevoya.com/blog/content/images/2020/07/Hydra-vs-Nodeos---Blog-poster-1.png" medium="image"/><content:encoded><![CDATA[<img src="https://klevoya.com/blog/content/images/2020/07/Hydra-vs-Nodeos---Blog-poster-1.png" alt="Which test environment? Hydra or nodeos+cleos?"><p>You've sat down at your terminal, opened up a terminal and are ready to start debugging your new smart contract.</p><p>You type in <code>nodeos</code>, hit Enter and then see those cryptic words every EOSIO smart contract developer who has ever played around regularly with nodeos dreads:</p><blockquote>nodeos replay required</blockquote><p>Or, my personal favourite:</p><blockquote>nodeos database dirty flag set</blockquote><p>What in the....? You think. Why is the database dirty?</p><p>You start Googling and going through EOSIO Dev Telegram posts for a solution, all the while wondering how it suddenly became your job to be a part-time BP!</p><p>You figure out how to clean your dirty database, which will probably require you to completely wipe your local test net and reinitialise the state of your smart contract and all your local system contracts. And eventually you get your tests running.</p><p>Until it happens again.</p><p>"This is backwards," a little voice whispers inside of you. "There's got to be a better way."</p><p>And the truth is, yes you can write a bunch of shell scripts that will setup your test environment and have it working just the way you like it. While this is very flexible and allows quick prototyping, it takes some effort to create the scripts in the first place. It's like re-inventing the wheel and missing out on all of the advances in automated testing frameworks that run a suite of tests every time you make a code change.</p><h2 id="what-s-important-in-a-test-environment">What’s important in a test environment?</h2><p>To get the most out of automated testing, it’s important that a testing framework supports the developer in 2 ways:</p><h3 id="simplicity">Simplicity</h3><p>The testing framework should make it simple to write and run tests.<br>Specifically when testing EOSIO smart contracts, a testing framework should eliminate a lot of the tedious and repetitive tasks encountered when testing:</p><ol><li>Having to set up and maintain an EOSIO network</li><li>Preparing the blockchain for the tests: Creating test accounts, managing private keys, setting up account permissions, setting the smart contract code, and bringing the blockchain into a testing state, e.g., by creating and issuing tokens</li><li>Sending transactions and observing the outcome by checking contract tables or action traces</li></ol><h3 id="repeatability-determinism">Repeatability / Determinism</h3><p>The point of having automated tests is that they can be run anytime on code changes, for example, on the CI server whenever a team member commits new code to GitHub to ensure a change did not negatively affect existing features (regression testing). The tests need to be easily repeatable for every developer and run in the same blockchain environment every time. This usually means running the tests on a local or private EOSIO network that is fully controlled.</p><p>Public testnets can be problematic because the environment constantly changes and cannot be reset. One is at the mercy of the chain’s RAM/CPU/NET restrictions, token faucets, and might encounter unstable BPs experimenting with non-standard settings. Private testnets mean having to maintain and debug your nodeos installation and running on high-end machines.</p><h2 id="testing-without-nodeos">Testing without nodeos</h2><p>It is possible to run tests without directly connecting to an existing nodeos node. There are several test frameworks that do this by either running a stripped down nodeos version or not requiring running a node at all.</p><p>This removed overhead makes them great for writing unit tests and allows for more flexibility as they are not restricted by the node behaviour. On the other hand, one cannot use them for deploying and running tests on a real EOSIO network.</p><h3 id="hydra">Hydra</h3><p>Hydra is one such testing framework that allows you to quickly get started writing unit tests.</p><p>Tests are written in JavaScript or TypeScript and allows you to use familiar JavaScript testing frameworks like Jest and Mocha.  In addition, it comes with some convenience features like bootstrapping test files, loading initial table contract data from JSON files, or being able to change the block time.</p><p>The reason it can do all this is that it runs on a customized EOSIO version (run by the Klevoya team) specifically designed for unit testing. Hydra therefore does not require any additional local setup at all, albeit it does need an internet connection.</p><p>This allows tests written in Hydra to be easily integrated into CI systems and the developer workflow. Along with its simple API and good documentation it's a great choice to test EOSIO smart contracts.</p><h3 id="check-out-hydra">Check out Hydra</h3><p>We hope this helps you see that there is an alternative to debugging those cryptic nodeos errors. Check out <a href="https://klevoya.com/hydra/">Hydra</a> and see how easy it is to get testing!</p><p>For more details on how Hydra compares to nodeos+cleos, EOS Native Tester, EOSIO Unit Tests &amp; Boost, or other EOSIO test frameworks, then download our <a href="https://klevoya.ck.page/which-eosio-test-environment/">EOSIO test framework comparison guide</a>.</p>]]></content:encoded></item><item><title><![CDATA[Klevoya receives EOS.VC grant to develop cybersecurity solution for EOSIO]]></title><description><![CDATA[Block.one announced that it has awarded Klevoya with a $50k grant to further develop it's smart contract verification system]]></description><link>https://klevoya.com/blog/klevoya-receives-grant-from-eos-vc/</link><guid isPermaLink="false">5ecff75936591d03eea55677</guid><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Thu, 28 May 2020 17:00:00 GMT</pubDate><media:content url="https://klevoya.com/blog/content/images/2020/05/EOS-VC-Grants-Recipients-Announcement-1024x585.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://klevoya.com/blog/content/images/2020/05/EOS-VC-Grants-Recipients-Announcement-1024x585.jpg" alt="Klevoya receives EOS.VC grant to develop cybersecurity solution for EOSIO"><p>EOSIO software developer Block.one announced today that it has <a href="https://eos.io/news/blockone-announces-eos-vc-grants-recipients/">awarded Klevoya with a $50k grant</a> to further develop it's smart contract verification system and foster the adoption of blockchain technology.</p><p>"At Klevoya we know that building quality dApps is complicated. So we made it our mission to help EOSIO dApp developers ship bug free, secure code. With the support from the EOS.VC grants program, we will increase the number of vulnerabilities that our <a href="https://klevoya.com/inspect">Inspect smart contract analysis tool</a> can detect,"  said Moti Tabulo, Founder of Klevoya. "Developers who are using Inspect and <a href="https://klevoya.com/hydra/">Hydra, our smart contract execution environment</a>, have found that checking for bugs in their smart contracts is not the painful experience it used to be," he added.</p>]]></content:encoded></item><item><title><![CDATA[Hello Hydra: the EOSIO test environment that just works]]></title><description><![CDATA[Introducing Hydra: a simple and fast EOSIO smart contract test and execution environment that allows you  quickly create and execute test cases without needing to maintain and run a local blockchain.]]></description><link>https://klevoya.com/blog/hello-hydra/</link><guid isPermaLink="false">5e9030f66cc2a203f2fa4500</guid><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Fri, 10 Apr 2020 00:20:00 GMT</pubDate><media:content url="https://klevoya.com/blog/content/images/2020/04/Hydra---Medium-poster.png" medium="image"/><content:encoded><![CDATA[<img src="https://klevoya.com/blog/content/images/2020/04/Hydra---Medium-poster.png" alt="Hello Hydra: the EOSIO test environment that just works"><p>At Klevoya our goal is to help EOSIO developers ship bug free, secure software. When we started talking to potential users, a common theme we heard was that developers spent too much time on verifying their smart contracts. This led us to explore an idea – what if testing just worked? What if instead of fiddling around with nodeos installs, running your own blockchain and multiple test scripts with cleos commands you could just open your IDE and start running tests. What if developers who want to test their smart contracts didn't have to also work as block producer administrators. What if developers could just write and run their test cases without setting up a blockchain on every computer they wanted to work on. What if test teams could easily integrate tests into a CI environment. What if test teams could rapidly spin up many hundreds of test variants.</p><p>Existing test environments solve some of these problems by wrapping your local EOSIO node's chain_api in some easier to use format. However you are still restricted to all the limitations and disadvantages of running a local blockchain; making sure it is installed locally, correctly set up, and running whenever you run your tests.</p><h3 id="introducing-hydra">Introducing Hydra</h3><p>Today, we're changing this. Hydra is a simple and fast EOSIO smart contract test and execution environment that allows you  quickly create and execute test cases without needing to maintain and run a local blockchain. The approach we have taken with Hydra is fundamentally different: Whilst it has similar APIs to existing testing tools, it eliminates all of the drawbacks of running a local blockchain by running a modified EOSIO node on our back-end which is specifically designed for testing. Hydra also comes with many convenience features (e.g. CLI to bootstrap tests and loading of smart contract tables from JSON files) that allow you to very easily write tests for your smart contracts.</p><h3 id="how-to-get-hydra">How to get Hydra</h3><p>You can get started using Hydra <a href="https://docs.klevoya.com/hydra/about/getting-started/">here</a>. Try it, we think you'll like it.</p>]]></content:encoded></item><item><title><![CDATA[So you want to check your smart contract for security bugs?]]></title><description><![CDATA[Smart contracts for the Ethereum and EOS blockchains are vulnerable to hacks... Use of automated analysis before deployment can resolve those issues.]]></description><link>https://klevoya.com/blog/check-smart-contract-for-bugs/</link><guid isPermaLink="false">5d7faa34bd978609d87b2c5d</guid><category><![CDATA[Tech]]></category><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Wed, 21 Aug 2019 16:06:39 GMT</pubDate><media:content url="https://klevoya.com/blog/content/images/2019/09/chaozzy-lin-AGpG03AlllE-unsplash.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://klevoya.com/blog/content/images/2019/09/chaozzy-lin-AGpG03AlllE-unsplash.jpg" alt="So you want to check your smart contract for security bugs?"><p><br>Smart contracts are programs that, once deployed, execute autonomously on blockchains. Depending on the blockchain being used (and the method of smart contract deployment), these smart contracts can be to a smaller or larger extent immutable. Immutable in the sense that once deployed they may not be modifiable by their creator.</p><p>If you've ever developed a significant piece of software then you know that deploying SW that is right the first time is extremely difficult as the SW you develop may contain a variety of bugs:</p><figure class="kg-card kg-image-card"><img src="https://klevoya.com/blog/content/images/2019/09/SmartContractAnalysis-BugSmall.png" class="kg-image" alt="So you want to check your smart contract for security bugs?"></figure><ul><li>Logical errors</li><li>Business errors</li><li>Security vulnerabilities</li></ul><p>While logical and business errors can be mitigated to some extent, security vulnerabilities in blockchain smart contracts can be much harder to recover from. Smart contracts often control crypto tokens that are pseudonymous and easily transferrable into liquid cash. This makes smart contracts very lucrative targets for bad actors looking to exploit any errors for quick profit at relatively lower risk of detection. In fact this is so common that the blockchain space is rife with incidents of bad actors exploiting smart contracts for <a href="https://www.technologyreview.com/s/612974/once-hailed-as-unhackable-blockchains-are-now-getting-hacked/">real world gain</a>.</p><h1 id="avoidance-is-better-than-cure">Avoidance is better than cure</h1><p>To avoid these exploits software developers are adapting techniques from off-chain development ranging from:</p><figure class="kg-card kg-image-card"><img src="https://klevoya.com/blog/content/images/2019/09/SmartContractAnalysis-MitigationSmall.png" class="kg-image" alt="So you want to check your smart contract for security bugs?"></figure><ul><li>Following smart contract development best practices</li><li>Auditing their contracts via a thorough review of the code</li><li>Subjecting their deployed contracts to white hat hackers</li></ul><p>In this piece we concentrate on the <em>second of these</em>; auditing your smart contracts to discover vulnerabilities before deployment. Auditing can take two forms. Firstly, what many in the space are familiar with is a manual review of the business and programming logic of your smart contract by a team of experts who are well versed in the state of the art of security vulnerabilities. These experts pore over the design and source code of your smart contracts with the aim of identifying any exploits. Depending on the size and scope of your smart contract this process may take anything from a week to a couple of months and cost anywhere from $50k to $500k. Smart contract auditing is a very specialised skill and so it is unlikely that many of the nascent projects in the space will have such an expert internally. They will typically rely on commissioning an external organisation to conduct their audits.</p><p>Even if the organisation commissioning the external security audit is well-funded, multiple iterations through such an audit are likely to be time and cost prohibitive. Organisations therefore leave such audits as the last step before deploying their smart contract to their blockchain of choice. In this world of agile development, this feels rather like going back to the old days of waterfall development. In short, manual security audits are simply not scalable.</p><p>A second approach which is now beginning to gain traction is the use of smart contract analysis tools that perform an automated review of the smart contract to identify vulnerabilities. Whilst the results from automated analysis may not catch the full breadth of issues exposed by a properly in-depth manual security audit, automated analysis does have the benefit that it is relatively lower cost and more convenient to execute than a manual audit. This allows automated analysis to be used within the development cycle to catch potential issues prior to the code being submitted for a final manual security audit. Automated analysis also enables developers to leverage the efforts of a handful of expert smart contract security researchers making automated analysis a much more scalable approach.</p><h1 id="automated-smart-contract-vulnerability-analysis-methods">Automated smart contract vulnerability analysis methods</h1><p>Automated vulnerability analysis of software programs is a well researched area with a rich pedigree in the off-chain world of web, desktop and enterprise software.  In designing an automated analysis approach, there are two main areas where trade-offs need to be made:</p><ul><li>Reproducibility: what steps need to be taken to exactly trigger a vulnerability define whether or not a vulnerability is reproducible. Some analysis approaches may not capture information on how to trigger a vulnerability and so any vulnerabilities identified may need to be manually verified.</li><li>Semantic insight: Insight into how and why a program, or parts of it, behaves.</li></ul><p>Typically automated analyses cannot optimise for both reproducibility and semantic insight. High reproducibility typically means low coverage as to make results reproducible an analysis needs to be able to understand how to reach the code under analysis; removing this requirement means that an analysis can achieve much higher code coverage. However the lack of reproducibility results in a high false positive rate (i.e. a false alarm for a vulnerability that does not actually exist). A high semantic understanding on the other hand may necessitate processing and storing of a large amount of data. Attempting an analysis that achieves both full semantic insight and identifies reproducible vulnerabilities may not be entirely different from executing the smart contract through all of its possible input permutations which is typically unscalable for a smart contract of sufficient complexity.</p><p>Automated vulnerability analysis can be divided into two types:</p><ul><li>Static vulnerability analysis: identifies defects <em>before</em> you run a smart contract</li><li>Dynamic vulnerability analysis: identifies vulnerabilities <em>after</em> you run a smart contract</li></ul><h2 id="static-vulnerability-analysis">Static vulnerability analysis</h2><p>Static vulnerability analysis on a smart contract is performed by reasoning about the code without actually executing it. Normally the analysis is done on some representation of the smart contract's source code, either the source code itself or some intermediate form that is above the object code. Occasionally static analysis can also be done on the object code.</p><p>Advantages of Static Analysis?</p><ul><li>It can achieve very good coverage of the smart contract under analysis and can often cover every possible execution path</li><li>It can be easier to trace the vulnerability back to the exact location in the code</li></ul><p>Static vulnerability analysis does have some drawbacks:</p><ul><li>Results are not reproducible: information on how to trigger the vulnerabilities identified is typically not captured and so the vulnerabilities may need to be verified to avoid false positives.</li><li>Lack semantic insight: They operate on simpler data domains and may have reduced insight into why a part of the smart contract has a vulnerability or what parts of the input cause misbehaviour</li></ul><h2 id="dynamic-vulnerability-analysis">Dynamic vulnerability analysis</h2><p>Dynamic vulnerability analysis is performed by executing the smart contract on a real or virtual processor and subjecting it to test inputs to verify its behaviour under a variety of conditions. Unit testing a smart contract to find errors is one of the most common method of dynamic analysis.</p><p>Automated dynamic analysis techniques are split into two main categories: concrete and symbolic execution.</p><ul><li>Concrete execution involves running the smart contract as normal against carefully crafted test cases provided by the user. A common dynamic concrete execution technique is fuzzing, where malformed input is provided to a smart contract in an attempt to discover a vulnerability. </li><li>Symbolic execution executes the smart contract in an emulated environment using symbolic variables and tracking the state of the smart contract throughout program execution. At each conditional branch the analyser follows every path and saves the path condition. The analyser can then use the accumulated path conditions to reason on how to exactly trigger an identified vulnerability.</li></ul><p>But how does dynamic analysis fare against static analysis?</p><p>Advantages of Dynamic analysis.</p><ul><li>Vulnerabilities identified are highly reproducible as you have the inputs or path conditions required to trigger the vulnerability</li><li>It allows for analysis of smart contracts in which you do not have access to the actual code.</li></ul><p>Drawbacks of Dynamic analysis.</p><ul><li>Fuzzers typically require carefully crafted test cases to avoid identifying only shallow vulnerabilities.</li><li>Similar to static analysis, fuzzers have limited semantic insight into what parts of the input caused a vulnerability to be tirggered. This makes it more difficult to trace a vulnerability back to the exact location in the code. Symbolic execution on the other hand offers high semantic insight. </li><li>With symbolic execution the number of condition paths causes an exponential increase in the possible paths to be explored limiting the complexity of smart contracts that can be analysed.</li></ul><p>As can be seen from above, both static and dynamic analysis techniques have different advantages and disadvantages. One technique cannot be said to be definitively better than the other. To take advantage of their different attributes we see some of the leading suppliers of smart contract analysis tools use both types of analyses in their offerings.</p><h1 id="top-vulnerability-analysis-tools-for-ethereum-and-eos">Top Vulnerability Analysis Tools for Ethereum and EOS</h1><p>Now that we have a fundamental understanding of the different smart contract vulnerability analysis methods, what tools are available to check your Ethereum and EOS smart contracts for bugs?</p><!--kg-card-begin: markdown--><ol>
<li><a href="https://mythx.io">MythX</a><br>
<img alt="So you want to check your smart contract for security bugs?" src="https://klevoya.com/blog/content/images/2019/09/mythxlogo.svg" style="width: 136px; height:127px"><br>
SaaS platform that combines static, fuzzing and dynamic symbolic analysis of Ethereum smart contracts. Developed by a Consensys spoke. Offers an API that tools (such as IDEs, web interfaces etc) can use to enable security scanning in their application. Pricing from 199 DAI per user.  <a href="https://mythx.io/plans">https://mythx.io/plans</a></li>
<li><a href="https://github.com/ConsenSys/mythril">Mythril</a><br>
<img alt="So you want to check your smart contract for security bugs?" src="https://klevoya.com/blog/content/images/2019/09/mythril_new.png" style="width: 136px; height:94px"><br>
Developed by some of the team that were behind MythX. Utilises dynamic symbolic execution. Open source and free to use.</li>
<li><a href="https://securify.chainsecurity.com/">Securify</a><br>
<img alt="So you want to check your smart contract for security bugs?" src="https://klevoya.com/blog/content/images/2019/09/chainsecurity.png" style="width: 136px; height:35px"><br>
Online and open-source security scanner for Ethereum smart contracts that performs static analysis. Online version is free to use, but requires signing over rights to submitted source code.</li>
<li><a href="https://github.com/trailofbits/manticore">Manticore</a><br>
<img alt="So you want to check your smart contract for security bugs?" src="https://klevoya.com/blog/content/images/2019/09/manticore.png" style="width: 128px; height:101px"><br>
Open source dynamic symbolic execution analysis tool. Can analyse Ethereum smart contracts and Linux ELF binaries. Appears to be actively maintained with multiple contributions to its Github repository over the last 3 months.</li>
<li><a href="https://tool.smartdec.net/">Smartcheck</a> Online and open source static analysis tool that translates Ethereum Solidity code into an XML based representation on which it checks against security patterns. Its Github repository does not show much sign of recent activity.</li>
<li><a href="https://github.com/quoscient/octopus">Octopus</a><br>
<img alt="So you want to check your smart contract for security bugs?" src="https://klevoya.com/blog/content/images/2019/09/logo-octopus.png" style="width: 136px; height:129px"><br>
Octopus supports basic analysis of smart contracts allowing contract disassembly, control flow analysis and conversion byte code into an Intermediate Representation. Although it is one of the few tools we found that supports both Ethereum's EVM and EOS' WASM byte code formats, it currently cannot run a vulnerability analysis. That is planned in the future through dynamic symbolic execution. Its Github repository does not show much sign of recent activity.</li>
</ol>
<!--kg-card-end: markdown--><h1 id="conclusion">Conclusion</h1><p>Automated vulnerability analysis is a burgeoning field that will help secure smart contracts.</p><p>There are a variety of tools available, but these primarily target the Ethereum ecosystem. We found only one tool that has minimal support for EOS.</p><p>Do you know of any tools that we should include in the list? Do you think automated analysis can be a substitute for manual review? Let us know what you think in the comments.</p>]]></content:encoded></item><item><title><![CDATA[Overview of the EOSIO WebAssembly Virtual Machine]]></title><description><![CDATA[EOSIO smart contracts are written in C++ and then compiled for execution using WebAssembly aka WASM which is a platform independent format. This post gives an overview of WASM virtual machine (VM) that makes this possible.]]></description><link>https://klevoya.com/blog/overview-of-the-eosio-webassembly-virtual-machine/</link><guid isPermaLink="false">5d7faa34bd978609d87b2c5f</guid><category><![CDATA[Tech]]></category><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Thu, 21 Mar 2019 14:32:12 GMT</pubDate><media:content url="https://klevoya.com/blog/content/images/2019/09/WASM-800x450.png" medium="image"/><content:encoded><![CDATA[<img src="https://klevoya.com/blog/content/images/2019/09/WASM-800x450.png" alt="Overview of the EOSIO WebAssembly Virtual Machine"><p>EOSIO programs are typically written in C++ and then compiled into a smart contract for execution on an EOSIO blockchain.</p><p>But did you know that C++ is not the only programming language that EOSIO programs can be written in? Some projects are working on Python and even Solidity based programs. These are all compiled down into platform independent code that can be run on the EOSIO WASM Virtual Machine (WAVM).</p><p>So the WAVM does not need to know anything at all about the high level programming language (C++, Python, Solidity etc). All it knows how to do is to execute its own binary instruction set called WebAssembly.</p><h1 id="what-is-webassembly">What is WebAssembly?</h1><p>The <a href="https://webassembly.github.io/spec/core/intro/introduction.html">project to develop</a> a new portable, size efficient binary format for the web was driven by the major browser vendors (Mozilla, Google, Apple and Microsoft). Apart from portability, WebAssembly's other design goals were for it to be:</p><ul><li>Fast: Able to execute at near native speed</li><li><a href="https://webassembly.org/docs/security/">Safe</a>: code executes in a sandboxed environment and eliminating dangerous features </li><li><a href="https://webassembly.org/docs/portability/">Hardware independent</a>: Implementable by web browsers and other completely different execution environments such as datacenters, IoT devices, mobile/desktops etc </li><li>Not break the web (allow calls/bindings to JavaScript)</li><li>A human-editable text format that is convertible to/from the binary format</li></ul><p>These goals, as well as the large browser ecosystem working to continuously improve it, make WASM a great choice for smart contract execution platforms. Apart from EOSIO, WASM is also planned to be used by Ethereum.</p><h2 id="the-eosio-wavm">The EOSIO WAVM</h2><p>EOSIO's WASM Virtual Machine (WAVM) is based on <a href="https://github.com/AndrewScheidecker/WAVM">Andrew Scheidecker's standalone WAVM</a>. </p><h3 id="stack-machine">Stack Machine</h3><p>The WAVM is a stack machine with two main components:</p><ol><li>a last-in, first-out stack is used to hold temporary values. Most of the WAVM instructions therefore assume that operands will be taken from the stack and results placed back on the stack.</li><li>A program counter that controls the execution of the program and is modified explicitly by control instructions and implicitly advanced when non-control instructions execute.</li></ol><p>This is in contrast to most modern computers that implement a register machine where temporary values are held in a set of registers.Advantages of using a stack machine over a register machine are that stack machines allow for:</p><ul><li>Compact object code: as instructions deal with values from the stack and do not need to select which registers to use</li><li>Simple compilers: as no register management is needed making code generation fairly trivial</li><li>Simple interpreters: particularly for Virtual Machines interpreters for stack machines are simpler as the logic for handling memory accesses is just in one place</li><li>Easier control flow: control flow is expressed as structured constructs like blocks, if and loops that have clear labels at their beginning and end. The WAVM has  Implementing control flow like this makes it very easy to compile and manipulate WASM and verify the correctness of control flow in a WASM program.</li></ul><h2 id="a-simple-execution-example">A simple execution example</h2><p>We can now go review a simple example to illustrate the whole flow from source code to WASM to execution of that code in the WAVM.As prerequisites we assume that you have:</p><ul><li>Installed the <a href="https://github.com/EOSIO/eosio.cdt">EOSIO Contract Development Toolkit</a> (CDT)</li><li>Have access to the Web Assembly Binary Toolkit (WABT pronounced wabbit). You can do this by running the eosio-wasm2wast/eosio-wast2wasm binaries that come with CDT. Alternatively you can also download and build the generic WABT version from <a href="https://github.com/WebAssembly/wabt">https://github.com/WebAssembly/wabt</a>. (A cursory examination seems to indicate that this versions are compatible if you disable "Generate Names" and "Fold Expressions")</li></ul><h3 id="compiling-hello">Compiling Hello</h3><p>For this example we'll be compiling the basic Hello World program:</p><!--kg-card-begin: markdown--><pre><code class="language-cpp">#include &lt;eosiolib/eosio.hpp&gt;
#include &lt;eosiolib/print.hpp&gt;


using namespace eosio;


class hello : public contract {
  public:
      using contract::contract;


      [[eosio::action]]
      void hi( name user ) {
         require_auth( user );
         print( &quot;Hello, &quot;, user);
      }
};


EOSIO_DISPATCH( hello, (hi))
</code></pre>
<!--kg-card-end: markdown--><p>Running the eosio C++ compiler eosio-cpp:</p><!--kg-card-begin: markdown--><pre><code class="language-bash">eosio-cpp -o hello.wasm hello.cpp
</code></pre>
<!--kg-card-end: markdown--><!--kg-card-begin: html--><pre><code class="language-bash">eosio-cpp -o hello.wasm hello.cpp</code></pre><!--kg-card-end: html--><p>This takes the C++ source file and converts it into an intermediate representation (IR) using a compiler tool chain called LLVM. LLVM performs some optimisations and then a back-end converts from the LLVM IR into WASM.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://klevoya.com/blog/content/images/2019/09/Compilation-Flow.png" class="kg-image" alt="Overview of the EOSIO WebAssembly Virtual Machine"><figcaption>C++ to WASM compilation flow</figcaption></figure><p>We get a WASM file, hello.wasm which is in binary. To make it readable we need to convert it into a WASM text format as follows:</p><!--kg-card-begin: markdown--><pre><code class="language-bash">eosio-wasm2wast hello.wasm -o hello.wast
</code></pre>
<!--kg-card-end: markdown--><p>This WAST file is typically huge (approximately 900 lines) so we will only concentrate on the first 50 or so lines here to illustrate some important concepts.</p><h3 id="wasm-sections">WASM sections</h3><p>The WebAssembly module is composed of several sections. Some sections are required in all WASM modules and some are optional (you may see the optional modules appearing at the end of the WAST file).<strong>Required:</strong></p><ol><li>Type. Contains the function signatures for functions defined in this module and any imported functions.</li><li>Function. Gives an index to each function defined in this module.</li><li>Code. The actual function bodies for each function in this module.</li></ol><p><strong>Optional:</strong></p><ol><li>Export. Makes functions, memories, tables, and globals available to other WebAssembly modules and JavaScript. This allows separately-compiled modules to be dynamically linked together. This is WebAssembly’s version of a .dll.</li><li>Import. Specifies functions, memories, tables, and globals to import from other WebAssembly modules or JavaScript.</li><li>Start. A function that will automatically run when the WebAssembly module is loaded (basically like a main function).</li><li>Global. Declares global variables for the module.</li><li>Memory. Defines the memory this module will use.</li><li>Table. Makes it possible to map to values outside of the WebAssembly module, such as JavaScript objects. This is especially useful for allowing indirect function calls.</li><li>Data. Initializes imported or local memory.</li><li>Element. Initializes an imported or local table.</li></ol><h3 id="section-examples">Section examples</h3><p>For our Hello.wast file this looks like so:</p><!--kg-card-begin: markdown--><pre><code class="language-wasm">(module
  (type (;0;) (func (param i32 i64)))
  (type (;1;) (func (result i32)))
  (type (;2;) (func (param i32 i32) (result i32)))
  (type (;3;) (func (param i32 i32)))
  (type (;4;) (func (param i32 i32 i32) (result i32)))
  (type (;5;) (func (param i64)))
  (type (;6;) (func (param i32)))
  (type (;7;) (func))
  (type (;8;) (func (param i64 i64 i64)))
  (type (;9;) (func (param i64 i64 i32) (result i32)))
  (type (;10;) (func (param i32) (result i32)))
  (import &quot;env&quot; &quot;action_data_size&quot; (func (;0;) (type 1)))
  (import &quot;env&quot; &quot;read_action_data&quot; (func (;1;) (type 2)))
  (import &quot;env&quot; &quot;eosio_assert&quot; (func (;2;) (type 3)))
  (import &quot;env&quot; &quot;memcpy&quot; (func (;3;) (type 4)))
  (import &quot;env&quot; &quot;require_auth&quot; (func (;4;) (type 5)))
  (import &quot;env&quot; &quot;prints&quot; (func (;5;) (type 6)))
  (import &quot;env&quot; &quot;printn&quot; (func (;6;) (type 5)))
  (import &quot;env&quot; &quot;set_blockchain_parameters_packed&quot; (func (;7;) (type 3)))
  (import &quot;env&quot; &quot;get_blockchain_parameters_packed&quot; (func (;8;) (type 2)))
  (import &quot;env&quot; &quot;memset&quot; (func (;9;) (type 4)))


  (table (;0;) 2 2 anyfunc)
  (memory (;0;) 1)
  (global (;0;) (mut i32) (i32.const 8192))
  (global (;1;) i32 (i32.const 16700))
  (global (;2;) i32 (i32.const 16700))
  (export &quot;memory&quot; (memory 0))
  (export &quot;__heap_base&quot; (global 1))
  (export &quot;__data_end&quot; (global 2))
  (export &quot;apply&quot; (func 11))
  (elem (i32.const 1) 12)
  (data (i32.const 8192) &quot;Hello, \00&quot;)
  (data (i32.const 8202) &quot;read\00malloc_from_freed was designed to only be called after _heap was completely allocated\00&quot;))
</code></pre>
<!--kg-card-end: markdown--><p>Here we see that there are 10 function signatures and indices for the functions in this WASM file</p><figure class="kg-card kg-image-card"><img src="https://klevoya.com/blog/content/images/2019/09/wasm-function-signature-large--1-.png" class="kg-image" alt="Overview of the EOSIO WebAssembly Virtual Machine"></figure><p>These signatures are similar to function prototypes and define the expected inputs and outputs for each type of function.</p><p>There are also some imported functions  such as</p><!--kg-card-begin: markdown--><pre><code class="language-wasm">(import &quot;env&quot; &quot;read_action_data&quot; (func (;1;) (type 2)))  
(import &quot;env&quot; &quot;require_auth&quot; (func (;4;) (type 5)))
(import &quot;env&quot; &quot;prints&quot; (func (;5;) (type 6)))
</code></pre>
<!--kg-card-end: markdown--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://klevoya.com/blog/content/images/2019/09/wasm-import-large.png" class="kg-image" alt="Overview of the EOSIO WebAssembly Virtual Machine"><figcaption>Imported type 2 function</figcaption></figure><p>We can also see our print statement being initialised in memory:  </p><!--kg-card-begin: markdown--><pre><code class="language-wasm">(data (i32.const 8192) &quot;Hello, \00&quot;)
</code></pre>
<!--kg-card-end: markdown--><p>The beginning of the code section contains the actual function bodies for each function in this module. Looking back at the function definitions we see that there is one function exported which has an index of function 11:</p><!--kg-card-begin: markdown--><pre><code class="language-wasm">(export &quot;apply&quot; (func 11))
</code></pre>
<!--kg-card-end: markdown--><p>This is the apply function that is called when an action is issued to this smart contract:</p><!--kg-card-begin: markdown--><pre><code class="language-wasm">  (func (;11;) (type 8) (param i64 i64 i64)
    (local i32)
    get_global 0
    i32.const 16
    i32.sub
    tee_local 3
    set_global 0
    call 10
    block  ;; label = @1
      get_local 1
      get_local 0
      i64.ne
      br_if 0 (;@1;)
      get_local 2
      i64.const 7746191359077253120
      i64.ne
      br_if 0 (;@1;)
      get_local 3
      i32.const 0
      i32.store offset=12
      get_local 3
      i32.const 1
      i32.store offset=8
      get_local 3
      get_local 3
      i64.load offset=8
      i64.store
      get_local 1
      get_local 1
      get_local 3
      call 13
      drop
    end
</code></pre>
<!--kg-card-end: markdown--><h2 id="deploy-your-smart-contract-">Deploy your smart contract!</h2><p>The last thing to do after compiling your smart contract is to send it to the blockchain by issuing a set code transaction using the cleos command line tool.</p><!--kg-card-begin: markdown--><pre><code class="language-bash">cleos set contract hello $YOURDIRECTORY/hello -p hello@active
</code></pre>
<!--kg-card-end: markdown--><p>When the block producer (BP) node receives the set code action it proceeds to create an instance of the smart contract WebAssembly module in the EOSIO blockchain's RAM. Instantiating the WebAssembly module is what makes it functional and the BP node does so by resolving memory references, linking external C++ functions and giving access to the exported functions like the apply() function. </p><p>Once the BP node completes this step the smart contract WebAssembly module will be on the chain's RAM and any BP node can then access actions intended for the smart contract.</p><h2 id="trigger-an-action-">Trigger an action!</h2><p>Now that the smart contract is on chain, you can trigger it by sending an action to the smart contract using cleos:</p><!--kg-card-begin: markdown--><pre><code class="language-bash">cleos push action hello hi '[&quot;bob&quot;]' -p bob@active
</code></pre>
<!--kg-card-end: markdown--><p>The message will be sent to the BP node which will load the smart contract WebAssembly instance and call the apply() function.</p><p>If you are curious, here's how the WebAssembly virtual machine would execute the first few instructions in the function:</p><!--kg-card-begin: markdown--><pre><code class="language-wasm">  (func (;11;) (type 8) (param i64 i64 i64)
    (local i32)
    get_global 0
    i32.const 16
    i32.sub
</code></pre>
<!--kg-card-end: markdown--><ul><li>get_global 0: gets the value of the global variable at index 0 and pushes it onto the stack</li><li>i32.const 16: Pushes the constant value sixteen onto the stack</li><li>i32.sub: remember we said WebAssembly was a stack machine earlier? With a stack machine all values an operand needs are pushed onto the stack before the operation is performed. The sub instruction knows that it needs two operands and will simply take the last two values from the top of the stack and return the result to the top of the stack. This means that instructions can be short (one byte for sub) as the instructions don't need to specify source or destination addresses which makes for more compact WASM files.</li></ul><p>Finally after the whole WebAssembly module has been executed, you should then see the smart contract reply:</p><blockquote>Hello, bob</blockquote><h2 id="closing-thoughts">Closing thoughts</h2><p>WebAssembly allows smart contract developers to write EOSIO applications in C++ (and in future other languages such as Solidity and Python) and ensures that the resulting code can run efficiently across different BP nodes.</p><p>It is perfectly possible for a smart contract developer to deply a distributed application (dApp) without knowledge of WebAssembly or how the WAVM works. However understanding how it works may help you to tackle difficult problems from time to time and deal better with security vulnerabilities in your smart contract.</p>]]></content:encoded></item><item><title><![CDATA[How to hire top smart contract developers for your blockchain project]]></title><description><![CDATA[Here are 4 ways that will help you recruit 10x better smart contract developers for your EOS, Ethereum, Tron blockchain startup. ]]></description><link>https://klevoya.com/blog/hire-smart-contract-developers/</link><guid isPermaLink="false">5d7faa34bd978609d87b2c5e</guid><category><![CDATA[Entrepreneur]]></category><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Tue, 29 Jan 2019 17:00:56 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p><img src="https://klevoya.com/blog/content/images/2019/09/joel-spolsky-10x-programmers-1.png" alt="if you try to skimp on programmers, you’ll make crappy software, and you won’t even save that much money - Joel Spolsky"></p>
<!--kg-card-end: markdown--><p>Joel Spolsky <a href="https://www.joelonsoftware.com/2005/07/25/hitting-the-high-notes/">wrote that line</a> more than a decade ago and it still rings true now. </p><p>To succeed with your blockchain project through the current crypto winter you are going to have to excel at finding the mythical 10x developers. You'll have to out-recruit those well funded projects that used the last crypto boom to amass a warchest of funds.</p><p>Here are 4 ways that will help you rise above the rest - to recruit the best smart contract developers for your crypto startup.</p><h3 id="-1-start-with-the-why">#1 Start with the why</h3><!--kg-card-begin: markdown--><p>In his TED talk <a href="https://www.ted.com/talks/simon_sinek_how_great_leaders_inspire_action?language=en">Simon Sinek</a> explains how leaders inspire action by focusing on why.</p>
<!--kg-card-end: markdown--><p><br>As a founder your job is to figure out why your company is differentiated and what is your Unique Recruitment Proposition.</p><p>This is not the same as your product's Unique Value Proposition - although that can be one of your recruitment propositions. In addition to you product, your recruitment propositions could be things like the impact employees can have in the role, your culture, work environment etc. Beware of using salary on its own as a differentiator. There will always be someone who can pay better than you can!</p><h3 id="-2-treat-your-recruitment-process-like-a-product">#2 Treat your recruitment process like a product</h3><p>You <a href="lhttp://theleanstartup.com/">iterate your product development</a>. Apply that same mindset for your recruitment process. </p><p><a href="https://firstround.com/review/turbocharge-your-recruiting-machine-heres-how/">Measure your recruitment funnel</a> and seek feedback from candidates about what does or doesn't work throughout your funnel.</p><p>Use that feedback to learn and continually improve your recruitment process.</p><h3 id="-3-look-critically-at-how-you-source-candidates">#3 Look critically at how you source candidates</h3><p>The best candidates are probably not actively looking for new roles. Those 10x engineers might be on the lookout for something new, but they are not out there scouring job boards. So how do you make sure that your role has the most chance of being seen?</p><!--kg-card-begin: markdown--><ul>
<li>
<p>Open source code: review open source projects on places like Github in fields related to yours. Note down the contributors who consistently put out well thought out changes, tools etc.</p>
</li>
<li>
<p>Chat channels: Every smart contract platform worth its salt has a developer chat channel on Telegram, Discord or Slack. Find out where your developer community hangs out and see who is posting and answering questions frequently. The way someone replies to posts can give you great insight into their thought process, problem solving and writing skills. Just be careful to ensure your posts meet the discussion's guidelines.</p>
<ul>
<li>
<p>Some of those will be employed directly by the platform and possibly out of your league. However good developers know other good developers and so if you approach them in the right way they may be able to refer you to someone who is open for recruitment.</p>
</li>
<li>
<p>There will often be developers who spend considerable amounts of time answering others questions for the love of the project. These are good candidates who may be open to a direct approach.</p>
</li>
</ul>
</li>
<li>
<p>Hackathons: Many smart contract platforms arrange hackathons to build out their base of developers (e.g. <a href="https://eoshackathon.io/">EOSIO</a>, <a href="https://www.hedera18.com/hackathon">Hedera</a>, <a href="https://klevoya.com/blog/hire-smart-contract-developers/%5Bhttps://tronaccelerator.io/">Tron</a>). These hackathons attract a wide range of people who are united about their passion about learning about the smart contract platform. Both attendees and mentors can be a good source of potential candidates.</p>
</li>
<li>
<p>Crypto events/meetups: many founders I see speaking at blockchain meetups focus their presentations as investor pitches missing out on another key audience that will be attending; potential recruits. If you can, contact the organiser beforehand to get an understanding of the audience demographic. If the crowd is more developer friendly then your standard VC pitch deck won't do. Focus your presentation more on your uniquness as a company whilst mixing in what interesting problems you're resolving.</p>
</li>
<li>
<p>Other chains: Enough of the crypto tribalism! Yes an Ethereum solidity developer may not be familiar with C++ and how smart contracts are deployed on EOSIO. But any decent developer should be able to learn a new programming language and smart contract architecture; having programmed any smart contract platform gives them a leg up.</p>
</li>
</ul>
<!--kg-card-end: markdown--><p>I come from the EOSIO space, and the following are good places to put the above into practice:</p><ul><li>Telegram groups: <a href="https://t.me/eos_jobs">https://t.me/eos_jobs</a>, <a href="https://t.me/eos_opportunities">https://t.me/eos_opportunities</a>, <a href="https://t.me/joinchat/Esi1OkPktgcFeJ3Lmlcrqg">https://t.me/joinchat/Esi1OkPktgcFeJ3Lmlcrqg</a> (developer chat)</li><li>Reddit: <a href="https://www.reddit.com/r/eosdev">https://www.reddit.com/r/eosdev</a></li></ul><h3 id="-4-have-your-interview-process-mirror-the-work-they-will-do">#4 Have your interview process mirror the work they will do</h3><p>I'm not a fan of online coding interview style tests. At most use those for an initial screen, but I find they give a weak signal about a candidate's capabilities. Similarly questions about algorithms perhaps only help if you are recruiting someone to spend time doing that.</p><p>I have found great effectiveness in having your interviewees complete a piece of work that approximates the work they will be doing with you. Think out of the box. It could be anything from a design guide, debugging a piece of SW or even developing a simple smart contract on a test net. There is a small upfront investment in getting these kinds of tests set up. But once you do, then you are able to quickly filter out for people who get things done.</p><h3 id="how-about-you">How about you?</h3><p>What's your favourite way to recruit smart contract developers for your blockchain project? Let me know in the comments.</p>]]></content:encoded></item><item><title><![CDATA[Battle of the EOS sister chains: MainNet vs Worbli vs Telos - Part 2]]></title><description><![CDATA[In Part 1 we covered what an EOSIO sister chain was. In this piece we look at how the two pre-eminent contenders, Telos and Worbli compare to the EOS MainNet. Let the battle commence!]]></description><link>https://klevoya.com/blog/battle-of-the-eos-sister-chains-mainnet-vs-worbli-vs-telos-part-2/</link><guid isPermaLink="false">5d7faa34bd978609d87b2c5c</guid><category><![CDATA[Sister chain]]></category><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Wed, 23 Jan 2019 12:31:23 GMT</pubDate><media:content url="https://klevoya.com/blog/content/images/2019/09/eos-main-net-vs-worbli-vs-telos.png" medium="image"/><content:encoded><![CDATA[<figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://klevoya.com/blog/content/images/2019/01/eos-main-net-vs-worbli-vs-telos.png" class="kg-image" alt="Battle of the EOS sister chains: MainNet vs Worbli vs Telos - Part 2"><figcaption>EOS MainNet vs the Telos and Worbli sister chains</figcaption></figure><img src="https://klevoya.com/blog/content/images/2019/09/eos-main-net-vs-worbli-vs-telos.png" alt="Battle of the EOS sister chains: MainNet vs Worbli vs Telos - Part 2"><p>In <a href="https://bloqsentry.com/battle-of-the-eos-sister-chains-mainnet-vs-worbli-vs-telos/">Part 1</a> we covered what an EOSIO sister chain was. In this piece we look at how the two pre-eminent contenders, Telos and Worbli compare to the EOS MainNet. Let the battle commence!</p><h2 id="eos-mainnet">EOS MainNet</h2><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://klevoya.com/blog/content/images/2019/09/eosio_logo.png" class="kg-image" alt="Battle of the EOS sister chains: MainNet vs Worbli vs Telos - Part 2"><figcaption>The EOSIO chestahedron which is named after its creator Frank Chester. It's unlikely he is aware of the range of copy cat logos this has spawned in the EOSIO sphere.</figcaption></figure><p>More information: no single website</p><p>Network status: Launched early June 2018</p><p>Value proposition: the original EOSIO based chain.</p><h3 id="pros">Pros</h3><ol><li>The big sister of them all. As such it captures most of the mindshare from Block Producers (BPs), investors (it has the highest market cap of all EOSIO chains by a huge margin), distributed application (dApp) developers and users.</li><li>Only chain that can lay claim to the EOS brand.</li><li>Perhaps the only EOSIO chain that makes it economically viable to run a BP node on. With multiple BPs running on other sister chains, the MainNet may effectively subsidise the sister chains.</li></ol><h3 id="cons">Cons</h3><ol><li>It's size and status means that it has limited range for innovation across the technical and governance aspects that differentiate sister chains. </li></ol><h2 id="telos">Telos</h2><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://klevoya.com/blog/content/images/2019/09/telos_logo.png" class="kg-image" alt="Battle of the EOS sister chains: MainNet vs Worbli vs Telos - Part 2"><figcaption>The Telos EOSIO sister chain. Hoping to grow their acorn into a mighty oak?</figcaption></figure><p>More information: <a href="https://telosfoundation.io">https://telosfoundation.io</a></p><p>Network launch status: <a href="https://medium.com/@teloslogical/telos-mainnet-activates-at-block-1-000-040-c0af0d65bd41">Launched December 2018</a></p><p>Value proposition: Learnt from the mistakes that EOS MainNet made at launch, more developer friendly.</p><h3 id="pros-1">Pros</h3><ol><li>Economic decentralization – Telos based its genesis snapshot on that of EOS, but capped each individual account to a maximum of 40k EOS (this is a cap on the genesis accounts only, in future a single account can acccumulate more than 40k TELOS). Potentially this means that voters are incentivised to vote in the early days as their vote counts for more. </li><li>DApp friendly: a) Lower cost of dApp deployment: TLOS currently trades at around 20-25x lower than EOS making network (CPU, NET and RAM) resources a steal for dApp developers. b) No RAM speculation: have an elected <a href="https://medium.com/@teloslogical/telos-ram-public-guidance-price-4d240dfb5fa6">RAM Admin Director</a> who can suggest RAM policy to the BPs and can also purchase/sell RAM to meet their RAM goals. c) Features dedicated to developers: IPFS storage, regular user token holder snapshots (that allow developers to choose which one to base their airdrops on) </li><li>No zombie BPs and equitable pay: Standby BPs are rotated into the top 21 every 3-7 days so they actually need to be ready to produce blocks. On pay, the top 21 BPs get the same pay, whilst an additional 30 standby BPs get 50% of what the top 21 get.</li><li>Proprietary dApps are allowed: EOS MainNet requires all dApps to be open-sourced (although many do not follow this rule), TELOS allows closed source/proprietary dApps.</li></ol><h3 id="cons-1">Cons</h3><ol><li>BP pay is unviable: the TLOS token price is too low to make running a BP cost-effective: some estimates that running an EOS BP has a break even token price of ~$1.75 to $2. With a token price 1/25 of that, it's hard to see how BPs operating solely on Telos can fund their operations</li><li>Will it overcome voter apathy: Not clear whether voters will still be incentivised to vote despite the capped voter accounts.</li><li>CPU issues follow from MainNet: Telos might have solved the RAM problem, but the rampant RAM speculation on MainNet has quietened down. What plagues MainNet now is a regular lack of CPU resources for their Apps to run. Telos does not look like it will offer anything novel in this regard except perhaps for the implementation of REX as and when block.one release the feature.</li><li>Smaller user pool, lack of brand name recognition: EOS MainNet has the majority of investor and user interest.</li></ol><h2 id="worbli">Worbli</h2><!--kg-card-begin: html--><p align="center">
    <figure class="kg-card kg-image-card">
        <img src="https://klevoya.com/blog/content/images/2019/09/worbli_logo.png" class="kg-image" style="width: 300px; height:300px" alt="Battle of the EOS sister chains: MainNet vs Worbli vs Telos - Part 2">
        <figcaption>The Worbli EOS sister chain. Not a chestahedron in sight, though we would love to get the design brief for this one as it's not clear what it's meant to be depicting.
        </figcaption>
    </figure>
</p><!--kg-card-end: html--><p>More information: <a href="https://worbli.io/">https://worbli.io/</a></p><p>Network launch status: <a href="https://medium.com/@WORBLI/worbli-is-live-portal-update-b0d168c7e4aa">Launched November 2018</a></p><p>Value proposition: On a mission to enable opportunity. Worbli wants to build the infrastructure for an honest, efficient and accessible financial system. By developing the world’s most cost-effective and developer-friendly, consumer and enterprise blockchain platform.</p><h3 id="pros-2">Pros</h3><ol><li>A walled garden with a user base of AML/KYCed customers: to sign up for a Worbli account requires each user to undergo Know Your Customer (KYC) and Anti-Money Laundering (AML) checks. This will reduce the friction for businesses (primarily financial ones that need AML/KYC).</li><li>Low friction finance setup for companies new to blockchain: Worbli initially promised they would be setting up a digital-crypto bank Gamma bank. They soon came to realise that that would be a huge undertaking which would require resolving regulatory issues across multiple jurisdictions. The ambition has now been tempered somewhat to instead introduce banking like facilities starting with a chain wide crypto-fiat exchange. In theory, once a dApp has been accepted onto Worbli then they should already be able to trade their token for fiat. For companies that have had to deal with delays in getting a bank account, or their token listed on exchanges, this could be a killer feature.</li><li>Proprietary dApps are allowed: EOS MainNet requires all dApps to be open-sourced (although many do not follow this rule), Worbli allows closed source/proprietary dApps.</li><li>Business centric approach: contrary to other EOS sister chains Worbli appears to be following a more traditional business development strategy where they seek to identify and bring value added partners to their network. This is in keeping with their strategy for a curated experience.</li></ol><h3 id="cons-2">Cons</h3><ol><li>Centralised for 2 years: for the first 2 years of its operation the Worbli Foundation will exert control of the network directing everything, from which BPs can produce, through to which applications are allowed on the network (only the Worbli foundation can delegate RAM to dApps). Voting for the BPs and Foundation members is currently locked and will not be open until the 2 year period elapses.</li><li>BP pay might be unviable: similar to Telos, the current value of the WBI token is too low to make producing blocks solely for Worbli unviable. However, it is not clear to what extent the Worbli Foundation is offering incentives to BPs to produce on their network.</li><li>Opaque governance model: at the time of publishing this post Worbli had yet to issue their Governance structure and documentation. This post will be updated once they do.</li></ol><h2 id="and-the-winner-is">And the winner is</h2><p>It's still early days with the launch of EOS sister chains. New sister chains seem to crop up monthly with sometimes little to differentiate them. At the moment if your dApp needs the user base, investor community and mindshare etc then the EOS MainNet has to be your first port of call. Telos has some interesting developer centric features that may make it the preferred chain for early developers. If you are developing a finance based application in a heavily regulated industry then Worbli's model for a pre-KYCed/AMLed userbase could be very attractive. However the current lack of public clarity on its governance structure may give some room for pause.</p><p>However, with EOSIO based dApps able to run on any EOSIO chain, then dApps may see the choice of whether to run on EOS or a sister chain as closer to an internationalisation feature. </p><p>Just as savvy web Apps choose to launch first in Canada, do all their learning and iteration and then re-launch in the USA, we may see dApps apply a similar market launch strategy. Deploy on a sister chain like Telos first where resources are cheap, prove some of the business and financial model and then re-launch on MainNet to access the larger user and investor base there. </p>]]></content:encoded></item><item><title><![CDATA[Battle of the EOS sister chains: MainNet vs Worbli vs Telos - Part 1]]></title><description><![CDATA[Why are we seeing so many EOS sister chains? Which one of these chains will win the battle for users and developers?]]></description><link>https://klevoya.com/blog/battle-of-the-eos-sister-chains-mainnet-vs-worbli-vs-telos/</link><guid isPermaLink="false">5d7faa34bd978609d87b2c5b</guid><category><![CDATA[Sister chain]]></category><dc:creator><![CDATA[M Tabulo]]></dc:creator><pubDate>Wed, 16 Jan 2019 19:06:39 GMT</pubDate><media:content url="https://klevoya.com/blog/content/images/2019/09/battle-sister-chain.png" medium="image"/><content:encoded><![CDATA[<h2 id="what-sisters">What sisters?</h2><img src="https://klevoya.com/blog/content/images/2019/09/battle-sister-chain.png" alt="Battle of the EOS sister chains: MainNet vs Worbli vs Telos - Part 1"><p>If you’re new to the EOS world you may have heard the words “sister chain” and “side chain” crop up in conversations. <br><br>First, a bit of background. <a href="https://block.one">Block.one</a> develops the EOSIO open source blockchain software, but has been very clear that they will not run any EOSIO based blockchain network. Instead, they view themselves as a provider of EOSIO software that will enable a potential multitude of EOSIO based networks.<br><br>When block.one released the EOSIO software in June 2018, it was then taken by a group of candidate Block Producers who launched what has since come to be termed the EOS main network (aka MainNet) as the only network with the “EOS” token that is listed on various cryptocurrency exchanges. block.one has since then come out to say that they encourage multiple EOSIO based blockchain networks based on its reference implementation. Coming from the Ethereum world where there is - for all intents and purposes - only one public and active Ethereum network [1] this concept can be a bit counter-intuitive to understand. Having multiple EOSIO chains is not necessarily a bad thing. In fact, as we will see it enables a diversity of chains that cater to particular niches.<br><br>Which brings us to sister and side chains. Terminology for what differentiates a sister and side chain varies, but we would propose some simple definitions:</p><ul><li>Side chain: any chain that uses the same token and token issuance as the EOS MainNet</li><li>Sister chain: any chain that has its own token and has a different token issuance to the EOS MainNet.</li></ul><p>A side chain therefore can be seen as an extension of the EOS MainNet with the same governance model and the same (or a subset) Community as the MainNet but perhaps only differing by some technical parameters such as how CPU and RAM is managed and priced.</p><p>For side chains to be useful, they will need to be able to synchronise regularly with the MainNet. For this Inter Blockchain Communication (IBC) is needed. Block.one has not publicly released any roadmap for IBC. Until they do side chains are a useful theoretical concept that has yet to be seen in practice. </p><h2 id="why-do-we-need-sister-chains-again">Why do we need sister chains again?</h2><p>In a word “differentiation”. Side chains differ technically but will adopt the same governance model that the MainNet does. Launching a sister chain allows for differentiation technically AND on the more squidgy Governance side. <br><br>This means that sister chains can tweak all of the following parameters to better suit their perceived dApp and Community audience:</p><ul><li>Governance</li><li>Choice of Block Producers</li><li>Dispute Resolution model</li><li>Token holders</li><li>Technical: Resource management (CPU, RAM and NET) and Source licensing</li></ul><h2 id="the-eos-family">The EOS Family</h2><p>It feels like every month there is a new EOS sister chain being launched. In no particular order here are the ones we know of. </p><ol><li><a href="https://everipedia.org/">Everipedia</a></li><li><a href="https://www.ono.chat/en/">ONO</a></li><li><a href="https://www.telosfoundation.io/">Telos</a></li><li><a href="https://wax.io/">Wax</a></li><li><a href="https://worbli.io/">Worbli</a></li><li><a href="https://www.eosforce.io/">EOS Force</a></li><li><a href="https://europechain.io/">EuropeChain</a></li><li><a href="https://enumivo.org/">Enumivio</a></li><li><a href="https://www.evolutionos.com/">EvolutionOS</a></li><li><a href="https://strongblock.io">StrongBlock</a>?</li><li><a href="https://boscore.io/">BOS Core</a></li></ol><h2 id="conclusion">Conclusion</h2><p>EOS Sister chains are positively encouraged. Will this lead to diffraction of the developer and user community? Or is it is a benefit? As a developer which one do you launch your dApp to?</p><p>In the next piece we profile 3 contenders; MainNet, Worbli and Telos. Stay tuned!</p><p>Know of a sister chain that we’ve missed? Let us know in the comments.</p><p>[Update] Part 2 of this series can be found <a href="https://bloqsentry.com/battle-of-the-eos-sister-chains-mainnet-vs-worbli-vs-telos-part-2/">here</a>.</p><p>[1] Sure there’s Ethereum Classic, but the market cap of ETC is 20x smaller than that of ETH so we can disregard it.</p>]]></content:encoded></item></channel></rss>