<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dr. Achim Klein on Medium]]></title>
        <description><![CDATA[Stories by Dr. Achim Klein on Medium]]></description>
        <link>https://medium.com/@draklein?source=rss-d762f71cb615------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*a4nnmkKNfolvfmq8HF4_cA.jpeg</url>
            <title>Stories by Dr. Achim Klein on Medium</title>
            <link>https://medium.com/@draklein?source=rss-d762f71cb615------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 02:39:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@draklein/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[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-d762f71cb615------2</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:16 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-d762f71cb615------2</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 16:16:03 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>
    </channel>
</rss>