<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tanvi Sheth on Medium]]></title>
        <description><![CDATA[Stories by Tanvi Sheth on Medium]]></description>
        <link>https://medium.com/@sheth.tanvi18?source=rss-6c8172dff473------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BEbPdpdNKUc7bQuPjLRpRw.jpeg</url>
            <title>Stories by Tanvi Sheth on Medium</title>
            <link>https://medium.com/@sheth.tanvi18?source=rss-6c8172dff473------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:31:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sheth.tanvi18/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[10x vs 10%]]></title>
            <link>https://medium.com/@sheth.tanvi18/10x-vs-10-4c8e8e82b80e?source=rss-6c8172dff473------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c8e8e82b80e</guid>
            <dc:creator><![CDATA[Tanvi Sheth]]></dc:creator>
            <pubDate>Sat, 20 May 2023 04:23:46 GMT</pubDate>
            <atom:updated>2023-05-23T02:09:48.296Z</atom:updated>
            <content:encoded><![CDATA[<h4>X — The largest moonshot factory in the world</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eGHkrdRHgidAkGQy25f39g.jpeg" /></figure><p><strong>Astro Teller works on a 10x scale.</strong></p><p>For those who don’t know Astro Teller, he’s an entrepreneur, scientist, engineer, and author, but his real expertise is impact. Impact through iteration. Take note of how I didn&#39;t say innovation.</p><p>And I got a chance to spend 30 minutes with him last week, asking him any question that came to mind. He’s the reason I started my one-crazy-thing-a-week journal, to internalize the crazy experiences that only a handful of people get and to recognize that<em> none of this is normal</em> (as <a href="https://www.linkedin.com/in/ian-lockhart-203819ab/">Ian </a>says).</p><blockquote>Let&#39;s start off with an AMA with Astro Teller. This article is more of a brain dump of me figuring out <em>why </em>he made every comment that he did on this call.</blockquote><p>“You’re gonna be limiting yourself by trying to find the perfect problem.”</p><p>Striving for perfection is the barrier to progress and growth, that I’ve understood fully. But there’s a reason why. When you’re trying to find the perfect problem, you’re taking away your valuable time and internal curiosity from something more important; <em>how you’re fixing it.</em></p><p>As long as you care about this problem, it&#39;s time to move on. It’s time to think of how fast you can learn about your solution. <strong>This is where you’ll get your validation; whether you’ve chosen the right thing to work on or not.</strong></p><p>This is how he explained it: if it takes hundreds of hours or millions of dollars to get that first bit of information for your solution, you’re likely never going to get it.</p><p><strong>That’s your sign to move on again.</strong></p><p>At X, pace and progress are valued over everything else. If two people are working on a project, and one makes the decision of killing it faster, they are celebrated. They hustled to find that bit of information first, recognizing the inviability of the solution faster.</p><p><strong>That just means more time on a more impactful one. Great. Move on.</strong></p><p>Nike says, ‘Just Do It.’ You quickly realize the return of ‘just doing it’ once you normalize it.</p><p>At X, they want to get to a point of 0 research, where their sole function is to impact by <em>building off of research.</em> Just doing it.</p><p>Instead of investigating or inventing A, B, and C, they focus on how A, B, and C can be combined to make the biggest impact possible. That’s why they are an impact factory and not a research organization. Iteration, tinkering, and finding a new way to put things together, sums up the work that is done at X.</p><p>According to Astro, <strong>research </strong>is the seeking of knowledge, which is indirectly obtained to make an impact. But here’s my take on this. Progress at an exponential pace &gt; proving everything right before moving on. In other words; striving for efficiency.</p><p>Research entails understanding the world around you, and then hopefully doing something helpful with your <em>potential </em>newfound discovery.</p><p>X ‘gets to’ stand on top of these potential discoveries, still acknowledging that they would be nothing without this foundation of knowledge holding them up.</p><p>That’s why I’ve come to a conclusion. X doesn’t want to invent things. Since they’re obsessed with efficiency, they merely build off of existing questions in the world.</p><blockquote><em>I think this is sufficient, because following through with a question and checking it off the list of ‘whys,’ is a significantly bigger step forward than adding a new ‘why’ to the list.</em></blockquote><p>I’ve recognized that X focuses on <em>knowing only what they need to know.</em> They’re <em>intentional </em>about what they need to figure out to make the project work.</p><p>I’ve recognized the significance of this, and in turn, the ineffectiveness of taking courses over building projects. Through a course, you learn content that you’ll never apply again, essentially wasting your time and energy trying to understand something that you never will <em>until you put it to use</em>.</p><p>When you build a project, you force yourself to figure out very specific details, and they’re a necessity to understand for your build to come together. You’re reinforcing each bit of knowledge in a specific context, helping you achieve a specific goal. Everything you learn is being put to use, and you’re guaranteeing that you actually understand the content.</p><p>Applying knowledge to a context is essentially acquiring experience. This is no news, but experience &gt; inapplicable knowledge.</p><p>I’ve had a few experiences with ‘innovating’ this past year, through hackathons, challenges, or moonshot projects.</p><p>My approach to each of the projects slightly changed over the year, as I gradually understood the concept and process of innovating in greater detail.</p><p><strong>Innovating does not equal inventing</strong>, because this entails <em>starting from scratch</em>, with no research holding you up or data points for you to asses. This misconception was first unraveled on a call with <a href="https://www.linkedin.com/in/lynn-jennifer-kulli/">Lynn Jeniffer Kulli</a> a few months back.</p><p>Iterating on things has a much higher chance of <em>impact </em>than innovating. You can predict the risks, plan your paths to mitigation, and expect certain stakeholder reactions. When people think of impact, they often forget to consider who they’re impacting. They get carried away with ‘revolutionizing’ their lives when a slight enhancement might have gotten the job done better.</p><p>If you have a foundation that lets you move past the initial stepping stones of the innovation process, it&#39;s your responsibility to acknowledge it. If you know how ‘impactees’ have previously reacted to a similar innovation, it&#39;s your responsibility to figure out how to convert the negative reactions by iterating on the right things. When you have case studies (from previous ‘innovations’) to analyze, you can optimize for impact by having a clear path on what to improve on. All of my attempts at innovation somewhat reflect this mindset. Check them out.</p><p><strong>PurifyAI x Pizeo</strong> — Tackling water-borne diseases that impact 1.7 billion people through <em>widely used </em>collision-induced dissociation processes + novel computer vision technology. This unique combination <strong>saves 300, 000 lives</strong>.</p><p><strong>Walmart Bluelabs</strong>— <em>Minutely tweaking </em>an Autraillian in-store touchpoint, switching to a <em>simpler technology </em>that analyzes foot traffic, and bringing back in-person interactions. None of this is <em>revolutionary</em>, but it makes <strong>22 billion dollars worth of impact.</strong></p><p><strong>EmpowerRefuge</strong> — Leveraging the <em>pre-existing Interpol database </em>to reunite separated refugee families at <em>pre-existing</em> UNHCR Blue Dot camps + help them rebuild their lives through a<em> simple blockchain verification </em>process of skills and expertise. <strong>This solution guides 26 million people.</strong></p><p><strong>Amazon Alexa</strong> — <em>Building off of </em>Kindle’s newest release, Kindle Scribe, and <em>combining </em>its hardware with a large language model software + Alexa. <em>Three pre-existing tools</em> were reimagined together to produce a disruptive (productivity tool) alternative for $200 that makes an <strong>8 billion</strong> <strong>dollar impact.</strong></p><p><strong>PowerThreads</strong> — Using <em>thoroughly researched</em> energy harvest, storage, and transfer techniques and <em>combining </em>them together in the context of a textile. Resulting in piezo-material clothing that <em>transfers self-harvested energy to your phone by simply sliding it into your pocket. </em>This takes <strong>730 000 watts (per person, annually) </strong>of pressure off of our depleting resources and overwhelmed electrical grid.</p><p><a href="https://tks.life/profile#portfolio"><strong>Check them all out here.</strong></a></p><p>I got carried away there, but I’m glad that my attempts at innovation somewhat align with Astro’s process, and although he claims ‘they’re certainly not the best in the world,’ no one else is impacting the way they impact.</p><p>And this status can be attributed to their commitment to iteration, leveraging research, and celebrating failure over everything else.</p><p>At X, your job is not about being right. <em>It&#39;s about identifying the thing that’ll work.</em> If it ends up working, great. Thats evidence. If it doesn&#39;t, great. Still evidence.</p><p>Your job is actually more ‘secure’ if you take smart risks. Unlike most of the rest of the world, you don&#39;t keep your head down here for fear of losing your job. That’s probably how you will lose your job at X.</p><p>It&#39;s sucky, but you learn to be like that. There’s a reason you learn to be like that; to maintain the intricate hierarchy of our world.</p><p>It&#39;s even more sucky, complicated, and painful to unlearn this. If everyone was trained to take risks in this world, I’m curious to know where we would be. <em>Maybe our world would be too chaotic. Maybe we would be 10–20 years ahead.</em></p><p>Regardless, I’ve learned to celebrate stopping projects that are clearly heading toward failure, and value the minute details I ‘figure out’ along the way — more than the final product or the traction I gain as a result.</p><p>There are always details that make or break the final product, and you’re pretty much at the finish line, <em>once you figure this one thing out.</em> At X, you should care more about how you do things instead of what you do. I now value the small details that make my product/solution work, over the product itself. Success shouldn’t be the goal, the number of things you <em>figure out </em>and take away should.</p><p><strong>Strategy &gt; Right vs Wrong</strong></p><p>“Can you make it work?,” is the question that’s asked at X. If you can’t, move on to something that you can make work. If you’re unsure that you can, and there are possibilities of error, look at how much you can contract those error bars. This reward-risk investment, the reward for each dollar of risk you take, is how people approach decisions at X.</p><p>So, if your goal is changing the world, you’re on team X’s side, and if you can figure things out quickly, make things work, and kill projects when you can’t, you’re perfectly suited to be at X.</p><p>You’re perfectly suited to make an impact.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c8e8e82b80e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moonshot: PowerThreads]]></title>
            <link>https://studentsxstudents.com/moonshot-powerthreads-3a17a90d1c38?source=rss-6c8172dff473------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a17a90d1c38</guid>
            <dc:creator><![CDATA[Tanvi Sheth]]></dc:creator>
            <pubDate>Fri, 12 May 2023 23:49:55 GMT</pubDate>
            <atom:updated>2025-07-28T18:55:34.135Z</atom:updated>
            <content:encoded><![CDATA[<h4>Thinking 10x over 10%</h4><p><strong>Self-reliant clothing that relies on sustainability, leverages mobility, and restructures the world’s energy expenditure to impact millions.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*g5LrdSksRghKuXueH-99Sg.png" /></figure><blockquote><a href="https://power-threads.typedream.app/">Website</a><br><a href="https://firebasestorage.googleapis.com/v0/b/tks-life-prod.appspot.com/o/items%2FL8wYdJzBsQXYGSAodVKmuzUBLOg2%2FUntitled.pdf?alt=media&amp;token=b6e0ab87-ef17-4810-9c4c-a36fa03f56f1">One-Pager</a></blockquote><p>I was talking to my parents the other day and had a chance to let curiosity get the best of me while I asked them about every aspect of their lives in the 1900s.</p><p>Not to make them feel old, but rather to see the progression within society in the last 50 years. The conclusion I got from that hour-long conversation is that we live in an exciting age, where technology has accelerated and automated the fundamental processes of our daily lives.</p><p>And, these giant strides within civilization &amp; technology boil down to one capability — <strong>our ability to harness and deploy energy.</strong></p><p>To date, we’ve been relatively successful in getting the task done, but as the demand for energy grows, we are falling behind due to the inefficiencies within the current system. For reference, the global energy expenditure is expected to be around <strong>777 quintillion joules by the year 2040</strong>.</p><p>That’s a lot.</p><h4>Underlying Causes of Not Being Able To Meet The Demand; The Status Quo</h4><p>I’ll be honest, it’s hard for me to conceptualize the large-scale impact of the number, as I’ve never firsthand witnessed or faced a lack of electricity within my household system.</p><p>But, as I was reading <a href="https://todayshomeowner.com/solar/guides/what-is-grid-stress/">this article</a>, I was exposed to the lack of sustainability that comes with our status quo of electricity production, and fossil fuels — from a resources standpoint along with an environmental perspective. Not only are we still using fossil fuels; we are putting way too much pressure on our electric grid, and this demand will only increase.</p><p>Although fossil fuels have been the primary source of energy within our world for centuries, the estimated global energy expenditure of <strong>777 quintillion joules by the year 2040 </strong>cannot be met sustainably by relying on both, non-renewable sources such as fossil fuels and our current energy grid.</p><p>This is because fossil fuels are finite resources, which will eventually run out, leading to a world where we have no means to produce electricity anymore. Our electric grid was also designed to sustain drastically lower demands, and restructuring it is a notoriously difficult process.</p><p>It’s easy to sideline the issue as one might assume that fossil fuels hold no flaws and our electric grid is capable, but they actually aren’t.</p><p><strong>According to the International Energy Agency (IEA), around 759 million people worldwide do not have access to electricity.</strong></p><blockquote>This inefficient system introduces the need for a self-sustaining alternative that takes the load off of our depleting resources and overwhelmed electric system, restructuring the way we power our lives.</blockquote><h4>So what are we proposing?</h4><blockquote>A self-sufficient renewable energy source, powered by your daily activity.</blockquote><p><a href="https://power-threads.typedream.app/"><strong>PowerThreads</strong></a> is an energy harvesting, storage, and transfer textile that charges all small-sized electronics, eliminating the need for an external energy source in your day-to-day life. This fabric optimizes your mechanical movement to generate energy in real-time and leverages a perpetual resource to alleviate our every grid from tens of Twh (1 trillion terra watts per hour) every year.</p><p><strong>Our solution takes 730 000 watts of pressure, per person, off our electric grid — to be exact.</strong></p><h4><strong>How do we plan on doing this?</strong></h4><blockquote>Tesla Master Plan 2.0. PowerThreads edition.</blockquote><p>There are materials that enable energy harvesting, but limitations on their functionality make them impractical. Solar textiles cause limitations on daily usage, and other e-fabrics mainly consisting of conductive yarn increase cost, and production time, and inevitably create a high-end, premium product that cannot be mainstreamed.</p><h4><strong>But, we’re okay with that.</strong></h4><p>The materials and manufacturing are expensive because there is <em>limited </em>R&amp;D (research and design) done on them to optimize for efficiency. <strong>That’s why we’re here.</strong></p><p><strong>As Elon Musk said:</strong></p><blockquote>“any new technology initially has high unit cost before it can be optimized and this is no less true for [energy harvesting clothing]. We’re trying to charge a phone by simply sliding it into your product, and the nature of doing so seems impossible.”</blockquote><h4>Here’s the plan.</h4><p>Enter the premium market. Source our fabric to high-end designers, and present our product as the <strong>subsection of the apparel industry that has not yet been tapped into yet.</strong></p><p>Customers that are willing to pay the price will indirectly contribute to successive models of our fabric.</p><p>This funding will pave a path to entering the daily apparel industry by creating cost-effective manufacturing processes and in turn a lower price for brands to work with. <strong>We want to reach the largest number of users, enabling the largest number of creative minds to design products with our fabric.</strong></p><p>With the need for convenient power sources and the growing focus on sustainable energy solutions for the top problem in the world, our product will be the first choice for companies that revolve their brand image around flexibility and comfort for customers; tackling <strong>47%</strong> of the clothing market.</p><p>Moving away from a high-end product has two intentions; reaching a global market to align with our high-impact vision, and considering the state of underprivileged communities. For example, Telus donates countless used/recycled phones to those in desperate need, regardless of power source or shelter availability.</p><p>With all cash flow being thrown back into R&amp;D, our initial customers will be contributing to the development + revolution in the apparel industry that, if ranked alongside individual GDPs, would represent the seventh-largest economy in the world.</p><h3>Part 1: Energy Harvesting</h3><blockquote><em>We present an energy harvesting </em>piezoelectric <em>textile where the power output is enhanced by water.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gQFXLdhWYCBWvP6I" /></figure><p>When mechanical force or pressure is applied to PVDF, the material undergoes a change in shape or deformation. This causes the polarization of its molecular structure, resulting in the separation of positive and negative charges within the material. The accumulation of charges generates an electric potential or voltage across the material, which can be harvested as electrical energy.</p><p>The most promising ingredient here is piezoelectric materials; the yarn would consist of a conducting core surrounded by a material called poly(vinylidene fluoride) (PVDF). The fabric is woven using a loom, and the conducting core of the yarn is arranged in one direction (called the warp).</p><p>This is the inner ‘electrode’ that is fully shielded from the outer electrode, which is the conducting yarns. The conducting yarns are integrated into the other direction (called the weft).</p><p>This architecture is called <strong>core-sheath</strong>, where one electrode is hidden within the core of the fiber. This prevents short circuits when the fabric gets wet and performs better when it comes into contact with water.</p><blockquote>In this specific design, the core is likely used to create a uniform and consistent electric field across the material, while the conducting yarn electrode (sheath) is used to collect the electric charges generated by the piezoelectric material.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/0*r776aOK3Lg0gxebZ.jpg" /><figcaption>Core-sheath structure perspectives</figcaption></figure><h4>Comparisons + Rationale</h4><p>PVDF is a type of material that can crystallize in different phases, including α, β, γ, and δ. The β phase has the highest polarization and can convert mechanical energy into electrical energy with an efficiency of at least 11%. Previously described textile generators — tribo and thermoelectric — require both electrodes to be exposed to the surroundings, and consequently, more susceptible to short-circuiting from high humidity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*ipFWhUWzCcmogDwq.png" /><figcaption>Example of core-sheath structure (using Nylon as textile example)</figcaption></figure><h4>Experiments + Results</h4><p>Long story short, an experiment was conducted where the textile was integrated onto a shoulder strap. The load-bearing textile outputted a voltage of up to 8 V per step under wet conditions, as water enhanced the electrical contact surface area between fibers. A brisk walk with the case produced a continuous output of 4 W.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*c8ZQFveTXWn_1oXt.jpg" /><figcaption>Manufacture and piezoelectric behavior of woven bands. a). Photograph of the band weaving machine used for the production of the piezoelectric textiles. Photographs of the textile bands (b: dry; c: submerged in water) when stretched by hand: the output voltage is shown on the oscilloscope screen. Schematics (top) and photographs (bottom, scale bars are 1 mm) of produced (d) plain weave and (e) twill textile architectures; the warp consists of piezoyarns, the weft of conducting yarns (photos: PAcarbon black). Generated piezoelectric voltage of f plain weave and g twill textiles at f = 4 Hz and ε = 0.25%: outer electrodes are PAcarbon black (blue), PAsteel (grey), and PAsilver (red)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*t9USdLuJXwr8P3nL.jpg" /><figcaption>Results for outer electrode harvest potential. a). Equivalent electric circuit of the woven piezoelectric textiles with conducting yarns as outer electrodes. b). Predicted output peak voltage Vout (blue) and power (red) of textiles produced with PAsteel; PAsilver); and PAsilver -wet; Ci and Ri were measured, and Vout and the power were modeled with SPICE software LTspice. c). Equivalent electric circuit for a piezoelectric textile connected to an energy harvesting circuit (EHC). d). Predicted charging voltage stored in the EHC, Vstored (red), and output voltage Vout (blue); outer electrodes PAsilver -wet</figcaption></figure><blockquote>For textile applications, piezoelectric polymers are the most suitable choice due to their low weight in combination with outstanding flexibility and tensile strength, as well as an enhanced efficiency with water.</blockquote><h3>Part 2: Energy Storage</h3><blockquote><em>Energy harvesting from clothing seems impossible enough, but storing energy as it is generated, in a usable state, is the real monkey to tackle.</em></blockquote><p><strong>Supercapacitors </strong>are the complementary combination of batteries and capacitors.</p><p><strong>Capacitors </strong>deliver large amounts of power in quick bursts resulting in a high<em> power density.</em> Electrochemical batteries perform similarly but release large amounts of stored energy over time. This is called <em>energy density</em>. Another thing to note is that capacitors charge up in seconds while batteries can take hours to be fully charged.</p><p><strong>Supercapacitors </strong>have attributes of both energy-storing methods; not only do they store energy approaching the level of batteries, but they also deliver in large capacitor-level bursts + charge up quickly. The best addition; they don’t lose their energy storage capabilities over time, <em>even after millions and millions of charges.</em></p><p>But, the energy density of supercapacitors currently on the market is an average of around 28 Watt-hour per kilogram (Wh/kg) compared to 200Wh/kg of a battery.</p><p>Going down a rabbit hole, we came across the research of graphene integration, a very recent concept that holds immense promise. They compete with all the properties of batteries and can charge up within seconds.</p><h4>Introducing Graphene</h4><p>Supercapacitors were initially powered by activated carbon electrodes, but a supposed replacement with a graphene electrode layer could re-structure the progress of e-textiles. The superiority can be attributed to their <em>high conductivity </em>and <em>large surface area</em> (the greater the surface area the more ions it can store and the greater its storage capacity).</p><blockquote>“Graphene’s high conductivity (&gt;1700 Siemens per meter (S/m)) compared to activated carbon (10 to 100 S/m).”</blockquote><h4>Actualizing</h4><p>Researchers built a supercapacitor that can take the shape of a fiber and be woven directly into clothing, using graphene and carbon nanotubes in a unique geometric structure. They are as long as 50 meters and have a charge capacity of 300 Farad per cubic centimeter.</p><blockquote>This is one option to fulfill the “demands [of] associat[ing] energy storages with [energy harvesters] which are cost-effective, durable, high-performance, have mechanical strength for flexibility and stretchability, non-toxic and explosive.</blockquote><p>But, they still fall short by requiring large bundles of them for high energy capacities. Other methods, including Injekt or screen printing, add additional steps to fabrication time and cost and limit large-scale production.</p><p>The most promising is<strong> laser printing</strong>, which is a <em>single-step</em> fabrication method useful for nano to large-scale structures. Recent reports on the development of stretchable laser-printed graphene supercapacitors up to 150% is a promising development.</p><h4>Fabrication Process of Laser Printing</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*CNBzz3EIXvLXGXVi.png" /><figcaption>Process for fabrication (exmaple used is solar cell harvesters rather than PVDF)</figcaption></figure><p>First, our fabric is coated with a waterproof elastomer solution and then painted with a graphene oxide/Matte binder solution to create thin films.</p><p>Then, different types of laser beams are used to reduce the films and create uniform electrical conductivity for the resulting energy storage electrodes.</p><p>The resulting supercapacitor electrodes have an optimized design (<a href="https://parametrichouse.com/hilbert-curve-fractal/"><em>Hilbert fractal</em></a>) and an interelectrode (<em>the distance between two adjacent electrodes</em>) distance of 80 μm (<em>drastically improves their electrical conductivity and capacitance properties</em>).</p><p>Four-probe measurements were conducted to understand their electrical conductivity using various laser beam powers, which showed that an optimum electrical conductivity of 20 S/m was obtained for the thin films using a laser beam power of 6.0W.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*_2D7111feByDpsOp.png" /><figcaption>(a) Photo image of the laser-printed graphene fractal electrodes in an area of 100 cm2 obtained at a laser beam power of 6 W (Scale-2.5 cm). Highlighted: Scanning electron microscopy (SEM) image of fabrics coated with laser-printed graphene thin films with a thickness of 10 µm, and the exposed laser-printed graphene due to the photothermal reduction of GO thin films resulting from the removal of water content. (b) CV measurements with different scan rates from 0.1 to 10 Vs−1 without the encapsulation conditions. CV measurements with varying rates of the scan from 0.1 to 10 Vs−1 with the encapsulation conditions. (d) The areal capacitance of the energy storage is calculated from the CV measurements. (e) CC measurements with different current densities from 5 to 25 mA cm−2 without the encapsulation conditions. (f) CC measurements with different current densities from 5 to 25 mA cm−2 with the encapsulation conditions. (g) Columbic efficiencies for the energy storages were calculated from the CC measurements.</figcaption></figure><p>These supercapacitors have excellent water interaction, high capacitance (49 mF cm−2) (<em>very high capacity to store energy)</em>, and good stretchability + stability (up to 200%) after several tests. For the more technical readers: energy density, 6.73 mWh/cm−2, power density, 2.5 mW/cm−2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WCOkOdYxXSlDgm9p.png" /><figcaption>Stretchability test results</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*6bWb5Na_a-9AIbvl.png" /><figcaption>Washability test results</figcaption></figure><p>These cost-effective self-reliant charging units can become an integral part of future electronic textiles used in clothing and wearable devices.</p><h4>Not only is this a simple process that can be implemented at a large scale, but 10cm² of this textile can be fabricated within 3 minutes.</h4><h3>Part 3: Energy Transfer</h3><p>The last step is to integrate power regulation and conversion circuitry within the clothing. This circuitry would be responsible for managing the energy flow from the supercapacitors to your phone’s battery, for example, ensuring compatibility between the voltage and current requirements of both systems.</p><p>We plan on a centralized control module located in a specific area of clothing, such as a pocket or a dedicated compartment. This module would house the regulators, converters, and control circuitry. Wires or conductive pathways would connect the energy-harvesting components and the supercapacitors to this central module in the pocket, so users can connect their device (eventually transitioning to wireless technology) to charge it in real-time.</p><p>That’s kinda cool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*eBOq2w--F6wYsD4wnQWIpg.png" /></figure><h4>It’s simple.</h4><p>Charging small electronics through traditional means destroys our environment, restricts mobility, and unnecessarily contributes to our exponential increase in energy expenditure.</p><blockquote>Our solution <em>leverages</em> mobility, <em>relies </em>on sustainability, and <em>restructures </em>the world’s energy expenditure to impact millions.</blockquote><p>Thanks,</p><p>Tanvi</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a17a90d1c38" width="1" height="1" alt=""><hr><p><a href="https://studentsxstudents.com/moonshot-powerthreads-3a17a90d1c38">Moonshot: PowerThreads</a> was originally published in <a href="https://studentsxstudents.com/">students x students</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A place for our digital ephemera]]></title>
            <link>https://studentsxstudents.com/a-place-for-our-digital-ephemera-ad559d2437d3?source=rss-6c8172dff473------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad559d2437d3</guid>
            <dc:creator><![CDATA[Tanvi Sheth]]></dc:creator>
            <pubDate>Sun, 09 Apr 2023 23:25:09 GMT</pubDate>
            <atom:updated>2025-07-08T17:12:12.995Z</atom:updated>
            <content:encoded><![CDATA[<h4>Decentralized storage</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0UIoqkavsf8yvvUQQ1wLIA.png" /></figure><blockquote>“We live in a world of refuse — not simply the banana peels, Amazon boxes, and old TVs rotting away in landfills but also the texts, emails, and torrented movies looked at once and left to languish in the cloud.” (Musiani)</blockquote><blockquote>We appear to be verging on a crisis point with the first kind of trash, but rarely ever think about the second: we fail to think of where our data ‘rots away’ once we’re done with its use. We fail to intentionally consider where we accumulate our digital ephemera.</blockquote><p>All the data that you have right now, whether that is years&#39; worth of photos or every assignment you’ve ever completed, is accumulating on a centralized storage network. Google Photos, Dropbox, whatever it may be. <em>But let me tell you something; there’s a lot wrong with them.</em></p><p><strong>Data</strong>. The single most important thing that our society is built upon. The single most important thing that drives innovation, automation, decision-making, and convenience in our lives today; humans don&#39;t recognize the role of data in the systems we’ve intricately established for ourselves. Our data is our identity, and we have enhanced because of the data we possess.</p><h3>Centralized storages</h3><h4>The problem</h4><p>With centralized storage, all data is stored in a single location, making it so much more vulnerable to cyberattacks and hacking attempts. A successful breach of the central server can mean the loss or theft of <em>all the data stored on it.</em></p><p>There’s also something called the single point of failure. Centralized storage creates <em>a single point of failure.</em> If the central server experiences technical difficulties or goes down for any reason, all data stored on it becomes inaccessible; <em>you won&#39;t have access to any of it, indefinitely.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*og6cwoGtUDZg9rDN" /></figure><p>In a centralized storage system, access to data is controlled by the central server. In OneDrive, this would be the Microsoft data facility. This creates limitations on who can access the data and how it can be used; most of these limitations are unknown to users. In other words; <em>we have no idea what&#39;s happening to our data.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/0*JMSHwxexyp5bxQHl" /></figure><p>I think you guys get the point here. But, an article never opens with a problem that can&#39;t be solved. So let&#39;s solve it.</p><h3>My take on the solution</h3><p>My third build in Web3 was a <em>very intentional one</em>. I decided to completely <strong>clone a centralized storage service</strong>, enabling the same functionalities for a user with 10x security, assurance, and convenience,<em> proving why the switch to decentralized storage is so worth it.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FB8XVS2CARag%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DB8XVS2CARag&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FB8XVS2CARag%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4eb7890f6fe3ac9a72055a406a33a8a5/href">https://medium.com/media/4eb7890f6fe3ac9a72055a406a33a8a5/href</a></iframe><h3>Decentralized Storages</h3><h4>Why switch to them?</h4><p><strong>Improved security: </strong>Decentralized storage systems use advanced encryption techniques and distribute data across multiple nodes, making it more secure and less vulnerable to hacking attempts or data breaches. This process is called sharding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*--0zO9CZ6NWedl7C" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LVwzMYi4_iQYwTxm" /></figure><p><strong>Greater accessibility:</strong> With decentralized data, users can access their information from anywhere in the world, as long as they have an internet connection. This is because the data is stored on a distributed network of nodes, rather than on a centralized server that may be restricted by location or access permissions.</p><p><strong>Lower costs:</strong> Decentralized data storage can be more cost-effective than traditional centralized storage since it doesn’t need expensive physical hardware or dedicated servers. Instead, it can leverage existing computing resources, making it more scalable and flexible.</p><p><strong>Enhanced privacy:</strong> Decentralized storage can provide greater privacy for users, as they have more control over their data and who has access to it. This is because data is not stored in a single location that can be easily accessed by third parties.</p><p><strong>Increased resilience:</strong> Decentralized storage is more resilient than centralized storage, as it is designed to withstand outages, attacks, and other disruptions. Because data is distributed across multiple nodes, there is no single point of failure that could bring down the entire system.</p><p>This is an important one.</p><p><strong>Ease of sharing:</strong> In decentralized storage, you can easily share files, peer-to-peer, and ensure that only the intended recipient can view and download the file. All files are authenticated, and it&#39;s actually <em>impossible </em>to view or download a file from decentralized storage if you don&#39;t have access to it/without being given access by its owner.</p><blockquote><em>You own your stuff, and you control who has access to your stuff.</em></blockquote><h4><strong><em>I created an application that leverages the IPFS decentralized storage network so users can interact with their invaluable data in a manner that is identical to OneDrive.</em></strong></h4><h3><strong>Let me introduce you to IPFS</strong></h3><p>IPFS (InterPlanetary File System) is a decentralized protocol that <em>enables </em>peer-to-peer file sharing and storage on the Internet. It is designed to create a distributed file system that is more resilient, efficient, and secure than traditional centralized systems. Let me break it down here:</p><p>IPFS works by using a content-addressed system, where each file is given a <strong>unique hash based on its contents.</strong> In IPFS, this is called a content identifier, or CID. A label is used to point to material in IPFS. It doesn’t indicate where the content is stored, but it forms a kind of address based on the content itself. CIDs are short, regardless of the size of their underlying content.</p><p><strong>CIDs are based on the content’s cryptographic hash. So,</strong></p><ol><li>Any difference in the content will produce a different CID.</li><li>The same content added to two different IPFS nodes using the same settings will produce the same CID.</li></ol><p>This hash is used to identify, upload and retrieve the file from the network. When a user requests a file, their IPFS client searches for nodes on the network that have a copy of the file and downloads it from them. <em>Not every node has a copy of all of them.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*43TtGez07ki6CMAfiO2zzg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NB2Gx-v5VlRX9EFFZQgHCQ.png" /></figure><p>In contrast, in traditional web protocols, <strong>such as HTTP,</strong> files are addressed using location-based addressing, which means that each file is identified by a URL (Uniform Resource Locator) that specifies its location on a <em>specific server</em>. <em>This makes it harder to retrieve files if the server or the URL is no longer available.</em></p><blockquote>This is why you can lose access to all your files on a centralized server so easily. It&#39;s also why you will never lose access to your files on decentralized storage.</blockquote><p>Using content-based addressing in IPFS provides so many benefits, such as enabling efficient content distribution, ensuring content integrity and authenticity, and enabling version control for files.</p><blockquote>This is an ongoing project, and I still have lots to work on to be at par with centralized storage services, but this is a run through V1 of my React front-end that communicates with IFPS, and the smart contract + its functionalities, each of which represent a step closer to an identical experience.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k30v1FMnbwERK3s6kxiR0Q.png" /></figure><p>There’s a lot going on here, but fundamentally, here is what happens when I upload a file through my dApp;</p><p>0. I’m the dApp creator, and I create a frontend and a backend with react and solidity. I compile all my smart contracts using a framework like Truffle or Hardhat, and I deploy them to a blockchain. When I want to deploy my application for use, I will use the Mainnet (Ethereum Network), but I’m working with a local blockchain for testing purposes.</p><ol><li>I enable Metamask to connect to this blockchain using a Web3 provider</li><li>I call the most basic function of my smart contract, which is to upload a file</li><li>The front-end, which is built on React, publishes my file to the IFPS decentralized storage.</li><li>IFPS returns a file hash (which you’ll see as the file hash in my code) to the front-end</li><li>The front-end works with the blockchain to add the hash to my smart contract</li><li>Since we’re adding information to the smart contract, it counts as a transaction, so we’ll need to access Metamask and the Web3 provider to follow through with it</li><li>The hash is added to the smart contract</li><li>The user can access this hash, and view/download the file</li><li>My other functions enable the users to delete, share, rename, list, search, and organize their uploaded files into folders — -&gt; enabling the <em>ideal </em>user experience</li></ol><p>Here’s a run-through of my smart contract, its functions, and my React front-end that enables access to all the functionalities.</p><h3>Upload file</h3><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract DStorage {<br>  string public name = &#39;DStorage&#39;;<br>  uint public fileCount = 0;<br>  uint public folderCount = 0;<br><br>  mapping(uint =&gt; File) public files;<br>  mapping(uint =&gt; Folder) public folders;<br><br>  struct File {<br>  uint fileId;<br>  string fileHash;<br>  uint fileSize;<br>  string fileType;<br>  string fileName;<br>  string fileDescription;<br>  uint uploadTime;<br>  address payable uploader;<br>    uint folderId;<br>}<br>  struct Folder {<br>  uint folderId;<br>  string folderName;<br>  uint creationTime;<br>  address payable owner;<br>  uint[] fileIds;<br>}<br>  event FileUploaded(<br>    uint fileId,<br>    string fileHash,<br>    uint fileSize,<br>    string fileType,<br>    string fileName, <br>    string fileDescription,<br>    uint uploadTime,<br>    address payable uploader,<br>    uint folderId<br>  );<br><br>function uploadFile(string memory _fileHash, uint _fileSize, string memory _fileType, string memory _fileName, string memory _fileDescription,uint folderId) public {<br>    // Make sure the file hash exists<br>    require(bytes(_fileHash).length &gt; 0);<br>    // Make sure file type exists<br>    require(bytes(_fileType).length &gt; 0);<br>    // Make sure file description exists<br>    require(bytes(_fileDescription).length &gt; 0);<br>    // Make sure file fileName exists<br>    require(bytes(_fileName).length &gt; 0);<br>    // Make sure uploader address exists<br>    require(msg.sender!=address(0));<br>    // Make sure file size is more than 0<br>    require(_fileSize&gt;0);<br>    //Make sure folder exists<br>    require(_folderId &gt; 0 &amp;&amp; _folderId &lt;= folderCount, &quot;Folder does not exist&quot;);<br><br>    // Increment file id<br>    fileCount ++;<br><br>    // Add File to the contract<br>    files[fileCount] = File(fileCount, _fileHash, _fileSize, _fileType, _fileName, _fileDescription, now, msg.sender, _folderId);<br><br>    // Trigger an event<br>    emit FileUploaded(fileCount, _fileHash, _fileSize, _fileType, _fileName, _fileDescription, now, msg.sender, _folderId);<br>  }</pre><p>The uploadFile function is used to add a new file to the decentralized storage system. It takes five input parameters:</p><blockquote>_fileHash: The IPFS hash of the file being uploaded.</blockquote><blockquote>_fileSize: The size of the file in bytes.</blockquote><blockquote>_fileType: The MIME type of the file.</blockquote><blockquote>_fileName: The name of the file.</blockquote><blockquote>_fileDescription: A description of the file.</blockquote><p>The function first checks that all the required input parameters are not empty and that the file size is greater than zero. It also checks if the folder ID provided for the file exists.</p><p>If all the checks pass, the function increments the fileCount variable to get a new unique ID for the file being uploaded. It then adds the file details to the file mapping using the fileCount ID as the key and the File struct as the value. The File struct contains details such as the file ID, file hash, file size, file type, file name, file description, the time the file was uploaded, the uploader’s address, and the folder ID.</p><p>Finally, the function emits a FileUploaded event with the details of the uploaded file, including the file ID, file hash, file size, file type, file name, file description, upload time, uploader’s address, and folder ID.</p><p>We can clearly see that I’m using IPFS as the underlying storage mechanism. The file is uploaded to IPFS and its <em>hash </em>is stored in the blockchain contract.</p><h3>Delete File</h3><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract DStorage {<br>  string public name = &#39;DStorage&#39;;<br>  uint public fileCount = 0;<br>  uint public folderCount = 0;<br><br>  mapping(uint =&gt; File) public files;<br>  mapping(uint =&gt; Folder) public folders;<br><br>  struct File {<br>  uint fileId;<br>  string fileHash;<br>  uint fileSize;<br>  string fileType;<br>  string fileName;<br>  string fileDescription;<br>  uint uploadTime;<br>  address payable uploader;<br>    uint folderId;<br>}<br>  struct Folder {<br>  uint folderId;<br>  string folderName;<br>  uint creationTime;<br>  address payable owner;<br>  uint[] fileIds;<br>}<br>event FileDeleted(<br>    uint fileId,<br>    string fileHash,<br>    uint fileSize,<br>    string fileType,<br>    string fileName, <br>    string fileDescription,<br>    uint uploadTime,<br>    address payable uploader,<br>    uint folderId<br>  );<br><br>function deleteFile(uint _fileId) public {<br>    // Check that the file exists<br>    require(_fileId &gt; 0 &amp;&amp; _fileId &lt;= fileCount, &quot;File does not exist&quot;);<br>    // Retrieve the file<br>    File storage file = files[_fileId];<br>    // Make sure only the uploader can delete the file<br>    require(msg.sender == file.uploader, &quot;Only the uploader can delete this file&quot;);<br><br><br>    // Remove the file from the folder&#39;s fileIds array<br>    uint folderId = file.folderId;<br>    uint[] storage folderFileIds = folders[folderId].fileIds;<br>    for (uint i = 0; i &lt; folderFileIds.length; i++) {<br>      if (folderFileIds[i] == _fileId) {<br>        // Shift the remaining elements to the left<br>        for (uint j = i; j &lt; folderFileIds.length - 1; j++) {<br>          folderFileIds[j] = folderFileIds[j+1];<br>        }<br>        // Remove the last element<br>        folderFileIds.pop();<br>        break;<br>      }<br>    }<br><br><br>  // Remove the file from the contract<br>  delete files[_fileId];<br>  // Trigger an event<br>  emit FileDeleted(_fileId, file.fileHash, file.fileSize, file.fileType, file.fileName, file.fileDescription, file.uploadTime, file.uploader, folderId);<br>}</pre><p>The deleteFile function deletes a file from the contract. It takes an input parameter _fileId which is the unique identifier of the file that needs to be deleted. Here’s what the function does:</p><p>Checks that the file exists in the contract by verifying that the _fileId is within the valid range of file IDs that have been created in the contract.</p><p>Retrieves the details of the file from the files mapping using the _fileId as the key. The details of the file are stored in a File struct, and this struct is stored in the file mapping.</p><p>Verifies that only the uploader of the file can delete it. This is done by comparing the msg. sender (i.e., the Ethereum address of the function caller) with the Ethereum address of the uploader of the file.</p><p>Removes the file from the fileIds array of the folder to which the file belongs.</p><p>Deletes the file from the files mapping using the _fileId as the key. This removes the File struct from the mapping and frees up the storage space associated with it.</p><p>Emits an event FileDeleted with the details of the deleted file, which can be used by clients or other contracts to track the deletion of the file.</p><p><strong>NOTE: This deletes the file from the smart contract. Not IPFS. I communicated with IFPS through my React front end, which we’ll get to very soon.</strong></p><h3>Rename File</h3><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract DStorage {<br>  string public name = &#39;DStorage&#39;;<br>  uint public fileCount = 0;<br>  uint public folderCount = 0;<br><br>  mapping(uint =&gt; File) public files;<br>  mapping(uint =&gt; Folder) public folders;<br><br>  struct File {<br>  uint fileId;<br>  string fileHash;<br>  uint fileSize;<br>  string fileType;<br>  string fileName;<br>  string fileDescription;<br>  uint uploadTime;<br>  address payable uploader;<br>    uint folderId;<br>}<br>  struct Folder {<br>  uint folderId;<br>  string folderName;<br>  uint creationTime;<br>  address payable owner;<br>  uint[] fileIds;<br>}<br>  event FileRenamed(<br>    uint fileId,<br>    string fileHash,<br>    uint fileSize,<br>    string fileType,<br>    string fileName, <br>    string fileDescription,<br>    uint uploadTime,<br>    address payable uploader,<br>    uint folderId<br>  );<br><br>function renameFile(uint _fileId, string memory _newFileName) public {<br>    // Check that the file exists<br>    require(_fileId &gt; 0 &amp;&amp; _fileId &lt;= fileCount, &quot;File does not exist&quot;);<br>    // Retrieve the file<br>    File storage file = files[_fileId];<br>    // Make sure only the uploader can rename the file<br>    require(msg.sender == file.uploader, &quot;Only the uploader can rename this file&quot;);<br>    // Make sure the new file name exists<br>    require(bytes(_newFileName).length &gt; 0, &quot;New file name cannot be empty&quot;);<br><br><br>    // Update the file name<br>    file.fileName = _newFileName;<br>    uint folderId = file.folderId; // add this line to get the folder id<br>    // Trigger an event<br>    emit FileRenamed(_fileId, file.fileHash, file.fileSize, file.fileType, _newFileName, file.fileDescription, file.uploadTime, file.uploader, folderId);<br>  }</pre><p>This function allows the uploader of a file to change the file name. The function takes two arguments: _fileId, which is the ID of the file that the user wants to rename, and _newFileName, which is the new name that the user wants to give to the file.</p><p>The function first checks that the file with the given ID exists and that only the uploader of the file can rename it. Then, it checks that the new file name is not empty. If all the checks pass, the function updates the fileName field of the file with the new name. It also retrieves the folder ID of the file and emits an event FileRenamed with the updated information, including the new file name, the original file uploader, and the folder ID.</p><h3><strong>Get User Files</strong></h3><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract DStorage {<br>  string public name = &#39;DStorage&#39;;<br>  uint public fileCount = 0;<br>  uint public folderCount = 0;<br><br>  mapping(uint =&gt; File) public files;<br>  mapping(uint =&gt; Folder) public folders;<br><br>  struct File {<br>  uint fileId;<br>  string fileHash;<br>  uint fileSize;<br>  string fileType;<br>  string fileName;<br>  string fileDescription;<br>  uint uploadTime;<br>  address payable uploader;<br>    uint folderId;<br>}<br>  struct Folder {<br>  uint folderId;<br>  string folderName;<br>  uint creationTime;<br>  address payable owner;<br>  uint[] fileIds;<br>}<br><br>function getUserFiles() public view returns (string[] memory) {<br>    // Create an array to store file names<br>    string[] memory fileNames = new string[](fileCount);<br>    uint numberOfFiles = 0;<br>   <br>    // Iterate through all files in the contract<br>    for (uint i = 1; i &lt;= fileCount; i++) {<br>      // Check if the file was uploaded by the sender<br>      if (files[i].uploader == msg.sender) {<br>        fileNames[numberOfFiles] = files[i].fileName;<br>        numberOfFiles++;<br>      }<br>    }<br>    // Return the array of file names uploaded by the sender<br>    return fileNames;<br>}</pre><p>The searchUserFilesByName function takes a file name as input and returns an array of all files uploaded by the sender (i.e., the user who called the function) that match the given file name. It first creates an array to store the matching files, iterates through all files in the contract, and checks if each file was uploaded by the sender and matches the given file name. If a file matches, it is added to the files array. After all the files have been checked, the function resizes the array to remove any empty elements and returns the array of matching files. The keccak256 function is used to hash the file names for comparison with the file’s hash from IFPS.</p><h3>Create Folder</h3><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract DStorage {<br>  string public name = &#39;DStorage&#39;;<br>  uint public fileCount = 0;<br>  uint public folderCount = 0;<br><br>  mapping(uint =&gt; File) public files;<br>  mapping(uint =&gt; Folder) public folders;<br><br>  struct File {<br>  uint fileId;<br>  string fileHash;<br>  uint fileSize;<br>  string fileType;<br>  string fileName;<br>  string fileDescription;<br>  uint uploadTime;<br>  address payable uploader;<br>    uint folderId;<br>}<br>  struct Folder {<br>  uint folderId;<br>  string folderName;<br>  uint creationTime;<br>  address payable owner;<br>  uint[] fileIds;<br>}<br> event FolderCreated(<br>  uint folderId,<br>  string folderName,<br>  uint creationTime,<br>  address payable owner<br>  );<br><br>function createFolder(string memory _folderName) public {<br>    // Make sure folder name exists<br>    require(bytes(_folderName).length &gt; 0);<br>    // Increment folder id<br>    folderCount ++;<br>    // Add Folder to the contract<br>    folders[folderCount] = Folder(folderCount, _folderName, now, msg.sender);<br>    // Trigger an event<br>    emit FolderCreated(_folderCount, _folderName, now, _owner)<br>  }</pre><p>This function creates a new folder in the contract with the given folder name. It first checks that the folder name is not empty, and then increments the folder count to get a unique folder ID. It then creates a new Folder struct with the ID, name, creation time (using now), and owner (the address of the user who called the function). Finally, it adds the new folder to the folders mapping with the folder ID as the key and triggers a FolderCreated event with the folder ID, name, creation time, and owner as parameters.</p><h3>Delete Folder</h3><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract DStorage {<br>  string public name = &#39;DStorage&#39;;<br>  uint public fileCount = 0;<br>  uint public folderCount = 0;<br><br>  mapping(uint =&gt; File) public files;<br>  mapping(uint =&gt; Folder) public folders;<br><br>  struct File {<br>  uint fileId;<br>  string fileHash;<br>  uint fileSize;<br>  string fileType;<br>  string fileName;<br>  string fileDescription;<br>  uint uploadTime;<br>  address payable uploader;<br>  uint folderId;<br>  }<br>struct Folder {<br>  uint folderId;<br>  string folderName;<br>  uint creationTime;<br>  address payable owner;<br>  uint[] fileIds;<br>  }<br>  event FolderDeleted(<br>  uint folderId,<br>  string folderName,<br>  uint creationTime,<br>  address payable owner<br>  );<br><br>  function deleteFolder(uint _folderId) public {<br>    // Check that the folder exists<br>    require(_folderId &gt; 0 &amp;&amp; _folderId &lt;= folderCount, &quot;Folder does not exist&quot;);<br>    // Retrieve the folder<br>    Folder storage folder = folders[_folderId];<br>    // Make sure only the owner can delete the folder<br>    require(msg.sender == folder.owner, &quot;Only the owner can delete this folder&quot;);<br><br>    // Delete all the files in the folder<br>    uint[] storage fileIds = folder.fileIds;<br>    for (uint i = 0; i &lt; fileIds.length; i++) {<br>      uint fileId = fileIds[i];<br>      deleteFile(fileId);<br>    }<br><br>    // Remove the folder from the contract<br>    delete folders[_folderId];<br>    // Trigger an event<br>    emit FolderDeleted(_folderId, folder.folderName, folder.creationTime, folder.owner);<br>}</pre><h3>Add File to Folder</h3><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract DStorage {<br>  string public name = &#39;DStorage&#39;;<br>  uint public fileCount = 0;<br>  uint public folderCount = 0;<br><br>  mapping(uint =&gt; File) public files;<br>  mapping(uint =&gt; Folder) public folders;<br><br>  struct File {<br>  uint fileId;<br>  string fileHash;<br>  uint fileSize;<br>  string fileType;<br>  string fileName;<br>  string fileDescription;<br>  uint uploadTime;<br>  address payable uploader;<br>  uint folderId;<br>}<br>struct Folder {<br>  uint folderId;<br>  string folderName;<br>  uint creationTime;<br>  address payable owner;<br>  uint[] fileIds;<br>}  <br><br>function addFileToFolder(uint _fileId, uint _folderId) public {<br>  // Check that the file exists<br>  require(_fileId &gt; 0 &amp;&amp; _fileId &lt;= fileCount, &quot;File does not exist&quot;);<br>  // Check that the folder exists<br>  require(_folderId &gt; 0 &amp;&amp; _folderId &lt;= folderCount, &quot;Folder does not exist&quot;);<br>  // Retrieve the file and folder<br>  File storage file = files[_fileId];<br>  Folder storage folder = folders[_folderId];<br>  // Make sure only the folder owner can add files to the folder<br>  require(msg.sender == folder.owner, &quot;Only the folder owner can add files to this folder&quot;);<br><br><br>  // Add the file to the folder<br>  folder.files.push(file);<br>    }</pre><p>This function allows a user to add a file to a folder they own. It takes two parameters: _fileId, which is the ID of the file to add to the folder, and _folderId, which is the ID of the folder to add the file to.</p><p>First, the function checks that both the file and folder exist in the contract using require statements. If either the file or folder does not exist, an error message is returned.</p><p>Next, the function retrieves the File and Folder objects using their respective IDs.</p><p>The function then checks that the user adding the file to the folder is the owner of the folder using the require statement. If the user is not the owner of the folder, an error message is returned.</p><p>Finally, the function adds the File object to the Folder object’s files array using the push() function. The file is now added to the specified folder.</p><h3>Get User Folders</h3><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract DStorage {<br>  string public name = &#39;DStorage&#39;;<br>  uint public fileCount = 0;<br>  uint public folderCount = 0;<br><br>  mapping(uint =&gt; File) public files;<br>  mapping(uint =&gt; Folder) public folders;<br><br>  struct File {<br>  uint fileId;<br>  string fileHash;<br>  uint fileSize;<br>  string fileType;<br>  string fileName;<br>  string fileDescription;<br>  uint uploadTime;<br>  address payable uploader;<br>  uint folderId;<br>}<br><br>struct Folder {<br>  uint folderId;<br>  string folderName;<br>  uint creationTime;<br>  address payable owner;<br>  uint[] fileIds;<br>}<br><br>function getUserFolders() public view returns (string[] memory) {<br>  // Create an array to store folder names<br>  string[] memory folderNames = new string;<br>  uint numberOfFolders = 0;<br><br><br>  // Iterate through all folders in the contract<br>  for (uint i = 1; i &lt;= folderCount; i++) {<br>  // Check if the folder was created by the sender<br>  if (folders[i].owner == msg.sender) {<br>  folderNames[numberOfFolders] = folders[i].folderName;<br>  numberOfFolders++;<br>  }<br>  }<br>  return folderNames;<br>  }</pre><p>This function getUserFolders returns an array of folder names created by the sender. It creates a dynamic array folderNames of size folderCount and initializes a variable numberOfFolders to 0. It then iterates through all the folders in the contract and checks if the folder was created by the sender. If so, it adds the folder name to the folderNames array and increments numberOfFolders.</p><p>Finally, it resizes the folderNames array to the correct size using the assembly block and returns the folderNames array. This is done to remove any unused elements from the array since the array is initialized with a maximum size of folderCount but may have fewer elements if the sender did not create all the folders.</p><h3>Get Files From Folder</h3><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract DStorage {<br>  string public name = &#39;DStorage&#39;;<br>  uint public fileCount = 0;<br>  uint public folderCount = 0;<br><br>  mapping(uint =&gt; File) public files;<br>  mapping(uint =&gt; Folder) public folders;<br><br>  struct File {<br>  uint fileId;<br>  string fileHash;<br>  uint fileSize;<br>  string fileType;<br>  string fileName;<br>  string fileDescription;<br>  uint uploadTime;<br>  address payable uploader;<br>  uint folderId;<br>}<br>struct Folder {<br>  uint folderId;<br>  string folderName;<br>  uint creationTime;<br>  address payable owner;<br>  uint[] fileIds;<br>}<br><br>function getFolderFiles(uint _folderId) public view returns (File[] memory) {<br>  // Check that the folder exists<br>  require(_folderId &gt; 0 &amp;&amp; _folderId &lt;= folderCount, &quot;Folder does not exist&quot;);<br>  // Retrieve the folder<br>  Folder storage folder = folders[_folderId];<br>  // Return the files in the folder<br>  return folder.files;<br>  }<br>}</pre><p>This function is used to get all the files in a given folder. It takes in a _folderId as a parameter and returns an array of File objects representing the files in the folder.</p><p>The function first checks that the folder exists by verifying that _folderId is within the range of valid folder ids. It then retrieves the folder using the _folderId parameter and returns the files array of the Folder object.</p><p>Note that since this function is marked as view, it does not modify any state variables in the contract and does not require any gas to execute.</p><blockquote>Note: These are a small portion of functionalities that I’ve included in my V1 of the application. Although they are all written on the smart contract, they don&#39;t necessarily need gas to execute/count as a transaction unless they are changing the state of the smart contract.</blockquote><h3>Front End</h3><h4>Let&#39;s quickly take a look at our front end + how two major functions, upload a file and delete a file, interact with IFPS:</h4><pre>import DStorage from &#39;../abis/DStorage.json&#39;<br>import React, { Component } from &#39;react&#39;;<br>import Navbar from &#39;./Navbar&#39;<br>import Main from &#39;./Main&#39;<br>import Web3 from &#39;web3&#39;;<br>import &#39;./App.css&#39;;<br><br>const ipfsClient = require(&#39;ipfs-http-client&#39;)<br>const ipfs = ipfsClient({ host: &#39;ipfs.infura.io&#39;, port: 5001, protocol: &#39;https&#39; }) // leaving out the arguments will default to these values<br><br>class App extends Component {<br><br>  async componentWillMount() {<br>    await this.loadWeb3()<br>    await this.loadBlockchainData()<br>  }<br><br>  async loadWeb3() {<br>    if (window.ethereum) {<br>      window.web3 = new Web3(window.ethereum)<br>      await window.ethereum.enable()<br>    }<br>    else if (window.web3) {<br>      window.web3 = new Web3(window.web3.currentProvider)<br>    }<br>    else {<br>      window.alert(&#39;Non-Ethereum browser detected. You should consider trying MetaMask!&#39;)<br>    }<br>  }<br><br>  async loadBlockchainData() {<br>    const web3 = window.web3<br>    // Load account<br>    const accounts = await web3.eth.getAccounts()<br>    this.setState({ account: accounts[0] })<br>    // Network ID<br>    const networkId = await web3.eth.net.getId()<br>    const networkData = DStorage.networks[networkId]<br>    if(networkData) {<br>      // Assign contract<br>      const dstorage = new web3.eth.Contract(DStorage.abi, networkData.address)<br>      this.setState({ dstorage })<br>      // Get files amount<br>      const filesCount = await dstorage.methods.fileCount().call()<br>      this.setState({ filesCount })<br>      // Load files&amp;sort by the newest<br>      for (var i = filesCount; i &gt;= 1; i--) {<br>        const file = await dstorage.methods.files(i).call()<br>        this.setState({<br>          files: [...this.state.files, file]<br>        })<br>      }<br>    } else {<br>      window.alert(&#39;DStorage contract not deployed to detected network.&#39;)<br>    }<br>  }<br><br>  // Get file from user<br>  captureFile = event =&gt; {<br>    event.preventDefault()<br><br>    const file = event.target.files[0]<br>    const reader = new window.FileReader()<br><br>    reader.readAsArrayBuffer(file)<br>    reader.onloadend = () =&gt; {<br>      this.setState({<br>        buffer: Buffer(reader.result),<br>        type: file.type,<br>        name: file.name<br>      })<br>      console.log(&#39;buffer&#39;, this.state.buffer)<br>    }<br>  }<br><br>  uploadFile = description =&gt; {<br>    console.log(&quot;Submitting file to IPFS...&quot;)<br><br>    // Add file to the IPFS<br>    ipfs.add(this.state.buffer, (error, result) =&gt; {<br>      console.log(&#39;IPFS result&#39;, result.size)<br>      if(error) {<br>        console.error(error)<br>        return<br>      }<br><br>      this.setState({ loading: true })<br>      // Assign value for the file without extension<br>      if(this.state.type === &#39;&#39;){<br>        this.setState({type: &#39;none&#39;})<br>      }<br>      this.state.dstorage.methods.uploadFile(result[0].hash, result[0].size, this.state.type, this.state.name, description).send({ from: this.state.account }).on(&#39;transactionHash&#39;, (hash) =&gt; {<br>        this.setState({<br>         loading: false,<br>         type: null,<br>         name: null<br>       })<br>       window.location.reload()<br>      }).on(&#39;error&#39;, (e) =&gt;{<br>        window.alert(&#39;Error&#39;)<br>        this.setState({loading: false})<br>      })<br>    })<br>  }<br><br>  constructor(props) {<br>    super(props)<br>    this.state = {<br>      account: &#39;&#39;,<br>      dstorage: null,<br>      files: [],<br>      loading: false,<br>      type: null,<br>      name: null<br>    }<br>    this.uploadFile = this.uploadFile.bind(this)<br>    this.captureFile = this.captureFile.bind(this)<br>  }<br><br>  render() {<br>    return (<br>      &lt;div&gt;<br>        &lt;Navbar account={this.state.account} /&gt;<br>        { this.state.loading<br>          ? &lt;div id=&quot;loader&quot; className=&quot;text-center mt-5&quot;&gt;&lt;p&gt;Loading...&lt;/p&gt;&lt;/div&gt;<br>          : &lt;Main<br>              files={this.state.files}<br>              captureFile={this.captureFile}<br>              uploadFile={this.uploadFile}<br>            /&gt;<br>        }<br>      &lt;/div&gt;<br>    );<br>  }<br><br>  async deleteFile(fileId) {<br>    this.setState({ loading: true })<br>    await this.state.dstorage.methods.deleteFile(fileId).send({ from: this.state.account })<br>    const updatedFiles = this.state.files.filter(file =&gt; file.id !== fileId)<br>    this.setState({ files: updatedFiles })<br>    const fileToDelete = updatedFiles.find(file =&gt; file.id === fileId)<br>    await ipfs.files.rm(fileToDelete.hash)<br>    this.setState({ loading: false })<br>  }<br>  render() {<br>    return (<br>      &lt;div className=&quot;container-fluid mt-5&quot;&gt;<br>        &lt;div className=&quot;row&quot;&gt;<br>          &lt;main role=&quot;main&quot; className=&quot;col-lg-12 d-flex text-center&quot;&gt;<br>            &lt;div className=&quot;content mr-auto ml-auto&quot;&gt;<br>              &lt;UploadForm<br>                captureFile={this.props.captureFile}<br>                uploadFile={this.props.uploadFile}<br>              /&gt;<br>              &lt;p&gt;&amp;nbsp;&lt;/p&gt;<br>              { this.state.loading<br>                ? &lt;div id=&quot;loader&quot; className=&quot;text-center&quot;&gt;&lt;p&gt;Loading...&lt;/p&gt;&lt;/div&gt;<br>                : &lt;FileList<br>                    files={this.props.files}<br>                    deleteFile={this.deleteFile}<br>                  /&gt;<br>              }<br>            &lt;/div&gt;<br>          &lt;/main&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>    <br>}<br><br><br>export default App;</pre><p>I first imported the IFPS client using the require statement, so my front end can interact with the decentralized storage and the methods it provides.</p><ol><li>Files are uploaded using the uploadFile() method, which takes a file description as a parameter. This method is called when the user submits a file through the file upload form.</li><li>First, the file is added to the InterPlanetary File System (IPFS) using the ipfs.add() method. This method takes the file buffer (i.e., the binary data of the file) as the first parameter and a callback function as the second parameter. The callback function is executed after the file is successfully added to IPFS or an error occurs.</li><li>If the file is successfully added to IPFS, the hash, and size of the file are obtained from the result object that is passed to the callback function. The hash and size, along with the file type, name, and description, are then passed as arguments to the uploadFile() method of the dstorage contract. The uploadFile() method is called using the send() method, which sends a transaction to the Ethereum network.</li><li>If the transaction is successfully mined, the file is added to the files array in the component’s state. This array is then used to display the list of uploaded files in the user interface.</li><li>Files are deleted using the deleteFile() method, which takes the ID of the file to be deleted as a parameter. This method is called when the user clicks the delete button next to a file in the file list.</li><li>When deleteFile() is called, the file is deleted from the files array in the component’s state using the filter() method. The ID of the file to be deleted is used to filter out the file from the array.</li><li>The deleteFile() method then calls the deleteFile() method of the dstorage contract, passing the ID of the file to be deleted as an argument. This method is also called using the send() method to send a transaction to the Ethereum network.</li><li>If the transaction is successfully mined, the file is deleted from IPFS using the ipfs.files.rm() method. This method takes the hash of the file to be deleted as a parameter. Once the file is deleted from IPFS, the loading flag in the component’s state is set to false, and the file list is updated to reflect the deleted file.</li></ol><p>This is just the V1 of my decentralized storage application. I plan on iterating and revamping the functionalities + establishing my user interface in the next couple of months, also considering how to leverage React.js to reduce the contents (specifically the read-only functions) of my smart contract. Regardless, I’ll keep everyone updated on the progress.</p><p>I’m glad to have reached the level of technical depth to deploy a project that has the potential to solve a prominent problem, one that we currently overlook right now. I’m excited to see where this project takes me, and I’m proud of how far along I’ve already come. Stay tuned for changes to this build.</p><blockquote>Thanks for giving this a read :) If you’re up for it, follow my <a href="https://medium.com/@sheth.tanvi18">Medium </a>account for more content as I navigate my curiosities. Feel free to connect with me on <a href="https://www.linkedin.com/in/tanvi-sheth-06b4501ba/">LinkedIn </a>or <a href="https://twitter.com/_TanviSheth">Twitter </a>and check out my <a href="https://tks.life/profile#portfolio">full portfolio</a> to keep up with my projects and experiences. To stay updated on my monthly progress and takeaways, subscribe to my <a href="https://tanvisheth.substack.com/?utm_source=substack&amp;utm_medium=web&amp;utm_campaign=substack_profile">newsletter </a>as well.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad559d2437d3" width="1" height="1" alt=""><hr><p><a href="https://studentsxstudents.com/a-place-for-our-digital-ephemera-ad559d2437d3">A place for our digital ephemera</a> was originally published in <a href="https://studentsxstudents.com/">students x students</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decentralized Funding in Real-World Contexts]]></title>
            <link>https://studentsxstudents.com/decentralized-funding-a3de5734e24a?source=rss-6c8172dff473------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3de5734e24a</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[world]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[enjoy-writing]]></category>
            <dc:creator><![CDATA[Tanvi Sheth]]></dc:creator>
            <pubDate>Sun, 26 Mar 2023 23:14:26 GMT</pubDate>
            <atom:updated>2025-07-08T17:11:02.976Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 1: FundMe dApp</h4><p><strong>Time for round two.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CN4tZrQi0St2ZCCFfwQotg.png" /></figure><p>My first decentralized application was a struggle, and I openly reflect on the unfamiliarity that I experienced building in Web3 as a beginner. Everything from the single lines of Solidity code to the shift in network architecture was new to me. That project taught me how to welcome struggle, appreciate setbacks, and experience real growth, to say the least. A <strong>fundamental understanding</strong> was my priority.</p><p>This time, I decided to make another full-stack decentralized application, but I prioritized something else. I wanted to start building things that <em>make sense for a user and developer to switch to</em>, now that I have the foundation to do so. I prioritized <em>functionality, convenience, and robustness for a user and a developer. </em>I prioritized <strong>real-world</strong> contexts.</p><p>This FundMe dApp can be modified according to its intended use case:</p><h4>Crowdfunding, Escrow Services, Charity Donations, Employee Payroll, Staking Rewards</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FcdMYh0kppiY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DcdMYh0kppiY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FcdMYh0kppiY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cebb4e04057a9f20825a05dce39c7d61/href">https://medium.com/media/cebb4e04057a9f20825a05dce39c7d61/href</a></iframe><h4>This is a <a href="https://medium.com/@sheth.tanvi18/functional-and-robust-smart-contracts-unit-and-stage-tests-oracles-and-gas-optimization-2861061c862">two-part</a> article, highlighting the two backbones of a decentralized application; <em>smart contracts and scripts</em>, but also an overview of the tools and advanced development techniques I incorporated to make this application <em>functional and convenient </em>for a user to use, and <em>efficient and robust </em>for a developer to build.</h4><h4>Oracles</h4><ul><li>Price Feeds</li><li>Libraries in Solidity</li></ul><h4>Gas Optimization Techniques + Operation Codes</h4><ul><li>Storage variables</li><li>Error statements</li><li>Libraries</li></ul><h4><strong>Test Frameworks</strong></h4><ul><li>Unit Tests</li><li>Staging Tests</li></ul><h4>Smart Contract</h4><p>So what’s the hype with these smart contracts?</p><p>In short, the power of smart contracts lies in their ability to unlock new levels of trust, transparency, and efficiency in our global economy, paving the way for a more decentralized, democratic, and equitable world.</p><p>In technical terms, a smart contract is a self-executing program that runs on a blockchain network. It’s really just a set of rules and instructions written in a programming language (e.g., Solidity for Ethereum) that are stored on a blockchain and are executed <em>automatically </em>when certain conditions are met. Not only do they need no human input to execute, but smart contracts are also designed to be immutable, meaning once they are deployed on the blockchain, their code cannot be changed; <em>instilling a deeper level of trust that cannot be replicated by centralized systems.</em></p><p>They enforce the terms of a contract between two or more parties without requiring a third-party intermediary, such as a lawyer or a bank, but they’re also used in running decentralized applications (dApps), which is what I’m using them for. Now that we know the purpose:</p><h4>Let’s break this down</h4><p>After initializing the contract and stating the solidity compiler version that I want to work with, I simply imported the necessary dependencies to get started with the smart contract. Generally, you import things when necessary, not prior to their use case.</p><pre>// SPDX-License-Identifier: MIT<br><br>pragma solidity 0.8.8;<br>//Imports<br>import &quot;@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol&quot;;<br>import &quot;./PriceConverter.sol&quot;;<br>import &quot;hardhat/console.sol&quot;;<br><br>//Errors<br>error FundMe__NotOwner();<br><br>//Libraries, Libraries, Contracts<br><br>/** @title A contract for crowd funding<br> * @author tanvi Sheth<br> * @notice This contract is demo a sample funding contract<br> * @dev This implements price feeds as our library*/</pre><p>The SPDX-License-Identifier specifies the license under which the code is released, in this case, the MIT license.</p><p>The second line pragma solidity 0.8.8; specifies the version of the Solidity compiler that will be used to compile the contract code. This needs to be done before you deploy any contracts or scripts to the blockchain.</p><p>Then, I’m importing the necessary dependencies for the smart contract to function properly. In this case, the code is importing the AggregatorV3Interface from the Chainlink library, which is used to obtain <strong>price data</strong> (which I will talk a lot more in-depth into once we get there) from an external source, as well as the PriceConverter contract console library.</p><p>The error statement after the imports is defining a custom error that will be thrown if someone who is not the owner of the contract tries to execute a function that only the owner is allowed to execute. These take up <em>less gas</em> than printing out a console. log, which is another aspect I will touch on as well. Oh, and the comments just state that this is a funding contract that uses price feeds from the imported libraries.</p><p>With all of that established, let&#39;s understand the purpose of this smart contract.</p><h4>Functions of a Smart Contract</h4><pre>contract FundMe {<br>    //type declarations<br>    using PriceConverter for uint256;<br><br>    //state variables!<br>    mapping(address =&gt; uint256) public s_addressToAmountFunded;<br>    address[] public s_funders;<br><br>    // Could we make this constant?  /* hint: no! We should make it immutable! */<br>    addresnd,s public immutable i_owner;<br>    uint256 public constant MINIMUM_USD = 50 * 10 ** 18;<br><br>    AggregatorV3Interface public s_priceFeed;<br><br>    modifier onlyOwner() {<br>        // require(msg.sender == owner);<br>        if (msg.sender != i_owner) revert FundMe__NotOwner();<br>        _;<br>    }<br><br>    constructor(address s_priceFeedAddress) {<br>        //price feed address is modularized based on what chain we&#39;re on<br>        i_owner = msg.sender;<br>        s_priceFeed = AggregatorV3Interface(s_priceFeedAddress);<br>    }<br><br>    receive() external payable {<br>        fund();<br>    }<br><br>    fallback() external payable {<br>        fund();<br>    }<br><br>    /**<br>     * @notice This function funds this contract<br>     * @dev This implements price feeds as our library<br>     */<br>    function fund() public payable {<br>        require(<br>            msg.value.getConversionRate(s_priceFeed) &gt;= MINIMUM_USD,<br>            &quot;You need to spend more ETH!&quot;<br>        );<br>        // require(PriceConverter.getConversionRate(msg.value) &gt;= MINIMUM_USD, &quot;You need to spend more ETH!&quot;);<br>        s_addressToAmountFunded[msg.sender] += msg.value;<br>        s_funders.push(msg.sender);<br>    }<br><br>    function getVersion() public view returns (uint256) {<br>        // ETH/USD price feed address of Goerli Network.<br>        return s_priceFeed.version();<br>    }<br><br>    function withdraw() public onlyOwner {<br>        for (<br>            uint256 funderIndex = 0;<br>            funderIndex &lt; s_funders.length;<br>            funderIndex++<br>        ) {<br>            address funder = s_funders[funderIndex];<br>            s_addressToAmountFunded[funder] = 0;<br>        }<br>        s_funders = new address[](0);<br>        // // transfer<br>        // payable(msg.sender).transfer(address(this).balance);<br>        // // send<br>        // bool sendSuccess = payable(msg.sender).send(address(this).balance);<br>        // require(sendSuccess, &quot;Send failed&quot;);<br>        // call<br>        (bool callSuccess, ) = payable(msg.sender).call{<br>            value: address(this).balance<br>        }(&quot;&quot;);<br>        require(callSuccess, &quot;Call failed&quot;);<br>    }<br><br>    function cheaperWithdraw() public payable onlyOwner {<br>        //rn doubling the amount of storage we are reading from<br>        //instead read the array into memory one time, and read and write from memeory (cheaper) instead of storage and update storage when done<br>        address[] memory funders = s_funders;<br>        for (<br>            uint256 funderIndex = 0;<br>            funderIndex &lt; funders.length;<br>            funderIndex++<br>        ) {<br>            address funder = funders[funderIndex]; //using funders array and not s_funders<br>            s_addressToAmountFunded[funder] = 0;<br>        }<br>        s_funders = new address[](0);<br>        (bool success, ) = i_owner.call{value: address(this).balance}(&quot;&quot;);<br>        require(success);<br>    }<br>}</pre><blockquote>I’ve commented out some lines of code that I had first written out but later modified as I discovered more efficient methods; for me to understand the purpose of modifying and recall the differentiation of the two.</blockquote><blockquote>I also explain other Web3 concepts that would be helpful to have some background info on throughout the article, in an italicized format just like this.</blockquote><h4>Type Declaration and State Variables</h4><p>This section includes the type declaration for the PriceConverter library and the state variables for the contract. It defines a mapping that maps addresses to the number of funds they have contributed to the contract, an array of funders, an immutable variable for the owner of the contract, a constant MINIMUM_USD value for the minimum amount of USD that needs to be spent to contribute, and an interface for the price feed to be used in the contract.</p><h4>Modifier and Constructor</h4><p>This section includes the onlyOwner modifier which restricts the execution of certain functions to only the contract owner. It also includes the constructor function that initializes the owner of the contract and the price feed to be used in the contract.</p><h4>Receive and Fallback functions</h4><p>These functions are fallback functions that allow the contract to receive and handle Ether transactions. The receive function is called when Ether is sent to the contract, and the fallback function is called when the contract receives a call that does not match any other function.</p><h4>Funding function</h4><p>This function allows users to contribute funds to the contract. It checks that the amount of Ether sent by the user is greater than or equal to the minimum USD amount and then adds the user’s address and contribution amount to the s_addressToAmountFunded mapping and the s_funders array, respectively.</p><h4>Get Version function</h4><p>This function returns the version number of the price feed interface used in the contract.</p><h4>Withdraw functions</h4><blockquote>I’ll explain why there is a ‘cheaper’ withdrawal function when I talk about gas optimization below.</blockquote><p>The withdraw function and cheaperWithdraw function are both functions in the FundMe smart contract. They allow the contract owner to withdraw all of the funds that have been deposited into the contract by its funders.</p><p>The withdraw function iterates through the s_funders array, which contains the addresses of all the funders who have contributed to the contract. For each funder in the array, the function sets their funding amount to 0 in the s_addressToAmountFunded mapping. After this, the s_funders array is reset to a new empty array. Finally, the contract owner is able to withdraw all the balance of the contract using the call function.</p><p>The cheaperWithdraw function is similar to the withdraw function, but with a more efficient approach. Instead of iterating through the s_funders array directly, the function creates a memory array called funders and copies the s_funders array to it. Then it iterates through the funders memory array and updates the s_addressToAmountFunded mapping for each funder. After this, the s_funders array is reset to a new empty array. Now, the contract owner can withdraw all the contract balance using the call function. Doing all of this is considered cheaper since it avoids reading and writing to <em>storage </em>for every iteration, but I’ll explain <em>why</em> <a href="https://medium.com/@sheth.tanvi18/functional-and-robust-smart-contracts-unit-and-stage-tests-oracles-and-gas-optimization-2861061c862">very soon</a>.</p><blockquote>A public function in Solidity is a function that can be accessed by anyone, including other contracts and external accounts. These functions are part of the contract’s external interface, and they can be called from anywhere in the blockchain network.</blockquote><blockquote>On the other hand, a not public or private function in Solidity is a function that can only be accessed within the contract itself. These functions cannot be called from outside the contract, and they are not part of the contract’s external interface. Private functions are typically used to encapsulate internal logic within the contract and to make the contract’s code more modular and easier to maintain.</blockquote><blockquote>It’s important to note that making a function public does mean that it can be called by anyone, which may increase the risk of unintended behavior or malicious attacks. So, I’ve learned that public functions should only be used for those functions that need to be called from outside the contract, such as functions that provide access to the contract’s state or ones that allow other contracts to interact with the contract.</blockquote><h4>Aiming for Functionality</h4><p>This pretty much sums up the functionality of the smart contract, but a major tool that I experimented with in this project were those price converters. I was able to retrieve and calculate the price of Ether (ETH) in USD using an implementation of the Chainlink Price Feed library (<em>AggregatorV3Interface</em>). These tools that layer overtop a basic smart contract are what set functional and realistic applications apart. I’ve recognized the potential of a smart contract, and have written and deployed enough basic ones to a blockchain to know there is much more potential for them. These tools fully unlock that potential.</p><h4>Solidity Libraries</h4><p>For this specific application, I created another ‘contract-like’ file called PriceConvertor.sol. Although it is written in Solidity, it does not serve the same purpose or functionality as a smart contract. Its a library.</p><blockquote>A library is a reusable piece of code that can be called by other smart contracts and libraries to perform specific functions or tasks. Libraries can be used to save gas costs and reduce the size of smart contracts by enabling developers to reuse code that would otherwise be duplicated in multiple smart contracts. In this case, the PriceConverter library is used to perform price conversion calculations for a specific token. The functions defined in the library can be used by my smart contract. This library uses an oracle to access the price feed data necessary for the conversion. I explain this more at the end!</blockquote><pre>// SPDX-License-Identifier: MIT<br>pragma solidity 0.8.8;<br><br>import &quot;@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol&quot;;<br><br>// Why is this a library and not abstract?<br>// Why not an interface?<br>library PriceConverter {<br>    // We could make this public, but then we&#39;d have to deploy it<br>    function getPrice(<br>        AggregatorV3Interface priceFeed<br>    ) internal view returns (uint256) {<br>        (, int256 answer, , , ) = priceFeed.latestRoundData();<br>        // ETH/USD rate in 18 digit<br>        return uint256(answer * 10000000000);<br>        // or (Both will do the same thing)<br>        // return uint256(answer * 1e10); // 1* 10 ** 10 == 10000000000<br>    }<br><br>    // 1000000000<br>    function getConversionRate(<br>        uint256 ethAmount,<br>        AggregatorV3Interface priceFeed<br>    ) internal view returns (uint256) {<br>        uint256 ethPrice = getPrice(priceFeed);<br>        uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1000000000000000000;<br>        // or (Both will do the same thing)<br>        // uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1e18; // 1 * 10 ** 18 == 1000000000000000000<br>        // the actual ETH/USD conversion rate, after adjusting the extra 0s.<br>        return ethAmountInUsd;<br>    }<br>}</pre><p>It is initialized just the same as a Solidity contract, but this time, I wrote out two functions:</p><h4>Functions of a Solidity Library</h4><p>The <strong>getPrice </strong>function takes an input parameter priceFeed of type AggregatorV3Interface. This parameter represents a price feed contract that is used to get the current price of an asset.</p><p>Within the function, the latestRoundData function is called on priceFeed, which returns a tuple of 5 values — the current round ID, the price of the asset in question, the timestamp of the price, the start time of the round, and the end time of the round. However, only the answer value, which represents the current price of the asset in question, is used in the function.</p><p>The answer value is then multiplied by 10000000000 and cast to an unsigned integer of type uint256. This value is returned by the function as the price of the asset in question, denominated in USD with 18 decimal places.</p><blockquote>When converting from ETH to USD or any other fiat currency, decimal places are used to represent fractional values.</blockquote><blockquote>In the context of Ethereum, the smallest unit of ETH is wei, which is equivalent to 10^-18 ETH. When converting from wei or ETH to USD, a decimal point is typically used to represent fractional values of the USD equivalent.</blockquote><blockquote>For example, if the price of ETH is $2000 USD, one ETH would be worth 2,000,000,000,000,000,000 wei or 2,000 USD. If the price of ETH changes to $2500 USD, one ETH would be worth 2,500,000,000,000,000,000 wei or 2,500 USD.</blockquote><blockquote>The <strong>getConversionRate</strong> function takes two input parameters: ethAmount, which represents the amount of ether to be converted to USD, and priceFeed, which is the price feed contract that represents the current price of ether in USD.</blockquote><p>Within the function, the getPrice function is called with the priceFeed parameter to get the current price of ether in USD. This value is then multiplied by ethAmount and divided by 1000000000000000000 (or 1e18), which is the number of wei in 1 ether. The resulting value represents the USD equivalent of the ethAmount parameter.</p><p>This value is returned by the function as the conversion rate of ethAmount ether to USD, based on the current price of ether in USD provided by the priceFeed parameter (from the oracle that the library has access to).</p><blockquote>Wei: the currency used to facilitate transactional operations on the Ethereum blockchain network, where ¹⁰¹⁸ or 1,000,000,000,000,000,000 wei is equivalent to one ether.</blockquote><h4>The Support System of a Smart Contract</h4><p>We’re done with the smart contracts, which is what seems like the entirety of Web3 development and Ethereum’s protocols. But, in order to execute these smart contracts and their functions, you need to write detailed scripts that have specific instructions for the intended use case of the smart contract. These scripts can be executed locally or deployed to a blockchain network. I first executed them on Hardhat’s localhost network that is provided, and then to a testnet, which in this case is Goerli.</p><blockquote>When I constructed my first dApp, I created a step-by-step tutorial of my project and explained concepts like testnets, fakeETH, and smaller details that I mention throughout this article. This project was intended for me to get familiar with the more advanced concepts of blockchain developments, so I focus on them more.</blockquote><h4>Scripts for a Smart Contract</h4><p><strong>I wrote 3 scripts.</strong></p><blockquote>Deploy Script</blockquote><blockquote>Fund Script</blockquote><blockquote>Withdraw Script</blockquote><blockquote><strong>Deploy Script</strong></blockquote><pre>const { ethers } = require(&quot;hardhat&quot;)<br>const { networkConfig, developmentChains } = require(&quot;../helper-hardhat-config&quot;) //extrapalate networkConfig from the helper shit<br>const { network } = require(&quot;hardhat&quot;)<br>const { verify } = require(&quot;../utils/verify&quot;)<br><br>module.exports = async ({ getNamedAccounts, deployments }) =&gt; {<br>    const { deploy, log } = deployments //pull from deployments<br>    const { deployer } = await getNamedAccounts() //pull account from getNamedAccounts() function<br>    const chainId = network.config.chainId // get chainId<br><br>    //if chainId is X, use address Y<br>    //if chainid is Z use address A<br><br>    //const ethUsdPriceFeedAddress = networkConfig[chainId][&quot;ethUsdPriceFeed&quot;] // no matter what network we deploy to, the chainId will use the right priceFeed address<br>    let ethUsdPriceFeedAddress<br>    if (developmentChains.includes(network.name)) {<br>        const ethUsdAgregator = await deployments.get(&quot;MockV3Aggregator&quot;)<br>        ethUsdPriceFeedAddress = ethUsdAgregator.address<br>    } else {<br>        ethUsdPriceFeedAddress = networkConfig[chainId][&quot;ethUsdPriceFeed&quot;]<br>    }<br><br>    //well what happens when we want to change chains?<br>    //when going for localhost or hardhat network we want to use a mock<br>    const args = [ethUsdPriceFeedAddress]<br>    const fundMe = await deploy(&quot;FundMe&quot;, {<br>        from: deployer,<br>        args: args, //put price feed address<br>        log: true,<br>        waitConfirmations: network.config.blockConfimations || 1,<br>    })<br>    log(&quot;__________________________&quot;)<br><br>    if (<br>        !developmentChains.includes(network.name) &amp;&amp;<br>        process.env.ETHERSCAN_API_KEY<br>        //name of network isnt development chain<br>    ) {<br>        await verify(fundMe.address, args)<br>    }<br>    log(&quot;________________&quot;)<br>}<br>module.exports.tags = [&quot;all&quot;, &quot;fundme&quot;]</pre><h4>Purpose</h4><ol><li>Imports necessary modules and helper functions. This primarily ensures that I can deploy to any chain with the correct price feed and verify my contract, as well as access certain things from the ethers library, which is so convenient.</li></ol><blockquote>Some of the key features of the “ethers” library include:</blockquote><blockquote>Support for multiple Ethereum networks and providers, including Ethereum mainnet, testnets, and private networks</blockquote><blockquote>Easy creation and management of Ethereum accounts and wallets</blockquote><blockquote>Simplified transaction creation and signing, with gas estimation and fee calculation</blockquote><blockquote>Convenient interaction with smart contracts, including contract deployment, function calls, and event listening</blockquote><blockquote>Integration with popular Ethereum tools and services, such as MetaMask, Infura, and Etherscan</blockquote><p>2. It defines an <a href="https://medium.com/@sheth.tanvi18/looking-at-unfamiliarity-through-a-familiar-lens-68c5d6d93cc8">asynchronous </a>function that takes getNamedAccounts and deployments as parameters.</p><p>3. Uses the deployments object to deploy the FundMe contract (and pulls the account from the getNamedAccounts() function) by calling the deploy function with the contract name, constructor arguments, and deployment options such as from, log, and waitConfirmations.</p><blockquote>“waitConfirmations” is a common function used in blockchain development to wait for a certain number of confirmations on a transaction before considering it as finalized or complete.</blockquote><blockquote>The “waitConfirmations” function typically takes in the transaction hash and the number of confirmations to wait for as parameters. It then periodically checks the blockchain network for new blocks and counts the number of confirmations for the given transaction. Once the required number of confirmations has been reached, the function returns, indicating that the transaction is complete.</blockquote><blockquote>This function is often used in decentralized applications (dApps) to ensure that important transactions, such as token transfers or smart contract interactions, have been fully confirmed before allowing the user to proceed.</blockquote><p>4. Determines the chain ID and uses it to get the Ethereum-USD price feed address from the networkConfig object. This object is described in another file, but I imported it at the top of my script (you’ll see all this in the comments). If the network is a local development chain, it uses a mock aggregator that is defined by a previous script (00-deploy-mocks.js — also in the GitHub Repo but didn&#39;t showcase here).</p><h4>A visual of the networkConfig object. I have defined two possible networks.</h4><pre>const networkConfig = {<br>    5: {<br>        name: &quot;goerli&quot;,<br>        ethUsdPriceFeed: &quot;0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e&quot;,<br>    },<br>    //keeping track of price feed addresses across chains<br>    137: {<br>        name: &quot;polygon&quot;,<br>        ethUsdPriceFeed: &quot;&quot;,<br>    },<br>}</pre><blockquote>These are examples of ‘constants,’ along with private keys, contract addresses, price feed addresses, API keys, ABI files, etc.</blockquote><p>5. Verifies the deployed contract on Etherscan if the network is not a development chain and an Etherscan API key is provided (all of this would be found in the hardhat. config file as constants in another object).</p><p>6. Exports the function with the tags property that specifies the tags for the deployment script. This is just to specify my command in the terminal. Just a small trick that I learned.</p><blockquote><strong>Fund Script</strong></blockquote><pre>const { getNamedAccounts, ethers } = require(&quot;hardhat&quot;)<br>async function main() {<br>    const { deployer } = await getNamedAccounts()<br>    const fundMe = await ethers.getContract(&quot;FundMe&quot;, deployer)<br>    console.log(&quot;Funding Contract...&quot;)<br>    const transactionResponse = await fundMe.fund({<br>        value: ethers.utils.parseEther(&quot;0.1&quot;),<br>    })<br>    await transactionResponse.wait(1)<br>    console.log(&quot;Funded!&quot;)<br>}<br><br>main()<br>    .then(() =&gt; process.exit(0))<br>    .catch((error) =&gt; {<br>        console.error(error)<br>        process.exit(1)<br>    })</pre><h4>Purpose</h4><p>This code deploys my smart contract FundMe and funds it with 0.1 ether. It uses the same libraries and frameworks as I mentioned above. The getNamedAccounts() function retrieves the Ethereum address of the predefined deployer account. The ethers.getContract() function creates an instance of the FundMe contract using the contract’s name and the deployer address. The fund() function is called on the fundMe instance with a value of 0.1 <strong>ether </strong>specified in wei. The transactionResponse.wait(1) function waits for the transaction to be confirmed on the blockchain. Finally, the main() function is executed, and if it completes successfully, the process is terminated with an exit code of 0 (no more async functions are pending). Super clear, and super easy.</p><blockquote><strong>Withdraw Script</strong></blockquote><pre>const { getNamedAccounts, ethers } = require(&quot;hardhat&quot;)<br>async function main() {<br>    const { deployer } = await getNamedAccounts()<br>    const fundMe = await ethers.getContract(&quot;FundMe&quot;, deployer)<br>    console.log(&quot;Withdrawing...&quot;)<br>    const transactionResponse = await fundMe.withdraw()<br>    await transactionResponse.wait(1)<br>    console.log(&quot;Got it back!&quot;)<br>}<br>main()<br>    .then(() =&gt; process.exit(0))<br>    .catch((error) =&gt; {<br>        console.error(error)<br>        process.exit(1)<br>    })</pre><h4>Purpose</h4><p>Another super clear and concise script; only meant for one thing. The asynchronous function called main retrieves the deployer’s address and creates an instance of the FundMe contract using the ethers.getContract method. The function logs a message to the console, withdraws funds from the contract by calling the withdraw function that I defined in the smart contract, and waits for the transaction to be mined. Once the transaction has been confirmed, the function logs another message to indicate that the funds have been retrieved. Finally, the code executes the main function and exits the program.</p><blockquote>Transaction Reciept: A transaction receipt is a record of a transaction that has been processed and included in a block on the Ethereum blockchain. It includes information such as the block number, transaction hash, and gas used. The receipt is a permanent record of the transaction and can be used to verify that the transaction was executed as intended.</blockquote><p>All you need is a script and a smart contract (along with some configuration files and libraries) to start the front end of a dApp. With the ABI and the contract address connecting your contract to a user interface, and some buttons that call functions from your smart contract, you would have a fully functional dApp. Just to make it super clear:</p><blockquote>The script would typically be used to interact with the smart contract, either by deploying it to a blockchain network or by calling its functions to perform some logic. The smart contract would define the logic of the dApp, such as storing data or managing tokens.</blockquote><blockquote>I want to prioritize developing a skill set to contribute to a new product for users and build things that make an impact. Of course, these projects are just the beginning, but optimizing them to be as suitable as possible for the real-world is the place I want to start.</blockquote><p>I’ll be going over how I leveraged three of those tools/techniques; gas optimization, oracles, and unit/staging testing in <a href="https://medium.com/@sheth.tanvi18/functional-and-robust-smart-contracts-unit-and-stage-tests-oracles-and-gas-optimization-2861061c862"><strong>Part 2</strong></a><strong> </strong>of this article. These add-ons became quite lengthy, but the detail and logic deserved an article of their own.</p><blockquote>Thanks for giving this a read :) If you’re up for it, follow my <a href="https://medium.com/@sheth.tanvi18">Medium </a>account for more content as I navigate my curiosities. Feel free to connect with me on <a href="https://www.linkedin.com/in/tanvi-sheth-06b4501ba/">LinkedIn </a>or <a href="https://twitter.com/_TanviSheth">Twitter </a>and check out my <a href="https://tks.life/profile#portfolio">full portfolio</a> to keep up with my projects and experiences. To stay updated on my monthly progress and takeaways, subscribe to my <a href="https://tanvisheth.substack.com/?utm_source=substack&amp;utm_medium=web&amp;utm_campaign=substack_profile">newsletter </a>as well.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3de5734e24a" width="1" height="1" alt=""><hr><p><a href="https://studentsxstudents.com/decentralized-funding-a3de5734e24a">Decentralized Funding in Real-World Contexts</a> was originally published in <a href="https://studentsxstudents.com/">students x students</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Functional and Robust Smart Contracts: Unit and Staging Tests, Oracles, and Gas Optimization]]></title>
            <link>https://studentsxstudents.com/functional-and-robust-smart-contracts-unit-and-stage-tests-oracles-and-gas-optimization-2861061c862?source=rss-6c8172dff473------2</link>
            <guid isPermaLink="false">https://medium.com/p/2861061c862</guid>
            <category><![CDATA[enjoy-writing]]></category>
            <category><![CDATA[testing-framework]]></category>
            <category><![CDATA[gas-optimization]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Tanvi Sheth]]></dc:creator>
            <pubDate>Sun, 26 Mar 2023 13:48:56 GMT</pubDate>
            <atom:updated>2025-07-08T17:13:47.161Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Part 2: FundMe dApp</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*fiFMd1K-im8jlqUakf0txg.png" /></figure><h4>This is a <a href="https://medium.com/p/a3de5734e24a/edit">two-part</a> article, highlighting the two backbones of a decentralized application; smart contracts and scripts, but also an overview of the tools and advanced development techniques I incorporated to make this application functional and convenient for a user to use, and efficient and robust for a developer to build.</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FcdMYh0kppiY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DcdMYh0kppiY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FcdMYh0kppiY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cebb4e04057a9f20825a05dce39c7d61/href">https://medium.com/media/cebb4e04057a9f20825a05dce39c7d61/href</a></iframe><h4>Oracles</h4><ul><li>Price Feeds</li><li>Console Contract Libraries in Solidity</li></ul><h4>Gas Optimization Techniques + Operation Codes</h4><ul><li>Storage variables</li><li>Error statements</li><li>Libraries</li></ul><h4>Test Frameworks</h4><ul><li>Unit Tests</li><li>Staging Tests</li></ul><p>This is <strong>Part 2</strong> of my FundMe dApp project article. If you haven’t already, check out <a href="https://medium.com/p/a3de5734e24a/edit"><strong>Part 1</strong></a> for an overview of the project and a deep dive into the contracts and scripts that I wrote for this decentralized application. In this article, I dive into the tools/techniques listed above.</p><blockquote>I want to prioritize developing a skill set to contribute to a new product for users and build things that make an impact. Of course, these projects are just the beginning, but optimizing them to be as suitable as possible for the real-world is the place I want to start.</blockquote><p>So, let&#39;s take a closer look at how I optimized this project to be as suitable as possible for real-world use and development.</p><h4>Price Feed Oracles</h4><p>These came in handy for the use case of my dApp and adding a realistic touch to the entire project that enables users to interact with my application with a purpose and efficient functionality.</p><p>A price feed oracle is a trusted source of price data that gives real-time price information for assets like cryptocurrencies. In my case, I used the oracle to fetch and update price data on-chain. But I first <em>established </em>a contract console library called PriceConvertor using Solidity in <a href="https://medium.com/p/a3de5734e24a/edit">Part 1</a>. Here’s how I <em>used</em> it to access the oracle data/network.</p><blockquote>Essentially, the oracle collects price data from multiple sources, such as exchanges, and aggregates it to provide an accurate and reliable price feed (that&#39;s why you see the MockV3Aggregator everywhere; that&#39;s what aggregates the data on a local chain). The price feed is then published on the blockchain and can be accessed by dApps and smart contracts that I’ve made that need to use the price information.</blockquote><p>Chainlink is a decentralized network of nodes that provide data and information from off-blockchain sources to on-blockchain smart contracts via oracles. This process, along with extra secure hardware, eliminates the reliability issues that might occur if using a single centralized source. This is what lets me access outside information into my dApp so it reflects current rates and can be used realistically + users will choose it over a centralized application that accompanies reliability issues. Now, my application makes sense to be used and switched to.</p><p>Let&#39;s take a look at the scripts more closely.</p><pre>const { ethers } = require(&quot;hardhat&quot;)<br>const { networkConfig, developmentChains } = require(&quot;../helper-hardhat-config&quot;) //extrapalate networkConfig from the helper shit<br>const { network } = require(&quot;hardhat&quot;)<br>const { verify } = require(&quot;../utils/verify&quot;)<br><br><br>module.exports = async ({ getNamedAccounts, deployments }) =&gt; {<br>    const { deploy, log } = deployments //pull from deployments<br>    const { deployer } = await getNamedAccounts() //pull account from getNamedAccounts() function<br>    const chainId = network.config.chainId // get chainId<br><br><br>    //if chainId is X, use address Y<br>    //if chainid is Z use address A<br><br><br>    //const ethUsdPriceFeedAddress = networkConfig[chainId][&quot;ethUsdPriceFeed&quot;] // no matter what network we deploy to, the chainId will use the right priceFeed address<br>    let ethUsdPriceFeedAddress<br>    if (developmentChains.includes(network.name)) {<br>        const ethUsdAgregator = await deployments.get(&quot;MockV3Aggregator&quot;)<br>        ethUsdPriceFeedAddress = ethUsdAgregator.address<br>    } else {<br>        ethUsdPriceFeedAddress = networkConfig[chainId][&quot;ethUsdPriceFeed&quot;]<br>    }<br><br><br>    //well what happens when we want to change chains?<br>    //when going for localhost or hardhat network we want to use a mock<br>    const args = [ethUsdPriceFeedAddress]<br>    const fundMe = await deploy(&quot;FundMe&quot;, {<br>        from: deployer,<br>        args: args, //put price feed address<br>        log: true,<br>        waitConfirmations: network.config.blockConfimations || 1,<br>    })<br>    log(&quot;__________________________&quot;)<br><br><br>    if (<br>        !developmentChains.includes(network.name) &amp;&amp;<br>        process.env.ETHERSCAN_API_KEY<br>        //name of network isnt development chain<br>    ) {<br>        await verify(fundMe.address, args)<br>    }<br>    log(&quot;________________&quot;)<br>}<br>module.exports.tags = [&quot;all&quot;, &quot;fundme&quot;]</pre><p>The price feed is involved by providing the ETH/USD price to the deployed contract “FundMe.”</p><p>In the code, the address of the price feed is obtained from the network configuration file or a mock aggregator contract depending on the current network. As I said before, this enables the correct price feed to be used based on the chain the contract is deployed on, since each chain has a different currency and conversion rate to USD/CAD. Here’s what the object looks like in the helper-hardhat-config file. I had first called the network manually, but this automates the selection based on the chain.</p><pre>const networkConfig = {<br>    5: {<br>        name: &quot;goerli&quot;,<br>        ethUsdPriceFeed: &quot;0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e&quot;,<br>    },<br>    //keeping track of pricefeed addreses accross chains<br>    137: {<br>        name: &quot;polygon&quot;,<br>        ethUsdPriceFeed: &quot;&quot;,<br>    },<br>}</pre><p>Going back to the script.</p><pre>const { ethers } = require(&quot;hardhat&quot;)<br>const { networkConfig, developmentChains } = require(&quot;../helper-hardhat-config&quot;) //extrapalate networkConfig from the helper shit<br>const { network } = require(&quot;hardhat&quot;)<br>const { verify } = require(&quot;../utils/verify&quot;)<br><br><br>module.exports = async ({ getNamedAccounts, deployments }) =&gt; {<br>    const { deploy, log } = deployments //pull from deployments<br>    const { deployer } = await getNamedAccounts() //pull account from getNamedAccounts() function<br>    const chainId = network.config.chainId // get chainId<br><br><br>    //if chainId is X, use address Y<br>    //if chainid is Z use address A<br><br><br>    //const ethUsdPriceFeedAddress = networkConfig[chainId][&quot;ethUsdPriceFeed&quot;] // no matter what network we deploy to, the chainId will use the right priceFeed address<br>    let ethUsdPriceFeedAddress<br>    if (developmentChains.includes(network.name)) {<br>        const ethUsdAgregator = await deployments.get(&quot;MockV3Aggregator&quot;)<br>        ethUsdPriceFeedAddress = ethUsdAgregator.address<br>    } else {<br>        ethUsdPriceFeedAddress = networkConfig[chainId][&quot;ethUsdPriceFeed&quot;]<br>    }<br><br><br>    //well what happens when we want to change chains?<br>    //when going for localhost or hardhat network we want to use a mock<br>    const args = [ethUsdPriceFeedAddress]<br>    const fundMe = await deploy(&quot;FundMe&quot;, {<br>        from: deployer,<br>        args: args, //put price feed address<br>        log: true,<br>        waitConfirmations: network.config.blockConfimations || 1,<br>    })<br>    log(&quot;__________________________&quot;)<br><br><br>    if (<br>        !developmentChains.includes(network.name) &amp;&amp;<br>        process.env.ETHERSCAN_API_KEY<br>        //name of network isnt development chain<br>    ) {<br>        await verify(fundMe.address, args)<br>    }<br>    log(&quot;________________&quot;)<br>}<br>module.exports.tags = [&quot;all&quot;, &quot;fundme&quot;]</pre><p>The obtained address is passed as an argument to the “FundMe” contract during deployment. The “FundMe” contract uses the price feed to convert ETH amounts to USD amounts for funding requests. Without a price feed, the contract would not be able to accurately calculate the USD value of the ETH received.</p><h4>In my smart contract</h4><pre>// SPDX-License-Identifier: MIT<br>pragma solidity 0.8.8;<br>//Imports<br>import &quot;@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol&quot;;<br>import &quot;./PriceConverter.sol&quot;;<br>import &quot;hardhat/console.sol&quot;;<br>//Errors<br>error FundMe__NotOwner();<br><br>//Libraries, Libraries, Contracts<br><br>/** @title A contract for crowd funding<br> * @author tanvi Sheth<br> * @notice This contract is demo a sample funding contract<br> * @dev This implements price feeds as our library<br><br>*/<br>contract FundMe {<br>    //type declarations<br>    using PriceConverter for uint256;<br><br>    //state variables!<br>    mapping(address =&gt; uint256) public s_addressToAmountFunded;<br>    address[] public s_funders;<br><br>    // Could we make this constant?  /* hint: no! We should make it immutable! */<br>    address public immutable i_owner;<br>    uint256 public constant MINIMUM_USD = 50 * 10 ** 18;<br><br>    AggregatorV3Interface public s_priceFeed;<br><br>    modifier onlyOwner() {<br>        // require(msg.sender == owner);<br>        if (msg.sender != i_owner) revert FundMe__NotOwner();<br>        _;<br>    }<br><br>    constructor(address s_priceFeedAddress) {<br>        //price feed address is modularized based on what chain we&#39;re on<br>        i_owner = msg.sender;<br>        s_priceFeed = AggregatorV3Interface(s_priceFeedAddress);<br>    }<br><br>    receive() external payable {<br>        fund();<br>    }<br><br>    fallback() external payable {<br>        fund();<br>    }<br><br>    /**<br>     * @notice This function funds this contract<br>     * @dev This implements price feeds as our library<br>     */<br>    function fund() public payable {<br>        require(<br>            msg.value.getConversionRate(s_priceFeed) &gt;= MINIMUM_USD,<br>            &quot;You need to spend more ETH!&quot;<br>        );<br>        // require(PriceConverter.getConversionRate(msg.value) &gt;= MINIMUM_USD, &quot;You need to spend more ETH!&quot;);<br>        s_addressToAmountFunded[msg.sender] += msg.value;<br>        s_funders.push(msg.sender);<br>    }<br><br>    function getVersion() public view returns (uint256) {<br>        // ETH/USD price feed address of Goerli Network.<br>        return s_priceFeed.version();<br>    }<br><br>    function withdraw() public onlyOwner {<br>        for (<br>            uint256 funderIndex = 0;<br>            funderIndex &lt; s_funders.length;<br>            funderIndex++<br>        ) {<br>            address funder = s_funders[funderIndex];<br>            s_addressToAmountFunded[funder] = 0;<br>        }<br>        s_funders = new address[](0);<br>        // // transfer<br>        // payable(msg.sender).transfer(address(this).balance);<br>        // // send<br>        // bool sendSuccess = payable(msg.sender).send(address(this).balance);<br>        // require(sendSuccess, &quot;Send failed&quot;);<br>        // call<br>        (bool callSuccess, ) = payable(msg.sender).call{<br>            value: address(this).balance<br>        }(&quot;&quot;);<br>        require(callSuccess, &quot;Call failed&quot;);<br>    }<br><br>    function cheaperWithdraw() public payable onlyOwner {<br>        //rn doubling the amount of storage we are reading from<br>        //instead read the array into memory one time, and read and write from memeory (cheaper) instead of storage and update storage when done<br>        address[] memory funders = s_funders;<br>        for (<br>            uint256 funderIndex = 0;<br>            funderIndex &lt; funders.length;<br>            funderIndex++<br>        ) {<br>            address funder = funders[funderIndex]; //using funders array and not s_funders<br>            s_addressToAmountFunded[funder] = 0;<br>        }<br>        s_funders = new address[](0);<br>        (bool success, ) = i_owner.call{value: address(this).balance}(&quot;&quot;);<br>        require(success);<br>    }<br>}</pre><p>The price feed is involved in the fund function of the FundMe contract as well. The require statement in the fund function uses the price feed to determine if the amount of ETH sent with the transaction is sufficient for funding.</p><p>The getConversionRate function of the Price Converter library takes the amount of ETH sent as a parameter and uses the price feed to convert it to its USD equivalent. If the USD equivalent is less than the MINIMUM_USD constant, which is set to 50 ETH in USD, the transaction reverts with an error message indicating that the sender needs to spend more ETH.</p><blockquote>In its simplest form, the price feed is used to determine the exchange rate between ETH and USD and to ensure that the amount of ETH sent with the transaction meets the minimum funding requirement in USD, but also enables users to quantify the money they are funding and withdrawing in a FIAT currency.</blockquote><p><a href="https://docs.chain.link/data-feeds/price-feeds/addresses/">Take a look at all of the Chainlink Price Feed Addresses that Chainlink provides</a>.</p><p><strong>Gas Optimization Techniques</strong></p><p>Gas optimization techniques are necessary for a blockchain because the process of executing transactions in a decentralized system like Ethereum takes a lot of computing resources. Every operation that a smart contract performs costs a certain amount of gas, and that is a unit of measurement for the computational effort required to run the operation. The gas limit is set for each block in the Ethereum network, and if a transaction exceeds this limit, it will fail.</p><p>Other than ensuring you are under the gas limit, these techniques help to reduce the time it takes for a transaction to be confirmed and included in a block. This is because miners are <em>incentivized </em>to include transactions with lower gas costs, so reducing gas usage can make a transaction more attractive to miners.</p><p><a href="https://github.com/crytic/evm-opcodes">Check this out.</a></p><p>If you take a look at all of these operation (opp) codes in this GitHub repo (which you can manually find in your bytecode when you deploy a contract), you can see exactly how much gas each operation takes up. All of them are pretty small amounts until you <em>save</em> and <em>load</em> them from storage. This is when everything gets really pricey (20000 and 800 gas fees!).</p><blockquote>I’ve appended each of the storage variables with an ‘<em>s’</em> so I know that I&#39;m working with <em>very</em> expensive operations and for other readers to be aware of this fact. Immutable variables are appended with ‘<em>i’ </em>and since constant values are also not in storage, I’ve appended them with CONSTANT.</blockquote><p><strong>This is a run-through of what happens on-chain</strong></p><ol><li>The gas fee is paid by the user who initiates the transaction or contract function and is denominated in units of gas.</li><li>The gas price is set by the user and represents the amount of Ether they are willing to pay for each unit of gas.</li><li>The total gas fee is calculated by multiplying the gas price by the amount of gas used to execute the transaction or contract function.</li><li>The gas fee is paid to the miners who process and validate transactions on the Ethereum network as a reward for their work.</li></ol><p><strong>In my contract, the portion that seems to have a lot of storage variables is the withdraw function(). So let&#39;s take a closer look at it.</strong></p><pre>function withdraw() public onlyOwner {<br>        for (<br>            uint256 funderIndex = 0;<br>            funderIndex &lt; s_funders.length;<br>            funderIndex++<br>        ) {<br>            address funder = s_funders[funderIndex];<br>            s_addressToAmountFunded[funder] = 0;<br>        }<br>        s_funders = new address[](0);<br>        // // transfer<br>        // payable(msg.sender).transfer(address(this).balance);<br>        // // send<br>        // bool sendSuccess = payable(msg.sender).send(address(this).balance);<br>        // require(sendSuccess, &quot;Send failed&quot;);<br>        // call<br>        (bool callSuccess, ) = payable(msg.sender).call{<br>            value: address(this).balance<br>        }(&quot;&quot;);<br>        require(callSuccess, &quot;Call failed&quot;);<br>    }</pre><p>First up, there&#39;s a <em>for </em>loop, which means every time we go through these sections, we are looping through and working with all of these pricey variables. We&#39;re comparing if the fundersIndex is less than the s_funders.length.</p><p>The longer the funders array is, the more times we will read from storage, and more gas will be used. <em>That is a crazy amount of gas guys.</em></p><p>Second, we’re reading a lot from storage in the line right below it and saving this data to the address funder memory variable, but also updating the storage variable <em>each time</em>.</p><p><strong>A lot of unnecessary reading from storage = a lot of unnecessary $$.</strong></p><blockquote>Why don&#39;t I create a much cheaper and gas efficient withdraw() function, now that I know how to :)</blockquote><p>One change I thought of making is reading the entire funders array into memory and accessing the indexes from memory each time instead of from storage. We can now read and write from the memory variable and only update storage when we’re done with everything.</p><pre>    function cheaperWithdraw() public payable onlyOwner {<br>        //rn doubling the amount of storage we are reading from<br>        //instead read the array into memory one time, and read and write from memeory (cheaper) instead of storage and update storage when done<br>        address[] memory funders = s_funders;<br>        for (<br>            uint256 funderIndex = 0;<br>            funderIndex &lt; funders.length;<br>            funderIndex++<br>        ) {<br>            address funder = funders[funderIndex]; //using funders array and not s_funders<br>            s_addressToAmountFunded[funder] = 0;<br>        }<br>        s_funders = new address[](0);<br>        (bool success, ) = i_owner.call{value: address(this).balance}(&quot;&quot;);<br>        require(success);<br>    }<br>}</pre><p>The new code does exactly that; puts the array into memory and then establishes the condition with funders instead of s_funders. Within the loop: address funder = funders[] — -&gt; is the memory array. We’re then resetting the funders array (which is a storage variable but there&#39;s no other way around it), and the rest is the same.</p><h4>Gas Reports</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MjoiYKZIjQd-bfhcqn506A.png" /><figcaption>Locally</figcaption></figure><p>Taking a look at the gas report (enabled by the testing frameworks I am using). cheaperWithdraw, on average, is actually more expensive than the withdraw function. This is because we only tested this function with the multi-withdraw scenario (I wrote the same tests for the cheaper withdraw and withdraw functions), so it actually had to withdraw on many more accounts.</p><p>However, this average is technically considered the max cost of the cheaper withdraw functions, so if we compare the <em>two max rates</em> (shift the average column to the left), we can see that the cheaperWithdraw function is much cheaper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Psdv-hzlsqeNL_eaD-3e_w.png" /><figcaption>On a testnet</figcaption></figure><p>Now, let&#39;s run on an actual testnet (by enabling the API key in the gas reporter object in the hardhat config file) and test both functions for the single funder scenario.</p><p>In this case, in the minimum column, the cheaperWithdraw is more expensive. This is because you only need to run the loop one time in the normal withdraw function, but the cheaperWithdraw has to do that extra step of loading the array to the memory before. Again, this is for the single-funder scenario only. But, looking at the average values, the cheaperWithdraw is indeed cheaper and you save around 3.70 cents on average, not even accounting for the large gap in the max values that would save an amount that is actually <em>worth doing all this extra work for.</em></p><h4>Testing</h4><blockquote>This was the unfamiliar part for me and took quite some time to determine how to leverage tests to ensure an efficient smart contract, which I prioritized for this project. Smart contract deployments are expensive, and a logically faulty contract with execution errors can cost you a lot of unnecessary time and money. Thats why tests are so convenient and crucial in blockchain development.</blockquote><p>In my first dApp, I had to redeploy my contract several times because I didn&#39;t account for a specific circumstance. Tests essentially prepare for all cases and situations. Primarily, they check if a contract’s code works correctly and that it can handle various inputs and scenarios, but also check for bugs, security issues, and performance problems if there are gaps in the logic. Here are the unit tests I wrote when deploying to the local blockchain, which is different from the staging tests you write before deploying to a test net blockchain.</p><blockquote>Unit tests are created to make sure each function or component of the contract works as expected. Unit tests can be run quickly and repeatedly, which makes them useful for catching bugs early in the development process.</blockquote><blockquote>Staging tests are more like holistic, end-to-end tests. This comprehensive testing involves testing the entire system from end to end. So along with the smart contract, any external systems that the contract interacts with, such as wallets, exchanges, or other contracts on the blockchain, are also tested. Staging tests are designed to ensure that the contract functions correctly in a real-world environment (or a testnet in my case) and that it is secure and resilient to attack.</blockquote><h4>Test Suite</h4><pre>const { assert, expect } = require(&quot;chai&quot;)<br>const { network, deployments, ethers } = require(&quot;hardhat&quot;)<br>const { developmentChains } = require(&quot;../../helper-hardhat-config&quot;)<br><br>!developmentChains.includes(network.name)<br>    ? describe.skip<br>    : describe(&quot;FundMe&quot;, function () {<br>          let fundMe<br>          let mockV3Aggregator<br>          let deployer<br>          const sendValue = ethers.utils.parseEther(&quot;1&quot;)<br>          beforeEach(async () =&gt; {<br>              // const accounts = await ethers.getSigners()<br>              // deployer = accounts[0]<br>              deployer = (await getNamedAccounts()).deployer<br>              await deployments.fixture([&quot;all&quot;])<br>              fundMe = await ethers.getContract(&quot;FundMe&quot;, deployer)<br>              mockV3Aggregator = await ethers.getContract(<br>                  &quot;MockV3Aggregator&quot;,<br>                  deployer<br>              )<br>          })</pre><p>The code first checks whether the current network’s name is included in an array of development chains (these are all defined in the helper-hardhat-config file as an object, which I mentioned above). If it isn’t, the entire test suite is skipped using the describe.skip method. Otherwise, the test suite for a contract named “FundMe” is executed.</p><p>The beforeEach function is used to run some code before each test in the suite. In this case, it sets up the fundMe and mockV3Aggregator variables by fetching them from the local network using the ethers.getContract method. It also sets up a deployer variable, which is used to deploy the contracts. Finally, it uses the deployments.fixture method to deploy all the contracts defined in the deployment script. After all of these actions are executed, the test for the specific function in the suite will be run.</p><h4>Constructor Function Test</h4><pre> describe(&quot;constructor&quot;, function () {<br><br>              it(&quot;sets the aggregator addresses correctly&quot;, async () =&gt; {<br>                  const response = await fundMe.getPriceFeed()<br>                  assert.equal(response, mockV3Aggregator.address)<br>              })<br>          })</pre><p>This is a test case for the constructor function of the FundMe contract. The test checks if the constructor correctly sets the address of the price feed aggregator by calling the getPriceFeed function and verifying that the returned address matches the address of the MockV3Aggregator contract that was set up in the beforeEach block.</p><p>The assert.equal statement is used to compare the actual value returned by getPriceFeed to the expected value (mockV3Aggregator.address), and the test will pass if they are equal. If the addresses do not match, the test will fail, indicating that there is an error in the constructor code that needs to be fixed (incorrect address).</p><h4>Fund Function Test</h4><pre>describe(&quot;fund&quot;, function () {<br>              // https://ethereum-waffle.readthedocs.io/en/latest/matchers.html<br>              // could also do assert.fail<br>              it(&quot;Fails if you don&#39;t send enough ETH&quot;, async () =&gt; {<br>                  await expect(fundMe.fund()).to.be.revertedWith(<br>                      &quot;You need to spend more ETH!&quot;<br>                  )<br>              })<br>              // we could be even more precise here by making sure exactly $50 works<br>              // but this is good enough for now<br>              it(&quot;Updates the amount funded data structure&quot;, async () =&gt; {<br>                  await fundMe.fund({ value: sendValue })<br>                  const response = await fundMe.getAddressToAmountFunded(<br>                      deployer<br>                  )<br>                  assert.equal(response.toString(), sendValue.toString())<br>              })<br>              it(&quot;Adds funder to array of funders&quot;, async () =&gt; {<br>                  await fundMe.fund({ value: sendValue })<br>                  const response = await fundMe.getFunder(0)<br>                  assert.equal(response, deployer)<br>              })<br>          })</pre><p><strong>This test checks three main things:</strong></p><blockquote>If someone tries to contribute an insufficient amount of ETH, the function should fail and revert the transaction.</blockquote><blockquote>If someone contributes a valid amount of ETH, the amount funded data structure should be updated correctly with the contribution amount.</blockquote><blockquote>If someone contributes a valid amount of ETH, their address should be added to the array of funders.</blockquote><p>The first test uses the expect syntax from the Waffle testing library to check that calling fund() with no value or an insufficient value reverts the transaction and returns the expected error message.</p><p>The second test checks that the amount funded data structure is updated correctly by calling fund() with a valid value, then calling getAddressToAmountFunded to retrieve the amount funded by the deployer address that funded the contract. It then checks that this amount matches the expected value.</p><p>The third test checks that the funder’s address is added to the array of funders by calling fund() with a valid value, then calling getFunder to retrieve the address of the first funder in the array. It then checks that this address matches the expected value of the deployer address.</p><h4>Withdraw Function Test</h4><pre>describe(&quot;withdraw&quot;, function () {<br>              beforeEach(async () =&gt; {<br>                  await fundMe.fund({ value: sendValue })<br>              })<br>              it(&quot;withdraws ETH from a single funder&quot;, async () =&gt; {<br>                  // Arrange<br>                  const startingFundMeBalance =<br>                      await fundMe.provider.getBalance(fundMe.address)<br>                  const startingDeployerBalance =<br>                      await fundMe.provider.getBalance(deployer)<br><br><br>                  // Act<br>                  const transactionResponse = await fundMe.withdraw()<br>                  const transactionReceipt = await transactionResponse.wait()<br>                  const { gasUsed, effectiveGasPrice } = transactionReceipt<br>                  const gasCost = gasUsed.mul(effectiveGasPrice)<br><br><br>                  const endingFundMeBalance = await fundMe.provider.getBalance(<br>                      fundMe.address<br>                  )<br>                  const endingDeployerBalance =<br>                      await fundMe.provider.getBalance(deployer)<br><br><br>                  // Assert<br>                  // Maybe clean up to understand the testing<br>                  assert.equal(endingFundMeBalance, 0)<br>                  assert.equal(<br>                      startingFundMeBalance<br>                          .add(startingDeployerBalance)<br>                          .toString(),<br>                      endingDeployerBalance.add(gasCost).toString()<br>                  )<br>              })<br>              // this test is overloaded. Ideally we&#39;d split it into multiple tests<br>              // but for simplicity we left it as one<br>              it(&quot;is allows us to withdraw with multiple funders&quot;, async () =&gt; {<br>                  // Arrange<br>                  const accounts = await ethers.getSigners()<br>                  for (i = 1; i &lt; 6; i++) {<br>                      const fundMeConnectedContract = await fundMe.connect(<br>                          accounts[i]<br>                      )<br>                      await fundMeConnectedContract.fund({ value: sendValue })<br>                  }<br>                  const startingFundMeBalance =<br>                      await fundMe.provider.getBalance(fundMe.address)<br>                  const startingDeployerBalance =<br>                      await fundMe.provider.getBalance(deployer)<br><br><br>                  // Act<br>                  const transactionResponse = await fundMe.cheaperWithdraw()<br>                  // Let&#39;s comapre gas costs :)<br>                  // const transactionResponse = await fundMe.withdraw()<br>                  const transactionReceipt = await transactionResponse.wait()<br>                  const { gasUsed, effectiveGasPrice } = transactionReceipt<br>                  const withdrawGasCost = gasUsed.mul(effectiveGasPrice)<br>                  console.log(`GasCost: ${withdrawGasCost}`)<br>                  console.log(`GasUsed: ${gasUsed}`)<br>                  console.log(`GasPrice: ${effectiveGasPrice}`)<br>                  const endingFundMeBalance = await fundMe.provider.getBalance(<br>                      fundMe.address<br>                  )<br>                  const endingDeployerBalance =<br>                      await fundMe.provider.getBalance(deployer)<br>                  // Assert<br>                  assert.equal(<br>                      startingFundMeBalance<br>                          .add(startingDeployerBalance)<br>                          .toString(),<br>                      endingDeployerBalance.add(withdrawGasCost).toString()<br>                  )<br>                  // Make a getter for storage variables<br>                  await expect(fundMe.getFunder(0)).to.be.reverted<br><br><br>                  for (i = 1; i &lt; 6; i++) {<br>                      assert.equal(<br>                          await fundMe.getAddressToAmountFunded(<br>                              accounts[i].address<br>                          ),<br>                          0<br>                      )<br>                  }<br>              })<br>              it(&quot;Only allows the owner to withdraw&quot;, async function () {<br>                  const accounts = await ethers.getSigners()<br>                  const fundMeConnectedContract = await fundMe.connect(<br>                      accounts[1]<br>                  )<br>                  await expect(<br>                      fundMeConnectedContract.withdraw()<br>                  ).to.be.revertedWith(&quot;FundMe__NotOwner&quot;)<br>              })<br>          })<br>      })</pre><blockquote>Cool, next up is the withdraw function. I followed a tutorial for this part and I think I could’ve broken this test up into a clearer format; its a bit lengthy and confusing to understand, but here&#39;s the gist of it:</blockquote><p>The first test case checks whether a single funder can withdraw their funds from the contract. The test first gets the starting balances of the contract and the funder’s account then calls the withdraw function and finally checks whether the contract’s balance is zero and whether the funder’s account balance has increased by the amount they initially funded plus any gas fees incurred during the transaction.</p><p>The second test case checks whether multiple funders can withdraw their funds from the contract. It first funds the contract with multiple accounts using a for loop and then performs the same steps as the previous test case. It also checks that the getFunder and getAddressToAmountFunded functions return the expected values after the withdrawal.</p><p>The third test case verifies that only the contract owner can withdraw funds. It tries to call the withdraw function using an account other than the owner and expects the transaction to be reverted with an error message.</p><blockquote>Time for another honest reflection. Part 2 of this article was much more of a challenge for me to write out. I was working with and trying to wrap my head around such unfamialir concepts, especially the tests, which require a very clear understanding of the contract in order to consider all of its scenarios and the logic that should be used to account for them. But, I knew that round two of dApp development had to bring another set of challenges, so I could experience growth from my last project; preparing me with the right technical skills.</blockquote><blockquote>Thanks for giving this a read :) If you’re up for it, follow my <a href="https://medium.com/@sheth.tanvi18">Medium </a>account for more content as I navigate my curiosities. Feel free to connect with me on <a href="https://www.linkedin.com/in/tanvi-sheth-06b4501ba/">LinkedIn </a>or <a href="https://twitter.com/_TanviSheth">Twitter </a>and check out my <a href="https://tks.life/profile#portfolio">full portfolio</a> to keep up with my projects and experiences. To stay updated on my monthly progress and takeaways, subscribe to my <a href="https://tanvisheth.substack.com/?utm_source=substack&amp;utm_medium=web&amp;utm_campaign=substack_profile">newsletter </a>as well.</blockquote><p><strong><em>We’re providing opportunities for the next generation of student thinkers, inventors, and learners, to publish their thoughts, ideas, and innovation through writing.</em></strong><br><em>Our writers span from all areas of topics — from </em><a href="https://studentsxstudents.com/"><em>Growth to Tech, all the way to Future and World</em></a><em>.</em><br><em>So if you feel like you’re about to jump into a rabbit hole of reading these incredible articles, don’t worry, we feel the same way. ;)</em><br><em>That’s why </em><a href="https://studentsxstudents.com/"><em>students x students</em></a><em> is the place for getting your voice heard!</em><br><em>Sounds interesting? </em><a href="https://studentsxstudents.com/for-students-by-students-becoming-a-contributor-and-expanding-your-impact-f6da9189fa78"><em>Why not join us on this epic journey</em></a>?</p><p><a href="https://studentsxstudents.com/">students x students</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2861061c862" width="1" height="1" alt=""><hr><p><a href="https://studentsxstudents.com/functional-and-robust-smart-contracts-unit-and-stage-tests-oracles-and-gas-optimization-2861061c862">Functional and Robust Smart Contracts: Unit and Staging Tests, Oracles, and Gas Optimization</a> was originally published in <a href="https://studentsxstudents.com/">students x students</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Looking at unfamiliarity through a familiar lens]]></title>
            <link>https://medium.com/@sheth.tanvi18/looking-at-unfamiliarity-through-a-familiar-lens-68c5d6d93cc8?source=rss-6c8172dff473------2</link>
            <guid isPermaLink="false">https://medium.com/p/68c5d6d93cc8</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[mindset]]></category>
            <dc:creator><![CDATA[Tanvi Sheth]]></dc:creator>
            <pubDate>Fri, 24 Mar 2023 00:55:45 GMT</pubDate>
            <atom:updated>2025-07-08T17:14:48.374Z</atom:updated>
            <content:encoded><![CDATA[<h4>The circle of competence</h4><p>This was not a planned article. It started out being a fun way to wrap your head around async functions. I saw a lot of use for them when I needed to incorporate time-consuming operations in my blockchain projects. But really, I was intrigued by how fast I wrapped my head around the concept when I was given real-world context and an opportunity to connect to the foundation I’ve established for myself over my life; my knowledge. Async functions really aren&#39;t fascinating, at all, but now I’ll use them as an example to convey a message in this spontaneous article of mine.</p><p>It’s these small examples and real-life scenarios that allow us the opportunity to understand concepts that seem complex and multilayered. I thought this was a great way to understand the tool that made my programs so much more efficient and productive, and suitable for the advanced blockchain development techniques that I want to build with. When you make connections to existing knowledge and tap into the data that is already ‘in your brain,’ you grasp concepts at an incredibly faster rate and make sense of them because of the familiarity you experience. Another way to understand this idea is the principle of the ‘Circle of Competence.’ It’s all about working <em>within </em>this circle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*QGL6Aaopw4mwhKak.jpeg" /></figure><blockquote>“If you want to improve your odds of success in life and business, then define the perimeter of your circle of competence, and operate inside. Over time, work to expand that circle but never fool yourself about where it stands today, and never be afraid to say “I don’t know.”</blockquote><p><strong>Shane Parrish</strong></p><p>Pretty much, always know what you don’t know and <em>work with what you do know</em>. Eventually, this circle of what you know will expand into areas of what you didn’t know, only getting larger, but only as a result of expanding into unfamiliar spaces through familiar methods and connections.</p><p>As I started working in blockchain, I found that nearly everything was unfamiliar to me, and the only way to make sense of these revolutionary ideas that completely disrupt the current systems our society is built on (not being dramatic), even at their surface level, was to leverage the logical understanding that I have of the world around me and comprehend things through a familiar lens. Again, async functions were not one of those mind-boggling things, but I started off this article with the example, so I’m going to stick to it.</p><p>And I’m really not sure why this concept took some time for me to wrap my head around. I blanked out every time I tried to read the lines of code. As I started writing scripts for my smart contracts, I realized that deploying, writing/reading, and getting transaction receipts/responses on a testnet blockchain are very time-consuming processes. This is when I was introduced to async functions.</p><h4>So, here’s an easy way to understand async functions.</h4><p><strong>Async function: </strong>An async function allows you to write asynchronous code that looks like synchronous code. An asynchronous operation is one that doesn’t block the main thread of execution and can execute in parallel with other code. Async functions always return a promise, which can be resolved with a value or rejected with an error.</p><p>Inside an async function, you can use the await keyword to wait for a Promise to resolve before continuing the execution of the function. This allows you to write code that appears to execute synchronously but is actually executed asynchronously in the background.</p><h4>This is an example that made my life a lot easier.</h4><ol><li>I put the popcorn in the microwave</li><li>While the popcorn is cooking, I’m pouring drinks (I don’t want to have to wait for the popcorn to finish cooking before pouring the drinks)</li><li>After the popcorn is finished cooking I sprinkle some salt over it (I can’t do this before or during the time the popcorn is cooking)</li><li>The movie can begin once both the popcorn has been salted and the drinks are ready</li></ol><pre>async function watchMovie() {<br> console.log(“Putting popcorn in the microwave…”)<br> const prepareDrinksPromise = prepareDrinks()<br> await cookPopcorn()<br> console.log(“Sprinkling salt on popcorn…”)<br> await new Promise(resolve =&gt; setTimeout(resolve, 1000)) // wait for 1 second to sprinkle salt<br> console.log(“Popcorn is ready!”)<br> await prepareDrinksPromise<br> console.log(“Time to watch a movie!”)<br> }<br> <br> async function prepareDrinks() {<br> console.log(“Pouring drinks…”)<br> await new Promise(resolve =&gt; setTimeout(resolve, 2000)) // wait for 2 seconds<br> console.log(“Drinks are ready!”)<br> }<br> <br> async function cookPopcorn() {<br> console.log(“Cooking popcorn…”)<br> await new Promise(resolve =&gt; setTimeout(resolve, 5000)) // wait for 5 seconds<br> console.log(“Popcorn is cooked!”)<br> }</pre><p>In this example, the watchMovie() function is declared as an async function. It starts by logging a message to the console indicating it’s putting popcorn in the microwave.</p><p>It then calls the prepareDrinks() function, which returns a promise that resolves when the drinks are ready, and stores that promise in a variable.</p><p>The cookPopcorn() function is then called using the await keyword, which pauses the execution of the watchMovie() function until the promise returned by cookPopcorn() is resolved. Once the popcorn is cooked, the function logs a message indicating that it’s sprinkling salt on the popcorn, waits for 1 second to sprinkle salt, and logs a message indicating that the popcorn is ready.</p><p>Finally, the await keyword is used to pause the execution of the function until the promise returned by prepareDrinks() is resolved, indicating that the drinks are ready.</p><p>Once both the popcorn and drinks are ready, the function logs a message indicating that it’s time to watch a movie.</p><p>The prepareDrinks() and cookPopcorn() functions are declared as async functions as well. The prepareDrinks() function pours drinks and waits for 2 seconds before logging a message indicating that the drinks are ready. The `cookPopcon’ also does the same.</p><p>I thought I could add value to all the beginners entering intimidating spaces, finding their way around, and making sense of unfamiliar things every day, just like me. That&#39;s all I wanted to say. Thanks for reading :)</p><blockquote>Thanks for giving this a read :) If you’re up for it, follow my <a href="https://medium.com/@sheth.tanvi18">Medium </a>account for more content as I navigate my curiosities. Feel free to connect with me on <a href="https://www.linkedin.com/in/tanvi-sheth-06b4501ba/">LinkedIn </a>or <a href="https://twitter.com/_TanviSheth">Twitter </a>and check out my <a href="https://tks.life/profile#portfolio">full portfolio</a> to keep up with my projects and experiences. To stay updated on my monthly progress and takeaways, subscribe to my <a href="https://tanvisheth.substack.com/?utm_source=substack&amp;utm_medium=web&amp;utm_campaign=substack_profile">newsletter </a>as well.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68c5d6d93cc8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Music Portal: Web3 app + Ethereum Smart Contract]]></title>
            <link>https://studentsxstudents.com/music-portal-web3-app-ethereum-smart-contract-18434bdb97a2?source=rss-6c8172dff473------2</link>
            <guid isPermaLink="false">https://medium.com/p/18434bdb97a2</guid>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Tanvi Sheth]]></dc:creator>
            <pubDate>Tue, 10 Jan 2023 11:53:47 GMT</pubDate>
            <atom:updated>2025-07-08T17:15:15.353Z</atom:updated>
            <content:encoded><![CDATA[<h4>Just getting started</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I0t4Sfi1tuxK46LI.png" /></figure><blockquote><em>One of the coolest things about Web3 is the way it opens up so many possibilities for innovation and creativity. It has the potential to completely democratize the web and allow a much more diverse range of people and organizations to participate in </em><strong><em>creating and shaping the online world, something our lives now revolve around.</em></strong></blockquote><blockquote><em>I initially built a decentralized application called the WavePortal, a place where anyone on the internet can learn about me and send a wave or message, and have the data saved on the blockchain through an Ethereum smart contract. Although this was my first experience with building in Web3, I wanted to create something that added some type of value to users’ lives, even at the smallest scale.</em></blockquote><p>I decided to ask users to link their favorite or ‘go to’ song and a little message about why it means so much to them. Now, users will have access to the ‘ultimate playlist of favorite songs’ that people from around the world will contribute to by simply connecting their wallets.</p><p>My application allows users to experience the diversity of our world’s rich culture through music, this powerful element that everyone around the globe holds so much value and respect for. My technical growth was exponential as I built this project, but I also hope that my application will introduce users to new music that they can be impacted by and gain a deeper appreciation for.</p><blockquote><a href="https://github.com/tanviSheth18"><strong>Here’s the GitHub repo for my front-end and back-end code</strong></a></blockquote><h3><strong>Check out the demo of my application below!</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.loom.com%2Fembed%2F6f6b54b69e7549babf1817717ea1b0d4&amp;display_name=Loom&amp;url=https%3A%2F%2Fwww.loom.com%2Fshare%2F6f6b54b69e7549babf1817717ea1b0d4&amp;image=https%3A%2F%2Fcdn.loom.com%2Fsessions%2Fthumbnails%2F6f6b54b69e7549babf1817717ea1b0d4-1673351284616.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=loom" width="1620" height="1215" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf8b072fe0102b759abe22ae70173201/href">https://medium.com/media/cf8b072fe0102b759abe22ae70173201/href</a></iframe><h3><strong>The change in networks</strong></h3><p>With a decentralized blockchain network, anyone can create and share content or build applications without the need for <em>approval from a central authority.</em> <em>Yet, people don’t recognize the power of decentralization.</em></p><p>There is immense potential for this game-changing technology to upend traditional systems and give power back to the people. As cheesy as this sounds, when you put this into a technical context, you start to appreciate the value of <em>having power</em> in a network when you start developing.</p><p>This shift from a centralized model, specifically the change in infrastructure that a blockchain provides, is what intrigued me most through this project. This was my chance to understand the architectural differences between traditional and blockchain networks, and the possibilities that present themself <em>as a result of these changes</em>. I learned to understand code fundamentally; not just the surface-level function of each line.</p><blockquote><em>Programming is fundamentally a logic game. With this project, I found myself creating mental </em>flow charts <em>as I ran and deployed my smart contracts. Essentially, they acted as visual representations of the </em>logic of my program.<em> Doing this revealed the components of the new network I was working in and the connections I was initiating between them through my code.</em></blockquote><h3>The rest of this article is a detailed tutorial of the entire project. I did this to solidify my understanding and reflect on the steps that I took for my final product to come to life.</h3><p><strong>A step-by-step tutorial for shipping my first Web3 app: Music Portal + Ethereum smart contract.</strong></p><ol><li>I wrote and deployed the smart contract</li><li>Built the website that users can connect their wallets to and interact with the contract</li><li>There’s also a random chance that they will win an amount of ETH for contributing to this ultimate playlist</li></ol><h3><strong>Get your local Ethereum networking running</strong></h3><p>First, you need to get your local Ethereum network working. This means setting up the environment to work with the blockchain. This is where I compiled and tested my smart contract before deploying it to a testnet. <strong>Connection</strong>: it&#39;s the same as spinning up a local environment to work on!</p><p>The smart contract lives on the blockchain; where anyone can read and write data for free and no one owns any of it. It&#39;s a huge shift in structure that I needed to understand.</p><p><strong>Hardhat </strong>lets you create a local server (server=blockchain) and gives us fake test ETH and accounts to work with.</p><p>After you have installed Node/NPM, you can use it to install <strong>Hardhat </strong>in the directory that you want to work in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9m1EVUPyKqeM2ekb" /></figure><p>To get a sample project running, you can simply run:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8RB9RKXPtpzNAXHp" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*d6tBSTKUkEf4Bdfy-XMPvw.png" /></figure><p>Choose the option <strong><em>Create a JavaScript project, </em></strong>and install hardhat-waffle and hardhat-ethers. Also, install this dependency in case it wasn’t installed automatically:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fZx6enUruJU5caiu" /></figure><p>Now, you can run <strong>npx hardhat accounts</strong> in your terminal. These are Ethereum addresses that Hardhat generates to stimulate real users on a blockchain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WrFCJSfMPWrLVy9q" /></figure><p>After running the following commands:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ikCnVoXLffD6dwLr" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sEtQIz3a2i85h7lQ" /></figure><p>This shows that Hardhat is running and we can test our contracts on this blockchain!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yn3g7jYxjPCuEDyn" /></figure><h3><strong>Writing the first smart contract</strong></h3><p>This contract lets users send a wave to the contract and <em>keep track of the # of waves.</em></p><p>You can create a file named WavePortal.sol under the contracts directory in any editor of your choice.<strong> I chose VS code.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ITtcBwVl5ImsVaM5" /></figure><p>After stating the version of the code Solidity compiler we want our contract to use, we imported one of the functions that Hardhat provides to do some console logs in the smart contract; it&#39;s easier to debug smart contracts with these. We created a contract called WavePortal and once we initialize it, the constructor underneath it will run and print out the console.log.</p><h3><strong>Compile contract locally and run it</strong></h3><p>Now that we’re done writing the smart contract, we need to</p><ol><li>Compile it</li><li>Deploy it to the local blockchain</li><li>The console.log will run once it&#39;s on the blockchain.</li></ol><p>We want our smart contract to be used by <em>real people. </em>So, even if we are working locally, we want to imitate the environment where our contract is used by real people. Now, we can just compile and run Solidity code,<strong> but its ability to interact with blockchain and Ethereum wallets is what sets it apart.</strong></p><p>The following script handles the three steps above. Go into the <strong>scripts </strong>directory and make a file named<strong> run.js. This is how run.js will look.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K3RB2ztGiF6fL8gp" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HDeVVnEEtvjP68y2" /></figure><p>This compiles our contract and generates the necessary files to work with the contract. They’ll pop up in the <strong>artifacts</strong> folder after this is run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OZrtfeU7csqGsJF6" /></figure><p>Hardhat will create a local Ethereum network for this contract. After the script completes, the network will destroy, giving us a fresh blockchain to work with every time it is run. Starting from a clean slate <strong>(connection: like refreshing your local server)</strong> makes it easier to debug in the earlier phases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vqWSf1FdyY-oZZn0" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f2nKpL66gCynMqGE" /></figure><p>After waiting for the contract to be deployed to the blockchain, the construction will run. After it is deployed, it’ll give us the address of the deployed contract. In a real Ethereum network, this address makes it easier to access the contract we want to interact with. It&#39;s how we will find it on the blockchain that has millions of others on it as well.</p><p>You should see your console.log and address when you run the contract with this line. The contract was complied with and deployed too!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wYbJPgGhjVdgpG9h" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GOD1ojuyC3X3b-nq" /></figure><h3><strong>Store data on the smart contract</strong></h3><p>Not only do we want users to wave or send us a message, but also <em>store that wave.</em> They need a function to hit to wave/send a message!</p><p>This is how the contract updates to store the data → <strong>in this case, the waves.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1PwmU4l7UW1RJaad" /></figure><p>This added a function to our Solidity code. The <strong>totalWaves</strong> variable will initialize to 0, but I learned that it&#39;s a little special. This is a ‘state variable’ that’s stored permanently in contract storage.</p><p><strong>msg.sender</strong> is the wallet address of the person who called the function. We will always know who called the smart contract function because you need to connect a valid wallet to call it in the first place. Makes it very ‘legit’ and acts as a built-in authentication → one of the perks of interacting with Web3 and blockchain networks. Technically, we can make this exclusive by only allowing certain addresses to send a wave and hit the function. It&#39;s a functionality that is now possible, but not necessary.</p><p><strong>Function wave() </strong>will iterate the variable and tell us who the sender is and the function <strong>getTotalWaves()</strong> will tell us the total number of waves.</p><p>Now, we’ll have to change <strong>run.js because we</strong> need to manually call the functions that were created. When this contract is deployed (with <strong>waveContractFactory.deploy()</strong>), the functions become available to be called, all thanks to the <strong>public</strong> in the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*td-XZdZPiMGTHS3-" /></figure><p>Let’s break this down:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8MfmOcJ0EH9AObs5" /></figure><p>We need a wallet address in order to deploy something to the blockchain, so this line takes the wallet address of the contract owner and another random wallet address <strong>randomPerson. </strong>The function <strong>getSigners()</strong> will return an array of signers or the addresses involved in this transaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JHG_ao-FOaaNeWMb" /></figure><p>This will let us see the address of the person that deployed the contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ziHMr1wV_fqQw-c-" /></figure><p>The code first gets the current total number of <strong>‘waves’</strong> stored in the smart contract by calling the <strong>getTotalWaves()</strong> function.</p><p>Then, it calls a function called ‘<strong>wave’ </strong>on the smart contract and assigns the returned value to a variable called <strong>waveTxn</strong>. <em>The</em><strong><em> </em>waveTxn</strong> <em>variable represents a transaction that has been sent to the blockchain but has not yet been included in a block.</em></p><p>Finally, the code calls the<strong> wait()</strong> function on the <strong>waveTxn</strong> variable, which causes the code to ‘wait’ until the transaction has been included in a block and is no longer pending. Once the transaction has been processed, the code then gets the updated total number of waves stored in the smart contract by calling <strong>getTotalWaves()</strong> again.</p><p>After running this script again using the line below, you’ll get this output instead in your terminal!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_6ZCoGPnVHu09QEq" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*49IpiGR_kjlfjMwR" /></figure><p>The <strong>wave() </strong>function was called, and the variable was updated. Awesome!</p><h3><strong>Test other users</strong></h3><p>You can see how the address that waved is also the address that employed the contract. I waved at myself here. Now, to let people other than myself send a wave, we need to make some changes to the function. The lines below stimulate other people hitting the functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QLZQ2n1Bx_SiiaKa" /></figure><p>I changed <strong>waveTxn</strong> to <strong>firstWaveTxn</strong> and then added these lines to the bottom.</p><p>The code calls the <strong>wave()</strong> function again, but this time it calls the wave function through a ‘connection’ with a person identified by the variable <strong>randomPerson. </strong>This call to <strong>wave </strong>is similar to the previous call, and it creates a new transaction that is stored in a variable called <strong>secondWaveTxn.</strong> The code then waits for this second transaction to be processed before getting the updated total number of waves stored in the smart contract again!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8c6Mr92zUg80wiuw" /></figure><h3><strong>Deploy locally to start building the website</strong></h3><p>Yes, we already deployed to our local network, but when you run <strong>scripts/run.js, </strong>it <em>creates a local network, deploys it, and then automatically destroys the local network when the script ends</em>. Remember? Now that we know our functions don&#39;t have any errors, we can deploy it to a local network that <strong>stays alive </strong>so we can keep talking to it and work on our website + test it out.</p><p>Connection: It&#39;s the same as keeping a local server, that you made with an API, alive so you can work on your website + test it out.</p><p>After opening a new window in the terminal and going to the directory you created at the beginning, you can start a local Ethereum network that <strong>stays alive.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x-WRnCsQ6hScjL1-" /></figure><p>Hardhat gave us 20 accounts to work with, each with <strong>10 000 ETH</strong>. However, this is a <em>fresh </em>blockchain → it’s empty! So, let&#39;s create the first block with our smart contract on it.</p><p>Under the scripts folder, create a file called <strong>deploy.js</strong>. The code for it is essentially the same as <strong>run.js.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uPHFp9mpWyyNrruP" /></figure><p>You can now deploy it from a <strong>different terminal window </strong>(so the terminal that’s keeping the local network alive is not tampered with) using the line below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wTjMpBscCji2PgNk" /></figure><p>You’ll see this <strong>output </strong>in the current terminal and a <strong>change </strong>in the local network terminal that is keeping the local network alive.</p><p>We deployed the contract and the smart contract’s address is also in the first block! The website will need this address so it can look for the contract on the ‘not-local’ blockchain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qni49OaSoDT0rQHF" /></figure><p>This is the <strong>change </strong>in the terminal that has the local network. You can see the transaction and block hashes of the first block that <em>we created </em>on the blockchain!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pdjQx_Z76faQqsUB" /></figure><p>A transaction hash is a unique identifier for a particular transaction on a blockchain. It is generated using the transaction data, and it serves as a digital signature for the transaction. <strong>The transaction hash is used to verify the authenticity of the transaction and to ensure that the transaction has not been altered.</strong></p><p>A block hash, on the other hand, is a unique identifier for a block on a blockchain. It is generated using the data in the block, and it serves as a digital signature for the block<strong>. The block hash is used to verify the authenticity of the block and to ensure that the block has not been altered.</strong></p><p>It’s cool how we can see all of this theory being applied; this is when I first got to visualize the structure of a blockchain through some context.</p><h3><strong>Setup a react app and Metamask</strong></h3><p><em>We need to get our front end to interact with our smart contract.</em></p><p>I used <strong>Replit </strong>to build + deploy my site, and thanks to BuildSpace, I got access to the base repo that I cloned and worked on locally. I recommend using this as a starting point that you can then iterate on to personalize the functionality. Just go here and near the right, you’ll see the<strong> Fork</strong> button. Now, you can work off of this basic <strong>React project.</strong></p><p>NOTE: if you create any new JavaScript files, you will need to use the <strong>.jsx </strong>extension instead of the<strong>.js</strong> simply because <strong>Replit </strong>requires you to use this file extension! This was a bug that took me too many hours to figure out and doesn&#39;t necessarily have a logical explanation.</p><p>Along with a <strong>deployed</strong> React project, we’ll need an Ethereum wallet. Using MetaMask, we can call the functions on our smart contract that <em>now lives on the blockchain</em>. Pretty awesome, right? The wallet will have our <strong>Ethereum address</strong> and <strong>private key. </strong>The wallet provider is what connects our website to the wallet and passes our credentials to the website, which it can then use to call the contract. <strong>You need valid credentials to access functions on the smart contract.</strong></p><p>Connection: Remember how I said <strong>built-in authentication? </strong>This is like the <strong>login </strong>to the blockchain. After logging in with the credentials, we can use them again to make requests from our website (API requests).</p><h3><strong>Deploy smart contract to the real testnet</strong></h3><p>We no longer need our local blockchain network running, because we’ll now be deploying the <strong>actual blockchain. </strong>Close the terminal that has this network running.</p><p>Make sure to make an account with <strong>QuickNode</strong> and get an <strong>API URL </strong>for our testnet. Sign up and choose the <strong>Goerli Testnet. </strong>I initially connected to the <strong>Rinkeby testnet</strong> and none of my scripts were running. Don’t make the same mistake and spend 5+ wondering what you’re doing wrong!</p><p>We’re deploying on a <strong>testnet </strong>because it costs real money to deploy on the <strong>Ethereum mainnet — -&gt; </strong>something you can do at the very end.</p><p>A <strong>testnet</strong> <em>clones the mainnet </em>and uses <strong>fake money </strong>— -&gt; this will let us test everything without a <em>real </em>cost. However, testnets are run by <em>real miners</em>, so we’re still testing our work in a <em>real-world scenario</em>. We’ll do the following on this testnet:</p><p>1. Broadcast our transaction</p><p>2. Wait for it to be picked up by actual miners</p><p>3. Wait for it to be mined</p><p>4. Wait for it to be broadcasted back to the blockchain, telling all the other miners to update their copies</p><p>You’ll also need to get some <strong>fake ETH to </strong><em>deploy </em>to the Goerli test network. Remember, testnets copy how mainnets works; if you use money to deploy to the mainnet, you’re also going to need money to deploy to the testnet.</p><p>NOTE: You can get<strong> </strong><em>fake ETH for Goerli through a faucet.</em> Just make sure your MetaMask wallet is set to the <strong>Goerli test network </strong>before using the faucet so you can actually use the money to deploy. Essentially, you’re asking the network for <strong>fake ETH</strong>, and this ETH will<strong> </strong><em>only work on the specific testnet</em>; Goerli in our case.</p><p>You’ll also need to change your hardhat.config.js file in the root directory of your smart contract project. You’re stating that the <strong>Goerli network</strong> is being used and your <strong>QuickNode API </strong>and <strong>private key</strong> will also be stored in this file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cMz3FMsQlxKX5UEb" /></figure><p>I also created a <strong>.env file</strong> in my root project folder and added the ‘secrets ’ in there too. Your private key <em>should be a secret</em>: it&#39;s the same one as <strong>your mainnet private key.</strong></p><p>The reason why you need your private key is that you need to log in<strong> </strong>to the blockchain to perform a transaction like deploying a contract.</p><p><em>Think of it this way: your username is your public address and your password is your private key. </em>Similar to logging into AWS to deploy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j74qlUn0H4uuzo0X" /></figure><p>NOTE: I added the <strong>hardhat.config.js </strong>file and the <strong>env. </strong>file to <strong>.gitignore</strong> so Git ignores it when I upload my project to GitHub and the unnecessary information (secrets) doesn’t leave my computer.</p><p>Once this is set up, you can go ahead and <strong>deploy</strong> the script that we wrote earlier by running the command through the root directory. The only difference from our last deployment is the network: <strong>localhost — -&gt; Goerli.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Iu6ujq1s_yz8Osmf" /></figure><p>This should be the output.<strong> </strong>Make sure to<strong> keep a copy of the address in the last line </strong>so you can have it for the front end when we start using it to call our contracts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8L-HFCNBpmtUiSRl" /></figure><p><strong>Now that we’ve deployed to an actual network, Etherscan will show you the state of the blockchain and where our transaction is. </strong>Paste the address in there to see your transaction!</p><h3><strong>Connect our wallet to our web app</strong></h3><p>A brief overview of how I manipulated my front end on <strong>Replit</strong>.</p><p>We now need to connect our wallet to our website if we want it to talk to the blockchain. This is when our website will have permission to call the smart contract — -&gt; <em>it&#39;s like authenticating into a website.</em></p><p>This is what my A<strong>pp.jsx </strong>looks like. Since I already have a Metamask browser extension, an object named <strong>ethereum</strong> was already injected into my window. This code checks simply if we have that object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wd0KWgR4Ny_tA5nJ" /></figure><p>Now, I have to make sure that I am actually authorized to access a user’s wallet; this access will let me call my smart contract. <em>Metamask only gives wallet credentials to websites that we authorize it to, not every site that we visit. </em>This code here is simply checking that I’m <strong>logged in and an account is authorized to be used.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IKOYpLybfFZ_JbcS" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F-oy0-iEiy6iIKCX" /></figure><p>The <strong>eth.accounts</strong> method lets me see if I’m authorized to access the account in a user’s wallet.</p><p>When I run this code, the <strong>console.log</strong> prints the error <strong>‘No authorized account found’</strong> because we haven’t yet told Metamask to give this website access to my wallet. This is why I need to create a <strong>Connect Wallet</strong> button. Remember, <em>connecting your wallet essentially means a login button for a user.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wQfiwlaZ5FeIyDlj" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W9bsBh4JuozTT2If" /></figure><p>The <strong>connectWallet() function </strong>is the major component here. I used the <strong>eth_requestAccounts method </strong>to ask Metamask to give me access to the user’s wallet. In terms of the UI, I added a button that calls the <strong>connectWallet() function.</strong> This button will only show up if there is no <strong>currentAccount: </strong>if we already have a <strong>currentAccount, </strong>we’ve already gained access to an account in the user’s wallet (that is authorized to be used on our site).</p><h3><strong>Read from the blockchain through our website</strong></h3><p>Now that we’ve connected our wallet, <strong>we can use the credentials we have access to from Metamask to <em>call our contract from the website.</em></strong></p><p>Remember that the contract has the function to retrieve the total number of waves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BVYUA_r64hWaiKfd" /></figure><p>In order to call this function from our website, we’ll need to make a <strong>wave()</strong> function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_LSNmwBaU2RMkpht" /></figure><p><strong>ethers</strong> is a library that lets the front end talk to the contract. We just need to import it at the top using <strong>import { ethers } from “ethers”;</strong></p><p><em>A</em><strong><em> provider </em></strong><em>is what talks to Ethereum nodes.</em> We are using nodes that Metamask provides to send and receive data from our deployed contract (just like we used <strong>QuickNode to <em>deploy </em>the contract).</strong></p><p>Now, to connect the <strong>wave button</strong> to this function, we need to update the <strong>onClick</strong> prop from <strong>null</strong> to <strong>wave. </strong>This makes sure that the function is called <strong>onClick.</strong></p><p>Note: the base repo that I forked already had this button initialized, so I simply made changes to its class using <strong>app.css</strong> to make my front end look exactly how I wanted it to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HwGg_UpzWc4uEWzR" /></figure><p><strong>This is probably the error you are getting right now.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jPFJo0-8tvFSZxin" /></figure><h3><strong>Setting your contract address</strong></h3><p><strong>This is when the smart contract address comes to use</strong>. It was one of the outputs of the deployment to the <strong>Goerli Testnet</strong>. <em>All we need is to get access to it in our React app.</em></p><p>Let’s create a new property called <strong>contractAddress</strong> and set the value to the WavePortal address that we had saved from before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*8L-HFCNBpmtUiSRl" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/0*dLsCYx1toeeBv2UT" /></figure><p>We’ll also need to fix the issue with the <strong>‘ABI.’ </strong>This is a file that is created when you compile a contract, and you’ll find it under your <strong>artifacts<em> </em></strong>in your root directory.</p><blockquote><em>An ABI is needed so our web app knows how to communicate with our contract. In simple terms, an ABI is a set of rules that dictate how two different programs or libraries should interact with each other. It defines a standard way for a program to call functions and access memory in another program or library, regardless of the programming language they were written in or the operating system they run on.</em></blockquote><blockquote><em>When a program is compiled, it is translated from the source code written in a programming language like C or Rust into machine code, which is a set of instructions that the computer’s processor can execute directly. An ABI defines the conventions that should be used when translating the source code into machine code, such as the format of the data that is passed to and from functions and the way that memory is laid out in the program’s address space.</em></blockquote><blockquote><em>An ABI also defines the conventions for linking a program to other libraries, such as the naming conventions for symbols (e.g. function names) and the layout of data in memory so that libraries can be used by different languages.</em></blockquote><p>You’ll find this file using this path: <strong>artifacts/contracts/WavePortal.sol/WavePortal.json </strong>and you simply need to copy its contents to the front end.</p><p>To get this<strong> JSON file</strong> to the front end, make a new folder called <strong>utils</strong> under <strong>src</strong> and create a file called <strong>WavePortal</strong>.<strong>json. </strong>Paste the contents from the back-end file (from your root) to this one.</p><p>Now, all that’s left is to import it into the <strong>App.js</strong> file and reference it. <em>This is what enables the functionality between the two languages.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rNW8Lg1DPQIMcgzD" /></figure><p>This is where you are actually using the ABI content:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vQyY8BNpNsbzO2H4" /></figure><p><strong>You’re now reading your data from the contract (<em>that’s on the blockchain!</em>) through your web client.</strong></p><p>Note: I was looking back at my code and realized that I didn’t know the exact functionality of .getSigner(). I realized it&#39;s an important component of the <strong>wave()</strong> function and I should understand what is really happening behind the scenes. Here’s what I found:</p><blockquote><em>.signer() is a method or function that is used to ‘sign’ some data, usually as part of a process called digital signature.</em></blockquote><blockquote><em>A digital signature is a way to prove the authenticity of a piece of data, such as a document or a message, by applying a mathematical algorithm to it. The algorithm generates a unique ‘signature’ based on the contents of the data and a secret key that is known only to the person or entity that is signing the data. The signature can be verified later using a corresponding public key, which is available to anyone (and we have access to this since we have a user’s wallet credentials), to ensure that the data has not been tampered with and that it truly comes from the person or entity that claims to have signed it.</em></blockquote><blockquote><em>The .signer() method takes the data and the secret key as inputs and applies the algorithm to generate the signature.</em></blockquote><h3>Writing data</h3><p>We’ve written code to read data from the contract, but now we want to <strong><em>write data to our contract.</em></strong> The major difference is that we now have to notify miners when a new contract is written <em>so that it can be mined</em>. <strong>‘Reads’</strong> don’t need to be mined because you’re simply reading from the blockchain; not changing it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*raNcZjJyxDEr3EKx" /></figure><p><strong>This is the completed client that can read and write data to the blockchain. That’s the foundation! Check out Etherscan again to see the transaction being mined in real time!</strong></p><h3><strong>Storing messages from users on the blockchain</strong></h3><p>I wanted this app to show all the past waves/messages it’s gotten as well, so I made a few changes to the smart contract and <strong>run.js script</strong> in order to have this functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K2iHwofKbEd-R_XR" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JTYzyTeqIvG9HXou" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oYI5lfylMcfeo-88" /></figure><p>Here’s the updated <strong>run.js</strong> script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ePCA-bV3LEBgME6v" /></figure><h3><strong>Test it</strong></h3><p>Using <strong>npx hardhat run scripts/run.js </strong>once again, we can see the changes being applied here.</p><p>We can see the necessary data I wanted is next to the ‘<strong>waver,’ ‘message,’ and ‘timestamp.’</strong> It stores the messages ‘A message and ‘Another message’ that we included in <strong>run.js</strong> file. It’s working!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PI7_Py0POHawpmFa" /></figure><h3><strong>Deploy it</strong></h3><p>After redeploying our updated smart contract using <strong>npx hardhat run scripts/deploy.js — network goerli, </strong>make sure to update the contact address in <strong>App.js</strong> (we got in the terminal from running <strong>run.js) </strong>and update the ABI file (<strong>from artifacts in root</strong>) in Replit. We need to do all of this because smart contracts are immutable, meaning they cannot be changed. In order to update the code of a smart contract, it must be fully redeployed, which resets all variables and treats the contract as if it is brand new. It now corresponds to the new contract address and ABI file that is generated after deployment.</p><h3><strong>Hooking it all up to our client</strong></h3><p>With this updated code and the new <strong>getAllWaves()</strong> function, I essentially fetch all the necessary data from the smart contract that we deployed on the blockchain. Calling the <strong>getAllWaves()</strong> method stores this data in an array called <strong>waves. </strong>It then processes this data by extracting the address, timestamp, and message fields from each element in the <strong>waves</strong> array and stores the resulting data in a new array called <strong>wavesCleaned. </strong>Finally, the function sets the state using the <strong>getAllWaves</strong> function, passing in the <strong>wavesCleaned</strong> array as an argument.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*3EXAJGp4E9LEATvU2aAY4A.png" /></figure><p>We can only call this <strong>getAllWaves()</strong> function when the user has connected a wallet with an authorized account. That’s the only way we can call it. So, we’ll call this function inside <strong>‘checkIfWalletIsConnected.’</strong></p><p>We’re almost done here!</p><p>To render this new data, I updated my HTML code; this is where all the information about my rendered buttons are. Here’s a snippet of it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BOgoS97NfSA-LNdQ" /></figure><p>I essentially go through <strong>allWaves</strong> and create div containers for every wave, which shows all the data on the website!</p><p>After polishing up my UI to make it as user-friendly and clean as possible, adding a few more functions in App.js for users to type a message, and an updated wave() function in my smart contract to <em>fund it, set a prize and send random users ETH, </em>I finally completed my very first Web3 build! This was a 30+ hour build and took a lot of patience, consistency, and resilience. However, my learning curve was exponential during this project and I’m glad I took this ambitious first step.</p><blockquote>Thanks for giving this a read :) If you’re up for it, follow my <a href="https://medium.com/@sheth.tanvi18">Medium </a>account for more content as I navigate my curiosities. Feel free to connect with me on <a href="https://www.linkedin.com/in/tanvi-sheth-06b4501ba/">LinkedIn </a>or <a href="https://twitter.com/_TanviSheth">Twitter </a>and check out my <a href="https://tks.life/profile#portfolio">full portfolio</a> to keep up with my projects and experiences. To stay updated on my monthly progress and takeaways, subscribe to my <a href="https://tanvisheth.substack.com/?utm_source=substack&amp;utm_medium=web&amp;utm_campaign=substack_profile">newsletter </a>as well.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18434bdb97a2" width="1" height="1" alt=""><hr><p><a href="https://studentsxstudents.com/music-portal-web3-app-ethereum-smart-contract-18434bdb97a2">Music Portal: Web3 app + Ethereum Smart Contract</a> was originally published in <a href="https://studentsxstudents.com/">students x students</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evil ̶D̶o̶e̶s̶n̶’̶t̶ Can’t Exist On a Blockchain]]></title>
            <link>https://studentsxstudents.com/dont-be-evil-vs-can-t-be-evil-392521bb31c0?source=rss-6c8172dff473------2</link>
            <guid isPermaLink="false">https://medium.com/p/392521bb31c0</guid>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Tanvi Sheth]]></dc:creator>
            <pubDate>Sun, 13 Nov 2022 22:46:11 GMT</pubDate>
            <atom:updated>2025-07-08T17:15:51.432Z</atom:updated>
            <content:encoded><![CDATA[<h4>Understanding why</h4><p>The role of <strong>trust</strong> in a blockchain and how it is achieved through <strong>consensus mechanisms.</strong></p><p>People can do suspicious things easily<em> </em>in the current banking system.</p><p>If you use a PayPal account to send money to others online, there is the possibility of your account being used by someone else or your money not ending up where you intended it to be.</p><p>This possibility<strong> </strong>of fraud and the ease<strong> </strong>of conducting fraudulent activity makes it difficult to <strong>trust </strong>the current banking system.</p><p>That&#39;s why I decided to re-invent the system so that the following is possible:</p><ul><li>It’s <em>harder</em> to go against the system than to follow it</li><li>It takes way more work trying to not be caught</li><li><em>You are incentivized to contribute to the system — more than committing fraud</em></li></ul><p>Now, this sounds like a system that you can wholeheartedly trust.</p><p>Unfortunately, I won&#39;t get a chance to invent it myself, because it already exists: blockchain. But, I will take credit for explaining how this foolproof system is possible.</p><p><strong>The entire Bitcoin, blockchain, and crypto space can be summed up in one word: ‘web3.’ And web3 has one feature that has never existed before; trust.</strong></p><p><strong>— Ben Horowitz</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hVUS1jRRAWtAwhk3.jpeg" /></figure><p>This quote can<em> </em>hold a lot of value to those who make the ‘clicks’ in their brain when reading: Bitcoin, blockchain, crypto, and Web3. But for most people, they are nothing more than buzzwords. With the jargon overlooked by your brain, the only keyword that registers is ‘<strong>trust.’ </strong>The only concept that you need to fundamentally understand is ‘<strong>trust</strong>,’ and the other ‘clicks’ will fall in place consequently.</p><p>Alright, we get it, blockchain is built on trust, and trust restores peace in the world. But let me break it down further for you guys. Why do we need trust? And how is trust created — in the context of a blockchain?</p><blockquote>Blockchain enables trust in a network through <strong>consensus</strong>. <strong>Consensus mechanisms </strong>are the reason why blockchain technology exists.</blockquote><p>The underlying concept of blockchain is this fascinating technology known as consensus mechanisms. They are a theoretically boring concept that dates back to the 1900s until you start applying it correctly.</p><p>Everything you need to know to understand fraudulent transactions and activity on a blockchain, and <strong><em>how</em> they’re not possible on a blockchain.</strong></p><p>This will be a ‘block-by-block’ run through of how a transaction gets initiated, validated and recorded on a blockchain using the consensus mechanism Proof Of Work:</p><p><strong>I’ll break down the details of:</strong></p><ul><li>probabilistic proof — the <strong>idea </strong>of ‘proving work’</li><li>cryptographic hashing, nonces, and mining difficulty —the <strong>math behind </strong>doing, proving and verifying work on a blockchain</li><li>51% attack — an exception that<strong> ‘lets you be evil’ </strong>on a blockchain</li><li>Google Coin vs Bitcoin — the <strong>architecture</strong> that sets Bitcoin, a currency on a blockchain, apart</li></ul><h3>Your genesis block of knowledge</h3><p>The basics of blockchain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/0*yYsc6CXNEiiTlOUi" /><figcaption>For beginner purposes; the hash is <strong>information</strong> about the block/the data inside.</figcaption></figure><p>A <strong>block </strong>is just a single record of information on a chain of connected information — a chain of connected blocks. Each block has information about the <strong>previous block</strong>; this is how they are connected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/0*5CTIySPhuADNz5Zy" /></figure><p><strong>Nodes</strong> are the individual people/computers in the blockchain network.</p><p>Each node has a <strong>copy</strong> of the blockchain, which is what makes blockchains <strong>decentralized</strong>; information is not stored in a single spot but rather distributed across all nodes.</p><p>Look at the image above compared to a network that is <em>not</em> on the blockchain (below). The data is <strong>centralized</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/0*noYlHVruFZ1BJRBu" /></figure><h3>If you can’t explain it simply, you don’t know enough about it</h3><p>A shared Google Document is the distributed ledger — the blockchain. Everyone has a copy of the document of information, therefore everyone has a copy of the blockchain. If someone adds information to the document , it adds a new block to the blockchain; this is updated on everyone’s document — blockchain. Cool? Cool.</p><h3>Someone tell me: what’s the need?</h3><p>I mentioned that blockchains are decentralized, which means that there is no ‘authoritative entity,’ like the bank, privately mediating the information, and preventing a fraudulent transaction. This is in the case of a cryptocurrency application.</p><p>Wait up. Let’s define <strong>fraudulent transactions.</strong> When a crypto frantic raises the question of fraudulent behavior, they are referring to the <strong>double spending problem, so </strong>when the same units of a currency could be spent twice. You’ll see what I mean as we go through an example.</p><p>Alright, so now that that’s cleared up; traditionally, <strong>banking middlemen</strong> act as go-betweens, facilitating money transfers between two bank accounts, and <strong>privately verifying</strong> the transaction to <strong>prevent fraud</strong>. But in a decentralized system with <strong>no authoritative figure,</strong> the transaction is <strong>publicly verified</strong> through <strong>consensus mechanisms.</strong></p><h3>The nature of decentralized things</h3><p>In a blockchain, <em>anyone</em> is allowed to produce a block (add information) to make the chain longer. This is what differentiates the blockchain from typical systems like banking; it’s an escape from normal regulation and government controls. However, it’s also kind of a problem. It would be very difficult to stop this blockchain from growing if anyone with a computer can anonymously produce a block.</p><p>You’ll soon find out that the people that produce a new block and add it to the chain are <strong>rewarded</strong>; so <em>what’s stopping the chain from growing at a rate equal to the number of people attempting to extend it? What’s stopping the invalid blocks from being added to the chain?</em></p><h3>The name drop</h3><p><strong>Proof Of Work </strong>is one solution to limiting this rate. This is the <strong>OG </strong>consensus mechanism, and we’re about to dive <em>really </em>deep into it.</p><p>Each block needs a <strong>proof-of-work, </strong>and doing this work gets harder as more people join the blockchain network. In fact, proof-of-work ensures that the production of a new block is so difficult that the entire applied computing capacity of the world (universe, even) cannot produce more than one block every ten minutes — and this will make sense when we understand the concept of <strong>mining difficulty </strong>later on.</p><h3>The complicated truth</h3><p>In a Proof Of Work mechanism, transaction data is stored in blocks, validated by people solving complicated math problems attached to it. These computations are done by powerful computers and are known as ‘mining.’ The first node to mine the code/cracks the problem is rewarded in the form of cryptocurrency.</p><h3>Curious beginners are the best to learn form</h3><p>Wait. <em>What?</em> These are the types of explanations that I found on the internet, and as a curious beginner, the useless jargon meant nothing to me. I quickly realized that it’s easier to learn from a curious beginner than an expert, so let’s go down this rabbit hole together.</p><p><strong>A proof-of-work is proof that some type of work was done.</strong></p><p><em>Don’t overcomplicate it:</em></p><ol><li>A large hole in the ground could serve as ‘proof of digging’</li><li>A chalkboard full of words is ‘proof of writing’</li></ol><p>They both require work, so there’s your proof of work.</p><p>Since a <strong>computer</strong> adds blocks to a blockchain network, <strong>proof of computational work</strong> is required.</p><p>Keep one thing in mind, this work needs to be <strong>hard</strong> to generate, but <strong>easy to verify</strong>.</p><h3>Simply put; just how we like it</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFo3dFJ5dR8zKDht471hrg.png" /></figure><p>I have a black box with a button and a screen. A random button between 1 to 100 appears on the screen every time the button is pressed. As a <strong>validator</strong>, I give the box to my sister, Jahnavi, and tell her that she can only return the box to me when the screen displays the number 1 or 2. Let’s break this down; there is a 1 in 50 chance that any button press will display a number in this range. So, I can assume that my sister had to press the button fifty times before the number displayed a 1 or 2.</p><p>I have <strong>verifiable proof</strong><em> </em>that my sister did some hardcore button-pushing work, and the <strong>difficulty</strong> of it is defined by the range of numbers that I will accept. If I decided to be nice to my sister and accept a number between 1 and 25, she would only need to press the button four times (on average), making the <strong>difficulty much less.</strong></p><h3>Now, let’s get technical</h3><p><strong>All media;</strong> documents, survey results, and music are just strings of numbers/data.</p><p>Something called a <strong>hash function </strong>turns this media/data of <strong>arbitrary size</strong> into data of a <strong>fixed size</strong>. The function that Bitcoin uses, for example, is “SHA256,” which takes data of any length and turns it into data that is exactly 256 bits. This is called a <strong>hash or digest </strong>of 256 bits.</p><p>The data will <em>always </em>produce the same hash when you put it through the function, so we can say that the data is ‘mapped’ to the hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0m1vonozQ-jpQLDJ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y2y9zzaq0GrT6Xtr" /></figure><h3>Fundamentals for a fundamental understanding</h3><ol><li>Each piece of input only has <strong>one possible hash</strong></li><li>There is only one efficient way to generate hashes; shortcuts to producing hashes do not exist.</li></ol><p>3. You can easily create the hash for an input that is given to you, but it’s very difficult to calculate the input when given only the hash. This makes the function ‘one-directional.’ Reversing the process to figure out the input/information of the hash is out of the question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*RfvkwlwPaSEBb98W" /></figure><p><strong>It’s easy when you have all the ingredients (input) to make a banana smoothie (output), but its impossible to get those ingredients back once they’ve been crushed together (deciphering the input given the output).</strong></p><p>4. A slight change<strong> </strong>in the <strong>input</strong> will dramatically change<strong> </strong>the <strong>hash</strong></p><p>Keep in mind; the information of the previous block — the hash of the previous block is stored on the next one in the chain. If someone tampers with this information , the hash of the block changes, which alters the information on the next block as well.</p><h3>Technically…</h3><p>Alright, so I’ve had enough. I think that my sister sends me too many messages, and it’s getting annoying. So, I <strong>disincentivize</strong> this scenario by asking her for a <strong>‘proof-of-work’</strong> with each message she sends me. She’ll definitely send fewer messages if they’re <strong>harder to send/take more work.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*6f88ycurs7oGW9hYpuZ-Ug.png" /></figure><p>But there’s a catch! I’ll establish the <strong>difficulty of the proof</strong> and will only accept her message if the first character of the hash<strong> — </strong>of the message<strong> — </strong>is a 7.</p><h4>This is my sister hashing her first message to me.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CKwWtSh2ZojoOPl6" /></figure><p>This hash starts with an ‘e,’ so I won’t be accepting the message from her. She’ll need to find a way to <strong>modify the hash</strong>, without changing her message.</p><p>Being the nice and helpful sister that I am, I define a new message format with a <strong>nonce</strong>. This is a string of numbers that she can change up for the sole purpose of changing the hash. It’ll affect the hash but won’t affect the message.<strong> [&lt;message&gt;][&lt;nonce&gt;]. </strong>Now, my sister just needs to <strong>modify the nonce</strong> until the hash starts with a 7.</p><h4>Her attempts</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gchq9Q0CL4zzXufA" /></figure><p>My sister put in the work to find the <strong>required nonce </strong>and can now send the message [Lunchtime?][16] to me. I just need to <strong>verify</strong> her proof-of-work by putting her message, which is now the [&lt;message&gt;][&lt;nonce&gt;], into the hashing algorithm, confirming that the hash starts with a 7.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QXWd3gb90t_W_ept" /></figure><p>Now, I <em>would</em> have to verify each of my sister’s attempts manually unless I come up with some software that intercepts her messages and checks them before I get alerted. However, this is a good representation of a cryptographic hashing algorithm used to find a <strong>random number</strong> for any piece of data. The <strong>uncertainty</strong> of the number can then be used to generate a <strong>proof-of-work.</strong></p><h3>This technique is legit</h3><p>Let’s take a look at <strong>cryptocurrencies</strong> using proof-of-work.</p><p>We have a block with the following information; a timestamp, a hash representation of the transaction, the hash of the previous block, and a cryptographic nonce. This is called the <strong>block header.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IuCpsd3PUrSrkjV5" /></figure><p>I want to send my sister some Bitcoin for her birthday. The information of this transaction is on a new block that I create, along with a hash representation of it, the hash of the previous block’s information (a previous transaction that took place on the network), and a <strong>nonce</strong>. Remember: this transaction is broadcasted out to every node on the Bitcoin network.</p><p><strong>Now, all of the contents of the block are hashed once again.</strong></p><p>But, I knew the drill; there is a ‘requirement’ for the transaction to take place and the money to be sent to her (just like the messages she was sending me). This is called the <strong>hash target</strong>. For the transaction of Bitcoin to be validated, somebody on this network has to do the <strong>proof-of-work</strong> for it. AKA; find the <strong>nonce</strong> that changes the hash of the data so that it fits the requirement. More specifically, the hash has to be <em>below</em> the <strong>hash target.</strong></p><p>Only when this nonce is found and verified, is the block added to the public ledger. The transaction that took place between my sister and me is recorded on this public ledger for everyone to see <strong>for the rest of eternity. </strong>I <strong>cannot<em> </em></strong>use these units of currency ever again unless I <em>want </em>to be caught.</p><h3>The whole picture</h3><p>Proof-of-work can be done by <em>anyone</em> in the network in return for a reward (in Bitcoin currency).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*aDymN-busDmjyE4J" /></figure><ol><li>A transaction takes place and all of its information is put ‘inside’ a block.</li><li>Everyone is notified of this block, and each participating node attempts to complete the proof-of-work for it. This process is called <strong>‘mining.’ </strong>Everyone that makes an attempt is called a <strong>miner</strong>.</li><li>When a node finds the nonce and broadcasts the ‘answer’ back to the public network, everyone else in the network verifies their proof-of- work, simply by putting the <strong>[block’s hash][nonce]</strong> through the hashing algorithm to see if it really is <strong>under the hash target.</strong></li><li>Only then is the block added to the public blockchain for everyone to see and add on to. The main blockchain <strong>only has validated blocks.</strong></li></ol><p>It’s a process. But, it does <strong>guarantee</strong> secure transactions and the idea that I began with; <strong>trust</strong>.</p><h3>If I was a criminal…</h3><p>If someone were to tamper with the input of any block on the public blockchain, the hash of it would change. Since this hash is used for the proof-of-work of the next block (it’s in the contents of the next block), the proof-of-work of the block would be <em>invalid, </em>causing a <em>domino effect and </em>making the rest of the blocks on the chain invalid as well.</p><p>So, unless I can re-do the proof-of-work of all of the blocks after the tampered one, this tamper will be identified <em>immediately. </em>Unfortunately, I cannot.</p><h3>Speed is the answer, but it’s not possible</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*caqbFlp6FH5PnrzP" /></figure><p>As I said before, each block takes about 10 minutes to validate. The blockchain network of a Bitcoin, for example, alters the hash target according to the amount of people mining:</p><p><strong>More nodes or faster computers</strong> = lower hashing target to get under, making the puzzle <strong>more difficult</strong> to crack.</p><p><strong>Fewer nodes</strong> = a higher hashing target to get under, making the puzzle <strong>less difficult </strong>to crack.</p><p>This alteration maintains the 10-minute validation rate, making it <strong>impossible </strong>to redo the proof-of-work faster than the chain extending. There is no way a fraudulent transaction can take place; once a transaction is validated on a block, the money cannot be used again/removed.</p><h3><strong>Annoying exceptions</strong></h3><p>When a node comes up with a solution, they are supposed to broadcast it to the network so everyone can <em>reach consensus</em> and the block can be added to the chain.</p><p>Here’s another fake scenario; why not.</p><p>I can create an offspring of the blockchain by not broadcasting the solutions to the blocks to rest of the network. <strong>There are now two versions of the blockchain in this scenario, which just so happens to favor me :)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3rxLxc3SZMkLr23_" /></figure><p>I’m now working on my own version of that blockchain and casually <strong>not </strong>broadcasting it to the rest of the network; no one picks up on this chain.</p><p>I spend all my Bitcoins on the truthful version of the blockchain that all the miners are working on. Let’s say I spend it on a Rolls-Royce :)</p><p>On the truthful blockchain, my Bitcoins are <strong>spent, </strong>but this transaction is not<strong> </strong>included on my isolated version of the blockchain.</p><p><strong>On my private blockchain, I still have my coins.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5ufl4_CiWCpY8L4t" /></figure><p>I still continue to pick up blocks (other’s transactions) from the network and verify them myself on my isolated blockchain. I’m adding onto my chain.</p><p>This seems wrong…you’re right.</p><p>The blockchain is programmed to follow the majority; it always follows the longest chain, which is <strong>supposed to be </strong>the truthful one. After all, the longest chain should be the truthful one; it is being validated/blocks are solved the <em>fastest </em>due to the combined mining power of<em> the majority of the nodes.</em></p><blockquote><strong>A race has now started.</strong></blockquote><p>Whoever has the most hashing power will add blocks to their version of the chain faster.</p><ol><li>The truthful chain <em>should </em>win because the majority of the nodes are contributing to it (majority of the hashing power is contributing to it)</li><li>If I have 51% of the hashing power (control over 51% of the nodes), I can create a chain faster. I happen to have control of the majority of the nodes/hashing power, so its time to have some fun.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k2nRa48XiLYca-6r" /></figure><p>As soon as I create a longer blockchain, I will broadcast this version of the blockchain to the rest of the network; which will now detect that this (corrupt) version of the blockchain is actually <em>longer</em> than the one they are working on, and the protocol will force them to switch to my chain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BXIG45sM_w0B47Ee" /></figure><p>Guess what? The previous blockchain <strong>validated</strong> my purchase of the Rolls-Royce, so I officially own the car. But according to my private chain, that has become the <strong>new public blockchain</strong>, the coins haven&#39;t been used, so I can spend the same coins <em>again</em>. I can <strong><em>double spend.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-MVcprBgY20PPcQa.png" /></figure><p><strong>This is a called a 51% attack because I require more hashing power than the rest of the network combined (51% of it ) in order to add blocks to my version of the chain faster, allowing me to build a longer chain and make it the public blockchain.</strong></p><h3><strong>A truth that no one understands</strong></h3><p>Industry leaders at top companies may not even understand the following fundamental concept;</p><p>Before blockchains, software was always been <strong>subordinate to hardware</strong> (and the owner of that hardware). Blockchains are different in the way they’re architected: the <strong>software</strong> is in charge of the <strong>hardware </strong>via the <strong>consensus mechanism.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*9BDKJbzdKk2X8TY7oxpuuQ.png" /></figure><p>Let’s say that Google released a cryptocurrency called Google Coin (very creative). Google says that the currency is capped at 21 million; the maximum number of Google Coins that can be issued to miners as a reward. But, Google owns the hardware of this network and <em>can </em>change this limit to whatever it wants, whenever it wants. This is because the <strong>software is controlled by Google-owned hardware.</strong></p><p>There is<strong> no control</strong> to the supply, and thus, future price fluctuations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LGssUNcwZVrwyKKl" /></figure><p>Compare this to <strong>Bitcoin</strong>, which promises that there will only ever be 21 million Bitcoins. This rule is written <em>on </em>the blockchain, and you can trust that it’s true because it’s baked into the architecture. <em>More jargon;</em> lets break this down.</p><p>Once 21 million coins are received as rewards in the network, Bitcoin miners will no longer get ‘rewards’ for mining.</p><p>There cant be more than 21 million coins circulating, as all transactions involving the coins are<strong> permanently recorded and verified </strong>(via consensus mechanisms) <strong>on the public blockchain.</strong></p><blockquote><strong>Once 21 millions coins have been created and received by miners—all shown/verified on the public blockchain, coins will stop generating.</strong></blockquote><p>Undermining this rule is impossible on a blockchain, even if a lot of people running the Bitcoin code (the miners) try to do so. <strong>There is no company that controls the hardware that controls the software :)</strong></p><p>This <strong>controls</strong> the supply and, thus, future price fluctuations</p><p>The consensus mechanism <strong><em>governs</em></strong><em> </em>what someone can and cannot do to modify the ledger.</p><p>For example, a node with a Bitcoin address cannot spend more Bitcoin than it has previously received. There is a transaction on the public ledger that states how much money they have previously received, and all transactions are <em>validated </em>through consensus mechanisms before they’re added to the ledger; <strong>if you don&#39;t have the money, you cant pretend that you do. There has to be proof that you do on the public blockchain.</strong></p><p>Google’s slogan is <strong>‘don’t be evil.’ </strong>But Bitcoin ensures that you ‘<strong><em>can’t</em> be evil.’</strong></p><p>The consensus mechanism, encryption, and cryptography of a blockchain <strong><em>don&#39;t let you</em> </strong>commit fraud.</p><p>Good luck to those who think they can.</p><blockquote>Thanks for giving this a read :) If you’re up for it, follow my <a href="https://medium.com/@sheth.tanvi18">Medium </a>account for more content as I navigate my curiosities. Feel free to connect with me on <a href="https://www.linkedin.com/in/tanvi-sheth-06b4501ba/">LinkedIn </a>or <a href="https://twitter.com/_TanviSheth">Twitter </a>and check out my <a href="https://tks.life/profile#portfolio">full portfolio</a> to keep up with my projects and experiences. To stay updated on my monthly progress and takeaways, subscribe to my <a href="https://tanvisheth.substack.com/?utm_source=substack&amp;utm_medium=web&amp;utm_campaign=substack_profile">newsletter </a>as well.</blockquote><p><strong><em>We’re providing opportunities for the next generation of student thinkers, inventors, and learners, to publish their thoughts, ideas, and innovation through writing.</em></strong></p><p><em>Our writers span from all areas of topics — </em><a href="https://studentsxstudents.com/"><em>from Growth to Tech, all the way to Future and World.</em></a></p><p><em>That’s why studentsxstudents is the place for getting your voice heard!</em></p><p><em>Sounds interesting? Why not </em><a href="https://studentsxstudents.com/for-students-by-students-becoming-a-contributor-and-expanding-your-impact-f6da9189fa78"><em>join us</em></a><em> on this epic journey?</em></p><p><em>https://studentsxstudents.com/</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=392521bb31c0" width="1" height="1" alt=""><hr><p><a href="https://studentsxstudents.com/dont-be-evil-vs-can-t-be-evil-392521bb31c0">Evil ̶D̶o̶e̶s̶n̶’̶t̶ Can’t Exist On a Blockchain</a> was originally published in <a href="https://studentsxstudents.com/">students x students</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>