<?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 Joseph Delong on Medium]]></title>
        <description><![CDATA[Stories by Joseph Delong on Medium]]></description>
        <link>https://medium.com/@josephdelong?source=rss-eea4e29061a4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*w0jEg4TmRAX8U974.jpg</url>
            <title>Stories by Joseph Delong on Medium</title>
            <link>https://medium.com/@josephdelong?source=rss-eea4e29061a4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 22:27:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@josephdelong/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[Ethereum 2.0 Deposit Merkle Tree]]></title>
            <link>https://medium.com/@josephdelong/ethereum-2-0-deposit-merkle-tree-13ec8404ca4f?source=rss-eea4e29061a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/13ec8404ca4f</guid>
            <category><![CDATA[sparse-merkle-tree]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[merkle-tree]]></category>
            <category><![CDATA[validator]]></category>
            <category><![CDATA[deposit]]></category>
            <dc:creator><![CDATA[Joseph Delong]]></dc:creator>
            <pubDate>Tue, 11 Jun 2019 20:40:31 GMT</pubDate>
            <atom:updated>2019-06-27T16:13:59.036Z</atom:updated>
            <content:encoded><![CDATA[<h3>Explainer &amp; Practical Implementation Guide</h3><h4>What is a sparse Merkle tree?</h4><p>Sparse Merkle tree is a strategy of calculating a Merkle root in a reduced memory space. The computation is constrained but by a clever algorithm that allows the root calculation to be a single contiguous calculation. Overall computation necessary for root calculation is increased but, it is an incremental root calculation distributed across multiple deposit method invocations.</p><p>For a more academic explanation of a sparse Merkle tree read the <a href="https://eprint.iacr.org/2016/683.pdf">Efficient Sparse Merkle Trees</a> white paper.</p><h4>Why a sparse Merkle tree for Ethereum 2.0 deposits?</h4><p>Memory is reduced by using a single array with a size the same as the tree order, in the case of the Ethereum 2.0 deposit tree it is a 32 element array. A traditional Merkle tree calculation of size 2³² SHA2 hashes would require 360,777,252,864 gas far exceeding the current gas limit of 8,000,000 for a single block (storage costs not included). Calculations demonstrated with the following values below:<a href="https://ethgastable.info/">¹</a></p><pre>-- SHA256BASE 60 Base cost of SHA256.<br>-- SHA256WORD 12 Cost of SHA256 per word.</pre><p><strong>²³²(60+12+12)=360,777,252,864</strong></p><p>To be fair the previous calculation is a trivial implementation that doesn’t incorporate the efficiencies of empty leaves. Regardless, each depositor would need to pay gas cost that grows exponentially at each increment of the total deposit count.</p><p>By calculating the root incrementally as described in the previous section the sparse tree algorithm allows for the gas costs to be distributed equitably among the depositors. Clean storage is only requested once at contract deployment and does not grow as the size of the tree increases.</p><h4>How does a sparse Merkle tree work?</h4><p>A sparse Merkle tree relies on two key principles. The first being <strong>zero hashes </strong>and the second is that leafs are <strong>inserted in numeric order by index</strong>. Below is a diagram of zero hash tree.</p><h4>Zero Hashes</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*FeDcyXCRdhW-fQyQgxOOHw.png" /></figure><pre>zerohashes[0]=&#39;0x000...&#39;=0x0<br>zerohashes[1]=&#39;0xf5a...&#39;=H(0x0,0x0)<br>zerohashes[2]=&#39;0xdb5...&#39;=H(H(0x0,0x0),H(0x0,0x0))<br>zerohashes[3]=&#39;0xc78...&#39;=H(H(H(0x0,0x0),H(0x0,0x0)),H(H(0x0,0x0),H(0x0,0x0)))</pre><p>Zero hashes are the default value null value in the tree at a particular level. In this particular instance (an empty tree) the root is calculated as the hash of zerohashes[3].</p><pre>root =<br><strong>H(</strong>H(H(H(0x0,0x0),H(0x0,0x0)),H(H(0x0,0x0),H(0x0,0x0))),<br>H(H(H(0x0,0x0),H(0x0,0x0)),H(H(0x0,0x0),H(0x0,0x0)))<strong>)</strong></pre><pre>root = <strong>H(</strong>zerohashes[3],zerohashes[3]<strong>)</strong></pre><p>Below is an example of inserting out first leaf. For example, if a leaf of value 0xA were to be inserted into index 0 the proof path labeled in pink would be the only values recalculated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*IViQPq93OxhgcEFwEtqtyw.png" /></figure><pre>root =<br><strong>H(</strong>H(H(0xA,0x0),H(0xA,0x0)),H(H(0xA,0x0),H(0xA,0x0))),<br>H(H(H(0x0,0x0),H(0x0,0x0)),H(H(0x0,0x0),H(0x0,0x0)))<strong>)</strong></pre><pre>root = <strong>H(</strong>H(H(0xA,0x0),H(0xA,0x0)),H(H(0xA,0x0),H(0xA,0x0)), zerohashes[3]<strong>)</strong></pre><p>The zero hashes are used to rebalance the tree where n%2!=0 at any particular order. An observation to make is that the zero hash values are standing in to allow a leaf or node to be hashed when there isn’t a value to pair with.</p><p>Next, if the an example of how the <a href="https://github.com/ethereum/deposit_contract/blob/v0.5.1/deposit_contract/contracts/validator_registration.v.py">validator_registration.v.py</a> contract from the <a href="https://github.com/ethereum/eth2.0-specs">Ethereum 2.0 specification</a> generates zero hashes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ec8651e1a244c1565ab20a89992b409/href">https://medium.com/media/7ec8651e1a244c1565ab20a89992b409/href</a></iframe><p>The implementation of __init__ allows only <strong>32</strong> elements to be stored in the array zerohashes. Notice from the example above that zero hashes remain the same across nodes comprised of zero hashes. This is the first part of the strategy for reducing memory with a sparse Merkle tree.</p><h4>Insert By Index</h4><p>As mentioned previously, the second principle to reducing memory size in a sparse Merkle tree is to insert leaves in numeric order of index.</p><p>In the <a href="https://github.com/ethereum/deposit_contract/blob/v0.5.1/deposit_contract/contracts/validator_registration.v.py">validator_registration.v.py</a> deposit contract the zerohashes[] array is then copied over to another array named branches[] of the same size. The branches[] array is data structure that stores a single proof path for the sparse Merkle tree of the most recently inserted leaf. Each time a new leaf is inserted into the tree branches[] array is updated to reflect the proof path of that leaf.</p><p>The first step when the deposit method of the contract is called is to calculate i. Example below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7331f7edb60378927daf436e61c17eb5/href">https://medium.com/media/7331f7edb60378927daf436e61c17eb5/href</a></iframe><p>The branch index i will be used to calculate the depth of the tree to be hashed. The deposit parameters are hashed into a variable named value and inserted into the branch[] array.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3266acf0b33e01769fcd6ac1e1fea9f6/href">https://medium.com/media/3266acf0b33e01769fcd6ac1e1fea9f6/href</a></iframe><p>In this previous gist it can be seen that the value is hashed with branch[j] and the final calculated value is inserted at branch[i]. Using this insertion algorithm allows branches[] to maintain a proof path of the most recent insertion.</p><p>Using the get_deposit_root method the contract is able to calculate a root from the branches[] array once the deposit threshold has been met. The root calculation will match the standard calculation described in the implementation section.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3234c83816d1692787c97281d9abbd64/href">https://medium.com/media/3234c83816d1692787c97281d9abbd64/href</a></iframe><p>To learn more about how the sparse Merkle tree is implemented in the deposit contract read the <a href="https://github.com/runtimeverification/verified-smart-contracts/blob/master/deposit/formal-incremental-merkle-tree-algorithm.pdf">formal verification of the deposit contract</a>.</p><h4>Client Side Merkle Proof Path Calculation</h4><p>Since the client needs to calculate a proof path for each individual deposit for the root found in the Eth2Genesis event, calculation on the client side is not computed as a sparse Merkle tree. There are several approaches that can be used to calculate a Merkle tree proof path; trading off between the coefficients of memory, computation, and storage.</p><p>Proof calculation must satisfy the verify_merkle_branch method documented in the Ethereum 2.0 specification repository. proof the proof path, an array of values that will be hashed together with the valueleaf to prove the inclusion of the leaf in the Eth2Genesis root.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28cdaff5f0eaa83f7c02726e7b0604ed/href">https://medium.com/media/28cdaff5f0eaa83f7c02726e7b0604ed/href</a></iframe><p>Artemis’ implementation of the same verify_merkle_branch method can be seen below</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05f0d751694fd22b41d891904fc54aae/href">https://medium.com/media/05f0d751694fd22b41d891904fc54aae/href</a></iframe><p>Below you can find the implementation of the MerkleTree class from the Artemis client, afterwards there will be a break down of each of the methods.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df03f7276636c533423b41eeeeb151ff/href">https://medium.com/media/df03f7276636c533423b41eeeeb151ff/href</a></iframe><p>The constructor method is invoked when an instance of the MerkleTree is created. The parameterheight provided is used to create an array for each level of the tree. Additionally, the zeroHashes array is created.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c521017c79213e463f5d020e309f0fb7/href">https://medium.com/media/c521017c79213e463f5d020e309f0fb7/href</a></iframe><p>The generateZeroHashes method is used to fill the zeroHashes array. The generateZeroHashes method works identical to the method __init__ in the validator_registration.v.py deposit contract.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1db1fac9a375110c6f5693eda947656d/href">https://medium.com/media/1db1fac9a375110c6f5693eda947656d/href</a></iframe><p>Below is an example of the zeroHashes array when implemented properly for a Merkle tree with a height of 32.</p><pre>[ &#39;0x0000000000000000000000000000000000000000000000000000000000000000&#39;,<br>  &#39;0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b&#39;,<br>  &#39;0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71&#39;,<br>  &#39;0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c&#39;,<br>  &#39;0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c&#39;,<br>  &#39;0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30&#39;,<br>  &#39;0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1&#39;,<br>  &#39;0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c&#39;,<br>  &#39;0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193&#39;,<br>  &#39;0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1&#39;,<br>  &#39;0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b&#39;,<br>  &#39;0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220&#39;,<br>  &#39;0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f&#39;,<br>  &#39;0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e&#39;,<br>  &#39;0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784&#39;,<br>  &#39;0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb&#39;,<br>  &#39;0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb&#39;,<br>  &#39;0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab&#39;,<br>  &#39;0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4&#39;,<br>  &#39;0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f&#39;,<br>  &#39;0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa&#39;,<br>  &#39;0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c&#39;,<br>  &#39;0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167&#39;,<br>  &#39;0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7&#39;,<br>  &#39;0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0&#39;,<br>  &#39;0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544&#39;,<br>  &#39;0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765&#39;,<br>  &#39;0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4&#39;,<br>  &#39;0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1&#39;,<br>  &#39;0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636&#39;,<br>  &#39;0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c&#39;,<br>  &#39;0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7&#39; ]</pre><p>Next, the add method will be used to add new leaves to the MerkleTree. Each time a new leaf is added the MerkleTree instance is marked as dirty. Doing so allows the instance to know when it is necessary to recompute branch values.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62ece3790e303c54d64caa1039cd2898/href">https://medium.com/media/62ece3790e303c54d64caa1039cd2898/href</a></iframe><p>Below is an implementation used to calculate all the branch and root values. The algorithm is iterating through each level of the tree. Each iteration has an arraychild (<em>values to be hashed)</em> and an arrayparent (<em>place to store the hashed values). During the </em>last iteration theparent array is the root of the MerkleTree. If the child level is unbalanced the statement Bytes32 rightNode = (j + 1 &lt; child.size()) ? child.get(j + 1) : zeroHashes.get(i) replaces the rightNode to be replaced with an element from zeroHashes of the same order. The index to store the resulting hash in parent is calculated using j/2.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6270dbed4898fb36fb8cf8cc4ed569f/href">https://medium.com/media/c6270dbed4898fb36fb8cf8cc4ed569f/href</a></iframe><p>Once the branches have been calculated the value dirty is set to false to indicated the MerkleTree instance has an up to date calculation of the branch values.</p><p>Now to generate the proof path the method getProofTreeByIndex is used to iterate through the tree object and get the proof values pertinent to the deposit index provided.The algorithm employed iterates through each order of the tree. The index value is non-final and is divided by two at each iteration. Initially if the value of index is odd index is decremented, otherwise increment using the statement index = index % 2 == 1 ? index — 1 : index + 1.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de21b9ddee70064e7a35157d51580af4/href">https://medium.com/media/de21b9ddee70064e7a35157d51580af4/href</a></iframe><p>A proof path of the same size as the MerkleTree height will be created and returned as the array proof.</p><ol><li><a href="https://ethgastable.info/">https://ethgastable.info/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13ec8404ca4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Artemis Update #1]]></title>
            <link>https://medium.com/@josephdelong/artemis-update-1-87355b2d33ef?source=rss-eea4e29061a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/87355b2d33ef</guid>
            <category><![CDATA[pegasys]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[consensys]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Joseph Delong]]></dc:creator>
            <pubDate>Fri, 07 Jun 2019 17:31:10 GMT</pubDate>
            <atom:updated>2019-06-07T17:31:10.238Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jSjp6p9eumltoapVNkmLTA.png" /></figure><h4>v0.5.1 Merged into Master Branch</h4><p>Following much anticipation we were able to <a href="https://github.com/PegaSysEng/artemis/pull/687">merge 0.5.1</a> into our master branch. The team has been working on the update diligently since early May and has finally completed the merge. The 0.5.1 update is huge in terms of the number of the changes from 0.4 to 0.5.1. Which can be viewed in the change log for <a href="https://github.com/ethereum/eth2.0-specs/releases/tag/v0.5.0">0.5.0</a> and <a href="https://github.com/ethereum/eth2.0-specs/releases/tag/v0.5.1">0.5.1</a>.</p><p>Some of such issues regarding the update was breaking change to SSZ that restructured how bytes were serialized. Previously, all SSZ types following the same serialization scheme. After the update SSZ containers implicitly carry their type. The type now affects serialization and hashing schemas.</p><p>In addition, changes to the structure, parameters, and naming of core methods in the specification created the need for reimplementation and retesting.</p><h4>Deposit Merkle Tree</h4><p>Work on implementation of the <a href="https://github.com/PegaSysEng/artemis/pull/694">merkle deposit tree</a> started three weeks ago. We have successfully implemented the MerkleTree data structure and proof generation algorithm that will satisfy the 0.5.1verify_merkle_branch method.</p><h4>Prometheus Integration</h4><p><a href="https://twitter.com/_tmio">Antoine Toulme</a> has been assisting team Artemis with an <a href="https://github.com/PegaSysEng/artemis/pull/691">implementation</a> that allows for <a href="https://prometheus.io/">Prometheus</a> monitoring.</p><h4>Artemis Testnets</h4><p>The Artemis team is running and testing short lived testnets on the WhiteBlock platform using the <a href="https://github.com/deltap2p/hobbits">Hobbits</a> protocol.</p><h4>Minimal Viable JVM libP2P implementation</h4><p>Artemis is teaming up with Harmony and Protocol Labs to create a minimal libp2p implementation that is compatible with golibp2p on the wire-protocol level.</p><h4>Coming Soon: Hobbits Bounties</h4><p>ConsenSys will be posting bounties to implement Hobbits for all clients. In a strategy that will ensure that all clients have this as a networking option in preparation for the <strong>#Interop</strong> Lock-in. <strong>Stay tuned </strong>or join us in our <a href="https://gitter.im/PegaSysEng/artemis?utm_source=share-link&amp;utm_medium=link&amp;utm_campaign=share-link">Gitter</a> channel for more information.</p><h4>Interop Lock-in</h4><p><strong>September 6–13, 2019</strong><br>The Artemis team has also been coordinating a retreat open to all Ethereum 2.0 implementation teams and researchers. The goal of <strong>#Interop</strong> is to bring all the Ethereum 2.0 implementation teams together and bring all the clients to interoperability. Interoperability is the ability for clients to universally communicate.</p><h4>External Contributors</h4><p>We would also like to thank our recent external contributors to the project. <a href="https://www.linkedin.com/in/mankena-venkatesh-86b14518/">Venkatesh Mankena</a>, <a href="https://twitter.com/jalex_towle">Alex Towle</a>, and <a href="https://twitter.com/_tmio">Antoine Toulme</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pSxVDG7oKi3Dl6NcKji_eQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87355b2d33ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fundamentals of Dapp Development]]></title>
            <link>https://medium.com/@josephdelong/fundamentals-of-dapp-development-b97df954a9a?source=rss-eea4e29061a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b97df954a9a</guid>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Joseph Delong]]></dc:creator>
            <pubDate>Fri, 07 Dec 2018 08:49:08 GMT</pubDate>
            <atom:updated>2019-02-15T16:31:21.986Z</atom:updated>
            <content:encoded><![CDATA[<h3>Prerequisites</h3><ul><li><a href="https://nodejs.org/en/download/">NodeJS</a></li><li><a href="https://www.npmjs.com/">Node Package Manager (NPM)</a></li><li><strong>Linux</strong>, <strong>MacOS</strong>, Windows w/ a Linux subsystem installed</li><li><a href="https://gist.github.com/derhuerst/1b15ff4652a867391f03">Git</a></li><li><a href="https://www.google.com/chrome/">Chrome</a>, <a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a>, <a href="https://www.opera.com/download">Opera</a>, or <a href="https://brave.com/download/">Brave browser</a> w/ a <a href="https://metamask.io/">Metamask</a> extension installed</li></ul><h3>Installation</h3><ol><li>Install the Truffle package sudo npm install -g truffle</li><li>Verify that it has been downloaded successfully truffle</li><li>We also need to install ganache-cli sudo npm install -g ganache-cli</li><li>Verify that it has been downloaded successfully ganache-cli</li></ol><h3>Setup</h3><p>5. Create a new directory named sandbox mkdir sandbox</p><p>6. Navigate to that directory cd sandbox</p><p>7. Initialize a default truffle project in the sandbox directory truffle init</p><p>8. To configure truffle to use our ganache-cli test network, using your favorite text editor; edit truffle.js to match:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e07ff68b523f2c84d7209b2bf5cb970/href">https://medium.com/media/9e07ff68b523f2c84d7209b2bf5cb970/href</a></iframe><h3>Contract Development</h3><p>Let’s write our first contract. Create a new file in the contracts directory called SimpleStorage.sol</p><p>Populate SimpleStorage.sol with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2815a3e78be3c8fce896254cff65183/href">https://medium.com/media/f2815a3e78be3c8fce896254cff65183/href</a></iframe><p>Let’s compile our contract. Run truffle compile in our truffle project&#39;s root directory. You should receive some helpful warnings. You should also be notified that a new artifact has been written.</p><h3>Contract Deployment</h3><p>We now have to configure truffle to deploy this artifact to our network. Create a new file in the migrations directory called 2_deploy_contracts.js.</p><p>Populate 2_deploy_contracts.js with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df31bc3a604a3cb0b5297bdc4f6c53d3/href">https://medium.com/media/df31bc3a604a3cb0b5297bdc4f6c53d3/href</a></iframe><p>Now if we run truffle deploy we should see our migration script running, and eventually truffle will tell us the address that the contract account has been created at.</p><p>Copy the address from the deployment to your clipboard. An example of that is shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G5gezth9Gezyh9TKRhXb3g.png" /></figure><h3>Contract Communication</h3><p>Switch your Metamask to target the localhost:8545</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PULjlWKW0FoTo9AdW65Q4A.png" /></figure><p>Copy private key for import into Metamask</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LeI-gLEmKyBPa0pPhqhSpw.png" /><figcaption>Never share your private key!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gGj04z1S8Nve1WSO1dJqyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zmmav1MoHTWQeOPhQxvwBQ.png" /><figcaption>Copy your private key into the field above</figcaption></figure><p>If you succeeded your ETH balance should show 100 ETH</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P36ePTWT2MxnjHKXTaopGA.png" /></figure><h3>Contract Tests</h3><p>What can we do with our contract now? We should test it before we consider deploying it permanently (on a live Ethereum network)!</p><p>Let’s write our first tests. Create a new file in the test directory called simpleStorage.js.</p><p>Populate simpleStorage.js with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbf824fd3964f871f678de29dd6975d9/href">https://medium.com/media/cbf824fd3964f871f678de29dd6975d9/href</a></iframe><p>Before running our tests, we need to make sure our Ethereum client is running. Open up another terminal window and run ganache-cli if you haven&#39;t already.</p><p>Now go back to your truffle project and run truffle test. One of our tests should fail. Find the error and fix it.</p><h3>Configure React App to Interface with Contracts</h3><p>Clone the repository for the React app to your local using the following command:</p><pre>git clone git@github.com:dangerousfood/simple-client.git<br>cd simple-client/</pre><p>Open the file app.js in your favorite editor and update the value labeled ADD_ADDRESS_HERE with the value from the deployed contract</p><pre>const config = {</pre><pre>addressSimpleStorage: &#39;ADD_ADDRESS_HERE&#39;</pre><pre>}</pre><p>Now, we will download the packages and start the React app</p><pre>npm install<br>npm start</pre><p>A a browser page should open automatically, if it doesn’t enter localhost:3000 into your browser URL bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y4-_XPLURixJfMC2yH5vaQ.png" /><figcaption>Your screen should look like this after wards</figcaption></figure><p>Try entering a value number value into the UPDATE field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0z0pXZwuFfdddZJPW5brGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VuitLliRkWvFVny4-1c9mA.png" /><figcaption>Successful submission</figcaption></figure><p>Now validate the value was stored in the contract using the CHECK NUMBER field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JwRjb3yz2TtIBNz1evTSRA.png" /></figure><h3>Troubleshooting</h3><p>If you encounter problems I have GitHub repository with a working version of this guide. In your terminal run:</p><p>git clone <a href="https://github.com/dangerousfood/hello_contract.git">https://github.com/dangerousfood/hello_contract.git</a></p><p>If truffle compile or truffle test fails in the newly cloned folder then there may be an environmental issue. Ensure that NodeJS and NPM are installed correctly.</p><h3>Further Links</h3><ul><li><a href="https://solidity.readthedocs.io/en/develop/index.html#">Solidity Documentation</a></li><li><a href="http://truffleframework.com/docs/">Truffle Documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b97df954a9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying an ERC20 Token to Ethereum]]></title>
            <link>https://medium.com/@josephdelong/deploying-an-erc20-token-to-ethereum-b31a1774bce1?source=rss-eea4e29061a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b31a1774bce1</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[token-sale]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Joseph Delong]]></dc:creator>
            <pubDate>Tue, 17 Jul 2018 22:45:50 GMT</pubDate>
            <atom:updated>2018-07-17T22:45:50.793Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 1 of 2</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ghh-C3-wKvihRBfQfP-uFQ.png" /></figure><h4><strong>Prerequisites</strong></h4><ul><li><a href="https://nodejs.org/en/download/">NodeJS</a></li><li><a href="https://www.npmjs.com/">Node Package Manager (NPM)</a></li></ul><h4>Installation</h4><ol><li>We need to install the Truffle package first sudo npm install -g truffle</li><li>Verify that it has been downloaded successfully truffle</li><li>Follow this link to download, install, and open <a href="https://truffleframework.com/ganache">Ganache</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0rTjoqIoKoPrPh_e5hAmpA.png" /><figcaption>When you’ve opened Ganche it should look like this</figcaption></figure><p>4. Create a new directory mkdir Alamo</p><p>5. Change directory to the newly create folder cd Alamo</p><p>6. Initialize a default truffle project by running truffle init</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dWrcA6QN6K45M17784sv7g.png" /><figcaption>Your previously empty folder should look like this now</figcaption></figure><p>7. Install the <a href="https://openzeppelin.org/">OpenZeppelin</a> libraries npm install openzeppelin-solidity</p><p>8. Register for a developer public key with <a href="https://infura.io/register">Infura.io</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NjmWZCN_y0Zm9PBhWc5lwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4G-d4HFlcWeRNg_OPjnuXQ.png" /></figure><p>9. Configure truffle to use our Ganache <strong>development</strong> network, populate truffle.js with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd7b892fec43906de64a772beb95037b/href">https://medium.com/media/fd7b892fec43906de64a772beb95037b/href</a></iframe><p>Make sure you replace <strong>YOUR_MNEMONIC_FROM_GANACHE </strong>and <strong>YOUR_PUBLIC_KEY_FROM_INFURA </strong>in truffle.js with your own details.</p><ul><li><strong>YOUR_MNEMONIC_FROM_GANACHE </strong>can be found in the title bar of the Ganache window</li><li><strong>YOUR_PUBLIC_KEY_FROM_INFURA </strong>can be found in the project as the public key</li></ul><h4>Contract</h4><p>Let’s write our first contract. Create a new file in the directory <strong>Alamo/contracts</strong> directory called AlamoToken.sol</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sBlu8rv4g7y5NBe5Vnzr7w.gif" /></figure><p>Populate AlamoToken.sol with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94749a3588996c74d7a7b33061372297/href">https://medium.com/media/94749a3588996c74d7a7b33061372297/href</a></iframe><h4>Deploy</h4><p>We now have to configure truffle to deploy this artifact to our network. Create a new file in the migrations directory called 2_deploy_contracts.js.</p><p>Populate 2_deploy_contracts.js with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/947e47eebc11070bc695c04ae0d4b634/href">https://medium.com/media/947e47eebc11070bc695c04ae0d4b634/href</a></iframe><p>Next, run truffle build to build the contracts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rC_9pXaEHCWLu8K_KQX5yA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W1CzudnhL_c7Hg__nUS5DA.gif" /><figcaption>Console output should look like this</figcaption></figure><p>Call truffle deploy to deploy the compiled contract to the <strong>development</strong> network created by Ganache</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j6gtxMGIlxzg8T_eVaI4PA.png" /><figcaption>Console output should look like this</figcaption></figure><p>Now the contracts have been successfully deployed to the <strong>development</strong> network.</p><h4>Follow on to <a href="https://medium.com/p/e161ba14cdcc/">Part 2</a> to deploy to Ropsten and Mainnet</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b31a1774bce1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blockchain Private Channel is an Oxymoron]]></title>
            <link>https://medium.com/coinmonks/blockchain-private-channel-is-an-oxymoron-2ec30c38b095?source=rss-eea4e29061a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ec30c38b095</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[quorum]]></category>
            <category><![CDATA[private-permissioned]]></category>
            <dc:creator><![CDATA[Joseph Delong]]></dc:creator>
            <pubDate>Fri, 20 Apr 2018 00:57:44 GMT</pubDate>
            <atom:updated>2018-04-28T13:36:46.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*11DoUz1iZt4Fs6R_5SB_NA.jpeg" /></figure><p>Private channels are the generic term used to describe a method of communicating using a blockchain ledger with a subset of network participants. The communication paradigm is the same a regular blockchain except the peer communication is encrypted over a TLS connection and decrypted at the endpoints.</p><p>In Quorum v2.0.2 those communications are called private transactions.<a href="http://2.https//github.com/jpmorganchase/quorum-docs/blob/master/Quorum%20Whitepaper%20v0.1.pdf">²</a> In Hyperledger Fabric v1.1 the same convention is called channels.<a href="http://1.https//hyperledger-fabric.readthedocs.io/en/release-1.1/channels.html">¹</a></p><p>In theory private transactions are being made by nodes that are achieving a byzantine fault tolerant consensus. Quorum v.2.0.2 uses two separate consensus mechanisms that are selectable at deployment. The first is a Raft a consensus model and the second is Istanbul Byzantine Fault Tolerance (IBFT) which is a modified derivative of Practical Byzantine Fault Tolerance (PBFT).<a href="http://3.https//github.com/jpmorganchase/quorum">³</a> <a href="http://6.https//github.com/ethereum/EIPs/issues/650">⁶</a></p><p>Below are equations for the aforementioned consensus mechanisms. In these equations <strong>N</strong> is the total nodes and <strong>F</strong> are the number of included faulty nodes. For the value <strong>F </strong>the resulting value of <strong>N</strong> is the number of nodes required to achieve consensus.</p><p><strong>PBFT Consensus Fault Tolerance Equation</strong><a href="http://4.http//pmg.csail.mit.edu/papers/osdi99.pdf"><strong>⁴</strong></a></p><blockquote><strong>N</strong> = 3<strong>F</strong> +1</blockquote><p><strong>Raft Consensus Fault Tolerance Equation</strong><a href="http://5.https//www.cl.cam.ac.uk/techreports/UCAM-CL-TR-857.pdf?__hstc=137489263.d50a3c91e72c280a7921bf0d7ab734f9.1522540800074.1522540800075.1522540800076.1&amp;__hssc=137489263.1.1522540800077&amp;__hsfp=1773666937"><strong>⁵</strong></a></p><blockquote><strong>N</strong> = 2<strong>F</strong> +1</blockquote><p>In practice, byzantine fault tolerance cannot be achieved by these channels due to a lack of participating nodes. In the average case the requirement for privacy means that there will only be two participating nodes in the private channel. If there is a single faulty node in a PBFT private channel there needs to be 4 participating nodes. Likewise, if there is a single faulty node in a Raft private channel there needs to be 3 participating nodes.</p><p>This same fallibility is detailed in the Castro-Liskov 99 paper where it states,</p><blockquote>“The algorithm does not address the problem of fault tolerant privacy: a faulty replica may leak information to an attacker. It is not feasible to offer fault-tolerant privacy in the general case because service operations may perform arbitrary computations using their arguments and the service state; replicas need this information in the clear to execute such operations efficiently”.<a href="http://4.http//pmg.csail.mit.edu/papers/osdi99.pdf">⁴</a></blockquote><h3><strong>Therefore, there is no known way to achieve privacy at the consensus layer of a blockchain.</strong></h3><p>Defenders of the private channel schema will likely make reference to the check pointing techniques employed by Quorum. Check pointing measures are taken in private channels by inserting the block hash from a globally visible chain into the new private blocks and vice versa inserting the block hash of each new private block into a globally visible chain. The check pointing process ensures the provenance of the private chain is globally auditable.</p><p>The reason this technique is not an effective mitigation is the private channel can only append a new checkpoint to the global chain after the private consensus has been achieved. As stated before in the presence of a single faulty node a two-party private channel cannot achieve consensus.</p><h3><strong>Effective mitigation techniques include</strong></h3><blockquote>1. Don’t use private channels for parties less than 4 for PBFT and 3 for Raft.</blockquote><blockquote>2. Add inert parties to the channel, such as a neutral observer from the global chain.</blockquote><blockquote><strong>3. Don’t use private channels.</strong></blockquote><h3><strong>References</strong></h3><p>1. <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.1/channels.html">https://hyperledger-fabric.readthedocs.io/en/release-1.1/channels.html</a></p><p>2. <a href="https://github.com/jpmorganchase/quorum-docs/blob/master/Quorum%20Whitepaper%20v0.1.pdf">https://github.com/jpmorganchase/quorum-docs/blob/master/Quorum%20Whitepaper%20v0.1.pdf</a></p><p>3. <a href="https://github.com/jpmorganchase/quorum">https://github.com/jpmorganchase/quorum</a></p><p>4. <a href="http://pmg.csail.mit.edu/papers/osdi99.pdf">http://pmg.csail.mit.edu/papers/osdi99.pdf</a></p><p>5. <a href="https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-857.pdf?__hstc=137489263.d50a3c91e72c280a7921bf0d7ab734f9.1522540800074.1522540800075.1522540800076.1&amp;__hssc=137489263.1.1522540800077&amp;__hsfp=1773666937">https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-857.pdf?__hstc=137489263.d50a3c91e72c280a7921bf0d7ab734f9.1522540800074.1522540800075.1522540800076.1&amp;__hssc=137489263.1.1522540800077&amp;__hsfp=1773666937</a></p><p>6. <a href="https://github.com/ethereum/EIPs/issues/650">https://github.com/ethereum/EIPs/issues/650</a></p><p><a href="https://www.pexels.com/photo/interior-of-office-building-325229/">Photo by Manuel Geissinger from Pexels</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ec30c38b095" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/blockchain-private-channel-is-an-oxymoron-2ec30c38b095">Blockchain Private Channel is an Oxymoron</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with Solidity development using Truffle]]></title>
            <link>https://medium.com/coinmonks/getting-started-with-solidity-development-using-truffle-2cc6c1df9133?source=rss-eea4e29061a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cc6c1df9133</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[truffle]]></category>
            <category><![CDATA[dapps]]></category>
            <dc:creator><![CDATA[Joseph Delong]]></dc:creator>
            <pubDate>Mon, 09 Apr 2018 22:03:51 GMT</pubDate>
            <atom:updated>2020-10-16T12:28:25.895Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRxtljcUPuD0Ea-FHdwC8g.png" /></figure><p><strong>Presented by </strong><a href="https://www.linkedin.com/in/yorke-rhodes-iv/"><strong>Yorke Rhodes</strong></a><strong> </strong>January 31, 2017</p><p><strong>Updated by </strong><a href="https://www.linkedin.com/in/joseph-delong-b3084332/"><strong>Joseph Delong</strong></a> April 9, 2018</p><h3>Prerequisites</h3><ul><li><a href="https://nodejs.org/en/download/">NodeJS</a></li><li><a href="https://www.npmjs.com/">Node Package Manager (NPM)</a></li></ul><h3>Walkthrough</h3><h4><strong>Installation</strong></h4><ol><li>We need to install the Truffle package first sudo npm install -g truffle</li><li>Verify that it has been downloaded successfully truffle</li><li>We also need to install TestRPC sudo npm install -g ethereumjs-testrpc</li><li>Verify that it has been downloaded successfully testrpc</li></ol><p>Setup to initialize a default truffle project, navigate to the desired directory and run truffle init</p><p>To configure truffle to use our testRPC client, populate truffle.js with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e07ff68b523f2c84d7209b2bf5cb970/href">https://medium.com/media/9e07ff68b523f2c84d7209b2bf5cb970/href</a></iframe><h4>Contract</h4><p>Let’s write our first contract. Create a new file in the contracts directory called SimpleStorage.sol</p><p>Populate SimpleStorage.sol with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2815a3e78be3c8fce896254cff65183/href">https://medium.com/media/f2815a3e78be3c8fce896254cff65183/href</a></iframe><p>Let’s compile our contract. Run truffle compile in our truffle project&#39;s root directory. You should receive some helpful warnings. You should also be notified that a new artifact has been written.</p><h4>Deploy</h4><p>We now have to configure truffle to deploy this artifact to our network. Create a new file in the migrations directory called 2_deploy_contracts.js.</p><p>Populate 2_deploy_contracts.js with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df31bc3a604a3cb0b5297bdc4f6c53d3/href">https://medium.com/media/df31bc3a604a3cb0b5297bdc4f6c53d3/href</a></iframe><p>Now if we run truffle deploy we should see our migration script running, and eventually truffle will tell us the address that the contract account has been created at.</p><h4>Tests</h4><p>What can we do with our contract now? We should test it before we consider deploying it permanently (on a live ethereum network)!</p><p>Let’s write our first tests. Create a new file in the test directory called simpleStorage.js.</p><p>Populate simpleStorage.js with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbf824fd3964f871f678de29dd6975d9/href">https://medium.com/media/cbf824fd3964f871f678de29dd6975d9/href</a></iframe><p>Before running our tests, we need to make sure our Ethereum client is running. Open up another terminal window and run testrpc if you haven&#39;t already.</p><p>Now go back to your truffle project and run truffle test. One of our tests should fail. Find the error and fix it.</p><h3>Troubleshooting</h3><p>If you encounter problems I have GitHub repository with a working version of this guide. In your terminal run:</p><p>git clone <a href="https://github.com/dangerousfood/hello_contract.git">https://github.com/dangerousfood/hello_contract.git</a></p><p>If truffle compile or truffle test fails in the newly cloned folder then there may be an environmental issue. Ensure that NodeJS and NPM are installed correctly.</p><h3>Further Links</h3><ul><li><a href="https://solidity.readthedocs.io/en/develop/index.html#">Solidity Documentation</a></li><li><a href="http://truffleframework.com/docs/">Truffle Documentation</a></li></ul><blockquote><a href="https://coincodecap.com/?utm_source=coinmonks">Get Best Software Deals Directly In Your Inbox</a></blockquote><figure><a href="https://coincodecap.com/?utm_source=coinmonks"><img alt="" src="https://cdn-images-1.medium.com/max/584/0*OJ-qb5G6i863msBB.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cc6c1df9133" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/getting-started-with-solidity-development-using-truffle-2cc6c1df9133">Getting started with Solidity development using Truffle</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>