{"id":8905,"date":"2025-02-23T06:20:54","date_gmt":"2025-02-23T05:20:54","guid":{"rendered":"https:\/\/wsj-crypto.com\/?p=8905"},"modified":"2025-02-23T06:20:54","modified_gmt":"2025-02-23T05:20:54","slug":"building-serverless-applications-for-mist-a-comprehensive-guide","status":"publish","type":"post","link":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/","title":{"rendered":"Building Serverless Applications for Mist: A Comprehensive Guide"},"content":{"rendered":"<p><\/p>\n<div id=\"\"><head><meta charset=\"utf-8\"\/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\/><link rel=\"icon\" type=\"image\/x-icon\" href=\"https:\/\/blog.ethereum.org\/images\/favicon.png\"\/><title>How to create serverless applications for Mist | Ethereum Foundation Blog<\/title><meta name=\"title\" content=\"How to create serverless applications for Mist | Ethereum Foundation Blog\"\/><meta name=\"description\" content=\"\"\/><meta name=\"application-name\" content=\"Ethereum Foundation Blog\"\/><meta name=\"image\" content=\"https:\/\/blog.ethereum.org\/images\/eth-org.jpeg\"\/><meta property=\"og:title\" content=\"How to create serverless applications for Mist | Ethereum Foundation Blog\"\/><meta property=\"og:description\" content=\"\"\/><meta property=\"og:type\" content=\"website\"\/><meta property=\"og:site_name\" content=\"Ethereum Foundation Blog\"\/><meta property=\"og:url\" content=\"https:\/\/blog.ethereum.org\/2016\/07\/12\/build-server-less-applications-mist\"\/><meta property=\"og:image\" content=\"https:\/\/blog.ethereum.org\/images\/eth-org.jpeg\"\/><meta property=\"og:image:url\" content=\"https:\/\/blog.ethereum.org\/images\/eth-org.jpeg\"\/><meta property=\"og:image:secure_url\" content=\"https:\/\/blog.ethereum.org\/images\/eth-org.jpeg\"\/><meta property=\"og:image:alt\" content=\"Ethereum Foundation Blog\"\/><meta property=\"og:image:type\" content=\"image\/png\"\/><meta name=\"twitter:card\" content=\"summary_large_image\"\/><meta property=\"twitter:url\" content=\"https:\/\/blog.ethereum.org\/2016\/07\/12\/build-server-less-applications-mist\"\/><meta name=\"twitter:creator\" content=\"@ethereum\"\/><meta name=\"twitter:site\" content=\"@ethereum\"\/><meta name=\"twitter:title\" content=\"How to create serverless applications for Mist | Ethereum Foundation Blog\"\/><meta name=\"twitter:description\" content=\"\"\/><meta name=\"twitter:image\" content=\"https:\/\/blog.ethereum.org\/images\/eth-org.jpeg\"\/><link rel=\"icon\" href=\"https:\/\/blog.ethereum.org\/images\/favicon.png\"\/><link rel=\"canonical\" href=\"https:\/\/blog.ethereum.org\/2016\/07\/12\/build-server-less-applications-mist\"\/><link rel=\"preload\" as=\"image\" imagesrcset=\"\/_next\/image?url=%2Fimages%2Feth-org.jpeg&amp;w=1080&amp;q=75 1x, \/_next\/image?url=%2Fimages%2Feth-org.jpeg&amp;w=3840&amp;q=75 2x\"\/><meta name=\"next-head-count\" content=\"28\"\/><link rel=\"preconnect\" href=\"https:\/\/fonts.googleapis.com\"\/><link rel=\"preconnect\" href=\"https:\/\/fonts.gstatic.com\" crossorigin=\"true\"\/><link rel=\"preconnect\" href=\"https:\/\/fonts.googleapis.com\"\/><link rel=\"preconnect\" href=\"https:\/\/fonts.gstatic.com\" crossorigin=\"true\"\/><link rel=\"preconnect\" href=\"https:\/\/Y49Y4R9SYF-dsn.algolia.net\" crossorigin=\"true\"\/><link rel=\"stylesheet\" href=\"https:\/\/cdn.jsdelivr.net\/npm\/instantsearch.css@7.3.1\/themes\/reset-min.css\" integrity=\"sha256-t2ATOGCtAIZNnzER679jwcFcKYfLlw01gli6F6oszk8=\" crossorigin=\"anonymous\"\/><link rel=\"preconnect\" href=\"https:\/\/fonts.gstatic.com\" crossorigin=\"\"\/><link rel=\"preload\" href=\"https:\/\/blog.ethereum.org\/_next\/static\/css\/433fa9e02c79e69c.css\" as=\"style\"\/><link rel=\"stylesheet\" href=\"https:\/\/blog.ethereum.org\/_next\/static\/css\/433fa9e02c79e69c.css\" data-n-g=\"\"\/><noscript data-n-css=\"\"\/><\/head><body id=\"wp_automatic_ReadabilityBody\"><\/p>\n<div id=\"__next\">\n<div class=\"css-1b6n4o1\">\n<div dir=\"ltr\" class=\"css-1mbdz04\">\n<div class=\"css-117th2g\"><\/div>\n<div class=\"css-nizyf\"><img decoding=\"async\" alt=\"ETH bottom background ending image\" src=\"https:\/\/blog.ethereum.org\/images\/eth-bottom-right@2x.png\" class=\"chakra-image css-147f9zw\"\/><\/div>\n<\/div>\n<div class=\"css-13vzj2f\">\n<div class=\"chakra-container css-t26gxy\"><main><\/p>\n<h2 class=\"chakra-text css-1hp3qq6\">Published by Alex Van de Sande on July 12, 2016<!-- --><\/h2>\n<div class=\"css-rszk63\">\n<div class=\"css-0\"><span style=\"box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%\"><span style=\"box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%\"><img decoding=\"async\" style=\"display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0\" alt=\"\" aria-hidden=\"true\" src=\"data:image\/svg+xml,%3csvg%20xmlns=%27http:\/\/www.w3.org\/2000\/svg%27%20version=%271.1%27%20width=%271064%27%20height=%27456%27\/%3e\"\/><\/span><img alt=\"How to create serverless applications for Mist\" srcset=\"\/_next\/image?url=%2Fimages%2Feth-org.jpeg&amp;w=1080&amp;q=75 1x, \/_next\/image?url=%2Fimages%2Feth-org.jpeg&amp;w=3840&amp;q=75 2x\" src=\"https:\/\/blog.ethereum.org\/_next\/image?url=%2Fimages%2Feth-org.jpeg&amp;w=3840&amp;q=75\" decoding=\"async\" data-nimg=\"intrinsic\" style=\"position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%\"\/><\/span><\/div>\n<\/div>\n<div class=\"chakra-stack css-6i8n52\">\n<div class=\"chakra-stack css-1kd73y8\">\n<article>\n<p class=\"chakra-text css-gi02ar\">Ethereum is not envisioned to serve as a platform for constructing obscure smart contract applications that necessitate a STEM degree to comprehend; rather, it aspires to be a foundational element of a different framework for applications on the internet. This article aims to clarify how this can be achieved and provide some fundamental examples of how to initiate the creation of a decentralized application.<!-- --><\/p>\n<p><!-- --><\/p>\n<h2 class=\"chakra-heading css-1w54o5f\" id=\"who-is-this-for\">Who is the target audience?<!-- --><\/h2>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">This article targets those with a basic grasp of web technologies and the ability to develop a simple JavaScript and HTML application, and desire to adapt these skills for building applications in the Ethereum ecosystem.<!-- --><\/p>\n<p><!-- --><\/p>\n<h2 class=\"chakra-heading css-1w54o5f\" id=\"how-can-apps-run-without-servers\">How can applications operate without servers?<!-- --><\/h2>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Currently, servers in web applications perform far more tasks than they were initially designed for. In addition to serving static pages, they also manage private data, oversee user authentication, and handle all the complex methods in which data is processed and stored. The only role of the user&#8217;s device \u2014 once considered a supercomputer at the inception of the web \u2014 is to load and present that data to the user.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\"><a class=\"chakra-link css-ug8vf0\" href=\"https:\/\/blog.ethereum.org\/images\/posts\/2016\/07\/Screen-Shot-2016-07-08-at-5.27.25-PM.png\"><img decoding=\"async\" alt=\"Current server models\" src=\"https:\/\/blog.ethereum.org\/images\/posts\/2016\/07\/Screen-Shot-2016-07-08-at-5.27.25-PM.png\" class=\"chakra-image css-hw6q2r\"\/><\/a> Current server models<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">In contrast, a more decentralized structure would permit a significantly more modular approach, with various machines and protocols managing specific functions, some on the user&#8217;s end and others on specialized machines distributed throughout a peer-to-peer network. Thus, all Data logic (which data is stored, who stores it, conflict resolution, etc.) is managed by smart contracts on the blockchain, static files are delivered via <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"http:\/\/swarm-gateways.net\/bzz:\/a600d48f01d5e6d07907d9d14db0ff205624caf0570d0c2601cdb80c9767bcb9\/index.html\"> Swarm <!-- --><\/a> and real-time interaction is facilitated through <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/github.com\/ethereum\/wiki\/wiki\/Whisper\"> Whisper<!-- --><\/a>. The user&#8217;s device retains user authentication and operates the application&#8217;s interface.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Implementing this model would diminish the risk of data breaches and attacks since fewer single nodes hold large amounts of unencrypted data, while also alleviating the burden and expenses of serving applications by spreading it across the network. Given that all these protocols are decentralized, anyone can access the network and begin offering a specialized service: if the user is browsingfrom a robust laptop, for example, they can likewise provide static files to neighboring networks.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">\u00a0<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\"><a class=\"chakra-link css-ug8vf0\" href=\"https:\/\/blog.ethereum.org\/images\/posts\/2016\/07\/Screen-Shot-2016-07-08-at-5.37.32-PM.png\"><img decoding=\"async\" alt=\"Decentralized Server models\" src=\"https:\/\/blog.ethereum.org\/images\/posts\/2016\/07\/Screen-Shot-2016-07-08-at-5.37.32-PM.png\" class=\"chakra-image css-hw6q2r\"\/><\/a> Decentralized Server models<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">A decentralized framework also fosters creativity: as the interface is separate from the data, anyone is free to develop a new interface for the same application, thus cultivating a more dynamic and competitive environment. It could be said that one of the most fascinating and inventive phases in Twitter&#8217;s timeline occurred when it operated primarily as a central data source and allowed anyone to construct their own Twitter Application.<!-- --><\/p>\n<p><!-- --><\/p>\n<h2 class=\"chakra-heading css-1w54o5f\" id=\"see-it-working\">See it in action<!-- --><\/h2>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">If you&#8217;re eager to test the app prior to fully understanding it, we suggest you <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/github.com\/ethereum\/mist\/releases\/tag\/0.8.0\">download Mist and consult our beginner&#8217;s guide on how to set up and operate the application.<!-- --><\/a> Alternatively, if you&#8217;re simply interested in viewing the entire application, it can be obtained directly from the <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/github.com\/ethereum\/stake-voice\">Stake Voice Github repository<!-- --><\/a>.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">\u00a0<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\"><a class=\"chakra-link css-ug8vf0\" href=\"https:\/\/blog.ethereum.org\/images\/posts\/2016\/07\/92730668-4473-11e6-8a49-fef5d43a1eb7-1.png\"><img decoding=\"async\" alt=\"Stake Voice operational on the Mist Browser\" src=\"https:\/\/blog.ethereum.org\/images\/posts\/2016\/07\/92730668-4473-11e6-8a49-fef5d43a1eb7-1.png\" class=\"chakra-image css-hw6q2r\"\/><\/a> Stake Voice operational on the Mist Browser<!-- --><\/p>\n<p><!-- --><\/p>\n<h2 class=\"chakra-heading css-1w54o5f\" id=\"lets-get-to-it\">Let\u2019s dive in<!-- --><\/h2>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">We are set to create a straightforward application known as &#8220;Stake Voice&#8221;. The concept is to enable ether stakers to express their votes on any subject they choose, with the application tallying the total ether balance of all individuals who concur or dissent with the proposition.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">The foundational contract of the application is crafted in <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/solidity.readthedocs.io\/en\/latest\/\">Solidity<!-- --><\/a>, a javascript-like syntax which is quite elementary:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>contract EtherVote <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0event LogVote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>bytes32 indexed proposalHash, bool pro, address addr<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">function<!-- --><\/span><span> vote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>bytes32 proposalHash, bool pro<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">if<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>msg.value <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&gt;<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(247, 140, 108)\">0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> throw<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0LogVote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>proposalHash, pro, msg.sender<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token function-name\" style=\"color:rgb(130, 170, 255)\">function<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span> throw<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">The initial line establishes the contract name and the subsequent line generates an event titled &#8220;LogVote&#8221;, which will record the following in the logs:<!-- --><\/p>\n<p><!-- --><\/p>\n<ul role=\"list\" class=\"css-1onhfjo\">\n<li class=\"css-cvpopp\">a hash of the proposal under voting<!-- --><\/li>\n<li class=\"css-cvpopp\">whether the voter is in favor or against it<!-- --><\/li>\n<li class=\"css-cvpopp\">the voter&#8217;s address<!-- --><\/li>\n<\/ul>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">The &#8220;vote&#8221; function will subsequently trigger the log, which the application will later tally. Additionally, it includes a validation to ensure that no ether is sent unintentionally. The \u201canonymous\u201d function executes when any ether is added to the smart contract and will effectively reject it.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">To deepen your understanding of coding in Solidity, we recommend starting with the <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/ethereum.org\/token\">ethereum<!-- --><\/a> <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/ethereum.org\/crowdsale\">solidity<!-- --><\/a> <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/ethereum.org\/dao\">tutorials<!-- --><\/a>, reviewing the \u00a0<!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/solidity.readthedocs.io\/en\/latest\/\">official documentation page<!-- --><\/a>, and experimenting on your browser using the <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/ethereum.github.io\/browser-solidity\/#version=soljson-latest.js\">online compiler<!-- --><\/a>.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">That&#8217;s fundamentally it: you select a hash,&#8220;`html<br \/>\nchoose a position and perform Vote(). So how does this convert into a voting application?<!-- --><\/p>\n<p><!-- --><\/p>\n<h2 class=\"chakra-heading css-1w54o5f\" id=\"serverless-architecture\">Serverless Infrastructure<!-- --><\/h2>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Adhering to the KISS principle, we are creating the simplest viable product that remains functional, which signifies that we will not utilize databases for holding proposals or implement any capabilities that depend on anything beyond basic JavaScript and standard HTML.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Thus, we will make use of the app&#8217;s URL to retain the proposal content, which we will then leverage to present to the user and create a hash that can subsequently verify the votes. Users can share their desired proposals for discussion via social media or opt for direct links.<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>\/\/ During the initial startup operation:\n<!-- --><\/span><span>proposal <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> decodeURI<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>getParameterByName<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'proposal'<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">))<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span>\n<!-- -->\/\/ <!-- --><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<h2 class=\"chakra-heading css-1w54o5f\" id=\"start-with-basics\">Begin with the fundamentals<!-- --><\/h2>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">So obtain your preferred HTML framework and set up a basic site on your local device, then access it through Mist. All pages within Mist have access to a JavaScript object known as web3, where you will predominantly be operating. First, we should ascertain whether web3 is available:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>Function <!-- --><\/span><span class=\"token function-name\" style=\"color:rgb(130, 170, 255)\">init<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">..<!-- --><\/span><span>.\n<!-- --><\/span><span>if<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>typeof web3 <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">==<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'undefined'<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>\u00a0   \/\/ Notify the user that they are not <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">in<!-- --><\/span><span> a web3 compatible browser\n<!-- --><\/span><span>\u00a0\u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">return<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span> \u00a0\u00a0\u00a0\n<!-- --><\/span><span>\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span> <!-- --><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Some developers may wish to load their own web3 object to ensure future compatibility. To accomplish this, simply add just before <!-- --><em class=\"chakra-text css-0\"\/><\/p>\n<\/article>\n<\/div>\n<\/div>\n<p><\/main><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><\/body><!-- --><\/p>\n<p> tag:<!-- --><\/p>\n<p><!-- --><br \/>\n<!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">And then incorporate this into your initial function to load your custom web3 provider:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>\/\/ Verifies Web3 support\n<!-- --><\/span><span>if<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>typeof web3 <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!=<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'undefined'<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&amp;&amp;<!-- --><\/span><span> typeof Web3 <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!=<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'undefined'<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>\u00a0\u00a0\u00a0\u00a0\/\/ If a web3 library is loaded, proceed to construct your own web3\n<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\u00a0\u00a0\u00a0\u00a0web3 = new Web3(web3.currentProvider);\n<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">} else if (typeof Web3 !== '<!-- --><\/span><span>undefined<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">') {\n<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\u00a0\u00a0\u00a0\u00a0\/\/ If there isn'<!-- --><\/span><span>t <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">then<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">set\n``````html\n<!-- --><\/span><span> a supplier\n<!-- --><\/span><span>\u00a0\u00a0\u00a0\u00a0web3 <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> new Web3<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>new Web3.providers.HttpProvider<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"http:\/\/localhost:8545\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">))<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">otherwise<!-- --><\/span><span> if<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>typeof web3 <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">==<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'undefined'<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>\u00a0\u00a0\u00a0\u00a0\/\/ Notify the user that they are not <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">within<!-- --><\/span><span> a web3 compatible browser\n<!-- --><\/span><span>\u00a0\u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">return<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span> \u00a0\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<h2 class=\"chakra-heading css-1w54o5f\" id=\"load-information-from-the-blockchain\">Retrieve data from the blockchain<!-- --><\/h2>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">You verified you are connected to a blockchain, but which one is it? Is it the main ethereum network? Possibly a testnet or a private network? It might even be a future fork and your chain is entirely new. The most effective method to confirm this is to check whether the contract address you aim to access has any code present.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Moreover, to\u00a0execute a contract, you need to know two fundamental elements: its address and the ABI, which will be a JSON encoded file that holds interface details.<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>var contractAddress <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'0x1e9d5e4ed8ef31cfece10b4c92c9057f991f36bc'<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span>var contractABI <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"constant\"<!-- --><\/span><span>:false,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"inputs\"<!-- --><\/span><span>:<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"name\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"proposalHash\"<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"type\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"bytes32\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"name\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"pro\"<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"type\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"bool\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"name\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"vote\"<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"outputs\"<!-- --><\/span><span>:<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"type\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"function\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"anonymous\"<!-- --><\/span><span>:false,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"inputs\"<!-- --><\/span><span>:<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"indexed\"<!-- --><\/span><span>:true,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"name\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"proposalHash\"<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"type\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"bytes32\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"indexed\"<!-- --><\/span><span>:false,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"name\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"pro\"<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"type\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"bool\"<!-- --><\/span>\n``````html\n<span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"indexed\"<!-- --><\/span><span>:false,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"name\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"addr\"<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"type\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"address\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"name\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"LogVote\"<!-- --><\/span><span>,<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"type\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 203, 139)\">:<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"event\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">With that information in hand, it&#8217;s possible for you to verify the existence of the contract within the startup function:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>\/\/ Retrieve the contract\n<!-- --><\/span><span>web3.eth.getCode<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>contractAddress, function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>e, r<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>    <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">if<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!<!-- --><\/span><span>e <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&amp;&amp;<!-- --><\/span><span> r.length <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&gt;<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(247, 140, 108)\">3<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>\n<!-- --><\/span><span>    \u00a0   loadContract<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span>\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>\n<!-- --><\/span> <!-- --><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">It is also feasible to execute this command repeatedly in an attempt to reconnect using a different address (in case you are indeed connected to the testnet). Upon locating your contract, you can load it here:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>\n<!-- --><\/span><span>Function \u00a0\u00a0<!-- --><\/span><span class=\"token function-name\" style=\"color:rgb(130, 170, 255)\">loadContract<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span>\/\/ import the contract to javascript\n<!-- --><span> \u00a0\u00a0\u00a0\u00a0\u00a0ethervoteContract <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> web3.eth.contract<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>contractABI<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0ethervote <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> ethervoteContract.at<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>contractAddress<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Utilizing the web3 object permits you to establish a brand new javascript object capable of carrying out all ethereum operations directly via the browser. Should you wish to load merely a single instance of the contract, it&#8217;s possible to accomplish it in a single line:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span> \u00a0\u00a0\u00a0\n<!-- --><\/span><span>ethervote <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> web3.eth.contract<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>contractABI<!-- -->\n```<\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>.at<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>contractAddress<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<h2 class=\"chakra-heading css-1w54o5f\" id=\"identify-the-user\">Identify the user<!-- --><\/h2>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Understanding the user&#8217;s account discloses a substantial amount of details about them: the balance of ether and any other tokens they possess, along with their transaction history. Therefore, having all applications recognize this by default could lead to a super cookie phenomenon, which would represent an intolerable breach of privacy. Conversely, mandating that the user register an account complete with login credentials for each website is not only bothersome for the individual, but also places their sensitive information under the control of third-party entities, resulting in significant honey pots that hackers can infiltrate.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Consequently, most individuals find that their personal and authentication data is <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/xkcd.com\/1150\/\">managed by a handful of billion-dollar corporations<!-- --><\/a>. Privacy should not be a trade-off we accept for the sake of convenience: users ought to effortlessly authenticate into any application while retaining authority over their personal information.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">With Mist, applications do not possess any details about the user until the individual chooses to disclose themselves to the application. When you wish to inquire about the accounts, the getAccounts function should be called:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>web3.eth.getAccounts<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>e,accounts<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>    <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">if<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!<!-- --><\/span><span>e<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>        \/\/ <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">do<!-- --><\/span><span> something with the accounts\n<!-- --><\/span><span>   <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">At present, the returned object is an array that contains straightforward accounts accessible to the user, but in the future, it will also incorporate smart contract accounts the user employs for identification purposes. This will enable users to access functionalities currently reserved for centralized authenticators, such as two-factor authentication or cloud backup, along with future advancements unique to smart contracts, like permitting a few trusted friends to grant you access to an account for which you&#8217;ve lost the keys or facilitating automatic inheritance of dormant accounts.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Every forthcoming Ethereum browser will manage how users identify themselves to the application. Within Mist, we have two methods: either the user can initiate it by pressing the &#8220;connect&#8221; button (currently labeled as a &#8220;no accounts&#8221; button) or the application can solicit authentication by invoking the &#8220;requestAccount&#8221; API.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Notice: the accounts listed here are merely those that the user claims to control the key for, but the user has not provided any evidence of this; therefore, you may present a different interface, but do not transmit any confidential information designated solely for that account. If you require verification of the user\u2019s identity, you will need them to sign a message. While Mist will also support this in the future, be aware that it would necessitate an additional step for the user to enter their password, so this should only be implemented when absolutely essential.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">\u00a0<!-- --><\/p>\n<p><!-- --><\/p>\n<h2 class=\"chakra-heading css-1w54o5f\" id=\"voting\">Voting<!-- --><\/h2>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Once you possess the contract as an object, executing votes is simply a matter of invoking it from JavaScript. This will trigger a Mist transaction pane, allowing the user to verify the transaction before entering their password. Thus, we will first create two interactive objects that call a vote function:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span> \u00a0\u00a0\u00a0\n<!-- --><\/span><span>document.getElementById<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'vote-support'<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>.addEventListener<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'click'<!-- --><\/span><span>, <!-- --><\/span><span class=\"token function-name\" style=\"color:rgb(130, 170, 255)\">function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span> vote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>true<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span>```html\n<span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>, <!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 88, 116)\">false<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span>document.getElementById<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'vote-against'<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>.addEventListener<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'click'<!-- --><\/span><span>, <!-- --><\/span><span class=\"token function-name\" style=\"color:rgb(130, 170, 255)\">function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span> vote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>false<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>, <!-- --><\/span><span class=\"token\" style=\"color:rgb(255, 88, 116)\">false<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Observe that one invokes the function with a true argument while the other employs false. The vote function may be as straightforward as:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>Function <!-- --><\/span><span class=\"token function-name\" style=\"color:rgb(130, 170, 255)\">vote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>    ethervote.vote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>proposalHash, support, <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>from: web3.eth.accounts<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span class=\"token\" style=\"color:rgb(247, 140, 108)\">0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">&#8220;Ethervote&#8221; represents the entity we established earlier, and &#8220;vote&#8221; is one of its methods, corresponding to one of the contract methods:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span class=\"token\" style=\"color:rgb(127, 219, 202)\">function<!-- --><\/span><span> vote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>bytes32 proposalHash, bool pro<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">We supply the two required parameters for the function and then incorporate a third object that includes transaction details, such as the sender&#8217;s address and, optionally, how much gas to allocate or the cost of the gas.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">As a result, this would prompt a dialog requesting the user to verify the transaction &#8211; yet it will likely produce an error because the web3.eth.accounts object is an empty array by default; therefore, it is necessary to validate this and if it is empty, prompt the user to provide the accounts:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span class=\"token\" style=\"color:rgb(127, 219, 202)\">function<!-- --><\/span><span> vote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>support<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span>\n<!-- --><span>     web3.eth.getAccounts<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>e,accounts<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>        \/\/ Verify <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">if<!-- --><\/span><span> there are accounts accessible\n<!-- --><\/span><span>        <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">if<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!\n``````html\n<!-- --><\/span><span>e <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&amp;&amp;<!-- --><\/span><span> accounts <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&amp;&amp;<!-- --><\/span><span> accounts.length <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&gt;<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(247, 140, 108)\">0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span>            \/\/ Create a dialog initiating the transaction\n<!-- --><span>            ethervote.vote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>proposalHash, support, <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>from: accounts<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span class=\"token\" style=\"color:rgb(247, 140, 108)\">0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>\n<!-- --><\/span>\n<!-- --><span>          <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">else<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>            mist.requestAccount<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>e, account<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>                if<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!<!-- --><\/span><span>e<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span>                    \/\/ Create a dialog initiating the transaction\n<!-- --><span>                    ethervote.vote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>proposalHash, support, <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>from: account.toLowerCase<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>\n<!-- --><\/span><span>                <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><span>            <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span>        <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><span>    <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">You ought to only ask for an account when the user has initiated an action: unexpectedly pinging a transaction will rightfully frustrate the user and likely prompt him to exit your application. Should we notice misuse of this feature by applications, we may implement more stringent requirements regarding when a notification appears.<!-- --><\/p>\n<p><!-- --><\/p>\n<h2 class=\"chakra-heading css-1w54o5f\" id=\"watch-the-contract\">Monitor the contract<!-- --><\/h2>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Lastly, in order to tally all the votes, it&#8217;s necessary to observe the contract events and determine which votes were cast. To accomplish this, we must execute this function once to commence monitoring the events, subsequent to instantiating &#8220;ethervote&#8221;:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>ethervote <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> web3.eth.contract<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>contractABI<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>.at<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>contractAddress<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span>var logVotes <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> ethervote.LogVote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>proposalHash: proposalHash<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>, <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>fromBlock: <!-- --><\/span><span class=\"token\" style=\"color:rgb(247, 140, 108)\">1800000<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span>\/\/ Wait <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">for<!-- --><\/span><span> the events to load\n<!-- --><\/span><span>logVotes.watch<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>error, result<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">if<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!<!-- --><\/span><span>error<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n<!-- --><\/span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ Perform an action whenever the event\n```happens\n<!-- --><span> \u00a0\u00a0\u00a0\u00a0\u00a0receivedEvent<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>result<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">The code provided above will commence retrieving all blocks from 1.8M onwards (the moment the contract was deployed) and subsequently execute the receivedEvent() function for each event. Each time a new block is received containing an event, this function will be activated again, thus eliminating the need for constant calls. So, what exactly does this function do?<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>Var voteMap <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span>Function receivedEvent<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>event<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span> \u00a0\u00a0\u00a0\/\/ Retrieve the present balance of a voter \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n<!-- --><span> \u00a0\u00a0\u00a0var bal <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> Number<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>web3.fromWei<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>web3.eth.getBalance<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>event.args.addr<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>, <!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"finney\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">))<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0voteMap<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span>res.args.addr<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>balance: bal, support: event.args.pro<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">From the original solidity contract, you can observe that the LogVote event includes three arguments: proposalHash, Pro, and Addr:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>event LogVote<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>bytes32 indexed proposalHash, bool pro, address addr<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Thus, the operation of this function entails utilizing the web3.eth.getBalance function to verify the current ether balance of the voting address. All balances consistently return figures in wei, which represents 1\/1000000000000000000 of an ether and is not particularly useful in this context; therefore, we utilize a different web3 function that converts it into any ether unit of our choice. In this instance, we will use finney, which corresponds to a thousandth of an ether.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Following that, the function will store the balance along with the voter&#8217;s position in a mapping based on their address. One benefit of employing a mapping in place of an array is that it will automatically override any previous data relating to the same address; thus, if an individual votes multiple times, only their most recent stance will be retained.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Additionally, we could potentially identify the user and indicate whether they have voted or not.<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>\/\/ Verify <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">if<!-- --><\/span><span> the present owner has already cast their vote and display that on the interface\n<!-- --><\/span><span>web3.eth.getAccounts<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>e,accounts<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>    <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">if<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span>```html\n<span class=\"token\" style=\"color:rgb(127, 219, 202)\">!<!-- --><\/span><span>e <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&amp;&amp;<!-- --><\/span><span> accounts <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&amp;&amp;<!-- --><\/span><span> accounts<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span class=\"token\" style=\"color:rgb(247, 140, 108)\">0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">==<!-- --><\/span><span> res.args.addr<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>        <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">if<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>res.args.pro<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>            \/\/ User has cast a positive vote<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!<!-- --><\/span><span>\n<!-- --><\/span><span>        <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">else<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>            \/\/ User has voted negatively<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!<!-- --><\/span><span>\n<!-- --><\/span><span>        <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><span>    <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<h2 class=\"chakra-heading css-1w54o5f\" id=\"tally-up-the-votes\">Count the votes<!-- --><\/h2>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">In conclusion, we need to introduce a distinct function for totaling the votes:<!-- --><\/p>\n<p><!-- --><br \/>\n<!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">What is the reason for tallying votes in a separate function? Since the weight of each vote is derived from the current balance of every account, it is essential to recalculate these balances with every new block, even if no new event has transpired. To accomplish this, you can implement the following function that triggers automatically with each new block entry:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>web3.eth.filter<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'latest'<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>.watch<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>e, result<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0if<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!<!-- --><\/span><span>e<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0calculateVotes<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span> <!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Eventually, we will move on to the final total calculation. Previously, we utilized eth.getBalance in synchronous fashion, where the application awaited the outcome of the preceding action. Now, since multiple actions may be invoked during each block, we will employ it in asynchronous mode: calling the node and executing the action when it responds, all while keeping the interface fluid.<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>var totalPro, totalAgainst, totalVotes<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(127, 219, 202)\">function<!-- --><\/span><span> <!-- --><\/span><span class=\"token function-name\" style=\"color:rgb(130, 170, 255)\">calculateVotes<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0totalPro <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(247, 140, 108)\">0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0totalAgainst <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(247, 140, 108)\">0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0totalVotes <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> <!-- --><\/span>\n``````html\n<span class=\"token\" style=\"color:rgb(247, 140, 108)\">0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0Object.keys<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>voteMap<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>.map<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>a<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ invoke the <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">function<!-- --><\/span><span> asynchronously\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0web3.eth.getBalance<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>a, function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>e,r<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0voteMap<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span>a<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span>.balance <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> Number<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>web3.fromWei<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>r, <!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'finney'<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">))<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">if<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>voteMap<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span>a<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span>.support<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0totalPro <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">+=<!-- --><\/span><span> parseFloat<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>voteMap<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span>a<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span>.balance<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">else<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0totalAgainst <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">+=<!-- --><\/span><span> parseFloat<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>voteMap<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">[<!-- --><\/span><span>a<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">]<!-- --><\/span><span>.balance<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">perform<!-- --><\/span><span> something exciting with the outcomes<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n<!-- --><\/span><span> \u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span\/><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">As you can see from the code, the application iterates through each voting address to fetch their balance, and upon receiving it, it will either contribute to the pro or against camp and calculate the totals.<!-- --><\/p>\n<p><!-- --><br \/>\n<!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">A few additional warnings: if no events occur, nothing will be retrieved and votes won&#8217;t be computed, so it&#8217;s advisable to include a timeout mechanism in all functions that depend on events from the blockchain.<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span>setTimeout<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token function-name\" style=\"color:rgb(130, 170, 255)\">function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ In case the application does not respond post a <!-- --><\/span><span class=\"token\" style=\"color:rgb(130, 170, 255)\">timeout<!-- --><\/span><span> it likely has no votes\n<!-- --><\/span><span> \u00a0\u00a0\u00a0<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>, <!-- --><\/span><span class=\"token\" style=\"color:rgb(247, 140, 108)\">3000<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Now, you are free to employ all your current web development techniques to create whatever impressive outcome you desire. Use the figures to craft a captivating 3D visualization or link to your preferred social media to promote the most intriguing questions.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">Mist also aims to streamline your code by offering some fundamental navigation and UI functionalities. If you wish for your application to be headerless and take up the full height of the mist app, simply add the following to your <\/p>\n<p><head\/><\/p>\n<p> tag:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre>\n```<pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\"\/><span>meta <!-- --><\/span><span class=\"token assign-left\" style=\"color:rgb(214, 222, 235)\">name<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"ethereum-dapp-url-bar-style\"<!-- --><\/span><span> <!-- --><\/span><span class=\"token assign-left\" style=\"color:rgb(214, 222, 235)\">content<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">\"transparent\"<!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&gt;<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">In the event that you wish to utilize Mist itself for navigating your application, you can employ the <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/github.com\/ethereum\/mist\/blob\/develop\/MISTAPI.md#mistmenu\">Mist.menu<!-- --><\/a> object:<!-- --><\/p>\n<p><!-- --><\/p>\n<div class=\"chakra-stack css-1uyok63\">\n<pre><pre style=\"color:white;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:0.5em 0;overflow:auto;background:#011627\"><code class=\"language-bash\" style=\"color:#d6deeb;font-family:Consolas, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;font-size:1em;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none\"><span class=\"token\" style=\"color:rgb(127, 219, 202)\">for<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>item of propHistory<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>    <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">if<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>item.length <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&gt;<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(247, 140, 108)\">0<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">&amp;&amp;<!-- --><\/span><span> item <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">!=<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'null'<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>        mist.menu.add<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span> item ,<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span>        name: item,\n<!-- -->        position: n++,\n<!-- --><span>        selected: item <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">==<!-- --><\/span><span> proposal\n<!-- --><\/span><span>        <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>, <!-- --><\/span><span class=\"token function-name\" style=\"color:rgb(130, 170, 255)\">function<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">{<!-- --><\/span><span>\n<!-- --><\/span><span>            window.location.search <!-- --><\/span><span class=\"token\" style=\"color:rgb(127, 219, 202)\">=<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(173, 219, 103)\">'?proposal='<!-- --><\/span><span> + encodeURI<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">(<!-- --><\/span><span>this.name<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span>        <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">)<!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">;<!-- --><\/span><span>\n<!-- --><\/span><span>    <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><span>\n<!-- --><\/span><span> <!-- --><\/span><span class=\"token\" style=\"color:rgb(199, 146, 234)\">}<!-- --><\/span><\/code><\/pre>\n<\/div>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">An excellent feature of Ethereum is the capability to build upon this straightforward contract functionality without requiring authorization: you can append additional functions on distinct contracts, maintaining each one simple and more manageable for troubleshooting. Furthermore, it allows others to incorporate the contracts you established into their applications, thereby providing new functionality. Meanwhile, all applications access the same data and backend.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\">You can experiment with this application live hosted on <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/github.com\/ethereum\/stake-voice\">github pages<!-- --><\/a>, but keep in mind that this isn&#8217;t the authoritative source, just one of numerous potential interfaces to it. The same application will also function as a local HTML file on your device or on an <!-- --><a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-ug8vf0\" href=\"https:\/\/ipfs.io\/\">IPFS network<!-- --><\/a> and it is expected that it will be downloaded directly via Mist utilizing Swarm in the future.<!-- --><\/p>\n<p><!-- --><\/p>\n<p class=\"chakra-text css-gi02ar\"><b>Here are some concepts on how you might explore:<!-- --><\/b><\/p>\n<p><!-- --><\/p>\n<ul role=\"list\" class=\"css-1onhfjo\">\n<li class=\"css-cvpopp\">Form a list of currently accessible statements. Anyone can verify them by viewing the sha3 of the proposal text, hence you don&#8217;t require permission.<!-- --><\/li>\n<li class=\"css-cvpopp\">Establish threaded comments where users can respond to statements and subsequently upvote or downvote them, akin to a decentralized stake-based Reddit<!-- --><\/li>\n<li class=\"css-cvpopp\">Rather than (or in addition to) utilizing ether balance, you could use another Ethereum token, such as The DAO or Digix Gold to differentiate your questions. Given that all the original contract registers is the sender, you can review all balances. Alternatively, you might create your own currency based on reputation, karma, or another criterion.<!-- --><\/li>\n<\/ul>\n<p><!-- --><br \/>\n<!-- --><span\/><\/div>\n<p><br \/>\n<br \/><a href=\"https:\/\/blog.ethereum.org\/en\/2016\/07\/12\/build-server-less-applications-mist\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to create serverless applications for Mist | Ethereum Foundation Blog Published by Alex Van de Sande on July 12, 2016 Ethereum is not envisioned to serve as a platform for constructing obscure smart contract applications that necessitate a STEM degree to comprehend; rather, it aspires to be a foundational element of a different framework<\/p>\n","protected":false},"author":3,"featured_media":8282,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[1421],"class_list":["post-8905","post","type-post","status-publish","format-standard","has-post-thumbnail","category-ethereum","tag-return-a-list-of-comma-separated-tags-from-this-title-how-to-build-server-less-applications-for-mist"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Building Serverless Applications for Mist: A Comprehensive Guide - WSJ-Crypto<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building Serverless Applications for Mist: A Comprehensive Guide - WSJ-Crypto\" \/>\n<meta property=\"og:description\" content=\"How to create serverless applications for Mist | Ethereum Foundation Blog Published by Alex Van de Sande on July 12, 2016 Ethereum is not envisioned to serve as a platform for constructing obscure smart contract applications that necessitate a STEM degree to comprehend; rather, it aspires to be a foundational element of a different framework\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"WSJ-Crypto\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-23T05:20:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"2100\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"wsjcrypto\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Scritto da\" \/>\n\t<meta name=\"twitter:data1\" content=\"wsjcrypto\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo di lettura stimato\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/\",\"url\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/\",\"name\":\"Building Serverless Applications for Mist: A Comprehensive Guide - WSJ-Crypto\",\"isPartOf\":{\"@id\":\"https:\/\/wsj-crypto.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg\",\"datePublished\":\"2025-02-23T05:20:54+00:00\",\"author\":{\"@id\":\"https:\/\/wsj-crypto.com\/#\/schema\/person\/88a93723b30416db1a352d5a0096c4a7\"},\"breadcrumb\":{\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/#primaryimage\",\"url\":\"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg\",\"contentUrl\":\"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg\",\"width\":2100,\"height\":900},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wsj-crypto.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building Serverless Applications for Mist: A Comprehensive Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wsj-crypto.com\/#website\",\"url\":\"https:\/\/wsj-crypto.com\/\",\"name\":\"WSJ-Crypto\",\"description\":\"Just Another Crypto News Website\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wsj-crypto.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/wsj-crypto.com\/#\/schema\/person\/88a93723b30416db1a352d5a0096c4a7\",\"name\":\"wsjcrypto\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/wsj-crypto.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/86fe8af82ea089646d6639ca2f87e0243d8688d957bd8e3ec22ec3c457cc16d4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/86fe8af82ea089646d6639ca2f87e0243d8688d957bd8e3ec22ec3c457cc16d4?s=96&d=mm&r=g\",\"caption\":\"wsjcrypto\"},\"url\":\"https:\/\/wsj-crypto.com\/index.php\/author\/wsjcrypto\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Building Serverless Applications for Mist: A Comprehensive Guide - WSJ-Crypto","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/","og_locale":"it_IT","og_type":"article","og_title":"Building Serverless Applications for Mist: A Comprehensive Guide - WSJ-Crypto","og_description":"How to create serverless applications for Mist | Ethereum Foundation Blog Published by Alex Van de Sande on July 12, 2016 Ethereum is not envisioned to serve as a platform for constructing obscure smart contract applications that necessitate a STEM degree to comprehend; rather, it aspires to be a foundational element of a different framework","og_url":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/","og_site_name":"WSJ-Crypto","article_published_time":"2025-02-23T05:20:54+00:00","og_image":[{"width":2100,"height":900,"url":"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg","type":"image\/jpeg"}],"author":"wsjcrypto","twitter_card":"summary_large_image","twitter_misc":{"Scritto da":"wsjcrypto","Tempo di lettura stimato":"16 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/","url":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/","name":"Building Serverless Applications for Mist: A Comprehensive Guide - WSJ-Crypto","isPartOf":{"@id":"https:\/\/wsj-crypto.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/#primaryimage"},"image":{"@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg","datePublished":"2025-02-23T05:20:54+00:00","author":{"@id":"https:\/\/wsj-crypto.com\/#\/schema\/person\/88a93723b30416db1a352d5a0096c4a7"},"breadcrumb":{"@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/"]}]},{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/#primaryimage","url":"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg","contentUrl":"https:\/\/wsj-crypto.com\/wp-content\/uploads\/2025\/02\/eth-org.jpeg","width":2100,"height":900},{"@type":"BreadcrumbList","@id":"https:\/\/wsj-crypto.com\/index.php\/2025\/02\/23\/building-serverless-applications-for-mist-a-comprehensive-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wsj-crypto.com\/"},{"@type":"ListItem","position":2,"name":"Building Serverless Applications for Mist: A Comprehensive Guide"}]},{"@type":"WebSite","@id":"https:\/\/wsj-crypto.com\/#website","url":"https:\/\/wsj-crypto.com\/","name":"WSJ-Crypto","description":"Just Another Crypto News Website","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wsj-crypto.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/wsj-crypto.com\/#\/schema\/person\/88a93723b30416db1a352d5a0096c4a7","name":"wsjcrypto","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/wsj-crypto.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/86fe8af82ea089646d6639ca2f87e0243d8688d957bd8e3ec22ec3c457cc16d4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/86fe8af82ea089646d6639ca2f87e0243d8688d957bd8e3ec22ec3c457cc16d4?s=96&d=mm&r=g","caption":"wsjcrypto"},"url":"https:\/\/wsj-crypto.com\/index.php\/author\/wsjcrypto\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/posts\/8905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/comments?post=8905"}],"version-history":[{"count":2,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/posts\/8905\/revisions"}],"predecessor-version":[{"id":8909,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/posts\/8905\/revisions\/8909"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/media\/8282"}],"wp:attachment":[{"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/media?parent=8905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/categories?post=8905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wsj-crypto.com\/index.php\/wp-json\/wp\/v2\/tags?post=8905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}