<?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[51nodes - Medium]]></title>
        <description><![CDATA[51nodes based in Stuttgart is a provider of crypto economy solutions. 51nodes supports companies and other organizations in realizing their Blockchain projects. We offer technical consulting and implementation with a focus on smart contracts, DApps and tokenization of assets - Medium]]></description>
        <link>https://medium.com/51nodes?source=rss----89b961a921c---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>51nodes - Medium</title>
            <link>https://medium.com/51nodes?source=rss----89b961a921c---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 28 Aug 2026 07:15:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/51nodes" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Why Upgrading OpenZeppelin Smart Contracts from Version 4 to Version 5 is Unsafe]]></title>
            <link>https://medium.com/51nodes/why-upgrading-openzeppelin-smart-contracts-from-version-4-to-version-5-is-unsafe-e08be30efd8a?source=rss----89b961a921c---4</link>
            <guid isPermaLink="false">https://medium.com/p/e08be30efd8a</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[openzeppelin]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Majd]]></dc:creator>
            <pubDate>Fri, 22 Dec 2023 14:15:51 GMT</pubDate>
            <atom:updated>2023-12-23T19:20:06.338Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*5WjQaHVQt16XB5Lr_2TeeQ.png" /><figcaption><a href="https://forum.openzeppelin.com/t/contract-upgrade-failed-because-variables-are-deleted-in-openzepplin-5-0/38341">unsafe upgradability note</a></figcaption></figure><p>OpenZeppelin is a well-known and trusted company in the blockchain world. It provides secure open-source smart contracts and libraries, which accelerate the blockchain development worldwide. For more than two years, developers from all over the world have been using OpenZeppelin’s <em>v4</em> contracts to build applications. The <em>v4</em> contracts were maintained, well-documented, and audited over a long period. However, On the 5th of October, a new journey began with the release the <em>v5</em> of OpenZeppelin contracts. In this article, we will explain - with an example - why it is not safe to upgrade existing deployments from OpenZeppelin Contract <em>v4</em> to <em>v5</em>.</p><h4>TLDR</h4><p>The <em>v5</em> of the contracts includes significant changes and improvements. Some contracts and libraries have been restructured, while others have been removed. However, the most crucial reason for the incompatibility is that the <em>v5</em> contracts of OpenZeppelin integrate a significant change to the storage layer. The contracts in <em>v5</em> adopt <strong>the namespaced storage layout</strong>, which is defined in <a href="https://eips.ethereum.org/EIPS/eip-7201"><strong>ERC-7201</strong></a>. This change implies that the new logic of <em>v5</em> contracts will query existing data and write new data in <strong>incorrect</strong> storage slots, making an upgrade from <em>v4</em> to <em>v5</em> not safe. Developers have several options to update an existing contract, such as reinitializing the contract, deploying it as a new proxy, or choosing to continue with updated v4 contracts. Each option has its own unique challenges and requirements.</p><h4>Prerequisites</h4><p>We consider the knowledge of upgradeable smart contracts and rudimentary knowledge of the Ethereum Virtual Machine (EVM) storage as a requirement for understanding this article. The following tutorials give a good overview about upgradability of smart contracts:</p><ul><li><a href="https://www.youtube.com/watch?v=JgSj7IiE4jA">https://www.youtube.com/watch?v=JgSj7IiE4jA</a></li><li><a href="https://www.youtube.com/watch?v=kWUDTZhxKZI">https://www.youtube.com/watch?v=kWUDTZhxKZI</a></li><li><a href="https://www.youtube.com/watch?v=YJZV9uiDbJI">https://www.youtube.com/watch?v=YJZV9uiDbJI</a></li></ul><p>For the EVM storage layer we recommend the following articles:</p><ul><li><a href="https://steveng.medium.com/ethereum-virtual-machine-storage-layout-beb9a72a07e9">https://steveng.medium.com/ethereum-virtual-machine-storage-layout-beb9a72a07e9</a></li><li><a href="https://www.adrianhetman.com/unboxing-evm-storage/">https://www.adrianhetman.com/unboxing-evm-storage/</a></li><li><a href="https://medium.com/@Knownsec_Blockchain_Lab/knowsec-blockchain-lab-depth-understanding-of-evm-storage-mechanism-and-security-issues-50509acea373">https://medium.com/@Knownsec_Blockchain_Lab/knowsec-blockchain-lab-depth-understanding-of-evm-storage-mechanism-and-security-issues-50509acea373</a></li></ul><h4>Comparing how state variables are stored in OpenZeppelin upgradeable contracts in v4 versus v5</h4><p>The Ethereum Virtual Machine (EVM) stores state variables in a key-value store with 256-bit keys and 256-bit values. These state variables are stored in a compact, continuous manner. Therefore, <strong>the order</strong> of the state variables in a smart contract determines their position in the storage.</p><p>OpenZeppelin <em>v4</em> upgradeable contracts primarily use the default approach for storage management. The storage slots for state variables are determined by their sequential order in the contract. Therefore, base contracts often include a ‘storage buffer’ — defined as <strong><em>uint256[49] __gap; </em></strong>— to reserve storage slots. This will allow future versions of that contract to use up those slots without affecting the storage layout of child contracts. This approach of storage handling complicates contract management and upgradeability by increasing the risk of mistakes and storage conflicts, where new upgrades may unintentionally overwrite existing storage slots.</p><p>To simplify upgradability and minimize storage conflicts, OpenZeppelin <em>v5</em> adopted the <strong>namespace storage layout,</strong> which has been proposed officially as <strong>ERC-7201</strong> on June 20, 2023. The ERC-7201 recommends using pseudorandom locations derived from a namespace as the basis for new storage trees in base contracts. The root slot for storage is calculated using a <a href="https://eips.ethereum.org/EIPS/eip-7201#formula">specific formula</a>. This approach does not require changes on the EVM level and can be implemented by grouping state variables within a struct and using assembly language to access specific storage slots directly, as shown in the example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*ZoQ8W_gLnUAdFo2yBFizbw.png" /><figcaption>Example of namespace-based storage locations in a smart contract following <a href="https://eips.ethereum.org/EIPS/eip-7201">ERC-7201</a></figcaption></figure><p>In the example smart contract <strong><em>x</em></strong> and <strong><em>y</em></strong> are state variables. However, they are not stored on the first and second slots in the storage as default. They will be stored in the storage tree under the given root <em>MAIN_STORAGE_LOCATION</em> = <em>0x183a…b500, </em>which is calculated using the suggested formula in ERC-7201.</p><p>When a <em>v4</em> upgradeable contract is deployed on the network, the state variables of the contract are initialized, stored, and managed using the default storage pattern based on their order in the contracts. However, if the implementation contract is upgraded using <em>v5</em> contracts, a critical issue occurs. The new <em>v5</em> contracts are designed to interact with storage in a different way, using the namespaced storage layout introduced in ERC-7201. As a result, these updated contracts will not recognize or access the original storage slots used by the old contract. This mismatch in storage access will lead to dangerous and incorrect states where variables may not reflect the intended values, and functions may behave unpredictably, leading to loss of funds or compromised security.</p><h4>Unsafe Upgradability Example</h4><p>The following <strong><em>ExampleV4</em></strong> contract uses OpenZeppelin <em>v4</em> and imports the following contracts <strong><em>Initializable</em></strong>, <strong><em>OwnableUpgradeable</em></strong>, and <strong><em>UUPSUpgradeable</em></strong>. It sets the value of <em>exampleStateVariable</em>, the address of the owner, the address of implementation contract, and the status of the contract to Initialized during the initialization process when it is deployed as proxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*NEgIUdRNixj945TWaZH-vA.png" /><figcaption>example upgradable contract using v4 version</figcaption></figure><p>To check the storage keys of the state variables, we can deploy it as <a href="https://remix-ide.readthedocs.io/en/latest/run_proxy_contracts.html">proxy using Remix IDE</a> and then debug it using the <a href="https://remix-ide.readthedocs.io/en/latest/debugger.html">Debugger</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*maeTLLFwIIC7Osk7qFxpjQ.png" /><figcaption>the storage of the contract</figcaption></figure><p>As shown in the picture, slot <em>0x000…000</em> (slot 0) has the value <em>0x01 </em>marking the contract as initialized. At Slot <em>0x000….033</em> (Slot 51) the, address of the owner of the contract is stored. At <em>0x000…0c9 (</em>Slot 201) the value <strong>7</strong> of the <em>exampleStateVariable </em>is stored<em> </em>(<strong>Note</strong>: The variables are not sorted at slots 0, 1, 2 due to the buffer gaps between the contracts). At Slot <em>0x36089…82bbc</em> the address of the implementation contract stored (<strong>Note</strong>: The slot of the implementation contract address was already hardcoded in v4 in a similar way to the namespaced storage layout to prevent conflicts).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4ubieJKckFVLtVfmvePVg.png" /><figcaption>map current slots to values in v4</figcaption></figure><p>For demonstration purposes, we will update the implementation contract to <strong>ExampleV5</strong> using OpenZeppelin <em>v5</em> contracts, without introducing new logic. To execute the upgrade, we must import the new <em>v5</em> contracts, make minor modifications to the original contract to align with the new structure, and then deploy it. Then, we invoke the upgradeTo function on the proxy contract, providing the address of the new implementation contract as an argument.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*I1PW5hI4syYiX4c5CfnYMQ.png" /><figcaption>Code of the upgradeable smart contract in OpenZeppelin version 5</figcaption></figure><p>After upgrading the contract we can call the two state variables in the proxy contract to check their values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*5IxkINGc3L8WWWkA9XJvTA.png" /><figcaption>the values of the state variables after the upgrade</figcaption></figure><p>The value of <em>exampleStateVariable</em> is now <strong>1</strong> and not <strong>7</strong> because the upgraded contract reads the value from the first storage slot, which was the same slot of the initialized status. Furthermore, the owner is the zero address <em>0x000…000</em> because the new implemented contract following <em>v5</em> of OpenZeppelin looks for the address of the owner at another storage slot. Inspecting the <em>v5</em> contract, we will find that the owner value is read from slot <em>0x9016…9300,</em> which is empty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*GB6smNDzOj7aUVi5DT881w.png" /><figcaption>the <a href="https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/v5.0.1/contracts/access/OwnableUpgradeable.sol">OwnableUpgradeable</a> v5 contract</figcaption></figure><p>The same issue applies to the <strong><em>Initialization</em></strong> status of the contract. It is read from slot <em>0xf0c5…6a00</em> and not from <em>0x000…000</em> as it was in <em>v4</em> contracts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*JUVL1OAgmGzZrif4gBf2Bg.png" /><figcaption>the <a href="https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/v5.0.1/contracts/proxy/utils/Initializable.sol">Initializable</a> v5 contract</figcaption></figure><p>This means our very simple updated contract has incorrect values, is not initialized, and has the zero address as Owner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bc1wVdNiPRpEsYdGTZjhXA.png" /><figcaption>compare current slots to values before and after upgrade shows the misplacing of state variables between old and new v5 contract</figcaption></figure><p>At this point, anyone would be able to initialize it again giving the address of owner to control the contract. Even if the original owner still managed to initialize the contract before anyone else the contract will stay in an unsafe state. To explain this we will re-initialize and debug the storage of the upgraded contract using Remix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*_Vka33pQg0Q8EubBqlq7jg.png" /><figcaption>The storage keys and values after the upgrade and re-initialization of the contract</figcaption></figure><p>As displayed on the above storage snapshot, the original (v4) storage slots at <em>0x000…0c9</em>, <em>0x000…033</em> are not empty. Therefore, new state variables added to the contract could unintentionally use these slots, creating invalid values.</p><h4>Going Forward with Existing Contracts</h4><p>For developers, finding the best way to update existing contracts is crucial. There are several options for updating deployed <em>v4 </em>upgradable contracts, some of these options are:</p><ul><li><strong>Reinitializing the Contract</strong>: This process involves clearing the storage and migrating the data within the contract. While this approach might be feasible for simple contracts, for complex contracts with dynamic data types such as arrays, strings, and mappings, the storage becomes overly complicated, making migration within the contract impractical, if not impossible.</li><li><strong>Deploying as a Proxy</strong>: Similar to the <a href="https://sergiomartinrubio.com/articles/how-to-release-new-versions-of-smart-contracts/#social-migration">Social Migration</a> approach for non-upgradable contracts, this method involves deploying the new contract as a new proxy with a new address, followed by migrating the data and users to this new contract. Depending on the contract type and existing data, this process can become complicated. Additionally, it requires users’ involvement.</li><li><strong>Updating using v4 Contracts</strong>: Likely the most advisable approach is to continue using v4 contracts. This method eliminates the need for data migration or storage restructuring. Developers need to maintain their existing OpenZeppelin v4 contracts, extending or updating only the necessary components for their specific needs when required.</li></ul><h4>Summary</h4><p>In Ethereum, upgradeable contracts are complicated due to potential storage conflicts. The introduction of a new storage layout aims to make the upgrade process easier and cleaner. However, old upgradable <em>v4</em> contracts will face issues with the new layout, as their state variables could be dislocated, leading to an invalid contract state. Therefore, a native upgrade from <em>v4</em> contracts to <em>v5</em> is considered as not safe and is not recommended, requiring careful selection of strategies for updating <em>v4</em> Upgradeable Contracts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e08be30efd8a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/51nodes/why-upgrading-openzeppelin-smart-contracts-from-version-4-to-version-5-is-unsafe-e08be30efd8a">Why Upgrading OpenZeppelin Smart Contracts from Version 4 to Version 5 is Unsafe</a> was originally published in <a href="https://medium.com/51nodes">51nodes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Indexing and Querying Revoked Verifiable Credentials]]></title>
            <link>https://medium.com/51nodes/indexing-and-querying-revoked-verifiable-credentials-e229dc2781d4?source=rss----89b961a921c---4</link>
            <guid isPermaLink="false">https://medium.com/p/e229dc2781d4</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[self-sovereign-identity]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[verifiable-credentials]]></category>
            <category><![CDATA[the-graph]]></category>
            <dc:creator><![CDATA[Majd]]></dc:creator>
            <pubDate>Fri, 01 Jul 2022 08:36:03 GMT</pubDate>
            <atom:updated>2022-07-01T08:35:50.188Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cf_nHmZ_YMKWONZYpkYo5w.jpeg" /></figure><p>Due to its immutability and censorship resistance, the Blockchain seems to be a suitable place to manage identities and credentials. However, querying the data on the blockchain in a trusted and efficient way is one of the most challenging issues every Web3 developer has to face while developing a DApp. Therefore, this article describes a simple approach to revoke verifiable credentials and a decentralized and efficient way to index and query those revoked credentials using the <a href="https://thegraph.com/en/">Graph protocol</a>.</p><p>We consider the knowledge of Self-Sovereign Identity (SSI) and rudimentary knowledge of the <a href="https://github.com/decentralized-identity/ethr-did-resolver/blob/master/doc/did-method-spec.md">Ethr DID method</a> as a requirement for understanding this article.</p><h4>Ethr DID and Credentials</h4><p>The Ethr DID method uses Ethereum addresses as identifiers. By default, the DID of the issuer/subject does not require an on-chain registration and it is constructed from the Ethereum address and controlled by its private key. This feature minimizes the effort of integrating Identities in many on-chain use cases.</p><p>When an off-chain verifiable credential is created, the issuer entity must set the “<em>issuer</em>” property to its Ethr DID and the “<em>credentialSubject.id</em>” property to the Ethr DID of the subject. Example:</p><pre>&quot;verifiableCredential&quot;: {<br>    &quot;@context&quot;: [..],<br>    &quot;issuer&quot;: {<br>      &quot;id&quot;: &quot;<strong><em>did:ethr:0xf1232f840f3ad7d23fcdaa84d6c66dac24efb198</em></strong>&quot;<br>    },<br>    &quot;issuanceDate&quot;: &quot;2022-07-2T12:00:00.000Z&quot;,<br>    &quot;credentialSubject&quot;: {<br>      &quot;id&quot;: &quot;<strong>did:ethr:0x435df3eda57154cf8cf7926079881f2912f54db4</strong>&quot;,<br>      &quot;degree&quot;: &quot;Bachelor Of Arts&quot;<br>    },<br>    &quot;proof&quot;: { ... }<br>  }</pre><p>After that as usual the issued credential will be used by the subject to generate a verifiable presentation. The verifier will verify the presentation and accept or reject it depending on its business logic.</p><h4>Credential Revocation</h4><p>Verifiable Credentials are similar to certificates, some of them have an expiration date and some don’t. However, in both cases, the <em>issuer</em> and the <em>subject</em> must be able to revoke them. To enable this critical requirement, we need a tamper-proof revocation data registry that is always available and cannot be censored by any of the mentioned parties. This can be achieved using the Blockchain. Such a registry can be implemented as a simple smart contract that stores a reference of the credential and a reference of the entity who revoked it.</p><p>The revocation process:</p><ul><li>Get the hash value of the issued verifiable credential using the <em>keccak256</em> hash function after converting the credentials to bytes. This value will be used as the on-chain reference to the credential</li><li>Send a transaction to the revocation smart contract to call the revoke method revoke(bytes32 digest)giving the extracted hash value as input</li><li>The entity that revoked the credential is the address of the invoker and it can be matched with the issuer or subject of the credential based on their DIDs</li></ul><p>The additional important key that will help use indexing those revocations is that when a credential is revoked, the revocation smart contract triggers an event that includes the <em>keccak256 </em>hash of that credential and the address of the entity that revoked it.</p><p>In the Github <a href="https://github.com/51nodes/vc-revocation-graph">Repository</a>, we prepared a simple project that:</p><ul><li>Deploys a revocation smart contract that stores references to the credential and the entity that revoked it.</li><li>Uses the <em>did-jwt-vc</em> and <em>ethr-did</em> libraries to issue 3 off-chain verifiable credentials by 3 different issuers and revoke them on-chain</li></ul><p>Please check the<em> ./ssi-contracts </em>folder and follow the instructions in the <a href="https://github.com/51nodes/vc-revocation-graph/tree/main/ssi-contracts"><em>README</em></a> file. After following the steps you should have the address of the revocation registry smart contract deployed on the <em>Goerli </em>network<em>. </em>The 3 revoked transactions can be found on <a href="https://goerli.etherscan.io/">Etherscan</a> using the address of the deployed contract.</p><p><strong>Why do we need to index the revoked Credentials?</strong></p><p>In a verification scenario, the verifier gets a verifiable presentation that includes <em>1 to n </em>verifiable credentials from the subject. In addition to the normal validation process of the credentials, the verifier must also check the on-chain status of the credential at any time easily and efficiently. To do that the verifier could request the status of each credential by calling the methodrevoked(address issuer, bytes32 digest) in the revocation registry contract. However, this approach of getting the information is limited, costly, and not efficient for many reasons, some of which are:</p><ul><li>It requires knowledge of the Blockchain and Web3 technology</li><li>It is slow and limited because of the latency, number of requests, node capability</li><li>It requires running a blockchain node or relaying on a node provider</li><li>Duplicate requests for the same credentials are sent over and over again</li><li>It requires the verifier to be online all the time</li></ul><p>And this is when <strong>indexing</strong> comes into play to provide an easy, fast and simple way to iterate and query data. Indexing is especially needed in the Blockchain area where its underlying design makes it difficult to search for relevant data.</p><p><strong>But How can we index the Blockchain?</strong></p><p>One approach is iterating all transactions and checking if the transaction interacts with our revocation contract. This method is very slow and resource-intensive. The other approach which is used by most developers is to subscribe to events that are triggered by the target contract. This method is much easier, supported by tools and libraries like web3js, and is more resource-saving. Now we come to the second important question of <strong>who</strong> should do the indexing? There are some possible answers:</p><p>1. <strong>The verifier himself. </strong>But it is not a good solution because each verifier needs to build up and maintain its own logic and infrastructure. Furthermore, the server of the verifier that is responsible for the indexing is a Single-point-of-failure</p><p>2.<strong> External ingestion service </strong>that indexes the data on behalf of the verifier. Such a service could be very useful. However, it creates one of the most critical issues which is the lack of <strong><em>TRUST</em></strong>. Verifiers need to trust the ingestion service and relying on it eliminates the advantage of using the Blockchain</p><p>3. <strong>Decentralized indexing protocol</strong> like <strong>The Graph protocol</strong>, which enables decentralized applications to query complex data from the blockchain without having to develop and operate proprietary indexing servers or use a centralized service provider. This is the preferred solution in most use cases because:</p><ul><li>It is distributed and decentralized. Therefore it removes the Single-point-of-failure and the missing trust issue</li><li>It does not require advanced Web3 knowledge. Developers use only <strong><em>GraphQL</em></strong> requests to query the data from already implemented and indexed Subgraphs</li><li>The technology behind it has been designed specifically for the Blockchain. Therefore, it is quick and easy to query and filter</li><li>Cost-efficient because indexers are competing with each other to provide the best service for the lowest price</li><li>Can be used by many verifiers around the world with minimal latency because the nodes are distributed and public</li></ul><p>The creators of the Graph protocol recognized the indexing and querying problem at the end of 2017 and started working to solve it by defining and implementing a decentralized indexing protocol. The <a href="https://thegraph.com/docs/en/about/introduction/">introduction page</a> of the Graph protocol offers detailed information about the protocol and you can also join the free and very useful courses provided by <a href="https://thegraph.academy/courses/"><em>The Graph Academy</em></a><em>.</em></p><p><strong>Develop and Deploy a Revocation Subgraph</strong></p><p>A Subgraph defines which data should be indexed from a blockchain, and how it should be stored. In our simple example, the core data the verifier requires is the hash of the credential and who revoked it. To make things easier for verifiers we could also add the timestamp and block number.</p><p>To keep the article simple we will deploy the subgraph on a <a href="https://thegraph.com/docs/en/hosted-service/what-is-hosted-service/">hosted service</a>. Hosted service can be seen today as a good and easy place to start with the development of Subgraphs because it is free to use and reduces the deployment and testing complexity of Subgraphs. Developers can at any time migrate their Subgraphs to the decentralized network.</p><p>The following steps to develop and deploy the Subgraph are described in detail with all the related files in this <a href="https://github.com/51nodes/vc-revocation-graph/tree/main/credential-revocation-subgraph-files">repository</a> :</p><ul><li>First, initialize a new sample project using the <a href="https://github.com/graphprotocol/graph-cli"><em>graph cli</em></a></li><li>Then modify some of the configurations like adding a startBlock and checking the address of the contract</li><li>After that comes the main part of the development which is to define the entities and implement the <em>handle</em> method that will be executed when an event is emitted by a smart contract</li><li>In the end, build the project and deploy it on the <em>hosted service</em> using the <em>graph cli</em> and an access token</li></ul><p>When the Subgraph is deployed and synchronized we can query the indexed data using simple <strong><em>GraphQL </em></strong><em>requests.</em></p><p>Example: open https://api.thegraph.com/subgraphs/name/<strong>&lt;github-name&gt;</strong>/credential-revocation-graph in browser and run the following query to get the hashes of all credentials that are revoked by Issuer-A from ./ssi-contracts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7NSnQbUcFT_RW0c3sngmaw.png" /><figcaption>Query revoked credentials by an issuer</figcaption></figure><p>The results should contain only a single revoked credential unless you modified the scripts inside ./ssi-contract or used an already existing contract for this query. You can also compare the results with the logged data of the executed script in./ssi-contract</p><h4>Summary</h4><p>In this article, we described one of many approaches on how to revoke issued credentials. This outlined approach benefits from the Ethr DID characteristic and it depends on the Blockchain as an immutable registry accessible for all parties. We also talked about the likely best way to index and query revoked credentials without relying on centralized services. And at the end, we showed how to develop a simple Subgraph that could run on the Graph protocol decentralized indexing <a href="https://thegraph.com/explorer/">network</a> and index the required data.</p><p><a href="https://www.51nodes.io/">51nodes GmbH</a> is a provider of crypto-economy solutions based in Stuttgart, Germany.</p><p>51nodes supports companies and other organizations in realizing their Blockchain projects. 51nodes offers technical consulting and implementation with a focus on smart contracts, decentralized apps (DApps), integration of blockchain with industry applications, and tokenization of assets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e229dc2781d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/51nodes/indexing-and-querying-revoked-verifiable-credentials-e229dc2781d4">Indexing and Querying Revoked Verifiable Credentials</a> was originally published in <a href="https://medium.com/51nodes">51nodes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Blockchain Development: Pros and Cons of Tatum vs. Moralis]]></title>
            <link>https://medium.com/51nodes/getting-started-with-blockchain-development-pros-and-cons-of-tatum-vs-moralis-91dd5acea624?source=rss----89b961a921c---4</link>
            <guid isPermaLink="false">https://medium.com/p/91dd5acea624</guid>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[sdk]]></category>
            <dc:creator><![CDATA[Daniel Niemczyk]]></dc:creator>
            <pubDate>Fri, 25 Feb 2022 07:41:11 GMT</pubDate>
            <atom:updated>2022-02-25T07:41:09.556Z</atom:updated>
            <content:encoded><![CDATA[<p>Blockchain development and the development of decentralized apps (Dapps) has changed over the past 5 years. When I started with crypto in 2017, Ethereum had just launched, and Solidity programming became the new thing a lot of people wanted to learn. The only problem these days was that little information to get started was available, whereas today we can build on thousands of Youtube videos, courses like <a href="https://cryptozombies.io/">Cryptozombies </a>or <a href="https://openzeppelin.com/contracts/">Openzeppelin </a>standards.</p><p>Today, one doesn’t even have to know anything about Solidity programming or blockchains at all to create a product or service that is built on top of a blockchain. Nowadays there are services like Tatum and Moralis, providing almost everything you need to instantly start developing your product or service instead of managing all the “behind the scenes” things on your own.</p><p>This post explains how to get started with blockchain development using the platforms of Tatum and Moralis. I discuss pros and cons and what you can build with them today.</p><h3>Introduction</h3><p>The two main features of Moralis and Tatum are a <strong>Web API</strong> and an <strong>SDK</strong> for application development based on a public blockchain. With the Web API we can retrieve all the necessary data from a blockchain and with the SDK we can easily use code to interact with the blockchain to make a transaction or call a function of a smart contract. The blockchain data retrieved by the Web API can be accessed with the SDK as well. Without using such a service a developer must run his own full node to know the blockchains state in order to make a correct transaction based on the current state.</p><p>Moralis and Tatum work on multiple public blockchains like Ethereum, Binance Smart Chain, and Polygon. Thus, one can retrieve data from all these blockchains using a single Web API. While <a href="https://docs.moralis.io/moralis-server/web3-sdk/intro#supported-chains">Moralis</a> “only” covers 6 blockchains, the <a href="https://docs.tatum.io/supported-blockchains">Tatum API</a> covers around 40. Both APIs can be used to access the main network and a test network of a blockchain like for example Rinkeby or Ropsten for Ethereum.</p><p>Behind the scenes, services like Tatum and Moralis run a full node of every blockchain they support. Having access to all blockchains’ data, they are able to aggregate it so that one can access all users’ balances, token balances or NFTs in one place. The API can then be used within the respective SDK to help developers creating their product or service. The following picture shows the general architecture of Moralis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJDeNv9fB64B_tNv7d7bRg.png" /><figcaption><a href="https://moralis.io/">The architecture of Moralis</a></figcaption></figure><h3>Web API comparison of Moralis and Tatum</h3><p>Using a Web API to get all necessary blockchain data saves developers a lot of time and money. Retrieving blockchain data via Tatum and Moralis is free of charge. Both APIs are able to:</p><ul><li>Get all Transactions an address has made.</li><li>Get the current block of any chain.</li><li>Get the native balance or balance of any ERC-20 token.</li><li>Get all NFT information of a user or a contract.</li><li>Get and write data from and to <a href="https://ipfs.io/">IPFS</a>.</li></ul><p>Both, Moralis and Tatum cover all “basic” API requests. Differences are listed in the following.</p><h4><strong>Requests specific to Moralis’ API</strong></h4><ul><li>Get all Events emitted at a specific smart contract.</li><li>Get liquidity pair reserves for a Uniswap based exchange (DeFi).</li><li>Resolve an <a href="https://unstoppabledomains.com/learn">unstoppable domain</a> and return the address.</li></ul><p>Good thing to know: The Moralis Web API differentiate between all Ethereum Virtual Machine (EVM) blockchains like Ethereum, Binance Smart Chain, Avalanche and Polygon and the new created Solana Web API for Solana. For Solana, one can “only” retrieve users’ current balance, transactions, NFTs and tokens at the moment.</p><h4><strong>Requests specific to Tatum’s API</strong></h4><ul><li>Generate a wallet and get the private key, the mnemonics and the address.</li><li>Deploy a standard ERC-20, ERC-721 and ERC-1155 contract.</li><li>Interact with virtual accounts and the off chain ledger — I will cover this later in more detail.</li></ul><h4>How to use the APIs</h4><p>After you registered for Moralis you can see on the left side of the screen the Web3 API Button. Once clicked you can use the whole Web API within the browser (see figure below). The <em>x-api-key</em> and the whole <em>curl </em>request are shown when you execute a request. Using the API from outside the browser like for example with Postman or curl is also possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mxfiRxsoH-JZOMauAUvJew.png" /><figcaption><a href="https://admin.moralis.io/web3Api">The Moralis Web3 API webinterface</a></figcaption></figure><p>Using Tatum’s API works a bit different. After the registration you will be redirected to your dashboard. Here you can find your API keys — one for all main networks and one for all test networks.</p><p>To see the whole API you have to go back to the homepage to find the <a href="https://tatum.io/apidoc.php">documentation of the API</a>. Sadly, it is not possible to use the API within the browser. However, Tatum provides request code examples in 13 programming languages (see below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1X0UYGycnirNtVvZaAEaRQ.png" /><figcaption><a href="https://tatum.io/apidoc.php#tag/Blockchain-Polygon-(Matic)">Tatum API example to create a new wallet on Polygon</a></figcaption></figure><h4>Pricing</h4><p>Both APIs have a very good free version that can be used immediately after registration. The following figures show the number of requests possible with the APIs, depending on the plan you may choose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qi7T-vUJVWh7sSyeAYNgXg.jpeg" /><figcaption><a href="https://moralis.io/pricing/">Moralis Pricing for number of requests</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iiZkoFqoxe4uGSA6yFjieQ.png" /><figcaption><a href="https://tatum.io/pricing.html">Tatum Pricing for number of requests</a></figcaption></figure><h4>Web API conclusion</h4><p>Most importantly first: both API’s from Moralis and Tatum are working great and as expected and I can recommend both to you. Moralis has a little bit less supported blockchains and features than Tatum but looks more modern on the other hand. With both API’s you have access for all “basic” requests and if you really need something advanced you should look at both API’s and compare if one of these API’s is already dealing with your problem. If so just choose it and try it out.</p><h3><strong>How to use Moralis’ blockchain SDK</strong></h3><p><a href="https://moralis.io/">Moralis</a> describes itself as “the ultimate Web3 Development Platform” and is often said to be “the firebase of crypto”. Regarding help in blockchain software development, a JavaScript SDK is available. You can either use it as a plain npm module named “moralis” or you can use the “react-moralis” module to use the SDK within your React project. All the following paragraphs will focus on EVM blockchains but like already mentioned Moralis also support Solana.</p><h4>Moralis server</h4><p>Starting a new project with Moralis requires you to create a Moralis Server within your Dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6FtObUxoZlBdoNgiyeAemg.png" /><figcaption><a href="https://admin.moralis.io/servers">Add a new Moralis Server within your Dashboard</a></figcaption></figure><p>Creating a Moralis server requires only to select a name, your region, main network or test network and which blockchains should be included and listened to. In the free version of Moralis, you can run 3 of these servers at the same time but you must revoke them manually after 7 days.</p><p>After you created your Moralis server, you can open either its details or its dashboard. Opening the details will show you your <strong>Server URL</strong> and your <strong>Application ID</strong>. These two keys have to be imported in your SDK to use it correctly. In the dashboard you can see all your additional databases Moralis is creating for you.</p><p>In the following paragraphs I will show use cases of these additional databases and cover some of the more advanced features you can do with your Moralis server that is helpful for Dapp development.</p><h4><strong>Authenticating users</strong></h4><p>The Moralis SDK provides a simple way to track all users of a Dapp. Either users can register themselves with a username and password or do it the web3 way by using Metamask. The following code example shows how to connect your Dapp with your Moralis server and how to authenticate users the web3 way.</p><pre>const Moralis = require(&#39;moralis&#39;);</pre><pre>const serverUrl = &quot;YOUR_SERVER_URL&quot;;<br>const appId = &quot;YOUR_APP_ID&quot;;</pre><pre>Moralis.start({ serverUrl, appId });</pre><pre>Moralis.authenticate()</pre><p>The authenticate function will open the user’s Metamask window and request a signature from the user by clicking the “Sign” button. Note that there is no gas fee involved in signing because it is not a transaction.</p><p>Now, here’s the cool part. Once a new user logged in, you can observe a new row added to your “User” table in the Moralis dashboard with the address of the user. Furthermore, the Moralis server creates additional tables like for example “EthTransactions”, where you can see all transactions made of all users on the blockchain networks you selected when creating the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dDBgoaWK5FEHIESfe-QOGg.png" /><figcaption>Moralis Server Dashboard — Get all transaction made from all users</figcaption></figure><p>Because your tables can get fast quite big, your whole database is capable of managing queries and filters in order to only get and show the desired data.</p><h4>Listening to events</h4><p>One feature only Moralis provides, is listening to events of a specific contract. To this respect, open your server details and go to the “sync” tab. Now either choose to “follow” a specific address or a specific event. If you choose to follow an event, you only have to paste its name with parameter, its ABI as JSON and the contract address. After creation the data will synchronize automatically and the result can be found within a newly generated table in your server. A more detailed tutorial can be found <a href="https://moralis.io/sync-and-index-smart-contract-events-full-guide/">here</a>.</p><h4>Cloud-based queries</h4><p>Complex database queries can be run on the Moralis server in the cloud. For example, if you have a table with movie ratings with 1–5 stars and you would like to know the average film rating, you normally would first get all ratings and then calculate the average. To directly get the answer, just deploy and call the query as a JavaScript function within your Moralis server. For more information about the correct syntax check out Moralis’ documentation <a href="https://docs.moralis.io/moralis-server/cloud-code">here</a>.</p><h4>Getting data with Moralis’ SDK</h4><p>Let’s take a closer look at the actual JavaScript SDK and how to retrieve blockchain data. Moralis differentiates between their “normal” API for all EVM blockchains and their Solana API. The following paragraphs refer to the EVM blockchain API.</p><p>To get some data, there are 4 entry points:</p><ul><li>With <em>Moralis.Web3API.native.functionName(options) </em>we can access the Web API data within our SDK. Click <a href="https://docs.moralis.io/moralis-server/web3-sdk">here </a>for more information.</li><li>With the <em>useMoralisQuery(‘tablename’)</em> function we can get access to all the data within a specific table of our Moralis server. With the React SDK it should also be possible to enable live updates whenever your table you reference to updates. However, this didn’t work for me while testing.</li><li>With the <em>Moralis.executeFunction(‘options’)</em> function we can interact with a smart contract directly in order to get the state of a public variable or the result of a read only function. Click <a href="https://docs.moralis.io/moralis-server/web3/web3">here </a>for more information.</li><li>With the <em>Moralis.Cloud.run(‘function_name’)</em> function we can execute our cloud functions and get the result back.</li></ul><p>Using these methods, you can retrieve all blockchain data required for building your Dapp. Of course, all these possibilities can be combined within your Dapp. For example, many requests like getting the specific ERC-20 balance of an address can be resolved using any of these four possibilities.</p><h4>Creating transactions with Moralis’ SDK</h4><p>Knowing how to get blockchain data, let’s look at how to make a transaction with the Moralis SDK. The general approach of doing a transaction with the Moralis SDK is by conducting the actual transaction via Metamask. This way, the user and the developer don’t have to deal with any private keys, because Metamask handles them. Metamask provides the SDK with the information, which network the user is currently connected to, so we don’t have to deal with any blockchain network code. The SDK creates a correct transaction with the currently connected network on its own. Thus, the user only has to click on a button within the Dapp and Metamask to accept the transaction.</p><p>Making a transaction with the Moralis SDK is a one liner of code. Only the parameters of a transaction, e.g., the transaction amount, the receiver and the contract address have to be passed as JSON parameter to the <em>Moralis.transfer(options)</em> function. Note the different parameter settings in the code examples below to create a transaction for respectively sending a native coin, an ERC-20 token or an NFT. For more information click <a href="https://docs.moralis.io/moralis-server/sending-assets">here</a>.</p><pre>1) Transfer native coin options<br>const options = <br>{type: &quot;native&quot;, <br> amount: Moralis.Units.ETH(&quot;0.5&quot;), <br> receiver: &quot;0x..&quot;<br>}</pre><pre>2) Transfer ERC20 Token options<br>const options = <br> {type: &quot;erc20&quot;,<br> amount: Moralis.Units.Token(&quot;0.5&quot;, &quot;18&quot;),<br> receiver: &quot;0x..&quot;,<br> contractAddress: &quot;0x..&quot;<br>}</pre><pre>3) Transfer ERC721 Token options<br>const options = <br>{type: &quot;erc721&quot;,<br> receiver: &quot;0x..&quot;,<br> contractAddress: &quot;0x..&quot;,<br> tokenId: 1<br>}</pre><pre>// Call the Moralis.transfer function with options as parameter<br>const transaction = await Moralis.transfer(options);</pre><pre>// You can wait until its confirmation and do sth. with the result<br>const result = await transaction.wait();</pre><h4>Interacting with smart contracts</h4><p>For interacting with a function of a smart contract, you have to create an options variable as JSON string that includes the contract address, the function name, the <a href="https://www.quicknode.com/guides/solidity/what-is-an-abi">ABI </a>of the function, and the parameters. Now call the <em>Moralis.execute(options)</em> function with the options string as parameter. That’s everything it takes to create a transaction with the Moralis SDK as shown in the following <a href="https://docs.moralis.io/moralis-server/web3/web3">code example</a>.</p><pre>let options = {<br> contractAddress: &#39;0x...&#39;,<br> functionName: &#39;FUNCTION_NAME&#39;,<br> abi: [ FUNCTION_ABI_AS_JSON ],<br> params: {<br>     parameter1: value1,<br>    }<br>};</pre><pre>const tx = await Moralis.executeFunction(options);<br>const result = await tx.wait();</pre><h4>Moralis conclusion</h4><p>Moralis appears modern and helps building a Dapp. The Web API works great and using the SDK, it becomes a one liner to handle user authentication, getting data from any blockchain or creating valid transactions. Also, the documentation is very well written and detailed. They also have a very active <a href="https://www.youtube.com/c/MoralisWeb3">Youtube Channel</a>.</p><p>A limitation of Moralis is that it only deals with reading from and writing to a blockchain. Creating your own wallet or deploying a new smart contract are not possible. Therefore, scripting can get complicated because to send a transaction you have to deal with Metamask in the first place. But if you are only looking for a SDK that helps you build the JavaScript/backend part of your Dapp then choosing Moralis makes a good choice.</p><h3><strong>How to use Tatum’s blockchain SDK</strong></h3><p><a href="https://tatum.io">Tatum</a> describes itself as “The ultimate blockchain development platform” that offers a unified framework for 40+ blockchain protocols to reduce the complexity of blockchain development. While Moralis specialized in building Dapps, Tatum is a more general tool with a lot of methods needed to deal with a blockchain. Methods for creating and managing your own wallets and private keys, deploying smart contracts and interacting with them are included in the Tatum JavaScript SDK and their API.</p><p>Maybe because of the broad scope of Tatum, it feels a little bit unfinished. They feature a lot of services and endpoints instead of specializing on one specific. Thus, their Web API documentation is so big that it takes more than 2–3 seconds to load and render the whole page. Also, a lot of things are missing completely, and some other things are not properly explained yet in the documentation. However, Tatum told me that they are working on it already. So as well as in the Moralis section of this article, I will focus in the following paragraphs on EVM blockchains only, since the Tatum API is most developed for these kind of blockchains.</p><p>In the following paragraphs, I will show you the most important things you can put to use already today with Tatum.</p><h4><strong>Initializing Tatum’s SDK</strong></h4><p>Tatum’s SDK is as well written for JavaScript and can be downloaded as npm module with the name ‘@tatumio/tatum’. Once installed you can import it within your project and use one of the hundreds of functions Tatum provides. Calling any of these functions is a one liner. But compared to Moralis you don’t pass all the options as a single JSON string, but rather each parameter is passed individually.</p><h4>Generating a wallet</h4><p>By creating a wallet from scratch, we can script any transaction we want because we know the private key and can sign transactions on our own. To create a wallet with the Tatum SDK you need to import the <em>generateWallet </em>function and the <em>Currency </em>Enum. Once you call the function with the desired cryptocurrency, like for example Bitcoin or Ethereum, you will get your <em>24-mnemonic words</em> and your <em>xpub </em>for your newly generated <a href="https://www.investopedia.com/terms/h/hd-wallet-hierarchical-deterministic-wallet.asp">HD-wallet</a>.</p><p>With these two variables, Tatum can create new addresses with the corresponding private keys for your new wallet using the <em>generateAddressFromXPub </em>and <em>generatePrivateKeyFromMnemonic </em>functions, which you have to import as well. <a href="https://docs.tatum.io/your-first-app">The following code</a> demonstrates the whole process.</p><pre>1) const {generateWallet, generateAddressFromXPub, generatePrivateKeyFromMnemonic, Currency} = require(&quot;@tatumio/tatum&quot;);</pre><pre>2) const btcWallet = await generateWallet(Currency.BTC, false);</pre><pre>3) const btcAddress = generateAddressFromXPub(Currency.BTC, false,    &quot;YOUR_XPUB&quot;, &quot;HD_WALLET_INDEX&quot;);</pre><pre>4) const btcPrivateKey = await   generatePrivateKeyFromMnemonic(Currency.BTC, false, &quot;YOUR_MNEMONICS&quot;, &quot;HD_WALLET_INDEX&quot;)</pre><p>In the first line of code, we import the SDK and all required functions. In the second line, we generate a Bitcoin wallet and get the <em>mnemonic</em> and the <em>xpub</em>. In the third line, we create a new address from the <em>xpub</em> and in the fourth line, we create the private key for it. Because we are dealing with a HD-Wallet you must also pass the index of it as a parameter.</p><h4>Tatum’s Key Management System (KMS)</h4><p>To create a transaction, we need our newly created private key to be passed as a parameter to each function. Because it is never a good idea to send your private key across the internet, Tatum provides two approaches: (1) You can sign your transaction locally — this way you must have your private key stored locally on your computer, or (2) you can use the Tatum Key Management System (KMS). KMS is a cloud solution by Tatum, allowing to import your private keys encrypted with a password of your choice to let Tatum sign transactions for you within their service. This way, the private key doesn’t have to be sent across the internet because Tatum signs your transaction and only sends the signature of the transaction. For more information, click <a href="https://docs.tatum.io/tutorials/how-to-securely-store-private-keys">here</a>.</p><h4><strong>Accessing blockchain data</strong></h4><p>Currently, the Tatum SDK does not support yet to get all the blockchain data being available via the API. So to access blockchain data via Tatum, one should consult the <a href="https://tatum.io/apidoc.php">Web API docs</a> and make a HTTP request. This method can be used to build your own Dapp. I recommend to create a separate function for each request, in which you pass all necessary parameters and do the actual HTTP request within this function. This way, you create your own little framework for one-liner requests to get any necessary data from the blockchain.</p><h4>Interacting with a smart contract</h4><p>Interacting with a smart contract doesn’t work yet with the SDK at the time of writing. Instead, you must use the API as described <a href="https://tatum.io/apidoc.php#operation/EthBlockchainSmartContractInvocation">here</a>.</p><h4><strong>Transfering coins and tokens</strong></h4><p>At least the transfer functions for native coins, ERC-20 tokens, NFTs and ERC-1155 tokens exist already in Tatum’s SDK and are documented. The <a href="https://docs.tatum.io/guides/blockchain/how-to-send-ethereum-transaction">following code example</a> shows how to create an ERC-20 token transaction. For more information, check out the <a href="https://docs.tatum.io/guides/blockchain">documentation</a>.</p><pre>import {sendEthOrErc20Transaction, ethGetTransaction, Currency} from &#39;@tatumio/tatum&#39;;</pre><pre>const transaction = await sendEthOrErc20Transaction({<br>chain: Currency.&#39;CHAIN_TO_USE&#39;, <br>fromPrivateKey: &#39;YOUR_PRIVATE_KEY&#39;,<br>contractAddress: &#39;CONTRACT_ADDRESS&#39;,<br>digits: DIGITS_OF_TOKEN,<br>amount: &quot;AMOUNT_TO_SEND--0.1 for example&quot;,<br>to: &quot;TO_ADDRESS&quot;<br>});</pre><pre>const transaction = await ethGetTransaction(transaction.txId);</pre><h4>Deploying a standard smart contract</h4><p>Tatum’s SDK allows deploying standard smart contracts for EVM-compatible blockchains. Thus, one can deploy a smart contract with custom parameters for token standards listed below. Detailed information on parameters to use regarding using one of the token standards are linked to the list:</p><ul><li><a href="https://docs.tatum.io/guides/blockchain/how-to-create-an-erc-20-token">ERC-20</a></li><li><a href="https://docs.tatum.io/guides/blockchain/how-to-create-nft-token">ERC-721 (NFT)</a></li><li><a href="https://docs.tatum.io/guides/blockchain/how-to-create-erc-1155-multi-tokens">ERC-1155</a></li></ul><h4>Virtual accounts</h4><p>Virtual accounts are more or less the equivalent of a Moralis server. It’s a separate private ledger maintained by Tatum to enable, e.g., setting up webhook notifications when at a specific address a new transaction is observed. While for Moralis you must paste your address to synchronize and the webhook URL endpoint in your server’s dashboard, in Tatum you must set it up using the SDK or API. Moralis’ dashboard has great usability but Moralis provides no API for specifying webhooks. Tatum on the other hand has no dashboard but provides an API and SDK for the setup.</p><p>Unfortunately, Tatum’s SDK did not work properly during my experiments and I had to use the API again to test the webhooks. The steps for setting up a virtual account in Tatum and to subscribe to blockchain events are:</p><ul><li>Create a new wallet and save your ‘xpub’</li><li>Create a new virtual account with the ‘xpub’ as one of the parameters. Only a private key corresponding to this ‘xpub’ is allowed to do a transaction within this virtual account.</li><li>Connect the address to sync with your virtual account</li><li>Initialize a subscription that listens to incoming events and send the data to the endpoint of your choice.</li></ul><h4>Tatum conclusion</h4><p>Tatum’s SDK is a not a complete product at the moment, given its claims. Tatum aims at offering much more features than Moralis for interacting with a blockchain, especially when starting from scratch. Tatum is also more flexible by supporting more blockchains and already provides more usable features that can be helpful for scripting: Generating a wallet, managing keys, or deploying a new smart contract works great. The documentation is quite okay, but I would like to see Tatum to improve on that in the future. For functions not present in the SDK yet, you can use Tatum’s API instead, which works fine. To conclude, Tatum already provides a decent service and given the assumption that they will improve their documentation and SDK, I can recommend using Tatum’s SDK and API for developing a Dapp.</p><h3>Other blockchain SDKs and APIs worth considering</h3><p>Besides Moralis and Tatum, several other services exist that provide a Web API and a SDK for Dapp development. But none of them are as advanced as Moralis and Tatum and can be used only for some parts of your Dapp probably.</p><ul><li><a href="https://idexo.com/">Idexo</a>: It is another service, offering an SDK for blockchain development that feels like the very small brother of Tatum. Idexo provides only an SDK and is very limited regarding the number of blockchains and features. When trying to evaluate it, I had problems with registration and login. What Idexo is most known for is their Telegram bot that allow users to mint an NFT within Telegram.</li><li><a href="https://thegraph.com/en/">The Graph</a>: This is a Web API, focussing on complex and automated queries on Ethereum and IPFS.</li><li><a href="https://nownodes.io/nodes">NOWNodes</a>: They offer a Web API that is comparable to Tatum. The service supports also 40+ blockchains and a lot of endpoints are supported for each blockchain.</li><li><a href="https://infura.io/">Infura</a>: Infura provides some tools and endpoints to interact with the Ethereum blockchain and IPFS.</li><li><a href="https://v1.cosmos.network/">Cosmos</a>: If you even want to build a custom blockchain, then the Cosmos SDK might be worthwhile. Creating an own blockchain gets almost as simple as deploying a new token with it.</li></ul><h3>Conclusion</h3><p>It’s astonishing to experience how easy blockchain development has become due to tools and services like Moralis and Tatum. I recommend to use Moralis for developing a Dapp and to use Tatum for close interaction with different blockchains. I expect more to come as these services are evolving quickly. On top of that many other services exist to keep an eye on.</p><p>51nodes GmbH based in Stuttgart is a provider of crypto economy solutions. 51nodes supports companies and other organizations in realizing their Blockchain projects. 51nodes offers technical consulting and implementation with a focus on smart contracts, decentralized apps (Dapps), integration of blockchain with industry applications, and tokenization of assets.</p><p>Thanks to <a href="https://medium.com/@draklein">Achim Klein</a> and <a href="https://medium.com/@jpbu">Jan-Paul Buchwald</a> for their help in the course of developing this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91dd5acea624" width="1" height="1" alt=""><hr><p><a href="https://medium.com/51nodes/getting-started-with-blockchain-development-pros-and-cons-of-tatum-vs-moralis-91dd5acea624">Getting Started with Blockchain Development: Pros and Cons of Tatum vs. Moralis</a> was originally published in <a href="https://medium.com/51nodes">51nodes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Das Potenzial von Selbstsouveränen Identitäten am Beispiel der Energiewirtschaft]]></title>
            <link>https://medium.com/51nodes/das-potenzial-von-selbstsouver%C3%A4nen-identit%C3%A4ten-am-beispiel-der-energiewirtschaft-22224d30de53?source=rss----89b961a921c---4</link>
            <guid isPermaLink="false">https://medium.com/p/22224d30de53</guid>
            <category><![CDATA[ssi-use-cases]]></category>
            <category><![CDATA[ssi]]></category>
            <category><![CDATA[energy]]></category>
            <category><![CDATA[decentralization]]></category>
            <dc:creator><![CDATA[Dr. Achim Klein]]></dc:creator>
            <pubDate>Mon, 22 Nov 2021 11:44:53 GMT</pubDate>
            <atom:updated>2021-11-22T11:47:21.525Z</atom:updated>
            <content:encoded><![CDATA[<p>Bisherige Lösungen für das Managen von Identitäten sind gekennzeichnet von Datensilos, die einerseits jeder Diensteanbieter mit hohem Aufwand selbst betreibt — oder andererseits von globalen Identitätsanbietern, die den Diensteanbietern diesen Aufwand abnehmen können. Das Problem des isolierten Identitätsmanagements ist, dass der durchschnittliche Internetnutzer über 20 verschiedene Identitäten hat, die separat angelegt und gewartet werden müssen — mit entsprechendem Aufwand und daraus resultierend Inkonsistenzen zwischen den Datensilos. Globale Identitätsmanager wie Google helfen, diese Probleme mit Hilfe des Single-Sign-On unter Nutzung einer Google-ID zu überwinden. Für den Nutzer ist dies bequem und einfach. Jedoch wird die Hoheit über persönliche Daten und deren kommerzielle Verwertung aus der Hand gegeben.</p><p>Vor diesem Hintergrund streben Selbstsouveräne Identitäten (SSI) die Verknüpfung der Nutzerfreundlichkeit einer Google-ID mit einem hohen Grad an Nutzerkontrolle und Privatsphäre an.</p><h4><strong>Was genau ist SSI?</strong></h4><p>SSI bilden die neueste Entwicklungsstufe digitaler Identitäten. Eine <em>Identität </em>meint alle Attribute einer Person, Organisation, oder Gegenstands, die dieses Subjekt definieren. <em>Attribute </em>beschreiben die Charakteristika eines Subjekts. Eine <em>digitale Identität</em> meint hier die digitale Repräsentation dieser Attribute. Je nach Verwendungskontext können verschiedene <em>Teilidentitäten </em>benötigt werden, die nur einen Teil der Attribute umfassen.</p><p>Ein <em>Credential </em>ist ein fälschungssicherer und überprüfbarer Nachweis von Attributen eines Subjekts. Credentials werden in einem persönlichen digitalen Wallet gehalten. Das Subjekt ist der <em>Holder </em>der Nachweise, nachdem es diese von einem Issuer beschafft hat. Ein <em>Issuer </em>stellt Credentials nach einem Schema aus, das eine übergreifende Verwendung und allgemeingültige Interpretation erlaubt. Ein <em>Verifier </em>fordert, z.B. für den Zugriff auf einen Dienst, einen Nachweis einer Berechtigung (ein Credential) von dem zugreifenden Subjekt. Über ein <em>Verifiable Data Registry</em> werden dazu <em>Identifikatoren </em>ausgetauscht, die auf Subjekte, deren Credentials und deren Issuer verweisen können. Das Verifiable Data Registry enthält keine subjektbezogenen Daten.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*CIvFM4GiXkwo6momcebtww.png" /><figcaption>Rollen und Informationsflüsse beim Identitätsmanagement mit SSI (Quelle: <a href="https://www.w3.org/TR/vc-data-model/#roles)">https://www.w3.org/TR/vc-data-model/#roles)</a></figcaption></figure><h4><strong>Welchen Mehrwert bringt SSI?</strong></h4><p>SSI überwindet das inkonsistente und — für Nutzer als auch Diensteanbieter — aufwändige Identitätsmanagement in isolierten Datensilos und gleichzeitig die Abhängigkeit von bisherigen Single-Sign-On-Identitätsmanagern wie Google und Twitter, die die Anmeldevorgänge der Nutzer kontrollieren, auswerten und verwerten. Mit SSI haben Subjekte wie Personen oder Maschinen eine einzige Identitätsverwaltung (zumindest für einen gewissen Namensraum). Die einer Identität zugeordneten Berechtigungsnachweise müssen nur einmal eingeholt werden und können dann nach Bedarf passgenau für beliebig viele Anmelde- und Nachweisprozesse eingesetzt werden. Analog zur Plastikkärtchen-Identität können die Nachweise geprüft werden, ohne den Herausgeber zu involvieren.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bY_mRUBfQqEVxx8G_zULyw.png" /><figcaption>Heutiges Identitätsmanagement in Silos vs. Selbstsouveränes Identitätsmanagement (Adaptiert von: <a href="https://digitaleweltmagazin.de/2019/08/12/chancen-der-self-sovereign-identities-ssi-aus-sicht-von-unternehmen-fuer-das-identity-access-management-iam/">https://digitaleweltmagazin.de/2019/08/12/chancen-der-self-sovereign-identities-ssi-aus-sicht-von-unternehmen-fuer-das-identity-access-management-iam/</a>)</figcaption></figure><p>Für Diensteanbieter vereinfachen sich Onboardingprozesse, das sogenannte Know-your-Customer und die Compliance zu den damit verbundenen Regularien. Zudem sind die bereitgestellten Identitätsinformationen aktuell. Durch die Vereinfachung der Onboardingprozesse werden diese auch mit einer höheren Wahrscheinlichkeit als bislang von den Nutzern abgeschlossen.</p><p>Nutzer von Diensten (beliebige Subjekte, auch Maschinen) können ihre Identität in Plug-and-Play-Manier einsetzen und ihre Identität einfach zwischen verschiedenen Diensten portieren. Das Verwalten und Aktuellhalten von dutzenden Nutzerkonten und das Merken der zugehörigen Passwörter entfällt, da nur noch ein Zugang zum persönlichen Wallet erforderlich ist. Konsequenterweise reduzieren sich auch IT-Sicherheitsprobleme, die durch die Verwendung des gleichen Passworts für verschiedene Nutzerkonten entstehen.</p><h4>Welche Herausforderungen gibt es?</h4><p>Einschränkend kann vermerkt werden, dass die Vorzüge und Nutzbarkeit einer selbstsouveränen Identität sich zunächst auf diejenigen Dienstanbieter beziehen, die auf einer Verifiable Data Registry präsent sind — ähnlich den mobilen Anwendungen auf den App Stores. In Analogie dazu ist ein SSI-Netzwerk umso wertvoller für seine Nutzer, je mehr Dienste darüber nutzbar sind. Schließlich ist hier ein Wachstums- und Konsolidierungsprozess zu erwarten, der über die Durchsetzung von bestimmten Angeboten entscheidet.</p><p>Ein kritischer Gedanke ist, dass mit dem Verifiable Data Registry eine ähnliche Abhängigkeit der Identitäts-Subjekte wie bislang zu den Single-Sign-On-Anbietern aus den Sozialen Medien entstünde. Dieser Gedanke führt jedoch in die Irre, denn das Verifiable Data Registry kann mit Hilfe von Distributed Ledger-Technologie in einem Blockchain-basierten Netzwerk betrieben werden. Mehrere dezentrale Rechenknoten, die von unterschiedlichen Akteuren betrieben werden können, würden das Netzwerk bilden. Oftmals sind hier auch Non-Profit-Organisationen wie <a href="https://sovrin.org/">Sovrin </a>oder die <a href="https://energyweb.org/reports/the-energy-web-chain/">Energy Web Foundation</a> aktiv. Ein deutlicher Kontrast zu den bisherigen Single-Sign-On-Anbietern.</p><p>Ein ausschlaggebender Faktor für den Erfolg von SSI wird sein, dass die Issuer von Credentials das erforderliche Vertrauen herstellen können. Weiterhin wird, wie so oft, die Nutzererfahrung und die daraus resultierende Akzeptanz entscheidend sein. Lösungsanbieter wie Spherity nutzen eine Cloud, um ein <a href="https://medium.com/spherity/multi-party-computation-b4d2a7c3042">nutzerfreundliches Identitätswallet</a> bieten zu können, das auch Private Keys verwahrt und vor dem ungewollten Verlust der Identität schützt.</p><h4><strong>Wer treibt SSI voran?</strong></h4><p>Die Bundesregierung und die Europäische Union sind unter anderem Treiber von SSI. Sie fördern das Entwickeln der Konzepte, Technologie, Standards und Regulierungen bis hin zu Pilotierungen in verschiedensten Branchen und Bereichen.</p><p>Das Bundesministerium für Wirtschaft und Energie fördert z.B. das <a href="https://digitale-identitaeten.de/">„Schaufenster sichere digitale Identitäten“</a>. Eines der Schaufensterprojekte ist IDunion. <a href="https://idunion.org/">IDunion </a>arbeitet an der Schaffung eines offenen Ökosystems für dezentrale, selbstsouveräne Identitäten. Dazu wird mit Blockchain-Technologie ein verteiltes Identitätsnetzwerk aufgebaut. Das Projekt wird von 47 namhaften Forschungs- und Industriepartnern vorangetrieben. 51nodes ist Partner von IDunion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pR1OISxpI1Wx9liL52bUPA.png" /><figcaption>Schaufensterprojekte Digitale Identitäten (Quelle: <a href="https://digitale-identitaeten.de/schaufensterprojekte/">https://digitale-identitaeten.de/schaufensterprojekte/</a>)</figcaption></figure><p>Die Europäische Union finanziert z.B. das <a href="https://essif-lab.eu/">„European Self-Sovereign Identity Framework Lab“</a>. 20 Teilprojekte kümmern sich um die Schaffung und Erweiterung eines Open Source-Softwareframeworks für SSI. Weitere 42 Teilprojekte entwickeln kommerzielle Komponenten and Dienste unter Nutzung des SSI-Frameworks.</p><h4>Anwendungsbeispiel: Wie kann SSI der Energiewirtschaft helfen?</h4><p>Vor dem Hintergrund der Energiewende stehen die Betreiber von Übertragungs- und Verteilnetzen für elektrischen Strom vor großen Herausforderungen und neuen gesetzlichen Pflichten. Über eine Million (privater) dezentraler Stromerzeuger müssen effizient und effektiv in bestehende energiewirtschaftliche Prozesse (z.B. der <a href="https://www.next-kraftwerke.de/wissen/regelenergie">Regelleistung</a> und des <a href="https://www.transnetbw.de/de/strommarkt/systemdienstleistungen/redispatch-2-0">Engpassmanagements im Redispatch 2.0</a>) integriert werden.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*_PHuJJDjX7FOPcBF8WVgvQ.png" /><figcaption>Leistungen und Prozesse der Energiewirtschaft (Quelle: <a href="https://www.next-kraftwerke.de/wissen/systemdienstleistungen">https://www.next-kraftwerke.de/wissen/systemdienstleistungen</a>)</figcaption></figure><p>Aktuell sind energiewirtschaftliche Prozesse gekennzeichnet durch produktspezifische und teilweise aufwendige Registrierungsprozesse an verschiedenen Stellen. Beispielsweise kann man hier das <a href="https://www.marktstammdatenregister.de/MaStR">Marktstammdatenregister </a>der Bundesnetzagentur, die <a href="https://www.regelleistung.net/">Regelleistungsplattform</a> der Übertragungsnetzbetreiber und die Plattform <a href="https://netz-connectplus.de/home/projekt/">connect+</a> zur Kooperation und zum Datenaustausch der Netzbetreiber nennen. Hinzu kommt eine geringe Motivation der Betreiber von kleinen Energieerzeugungsanlagen und der Sicherung der Aktualität der Daten an den unterschiedlichen Registrierungsorten.</p><p>Die Frage von erforderlichen Nachweisen betrifft z.B. die Art der Stromerzeugung (z.B. EEG-Anlage) bzw. für welches energiewirtschaftliche Produkt die Anlage eingesetzt werden darf und kann. Die Identifikatoren (Energy Identification Code) für Anlagen werden zentral durch den <a href="https://www.energiecodes-services.de/bdew-codes.html">BDEW </a>vergeben. Weiterhin gibt es Vorgaben zur Marktkommunikation durch den Regulator, die mit Hilfe einer Zertifikatinfrastruktur für Signierung und Verschlüsselung erfolgt. D.h. die Zertifikate müssen bei allen genannten Stellen eingepflegt und aktuell gehalten werden. In einem “Internet of Energy”, wenn Millionen von Endkunden mit ihren dezentralen Flexibilitätsanlagen (z.B. Elektromobilität, Heimspeicher, Wärmepumpen, etc.) auf den Energiemarkt drängen, kommen diese Systeme zur Abwicklung der Massenprozesse für Registrierungs- und Veränderungsanforderungen in der notwendigen Geschwindigkeit an ihre Grenzen.</p><p>Der Ansatz von SSI verspricht demgegenüber die Vision der Integration von Millionen von dezentralen Anlagen in die Prozesse und IT-Systeme der Netzwirtschaft in unaufwändiger Plug-and-Play-Manier, ohne dass Mehrfachanmeldungen und parallele Konsistenzhaltung in redundanten isolierten Identitätsmanagementsystemen weiter erforderlich wären. Damit sollten Hürden für Anlagenbetreiber sinken und die Prozesse der Netzwirtschaft können schlanker und reibungsärmer aufgestellt werden. Schließlich würde ein wichtiger Beitrag für das Gelingen der Energiewende geleistet.</p><p>Aktuell arbeitet 51nodes gemeinsam mit dem Übertragungsnetzbetreiber <a href="https://www.transnetbw.de/de">TransnetBW</a> an der Erörterung von SSI im Kontext der Energiewirtschaft. Bislang konnten schon mehr als zehn potenzielle Anwendungsfälle für SSI identifiziert werden.</p><h4><strong>Interesse an SSI?</strong></h4><p><a href="https://www.51nodes.io/">51nodes</a> ist ein Anbieter von Lösungen für die Crypto Economy. 51nodes unterstützt Unternehmen und andere Organisationen bei der Umsetzung ihrer SSI- und Blockchain-Projekte. Sie haben Fragestellungen zu digitalen Identitäten und Anknüpfungspunkte zur Nutzung von SSI? Kommen Sie gerne auf uns zu!</p><h4>Weiterführende Informationen zu SSI</h4><p>(1) <a href="https://tykn.tech/self-sovereign-identity/">Self-Sovereign Identity: The Ultimate Beginners Guide</a> (Webseite) <br>(2) <a href="https://www.fim-rc.de/wp-content/uploads/2021/06/Fraunhofer-FIT_SSI_Whitepaper.pdf">Self-Sovereign Identity: Grundlagen, Anwendungen und Potenziale portabler digitaler Identitäten</a> (Whitepaper des Fraunhofer FIT) <br>(3) <a href="https://digitaleweltmagazin.de/2019/08/12/chancen-der-self-sovereign-identities-ssi-aus-sicht-von-unternehmen-fuer-das-identity-access-management-iam/">Chancen der Self-Sovereign Identities aus Sicht von Unternehmen für das Identity &amp; Access Management</a> (Webseite) <br>(4) Ein <a href="https://www.hindawi.com/journals/scn/2021/8873429/">Überblick über das SSI-Ökosystem</a> (wissenschaftlicher Artikel) <br>(5) Eine technische Umsetzungsplattform für SSI in der Energiewirtschaft: <a href="https://energy-web-foundation.gitbook.io/energy-web/foundational-concepts/self-sovereign-identity">Energy Web Decentralized Operating System</a> (Technische Konzeptdokumentation)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22224d30de53" width="1" height="1" alt=""><hr><p><a href="https://medium.com/51nodes/das-potenzial-von-selbstsouver%C3%A4nen-identit%C3%A4ten-am-beispiel-der-energiewirtschaft-22224d30de53">Das Potenzial von Selbstsouveränen Identitäten am Beispiel der Energiewirtschaft</a> was originally published in <a href="https://medium.com/51nodes">51nodes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring IOTA 2.0 Smart Contracts in a Private Network: Developing a Prediction Market]]></title>
            <link>https://medium.com/51nodes/exploring-iota-2-0-smart-contracts-in-a-private-network-developing-a-prediction-market-c2d81988f75e?source=rss----89b961a921c---4</link>
            <guid isPermaLink="false">https://medium.com/p/c2d81988f75e</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[iota]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[prediction-markets]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Dr. Achim Klein]]></dc:creator>
            <pubDate>Thu, 16 Sep 2021 20:53:58 GMT</pubDate>
            <atom:updated>2021-09-16T20:53:58.736Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Abstract </em>— Smart contracts are being introduced to IOTA, which has proposed an interesting take on distributed ledgers by proposing the Tangle. The Tangle promises to provide a more scalable transaction infrastructure with lower fees, potentially overcoming limitations of Ethereum and other blochain-based ledgers. Due to the current alpha state of IOTA smart contracts, the official documentation lags and it is a bit of challenge to get a working setup. To help interested developers and the IOTA community to more quickly try out smart contracts, this article describes how to set up a private IOTA network with the latest state of the software and demonstrates a workable prediction market smart contract developed in Rust.</p><h3>Introduction</h3><p>Smart contracts are codified contracts using rules and algorithms that can automatically trigger and incur electronic transactions of cryptocurrencies like Ether. The expected economic impact of smart contracts is very large as they allow for improving the efficiency of many existing business models and they also allow for completely new business models. For instance payouts of insurance contracts can be automated using smart contracts or autonomous cars could also pay tolls and parking fees automatically.</p><p>While smart contracts are already well known amendments from blockchain approaches like Ethereum, these approaches suffer from shortcomings like low throughput, and high transaction costs. For these reasons, the IOTA foundation had set out to first propose a new and more scalable transaction system based on the so called “Tangle”. Secondly, IOTA version 2.0 is currently under development, and it includes an approach to smart contracts. Smart contracts under IOTA 2.0 are promised to be built on an infrastructure that both scales well, and incurs low transaction costs.</p><p>Before the background of a promising new approach for smart contracts, I started to explore how to set up a private IOTA network for development and how to develop and deploy a smart contract on it. As the IOTA developer documentation is lagging it was quite a challenge to get a working solution. Thus, the <strong>main contributions</strong> of this article are, (1) a proper description how to set up the network and how to enable smart contracts, and (2) a fully working demonstration smart contract, which implements a simple prediction market in which multiple network participants can predict and bet on a certain outcome of an event.</p><p>The <strong>outline</strong> of this article is, I give (1) an overview of IOTA and the network’s smart contract integration, (2) a description of how to set up an environment for developing and testing IOTA smart contracts, (3) an implementation of a simple prediction market as a smart contract, (4) some notes and insights on IOTA and smart contracts, and (5) a conclusion.</p><h3>The IOTA Network and Smart Contracts</h3><p>IOTA is about a new kind of public and permissionless distributed ledger for exchanging value and data. The IOTA network has been designed to overcome the main bottlenecks of Blockchain-based distributed ledgers. Due to the organization of transactions (of value) in a chain, there is just one end to append new ones, which makes it slow. Thus, in contrast to the Blockchain-based approaches the distributed ledger of IOTA is organized in a different way. The Blockchain, which is central to Bitcoin or Ethereum for instance, is replaced by the Tangle. The Tangle connects transactions via edges in a directed (and acyclical) graph (see next figure). In contrast to the Blockchain, there are multiple nodes (representing transactions) on which new edges to new nodes, i.e., transactions, can be appended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*wkujYx46q_Wb4V-Rj7iMRA.png" /><figcaption>The Tangle data structure of IOTA’s distributed ledger. Green: validated transactions, White: not yet validated, Grey: new transactions. <a href="https://iota-einsteiger-guide.de/was-ist-iota.html">Source</a> (2021–09–10)</figcaption></figure><p>Beside the data structure, there are further key differences to classic Blockchain-based approaches. The consent mechanism requires no miners because all users help in validating transactions. Therefore, transactions can be essentially conducted with zero fees. The current IOTA network still requires a central coordinator, defining trusted transaction milestones, which other transactions need to reference to be also trusted. To achieve true decentralization, the planned update to IOTA 2.0 should overcome this limitation.</p><p>The key properties and key promises of <a href="https://www.iota.org/get-started/what-is-iota">IOTA</a> are of being</p><ul><li>highly scalable by a new data structure allowing for parallel transactions</li><li>requiring few resources and being suitable for devices and sensors</li><li>having zero-fee transactions</li><li>running fast transactions</li><li>finally approving messages within seconds</li><li>providing a distributed network, which is robust against attacks</li></ul><p>These properties would enable a layer of trust and a very scalable and efficient messaging system for the <a href="https://www.iota.org/get-started/what-is-iota">“machine economy”</a> with a very large amount of devices connected to the Internet. The current version of IOTA on the Mainnet is <a href="https://en.wikipedia.org/wiki/IOTA_(technology)">1.5</a>, which went live in April 2021. Version 1.5 is seen as an intermediate step in maturing the IOTA technology and proving its usability and practical value. This would form the basis for smart contracts that use the messaging capabilities of the IOTA network. Smart contracts are supposed to be introduced in version 2.0 the latest and might <a href="https://twitter.com/iota/status/1428704497992413185">be even backported to 1.5</a>. At the time of writing, smart contracts are subject to development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*1qGJric4onj1wqWmj07Neg.png" /><figcaption>IOTA network layers. <a href="https://github.com/iotaledger/goshimmer/blob/develop/documentation/static/img/protocol_specification/layers.png">Source</a> (2021–09–10)</figcaption></figure><p>The design for IOTA 2.0 foresees different layers (see figure above) that separate the general underlying messaging, transacting, and validating infrastructure from the application layer, which comprises also smart contracts, which would then use layer 1 capabilities to realize their features. A main reason for separating smart contracts into another layer is to not compromise the messaging functionality. Smart contracts run on Wasp nodes on layer 2 in connection with Goshimmer on layer 1, responsible for conducting transactions and messaging (see next figure).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*hD7FpXTIZw0VPvmaYSiVxg.png" /><figcaption>GoShimmer for messaging and Wasp nodes for smart contracts in an IOTA 2.0 network. <a href="https://github.com/iotaledger/wasp/blob/master/documentation/ISCP%20architecture%20description%20v3.pdf">Source</a> (2021–09–10)</figcaption></figure><p>Due to the separation of Wasp and Goshimmer, they need a technical capability to connect and interact with each other. Therefore, Goshimmer nodes contain a “txstream” plugin, which needs to be activated for connecting Wasp nodes. Smart contracts are developed in the Rust programming language. <a href="https://www.rust-lang.org/">Rust</a> is known to generate very performant and memory efficient executables while preventing the developer from many classes of errors by a helpful compiler and a well-designed language. To test smart contracts and run unit tests against smart contract functionality, the <a href="https://pkg.go.dev/github.com/iotaledger/wasp/packages/solo">“solo” environment</a> written in Go can be used.</p><h3>Setup</h3><p>The described setup defines a private IOTA 2.0 network you can run on your laptop. The network hosts a layer 1 Goshimmer node for messaging and a layer 2 Wasp node for running smart contracts. On this basis, the next chapter shows how to develop and deploy a smart contract to this network.</p><h4>Environment</h4><p>I used Ubuntu 20.04 LTS with latest updates and upgrades and</p><ul><li>installed <strong>git</strong></li><li>installed <a href="https://www.rust-lang.org/"><strong>rust</strong></a> 1.53.0 for developing native IOTA smart contracts by<br>curl --proto &#39;=https&#39; --tlsv1.2 -sSf https://sh.rustup.rs | sh</li><li>installed <strong>wasm-pack</strong> 0.10.0 for compiling smart contracts into “WebAssembly” binaries by<br>curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh</li></ul><p>Installed dependencies for <a href="https://github.com/facebook/rocksdb/blob/master/INSTALL.md">rocksdb</a> required by Goshimmer as its underlying database engine:</p><ul><li>sudo apt-get install libgflags-dev</li><li>sudo apt-get install libsnappy-dev</li><li>sudo apt-get install zlib1g-dev</li><li>sudo apt-get install libbz2-dev</li><li>sudo apt-get install liblz4-dev</li><li>sudo apt-get install libzstd-dev</li></ul><p>Cloned and built Goshimmer <strong>0.7.5</strong> from the <strong>develop</strong> branch (in the version of 2021–08–16) according the following description:</p><ul><li>git clone -b develop <a href="https://github.com/iotaledger/goshimmer.git">https://github.com/iotaledger/goshimmer.git</a></li><li>git checkout tags/v0.7.5</li><li>cd goshimmer</li><li>go build -tags rocksdb</li></ul><p>Prepared Goshimmer for transaction handling<br>Save the <a href="https://github.com/51nodes/prediction-market-smart-contract/blob/main/goshimmer/config.json"><em>config.json</em> file</a> to your Goshimmer directory to</p><ul><li>enable the <strong>txstream</strong> plugin, which allows Goshimmer to communicate with Wasp nodes</li><li>disable the <strong>portcheck</strong> plugin</li></ul><p>To check whether Goshimmer synchronizes its time and whether messaging works, open up the dashboard on your local machine by <a href="http://127.0.0.1:8081/dashboard">http://127.0.0.1:8081/dashboard</a>. It needs to display</p><ul><li>TangleTime Synced: Yes</li><li>Message: DBVBaNbSEsq8D1SuNd7ULLeSPTXLwQBwfW1agWKnFX23 (as an example) — that is, the message must <em>not</em> read 1111111111111111111111111 .. (containing only ones)</li></ul><p>Before running Goshimmer, delete the message database of previous (erroneous) attempts ( <em>if any</em>) by rm -rf mainnetdb in the mainnetdb subdirectory of Goshimmer. The database will be automatically generated again with a fresh start of Goshimmer.</p><p>Also in case tangle time does not synchronize (see the dashboard on your local machine by <a href="http://127.0.0.1:8081/dashboard">http://127.0.0.1:8081/dashboard</a> or the Goshimmer log: “can’t issue payload: tangle not synced”), shutdown Goshimmer, delete the message database, and restart Goshimmer.</p><p>Run Goshimmer in its directory as follows — after having created the ./assets/snapshotTest.bin file as described subsequently:</p><p>./goshimmer --autopeering.seed=base58:8q491c3YWjbPwLmF2WD95YmCgh61j2kenCKHfGfByoWi --node.enablePlugins=bootstrap,prometheus,spammer,&quot;webapi tools endpoint&quot;,activity,snapshot,txstream --messageLayer.startSynced=true --autopeering.entryNodes= --node.disablePlugins=clock --messageLayer.snapshot.file=./assets/snapshotTest.bin --messageLayer.snapshot.genesisNode= --metrics.manaResearch=false --mana.enableResearchVectors=false --mana.snapshotResetTime=true --statement.writeStatement=true --statement.writeManaThreshold=1.0 --config=./config.json</p><h4>Create a cli wallet</h4><p>The cli wallet can send IOTA funds to a Wasp wallet, where it is used to deploy smart contracts. We generate an initial transaction with funds for our cli wallet.</p><p>Install the cli-wallet in a new directory</p><ul><li>wget https://github.com/iotaledger/goshimmer/releases/tag/v0.7.5 download cli-wallet-0.7.5_Linux_x86_64.tar.gz</li><li>tar -xf cli-wallet-0.7.5_Linux_x86_64.tar.gz</li></ul><p>Set reuse_addresses=true in the config.json of cli-wallet:</p><p>To create a new wallet run ./cli-wallet init , returning</p><blockquote><em>IOTA 2.0 DevNet CLI-Wallet 0.2 GENERATING NEW WALLET … [DONE] ================================================================ !!! PLEASE CREATE A BACKUP OF YOUR SEED !!! !!! !!! !!! E7owJWtDBGSUAZUWQkn1kHG5zUy2PLQf6eEr3RoMCJs7 !!! !!! !!! !!! PLEASE CREATE A BACKUP OF YOUR SEED !!! ================================================================ CREATING WALLET STATE FILE (wallet.dat) … [DONE]</em></blockquote><p>Note <em>your</em> SEED for allocating funds to this wallet.</p><p>We generate a custom genesis snapshot, with the transaction that allocates the funds.</p><p>Go to the Goshimmer installation directory and then to the following subdirectory ./tools/genesis-snapshot</p><p>Paste the seed of the previously generated cli wallet to the following command</p><p>go run main.go --token-amount 3500000 --seed E7owJWtDBGSUAZUWQkn1kHG5zUy2PLQf6eEr3RoMCJs7 --snapshot-file snapshotTest.bin</p><p>Now,</p><ul><li>go to your Goshimmer directory and inside of it run</li><li>mkdir assets</li><li>cp ./tools/genesis-snapshot/snapshotTest.bin ./assets/snapshotTest.bin to provide the generated snapshotTest.bin file to Goshimmer.</li></ul><h4>Setting up a Wasp node for smart contracts</h4><p>I installed Wasp from the <strong>master</strong> branch in the state of 2021–08–03.</p><ul><li>git clone <a href="https://github.com/iotaledger/wasp.git">https://github.com/iotaledger/wasp.git</a></li><li>check out a workable state of the code from the repository. I used this <a href="https://github.com/iotaledger/wasp/commit/05516ca29edd9e93b17ed9a0f788ddb51c407d48">commit</a>.</li><li>go build -tags rocksdb</li><li>go build -tags rocksdb ./tools/wasp-cli</li></ul><p>We need to transfer funds to the Wasp wallet by creating the wallet in the first place by ./wasp-cli init</p><p>We need to get the address of the wallet by ./wasp-cli balance , returning something like</p><blockquote>Address index 0 Address: 1Ah4cqMPdrDGx6Htapk7NZUxxcYHsP1C3oAugEYHVmACj</blockquote><p>To send funds to this wallet, paste <em>your</em> address into this command and run it in the cli-wallet’s directory:</p><p>./cli-wallet send-funds -amount 40000 -dest-addr 1Ah4cqMPdrDGx6Htapk7NZUxxcYHsP1C3oAugEYHVmACj</p><p>Now, ./wasp-cli balance returns a balance of 40,000 IOTA.</p><p>Finally, configure wasp-cli to be able to connect to the local Goshimmer node and to form a committee of one local Wasp node by saving the <a href="https://github.com/51nodes/prediction-market-smart-contract/blob/main/wasp/wasp-cli.json"><em>wasp-cli.json</em> file</a> to the directory of your wasp-cli.</p><h4>Deploying a chain</h4><p>Smart contracts are deployed on a chain, which needs to be deployed first:</p><p>./wasp-cli chain deploy --committee=0 --quorum=1 --chain=predmarketchain --description=&quot;Prediction Market&quot;</p><p>where</p><ul><li><em>committee=0</em> specifies to use one Wasp node only, which handles smart contracts.</li><li><em>quorum=1</em> says one Wasp node is enough here — for development and testing</li></ul><p>Now we have to provide funds to the chain by</p><p>./wasp-cli chain deposit IOTA:1000 --chain=predmarketchain ,</p><p>reducing the wasp wallet’s balance by 1,000 IOTA.</p><h3>A Prediction Market Smart Contract</h3><p>The private IOTA network is now used to develop and deploy a smart contract. I report the design and implementation of a simple prediction market in Rust, how to build and deploy it, and finally how to use it.</p><h4>Design</h4><p>A classic example of realizing a smart contract is given by a prediction market. A prediction market is a virtual electronic market allowing to predict outcomes of future events by placing a monetary bet on a certain outcome. Such events could be sports events, political events, future prices of stocks, or other events with uncertain future outcomes. For instance, the outcome of a political election could be subject to predictions on a prediction market. A simple binary question to be answered by prediction market participants could be “Will candidate/team A win?” — with possible outcomes being “yes” or “no”.</p><p>Our design of a prediction market for demonstration purposes is simple. We omit a book maker and a pricing mechanism. Formally, we do not pose a question with predefined possible outcomes. Instead, market participants can bet basically on any outcome of an event with an arbitrary amount of tokens until the time for predictions is over. Afterwards, the winning outcome is determined and winning bets placed on the correct outcome receive back their share on the overall amount of tokens placed in bets. Assume, in total 700 tokens were bet on “no” and 300 tokens in total were bet on “yes”, and “yes” is the actual outcome. A single bet on “yes” with 100 tokens receives (100/300)*(700+300) = 333 tokens, making a win of 233 tokens.</p><p>Realizing this design as a smart contract in the IOTA network allows to deploy one contract per question to be answered. The account deploying the contract is in control and has to specify the time until when bets can be placed on outcomes. The actual question to be answered has to be communicated in third party channels. Any network participant can then look up the contract and call a function to place a bet on an outcome by sending some IOTA from their wallet. Finally, after the time for predictions and bets has passed, the deploying account has to call a function to close the prediction market and to provide the actual outcome of the event and correct answer to the question. This triggers the evaluation of all bets with regard to the correct answer. Accounts with the correct answer receive the winning amount of IOTAs in a transaction.</p><p>Note that in a real world and more production-like scenario, one might consider using an <a href="https://blog.iota.org/introducing-iota-oracles/">oracle</a> to provide the outcome of an event. Oracles can stream off-chain data (about events) into the Tangle, so smart contracts can use this data in their evaluations.</p><h4>Implementation</h4><p>Smart contracts for the IOTA network can be implemented in <a href="https://www.rust-lang.org/">Rust</a> and then compiled to a <a href="https://www.rust-lang.org/what/wasm">WebAssembly</a> file.</p><p>Our demonstration smart contract implemented in Rust can be viewed and cloned from this <a href="https://github.com/51nodes/prediction-market-smart-contract">repository</a>. The smart contract first exposes three functions for (1) initializing a prediction market, (2) placing a bet on an outcome, and (3) closing the prediction market for determining winners. When the contract is loaded, the mentioned functions’ implementations are made publicly available under the first string’s name, e.g., “initmarket”.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5344e81dcddb48c33507805f2c69a911/href">https://medium.com/media/5344e81dcddb48c33507805f2c69a911/href</a></iframe><p>The first function should be called by the account deploying the contract for <strong>initialization. </strong>Optionally, the function can set an end time for betting using the parameter BETENDUTC, which is a date-and-time string in ISO format, assuming time in UTC. In case the parameter is omitted, bets can be placed at any time until the closemarket function is called (see below).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d46be7c079448590d97dec4737f438fb/href">https://medium.com/media/d46be7c079448590d97dec4737f438fb/href</a></iframe><p>The second function allows to <strong>place a bet</strong> on a certain outcome value of an event, provided as parameter BETVALUE, e.g. “yes”. The amount to bet is the amount of IOTA sent with the function call. Bets must be placed in time before the <em>betenddatetime</em> has passed, which was set on initialization of the market. To save incoming bets for future evaluation to determine winners, I use two structs, defined in the beginning. That is, I define a hash map, mapping a betting account’s id to a <em>Bet</em> struct, which defines the amount of tokens and the outcome value of the bet. These custom structs are used instead of the built-in map offered by the context object of the function because only a proper hash map allows iterating over all keys and elements stored. As custom objects are not accommodated by the state stored in the context of the function, we need to jsonify it to produce a string, which can then be stored in the state.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/af893e01ef9fe5dace30c0eeca30aa3a/href">https://medium.com/media/af893e01ef9fe5dace30c0eeca30aa3a/href</a></iframe><p>The third function closes the prediction market and is to be called by the contract owner. Calls by other accounts will fail. The function can only be run after the specified end time has passed for predictions, and the function to close the market can be called successfully only once. The function requires a BETVALUE parameter, specifying the winning outcome, e.g., “yes”. The function runs through the stored bets, determines winning bets and the amount of IOTA coins they receive, and sends the IOTA to the wallets of the winners.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77f8fb7fbb1ddf71c8932d0b0c861cef/href">https://medium.com/media/77f8fb7fbb1ddf71c8932d0b0c861cef/href</a></iframe><h4>Build</h4><p>To build the smart contract, one can pull the accompanying <a href="https://github.com/51nodes/prediction-market-smart-contract">repository</a> on github with the following structure:</p><pre>* Cargo.toml <br>* src/lib.rs <br>* pkg/ <br>* target/</pre><p>The full Rust code of the smart contract is contained in a file called <em>lib.rs</em>. The structure and the naming of files follows standard conventions for Rust. To define dependencies of the smart contract code, the <a href="https://github.com/51nodes/prediction-market-smart-contract/blob/main/Cargo.toml"><em>Cargo.toml</em> file</a> reads as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/396e59bd1247b54f3142f12d97149c63/href">https://medium.com/media/396e59bd1247b54f3142f12d97149c63/href</a></iframe><p>The most important dependency is <em>wasmlib</em>, which is the IOTA’s smart contract library, allowing to produce smart contracts as compiled WebAssembly files. Furthermore, <em>serde</em> is used for serializing custom state objects to json strings for storage in the smart contract’s state. <em>chrono</em> brings some date and time related functionality required to control the end of a prediction market.</p><p>To build the smart contract, run wasm-pack build in the directory where <em>Cargo.toml</em> resides. The other directories like <em>pkg</em> and <em>target</em> are created automatically in the build process. The compiled WebAssembly file is located in the <em>pkg</em> directory and named <em>predictionmarket_bg.wasm</em>.</p><h4>Preparation</h4><p>We proceed by deploying our simple smart contract compiled as a WebAssembly <em>wasm</em> file.</p><p>Note: please adapt the path to the wasm file if required.</p><p>./wasp-cli chain deploy-contract wasmtime predictionmarket &quot;Prediction Market SC&quot; ./prediction-market-smart-contract/pkg/predictionmarket_bg.wasm --chain=predmarketchain --upload-quorum=1 -d --address-index=0</p><p>outputing:</p><pre>uploaded blob to chain -- hash: 6wVabTkRUUGrQzEj8s4yuPC8dfaHGLsoHLXsqvveSw4hPosted on-ledger transaction BChQcWEmMptqRM1z4C9ZffTQXPebg1MMiEYENuAnV7KV containing 1 request:<br>- Request 4RkBSF6BAHgfamyJnXFy4r1YoVU9wvZ9b6uvXUjt2VWAfF5<br>Waiting for tx requests to be processed...<br>Posted off-ledger request 2JdtBzxjP4Bc6Tj2SnZPSctoYDHxuCAvPWJwn6ufMShJ6Lw</pre><p>Now, functions can be called on the contract. First, the same wasp-cli that deployed the contract needs to call the <em>initmarket</em> function. There are two possibilities:</p><p>a) do not specify a specific an end date for the prediction market to simplify testing and development by this call ./wasp-cli chain post-request predictionmarket initmarket --chain=predmarketchain</p><p>b) specify a specific end date and time for the prediction market. The iso format is used and UTC is assumed. In this way, all bets must be placed before this time and the market can be only closed after this time. Run ./wasp-cli chain post-request predictionmarket initmarket string BETENDUTC string &quot;2021-09-08 23:00&quot; --chain=predmarketchain</p><p>Before placing a bet, we check the wallet’s balance with ./wasp-cli balance</p><p>returning</p><pre>Address index 0<br>Address: 1BAgmaSN1RYk5rbbxMK21CZo8t2zQ3EFeMwDPnMhQdQbs<br>Balance:<br>IOTA: 28653<br>------<br>Total: 28653</pre><p>For the deployed prediction market, we assume two possible outcomes “yes” and “no” on which bets can be submitted. To place a bet with 10 IOTA on “no”, we run</p><p>./wasp-cli chain post-request predictionmarket bet string BETVALUE string no --chain=predmarketchain -t IOTA:10</p><p>and afterwards, by ./wasp-cli balance we see the wallet&#39;s balance reduced by 10 IOTA.</p><pre>Address index 0<br>Address: 1BAgmaSN1RYk5rbbxMK21CZo8t2zQ3EFeMwDPnMhQdQbs<br>Balance:<br>IOTA: 28643<br>------<br>Total: 28643</pre><p>We now introduce and prepare the setup for four more participants to the prediction market. Each participant requires another wasp wallet. Thus, we create four new subdirectories <em>waspwallet2</em>, <em>waspwallet3</em>, <em>waspwallet4</em>, <em>waspwallet5</em> and copy <em>wasp-cli</em> and <em>wasp-cli.json</em> to those directories by repeating with regard to these directories</p><p>The last command initializes a new wallet.</p><p><strong>In case the contract’s code is changed, it needs to be re-deployed</strong> using the first and main wasp-cli. You also need to re-deploy the chain on which the contract is deployed first. Due to the redeployment of the contract, the copied versions <em>of wasp-cli.json</em> (in <em>waspwallet2</em> to <em>waspwallet5</em> directories) miss the new address of the deployed <em>predmarketchain</em> chain. In this case, we need to get it back in there to be able to run bets on the same prediction market from another account. Either you noted the address of the chain when it was created, such as</p><pre>activating chain nZBwoJi5q7KGk8D2cgm16PWrdM6aL2qTdCY27HHjZgrK.. OK.</pre><p>or you perform a cat wasp-cli.json in the directory of your first wasp wallet, giving you some information like this (among other information):</p><pre>{<br>  &quot;chains&quot;: {<br>    &quot;predmarketchain&quot;: &quot;nZBwoJi5q7KGk8D2cgm16PWrdM6aL2qTdCY27HHjZgrK&quot;,<br>  },</pre><p>Now you need to provide this address of the <em>predmarketchain</em> to the new wasp wallets’ configuration files. To do this, you can run the following command for the new wallets in the respective directories (e.g. in <em>waspwallet2</em> through <em>waspwallet5</em> in our example).</p><p>./wasp-cli set chains.predmarketchain nZBwoJi5q7KGk8D2cgm16PWrdM6aL2qTdCY27HHjZgrK</p><p>Please adapt the chain’s actual address <em>nZBwoJi5q7KGk8D2cgm16PWrdM6aL2qTdCY27HHjZgrK</em> to yours.</p><p>Finally, all four new wasp wallets need to be funded. First, find out their address by running (for each new waspwallet subdirectory)</p><p>waspwallet2/wasp-cli address</p><p>Then, provide the funds using cli-wallet (in the directory where it resides on your computer) by running</p><p>./cli-wallet send-funds -amount 40000 -dest-addr 1Ah4cqMPdrDGx6Htapk7NZUxxcYHsP1C3oAugEYHVmACj</p><p>and replacing the address <em>1Ah4cqMPdrDGx6Htapk7NZUxxcYHsP1C3oAugEYHVmACj</em> with the actual address found by running ./wasp-cli balance before in the respective subdirectories (of <em>waspwallet2</em> to <em>waspwallet5</em>).</p><h4>Simulation of a Prediction Market</h4><p>Now we are ready to place bets in the deployed contract’s prediction market on behalf of these four new participants. So, in the respective subdirectories we run say</p><ul><li>cd waspwallet2</li><li>./wasp-cli chain post-request predictionmarket bet string BETVALUE string yes --chain=predmarketchain -t IOTA:100</li><li>cd ../waspwallet3</li><li>./wasp-cli chain post-request predictionmarket bet string BETVALUE string no --chain=predmarketchain -t IOTA:50</li><li>cd ../waspwallet4</li><li>./wasp-cli chain post-request predictionmarket bet string BETVALUE string yes --chain=predmarketchain -t IOTA:200</li><li>cd ../waspwallet5</li><li>./wasp-cli chain post-request predictionmarket bet string BETVALUE string yes --chain=predmarketchain -t IOTA:500</li></ul><p>Finally the contract owner (with the first wallet) can close the prediction market by running in the directory of the first wallet</p><p>./wasp-cli chain post-request predictionmarket closemarket string BETVALUE string no --chain=predmarketchain</p><p>In this example, the actual outcome is specified to be “no”. When running this command from a different wasp wallet’s directory, we obtain a log output on the Wasp node</p><pre>You are not authorised to close the prediction market - only contract creator is allowed to close the market.</pre><p>When successfully closing the prediction market, the Wasp node’s log outputs</p><pre>CLOSEMARKET is executed:<br>the winning value is: &quot;no&quot;<br>total amount of bets placed on &quot;no&quot; is 60 IOTA<br>total amount of bets placed on &quot;yes&quot; is 800 IOTA<br>total amount of bets over all values: 860 IOTA<br>1FbCCHv9if3xbnRg3wJ7SY1kBFSdhNFR6Ax6haw6PhYDL placed a bet on &quot;no&quot;, which is a WIN<br>bet amount: 10 IOTA; won amount: 143 IOTA; of total amount placed a bet on 860; where total amount per winning value: 60<br>transferring won amount of IOTA to: 1FbCCHv9if3xbnRg3wJ7SY1kBFSdhNFR6Ax6haw6PhYDL<br>1FZtVTCi2GDuQ1oMGZqpT38akLpcMiMv6a8MVKNJYYdsr placed a bet on &quot;yes&quot;, which is not a win<br>1F81pGLKLhPb5ANFSGWQ7UPMSnPdahNZaZkgrcyaFXvpu placed a bet on &quot;no&quot;, which is a WIN<br>bet amount: 50 IOTA; won amount: 716 IOTA; of total amount placed a bet on 860; where total amount per winning value: 60<br>transferring won amount of IOTA to: 1F81pGLKLhPb5ANFSGWQ7UPMSnPdahNZaZkgrcyaFXvpu<br>17jdFbAhWwF79fBEia6A8AYMTmMYncipaFhDTjsqUbMfp placed a bet on &quot;yes&quot;, which is not a win<br>1BAgmaSN1RYk5rbbxMK21CZo8t2zQ3EFeMwDPnMhQdQbs placed a bet on &quot;yes&quot;, which is not a win<br>consensus/action.go:338 postTransaction: POSTED TRANSACTION: 4Aw6PzQGkk6MFzPVAXZkz8RGiPocYxuxhA9o7qgeDN7h, number of inputs: 2, outputs: 3<br>EVENT: state was synced to block index #11, approving output: [0]4Aw6PzQGkk6MFzPVAXZkz8RGiPocYxuxhA9o7qgeDN7h<br>STATE TRANSITION TO #11. requests: 1, chain output: [0]4Aw6PzQGkk6MFzPVAXZkz8RGiPocYxuxhA9o7qgeDN7h</pre><p>Revisiting the bets, we had placed the following ones:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b27b63cd0d3c74c7d815b7070566647/href">https://medium.com/media/0b27b63cd0d3c74c7d815b7070566647/href</a></iframe><p>Bets number 1 and 3 were on “no” and the bet was on the actual outcome “no”. So the total amount of IOTA was 860, the bets on “no” were only 60 IOTA in total. The share of bet number 1 is 10/60 and share of bet number 2 is 50/60. So, wasp wallet 1 receives 1/6 of 860 IOTA, i.e, 143 IOTA. And wasp wallet 3 receives 5/6 of 860 IOTA, i.e, 716 IOTA. Note that when transferring funds, a minimum transaction of fee of 1 IOTA is deducted from the amount to be transferred.</p><p>Note that running the <em>closemarket</em> function of the smart contract a second time leads to an error message in the Wasp node’s log:</p><pre>the prediction market was already closed</pre><h4>Limitations</h4><p>There are some limitations of the presented prediction market</p><ul><li>Only one contract per chain can be deployed because the bets are not stored per contract identification in the chain’s state</li><li>All bets are stored on-chain, so they are public</li><li>Each account (given by a wasp wallet) can place only one bet per deployed prediction market contract</li><li>The actual question asked by the prediction market and the possible outcomes have to be conveyed informally</li><li>Bets are against other market participants — there is no market maker</li></ul><h3>Insights</h3><p>Along the way of producing this article and experimenting with IOTA smart contracts, many small insights were gained. With the hope that these insights will be helpful, I share them in the following.</p><h4>Transaction Time</h4><p>Running transactions in the described setup on a laptop can take several seconds when waiting for the wasp-cli commands to finish. However, they can be run asynchronously when using the wasp-cli, i.e., commands can return immediately after issuing a command. Of course, transactions can run in parallel. When running scripted wasp-cli requests, one has to take care not to create too much load on the Wasp node because otherwise requests will fail with “time out”-errors. To evaluate transaction times in a production setup on the Devnet or Mainnet, further investigations are required.</p><h4>Transaction Fees</h4><p>In principle fees for transactions and deployments are configurable. However, there are some minimum fees that apply such as for deploying a chain (100 IOTA), deploying a smart contract, and posting state changing requests to a smart contract (1 IOTA). With default minimum fees in mind, transaction costs in the IOTA network should be very low compared to transaction fees in the Ethereum network. Note that chain owners could also increase transaction fees.</p><h4>Production Readiness</h4><p>On a first shot, nothing really worked when trying to set up a private IOTA network based on public documentation. That is, one has to find workable versions of the software, find a proper configuration and parameters, and find working ways for funding wallets and deploying contracts. The IOTA 2.0 software is under development and special notice has to be taken on which versions to run and which version of the different pieces (Wasp, GoShimmer, cli) to combine. The documentation in <a href="https://github.com/iotaledger/">IOTA’s repositories</a> is lagging behind the development process. However, the IOTA community is very helpful and can be reached on <a href="https://discord.iota.org/">Discord</a>. So, getting the network up and running depended digging into material on the <a href="https://github.com/iotaledger/">github</a> repositories, third party information (e.g., on <a href="https://www.youtube.com/playlist?list=PLyzQwFp8SFUWHhim4PBhV75W3nLxBWZI6">youtube</a>), own experiments, and asking questions on IOTA’s <a href="https://discord.iota.org/">discord</a> server. Once the IOTA private network and the smart contract are up and running, you are ready for testing and experiments. Further steps taken by IOTA to bring the smart contract implementation and IOTA 2.0 to production readiness can be looked up in their <a href="https://roadmap.iota.org/">roadmap</a>.</p><h4>Developing Smart Contracts</h4><p>Using Rust as a language for developing smart contracts might help producing error-free and stable smart contracts because Rust is well-known for its strict and sophisticated compiler which together with the strong typing and the language design eliminates whole classes of errors common in other languages. Also, the compiler provides helpful error messages. Therefore, using <a href="https://www.innoq.com/de/articles/2020/08/smart-contracts-in-rust/">Rust can provide some advantages</a> over the Solidity language, which is usually used for developing Ethereum smart contracts. However, Rust might be unfamiliar for smart contract developers being used to Solidity.</p><h3>Conclusion</h3><p>This article discussed smart contracts as a new and upcoming feature in IOTA 2.0. Because IOTA has a different approach to conduct and store transactions in a more parallel way with fewer resources than Ethereum, a higher scalability and lower fees are promises that come with this approach. Our experimental setup of a private IOTA network and simple prediction market IOTA smart contract shows that it is already possible to use IOTA smart contracts for development and testing. As the process of setting up the IOTA network and running smart contracts was a bit challenging, I believe this article and example code can provide useful input and support for other developers and the community interested in IOTA smart contracts.</p><p>51nodes GmbH based in Stuttgart is a provider of crypto economy solutions. 51nodes supports companies and other organizations in realizing their Blockchain projects. 51nodes offers technical consulting and implementation with a focus on smart contracts, decentralized apps (DApps), integration of blockchain with industry applications, and tokenization of assets.</p><p>Thanks to <a href="https://medium.com/@turfa">Majd Turfa</a> and <a href="https://medium.com/@jpbu">Jan-Paul Buchwald</a> for their help in the course of developing this article, experiments, and the setup.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2d81988f75e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/51nodes/exploring-iota-2-0-smart-contracts-in-a-private-network-developing-a-prediction-market-c2d81988f75e">Exploring IOTA 2.0 Smart Contracts in a Private Network: Developing a Prediction Market</a> was originally published in <a href="https://medium.com/51nodes">51nodes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kusama & Polkadot: Build an application specific Blockchain and launch a Parachain!]]></title>
            <link>https://medium.com/51nodes/kusama-polkadot-build-an-application-specific-blockchain-and-launch-a-parachain-524ff4560acf?source=rss----89b961a921c---4</link>
            <guid isPermaLink="false">https://medium.com/p/524ff4560acf</guid>
            <category><![CDATA[substrate]]></category>
            <category><![CDATA[kusama]]></category>
            <category><![CDATA[parachain]]></category>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[rococo]]></category>
            <dc:creator><![CDATA[Marco Walz]]></dc:creator>
            <pubDate>Thu, 18 Feb 2021 11:15:52 GMT</pubDate>
            <atom:updated>2021-02-18T15:31:58.266Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n61GTJQmkSx8ir-a.png" /><figcaption>Source: <a href="https://polkadot.network/">https://polkadot.network/</a></figcaption></figure><blockquote><strong>Note:</strong> This article provides a general and slightly technical introduction to Parachains and indicates how to get started building a Substrate based blockchain which can be launched as Parachain in the Kusama &amp; Polkadot ecosystem. It will explain some parts of Polkadot but it won’t get too much into specific details like staking, slashing or other important mechanics in the ecosystem. Check out the <a href="https://wiki.polkadot.network/">official wiki</a> to learn more about Polkadot.</blockquote><h3>Status quo</h3><p>First of all it is important to mention that the <a href="https://wiki.polkadot.network/docs/en/learn-parachains"><strong>Parachain</strong></a> functionality is not live yet. This functionality is the last missing piece of the Polkadot <a href="https://github.com/polkadot-io/polkadotpaper/raw/master/PolkaDotPaper.pdf">whitepaper</a> and there is a public <a href="https://polkadot.network/launch-parachains/"><strong>rollout plan</strong></a><strong> </strong>available that provides an overview about the progress. However, <a href="https://medium.com/polkadot-network/introducing-rococo-polkadots-parachain-testnet-e3e67fc40b56">since August 2020</a> the Parachain functionality is being tested in the official Parachain Testnet <strong>Rococo</strong> which in V0 only ran with prototype code. In December 2020 <a href="https://medium.com/plasm-network/announcing-plasm-network-parachain-on-rococo-v1-bf49b3f3ca53">Rococo V1 was launched</a> and recently <strong>Plasm Network</strong> <a href="https://medium.com/plasm-network/announcing-plasm-network-parachain-on-rococo-v1-bf49b3f3ca53">announced to be the first project that joined the Rococo V1 Testnet</a> which surely is a big milestone as the <em>codebase of Rococo V1 will also be used in </em><strong><em>Kusama</em></strong><em> and </em><strong><em>Polkadot</em></strong>. Meanwhile other possible future Parachains like <strong>KILT</strong> <a href="https://kilt-protocol.medium.com/kilts-path-to-parachains-ad3be644db8a">followed and announced their own Roadmap</a>.</p><h3>Kusama vs. Polkadot</h3><p>Although Kusama can be seen as the pre-production environment for Polkadot you should be aware that Kusama might and probably will evolve independently from Polkadot. If your project is in an early stage or you want to experiment with Parachains in a real world environment before moving it into production you will probably prefer Kusama over Polkadot first. You might also be interested in testing specific features in Kusama which aren’t yet available on Polkadot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qiuv8QDipVkh2f6L.png" /><figcaption>Source: <a href="https://polkadot.network/">https://polkadot.network/</a></figcaption></figure><h3>Relay Chain &amp; Parachains</h3><p>The Relay Chain is the central chain of Polkadot. All validators of Polkadot are staked on the Relay Chain in DOT and validate for the Relay Chain. It has deliberately minimal functionality and its main responsibility is to coordinate the system as a whole, including Parachains. Other specific work is delegated to the Parachains that serve different purposes. All Parachains that are connected to the Relay Chain <strong>share</strong> the same <strong>security</strong>. Polkadot also has a <strong>shared state</strong> between the Relay Chain and all connected Parachains to <em>ensure the validity of the entire system</em>. Smart Contracts are not supported on the Relay Chain but <strong><em>can be</em></strong> <strong><em>supported</em></strong> by Parachains.</p><blockquote>It’s expected that each Parachain will be as light and application specific as possible and serve a specific use case.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RaNttLQ9gOHCEHSX.png" /><figcaption>Source: <a href="https://medium.com/polkadot-network/parathreads-pay-as-you-go-parachains-7440d23dde06">https://medium.com/polkadot-network/parathreads-pay-as-you-go-parachains-7440d23dde06</a></figcaption></figure><p>In <a href="https://medium.com/polkadot-network/the-path-of-a-parachain-block-47d05765d7a"><em>The Path of a Parachain Block</em></a> it is described in detail how a new Parachain Block is produced.</p><p>You may notice the term <strong>Parathread</strong> in the picture above. The current (optimistic) assumption is that the Relay Chain supports <strong>up to 100 Parachains</strong> and some of these Parachain slots will be permanently reserved to serve the network on system level (e.g. Governance). Thus there probably won’t be enough slots available for all projects which is why they need to be obtained in a so-called auction (more on that below). Whereas Parachains get a guaranteed high throughput by bonding DOT tokens, Parathreads follow a <a href="https://medium.com/polkadot-network/parathreads-pay-as-you-go-parachains-7440d23dde06">pay as you go model</a> where a fee in DOT is being paid to validators for creating blocks. In some cases this even makes sense if there aren’t many or high frequent state updates expected (e.g. DNS, Oracles).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2KsYeqB_0a04LztN.png" /><figcaption>Source: <a href="https://medium.com/polkadot-network/parathreads-pay-as-you-go-parachains-7440d23dde06">https://medium.com/polkadot-network/parathreads-pay-as-you-go-parachains-7440d23dde06</a></figcaption></figure><p>Parachains can become Parathreads and vice versa as they share the same technical base.</p><h3>Parachain Slot Auction &amp; Parachain Crowdloans</h3><p>In order to become a Parachain in Kusama or Polkadot a slot must be obtained in a <a href="https://wiki.polkadot.network/docs/en/learn-auction">Parachain Slot Auction</a>. Each slot duration is capped to 2 years and divided into 6-month lease periods. Parachains may lease more than one slot over time in order to extend their lease to Polkadot past the 2 year slot duration. Depending on the auction it might be possible that a slot is owned by 4 different Parachains during the 2 year slot duration.</p><blockquote>Parachains don’t need to always inhabit the same slot. As long as a Parachain inhabits any slot it can continue as Parachain.</blockquote><p>Parachain candidates can place bids in unpermissioned <a href="https://en.wikipedia.org/wiki/Candle_auction"><strong><em>candle auctions</em></strong></a> that rely on <a href="https://en.wikipedia.org/wiki/Verifiable_random_function">verifiable random functions</a> (VRFs) where the original mechanism has been slightly modified to be secure on a blockchain. The auction can be divided into two phases:</p><ul><li>Opening Phase</li><li>Closing Phase</li></ul><p>No matter in what phase the auction is, the <strong><em>bids are public</em></strong>. From the first block until the last block during the Closing Phase a winner will be determined randomly and <em>nobody knows which block determines the winner until the Closing Phase is finished</em>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FfYc1yolanoE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DfYc1yolanoE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FfYc1yolanoE%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/74f01e0b9f03cb00c1fe3dec94af1a77/href">https://medium.com/media/74f01e0b9f03cb00c1fe3dec94af1a77/href</a></iframe><p>Projects will also be able to launch a <a href="https://wiki.polkadot.network/docs/en/learn-crowdloans"><strong>Crowdloan Campaign</strong></a> with specific parameters which allows them to loan DOTs from the community to obtain a Parachain slot without having to bond all the required DOTs on their own.</p><p>In the video above core developer Shawn Tabrizi explains both variants very well.</p><h3>Substrate</h3><p>After giving an overview about the Polkadot ecosystem it’s time to introduce <strong>Substrate</strong>. It is a modular framework that enables you to create purpose-built blockchains by composing custom and/or pre-built components.</p><p>Substrate is the foundation of all blockchains in the Polkadot ecosystem and requires knowledge in <a href="https://www.rust-lang.org/"><strong>Rust</strong></a>.</p><p>In the Substrate Developer Hub (link below) you can learn everything that is required to get started developing your own Substrate-based chain.</p><p><a href="https://substrate.dev/">Official Substrate Documentation for Blockchain Developers · Substrate Developer Hub</a></p><p>A few important things to know about Substrate:</p><ul><li>The <strong>runtime</strong> of Substrate is referred to as the “state transition function” which contains the business logic that defines the behavior of the blockchain. You as a developer can define <strong>storage items</strong> that represent the state of the blockchain and <strong>functions</strong> that allow users to make changes to the state.</li><li>Substrate ships with <strong>FRAME</strong> (Framework for Runtime Aggregation of Modularized Entities) which is a set of modules (called <strong>Pallets</strong>) and support libraries that simplify runtime development. Pallets are individual modules within FRAME that host domain-specific logic.</li><li>To enable forkless <strong>runtime upgrade capabilities</strong>, Substrate uses runtimes that are built as <strong>WebAssembly (WASM)</strong> bytecode.</li></ul><p>To learn more about how to perform a forkless runtime upgrade you can take a look at the <a href="https://substrate.dev/docs/en/tutorials/upgrade-a-chain/">official tutorial</a>.</p><h3>Pallets vs. Smart Contracts</h3><p>For people heading over from other chains and ecosystems like Ethereum it might be obvious that application specific logic is always written in Smart Contracts which in turn are deployed on the blockchain. But as you already learned the idea of the Polkadot ecosystem is to have different Parachains that are as light and as application specific as possible.</p><p>There are basically 3 possibilities to add custom logic to a Substrated-based blockchain:</p><ol><li>Write <strong>custom Pallets</strong> and include it in the runtime<br>- <a href="https://substrate.dev/docs/en/tutorials/create-a-pallet/">https://substrate.dev/docs/en/tutorials/create-a-pallet/</a><br>- <a href="https://substrate.dev/recipes/pallets-intro.html">https://substrate.dev/recipes/pallets-intro.html</a></li><li>Include the <a href="https://substrate.dev/docs/en/knowledgebase/smart-contracts/contracts-pallet"><strong>Contracts Pallet</strong></a> in the runtime and write contracts in <strong>ink!</strong> (Rust based eDSL)<br>- <a href="https://paritytech.github.io/ink-docs/">https://paritytech.github.io/ink-docs</a><br>- <a href="https://substrate.dev/substrate-contracts-workshop/#/">https://substrate.dev/substrate-contracts-workshop</a></li><li>Include <strong>Frontier</strong> (Pallets that serve as Ethereum compatibility layer) to the runtime and write contracts in <strong>Solidity<br></strong>- <a href="https://github.com/paritytech/frontier">https://github.com/paritytech/frontier</a><br>- <a href="https://substrate.dev/frontier-workshop/#/">https://substrate.dev/frontier-workshop</a></li></ol><blockquote><strong>Custom Pallets</strong> are the best choice if you are building a greenfield project that serves a specific purpose and needs to run its own network.</blockquote><p>Substrate already provides a lot of Pallets which you can combine together as needed, including your custom Pallet(s) in order to build a lightweight and unique runtime for your application specific blockchain:</p><ul><li><a href="https://github.com/paritytech/substrate/tree/v3.0.0/frame">Default Pallets of Substrate</a> (Note: The link points to the v3.0.0 version of Substrate which was released a few days ago. Most tutorials are still based on v2.0.0)</li><li><a href="https://github.com/danforbes/pallet-nft">NFT Pallet</a> (There is also a WIP reference implementation that showcases CryptoKitties on Substrate)</li></ul><p>I also discovered a <a href="https://marketplace-staging.substrate.dev/"><strong>Substrate Marketplace</strong></a> where you are able to find different Pallets (at least the default ones) which you can include into your runtime.</p><p>If you aim to write contracts in <strong>ink!</strong> or port a <strong>Solidity</strong> based application from Ethereum over to a Substrate-based Parachain you don’t necessarily need to launch your own Parachain as there already exist projects that plan to launch a Parachain and include the required Pallets in their runtime:</p><ul><li><a href="https://edgewa.re/"><strong>Edgeware</strong></a><strong> </strong>(ink! based contracts)</li><li><a href="https://moonbeam.network/"><strong>Moonbeam</strong></a> (Solidity contracts)</li></ul><blockquote><strong>Note:</strong> To check out how Moonbeam works you can clone the following repository: <a href="https://github.com/51nodes/moonbeam-playground">https://github.com/51nodes/moonbeam-playground</a></blockquote><h3>Polkadot compatibility with Cumulus</h3><p>When you have written (and hopefully tested ;-)) your custom Pallets you need to make sure that you build a Polkadot compatible runtime that exposes an interface for validating its state transition and provides interfaces to send and receive messages of other Parachains.</p><p><a href="https://wiki.polkadot.network/docs/en/build-cumulus"><strong>Cumulus</strong></a> is an extension to Substrate that makes it easy to transform any Substrate-built runtime into a Polkadot-compatible Parachain. It is still in development, but the idea is that it should be simple to take a Substrate chain and add the Parachain code by importing the crates and adding a single line of code. You can also dive deeper into that topic and learn more about the mechanics of Polkadot by reading the <a href="https://w3f.github.io/parachain-implementers-guide/index.html"><strong>Parachain Implementers Guide</strong></a>.</p><p>If you have built your own Parachain and want to join the official Rococo Testnet you have to follow <a href="https://wiki.polkadot.network/docs/en/build-parachains-rococo#rococo-v1-parachain-requirements">this guide</a>. <em>The auction mechanism mentioned above is not active yet and Rococo is currently controlled by the development leads at Parity Technologies</em>. For joining the network you have to run at least 1 Collator for your Parachain and 1 Validator node for Rococo.</p><blockquote><strong>Note:</strong> Learn how to setup a local Polkadot network based on Rococo by following the Readme of our repository: <a href="https://github.com/51nodes/polkadot-local-rococo">https://github.com/51nodes/polkadot-local-rococo</a></blockquote><h3>Final Thoughts</h3><p>Substrate has a clean design and makes it very easy to build an application specific blockchain for everyone familiar with Rust. If you decide to run your own Parachain (or Parathread) you should also think about how to incentivise other players to run a Collator node in your network — for example by introducing your own network token.</p><p>Although Parachains are not live on Kusama and Polkadot yet we can already see many projects that aim to become a Parachain as soon as possible. It will be interesting to watch the battle of those projects to secure their exclusive Parachain slot on Kusama and Polkadot. Personally I am very interested to see how the auction mechanism works and which projects will secure their Parachain slot via a Crowdloan Campaign.</p><p>I am also looking forward to play around with the interoperability features that Polkadot provides when the implementation is mature enough.</p><p><a href="https://www.51nodes.io/">51nodes GmbH</a> based in Stuttgart is a provider of Crypto Economy solutions.</p><p>51nodes is member of the <a href="https://www.parity.io/announcing-substrate-delivery-partners/">Substrate Delivery Partners</a> program and supports companies and other organizations in realizing their blockchain projects. 51nodes offers technical consulting and implementation with a focus on smart contracts, decentralized apps (dApps), integration of blockchain with industry applications, and tokenization of assets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=524ff4560acf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/51nodes/kusama-polkadot-build-an-application-specific-blockchain-and-launch-a-parachain-524ff4560acf">Kusama &amp; Polkadot: Build an application specific Blockchain and launch a Parachain!</a> was originally published in <a href="https://medium.com/51nodes">51nodes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Self-Sovereign Identity (SSI) as building block of the Crypto Economy]]></title>
            <link>https://medium.com/51nodes/self-sovereign-identity-ssi-as-building-block-of-the-crypto-economy-6fba55524e50?source=rss----89b961a921c---4</link>
            <guid isPermaLink="false">https://medium.com/p/6fba55524e50</guid>
            <category><![CDATA[did]]></category>
            <category><![CDATA[digital-identity]]></category>
            <category><![CDATA[ssi]]></category>
            <category><![CDATA[decentralized-identifier]]></category>
            <category><![CDATA[self-sovereign-identity]]></category>
            <dc:creator><![CDATA[Marco Walz]]></dc:creator>
            <pubDate>Tue, 24 Nov 2020 17:44:42 GMT</pubDate>
            <atom:updated>2020-11-25T08:43:01.993Z</atom:updated>
            <content:encoded><![CDATA[<p>The term <strong>Self-Soverein Identity (SSI)</strong> will be omnipresent in the coming years. The entire development taking place in this area lays the foundation for our vision of a <strong>Crypto Economy</strong> which will <strong><em>transform the way business is done</em></strong> in many industries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*E6ClXS0Xltff3ATc.png" /></figure><p>By implementing SSI solutions we will be able to:</p><ul><li>dramatically<strong> reduce</strong> (governmental) <strong>bureaucracy</strong> by providing efficient and frictionless<strong> </strong>processes</li><li>exchange and verify (personal) data in a safe way and thus <strong>avoid </strong>the<strong> </strong><a href="https://www.informationisbeautiful.net/visualizations/worlds-biggest-data-breaches-hacks/"><em>growing amount of data breaches</em></a></li><li>eliminate<strong><em> </em>fraud</strong></li><li>get<strong> </strong>rid<strong> </strong>of<strong> centralized logins</strong> using different authentication providers like Google, Facebook, Apple, Twitter and many more (<a href="https://www.businessinsider.com/google-users-locked-out-after-years-2020-10"><em>why is that important?</em></a>)</li></ul><blockquote>In the future, any type of <strong>certificate</strong>, <strong>attestation</strong> or <strong>authorization</strong> can be <strong>issued</strong> and <strong>verified</strong> <strong>digitally</strong> in a simple yet <strong>secure</strong> manner.</blockquote><p>Imagine that every card we are holding in our personal wallet right now can be issued digitally and instead of having it physically in our pocket we will have it stored on our smartphone. If a service or a business needs to verify our age or any other personal or financial data we will be able to prove this within seconds by just pushing a button on our smartphone. The beauty here is that we will be able to do this (almost) completely independent from specific vendors and technologies. This is all possible thanks to <a href="https://www.w3.org/TR/vc-data-model/#introduction"><strong><em>Verifiable Credentials (VCs)</em></strong></a>.</p><p>Sounds too good to be true? We encourage you to make yourself familiar with this topic and <strong>get in touch<em> </em></strong>with us if you are interested! Here some good reading material to start with:</p><ul><li><a href="https://medium.com/decentralized-identity/where-to-begin-b2a55b898b3"><strong><em>Where to begin?</em></strong></a> (Decentralized Identity Foundation Blog)</li><li><a href="https://medium.com/spherity/ssi101-an-introductory-course-on-self-sovereign-identity-the-spherity-way-19e0d1de3603"><strong><em>SSI101: An Introductory Course</em></strong></a><strong><em> </em></strong>(Spherity Blog)</li><li><a href="https://tykn.tech/self-sovereign-identity/"><strong><em>Ultimate Beginners Guide</em></strong></a> (Tykn.tech)</li></ul><h3>Characteristics</h3><p>For an <strong>identity</strong> to be <strong>self-sovereign</strong>, at least following statements must be fulfilled:</p><ul><li>Each individual owns their own data and does <strong>NOT</strong> <strong>rely</strong> on a <strong>central party</strong> to prove claims about themself.</li><li>Each individual has <strong>full control</strong> on what <strong>personal information</strong> they are sharing and with whom.</li><li>The SSI must be <a href="https://medium.com/51nodes/decentralized-identifiers-based-interoperability-architecture-71afb52b4e7f"><strong><em>interoperable</em></strong></a>. Each individual can use their identity across multiple platforms and locations.</li></ul><blockquote>A Self-Sovereign Identity is <strong>portable</strong>, <strong>private</strong> and <strong>secure</strong>.</blockquote><h3>Trust over IP and the role of blockchain</h3><p>On 5 May 2020, the Linux Foundation <a href="https://www.linuxfoundation.org/press-release/2020/05/cross-industry-coalition-advances-digital-trust-standards/">announced a new addition to its roster of global open source ecosystem projects</a>: the <a href="https://trustoverip.org/"><strong>Trust over IP Foundation</strong></a>. The mission of this new Foundation is to simplify and standardize how trust is established online so that everyone can feel safe, secure, and private in all of our digital interactions — whether between individuals, businesses, governments, or any “thing” on the Internet of Things.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MviT1lslToWAuBhl" /><figcaption>Source: Aries RFC 0289 - The Trust Over IP Stack</figcaption></figure><p><strong>Layer 1</strong> can be implemented on any distributed system and <strong><em>doesn’t necessarily have to be a blockchain or a distributed ledger</em></strong>. But of course the high availability and cryptographic verifiability of blockchains enable strong roots of trust and won’t serve as single point of failure.</p><p>The most interesting work is currently happening on <strong>Layer 2</strong> and <strong>Layer 3</strong>. If you want to dive deeper into that topic you should get in touch with the different <a href="https://identity.foundation/#wgs"><em>working groups</em></a> of the <strong><em>Digital Identity Foundation</em></strong> and take a closer look at <a href="https://www.hyperledger.org/use/aries"><strong><em>Hyperledger Aries</em></strong></a>. It is for example possible to prove facts that are written in a VC without having to reveal all the information the VC contains. This is called <strong>selective disclosure</strong> and can be achieved by making use of <a href="https://en.wikipedia.org/wiki/Zero-knowledge_proof"><strong>Zero-Knowledge Proofs (ZKP)</strong></a>.</p><h3>Solution approaches and initiatives</h3><p>In Germany alone we have many players working on exploring and implementing SSI solutions. The German ministry for economic affairs and energy (BMWi) is currently running an innovation competition called <a href="https://www.digitale-technologien.de/DT/Redaktion/EN/Standardartikel/sdi_programm.html"><strong><em>Secure Digital Identities</em></strong></a> where many different smaller and bigger companies collaborate in consortiums to transform the way we will manage our digital identity in the future.</p><p>For the project <a href="https://www.daimler-mobility.com/en/company/news/project-blockchain-mobility-platform/"><strong><em>Mobility Blockchain Platform</em></strong></a> (MBP) of the <strong>Daimler Mobility AG Blockchain Factory</strong>,<strong> </strong>which we have accompanied since the beginning, SSI plays also a very important role. We worked together with companies like <a href="https://evan.network/"><em>evan.network</em></a>, <a href="https://blockchain-helix.com/"><em>Blockchain Helix</em></a><em>, </em><a href="https://spherity.com/"><em>Spherity</em></a><em> and </em><a href="https://ont.io/"><em>Ontology</em></a><em> </em>to provide users access to services of the MBP with an SSI based solution.</p><h3>Status quo &amp; outlook</h3><p>From the perspective of a company that builds and makes use of SSI based solutions we can certainly say that SSI is here to stay and that we can already build upon a set of technologies and frameworks to make our vision of a <strong>Crypto Economy</strong> reality.</p><p>Of course there are some technical and practical challenges like <strong>communication</strong>,<strong> interoperability</strong><em> </em>and <strong>key management</strong> (including key recovery) which is being heavily worked on. But we are confident that it is just a matter of time until we can <strong>hide </strong>this<strong> complexity</strong> and make it as easy as possible for <strong>businesses</strong> and <strong>individuals</strong> to make use of SSI solutions.</p><blockquote>The <strong>biggest challenge</strong> right now is to <strong>explain the value</strong> that SSI represents to <strong>businesses</strong> and <strong>people</strong>.</blockquote><p>In the book <a href="https://www.manning.com/books/self-sovereign-identity"><em>“Self-Sovereign Identity Decentralized Digital Identity and Verifiable Credentials”</em></a>, which isn’t finished yet and will approximately be published in summer 2021, the authors have written a whole chapter to guide people how to explain SSI to businesses!</p><p><a href="https://www.51nodes.io/">51nodes GmbH</a> based in Stuttgart is a provider of Crypto Economy solutions.</p><p>51nodes supports companies and other organizations in realizing their blockchain projects. 51nodes offers technical consulting and implementation with a focus on smart contracts, decentralized apps (dApps), integration of blockchain with industry applications, and tokenization of assets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fba55524e50" width="1" height="1" alt=""><hr><p><a href="https://medium.com/51nodes/self-sovereign-identity-ssi-as-building-block-of-the-crypto-economy-6fba55524e50">Self-Sovereign Identity (SSI) as building block of the Crypto Economy</a> was originally published in <a href="https://medium.com/51nodes">51nodes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decentralized Identifiers based Interoperability Architecture]]></title>
            <link>https://medium.com/51nodes/decentralized-identifiers-based-interoperability-architecture-71afb52b4e7f?source=rss----89b961a921c---4</link>
            <guid isPermaLink="false">https://medium.com/p/71afb52b4e7f</guid>
            <category><![CDATA[verifiable-credentials]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[decentralized-identifier]]></category>
            <category><![CDATA[interoperability]]></category>
            <category><![CDATA[distributed-ledgers]]></category>
            <dc:creator><![CDATA[Jan-Paul Buchwald]]></dc:creator>
            <pubDate>Fri, 30 Oct 2020 11:06:59 GMT</pubDate>
            <atom:updated>2020-10-30T11:06:59.029Z</atom:updated>
            <content:encoded><![CDATA[<p>How the DID, VC and VP concepts can be used to achieve lightweight, scalable interoperability between different distributed ledger networks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X15tngto7lIVvlUP-tk-JA.jpeg" /></figure><h3>Introduction</h3><p>Given the growing number and adoption of distributed ledger solutions and the assumption that the future digital infrastructure will be based on a variety of networks rather than one single blockchain, the importance of interoperability between different distributed ledger networks becomes evident. However, inter-ledger interoperability is still in its infancy and focuses on the transfer of tokens or more generalized assets. It quickly hits limits when it gets to the exchange of identities and data related to individual business processes or logic. For example, using the account and identity of a consumer or a business verified in blockchain network A to interact and sign business transactions in blockchain network B, is not possible using today’s inter-ledger approaches.</p><p>In the following, a pragmatic approach how to handle interoperability of identities and claims based on <a href="https://www.w3.org/TR/did-core/">W3C Decentralized Identifiers</a> (DIDs) and the related <a href="https://www.w3.org/TR/vc-data-model/">Verifiable Credential</a> concept is introduced. By adding a thin abstraction layer on the application level, business applications using distributed ledger networks that support DIDs can easily be enhanced for supporting multiple DID methods related to different networks.</p><h3>Solution Description</h3><p><em>Note: the following description requires basic knowledge of the concepts of Decentralized Identifiers (DID) and Verifiable Credentials (VC) / Verifiable Presentations (VP). For a brief introduction see the </em><a href="https://w3c-ccg.github.io/did-primer/"><em>W3C Primer</em></a><em>. In the context of the suggested approach, we only consider public DIDs, contrary to private (“pairwise”) DIDs which are only used and shared as part of direct communication between two parties.</em></p><h4>DID Resolution</h4><p>Public DIDs can be resolved to a DID document that gives information about the validity, public keys or other means of authentication, and additional attributes of the respective identity. Each DID method must specify how DIDs can be resolved in a deterministic, immutable manner. Usually, providing a reference implementation of a DID resolver and adding it to the <a href="https://dev.uniresolver.io/">universal resolver</a> initiative for universal resolving is part of the DID method specification. The DID resolution step gives a standardized way to verify and authenticate an identity, and systems or applications that identify users based on DIDs can support any DID method by adding a respective resolver of this DID method into their code or dispatch to the universal resolver.</p><h4>Verifiable Credentials and Presentations</h4><p>For the exchange of more specific claims, proofs and signatures related to a DID, Verifiable Credentials are issued and signed by a trusted party (also identified by the issuer DID) to a particular subject DID. The subject DID can then present one or more VCs to a verifier using a Verifiable Presentation, which basically adds the subject’s signature to the presented claims as a means of authentication.</p><p>Although VCs and VPs are supposed to be a standard, there are different implementation options and technical representations, which causes some challenges to interoperability in real-world applications. The most commonly used representations are the <a href="https://www.w3.org/TR/vc-data-model/#json-ld">JSON(-LD)</a> format described and used in examples in the W3C documents, but in practice the <a href="https://www.w3.org/TR/vc-data-model/#json-web-token">JWT</a> (JSON Web Token) mapping is also widely used. By supporting those two alternatives, most current DID and related VC/VP implementations can be handled.</p><h4>Multi DID Method Handler Architecture</h4><p>Based on the previously described elements, we can define an architecture pattern adding a thin layer for the orchestration of DID, VC and VP related operations supporting different DID methods and related configuration properties.</p><p>The following diagram shows the suggested architecture in more detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*WnOzKNnwc62s6HpscV4A0g.png" /><figcaption>Architecture scheme</figcaption></figure><p>The business logic of an application interacts with the DID orchestration layer through an interface that is purely based on general DID and VC/VP elements. The interface is implemented by a single orchestrator that handles the orchestration and dispatching of operations based on the DID method of the involved DIDs. The operations related to a particular DID method are dispatched to a specific handler that is registered for this DID method. Handlers all implement the same operations and can be realized or looked up using a plugin mechanism to allow extensibility for new DID methods. Only the handler for a particular DID method connects to the underlying blockchain or DLT network of this DID method if necessary. The configuration of the component can contain the information about supported DID methods or handlers, the own DID and account information for write operations, as well as node endpoints or other blockchain related properties.</p><p>Operations provided by the interface could include:</p><ul><li>Resolve DID document for DID</li><li>Validate signature for DID and message</li><li>Validate VC issued by DID</li><li>Validate VP signed by DID</li><li>Update DID document for own DID</li><li>Sign message with own DID</li><li>Issue new VC with own DID as issuer</li><li>Issue new VP for list of VCs with own DID as signer</li></ul><p>The interface could be distinguished in a read-only part allowing resolution and validation only, and a write part requiring to have direct or indirect (via custodian mechanisms) access to an account private key in order to generate signatures or authenticate. Applications that only perform validation could be restricted to the read-only part with a simplified configuration.</p><p>The interface must be defined in a way to be able to treat VCs and VPs both as JSON or strings (JWT), which may cause some challenges for the implementation, but should be possible in most object oriented and type-safe programming languages.</p><h4>Example</h4><p>To make it more comprehensible how an implementation of this approach would look like in practice, let’s have a look at the typical VC and VP example scenario of a university degree credential issued by the university to a student and verified by an employer e.g. as part of a recruitment process.</p><p>It is assumed that the student uses <em>application 1</em> (which could be a general self-sovereign identity app) and has registered <em>DID a</em> with <em>DID method A</em>, which is related to <em>blockchain network A</em> and uses JWT as the format for VCs and VPs. The university uses <em>application 2</em> that implements the described DID, VC &amp; VP abstraction component. The university has registered <em>DID b</em> with <em>DID method B</em> related to <em>DLT network B</em> using JSON as the format for VCs and VPs, which is configured as the own account. The employer uses <em>application 3</em> also implementing the DID, VC &amp; VP abstraction, however only in a read-only manner without the need for an own DID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*bGsPjtlPKgbyFKnhNiSYhw.png" /><figcaption>Example Scenario and Flow</figcaption></figure><p>The flow could then look like the following:</p><ol><li>The student (<em>application 1</em>) requests a Verifiable Credential from the university (<em>application 2</em>) by providing a proof of the physical identity and a signature by <em>DID a</em>.<br><em>Note: for the sake of comprehensibility, in this example the university (application 2) checks the physical identity of the student itself. In more realistic scenarios, the student could have already run through an identification by a third party identity provider that mapped the student’s DID to relevant properties of the physical identity, and only present a reference to the id provider or respective Verifiable Credentials issued by the id provider</em>.</li><li>Using the abstraction component, the business logic in <em>application 2</em> can validate <em>DID a</em> and its signature, dispatching the validation to the handler for <em>DID method A</em>.</li><li>The business logic of <em>application 2</em> checks the physical identity of the student, see note in step 1.</li><li>After successful verification, <em>application 2</em> issues a Verifiable Credential using its own <em>DID b</em> as the issuer and <em>DID a</em> as the subject via the handler for <em>DID method B</em>.</li><li><em>Application 2</em> returns the VC issued in step 4 to the student (<em>application 1</em>).</li><li>The student (<em>application 1</em>) prepares a Verifiable Presentation containing the VC from the previous step, signed by <em>DID a</em> and using the JWT format according to <em>DID method A</em>. It sends the VP to the employer (<em>application 3</em>).</li><li>Using the abstraction component, the business logic in <em>application 3</em> can validate both DIDs and signatures of <em>DID a</em> (7a) and <em>DID b</em> (7b) with the respective handlers. If all is valid in terms of that the DIDs exist, the signatures are correct and there is no expiration or revocation of the credentials, the abstraction component returns the validated VC information.</li><li>The business logic of <em>application 3</em> can now further validate the VC content from a functional perspective. The validation should include a check whether the issuer DID of the VC is trusted.</li></ol><h3>Evaluation</h3><p>With the suggested approach, an application can easily be extended to support multiple DID methods based on a common, reusable pattern. As an additional benefit, business logic is kept independent of particular DID methods or DID, VC and VP processing.</p><p>Assuming that the DID, VC and VP concept establishes as the standard for decentralized, self-sovereign identity, it is likely that DIDs from different systems or networks will interact. Since the main usage scenarios for DIDs and VCs are user authentication (“single sign-on”) and verification (KYC — Know Your Customer and digital signatures), providers implementing those kinds of authentication and verification methods will want to support consumers from as many ecosystems and related DID methods as possible. The suggested approach is a suitable, rather light-weight solution for achieving such an interoperability on a DID level which should be flexible enough to be integrated into any existing application or environment. This differs from other solution approaches to DID interoperability like <a href="https://github.com/decentralized-identity/didcomm-messaging">DIDComm</a> or <a href="https://www.hyperledger.org/use/aries">Hyperledger Aries</a>, which require to adjust the software architecture and workflows towards an agent-based model and may not be suited for every case or come with high costs.</p><p>A drawback of the approach is a certain initial effort for implementing handlers to support new DID methods. This could be eased by moving the abstraction to a reusable component like a library or SDK, or even a separate micro-service, that can be shared by many applications. The general complexity due to dependencies to multiple networks and related configuration effort cannot be avoided, but should be mitigated in the implementation by sound error and exception handling. Also, the approach suffers from the current gaps and room for interpretations in the DID, VC and VP specification. In practice, this leads to DID methods that do not fully comply to the specification or implement different, incompatible extensions or variants. It is expected, though, that with increasing adoption the specification will become more robust and implementations will align in the future.</p><h3>Summary and Outlook</h3><p>This article described an architectural approach to realize interoperability between DIDs of different networks that can be well integrated into most existing application architectures.</p><p>A similar approach has been successfully prototyped and shown as a demo in a mobility use case allowing interoperability between the <a href="https://evan.network/">Evan network</a> (Ethereum based business blockchain network) and the <a href="https://ont.io/">Ontology</a> blockchain as part of the <a href="https://expo8.pnptc.events/">8th Startup Autobahn</a> program. You can watch the <a href="https://www.youtube.com/watch?v=1LkPV7T4D94">recording of the breakout session</a> during the virtual expo to get more details. Gratitude and acknowledgements go to the project partners that gave valuable input and made the solution possible, in particular Dr. Harry Behrens of the Daimler Mobility Blockchain Factory and the team of Ontology.</p><p>Future work on this topic may include the adaptation in real business applications to understand the needs and adjust the approach based on learnings from more usage scenarios, providing open source reference implementations or libraries in different programming languages, as well as the implementation and test of handlers for the most widely used DID methods.</p><p><a href="https://www.51nodes.io/">51nodes GmbH</a> based in Stuttgart is a provider of crypto economy solutions.</p><p>51nodes supports companies and other organizations in realizing their Blockchain projects. 51nodes offers technical consulting and implementation with a focus on smart contracts, decentralized apps (DApps), integration of blockchain with industry applications, and tokenization of assets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71afb52b4e7f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/51nodes/decentralized-identifiers-based-interoperability-architecture-71afb52b4e7f">Decentralized Identifiers based Interoperability Architecture</a> was originally published in <a href="https://medium.com/51nodes">51nodes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decentralized Schema Registry]]></title>
            <link>https://medium.com/51nodes/decentralized-schema-registry-aa662b8db12b?source=rss----89b961a921c---4</link>
            <guid isPermaLink="false">https://medium.com/p/aa662b8db12b</guid>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[decentralized-identity]]></category>
            <category><![CDATA[schemaregistry]]></category>
            <dc:creator><![CDATA[Jan-Paul Buchwald]]></dc:creator>
            <pubDate>Wed, 30 Sep 2020 07:03:45 GMT</pubDate>
            <atom:updated>2020-10-02T10:02:53.268Z</atom:updated>
            <content:encoded><![CDATA[<p>DID method to identify and resolve data schemas</p><p><em>Authors: </em><a href="https://medium.com/@julianvoelkel"><em>Julian Voelkel</em></a><em>, </em><a href="https://medium.com/@turfa"><em>Majd Turfa</em></a><em>, Jan-Paul Buchwald</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kPNxw_r5wmesEmmPcYStnQ.jpeg" /></figure><h3>TL;DR</h3><p>In this article, we introduce a new DID method that is used to identify and resolve data schemas. By supporting different underlying decentralized storage mechanisms (currently public IPFS and Evan IPFS) and an optional declaration and validation of the schema type, it provides flexibility and allows future extensions. We believe the schema DID method can build the foundation for a decentralized schema registry with globally unique and immutable schema identifiers to be used across centralized and decentralized systems.</p><h3>Introduction and motivation</h3><p>Whenever pieces of data with a certain semantic meaning are exchanged between different parties, it is essential to agree on a format and structure of this data. This is usually achieved via schemas or schema definitions, and within the history of software development, many representations of such schemas evolved. Most common schemas in use are related to <a href="https://en.wikipedia.org/wiki/XML_Schema_(W3C)">XML</a> (XSD — XML Schema Definition), <a href="https://json-schema.org/understanding-json-schema/">JSON</a> (JSON Schema), DDL (SQL Databases), <a href="https://graphql.org/">GraphQL</a> (GraphQL Schema), but also to embedded protocols (Protobuf) or particular products and frameworks (Thrift, Avro).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*2V9k__gzi-tQgh_EnwbTuQ.png" /><figcaption>Example of a simple JSON Schema</figcaption></figure><p>While a schema perfectly describes the structure of a piece of data and can be used to validate data, a further question is how to share those schemas between different parties or components using them. The obvious solution is a Schema Registry, meaning a repository to store and identify schemas. Today schema registries such as <a href="https://docs.confluent.io/current/schema-registry/index.html">Confluent Schema Registry</a> or <a href="https://aws.amazon.com/eventbridge/?nc1=h_ls">Amazon EventBridge</a> Schema Registry are used to store and address schemas in a particular namespace. This kind of schema registry is based on internal identification and central storage, which makes it dependent on a single party and narrows the usage scope immensely. So, we asked ourselves: how to share and reuse schema definitions across multiple systems or even globally?</p><p>The goal was to design a Decentralized Schema Registry based on a globally unique identifier allowing the use of immutable schemas which are accessible to the public or a set of relevant parties (depending on the chosen network).</p><h3>Solution</h3><p>Our solution for the previously stated challenge is a new <a href="https://www.w3.org/TR/did-core/#dfn-decentralized-identifiers">DID</a> <a href="https://www.w3.org/TR/did-core/#dfn-did-methods">method</a> for identifying schemas, combined with a (preferably decentralized and immutable) storage mechanism. A schema DID should allow a globally unique resolution of the schema by providing a service endpoint to “get” or download the actual schema content. The DID format should be open to support multiple storage mechanisms or networks and provide a way to also expose the schema type.</p><p>The following gives some more explanation on the DID method and related software components we defined and implemented.</p><h4>Schema Registry DID Method</h4><p>The DID is comprised of multiple elements separated by colons (:):</p><ul><li>The general DID and method prefix <em>did:schema</em></li><li>The method-specific id consisting of:<br>1. A mandatory identifier for the storage network, chosen from a list of supported storage mechanisms and networks.<br>2. An optional identifier for the type or format of the schema, chosen from a list of supported types.<br>3. The mandatory schema-hash identifying the schema file in the given storage network, represented as a string.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PUih8i1-y5gPtpbVUo1a-Q.png" /><figcaption>Example of a schema DID</figcaption></figure><p>The full DID method specification can be found on <a href="https://github.com/51nodes/schema-registry-did-method">GitHub</a>. The schema DID method was also added to the official registry of DID methods in the <a href="https://w3c.github.io/did-spec-registries/">W3C method registry</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*EXuQOfWlLf0CzbTUnrMc4Q.png" /><figcaption><a href="https://w3c.github.io/did-spec-registries/#did-methods">https://w3c.github.io/did-spec-registries/#did-methods</a></figcaption></figure><h4>Reference Library</h4><p>To make the DID method available for other developers, we implemented a <a href="https://www.typescriptlang.org/">Typescript</a> based library that supports the registration and extraction of schemas on different distributed networks by the two functions <em>registerSchema</em> and <em>getSchema</em>.</p><ul><li>The <em>registerSchema</em> method is used to store the schema on one of the supported networks and it returns the DID of the schema. The schema type is a mandatory parameter, and the given schema content is validated to comply to the given type.</li><li>The <em>getSchema</em> method gets a DID as Input and returns the schema that is stored behind the given DID. If the DID contains a schema type, the library validates the content and treats it as “not found” if it does not comply to the type.</li></ul><p>For the first version of the library, the supported schema types are JSON-Schema and XSD, the supported storage networks are the public <a href="https://en.wikipedia.org/wiki/InterPlanetary_File_System">IPFS</a> and Evan IPFS, which is a permissioned IPFS network provided by the <a href="https://evan.network/">evan.network</a>. The library also provides a function to initialize the library by setting the configuration needed to connect to the required networks and other utility functions to handle the DID.</p><p>Data stored on IPFS gets usually removed after some time, and only pinned files are stored permanently on the node. Since each node in IPFS networks handles this individually and pinning may incur costs, the pin functionality can be enabled or disabled in the library configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*IA195C9QFIpX7m7iXJKAQw.png" /><figcaption>Sequence Diagram for the registerSchema function</figcaption></figure><p>The library is published on npm as <a href="https://www.npmjs.com/package/@51nodes/decentralized-schema-registry">@51nodes/decentralized-schema-registry</a>, and the source code is available on <a href="https://github.com/51nodes/schema-registry-did-crud">GitHub</a>. Detailed instructions on how to use the library are described in the README file. The project also contains a simple JavaScript <a href="https://github.com/51nodes/schema-registry-did-crud/tree/master/example">example</a>.</p><h4>DID Resolver</h4><p>Using the provided library, we also implemented a DID resolver as a <a href="https://nestjs.com/">NestJS</a> application. It provides a GET endpoint to get the DID document of a schema DID. An example of a returned DID document is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*7dMEhuH6yQxLKjUJWDYu1A.png" /><figcaption>DID Document for the schema DID</figcaption></figure><p>The DID document includes a <a href="https://www.w3.org/TR/did-core/#dfn-service-endpoints">service endpoint</a> that points to a gateway that provides the underlying schema content. For the public IPFS this is currently an <a href="https://infura.io/">infura</a> public gateway, and for the evan.network IPFS there is a central gateway from evan.network, both loading a single resource identified by hash from the respective IPFS network.</p><p>The NestJS Application is dockerized and the Docker image is published under <em>51nodes/schema-registry-did-resolver</em> on <a href="https://hub.docker.com/repository/docker/51nodes/schema-registry-did-resolver">Docker Hub</a>. To build and run the driver locally, read the instructions with the provided source code which are published on <a href="https://github.com/51nodes/schema-registry-did-resolver">GitHub</a>.</p><p>The Docker image of the resolver was also added as a driver to the <a href="https://dev.uniresolver.io/">universal DID resolver</a>, which aims to provide a central resolution service for all kinds of DID methods (currently over 30).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtKEWx0nekVxtf3VolXoVQ.png" /><figcaption>Schema DID in Universal Resolver (<a href="https://dev.uniresolver.io/">https://dev.uniresolver.io/</a>)</figcaption></figure><p>Independent from the universal resolver the driver provides a GET request to download the saved schema directly under the endpoint <a href="http://localhost:8080/1.0/identifiers/{did}/get"><em>http://localhost:8080/1.0/identifiers/{did}/get</em></a></p><h3>Benefits and Usage Scenarios</h3><p>The main benefit of the schema DID is to allow a stable identifier and public registry for schema files or objects which could replace existing proprietary (siloed) schema registries or other schema storage solutions. Applications can use DIDs for referencing schemas stored in different locations and only need a standardized resolver (or use the universal resolver) to load the schema contents, allowing not only interoperability, but also much better reuse across systems and applications.</p><p>In particular, schema DIDs could be useful in the following scenarios:</p><p><strong>Schema references and validation for distributed data storage</strong></p><p>Schema DIDs can reference schemas for payload data in Blockchain or smart contract transactions. Further this approach enables the use of structured data in distributed file or data storages themselves, or could be used for schemas of <a href="https://www.w3.org/TR/vc-data-model/#what-is-a-verifiable-credential">Verifiable Credentials</a>.</p><p><strong>Cross-organization processes and communication</strong></p><p>Cross-organizational interactions become even more important in times of decentralized systems. Collaboration is the key for enhancing processes. Schemas stored in a distributed manner would enable cross-organizational standardized data interfaces accessible to everyone. This could elevate the collaboration to another level.</p><h3>Outlook and next steps</h3><p>Firstly, we are happy to get feedback on the solution and would love to see first adoption in real-world applications. Of course, we plan to use the DID based decentralized schema registry in our own future projects as well. We also want to have a closer look on the relations and possible usage in linked data such as <a href="https://json-ld.org/">JSON-LD</a> or <a href="https://docs.ipld.io/">IPLD</a> and in composite or nested schemas.</p><p>For the schema DID framework itself, we are looking for other networks that could be used as alternative decentralized storage networks. Some of the interesting projects in this area that we will keep an eye on are <a href="https://filecoin.io/">FileCoin</a>, <a href="https://www.bigchaindb.com/">BigChainDB</a>, <a href="https://ipdb.io/">IPDB</a>, <a href="https://sia.tech/">Sia</a> and <a href="https://www.arweave.org/">arweave</a>. We are looking as well to support other schema types like GraphQL-Schema for GraphQL which is getting more attention lately. Furthermore, implementing the library with other programming languages like Java and Rust would help to make the schema DID method available to a wider number of developers. For all those topics, we welcome interested open source developers to participate and help to grow the solution.</p><p><a href="https://www.51nodes.io/">51nodes GmbH</a> based in Stuttgart is a provider of crypto economy solutions.</p><p>51nodes supports companies and other organizations in realizing their Blockchain projects. 51nodes offers technical consulting and implementation with a focus on smart contracts, decentralized apps (DApps), integration of Blockchain with industry applications, and tokenization of assets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa662b8db12b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/51nodes/decentralized-schema-registry-aa662b8db12b">Decentralized Schema Registry</a> was originally published in <a href="https://medium.com/51nodes">51nodes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The role of blockchain in the context of hyperautomation]]></title>
            <link>https://medium.com/51nodes/the-role-of-blockchain-in-the-context-of-hyperautomation-653bcd60f756?source=rss----89b961a921c---4</link>
            <guid isPermaLink="false">https://medium.com/p/653bcd60f756</guid>
            <category><![CDATA[hyperautomation]]></category>
            <category><![CDATA[cryptoeconomy]]></category>
            <category><![CDATA[inter-company-transfer]]></category>
            <category><![CDATA[baseline-protocol]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Marco Walz]]></dc:creator>
            <pubDate>Fri, 24 Jul 2020 09:29:07 GMT</pubDate>
            <atom:updated>2020-11-24T17:52:49.215Z</atom:updated>
            <content:encoded><![CDATA[<p>According to Gartner, <strong>hyperautomation</strong> is the <a href="https://www.gartner.com/smarterwithgartner/gartner-top-10-strategic-technology-trends-for-2020/">number 1 technology trend</a> in 2020. Everything that can be automated will be automated. Multiple tools and techniques including robotic process automation (<strong>RPA</strong>) and artificial intelligence (<strong>AI</strong>) will be combined to <strong>replace human workers</strong>. This will make business processes way more efficient and less error-prone than today. Although in many areas business processes are already highly optimized there is still a lot potential for improvement.</p><p>But what type of business processes are we talking about? When diving deeper into that topic one will quickly realize that almost all business processes that are considered to be automated when talking about hyperautomation are <strong>internal</strong> <strong>processes</strong>.</p><p>Why is that? Isn’t there a lot more potential to automate processes across multiple <strong>independent</strong> <strong>companies</strong>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Jg_IdkFLcwM5t_IrZhDXg.png" /></figure><p>We call these <strong>intercompany processes*</strong> and we think that by utilizing blockchain in combination with other techniques it will be possible to fully automate them in the future.</p><p>But what exactly is the role of blockchain in the context of hyperautomation?</p><blockquote>*By our definition intercompany processes are processes where multiple <strong>independent</strong> companies are involved</blockquote><h3>Existing problems and the need for an intercompany transaction network (ICTN)</h3><p>Business processes across companies are characterized by the fact that numerous process steps require the integration of <strong>different IT systems</strong> and the involvement of different roles. Today, these processes run via several communication media such as telephone, e-mail, Internet and paper-based correspondence. Due to a lack of<strong> system integration</strong> they are by definition costly, error-prone and usually lack consistent monitoring. Media and system discontinuities also mean that information from different systems has to be <strong>consolidated</strong> again and again at great expense.</p><p>Typical characteristics of <strong>intercompany processes</strong>:</p><ul><li>error-prone</li><li>inconsistent data</li><li>difficult to monitor</li><li>high consolidation effort</li><li>expensive</li></ul><p>Today there doesn’t exist a solution to that problem which allows various companies to integrate their systems in a convenient and efficient way to get away from the unintended characteristics mentioned above.</p><p>If we think about automating intercompany processes, the following topics come to our minds and need to be tackled:</p><p><strong>Missing standards and/or high integration costs</strong></p><ul><li>Integration needs to be done for each business partner (!)</li><li>Integration often not worth doing for small and medium-sized enterprises (SMEs) due to economical reasons</li></ul><p><strong>Lack of trust</strong></p><ul><li>Business partners are at the same time often competitors and companies usually don’t want to share sensitive data with them</li></ul><p><strong>Missing data consistency</strong></p><ul><li>There is no instrument to ensure data consistency<strong> </strong>in a shared business process where multiple companies are involved</li></ul><p><strong>Confidential and secure message system</strong></p><ul><li>Communication and contract data should only be shared with involved parties</li></ul><p>A solution that allows every business partner involved in a shared business process, e.g. in a supply chain, to get a <strong>realtime view</strong> for the current state of the process is desired. And wouldn’t it be great if it were possible to automate <strong>accounting</strong> related tasks which would allow to perform <strong>automated audits</strong>?</p><p>The solution to these questions which combines multiple techniques including <strong>blockchain</strong> is what we call an <strong>intercompany transaction network (ICTN)</strong>.</p><p>We think that by leveraging blockchain technology in a common framework it will be possible to fully automate intercompany business processes without creating new<strong> monopolies</strong> and <strong>data silos</strong>.</p><p>The components required to enable an ICTN will be discussed later. First we want to recap past approaches that aimed to solve this problem by making use of blockchain technology.</p><h3>Past approaches &amp; consortium blockchain solutions</h3><p>If we take a closer look at past pilot projects where a blockchain was involved many of these tried to <strong>replace</strong> and <strong>extend</strong> existing business process implementations by coding a similar logic in smart contracts.</p><p>The promise was that business processes could now take place across companies in realtime without media disruption and thus much more efficiently while ensuring data consistency. Since <strong>sensitive data</strong> is involved in the processes, these should not be publicly visible and for this reason often solutions like <a href="https://www.goquorum.com/"><strong>Quorum</strong></a> (modified Ethereum) or <a href="https://www.hyperledger.org/use/fabric"><strong>Hyperledger Fabric</strong></a> were chosen as the solution as these provide some important <strong>privacy </strong>features.</p><p>However, although most of these promises have been verified in pilot projects to some extent there are several reasons why it is <strong>difficult</strong> and <strong>risky</strong> to <strong>replace</strong> <strong>existing solutions</strong> with such a blockchain solution.</p><p>A blockchain network based on <strong>Quorum</strong>, <strong>Hyperleger Fabric</strong> or any similar solution always requires a <strong>consortium </strong>setup which is hard to establish and to maintain as the initial consortium and joining members all need to agree upon the governance model. This is typically a <strong>lengthy process</strong> that requires at least following questions to be answered:</p><ul><li>Who controls the network?</li><li>What are the rules for new participants to join?</li><li>How are critical errors in smart contracts dealt with?</li><li>How will protocol updates be governed?</li></ul><p>Besides the difficulty to establish one or more consortium chains with different partners there are other aspects to be considered:</p><ul><li>Is there enough incentive for other businesses to join the network? (we need <strong>network effects</strong>!)</li><li>Is the technology mature enough to replace existing systems?</li><li>Isn’t this just another data silo that is being built?</li></ul><p>I guess none of the companies CIOs would be willing to take these risks and try to replace existing systems with such a solution as long as it isn’t battle tested. And here we haven’t even talked about performance, IT security policies and general compliance topics which must not be forgotten.</p><p>We need a solution that can tackle the existing problems without having to reinvent the wheel and this is where ICTN comes into place.</p><h3>Idea &amp; key components of ICTNs</h3><p>The idea behind an ICTN is to combine multiple different techniques — including blockchain — in a <strong>common framework</strong>. An ICTN will allow companies to establish fully automated, secure and private intercompany business processes without media disruption while ensuring <strong>data consistency across all involved parties</strong>.</p><p>It is very important to mention that an <strong>ICTN</strong> can be integrated in <strong>any system landscape</strong>, no matter how <strong>heterogenous</strong> the <strong>ERP systems</strong> of the involved companies are. While the <strong>sensitive business data</strong> stays in the existing IT systems we make use of cryptographic methods to prove to all involved parties that certain steps in an intercompany business process have been completed correctly.</p><p>Whenever in the intercompany process an agreement between one or multiple parties takes place, <a href="https://en.wikipedia.org/wiki/Zero-knowledge_proof"><strong>zero-knowledge proofs</strong></a> are used to ensure that previously defined business rules are met. Thus every party involved in the overall process can be sure that the state of the process is <strong>consistent</strong> and <strong>up to date</strong>.</p><blockquote>This is the role of the <strong>blockchain</strong> in the context of <strong>hyperautomation</strong> as we see it today.</blockquote><p>In an ICTN the blockchain is the <strong>immutable</strong> state machine where zero-knowledge proofs are stored <strong>irreversible </strong>and can <strong>always</strong> be <strong>verified</strong> by all parties involved in an <strong>intercompany business process</strong>.</p><p>Another major advantage is that auditors could also be integrated in an ICTN which means that it would be possible to fully <strong>automate audits</strong>.</p><p>We identified following <strong>key components</strong> which are necessary to make an ICTN possible:</p><h4>Secure and Private Communication</h4><p>To enable an intercompany transaction network the companies involved in the processes need a <strong>communication protocol</strong> that allows them to <strong>send</strong> and <strong>receive</strong> <strong>messages</strong> in a secure and private manner. Although the protocol is used by all participants, messages required for certain steps in the process should stay <strong>confidential</strong> between involved parties and not be visible to other players.</p><h4>Zero-knowledge</h4><p>The <strong>zero-knowledge</strong> component is required to <strong>create</strong> and <strong>verify</strong> cryptographic <strong>proofs</strong> which contain transaction data for a certain step in a business process. The cryptographic proofs ensure the previously defined <strong>business rules</strong> are met and they are stored on the immutable state machine (blockchain). The proofs can be verified by all parties involved in the business process and this allows them to get a <strong>consistent view</strong> of the <strong>overall process</strong> while ensuring that confidential data between certain business partners stays confidential.</p><p>Zero-knowledge cryptography can also enable confidential value transfer between multiple parties. This way <strong>payments</strong> or transfers of <strong>tokenized business assets </strong>could be performed confidential on a public blockchain.</p><h4>Immutable state machine / Blockchain</h4><p>The role of the blockchain in an intercompany transaction network is to provide an <strong>always accessible</strong> and <strong>immutable</strong> state of records of business relevant proofs.</p><h4>Company identity registry</h4><p>The company identity registry is another important piece in an ICTN because there needs to be a way to verify that a business partner really is who it claims to be. This could for example be a <strong>global registry</strong> which stores DIDs of <strong>verified companies</strong>. If you aren’t familiar with DIDs we encourage you to <a href="https://medium.com/decentralized-identity/overview-of-decentralized-identity-standards-f82efd9ab6c7">read about the <strong>decentralized identity standard</strong></a>.</p><p>Another <strong>optional component</strong> we identified is a so called “<strong>Gas Station Network</strong>”. Since a public blockchain is considered to be used the companies would need to pay for the transaction fees to store the proofs on the blockchain. We expect that many companies don’t want to hold a cryptocurrency like ETH to cover the fees. This is why relayers might be necessary which take the transactions of the companies and publish them on behalf of the companies.</p><p>Does this idea sound familiar to you? Then you probably heard or read about the <a href="https://baseline-protocol.org/"><strong>Baseline Protocol</strong></a> which has been hyped and advertised a lot in the recent weeks and months.</p><p>It was <a href="https://www.ey.com/en_gl/news/2020/03/ey-launches-baseline-protocol-an-open-source-initiative-for-the-public-etherum-blockchain">announced back in March 2020 by EY</a> and a first <a href="https://docs.baseline-protocol.org/radish34/radish34-demo">Proof of Concept</a> was developed in cooperation with Microsoft and ConsenSys.</p><blockquote><strong>“Blockchains will do for networks of enterprises and business ecosystems what ERP did for the single company.” (Paul Brody, EY)</strong></blockquote><p>If this statement by EY is correct, we cannot even begin to imagine how big this market will be.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FMnnBWQR6SVM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DMnnBWQR6SVM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FMnnBWQR6SVM%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/661e63d93deea18a122a4a8f6f906019/href">https://medium.com/media/661e63d93deea18a122a4a8f6f906019/href</a></iframe><p>Although there a still some open questions and challenges that need to be tackled we think that <strong>Baseline Protocol</strong> deserves to be hyped. We think so because we identified similar key components for our definition of an ICTN and it is an approach that can be <strong>integrated</strong> in the <strong>existing</strong> <strong>system</strong> <strong>landscape</strong> and hopefully will be seen very soon in a <strong>production environment</strong>.</p><h3>The role of 51nodes</h3><p>We are always trying to be at the forefront of the development that takes place in the crypto space and we think that the <strong>Baseline Protocol</strong> is a promising approach that can bring our vision of an intercompany transaction network into reality. Of course we will keep our eyes always open and look for other solutions.</p><p>If you are interested in learning more about this idea or you want to integrate and verify a solution like Baseline Protocol we would be pleased to assist you in your project!</p><p><a href="https://www.51nodes.io/">51nodes GmbH</a> based in Stuttgart is a provider of Crypto Economy solutions.</p><p>51nodes supports companies and other organizations in realizing their blockchain projects. 51nodes offers technical consulting and implementation with a focus on smart contracts, decentralized apps (dApps), integration of blockchain with industry applications, and tokenization of assets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=653bcd60f756" width="1" height="1" alt=""><hr><p><a href="https://medium.com/51nodes/the-role-of-blockchain-in-the-context-of-hyperautomation-653bcd60f756">The role of blockchain in the context of hyperautomation</a> was originally published in <a href="https://medium.com/51nodes">51nodes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>