<?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[WASM conference - Medium]]></title>
        <description><![CDATA[A 1-day virtual event dedicated to the Polkadot smart contracts. We will bring top parachains, prospects, and builders together to create the future of Polkadot. - Medium]]></description>
        <link>https://medium.com/supercolony?source=rss----35210e40651d---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>WASM conference - Medium</title>
            <link>https://medium.com/supercolony?source=rss----35210e40651d---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 00:29:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/supercolony" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deep dive into OpenBrush]]></title>
            <link>https://medium.com/supercolony/deep-dive-into-openbrush-dc04d5cc7825?source=rss----35210e40651d---4</link>
            <guid isPermaLink="false">https://medium.com/p/dc04d5cc7825</guid>
            <category><![CDATA[ink]]></category>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[wasm]]></category>
            <category><![CDATA[openzeppelin]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Sven Seven]]></dc:creator>
            <pubDate>Mon, 25 Jul 2022 22:11:02 GMT</pubDate>
            <atom:updated>2022-08-15T10:06:49.811Z</atom:updated>
            <content:encoded><![CDATA[<p>My name is Danylo Semirazov — I am a CTO at Asylum and Supercolony and will walk you through our open-source product — OpenBrush, a tool for smart contracts development. I’ll explain to you what it is and why it is crucial for the future of WASM smart contracts.</p><p>When we started our product a year ago, on the scene of Smart Contracts development, the Ethereum ecosystem looked way more attractive. You can start scratching a project in Remix IDE, and take basic blocks from OpenZeppelin contracts, which are well tested and secure. Then, cover your contracts with integration tests with the help of Hardhat or Truffle, then deploy your contracts on test-net Rinkeby with the help of Infura suite. Unlike Ethereum, Polkadot community pays less attention to Smart Contracts, focusing more on Layer-1 solutions. But still, there is a beautiful tool ink!, which allows you to write Smart contracts on Rust and then compile them into WASM.</p><p>But still, talking about the developer tools, there is no such diversity as in Ethereum, and for ordinary developers, it is tough to start something in Polkadot.</p><p>I want to share with you our experience. In May 2021 together with our friends AllianceBlock, we were working on the lending protocol and we decided to implement it fully on smart contracts in ink! and thus test this concept. It was so difficult to build something complex in ink! so we started by implementing the basic blocks: FT in ink!, NFT, Multi Token standards and then layered the functionality step by step. Then we combined all these best practices and utilities and created a library based on which we successfully built quite complex DeFi projects on smart contracts which are DEX and lending protocol.</p><h3>What is OpenBrush?</h3><p>Further, with the support of W3F we introduced this library to the public and named it — OpenBrush. So OpenBrush is a library for secure smart contracts development in ink!. And now you have ink! and a Brush to write your beautiful smart contracts in Polkadot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NKPHltEoo2wkdHkhKmO1ng.png" /></figure><h3>Motivation</h3><p>Our motivation was relatively straightforward. We wanted to have a library on Rust for writing smart contracts which will ease the smart contract development by providing all necessary utilities. Moreover, the library should provide secure and easy-to-reuse contracts built upon the standards to make these contracts interoperable, which is very important. We understand that it is impossible without contributing to ink! and substrate contracts pallet and this is the part of OpenBrush team’s responsibility. Finally, such a library should serve as some kind of entry point for any smart contract developer in Polkadot.</p><h3>Features</h3><p>Let’s eventually understand the features OpenBrush provides. According to the Rust specifics, we call the first feature default implementation.</p><h4>Default implementation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YQ4URpV2q1TQ2gUwPVGdcQ.png" /></figure><p>Open Brush includes over 25 contract default implementations. You can reuse our implementations simply by specifying the contract’s storage and selecting the field where default storage will be embedded, and then implementing default traits for your storage. Thereby you’ll inherit all necessary methods from the default implementation.</p><h3>Contracts</h3><p>You have contracts default implementations for different purposes, and this list is not final and will be extended with future library releases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hcMW_m1Sg10KgR6np1Ci0A.png" /></figure><h3>Modifiers</h3><p>Modifiers are pretty much the same concept as in Solidity. You can use them, for instance, to declaratively control the access to the contracts’ method. As you can see in the example below, only the owner can access the mint method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g3AciDDito8BQn40yZyYHg.png" /></figure><h3>Wrappers</h3><p>Wrappers is a handy feature that simplifies the cross-contact communication within your project. Due to the Rust specifics, the cross-contract communication can be pretty verbose, so we hid all inners inside the beautiful #[brush::wrapper] macro, and you can simply refer to any contract in the network by its interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x5Nwld2jjlL5gtlACgC60g.png" /></figure><h3>Upgradeable Contracts</h3><p>The next feature is upgradeable contracts, and at the moment, you have two options to write your upgradeable contracts. The first option is more from the Ethereum world, and you can use the delegate code technique: Proxy or Diamond standard. The second option is the powerful set_code_hash, and I’d mark this option as high risk as you can lose access to the contract storage by mistake, but it’s closer to the Polkadot world. A more detailed explanation of upgradable contracts in ink! you can find in Polkadot Decoded video below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Feo_cY8lVNes%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Deo_cY8lVNes&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Feo_cY8lVNes%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c81098ae65912fd5abe197fe15327ebe/href">https://medium.com/media/c81098ae65912fd5abe197fe15327ebe/href</a></iframe><h3>Optimized WASM binary size</h3><p>One is the bottleneck of the contracts pallet in Polkadot might become Relay Chain validators who will execute smart contracts WASM binary. That’s why we should keep the lowest binary size, and we did a lot of work around the storage data structure in ink! to find the best option which will be easy to use and well-optimized. Of course, it comes without saying that all OpenBrush default implementations are size optimized.</p><h3>Standards</h3><p>There is not much sense in talking about smart contracts if they’re not built upon the standards. Standards are very important for interoperability and in the Polkadot world, we have the Polkadot Standards Proposal (PSP), which is a community-driven repository for such standards. With the OpenBrush team, we developed and proposed three token standards: FT standard — PSP22, NFT standard — PSP34, and Multi Token standard — PSP35. Two of them are already accepted by the community, and the last one is in the finalization stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JtGcuO6xXL_dvHXaRViPqw.png" /></figure><p>These standards are pretty much inspired by ERC20, 721, and 1155 but more advanced, keeping the Polkadot specifics, covering some missing features, and more open for extension.</p><h3>What are our plans?</h3><p>It’s hard to find a project in the Dotsama community that doesn’t support XCM — the Cross-Consensus Message Format, which is so crucial and so important for interoperability in the Polkadot. OpenBrush contracts are not an exception. We’re going to implement the chain extension for each kind of token standard introduced in OpenBrush. Thus delegating the storage to the substrate level instead of the contract level. Of course, we have to standardize it via PSP so that anyone in the network can achieve interoperability in smart contracts. These steps will, of course, reduce the size of the smart contracts and finally bring XCM support by default so that any PSP22 smart contract deployed to Parachain A can talk to another PSP22 smart contract on Parachain B.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GzCDZOL5fVBVMR6Ojs9gFA.png" /></figure><h3>New standards for WASM contracts</h3><p>We plan to create an NFT2.0 token standard. Of course, we will create the chain extension and bring XCM support and in the same way, we’re going to introduce the multi-token standard on the substrate level and integrate it with the smart contracts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGxJbDcHrGlpXuMFOJWT1g.png" /></figure><h3>Adoption</h3><p>We have to fight for developers&#39; attention as they are crucial players who push the community, so we have to make WASM smart contracts more attractive. Developers adore educational materials, and that’s why we’re going to create more educational content, articles, and videos and continue updating our documentation. We have already done three workshops, and we are going to make more and continue our social network activity. Talking about their marketing strategy, we are going to organize the hackathons and involve developers from different channels, and introduce the power of WASM smart contracts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oHWFu11lOfKAPN4aYK6eKw.png" /></figure><h3>About Supercolony 🪐</h3><p>Supercolony is a venture studio dedicated to converting business ideas into successful high-level companies, leading the development processes, improving and strengthening business models, and increasing market capitalization. Supercolony’s goal is ecosystem creation, taking leadership in moving the market forward, creating the vector of ecosystem development, and making the entrance points for businesses more accessible.</p><p>Our main mission is to make blockchain usable for everyone.</p><p><a href="https://www.linkedin.com/company/super-colony/mycompany/">LinkedIn</a> | <a href="https://supercolony.net/">Website</a> | <a href="https://twitter.com/supercolony_net">Twitter</a> |<a href="https://t.me/supercolony_polkadot">Telegram</a> | <a href="https://github.com/Supercolony-net">GitHub</a> | <a href="https://www.youtube.com/channel/UC5278rH2_UejuHEVvsArvkA/videos">YouTube</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc04d5cc7825" width="1" height="1" alt=""><hr><p><a href="https://medium.com/supercolony/deep-dive-into-openbrush-dc04d5cc7825">Deep dive into OpenBrush</a> was originally published in <a href="https://medium.com/supercolony">WASM conference</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A look into Virtual Machines and Smart Contract Runtimes]]></title>
            <link>https://medium.com/supercolony/a-look-into-virtual-machines-and-smart-contract-runtimes-313cd7d494e3?source=rss----35210e40651d---4</link>
            <guid isPermaLink="false">https://medium.com/p/313cd7d494e3</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[wasm]]></category>
            <category><![CDATA[vm]]></category>
            <dc:creator><![CDATA[Karel Kubat]]></dc:creator>
            <pubDate>Thu, 16 Jun 2022 09:53:03 GMT</pubDate>
            <atom:updated>2022-06-16T09:53:03.435Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by Karel Kubat, CTO of Composable Finance</em></p><p><em>Post Material after WASM conference 2022</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fVub3Bv0YziUFaHc8Hff1g.png" /></figure><p>Virtual machines form the basis of execution environments for smart contracts. The EVM is the most dominant solution at the moment. Still, many models exist, some with only performance differences, others with changed semantics, such as an entirely different storage backend, account model, and calling convention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZ5a44T3I-CeXZPpLR47gw.png" /></figure><h3>Why should you care as a smart contract developer?</h3><p>To write a smart contract, one does not really need to know the internal implementation of the VM, aside from the account model and some general APIs. However, as substrate developers, we need to have a clearer understanding of the pallets we build and the different tradeoffs with regard to security and performance. To be a senior developer, you do not need to be able to read assembly, but it sure helps out a lot.</p><p>Choosing an actual ecosystem to develop on should then be related to current token prices, which contracts are easiest to copy-paste over, and what best suits the products you are trying to build.</p><h3>How does a chain actually run your contracts?</h3><p>Smart contracts are essentially Javascript runtime included in your browser or the operating system loading a binary. Code is loaded in some format from the chain’s storage, loaded into the VM instance, and passed the bytes from the transaction. The contract deserializes it into the types that the smart contract developer specifies, and then we enter the method written by the actual developer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NI4EJytsTDOpuf12" /></figure><p>Depending on the execution environment, the VM might allow the contract to directly access storage (using a cache for transactionality) or emit a UTXO for more exotic architectures. The same goes for reading storage of other contracts and directly calling them. Although the EVM did set a standard for these procedures, recently, a lot of cool work is being done on innovative runtimes deviating from the EVM’s model. On the surface, it seems to overcomplicate the smart contract logic, but the advantages are very significant overall.</p><p>There can be fairly obvious advantages, such as the ease of adding a precompile to Wasmer versus the full suite of changes needed to the EVM, opcode handling and logic with the EVM. In other cases, a UTXO based model better protects against re-entrancy, as the next contract call means that execution and in-memory state from the caller is wiped.</p><h3>Alternative model and its advantage: CosmWasm</h3><p>CosmWasm is very similar to ink! in many regards. Both are an eDSL (an embedded, domain-specific language -basically a fancy macro-), and libraries that do not depend on ink! or Cosmwasm host functions are fully compatible. In the end, all that their respective instances require are well-formed WASM programs with certain exports.</p><p>The differences become more apparent when we look at the calling of the contract. In CosmWasm, instead of calling a contract by methods and providing the arguments in some serialized format, the contract exports one top-level entrypoint. This entrypoint accepts a per contract defined Message type, which is usually some algebraic data type, and internally handles the message; an example of this contract can be seen <a href="https://gist.github.com/rust-play/102db6e32a608b0f6250d2bbd417e038">here</a>. This has consequences for actually interacting with other contracts as well. Instead of importing them into your smart contract and calling them by methods, as if they were instantiated classes, you exit the current smart contract execution with a vector of messages handled by further smart contracts. Transactionality is dependent on the order of messages, replies and if they are propagated to other chains. Each contract maintains a mailbox and logic to handle replies based on earlier dispatched messages.</p><p>This actual model is referred to as the actor model, the most well-known ones in the Rust ecosystem being Actix and Lunatic, and brings big advantages. First of all, CosmWasm contracts are safe from reentrancy attacks, as they have no in-memory state after sending messages. In non-pallet contexts, CosmWasm contract execution can also be (eagerly) parallelized, by constructing a growing DAG out of emitted messages and executing the contracts in parallel. This has the caveat of needing to revert some execution if contracts send messages to each other at the same height, but the initial block producer only incurs this cost. (more on that in a future article).</p><p>Finally, the actor model scales really nicely to cross-chain contract calls, as they are essentially the same as a regular contract call.</p><h3>Tying it all together with XBI and IBC</h3><p><a href="https://github.com/t3rn/Grants-Program/blob/e3b4832460295cb747585069ec20eda25cbe5c21/applications/xbi-format-psp-t3rn.md">XBI</a> is current research being done on the XCM interface for cross-chain contract calls. It defines calls such as:</p><pre><strong>call_wasm: trigger smart contract call</strong></pre><pre>caller: AccountId</pre><pre>dest: MultiAddress&lt;AccountId, ()&gt;</pre><pre>value: Balance</pre><pre>input: Bytes</pre><pre>additional_params: Option&lt;Vec&lt;ABIType&gt;&gt;</pre><p>which cleanly map to our CosmWasm actors. Each contract can emit a contract call message that cleanly maps back to XBI.</p><p>Obviously, CosmWasm was designed with IBC in mind, and thus we already have tooling and integrations with that in mind. However, it is not limited to the Cosmos. We at <a href="http://composable.finance/">Composbale Finance</a> are working at actually bringing the best of both worlds together, connecting Polkadot and the Cosmos.</p><p>The Composable XCVM is not only the next step in Wasm smart contract development — we believe it has the potential to become DeFi’s end game. CosmWasm developers utilizing the XCVM will not have to worry about what chains, dApps, or contracts they interact with. Instead, they can specify a function, and let the XCVM Routing Layer assure that the optimal route is taken at the time of execution. This new approach to smart contract development unlocks the true potential of native composability across several DeFi ecosystems. Composable’s vision is to facilitate the creation of interoperable, modular applications which are capable of functioning across entire ecosystems.</p><p><strong>Check out Composable Finance’s socials:</strong></p><p><a href="https://twitter.com/ComposableFin">Twitter </a>| <a href="https://t.me/joinchat/uAGCJk_Cjc9iYTky">Telegram </a>| <a href="https://discord.gg/pFZn2GCn65">Discord </a>| <a href="https://www.composable.finance/">Website</a> | <a href="https://github.com/ComposableFi">GitHub</a> | <a href="https://www.linkedin.com/company/composable-finance/">LinkedIn</a> | <a href="https://www.youtube.com/channel/UCXlKp8ev-8zOpJu0TNcc0uA">Youtube</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=313cd7d494e3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/supercolony/a-look-into-virtual-machines-and-smart-contract-runtimes-313cd7d494e3">A look into Virtual Machines and Smart Contract Runtimes</a> was originally published in <a href="https://medium.com/supercolony">WASM conference</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Subspace road towards 1M+ TPS]]></title>
            <link>https://medium.com/supercolony/subspace-road-towards-1m-tps-19b97ba86c35?source=rss----35210e40651d---4</link>
            <guid isPermaLink="false">https://medium.com/p/19b97ba86c35</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[subspace]]></category>
            <category><![CDATA[wasm-contract]]></category>
            <category><![CDATA[subspace-network]]></category>
            <category><![CDATA[substrate]]></category>
            <dc:creator><![CDATA[Nazar Mokrynskyi]]></dc:creator>
            <pubDate>Sat, 11 Jun 2022 11:12:34 GMT</pubDate>
            <atom:updated>2022-06-11T11:12:34.446Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Post Material after WASM conference 2022</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EBJVWu7yrOGqMLpVvMO4Fg.png" /></figure><h3>Why?</h3><p>At Subspace we believe Web3 is the future, which in turns means more and more apps will need to be running on chain. While current generation blockchains push the boundaries of what is possible, we need a system that can truly run at Internet scale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4qGy0PxsWwhKXXW1" /><figcaption>More</figcaption></figure><p>So we need more, much more TPS and on-chain persistent storage capacity to support use cases like Metaverse where quite literally everything is an NFT that needs to have on chain ownership and some assets associated with it. In this article we’ll focus on transaction throughput specifically.</p><h3>The plan</h3><p>In this article we’ll start with deep dive into some aspects of WASM Runtime environment that might impact performance both for pallets and for smart contracts, then we’ll dive into challenges specific for smart contracts (pallet-contracts in Substrate).</p><p>Once we are done with internals, we’ll look at the blockchain from the other side of the stack at how transactions are scheduled for executions, what opportunities for improvements are there and how we can leverage some of the vertical scalability technics for achieving higher performance on a single chain.</p><p>Then we’ll talk about scaling single chain performance horizontally with sharding.</p><p>We’ll concluse with some simple math and funny numbers based on public information that will give us an idea of what the performance of the blockchain utilizing some of the described technics might look like.</p><p>Overall this article is the result of the extensive research and following upstream work at Substrate and ink! and I hope you’ll find this information useful. Be prepared for a bunch of links with additional reading material if anything is of a special interest for you.</p><h3>Fundamental limits of physics</h3><p>Before we dive into how blockchains look internally, we need to understand some of the fundamental limits we can’t bypass on one hand and should strive for on the other.</p><p>The ideal blockchain would utilize all of the bandwidth available, work at the network latency propagation delay, would use all of the CPU cores/RAM/GPUs available and would probably be bottlenecked by random access of the disk subsystem in the end.</p><p>When looking at existing live blockchains, however, they typically utilize only a fraction of those resources:</p><ul><li>coupled block authoring and execution limits bandwidth utilization as increasing block size beyond optimal leads to increase in propagation delay</li><li>reducing block time typically leads to increased forking rate and thus security decrease</li><li>it is still a big challenge for blockchains to utilize more than one core for transaction processing, let alone take advantage of GPUs capable of processing large amounts of parallel tasks</li><li>situation around storage is challenging as well both in terms of preserving the whole history of the chain, which requires a lot of space, as well as performance-wise due to the nature of frequent random reads/writes during smart contract execution</li></ul><p>It doesn’t mean, however, we can’t get closer to those limits. One of the papers that describes how to overcome the limitations of vertical scalability and improving latency is <a href="https://dl.acm.org/doi/abs/10.1145/3319535.3363213">Prism: Deconstructing the Blockchain to Approach Physical Limits</a> where researches try to separate different parts of the regular operation of the blockchain (transaction processing, block authoring and block confirmation) into separate chains that can be scaled independently to improve both transaction throughput and confirmation latency at the same time, <a href="https://arxiv.org/abs/1909.11261">Scaling Bitcoin by 10,000x</a>.</p><h3>Wasm Background</h3><p><a href="https://webassembly.org/">WebAssembly</a> is a binary instruction format for a stack-based virtual machine. In short that means you don’t run it directly on the hardware, but rather with an engine that can turn WebAssembly into actual hardware instructions specific to your CPU.</p><p>There are a few types of those:</p><ul><li>Interpreters (Substrate uses Wasmi)</li><li>Ahead-of-Time compilers (Substrate has Wasmtime and Wasmer)</li><li>JIT</li></ul><p>Interpreter is a relatively simple one of the bunch, it just reads and executes instruction by instruction, meaning that it doesn’t have to do much preparation before it starts running the code, it also has predictable performance, but ultimately performance of it is ~1–3% of the native machine code, not particularly impressive.</p><p>AoT compiler will generally result in much more efficient code for the CPU reaching ~50% of native (sometimes higher), but it takes a long time to compile the code due to various optimizations compiler does, meaning there is a significant amount of time (orders of magnitude) comparing to interpreter.</p><p>JIT compilers are an interesting mix, they can start interpreting code right away and do various smart optimizations of hot paths and whatnot in the background and swap slower code with faster on the fly.</p><p>Here are a few useful links to read about Wasm performance:</p><ul><li><a href="https://medium.com/wasmer/benchmarking-webassembly-runtimes-18497ce0d76e">https://medium.com/wasmer/benchmarking-webassembly-runtimes-18497ce0d76e</a></li><li><a href="https://00f.net/2021/02/22/webassembly-runtimes-benchmarks/">https://00f.net/2021/02/22/webassembly-runtimes-benchmarks/</a></li><li><a href="https://wasmer.io/posts/wasmer-2.2">https://wasmer.io/posts/wasmer-2.2</a></li></ul><h3>Substrate Wasm Runtime environment</h3><p>In Substrate Runtime is a bunch of code compiled into Wasm blob that implements state transition function, which means it takes state as of previous block and a set of transactions and produces a new state.</p><p>For this use case Substrate uses Wasmtime AoT compiler. This is primarily because runtime upgrade (one of the important distinguishing features of Substrate) happens relatively infrequently, thus it is fine to spend some time to get faster binary out of the compiler.</p><p>In order to make sure individual blocks can be executed within some known amount of time, weight system is used for extrinsic calls (think transactions) to limit number of extrinsics that can be included per block. This works due to runtime code being considered “trusted”, so it is possible to rely on it to tell that information to the client (part of the node outside of runtime).</p><p>Client also caches different versions of the runtime in order to optimize re-compilation and make sure blockchain runs as fast as possible.</p><p>For performance reasons and due to WebAssembly sandbox there is a set of host functions exposed to the runtime that allows pallets to manipulate state, spawn other Wasm VM instances, offloading heavy cryptographic and other computations to the native implementation with hardware support.</p><p>While Substrate maintainers at Parity are hard working on things like <a href="https://github.com/paritytech/substrate/issues/10707">enabling more</a> of <a href="https://webassembly.org/roadmap/">WebAssembly features</a> and other low-level optimizations, there is still something you can do to make things faster in your runtime.</p><p>First of all, you can introduce more <a href="https://paritytech.github.io/substrate/master/sp_wasm_interface/trait.HostFunctions.html">host functions</a> to offload heavy computations, for instance when you verify ZK proof on a specific curve. The thing to remember here though is that host functions are not free: your client will have to support any introduced host APIs basically forever or old runtimes, when syncing from genesis for instance, would break. There are quite a few primitives already available if you use sp-io crate, take advantage of that!</p><p>Also benchmark your runtime, sometimes approaches that lead to faster native code like monorphisation could be more expensive than dynamic dispatch in Wasm. Another example is use of reference to values may lead to smaller and faster code instead of passing data structures by value to functions.</p><p>Finally, it might be the case that some kind of smart caching combined with Wasmer singlepass compiler for popular contracts (as observed in Ethereum ecosystem) could be used to significantly improving throughput, but more work needs to be done in that direction.</p><p>Some of the interesting optimizations on the table in Substrate that will make runtime even faster for you to follow:</p><ul><li><a href="https://github.com/paritytech/substrate/issues/8251">https://github.com/paritytech/substrate/issues/8251</a></li><li><a href="https://github.com/paritytech/substrate/issues/8846">https://github.com/paritytech/substrate/issues/8846</a></li><li><a href="https://github.com/paritytech/substrate/issues/10244">https://github.com/paritytech/substrate/issues/10244</a></li></ul><h3>Pallet-contracts</h3><p>This is Substrate’s default envionment for WebAssembly smart contracts (typically written in <a href="https://github.com/paritytech/ink">ink! DSL</a>, but there are other options).</p><p>The first challenge with smart contracts comes from the fact that user-provided code can’t be considered “trusted” the same way runtime can, which means:</p><ul><li>AoT compilers are not generally applicable</li><li>Gas metering is required to prevent DoS instead of static weights</li></ul><p>By default pallet-contracts uses slow Wasmi interpreter. Making matters worse is that Wasmi interpreter itself is compiled to Wasm and is running fully inside of the runtime, which doesn’t help with performance as you might have guessed.</p><p>There is work ongoing to make use of Wasmer singlepass AoT non-optimizing compiler, which generally is faster at running compiled code, but takes time to prepare Wasm beforehand. In the end the benefit is a wash when end-to-end execution time is measured, but, hopefully, that’ll change in the near future. Follow the latest progress on Wasmer singlepass at <a href="https://github.com/paritytech/substrate/issues/10298">https://github.com/paritytech/substrate/issues/10298</a>.</p><p>Gas metering is a big topic in any VM and Wasm is not an exception. Most of research easily searchable online compares <a href="https://arxiv.org/abs/2012.01032">eWasm with EVM</a> for Ethereum 2.0 upgrade and rarely about WebAssembly smart contracts more generally.</p><p>Approaches to gas metering can be generalized into 3 broad categories:</p><ul><li>Native to the VM (EVM, <a href="https://docs.rs/wasmer-middleware-common/0.17.1/wasmer_middleware_common/metering/struct.Metering.html">Wasmer middleware</a>)</li><li>Instrumentation with host calls (Substrate today)</li><li>Instrumentation with local counter (<a href="https://gov.near.org/t/on-running-some-wasm-contracts-with-llvm-specifically-for-evm/2869/6">NEAR</a>, <a href="https://github.com/paritytech/substrate/discussions/11143#discussioncomment-2507346">Substrate from the future</a>)</li></ul><p>Native instrumentation is fast and great overall, but both NEAR and Substrate want to be VM-agnostic and need to implement generic solution. The way it works on high-level in both today is to instrument Wasm bundle with injected gas metering code before execution. More specifically this allows interesting optimizations where gas for the piece of code that doesn’t branch can be charged all in one go removing most of the gas metring calls. Where NEAR and Substrate differ however is that in NEAR gas metering is done with a counter local to WebAssembly code and Substrate currently does host calls all the time, which has significant implications described below.</p><p>In <a href="https://www.parity.io/blog/ink-3-0-paritys-rust-based-language-gets-a-major-update">ink! 3.0</a> a bunch of smart “lazy” data structures were removed. The idea behind those was to minimize state access by reading only necessary subset of state available to the contract. This is a sound approach on the surface and should result in the faster code, but in practice it turned out that there are two issues with it that led to removal of those data structures:</p><ul><li>smart data structures mean a lof of extra code added to the smart contract’s Wasm bundle, which makes it both slower to run that it would otherwise and adds to startup latency</li><li>sofisticated data structures added a lot of the extra branching to the code of the contract, meaning gas metering mentioned above happened much more often</li></ul><p>In the end, while gas charged might have been lower in some cases, the cost of gas metering itself (host calls) meant that the contract call as a whole ran SLOWER. Yeah, I found that whole situation quite funny to be completely honest. See <a href="https://github.com/paritytech/ink/pull/1111">https://github.com/paritytech/ink/pull/1111</a> for some of the details.</p><h3>Starting point</h3><p>Lets step back from low-level details on how things work internally and how you can make your code faster, what is out baseline anyway?</p><p>I was able to find these Tweets from Gavin Wood himself:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*ePR3ITOtfu0oGTOp" /><figcaption><a href="https://twitter.com/gavofyork/status/1255859146127179782">https://twitter.com/gavofyork/status/1255859146127179782</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*EPr128OYYjLhrXFi" /><figcaption><a href="https://twitter.com/gavofyork/status/1270025498580656134">https://twitter.com/gavofyork/status/1270025498580656134</a></figcaption></figure><p>I think it is fair to assume that things would only get better since, but we can take those as a baseline anyway and estimate how far off we are, if we just use off-the-shelf Substrate-based node, from the goal of 1M+ TPS:</p><pre>1_000_000/1_500=666 TPS</pre><p>Not great, not terrible.</p><h3>Where is block time spent anyway?</h3><p>Turns out we can slice block tiem into 3 big chunks:</p><ul><li>Block autoring (collecting transactions from transaction pool, executing them, putting block header together, signing)</li><li>Block propagation</li><li>Block import</li></ul><p>Only after newly produced block was imported we can move on to building the next block on top.</p><p>Turns out most of the time nodes are not executing transactions…</p><p>…but it would have been really nice if they did!</p><h3>Decoupled execution</h3><p>In a standard blockchain each full node will:</p><ul><li>Propose new blocks</li><li>Verify new transactions</li><li>Maintain chain history (blocks)</li><li>Maintain chain state (result of blocks execution)</li></ul><p>In <a href="https://subspace.network/">Subspace</a> we apply the technic similar to described in the Prims paper linked earlier, where we split those responsibilities between two distinct roles on the network: farmers and executors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DwIu_vLQgePDP6Qu" /><figcaption>Two roles in Subspace: farmers and executors</figcaption></figure><p>Farmers provide safety to the protocol using novel Proof-of-Archival-Storage consensus and are responsible for proposing blocks and maintaining history. While staked executors provide liveness to the protocol by verifying transactions and maintaining state (doign execution).</p><p>So instead of coupling everything together we have the following workflow:</p><ul><li>users submit transactions</li><li>executors validate transactions and combine them into transaction bundles</li><li>farmers include transaction bundle headers into blocks that they produce</li><li>executors then deterministically follow farmer blocks and apply state transitions that result in execution receipts</li><li>farmers include execution receipts in upcoming blocks, completing the journey of the transaction</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n4k71vYxt_hk33qb" /><figcaption>Decoupled execution</figcaption></figure><p>Such decoupling allows farmers to produce blocks at their own pace and propose relatively small transaction bundle headers, resulting in low overhead and opening possibilities for mass participation in consensus (we have over 25_000 consensus nodes during stress-test of our non-incentivized test network), while executors can pack megabytes of transactions into bundles and keep their execution engine busy 100% of the time.</p><p>This is certainly great for performance! If we assume that block authoring, propagation and import take about the same amount of time, we can increase effective transaction throughput by a factor of 3, leading us to 4_500 TPS. How far off we are from 1M now?:</p><pre>1_000_000/4_500=222 TPS</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K4VtybwgDoVQW94q" /></figure><p>This is certainly better than before, but we are still 2 orders of magnitude below target.</p><p>For some context here are some numbers claimed (and somewhat theoretical) from already live protocols:</p><ul><li>Ethereum: 15 TPS</li><li>NEAR: <a href="https://www.reddit.com/r/nearprotocol/comments/pk064h/comment/hc1f806/">100_000 TPS (@1M nodes)</a></li><li>Solana: 50_000/<a href="https://docs.solana.com/introduction#why-solana">710_000 TPS (176 bytes/tx @1 Gbps)</a></li></ul><p>There is still room to grow then.</p><h3>Cores? Cores!</h3><p>Modern CPUs are multi-threaded, why not make blockchain multi-threaded too?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XOCCNvr_r9-3eju_" /><figcaption><a href="https://en.wikichip.org/wiki/intel/microarchitectures/coffee_lake">https://en.wikichip.org/wiki/intel/microarchitectures/coffee_lake</a></figcaption></figure><p>There are two options how transaction processign in blockchains can be made parallelizable that I’d like to cover:</p><p>Speculative execution:</p><ul><li><a href="https://arxiv.org/abs/1901.01376">https://arxiv.org/abs/1901.01376</a></li><li><a href="https://www.microsoft.com/en-us/research/uploads/prod/2021/09/Forerunner_final_full.pdf">https://www.microsoft.com/en-us/research/uploads/prod/2021/09/Forerunner_final_full.pdf</a></li></ul><p>Explicit:</p><ul><li><a href="https://docs.solana.com/developing/programming-model/accounts">https://docs.solana.com/developing/programming-model/accounts</a></li><li><a href="https://solana.com/news/sealevel---parallel-processing-thousands-of-smart-contracts">https://solana.com/news/sealevel---parallel-processing-thousands-of-smart-contracts</a></li><li><a href="https://github.com/paritytech/substrate/discussions/11253">https://github.com/paritytech/substrate/discussions/11253</a></li></ul><p>A simpler route that both NEAR and Solana took is to change the design of the environment and make it easy for executor to identify which transactions touch non-conflicting parts of the state, such that executor can know precisely which transactions can be run in parallel. In both cases conceptually the state is tied to the account instead of the contract, such that transactions from different accounts often do not overlap. In Solana it is even envisioned that SIMD instructions and eventually even GPUs can be used to run the same contract with multiple accounts (inputs) massively in parallel.</p><p>Let’s not be greedy though and assume we can build a simpler system with explicit annotations about which state will be read and written by contract call and we’ll still get 8x improvement, then we get much closer to 1M TPS with 36_000 TPS, but are still quite far from it (and even NEAR/Solana theoretical performance):</p><pre>1_000_000/4_500/8=27</pre><h3>Horizontal scaling (Sharding)</h3><p>Once we reached the reasonable limit of vertical scaling all that is left is to apply classical Web2 approach: introduce horizontal scaling with sharding.</p><p>In Subspace due to decoupled execution nature of the protocol we can implement nice tricks that do not require sacrifice of safety when shards are added. The insight is that even with multiple shards the history of the blockchains (that farmers store and use as tickets for a chance to produce next block) can be global, meaning history of all individual chains ties together in the end and that global history farmer use for, well, farming. Once they win, solution is sortitioned to one of the shards where they get to produce a block. With farmers effectively solving on all shards at the same time, all shards get the same and full security in a permissionless setting.</p><p>Executors, however, are free to choose what shard they decide to stake and execute on using protocol based on <a href="https://arxiv.org/abs/2005.09610#">free2shard</a>, so they don’t have to rotate often incurring significant overhead.</p><p>Together those two aspects allow for a sharding design that isn’t limited in the same way as other sharding designs are and can scale without limits. The working number for calculations is 2¹⁶ shards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*NrhIbEOF1bv6Xo-I" /><figcaption>Horizontal sharding</figcaption></figure><p>When we take that into account, situation with 1M TPS goal changes significantly:</p><pre>1_000_000/4_500/8/65_536=0.000_423_855</pre><p>When we turn it the other way around we get something that is hard to believe without explanation above:</p><pre>4_500*8*65_536=2_359_296_000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/0*kpdueRdMiOKoif9B" /></figure><p>It doesn’t mean that protocol will ever process over 2B TPS. What it means is that it could if there was enough demand for it, otherwise we can have 4.5TPS per shard, 65 shards or some mix of those and still push 1M+ TPS on Subspace Network.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19b97ba86c35" width="1" height="1" alt=""><hr><p><a href="https://medium.com/supercolony/subspace-road-towards-1m-tps-19b97ba86c35">Subspace road towards 1M+ TPS</a> was originally published in <a href="https://medium.com/supercolony">WASM conference</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Parity’s “ink!”?]]></title>
            <link>https://medium.com/supercolony/what-is-paritys-ink-3b831435c343?source=rss----35210e40651d---4</link>
            <guid isPermaLink="false">https://medium.com/p/3b831435c343</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[ink]]></category>
            <category><![CDATA[parity]]></category>
            <dc:creator><![CDATA[Supercolony]]></dc:creator>
            <pubDate>Wed, 08 Jun 2022 14:19:51 GMT</pubDate>
            <atom:updated>2022-06-08T14:19:51.683Z</atom:updated>
            <content:encoded><![CDATA[<p><em>written by Michael Muller, the Core Developer at Parity</em></p><p><em>Post Material after WASM conference 2022</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ey1JebRFmInLDa8zNiKV1Q.png" /></figure><p>This is a summary of the talk “What is Parity’s ink!?” which Michael Müller gave for the Wasm Conference 2022. Michi has been a developer at Parity for a couple of years now, working mostly on the ink! ecosystem for a while.</p><p>Before we can talk about ink! we need to clarify what Substrate and its pallet-contracts are first.<br>The substrate is a framework for building blockchains ‒ those can be standalone blockchains or blockchains connected to Kusama or Polkadot. The substrate contains a number of modules, in Substrate terminology those are called “pallets”. There’s a pallet for anything one wants to have in a modern blockchain ‒ fungible tokens, non-fungible tokens, governance, etc…</p><p>If a developer uses Substrate they can easily add smart contract functionality by including the pallet-contracts. See <a href="https://docs.substrate.io/how-to-guides/v3/pallet-design/contracts-pallet/">this</a> how-to guide in case you’re interested in this. <a href="https://github.com/paritytech/substrate/tree/master/frame/contracts">The readme</a> of the pallet has more details.<br>How does ink! come into play here? Well, with ink! you can write smart contracts in Rust for blockchains built on the Substrate framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*Y0hgRCPhxDbRmMTB.png" /></figure><p>A confusing thing for people learning about Substrate, Polkadot, and Kusama (or as it’s also called the Dotsama universe) is the difference between when to write a Substrate pallet and when to use the smart contracts module.</p><p>The distinction here is that in the context of Polkadot and Kusama a parachain leases a slot for a couple of months for up to two years. As part of this lease the parachain can execute its state transition function with every block that is appended to Polkadot/Kusama.</p><p>So the code that the parachain executes during that time doesn’t get further validated ‒ it’s up to the parachain what it does with its slot time. It can build its own world and has all the freedom ‒ it can for example decide on how transaction fees work, how governance works, design its own crypto-economics, etc… A more detailed explanation can be found <a href="https://stackoverflow.com/questions/56040779/when-should-i-build-a-substrate-runtime-module-versus-a-substrate-smart-contract">here</a>.</p><p>For smart contracts, on the other hand, an existing parachain has to include the pallet-contracts for you to upload smart contracts there. The uploaded smart contract is always untrusted here. This is because anyone (or any program) that has tokens of the chain could upload any smart contract. The pallet-contracts has to assume that this program could be adversarial, so it has to put a number of safety pillars into place to ensure that the contract can not e.g. stall the chain (gas metering, etc.).</p><p>So developing a parachain runtime is different from developing a smart contract ‒ it’s on different layers, <em>a smart contract sits on top of a parachain</em>.</p><p>The trade-off is that with a parachain you write (nearly) all the rules by yourself, whereas with a smart contract your constrained by what the chain allows you to do and all the safety pillars that necessarily have to be in place.<br>A smart contract on the other hand is way easier to develop and deploy ‒ you don’t have to take care of governance, crypto-economics, etc… You just need a few tokens and then you can deploy your contract. The following schema shows the trade-off:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*wefwwGT12TdhYQJS.png" /></figure><h3>How the pallet-contracts works</h3><p>We intentionally designed pallet-contracts in a way that is decoupled from the language that is used on top of it.</p><p>This means you can use ink!, but also other languages. Right now there are three languages you can choose from:</p><ul><li><a href="https://github.com/paritytech/ink">Parity’s ink!</a> for Rust</li><li><a href="https://github.com/patractlabs/ask">ask!</a> for Assembly Script</li><li>The <a href="https://github.com/hyperledger-labs/solang">Solang</a> compiler for Solidity</li></ul><p>It’s not hard to add new languages. The language just needs to compile down to WebAssembly (Wasm) and implement the API of pallet-contracts. This API at the moment consists of about 15-20 functions for anything a smart contract may desire: storage access, crytpography functionality, environmental information like block numbers, access to functions to get random numbers or self-terminate the contract, etc… The language on top doesn’t have to implement all of those functions ‒ the ink! hello world requires just six. The following schema depicts this relationship:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KWipyFCmx8CROyhM.png" /></figure><h3>Use Cases for pallet-contracts</h3><p>There’s a couple use cases for the pallet.<br>An obvious one is a chain which has smart contracts as a “first class citizens”, meaning smart contracts are the central thing of the chain.</p><p>Those chains typically take the pallet-contracts and put some additional unique value proposition on top of it. For example, a big chain using the pallet-contracts has built some way of how contract developers can get a passive income from their contracts being used on top of the pallet.</p><p>The other big use case is to have smart contracts as “second class citizens”. The pallet provides an API (called <a href="https://ink.substrate.io/macros-attributes/chain-extension">chain extensions</a>) with which a parachain can decide to expose certain parts of its business logic to smart contract developers. This way the parachain can adding customizability for parts of its business logic. Think for example of a decentralized exchange blockchain. That chain would have an orderbook to place bids and asks; it could now decide to expose this into smart contracts, thus giving developers the option of uploading trading algorithms as smart contracts to the chain.</p><p>Another big use case for the pallet is to prototype an idea as a smart contract before going for a dedicated parachain slot.<br>Since the threshold for developing a smart contract is way lower this can make sense depending on the use-case. One could deploy an MVP smart contract first, see if it gains traction and the idea works, and only subsequently once there is a need to control e.g. transaction fees or have some governance mechanism go for a dedicated parachain runtime. Since ink! and Substrate are both Rust and share similar primitives there is a clear path of graduating from a smart contract to its own runtime.</p><p><a href="https://github.com/paritytech/substrate/tree/master/frame/contracts">Readme</a></p><p><a href="https://docs.substrate.io/v3/runtime/smart-contracts/">https://docs.substrate.io</a></p><h3>Simple ink! program</h3><p>ink! is really just Rust, that’s our overarching goal. We aim to be minimally invasive, enabling you to use<br>everything that you can use with Rust ‒ IDEs, cargo fmt, cargo clipy, code snippets, crates (no_std compatible ones), etc…</p><p>In the following picture you can see a simple ink! contract. The contract<br>here has one boolean in its storage. Once the contract is created it sets<br>the boolean to true by default. The contract exposes two functions: one<br>to read the current value of the boolean (get) and one to switch it to<br>its opposite boolean value (flip).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*A1Yexeq4Fxfilea7.png" /></figure><p>The colored lines are ink!-specific annotations for the code.</p><p>Unit and integration tests can be written also as just Rust:</p><pre>#[ink::test]<br>fn default_works() {<br>    let flipper = Flipper::default();<br>    assert_eq!(flipper.get(), false);<br>}</pre><p>The #[ink::test] annotation has the effect of wrapping the test in a mocked blockchain environment.<br>This enables you to mock e.g. the value that is transferred to a contract, its sender, block numbers, etc…<br>For example, you can use ink_env::test::set_value_transferred within an #[ink::test] to mock the value (i.e. tokens) send to a contract.<br>You can see the full list of ink_env::test functions in the crate documentation <a href="https://paritytech.github.io/ink/ink_env/test/index.html">here</a>.</p><h3>Cargo-contract</h3><p>For building ink! smart contracts you have to go through <a href="https://github.com/paritytech/cargo-contract">cargo-contract</a>, which is a command-line tool that mirrors cargo. It’s kind of a swiss army knife for ink! smart contracts, it can do much more besides just building a contract, but we’ll talk about that later.</p><p>For building contracts you use cargo contract build. Note that the typical Rust cargo build behavior is that you need to supply --release if you want the smallest possible binary size, same with cargo contract build --release.<br>If you run this command you’ll see that cargo-contract executes the “normal” cargo build on your contract, but it does some more stuff as well. The three most important additional steps it does are:</p><ul><li>It runs a linter for ink! contracts that works analog to Rusts’s clippy, it checks your contract for idiomatic use of ink!. We’re constantly improving this linter and plan to add detections of common security pitfalls there as well.</li><li>It post-processes and compresses your contracts binary. This is done because it reduces the costs of deploying the contract, as well as the gas fees for users interacting with the contract. The contract size also correlates to the throughput a chain can achieve.</li><li>It generates metadata for the contract. With metadata we refer to anything that is needed to interact with the contract binary. The binary itself will be just a Wasm blob ‒ byte code of the contract that without further information doesn’t make any sense. In order to know what functions the contract exposes, what arguments they take, etc. you need to have the metadata.<br>You might also know this concept under the term ABI from other blockchains. In our case the metadata contains a bit more than just the ABI though, it also has information on e.g. how the contract stores its data, this is helpful for off-chain tooling (e.g. a block explorer).</li></ul><p>As part of cargo contract build you get three files:</p><ul><li>my_contract.contract: the contract’s WebAssembly blob in hex encoding + the contract’s metadata.</li><li>my_contract.wasm: the contract’s WebAssembly blob.</li><li>metadata.json: the contract’s metadata.</li></ul><p>Each of those files has a different use case:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*ACkz8Sy5NinYv1WN.png" /></figure><p>The WebAssembly is the only part that is actually stored on-chain. This is because storing data on-chain should be only done for the things<br>that are strictly necessary. The metadata is not necessary to be on-chain, if you have a Dapp the Dapp can contain the hardcoded metadata.</p><p>The *.contract bundle is only needed if you’re developing a smart contract, then you can upload this file to a Developer UI and it will deploy it and give you all the options of interacting with the contract.</p><h3>Developing?</h3><p>For development you can use any testnet or tooling of existing parachains that support the pallet-contracts and ink!.</p><p>We’re providing a couple of handy things as well:</p><ul><li><a href="https://github.com/paritytech/substrate-contracts-node">substrate-contracts-node</a><br>This repository contains Substrate’s node-template configured to include pallet-contracts.<br>This node is tracking Substrate’s master and has been modified<br>to make it a great fit for development and testing. For example, it doesn’t have any fixed block time,<br>everything is processed immediately. This comes at the cost of making the node unsuitable for production use, but great for e.g. CI’s.<br>If you’re looking for production templates take a look at Substrate’s <a href="https://github.com/paritytech/substrate/tree/master/bin/node/runtime">node</a> or the How-To guide in Substrate’s documentation on how to add the pallet-contracts (<a href="https://docs.substrate.io/how-to-guides/v3/pallet-design/contracts-pallet/https://docs.substrate.io/how-to-guides/v3/pallet-design/contracts-pallet/">link here</a>).</li><li>We maintain a testnet named plainly Contracts on Rococo. Rococo is a testnet for anything Polkadot and Kusama. This means many parachains are connected to Rococo with their own testnets. You can read more about it <a href="https://ink.substrate.io/testnet">in our documentation</a>.</li></ul><p>There’s also a number of community testnets, you can find an overview on <a href="https://github.com/paritytech/awesome-ink">https://github.com/paritytech/awesome-ink</a>.</p><p>For Developer UI’s you have currently those choices:</p><ul><li><a href="https://paritytech.github.io/contracts-ui">Contracts UI</a>: Ideal for beginners, gives helpful hints and assists.</li><li><a href="https://polkadot.js.org/apps">polkadots.js</a>: Advanced interface that exposes any functionality you could possibly ever want.</li><li><a href="http://ink-playground.substrate.io/">ink! playground</a>: A playground to try out ink! in the browser or share permalinks to code snippets. This is very handy if you’re asking questions on our <a href="https://substrate.stackexchange.com/questions/tagged/ink?tab=Votes">StackExchange</a>.</li><li><a href="https://github.com/paritytech/cargo-contract">cargo-contract</a>: If you’re looking to deploy contracts from the command-line, call them, decode their output, etc. then this tool provides a handy option to do all of that as a CLI. You can also use the tool for e.g. scripting or CI integrations.</li></ul><p>In terms of ink! documentation the resources are:</p><ul><li>If you are looking for a quickstart,<br><a href="https://docs.substrate.io/tutorials/v3/ink-workshop/pt1/">ink!’s Guided Tutorial for Beginners</a> provides a great starting point.</li><li>Other than that, <a href="https://ink.substrate.io/">ink.substrate.io</a> is our documentation portal.</li><li>Since ink! is just Rust you can also check out the crate docs. For example, the ink_env crate is the one which has all the functions you might need in your contract: <a href="https://docs.rs/ink_env/latest/ink_env/">https://docs.rs/ink_env/latest/ink_env/</a>.<br>We’ve linked other relevant crate docs in our readme <a href="https://github.com/paritytech/ink#developer-documentation">here</a>, e.g. the crate for data structures (ink_storage) is linked there.</li></ul><p>If you have any questions whatsoever its best to ask them on our <a href="https://substrate.stackexchange.com/questions/tagged/ink?tab=Votes">StackExchange</a> site or open an issue in the fitting repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b831435c343" width="1" height="1" alt=""><hr><p><a href="https://medium.com/supercolony/what-is-paritys-ink-3b831435c343">What is Parity’s “ink!”?</a> was originally published in <a href="https://medium.com/supercolony">WASM conference</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smart Contrats vs Centralized Backend]]></title>
            <link>https://medium.com/supercolony/smart-contrats-vs-centralized-backend-14b2e56f5f38?source=rss----35210e40651d---4</link>
            <guid isPermaLink="false">https://medium.com/p/14b2e56f5f38</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[metaverse]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[gaming]]></category>
            <category><![CDATA[polkadot]]></category>
            <dc:creator><![CDATA[Abrosimov Illia]]></dc:creator>
            <pubDate>Wed, 08 Jun 2022 09:19:26 GMT</pubDate>
            <atom:updated>2022-06-08T09:19:26.722Z</atom:updated>
            <content:encoded><![CDATA[<h3>Smart Contracts vs Centralized Backend</h3><p><em>Post Material after WASM conference 2022</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sx8DSDFeTYOtAXwvEyvSEg.png" /></figure><h3>Intro</h3><p>In this article, I want to overview the usage of smart contracts as the alternative for a centralized backend in general-purpose applications (and particularly in gaming).</p><p>An important note here — I’ll talk about the smart contracts as a particular case of the decentralized architecture, but in most cases given info will be also applicable for the other solutions, e.g. blockchains with built-in custom logic.</p><p>So, we will start with the application architecture. Traditionally it can be divided into two significant parts — frontend (or client) and backend. It should be mentioned here to underline that the client’s purpose is to show the convenient interface, stunning pictures, and so on, but the backend is fully responsible for all application logic and data. And this is the reason why we should maximally care about how it is working and who owns all data and control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d80ngRJWl9pcenv13_4IGA.png" /></figure><p>So what problems centralized backend is causing? Here is the set of the most typical ones:</p><ul><li>User has no direct control<br>In centralized systems, controlling authority has root control of users’ assets and behavior. New backend code can be deployed without notifying the users, a database could be read/rewritten, and so on. Users always should trust the organization without having the possibility to verify it.</li><li>Single point of failure<br>A centralized backend always had a server where it’s running, whose failure will lead to the failure of the whole system. Obviously, some approaches are trying to solve this, but centralized system design always has this problem, so can be sensitive to various types of attacks.</li><li>Privacy of your data<br>This point is the particular instance of the first point — control. As your data is in full control of the organization nobody could guarantee its privacy. It can be compromised, or even the organization can decide to make something you’re not expecting with this data.</li></ul><h3>Smart contracts as a solution</h3><p>After we’ve defined the problems, we can look at the smart contract and decentralized architecture as the solution to solve these problems. Let’s consider the value that it can bring vs a centralized backend:</p><ul><li>User always keeps his control (vs organization keeps control)<br>Unlike centralized systems, where the controlling authority has root control of users’ assets and behavior, blockchain allows every user to be truly in full control. The user fully controls wallet balance, transactions, and any other actions — no authority can put any restrictions on the above.</li><li>Permissionless and open (vs closed and should be trusted)<br>All your activity on a blockchain is bonded only with your wallet address. No documents or any other verification of your real identity. And at the same time everything in the system is open — starting from the source code and up to transactions history, so you can personally verify everything in this space.</li><li>Unstoppable (vs single point of failure)<br>Thanks to the decentralized architecture, the blockchain does not have a server which failure will lead to the failure of the whole system. Such systems are much more sustainable and share the responsibility of maintaining the system between its users — persons who have the most interest in keeping it stable</li></ul><p>But like any other solution, the usage of smart contracts also has its cons and pitfalls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_BnEBxhyglBGVKUdGx98Gg.png" /></figure><ul><li>Every decision point should be automated or replaced by DAO<br>Actually, for users, it’s not a con, but it’s required much more work on the development side, new approaches in a system design, and additional attention from the user’s side — to maintain the system. But mostly, this point is here because the ecosystem is young and it’s up to builders (like the Asylum team, where we’re developing the ecosystem for games) to develop it and create useful tools and approaches to the make ecosystem better.</li><li>Scalability<br>One of the main problems of blockchains that we have for now is scalability. High transaction fees, high latency — all this stuff makes smart contracts not suitable for many use cases. But looking at how much attention and efforts are now focused on this problem I think we can hope for it to be solved soon.</li><li>“Intellectual rights”<br>As the code of smart contracts is open — you can not feel it as your property because it has no protection from being cloned and deployed by someone else. Due to this point, smart contracts can be not suitable for some organizations that rely on proprietary software.</li></ul><p>And after such an overview, I want to take a quick look at the possible scenarios for smart contract usage. Obviously, we will skip the DeFi scenarios here because they are the primary purpose of smart contracts.</p><ul><li>Marketplaces<br>One of the good examples is where we can use a decentralized backend. And here I am talking not only about NFT marketplaces but also about the ones with real-world assets. Not a lot of transactions — so fees and latency are not so important, but the importance of control for your assets and actions is high.</li><li>Government services<br>Here we are discovering the need for an unstoppable and open system, where every action is clear and no possibility of cheating. And here the fees and latency are also not so important due to the low number of transactions.</li><li>Gaming<br>Gaming is always about modeling some virtual world with some rules, so its sustainability, absence of the godlike admins, fair p2p interactions, and other features of decentralizations are making this world more and more attractive for users to play. We will focus on it onward.</li><li>General-purpose apps<br>Besides the mentioned scenarios smart contracts can also be a good solution in many other cases, mostly in apps that require fair and clear processes in it.</li></ul><h3>Decentralized backend in gaming</h3><p>As it was said gaming is one of the areas where a transition to decentralized architecture is very suitable. As it is about creating worlds — we are talking about the life-like experience, and in real life, we see that democracy and freedom are the principles most valued in a healthy society.</p><p>And after we considered the cons of centralized architecture in general, let’s see what effects it can bring to the gaming:</p><ul><li>No real Assets ownership<br>Digital assets bought or earned via gameplay cannot be normally exchanged on secondary markets for real-world money — while there currently exists some under-the-desk reselling of items in some MMORPGs, like World of Warcraft, it is a risky practice that tends to go against End-Users License Agreements and leads to inglorious bans.</li><li>No direct game control<br>Vitalik Buterin, says in his bio that he “realized what horrors centralized services can bring” after Blizzard removed the damage component from his beloved warlock’s Siphon Life spell. Soon after that, he decided to quit the game. <br>It’s a good example of when the absence of control of the game (like deciding what features should be added/removed, what changes are acceptable) is demotivating players to play it.</li><li>Possible unfair gameplay<br>This is a story about unfair (or unclear) pay-to-win that is appearing from time to time in many multiplayer games. As an example, a lot of players report unfair matchmaking processes in games, when if you donated more money to the game — you will be matched with a less skilled opponent, which gives you a preliminarily advantage.</li></ul><p>So let’s get down to the usage of smart contracts in gaming, where firstly I would like to underline a few examples of how it shouldn’t be designed.</p><ul><li>“Centralized” code approaches<br>Some games, already written on-chain, still have centralized control models. For example, there are admins (hardcoded accounts) who could make the changes to the gameplay processes. It breaks the trustless value, so it’s obviously a bad design for such systems. The obvious solution to avoid this — is to use DAO for decisions that will affect the whole game.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oWH-1amZ-PaoJ6eBJcJ1pQ.png" /></figure><ul><li>Conjunction with a centralized node<br>There are also a lot of cases where developers are creating nice contracts, for example, for in-game NFTs, but also writing the common backend node that is conditionally minting these NFTs (like items drop, or crafting). In addition to being related to the previous point (broken trustless), it also brokes the benefits of fault tolerance because the centralized node could be attacked and shut down or even compromised</li><li>Non-critical computations<br>Here is the obvious point, about that not everything in games’ backend logic is critical, so not everything should be written decentralized. If there is a way to bring some computation off-chain to improve user experience without breaking the principles — it’s a good idea to do it.</li></ul><p>Finally, elaborating on the last point, I would like to share my thoughts about the balance between using centralized and decentralized approaches in games.</p><p>First of all, should be mentioned in-game assets ownership and management, that is definitely should live on-chain, but, obviously, not storage of these assets, that is okay to be off-chain to reduce the load. For this purpose could be used decentralized storages that can incentivize players to store assets to support the game. Btw, usage of NFTs for in-game items may give games much more than just true ownership. We, at the Asylum, are now working on the standard for NFT items that will allow cross-game NFTs usage, so obtaining the NFT sword in one game you will be able to use it in other similar games, extending its value and exploring more possibilities for gameplay.</p><p>As a next important point, we should consider governance, which can be both a part of the gameplay and a control point for players to decide (approve) the vector of game development and new changes. This space needs much more research work because for now there are not a lot of fully player-owned games, but by exploring the possibilities of DAO we will build much better worlds as they will reflect the players’ decisions and desires. As an initial point, we can propose on-chain versioning of every game update — client and backend — and give DAO the possibility to choose the version to keep it as a live game.</p><p>A more complicated question is about where to keep a gameplay logic — it relies highly on the peculiarities of every specific case and also on scaling possibilities of the chosen chain. As an example — the gameplay of the card game, like hearthstone, can be placed on-chain, as it has a step-by-step process and is not super demanding to transaction time. The other case is the gameplay of the shooter, like CS:GO, that obviously cannot be placed on-chain. But the blockchain gaming ecosystem is now exploring the possibilities of secure off-chain solutions for latency-demanding backends, like TEE.</p><p>And the last point — player identity, that can be moved to the blockchain as an Avatar, along with all related info, achievements, and so on, the similar way as the in-game assets.</p><p>Finalizing everything told above, the gaming can be the primary area that needs decentralization, and if you’re interested in what significant benefits it can bring — you should check out the <a href="http://asylum.space/">Asylum </a>project, which is built to ease the integration, bring the control to Players, and freedom to Creators and finally — unite all games into a single Metaverse!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14b2e56f5f38" width="1" height="1" alt=""><hr><p><a href="https://medium.com/supercolony/smart-contrats-vs-centralized-backend-14b2e56f5f38">Smart Contrats vs Centralized Backend</a> was originally published in <a href="https://medium.com/supercolony">WASM conference</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fat Contract: Introduce Off-chain Computation to Smart Contract]]></title>
            <link>https://medium.com/supercolony/fat-contract-introduce-off-chain-computation-to-smart-contract-d44dc8afb141?source=rss----35210e40651d---4</link>
            <guid isPermaLink="false">https://medium.com/p/d44dc8afb141</guid>
            <category><![CDATA[fat-contract]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[phala-network]]></category>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Shelvenzhou]]></dc:creator>
            <pubDate>Wed, 08 Jun 2022 09:10:30 GMT</pubDate>
            <atom:updated>2022-06-08T09:10:30.456Z</atom:updated>
            <content:encoded><![CDATA[<p><em>written by Shelven Zhou, the Lead Researcher of Phala Network</em></p><p><em>Post Material after WASM conference 2022</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mUa1cl0JbgUj6lkotBf2Ng.png" /></figure><h3>What is off-chain computation?</h3><p>Before introducing the off-chain computation, let’s first learn about the on-chain computation model adopted by almost all the existing smart contracts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*2KNyuP6tw16RjThp" /><figcaption><em>Figure 1. On-chain Execution of Transaction</em></figcaption></figure><p>Figure 1 shows the on-chain execution model. The on-chain execution itself is <em>deterministic</em>: the transaction is executed by all nodes and they must agree on the final state.</p><p>Such requirements on state consistency unavoidably introduce limitations: it is slow and expensive. More importantly, operations like network requests are forbidden since they can result in different final states on different nodes (network requests may fail on some nodes and succeed on others).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*lz11hJWXHDqKPdlb" /><figcaption><em>Figure 2. Off-chain Execution for Blockchain</em></figcaption></figure><p>The off-chain execution was first proposed to satisfy the need for <a href="https://chain.link/education/blockchain-oracles">Oracle</a>, i.e., to introduce the off-chain input like real-time BTC price from some exchanges during execution. Unlike on-chain execution, off-chain execution is conducted by a limited number of (sometimes only one) off-chain workers, so it also improves the performance and cost. Now the nodes only need to verify the execution results are really produced by these workers (it’s a bit like the rollups of a single transaction).</p><p>This model, unfortunately, also has limitations. The trust of off-chain workers is implied in this solution since the on-chain nodes can only know that these workers produce the results but not that they use the “right” off-chain input and do the execution faithfully. That’s why such a solution is usually only used by the chain development teams who host their own workers.</p><h3>A step to trustless off-chain infrastructure</h3><p>The key to the problem above is to find the “trusted” off-chain workers, and there are some candidates like verifiable computation methods like zero-knowledge proof, or hardware-based solutions like the secure enclave.</p><p>Phala is a trustless computing cloud whose miner nodes are all Secure Workers using secure enclaves. The secure enclave is usually implemented as a secure subsystem of modern processors and provides two important secure guarantees: <em>confidentiality </em>and <em>execution integrity</em>. This means that the malicious operators, even with the physical access to the machines, cannot read the state in memory (since it is encrypted by dedicated chips), or manipulate the program execution to provide false results. With this, even the individual developers can rent their own off-chain workers from Phala blockchain and enjoy the benefits.</p><p>This drives us to design a new contract execution model, i.e., the <em>Fat (PHAt) Contract</em>, that is able to do off-chain computation. It is worth noting that we deliberately choose not to simply migrate EVM into a secure enclave since it was designed for on-chain execution and thus hard to extend.</p><h3>Features and application scenarios</h3><p>The Fat Contract is meant to be written with Parity’s ink!. From the developers’ perspective, there is little difference when writing ink! contract and Fat Contract, except for the extensions we provide for Fat Contract. The key difference is where they are executed: the ink! contract is executed by Substrate nodes and Fat Contract in pRuntime (runtime customed by Phala) in our off-chain Secure Workers. Obviously, Fat Contract enjoys all the benefits mentioned above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*rZs3ikkho8n8jrPm" /><figcaption><em>Figure 3. Compare Fat Contract with Existing Smart Contract</em></figcaption></figure><p>With Fat Contract, it’s now possible to implement the applications that used to require creating a new chain with a single contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*TaudeS4PFZxst_OT" /><figcaption><em>Figure 4. The application scenarios of Fat Contract</em></figcaption></figure><h3>The model of Fat Contract</h3><p>The design principle for Fat Contract is simple: while supporting the legacy on-chain execution logic, it tries to provide a full-functional off-chain execution environment with privacy, high performance, and necessary features like Internet access and storage. Our insight here is that only a small portion of the state (like token balance and NFT ownership) in DApps really needs to be persisted on-chain, that’s why we encourage developers to implement most of their logic off-chain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/0*Ubl8BB9F_JhGkmoo" /><figcaption><em>Figure 5. An ink! / Fat Contract example</em></figcaption></figure><p>Talk is cheap and let me show you some code. This is the Hello World contract from ink!. As promised, you can run it in Phala with no modifications. In this contract, the contract (on-chain) state is described by variable <em>value，</em>. And based on whether the state will be changed, the following functions are divided into two classes, mutable (<em>flip()</em> function) and immutable (<em>get()</em> function). Correspondingly, we divide the user’s requests to these functions into Commands, which are sent to mutable functions and change the on-chain state, and Query, which are sent to immutable functions and leave the on-chain state unchanged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*ACKeZ7gdIHX--5tb" /><figcaption><em>Figure 6. Command execution in Fat Contract</em></figcaption></figure><p>Among them, the Command follows the traditional off-chain execution path, except that it is encrypted and can only be decrypted in secure enclaves. This means Command, like normal transactions, needs to be posted on-chain, packed into the block, and then synced to off-chain workers for execution. It can be a performance bottleneck so should be used with caution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*aV1Lw57xDKbsTkTd" /><figcaption><em>Figure 7. Query execution in Fat Contract</em></figcaption></figure><p>Query, on the other hand, is very different. First, it is directly sent to the Secure Worker just like Client/Server communication, so it is free of the latency of blockchain transactions and the gas fee for execution (you rent the worker instead of paying for each instruction in Query processing). Second, Query is meant to change the local (off-chain) state. We further empower it with the ability to <a href="https://github.com/Phala-Network/phala-blockchain/tree/master/crates/pink/examples/use_cache">read/write local cache</a> and <a href="https://github.com/Phala-Network/phala-blockchain/tree/master/crates/pink/examples/http_client">send HTTP requests</a>, this means you can directly utilize all existing web services including data feeds, Telegram/Discord bot APIs, online storage like AWS, and more.</p><p>In other words, when you are writing functions for Query, it’s more like you are writing a normal server program instead of a smart contract. But this time, your “server program” is executed on a real decentralized cloud, and can use the blockchain as the root of trust: each Fat Contract is allocated a key pair with the public key published on-chain. This key pair proves the program identity and can be used to sign any messages to prove that they are really produced by a certificated contract and thus can be trusted. This enables attestation operation, which is the basis of Oracle, Decentralized Identity, and other interesting Web3 applications.</p><p>Now, why not get your hands dirty and <a href="https://wiki.phala.network/en-us/build/developer/fat-contract-tutorial/">try the Fat Contract yourself</a>?</p><h3>More Readings</h3><ol><li>Blog: <a href="https://medium.com/phala-network/introduction-of-fat-contract-dea79ffcf0dc">Introduction of Fat Contract</a></li><li>Paper: <a href="https://www.ise.tu-berlin.de/fileadmin/fg308/publications/2018/Off-chaining_Models_and_Approaches_to_Off-chain_Computations.pdf">Off-chaining Models and Approaches to Off-chain Computations</a></li><li>Blog: <a href="https://www.parity.io/blog/substrate-off-chain-workers-secure-and-efficient-computing-intensive-tasks/">Substrate off-chain workers: Secure and efficient computing-intensive tasks</a></li><li>Blog: <a href="https://medium.com/@YondonFu/off-chain-computation-solutions-for-ethereum-developers-507b23355b17">Off-Chain Computation Solutions for Ethereum Developers</a></li></ol><h3>About Phala</h3><p>Phala Network tackles the issue of trust in the computation cloud.</p><p>By organizing a decentralized network of computation nodes around the world, it offers high-performance services without relying on any cloud vendor. Phala workers run the programs in Secure Enclaves, a privacy technology already embedded into modern processors, enabling versatile and confidential execution. Together, this creates the infrastructure for a powerful, secure, and scalable trustless computing cloud.</p><p>🍽 — <a href="https://mailchi.mp/fd48395f09dc/w3a-landing-page">Subscribe</a> | <a href="https://phala.network/">Website</a> | <a href="https://twitter.com/PhalaNetwork">Twitter</a> | <a href="https://github.com/Phala-Network">Github</a></p><p>🥤 — <a href="https://discord.gg/myBmQu5">Discord</a> | <a href="https://forum.phala.network/">Forum</a> | <a href="https://t.me/phalanetwork">Telegram</a> |<a href="https://medium.com/phala-italia/ancora-pi%C3%B9-premi-in-arrivo-fino-a-150-pha-per-ksm-e-nuove-nft-in-edizione-speciale-ba2776148de8">Italiano</a> |<a href="https://medium.com/phala-fran%C3%A7ais/encore-plus-de-r%C3%A9compenses-jusqu%C3%A0-150-pha-par-ksm-et-de-nouveaux-nft-%C3%A9dition-sp%C3%A9ciale-9e5f7683c5b6">Français</a> | <a href="https://virgool.io/PhalaNetwork-Persian/%D8%AC%D9%88%D8%A7%DB%8C%D8%B2-%D8%A8%DB%8C%D8%B4%D8%AA%D8%B1-%D8%A8%D8%B2%D9%88%D8%AF%DB%8C-%D8%AA%D8%A7-%DB%B1%DB%B5%DB%B0-pha-%D8%A8%D9%87-%D8%A7%D8%B2%D8%A7%DB%8C-%D9%87%D8%B1-ksm-%D9%88-%D9%86%D8%B3%D8%AE%D9%87-%D9%87%D8%A7%DB%8C-nft-%D9%88%DB%8C%DA%98%D9%87-ejxonlenaxp2">Persian</a> | <a href="https://medium.com/phala-%ED%95%9C%EA%B5%AD">Korean</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d44dc8afb141" width="1" height="1" alt=""><hr><p><a href="https://medium.com/supercolony/fat-contract-introduce-off-chain-computation-to-smart-contract-d44dc8afb141">Fat Contract: Introduce Off-chain Computation to Smart Contract</a> was originally published in <a href="https://medium.com/supercolony">WASM conference</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A hitchhiker’s guide to WASM smart contract ecosystem]]></title>
            <link>https://medium.com/supercolony/a-hitchhikers-guide-to-wasm-smart-contract-ecosystem-c8c2d249a45c?source=rss----35210e40651d---4</link>
            <guid isPermaLink="false">https://medium.com/p/c8c2d249a45c</guid>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[wasm]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[astar-network]]></category>
            <dc:creator><![CDATA[Hoon Kim]]></dc:creator>
            <pubDate>Tue, 07 Jun 2022 17:49:18 GMT</pubDate>
            <atom:updated>2022-06-07T17:49:18.701Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Post Material after WASM conference 2022</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6RroHjc2RfmQo1i-gkEKZA.jpeg" /><figcaption>Post Material after WASM conference 2022</figcaption></figure><h3>Introduction</h3><p>Smart contracts are what allow other people to create custom use cases on top of a blockchain.</p><p>For a blockchain to support smart contracts, it must have a smart contract execution environment or a smart contract virtual machine. Arguably the most popular environment is the Ethereum Virtual Machine (EVM), first introduced by the Ethereum blockchain, and later adopted by many different networks that wish to leverage the massive ecosystem that Ethereum was able to create. However, there are other smart contract virtual machines that are not EVM, and most of them are based on WebAssembly (WASM).</p><h3>EVM vs WASM</h3><p>EVM is a stack-based state machine that interprets the EVM opcode into computational instructions that can be executed on top of the blockchain. It was made by the founder of Polkadot, Dr. Gavin Wood. Developers can use the contract-oriented language, such as Solidity or Vyper to write applications that can compile down to the EVM byte code. EVM has a depth of 1024 items, and each item is a 256-bit word.</p><p>The 1024 item limitation means that there is an inherent limitation of complexity for EVM smart contracts. On top of this, because all operations are 256-bit, this also means that all non-256-bit processors (so all) will have a significant overhead when computing these operations. Furthermore, the language capability is also a problem as the EVM bytecode is made from the ground up, so if any other language were to target EVM, they will have to create the compiler from scratch, making it very difficult for expandability. Not to mention the unusual syntax of a contract-oriented language, making the barrier of entry quite steep. Overall, the limitation of EVM makes it very challenging for Solidity dApp developers to create a complex use case.</p><p>With more advanced use cases, smart contracts demand more complexity and EVM has been showing its limitations. That is where the WASM-based smart contract comes in.</p><p>WASM is technically a binary instruction format that can run on stack-based virtual machines that implement the instructions such as V8. But for the general public and in this context, when we say WASM, we refer to a generic virtual machine that can execute WASM instructions. WASM itself is a common standard for executing native-level operations from a browser environment. The development is led by industry leaders like Google, Microsoft, Mozilla, Apple, and more. With the power of WASM, you can run any hardware-intensive work such as games from the browser with near native-level performance.</p><p>Similar to EVM, WASM is also a stack-based VM that operates through a bytecode. Programming in WASM means using a higher-level language that can compile down to WASM bytecode that can only run within the WASM sandbox (VM). In other words, WASM can be a perfect fit for a smart contract VM. And many popular blockchains share this sentiment as we are seeing an increased number of high-performing networks that use a custom VM that is either inspired by WASM or is directly using WASM.</p><p>The main advantage that WASM has over EVM are but are not limited to:</p><ul><li>Native 32/64-bit operations</li><li>Extensive language support</li><li>Easier to expand the ecosystem</li><li>High performance and compatibility</li></ul><p>There may be more, but these are the main reasons why the blockchain ecosystem is moving to WASM including eWASM, a WASM implementation of EVM.</p><p>So we know that WASM-based smart contracts are technically superior to EVM, but why is EVM still king when it comes to dApp development? Why are so many networks still using EVM?</p><p>The simple answer is because of its developer ecosystem. There are so many tools, examples, materials, and communities behind it, Solidity is the gateway language for many new dApp developers, and because most blockchains with high liquidity support EVM, it makes it difficult for new projects to ignore them.</p><p>So let’s look into how other blockchain networks using an alternative VM manage to row their ecosystem despite EVM?</p><h3>Other Smart Contract Platforms</h3><h3>Solana</h3><p>Solana is well-known for its near-instant finality and smart contract performance. Interestingly, they call their smart contracts ‘on-chain programs’ which can be written in C++ and Rust. And technically, Solana does not operate in WASM. Instead, they use Berkeley Packet Filter bytecode as their VM. However, the contract language will use LLVM (the same compiler that targets WASM) to compile their program, and it is very easy to recompile the code with minimal changes to WASM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qoQtzNKyS1swF775" /></figure><p>The main documentation can be found in the official Solana docs (<a href="https://docs.solana.com/">https://docs.solana.com/</a>), which is where all new developers are expected to start. However, there are no other educational materials that are maintained or endorsed by the core team.</p><p>Although their client API, @solana/web3.js is lackluster due to the way how communication with on-chain programs works, their biggest strength comes from their all-in-one tool called the Solana Command-line tool.</p><p>From a single CLI tool, users can use the following functions to name a few:</p><ul><li>Faucet airdrop</li><li>Account management</li><li>Deploy on-chain program</li><li>Build transactions</li><li>Node management</li><li>Staking</li><li>Signature utility</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_-GdvoCrY_L-SZ10" /></figure><p>There is no embedded scaffolding in the CLI, there is a separate repository maintained by the core team that developers can use for their projects.</p><h3>Near</h3><p>Near is famous for its nightshade shards and high-performance WASM smart contract VM. But another reason why it is famous amongst developers is probably because of its sophisticated developer ecosystem. You can write Near smart contracts with Rust and AssemblyScript (a variant of TypeScript)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9Oj-If10p47AU_Ny" /></figure><p>Similar to Solana, Near also has a single document site which can be found at<a href="https://docs.near.org/"> https://docs.near.org/</a>. First-time developers will only need this documentation for both client-side and smart contract development, with a link to the node management/development in there too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/0*V0qjAIlJLFOSAY2_" /></figure><p>They also have a list of external resources that are helpful for developers wanting to learn on their front page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*7EfRL1KLIcX6-2cz" /></figure><p>Near also has its own JavaScript client API called near-api-js. Developers can use this API to create any RPCs for the node such as calling smart contracts, making transactions, and more.</p><p>Perhaps the biggest tool that Near has is the Near CLI, which is a Node.js CLI tool that uses the near-api-js in the back to interact with the Near blockchain.</p><p>The Near CLI can do the following:</p><ul><li>Account management</li><li>Deploy smart contracts</li><li>Interact with smart contracts</li><li>Build transactions</li><li>Manage validators</li><li>Scaffold dApp repository (contracts and frontend)</li></ul><h3>CosmWasm</h3><p>The Cosmos ecosystem is quite similar to the Polkadot ecosystem in the sense that it has a core SDK for building a modular blockchain with interoperability in mind. CosmWasm is a module for the Cosmos SDK that adds smart contract functionality to the Cosmos ecosystem. One famous network that uses this is Terra. Currently, CosmWasm only officially supports Rust smart contracts, but because the core module is made using Go, we can imagine expanded language support in the future.</p><p>Because CosmWasm is a module of the Cosmos SDK, there is a main CosmWasm developer document and multiple smaller documents that are maintained by the Cosmos ecosystem projects that use the CosmWasm module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XGdnjbu5QtCSW4W9" /></figure><p>For example, the Terra Academy (<a href="https://academy.terra.money/">https://academy.terra.money</a>) is the main source for learning hands-on development using Rust and developing a smart contract with CosmWasm. And the main Terra document only contains the developer reference for the CosmWasm smart contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p4K-pD2FzZHyU7Zy" /></figure><p>Most of the developer documentation can be found on the main CosmWasm document page (<a href="https://docs.cosmwasm.com/">https://docs.cosmwasm.com</a>). However, CosmWasm is not a sovereign blockchain, most new developers will start their journey from documents that are maintained by projects that are using the CosmWasm module, and then will eventually refer to the main document for details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SYgYWRzh-XzcFlE1" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FBAMkhIPjvbd7l_x" /></figure><p>CosmWasm has its own JavaScript API called the CosmJs, and terra.js which is made for interacting with WASM smart contracts on the Terra Network.</p><p>Unlike the other networks, CosmWasm does not have a dedicated all-in-one CLI tool, instead, it uses cargo to compile the Rust smart contract, and the Go CLI called wasmd to deploy and interact with it from the terminal. However, there are a lot of manual configurations and prerequisites for setting up the developer environment for CosmWasm. That is why Terra has an all-in-one CLI tool called the Terrain. Terrain can do the following:</p><ul><li>Account management</li><li>Network management</li><li>Scaffold dApp repository (contracts and frontend)</li><li>Testing</li><li>Deploy smart contract</li><li>Interact with contracts</li><li>Client script framework</li></ul><h3>Polkadot/Substrate</h3><p>The Polkadot ecosystem also has an interesting structure as the Polkadot network itself does not support smart contracts. Instead, blockchains that are built with Substrate (the equivalent to a Polkadot SDK) can implement a runtime module called the Contract Pallet. This pallet will allow any blockchains that implement it to execute WASM smart contracts. Currently, it supports ink (an eDSL of Rust) and there are works to support an eDSL of AssemblyScript.</p><p>Substrate WASM contract documentation is quite messy and spread out instead of having a single source as Substrate treats the contract pallet, the WASM contract language (ink), and the JavaScript API as a separate project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PjJiowhmHPuz38v0" /></figure><p>Substrate node developers can learn about the contract pallet through the official Substrate developer document<a href="https://docs.substrate.io/v3/runtime/smart-contracts/"> https://docs.substrate.io/v3/runtime/smart-contracts/</a> and on their workshop<a href="https://docs.substrate.io/tutorials/v3/ink-workshop/pt1/"> https://docs.substrate.io/tutorials/v3/ink-workshop/pt1/</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BNGRp-VEdwo7qEdZ" /></figure><p>New developers wishing to build on the Polkadot ecosystem may start from the official Polkadot documentation<a href="https://wiki.polkadot.network/docs/build-smart-contracts"> https://wiki.polkadot.network/docs/build-smart-contracts</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uO8oXot_SM0gaemi" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*APd1oQV7dffBB3AH" /></figure><p>But ultimately, they will have to read the detailed development guidelines from the official ink document (<a href="https://ink.substrate.io/">https://ink.substrate.io/</a>), or from the individual parachain’s developer documents like the one Astar Network provides<a href="https://docs.astar.network/wasm-smart-contracts/smart-contract-development"> https://docs.astar.network/wasm-smart-contracts/smart-contract-development</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hF_VDm5esSqScbaQ" /></figure><p>Perhaps the most comprehensive and mature WASM smart contract developer documentation for the Polkadot/Substrate ecosystem might be OpenBrush maintained by SuperColony. For general WASM contract development with ink, this is the best source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_dDRl3zGHOUB_cYB" /></figure><p>Polkadot/Substrate also has a JavaScript API called the @polkadot/api, which also has its own documentation. Because the smart contract API is part of the Polkadot API package, the documentation is kept here, maintained by the Polkadot.js team.</p><p>As you can see, there is no single go-to documentation for developing WASM smart contracts on the Polkadot/Substrate ecosystem like the other projects, and because the contract pallet, the language compiler, and the JavaScript API for interacting with the contract are treated as separate projects, the documents are kept separately without a single source where new developers can see everything at a glance.</p><p>For the CLI tool, Polkadot/Substrate does not have an all-in-one tool or a standard developer environment for building smart contracts like Terrain, Near CLI, or Solana CLI. Instead, the tools are split into the Substrate node management tool and the language compiler tool. Although there was a tool called Redspot that streamlines the node setup and account management process for smart contract developers, this tool is no longer maintained.</p><p>The Substrate CLI provides:</p><ul><li>Account management</li><li>Signer utility</li><li>Node management</li><li>Network management</li></ul><p>And the ink contract compiler CLI (also known as the cargo contract provides:</p><ul><li>Build contract</li><li>Deploy contract</li><li>Run unit tests</li><li>Interact with the smart contract</li><li>Decode contract data</li></ul><h3>The ecosystem at a glance</h3><p>Now we’ve explored what the WASM contract ecosystem has to provide, let’s compare and contrast these networks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JQpLiafnyB2dlvf2JOVzbA.png" /></figure><p>As you can see, it is much easier for a single blockchain network to provide a unified developer environment and documentation, making it easy for new developers to understand everything at a glance. On the other hand, blockchain frameworks and layer 0 chains like Cosmos and Polkadot/Substrate have a hard time creating a unified developer environment and CLI tools as it could put a bias in certain networks. That is why it is natural for the blockchain that is built on top of that framework to provide the documentation and tools like how Terra does. Although the CosmWasm is much more unified than how Substrate handles it since CosmWasm treats the language, contract module, and the JavaScript API as part of the single project, rather than separate everything like Substrate.</p><p>Let’s look at the tool support now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*He2466meIBQDQ0oUrsTjiw.png" /></figure><p>It’s clear that blockchains like Near and Solana provide more integrated all-in-one tools for developers, while the Cosmos ecosystem with CosmWasm only provides basic features and relies on its ecosystem projects like Terra to create a fully integrated environment alongside its existing tools. On the other hand, Substrate CLI tools are very scattered as the developer must first set up a local contract node as the deploy target, and although we have the cargo contract, the Substrate ecosystem expects to see more smart contract languages like ask, having a CLI tool that is made specifically made for a single language will make it difficult for future language adoption.</p><h3>Making WASM Swanky Again 😎</h3><p>As you can see from the previous sections, although the WASM contract ecosystem is still new, there are many high-profile projects that are really pushing this technology for mass adoption. But the progress for the Substrate ecosystem still seems lagging and disorganized even though the underlying technology is on par if not better.</p><p>That is where we come in. Astar Network aims to push the Substrate WASM ecosystem for all future dApps who wish to leverage the interoperability of Astar Network.</p><p>To do this, we, at Astar Network, will focus on unifying the developer documentation who starts their developer journey from Astar Network, increase developer education, incubate and provide grants for new and innovative WASM dApps, and most importantly, create the Swanky CLI.</p><p>Swanky CLI is an all-in-one CLI tool for Substrate WASM contract developers that our ecosystem needs the most.</p><p>This tool is still under heavy development, but we plan to support various features like:</p><ul><li>Unit-testing</li><li>Contract interaction</li><li>Deploying</li><li>Account management</li><li>Developer node setup</li></ul><p>By the end of June, and in the future, we will add:</p><ul><li>Integration tests</li><li>Scaffolding for both front-end apps and contracts</li><li>and much more</li></ul><p>Because the codebase is made with modularity in mind, Swanky will add support for multiple smart contract languages as more projects join to expand the ecosystem. We are excited to be part of the future of smart contracts.</p><p>And this is the end of the hitchhiker’s guide to the WASM smart contract developer ecosystem.</p><p>Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8c2d249a45c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/supercolony/a-hitchhikers-guide-to-wasm-smart-contract-ecosystem-c8c2d249a45c">A hitchhiker’s guide to WASM smart contract ecosystem</a> was originally published in <a href="https://medium.com/supercolony">WASM conference</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hybrid dApps and the future of Smart Contracts]]></title>
            <link>https://medium.com/supercolony/hybrid-dapps-and-the-future-of-smart-contracts-b156eff402e4?source=rss----35210e40651d---4</link>
            <guid isPermaLink="false">https://medium.com/p/b156eff402e4</guid>
            <category><![CDATA[acala]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[wasm-contract]]></category>
            <category><![CDATA[polkadot]]></category>
            <dc:creator><![CDATA[Bryan Chen]]></dc:creator>
            <pubDate>Tue, 07 Jun 2022 16:13:19 GMT</pubDate>
            <atom:updated>2022-06-07T16:13:19.144Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Post Material after WASM conference 2022</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FR237ZDJJ8vUlP0uSFm0oQ.png" /></figure><p>Historically, there were only a few options when building a blockchain protocol: build using smart contracts and deploying it to either Layer 1 or Layer 2 blockchains, or building it as a Layer 1 or a Layer 2 blockchain. Each option has its own advantages and disadvantages, but there are always some trade-offs. However, there is a third option that is currently fairly unexplored. We can decide on both options simultaneously. Getting the best of both worlds is achieved by thoughtfully designing the architecture of components and creating a hybrid DApp that utilizes the advantages of both approaches mentioned in the beginning. The ability to build a blockchain and smart contracts using the same language (e.g. Rust), which are running within the same virtual machine (e.g. WASM), opens up many interesting and possibly revolutionary possibilities to be discovered.</p><h3>Acala and the Protocol Setup</h3><p>Acala is the decentralised finance network powering the aUSD (native multichain overcollateralized stablecoin) ecosystem. aUSD is the native decentralised stablecoin of Polkadot Polkadot and Kusama, and can be easily and trustlessly integrated into parachains and DApps. aUSD protocol implements advanced risk management mechanisms such as on-chain keeper system and Quality of Service for Oracle price feeds.</p><p>Acala leverges unique features powered by Substrate and Polkadot’s shared security &amp; crosschain interaction protocol to deliver a solid foundation to build a new generation of DeFi protocols. By offering both pallets and smart contracts protocols, new innovative ideas can be implemented benefiting from the hybrid DApps architecture.</p><p>Acala has three native supporting protocols:</p><ul><li>Homa Liquid Staking powering LDOT/LKSM staking derivatives as high-quality collateral for aUSD and an essential building block for DeFi on Polkadot</li><li>Acalaswap is an evolving DeX aggregator. Its core purpose is to enhance the liquidation mechanism for aUSD and power `pay fees in any token` feature of the Acala network.</li><li>EVM+ that brings together the best of Substrate pallet development and smart contract development; it empowers Acala to be the multi-chain liquidity hub, where smart contracts can integrate Polkadot-native assets seamlessly as ERC-assets, and ERC-assets can become Polkadot-native assets and trustlessly cross to any other connected parachains. EVM+ also allows developers to build Hybrid DApps that integrate with native pallet protocols and leverage powerful Substrate features such as auto-scheduler.</li></ul><p>Examples of different types of DApps</p><ol><li>Core protocols built using pallets: aUSD Stablecoin, Liquid Staking, and Acalaswap.</li><li>Smart contract dapps: Wormhole (multichain bridge), Citizend (Compliant Polkadot Launchpad), Project Venkman (Loyalty and NFT platform for real world businesses)</li><li>Hybrid protocols that built with both pallets and Smart Contracts: Taipo (stableswap and synthetic asset) and Kujira (liquidation marketplace)</li></ol><h3>Compiled versus scripted approach</h3><p>When teams are considering building their solutions in the Polkadot ecosystem, they often consider whether they should build a pallet or a smart contract. Determining the best option requires understanding the advantages and disadvantages of pallets and smart contracts, and how they compare to each other. Interestingly, the comparison is similar to between choosing a compiled language (e.g. C++, Rust, Go) versus choosing a scripting language (e.g. JavaScript, Python, Ruby) when building a web2 project.</p><h3>Advantages and disadvantages of pallets</h3><p>The primary advantage of building a pallet is the ability to access the raw performance of the platform. This way the application is faster and uses less memory or storage. It also means the application has direct access to the low-level features and can use various advanced APIs that might be available. Since the ability to access the low level primitives translates to more optimization possibilities, the performance cannot be matched using smart contracts.</p><p>The downside of using the pallet approach is the development, deployment, and execution feedback loop is usually much longer for pallets than it is for smart contracts. This is because the whole runtime usually takes longer to build, the changes can affect multiple other modules, and additionally the deployment of the runtime usually requires a long governance process, similar to a long review process when deploying a native app to an app store. The ability to access the low level primitives can be powerful but introduces additional security aspects to consider at the same time. These include, but are not limited to, logic errors, resource exhaustion errors and denial of service attack vectors. If the runtime panics, the blockchain is likely to be bricked and can be very hard to restore. Adding up all the potential pitfalls of the pallet approach means there is a very steep learning curve, because there is a significant amount of knowledge required besides just writing business logic.</p><h3>Advantages and disadvantages of smart contracts</h3><p>Compared to pallets, smart contracts offer a fresh set of advantages and disadvantages. The chief advantage of smart contracts is that they are more accessible. The deployment of smart contracts is usually permissionless, so anyone with enough funds to pay for the transaction fee can deploy their own smart contract. This is similar to when applications offer the ability for external developers to write and deploy plugins using a scripting language. Another benefit of smart contracts is the development and deployment cycles are usually faster, as there is less compilation required, and deployment is easier and faster. This can improve productivity by allowing developers to have a shorter feedback loop and can adjust the code based on the actual execution quicker. Smart contracts, as well as scripts, are usually executed within a sandbox. While this means there might be restrictions on what can be done, it also means the code can’t do things it’s not supposed to (unless there is a critical vulnerability in the sandbox). Security is still the top priority of any smart contract, but in case anything goes wrong, the sandbox will ensure only the faulty smart contract (and the contracts that depend on it) are affected, and won’t will not damage the underlying platform. Another benefit of smart contracts is developers only need to focus on the business logic without worrying about many additional details. This means they have a more gradual learning curve and are easier for new developers to get started.</p><p>Running inside a sandbox also introduces additional overhead. This means the application might be slower and use additional resources due to the overhead. Since the application can only access features exposed by the sandbox, it may not access some of the more advanced features that are deemed potentially unsafe. The smart contract can only execute whatever the platform allows it to.</p><h3>Hybrid approach to DApp design</h3><p>We observed the advantages and disadvantages of both approaches. However, if we thoughtfully approach the design of our application components, we can create a hybrid application that utilizes the benefits of both approaches, while avoiding as many of the disadvantages. This approach has already been employed to address various use cases, such as game engines, IDEs and automation tools. Game engines are usually written in system programming languages such as C or C++, since they are very sensitive to the performance and resource usage. They also require direct control of the execution and all the resources.However, to improve the productivity of game development, most of the game engines can embed a scripting language for the game logic that is not performance sensitive. IIt creates a possibility for third party developers to create custom mods and add additional features to the game. Developers have the ability to build new games on top of an existing game. Another example are IDEs and advanced text editors. Most of them support third-party plugins that allow third-party developers to create and publish plugins to further enhance their functionality. It’s relatively easy to create a new plugin for an IDE to support a new language, with no IDE team to get involved at all.</p><p>Examining how traditional applications employ the hybrid approach can provide some insight into how a similar approach can be utilized when building a DApp. Much like the game engine design, where the performance sensitive features are implemented in a compiled programming language, the compute-intensive operations should be implemented in the pallets to avoid the extra overhead and expose them in a way that they are accessible to the smart contracts. Many features, like initialization on hook and transaction fee customization, are unsafe to be exposed to the permissionless smart contracts directly. However, it’s safe to expose a limited set of those functionalities for a specific purpose to allow smart contracts to utilize those advanced features as well.</p><p>For example, it’s possible to pay a transaction fee in Acala using any ERC-20 token that’s listed on Acala Swap. Because of security requirements and the nature of decentralized governance, it’s imperative for the runtime upgrade process to be slow. This means it can take a significant amount of time to have new changes to pallets deployed. For this reason, the pallet code needs to be stable, and the code that requires frequent modifications and upgrades should be implemented with smart contracts, which can be upgraded relatively quickly, depending on the governance configuration. For example, the token fee model can be implemented in smart contracts to allow anyone to propose their own model and use governance to decide which one shall be selected. Smart contracts can enhance pallet code. We can use smart contracts to implement more advanced batch transaction mechanics to smartly execute multi step actions automatically based on various conditions. This can make advanced yield farming strategies easily accessible to everyone. We could also use smart contracts to complement pallets. For example, we can implement a passive liquidation pooling strategy to participate in stablecoin liquidations on off-chain liquidation bots to actively participate in liquidations. These are just a few examples of what can be done. There are a lot more interesting applications of hybrid pallet approaches that could change how we are building DApps.</p><p>Another advantage of specifically building using ink! and WASM smart contracts if they are powered by the same tool that powers a Substrate chain: Rust and WASM. This means sometimes you don’t even need to decide where the logic will be executed initially. With the right abstractions, you can design the logic to be generic and runnable within both, pallets and smart contracts. This provides the freedom to explore the best way to structure the components without committing to one option too early into the development. We can share a lot of code between the pallet and the runtime because of it. For example, XCM has defined many structures that would be cumbersome to redefine in other languages. But with ink! we could theoretically just import the crate from Polkadot and have an up-to-date definition of XCM. The ability to share code and interfaces between pallets and smart contracts can significantly reduce the effort required to build and maintain a hybrid app and eliminate a category of bugs caused by mismatched interfaces. This also provides a graduation path for smart contracts. People can prototype and launch their project with smart contracts, deploy to one of the parachains that support smart contracts and later, if needed, can upgrade them to a parathread or parachain by reusing most of the existing code.</p><h3>DApps The Future of Blockchain</h3><p>Among the hindrances of blockchain application advancement or DApp development is the complexity in design approach; developers must select either the pallets route or smart contract route and accept the pros and cons of each option. However, with the hybrid design, developers can leverage the best of both worlds.</p><p>Traditional applications like games demonstrate the effectiveness of utilizing different approaches to deliver an efficient, performing application. Applying the same concept to DApps encourages inventive thinking on DApp development. Smart contracts and pallets when used tactfully and with purpose, both technologies can synergise to facilitate complex logic execution in advanced industry scenarios.</p><p>The hybrid model provides a path for developer integration and advancement in the world of blockchain. The code sharing ability between smart contracts and pallets through the hybrid model encourages gradual developer improvement in DApp design, and the code and interface exchange between smart contracts and pallets can inspire developers to continue building with the goal of constantly upgrading or improving their DApps as they better understand the hybrid model.</p><p>Thus, hybrid application highlights the future of smart contracts, one where developers use them as stepping stones to create holistic, strengthening platforms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b156eff402e4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/supercolony/hybrid-dapps-and-the-future-of-smart-contracts-b156eff402e4">Hybrid dApps and the future of Smart Contracts</a> was originally published in <a href="https://medium.com/supercolony">WASM conference</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smart contracts vs Custom blockchains]]></title>
            <link>https://medium.com/supercolony/smart-contracts-vs-custom-blockchains-eeb04f9f2119?source=rss----35210e40651d---4</link>
            <guid isPermaLink="false">https://medium.com/p/eeb04f9f2119</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[substrate]]></category>
            <dc:creator><![CDATA[Heorhii Lutsenko]]></dc:creator>
            <pubDate>Tue, 07 Jun 2022 12:02:23 GMT</pubDate>
            <atom:updated>2022-06-07T12:24:07.889Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Post Material after WASM conference 2022</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aUpyXsJb8ZXgie1nx697BQ.png" /></figure><blockquote><em>No silver bullet</em></blockquote><blockquote><em>Fred Brooks, “No Silver Bullet — Essence and Accident in Software Engineering”</em></blockquote><p>Despite all of you should already know what a smart contract and blockchain are, we still need to provide simple definitions of the smart contract and custom blockchain.</p><p>Ethereum’s definition of the smart contract sounds like this: a “smart contract” is simply a program that runs on the Ethereum blockchain. It’s a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain. If we exclude Ethereum from here, we can get the most simple definition of smart contracts.</p><p>As for the definition of a custom blockchain, the situation is complicated, so I propose to rephrase the question of what is a custom blockchain into what do we call a custom blockchain?</p><p>Generally speaking, all blockchains are custom in some sense. Bitcoin aimed to be digital cash, Ethereum aimed to be an internet computer, and many other projects also tried to resolve different problems. We won’t exclude any blockchain from the term custom blockchain, but we think that the best examples of custom blockchain originate from <a href="https://substrate.io/">Substrate</a>-based blockchains or application-specific <a href="https://cosmos.network/">Cosmos</a> blockchains. Both Substrate and Cosmos SDK provide us with different blockchain-specific modules, such as consensus mechanism, networking, cryptography, RPC module, tests, and benchmarks. So we can focus development on blockchain logic itself.</p><p>Let’s move to the goals of this article. We aim to answer the next questions:</p><p>What is a more secure smart contract or custom blockchain?</p><p>What limitations each approach has?</p><p>What technologies do we use, and is a development process convenient enough?</p><p>What is the image of smart contracts and custom blockchains from a business perspective?</p><p>When should we use smart contracts or custom blockchains?</p><h3>Comparison</h3><p>Smart contracts and custom blockchains are different entities, so there is no sense to compare them face to face, we can only try to measure the different properties of each approach. So we need to keep in mind that one term can mean different things for smart contracts and blockchains. We will try to highlight this difference where it’s possible. We will discuss our vision for the next topics:</p><p><strong>Security</strong>. What is security for contracts and what is security for blockchains? What are the risks for both approaches? What does security consist of in our context?</p><p><strong>Freedom</strong>. What is possible and what is not when using each of the approaches?</p><p><strong>Development and Technologies</strong>. What do we need for the development process? Is it convenient from our point of view?</p><p><strong>Business</strong>. There are no simple answers to the question of what approach is better in your case. We try to describe the status quo and express our thoughts.</p><h3>Smart contracts. Security</h3><p>Security can have different meanings depending on the context, but certainly, the whole blockchain industry tries to achieve the maximum level of security. We will talk about this in smart contracts and custom blockchain contexts.</p><p>So what is the definition of security in the context of a smart contract? We can separate two faces of smart contracts security:</p><ul><li>Security of smart contract per se.</li><li>Smart contract safety in the broader context of the network where we deployed a smart contract.</li></ul><p>By the smart contract per se, we mean any security issue which originates from the smart contract developer side, i.e. critical bugs, and backdoors, also we can mention here the smart contract level of decentralization, I mean how the rights are distributed among the users because if we have a super user with too many privileges we should trust in this authority and if this authority is a little bit malicious we may lose our funds and assets.</p><p>Can we say that smart contracts guarantee the safety of your funds and assets? Not and I think you can mention many real-life examples of such situations. But can we blame the idea of smart contracts itself? Of course not. The concrete implementation of smart contracts is the responsibility of the developer. We can only build some walls on hacker paths: security audits, high level of expertise, bounty programs, tests, etc. The final nail in the coffin of the contract’s security is that even the technologies we use to create them can have bugs and that the environment where execution takes place can be unsafe. But does this problem stop somebody from making a smart contract? The reality gives us an answer — no, we can live with such risks. In some cases, network authorities can fork the blockchain only to revert changes that malicious actors make by exploiting the vulnerabilities of a smart contract. Of course, I mean the history behind the <a href="https://www.gemini.com/cryptopedia/the-dao-hack-makerdao#section-origins-of-the-dao">Great DAO hack</a> and Ethereum hard fork, and we should keep this in mind.</p><p>Regarding security in a network context, the picture looks much brighter. Generally speaking, the network is safe because it has a sandbox for smart contract execution. Also, the network can guarantee that nobody will abuse the contract because you should pay both for smart contract storage and execution. So, if fees in the networks are high enough, then malicious actors won’t have a cause to, for example, DDoS your contract if they have such intention.</p><p>But sometimes we can not separate smart contracts’ safety from protocol safety because smart contracts are pillars of interoperability between different networks, such as bridges. In this case, unsafe smart contracts can disrupt security. The <a href="https://en.wikipedia.org/wiki/Poly_Network_exploit">PolyNetwork hack</a> is an excellent example of this case.</p><h3>Custom blockchain. Security</h3><p>It’s hard to define security for the custom blockchains because we need to talk about the base level of blockchain:</p><ul><li>Cryptography</li><li>Consensus &amp; finality</li><li>Networking</li><li>Economic</li></ul><p>The development of each of these topics has practical and theoretical problems.</p><p>Cryptography gives us a way to protect the information and preserve some privacy. But if you want to implement something new in this field, you need a team of Ph.D. to research the issue and prepare a theoretical base.</p><p>Consensus &amp; finality is blockchain-related stuff. We have different consensus mechanisms with various properties: PoW, different kinds of PoS, Proof of Capacity, and others, and who knows what we will see in the future. Implementing your custom consensus or choosing parameters of an already existing consensus mechanism is complicated. Your choice can lead to security issues.</p><p>Networking: what network topology do we require? How will different nodes communicate with each other? Is it easy to try a Sybilla attack on your network? What data format will we use for network communication? It would help if you had the correct answers to all these questions to make your network safe.</p><p>Economy. Your economic model should incentivize good behavior and punish the bad actors somehow. But is your economy’s stimulus strict enough to enforce good behavior? For example, if your blockchain has very cheap transactions, DDoS attacks become possible, but we will have scalability problems if they are too expensive. The problem with a cheap transaction fee is only one side of the problem. Recently, one <a href="https://en.wikipedia.org/wiki/Terra_(blockchain)">famous ecosystem</a> fell due to a faulty economic model.</p><p>As you can see, custom blockchains are much more sophisticated than smart contracts security.</p><p>To sum up, the pros/cons of smart contracts are that we inherit security from the network, and the contract can not violate the network’s security. The pros/cons of the custom blockchain are that we are responsible for complete security. Let’s move on to the next topic, highlighting the above-mentioned issues.</p><h3>Smart contracts. Freedom</h3><p>The word freedom may look pathetic in this context, but why not. By freedom, we mean the level of project complexity we can achieve and the tradeoffs, which we should keep in mind when implementing your solution as smart contracts or as a custom blockchain.</p><p>What can we achieve by using smart contracts? Simple answer — anything, smart contracts themselves don’t limit you. Real answer:</p><ul><li>The last section mentioned a safe environment (sandbox) for smart contract execution. Sandbox is overhead. Also, both <a href="https://ethereum.org/en/developers/docs/evm/">EVM</a> and <a href="https://webassembly.org/">WASM</a> can be inefficient depending on implementation details, so computational intensive logic can cost too much for you. For example, EVM 256 bits integers…</li><li>Networks can limit the size of your contract. For example, Ethereum allows only 24 Kb smart contracts. Yes, we can use a diamond pattern, but the limitation is still a limitation.</li><li>The network economy can limit you too because it should guarantee honesty and fairness for all actors, not only for you. So, the competition for the network resources can be very hard and cost too much.</li><li>Currently, we have one main platform type for smart contracts — EVM. WASM for smart contracts only carving its path. Both of them limit you in some sense. There are no solutions that will guarantee that your smart contracts can be deployed in all networks. We don’t mean that we need only one platform for all, but we need compatibility between platforms.</li><li>Smart Contracts would still need to be interpreted by a virtual machine, limiting performance compared to a native application.</li><li>The contract can’t be self-executed, i.e., we can’t implement something like “Call this function each third block”.</li><li>Of course, you can’t implement something related to the blockchain itself, for example, consensus and networking.</li></ul><h3>Custom blockchain. Freedom</h3><p>The question of what we can achieve by implementing custom blockchain sounds dumb because the whole blockchain world proves that there is nothing impossible:</p><ul><li>Digital currency</li><li>Internet computer</li><li>Decentralized storage</li><li>And all other fields, where we want to replace central ownership with decentralization</li></ul><p>One unresolved issue worth mentioning is the interoperability problem between different blockchains. There are different approaches for this — bridges or a Polkadot sharding, but no standard solutions exist.</p><p>Nothing changed in this sense compared to when the first blockchains emerged, except for one thing — now we have convenient tools to develop our blockchain, but let’s discuss it in the following topic about the development process.</p><p>So, the main question here is to be or not to be. Do you need this level of freedom as custom blockchain provides?</p><p>The goal of smart contracts is to extend blockchain business logic level, not to replace it; thus, comparing the degree of freedom for these two technologies may look senseless. I’m sure that the most enlightened of you can tell me that we already have different ways to overcome smart contracts limitations, so I should mention several of them:</p><ul><li><a href="https://ethereum.org/en/developers/docs/scaling/#layer-2-scaling">Layer 2 solutions</a> with off-chain computation can give us cheap network resources and make sandbox overhead and platform performance problems insignificant; this leads us to cheap and fast smart contracts.</li><li>TEE or <a href="https://en.wikipedia.org/wiki/Trusted_execution_environment">trusted execution environment</a>. You can use Phala Network <a href="https://wiki.phala.network/en-us/learn/products/about-fat-contract/">Fat Contract</a> as a reference.</li></ul><p>Both smart contracts and custom blockchains have problems with interoperability and interaction with the real world. For now, we have a hack called oracles to interact with the off-chain world safely. The interoperability problem for blockchains also has some solutions, such as Polkadot cross-chain messaging protocol and Cosmos hubs cross-bridging between different networks. However, we still don’t have a safe and scalable solution for this problem.</p><p>At the same time, the development of custom blockchain became much more straightforward; thus, competition in the common application field for smart contracts and custom blockchain, i.e., DApp, will become much more fierce. The main advantage of custom blockchain in the DApp case is independence from anything and everything and a higher level of performance.</p><h3>Smart contracts. Development and Technologies</h3><p>Unfortunately, we can’t just conjure a custom blockchain or smart contract — we need to develop it. For now, we need exceptional people to do this; thus, the development process has not only a technical dimension but also a social dimension.</p><p>First of all, people. The competition for professionals is a normal state of the labor market. The competition for IT specialists looks more fierce than in some abstract labor markets. At this moment, relatively new blockchain technology has become a point of interest for the world. I don’t think I’ll say something new right now, but the entire industry is experiencing a solid staff shortage, particularly the blockchain industry. So the common problem for both smart contracts and custom blockchains is to find the right people to do the right things.</p><p>Smart contracts development and technologies look more mature now, highlighting some obvious but important points. Despite new technology, we have</p><ul><li>Different languages for writing smart contracts: domain-specific languages for EVM (Solidity, Viper, Yul(+)) and potentially all general-purpose programming languages such as C++, Java, Rust, and others, for WASM technology.</li><li>It is worth mentioning that detailed documentation and tutorials exist for smart contract development.</li><li>It’s controversial, but we think that smart contracts development will be entirely separated from the underlayer network, which developers will interpret as a black box in the future.</li><li>Smart contracts have a relatively lower bar to entry for development. RELATIVELY, I don’t want to offend the smart contract’s developer community.</li><li>We think that technology is relatively mature because we have standards here. Standards are a language for software architecture.</li><li>Deploying smart contracts is easy.</li></ul><h3>Custom blockchain. Development and Technologies</h3><p>How can you develop your custom blockchain? There are several classic but always applicable options:</p><ul><li>We can create it from scratch</li><li>Fork and modify the existing solution</li><li>Use framework</li></ul><p>Also, we can use different programming languages to develop blockchains, but a comprehensive guide on how to make a good blockchain for every application does not exist.</p><p>Regarding frameworks for building blockchains with needed properties. I cannot avoid mentioning the Substrate and Cosmos SDK. They have different architecture. For example, Substrate is potent in the broader context of Polkadot parachains, but it is not limited by it.</p><ul><li>But developing your custom blockchains will require a relatively higher level of expertise from developers.</li><li>And deploying custom blockchains isn’t an easy task.</li></ul><p>The main advantage of smart contracts here is the development speed, standards, and required expertise. As for the custom blockchains’ development, it is more sophisticated. This is the price of freedom that we get.</p><h3>Smart contracts. Business</h3><p>Smart contracts are relatively cheap:</p><ul><li>Time is money, so fast development will save your resources.</li><li>If you want to integrate your business with existing smart contract solutions, it is better to do it with smart contracts.</li><li>Cheap and fast deployment.</li><li>It’s easier to gather a community around them.</li><li>Limited opportunities.</li><li>The development of smart contracts is more effortless than custom blockchains, but users will pay for it at a higher price.</li></ul><h3>Custom blockchain. Business</h3><p>Custom blockchains are relatively expensive:</p><ul><li>The development takes more resources, even with the framework.</li><li>You need to attract network validators.</li><li>More research work is required because it’s complicated to anticipate the best network parameters.</li><li>More security concerns.</li><li>Total freedom.</li><li>The development of custom blockchains costs much, but it’s cheaper for users.</li><li>The interoperability problem is not solved yet. But existing solutions have some price. For example, you need to compete with others for parachain slots during the auction.</li></ul><p>Custom blockchains are not for everyone, but they are better if you have the required resources.</p><h3>Conclusions</h3><p>To sum up, our thoughts about smart contracts and custom blockchains are contradictory. On the one hand, we can implement DApp using smart contracts, which will be faster and cheaper in development. On the other hand, custom blockchains look like a better solution in the long run because of their flexibility, performance, and independence. But this leads to another problem. While you are developing your great business idea as a custom blockchain, someone might already have gathered a community around smart contracts that had implemented it. But we can look at this from the other side, you can implement your idea as smart contracts as PoC and then start development of the custom blockchain, but this looks problematic in the world of limited resources.</p><p>What are our thoughts about smart contracts’ future? They will remain. Layer 2 solutions, adoption of WASM will support the steady growth of everything related to smart contracts.</p><p>What are our thoughts about the custom blockchains’ development? This approach will become more popular because of technologies for building your blockchains. Let’s compare the flexibility and performance of smart contracts and custom blockchains. The second is better but should keep in mind the required resources to develop, maintain and pay for it.</p><h3>Examples</h3><p>Let’s give simple answers to complicated questions.</p><p>When do we need smart contracts?</p><ul><li>When you require fast and relatively cheap development and easy deployment.</li><li>When your logic is simple, for example, you require just a token.</li><li>In cases of one-time events(ICOs, elections).</li><li>When you already have a vast smart contract, you want to port it to a compatible network.</li><li>When you want to be a part of a robust ecosystem based on smart contracts.</li><li>When you want to test your business model in reality.</li></ul><p>When do we require a custom blockchain?</p><ul><li>When you are unsatisfied with your current network capabilities: tps, fees, performance.</li><li>When you want to leverage specific platform benefits (for example, being a Polkadot parachain). But even in this case, you can deploy your smart contracts on different parachains with smart contract support such as Acala, Moonbeam, and Astar.</li><li>When you have a relatively long development time and have experts.</li><li>If it’s impossible to implement your idea on smart contracts.</li><li>Your goal is to implement something fundamentally different from existing blockchains, for example, a new consensus mechanism.</li></ul><h3><strong>About Supercolony 🪐</strong></h3><p>Supercolony is a venture studio dedicated to converting business ideas into successful high-level companies, leading the development processes, improving and strengthening business models, and increasing market capitalization. Supercolony’s goal is ecosystem creation, taking leadership in moving the market forward, creating the vector of ecosystem development, and making the entrance points for businesses more accessible. Our main mission is to make blockchain usable for everyone.<br><a href="https://www.linkedin.com/company/super-colony/mycompany/">LinkedIn</a> | <a href="https://supercolony.net/">Website</a> | <a href="https://twitter.com/supercolony_net">Twitter</a> |<a href="https://t.me/supercolony_polkadot">Telegram</a> | <a href="https://github.com/Supercolony-net">GitHub</a> | <a href="https://www.youtube.com/channel/UC5278rH2_UejuHEVvsArvkA/videos">YouTube</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eeb04f9f2119" width="1" height="1" alt=""><hr><p><a href="https://medium.com/supercolony/smart-contracts-vs-custom-blockchains-eeb04f9f2119">Smart contracts vs Custom blockchains</a> was originally published in <a href="https://medium.com/supercolony">WASM conference</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tools for Smart Contracts in Polkadot]]></title>
            <link>https://medium.com/supercolony/tools-for-smart-contracts-in-polkadot-60453341e934?source=rss----35210e40651d---4</link>
            <guid isPermaLink="false">https://medium.com/p/60453341e934</guid>
            <category><![CDATA[wasm]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[openzeppelin]]></category>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[polkadot]]></category>
            <dc:creator><![CDATA[Toma Sadova]]></dc:creator>
            <pubDate>Fri, 29 Apr 2022 16:52:03 GMT</pubDate>
            <atom:updated>2022-05-03T08:05:37.496Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4reg_Ws-wVSnL-fzzcnc6A.png" /></figure><p>My name is Toma, I am <a href="https://supercolony.net/">Supercolony</a> Market Growth Unit Lead, Product Owner of <a href="https://openbrush.io/">OpenBrush</a> (tool for smart contracts in Polkadot), WASM Conference Lead, and just a girl who explores the crypto, WEB3, and Polkadot world every day.</p><p><a href="https://supercolony.net/"><strong>Supercolony</strong></a> is a venture studio. As a venture studio, we are dedicated to converting business ideas into working companies and increasing market capitalization. And also to help existing businesses reach new levels, improve business models, tech expertise, or company structure.</p><p><em>Why the venture studio is focused not only on business issues but also on ecosystem growth and developing tools in Polkadot?</em></p><p>The vision of Supercolony is ecosystem creation, taking leadership in moving the market forward, and creating the way if there isn’t one. Now we clearly see this way: WASM in Polkadot as an essential next step in WEB3 progress.</p><p>This article is about <strong>TOOLS FOR SMART CONTRACTS IN POLKADOT</strong>. That was the topic of my speech at the AmsterDOT conference in Amsterdam, and now I would like to share this knowledge with everybody who wasn’t at this conference. Here I will explain the importance of WASM. Moreover, I would like to cover the business point of promoting/developing smart contracts in the current state of Polkadot.</p><p>So why did I decide to talk about the <strong>WASM</strong>, and why do I have confidence that it will be in the public eye for the next 2–3–4 years. Because I see a massive gap in knowledge, understanding, and vision for the whole community in that sphere, I aim to highlight all growth points and change them to breakthrough spots!</p><p>As probably all know, The Polkadot relay chain itself doesn’t support smart contracts. Polkadot was architected not for smart contracts at all. We adapted the understandable and useful technology to the new ecosystem. If we have such a need, let’s build the infrastructure for comfortable use. So for using smart contracts — you need a virtual machine such as EVM, eWASM, and WASM.</p><blockquote>As Gavin Wood once said — “WebAssembly in the future, but legacy EVM is right now.” I think the future is coming, and we should build the necessary conditions to speed up it.</blockquote><h3><strong>Why should we choose WASM Contract Pallet over EVM or others?</strong></h3><p>The problem with EVM is that it is a stack-based machine with its limitations, which you all probably know about, and so this means that smart contract cannot surpass a certain complexity and has some limitations in what can be done. This limits the features that the contract developers can create and discourage innovative projects from appearing on blockchains. Even with eWASM, the contract performance will be very slow, meaning that eWASM will not be as performant as a native WASM solution.</p><p>Furthermore, unlike EVM, adding additional language support for smart contract development (I’m talking about ink! ask! etc.). If we want to expand the smart contract development scene for a better future for blockchain technology, we need to make the technology more accessible for everyone.</p><h3><strong>Why WebAssembly for Smart Contracts?</strong></h3><ul><li>WASM has near-native performance, which is good for blockchain cases to run faster.</li><li>Wasm is high performance — it’s built to be as close to native machine code as possible while still being platform-independent.</li><li>It facilitates small binaries to ship over the internet to devices with potentially slow internet connections. This is an excellent fit for the space-constrained blockchain world.</li><li>Wasm expands the family of languages available to smart contract developers to include Rust, C/C++, C#, Typescript, Haxe, and Kotlin. This means you can write smart contracts in whichever language you’re familiar with, though we’re partial to Rust due to its lack of runtime overhead and inherent security properties.</li><li>The whole spectrum of functionality.</li></ul><p>Also, we need to understand the current state of WASM in Polkadot.</p><h3><strong>But what about the current status of WASM in Polkadot?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RU9OwpUIgMnJYzmN1ZGWug.jpeg" /></figure><p>We, as a venture studio, understand that WASM contract performance on Parachains is not ideal. The main problem is the size of the contracts.</p><p>We can look at this problem from the developers’ perspective and see why the WASM contract hasn’t become mainstream yet:</p><ol><li>Because WASM is a common language, and many other languages can be compiled into WASM. Because it is so extensive, only part of it is covered in the ink! documentation. No single source of documentation.</li><li>No dedicated development tools or environment compared to Solidity/EVM. Also, some tools and solutions are not available at WASM at all.</li><li>There is a lack of live public networks that provide the environment for WASM contracts to live on. The reason is that the contract has a huge size — no environment for running a contract.</li><li>Not enough projects are made with ink to make it the benchmark or starting point for future projects — Btw, we, as a venture studio, created — Funders(Product of AllienceBlock) is the first ink! commercial project.</li><li>There is no network-specific documentation or sample projects as all WASM contract docs are pointing to the Substrate contract pallet on a local Substrate dev node, which is unthinkable for anyone from other smart contracts.</li></ol><h3><strong>What could we do?</strong></h3><ul><li>Promote WASM as workshops etc.</li><li>work on improving existing instrumentation and documentation</li><li>create infrastructure projects</li><li>Create some simple projects as an example of performance and low-cost</li><li>build tools to make the starting point easier.</li><li>encourage developers to build their projects on wasm and share it</li><li>Create a lower entry threshold for newcomers</li></ul><p>As I mentioned, one of the points that we could make — is to build the tools for the smart contract development.</p><p>Let’s talk about the specific instruments in our ecosystem.</p><h3><strong>What do we have for now for smart contract development?</strong></h3><p><a href="https://github.com/patractlabs/europa"><strong>Europe(Patract)</strong> <br></a>Europa is a private test blockchain-based on Substrate to help Runtime Pallet and pallet-contracts development. It modifies the native Substrate chain by removing unnecessary components such as Wasm execution and adding great features to help developers get more insights into the contract execution details.</p><p>The advantage was that Europe helps quickly generated blocks and allows developers to see the call stack of the smart contract — it was useful for debugging.</p><p><a href="https://redspot.patract.io/en/"><strong>Redspot(Patract)</strong> <br></a>Redspot is named after Jupiter’s Great Red Spot, which is also the largest DOT in the solar system. Redspot’s target project is like <a href="https://github.com/trufflesuite/truffle">Truffle</a> in Truffle Suite. Redspot is a development environment, testing framework, and asset pipeline for pallet-contracts. Redspot is trying to let the development of ink! be projectized and simplify the testing and interaction with contracts. With Redspot help — pallet-contracts could be integrated into any substrate chain with some partial modification.</p><p>This project is used for contracts developers if developers want to deploy and test on a blockchain.</p><p>As Patract Labs is no longer active, so the problem is that their products(Europe, Redspot, Jupiter) don’t maintain at all.</p><p><a href="https://polkadot.js.org/"><strong>Polkadot</strong></a><strong> js (Parity)</strong></p><p>It is a Javascript library for interacting with the Substrate Blockchain. Without this tool, it is almost impossible to interact with the Substrate blockchain, and the same issue is with contracts.</p><p>The main problem is that not many developers are working on Polkadot.js. Furthermore, the need and demand for this tool are growing.</p><p><a href="https://github.com/paritytech/contracts-ui"><strong>Canvas UI (Parity)</strong> <br></a>Substrate Contracts UI is a React.js application for testing WASM smart contracts deployment and interaction on compatible Substrate blockchains. It was created by the Parity team too. Currently works only with smart contracts written in <a href="https://paritytech.github.io/ink-docs/">ink!</a> but should support similar smart contract languages in the near future.</p><p>In order to deploy a smart contract, you have to run a local <a href="https://github.com/paritytech/substrate-contracts-node">Substrate Contracts Node</a>.</p><p>Btw, Support for Canvas Testnet and other smart contract chains coming soon.</p><p><a href="https://github.com/paritytech/ink"><strong>ink!</strong></a></p><p><a href="https://github.com/paritytech/ink"><strong>ink!</strong></a><strong>-</strong> an extension of the Rust programming language, is what allows developers to write smart contracts for blockchains that utilize the Contracts pallet.</p><p>You can use any language to build a smart contract. In the final, it should be compiled into WASM and deployed to the network. The contract pallet is agnostic to language, so you only need to call its methods. It can be done in a raw way like in Solana, GEAR, where you call each method. ink! provides developer-friendly Rust-like language to simplify the development and hide the raw implementation under the hood. It provides useful abstraction and defines rules on how to develop a contract and how to interact with other contracts. It aims to save developers time by removing redundant code.</p><h3><strong>OpenBrush</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sUaXH9WE5aH4xer7.png" /></figure><p>Finally, let’s talk about <a href="https://openbrush.io/">OpenBrush</a>. More than 9 months ago, we created <a href="https://openbrush.io/">OpenBrush</a> with a mission to foster ink! and WASM development and adoption. The mission of this project is to make ink! usable and facilitate WASM ecosystem adoption. Here are some key statements related to <a href="https://openbrush.io/">OpenBrush</a>.</p><ol><li>OpenBrush is a library for secure smart contract development on ink!</li><li>We know that — OpenBrush should serve as a starting point for every developer entering a Polkadot(ink!) ecosystem.</li><li>In addition to having a standard implementation, Openbrush has macros to simplify and abstract up applications(smart contracts) development.</li></ol><p>This project is important to us as it’s our strategic Supecolony goal to accelerate Polkadot ecosystem development. Applications on Ink! are a considerable part of it. From our side, we’ve already made a huge contribution to WASM, ink!</p><p>We’re planning to continue to do that — together with the <a href="https://astar.network/">Astar Network</a> team. Astar is a multi-chain smart contract platform that supports multiple blockchains and virtual machines. They are WASM believers, and together, we will make it usable. On AmsterDOT, only Supercolony &amp; Astar were talking about the importance of WASM. We promise you that lots of new WASM-addicted people and projects will appear in the Dotsama ecosystem in the nearest time.</p><ul><li>Our team created the first accepted Polkadot Standard for fungible tokens targeting Substrate based blockchains. (PSP22 — analog of ERC20).</li><li>Also, we are integrating contracts with XCM in order to have all the benefits of Substrate in WASM!</li><li>OpenBrush provides tools and documentation to improve the development experience. For example, modifiers, like in Solidity, wrap around the traits to simplify cross-contact communication. Or Documentation with the description of how to better start development, how to better organize your project, and so on.</li><li>We have the final vision for the development of smart contracts and not all ideas can be done on the OpenBrush level, so it requires the changes on ink! level — and we do it step by step to success.</li></ul><p>We are working in all directions to simplify the development and adaptation of Solidity developers. The documentation will cover all popular topics with examples in the code and tests. Here is the thing — you could start the development of a smart contract really easily with OpenBrush using!</p><p>To sum it up,<strong> It is a lack of existing tools in the Polkadot ecosystem</strong>. We don’t have tools like Sol2Ink (simple compiler from Solidity to ink!) or Indexer( Event indexer for DApp to create a proper UI). Supercolony will lead the creation of the Infrastructure Alliance of tools — with good/useful tools for smart contracts development.</p><blockquote>You know — the Crypto world is very volatile, one day, you are a winner, next day, you are a loser because the situation on the market has drastically changed. Typically, this forces on project teams too by inclining to cover some holes with tactical solutions. The current blockchain engineering market is overfilled with the Solidity developers who use EVM. However, there was WASM introduced as a competitor in blockchain technologies.</blockquote><p>But beyond, it`s not enough to know some languages and use tools. You need to understand what is going on in the ecosystem, what is the hottest things and just be “in trend”. To keep moving the ecosystem forward and make the first step in Infrastructure Alliance building, Supercolony is pioneering <a href="https://wasm-conference.com/"><strong>The First Virtual WASM Conference</strong>.</a> The one-day virtual event, 31 May, free registration. Our goal is to create a future of WASM in WEB3.0 by making it the starting point for business in the Polkadot ecosystem. It will accelerate main WASM stakeholders and key players in the whole ecosystem to discuss hot questions about WASM and ink!, and determine the vector of ecosystem development. Conference attendees will help grow the ecosystem by resolving pertinent issues, accelerating innovation, and attracting more top talent to the Polkadot.</p><p>This conference aimed to accelerate main stakeholders and key players in the whole ecosystem to discuss hot questions like — <em>“Why WASM is the base layer of decentralized application development.”, “Why WebAssembly Matters in Polkadot”, “Future of the smart contracts»</em>, and more exciting things! We will cover everything that was covered today, but more and more deeply way. We aim to develop the Polkadot ecosystem further.</p><p>Moreover, we believe that the attendees could help grow the ecosystem by resolving relevant issues, accelerating innovation, and attracting more top talent to the Polkadot ecosystem. Also, I strive for each participant to understand why it is essential to develop the ecosystem in this direction. <strong>At the conference, you understand why you will be left “overboard” without going to WASM!</strong></p><p>That’s why it was vital for us to continue our work and make the WASM Conference as significant as possible. And we continued to do our work. Here is the line — WASM is not just about the future, decentralization, and web3.0 — it’s about a new, honest and fair world.</p><p>Supercolony and I personally <strong>want to push everything related to WASM and bring the future (especially WASM) to the Web3.0 world.</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVdOmeJduZ20%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVdOmeJduZ20&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVdOmeJduZ20%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a7d988be3521587b764d68ec48510c8/href">https://medium.com/media/8a7d988be3521587b764d68ec48510c8/href</a></iframe><h4>Personal Contact 🦦</h4><p><a href="https://twitter.com/Toma_Sadova"><strong>Toma Sadova</strong></a><strong><br></strong>Market Growth Lead, Supercolony<em><br>toma.sadova@supercolony.net</em></p><h4><strong>About Supercolony 🪐</strong></h4><p>Supercolony is a venture studio dedicated to converting business ideas into successful high-level companies, leading the development processes, improving and strengthening business models, and increasing market capitalization. Supercolony’s goal is ecosystem creation, taking leadership in moving the market forward, creating the vector of ecosystem development, and making the entrance points for businesses more accessible.</p><p>Our main mission is to make blockchain usable for everyone.</p><p><a href="https://www.linkedin.com/company/super-colony/mycompany/">LinkedIn</a> | <a href="https://supercolony.net/">Website</a> | <a href="https://twitter.com/supercolony_net">Twitter</a> |<a href="https://t.me/supercolony_polkadot">Telegram</a> | <a href="https://github.com/Supercolony-net">GitHub</a> | <a href="https://www.youtube.com/channel/UC5278rH2_UejuHEVvsArvkA/videos">YouTube</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60453341e934" width="1" height="1" alt=""><hr><p><a href="https://medium.com/supercolony/tools-for-smart-contracts-in-polkadot-60453341e934">Tools for Smart Contracts in Polkadot</a> was originally published in <a href="https://medium.com/supercolony">WASM conference</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>