<?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 Kwang Yul Seo on Medium]]></title>
        <description><![CDATA[Stories by Kwang Yul Seo on Medium]]></description>
        <link>https://medium.com/@kseo?source=rss-ec4d2e62f8d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*yHf9caiSH0jBdZhiVHOxQA.jpeg</url>
            <title>Stories by Kwang Yul Seo on Medium</title>
            <link>https://medium.com/@kseo?source=rss-ec4d2e62f8d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 08:04:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kseo/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[CodeChain Staking Guide]]></title>
            <link>https://medium.com/codechain/codechain-staking-guide-eecbc3fff041?source=rss-ec4d2e62f8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/eecbc3fff041</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[proof-of-stake]]></category>
            <category><![CDATA[delegation]]></category>
            <category><![CDATA[stakeholder]]></category>
            <category><![CDATA[chaincode]]></category>
            <dc:creator><![CDATA[Kwang Yul Seo]]></dc:creator>
            <pubDate>Thu, 16 May 2019 06:46:50 GMT</pubDate>
            <atom:updated>2020-02-26T07:43:10.737Z</atom:updated>
            <content:encoded><![CDATA[<p>CodeChain is a proof-of-stake based network. Stakeholders elect validators by delegating their stakes to credible validator candidates. The elected validators perform consensus for the network to earn rewards. This guide explains how staking in CodeChain works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RCwrJu7mG8AsmA85zQEU0w.jpeg" /><figcaption><a href="https://www.pexels.com/photo/close-up-photography-of-yellow-green-red-and-brown-plastic-cones-on-white-lined-surface-163064/">https://www.pexels.com/photo/close-up-photography-of-yellow-green-red-and-brown-plastic-cones-on-white-lined-surface-163064/</a></figcaption></figure><h3>Two Token Model</h3><p>Before diving into the details of staking and delegation, you need to understand the token economy of the CodeChain network. CodeChain has two native tokens: a) Fee Token (CCC) and b) Stake Token (CCS). Let’s examine these two tokens in order.</p><h4>CodeChain Fee Token (CCC)</h4><p>CCCs are the native tokens of CodeChain, which is used for paying transaction fees. On the CodeChain network, anyone who signs a transaction pays the transaction fees. Transaction fees consist of a) minimum fees and b) express fees.</p><p>Minimum fees specify the minimum amount of CCC that must be paid for a transaction to be processed by the network. A transaction that does not meet the minimum fee requirement is rejected by validators.</p><p>But why would one pay higher transaction fees if any validator accepts a transaction with the minimum fee? Users pay extra transaction fees if they want their transactions to be processed more quickly. Validators pick transactions with higher fees because they can earn more rewards by including these high-priced transactions in the block. These extra fees (excluding minimum fees) are called express fees.</p><p>Then who are the beneficiaries of transaction fees? There are two beneficiaries: validators and stakeholders. Minimum fees are distributed to the network stakeholders who own stakes and express fees are given to the block author as described in the diagram below. Contrary to other popular PoS networks, CodeChain stakeholders earn transaction fees with no endeavor to delegate their stakes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*D6OUZ74Q5mUivlVq3xNu8Q.png" /></figure><p>Note that each transaction type has a different minimum fee requirement. The minimum fee for each transaction type can be changed by the stakeholders’ votes (if more than 51% agree to the change). The minimum fee at genesis is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*9pBW477g3ePli6DHlsSoAw.png" /></figure><h4>CodeChain Staking Token (CCS)</h4><p>CCSs are the native staking tokens of CodeChain. CCSs represent two rights:</p><ol><li>Participate in consensus for CodeChain by delegating stakes to validators. Stakeholders have the right to choose validators in proportion to shares by delegating their stakes.</li><li>Earn transaction fees paid to the network. Earnings are distributed to stakeholders on a pro-rata basis. If a stakeholder has 20% of the total CCS, he gets 20% of the transaction fees paid to the network. The fees are paid every block.</li></ol><p>Now that you understand the token model of CodeChain, it’s time to learn how staking in CodeChain works. Let’s start the journey by explaining how one can participate in the CodeChain consensus by becoming a validator.</p><h3>Nomination</h3><p>Any node can nominate itself as a validator by depositing at least 10M CCC (MIN_DEPOSIT). The deposit is slashed when malicious behavior, such as double-signing of blocks, is reported.</p><p>CCSs are not required for nomination, but a node needs to get delegations of stakeholders to be elected as a validator. Depositing a large amount of CCC is a good signal to stakeholders because the deposit shows its willingness to be an honest validator.</p><h3>Validator Election</h3><p>CodeChain validator election algorithm picks 30 (MAX_NUM_OF_VALIDATORS) candidates in order of the amount of received delegations. The top 4 (MIN_NUM_OF_VALIDATORS) nodes become validators regardless of the amount of delegations because the Tendermint algorithm that CodeChain uses needs at least 4 validators to be functional.</p><p>The accounts that received less than 100,000 CCS (DELEGATION_THRESHOLD, 1% of total CCS) are dropped from the list of validators, even though they are a part of the top 30 validators. This prevents accounts with little delegations from becoming validators.</p><p>Here’s the formal procedure of the validator election:</p><ol><li>Pick 30 candidates in order of the amount of received delegations.</li><li>Select the top 4 accounts; they become validators no matter what.</li><li>Among the rest of them, drop the accounts that received less than 100,000 CCS; the remaining accounts become validators.</li></ol><h3>Validator Reward</h3><p>Why would a node want to be a validator? What rewards does a node get by becoming a validator? As we briefly discussed in the token model, the block author gets the express fees of the blocks at the end of a term. These express fees have real value because validators can sell them on cryptocurrency exchanges and earn cash.</p><p>Most PoS-based blockchain networks, such as EOS, give block rewards to their validators by generating new tokens. In other words, staking rewards are created through inflation. This is pointless as described in the <a href="https://medium.com/@bendavenport/a-stake-to-the-heart-57fcd8ec323b">article by Ben Davenport</a>:</p><blockquote><em>If everyone holding a given crypto-asset is staking all their coins, then everyone gets (out of thin air) a new amount of coins each period exactly proportional to their existing ownership. So, at the end of every period, everyone’s ownership stake in the asset is exactly the same as it was previously</em></blockquote><p>Validators can withdraw the reward after waiting for 1 hour. This withdrawal delay is mandatory because validator rewards are slashed when malicious behaviors such as a) double-votes or b) extended validator downtime are detected.</p><h3>Punishment</h3><p>The deposit made and the reward earned by the criminal validator are slashed if double-signing of blocks is detected. The slashed deposit and rewards are given to the informant reporting the double vote. Any validator of the committee at the given term can report malicious behavior.</p><p>Selfish validators who do not participate in signing the blocks proposed by other nodes are punished by incrementally slashing the rewards that the validator can claim at the end of the term. If a validator misses 1/3 of the blocks, the reward is decreased by 10%. If it misses more than 1/3 of the blocks, the reward decreases at a much more rapid rate, up to 90%. Finally, there is no reward at all if it misses more than 2/3 of the blocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/0*MXTw_lFyTJ7ME7A2" /></figure><p>Also to prevent some validators from rejecting other validators’ signatures to their proposal, CodeChain gives additional rewards to validators who diligently collected signatures. The reward algorithm is described in the <a href="https://github.com/CodeChain-io/codechain/blob/master/spec/Dynamic-Validator.md#validator-reward">“Validator Reward”</a> section of the spec.</p><p>Note that on contrary to other PoS chains that slash both validator deposits and delegator funds, CodeChain only slashes the validator’s deposit in all cases. Stakeholders are risk-free and encouraged to change their delegations to another validator quickly to make the network stable.</p><h3>Jail</h3><p>A validator who doesn’t produce blocks is jailed for a while. It gives validators time to fix the nodes that they manage. The jailed account can nominate itself again after 24 hours (CUSTODY_PERIOD). There is no deposit slash because this situation can happen due to unforeseeable circumstances, such as network failure.</p><h3>Validator Lifecycle</h3><p>We can summarize the lifecycle of a validator we’ve discussed so far as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*_QsMnxYJCVnG2QN0SU3ngg.png" /></figure><ol><li>An eligible node becomes a candidate node by self-nomination.</li><li>If there is no self-nomination during NOMINATE_EXPIRATION terms, the candidate node goes back to an eligible state.</li><li>A candidate node is elected as a validator according to the election algorithm described below.</li><li>A validator node goes back to a candidate node when the given term ends, and the validator did its work.</li><li>A validator is jailed if it didn’t work properly.</li><li>A validator who double-voted is banned permanently.</li><li>A jailed validator becomes a candidate node again if it self-nominates after CUSTODY_PERIOD</li><li>A jailed validator can’t get out of the jailed state if it self-nominates before CUSTODY_PERIOD</li><li>A jailed validator goes back to an eligible state if there is self-nomination during RELEASE_PERIOD.</li></ol><h3>Validator Hardware Requirements</h3><p>If you want to participate in the network as a validator, you must meet the minimum hardware requirements specified below:</p><p>CPU: Intel Core i7–6700 / AMD Ryzen 5 1600 and above</p><p>Memory: 16GiB+</p><p>Disk: 1TiB+ SSD</p><p>Network: 1Gbps+</p><p>If you plan to run a validator on Amazon AWS, we recommend c5.2xlarge instance.</p><h3>Parameters</h3><p>Currently, staking parameters are defined as follows. They are subject to change upon stakeholders’ voting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*S3oP85kDsqh7kT7bT_wdZQ.png" /></figure><h3>Conclusion</h3><p>This article is a guide to help validators understand the mechanism of CodeChain staking. If you would like to know the details of each rule, please refer to the <a href="https://github.com/CodeChain-io/codechain/blob/master/spec/Dynamic-Validator.md">specification</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eecbc3fff041" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codechain/codechain-staking-guide-eecbc3fff041">CodeChain Staking Guide</a> was originally published in <a href="https://medium.com/codechain">CodeChain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeChain Tooling Support]]></title>
            <link>https://medium.com/codechain/codechain-tooling-support-1a56355444a6?source=rss-ec4d2e62f8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a56355444a6</guid>
            <category><![CDATA[tooling]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[chaincode]]></category>
            <dc:creator><![CDATA[Kwang Yul Seo]]></dc:creator>
            <pubDate>Tue, 30 Apr 2019 08:45:40 GMT</pubDate>
            <atom:updated>2019-04-30T12:09:33.517Z</atom:updated>
            <content:encoded><![CDATA[<p>There are numerous teams that aim to implement new blockchains. Many ICO teams with Ethereum-based ERC-20 tokens are planning to create their own chains and no longer rely on Ethereum. Despite efforts to improve scalability, Ethereum’s performance is not yet sufficient and DApps may require additional functionality not provided by existing blockchain platforms, and thus attempts to create new blockchains are expected to continue to rise.</p><p>However, what does it mean to make a blockchain from scratch? Would the sole idea of a groundbreaking consensus algorithm that raises the Transaction Per Second (TPS) automatically lead to a new blockchain implementation? It is true that from the end of last year to early this year when the ICO was booming, it was easy to collect tens of billions of dollars using this approach, but unfortunately, blockchains aren’t so easy to create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZEZdLLMxj9UsPa6Q5zlAFQ.jpeg" /></figure><p>To create a blockchain, you initially need to implement a blockchain engine. The consensus algorithm is also an important element of the blockchain engine; however, the engine also includes a virtual machine for smart contracts, a network stack for P2P communication, storage for storing block and state data, a verifier that verifies the validity of blocks and transactions and all of these elements must be connected in harmony. If you are considering blockchain technology that focuses on performance and scalability, you must also consider sharding or interchains too. Since it is difficult to build a blockchain engine from scratch, most projects begin from a fork of existing projects and end up modifying only one or two elements.</p><p>The successful implementation of a blockchain engine does not conclude the development process. In order to facilitate the process for people to use your blockchain, various tool support is also required. First, we need a block explorer to check the contents of generated blocks and transactions. You also need to create a wallet that allows you to send and receive digital assets that are published on the blockchain. If you are running a testnet, you also need a Faucet site to distribute test coins. SDKs should also be provided to allow developers to easily utilize the blockchain nodes. If the blockchain supports Smart Contracts, there should be tools for that Smart Contract Language as well.</p><p>Nodes also need tools to participate as validators in the blockchain network. In the case of a blockchain engine that uses Proof of Work (PoW), mining software must be provided. Furthermore, since a single block validator can operate several nodes, software that provides monitoring and management functions for several nodes is also needed. In addition, there may be even more tools that can provide convenience to blockchain users. For example, it is convenient to have a command line tool that can generate and manage keys, or software that can provide a view and allow easy management of digital assets that are published on the blockchain.</p><p>CodeChain provides a variety of tools to provide a seamless experience for the user:</p><ul><li><a href="https://explorer.codechain.io/">CodeChain Explorer</a>: CodeChain block explorer.</li><li><a href="https://github.com/CodeChain-io/codechain-indexer">CodeChain Indexer</a>: A query engine that provides data search on CodeChain.</li><li><a href="https://corgi.codechain.io/faucet">https://corgi.codechain.io/faucet</a>: A web service that issues CodeChain testnet coins.</li><li><a href="https://github.com/CodeChain-io/codechain-sdk-js">CodeChain SDK JS</a>: CodeChain JavaScript SDK.</li><li><a href="https://github.com/CodeChain-io/codechain-test-helper-js">CodeChain TestHelper JS</a>: A JavaScript library to help you write CodeChain test cases.</li><li><a href="https://github.com/CodeChain-io/codechain-keystore-js">CodeChain KeyStore JS</a>: JavaScript library for CodeChain key generation and management.</li><li><a href="https://github.com/CodeChain-io/codechain-keystore-cli">CodeChain KeyStore CLI</a>: A tool to generate and manage CodeChain keys from the command line.</li><li><a href="https://github.com/CodeChain-io/codechain-dashboard">CodeChain Dashboard</a>: A tool for monitoring and managing multiple CodeChain nodes.</li></ul><p>Tool support is essential for facilitating usage for any software out there. CodeChain invests a lot of time and effort not only in developing our blockchain engine but also in the tools that allow the engine to be used easily. We are currently preparing a CodeChain Console project that will allow users to effortlessly issue digital assets on CodeChain. I’ll go into more detail about that in the next article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a56355444a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codechain/codechain-tooling-support-1a56355444a6">CodeChain Tooling Support</a> was originally published in <a href="https://medium.com/codechain">CodeChain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeChain transaction fees]]></title>
            <link>https://medium.com/codechain/codechain-transaction-fees-7c5a51dfd5bd?source=rss-ec4d2e62f8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c5a51dfd5bd</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[chaincode]]></category>
            <category><![CDATA[transaction-fees]]></category>
            <dc:creator><![CDATA[Kwang Yul Seo]]></dc:creator>
            <pubDate>Tue, 16 Apr 2019 06:30:46 GMT</pubDate>
            <atom:updated>2019-04-16T07:30:29.732Z</atom:updated>
            <content:encoded><![CDATA[<p>There has been continuous <a href="https://ethresear.ch/t/against-replacing-transaction-fees-with-deposits/940/3">debate over transaction fees</a>. There are two schools of thoughts on who should pay the transaction fees.</p><p>The first school claims that users should pay the transaction fees every time they interact with blockchain. Ethereum is a good example; users have to pay upfront transaction fees whenever they have to use the network. Players of the sensational game CryptoKitties must pay transaction fees whenever they trade or breed their cats on the Ethereum network.</p><p>The second claims that accounts should be rate-limited based on their balance. If you own 1/1000 of the total stake, then you will always have access to 1/1000th of the total network bandwidth and storage. This is how EOS achieves the “no transaction fees” for end users. In this case, DApp developers pay transaction fees on behalf of the users by the capital lockup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8dztYu2TPMrFyJQNN9vBQQ.jpeg" /></figure><p>Our team agrees to EOS’s idea in that interacting with the blockchain must be free; otherwise, users of a platform that needs continuous interactions will suffer a big pain in the neck. Imagine yourself paying transaction fees every time you click a “Like” button on a social media dapp!</p><p>However, the ownership model of EOS is not only hard to implement, or I’d say rather impossible, but also does not address efficiency issues. What if you own only 10 EOS out of 1 billion EOS tokens? How does an EOS block producer schedule your transactions and rate limit them? Are modern operating systems and VMs capable of scheduling them to this precision? EOS’s so-called “<a href="https://github.com/EOSIO/Documentation/blob/master/TechnicalWhitePaper.md#subjective-best-effort-scheduling">Subject Best Effort Scheduling</a>” deliberately avoids specifying how to achieve this.</p><p>It does not make economic sense either. Vitalik already pointed out this problem in his critics on EOS. If block producers have the power to choose from a list of transactions which ones to include in the next block, transaction senders naturally have the incentive to bribe block producers.</p><p>So what do we need? A blockchain network has to let application providers pay for the transaction fees in lieu of their users if they wish. This is the most popular cost model used by most Internet services and games and solves the real pain of current Ethereum Dapps which enforce their users to pay transaction fees whenever they interact with the blockchain.</p><p>In CodeChain, anyone who signs the transaction pays the transaction fee. Users create transactions and send them to the gateway which is run by their application provider. The gateway pays the transaction fees by signing the transaction. It is also possible for a user to sign the transaction by herself if she is willing to pay for the transaction fee.</p><p>In conclusion, CodeChain achieves no transaction fees for end users and no capital lockup cost for application providers. This model allows application providers who start small services to make use of our blockchain technology without needing big amount of capital lockup as in the case of EOS. It also allows application providers to provide a service without making their users suffer from paying fees every time they input an action.</p><p><strong>Check out the source code at our </strong><a href="https://github.com/CodeChain-io/codechain/wiki"><strong>github repo</strong></a><strong>. If you would like to chat with the CodeChain developers’ community, join our </strong><a href="https://gitter.im/CodeChain-io/codechain"><strong>gitter channel</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c5a51dfd5bd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codechain/codechain-transaction-fees-7c5a51dfd5bd">CodeChain transaction fees</a> was originally published in <a href="https://medium.com/codechain">CodeChain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeChain Consensus Algorithms]]></title>
            <link>https://medium.com/codechain/codechain-consensus-algorithms-8c7bb6477a41?source=rss-ec4d2e62f8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c7bb6477a41</guid>
            <category><![CDATA[chaincode]]></category>
            <category><![CDATA[consensus]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Kwang Yul Seo]]></dc:creator>
            <pubDate>Tue, 16 Oct 2018 03:33:08 GMT</pubDate>
            <atom:updated>2018-10-17T06:45:08.328Z</atom:updated>
            <content:encoded><![CDATA[<p>What is the best consensus algorithm? PoW (Proof of Work), PoS (Proof of Stake) or PoA (Proof of Authority)? There is no right answer here. It is hard to say a specific consensus algorithm is the best because each algorithm has its merits and demerits regarding performance, security, and decentralization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NtNByQ8WIgAGZh3dzJy8Xg.jpeg" /></figure><p>When you set up a blockchain network by yourself, you need to choose a consensus algorithm that meets your network requirements. If you want a consensus algorithm that provides high TPS (Transaction Per Second) and fast block confirmation speed, a consensus algorithm based on BFT (Byzantine Fault Tolerance) is definitely the right choice. However, if you build an application that requires many validators with a high level of security, PoW is a better option.</p><p>CodeChain lets you choose a consensus algorithm when you set up a network. Currently, it supports PoA, PoW, and <a href="https://allquantor.at/blockchainbib/pdf/buchman2016tendermint.pdf">Tendermint</a>. CodeChain has a pluggable consensus architecture, which allows easy integration of new consensus algorithms. You can choose a consensus algorithm that best serves your application.</p><p>CodeChain currently runs two testnets.</p><p>Our first testnet, <a href="https://saluki.codechain.io/">Saluki</a>, uses a PoA consensus algorithm. Because we know the identity of nodes participating in a PoA network, we can punish Byzantine nodes by law. PoA is simple and fast because it does not need a staking mechanism that slashes the deposit of a node when the node misbehaves.</p><p>Our other testnet, <a href="https://husky.codechain.io/">Husky</a>, uses a PoW consensus algorithm based on the <a href="https://github.com/tromp/cuckoo">Cuckoo Cycle</a>. Each node has to compute the solution of the problem by finding cycles in random bipartite graphs. When a node finds a solution, it can produce a block and get the block reward. Husky currently produces a block every 30 seconds and the difficulty is adjusted automatically if block producing speed is either too fast or too slow.</p><p>We are going to open our third testnet, Corgi, that uses Tendermint, the best known BFT consensus algorithm. Tendermint is resilient up to ⅓ Byzantine nodes and has the throughput of 1000–2000 TPS. It guarantees instant finality (3–4 seconds) while PoW only has probabilistic finality. Some deposits are required to participate in the network as a node and they are slashed when the node misbehaves. BFT is different from PoA in that a node does not need to verify its identity.</p><p>CodeChain is experimenting with many new consensus algorithms as well. One is a consensus algorithm that is similar to <a href="https://people.csail.mit.edu/nickolai/papers/gilad-algorand-eprint.pdf">Algorand</a> which utilizes a <a href="https://people.csail.mit.edu/silvio/Selected%20Scientific%20Papers/Pseudo%20Randomness/Verifiable_Random_Functions.pdf">VRF (Verifiable Random Function)</a> to choose committee members. We are also experimenting with a hybrid approach which combines PoW and BFT where PoW is used to choose committee members for BFT consensus. More details will follow soon.</p><p>Blockchain consensus algorithms are actively being researched at the moment. We expect many new consensus algorithms that achieve performance, security, and decentralization simultaneously will be proposed. CodeChain will provide a test bed where researchers and developers can experiment with their new ideas without a hassle.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c7bb6477a41" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codechain/codechain-consensus-algorithms-8c7bb6477a41">CodeChain Consensus Algorithms</a> was originally published in <a href="https://medium.com/codechain">CodeChain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeChain’s Merkleized UTXO Set]]></title>
            <link>https://medium.com/codechain/codechains-merkleized-utxo-set-c76c9376fd4f?source=rss-ec4d2e62f8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c76c9376fd4f</guid>
            <category><![CDATA[chaincode]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[utxo]]></category>
            <category><![CDATA[merkle-patrcia-trie]]></category>
            <category><![CDATA[utxo-set]]></category>
            <dc:creator><![CDATA[Kwang Yul Seo]]></dc:creator>
            <pubDate>Wed, 02 May 2018 02:38:51 GMT</pubDate>
            <atom:updated>2018-07-27T23:59:55.862Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bitcoin UTXO Set</h3><p>Bitcoin makes use of the Unspent Transaction Output (UTXO) set to keep track of output transactions that have not been yet spent. The UTXO stores all the required information to validate a new transaction without having to inspect the full blockchain. When a new transaction is created, UTXOs are used to claim the funds they are holding, and new UTXOs are created. Therefore, the data structure of this set directly impacts the performance and storage requirements of Bitcoin.</p><p>Bitcoin Core has constantly been improving the internal format of the UTXO set in favor of better performance both in reading time and memory usage. <a href="https://eprint.iacr.org/2017/1095.pdf">Analysis of the Bitcoin UTXO set</a> succinctly describes the Bitcoin Core 0.15 format of the UTXO set as follows:</p><blockquote><em>This new format uses a per-output model in contrast to the previously defined per-transaction model, that is, every entry in the chainstate now represents a single UTXO, instead of a collection of all the UTXOs available for a give transaction. To achieve this, the key-value (known as outpoint-coin in the source code) structure has been modified. Keys encode both the 32-byte transaction hash and the index of the unspent output, preceded by the prefix “C”. Regarding coins, each one encodes a code, that contains metadata about the block height and whether the transaction is coinbase or not (notice that the transaction version has been dropped), a compressed amount of bitcoins, and the output type and script encoded in the same way as the version v0.14.</em></blockquote><p>In other words, an entry in the UTXO set represents a single UTXO which contains the information required to validate a new transaction without access to the blockchain. However, this is not the end of the story. <a href="https://medium.com/@ConsenSys/thoughts-on-utxo-by-vitalik-buterin-2bb782c67e53">One common argument against UTXOs</a> is that the UTXOs are unnecessarily complicated and there is some truth in it.</p><p>Because Bitcoin uses Proof of Work consensus, there are occasional chain reorganizations. When a fork becomes the canonical chain, some blocks are retracted. The UTXO set must be able to undo all the changes made by the transactions included in the retraced blocks. Thus, Bitcoin Core keeps track of <a href="https://bitcoin.stackexchange.com/a/57981">undo data</a> for each block and applies undo data to revert changes made to the UTXO set by the retracted blocks. This complicates the implementation of the Bitcoin Core UTXO Set.</p><h3>Merkleized UTXO Set</h3><p>CodeChain implements the UTXO set on top of <a href="https://github.com/ethereum/wiki/wiki/Design-Rationale#merkle-patricia-trees">Merkle Patricia Trie</a>. MPT has been adopted by Ripple and Ethereum and is used to store all account state, as well as transactions receipts in each block. The key properties of MPT are as follows:</p><ol><li>Every unique set of key/value pairs maps uniquely to a root hash, and it is not possible to spoof membership of a key/value pair in a trie (unless an attacker has ~2¹²⁸ computing power)</li><li>It is possible to change, add or delete key/value pairs in logarithmic time</li></ol><p>MPT is a key-value pairs map which has some <a href="https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/">nice properties</a>. One property that is particularly useful in the context of UTXO set implementation is that we can safely go back to the previous state without keeping track of any undo data. For example, Ethereum can quickly go back to the previous state by switching the state root to the state root of the previous block as depicted below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/0*GeqqTkQ_damU_K48." /></figure><p>CodeChain stores UTXOs as well as account state and asset scheme in MPT. The keys of UTXO entry encode both the 32-byte transaction hash and the index of the unspent output, preceded by the prefix “A”. Values contain the information required to validate a transaction such as an asset type, lock script hash, lock script parameters and amount. Thanks to the nice property of MPT described above, CodeChain does not need to keep track of separate undo data. MPT already contains all the necessary information required to go back to the previous state including account state, asset scheme, and UTXOs.</p><p>In summary, CodeChain implemented the UTXO set on top of MPT so that it has become easy to restore state when chain reorganization occurs. We will share performance and memory usage data in an upcoming post. Stay tuned!</p><p><strong>Check out the source code at our </strong><a href="https://github.com/CodeChain-io/codechain/wiki"><strong>github repo</strong></a><strong>. If you would like to chat with the CodeChain developers’ community, join our </strong><a href="https://gitter.im/CodeChain-io/codechain"><strong>gitter channel</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c76c9376fd4f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codechain/codechains-merkleized-utxo-set-c76c9376fd4f">CodeChain’s Merkleized UTXO Set</a> was originally published in <a href="https://medium.com/codechain">CodeChain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeChain’s UTXO Model]]></title>
            <link>https://medium.com/codechain/codechains-utxo-model-fc967901578d?source=rss-ec4d2e62f8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc967901578d</guid>
            <category><![CDATA[utxo]]></category>
            <category><![CDATA[cold-wallet]]></category>
            <category><![CDATA[chaincode]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Kwang Yul Seo]]></dc:creator>
            <pubDate>Tue, 01 May 2018 02:47:06 GMT</pubDate>
            <atom:updated>2018-07-05T02:02:26.524Z</atom:updated>
            <content:encoded><![CDATA[<p>Two bookkeeping models are popular in today’s blockchain technology. The first model is called the <a href="https://bitcoin.org/en/glossary/unspent-transaction-output">UTXO(Unspent Transaction Output)</a> model and the second one is the Account/Balance model. The UTXO model has been firstly employed by Bitcoin and used by many other cryptocurrencies derived from Bitcoin. Ethereum and other smart contract platforms are using the Account/Balance model.</p><p>CodeChain is a programmable multi-asset blockchain platform which is inspired by Color Coins project. In this article, we will explain how CodeChain’s UTXO model works and how it differs from Bitcoin’s UTXO model.</p><p>In the UTXO model, each transaction spends output from prior transactions and generates new outputs that can be spent by future transactions. The benefits of the UTXO model are:</p><ol><li><strong>Scalability</strong>: It is possible to process multiple UTXOs at the same time. Because CodeChain aims to provide a scalable blockchain solution to multi-asset applications such as games, the scalability benefit of the UTXO model becomes very important.</li><li><strong>Privacy</strong>: UTXO provides a higher level of privacy if a user uses new addresses for each transaction.</li></ol><p>A user’s balance in UTXO model is not stored as a single number; rather, it must be computed as the total sum of the UTXOs that the user owns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*2XYQwqigJa1sa5oT." /></figure><p>In the UTXO model, a transaction must satisfy two rules:</p><ol><li>It must contain a valid signature for the owner of each UTXO it consumes.</li><li>The total sum of the UTXOx consumed must be equal or greater than the total sum of the UTXOs it produces. This rule prevents accidental inflation.</li></ol><p>So far so good, but there is one serious problem with Bitcoin’s implementation. A transaction input in Bitcoin only contains the transaction hash and index of the output. It means that we cannot tell how much a transaction is spending without having to have all the input transactions.</p><p>Here is an example showing why it is a serious problem:</p><blockquote><em>Let’s say I want to create a $10 offline signing device. I will put 32 kB of RAM and a small screen and a tiny embedded chip that is just powerful enough for ECDSA signing. It will sign transactions for me after asking me to physically confirm with a button press. But the device has so little RAM, it can’t support arbitrary transactions. So, I’ll just make sure my online computer software never produces transactions bigger than 10 kB, and just do multiple transactions if necessary.</em></blockquote><p><a href="https://bitcointalk.org/index.php?topic=181734.0">In Bitcoin, this isn’t possible</a>. Without access to the blockchain, the device does not know whether it is signing 1 BTC input, or 1000 BTC input without supplying all supporting transaction along with the one to be signed.</p><p>Our team recognized this problem from day 1 and solved it simply by adding input value to transactions. Now we can tell how much a transaction is spending without having to have input transactions. When a CodeChain offline wallet user signs a transaction input that is worth 12.33 coins, the signature becomes only valid if that’s how much it’s actually worth. This small change greatly simplified offline tx signing.</p><p>Here is CodeChain’s <em>AssetOutPoint</em> struct which corresponds to Bitcoin’s <em>COutPoint</em> class. You can see it has <em>amount</em> field.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd486ba80cbc9b4b0a502d8b9ce8d155/href">https://medium.com/media/dd486ba80cbc9b4b0a502d8b9ce8d155/href</a></iframe><p>In conclusion, a small change in transaction format can greatly simplify offline tx signing. CodeChain learned this lesson from Bitcoin. It would be great that Bitcoin also had this support which only takes a few lines of code, but unfortunately this would mean a hard-fork.</p><p><strong>Check out the source code at our </strong><a href="https://github.com/CodeChain-io/codechain/wiki"><strong>github repo</strong></a><strong>. If you would like to chat with the CodeChain developers community, join our </strong><a href="https://gitter.im/CodeChain-io/codechain"><strong>gitter channel</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc967901578d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codechain/codechains-utxo-model-fc967901578d">CodeChain’s UTXO Model</a> was originally published in <a href="https://medium.com/codechain">CodeChain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open Sourcing language-solidity, a Solidity parser written in TypeScript]]></title>
            <link>https://medium.com/codechain/open-sourcing-language-solidity-a-solidity-parser-written-in-typescript-375d240f7bf3?source=rss-ec4d2e62f8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/375d240f7bf3</guid>
            <category><![CDATA[solidity-language]]></category>
            <category><![CDATA[kodebox]]></category>
            <category><![CDATA[tooling]]></category>
            <category><![CDATA[parser]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Kwang Yul Seo]]></dc:creator>
            <pubDate>Mon, 30 Apr 2018 09:11:25 GMT</pubDate>
            <atom:updated>2018-05-29T04:27:17.337Z</atom:updated>
            <content:encoded><![CDATA[<p>Posted by <a href="http://localhost:1313/post/open-sourcing-language-solidity/#">CodeChain Team</a> on Tue, Nov 7, 2017</p><p>Solidity is a new experimental language for writing smart contracts. It is still in an early stage of development and lacks the tooling needed to be considered a serious programming language. One of the big problems that Solidity has is that it lacks a formal language specification. <a href="https://github.com/ethereum/solidity">The official Solidity compiler</a> is the only Solidity compiler available and unfortunately it is its implementation detail, and not the spec, that specifies the behavior of the programs. So it is not easy to write a spec-conforming language tool without reusing the source code of the compiler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*AMGS0G4Y4iEW7jQxNrtcoA.png" /></figure><p>Many Solidity tools such as <a href="https://github.com/duaraghav8/Solium">Solium</a> and <a href="https://github.com/juanfranblanco/vscode-solidity">vscode-solidity</a> are written in JavaScript/TypeScript. They use Consensys’ <a href="https://github.com/ConsenSys/solidity-parser">solidity-parser</a> or its variant <a href="https://github.com/duaraghav8/solparse">solparse</a>to parse a Solidity program into a syntax tree. But these parsers do not conform to the specification. They work fine for simple imports parsing, but for full Solidity parsing its structure is too different from the official Solidity specification (or C++ implementation). They keep breaking for all sorts of edge cases.</p><p>Since CodeChain team needed a 100% compatible Solidity parser to implement advanced language server features such as auto-completion, formatting and renaming, we wrote a spec conforming Solidity parser in TypeScript and decided to release it as an open source project.</p><p><a href="https://github.com/CodeChain-io/language-solidity">language-solidity</a> currently provides the lexer, parser and AST nodes for manipulating Solidity programs. The code is based on the Solidity compiler written in C++, and it passes all the parser tests of the compiler.</p><p>Here’s an example program which extracts the contract names from the given Solidity program:</p><pre>import * as fs from &quot;fs&quot;;<br><br>import {<br>    ASTVisitor,<br>    CharStream,<br>    ContractDefinition,<br>    DiagnosticReporter,<br>    Parser,<br>    Scanner,<br>    SourceUnit<br>} from &quot;../src&quot;;<br><br>class ContractNameCollector extends ASTVisitor {<br>    public contractNames: string[] = [];<br><br>    constructor(node: SourceUnit) {<br>        super();<br>        node.accept(this);<br>    }<br><br>    public visitContractDefinition(node: ContractDefinition): boolean {<br>        this.contractNames.push(node.name);<br>        return true;<br>    }<br>}<br><br>function main() {<br>    const source = fs.readFileSync(&quot;MetaCoin.sol&quot;).toString();<br>    const scanner = new Scanner(new CharStream(source));<br>    const reporter = new DiagnosticReporter();<br>    const parser = new Parser(reporter);<br>    const node = parser.parse(scanner);<br>    const collector = new ContractNameCollector(node);<br>    console.log(collector.contractNames);<br>}<br><br>main();</pre><p><a href="https://github.com/CodeChain-io/solidity-language-server">Our Solidity language server</a> has already begun to use <a href="https://github.com/CodeChain-io/language-solidity">language-solidity</a> for imports parsing and will use it to implement other advanced IDE features. We certainly believe the newly Solidity parser will help the Solidity community create better tooling.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=375d240f7bf3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codechain/open-sourcing-language-solidity-a-solidity-parser-written-in-typescript-375d240f7bf3">Open Sourcing language-solidity, a Solidity parser written in TypeScript</a> was originally published in <a href="https://medium.com/codechain">CodeChain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solidity Language Support for VSCode]]></title>
            <link>https://medium.com/codechain/solidity-language-support-for-vscode-541edf23e43d?source=rss-ec4d2e62f8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/541edf23e43d</guid>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[lsp]]></category>
            <category><![CDATA[language-server]]></category>
            <category><![CDATA[kodebox]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Kwang Yul Seo]]></dc:creator>
            <pubDate>Mon, 30 Apr 2018 09:09:23 GMT</pubDate>
            <atom:updated>2018-05-29T04:27:30.938Z</atom:updated>
            <content:encoded><![CDATA[<p>Posted by <a href="http://localhost:1313/post/solidity-language-support-vscode-extension/#">CodeChain Team</a> on Sat, Oct 14, 2017</p><p><a href="https://marketplace.visualstudio.com/items?itemName=kodebox.solidity-language-server#overview">Solidity Language Support for VSCode</a> is now available at the Visual Studio Code Marketplace. This extension is powered by <a href="https://github.com/CodeChain-io/solidity-language-server">solidity-language-server</a> which was released as an open source project a few days ago.</p><p>Solidity Language Support provides:</p><ul><li>Syntax highlight</li><li>Diagnostics via solc and solium</li><li>Auto-completion</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*0K8u79-8UJYT5VAgd5Q7nA.gif" /></figure><p>Solidity Language Support extension automatically recognizes the project structure created by <a href="http://truffleframework.com/docs/getting_started/packages-npm">truffle</a> and resolves modules located under “installed_contracts” directory which are installed by truffle installcommand. It also locates modules under “node_modules” directory which are installed by npm install command.</p><p>Other IDEs features such as “jump to definition”, “type information and documentation on hover”, and renaming will be available soon.</p><p>Enjoy smart contract hacking with Solidity Language Support!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=541edf23e43d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codechain/solidity-language-support-for-vscode-541edf23e43d">Solidity Language Support for VSCode</a> was originally published in <a href="https://medium.com/codechain">CodeChain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Idioms of Solidity Smart Contract Programming]]></title>
            <link>https://medium.com/codechain/idioms-of-solidity-smart-contract-programming-codechain-tech-blog-7302b7e5a590?source=rss-ec4d2e62f8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/7302b7e5a590</guid>
            <category><![CDATA[planets]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[idioms]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Kwang Yul Seo]]></dc:creator>
            <pubDate>Thu, 26 Apr 2018 14:20:54 GMT</pubDate>
            <atom:updated>2018-08-07T15:25:15.107Z</atom:updated>
            <content:encoded><![CDATA[<p>Solidity is a new and highly experimental programming language for writing Ethereum-flavoured smart contracts. When Solidity first came out, nobody likely knew how to write smart contracts. One could learn the syntax and semantics of the language, but it was impossible to refer to other idioms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D_n9L0p48ZQXkonq8Pqe8A.jpeg" /></figure><p>Fortunately, as developers started to write smart contracts over time, several patterns and idioms have emerged. For example, smart contract developers realized that they tended to write the same life cycle management and access control code again and again. So they started to create a reusable library that could be imported by other smart contracts.</p><p>The most popular library is <a href="https://github.com/OpenZeppelin/zeppelin-solidity">OpenZeppelin</a>. It provides secure, tested and community-audited code that can be reused. In this post, we will look at some of the most common idioms of Solidity smart contract programming through OpenZeppelin library.</p><h3>Ownership</h3><p>Many smart contracts have functions that only its owner can call. A common way of implementing this is to assign the value of msg.sender to a state variable. Then functions that need access control check if msg.sender is equal to the stored owner and throw if they do not match.</p><p>OpenZeppelin’s Ownable contract captures the essence of this idiom. onlyOwner modifier provided by Ownable throws if it is called by any account other than the owner. A smart contract inheriting Ownable can simply add onlyOwner modifier to the functions that need access control.</p><pre>contract Ownable {</pre><pre>  address <strong>public</strong> owner;</pre><pre><strong>  function</strong> <strong>Ownable</strong>() {</pre><pre>    owner = msg.sender;</pre><pre>  }</pre><pre>  modifier onlyOwner() {</pre><pre><strong>    require</strong>(msg.sender == owner);</pre><pre>    _;</pre><pre>  }</pre><pre>}</pre><p>Ownable also provides transferOwnership function which transfers control to a new owner. It emits OwnershipTransferred event once the ownership is successfully transferred.</p><h3>Lifecycle management</h3><p>In addition to the ownership management, a lot of smart contracts need to be destroyed when they are no longer needed. selfdestruct operation removes the code from the blockchain and sends the remaining Ether stored at the contract address to a designated target. As this operation must be called by the owner of the contract, OpenZeppelin provides Destructible contract which is inherited from Ownable. Its member function destroy transfers the current balance to the owner while its sibling member destroyAndSend transfers the current balance to the given recipient.</p><pre>contract Destructible is Ownable {</pre><pre><strong>  function</strong> <strong>Destructible</strong>() <strong>payable</strong> { }</pre><pre><strong>  function</strong> <strong>destroy</strong>() <strong>onlyOwner</strong> {</pre><pre>    selfdestruct(owner);</pre><pre>  }</pre><pre><strong>  function</strong> <strong>destroyAndSend</strong>(address _recipient) <strong>onlyOwner</strong> {</pre><pre>    selfdestruct(_recipient);</pre><pre>  }</pre><pre>}</pre><p>Another common idiom regarding the lifecycle management of a contract is circuit breaker. Any non-trivial contract has errors in it. Peer review and code auditing cannot guarantee the absence of bugs since new bugs and security risks are being constantly discovered. Therefore, you must be able to respond to bugs and vulnerabilities.</p><p>Circuit breaker provides a way of pausing a contract when things go wrong. OpenZeppelin’s Pausable contract is the implementation of circuit breaker idiom. Functions decorated with whenNotPaused modifier throw when the contract is paused by calling pause function. When you discover your smart contract is under attack, you can buy time to upgrade the contract by immediately pausing the contract.</p><pre>contract Pausable <strong>is</strong> Ownable {</pre><pre><strong>  event</strong> <strong>Pause</strong>();</pre><pre><strong>  event</strong> <strong>Unpause</strong>();</pre><pre><strong>  bool</strong> <strong>public</strong> paused = false;</pre><pre>  modifier <strong>whenNotPaused</strong>() {</pre><pre>    require(!paused);</pre><pre>    _;</pre><pre>  }</pre><pre>  modifier <strong>whenPaused</strong>() {</pre><pre>    require(paused);</pre><pre>    _;</pre><pre>  }</pre><pre>  function <strong>pause</strong>() onlyOwner whenNotPaused {</pre><pre>    paused = true;</pre><pre>    Pause();</pre><pre>  }</pre><pre>  function <strong>unpause</strong>() onlyOwner whenPaused {</pre><pre>    paused = false;</pre><pre>    Unpause();</pre><pre>  }</pre><pre>}</pre><p>In this post, we covered only the most common idioms that are used in almost all contracts. This is not the end of story. There are other idioms for common smart contract usages such as crowdsale and token. If you are interested in knowing more, refer to <a href="https://github.com/OpenZeppelin/zeppelin-solidity">the source code of OpenZeppelin</a>.</p><p>Originally Posted by <a href="https://blog.codechain.io/post/idioms-of-solidity-smart-contract-programming/#">CodeChain Team</a> on Wed, Oct 18, 2017</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7302b7e5a590" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codechain/idioms-of-solidity-smart-contract-programming-codechain-tech-blog-7302b7e5a590">Idioms of Solidity Smart Contract Programming</a> was originally published in <a href="https://medium.com/codechain">CodeChain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EVM STATICCALL opcode]]></title>
            <link>https://medium.com/codechain/evm-staticcall-opcode-a3f821b3ff3?source=rss-ec4d2e62f8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3f821b3ff3</guid>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[kodebox]]></category>
            <category><![CDATA[staticcall]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Kwang Yul Seo]]></dc:creator>
            <pubDate>Mon, 16 Apr 2018 02:11:09 GMT</pubDate>
            <atom:updated>2018-05-29T04:27:44.123Z</atom:updated>
            <content:encoded><![CDATA[<p>The Byzantium hardfork added a new opcode called STATICCALL to EVM. In this post, we will take a look at this new opcode and explain in detail the problem it addresses to solve.</p><h3>What is it?</h3><p>STATICCALL is a new variant of CALL that permits only non-state-changing calls to other contracts (including itself). Any opcode that performs modifications to the state results in an exception instead of performing the modification. It is specified in <a href="https://github.com/ethereum/EIPs/pull/214">EIP214</a> and is included in the Byzantium HF upgrade.</p><p>State change operations include:</p><ul><li>CREATE, CREATE2</li><li>LOG0, LOG1, LOG2, LOG3, LOG4</li><li>SSTORE</li><li>SELFDESTRUCT</li><li>CALL with a non-zero value</li></ul><p>Note that CALLCODE is not included in the list even when the value is non-zero.</p><h3>What problem it addresses to solve</h3><p>What’s the essence of smart contracts? They are basically a state transition function which results in a new state given the current state and arguments. To write smart contracts securely, you need to control when the state can be modified.</p><p>STATICCALL allows you to call a function while disallowing any state change operation. If a contract depends only on reading data from another contract, you can safely assume that a conflicting state change won’t be triggered. It means a subset of <a href="https://github.com/ConsenSys/smart-contract-best-practices#reentrancy">reentrancy vulnerabilities</a> is prevented.</p><h3>How it is related to Solidity</h3><p>Solidity already has the so-calledpure and view state modifiers.</p><ul><li><em>pure</em>: functions that do not read or modify the state of the blockchain</li><li><em>view</em>: functions that can read, but never modify the state of the blockchain</li></ul><p>At first it may look as if STATICCALL had a strong relationship with view state modifier because both allow only read and disallow modifications to the state. However, Solidity does not compile invocations of functions with view state modifier to STATICALL. Currently, both <em>view</em> and <em>pure</em> modifiers are enforced only in the compile time and erased once they are compiled to EVM bytecodes. However, it could be possible that future versions of the Solidity compiler use STATICCALL to enhance the security of Solidity programs.</p><p>This post was written in Oct 22, 2017.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3f821b3ff3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codechain/evm-staticcall-opcode-a3f821b3ff3">EVM STATICCALL opcode</a> was originally published in <a href="https://medium.com/codechain">CodeChain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>