<?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 Thomas on Medium]]></title>
        <description><![CDATA[Stories by Thomas on Medium]]></description>
        <link>https://medium.com/@frank_h_58267?source=rss-d8ebaf559d11------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Thomas on Medium</title>
            <link>https://medium.com/@frank_h_58267?source=rss-d8ebaf559d11------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 18 May 2026 11:32:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@frank_h_58267/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[Développer sur FreeTON (1): Créer son wallet avec ft]]></title>
            <link>https://medium.com/ocamlpro-blockchain-fr/d%C3%A9velopper-sur-freeton-1-cr%C3%A9er-son-wallet-avec-ft-99c0e778c462?source=rss-d8ebaf559d11------2</link>
            <guid isPermaLink="false">https://medium.com/p/99c0e778c462</guid>
            <category><![CDATA[ocaml]]></category>
            <category><![CDATA[wallet]]></category>
            <category><![CDATA[free-ton]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Thomas]]></dc:creator>
            <pubDate>Tue, 31 Aug 2021 11:18:36 GMT</pubDate>
            <atom:updated>2021-08-31T11:18:36.906Z</atom:updated>
            <content:encoded><![CDATA[<p>Dans nos articles précédents, nous avons <a href="https://medium.com/ocamlpro-blockchain-fr/la-blockchain-freeton-5019c7fa8a2a">présenté la blockchain FreeTON</a>, et <a href="https://medium.com/ocamlpro-blockchain-fr/la-blockchain-freeton-5019c7fa8a2a">comment créer son premier compte sur FreeTON </a>en utilisant l’interface web de TON Surf. Maintenant, nous allons commencer à nous intéresser au développement de smart contracts en Solidity sur FreeTON. Pour cela, nous avons besoin de pouvoir manipuler de nombreux comptes pour déployer et tester les contrats. C’est ce que va nous permettre ft , un wallet en ligne de commande que nous avons spécialement développé pour cet usage, et bien d’autres, puisque cet outil concentre des années d’expérience sur Tezos, Dune Network et maintenant FreeTON, pour fournir aux développeurs un couteau suisse puissant, intuitif et documenté. <a href="https://ocamlpro.github.io/freeton_wallet/">La documentation complète de ft est disponible sur github</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*MnnLBebD6C5x1uU_.jpg" /></figure><h3>Installer l’outil ft</h3><p>La première étape de notre voyage consiste bien entendu à installer ft. La façon la plus rapide est d’utiliser Docker, qui permet d’exécuter ft sous Linux, Mac et Windows. Les courageux qui souhaitent bénéficier des dernières améliorations opteront pour la compilation depuis les sources avec opam.</p><h4>Installer ft avec Docker</h4><p>La manière la plus simple d’installer ft consiste à utiliser docker, <a href="https://hub.docker.com/r/ocamlpro/ft">comme indiqué ici</a>. Il est conseillé d’utiliser une version récente de docker .</p><p>Cette méthode consiste simplement à télécharger un script, et à utiliser ce script en lieu et place de ft . Le script téléchargera l’image depuis le Docker-Hub à la première exécution et se comportera ensuite simplement comme ft , avec quelques limitations mineures (pas de commande ft exec , accès aux fichiers uniquement dans les sous-répertoires).</p><p>L’image est mise à jour assez régulièrement, il suffit alors de lancer la commande docker pull ocamlpro/ft pour utiliser la dernière version.</p><h4>Installer ft avec opam</h4><p>Pour suivre le développement de ft au jour le jour, le mieux est de construire le programme depuis les sources. Cette méthode fonctionne bien sous Linux, mais n’a pas été testée sous Mac et Windows.</p><p>La méthode consiste ici à installer opam , le gestionnaire de paquets de référence de OCaml, d’ajouter <a href="https://github.com/OCamlPro/ocp-opam-repository">le dépôt des paquets d’OCamlPro</a>, puis d’installer les paquets nécessaires. Il faut aussi installer cargo , le gestionnaire de paquets de Rust, dont dépend le SDK de FreeTON. Cela donne les commandes suivantes pour préparer l’environnement:</p><pre>$ sh &lt;(curl -sL <a href="https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)">https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)</a><br>$ opam init --comp=4.10.0<br>$ opam repo add ocp git+<a href="https://github.com/OCamlPro/ocp-opam-repository">https://github.com/OCamlPro/ocp-opam-repository</a><br>$ opam update<br>$ curl --proto &#39;=https&#39; --tlsv1.2 -sSf <a href="https://sh.rustup.rs">https://sh.rustup.rs</a> | sh<br>$ opam install --deps-only ft</pre><p>Il faut ensuite installer le paquet freeton_wallet ou ft avec opam . La commande ft doit alors apparaître dans le PATH en faisant eval $(opam env) :</p><pre>$ opam install freeton_wallet<br>$ eval $(opam env)<br>$ ft</pre><p>Soit de compiler depuis les sources sur Github. La commande ft apparaît alors dans le répertoire local:</p><pre>$ git clone <a href="https://github.com/OCamlPro/freeton_wallet">https://github.com/OCamlPro/freeton_wallet</a><br>$ cd freeton_wallet<br>$ eval $(opam env)<br>$ drom build --switch 4.10.0<br>$ ./ft</pre><p>ft n’utilisant pas de fichiers externes, il est tout à fait possible de copier l’exécutable dans un endroit plus pratique, ou de créer un lien symbolique:</p><pre>$ sudo ln -s $(which ft) /usr/local/bin/ft</pre><p>Vous pourrez à tout moment consulter la liste des commandes à l’aide de ft --help :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8drRebTppUDRMTte9Z-mbQ.png" /></figure><p>Vous pouvez aussi demander de l’aide sur une sous-commande, par exemple ft account create --help :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VkltJexuuY9BSFwnlZLk3w.png" /></figure><h3>Tout wallet FreeTON est un “multisig”… ou presque !</h3><p>Dans la suite, pour un utilisateur, nous allons distinguer les termes <strong>clé</strong>, <strong>passphrase</strong>, <strong>wallet</strong>, <strong>adresse</strong> et <strong>compte</strong>.</p><ul><li>La <strong>clé</strong> d’un utilisateur est en fait une paire de clés cryptographiques, composée d’une clé secrète (ou privée) et d’une clé publique (<em>pubkey</em>); la clé secrète ne doit jamais être communiquée à quiconque; au contraire, la clé publique peut être librement partagée, elle permet aux autres utilisateurs de reconnaître cet utilisateur.</li><li>La <strong>passphrase</strong> d’un utilisateur est un ensemble de mot permettant de créer une paire de clés, secrète et publique. Elle a l’avantage de pouvoir être facilement mémorisable, ou écrite sur papier pour être stockée dans un coffre, alors que la clé secrète l’est difficilement. Comme la clé secrète, elle doit rester secrète. Sur FreeTON, la passphrase est généralement composée de 12 mots, facilement distinguables.</li><li>Un <strong>wallet</strong> est un emplacement sur la blockchain, contrôlé par la clé d’un utilisateur. De la crypto-monnaie peut y être stockée. Sur FreeTON, cet emplacement est toujours géré par un smart contract, qu’il est donc nécessaire de déployer pour pouvoir déplacer les tokens.</li><li>Une <strong>adresse</strong> est l’adresse sur la blockchain d’un wallet, qui permet d’accéder à ce wallet, au smart contract qu’il contient, et de demander des transferts de tokens. Sur FreeTON, l’adresse d’un wallet est uniquement déterminée par le clé de l’utilisateur, le code du smart contract et les données statiques du contrat.</li><li>Finalement, un <strong>compte</strong> est le nom associé par ft à une clé ou une adresse mémorisée dans son carnet de contacts. Ce nom permet de référencer une clé ou une adresse beaucoup plus facilement que leur version numérique.</li></ul><p>Sur FreeTON, l’adresse d’un wallet dépend donc du code du smart contract qu’il abrite. Pour simplifier les choses, la plupart des utilisateurs déploient un contrat standard, appelé “multisig”, pour gérer leurs tokens. Nous reviendrons plus tard sur l’ensemble des possibilités offertes par ce type de contrats, mais pour l’instant, il suffit de savoir <a href="https://github.com/tonlabs/ton-labs-contracts/tree/multisig-surf-v2/solidity/surfmultisig">qu’il s’agit quasiment toujours du contrat</a> historiquement appelé SetcodeMultisigWallet2 (et récemment renommé SurfMultisigWallet), déployé par défaut par TON Surf, et par ft avec l’option --surf .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4EkbB8MFfORIpvIZ.jpg" /><figcaption>ft permet de facilement switcher entre plusieurs réseaux FreeTON, tels que le mainnet, le testnet et les réseaux déployés localement (sandboxes)</figcaption></figure><h3>La notion de “switch” pour manipuler les réseaux</h3><p>Je suppose à présent que vous disposez d’un exécutable ft . Comme toutes les blockchains, FreeTON dispose de plusieurs réseaux: mainnet est la blockchain principale, testnet la blockchain de test… Parfois, à l’occasion de contests particuliers, de nouveaux réseaux sont déployés. C’était le cas pour le contest <a href="https://medium.com/ocamlpro-blockchain-fr/zk-snarks-freeton-et-ocamlpro-796adc323351">auquel nous avons participé</a>, un réseau prenant en charge un opérande de vérification des preuves zero-knowledge avait été déployé par la Nil Foundation.</p><p>ft permet de changer facilement d’univers sans se soucier de perdre d’informations. Il permet aussi de créer des bacs à sable ou <em>sandbox</em> dans lesquelles on peut facilement, et rapidement, déployer des contrats, tester des scénarios, et disposer d’argent de poche sans avoir à en <a href="https://ton-faucet.herokuapp.com/">demander à quiconque</a>. Ces univers sont appelés des switch et on passe de l’un à l’autre ainsi:</p><pre>$ ft switch to mainnet</pre><p>Si vous n’avez pas encore d’argent sur un compte FreeTON, ou si vous préférez commencer doucement en sandbox, vous pouvez lancer:</p><pre>$ ft switch create sandbox1</pre><p>puis</p><pre>$ ft node start</pre><p>Par défaut, une sandbox vient avec des utilisateurs user0 , user1 , etc à qui vous pouvez facilement verser des TON:</p><pre>$ ft node give user0 --amount 1000000</pre><p>Vous voilà armé(e) pour la suite.</p><h3>Créer un compte avec ft</h3><p><strong>Si vous possédez déjà un compte TON Surf:</strong></p><p>Peut-être possédez-vous déjà un compte sur FreeTON, <a href="https://medium.com/ocamlpro-blockchain-fr/premiers-pas-sur-freeton-cr%C3%A9er-son-compte-c714373d5090">par exemple sur TON Surf</a>. Dans ce cas, cela signifie que vous avez à la fois un compte (défini par votre clé privée, que vous avez probablement stockée en lieu sûr sous la forme de douze mots ou dans un Ledger) et un contrat multisig déployé (seulement si vous avez de l’argent sur ce compte) depuis ce compte, à partir duquel TON Surf calcule votre adresse. Vous pouvez facilement importer votre compte TON Surf dans ft :</p><pre>$ ft account create mon_compte --passphrase “votre passphrase” --contract SetcodeMultisigWallet2</pre><p>(mon_compte est simplement l’alias que vous souhaitez donner à votre compte.) Cela vous permet simplement de contrôler votre compte depuis ft en plus de TON Surf, et ne va rien transférer ou modifier à votre compte. Alternativement, vous pouvez ajouter votre compte “en lecture seule”:</p><pre>$ ft account create mon_compte --address &lt;une de vos adresses&gt; --surf</pre><p>Vous ne pourrez alors pas initier de transactions depuis votre compte sur ft, mais vous pourrez consulter l’état (typiquement, le solde) de votre compte.</p><p><strong>Si vous n’avez pas encore de compte:</strong></p><p>Si vous n’avez pas encore de compte, vous pouvez simplement appeler la commande:</p><pre>$ ft account create blog_example<br>[...]<br>Passphrase: &quot;produce coconut gospel observe wild bounce make sudden capital blur banana pen&quot;<br>{ &quot;public&quot;: &quot;0bbb94fc6e2876c9eda45e904e1e4fb34c0a8373bb7ea3963f6c295e6ca89b51&quot;,<br>  &quot;secret&quot;: &quot;ed9c7b590b26473ac583f63487f73495a622c4229d4e56e063d6743d39d8a7ee&quot; }<br>Key for user &quot;blog_example&quot; generated<br>Saving wallet file /home/thomas/.ft/sandbox1/wallet.json<br>Saving config file /home/thomas/.ft/config.json</pre><p>Vous pouvez voir votre clé privée sous forme hexadécimale et sous forme de “passphrase”, ainsi que votre clé publique. Vous n’avez pas encore d’adresse puisque vous n’avez pas encore créé de wallet. D’ailleurs, vous n’avez pas besoin de déployer un wallet pour connaître sa future adresse:</p><pre>$ ft account create multisig_blog_example --passphrase &quot;produce coconut gospel observe wild bounce make sudden capital blur banana pen&quot; --contract SetcodeMultisigWallet2<br>[...]</pre><pre>Account &quot;multisig_blog_example&quot; created.<br>{<br>  &quot;name&quot;: &quot;multisig_blog_example&quot;,<br>  &quot;passphrase&quot;: &quot;produce coconut gospel observe wild bounce make sudden capital blur banana pen&quot;,<br>  &quot;pair&quot;: {<br>    &quot;public&quot;: &quot;0bbb94fc6e2876c9eda45e904e1e4fb34c0a8373bb7ea3963f6c295e6ca89b51&quot;,<br>    &quot;secret&quot;: &quot;ed9c7b590b26473ac583f63487f73495a622c4229d4e56e063d6743d39d8a7ee&quot;<br>  },<br>  &quot;account&quot;: {<br>    &quot;address&quot;: &quot;0:51ea97d220272fca86bf7c85446df4d7e5e8f70891433c50ec6383f72ed02fba&quot;,<br>    &quot;contract&quot;: &quot;SetcodeMultisigWallet2&quot;<br>  }<br>}</pre><p>Lorsque mon compte recevra de l’argent, je pourrai déployer le contrat SetcodeMultisigWallet2 et mon adresse sera celle renvoyée par la commande précédente (0:51ea97d220272fca86bf7c85446df4d7e5e8f70891433c50ec6383f72ed02fba ). Vérifions-le:</p><pre>$ ft multisig create multisig_blog_example<br>[...]</pre><pre>fatal exception Deploy failed: {<br>    code:409.000000<br>    message:Account does not exist. You need to transfer funds to this account first to have a positive balance and then deploy its code<br>    data:{<br>      core_version:1.16.1<br>      account_address:0:51ea97d220272fca86bf7c85446df4d7e5e8f70891433c50ec6383f72ed02fba<br><br>     [...]<br>  }</pre><p>Le déploiement a échoué, puisque le compte n’avait pas d’argent. Par contre, on vérifie que l’adresse est bien la même qu’auparavant! Une manière plus orthodoxe de vérifier que le compte n’est pas actif:</p><pre>$ ft account info multisig_blog_example<br>[...]<br>Loading wallet file /home/thomas/.ft/sandbox3/wallet.json<br>Account &quot;multisig_blog_example&quot;: not yet created (empty balance)</pre><h3>Transférer des tokens</h3><p>Envoyons donc de l’argent à notre (futur) contrat en le parrainant avec l’option --sponsor :</p><pre>ft multisig transfer 100.000 --from user0 --to multisig_blog_example --sponsor<br>Config loaded from /home/thomas/.ft/config.json<br>Network: sandbox4<br>Loading wallet file /home/thomas/.ft/sandbox4/wallet.json<br>call: 0:108f6113fb0cad8c98b70e8ea3cfd12b52710ec20441d05ceb78cacb4f5566b7<br>method: submitTransaction<br>params: {&quot;dest&quot;:&quot;0:51ea97d220272fca86bf7c85446df4d7e5e8f70891433c50ec6383f72ed02fba&quot;,&quot;value&quot;:100000000000,&quot;bounce&quot;:false,&quot;allBalance&quot;:false,&quot;payload&quot;:&quot;&quot;}<br>signed: user0<br>MessageId: ea235abb3a2dd6adfb9ee98aa5c4bb080f1798123d45c512f4a5522b2ac4c31e<br>call result:<br>{<br>  &quot;transId&quot;: &quot;0&quot;<br>}</pre><h4>Effectuer un transfert de tokens dans FreeTON avec ft</h4><p>Dernière opération de ce tutoriel, je vais maintenant transférer de l’argent à user1 :</p><pre>$ ft multisig transfer 100.000 --from multisig_blog_example --to user1<br>[...]<br>call: 0:51ea97d220272fca86bf7c85446df4d7e5e8f70891433c50ec6383f72ed02fba<br>method: submitTransaction<br>params: {&quot;dest&quot;:&quot;0:108f6113fb0cad8c98b70e8ea3cfd12b52710ec20441d05ceb78cacb4f5566b7&quot;,&quot;value&quot;:100000000000,&quot;bounce&quot;:true,&quot;allBalance&quot;:false,&quot;payload&quot;:&quot;&quot;}<br>signed: multisig_blog_example<br>MessageId: b6a34407669008dce626d769e208f2b47feec3be17cc4cbbe92ceec71516f8b7<br>call result:<br>{<br>  &quot;transId&quot;: &quot;0&quot;<br>}</pre><p>On peut ensuite vérifier que les tokens ont bien été réceptionnés:</p><pre>$ ft account info user1</pre><h3>Conclusion</h3><p>Et voilà! Nous n’avons fait qu’effleurer la surface des possibilités de ft, mais j’espère vous avoir donné envie de l’utiliser! Les prochaines fois, nous verrons par exemple que ft:</p><ul><li>connaît des dizaines de contrats standard de FreeTON par défaut;</li><li>permet d’utiliser l’ABI des contrats pour faire des vérifications de typage au moment des appels;</li><li>permet de surveiller un contrat en direct et les transactions qui lui parviennent, et de les stocker dans une base de données;</li><li>permet de faire des substitutions complexes à la fois dans l’entrée et la sortie des appels;</li><li>permet à tout moment d’appeler tonos-cli pour lui faire exécuter l’équivalent de la commande actuelle;</li><li>permet de créer et exécuter des debots , ces “bots décentralisés” privilégiés par l’écosystème FreeTON pour interagir avec les smart contracts.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99c0e778c462" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ocamlpro-blockchain-fr/d%C3%A9velopper-sur-freeton-1-cr%C3%A9er-son-wallet-avec-ft-99c0e778c462">Développer sur FreeTON (1): Créer son wallet avec ft</a> was originally published in <a href="https://medium.com/ocamlpro-blockchain-fr">OCamlPro FreeTON FR</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OCamlPro remporte le concours FreeTON sur les Zk-SNARKs!]]></title>
            <link>https://medium.com/ocamlpro-blockchain-fr/ocamlpro-remporte-le-concours-freeton-sur-les-zk-snarks-4b8ad1314c37?source=rss-d8ebaf559d11------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b8ad1314c37</guid>
            <category><![CDATA[ocaml-pro]]></category>
            <category><![CDATA[arithmetic]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[free-ton]]></category>
            <dc:creator><![CDATA[Thomas]]></dc:creator>
            <pubDate>Tue, 31 Aug 2021 09:46:32 GMT</pubDate>
            <atom:updated>2021-08-31T09:46:32.744Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1_71HLMP6ydroXr_fbyFRA.png" /></figure><p>Le mois dernier, nous avions <a href="https://medium.com/ocamlpro-blockchain-fr/zk-snarks-freeton-et-ocamlpro-796adc323351">participé à un concours</a> d’idées et d’implémentations de <em>use-cases</em> des zk-SNARKs sur la blockchain FreeTON. Nous avons le grand plaisir d’annoncer qu’OCamlPro a obtenu la première place à ce concours!</p><h4>Anecdote mathématique et problème pour nos lectrices et lecteurs</h4><p>Pour le use-case des Sudoku (de taille 4 dans notre implémentation), j’avais choisi d’encoder et de tester l’unicité de chacun des nombres présents dans une colonne, une ligne ou une boîte par la propriété que <em>x + y + z + t = 1 + 2 + 3 + 4 = 10 </em>et le produit<em> x · y · z · t = 1 · 2 · 3· 4 = 4! = 24</em>. Il est vrai que si <em>x</em>,<em>y</em>,<em>z</em> et <em>t</em> sont des entiers entre 1 et 4, alors les ensembles <em>{ x, y, z, t }</em> et <em>{1, 2, 3, 4}</em> sont égaux. Qu’en est-il pour le Sudoku de taille 9? Peut-on se contenter de dire que la somme des 9 entiers vaut 45 et que leur produit vaut 9! pour garantir que ces 9 entiers entre 1 et 9 sont distincts?</p><p>J’ai écrit un programme pour chercher des contre-exemples, pour les premières valeurs de n (ce calcul ferait au passage un bon Project Euler!) et j’ai découvert que l’unicité de la solution est vraie jusqu’à n=8, et qu’il existe exactement un contre-exemple pour n=9 (et de plus en plus pour n plus grand). Je propose donc un petit défi pour nos lecteurs et lectrices: saurez-vous trouver ce contre-exemple de x_1, x_2, ..., x_9 de somme 45 et de produit 9! (9 factoriel)? Question bonus: Quel est le plus grand entier n pour lequel vous parvenez à calculer tous les contre-exemples en moins d’une minute?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b8ad1314c37" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ocamlpro-blockchain-fr/ocamlpro-remporte-le-concours-freeton-sur-les-zk-snarks-4b8ad1314c37">OCamlPro remporte le concours FreeTON sur les Zk-SNARKs!</a> was originally published in <a href="https://medium.com/ocamlpro-blockchain-fr">OCamlPro FreeTON FR</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zk-SNARKs, FreeTON and OCamlPro]]></title>
            <link>https://medium.com/ocamlpro/zk-snarks-freeton-and-ocamlpro-eaaa1849ffd1?source=rss-d8ebaf559d11------2</link>
            <guid isPermaLink="false">https://medium.com/p/eaaa1849ffd1</guid>
            <category><![CDATA[zksnark]]></category>
            <category><![CDATA[free-ton]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Thomas]]></dc:creator>
            <pubDate>Tue, 27 Jul 2021 12:04:20 GMT</pubDate>
            <atom:updated>2021-07-27T12:04:20.474Z</atom:updated>
            <content:encoded><![CDATA[<p>You may have heard of zk-SNARKs, the mathematical black magic enabling you, under certain conditions, to prove that you know a solution to a problem without revealing any information about that solution. Such a proof is called a <strong>zero-knowledge</strong> proof. It used to be a (mostly) theoretical amusement for cryptographers; since <a href="https://z.cash/technology/zksnarks/">Zcash</a>, it has become a very real application on blockchains. Many projects are integrating some form of zk-SNARKs, such as <a href="https://www.youtube.com/watch?v=jr95o_k_SwI">Ethereum</a>, <a href="https://tezos.gitlab.io/alpha/sapling.html">Tezos</a> or <a href="https://deck.concordium.com">Concordium</a>. The Mina project is even building <a href="https://www.youtube.com/watch?v=GvwYJDzzI-g">its entire blockchain</a> from zk-SNARKs!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*61nqIAeOLVokJ8wP2lZZuw.jpeg" /></figure><p>Last year, thanks to our in-house <a href="http://liquidity-lang.org/">Liquidity</a> programming language, <a href="https://medium.com/dune-network/experimenting-with-privacy-using-zcashs-sapling-in-liquidity-b92ae741d6e5">we had started to adapt and extend zk-SNARKs on Tezos </a>in the <a href="https://dune.network/">Dune Network</a> project which is in the process of merging with <a href="https://www.freeton.link/">FreeTON</a>. With the introduction of zk-SNARKs on FreeTON by the <a href="https://nil.foundation/">Nil Foundation</a>, it was time to get back to it! We participated in the last few weeks in <a href="https://devex.gov.freeton.org/proposal?proposalAddress=0%3Ae6b65075478e7d412fdb0870452f30dfa8bf51272e28a3167abc5c5df6fd051d">Contest 18</a>, where we had to propose applications of this technology on FreeTON smart contracts. The results are not yet known, but we are proud to tell you about our submission which contains three different applications.</p><h4>Verifying hidden Sudokus</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*tTciSY1G19nMkti18yK2Vg.png" /><figcaption>A Sudoku instance (source : Wikimedia)</figcaption></figure><p>The first one consists in a smart contract for solving Sudokus. The Sudoku is to zero-knowledge proofs what the <a href="https://medium.com/dune-network/introducing-dune-playground-part-1-free-duns-and-the-rock-paper-scissors-game-e9bcdb599e99">Rock-Paper-Scissors</a> game is to smart contracts: a simple example, <a href="https://www.youtube.com/watch?v=jr95o_k_SwI">useful to explain the concept at hand</a>, but already sufficiently annoying to pose some technical problems. In particular, we need to find an encoding of the Sudoku constraints in the form of a quadratic program (details in our <a href="https://firebasestorage.googleapis.com/v0/b/ton-labs.appspot.com/o/documents%2Fapplication%2Fpdf%2Fuaw6elz64t9kr538q99-submission.pdf?alt=media&amp;token=cc619b2f-402f-4d60-8292-57b2c9e76b65">submission</a> for the curious). Then, the principle is simple: a Sudoku instance is proposed by the contract, and the user must find a solution, generate a local zero-knowledge proof that he has found it, and submit it to the contract.</p><h4>Decentralized Infrastructure for Project Euler problems</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uwkjDXUz1sAJ0suhiL54QQ.png" /><figcaption>A screenshot of the Project Euler webpage, Problem 1</figcaption></figure><p><a href="https://projecteuler.net/">Project Euler</a> is perhaps the site where I learned the most about programming. It submits problems mixing mathematics and computer science and of varying difficulty (the first problem was solved by a million people; some have only a dozen solutions at their output). To avoid brute-force attacks, which would consist of testing all possible solutions to a problem, the site uses a system of captchas. How could one decentralize Project Euler? The two main problems are<br>1. verifying solutions without revealing them in the smart contract, either in advance in the verification function or after the answer has been submitted;<br>2. discouraging brute-forceto attempts.</p><p>Zk-SNARKs are a perfect answer to the first problem, since they allow to check a solution without revealing it. For the second problem, we have chosen the following approach: each problem is provided with a nonce. The solution stored (but obfuscated by the zk-SNARKs) in the contract is actually :</p><blockquote>SHA256¹⁰⁰⁰⁰⁰⁰(problem number | solution | nonce)</blockquote><p>Computing one million iterations of SHA256 takes about 20 seconds, which in a way emulates the captcha. This does not, however, protect against a pre-computation of all possible solutions, hence the presence of the nonce and the problem number, which makes the attacker’s task much more difficult. With this simple trick, the Project Euler submission platform can be completely decentralized!</p><h4>Recovering from a lost key using a passphrase</h4><p>Our last use case of zk-SNARKs on FreeTON is more technical: it is to propose a backup solution to change the public key controlling a FreeTON wallet. A common solution to protect oneself from the loss of a private key is the multisig, and in fact the FreeTON wallets are multisig by default. It is then a question of keeping the recovery key in a safe place, typically in a bank safe (a paradox of the cryptocurrency world…). But this is a very slow solution, to which we propose an alternative: choose a password that allows to change the public key that controls a wallet. This solution should be avoided in the absence of zk-SNARKS: the password (or its hash) can always be intercepted and reused by an attacker to hijack the wallet to his advantage. In the framework of zk-SNARKs, the zero-knowledge proof attests to the knowledge of the password coupled with the public key, so that this proof is unusable with another public key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*P9pG0ECzm7xyRz3OSRh5SA.jpeg" /></figure><h4>Conclusion</h4><p>Participating in this very fun contest allowed us to think about the different uses of zk-SNARKs on the blockchain. Although this first step is much simpler than the Z-cash applications, which are the subject of separate contests, we have already identified different categories:<br>1. Computation (a precise mathematical calculation is encoded in the zk-SNARK instance used): this is the case of Sudoku, it could have been the factorisation of an integer for example;<br>2. Static : the static answer is known, and we just check that the user knows it (possibly with a brute-force) : this is the case of Project Euler;<br>3. Protocol: The essential function of zk-SNARK can be a calculation or static, but the essential issue is to act at the protocol level by triggering transactions or modifying access rights: this is the case of Pincode.</p><p>It is easy to see that these categories are not isolated from one another, but they allow us to think about usage paradigms.</p><p>Wish us good luck for the upcoming vote and don’t hesitate to ask us questions in the comments section or on <a href="https://twitter.com/OCamlPro">twitter</a>!</p><p>— <br>If you want to know more about FreeTON, you can visit our website <a href="http://www.freeton.link">www.freeton.link</a> and try our wallet in OCaml <a href="https://ocamlpro.github.io/freeton_wallet/">ft</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eaaa1849ffd1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ocamlpro/zk-snarks-freeton-and-ocamlpro-eaaa1849ffd1">Zk-SNARKs, FreeTON and OCamlPro</a> was originally published in <a href="https://medium.com/ocamlpro">OCamlPro</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zk-SNARKs, FreeTON et OCamlPro]]></title>
            <link>https://medium.com/ocamlpro-blockchain-fr/zk-snarks-freeton-et-ocamlpro-796adc323351?source=rss-d8ebaf559d11------2</link>
            <guid isPermaLink="false">https://medium.com/p/796adc323351</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[zksnark]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ocaml-pro]]></category>
            <category><![CDATA[free-ton]]></category>
            <dc:creator><![CDATA[Thomas]]></dc:creator>
            <pubDate>Tue, 20 Jul 2021 14:28:56 GMT</pubDate>
            <atom:updated>2021-07-20T15:16:55.665Z</atom:updated>
            <content:encoded><![CDATA[<p>Vous avez peut-être entendu parler des zk-SNARKs, magie noire mathématique permettant, sous certaines conditions, de prouver que vous connaissez une solution à un problème sans révéler la moindre information sur cette solution: on appelle une telle preuve, une preuve <strong>zero-knowledge</strong>. C’était autrefois un amusement (surtout) théorique pour <a href="https://fr.wikipedia.org/wiki/Liste_de_cryptologues">cryptologues</a> ; depuis <a href="https://z.cash/technology/zksnarks/">Zcash</a>, c’est devenu une application bien réelle sur les blockchains, permettant de cacher complètement des transferts de crypto-monnaies. De nombreux projets sont en train d’intégrer une forme ou une autre de zk-SNARKs, comme par exemple <a href="https://www.youtube.com/watch?v=jr95o_k_SwI">Ethereum</a>, <a href="https://tezos.gitlab.io/alpha/sapling.html">Tezos</a> ou <a href="https://deck.concordium.com">Concordium</a>. Le projet Mina construit même <a href="https://www.youtube.com/watch?v=GvwYJDzzI-g">toute sa blockchain</a> à partir des zk-SNARKs !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*8jqQRL-m_N8Bfkzl.jpg" /></figure><p>L’année dernière, grâce à notre langage de programmation <a href="http://liquidity-lang.org/">Liquidity</a>, <a href="https://medium.com/dune-network/experimenting-with-privacy-using-zcashs-sapling-in-liquidity-b92ae741d6e5">nous avions commencé à adapter et étendre les zk-SNARKs de Tezos</a> dans la blockchain <a href="https://dune.network/">Dune Network</a>, qui est aujourd’hui en voie de fusion avec la blockchain <a href="https://www.freeton.link/">FreeTON</a>. Avec l’introduction des zk-SNARKs sur FreeTON par la <a href="https://nil.foundation/">Nil Foundation</a>, il était temps de s’y remettre ! Nous avons participé ces dernières semaines au <a href="https://devex.gov.freeton.org/proposal?proposalAddress=0%3Ae6b65075478e7d412fdb0870452f30dfa8bf51272e28a3167abc5c5df6fd051d">Contest DevEx 18</a> à l’occasion duquel nous devions proposer des applications des zk-SNARKs sur les smart contracts FreeTON. Le classement n’est pas encore connu, mais nous sommes fiers de vous présenter notre soumission qui contient trois applications différentes !</p><h4>Vérification de Sudokus Cachés</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*tTciSY1G19nMkti18yK2Vg.png" /><figcaption>Une instance de Sudoku (source: Wikimedia)</figcaption></figure><p>Notre première application consiste en un smart contract de vérification de Sudokus. Le Sudoku est un peu aux preuves zero-knowledge ce que le <a href="https://medium.com/dune-network/introducing-dune-playground-part-1-free-duns-and-the-rock-paper-scissors-game-e9bcdb599e99">Pierre-Feuille-Cisea</a>u est aux smart contracts: un exemple simple, <a href="https://www.youtube.com/watch?v=jr95o_k_SwI">utile pour expliquer le concept en question</a>, mais suffisamment embêtant pour poser déjà quelques problèmes techniques. Il faut notamment trouver un encodage des contraintes du Sudoku sous forme de programme quadratique (détails dans notre <a href="https://firebasestorage.googleapis.com/v0/b/ton-labs.appspot.com/o/documents%2Fapplication%2Fpdf%2Fuaw6elz64t9kr538q99-submission.pdf?alt=media&amp;token=cc619b2f-402f-4d60-8292-57b2c9e76b65">soumission</a> pour les curieux). Ensuite, le principe est simple: une instance de Sudoku est proposée par le contrat, et l’utilisateur doit trouver une solution, générer localement une preuve zero-knowledge qu’il l’a trouvée, et la soumettre au contrat. Ainsi, il prouve qu’il l’a résolu, sans fournir la solution aux autres utilisateurs !</p><h4>Infrastructure pour le Projet Euler</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uwkjDXUz1sAJ0suhiL54QQ.png" /><figcaption>Un screenshot de Project Euler, Problème numéro 1</figcaption></figure><p><a href="https://projecteuler.net/">Project Euler</a> est peut-être le site sur lequel j’ai le plus appris à programmer. Il soumet des problèmes mêlant mathématiques et informatique et de difficulté très variable (le premier problème a été résolu par un million de personnes ; certains n’ont qu’une dizaine de solutions à leur sortie). Pour éviter les attaques brute-force qui consisteraient à tester toutes les solutions possibles à un problème, le site utilise un système de captchas. Comment décentraliser Project Euler ? Les deux problèmes principaux résident</p><ol><li>dans la vérification des solutions sans les révéler dans le smart contract, soit à l’avance dans la fonction de vérification, soit par la suite après la soumission de la réponse ;</li><li>dans le fait de décourager le brute-force.</li></ol><p>Les zk-SNARKs sont une réponse parfaite au premier problème, puisqu’ils permettent de vérifier une solution sans la révéler. Quant au second problème, nous avons choisi l’approche suivante : chaque problème est muni d’un nonce aléatoire à sa création. La solution stockée (mais obfusquée par les zk-SNARKs) dans le contrat est en réalité :</p><blockquote>SHA256¹⁰⁰⁰⁰⁰⁰(numéro du problème | solution | nonce)</blockquote><p>Calculer un million d’itérations de SHA256 prend environ 20 secondes, ce qui émule en quelque sorte le captcha. Cela ne protège pas, en revanche, contre un pré-calcul de toutes les solutions possibles, d’où la présence du nonce et du numéro de problème qui compliquent singulièrement la tâche de l’attaquant. Par ce simple tour de passe-passe, on peut complètement décentraliser la plate-forme de soumission de Project Euler!</p><p>Au final, notre solution permet de facilement créer de nouveaux problèmes en ligne, d’obtenir pour chaque problème un TOP10 des premiers à l’avoir résolu, et de conserver, pour chaque utilisateur, la liste de tous les problèmes qu’il a résolu… sans jamais qu’aucune solution ne soit révélée !</p><h4>Récupération de la Perte d’une Clé Secrète via une Passphrase</h4><p>Notre dernier cas d’utilisation des zk-SNARKs sur FreeTON est plus technique : il s’agit de proposer une solution de secours pour changer de clé publique quand on a perdu la clé secrète correspondante. Une solution commune pour se prémunir de la perte d’une clé privée est le multisig, et d’ailleurs les wallets FreeTON sont multisig par défaut. Il s’agit alors de conserver en lieu sûr, typiquement dans le coffre-fort d’une banque (c’est un paradoxe du monde des cryptomonnaies…) la clé de récupération. Or c’est une solution compliquée à mettre en oeuvre, lente à récupérer, qu’au final, peu de gens prennent le temps de mettre en place… prenant ainsi des risques considérables !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*WdpRGfvI1xtRwCye.jpg" /></figure><p>Nous proposons donc une alternative simple et pratique à base de sk-SNARKs : choisir un mot de passe permettant de changer la clé publique qui contrôle un wallet, et n’importe quel contrat compatible. Cette solution est à proscrire en l’absence des zk-SNARKS: le mot de passe (ou son hash) pourrait être intercepté et réutilisé par un attaquant pour détourner le wallet à son avantage. Dans le cadre des zk-SNARKs, la preuve zero-knowledge atteste la connaissance du mot de passe <strong>couplée</strong> avec la clé publique, de sorte que cette preuve est inutilisable avec une autre clé publique.</p><h4>Conclusion</h4><p>Participer à ce contest au demeurant très amusant nous a permis de réfléchir aux différentes utilisations des zk-SNARKs sur la blockchain. Bien que cette première étape reste beaucoup plus simple que les applications à la Z-cash, qui font l’objet de contests séparés, nous avons déjà identifié différentes catégories :</p><ol><li>Calcul (un calcul mathématique précis est encodé dans l’instance de zk-SNARK utilisée) : c’est le cas du Sudoku, ça aurait pu être la factorisation d’un entier par exemple ;</li><li>Statique : la réponse statique est connue, et on se contente de vérifier que l’utilisateur la connaît (en se prémunissant éventuellement d’un brute-force): c’est le cas du Project Euler ;</li><li>Protocole : L’essentiel de la fonction du zk-SNARK peut être un calcul ou statique, mais l’enjeu essentiel est d’agir au niveau du protocole en déclenchant des transactions ou en modifiant des droits d’accès : c’est le cas du Pincode.</li></ol><p>On voit aisément que ces catégories ne sont pas imperméables entre elles, mais elles permettent de penser des paradigmes d’utilisation.</p><p>Souhaitez-nous bonne chance pour le vote à venir et n’hésitez pas à nous poser des questions en commentaire ou sur <a href="https://twitter.com/OCamlPro">twitter</a>!</p><p>Si vous voulez en savoir plus sur FreeTON, vous pouvez notamment aller voir notre site <a href="http://www.freeton.link">www.freeton.link</a> et essayer notre wallet en OCaml <a href="https://ocamlpro.github.io/freeton_wallet/">ft/freeton_wallet</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=796adc323351" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ocamlpro-blockchain-fr/zk-snarks-freeton-et-ocamlpro-796adc323351">Zk-SNARKs, FreeTON et OCamlPro</a> was originally published in <a href="https://medium.com/ocamlpro-blockchain-fr">OCamlPro FreeTON FR</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Premiers pas sur FreeTON : créer son compte]]></title>
            <link>https://medium.com/ocamlpro-blockchain-fr/premiers-pas-sur-freeton-cr%C3%A9er-son-compte-c714373d5090?source=rss-d8ebaf559d11------2</link>
            <guid isPermaLink="false">https://medium.com/p/c714373d5090</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[free-ton]]></category>
            <category><![CDATA[wallet]]></category>
            <dc:creator><![CDATA[Thomas]]></dc:creator>
            <pubDate>Thu, 20 May 2021 20:18:48 GMT</pubDate>
            <atom:updated>2021-05-21T08:09:24.981Z</atom:updated>
            <content:encoded><![CDATA[<h3>Premiers pas sur FreeTON : créer son compte</h3><p>Après notre <a href="https://medium.com/ocamlpro-blockchain-fr/la-blockchain-freeton-5019c7fa8a2a">premier article sur la blockchain FreeTON</a>, nous allons vous montrer comment créer votre compte et comment le gérer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NDxZQ2XCn9zxDf9C.jpg" /><figcaption>Jean-François Millet (1814–1875), Les Premiers Pas, pastel sur papier</figcaption></figure><p>Il existe plusieurs logiciels (wallets) pour gérer ses tokens:</p><ul><li><a href="https://beta.ton.surf/">TON Surf </a>est probablement le plus utilisé. Ce wallet développé et maintenu par <a href="https://tonlabs.io/main">TON Labs</a> existe en plusieurs variantes : web, mobile, sur Android, mais hélas pas encore sur iOS en France. Il présente l’avantage de supporter les DeBots, une fonctionalité spécifique à Free TON dont nous parlerons dans nos prochains articles ;</li><li><a href="https://chrome.google.com/webstore/detail/extraton/hhimbkmlnofjdajamcojlcmgialocllm">ExtraTON</a> est une extension de navigateur, comme Metamask, pour l’instant uniquement disponible sur Google Chrome.</li><li><a href="https://l1.broxus.com/freeton/wallet">TON Crystall Wallet</a> est un wallet desktop, développé par <a href="https://broxus.com/">Broxus</a>, qui permet de facilement staker (investir) ses tokens.</li><li>Pour la ligne de commande, il y a le choix entre <a href="https://github.com/tonlabs/tonos-cli">tonos-cli, le client officiel,</a> relativement difficile au premier abord, et <a href="https://github.com/ocamlpro/freeton_wallet">notre wallet orienté développeur</a> ft , dont nous aurons l’occasion de parler plus amplement dans de prochains articles.</li></ul><p>Dans ce tutoriel, nous allons utiliser la version web de TON Surf, qui présente le plus de potentiel à notre goût. (Si vous l’utilisez en français, vous pourrez apprécier la saveur particulière des traductions, exotiques mais toujours compréhensibles, depuis le russe.)</p><h3>Important</h3><p>En l’absence de support pour les Hardware Wallets de type Ledger, Free TON utilise des “passphrases” (BIP39) pour générer les clés secrètes et adresses correspondantes. Il sera indispensable, dans le suite, <strong>de sauvegarder cette liste de 12 mots correspondant à votre clé secrète, hors de votre ordinateur et loin de tout regard</strong>, pour pouvoir récupérer vos tokens à tout moment depuis n’importe où.</p><h3>Le wallet web TON Surf</h3><p>Rendez-vous sur <a href="https://web.ton.surf/settings/">web.ton.surf/settings</a>. La page suivante doit s’afficher :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RN0aakLoAEDhE6pjmwSeWQ.png" /></figure><p>Cliquez sur “Créer un portefeuille”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SAW7MWSdlMCMAU22wmb0fQ.png" /></figure><p>Free TON met la décentralisation au centre de sa vision. Les créateurs de ce wallet vous demandent de signaler votre accord en signant cette charte. Lisez-la et confirmez votre accord.</p><p>Avant que TON Surf ne génère notre clé secrète et le compte associé, nous allons entrer un code PIN de 6 chiffres qui permettra de le conserver sur cet ordinateur et de le protéger d’autres utilisateurs. Il faut donc entrer ce code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*teORvOPqq-mUpO_pRupkCQ.png" /></figure><p>puis le confirmer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RtTkHcHeWsCbemjok7sPgQ.png" /></figure><p>Cela étant fait, le wallet génère votre clé secrète, et vous accédez à la page d’accueil de votre compte nouvellement créé :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RKqm9HbASdcetA2C7i0BfQ.png" /></figure><p>Nous ne possédons pour l’instant pas de tokens.</p><p>L’important, pour l’instant, est de sauvegarder la passphrase, ou clé maître. Pour cela, sur cette page “Paramètres”, cliquez sur l’option “Protection de sécurité”.</p><p>Dans ce menu, on peut accéder à son adresse avec l’option “Adresse et clés” :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cYqTarmQrcJ4uQAjYjDqqw.png" /></figure><p>L’adresse de votre compte est celle qui commence par 0: puis une suite de 64 caractère hexadécimaux. Enregistrer cette adresse pour plus tard, c’est elle qui vous communiquerez à vos contacts pour qu’ils vous transfèrent des tokens.</p><p>Maintenant, revenons dans l’onglet “Protection de sécurité”, et cliquez sur “Mot de passe principal” (“Master password” si votre interface est en anglais). Le wallet vous demande de fournir votre PIN de 6 chiffres pour pouvoir y accéder. Il affiche alors la liste de 12 mots qui composent votre passphrase. Sauvegardez là sur un papier, que vous conserverez dans un endroit sûr (coffre fort, etc.). Encore une fois, elle vous sera <strong>indispensable</strong> (mathématiquement indispensable, et pas juste pour prouver votre identité à quelqu’un: personne ne pourra la retrouver avec toutes les ressources du monde) si vous changez d’ordinateur par exemple, et elle constitue la seule garantie d’accès à votre compte.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jnLxNnTS6Y_lY3a0xRg1Vg.png" /></figure><p>Nous vous recommandons de suivre le processus d’enregistrement de de révérification: notez votre mot de passe sur un papier:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*08lD4wy-vbsV5N8KOxVGIg.png" /></figure><p>Appuyez sur <strong>Enregistré. Revérifier</strong> et réécrivez manuellement votre mot de passe principal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*METi74IiVbYqdWjGlq9KTA.png" /></figure><p>Et voilà! Vous avez maintenant en votre possession les deux informations les plus importantes:</p><ul><li>une adresse de portefeuille sur laquelle recevoir et transférer des tokens</li><li>la passphrase permettant de retrouver cette adresse depuis n’importe quel autre ordinateur (ou si vous oubliez votre code PIN…)</li></ul><p>Nous allons voir dans nos prochains articles comment aller plus loin, d’une part à travers la délégation des tokens aux validateurs, d’autre part à travers l’utilisation de ft , notre wallet en ligne de commande, pour les développeurs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c714373d5090" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ocamlpro-blockchain-fr/premiers-pas-sur-freeton-cr%C3%A9er-son-compte-c714373d5090">Premiers pas sur FreeTON : créer son compte</a> was originally published in <a href="https://medium.com/ocamlpro-blockchain-fr">OCamlPro FreeTON FR</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Origins of Spice: lessons learned in smart contract development (Part I)]]></title>
            <link>https://medium.com/dune-network/origins-of-spice-lessons-learned-in-smart-contract-development-part-i-9d8b1a6c4cff?source=rss-d8ebaf559d11------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d8b1a6c4cff</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[dune-networks]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[dapps]]></category>
            <dc:creator><![CDATA[Thomas]]></dc:creator>
            <pubDate>Tue, 17 Nov 2020 08:29:07 GMT</pubDate>
            <atom:updated>2020-11-17T08:29:07.696Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This post is the first in a series about our in-house, </em><a href="https://en.wikipedia.org/wiki/Eating_your_own_dog_food"><em>dog-fed</em></a><em> tool: Dune Spice. Are you interested in having the Spice’s accumulated expertise ported to your blockchain/language? Then get in touch! We’ll be releasing Spice very soon!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qxc2JGume-C_8FCM86tnlw.jpeg" /></figure><p>When I started writing smart contracts, I assumed it would be just like any other programming task. You have your world computer, the blockchain. You write entrypoints which receive money, compute stuff and possibly send back some money. You stare really hard at the program once written, test it, maybe even prove it correct to some extent. In return, you get a sort of unbreakable vending machine that people can trust because it does exactly what its code tells it. End of story?</p><p>Well, not all your users will be keen on writing command line calls to your dapp. Perhaps then, you’ll want to build a front-end: a webapp. This webapp is going to need to interact with the blockchain constantly, either to query its state or to send transactions.</p><p>So, for the sake of usability, you’re going to want to replicate the on-chain data structures in your webapp, and sync it with the blockchain. You’ll probably need to do some of that in the back-end. Maybe you’re running a <a href="https://playground.dune.network/dune-raffle.php">raffle</a>, and you need to periodically insert a secret number into it, and, later, you need to reveal it? You need to crawl the blockchain for transactions to and from your smart contract, in order to monitor what’s going on.</p><p>What I’m getting at is you’ll probably need to duplicate a lot of code, in several programming languages (say Liquidity, OCaml and Javascript in our case). Smart contracts are hard to get right. You need performance and security because this piece of code will be on-chain forever, manipulating people’s money. Odds are you’re going to have to make lots of small to big changes all the way until the last stages. Every time, you’ll need to modify at least three code-bases to propagate these changes. What could go wrong?!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pA88Eat5f7qLmgE5xHDJOA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@dexezekiel?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Dex Ezekiel</a> on <a href="https://unsplash.com/s/photos/confused?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>It is dangerous to do things this way, this much is clear. But what I’ve learned from actually developing and deploying smart contracts is that it’s also really, really tedious. My bet is that this is playing a big part in why smart contract development has not taken off as much as one might have imagined a few years ago. And when it has, spectacular bugs have occurred (at this point, I don’t think I even make a list of links to the horror stories out there!).</p><h3>Dogfooding Spice</h3><p>In response to both the tedium and the anxiety of getting things wrong, we started developing our own internal tool for smart contract development. Every time we wrote a new smart contract, we automated some parts of what had been done in the previous one. First, it was about scripting simple scenarios: deploy your contract, memorize its address, make some calls to it. Next, we wanted to be able to generate a simple Dapp directly from the smart contract source code. For this, we used OCaml’s outstanding fitness for programming languages manipulation. Our code would automatically spit out OCaml and Javascript interfaces to our contracts. Now, every time there was a change to a contract, we could just re-generate our dapp and get nice, readable type errors wherever we had broken things.</p><p><em>But wait!</em> If our contracts were now basically OCaml interfaces, we could do so much more than just script a smart-contract deployment and a few calls! We could write full-fledged scenarios, check invariants automatically, use property-based testing (speaking of which, check out <a href="https://medium.com/blockchain-academy-network/preventing-an-8m-attack-on-ethereums-bzx-defi-platform-with-property-based-testing-12234d9479b7">this beautiful post from the Concordium Blockchain centre</a>).</p><p>We built all these features into a tool we call Spice, whose release is imminent. Spice is the reason we’ve been able to<a href="https://medium.com/dune-network/experimenting-with-privacy-using-zcashs-sapling-in-liquidity-b92ae741d6e5"> port Tezos’ zk-snarks to Dune Network</a>, right as development was being made public. Using Spice, we delivered the <a href="http://playground.dune.network/">Dune Playground game platform</a>. We’re also using it to develop <a href="https://medium.com/dune-network/dune-network-defi-1-introducing-oasis-4cadaf3695f2">Dune Oasis</a> in record time, as well as another, major ongoing project!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*acJaDoh-GNelqPKlPTtGQA.png" /></figure><p>Our dedicated team of nine have developed many other awesome tools for Tezos and/or Dune Network. The <a href="https://medium.com/@tzscan/tzscan-is-dead-long-live-dunscan-6328506ec239">Dunscan block explorer</a> pioneered UIs for Proof-of-stake. The <a href="https://www.liquidity-lang.org/">Liquidity</a> and <a href="https://medium.com/dune-network/love-a-new-smart-contract-language-for-the-dune-network-a217ab2255be">Love</a> smart contract languages, made by our PhDs in programming languages, are both <a href="https://www.liquidity-lang.org/edit/?">readable</a> and strongly-typed. The <a href="https://medium.com/dune-network/dune-metal-lets-get-ready-to-rock-48783d389114">Metal browser extension</a> is a simple and elegant way to interact with dapps in the browser. <a href="https://medium.com/dune-network/tezos-irmin2-vs-dune-ironmin-8146ee28749e">The IronMin storage library has brought massive performance improvements on vanilla Tezos storage</a>. We have <a href="https://medium.com/dune-network/a-solidity-parser-in-ocaml-with-menhir-e1064f94e76b">ported the Solidity programming language to OCaml</a> and are currently testing it <a href="https://medium.com/dune-network/solidity-lands-on-the-dune-network-ea5f5aa15ff2">on the Dune Network</a>. The list goes on!</p><p>We’re constantly innovating from the ground up, developing our own smart contracts and learning the pain points! At the same time, we’re reliably delivering tools and services for the public and our clients. In the next post, we’ll go into more detail about the inner workings of Spice. I will open-source it, and detail exciting prospects for the future with Solidity integration and more formal methods. Please get in touch if you’re interested in getting Spice for other smart contract languages/blockchains!</p><h3>Join the #duniverse:</h3><p>Discord: <a href="https://discord.gg/JBUGqFg">https://discord.gg/JBUGqFg</a><br>Telegram: <a href="https://t.me/dune_network">https://t.me/dune_network</a><br>Medium: <a href="https://medium.com/dune-network">https://medium.com/dune-network</a><br>Twitter: <a href="https://twitter.com/dune_network">https://twitter.com/dune_network</a><br>Reddit: <a href="https://www.reddit.com/r/dune_network/">https://www.reddit.com/r/dune_network/</a><br>Gitlab: <a href="https://gitlab.com/dune-network">https://gitlab.com/dune-network</a><br>Website: <a href="https://dune.network/">https://dune.network</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d8b1a6c4cff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dune-network/origins-of-spice-lessons-learned-in-smart-contract-development-part-i-9d8b1a6c4cff">Origins of Spice: lessons learned in smart contract development (Part I)</a> was originally published in <a href="https://medium.com/dune-network">Dune Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Dune Playground — Part 2: DGG Token and Moonshot Game]]></title>
            <link>https://medium.com/dune-network/introducing-dune-playground-part-2-dgg-token-and-moonshot-game-3617332127e8?source=rss-d8ebaf559d11------2</link>
            <guid isPermaLink="false">https://medium.com/p/3617332127e8</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[games]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[technical]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Thomas]]></dc:creator>
            <pubDate>Thu, 18 Jun 2020 13:21:30 GMT</pubDate>
            <atom:updated>2020-06-19T11:09:55.054Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introducing Dune Playground — Part 2: DGG Token and Moonshot Game</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMKN_hEvgbOJ8wJbV7BJFQ.png" /></figure><h3>TL;DR</h3><blockquote><a href="https://playground.dune.network/">Explore Dune Playground website</a> and discover our new <a href="https://playground.dune.network/moonshot+server.php">Dune Moonshot game</a>!</blockquote><p>In <a href="https://medium.com/dune-network/introducing-dune-playground-part-1-free-duns-and-the-rock-paper-scissors-game-e9bcdb599e99">the first part</a> of “Introducing Dune Playground”, we set up the Dune Metal extension, got some free $DUN and played Rock-Paper-Scissors. Recall that we earned tokens, called DGG (for Dune Good Game), and I promised I would explain how these can be converted back into $DUN. Some of you actually figured out how to do it, as demonstrated by some transactions on DunScan.</p><h3>The DGG token</h3><p>Think of it as a Casino chip, except that we never ask you to spend it to be able to play our games: you will only receive it as a reward for playing. You can convert them to $DUN coins, or alternatively keep them as proof of your gaming skills.</p><p>The DunScan block explorer handles <a href="https://medium.com/dune-network/fungible-token-standard-1b062973d834">fungible tokens</a> <em>à la</em> ERC-20 (written in Michelson or in Love languages) such as DGG. If you go search your address in DunScan after playing Rock Paper Scissors from the previous tutorial, you will notice a new tab called “Tokens”. Clicking on the “Tokens” tab, we get a summary of transactions involving the DGG token for your address:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sgrakwXvnLdOMI6BGzfoHA.png" /></figure><p>Handily, the <a href="https://playground.dune.network/dgg-token.php">Dune Playground provides a special page</a> for converting your DGG to $DUN if you wish, at the current rate of 20 DGG for 1 $DUN. For this, you need to send your DGG tokens to the <a href="https://dunscan.io/KT1HfsPEKiftJvexbFuTUPevW4o48JkC49aU">address of the exchange contract</a>, which will in return send back the corresponding amount of $DUN to your address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*re5pXi6_7w0wQGyJ3UVppA.png" /></figure><p>As shown below, you can simply click on the exchange address at the bottom of the page, or copy it here: <strong>KT1HfsPEKiftJvexbFuTUPevW4o48JkC49aU. </strong>Input any whole amount of DGG between 1 and your current amount (in my case, 10), and then click “Send”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M13JQhbZnUD9RzmBQzSlIQ.png" /></figure><p>Just like last time, after approving the transaction, you will see the hash of a transaction that has been injected by Metal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jFDPF8XnNiyGeKXDoKEK6Q.png" /></figure><p>The DGG transaction will appear in the “Tokens” section of your account on DunScan:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z9J1tvXNtlXwpgtAR7Tkzw.png" /></figure><p>Then, you will receive your $DUN (in my case, .5 $DUN):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*su3sP0M5YX-rVUqjtFjulw.png" /></figure><p>Now that you know how to cash out, let’s play a more exciting game than Rock Paper Scissors.</p><h3>Play Dune Moonshot</h3><p>You’re trying to send a rocket to the Moon, set at the realistic distance of 8 kilometers from the Earth. It may reach the moon, in which case you will make 34 DGG. Or it may blow up before. You can decide to jump off the rocket at any whole number of kilometers between 1 and 8. As long as you jump before it explodes, you earn an amount of DGG that depends on how many kilometers you already went.</p><p>Here is the welcome screen of Moonshot inside the Dune Playground.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D5JDt71ozDrELJG37Hr9bw.png" /></figure><p>Let’s say we guess 3 and click send.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ODhUjqSZxvaCWcnWlJ9xA.png" /></figure><p>The operation is then injected in the blockchain and Dune Playground will monitor its inclusion:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y3ju4jsnuVtcQjKk5Bghsw.png" /></figure><p>As usual, we can follow the operation on the blockchain with DunScan blocks explorer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2wUnAi-cvBn26jWZff66Ag.png" /></figure><p>Nice! My guess is not greater than the oracle’s value. I jumped before the rocket explodes :-). For this move, I earned 3 DGG:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p00t2ueU-VtrsUZoghdcXQ.png" /></figure><p>Will you be able to bet 8 and win ? In which case you’d earn 34 DGG ? In fact, you may want to know that the rewards map is as follow:</p><ul><li>lost game 🠆 earn 1 DGG</li><li>bet 1 and win 🠆 earn 1 DGG</li><li>bet 2 and win 🠆 earn 2 DGG</li><li>bet 3 and win 🠆 earn 3 DGG</li><li>bet 4 and win 🠆 earn 5 DGG</li><li>bet 5 and win 🠆 earn 8 DGG</li><li>bet 6 and win 🠆 earn 13 DGG</li><li>bet 7 and win 🠆 earn 21 DGG</li><li>bet 8 and win 🠆 earn 34 DGG</li></ul><p>Do you recognize Fibonacci sequence here ? :-)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EwSaqnONZkr_uhDEnkLpbA.png" /></figure><p>Have fun playing and come back soon for more games and technical details!</p><h3>Connect with us:</h3><p><strong>Discord: </strong><a href="https://discord.gg/JBUGqFg">https://discord.gg/JBUGqFg</a><br><strong>Telegram: </strong><a href="https://t.me/dune_network">https://t.me/dune_network</a><br><strong>Medium: </strong><a href="https://medium.com/dune-network">https://medium.com/dune-network</a><br><strong>Twitter: </strong><a href="https://twitter.com/dune_network">https://twitter.com/dune_network</a><br><strong>Reddit: </strong><a href="https://www.reddit.com/r/dune_network/">https://www.reddit.com/r/dune_network/</a><br><strong>Gitlab: </strong><a href="https://gitlab.com/dune-network">https://gitlab.com/dune-network</a><br><strong>Website: </strong><a href="https://dune.network/">https://dune.network</a><br><strong>Email: </strong><a href="mailto:contact@dune.network">contact@dune.network</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3617332127e8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dune-network/introducing-dune-playground-part-2-dgg-token-and-moonshot-game-3617332127e8">Introducing Dune Playground — Part 2: DGG Token and Moonshot Game</a> was originally published in <a href="https://medium.com/dune-network">Dune Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Dune Playground — Part 1: Free DUNs and the Rock-Paper-Scissors Game]]></title>
            <link>https://medium.com/dune-network/introducing-dune-playground-part-1-free-duns-and-the-rock-paper-scissors-game-e9bcdb599e99?source=rss-d8ebaf559d11------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9bcdb599e99</guid>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[games]]></category>
            <category><![CDATA[community]]></category>
            <category><![CDATA[dune-networks]]></category>
            <dc:creator><![CDATA[Thomas]]></dc:creator>
            <pubDate>Wed, 03 Jun 2020 13:01:29 GMT</pubDate>
            <atom:updated>2020-06-03T13:33:32.162Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introducing Dune Playground — Part 1: Free DUNs and the Rock-Paper-Scissors Game</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*ljhQaiIicawICRAD-JBqVg.png" /></figure><p>We are happy to introduce the Dune Playground! It is intended<br>both as a place where <strong>anyone can play games</strong> and <strong>earn tokens while<br>playing</strong>, and a showcase for developers to learn how to write DApps for Dune Network. This tutorial is intended for a wide audience and will walk you through the steps to install Dune Metal, get free $DUN tokens and use them to play the Rock-Paper-Scissors game.</p><p>The playground website can be found here: <a href="https://playground.dune.network/">playground.dune.network/</a></p><h3>1. Installing the Dune Metal extension</h3><p>In order to use it, you will first need to install the <a href="https://metal.dune.network">Dune Metal browser extension</a>, an in-the-browser wallet to secure your secret key. Metal will sign your transactions to the blockchain during the game, and will allow you to receive rewards and move them between accounts.</p><p>If you already have Metal installed and configured (or if you just want to get some free $DUNs), you can go directly to section 2. Otherwise, in any of the four supported browsers (Chromium, Firefox, Brave and Chrome), head to the <a href="https://metal.dune.network">Dune Metal webpage</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pdFlUdWPEIe7kX8q5dNMbw.png" /><figcaption>Dune Metal homepage</figcaption></figure><p>Click “download”. Depending on your browser, you will be taken to different pages. We only deal with Firefox and Chrome here, the other ones are similar to Chrome.</p><h4>In Firefox</h4><p>Click “Add to Firefox” and then “Add” in the popup window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IwbgcVp52E8V_-29z36HHg.png" /></figure><p>Go below to see how to setup Metal.</p><h4>In Chrome</h4><p>Click “Add to Chrome” and then “Add extension” in the popup window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zFsef-ZFr4s2Oi_Ron0oWQ.png" /></figure><h4>Setting up Metal</h4><p>In both browsers, you will land on a setup page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iIzdc0jAVdjS0jBycbO3XA.png" /></figure><p>Read the instructions at your convenience and click next until you get to the page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lDXqFMk_Mh5_DXr54mx21g.png" /></figure><p>Unless you already have a Dune Network account that you want to use with Metal, you will want to create a new account. Anyway, Metal can manage multiple accounts if you want:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YK4QvdA2n4iVRzTCnpaMcA.png" /></figure><p>Metal generates a mnemonic which is a word representation of the secret key which controls your account. Write it down somewhere safe, and then proceed with “I wrote down my mnemonic”. Optionally choose a password, and you’re all set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e_qNLLFjY-r7NjKMNiJEpw.png" /></figure><p>You don’t have any DUN for now, and your account has not been “revealed” to the wide world, meaning that it only exists as a number on your computer for now (unless you restored your personal account on Metal).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3sAs_BV3yY5QSJG81SRdpQ.png" /></figure><p>Let us remedy these two problems by getting some free $DUN and playing a game of Rock Paper Scissors.</p><h3>2. Get Free $DUN Tokens</h3><p>Even though all games on the Dune playground are free to play, you will need a little $DUN just to reveal your fresh account and to pay for fees (if the games’ smart contract doesn’t pay fees for you). We have set up a simple page where you may retrieve 0.3 $DUN every 20 minutes.</p><p>Head to the <a href="https://playground.dune.network/free-duns.php">Dune Playground</a>, our game area:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MwXA94dbl3TP5AKlyA5bow.png" /></figure><p>Click on “Get Free $DUN”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Droz_uIhIrphPGaPsfmSQ.png" /></figure><p>The Get-Free-DUNs DApp respectfully requests your permission for Dune Metal to interact with it. Approve it by clicking the green check. Your address is automatically filled in the input box of the $DUN faucet. Click “Get free $DUN” and fill the captcha. If you don’t have Metal installed or you want to airdrop another dn1 wallet, just provide the address you’d like to airdrop in the text area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iVs4me5bsXVKV0qizuP40w.png" /></figure><p>It should only take a couple of minutes (a couple of blocks on the blockchain) for you to receive your free $DUN to appear in Metal. You can also check out the <a href="https://dunscan.io/">Dunscan</a> block explorer and type your address (you can find it in the Metal icon on the top right of your browser, or in the “Get Free $DUN” input box) in the search bar to monitor the incoming transaction. Eventually you receive 0.3 $DUN:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BmgLIeAJeM0n-QCxEQvlhA.png" /></figure><p>You’re now ready to play a game of Rock-Paper-Scissors.</p><h3>3. Playing Rock Paper Scissors on Dune</h3><p>In the Dune Playground home page, click “Play Rock Paper Scissors”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5JNMjJCdPqw6S0kGYKOnJw.png" /></figure><p>You may be wondering why we chose this game as a first example. It turns out historically, it was one of the first “simple enough that everyone understands the game, hard enough that everybody gets it wrong the first time” examples of smart contracts <a href="https://eprint.iacr.org/2015/675.pdf">studied</a> by <a href="https://eprint.iacr.org/2015/460.pdf">researchers</a>. This gives it a bit of a <a href="https://en.wikipedia.org/wiki/%22Hello,_World!%22_program">Hello world</a> (ok, maybe <a href="https://www.hackerrank.com/challenges/fizzbuzz/problem">FizzBuzz</a>) feel as far as DApps go. In this case, an oracle has already chosen moves that it has committed to (using a hash). Uncheck “Pay fees for me if possible” (only this first time, so your address is revealed). Choose one of Rock, Paper, or Scissors and click on it. You get a transaction request from Metal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8RsQKs7weOO3m0paMjn4ag.png" /></figure><p>Note that the amount of the transaction is 0 $DUN, but the fee is something like ~ 0.011 $DUN. This fee is used to pay for the transaction to be included in the blockchain. As explained above, once you send this one transaction, all future calls to the Dune Playground games can have their fees paid for by the contract itself, thanks to our <a href="https://medium.com/dune-network/collect-calls-76fb0e69a2f8">novel “collect-call” feature</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lskxwLsf-UPlh9zLQuKcMg.png" /></figure><p>Once you send the transaction, notice the message saying “Latest choice injected with hash …” at the bottom. You may click on the link and, if the operation has been included into the blockchain (on average it takes one minute), you will see inside <a href="https://dunscan.io">Dunscan</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lbV5oR9OaIpm2Bt-zz6p3w.png" /></figure><p>(Bonus: if you click on the “Yes” link under “Params” at the bottom of the page, you will actually see your move encoded in the transaction)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yHo-uMbolFVvTm1JypSxZQ.png" /></figure><p>Going back to the Rock Paper Scissors page, you will see that the current game is marked as “Ongoing”. Your transaction has been included, the oracle is now proceeding to reveal its move (which was already set in stone before you played, thanks to hash commitments). And..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dvezpSSwaGOcxoj2Dp6aMA.png" /></figure><p>Well, I lost. I’m sure you’ll do better. But I still get 1 DGG token for my trouble. These are in-house tokens for the Dune Playground, which may be earned by playing games and even sold for $DUN! We will expand on these two aspects next time. Thanks for playing, have fun!</p><p>Last, but not least, don’t hesitate to give your feedback, to spread the word, to contribute or to report bugs.</p><h3>Connect with us:</h3><p><strong>Discord: </strong><a href="https://discord.gg/JBUGqFg">https://discord.gg/JBUGqFg</a><br><strong>Telegram: </strong><a href="https://t.me/dune_network">https://t.me/dune_network</a><br><strong>Medium: </strong><a href="https://medium.com/dune-network">https://medium.com/dune-network</a><br><strong>Twitter: </strong><a href="https://twitter.com/dune_network">https://twitter.com/dune_network</a><br><strong>Reddit: </strong><a href="https://www.reddit.com/r/dune_network/">https://www.reddit.com/r/dune_network/</a><br><strong>Gitlab: </strong><a href="https://gitlab.com/dune-network">https://gitlab.com/dune-network</a><br><strong>Website: </strong><a href="https://dune.network/">https://dune.network</a><br><strong>Email: </strong><a href="mailto:contact@dune.network">contact@dune.network</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9bcdb599e99" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dune-network/introducing-dune-playground-part-1-free-duns-and-the-rock-paper-scissors-game-e9bcdb599e99">Introducing Dune Playground — Part 1: Free DUNs and the Rock-Paper-Scissors Game</a> was originally published in <a href="https://medium.com/dune-network">Dune Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Games with oracles on blockchains (Part II)]]></title>
            <link>https://medium.com/dune-network/games-with-oracles-on-blockchains-part-ii-89fbbf7dc480?source=rss-d8ebaf559d11------2</link>
            <guid isPermaLink="false">https://medium.com/p/89fbbf7dc480</guid>
            <category><![CDATA[dune-networks]]></category>
            <category><![CDATA[technical]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[oracle]]></category>
            <dc:creator><![CDATA[Thomas]]></dc:creator>
            <pubDate>Thu, 28 May 2020 13:37:31 GMT</pubDate>
            <atom:updated>2020-09-21T09:27:57.366Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JQ_dCt6gbNjhk-QX" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><a href="https://medium.com/dune-network/games-with-oracles-on-blockchains-part-i-37f336250629">Last time</a>, we examined various ways for an oracle to provide randomness for games on the blockchain. Today we take a closer look at our implementation of what we call OnChainAlea, our on-chain mediator between games and oracles. It is written in the <a href="https://medium.com/dune-network/love-a-new-smart-contract-language-for-the-dune-network-a217ab2255be">Love smart contract language</a>.</p><p>If you haven’t , we recommend you read the <a href="https://medium.com/dune-network/games-with-oracles-on-blockchains-part-i-37f336250629">last article</a> before getting back here.</p><p>As we explained then, this contract acts as an intermediate between an oracle (or possibly several, in the future) and various users, most of which we expect to be DA<a href="https://en.wikipedia.org/wiki/Decentralized_application">pps</a>. A DApp may request a random integer (from, say, 0 to 9) from the mediator. Let’s call such a random number a <strong>prophecy</strong> in the rest of this post. The oracle can then supply a prophecy to the mediator, which is passed on to the DApp. Using this mechanism has at least two benefits. First, we provide a low transaction fee average cost (since a hash commitment to a random number takes non-negligible space on the chain, it is better to group them). Second, we provide high assurance that the prophecy is tamper-proof, meaning that the random value has not changed between its commitment by the oracle and its request by the DApp. This is at the cost of the slightly increased latency due to the indirection through our mediator.</p><p>Let’s examine our ~600-LOC smart-contract (which can be found <a href="https://gist.github.com/tomsib2001/7937cf1d69d23e9cc2ed9479cc18b44f">here</a>):</p><h3>Storage</h3><p>The storage of the contract is composed of owner-defined origination parameters and permanent data structures.</p><h4>Owner-defined parameters</h4><p>The following are set at deployment time.</p><ul><li>owners: the addresses controlling the oracle.</li><li>nb_prophecies_per_commit: the number of prophecies to which the oracle commits every time it submits a hash.</li><li>nonces_safety_limit: maximal number of batch commitments an oracle may insert without revealing them. We will see later that the oracle has to pay for every commitment it does not honor, hence it is imperative that it remain &quot;solvable&quot; with respect to this &quot;debt&quot;.</li><li>gc_protection_window: Minimal number of blocks during which prophecies may not be garbage collected: DApps may need answers to remain for say, a few days, before a game is closed. Note that we are considering ways to make the history of prophecies permanently accessible using Merkle trees and an incentive system, without clogging the storage of the contract. We may address this point in a later post.</li><li>min_safety_deposit_per_reservation: A deposit per prophecy that the oracle may lose if it does not honor its obligations (such as actually revealing the prophecy).</li><li>reservation_cost: cost for a DApp to reserve a slot and obtain a prophecy. This serves in part the purpose of paying the oracle for its service.</li><li>prophecy_reveal_delay: Maximum delay to reveal a prophecy after a reservation is made.</li><li>nonce_reveal_delay: Maximum delay to reveal a nonce after all the prophecies for a corresponding commit are revealed.</li></ul><h4>Other storage</h4><p>The storage contains:</p><ul><li>various maps storing the address of the oracle, non garbage-collected commitments, reserved prophecies, revealed prophecies, and a lookup table to match query ids to slot indices.</li><li>Indices for the last_inserted_commit, the last_revealed_commit, the last_GCed_commit, the last_reserved_prophecy and the last_revealed_prophecy.</li><li>A terminated boolean which, if true, means the contract is dead and makes it unusable.</li><li>A min_safety_deposit (which is automatically computed from user-defined parameters). It is deposited by the oracle. It allows compensation of all flouted parties in the worst case of oracle malfunction, whether accidental or malicious.</li><li>The above user-defined parameters.</li></ul><h3>Entrypoints and views</h3><h4>Entrypoints and views for dapps</h4><p>On the DApp-facing side, the main entrypoints are:</p><ol><li>val%entry reserve storage _d (qid : query_id)<br>The reserve entrypoint expects a query id of type nat (non-negative integers). This id should be unique from the point of view of the Dapp, the easiest way being to increment a counter every time a new prophecy is needed. The effect of this function is to book a &quot;slot&quot; in one of the upcoming batches of prophecies. The function may fail if no commitment has been inserted and all current slots have been booked.</li><li>val%view get_answer storage ((qid,addr) : query_id * address option) : nat option<br>The get_answer view allows anyone to observe the prophecy corresponding to a given query_id and (optionally) address. Note that this function may also be called off-chain with an RPC, which can be useful when building the client-facing UI of a DApp.</li><li>val%entry denounce_prophecy storage d (i : slot_index)<br>The denounce_prophecy entrypoint can be called by anyone, and its existence is meant to hopefully ensure that it will never be called. It takes as input the index i of a slot for which the caller thinks the oracle has not provided a prophecy, even though prophecy_reveal_delay blocks have been published since the oracle&#39;s initial commitment to its batch. This triggers a reimbursement of the DApp of min_safety_deposit_per_reservation DUN from the oracle&#39;s initial security bond.<br>This reimbursement may be used in turn for the DApp to provide guarantees to its user: if a game stalls because of foul play on the oracle side, the DApp can implement a mechanism to pay the user back, no questions asked. Of course, we envision several mediators for various levels of risk: min_safety_deposit_per_reservation may be 1 cent, 1 euro or a 100 depending on the stakes.</li><li>val%entry denounce_comm storage d (i : comm_index)<br>Similarly to denounce_prophecy, the denounce_comm entrypoint is a deterrent which can be called by anyone to punish the oracle for not revealing a nonce for a batch of prophecies (the nonce is crucial to check that prophecies have not been tampered with by the oracle). If the denunciation is well-founded, a payment is made to each Dapp of min_safety_deposit_per_reservation for each slot in a batch (there are nb_prophecies_per_commit per batch).</li></ol><h4>Entrypoints and views for the oracle</h4><p>Most of the rest of the contract deals with entrypoints for the oracle.</p><ol><li>val%entry insertCommitments storage d (cl : bytes list)<br>insertCommitmentsenables the oracle to send one or more commitments, each for a nonce and a list of prophecies. Recall from <a href="https://gist.github.com/tomsib2001/previous%20article">last time</a> that a commitment is computed as<br><em>hₖ =</em> sha256( nonce<em>, u</em>₀ … <em>uₙ</em>)</li><li>val%entry revealProphecies storage d (pl : nat list)<br>revealProphecies enables the oracle to reveal one or more prophecies <em>for already inserted commitments</em>. Only prophecies whose slot have already been reserved by some DApp or user may be revealed. The oracle should be especially careful not to attempt to reveal values which have not been committed (for example by attempting to simulate the execution of the revealProphecies function off-chain, on a local node) because, even if the transaction fails, the value it contains should now be considered public.</li><li>val%entry revealNonces storage d (nl : nat list)<br>In the same way, revealNonces enables the oracle to reveal one or more nonces for already made commitments whose prophecies have all been revealed. In the same way, the oracle should be careful to check that these properties are satisfied, let it should inadvertently reveal information which may be used to cheat its users.</li><li>val%entry gc storage d (() : unit)<br>gc garbage collects old commitments and revealed and reserved prophecies, so as to maintain a low cost of storage for the contract. In future versions, we might keep a root hash of an off-chain Merkle tree containing all past history, and incentives for actors to store it and provide parts of it on-demand.</li><li>val%entry withdraw storage d ((amount, dest) : dun * address)<br>If the contract is terminated and the oracle has fulfilled all its obligations, it may withdraw its security bond using this entrypoint. Nothing can be done by the contract unless the security bond is at least min_safety_deposit.</li><li>val%entry deposit storage d (_ : unit) <br>The oracle (or anyone on its behalf) may deposit money into the contract in order to reach min_safety_deposit and be able to function normally.</li><li>val%entry terminate storage d (_ : unit)<br>The terminate entry will only function if all obligations (nonces and prophecies revealed) are met. It will make the contract unusable from then on. All withdrawals must be made before terminate is called.</li><li>val%entry delegate storage d (pkh_opt : keyhash option) <br>The owner may choose to delegate the contract’s balance to a baker using the delegate entrypoint.</li></ol><h4>Observations on trust</h4><p>We want to address one attack channel: the oracle might offer its prophecies to the highest bidder, off-chain, before they are revealed on-chain. Thus, the oracle could theoretically cheat its users (the DApps and/or the users of the DApps) while still scrupulously meeting its (smart-)contractual obligations to them. This does not make such an oracle unusable, however:</p><ul><li>In the long term, a bias would show in the results of the DApp and the reputation of the oracle (which is all it has to show for itself) would take a significant blow;</li><li>If the incentives are correctly balanced on the DApp side, the maximum feasible cost of knowing a prophecy in advance should be very low. Thus the oracle would need to sell this information to many users to make it worth its while, which in turn would increase the risk of being outed and losing all its customer base.</li></ul><p>In our upcoming Raffle smart contract, we enable any user to add randomness to the oracle, to prevent collusion. This is too expensive however to do in the case of games with smaller stakes.</p><h3>Conclusion</h3><p>The full source code of the contract is <a href="https://gist.github.com/tomsib2001/7937cf1d69d23e9cc2ed9479cc18b44f">available here</a> but we hope that this article has clearly articulated the architecture of our OnChainAlea mediator contract. It plays an intermediate role, for both safety and efficiency reasons, between an oracle and DApps in need of random numbers (or <em>prophecies</em>) to properly function. Next time, we will showcase Dapps using slightly different oracles.</p><p><em>Footnotes:</em></p><ol><li>By batching prophecies instead of sending one commitment for every prophecy.</li><li>that is to say, that it has not been modified upon learning what it would be used for.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89fbbf7dc480" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dune-network/games-with-oracles-on-blockchains-part-ii-89fbbf7dc480">Games with oracles on blockchains (Part II)</a> was originally published in <a href="https://medium.com/dune-network">Dune Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Binance DEX, Part I: Atomic Swaps]]></title>
            <link>https://medium.com/dune-network/introduction-to-binance-dex-part-i-atomic-swaps-840ef3de592d?source=rss-d8ebaf559d11------2</link>
            <guid isPermaLink="false">https://medium.com/p/840ef3de592d</guid>
            <category><![CDATA[smart-contrac]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[binance]]></category>
            <category><![CDATA[atomic-swap]]></category>
            <category><![CDATA[technical]]></category>
            <dc:creator><![CDATA[Thomas]]></dc:creator>
            <pubDate>Thu, 26 Mar 2020 13:06:27 GMT</pubDate>
            <atom:updated>2020-03-27T13:37:26.026Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to Binance DEX: Part I, Atomic Swaps explained</h3><p><em>By </em><a href="https://medium.com/u/d8ebaf559d11?source=post_page-----37f336250629----------------------"><em>F.</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a0TgMNsuGxcQAYbqtVCILg.png" /></figure><p><em>In this series of articles, we summarize various relevant information about the Binance DEX decentralized cryptocurrency exchange, how it works, and the process of applying. In doing so, we hope to help the community with issuing and swapping tokens and make the process even smoother. This first article describes how atomic swaps work. The next will dwelve into more technical details of how atomic swaps are done on Binance DEX.</em></p><p>Blockchains are all about decentralization. Bitcoin was the first decentralized digital currency, i.e. controlled by no central entity: decision power was distributed proportionally to miners which meant, initially <a href="https://www.ccn.com/missing-hard-drive-with-7500-bitcoin-now-worth-72-million/">anyone with a laptop</a>.</p><p>Besides the <a href="https://hackernoon.com/x-3yl221s6">concentration of mining due to specialized hardware</a>, cryptocurrency exchanges have been a major factor in the centralization of the ecosystem. Much like nowadays most email addresses are hosted at Google and Microsoft, it seems a large fraction of cryptocurrency users are giving up ownership of their coins to a few exchanges. This has made the numerous hacks of such websites extremely damaging, the most egregious example to this day remaining <a href="https://blockonomi.com/mt-gox-hack/">Mt Gox in 2014</a>.</p><p>In the case of exchanging cryptocurrency against <a href="https://en.wikipedia.org/wiki/Fiat_money">fiat currency</a>, it is difficult to improve on the centralized model. However, swapping between two cryptocurrencies is elementary — as it should! — thanks to a cryptographic setup called the <em>atomic swap</em>.</p><h3>Intro</h3><p>Why the name? Atomic etymologically means “that which can not be divided in smaller parts”, and the concept comes from <a href="https://en.wikipedia.org/wiki/Atomicity_(database_systems)">concurrent programming and database systems</a> where it designates a series of operations of which either all occur, or none. In our case, suppose we wish to trade BTC for DUN: the operation will consist in two transactions, one transferring BTC, the other transferring DUN, but we never wish for one to occur without the other, in other terms we wish for the swap to be <em>atomic</em>.</p><h3>Protocol</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sj04KSdbz0L34HqDsXsR3g.png" /></figure><p>Suppose then Alice wants to send BTC to the White Rabbit, in exchange for DUN.</p><ol><li>Alice chooses a secret random number , and hashes it into , for example using for the well-known SHA-256 function.</li><li>Alice creates on the Bitcoin blockchain a special transaction, called a hash time-locked (HTL) transfer, with the following properties:</li></ol><ul><li>If after two days no-one has claimed the transaction, it reverts all the money (in BTC) back to Alice.</li><li>this transaction can only be claimed by revealing , upon which it will transfer its amount to the White Rabbit: that is to say, it knows and will hash any input to check that before releasing any funds.</li></ul><p>3. The White Rabbit, seeing this transaction, creates a quite similar<br> transaction on the Dune Network blockchain:</p><ul><li>If after <em>one</em> day no-one has claimed the transaction, it reverts all the money (in DUN) to the White Rabbit.</li><li>this transaction can also only be claimed by producing (which is then hashed and compared to since the White Rabbit doesn’t know yet).</li></ul><p>4. Now let’s examine what could happen from then on, and why this is<br> called an <em>atomic</em> transaction:</p><ul><li>If Alice does not reveal , the White Rabbit’s transaction expires first — upon which it receives its money back. There is no point then for Alice to release and forfeit her bitcoins, and thus the swap operation is canceled.</li><li>if Alice reveals by releasing the White Rabbit’s transaction, then, because the Dune blockchain is public, the White Rabbit can see the value of and use it to release Alice’s transaction on the Bitcoin blockchain — which is still time-locked for at least 24 more hours, hence the White Rabbit has ample time.</li></ul><h3>Atomicity</h3><p>As you may already have noticed, atomic swaps are not as “atomic” as one might expect knowing the usual definition. For example, if after the White Rabbit’s transaction expires, Alice releases by mistake, she forfeits her BTC without getting DUN in return.</p><p>Thus, as often with blockchain concepts, this “atomicity” property is conditional on agents being “rational” in the narrow economic sense, something along the lines of “if I possess information () which I can use to transfer money to myself, I <em>will</em> use it”. There are of course many cases in real life when this is not the case.</p><p>To make the transaction “more” atomic, one possibility is to give anyone the possibility of submitting to the smart contract locking the funds, in exchange for a reward. Creating this incentive makes it more likely that someone will act “rationally” and propagate .</p><p>One of the biggest cryptocurrency exchanges, Binance, has recently decided to launch a decentralized version of itself, <a href="https://www.binance.org/">Binance DEX</a>, using atomic swaps as a building block.</p><p>Binance has its own <a href="https://github.com/binance-chain/">blockchain</a>, built on top of the <a href="https://tendermint.com/">Tendermint</a> framework, and on which it maintains its own token <a href="https://coinmarketcap.com/currencies/binance-coin/">BNB</a>.</p><p>The Binance blockchain does not have smart contracts <em>per se</em>, but it provides hash time-locked transfers as a native feature. In the next article, we will first examine how things work once a token has been issued; then we will address the question of issuing your own tokens on Binance DEX. Stay duned!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a_LpuPgY-A8y66nuHHUJYQ.png" /></figure><h3>Connect with us:</h3><p><strong>Discord: </strong><a href="https://discord.gg/JBUGqFg">https://discord.gg/JBUGqFg</a><br><strong>Telegram: </strong><a href="https://t.me/dune_network">https://t.me/dune_network</a><br><strong>Medium: </strong><a href="https://medium.com/dune-network">https://medium.com/dune-network</a><br><strong>Twitter: </strong><a href="https://twitter.com/dune_network">https://twitter.com/dune_network</a><br><strong>Reddit: </strong><a href="https://www.reddit.com/r/dune_network/">https://www.reddit.com/r/dune_network/</a><br><strong>Gitlab: </strong><a href="https://gitlab.com/dune-network">https://gitlab.com/dune-network</a><br><strong>Website: </strong><a href="https://dune.network/">https://dune.network</a><br><strong>Email: </strong><a href="mailto:contact@dune.network">contact@dune.network</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=840ef3de592d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dune-network/introduction-to-binance-dex-part-i-atomic-swaps-840ef3de592d">Introduction to Binance DEX, Part I: Atomic Swaps</a> was originally published in <a href="https://medium.com/dune-network">Dune Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>