<?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 Seraphin Vandegar on Medium]]></title>
        <description><![CDATA[Stories by Seraphin Vandegar on Medium]]></description>
        <link>https://medium.com/@svandegar?source=rss-2951e66668ad------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*ZByiEgFioxJ8-pL687Yv0w.jpeg</url>
            <title>Stories by Seraphin Vandegar on Medium</title>
            <link>https://medium.com/@svandegar?source=rss-2951e66668ad------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 20:26:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@svandegar/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[5 avantages du robot conversationnel pour votre organisation]]></title>
            <link>https://medium.com/@svandegar/5-avantages-du-robot-conversationnel-pour-votre-organisation-535df10a170b?source=rss-2951e66668ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/535df10a170b</guid>
            <category><![CDATA[french]]></category>
            <category><![CDATA[chat]]></category>
            <category><![CDATA[chatbot-design]]></category>
            <category><![CDATA[francais-vf]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[Seraphin Vandegar]]></dc:creator>
            <pubDate>Fri, 25 Sep 2020 16:31:34 GMT</pubDate>
            <atom:updated>2020-09-25T16:31:34.042Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*EaIXhNWa9tq-TbeX.png" /></figure><p>Tirez parti de cette technologie</p><p>Les robots conversationnels (ou <em>chatbots</em>) occupent une place de plus en plus grande sur Internet. Que ça soit pour fixer un rendez-vous à la banque, signaler une panne de votre service de télévision par satellite ou obtenir des horaires de bus, il y a de grandes chances que votre premier interlocuteur soit un robot.</p><p>Pourquoi ces robots sont-ils partout? Dans cet article, j’apporte une réponse sous la forme de cinq avantages de l’utilisation d’un robot conversationnel pour votre business.</p><p>Mais attention! Le développement d’un robot conversationnel doit être réalisé avec précaution. Je vous parle des erreurs à éviter dans cet article : <a href="https://aynils.com/blog/5-erreurs-robot-conversationnel">5 erreurs à éviter lors du développement d’un robot conversationnel</a>.</p><h3>1. Réponse 24h/24 et 7 jours/7</h3><p>Un robot ne dort pas. Ce qui signifie que vos client∙e∙s peuvent obtenir une réponse à leur question, quelle que soit l’heure ou le jour. Pas besoin d’attendre le lundi matin pour obtenir une réponse ou d’engager des équipes prêtes à répondre en dehors des heures de bureau.</p><h3>2. Des employé∙e∙s plus motivé∙e∙s</h3><p>Dans le service à la clientèle, un grand nombre de questions sont semblables. La motivation des employé∙e∙s au service de la clientèle est particulièrement impactée par deux facteurs négatifs : le nombre de questions simples et répétitives et la pression pour répondre rapidement. Un robot conversationnel permet d’automatiser la réponse à ces questions simples, tout en permettant aux employé∙e∙s de passer plus de temps à répondre aux questions complexes et stimulantes.</p><h3>3. Réponse immédiate</h3><p>Un des avantages d’un robot conversationnel, c’est qu’il est capable de répondre à une infinité de questions simultanées. Au lieu d’attendre dans une file d’attente (pensez aux Quatre Saisons de Vivaldi, diffusées avec une qualité audio moyenne, pendant que vous attendez une réponse au téléphone), vos client∙e∙s obtiennent des réponses immédiates à la plupart de leurs questions. Votre équipe rendue disponible par la diminution du nombre de contacts directs est disponible pour répondre directement aux questions complexes.</p><h3>4. Données précises sur les besoins de vos client∙e∙s</h3><p>Un robot conversationnel identifie les questions posées et les classe dans différentes catégories. L’enregistrement des questions permet de récolter des données précises et de générer des rapports montrant les questions les plus fréquemment posées. Ces rapports permettent d’alimenter le processus d’amélioration continue de votre documentation. Les efforts de votre équipe peuvent être dirigés vers les sujets les plus importants.</p><h3>5. Augmentation de la satisfaction de vos client∙e∙s</h3><p>Une documentation qui couvre la majorité des besoins, une réponse immédiate à n’importe quelle heure du jour ou de la nuit, même le dimanche. Un support efficace et agréable. Tous les avantages exposés pour votre entreprise bénéficient de la même façon à vos client∙e∙s. Un∙e client∙e satisfait∙e qui parle de vous est un puissant moteur pour la croissance votre entreprise.</p><p>Alors, qu’attendez-vous pour mettre en place un robot conversationnel ?</p><p>Séraphin</p><p><a href="https://aynils.ca/fr/contact">Contactez-nous!</a></p><p>Si vous avez des questions ou voulez en savoir plus sur le sujet, nous sommes là pour vous aider.</p><p><em>Originally published at </em><a href="https://aynils.ca/blog/5-avantages-robot-conversationnel/"><em>https://aynils.ca</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=535df10a170b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 erreurs à éviter lors du développement d’un robot conversationnel]]></title>
            <link>https://medium.com/@svandegar/5-erreurs-%C3%A0-%C3%A9viter-lors-du-d%C3%A9veloppement-dun-robot-conversationnel-64d27ee08d5?source=rss-2951e66668ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/64d27ee08d5</guid>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[chatbot-design]]></category>
            <category><![CDATA[french]]></category>
            <category><![CDATA[francais-vf]]></category>
            <category><![CDATA[chat]]></category>
            <dc:creator><![CDATA[Seraphin Vandegar]]></dc:creator>
            <pubDate>Fri, 25 Sep 2020 16:30:06 GMT</pubDate>
            <atom:updated>2020-09-25T17:47:01.719Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Qrv_XLWvI3HEA4iu.png" /></figure><h4>Et cinq solutions</h4><p>De nos jours, les robots conversationnels (ou <em>chatbots</em>) sont de plus en plus présents sur Internet. Que ça soit pour obtenir du support chez votre opérateur téléphonique, fixer un rendez-vous avec votre banquier∙ère ou obtenir des horaires de trains, il y a fort à parier que votre premier interlocuteur soit un robot.</p><p>Est-ce que ces robots présentent des risques pour votre entreprise? Dans cet article, j’apporte une réponse sous la forme de cinq erreurs à éviter lors du développement d’un robot conversationnel.</p><p>Si vous prenez garde à ces risques, l’utilisation d’un robot conversationnel présente de nombreux avantages. Je vous parle de ces avantages dans cet article : <a href="https://aynils.com/blog/5-avantages-robot-conversationnel">5 avantages du robot conversationnel pour votre organisation</a>.</p><h3>1. La communication imposée avec le robot</h3><p>Au vu du coût réduit de la communication avec un robot conversationnel, il pourrait être tentant de réduire les possibilités de contact offertes à vos clients pour leur imposer l’utilisation d’un robot conversationnel. Bien qu’il soit intéressant d’en promouvoir l’usage, il est primordial que ce canal de support reste optionnel.</p><h4>Erreur</h4><p>Imposer à vos clients de communiquer uniquement avec un robot conversationnel.</p><h4>Problème</h4><p>Il existe plusieurs catégories de personnes pour lesquelles l’utilisation d’un robot conversationnel ne conviendra pas : les personnes éprouvant des difficultés pour lire ou écrire dans la langue de votre robot, les personnes éprouvant des difficultés avec l’outil informatique, les clients mécontents… ou tout simplement les personnes réfractaires à la communication avec un robot.</p><h4>Solution</h4><p>Il faut toujours proposer une porte de sortie. Un message comme “ Parler à un humain “ doit toujours être correctement interprété par le robot conversationnel et la conversation doit être transférée vers votre équipe. De plus, une possibilité de contact direct doit toujours être disponible sur votre site Internet.</p><h3>2. Le dialogue de sourds</h3><p>Quoi de plus énervant que de recevoir une réponse ne correspondant pas à la question qui a été posée? Vous ne voulez certainement pas générer cette frustration chez vos client∙e∙s.</p><h4>Erreur</h4><p>Un robot conversationnel qui ne répond pas à la question posée.</p><h4>Problème</h4><p>Votre client∙e sentira rapidement qu’il∙elle n’est pas écouté∙e si votre robot répond avec assurance à autre chose que la question qui a été posée. Cela peut arriver lors de l’utilisation d’algorithmes peu performants ou si l’on ignore l’indice de confiance proposé par les algorithmes d’analyse du langage.</p><h4>Solution</h4><p>Implémenter un mécanisme de précision de la question lorsque votre robot conversationnel n’a pas une confiance suffisante en sa compréhension de la question posée. Une question complémentaire, une demande de reformulation ou le transfert vers un être humain sont différentes options permettant d’éviter à vos client∙e∙s de se sentir piégé∙e∙s dans un dialogue de sourds.</p><h3>3. La conversation trop complexe</h3><p>Combien de fois vous est-il arrivé de vous retrouver au téléphone avec un répondeur automatique, sans savoir quelle option choisir? Voire à choisir au hasard car aucune des options proposées ne semble correspondre à votre situation?</p><h4>Erreur</h4><p>Les choix proposés par le robot conversationnel sont complexes ou trop spécifiques.</p><h4>Problème</h4><p>Vos client∙e∙s risquent de se sentir perdus, face à la complexité des choix qui sont proposés.</p><h4>Solution</h4><p>Proposer un nombre réduit (trois maximum) d’options. Appliquer la technique de l’entonnoir : proposer des questions simples et générales puis préciser avec des questions subséquentes.</p><h3>4. Le bot capable de répondre à toutes les questions</h3><p>Au vu de tous les avantages pour votre entreprise apportés par un robot conversationnel, il peut être tentant d’utiliser cet outil pour répondre à toutes les questions, dans tous les domaines.</p><h4>Erreur</h4><p>Vouloir un robot conversationnel essayant de répondre à toutes les questions.</p><h4>Problème</h4><p>Plus on ajoute de domaines de compétence à un seul robot conversationnel, plus le risque d’une mauvaise interprétation de la question est élevé. On peut alors tomber dans un dialogue de sourds (voir point 2.)</p><h4>Solution</h4><p>Commencer par l’implémentation d’un robot conversationnel pour le domaine d’activité pour lequel vous recevez le plus de questions. Ensuite, grâce aux données d’utilisations récoltées, identifiez des domaines secondaires pour lesquels un second robot pourrait être implémenté. Délimitez clairement le champ de compétences de chaque robot.</p><h3>5. Le ton de conversation non adapté</h3><p>Votre banquière et votre boulanger ne s’adressent pas à vous de la même façon. Pourquoi leurs assistants virtuels le feraient?</p><h4>Erreur</h4><p>Utiliser un ton de conversation neutre, quel que soit l’objet de votre entreprise. Ou pire, un ton inadapté (familier au lieu de formel ou formel au lieu de familier).</p><h4>Problème</h4><p>Un ton neutre sera perçu comme manquant de personnalité par certain∙e∙s client∙e∙s. Un ton formel pour une entreprise familiale sera perçu comme froid alors qu’un ton familier sera perçu comme impoli si votre entreprise est de nature formelle.</p><h4>Solution</h4><p>Développer votre robot conversationnel de façon à lui donner une personnalité correspondant à votre entreprise. Si vous avez un rapport détendu avec votre clientèle, cela doit aussi s’appliquer aux conversations au travers de votre robot conversationnel. Au contraire, si vos relations sont de nature formelle, il faut impérativement que votre robot conversationnel utilise les formules adéquates.</p><p>Vous voilà prêt∙e à développer un robot conversationnel efficace!</p><p>Séraphin</p><p>Si vous avez des questions ou voulez en savoir plus sur le sujet, nous sommes là pour vous aider.</p><p><a href="https://aynils.ca/fr/contact">Contactez-nous!</a></p><p><em>Originally published at </em><a href="https://aynils.ca/fr/blog/5-erreurs-robot-conversationnel/"><em>https://aynils.ca</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64d27ee08d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[En français, s’il vous plaît]]></title>
            <link>https://medium.com/@svandegar/en-fran%C3%A7ais-sil-vous-pla%C3%AEt-42671e63cdf4?source=rss-2951e66668ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/42671e63cdf4</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[francais-vf]]></category>
            <category><![CDATA[language]]></category>
            <dc:creator><![CDATA[Seraphin Vandegar]]></dc:creator>
            <pubDate>Fri, 25 Sep 2020 16:22:58 GMT</pubDate>
            <atom:updated>2020-09-25T16:22:58.293Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*QdUzzVbBpzYQD5lo.png" /></figure><h4>L’importance de développer des logiciels en français</h4><p><em>Game-over; Continue, Cancel, format c</em> :si, comme moi, tu as grandi dans les années nonante (quatre-vingt-dix, pardon), tu as certainement découvert ces mots anglais à travers les jeux vidéo et les premiers ordinateurs. Depuis toujours, la langue principale de mon ordinateur est l’anglais. Je connais les formules d’Excel en anglais et je galère quand on me demande de l’aide pour un tableau dans la version francophone.</p><p>Jusqu’il y a peu, je trouvais ça normal. Après tout, l’informatique nous vient d’Amérique et puis, tout le monde comprend l’anglais, non?</p><p>Eh bien non.</p><p>Depuis que je vis au Canada, je réalise l’importance de bénéficier de services équivalents dans les deux langues nationales : le français et l’anglais. Car même si j’ai la chance d’avoir appris l’anglais à l’école et que je me débrouille plutôt pas mal dans cette seconde langue, je me rends compte que, quand il s’agit de lire des textes de loi, de demander une aide gouvernementale ou de parler à un médecin, je suis heureux de pouvoir le faire dans ma langue maternelle. Puis aussi quand je parle à Siri ou que je cherche de la documentation en ligne ou que je commande un Tim Hortons au service au volant, c’est plus facile en français. Alors pourquoi développer des logiciels uniquement en anglais?</p><p>Du coup, je m’adresse à toi, le développeur indépendant et aussi à toi, le responsable de produit. S’il vous plaît, développez vos logiciels en français, <a href="https://fr.wikipedia.org/wiki/Francophonie">pour les 300 million de francophones dans le monde</a>. Puis traduisez-les dans toutes les langues dans lesquelles vous prévoyez de vendre votre produit.</p><p>En tant qu’utilisateurs de logiciels et services, nous avons tous une responsabilité. Notre utilisation de ces produits est mesurée, la langue que nous choisissons est enregistrée et les décisions de développement dans une langue spécifique sont basées sur ces chiffres. En choisissant le français, nous marquons notre préférence et influençons les choix des développeurs, développeuses et responsables de produit.</p><p>Si tu es développeur, développeuse, chef∙fe de produit, utilisateur ou utilisatrice de logiciels (oui, en gros, ça concerne tout le monde), je serais heureux d’entendre ton avis ou de répondre à tes questions dans les commentaires ci-dessous.</p><p><em>Originally published at </em><a href="https://aynils.ca/fr/blog/en-francais-s-il-vous-plait"><em>https://aynils.ca</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42671e63cdf4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Certify data on Blockchain with Python and no prior Blockchain experience]]></title>
            <link>https://python.plainenglish.io/certify-data-on-blockchain-with-python-and-no-prior-blockchain-experience-f09b7e3deb30?source=rss-2951e66668ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/f09b7e3deb30</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Seraphin Vandegar]]></dc:creator>
            <pubDate>Fri, 10 May 2019 22:05:27 GMT</pubDate>
            <atom:updated>2020-04-26T08:47:50.921Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the key principles of blockchains is to dispense with third-party certification to establish trust between two parties.</p><p>Once a transaction is registered on the Blockchain, it is nearly impossible to alter or delete it. Modifying the historical state of a blockchain would require at least 51% of the computing power of this chain. This is called a 51% attack and is explained in detail on <a href="https://en.bitcoinwiki.org/wiki/51%25_attack">BitcoinWiki</a>. Due to the high number of nodes on the Ethereum Blockchain, this kind of attack is close to impossible.</p><p>So, data stored on the Ethereum Blockchain is considered immutable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1l9le2qhZl-gqmRkd3EP2w.jpeg" /><figcaption>Stamp</figcaption></figure><p>Business supply chains often require data certification. Food suppliers need to ensure that perishables are kept at the proper temperature throughout the entire supply chain. A simple solution is to have temperature sensors and to store the data in a database. However, someone could easily alter the data in the database afterwards.</p><p>Storing this data on a blockchain is a perfect way to certify that no one can alter this data, once registered.</p><p>But how do you register data on the blockchain? This technology is still quite new and requires time and investment to understand and use. You can hire a blockchain consulting company, learn several new technologies or simply write a <strong>few lines of Python code</strong> 🐍</p><p>In this article, I will walk you through a few simple steps to certify the integrity of a dataset:</p><ol><li>Implement a hash chain in our data set</li><li>Deploy a Smart Contract on the Ethereum blockchain</li><li>Register key hashes from our data set on the Ethereum blockchain</li></ol><p><strong>Note</strong>: in this article, we assume that you’re already familiar with Python 3 and virtual environments. If not, I suggest that you follow this tutorial: <a href="https://docs.python-guide.org/dev/virtualenvs/">https://docs.python-guide.org/dev/virtualenvs/</a></p><h3>Prerequisites</h3><p>Before diving into the subject of this article, we need to get our keys to access the Ethereum network :</p><ul><li>A wallet loaded with some Ether</li><li>A provider API access</li></ul><p>If you already have these keys, you can jump to the first <a href="#4cbe">step</a>.</p><h4>Create an Ethereum Wallet</h4><p>There are many options to create an Ethereum wallet. My favorite is to use <a href="https://metamask.io/">Metamask</a>. Metamask is a browser extension that enables you to use your wallet to login to Dapps (Decentralized Applications) directly into your browser.</p><p>Go to <a href="https://metamask.io/">https://metamask.io/</a> and follow the steps described in the “HOW IT WORKS” video to create your wallets.</p><p>By default, Metamask creates multiple wallets on different networks. “Main Ethereum Network” is the actual Ethereum network. The others are test networks. These networks are perfect for development purposes as the Ether on these networks is worth nothing.</p><h4>Load your wallet with Ethers</h4><p>In this article, I’m using the Ropsten test net, which works exactly as the Main net but with free Ether.</p><ol><li><strong>Get your Ropsten wallet address</strong></li></ol><p>From your browser, open the Metamask extension and switch to the Ropsten network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*9COsdlc92htorf9d_1gJzw.png" /><figcaption>Metamask — select Ropsten Test Network</figcaption></figure><p>Then click on your username to copy your wallet address.</p><p><strong>Note</strong>: Save your address in a document, we will use it again later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*MSSDWz-4rG5UpjU9dVEAcw.png" /><figcaption>Metamask — copy wallet address to clipboard</figcaption></figure><p><strong>2. Get your private key</strong></p><p>In the Metamask window, click on the Account menu, select “Account Details” and “Export Private Key”. After entering your password, you will see your private key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*dnE2LBQzXNdHqXZPiWINpg.png" /><figcaption>Metamask — Menu icon</figcaption></figure><p><strong>Note: </strong>save this key in a secure place. Anyone with this key has full access to your wallet and if you lose it, there is no way to recover it. “<a href="https://medium.com/@infinitustoken/not-your-keys-not-your-coins-the-quadriga-conundrum-and-how-inf-could-have-helped-4616b1050246">Not your keys, nor your coins</a>”</p><p><strong>3. Get free Ethers</strong></p><p>Go to <a href="https://faucet.ropsten.be/">https://faucet.ropsten.be/</a> , enter your wallet address and click on “Send me test Ether”</p><p>Depending on the network usage, you should see 1 Ether appear in your wallet within a few minutes. Although 1 Ether is more than enough for testing purposes, you can use this faucet once every 24 hours .</p><h4>Get a provider API URL</h4><p>To interact with the Ethereum network, one option would be to run an Ethereum node on your machine and connect directly to this node. Even though it would be great to make your resources available for the Ethereum community, it represents a non-negligible amount of work. In this article, we will avoid this extra work by using the API provided by <a href="https://infura.io/">Infura</a>.</p><ol><li>Open an account on <a href="https://infura.io/">https://infura.io/</a></li><li>Create a new project and get the Ropsten endpoint URL from the project configuration screen.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*7IRPNhgA64fz3Q0bHlswXw.png" /><figcaption>Infura — Ropsten Network API Endpoint</figcaption></figure><p>🎉 Now we’re ready to write some code. 🎉</p><h3>Step 1: Implement a hash chain in our dataset</h3><p>We’ll start by implementing a hash chain in our dataset. But first things first: what is a hashchain?</p><p>According to <a href="https://en.wikipedia.org/wiki/Hash_chain">Wikipedia</a>, a hash chain is:</p><blockquote>The successive application of a cryptographic hash function to a piece of data. In computer security, a hash chain is a method to produce many one-time keys from a single key or password. For non-repudiation a hash function can be applied successively to additional pieces of data in order to record the chronology of data’s existence.</blockquote><p>Implementing a hash chain in a database is a great way to certify two things:</p><ul><li>No record has been tampered with</li><li>The chronological order of the records is respected.</li></ul><p>To implement this mechanism in our database, we use hashchain, a Python package that I wrote specifically to certify databases integrity on the Ethereum blockchain. The full documentation is available at <a href="https://hashchain.readthedocs.io/en/latest/index.html">Read the Docs</a>.</p><p>To start with, set up a new Python virtual environment with Python ≥ 3.5 and install the package hashchain: pip install hashchain</p><p>For the sake of simplicity, our database will be a JSON file. But you can apply this method to any kind of database. You can find an example using a MongoDB <a href="https://hashchain.readthedocs.io/en/latest/examples.html#implement-a-hash-chain-in-a-mongodb-database">here</a>.</p><p>Let’s start coding!</p><p><strong>First</strong>: create a JSON file named jsonDB.JSON containing an empty array: []</p><p><strong>Next</strong>: In the same folder, create a Python file with this content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb521827918afda76543a05567769075/href">https://medium.com/media/cb521827918afda76543a05567769075/href</a></iframe><ul><li>Lines 1–4: import required modules</li><li>Lines 6–10: open the JSON database</li><li>Lines 12–17: build fake datapoint</li><li>Lines 19–25: try to get the previous record from the database. If an IndexError is raised, it means that we’re registering the first record.</li><li>Line 27: build the Record object. Under the hood, the data JSON is hashed along with the hash of the previous record to create an unique hash.</li><li>Lines 30–31: add the record to the database</li><li>Lines 32–33: save the database to the JSON file</li></ul><p>If we run this code for the first time, our JSON file will look like this:</p><pre>[<br>  {<br>    &quot;hash&quot;: &quot;c60b7cf55aecc2e0200a4a8d5aa3c6e3078ff407c85456149826d6eb12a24448&quot;,<br>    &quot;previous_hash&quot;: &quot;4f64fe1ce613546d34d666d8258c13c6296820fd13114d784203feb91276e838&quot;,<br>    &quot;value&quot;: 0.12199900848615519,<br>    &quot;sensorId&quot;: &quot;ERDP-QT24&quot;,<br>    &quot;timestamp&quot;: &quot;2019-05-06T15:41:09.064795&quot;<br>  }<br>]</pre><p>Every time we run it, a new record will be added:</p><pre>[<br>  {<br>    &quot;timestamp&quot;: &quot;2019-05-06T15:41:09.064795&quot;,<br>    &quot;hash&quot;: &quot;c60b7cf55aecc2e0200a4a8d5aa3c6e3078ff407c85456149826d6eb12a24448&quot;,<br>    &quot;previous_hash&quot;: &quot;4f64fe1ce613546d34d666d8258c13c6296820fd13114d784203feb91276e838&quot;,<br>    &quot;sensorId&quot;: &quot;ERDP-QT24&quot;,<br>    &quot;value&quot;: 0.12199900848615519<br>  },<br>  {<br>    &quot;timestamp&quot;: &quot;2019-05-06T15:49:37.001869&quot;,<br>    &quot;hash&quot;: &quot;40c16afe0e7279ad7dc0d7a42f7183cb126f4f20f6b5520ee4cccff2996af178&quot;,<br>    &quot;sensorId&quot;: &quot;ERDP-QT24&quot;,<br>    &quot;previous_hash&quot;: &quot;c60b7cf55aecc2e0200a4a8d5aa3c6e3078ff407c85456149826d6eb12a24448&quot;,<br>    &quot;value&quot;: 0.1943030574950101<br>  },<br>  {<br>    &quot;sensorId&quot;: &quot;ERDP-QT24&quot;,<br>    &quot;timestamp&quot;: &quot;2019-05-06T16:14:41.869033&quot;,<br>    &quot;value&quot;: 0.5562692458165309,<br>    &quot;hash&quot;: &quot;e1421a5ae81837cb086f78b0f713b197a3c6353c0c69c22da7841dbc7eac50d3&quot;,<br>    &quot;previous_hash&quot;: &quot;40c16afe0e7279ad7dc0d7a42f7183cb126f4f20f6b5520ee4cccff2996af178&quot;<br>  }<br>]</pre><p>In every record, we can see two important values:</p><ul><li>previous_hash: the hash of the previous element, to guarantee the chronological order of the records</li><li>hash: hash of the data input + the previous hash. This hash guarantee that the data hasn’t been modified</li></ul><p>To verify our chain integrity, the records module provides the verify() function. Adding this function, just after loading the data from the JSON database will ensure that our records haven’t been tampered with. See lines 12–13.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6dc870e63103d3f7473ffc442fafbd0/href">https://medium.com/media/a6dc870e63103d3f7473ffc442fafbd0/href</a></iframe><p><strong>Note: </strong>you can play a bit with this script, try to modify some data in the JSON file and see the result. You should get a ValueError if the dataset is not valid.</p><p>This method is quite secure but not at 100%. Someone with the right access can still modify a datapoint from our dataset and recalculate the whole chain. This will result in a new chain appearing as valid. To prevent that, we need to store our hashes in a immutable storage. Which leads us to our second step.</p><h3>Step 2: Deploy a Smart Contract on the Ethereum Blockchain</h3><p>We started with the fact that data stored on the Ethereum blockchain is immutable. So, to certify our dataset, we will use the blockchain.</p><p>Scripts running on the Ethereum blockchain are called smart contracts. To learn more about smart contracts in general, I recommend this <a href="https://hackernoon.com/everything-you-need-to-know-about-smart-contracts-a-beginners-guide-c13cc138378a">excellent article</a>.</p><p>The second module of the haschain Python package is ethereum. This module provides two sub-modules: contract and connector. To deploy our smart contract, we will use the contract module.</p><p>The aim of this module is to create a Contract object that will contain all the parameters required to deploy and interact with a contract on the blockchain.</p><p>Let’s implement the contract creation in our script!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/153b53d4e087e4b25738e62cb1f44888/href">https://medium.com/media/153b53d4e087e4b25738e62cb1f44888/href</a></iframe><p>We added a few things:</p><ul><li>Line 1: import the ethereum module</li><li>Lines 12–15: input the keys that we created in the prerequisites. <strong>Note: </strong>these keys are in the script for the sake of simplicity. Never do that in a production environment. Anyone with access to your code could steal your keys. Best pratice is to store the keys in <a href="https://en.wikipedia.org/wiki/Environment_variable">environment variables</a>.</li><li>Lines 17–20: try to open a file named contract_interface.JSON</li><li>Lines 21- 27: if the file does not exists, deploy a new contract on the Ethereum blockchain</li><li>Lines 29–31: save the contract interface in a file named contract_interface.JSON</li></ul><p>When we run the script for the first time, a smart contract will be deployed on the Ethereum Ropsten Test Network. This operation can take a few seconds to complete. Once completed, we get the transaction hash printed in the console. This transaction hash is unique and public. Everyone can use a chain explorer like <a href="https://ropsten.etherscan.io/">Etherscan</a> to see the transaction details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pq82TBrcbzv1io8dOPPS4w.png" /><figcaption>Etherscan — Contract creation transaction details</figcaption></figure><p>The contract address and ABI (<a href="https://solidity.readthedocs.io/en/v0.5.3/abi-spec.html">Application Binary Interface</a>) are then saved in the contract_interface.JSON for later use.</p><p>Under the hood, the script deployed this smart contract:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f62e6e7cdef9b7d956f24c5936c29fd3/href">https://medium.com/media/f62e6e7cdef9b7d956f24c5936c29fd3/href</a></iframe><p>Although, it is not necessary to understand the Solidity Syntax because we will only interact through Python code, it is interesting to understand how our data will be stored.</p><ul><li>Line 1: compiler version definition</li><li>Lines 5–7: variables initialization. owner corresponds to an Ethereum wallet address while hashChain is a key-value pair storage</li><li>Lines 12–10: contract initialization. This function will only be run once, during contract creation. This is an important part of the script, where the address of the wallet used to deploy the contract will become the owner.</li><li>Line 18: fallback function. This function is executed if someone sends Ether to this contract. As this function is not <em>payable</em>, the Ether will be sent back to the sender.</li><li>Lines 20–25: the record function can only be called by the contract owner and update the hashChain variable with the key-value pair received. It works exactly like a Python dictionary. If the key exists, the value will be overridden. If not, a new entry will be created. As we use a hashchain in our database, we only need to register the last value to certify the whole chain. this function costs around 0<strong>.</strong>000035 Ether as it changes the chain state.</li><li>Lines 27–29: the getHash function returns the value for a given key. This function can be called by anyone and is free to run. We will use this function to verify our chain integrity.</li></ul><p>Now that our contract is deployed, let’s see how to use it!</p><h3>Step 3: Register key hashes from our data set on the Ethereum Blockchain</h3><p>With a hash chain in our database and a deployed smart contract, designed to store a key-value pair, the last step will be to interact with the smart contract, from our Python script.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05a9c1d2b6dd60910421bc63be452665/href">https://medium.com/media/05a9c1d2b6dd60910421bc63be452665/href</a></iframe><p>A few more lines of code:</p><ul><li>Lines 33–40: build the Ethereum connector object</li><li>Line 63: set the key. This key must be unique and linked to this specific dataset. Under the hood, this key is hashed locally, before being sent to the smart contract, so you don’t need to worry about privacy.</li><li>Line 64: register the key-pair value in the smart contract storage</li><li>Line 65: print the transaction hash in the console, for your records</li></ul><p><strong>Note:</strong> the connector.record() method accepts a wait argument, which makes the method wait to get the transaction validated, before returning the transaction hash. This can be used to control the flow of your script.</p><p>Let’s update our verification step to check if the last hash registered on the blockchain is the same as the last hash in our dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a57a68417b59df2da7e4fae0440118b/href">https://medium.com/media/5a57a68417b59df2da7e4fae0440118b/href</a></iframe><ul><li>Line 43: only check the value stored in the smart contract storage if the dataset from our database is valid.</li><li>Line 44: use the same key as the one used to register the hash</li><li>Line 45–46: ensure the last hash in our dataset is identical to the one stored in the smart contract storage. If not, raise an error</li></ul><p>Voilà, we certified our dataset!</p><h3>Remarks and references</h3><ul><li>All the code presented in this article can be found in this repo<a href="https://github.com/svandegar/hashchain-demo">,</a> under the jsonDB folder. This repo also contains a more elaborate script running on a Raspberry Pi 3. The script gets temperature data from a sensor, stores it in a MongoDB and registers it on the blockchain. I will certainly write an article detailing that code later.</li><li>Because of the time needed to register data on the blockchain and the cost associated with each transaction, high-frequency data writes can quickly get expensive. But since not every hash is required to ensure data integrity, we can get away with only storing the occasional hash on the blockchain. For example, registering one hash every hour or every time that a certain threshold is reached. This really depends on the use case. I would be more than happy to chat about your use cases in the comments section and help you define the best approach.</li><li>This is my first Medium article and English is not my first language. So, if you find something misspelled or unclear, please let me know and I’ll adapt ASAP.</li><li>The Python library used in this article has been developed as my final project for a blockchain development bootcamp and is still in progress. So, any feedback is welcome, too. The code is available on <a href="https://github.com/svandegar/hashchain">Github</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f09b7e3deb30" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/certify-data-on-blockchain-with-python-and-no-prior-blockchain-experience-f09b7e3deb30">Certify data on Blockchain with Python and no prior Blockchain experience</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>