<?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 Colin Kraczkowsky on Medium]]></title>
        <description><![CDATA[Stories by Colin Kraczkowsky on Medium]]></description>
        <link>https://medium.com/@ckraczkowsky?source=rss-ea7611a809ec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*v8jCeiL7hYwJOmBQ-SrgSw.jpeg</url>
            <title>Stories by Colin Kraczkowsky on Medium</title>
            <link>https://medium.com/@ckraczkowsky?source=rss-ea7611a809ec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 00:46:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ckraczkowsky/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[ EEG Data Loading & Cleaning Pipeline]]></title>
            <link>https://ckraczkowsky.medium.com/eeg-data-loading-cleaning-pipeline-dfc3ebc0b927?source=rss-ea7611a809ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfc3ebc0b927</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[neurotechnology]]></category>
            <category><![CDATA[eeg]]></category>
            <category><![CDATA[neuroscience]]></category>
            <dc:creator><![CDATA[Colin Kraczkowsky]]></dc:creator>
            <pubDate>Thu, 28 Aug 2025 19:06:40 GMT</pubDate>
            <atom:updated>2025-08-28T19:14:30.218Z</atom:updated>
            <content:encoded><![CDATA[<p>Python code can be found <a href="https://github.com/ckraczkowsky91/eeg-data-loading-cleaning/edit/main/README.md">here</a>.</p><h3>Background</h3><p>The raw data from brain recordings is messy requiring a preprocessing phase to get it into a useable, analyzable format. There are various approaches to this. The one that I describe here involves identifying “artifacts”, i.e. sources that are not brain signal, in the raw data and removing them to produce data clean of extraneous “noise” like eye blinks, interruptions to the electrodes, background frequencies, etc. One application of this artifact rejection is Independent Component Analysis (ICA) where the raw data is algorithmically sorted into “components” which represent what we believe to be distinct signals within the clustered data.</p><p>The process that I follow for artifact rejection:</p><ul><li>Observe the raw data</li><li>Pre-filter data (apply band-pass + notch filtering)</li><li>Run ICA</li><li>Identify artifacts</li><li>Clean the raw data</li></ul><p>The dataset that I use here is a public dataset with readings from 102 magnetometers, 9 stimulus devices, 60 electroencephalography devices, 1 electrooculography device taken at a sampling frequency of 150.2 Hz.</p><h3>Observe the raw data</h3><p>In this phase, I observe the raw data looking for early artifacts like low-frequency drift and powerline noise that will disrupt further down the pipeline.</p><pre>raw.compute_psd(fmax=75).plot() # fmax cannot exceed 1/2 of sfreq b/w Nyquist theorem</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oC-kqZLVKMXm8Jk1DRDAog.png" /></figure><p>Assuming that this data was collected in the U.S. we would see activity at 60 Hz and its harmonics due to activity in power lines. We do not observe that in this data, most likely because the data was collected at a low sampling frequency of 150.2 Hz which we can observe in <a href="http://raw.info/"><strong>raw.info</strong></a>.</p><h3>Filter data</h3><p>Prior to running the ICA, I filter out low-frequency drift and power line noise. This prevents the ICA algorithm from producing components representing these artifacts. I do this by applying band-pass filter to signal below 1 Hz (low-frequency drift).</p><blockquote><em>Note: I feel comfortable with a higher high-pass filter, i.e. 1 Hz, since we are not performing sleep analysis where lower frequency data is more important.</em></blockquote><blockquote><em>Note: As I didn’t observe power line noise in the PSD plot, I chose not to include it in the filter as it would effect the speed of code execution. If I observed it at ~60 Hz, I could apply a low-pass filter. If the sampling frequency was higher and I observed variance at 60 Hz and its harmonics, I would be inclined to apply a notch filter at ~60 Hz, 120 Hz, etc.</em></blockquote><p>I then rerun the PSD plot to validate that my filters have been applied appropriately.</p><pre>filtered_raw = raw.copy().filter(l_freq=1.0, h_freq=None)<br>raw.compute_psd(fmax=75).plot()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*95R2_bzmyZsRbYVuuuIb4w.png" /></figure><p>The computed PSDs prior to the high-pass filter have all dropped indicating that our filter has worked.</p><blockquote><em>Note: The filter does not adjust to 0 the PSD of all signal recorded below 1 Hz. Rather, it attenuates the signal.</em></blockquote><h3>Run ICA</h3><p>Component analysis is all about finding explanations for the variance in the signal data. For example, the MEG0111 and the MEG0121 channels both recorded femtotesla measurements at various points in time. We want to know 1) whether the variances in the recordings within each channel is due to brain activity or another factor and 2) whether the signal recorded by both channels at one time were measuring the same phenomena or different. When using mne for component analysis, the data is first run through principal component analysis (PCA) and then through independent component analysis (ICA).</p><p>As indicated in the documentation, PCA is a two-stage process consisting of “pre-whitening” and “decomposition”:</p><ol><li>Pre-whitening is important because the PCA looks cross all the channel types represented in the data (EEG, MEG, etc.) which have different units which can result in wider variation between channel types which can mislead the analysis.</li><li>Decomposition rewrites the as a weighted sum of “variance patterns” from most to least explanatory.</li></ol><p>As the name implies, the products of PCA are principal components. It groups together behaviour believed to be correlated into individual components such that separate principal components describe uncorrelated behaviour. The principal components are then used as inputs to the ICA. The products of ICA are independent components meaning that the behavior described by each are ideally independent such that one does not describe the other. Through this component analysis, we obtain components that ideally represent distinct, independent sources, often corresponding to unique physiological phenomena.</p><p>Running ICA in <strong>mne</strong> is an instantiation of an ICA object passing in metadata dictating how the analysis should be run. The object is then fitted to the data, in this case the copy of the data where I applied the band-pass filter.</p><pre>ica = ICA(n_components=15, max_iter=&quot;auto&quot;, random_state=55)<br>ica.fit(filtered_raw)<br>ica.plot_sources(filtered_raw, show_scrollbars=False)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OmgbRysjMpo2m8mq9LzwBA.png" /></figure><p>This produces the following components, in this case 15 as directed in the instantiation.</p><h3>Identify artifacts</h3><p>We now have 15 components representing unique physiological phenomena. The goal is to identify which are artifacts. Because the PCA algorithms work by basically finding the pattern of highest variance, then the next highest variance, and so on until either <strong>n_components</strong> or the max number of channels are reached, the earliest components most likely describe the greatest amount of variance in the data.</p><p>There are various approaches to identifying artifacts:</p><ul><li>We can look at the amplitudes of the components over time (e.g. eye blinks look like sporadic, large, slow deflections and heartbeats look like regular, repeating spikes at the subject’s heart rate, e.g. adult human’s typically have a heart rate of ~60 bpm so we’d expect to see a spike every 1 second)</li><li>We can look at the primary location of the components (e.g. eye blinks would appear around the frontal lobe and heartbeats would be diffuse across the scalp)</li></ul><p>I started by looking at the amplitudes of the components over time.</p><pre>ica.plot_sources(filtered_raw, show_scrollbars=False)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQS1omjLRSjlEYDe38opgQ.png" /></figure><p>ICA000 immediately stands out as it has long, sporadic activity. Additionally, it shows an almost identical pattern to the electrooculography channel (EOG061) leading me to believe that this component represents eye blinks.</p><p>ICA001 also stands up as spikes of identical amplitude occurring at a regular interval of ~1 Hz leading me to believe that this components represents a heartbeat.</p><p>To improve my confidence in my suspicious, I looked at the location of the components on a topographical map of the scalp.</p><pre>ica.plot_components()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7gsOe3IaNaYvaTCh_IDQUA.png" /></figure><p>As suspected, ICA000 shows powerful activity on both the right and the left frontal lobes consistent with eye blinks. Additionally, ICA001 shows diffuse activity across the scalp consistent with heartbeats.</p><p>To further build confidence, I can then look at the effect of removing these components. If they are truly artifacts, then removing them should smooth the data at the time that these artifacts occur while leaving the data outside of these time ranges relatively unchanged.</p><p>I started with ICA000 which I believed to represent an eye blink artifact.</p><pre>ica.plot_overlay(raw, exclude=[0], picks=&#39;eeg&#39;) # Look at the raw original data against the cleaned dat (ICA000 removed) applied to just the EEG channels</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Su3lKvr2HWTS8qR9N_TcQ.png" /></figure><p>We can see that at the points where we believe an eye blink occurred, the cleaned data is much smoother indicating that the component was a strong contributor to the variance in that data.</p><p>I then did the same for ICA001 which I believed to represent a heartbeat artifact.</p><pre>ica.plot_overlay(raw, exclude=[1], picks=&#39;mag&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*86m4ZYp2RPuZmpT3I0-RLQ.png" /></figure><p>Similarly as above, the cleaned data at the areas that we believe to be heartbeats is much smoother.</p><p>On the other hand, when we exclude component ICA004 from our EEG channels and our MAG channels, we observe relatively no change between the raw data and the cleaned data.</p><pre>ica.plot_overlay(raw, exclude=[4], picks=&#39;eeg&#39;)<br>ica.plot_overlay(raw, exclude=[4], picks=&#39;mag&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t6-zLzJrhFvj24_EeW4aJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OIamx4pQWPqSPNmsrvAadA.png" /></figure><p>This leads me to believe that the excluded ICA component didn’t contribute much to the signal in any of those channels and that the component is not a clear artifact.</p><h3>Clean the data</h3><p>Since I am pretty certain that ICA000 and ICA001 are components that represent artifacts, I exclude these components to produce cleaner data for further analysis.</p><pre>ica.exclude = [0, 1]<br>reconst_raw = raw.copy()<br>ica.apply(reconst_raw)<br>raw.plot(order=artifact_picks, n_channels=len(artifact_picks))                                      # see the plot of the original data looking at the subset of channels that we looked at at the beginning<br>raw_copy.plot(order=artifact_picks, n_channels=len(artifact_picks))                                 # see the plot of the cleaned data</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*ZdYeGv2bNDrsfd98fzHNyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*hvbFhrvLp9h78GpDiu2gJA.png" /></figure><p>By replotting both the raw data and the clean data, we can see how the ICA analysis has removed noise and smoothed out the signal.</p><h3>Conclusion</h3><p>This clean data can now be used for analysis such as:</p><ul><li>Event-Related Potentials (ERPs): where we zoom in on a particular time period during the test where a stimulus took place and observe if and where potentials occurred.</li><li>Time-Frequency Analysis: where we look at the PSD plot segmented by brain wave bands, e.g. delta, theta alpha, beta, gamma, and observe where activity was strongest.</li><li>Classification Modeling: where we turn findings from ERPs and Time-Frequency Analysis as inputs to model brain states.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfc3ebc0b927" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Can Involuntary Attention Interrupt Rumination?]]></title>
            <link>https://ckraczkowsky.medium.com/can-involuntary-attention-interrupt-rumination-1b3a1d0ba872?source=rss-ea7611a809ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b3a1d0ba872</guid>
            <category><![CDATA[mental-health]]></category>
            <category><![CDATA[attention]]></category>
            <category><![CDATA[neuroscience]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[neurotechnology]]></category>
            <dc:creator><![CDATA[Colin Kraczkowsky]]></dc:creator>
            <pubDate>Wed, 23 Jul 2025 02:24:08 GMT</pubDate>
            <atom:updated>2025-07-23T02:24:08.524Z</atom:updated>
            <content:encoded><![CDATA[<h3>Background</h3><p>As someone who struggles with ruminative thought loops, I’ve long been interested in how attention networks in the brain might influence this experience. It’s well established that rumination is linked to sustained activity in the Default Mode Network (DMN), i.e. the neural network associated with self-referential thought and mind wandering. My initial hypothesis was simple:</p><blockquote><em>Engaging directed attention (via the Dorsal Attention Network, or DAN) should downregulate the DMN and interrupt rumination.</em></blockquote><p>This made intuitive sense. If you’re focusing on a cognitively demanding task, you typically aren’t ruminating. The DAN and DMN are known to be anticorrelated, competing for neural resources.</p><p>But are there other ways to interrupt ruminative thinking?</p><h3>A Finding That Challenged My Model</h3><p>Recently, I listened to an interview with cognitive neuroscientist Marc Berman, whose research shows that walks in nature help people reduce ruminative thinking and perform better on cognitive tasks. At first, this seemed counterintuitive.</p><blockquote><em>According to Berman, nature activates involuntary attention not the kind of directed attention my original hypothesis depended on.</em></blockquote><p>So how could something that <em>de-emphasizes</em> directed attention reduce DMN-driven rumination?</p><h3>Expanding the Model</h3><p>Looking deeper into Berman’s work, I learned that in his experiments:</p><ul><li>Participants were induced to ruminate before the experiment.</li><li>They went for a walk in nature (or in an urban environment).</li><li>Afterward, they took cognitive performance tests.</li></ul><p>Those who walked in nature performed better, even those preloaded with ruminative thoughts.</p><p>This led me to expand my model. In addition to the DAN, another system, the Ventral Attention Network (VAN), may be at play.</p><p>The VAN is involved in stimulus-driven, involuntary attention. Nature likely engages the VAN.</p><blockquote><em>Revised hypothesis: Both directed attention (DAN) and involuntary attention (VAN) can disrupt ruminative loops by downregulating the DMN, albeit through different mechanisms.</em></blockquote><h3>Implications</h3><p>This revised model could inform mental health and cognitive wellness strategies:</p><ul><li>For those needing active interruption of rumination, try cognitively demanding tasks.</li><li>For those feeling cognitively fatigued, nature exposure may offer a restorative path to disengage the DMN</li></ul><h3>Why This Matters to Me</h3><p>I’m interested in the intersection of neuroscience, attention, and emotional well-being. By mapping the dynamics between attention networks and the DMN, I hope we can design better interventions for rumination, burnout, and mood disorders.</p><h3>Next Steps</h3><p>I’d like to:</p><ul><li>Visualize this model</li><li>Build a lightweight experiment using EEG to test VAN vs. DAN activation patterns</li><li>Talk to others working at the intersection of nature, attention, and mental health</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b3a1d0ba872" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creative Product Management: Lessons from Creative Legends]]></title>
            <link>https://ckraczkowsky.medium.com/creative-product-management-lessons-from-creative-legends-834163fc2a95?source=rss-ea7611a809ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/834163fc2a95</guid>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[creativity]]></category>
            <category><![CDATA[product-development]]></category>
            <category><![CDATA[decision-making]]></category>
            <category><![CDATA[design]]></category>
            <dc:creator><![CDATA[Colin Kraczkowsky]]></dc:creator>
            <pubDate>Sun, 27 Aug 2023 09:49:57 GMT</pubDate>
            <atom:updated>2023-08-27T09:49:57.367Z</atom:updated>
            <content:encoded><![CDATA[<h4>Paula Scher</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wZPKGCPWmz8mHn1dnvZ0Sg.png" /><figcaption>Paula Scher designed the brand identity for Shake Shack</figcaption></figure><p>I am interested in the intersection of creativity and product management: a role that I call the “Creative Product Manager”. I seek to take lessons from creative legends and apply them to the field. In this article, I look to designer Paula Scher.</p><h4><strong>Creative legend: Paula Scher</strong></h4><p>Paula Scher is a self-described “visual identity designer”. Her experience includes layout artist, designer, art director, and, most recently, partner with the renowned, international design consultancy Pentagram. Prior to Pentagram, Scher’s resume includes Random House, CBS Records, and Atlantic Records. This experience and breadth of skill make her a creative legend. I believe that <a href="https://medium.com/@ckraczkowsky/the-first-90-days-for-the-creative-product-manager-e87eacb7046e">creativity is about making mental connections to generate novel ideas that are useful</a>. An example of Paula Scher’s creative power is reviving historic typefaces and design styles by utilizing them in modern environments. For example, when designing the visual identity for Shake Shack’s launch Scher, inspired by the moderne influence of their prefab flagship restaurant in Madison Square Park, <a href="https://www.wired.com/2015/07/shake-shack-made-70-year-old-font-hot/">revived the Neutra typeface for Shake Shack’s logo</a>. Using her taste and knowledge of typefaces to connect the style of the architecture to a mid-century typeface influenced by the principles of architect and designer Richard Neutra, Scher generated an identity for Shake Shack that resulted in an internationally recognized brand and a leader in its industry of “fast casual restaurants” making over $450M in revenue in 2018 alone with an average store revenue more than twice that of McDonald’s.</p><h4><strong>Creative lessons from Paul Scher</strong></h4><p>Scher is often generating novel things. When she wins a project with a new client, she is creating for them an entirely new brand identity. This often involves helping the client figure out what they actually need and then convincing them of a concept. In the field of product management, we also encounter moments where we need to get a group of individuals to agree on a concept or decision. We refer to this as the skill of <strong>consensus building </strong>within the area of <strong>stakeholder management</strong>. This occurs during the <strong>discovery phase</strong> when we tune into an idea, experiment with it against our objective, and now need to convince our stakeholders to proceed with the idea. This occurs during the <strong>prioritization phase</strong> when we determine a list of ideas to build, assemble them into a roadmap, and now need our stakeholders to agree on the roadmap. When selecting a method for consensus building, Scher optimizes for comfort and personality type. She says to find the style that’s most comfortable for you. For example, Paula takes the approach of a schoolteacher talking through a concept and explaining why one thing works and other things don’t. Her colleagues at Pentagram have found other methods that are comfortable for them and work for their personalities: one uses sports analogies to explain a concept while another takes an analytical approach using succinct diagrams. The outcome is the same: Paula and her stakeholders have surveyed the various ideas and honed in on one concept.</p><p>As an aside, Scher notes differences that she has experienced between digital work (e.g. graphic design) and physical work (e.g. environmental design). In physical work, the prototype is often exactly what gets built because the duration to build is much longer and there is less flexibility to make changes leading to less desire for constant alignment. She has found that <em>digital work involves more frequent alignment </em>as the work periods are shorter and there is more flexibility during the process of producing the graphic.</p><blockquote>Follow-up: How do you know when someone is aligned?</blockquote><p>In addition to consensus building, Scher has another tool for <strong>stakeholder management</strong>. When starting with a new client, Scher found the most important task is to identify the key decision-maker and learn how to show and explain work to them, i.e. a <strong>top-down</strong> approach. This is an alternative approach to working bottom-up where one works with the team to come to consensus on a decision and then moves that decision up the chain of influence until a key decision-maker is reached who ultimately greenlights or shelves the idea. For example, when working on the brand identity for Shake Shack, Paula presented her concept directly to founder Danny Meyer who indicated that he wanted a neon element which led to the brand’s iconic neon hamburger logo. Had Paula started at the bottom, they could have spent time coming up with dozens of concepts and forming consensus on a couple only to receive that same feedback. This blends well with our Stakeholder Diagram where we identify the various stakeholders and assign them to rings of influence over the project. The key decision-makers in our Stakeholder Diagram are those within the Core ring.</p><blockquote>Follow-up: How to identify key decision-makers?</blockquote><p>Once Paula has identified the key decision-makers there is the process of actually making the decisions. Paula’s <strong>decision-making</strong> philosophy is to present the key decision-makers with three options: a safe option that is “more classic to the area it’s in and may be more expected but done better”, an edgy option that is “pushing a boundary and can be a little bit scary”, and an option that is somewhere between the two. Interestingly, she has found that most choose an option on either side of the spectrum and rarely the middle option. This philosophy resonates with Rick Rubin’s tool from the Creative Act to present two options, i.e. A/B testing. Product management is full of decisions particularly during the <strong>discovery phase </strong>of the product development process where we make decisions like:</p><ul><li>Decide what are our objectives</li><li>Decide which ideas to pursue</li><li>Decide how we will manifest the selected idea</li><li>Decide what we will build now and what we may build later</li><li>Decide whether to build the idea ourselves or to partner with a third-party</li></ul><p>We can craft an approach to these product development decisions using our creative legend as a guide. First, we create two or three options, i.e. proposals. Then we assemble our Core stakeholders, present the options, and use our consensus building skills to agree on one. If we find it difficult to reach agreement, we can leverage another consensus building tool used by game designer Justin Gray to nudge the process along. In his interview with Tim Ferriss, Gray advocates for <strong>deadlines</strong>. For example, we can set a deadline where we close the product spec for new input and only focus on clearly defining existing decisions; new input is automatically backlogged for a future iteration.</p><p>Consistent terminology that Scher uses is “elevating the profession” and “stretching the form”; she considers this her ultimate goal. Other sources would refer to this concept as “honing the craft”. For example, while working with record companies Scher listened to the musicians’ music to inform the covers she designed. She also has extensive expertise in typefaces, i.e. a design for letters, numbers, and symbols including variations in size, weight, slope, and width. She leveraged this expertise in creating the brand identity for Shake Shack. Getting extensive exposure to elements in her field like knowledge of her client or methods to visually convey information, e.g. typefaces, builds her taste. Taste is described by nearly all creative legends and thus seems critical in the creative world. The practices of honing craft and developing taste have a corollary in the field of product management in the skill area we call <strong>domain expertise</strong>. Developing domain expertise could mean getting exposure to different user experiences to create the best experience to meet our goals (i.e. UX research). It could mean interacting with a lot of people who match our desired user type (i.e. user research). This could mean using various competing products to learn how others are approaching this problem (i.e. competitive research).</p><blockquote>Follow-up: Are there more ways to build taste as a product manager?</blockquote><h4><strong>Case study: Pentagram</strong></h4><p>Aside from creative tools, I’m also interested in Pentagram and in exploring the concept for Creative Product Managers. Starting with some backgound, in 1991 Scher, having gained 20 years of design experience, was invited to be a partner in Pentagram: an international design consultancy with offices in design hubs like New York, London, Berlin, and Austin. The structure for Pentagram is unique. It is a hierarchically flat group of partners who own and manage the firm, often working collaboratively, and share in profits and decision-making. Each partner is a leader in their individual field like architecture, graphic design, and product design. New partners are added through invitation typically through a few channels: either Scher and her partners have been watching their work and then they meet socially at a design conference where the partners get to know the potential recruit personally, or one of the partners will have worked with them on a project, or the potential recruit has held senior roles with recognized brands like <a href="https://mattwilley.co.uk/About">Matt Willey</a> who joined Pentagram in 2020 after five years as the art director of <em>The New York Times Magazine</em>. In Pentagram’s business model each partner takes on their own projects and then shares the profits earned from those projects with the rest of the partners. This protects all partners in the event that one industry has a setback through a “diversified portfolio” concept. They have an ownership model for the business also developed stock in the business so the partners continue to see upside from the business after they retire. Additionally, this structure affords Scher and her partners a lot of independence and autonomy in their work. She can run business where you take on enough work to be profitable and control work you do and do pro bono work, e.g. Matt Willey has made seven typefaces available where all profits go to Cancer Research UK and Macmillan Cancer Support. and grow your visual vocabulary (i.e. the skill of describing a concept in images rather than words) and do things that elevate the profession. The risks of working in a declining industry, becoming an expert in a dying field, and losing a source of income when you leave a company are not unique to the design profession. A business with this structure is beneficial to most and it would be interesting to explore a similar consultancy for Creative Product Managers. From my research, the demand for product consultant expertise is primarily needed in many of the areas that I’ve discussed: developing product strategy, doing product discovery, and performing SWOT analyses including capability assessments and market research.</p><h4><strong>Final thoughts</strong></h4><p>Paula Scher is a successful and prodigious creative legend, and I found a few of her comments to be especially insightful, so I wanted to share them as final thoughts.</p><p>When asked how her relationship with design changed throughout the course of her life Scher replied, “I started out not knowing what being a designer meant, and <strong>I learned it on the job</strong>. And I <strong>began to find my own method of communicating</strong> building a language that people respond to and use.” Not only did Scher learn by doing, but she also did what many successful individuals do: she defined her role herself. As she says, there is no definition for her role so she learned by doing and eventually she went from “designer” to “visual identity designer”.</p><p>When asked about the importance of newness Scher replied, “I think you move things forward and you <strong>make discoveries usually through mistakes</strong>. You’re doing something and you’ve make a terrible mistake and you stop and then you realize that there’s a possibility and then you can play with it and move it forward and sometimes you stretch a form…I’m always trying to stretch the form”. In practice, a “mistake” is just an attempt where the objective is not achieved so what Scher is ultimately describing is <strong>experimentation</strong>. From her perspective, the path to create anything new is to experiment. Despite this, many product development conversations revolve around how not to make mistakes. This is because the process requires an experimental mindset. Developing this mindset means developing a few skills: <strong>objective setting</strong> to be able to form a hypothesis, <strong>hypothesis testing</strong> to test if there is a relationship between our idea and the objective, and <strong>planning small</strong> to build the necessary flexibility for what our tests reveal.</p><p>In an interview with Rick Rubin, Scher makes a closing remark that “all of our best work actually should seem so easy…almost as if it designed itself.” This is a reminder to not forget to question the assumption that the idea we are developing is actually a good idea. If we find it excessively challenging to determine the value and feasibility of an idea then perhaps it is not the time for that idea. There are great ideas all around us, Rick Rubin calls this “the source”. And as we’ve seen so much of the Creative Product Manager role is to scan through the source tuning into particular ideas. Tuning is a lot of work: objective setting, consensus building, decision-making, hypothesis testing, and planning. Scher cautions against this and implies a mindfulness practice of <strong>detachment</strong> and developing the skill of <strong>planning small</strong> to support it. If an idea is not designing itself then it’s best to bank this idea until such a time when the world is ready.</p><p>Paula Scher is a creative legend with an impressive history of design work. While the output appears different, the tools she uses in her work have applications in the field of product management. As Creative Product Managers, we must learn to work with these tools to develop our skills. When a decision must be made, we can practice Scher’s top-down approach and three options philosophy. When the team can’t agree on how to move forward, we can practice Scher’s schoolteacher approach talking through a concept and explaining why one thing works and other things don’t to build consensus. And when we are trying to stretch the form and build something new, we can implement an experimental mindset like Scher and plan small so that we remain detached from specific ideas allowing the work to design itself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=834163fc2a95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The First 90 Days for the Creative Product Manager]]></title>
            <link>https://ckraczkowsky.medium.com/the-first-90-days-for-the-creative-product-manager-e87eacb7046e?source=rss-ea7611a809ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/e87eacb7046e</guid>
            <category><![CDATA[product-development]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[career-capital]]></category>
            <category><![CDATA[product-strategy]]></category>
            <category><![CDATA[creativity]]></category>
            <dc:creator><![CDATA[Colin Kraczkowsky]]></dc:creator>
            <pubDate>Tue, 27 Jun 2023 21:45:38 GMT</pubDate>
            <atom:updated>2023-06-27T21:52:14.591Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to use your initial days to build and showcase Product Management skills utilizing tools from creative legends</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4K-vSBpBmzF3arN_0FKWw.jpeg" /></figure><p>Starting a new position inevitably comes with a lot of unknowns: what is the team like? what should I be doing? where are the bathrooms? Every role will approach these first few months differently, however I’m interested in mapping out a plan for the Product Manager. Specifically for the Product Manager who feels like they don’t fit squarely into just one of the boxes commonly used today: the Outbound Product Manager, the Project Product Manager, the Technical Product Manager, the Frontend Product Manager, the Delivery Product Manager. The Product Manager for whom I’m writing is analytical, technical, and systems-oriented, sure, but they are also imaginative, inventive, maybe a bit goofy and they may be sensitive and passionate. They display the skillset and the temperament of a Da Vinci or a Rubin or a Jobs: legendary creatives. For a while, I have been fascinated with exploring, synthesizing, and narrating how “creativity” can be claimed in the field of Product Management. I have taken to calling this role the “Creative Product Manager”. In this blog, I explore how Creative Product Managers can set ourselves up for success when starting with a new company specifically looking at the first 90 days. I define what areas the Creative Product Manager should focus on, what tools can be adapted from the traditionally creative world for us to leverage, and what we can deliver within this initial time frame to build a strong foundation.</p><h4><strong>Product strategy</strong></h4><p>In their essay <a href="https://hbr.org/2015/12/find-innovation-where-you-least-expect-it">Find Innovation Where You Least Expect It</a>, entrepreneurs Tony McCaffrey and Jim Pearson diagnose that creativity in businesses are often inhibited by cognitive biases: functional fixedness, design fixation, and goal fixedness. They’re prescription for overcoming functional fixedness is a “generic parts technique” where an object is broken apart into its elements and each element is then broken down further until they’re described in their most general terms. McCaffrey and Pearson use a candle as an example which when broken down fully is comprised of long, interwoven, fibrous strands and cylindrically shaped lipids. By deconstructing an object to identify its core components, we enable more use cases, i.e. ideas, to be discovered. This discovery results from a manifestation of creativity that Einstein described as “combinatorial play”. In <a href="https://hbr.org/2002/08/creativity-under-the-gun">Creativity Under the Gun</a>, founder Constance N. Hadley and fellow authors illustrate this form of play as “throwing a bunch of balls into the cognitive space [and] juggling them around until they collide in interesting ways.” The theory being that ideas that are rarely combined produce more novel outputs, and, as we know, creativity is partially about generating novel ideas.</p><p>Applying this concept to product, the Creative Product Manager seeks to generate novel products that are useful. This requires us to break apart our resources into their elemental parts. The analytical equivalent of “parts” in <em>product strategy</em> terms would be “strengths”. By identifying strengths early on, we set a foundation for combinatorial play to recombine these strengths in interesting ways to create new products. In addition to identifying strengths, Adam Brandenburger suggests in his article <a href="https://hbr.org/2019/03/strategy-needs-creativity">Strategy Needs Creativity</a> to “look at how weaknesses could be turned to the company’s advantage.” He gives the example of Tesla which does not have the dealership network utilized by most car manufacturers. While this can be viewed as a weakness, Tesla found an opportunity to innovate by taking control over pricing which eliminates price variations found in the traditional dealership model.</p><p>Some suggestions to identify strengths and weaknesses:</p><ul><li>Use your products — spend 2 hours a day during your first two weeks just using your product: figure out how they work, figure out the technical architecture</li><li>Interview your elders — have 3 coffee chats a week during your first month starting with the people who have been at the company longest: learn the company lore, find out how they keep up to speed on the industry, ask them about what they’re working on and how they’ve approached the problem</li><li>Explore other products in your industry — spend 2 hours a day during your first two weeks researching other players in your industry and what they are building</li></ul><p>Performing this analysis will result in identifying strengths and weaknesses and will also inevitably lead to identifying opportunities to utilize the strengths in your industry as well as threats exposed by your weaknesses. Documenting these will result in a full SWOT analysis for our new company, an artifact that will be core to our role as Product Managers but also as a creative foundation.</p><h4><strong>Stakeholder management</strong></h4><p>Some of the resources that we will discover through our SWOT analysis will be the people with which we interact, e.g. coworkers, customers, and partners. Many of these individuals will come into play during one of our projects. They might be actively involved in the project, be able mobilize resources to affect its outcome in some way, or have an interest in the project as they are positively or negatively affected as a result of its execution or completion. In the parlance of product management these individuals are stakeholders and our interactions with them utilize various skills under the area of <em>stakeholder management</em>. Within our first 90 days, it is important to start building relationships with these stakeholders and to understand how to work together. I’ve been working on a diagram to capture this analysis that I will refer to as a <em>stakeholder diagram</em> which I discuss in more depth in a different blog:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*YO1epeHL0ZYUXEANUHqX6g.png" /><figcaption>Stakeholder Diagram</figcaption></figure><ul><li>Core: This ring of stakeholders usually contains your product team including the Engineering Manager who mobilizes the technical team and the Designer who produces mockups, user flows, and the ultimate design. Most decisions on the project require a thumbs up from these stakeholders.</li><li>Contributors: Stakeholders in this ring include individuals who either contribute to your project or are directly affected by your project. You want to make sure that stakeholders in this ring are aware of your project and you have captured their feedback early. However day-to-day or week-to-week decisions do not require their input.</li><li>Observers: These stakeholders are mostly unaffected by your project and will have little or no input during the process. Many of them just want updates on what the project is and when it will be released. While their feedback could contain insight, decisions should not hang on their input.</li><li>Evaluators: I adapted this idea from Ed Catmull, co-founder of Pixar and former President of Walt Disney Animation Studios, who discusses in his article <a href="https://hbr.org/2008/09/how-pixar-fosters-collective-creativity">How Pixar Fosters Collective Creativity</a> the “creative brain trust”. The idea is to form a community of stakeholders within the company who have minimal investment in the product and no authority over the outcome but a mastery of value capture. The purpose of this ring is to have a sounding board when you are struggling with the value proposition for a feature or product which is a determining factor during the prioritization phase of the product development process.</li></ul><p>The further out an individual is in the <em>stakeholder diagram</em>, the fewer touchpoints you should need with them. The goal is white-glove service for the Core and self-service for the Observers. I’ve found that keeping an updated roadmap should be sufficient to answer 90% of the questions of an Observer.</p><p>In the first 90 days, take a moment after your coffee chats to reflect on the discussion and pin the colleague in the ring of the <em>stakeholder diagram</em> where you believe they fit, for now. For example, this person is working on something that reminded me of one of my focus areas — pin them as a Contributor. That person had key insights and I left the conversation trusting their opinion, but they’re so far removed I doubt I’ll organically interact with them often — pin them as an Evaluator. This person keeps asking for roadmap updates and for specific release dates for features — pin them as an Observer. Individuals will shift between rings over time so think of these as initial positions. The goal after 90 days is to have a quorum of individuals in each ring to visualize interactions with this individual thereby removing the cognitive friction of figuring out who to go to during <em>product development</em>.</p><p>At this early stage, it’s also helpful to start discussing expectations particularly amongst your Core stakeholders. In the first 90 days, it’s important to understand how these team members work. To prepare for these discussions, list out the details of how you’ve moved through the produce development process in the past. Who was responsible for user research? Where was key information about the project captured? How were specifications defined and who was responsible for which artifacts? What was the hierarchy or tickets and how was responsible for each tier? Now ask the team about their process and list out the responses. The goal is not to change anything. We haven’t yet built the trust or the capital to do so. But to get anything done we need to understand how the team works, and, once we’ve gone through the existing process a few times then can start making suggestions as to any weaknesses we’ve observed and how portions of alternative processes that we’ve observed might strengthen those areas.</p><h4><strong>Product development</strong></h4><p>Some timeless advice from Michael Watkins in his book <a href="https://www.amazon.com/s?k=the+first+90+days+book&amp;hvadid=616863264396&amp;hvdev=c&amp;hvlocphy=1022762&amp;hvnetw=g&amp;hvqmt=e&amp;hvrand=17844866814059315027&amp;hvtargid=kwd-2111876349&amp;hydadcr=24632_13611814&amp;tag=googhydr-20&amp;ref=pd_sl_1vt6gy3yli_e">The First 90 Days</a> is to secure “early wins”. Watkins elaborates that an early win should be “based on the expectations for your position and as laid out in prior conversations with your boss and stakeholders”. Having spent our initial days holding these conversations, we aligned on these expectations, started to build relationships, and formed an understanding of their needs. Now we need to identify what will be our early win. We want this problem to be important and able to be delivered in this 90 day period. A good starting point is to notice patterns in what our stakeholders consider a problem and acknowledge needs fixing. Look for unfinished projects that are followed by “we just haven’t had the time”. Given our limited timeline, we’ll need to promptly assess what skills, which team members, and how much time are necessary to execute on this. A good target for an early win is a problem where the details have largely been fleshed out already. If there are minimal details then it’s probably not an early win or a problem that needs solving at this time. The ideal early win can be done quickly with a small team. Remember that we filtered for problems that people just haven’t had the time to solve meaning that all the project really needs is someone to dedicated to making it happen. Once you’ve identified that win, take action: execute!</p><p>Securing an early win, in the parlance of product management, will exercise your <em>product development</em> skills and gain critical trust within the company. The first phase of <em>product development</em> is discovery where the problem is explored and clearly defined. If the problem has not already been solved then there is a good chance that the problem was not clearly defined or that it has not been thoroughly reduced to a core issue. In product management parlance, to express a problem in an action-oriented manner we use <em>goal setting</em>, a skill within the area of <em>product development</em>. For <em>goal setting</em>, the Creative Product Manager also has an arsenal of creative tools to deploy. Returning to McCaffrey and Pearson, stating a goal typically follows the format of verb (improve) + noun (usage) + prepositional phrase (of the API). They recommend “playing with the hyponyms of each of its parts [to] explore diverse approaches to your problem in a simple and cost-effective way” where hyponym is referring to more-specific synonyms, e.g. clamp is a hyponym for fasten. For example, if we substitute increase for improve such that our goal becomes “increase usage of the API” have we made the goal more explicit and provided additional clarity on what we want to accomplish? Here too we can lean on the SWOT analysis that we have been working on and leverage our increasing knowledge of the product to further reduce the goal. For example, let’s say that we learned that usage of the API requires holding an API key; we can state the goal now as “increase the number of keys for the API.” This might make discovery easier because now we have something more specific to explore. Perhaps we discover that the number API keys are low because users simply don’t know where to generate one. Your early win can be a simple redesign to make the flow easier.</p><blockquote>Rick Rubin utilized this tool in an interesting way while working on a record with legendary musician Tom Petty. They found boxes of refrigerator magnets of words, removed the connector words (e.g. the, and), and attached the rest to a music stand. Petty then started to sing while randomly choosing words from the music stand. After many iterations, these eventually became the lyrics for his tracks. Through replacing and rearranging words, an album was created.</blockquote><p>In addition to playing with the components of the goal, McCaffrey and Pearson introduce a second creative tool that can be useful for Product Managers: brain<em>swarming</em> (a play on words of the standard brain<em>storming</em> exercise). The exercise splits problem solving into goals and resources and then connects resources to goals via applications of the resource to achieve the goal; this forms a graph. The authors use the Titanic as an example and recommend starting with the most obvious solution connecting a goal node “Save passengers” to a resource node “Lifeboats” via an application node titled “Put people in lifeboats.” The exercise progresses with participants contributing new goals or new applications which in turn spurns identification of new resources. The result of <em>brainswarming</em> will be a list of potential solutions derived from a common goal and based on available resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6G5NIRj787UMuO4MfG6swA.png" /><figcaption>Brainswarming</figcaption></figure><p><em>Brainswarming</em> involves both a knowledge of the goal to be achieved and the available resources (i.e. strengths) of the company both of which we have uncovered through our SWOT analysis. One method of contributing new goals is to rephrase and reduce the root goal. This is where we can apply the <em>hyponym goal setting</em> technique from above. Additionally, McCaffrey and Pearson point out that the people involved in the exercise typically will fall into two camps, “strategically oriented people can focus on refining the goal, while those more familiar with technologies and production processes can begin with the resources.” Again, our initial <em>stakeholder management</em> work from our initial days will help to identify who falls into which camp to ensure the right mix of perspectives are present.</p><p>In <em>product development</em>, the discovery phase is followed by a prioritization phase, an execution phase, a promotional phase, and a retrospection phase. Since we are trying to secure an early win, our focus should be on completing the execution phase within the first 90 days. The output of discovery is a list of potential solutions, therefore the goal of prioritization is to reduce this list to solutions that will address the goal and to order the reduced list by impact and expense. This will create a roadmap. This roadmapping process can be daunting especially for those of us perfectionists who feel the need to find the optimal solution. A concept that I’ve found helpful is “satisfice”. I’m reminded of a quote by renowned record producer Rick Rubin, “There is no connection between how long something takes and how good it is. but that also doesn’t mean that it will be good quickly.” What you prioritize will probably not be the optimal solution, i.e. the perfect, final idea that will forever solve the problem. The satisficed goal during execution should follow the <a href="https://asana.com/resources/pareto-principle-80-20-rule">Pareto principle</a> where the first solutions in our roadmap have been evaluated for impact, i.e. they address the key causes of the bulk of the issues, and expense, i.e. the duration and effort needed to deliver. Early wins should maximize impact with an expense that doesn’t exceed our 90 day window. The ideal product team is working iteratively and is open to experimentation. Releases should be viewed as experiments that gauge how much impact our hypothetical solution actually has on our stated goal in the real world. Therefore these first releases should be small and flexible.</p><p>The output of the prioritization phase is a reduced list of solutions in priority order, therefore the goal of the execution phase is to pop the first item off the list and deliver it. The deliverable for the Product Manager, creative or not, is some sort of specification communicating to the product team what is to be delivered, i.e. a product requirements document (PRD). Once communicated to the team, there will be back and forth about the details of what’s being asked for and specifics like edge cases. This is where the Product Manager must ensure alignment with the goal while remaining flexible to feedback and willingness to scope the request down further. There are times when this pre-execution process of getting everyone to understand what is being built, receiving and integrating feedback, and waiting for your team members to produce their deliverables can drag on in what would be an amusing observance of Parkinson’s law, “Work complicates to fill the available time” if the product of that work wasn’t expected from you. This is why Product Managers often leverage constraints. I’ll discuss constraints more in future blogs, but generally the constraints in a Product Manager’s control are time and scope. In this case, we have a time-based constraint: we want to deliver something in 90 days net however long we used for discovery, prioritization, and the bit of buffer we reserved for initial <em>product strategy</em> and <em>stakeholder management</em>. We have kept this in mind during the previous phases so the first item in our prioritized roadmap should be something that we reasonably expected to fit this time frame. As a general purpose rule, I’d quantify this time frame as 60 days given:</p><p>90 total days — 15 days buffer + 10 days for discovery + 5 days for prioritization = 60 days for execution</p><p>So in pre-execution, we’ve further refined the PRD until the product team collectively estimates 60 days out from the start of the execution phase as time the delivered date. While the team is executing, we are making ourselves available to the team for the inevitable questions and additional refinement that occur when actual work is started. Having flexed our <em>product development </em>skills, we shift focus back to work on honing our <em>product strategy</em> skills through development of our SWOT analysis and our <em>stakeholder management </em>skills through adding to our <em>stakeholder diagram</em>.</p><h4><strong>Wrapping it up</strong></h4><p>Product Management is one of the most cross-functional roles at a company. Product Managers are expected to have expertise in the areas of <em>product strategy</em>, <em>stakeholder management</em>, <em>product development</em>, and a dozen more. We must decide which areas and which skills nested within these areas to develop and in what order. I argue that the Creative Product Manager spend their first 90 days focused on developing <em>product strategy</em> using creative tools like <em>functional fixedness</em> and <em>combinatorial play</em> to guide their development and set a strong foundation for further creative development. In addition, building skills in <em>stakeholder management </em>using frameworks like Pixar’s <em>collective brain trust</em> to create a group of individuals to turn to when you need help answering one of the most important questions for the Product Manager to answer: does this have value? And finally developing the area of <em>product development</em> using tools like <em>hyponym goal setting</em>, <em>brainswarming</em>, and <em>satisficing</em> to execute an early win. Thus, the first 90 days for a Creative Product Manager could look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pXf7HKaLTm3ashbSISW5OA.png" /><figcaption>90 Day Plan for the Creative Product Manager</figcaption></figure><p>This 90 day plan enables the Creative Product Manager to structure the critical early days at a new company. Following this, we build career capital within the field of Product Management utilizing creative tools that leverage our unique, creative side. We execute deliverables that showcase this effort and build trust with our colleagues. This lays a creative foundation on which we can build novel products that are useful.</p><p><em>Originally published on Mirror — </em><a href="https://mirror.xyz/0x6c26EB64D7f2645E466b019105aCD1C51aa67fb8/5aH8-tCRSIq3hzSmZZWd5UOfeDpnUzWTzZKuUFj2v78"><em>https://mirror.xyz/0x6c26EB64D7f2645E466b019105aCD1C51aa67fb8/5aH8-tCRSIq3hzSmZZWd5UOfeDpnUzWTzZKuUFj2v78</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e87eacb7046e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Soulbound Tokens, the evolved form of NFTs]]></title>
            <link>https://ckraczkowsky.medium.com/soulbound-tokens-the-evolved-form-of-nfts-965f60e65193?source=rss-ea7611a809ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/965f60e65193</guid>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[decentralization]]></category>
            <dc:creator><![CDATA[Colin Kraczkowsky]]></dc:creator>
            <pubDate>Fri, 10 Feb 2023 23:29:19 GMT</pubDate>
            <atom:updated>2023-04-10T15:09:00.017Z</atom:updated>
            <content:encoded><![CDATA[<h4>What are they? And what can we do with them?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Vz7wRgeZz2CCtenq0RIkZw.png" /></figure><h4><strong>What are soulbound tokens?</strong></h4><p>In summary, soulbound tokens (SBTs) are non-fungible tokens (NFTs) that, once minted to the individual, cannot be transferred or sold. So how did we get this definition?</p><p>The origination of soulbound tokens is popularly attributed to a <a href="https://vitalik.ca/general/2022/01/26/soulbound.html">blog post by Ethereum’s Vitalik Buterin</a> which was then expanded on in a <a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763">follow-up paper</a> between Buterin and other contributors. In his blog, Buterin first describes the concept of “soulbound” as something that remains in the individual’s possession unable to be transferred or sold. Tracing the idea back to World of Warcraft game mechanics, Buterin notes that soulbound items in the game enter the player’s possession upon the completion of a hard or risky task. In the game this keeps things interesting , however the concept’s importance expands to blockchain as well where tools to minimize rent seeking behavior are always in vogue. Rent seeking behavior involves individuals providing minimal value as a whole but slowly accumulating capital to gain power and it is problematic for blockchain networks and game mechanics alike. As in game mechanics, this behavior is detrimental to blockchains as individuals provides little value over but slwoly accumulates capital and eventually just purchases the item. While for World of Warcraft this capital are items and this power are particulary potent items, for blockchain network capital is captured in tokens and power is conferred in monetary, governance, and other forms. So Buterin’s blog naturally transitions to talking about tokens, specifically non-fungible tokens (NFTs). He introduces cases in which the transferability of NFTs is illogical. For example, the proof of attendance protocol (POAP) where individuals are minted NFTs to prove they were present at a particular event. Some projects tried to utilize these POAP NFTs to provide exclusive opportunities which gave them monetary value which of course meant that a market quickly formed to sell them to the highest bidder. Now one of these NFTs is sitting in someone’s wallet for an event they never attended which ultimately defeats the purpose of the POAP.</p><p>So now we have the ingredients for the definition of soulbound tokens. They have the quality of uniqueness implicit in all non-fungible tokens with the tweak of being bound to the individual for cases where it doesn’t make sense for a unique token to change ownership. Additionally, it makes sense that SBTs are extensions of NFTs and not fungible ERC-20s as the definition of fungibility means these tokens are indistinct from one another and are meant to change hands, frequently.</p><h4><strong>How are soulbound tokens being used today?</strong></h4><p>Since soulbound tokens are unique and cannot be transferred between individuals, they have been initially used for identity and participation. One such use case is decentralized governance which has historically been plagued by an issue where holders of large shares of available tokens, colloquially referred to as “whales”, can accumulate an outsized influence over the direction of the protocol. Using SBTs to establish a one-token-one-vote strategy, means that these protocols can allow individuals with smaller holdings to have an equal say. One protocol taking an innovative approach in decentralized governance that incorporates SBTs is Optimism.</p><p>Optimism is a fast, stable, and scaleable L2 blockchain. It aims to be decentralized meaning that it will need a decentralized way to make decisions. To this end, the team has actively been experimenting with governance schemes. Optimism is governed by a collaboration between the Optimism Foundation (“the Foundation”) and the members of the <a href="https://community.optimism.io/docs/governance/">Optimism Collective</a> (“the Collective”). The core governing structure of the Collective is established as two co-equal chambers: the Token House and the Citizens’ House. The Token House is made up of holders of the OP token, an ERC-20 token similar to the COMP token, that was originally distributed to thousands of addresses that engaged in positive-sum, community-oriented behavior. The Citizens’ House is made up of holders of a soulbound token whose distribution is governed by the Foundation and Token House. The Token House is responsible for governing the protocol. The Citizens’ House is responsible for governing the distribution of “retroactive public goods funding”.</p><p>About <a href="https://medium.com/ethereum-optimism/retroactive-public-goods-funding-33c9b7d00f0c">RPBF </a>— This is actually really interesting; like all blockchain networks, Optimism charges fees to process transactions, however, rather than distributing these fees directly to miners or stakers as rewards, Optimism puts those fees into a fund for public goods that have been retroactively determined to be beneficial to Optimism, Ethereum, and the Collective as a whole. This in itself is increasing access of funding to nonprofits, free, open-source software (FOSS), and public goods projects.</p><p>Using soulbound tokens Optimism has created multiple legislative bodies and the makings of a checks and balances system. If whales accumulating masses of OP tokens were to form in their ecosystem, their power would still be limited to decisions in just one of the legislative bodies. Additionally, since SBTs can’t be transferred, no marketplaces for these tokens will form thereby eliminating any incentive to seek profit from these tokens. Members of the Token House have a check on the Citizens’ House because they determine who is allowed to mint an SBT. Members of the Citizens’ House have a check on the Token House because they determine how the protocol’s treasury of collected gas fees gets distributed.</p><h4><strong>How can I see soulbound tokens in action?</strong></h4><p>I’ve found that the best way to see tokens in action is to write and deploy the smart contracts for them, so here is some code to write your own soulbound token:</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.7;<br><br>import &quot;@openzeppelin/contracts/token/ERC721/ERC721.sol&quot;;<br>import &quot;@openzeppelin/contracts/utils/Counters.sol&quot;;<br>import &quot;@openzeppelin/contracts/access/Ownable.sol&quot;;<br><br>contract SoulBoundToken is ERC721, Ownable {<br>    using Counters for Counters.Counter;<br><br>    Counters.Counter private _tokenIdCounter;<br><br>    constructor() ERC721(&quot;SoulboundToken&quot;, &quot;SBT&quot;) {}<br><br>    function safeMint(address to) public onlyOwner {<br>        uint256 tokenId = _tokenIdCounter.current();<br>        _tokenIdCounter.increment();<br>        _safeMint(to, tokenId);<br>    }<br><br>    function burn(uint256 tokenId) external {<br>        require(ownerOf(tokenId) == msg.sender, &quot;Only the owner of the token can burn it.&quot;);<br>        _burn(tokenId);<br>    }<br><br>    function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual override {<br>        super._beforeTokenTransfer(from, to, firstTokenId, batchSize);<br><br>        require(from == address(0) || to == address(0), &quot;This a Soulbound token. It cannot be transferred. It can only be burned by the token owner.&quot;);<br>    }<br><br>    function _burn(uint256 tokenId) internal override(ERC721) {<br>        super._burn(tokenId);<br>    }<br>}</pre><p>To see this code in action, perform the following steps:</p><ol><li>Go to <a href="https://remix.ethereum.org/">Remix IDE </a>.</li><li>In the File Explorer tab, create “SBT.sol” as a new file in the contracts folder, and copy/paste this code into SBT.sol (this code can also be found on my <a href="https://github.com/ckraczkowsky91/soulbound-token-contract/blob/main/SoulboundToken.sol">GitHub</a>)</li><li>Navigate to the Solidity Compiler tab and click “Compile SBT.sol” to compile the Solidity file into bytecode and an ABI</li><li>Navigate to the Deploy &amp; Run Transaction tab and change the Environment to “Injected Provider — MetaMask”</li><li>In MetaMask, change your network to “Goerli test network”</li><li>Back in the Deploy &amp; Run Transaction tab, click “Deploy”, MetaMask will pop up to sign the transaction (if you need GoerliETH go to Alchemy’s <a href="https://goerlifaucet.com/">Goerli Facuet</a>)</li><li>Interact with your newly deployed smart contract managing your soulbound tokens<br>- Execute the safeMint function a new soulbound token to your MetaMask address<br>- Check that you received the token by calling the ownerOf function with a tokenId of 0 and verifying that your address is in the response<br>- Try to transfer the token using the safeTransferFrom function and see that it errors out with the message that we defined, “execution reverted: This a Soulbound token. It cannot be transferred. It can only be burned by the token owner.”</li></ol><p>The code above demonstrates all the aspects of soulbound tokens that have been discussed. They are non-fungible tokens and inherit the properties and methods of these tokens. The two key differences being 1) we have overridden the _beforeTokenTransfer function of the NFT contract such that the token the soulbound token is unable to be transferred from the address and 2) we have overridden the burn function such that only the owner is able to destroy the soulbound token.</p><h4><strong>What could the future of soulbound tokens look like?</strong></h4><p>One dimension from which to view the future of soulbound tokens is to imagine the future use cases for the technology. In his blog, Buterin enumerates a few potential additional uses for soulbound tokens like driver’s licenses, university degrees, proofs of age, and vaccination records. There are also additional use cases within governance . In addition to whales, another problem that token project’s face with respect to governance is participation. Despite all kinds of incentives that project’s deploy to encourage all holders to vote, it remains true that only a fraction actually do. But if all participants are holding a soulbound token then could we enable additional incentives based on certain conditions being met? For example, if a proposal in Optimism is close to expiring and only 1% of soulbound token holding wallets that also hold less than 100 OP have voted then could these wallets become eligible for some sort of voting reward, e.g. free gas or a portion of gas fees for a particular period? The specific mechanics and tokenomics obviously need to be fleshed out in more detail, but we can see that the benefits of having a token available only to a specific wallet having performed a specific action enables use cases where we can 1) trust the attestations of the wallet, 2) better identify characteristics of the wallet by its actions, and 3) provide further incentives for this wallet.</p><p>A second dimension is to explore how the existing technology could evolve. What will be interesting to see in the future is how soulbound tokens will evolve as we have seen non-fungible tokens evolve. As we saw in the code above, SBTs are a subset of NFTs: smart contracts initialized with metadata of attributes. This metadata can be updated based on certain criteria being met. For example, we have seen NFT artwork where the image changes based on the time of the day. As we play around with soulbound tokens, we could see use cases like driver’s license SBTs expand. Imagine a young driver being granted a “Driver’s License” soulbound token with an attribute with a trait_type of status and value of beginner and a second trait_type of points with a value of 0 where, after they have successfully attested to certain qualifications, status automatically advances to intermediate. Adversely, if they get into a fender bender points changes to 2 and status to supervisory.</p><p>A third dimension is to think about how soulbound tokens can integrate with other technologies. One example from Buterin is how soulbound tokens can integrate with zero-knowledge technology. There are cases where it is desired an individual holding an SBT may not want the details of the token to be publicly available, e.g. vaccination records. In this case, if the individual was interacting with a smart contract where knowledge of the their vaccination was required then the individual could provide a zero-knowledge proof that proves the validity of their attestation about being vaccinated without requiring the smart contract direct-read access to the individual’s vaccination records.</p><p>In summary, the future of non-transferable, non-fungible tokens is bright and will be an exciting place to keep an eye on as use cases and the technology mature.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=965f60e65193" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wallets and Smart Contracts]]></title>
            <link>https://medium.com/coinmonks/wallets-and-smart-contracts-eee1d7da5888?source=rss-ea7611a809ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/eee1d7da5888</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Colin Kraczkowsky]]></dc:creator>
            <pubDate>Tue, 31 Jan 2023 18:07:44 GMT</pubDate>
            <atom:updated>2023-03-15T07:33:07.317Z</atom:updated>
            <content:encoded><![CDATA[<h4>Understanding interactions in Web3</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FT8Sl3WAVe3oPWO9g23-dg.jpeg" /></figure><p>In a previous post, I discussed <a href="https://www.anchorage.com/insights/a-look-at-smart-contract-voting-with-compound">smart contracts and how interactions with smart contracts are forming the basis of the rapidly growing Web3 world</a>. In that post, I honed in on governance via smart contracts. In this post, I take a look at decentralized applications, colloquially referred to as “dapps”, that are providing the interfaces and handling the interactions between smart contracts, wallets, and you. We will then look at how dapps communicate with wallets and the innovative services, like WalletConnect, facilitating this communication. Lastly we discuss the critical security role that wallets play in these interactions. Together, these form the building blocks for new Web3 services like decentralized finance, decentralized governance, decentralized identity, and more!</p><h4>What is a dapp?</h4><p>Ethereum, one of the first blockchain networks to support dapps, provides a good <a href="https://ethereum.org/en/developers/docs/dapps/">definition of a dapp</a>:</p><blockquote><em>A decentralized application (dapp) is an application built on a decentralized network that combines a smart contract and a frontend user interface. On Ethereum, smart contracts are accessible and transparent — like open APIs — so your dapp can even include a smart contract that someone else has written.</em></blockquote><p>Pulling from that definition, a dapp involves three main components:</p><ul><li>A frontend — the entry point for the user</li><li>Smart contract(s) — the place where the logic exists</li><li>A wallet — where the user signs messages and transactions triggered by the frontend</li></ul><p>Dapps have infiltrated many industries today from finance to music to gaming. Some examples of popular dapps in these areas include Compound, Audius, and Decentraland. Dapps often have their own token to hold and exchange value, e.g. Compound has COMP for participants to exchange voting power, Audius has AUDIO for listeners to exchange tips directly with artists, Decentraland has MANA for players to exchange for LAND which gives them virtual property rights. Most choose to custody these tokens in the safety of wallets. Because they run on blockchains, dapps can maintain users’ privacy, provide flexibility for developers, and are uncensorable.</p><p>The world of Web3 is a chain of interactions between smart contracts and wallets: calling functions in smart contracts, creating messages and transactions, signing those messages and transactions with a wallet, and broadcasting them to the blockchain to take effect. Dapps are facilitating these interactions making them a key building block of Web3.</p><h4>How do dapps interact with smart contracts?</h4><p>Since smart contracts are the starting point for these interactions, it’s important to take a quick look at how dapps interact with them. Smart contracts are programs that reside at a specific address on a blockchain network. Blockchain networks have built interfaces to communicate with nodes in the network, e.g. Ethereum provides the <a href="https://ethereum.org/en/developers/docs/apis/json-rpc/">JSON-RPC API</a>. Over the years, various convenience libraries have been built for dapp developers. One of the most popular libraries is web3.js which exposes JSON-RPC APIs as JavaScript APIs. These libraries abstract the lower level JSON-RPC calls for the developer and work in tandem with a wallet to sign transactions.</p><p>Smart contracts expose a piece of their functionality as a “function”. For example, the COMP smart contract that we analyzed in the aforementioned previous post provides the ability to delegate your voting power via a function appropriately named delegate.</p><pre>function delegate(address delegatee) public {<br>  return _delegate(msg.sender, delegatee);<br>}</pre><p>If we wanted to delegate our COMP ourselves, we could set up our own Ethereum client (e.g. geth, Nethermind, Erigon, Best), write the appropriate transaction, and make the right JSON-RPC calls to sign and broadcast this delegation. Or we could just use a dapp like the lovely <a href="https://app.compound.finance/#vote">governance dapp</a> that Compound already provides.</p><h4>Example transaction between smart contract, dapp, and wallet</h4><p>So we know how dapps interact with smart contracts, but how do all of the components fit together from the interaction provided by the smart contract to the signature by the wallet? To understand this, let’s look at an example using a simple smart contract.</p><p>First, we set up the environment and write a smart contract.</p><pre>mkdir understanding-dapps<br>npm install ganache<br>npx ganache-cli - secure</pre><pre>pragma solidity ^0.4.0;<br><br>contract SimpleSmartContract {<br>  uint storedData;<br>  function set(uint x) public {<br>    storedData = x;<br>  }<br>  function get() constant public returns (uint retVal) {<br>    return storedData;<br>  }<br>}</pre><p>In order to deploy this smart contract to the blockchain, we need what’s called an application binary interface (ABI). We can get one by running our code above through the <a href="https://remix.ethereum.org/">Remix IDE</a>.</p><p>608060405234801561001057600080fd5b5060df8061001f6000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063<strong>60fe47b1</strong>14604e578063<strong>6d4ce63c</strong>146078575b600080fd5b348015605957600080fd5b5060766004803603810190808035906020019092919050505060a0565b005b348015608357600080fd5b50608a60aa565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a7230582080122bb351e6e2c021f1c56c0c5933087e762ea6e7a3360b902b39cbed5a38f10029</p><p>We will deploy this smart contract to the blockchain using the web3.js library discussed above. Leave your instance of Ganache running in a separate terminal window and open a new terminal window to load a Node.js runtime environment. First, we set up our environment to use web3.js and configure it to point to the local blockchain provided by Ganache.</p><pre>//load Node.js<br>&gt; node<br>//setup web3.js<br>&gt; const Web3 = require(&#39;web3&#39;);<br>undefined<br>&gt; const web3 = new Web3(Web3.givenProvider || &quot;ws://localhost:8545&quot;);<br>//check connection<br>&gt; web3.eth.getAccounts().then(console.log)<br>[<br>&#39;0x0E3559cb03C0d26feF749Acec13027319b95D334&#39;,<br>&#39;0xbeec86a83B265a7d7CCF534f021Fe6B835ffd0d7&#39;,<br>&#39;0x062dDB435d5eEC15f27dbf67574eb54A093F6043&#39;,<br>&#39;0x0C2F0Ad891E487C4c80bE90e9217a52E05E27de9&#39;,<br>&#39;0x86E8af47f561db084D8975F911348A74b161D85A&#39;,<br>&#39;0x45e75191E73846eC89EDD0b0EC447de25BEE7720&#39;,<br>&#39;0x55C557719eaABd5aAB99a69eB1039533D19513DD&#39;,<br>&#39;0x34b27a072D8E8d37CD29756F3a98202Ae4e0D2A9&#39;,<br>&#39;0x016dc2F94Ffde589ef536E0dF5d312b15e24258b&#39;,<br>&#39;0xeAfF15999e7e81969dC55bD6fF541E3D85562dB7&#39;<br>]</pre><p>Let’s try deploying our smart contract, an on-chain transaction, from one of the wallets that Ganache provided to us.</p><pre>//deploy contract<br>&gt; web3.eth.sendTransaction({from:&quot;0x0E3559cb03C0d26feF749Acec13027319b95D334&quot;,data:&quot;608060405234801561001057600080fd5b5060df8061001f6000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c146078575b600080fd5b348015605957600080fd5b5060766004803603810190808035906020019092919050505060a0565b005b348015608357600080fd5b50608a60aa565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a7230582080122bb351e6e2c021f1c56c0c5933087e762ea6e7a3360b902b39cbed5a38f10029&quot;,gas:200000})<br>(node:8535) <br>UnhandledPromiseRejectionWarning: Error: Returned error: signer account is locked</pre><p>Here we can see signatures come into play. When trying to send a transaction without signing there’s an error. Because this is an on-chain transaction that takes an action, changes the state of the blockchain, and costs the sender, the network expects the transaction to be signed and thereby authorized by the sender. Let’s attempt deploying our smart contract again but first signing the transaction and then sending.</p><pre>//sign transaction<br>//https://web3js.readthedocs.io/en/v1.5.2/web3-eth.html#signtransaction<br>&gt; web3.eth.accounts.signTransaction({<br>from:&#39;0x0E3559cb03C0d26feF749Acec13027319b95D334&#39;,<br>To:``,<br>Data:&quot;608060405234801561001057600080fd5b5060df8061001f6000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c146078575b600080fd5b348015605957600080fd5b5060766004803603810190808035906020019092919050505060a0565b005b348015608357600080fd5b50608a60aa565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a7230582080122bb351e6e2c021f1c56c0c5933087e762ea6e7a3360b902b39cbed5a38f10029&quot;,<br>gas:&quot;200000&quot;},&quot;0x6fabda9cbd126a375be0ba1c213d7d3febc567427e2009e545ad07d003a79fb6&quot;).then(console.log)<br>{<br>messageHash: &#39;0xac244be68f7748624f7f9e42a5ef23838e9f718e7a0b0bfc079019354d4703bb&#39;,<br>v: &#39;0xa96&#39;,<br>r: &#39;0xaad92f4c8cd6626ec0f78c17c5dd43e70b64729c2f168349ce5ed65cc97c5cdc&#39;,<br>s: &#39;0x64d18c4237a5c56690887bcbd35638e2c51227213b43b43e2d1b38850c990d04&#39;,<br>rawTransaction: &#39;0xf90152808504a817c80083030d408080b8fe608060405234801561001057600080fd5b5060df8061001f6000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c146078575b600080fd5b348015605957600080fd5b5060766004803603810190808035906020019092919050505060a0565b005b348015608357600080fd5b50608a60aa565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a7230582080122bb351e6e2c021f1c56c0c5933087e762ea6e7a3360b902b39cbed5a38f10029820a96a0aad92f4c8cd6626ec0f78c17c5dd43e70b64729c2f168349ce5ed65cc97c5cdca064d18c4237a5c56690887bcbd35638e2c51227213b43b43e2d1b38850c990d04&#39;,<br>transactionHash: &#39;0x3c60f19f87badb559df9ab4047b0ad77afc371130933e1891b7cf69fb6f42ea9&#39;<br>}<br>//send signed transaction //https://web3js.readthedocs.io/en/v1.5.2/web3-eth.html#sendsignedtransaction<br>&gt; web3.eth.sendSignedTransaction(&#39;0xf90152808504a817c80083030d408080b8fe608060405234801561001057600080fd5b5060df8061001f6000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c146078575b600080fd5b348015605957600080fd5b5060766004803603810190808035906020019092919050505060a0565b005b348015608357600080fd5b50608a60aa565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a7230582080122bb351e6e2c021f1c56c0c5933087e762ea6e7a3360b902b39cbed5a38f10029820a96a0aad92f4c8cd6626ec0f78c17c5dd43e70b64729c2f168349ce5ed65cc97c5cdca064d18c4237a5c56690887bcbd35638e2c51227213b43b43e2d1b38850c990d04&#39;).then(console.log)<br>{<br>transactionHash: &#39;0x3c60f19f87badb559df9ab4047b0ad77afc371130933e1891b7cf69fb6f42ea9&#39;,<br>transactionIndex: 0,<br>blockHash: &#39;0x0be392fffbdb0d97ad2454e1a0999e05e1555fae61f4654ea52f40230d56aacb&#39;,<br>blockNumber: 1,<br>from: &#39;0x0e3559cb03c0d26fef749acec13027319b95d334&#39;,<br>to: null,<br>gasUsed: 101241,<br>cumulativeGasUsed: 101241,<br>contractAddress: &#39;0x84274E2beE243984B37b31E9c12be344dfaD8CC2&#39;,<br>logs: [],<br>status: true,<br>logsBloom: &#39;0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000&#39;<br>}</pre><p>We go back and use web3.js to sign the transaction using the private key provided by Ganache for that wallet which returns a “raw transaction”, a transaction that has been signed and encoded, which is our signature. We take that signature and use web3.js again to broadcast it to the blockchain and this time it works! A new block is added containing our transaction and we get back an address with which we can interact with our newly deployed smart contract.</p><p>This is where things get interesting now that our smart contract has been deployed to the blockchain and we can actually start interacting with it. Our first interaction will be to retrieve the data currently stored in our smart contract. This is an off-chain transaction that won’t require a signature as it will not create a new block.</p><pre>//interact with smart contract<br>&gt; var contractAddress = &#39;0x84274E2beE243984B37b31E9c12be344dfaD8CC2&#39;<br>&gt; var getSignature = &#39;0x6d4ce63c&#39;<br>&gt; var setSignature = &#39;0x60fe47b1&#39;<br>&gt; web3.eth.call({to: contractAddress, data: getSignature}).then(console.log)<br>0x0000000000000000000000000000000000000000000000000000000000000000</pre><p>We create two variables getSignature and setSignature to hold the “function signatures” of the functions that we exposed in our smart contract. A function signature is four bytes of code that is used internally by the Solidity programming language to identify and call the function. These signatures are one way that a user interface can display some useful information about the transaction that need signing. We use the function signature for the get function from our smart contract and provide our contract’s address on the blockchain to retrieve the initial value of storedData defined in our contract.</p><p>We’ve seen what an off-chain call to our smart contract looks like to retrieve data. Now let’s take a look at how on-chain transactions are made by setting a new value for storedData from our smart contract. This will be another on-chain transaction that will change the state of the blockchain and create a new block.</p><pre>&gt; web3.eth.sendTransaction({from:’0x0E3559cb03C0d26feF749Acec13027319b95D334&#39;,to:contractAddress,data:setSignature+`00000000000000000000000000000000000000000000000000000000000000ff`}).then(console.log)<br>(node:8535) UnhandledPromiseRejectionWarning: Error: Returned error: signer account is locked<br>&gt; web3.eth.accounts.signTransaction({from:&#39;0x0E3559cb03C0d26feF749Acec13027319b95D334&#39;,to:contractAddress,data:setSignature+`00000000000000000000000000000000000000000000000000000000000000ff`,gas:`200000`},&quot;0x6fabda9cbd126a375be0ba1c213d7d3febc567427e2009e545ad07d003a79fb6&quot;).then(console.log)<br>{<br>messageHash: &#39;0xca8c1d525f914b54cf27b358c5a51c191724281e2cccd82c2048de8a3044380c&#39;,<br>v: &#39;0xa95&#39;,<br>r: &#39;0x41d26f8374fb019b5ef54114b396905ff1a78d93cc29365d8cfbe7622e0b9b37&#39;,<br>s: &#39;0x583052e6422a7bf4638dee19afb6b9953664cb5eed201fa97e86613c01186ba9&#39;,<br>rawTransaction: &#39;0xf88b018504a817c80083030d409484274e2bee243984b37b31e9c12be344dfad8cc280a460fe47b100000000000000000000000000000000000000000000000000000000000000ff820a95a041d26f8374fb019b5ef54114b396905ff1a78d93cc29365d8cfbe7622e0b9b37a0583052e6422a7bf4638dee19afb6b9953664cb5eed201fa97e86613c01186ba9&#39;,<br>transactionHash: &#39;0x0c257077bc1bcf5873a27c85855d7e24f1a3b1598dec58780a3c2fe60ea76541&#39;<br>}<br>&gt; web3.eth.sendSignedTransaction(&#39;0xf88b018504a817c80083030d409484274e2bee243984b37b31e9c12be344dfad8cc280a460fe47b100000000000000000000000000000000000000000000000000000000000000ff820a95a041d26f8374fb019b5ef54114b396905ff1a78d93cc29365d8cfbe7622e0b9b37a0583052e6422a7bf4638dee19afb6b9953664cb5eed201fa97e86613c01186ba9&#39;).then(console.log)<br>{<br>transactionHash: &#39;0x0c257077bc1bcf5873a27c85855d7e24f1a3b1598dec58780a3c2fe60ea76541&#39;,<br>transactionIndex: 0,<br>blockHash: &#39;0xa42f268398a9cb0f12031d0434e17ffeadd1f2980254a87eb94738b09c801d97&#39;,<br>blockNumber: 2,<br>from: &#39;0x0e3559cb03c0d26fef749acec13027319b95d334&#39;,<br>to: &#39;0x84274e2bee243984b37b31e9c12be344dfad8cc2&#39;,<br>gasUsed: 41409,<br>cumulativeGasUsed: 41409,<br>contractAddress: null,<br>logs: [],<br>status: true,<br>logsBloom: &#39;0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000&#39;<br>}<br>&gt; web3.eth.call({to: contractAddress, data: getSignature}).then(console.log)<br>0x00000000000000000000000000000000000000000000000000000000000000ff</pre><p>Again, we see that the blockchain expects an on-chain transaction to be signed and will fail otherwise. We sign the transaction calling the set function from our smart contract which changes the value of storedData within the contract.</p><p>Thinking of our Node.js environment as simulating a dapp, the example above provides a tactical understanding of the interplay between smart contracts, dapps, and wallets.</p><ul><li>The smart contract exposes its contents as functions</li><li>The dapp presents these functions to the end user for interaction</li><li>The dapp assembles the information for the transaction including the address of the smart contract and the data to be signed</li><li>The dapp establishes a connection with the wallet</li><li>The dapp sends the transaction to the wallet</li><li>The wallet presents the transaction to the owner of the account for signing with the private key of the account to confirm that the owner authorizes the transaction (e.g. signTransaction)</li><li>The wallet interfaces with an Ethereum client, e.g. Metamask uses Infura and Anchorage Digital runs proprietary Ethereum nodes, to broadcast the transaction to the blockchain</li></ul><p>An important theme to notice here is the communication between each player, in particular the communication with the wallet since it is at this point that the transaction or message is signed enabling it to be broadcast to the blockchain. There are various ways for these players to communicate, and we will look at those next.</p><h4>Establishing communication</h4><p>Between the wallet and the dapp, a communication channel must be established so that the dapp can get the transaction to the wallet for signature and broadcasting. Some wallets, e.g. <a href="https://docs.metamask.io/guide/rpc-api.html">MetaMask</a>, have built proprietary means of communication. Other wallets build integrations with third-party services, e.g. <a href="https://docs.walletconnect.com/quick-start/dapps/node">WalletConnect</a>, which provide communication bridges that enable the dapp to securely pass a payload to the wallet to be handled at the wallet’s discretion. Using a third-party service means that the wallet provider doesn’t have to build bridges for all dapp. Instead, the wallet can communicate with any dapp also integrated with the service. Additionally these services often support multiple blockchain networks making it much easier for the wallet to sign transactions across different networks.</p><p>With WalletConnect a secure bridge is established between the dapp and the wallet so that payloads can be sent between them. This is enabled by a connection that WalletConnect creates between the dapp and the wallet using symmetric encryption such that only the dapp and the wallet, not WalletConnect, can read each other’s messages. This means that nobody can mishandle or change the message between the two peers.</p><p>Below is an example of a dapp integrated with WalletConnect; this could even be our simple dapp from above. Let’s say that while using this dapp, I trigger the set function which, as you recall, requires a signature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TezholM06ZI5r-lm" /></figure><p>As the wallet provider, I receive a request from WalletConnect which contains a payload that I format into something like what’s shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/0*QWWxXgPq7086KSsh" /></figure><p>The data in the payload should look familiar as it’s the same that we saw when signing a transaction in the example that we worked through above. Conveniently, WalletConnect provides structured payloads so that the wallet can choose which methods it wants to support and can present helpful information to the wallet owner when deciding to sign. An added layer of security that integrating with a bridge like WalletConnect provides is that the wallet can have exclusive access to the signature to avoid sending signatures back and forth between peers over networks that may not be secure. The wallet owner needs only to trust the wallet and not also the communication bridge or the dapp to handle their transactions appropriately.</p><p>The wallet can receive this payload and parse through it to handle on its specific terms. For example, the payload indicates the JSON-RPC method to be used, <a href="https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign">eth_sign</a>, and provides the parameters to be signed including the address and the message. The wallet provider can display the information from the payload to the wallet owner so that they are aware of what they are signing. The private key remains in the wallet so that the dapp never has access to it.</p><p>In addition to the JSON-RPC transaction methods that we have become familiar with (e.g. eth_sendTransaction, eth_signTransaction), WalletConnect also supports methods for signing off-chain messages (e.g. personal_sign, eth_signTypedData). Because messages don’t change the state of the blockchain which would create a new block and charge the sender, they have become very popular particularly when gas fees are high. A good example is <a href="https://docs.snapshot.org/">Snapshot</a>: a decentralized governance tool that enables projects to poll their participants and utilizes off-chain messages so participants aren’t charged for their vote but their votes can be easily verified because the messages are signed.</p><p>Further, WalletConnect supports <a href="https://docs.walletconnect.com/client-api#send-custom-request">custom requests</a> enabling the dapp and the wallet to engage methods that aren’t discretely supported by WalletConnect. For example, prior to <a href="https://eips.ethereum.org/EIPS/eip-712">EIP-712</a> the method eth_signTypedData did not exist. Had WalletConnect existed prior to this, a dapp would not be able to utilize this method with WalletConnects predefined methods. With custom requests, the dapp can create a custom payload with the alternative method and submit it to the wallet. This helps to future-proof WalletConnect as protocols continue to grow and improve.</p><p>As with anything, there are risks when interacting with dapps. One risk, for example, is agreeing to a transaction which you didn’t intend. A high-profile example of this occurred in early 2023 when <a href="https://cointelegraph.com/news/moonbirds-creator-kevin-rose-loses-1-1m-in-nfts-after-1-wrong-move">Kevin Rose lost $1.1M after being phished to sign a malicious transaction</a>. An example of a malicious transaction, the code below simulates the possibility of signing a transfer to a random address.</p><pre>//sign any txn<br>&gt; randomAddress = `0xbeec86a83B265a7d7CCF534f021Fe6B835ffd0d7`<br>&gt; web3.eth.accounts.signTransaction({from:&#39;0x0E3559cb03C0d26feF749Acec13027319b95D334&#39;,to:randomAddress,value:`500`,gas:`200000`},&quot;0x6fabda9cbd126a375be0ba1c213d7d3febc567427e2009e545ad07d003a79fb6&quot;).then(console.log)<br>{<br>messageHash: &#39;0x3102a3ebf1cb14bf5c0fc7a1e0c580d7428ccf4d9fc027dfd66a8107f9274e3e&#39;,<br>v: &#39;0xa95&#39;,<br>r: &#39;0xd893425f7666cc45cd0458f038c9799aa17461cfb02d000a7aa54ac01e2088fa&#39;,<br>s: &#39;0x73288761bdcce313662414e0157316c1240922345cc338e557fcfed4d7a7ba4&#39;,<br>rawTransaction: &#39;0xf869058504a817c80083030d4094beec86a83b265a7d7ccf534f021fe6b835ffd0d78201f480820a95a0d893425f7666cc45cd0458f038c9799aa17461cfb02d000a7aa54ac01e2088faa0073288761bdcce313662414e0157316c1240922345cc338e557fcfed4d7a7ba4&#39;,<br>transactionHash: &#39;0x7d610f3aa9c9276381fa9a936a748ab3cb137cd186b29ef7437065027de0c086&#39;<br>}<br>&gt; web3.eth.sendSignedTransaction(&#39;0xf869058504a817c80083030d4094beec86a83b265a7d7ccf534f021fe6b835ffd0d78201f480820a95a0d893425f7666cc45cd0458f038c9799aa17461cfb02d000a7aa54ac01e2088faa0073288761bdcce313662414e0157316c1240922345cc338e557fcfed4d7a7ba4&#39;).then(console.log)<br>{<br>transactionHash: &#39;0x7d610f3aa9c9276381fa9a936a748ab3cb137cd186b29ef7437065027de0c086&#39;,<br>transactionIndex: 0,<br>blockHash: &#39;0xfa2bb32b135e231a718faa8619bfa48b9a9a6f2a04606d115317a50bb80910ef&#39;,<br>blockNumber: 6,<br>from: &#39;0x0e3559cb03c0d26fef749acec13027319b95d334&#39;,<br>to: &#39;0xbeec86a83b265a7d7ccf534f021fe6b835ffd0d7&#39;,<br>gasUsed: 21000,<br>cumulativeGasUsed: 21000,<br>contractAddress: null,<br>logs: [],<br>status: true,<br>logsBloom: &#39;0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000&#39;<br>}</pre><p>Another risk is if someone gets a hold of the signature and tries to submit it again to replay the transaction. For these risks and more, Anchorage Digital is there to help! By holding assets in wallets with Anchorage, you see all available information about the transaction you are signing, can configure trusted destinations to ensure that the recipient of your transaction has been granted previous authorization, and are protected from your transactions being manipulated during processing or being replayed indefinitely. Anchorage Digital wants you to enter the world of Web3 and engage with these new decentralized applications confident that your assets are in good hands.</p><blockquote><em>New to trading? Try </em><a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a"><em>crypto trading bots</em></a><em> or </em><a href="https://medium.com/coinmonks/top-10-crypto-copy-trading-platforms-for-beginners-d0c37c7d698c"><em>copy trading</em></a><em> on </em><a href="https://medium.com/coinmonks/crypto-exchange-dd2f9d6f3769"><em>best crypto exchanges</em></a></blockquote><blockquote>Join Coinmonks<a href="https://t.me/coincodecap"> Telegram Channel</a> and<a href="https://www.youtube.com/c/coinmonks/videos"> Youtube Channel</a> get daily <a href="http://coincodecap.com/">Crypto News</a></blockquote><h3>Also, Read</h3><ul><li><a href="https://medium.com/coinmonks/free-crypto-signals-48b25e61a8da">Free Crypto Signals</a> | <a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a">Crypto Trading Bots</a></li><li>An ultimate guide to <a href="https://medium.com/coinmonks/leveraged-token-3f5257808b22">Leveraged Token</a></li><li><a href="https://medium.com/coinmonks/top-17-folding-electric-bikes-5e296f0918cb">16 Best Folding Electric Bikes</a></li><li><a href="https://medium.com/coinmonks/the-28-best-electric-bikes-review-and-buying-guide-in-2023-7bb3146cb403">28 Best Electric Bikes Review</a></li><li>Top 3 <a href="https://medium.com/coinmonks/top-3-binance-futures-trading-bots-e6031f84b3f9">Binance Futures Trading Bots</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eee1d7da5888" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/wallets-and-smart-contracts-eee1d7da5888">Wallets and Smart Contracts</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Declaration of Independence from Centralized Platforms — a Web3 Manifesto]]></title>
            <link>https://medium.com/the-modern-scientist/declaration-of-independence-from-centralized-platforms-a-web3-manifesto-93f4be57563f?source=rss-ea7611a809ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/93f4be57563f</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Colin Kraczkowsky]]></dc:creator>
            <pubDate>Sun, 08 Jan 2023 18:54:43 GMT</pubDate>
            <atom:updated>2023-01-17T19:36:46.181Z</atom:updated>
            <content:encoded><![CDATA[<h3>Declaration of Independence from Centralized Platforms — a Web3 Manifesto</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6X_ahAMSsJr6WQHgOtfo5A.png" /></figure><p>By the end of 2022 things seemed a little bleak in the blockchain industry. The year saw the collapse of many cryptocurrencies rendering many major players insolvent. It’s times like these where it’s important for me to remember why I work in this industry and to realign on what’s meaningful to me.</p><p>I believe that a large negative force in today’s world is rooted in detrimental economic models. Models that serve businesses at the expense of humans under the guise of being helpful. I believe that Web3 will create the opportunity to change these models and hopefully make the world a more peaceful, more creative, and more free place.</p><p>In some ways, this is my personal Web3 manifesto.</p><h4>Introduction</h4><p>This line of thinking, simmering in my unconscious mind, was reignited while listening to Sam Harris interview <a href="https://medium.com/u/2f1d573de33e">Cal Newport</a> who has spent the last ten years studying how information technology is changing us. While Newport’s research distinguishes between professional and personal sphere, he summarizes that in both spheres we are distracted and that this distraction is leading to issues. In the personal sphere those issues are:</p><ul><li>Issues of behavioral addiction</li><li>Engineered distraction</li><li>Attempts to maximize engagement which have unexpected consequences on health</li></ul><p>This all comes as a result of consolidating the internet to a small number of privately controlled, i.e. centralized, platforms trying to maximize engagement. Or, as Sam puts it, society is “unraveling based on the perverse business model that is mining our attention and amplifying divisive content.”</p><p>While listening to this interview something resonated in me; a signal that I felt that these guys were on to something. I related to the feelings of distraction and attention deficit that they were talking about, and I work in blockchain and Web3 so decentralization is always top of mind. It prompted me to understand a little better these “perverse” business models, the negative side effects of centralized platforms, and where Web3 can provide something different.</p><h4>What are these perverse Web2 business models?</h4><p>In today’s internet, or “Web2” as used colloquially by Web3 enthusiasts and the <a href="https://ethereum.org/en/developers/docs/web2-vs-web3/">Ethereum Foundation</a>, centralized platforms attract creators and consumers, enable creators to create or post their content for engagement with consumers, but ultimately the platform is the owner of that content. In the early days of the internet producing content and getting people to pay for that content was a working business model, however it was soon obvious that content production was a race to the bottom and platforms had to figure out other ways to generate revenue.</p><p>What they recognized was that as the owners of the content they could give it to consumers for free in return for something else: for other tokens of value like personal data and the consumer’s attention. The revenue to pay operating expenses instead could come from other businesses paying platforms because they believe that the platform will bring them business. Under this model, these businesses, not the creators nor the consumers, are the real customers. This creates a new incentive for platforms to maximize the consumer’s time spent on the platform to convince their corporate customers to spend money to be visible to these consumers. Platforms are now graded by how well they can take the creators’ content that they now own and get as many people to look at it to 1) prove to other businesses that people actually come to this platform and 2) direct as many of these people as possible to these businesses. The platforms have learned to achieve these metrics by acquiring as much content as possible and seeking content of the type that will get people on to the platform and to stay on the platform. This is the ad-based revenue model.</p><p>But owning the content isn’t enough to sustain this business model. Platforms needed to expand their reach into other aspects of the Web2 experience from the creators’ and consumers’ identities to their social interactions and even to the infrastructure powering the Web2 world.</p><h4>How are centralized platforms harming us today?</h4><p>There are a few health problems related to the business models of Web2.</p><p>The first problem of these business models: they thrive on the tendency for humans to have a short attention span and feed it with never ending shifts in focus. We know from Andrew Huberman’s podcast on <a href="https://hubermanlab.com/science-based-tools-for-increasing-happiness/">Science-Based Tools for Increasing Happiness</a> that we are more happy with increased focus. He quotes a paper titled <a href="https://www.science.org/doi/10.1126/science.1192439">A Wandering Mind Is an Unhappy Mind</a> whose study concluded that “the tendency for {the participant’s} mind to wander from an activity predicted lower levels of happiness than if they tended to be focused on the activity they were engaged in” and that “mind wandering was generally the cause and not merely the consequence of unhappiness.” In other words, shifts in focus, i.e. distraction, creates unhappiness. And, as we saw from above, Web2 depends on forced distraction. I specifically refer to this as “forced distraction” to differentiate it from natural distraction where our mind naturally shifts focus to things appearing in consciousness. In forced distraction, a third-party, e.g. a platform, decides where we focus next. And continued exposure to forced distraction perpetuates the destructive habit of shifting focus. Huberman summarizes that the paper “speaks to the tremendous power of building our ability to focus on what we are doing and to stay present to what we are doing.” The current business models of Web2 are incentivized to achieve neither. Today platforms are incentivized to hook consumers through constant shifts in focus and to keep them out of the present.</p><p>Additionally, centralized platforms perpetuate instant gratification. This is not good as <a href="https://medium.com/u/528e9a6004d8">James Clear</a> emphasizes in his book <em>Atomic Habits</em> when discussing hyperbolic discounting, i.e. the theory that the way that our brains evaluate rewards is inconsistent across time leading us to overvalue outcomes in the present. In other words, we believe that the reward that comes the quickest is the best and therefore we seek instant gratification. Clear notes that this pattern of behavior leads to self-destructive behaviors and poor outcomes like lower test scores, higher levels of substance abuse, heightened anxiety, worse social skills, etc. As discussed above, Web2 relies on forced distraction and its primary tool is instant gratification.</p><p>A third problem of the business models of Web2 is that it perpetuates easy access to an endless supply of purposefully divisive content. As discussed in the section above, Web2 is incentivized to get as many people on the platform as they can and to get them to stay on the platform. What it has to offer is content. And it is known that the type of content that brings the most eyeballs is divisive content. The type of content that is meant to trigger an emotional response from the consumer and is most likely to get them to interact.</p><p>Further, exposure to the problems of forced distraction, instant gratification, and easy access to unlimited divisive content is increasing. A <a href="https://www.pewresearch.org/internet/2022/08/10/teens-social-media-and-technology-2022/">survey run by Pew Research Center</a> of 1,316 U.S. teens from April 14 to May 4, 2022 found that “46% of teenagers report being online almost constantly” and that this is “up from only about a quarter (24%) of teenagers who said the same in 2014–15.” In the last seven years, nearly twice as many teens are constantly enmeshed in the business models of Web2.</p><h4>How is Web3 better?</h4><p>I believe that Web3 provides the opportunity to change the perverse business models causing the harm discussed in the section above. The primary reason being because it fundamentally alters the ownership structure. For creative businesses in Web3, creators are the owners of their own content. Their blogs or photos or designs or intellectual property are tokens on a blockchain that are merely read from their wallet and rendered to a platform. This means that at any point they can disconnect their wallet and take their content with them. The platform is incentivized to appease the creators and their role becomes to build the best tools for creators to produce content, to bring them readers who want to engage in what they’re creating, and to help build thriving communities. Failing to do this, the creators can take their content to a platform that does provide these features. This will force a change in business models because the customer has changed. Instead, the platform might provide the option for consumers to tip creators and take a small percentage of that tip. In that case, the business model is dependent on curating creators with tip-worthy content and attracting consumers who are more likely to be interested in this content.</p><p>This also unlocks new metrics. Rather than maximizing the number of eyeballs and the length of time they’re glued to the screen, platforms can seek to maximize engagement or participation or content quality.</p><p>As Web3 progresses there may even be a future where there is no need for a platform. If the creator owns their content and can make their content available to consumers globally by putting it directly on the blockchain, i.e. they no longer need platforms to host content on their databases, then the role of the platform changes. The value it provides instead is 1) to help creators produce content and 2) to get content in front of consumers. But is there a future where this second value-add is unnecessary? <a href="https://medium.com/u/f5a2e83d6d8f">Balaji S. Srinivasan</a> makes this case in his blog <a href="https://balajis.com/yes-you-may-need-a-blockchain/">Yes, You May Need a Blockchain</a> on the understanding that blockchains are “massively multiclient, open state databases”. This means that content can be <a href="https://en.wikipedia.org/wiki/Web_indexing">indexed</a> by anyone: indexing in this case means how people are able to find things spread across the millions of websites on Web2. Today, centralized platforms have total control over how content on their platform is indexed: they can make it exceptionally easy for Google Search to find your content or they can make it virtually impossible. In Web3, when everything is on the blockchain, tools can be built to index and surface anything on the blockchain; these tools are typically called “block explorers”. There may be a future where creators can upload their content to the blockchain, have it indexed and made discoverable, and connect directly with users without the need for an intermediary platform. In this future, there may be platforms or services to help creators to create but there is no platform playing for our attention.</p><h4>Why can’t we just quit centralized platforms?</h4><p>In the world of Web2, centralized platforms own everything from the infrastructure to the interactions.</p><p>Centralized platforms own the infrastructure of Web2. We saw a classic example of this at the end of 2022 when <a href="https://decrypt.co/116337/metamask-co-founder-dump-apple-ios-tax">Apple blocked Coinbase’s Wallet app</a> until it removed NFT transfer features or complied with their 30% in-app purchase tax. Existing platforms can force apps to change, block apps entirely, or in some cases take the app’s intellectual property because they own the machines, development tools, and distribution channels that the app needs to survive. While there have been cases where it’s been determined that these were the right decisions, the point is that the centralization of infrastructure has created a closed ecosystem of only a few players where these decisions are made by a ruling class and not by the many despite the fact that the latter is often the most affected by the decision. Whomever in the many would like to participate in a decision should have that ability; this is decentralization. There are interesting projects working to decentralize this infrastructure like <a href="https://ipfs.tech/">IPFS</a> to decentralize content storage, <a href="https://fleek.network/fleek-network.pdf?202212011428">Fleek Network</a> to decentralize content delivery, and <a href="https://www.alchemy.com/">Alchemy</a> for Web3 development tools. Industry analyst <a href="https://medium.com/u/6ea4a7e0c022">Ryan Selkis</a> seems to agree naming “Web3 Infrastructure” as a sector to watch in 2023 in his <a href="https://messari.io/crypto-theses-for-2023?__s=gxcitwxde720dwhbxpwg&amp;utm_source=drip&amp;utm_medium=email&amp;utm_campaign=An+investment+in+knowledge+pays+the+best+interest">Crypto Theses for 2023</a>.</p><p>Centralized platforms also own our social lives on Web2. Platforms like Facebook and Instagram and LinkedIn are built on social graphs, i.e. networks of people who we’re connected with who are connected to networks of other people. These social graphs include each connection that we make, every interaction that we have, all the content that we produce, each story that we share, all the reactions to our interactions, etc. What we do on these platforms and essentially the entire value of these platforms is based on this social graph, but at the end of the day you can’t take it with you. In Web3, we are seeing innovations like <a href="https://www.lens.xyz/">Lens Protocol</a> being built to change this; to make you the owner of your social life.</p><p>Further, centralized platforms own our identity in Web2. Think of the various tools, apps, or services that use “Sign in with Google” or “Log in with Facebook”. Under the hood, we’ve given the platform our names, our location, and sometimes our payment details to create an identity that they now own but represents our access to this platform and any service using this platform to prohibit access. This is not new information. We are aware that we have sold our most private information for the convenience of not having to remember a password or our credit card number. What was new information, to me at least, was that there is a better way. In Web3, we are seeing innovations like <a href="https://unstoppabledomains.com/">Unstoppable Domains</a> and <a href="https://login.xyz/">Sign In With Ethereum</a> (SIWE) providing this better way. With Unstoppable Domains, I can purchase a Web3 domain, e.g. ckraczkowsky.wallet, and ownership of that domain is transferred to my own Ethereum wallet as an NFT. This domain can be used as a destination for cryptocurrency transfers and provides a universal username allowing the holder to have a unique identity across the internet which can also be used as a login to Web3 through a service like Sign In With Ethereum. With SIWE, I can use my Ethereum wallet as my identity. Vitalik Buterin described the value in his blog, “It allows you to interact with a site without giving Google or Facebook access to your private information or the ability to take over or lock you out of your account.” Privacy is enhanced because the app doesn’t have default access to your name, address, or contact information unless you elect to provide that data. Buterin also describes a future where aspects of an individual can be independently verified and used for eligibility purposes without compromising users’ personal data. Think of how Ticketmaster could have used this in its Taylor Swift <a href="https://www.npr.org/2022/12/06/1140968805/taylor-swift-fans-ticketmaster-lawsuit">ticket presale debacle</a>; eligibility to ticket tiers could have been gated to wallets holding a special NFT representing the first thousand purchasers of the Mightnights album.</p><p>It is very difficult to quit centralized platforms because they are omnipresent. We access services using an identity that the platform owns and interact with other identities in a world that the platform owns. Even these services and worlds themselves are built on infrastructure that the platform owns. What may be the most powerful function of Web3 is that we can quit. At any point, we can disconnect our wallet and walk away with our identity, our contributions, and our connections. This alone fundamentally shifts the business models between Web2 and Web3. Because we can quit, individuals in Web3 are incentivized to build products that we enjoy using and want to continue to use. Or we quit.</p><h4>Conclusion</h4><p>The ultimate issue is that the centralized platforms are incentivized to hook our attention and keep it hooked for as long as possible regardless if the focus of our attention is worthwhile or healthy for us. But it’s hard to quit centralized platforms. They have become deeply embedded in modern life first by owning our networks, then by owning our identity to access these networks, and further by owning the infrastructure powering the apps we use to engage in these networks. Web3 offers the opportunity to change these business models and to redefine the incentives.</p><p>All of this is not to say that there won’t be unintended consequences from Web3, but we will have made headway in addressing the known destructive consequences of Web2 that Cal Newport attributes to our current business models. And it seems that the markets also see a beacon in Web3 since while the cryptocurrency side of the industry saw a lot of volatility towards the end of 2022, the <a href="https://www.coindesk.com/web3/2022/12/16/crypto-winter-isnt-chilling-vcs-from-investing-in-web3-says-pitchbook-analyst/">Web3 side saw an estimated $1.5 billion in investment</a> with predictions that this sector will see massive growth in the next five years.</p><p><em>Originally published on Mirror — </em><a href="https://mirror.xyz/dashboard/edit/MwpmsxtL3_Df6iCYJ9K9sAEV-trNcVs4X95lebCJ7Uc"><em>https://mirror.xyz/dashboard/edit/MwpmsxtL3_Df6iCYJ9K9sAEV-trNcVs4X95lebCJ7Uc</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93f4be57563f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-modern-scientist/declaration-of-independence-from-centralized-platforms-a-web3-manifesto-93f4be57563f">Declaration of Independence from Centralized Platforms — a Web3 Manifesto</a> was originally published in <a href="https://medium.com/the-modern-scientist">The Modern Scientist</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blockchain 101 — Understanding Gas Fees]]></title>
            <link>https://ckraczkowsky.medium.com/blockchain-101-understanding-gas-fees-343565116cb9?source=rss-ea7611a809ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/343565116cb9</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Colin Kraczkowsky]]></dc:creator>
            <pubDate>Fri, 08 Oct 2021 13:54:07 GMT</pubDate>
            <atom:updated>2021-10-08T14:03:21.845Z</atom:updated>
            <content:encoded><![CDATA[<h3>Blockchain 101 — Understanding Gas Fees</h3><h4>How gas fees work on blockchain networks and why they are important (with examples)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PD-n57_vFj2Qu8sbPdRmPg.jpeg" /></figure><p>On blockchain networks each node is incentivized to provide the processing power to add a new block to the chain by the promise of earning a reward. One such reward is a gas fee. A gas fee is paid per transaction in the network’s native currency by the blockchain address wishing to execute the transaction. Before we begin, I want to point out that as blockchain networks enter the mainstream it is easy to start viewing gas fees as a nuisance. We must keep in mind that they serve a very important purpose. First, gas fees help to pay for network security by rewarding the people keeping track of what is going on across the network. Without them, these people would be supporting the network at their own financial cost which would be unsustainable. Second, they incentivize people using the network to send transactions back and forth with purpose. If there was no personal investment in a transaction, it would be easy for anyone to spam the network with meaningless transactions threatening the stability of the network.</p><p>While the significance of gas fees should now be understood, the concept and how they work can seem convoluted especially when a transaction involves tokens that are not the native currency, e.g. ERC-20 tokens. To understand gas fees better, let’s look at some concrete examples.</p><p>We start by looking at gas fees for a transaction that directly interacts with the blockchain network. In this example, the blockchain will be Ethereum and the transaction is to deploy a smart contract containing a slimmed down ERC-20 token. To get a copy of this smart contract and to follow along, you can find the <a href="https://github.com/ckraczkowsky91/blockchain-essentials/blob/master/smart_contract_boilerplate.sol">source code</a> on my GitHub.</p><p>Our smart contract is written in the Solidity programming language, so we need to install a Solidity compiler to compile the file down into the necessary formats for deployment and execution.</p><pre>$ npm install -g solc</pre><p>To get the smart contract into a format readable by an Ethereum Virtual Machine (EVM), we first compile it down to bytecode which produces a .bin file. Next, so that other applications can interface with it, we compile the contract down to a binary interface which produces a .abi file.</p><pre>$ solcjs — bin smart_contract_boilerplate.sol<br>$ solcjs — abi smart_contract_boilerplate.sol</pre><p>We are ready to deploy our smart contract to the Ethereum blockchain. For the purposes of this example, we won’t deploy to the public blockchain. Instead, we spin up a local instance of Ethereum by opening up a terminal window then installing and launching a handy tool called Ganache. This will return a list of Ethereum addresses that we will use to send transactions.</p><pre>$ npm install -g ganache-cli</pre><pre>$ ganache-cli<br>Ganache CLI v6.12.2 (ganache-core: 2.13.2)</pre><pre>Available Accounts<br>==================<br>(0) 0x7Bb9a29cD5E4a88c8492AC18cd6d5Cf43aE6F63C (100 ETH)<br>(1) 0x9382422Ebc565CBdC9ec1f5A8e57147c114B3b5f (100 ETH)<br>(2) 0x52427A871d651741469c1B54E7897cea42a0a83F (100 ETH)<br>(3) 0x799F429f9C97573b5ad9Fb0D38a8e58dF0447569 (100 ETH)<br>(4) 0xB64085dF6cBF0236dC1768c7374a84470c495229 (100 ETH)<br>(5) 0xaE391A299Bd7CCa8d257f00978ea2422BE8b8fD0 (100 ETH)<br>(6) 0x1575Cbe396060f4F9085969E4993A1487c6c0364 (100 ETH)<br>(7) 0xa2A11Ec65234B57B7f14Ad28F06b486A48408893 (100 ETH)<br>(8) 0x506dE4A73e9BAd4fDBa3ce1fE43571F938247F50 (100 ETH)<br>(9) 0xEB3c794F04877fF2E5E21353d19cAE345d255ce1 (100 ETH)</pre><pre>Private Keys<br>==================<br>(0) 0xd5cc3503bdda975383f1bba1eb842e7da98a15c849c736c11d0cc0279c342067<br>(1) 0x9179bd1331132904063196a0b2e028627027ebe1f7769046cf4bbb4dd7bb1fca<br>(2) 0xbda163776ffe870178a10cc6f7ea00f7d98a101d9c636ff8cdc18a4d6d5b38d8<br>(3) 0xdc714e72b3aa8fc08074a069510cb228b615af3205fae6cd65e1227e4c9fa95f<br>(4) 0x3da26541d7517a06ccdbb2ad826ecac0fb767be571e869d065d9fe96d2ddbfd6<br>(5) 0xce6aa6e6f1e5b3e8951af81269f84521a66f7786410064cce2e65478589ddbde<br>(6) 0x9c8d09c9fe83d572c7d09180b22d4ee0a993308a1cd447d7ef67f918692149ee<br>(7) 0x52d56ba800c23a2455d6121cc9be313890961bab5a531fc4ff7161292ed00e34<br>(8) 0x7c8633bd2a48084757005f3cacb65f5bdf5739d9ad88ed8c64bafa78a3fbce6c<br>(9) 0xb45eccb005553904a4fac5530eb55e764d4f4b11c4b4e2e0cf3987e38f6dedbf</pre><pre>HD Wallet<br>==================<br>Mnemonic: crisp holiday club trap bridge cattle nominee stadium neck roof victory company</pre><pre>Base HD Path: m/44&#39;/60&#39;/0&#39;/0/{account_index}</pre><pre>Gas Price<br>==================<br>20000000000</pre><pre>Gas Limit<br>==================<br>6721975</pre><pre>Call Gas Limit<br>==================<br>9007199254740991</pre><pre>Listening on 127.0.0.1:8545</pre><p>Next, we need a way to interact with our local Ethereum blockchain. As I am most comfortable in a Node.js environment I chose to install and use the web3 library. Let’s open a new terminal window and launch a Node.js environment.</p><pre>$ npm install web3</pre><pre>$ node<br>var Web3 = require(‘web3’);</pre><pre>// point to the location of the host running our local Ethereum instance<br>const web3 = new Web3(‘<a href="http://127.0.0.1:8545/">http://127.0.0.1:8545</a>&#39;);</pre><pre>// verify that everything is working by grabbing the balance of one of the Ethereum addresses provided by Ganache<br>web3.eth.getBalance(‘0x7Bb9a29cD5E4a88c8492AC18cd6d5Cf43aE6F63C’).then(console.log); &gt; 100000000000000000000</pre><p>Now we are ready to deploy our smart contract. This deployment involves sending a transaction to the blockchain from an Ethereum address. Let’s use the address for which we got the balance in the previous step above.</p><pre>$ node<br>bytecode = fs.readFileSync(‘smart_contract_boilerplate_sol_BasicSmartContract.bin’).toString();</pre><pre>abi = JSON.parse(fs.readFileSync(‘smart_contract_boilerplate_sol_BasicSmartContract.abi’).toString());</pre><pre>var contract = new web3.eth.Contract(abi);</pre><pre>contract.deploy({data: bytecode}).send({from: ‘0x7Bb9a29cD5E4a88c8492AC18cd6d5Cf43aE6F63C’, gas: 1500000, gasPrice: web3.utils.toWei(‘0.00003’, ‘ether’)}).then((contractInstance) =&gt; { contract.options.address = contractInstance.options.address});</pre><p>The result of the deployment is a transaction being added to the mempool to eventually be included in a new block that will be added to the blockchain. Since we are using a local Ethereum blockchain, this new block will be added immediately. Back in the terminal window where Ganache is running, we can see this new block and the address of our freshly deployed smart contract.</p><pre>eth_sendTransaction</pre><pre>Transaction: 0x159d4dff8dee06a1836ac8ac767a53a200ed132dd9dd85363b6deb38c7620ce2<br>Contract created: 0x2a68bff8a231ed4dcad176bdfd2fdc5e648d2e0c<br>Gas usage: 168511<br>Block Number: 1<br>Block Time: Wed Sep 29 2021 10:34:24 GMT-0400 (Eastern Daylight Time)</pre><p>Back in the terminal running our Node.js environment, we see that the gas fee has been deducted from the address that sent the transaction.</p><pre>web3.eth.getBalance(‘0x7Bb9a29cD5E4a88c8492AC18cd6d5Cf43aE6F63C’).then(console.log);<br>&gt; 94944670000000000000</pre><p>In the deployment of our smart contract, we proposed a gasPrice of 30000000000000 Wei (0.00003 ETH) for the transaction. So we paid 0.00003 ETH per unit of gas and, as we can see in Ganache, the transaction used 168511 units of gas so the total price for the transaction was 5055330000000000000 Wei (5.05533 ETH) which was deducted for our sending address which is why we now see a balance of 94944670000000000000 Wei (94.94467 ETH) at that address.</p><p>Alright so we have seen how gas fees work for a transaction that directly interacts with the blockchain network. Next, we look at a transaction that interacts indirectly, e.g. when transacting with ERC-20 tokens like UNI, USDT, USDC, SUSHI, AAVE, OMG, ZRX, MKR, REP, GNT, LINK, LRC, etc. At their core, all ERC-20 tokens are smart contracts running on the Ethereum network; the 0x network has a good <a href="https://github.com/0xProject/0x-monorepo/blob/development/contracts/erc20/contracts/src/ERC20Token.sol">ERC-20 template</a> to understand how these tokens function.</p><p>So let’s say that I am Basecoin: an exchange for the purchase and sale of tokens. I have a user named Alice holding 100 USDC at Basecoin. Alice now wants to transfer 10 USDC to her account at Trinance, another exchange, perhaps because they can offer her a higher annual percentage yield (APY) for holding small amounts of USDC. When Alice issues that transfer, she will be charged ETH. Why is this so?</p><p>Under the covers, Alice has two addresses on the Ethereum network: 0x9382422Ebc565CBdC9ec1f5A8e57147c114B3b5f is her address at Basecoin and 0x52427A871d651741469c1B54E7897cea42a0a83F is her address at Trinance. Because USDC is an ERC-20 token managed by a smart contract, when we call the smart contract to retrieve the balance it recognizes that at address 0x9382422Ebc565CBdC9ec1f5A8e57147c114B3b5f there is a balance of 100 USDC. When Alice makes the transfer, she is sending a transaction to the Ethereum network calling that smart contract to deduct 10 USDC from her balance at her Basecoin address and to add 10 USDC to her Trinance address. Because this transaction will need to be included in a new block, it requires payment in ETH to perform which, as we saw above, is deducted from the ETH balance of the sending address. The price of that transaction is determined by how high a gas fee the caller contract is willing to pay (a higher gas fee results in quicker processing of the transaction, e.g. at time of writing <a href="https://ethgasstation.info/">ETH Gas Station</a> recommends 0.000000079 ETH to process a transaction in less than 2 minutes and 0.000000064 ETH to process it in under 30 minutes).</p><p>We can see this in action by returning to our deployed contract for our slimmed down ERC-20 token. As our smart contract is representative of the smart contract governing the USDC token, we’ll refer to this token as “pseudo-USDC”.</p><pre>// get ETH balance of Alice’s Basecoin address<br>web3.eth.getBalance(‘0x9382422Ebc565CBdC9ec1f5A8e57147c114B3b5f’).then(console.log);<br>&gt; 100000000000000000000</pre><pre>// get pseudo-USDC balance of Alice’s address at Basecoin<br>contract.methods.balanceOf(‘0x9382422Ebc565CBdC9ec1f5A8e57147c114B3b5f’).call().then(console.log);<br>&gt; 100</pre><pre>// get pseudo-USDC balance of Alice’s address at Trinance<br>contract.methods.balanceOf(‘0x52427A871d651741469c1B54E7897cea42a0a83F’).call().then(console.log);<br>&gt; 0</pre><pre>// transfer 10 tokens from Alice’s Basecoin address to her Trinance address<br>contract.methods.transfer(‘0x52427A871d651741469c1B54E7897cea42a0a83F’, 10).send({from:’0x9382422Ebc565CBdC9ec1f5A8e57147c114B3b5f’, gas:1500000, gasPrice:web3.utils.toWei(‘0.00003’, ‘ether’)});</pre><p>As discussed above, this transaction to change the balance at these two addresses adds a new block to the blockchain.</p><pre>Transaction: 0xc4ab359ce8334880a3764c01135d46c98055c539c06518b9787098c1a3e23f40<br>Gas usage: 37532<br>Block Number: 4<br>Block Time: Wed Sep 29 2021 13:10:54 GMT-0400 (Eastern Daylight Time)</pre><p>Let’s observe how this affected our ETH balance at Alice’s Basecoin address and her pseudo-USDC balances at her Basecoin and Trinance addresses.</p><pre>web3.eth.getBalance(‘0x9382422Ebc565CBdC9ec1f5A8e57147c114B3b5f’).then(console.log);<br>&gt; 98874040000000000000</pre><pre>contract.methods.balanceOf(‘0x9382422Ebc565CBdC9ec1f5A8e57147c114B3b5f’).call().then(console.log);<br>&gt; 90</pre><pre>contract.methods.balanceOf(‘0x52427A871d651741469c1B54E7897cea42a0a83F’).call().then(console.log);<br>&gt; 10</pre><p>As we can see, 1125960000000000000 Wei (1.12596 ETH) was deducted from Alice’s address at Basecoin such that her ETH balance at that address is now 98874040000000000000 Wei (98.87404 ETH). That amount was determined as a calculation of the 37532 units of gas that was used and the 30000000000000 Wei (0.00003 ETH) gasPrice that we were willing to pay which resulted in a total gas fee of 1125960000000000000 Wei (1.12596 ETH). In addition, her pseudo-USDC balance at that address has been deducted 10 pseudo-USDC and her balance at her address at Trinance has increased by 10 pseudo-USDC.</p><p>Having worked through this exercise, we should now understand more about the importance of gas fees for the security, sustainability, and validity of a blockchain network and how they are manifested by the network. We saw that gas fees are used to pay nodes to include our transactions in new blocks on the chain. These transactions may be direct interactions with the blockchain, e.g. deploying a smart contract, or indirect interactions, e.g. calling a smart contract to transfer tokens between addresses. In either case, the transaction is usually paid in the native currency of the blockchain, e.g. ETH on Ethereum, and the fee is deducted from the address sending the transaction.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=343565116cb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Provenance on the Blockchain]]></title>
            <link>https://ckraczkowsky.medium.com/creating-provenance-on-the-blockchain-63c8f4d47672?source=rss-ea7611a809ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/63c8f4d47672</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Colin Kraczkowsky]]></dc:creator>
            <pubDate>Mon, 18 Jan 2021 14:28:41 GMT</pubDate>
            <atom:updated>2021-01-22T15:40:03.347Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building an ERC-721 token on Ethereum with Solidity, Truffle, IPFS, and Pinata</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fsNxSQKlp3WYc8au" /></figure><p>Working in blockchain often requires one to explain amorphous concepts in a meaningful way. In my latest encounter with this challenge, I had to describe Non-Fungible Tokens (NFTs) to my 65+ year old mother. Having been a Product Manager in the tech industry, I am familiar with presenting complexities to individuals from a gambit of demographics and backgrounds. What I have found to be the most effective approach is to contextualize the concept to match the audience. In this case, my mother is a wonderful cook with an arsenal of recipes that span generations of our family. Today, these recipes are kept safe in a small, wooden chest stashed away in one of her various hiding places so that they remain “in the family.” Emotionally, these recipes are our family’s treasured possessions. Physically, they are a collection of data and a perfect vessel for establishing context for my mother to understand the wonderful world of NFTs.</p><p>The story I wove that day centered on the following question: What if you could store these recipes in perpetuity yet retain your ownership over them and even pass that ownership down as you see fit?</p><p>To illustrate the concept, I built and deployed a Non-Fungible Token based on the ERC-721 standard to the Ethereum blockchain using Solidity, Truffle, IPFS, and Pinata where my mother and I could see and interact with it using MetaMask.</p><p>To follow along, you can find the <a href="https://github.com/ckraczkowsky91/erc721-token-recipe">source code</a> on my GitHub.</p><h4>Creating our Non-Fungible Token</h4><p>As with most development projects, our first step is to set up our environment. So let’s open our terminal and run the following commands in a fresh window.</p><pre>$ mkdir erc721-token-recipe<br>$ cd erc721-token-recipe/<br>$ npm init -y</pre><p>We first create our project’s root directory. We then run npm init to create a package.json file and use the -y option to populate it with the default information.</p><pre>$ truffle init</pre><p>The truffle init command creates a variety of files and folders within our project necessary to use the tools provided by Truffle.</p><p>Now that we have set up the environment, we are ready to start writing the token! The token itself is a Solidity file that defines a smart contract, a core component of the Ethereum blockchain. Like the Internet, Ethereum is maintained and improved by a consortium of individuals. Improvements to the blockchain are submitted as proposals to undergo the <a href="https://eips.ethereum.org/all">Ethereum Improvement Proposals</a> (EIP) process. Under this process, changes to the standards governing smart contracts are submitted as an Ethereum Request for Comments (ERC). In 2018, <a href="https://eips.ethereum.org/EIPS/eip-721">ERC-721 Non-Fungible Token Standard Accepted</a> was created setting the standard for creating tokens on Ethereum of subjective value, e.g. a Holographic Charizard trading card != a Magikarp trading card, which built on the original ERC-20 standard that defined fungible tokens, e.g. 1 ETH = 1 ETH.</p><p>The specifics of ERC-721 tokens are defined in the standard. Rather than writing this ourselves, we will use OpenZeppelin who provides an implementation of the ERC-721 standard and adds security to ensure it is safe to use. Run the following installation in the root directory of our project.</p><pre>$ npm install @openzeppelin/contracts</pre><p>This command creates a new folder and installs all of the prebuilt contracts provided by OpenZeppelin. Let’s use this to build our NFT now.</p><pre>$ touch contracts/FamilyRecipe.sol</pre><p>In the FamilyRecipe.sol file, we define the smart contract.</p><pre>pragma solidity ^0.6.4;<br>import ‘@openzeppelin/contracts/token/ERC721/ERC721.sol’;<br>import ‘@openzeppelin/contracts/utils/Counters.sol’;</pre><pre>contract FamilyRecipe is ERC721{<br>  using Counters for Counters.Counter;<br>  Counters.Counter private _counter;<br>  mapping(string =&gt; uint8) public hashes;<br>  <br>  constructor() public ERC721(‘FamilyRecipe’, ‘REC’) {<br>  }<br>  <br>  function mintREC(address recipient, string memory hash, string memory metadata) public returns(uint256) {<br>    require(<br>      hashes[hash] != 1,<br>      “Hash has already been used!”<br>    );<br>    hashes[hash] = 1;<br>    _counter.increment();<br>    uint256 newRECId = _counter.current();<br>    _mint(recipient, newRECId);<br>    _setTokenURI(newRECId, metadata);<br>    return newRECId;<br>  }<br>}</pre><p>As you can see, we first import OpenZeppelin’s implementation of the ERC-721 token, aptly named ERC721, as well as another function that we will use later in our smart contract. We then define our contract instance naming it FamilyRecipe and use the is keyword provided by Solidity to declare it as an instance of ERC721 so that it will inherit the properties and methods of the standard.</p><p>We now define the functionality of our smart contract. We first include the Counters library within our contract. This library provides counters that can only be incremented or decremented by one to achieve a variety of use cases. We will use this functionality to issue IDs for our ERC-721 token. We include this library with the using keyword provided by Solidity. This keyword allows us to use a library within a contract.</p><pre>$ open node_modules/\@openzeppelin/contracts/utils/Counters.sol</pre><p>We can see by opening the Counters.sol file that Counters is indeed a library and it provides methods like current and increment which we will use later in our contract. Writing using Counters for Counters.Counter allows us to use any of the methods described in the Counters library on any value of type Counter within our FamilyRecipe contract. We do this in the proceeding line where we declare a private variable named _counter of type Counters.Counter which we will use to uniquely identify each of our tokens as they are minted. We then declare a public variable hashes of type mapping which will enable us to track that freshly minted tokens do not contain the same data as previously minted tokens.</p><p>Next, we add a constructor function for our FamilyRecipe contract. This function will run when our contract is deployed. Our contract inherits a constructor function from its ERC721 parent which we will repurpose for our contract. Let’s take a look at this function.</p><pre>$ open node_modules/\@openzeppelin/contracts/token/ERC721/ERC721.sol</pre><p>Opening the ERC721.sol file reveals its contents.</p><pre>...<br>constructor (string memory name_, string memory symbol_) public {<br>  _name = name_;<br>  _symbol = symbol_;<br>  _registerInterface(_INTERFACE_ID_ERC721);<br>  _registerInterface(_INTERFACE_ID_ERC721_METADATA);<br>  _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);<br>}<br>...</pre><p>The inherited constructor takes two string variables as arguments. These will be used as the name and symbol when viewing these with Ethereum clients like MetaMask. We pass ‘FamilyRecipe’ and ‘REC’ as arguments here.</p><p>Now it’s time to define a function to mint our REC tokens! There are a few pieces of information that we need to mint the token, so we add these as parameters to our mintREC function. A key property of Non-Fungible Tokens as indicated in the standard is that “each asset is distinct (non-fungible)…” We are going to ensure that every REC token represents a non-fungible asset using hashes. Hashes are created as a result of a hashing function which takes large amounts of data and condenses them into an alphanumeric string to represent that data. Any change to the underlying data will result in a different hash. We create a simple verification mechanism that requires that any hash passed to our minting function has not already been used by checking its value in the hashes mapping to 1. If the check passes, our function continues to process by assigning the hash a value of 1 in the hashes mapping so that it will revert the transaction if another REC token is attempted to be minted with that same hash.</p><p>Next, we assign the _counter property of our REC token a value using the increment method described above which will increment the _value property of the Counters library by one. We then create a new, local variable newRECId of type uint256 and assign it to the current value of the _value property using the current method also described above. We go about assigning the REC token an ID in this manner because the Counters library warns that the _value variable should never be accessed directly. Instead, we create a new instance of the Counter class, use the methods of that instance to increment _value, and assign our token an ID based on the value of that instance.</p><p>Next, we call the _mint method which our contract inherited from its ERC721 parent. Let’s take a look at this method.</p><p>$ open node_modules/\@openzeppelin/contracts/token/ERC721/ERC721.sol</p><p>Opening the ERC721.sol file reveals its contents.</p><pre>...<br>function _mint(address to, uint256 tokenId) internal virtual {<br>  require(to != address(0), “ERC721: mint to the zero address”);<br>  require(!_exists(tokenId), “ERC721: token already minted”);<br>  _beforeTokenTransfer(address(0), to, tokenId);<br>  _holderTokens[to].add(tokenId);<br>  _tokenOwners.set(tokenId, to);<br>  emit Transfer(address(0), to, tokenId);<br>}<br>...</pre><p>The result of this method call is the creation of a REC token by reassigning ownership of that token from the address(0), i.e. the genesis of the Ethereum blockchain for which it is assumed that nobody now or ever will have the private key, to the address of the recipient of that token including the token’s ID. The definition of this method includes a view requirements such as that the token isn’t being minted to address(0) which would effectively make the token unusable and that the ID of the token doesn’t match an existing token. To call the _mint method, we must pass the address of the recipient and the token’s ID as arguments.</p><p>After minting the token, we call the _setTokenURI method which our contract inherited from its ERC721 parent. Let’s also take a look at this method.</p><pre>$ open node_modules/\@openzeppelin/contracts/token/ERC721/ERC721.sol</pre><p>Opening the ERC721.sol file reveals its contents.</p><pre>...<br>function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {<br>  require(_exists(tokenId), “ERC721Metadata: URI set of nonexistent token”);<br>  _tokenURIs[tokenId] = _tokenURI;<br>}<br>...</pre><p>The result of this function is that our newly minted REC token is bound via its ID to the token’s metadata which asserts ownership and defines various properties.</p><p>And finally, if all requirements of our mintREC function are met, we are returned the ID of the new REC token which we can use to gather multitudes of data about that token. We will dive deeper into this in a later section.</p><h4>Deploying our Non-Fungible Token to the Ethereum blockchain</h4><p>At this point, we have a Solidity file containing our smart contract. Now, let’s put this contract to work! To do so, we need to get our contract on the blockchain. The blockchain that we will use is Ethereum. We can create a local instance of the Ethereum blockchain using the tools provided by Truffle.</p><p>The first step when deploying to the Ethereum blockchain is to compile our contracts down into the .abi and .bin files necessary for deployment. Truffle provides tools for us to do this, but first we are going to need to define our configuration needs. We will do so in the truffle-cofig.js file that was created when we initiated our Truffle project in the <strong>Creating our Non-Fungible Token </strong>section above. Replace the boilerplate code in that file with the following trimmed down code.</p><pre>module.exports = {<br>  networks: {<br>    development: {<br>      host: “127.0.0.1”,<br>      port: 9545,<br>      network_id: “*”,<br>    }<br>  },<br>  compilers: {<br>    solc: {<br>      version: “0.6.4”<br>    }<br>  }<br>};</pre><p>In the configuration above, we point Truffle to the correct blockchain instance which will be located at <a href="http://127.0.0.1:9545/">http://127.0.0.1:9545/</a> which is Truffle’s default port. We also define the version of the Solidity compiler with the version that we defined in our smart contract using the pragma keyword.</p><p>Truffle adds a step after compilation which they refer to as migration. The first migration that our application runs was predefined when we initiated our Truffle project and can be found in the migrations directory in the 1_initial_migration.js file. This deploys the Migrations contract that also came in the initialization of Truffle. To deploy our FamilyRecipe contract, we will need to add a second migration file.</p><pre>$ touch migrations/2_deploy_contracts.js</pre><p>Let’s add the directions for the migration to this new file.</p><pre>var FamilyRecipe = artifacts.require(‘FamilyRecipe’);<br>module.exports = function(deployer) {<br>  deployer.deploy(FamilyRecipe);<br>};</pre><p>Alright we are ready to deploy! Let’s first spin up a local instance of Ethereum using Truffle.</p><pre>$ truffle develop</pre><pre>Truffle Develop started at <a href="http://127.0.0.1:9545/">http://127.0.0.1:9545/</a><br>Accounts:<br>(0) 0x762fceb6848a20f118026fa4d63868a97381e575<br>(1) 0x726a3af4a354d3fa5246e6e9a767376d9c1a9971<br>(2) 0xb1e65a460863574d8971779ed416e209962e2135<br>(3) 0xd2fe247261350da249bdb21a2f63023f66204a50<br>(4) 0x0ec1e4a1041a05e1b6a896c1e354a98ed32eaca8<br>(5) 0xe03266378dbf4cc42d738d56d772796988e51f99<br>(6) 0x3a3734a9f15992b07c227e554ece641ef61a3a58<br>(7) 0x1eff998f196950a503762d6ed5d4cea9475026a5<br>(8) 0x90b398adc7dbd68c83de4fcbd676308e5c62ce6c<br>(9) 0xe3b5f3d0b3cf76aace406b7e269ed83ac63bd68f</pre><pre>Private Keys:<br>(0) c66b56212b0c19539f2d93aaeca2538578ad7f8e847cf7c6a043733614ebd3b4<br>(1) 37e9b79f9115c41f9bd100b6d791f130c61a52132ae2e47920432287a379c4d6<br>(2) 17168cf9944a9f36af688fe00f5e0f27b966e65b594d2d4ed4c3fff287690913<br>(3) 635dcc6b3130d29ccda99e0649f68a18e2076ddb0f074f79f5b787ee1c030c64<br>(4) 3bda71f106891ab04f170718c409f48c96c80b1c7a69ab06c66598f387d40f44<br>(5) f2a21eaa515294ee9c4b8276c829b531929adaf0913612dd6af4bbd47552a864<br>(6) 0ca58d43481dfafe60936f07d964f4a168e3a6b6334b929c9b082f8cb16b2317<br>(7) 19556056dfcade57602923452c1a4fed90e5270eebd67cabe4f87c9ab2ac4fe2<br>(8) bfe5ad396421add15e4ddd69630e19c7d0816cb05d9b8aade38c2932f25ef284<br>(9) 7ae79d9aa69e6ea2c1f1c1cc75489eb3025575d57471f8d6216f0bc89a3b7fc0</pre><pre>Mnemonic: awkward jump actress purity solid about number loud gossip intact cherry problem</pre><p>Now that we have a local instance of the Ethereum blockchain, we are ready to deploy our smart contract. We do so within the Truffle development console.</p><pre>truffle(develop)&gt; truffle compile<br>truffle(develop)&gt; truffle migrate</pre><pre>Compiling your contracts…<br>===========================<br>&gt; Everything is up to date, there is nothing to compile.</pre><pre>Starting migrations…<br>======================<br>&gt; Network name: ‘develop’<br>&gt; Network id: 5777<br>&gt; Block gas limit: 6721975 (0x6691b7)</pre><pre>1_initial_migration.js<br>======================<br>Replacing ‘Migrations’<br>— — — — — — — — — — —<br>&gt; transaction hash: 0x4fec9e3fe34d4fe7c6f356ea999d0942cc3ff70224d20224aea01f83b7e1a068<br>&gt; Blocks: 0 Seconds: 0<br>&gt; contract address: 0xe2fdE3f8265BEa9A019746Ea21B771fBa06EC10d<br>&gt; block number: 1<br>&gt; block timestamp: 1610664526<br>&gt; account: 0x762fCeb6848a20F118026Fa4D63868A97381E575<br>&gt; balance: 99.99615682<br>&gt; gas used: 192159 (0x2ee9f)<br>&gt; gas price: 20 gwei<br>&gt; value sent: 0 ETH<br>&gt; total cost: 0.00384318 ETH<br>&gt; Saving migration to chain.<br>&gt; Saving artifacts<br>— — — — — — — — — — — — — — — — — — -<br>&gt; Total cost: 0.00384318 ETH</pre><pre>2_deploy_contracts.js<br>=====================<br>Deploying ‘FamilyRecipe’<br>— — — — — — — — — — — —<br>&gt; transaction hash: 0x31aaaf53ed323bc6d4ae00f9030324f25837ada2d0239ec2d23226cd5064eac1<br>&gt; Blocks: 0 Seconds: 0<br>&gt; contract address: 0x5F0f4aa2D79b323fe1810c60349Ef069454688Dd<br>&gt; block number: 3<br>&gt; block timestamp: 1610664530<br>&gt; account: 0x762fCeb6848a20F118026Fa4D63868A97381E575<br>&gt; balance: 99.93938832<br>&gt; gas used: 2796087 (0x2aaa37)<br>&gt; gas price: 20 gwei<br>&gt; value sent: 0 ETH<br>&gt; total cost: 0.05592174 ETH<br>&gt; Saving migration to chain.<br>&gt; Saving artifacts<br>— — — — — — — — — — — — — — — — — — -<br>&gt; Total cost: 0.05592174 ETH</pre><pre>Summary<br>=======<br>&gt; Total deployments: 2<br>&gt; Final cost: 0.05976492 ETH</pre><p>Truffle will respond to a successful deployment with the information above. We can see that our account at address 0x762fCeb6848a20F118026Fa4D63868A97381E575 used 192,159 units of gas at 20 gwei per unit = 3,843,180 gwei which is how the subtotal came to 0.00384318 ETH. Likewise, our second migration used 2,796,087 in gas at 20 gwei per unit = 55,921,740 gwei or 0.05592174 ETH. In total, we spent 0.05976492 ETH to deploy our FamilyRecipe smart contract to the Ethereum blockchain which at a current trading price of 1 ETH = $1,197.28 USD means that the deployment cost $71.55 USD. On Ethereum’s mainnet, this gas price fluctuates significantly, e.g. on June 11, 2020 the minimum gas price was 0.00035 gwei while the maximum gas price was 508,034,850 gwei according to <a href="https://etherscan.io/chart/gasprice">Etherscan</a>, which is pushing many to devise ways to make blockchain development cheaper and keep the price more stable. What our purchase has bought us is essentially a digital mint capable of producing new REC tokens on demand.</p><p>Next, we will use our freshly deployed FamilyRecipe smart contract to mint a new REC token!</p><h4>Creating a digital asset and minting our Non-Fungible Token</h4><p>Let’s get to minting! Recall from our FamilyRecipe smart contract that we built in the <strong>Creating our Non-Fungible Token</strong> section above that the mintREC function requires three parameters.</p><pre>function mintREC(address recipient, string memory hash, string memory metadata) public returns(uint256) {<br>...<br>}</pre><p>The first parameter is a reference to the address of the individual who will receive the REC token. The second and third parameters are related to the content itself. Recall that what we are trying to achieve is to ascribe ownership to a digital asset. The second parameter represents that digital asset as a hash. The third parameter represents the metadata relevant to that digital asset and defines who is the owner.</p><p>We need somewhere to host our digital asset, in this case it’s my mother’s recipe for arguably the most delicious hermit cookies to ever come out of the oven. One benefit of the blockchain is that it is decentralized meaning that we are not deploying our application to a single server or a group of servers owned by a single entity. We can also apply this value system to our digital asset. Unfortunately, today, it is not economically viable to host something like a photograph on the blockchain. As we saw in the <strong>Deploying our Non-Fungible Token to the Ethereum blockchain</strong> section, deployments to the blockchain have a price. We paid 0.05976492 ETH ($71.55 USD) to deploy our smart contract which was only 879 Bytes (0.879 KB) in size. The size of the file containing our recipe is 430 KB in size. At the time of this writing, the average block size on the Ethereum blockchain was roughly 43,000 Bytes (43 KB) according to <a href="https://etherscan.io/chart/blocksize">Etherscan</a>. That means that it would take 10 blocks for us to store our recipe which means ten massive transactions which puts it well out of my price range. Luckily, there is another option for decentralized storage: a project called the <a href="https://ipfs.io/">InterPlanetary File System</a> (IPFS).</p><p>The simplest way that I have found to interact with IPFS is via a project called <a href="https://medium.com/u/3bf682b0b4e7">Pinata</a> which has built an API and toolkit. In order to use it, you will need to <a href="https://pinata.cloud/">create an account with Pinata</a>. After creating your account, you will need to generate an API Key after which Pinata will present you with a Pinata API Key, Pinata API Secret, and the JWT. Make sure to write down your Pinata API Key and Pinata API Secret as we will need them next!</p><p>Back in our project, we will build a small program that will upload our recipe to IPFS using the API provided by Pinata.</p><pre>$ mkdir utils<br>$ touch utils/uploadFile.js</pre><p>Let’s add the code for our program into the new uploadFile.js file.</p><pre>const pinataApiKey = &#39;{YOUR_API_KEY}&#39;;<br>const pinataApiSecret = &#39;{YOUR_API_SECRET}&#39;;<br>const axios = require(‘axios’);<br>const fs = require(‘fs’);<br>const FormData = require(‘form-data’);<br>var args = process.argv.slice(2);<br>var filePath = args[0];</pre><pre>const uploadFile = async () =&gt; {<br>  const url = ‘https://api.pinata.cloud/pinning/pinFileToIPFS&#39;;<br>  let data = new FormData();<br>  data.append(‘file’, fs.createReadStream(filePath));<br>  const res = await axios.post(url, data, {<br>    maxContentLength: ‘Infinity’,<br>    headers: {<br>      “Content-Type”: `multipart/form-data;<br>boundary=${data._boundary}`,<br>      pinata_api_key: pinataApiKey,<br>      pinata_secret_api_key: pinataApiSecret,<br>    },<br>  });<br>  console.log(res.data);<br>};</pre><pre>uploadFile();</pre><p>Our uploadFile program uses the axios REST client, so we need to install that.</p><pre>$ npm install axios</pre><p>Alright we are ready to point our program to the recipe and upload that to IPFS.</p><pre>$ node utils/uploadFile.js ./recipe.png</pre><p>If all is successful, Pinata will respond with a JSON object containing a hash from IPFS representing our file and a timestamp of when the file was uploaded.</p><pre>{<br>  IpfsHash: ‘QmfXZzR5LvqmBnAFNRR8nCKZGaHazMEr6BK4vd9xoSQ3nf’,<br>  PinSize: 429769,<br>  Timestamp: ‘2021–01–15T21:52:33.124Z’<br>}</pre><p>What’s really cool about this is that if we ran the same program again with our recipe file that the hash and the timestamp would be exactly the same because the underlying data is the same!</p><p>In addition to the API, Pinata has also built the “Pin Explorer” which provides a gateway to view files uploaded to IPFS. We can see the uploaded recipe here:</p><blockquote><a href="https://gateway.pinata.cloud/ipfs/QmfXZzR5LvqmBnAFNRR8nCKZGaHazMEr6BK4vd9xoSQ3nf">https://gateway.pinata.cloud/ipfs/QmfXZzR5LvqmBnAFNRR8nCKZGaHazMEr6BK4vd9xoSQ3nf</a></blockquote><p>Now that we have uploaded our digital asset to decentralized storage and generated a hash to uniquely represent it, we need to declare ownership over the asset. The ERC-721 standard achieves this via metadata, i.e. data that describes data. The standard requires that this metadata is a JSON file and made accessible via a URI. This ensures that the tokenURI method described by the standard enables anyone using Ethereum to interrogate the NFT for its name and for details about the asset which the token represents. Let’s create the JSON file for our asset now.</p><pre>$ touch recipe_metadata.json</pre><p>And populate the file.</p><pre>{<br>  “name”: “Family Hermit Recipe”,<br>  “hash”: “QmfXZzR5LvqmBnAFNRR8nCKZGaHazMEr6BK4vd9xoSQ3nf”,<br>  “cook”: “Mama”<br>}</pre><p>As this is a file, we are also going to upload this to IPFS via Pinata using our uploadFile program.</p><pre>$ node utils/uploadFile.js ./recipe_metadata.json</pre><p>Which should result in the creation of a new hash and timestamp.</p><pre>{<br>  IpfsHash: ‘QmTAXrF6y5k3jksmYAoSyS8oknNXyDhNBijj6djp7jBxAX’,<br>  PinSize: 123,<br>  Timestamp: ‘2021–01–17T16:08:55.446Z’<br>}</pre><p>Great, we now have all three parameters that we need to mint our first REC token! Let’s launch return to our Truffle development server and get going. First, we create new variables to store each parameter. We will grab a random address from Truffle to be the owner of the token.</p><pre>truffle(develop)&gt; recipient = ‘0xe3b5f3d0b3cf76aace406b7e269ed83ac63bd68f’;<br>truffle(develop)&gt; hash = ‘QmfXZzR5LvqmBnAFNRR8nCKZGaHazMEr6BK4vd9xoSQ3nf’;<br>truffle(develop)&gt; metadata = ‘ipfs://QmTAXrF6y5k3jksmYAoSyS8oknNXyDhNBijj6djp7jBxAX’;</pre><p>We check the balance of the receiving address which should be zero because we have not yet minted a REC token.</p><pre>truffle(develop)&gt; contract.methods.balanceOf(recipient).call(console.log);</pre><pre><strong>null</strong> 0</pre><p>Great, let’s get minting!</p><pre>truffle(develop)&gt; var tokenId;<br>truffle(develop)&gt; contract.methods.mintREC(recipient, hash, metadata).send({from:recipient,gas: 6721975,gasPrice: ‘30000000’}).then((res)=&gt;{tokenId=res.events.Transfer.returnValues.tokenId});</pre><p>We call our mintREC function providing the necessary parameters and dictating the terms of our transaction. We then store the ID of the newly minted token in a newly created tokenId variable.</p><p>Let’s check the balance of the receiving address which should now be 1 as we have a newly minted REC token.</p><pre>truffle(develop)&gt; contract.methods.balanceOf(recipient).call(console.log);</pre><pre><strong>null</strong> 1</pre><p>We can double-check this using the ownerOf method defined by the ERC-721 standard to find the owner of an NFT which should return the same address that we passed to our mintREC function via the recipient variable.</p><pre>truffle(develop)&gt; recipient</pre><pre>‘0xe3b5f3d0b3cf76aace406b7e269ed83ac63bd68f’</pre><pre>truffle(develop)&gt; contract.methods.ownerOf(tokenId).call(console.log);</pre><pre><strong>null</strong> 0xe3b5f3d0b3CF76AAce406b7e269Ed83aC63Bd68f</pre><p>So now we have verified ownership of the token. Let’s take a look at the asset that the token represents. We can do this using the tokenURI method mentioned earlier in this section.</p><pre>truffle(develop)&gt; contract.methods.tokenURI(tokenId).call(console.log);</pre><pre><strong>null</strong> ipfs://QmTAXrF6y5k3jksmYAoSyS8oknNXyDhNBijj6djp7jBxAX</pre><p>Cool! The final utility of NFTs that we will inspect is the transfer of ownership from one recipient to the next. This enables use cases like the sale of a digital asset or even something less transactional, more human like the passing down of a treasured amongst one another.</p><pre>truffle(develop)&gt; newRecipient = ‘0x90b398adc7dbd68c83de4fcbd676308e5c62ce6c’;<br>truffle(develop)&gt; contract.methods.safeTransferFrom(recipient, newRecipient, tokenId).send({from:recipient,gas: 6721975,gasPrice: ‘30000000’});<br>truffle(develop)&gt; contract.methods.ownerOf(tokenId).call(console.log);</pre><pre><strong>null</strong> 0x90B398AdC7dbd68c83de4fCBd676308e5c62CE6c</pre><pre>truffle(develop)&gt; contract.methods.balanceOf(recipient).call(console.log);</pre><pre><strong>null</strong> 0</pre><pre>truffle(develop)&gt; contract.methods.balanceOf(newRecipient).call(console.log);</pre><pre><strong>null</strong> 1</pre><p>Success, the person behind the address is the new owner of the REC token containing our recipe!</p><h4>What were we talking about, again?</h4><p>Hopefully at this point you are thinking, “Wow, this is pretty freaking cool!” But, if you are like me, you have also forgotten in all this excitement the most important aspect — why did we just build this thing?! Let’s launch back into orbit to reestablish the 30,000 foot view that we had 3,500 or so words ago. The goal was to explain the concept of Non-Fungible Tokens. In this case, I was explaining NFTs to my 65+ year old mother who loves to cook and cherishes tradition. To facilitate her understanding, I used things that she cared about to set the context. I built the REC token as a means to explain the foundational concepts of NFTs and the ERC-721 standard including non-fungibility, tokenization of a physical asset, as well as establishing and transferring ownership of that asset. By the end of our conversation, my mother had uploaded ten of her recipes to IPFS lording over her warchest of digital recipes and cackling as she watched her REC token count on MetaMask increase one by one. In her euphoria, she even transferred one of her favorite recipes, our family’s hermit cookie recipe, to me. So, like any millennial, I put it on blast to the Internet!</p><p>I am really excited about the future of Non-Fungible Tokens and their potential impact. Already innovators like <a href="https://medium.com/u/7f04ad9748f4">SuperRare</a>, <a href="https://medium.com/u/c8b1419b5d28">CryptoKitties</a>, <a href="https://medium.com/u/d2a18b7d79ed">Audius</a>, and <a href="https://medium.com/u/b7346f3882bb">OpenSea</a> are using NFTs to put control back into the hands of creators in markets like art, gaming, music, and collectibles. If you have read my other blogs, you know that I have a huge, squishy soft spot for blockchain and its applications to solve problems for small business owners including sole proprietors, the self-employed, solopreneurs, and other believers and participants of the passion economy. I believe that blockchain, and specifically Ethereum and smart contracts, will have a massive impact on key problems they face from <a href="https://medium.com/swlh/applying-blockchain-to-on-time-payment-collection-for-small-business-owners-e7eebd2b058e">on-time payment collection</a> to <a href="https://medium.com/swlh/applying-blockchain-to-the-external-financing-needs-of-small-business-owners-6fb0e0423ff1">access to lending</a>. I see NFTs helping to solve a suite of other challenges from intellectual property ownership to tokenization of assets that aren’t represented in the current financial system!</p><blockquote><strong>Note:</strong> As an example of the benefits of NFTs for intellectual property ownership, an article from <a href="https://medium.com/u/f2fa6f2d51a6">CoinDesk</a> reports <a href="https://www.coindesk.com/bitcoin-org-rebuts-craig-wrights-meritless-copyright-claim-on-bitcoin-white-paper?utm_source=Sailthru&amp;utm_medium=email&amp;utm_campaign=BITES%20%E2%80%93%20JAN%2021%2C%202021&amp;utm_term=Blockchain%20Bites">an individual’s attempt to claim copy right ownership over the Bitcoin white paper</a>. This white paper was published anonymously in 2008 by an individual under the pseudonym “Satoshi Nakamoto” whose true identity remains unknown although the individual’s public key is known. Had the Bitcoin white paper been published as an NFT complete with the author’s information and a timestamp, ownership would be clear and verifiable. Although, there is a good debate to be had over whether this is antithetical to the value system behind Bitcoin.</blockquote><p>Understanding these technologies is fundamental to seeing their impact, and sharing that knowledge is fundamental to universal adoption of these technologies and achievement of that vision. There are many outlets to staying updated on what is becoming known as the “NFT Revolution” including from sources like <a href="https://decrypt.co/collections/nfts">Decrypt</a>. I hope that this blog helped you to understand NFTs a bit better and gave you a tool to spread that knowledge!</p><p>If you know someone who you would like to share the knowledge of Non-Fungible Tokens, clone the <a href="https://github.com/ckraczkowsky91/erc721-token-recipe">source code</a> from my GitHub of the token that we built throughout this blog and run it on your local machine.</p><h4>About the author</h4><p>Colin Kraczkowsky is passionate about building solutions that solve people’s problems and loves to learn and share his thoughts on new technologies. His latest interest is in blockchain, specifically Ethereum development, and its applications to solving problems for small businesses including sole proprietors, the self-employed, and solopreneurs. Colin’s professional history includes working in both enterprise and startup environments to code web and mobile applications, launch new products, build mockups and prototypes, analyze metrics, and continuously innovate.</p><p>In his spare time, Colin can be found checking out an REI camp bundle for a weekend away in the woods, field testing the latest HOKAs, hunting fresh powder on the mountain, or surfing the Horror section on Netflix.</p><p>Connect with Colin — <a href="https://www.linkedin.com/in/colinkraczkowsky">https://www.linkedin.com/in/colinkraczkowsky</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63c8f4d47672" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Applying Blockchain to the External Financing Needs of Small Business Owners]]></title>
            <link>https://medium.com/swlh/applying-blockchain-to-the-external-financing-needs-of-small-business-owners-6fb0e0423ff1?source=rss-ea7611a809ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fb0e0423ff1</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[small-business]]></category>
            <category><![CDATA[loans]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Colin Kraczkowsky]]></dc:creator>
            <pubDate>Sat, 05 Dec 2020 00:34:53 GMT</pubDate>
            <atom:updated>2020-12-06T18:01:22.776Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building integrated smart contracts on Ethereum with web3.js, Node.js, and Ganache</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vj7j-aadPX4lPyNg" /></figure><p>Small business owners from sole proprietors to solopreneurs find it difficult to get external financing: from loans for growing their business to mortgages for purchasing a house. Driving this need for external financing is the fact that it takes two to three years, on average, for a small business to turn a profit. A survey of small business owners run by the National Federation of Independent Business (NFIB) in September 2020 found that <a href="https://www.nfib.com/surveys/small-business-economic-trends/"><strong>1% of small business owners report that external financing is their top business problem</strong></a> with 2% reporting that their last loan was harder to obtain than previously. Investment firm Biz2Credit confirms this reporting that <a href="https://www.biz2credit.com/small-business-lending-index/august-2020">big banks granted only 13.6% of loan applications</a> in August 2020 down from 13.8% in July.</p><p>In the last half of 2018, the Small Business Credit Survey, a national collaboration of the 12 Federal Reserve Banks, ran a survey of 6,614 small business owners to gather data to better understand their financing needs; the results were published in the <a href="https://www.fedsmallbusiness.org/medialibrary/fedsmallbusiness/files/2019/sbcs-employer-firms-report.pdf"><em>2019 Report on Employer Firms</em></a>. According to this report, 43% of respondents had applied for external financing that year. The reason? Most respondents sought external financing to expand their business by pursuing new opportunities or acquiring business assets and/or to meet operating expenses. Most small business owners regularly use loans and lines of credit as their source of external financing, so it comes as no surprise that 85% of respondents that applied for external financing applied for a loan or a line of credit.</p><blockquote><strong>Note: </strong>Loans and lines of credit are two different ways to borrow from lenders. A loan gives the borrower one-time access to only the amount loaned on which the borrower subsequently makes principal and interest payments until the amount loaned is paid off. Conversely, a line of credit gives the borrower a set credit limit which they can access repeatedly while making regular payments composed of both principal and interest.</blockquote><p>When seeking a loan or line of credit, small business owners have multiple options for both the type of financing as well as the lender providing that financing. The most popular type of external financing that small business owners pursued were business loans followed by business lines of credit followed by SBA loans/lines of credit. When it comes to lenders, 49% of small business owners applied at a large bank, 44% at a small bank, and 32% applied to an online lender according to the <em>2019 Report on Employer Firms</em>. On average, the monetary amount of funding that small businesses seek is relatively low. According to Raddon, a financial research and analysis subsidiary of Fiserv, 95% of small businesses seek loans of less than $250,000 and the average loan amount sought is $75,000. Yet despite the high demand for business loans and the low amount of funding sought, only 67% of applications were approved. Small business owners had better luck with business lines of credit where 73% of applications were approved and even worse luck with SBA loans/lines of credit with an acceptance rate of only 52%. In total, the <em>2019 Report on Employer Firms</em> found that <strong>only 47% of respondents that applied for external financing received the total amount that they sought</strong>.</p><p>Why is it that over half of the small business owners looking for financing experienced a “shortfall”, i.e. they obtained less funding than they sought. One could first look for answers from the lenders. What one would find is that overall most banks, especially big banks, have reduced their small business lending activity since 2006. According to the 2018 report <em>How Did Bank Lending to Small Business in the United States Fare After the Financial Crisis?</em> published by the U.S. Small Business Administration, small business lending from banks grew by 5% per year from 2009–2011 before <a href="https://www.sba.gov/sites/default/files/439-How-Did-Bank-Lending-to-Small-Business-Fare.pdf">growth dropped to less than 4% per year from 2012–2015</a>.</p><p>After scrutinizing the lenders, one could then look for answers in the process for getting a loan. According to industry experts from The Balance Small Business, Fundbox, and Entrepreneur common reasons that loan applications from small business owners are rejected include insufficient collateral or lacking the right type of collateral, low credit score or lack of credit history, already carrying a lot of debt, and inadequate cash flow. According to the <em>2019 Report on Employer Firms</em> these are also some of the same reasons that small business owners didn’t receive all of the funding they wanted.</p><blockquote><strong>Note: </strong>In fact, 61% of small businesses around the world struggle with cash flow issues. Among these issues, many business owners rank collecting payment quickly and accurately as their number one challenge. In a separate blog, I investigate <a href="https://medium.com/swlh/applying-blockchain-to-on-time-payment-collection-for-small-business-owners-e7eebd2b058e">how small business owners can leverage blockchain technology to approach cash flow issues</a> and avoid becoming one of the 50% of SMBs that close within five years of opening.</blockquote><p>In addition, Fundbox reports that one of the most common reasons small business loan applications are denied is that the applicant didn’t complete the application correctly, e.g. they didn’t include supporting documents like a business plan or they made a clerical error like inputting the wrong four-digit Standard Industrial Classification (SIC) code used to classify the industry the business is in, which isn’t surprising given that business owners often spend 20+ hours on a loan application.</p><p>Even after factoring in those who did not experience a shortfall, the majority of small business owners who applied for financing from big banks and online lenders reported challenges in the process. For big banks, the greatest challenges reported were the long wait to receive a decision and the difficulty of the application process. According to a survey conducted in 2019 of 1,000 small business owners and published in Small Business Trends, <a href="https://smallbiztrends.com/2019/06/how-long-does-it-take-to-get-a-business-loan.html">16.3% of respondents reported waiting at least a month to hear back about a loan application</a> while 7.5% reported waiting over six months. For online lenders, the greatest challenge reported was the high interest rates. According to Nav, a traditional bank loan the annual interest rate for a traditional bank loan ranges between 2% to 13% while <a href="https://www.nav.com/blog/what-is-the-average-business-loan-interest-rate-37650/">the rate on a loan from an online lender can range from 7% to 100%</a>.</p><p>There are clear problems inhibiting small business owners from getting external financing to pay for their various expenses. Their preferred lenders are approving fewer applications. The requirements to get an application approved are getting stricter. And the applications themselves are time-consuming and convoluted. There must be a solution to this problem. I believe that blockchain, and particularly smart contracts on the Ethereum blockchain, can provide such a solution.</p><h4>Applying blockchain to this problem</h4><p><em>Blockchain is quick and simple.</em> The Ethereum blockchain is founded on the core technology of “smart contracts”. <a href="https://medium.com/swlh/applying-blockchain-to-on-time-payment-collection-for-small-business-owners-e7eebd2b058e">Smart contracts are a collection of data and logic that can be securely deployed to a blockchain network</a> using cryptographically signed transactions. Conceptually this means that loan regulations could be added to smart contracts. Once the smart contract is filled, the borrower can publish it quickly and as funds start coming in they will be immediately accessible in their account. This digitalization of contracts in a secure environment enables lenders to validate transactions, verify legitimacy of the parties, and perform all loan administrative tasks in a fraction of the time as the traditional lending process. In addition, as described in the above, business owners often spend 20+ hours on a loan application yet many of these applications are denied because the application was not completed correctly. This alludes to complexity in the application process. Blockchain is a digital native technology benefiting from the simplicity that digital interfaces and processes provide. The developer of a smart contract can build and tailor a user experience that is intuitive and easy. Smart contracts have the potential to greatly accelerate the lending process which would lead to an additional benefit: reduced costs.</p><p><em>Blockchain is cost efficient.</em> In the traditional lending process, people require intermediaries like a loan officer, bank, underwriter, and loan processor to build the trust to provide financing. Each of these entities are subject to regulations. Each additional intermediary and regulation in the lending process increases the fee the borrower has to pay. Blockchain could reduce these costs through time efficiencies and by allowing the borrowers to deal directly with lenders.</p><p><em>Blockchain provides transparency.</em> A major factor in the problems with the traditional lending process is information asymmetry. Banks don’t want to approve a loan from an applicant with whom they have no previous relationship and for whom they can not be comfortably sure will repay the loan. Blockchain helps to establish this trust, or, from some perspectives, removes this need for trust altogether. One core component of blockchain is “distributed ledger technology” which enables all computers within the blockchain network to have the same copy of all transactions that are taking place on that blockchain where they are separately verified and protected by a consensus mechanism.This ensures that all transactions are immutable and that any alteration on the data within the blockchain is documented. Each transaction is time-stamped and includes the encrypted signature of the executor of the transaction for all participants of the blockchain to see. For lending markets, this enables information symmetry between borrowers and lenders. Borrowers can feel secure that the financing they are receiving is not at risk of being rescinded because the funds have already been spent multiple times. Lenders can see the borrowers transaction history to gauge the likelihood that they will be repaid.</p><p><em>Blockchain is borderless.</em> This greatly increases the scope of blockchain. For lending markets, the current fiat system introduces challenges to procuring a loan. One challenge is time complexity. It takes time to wire money internationally getting it from the lender’s account into the borrower’s account. Many sources estimate that the wire could arrive anywhere between one and five business days. The first step is to initiate the international wire transfer at which point the funds are deducted from the sender’s account. Instructions for the transfer are then normally moved through the Society for Worldwide Interbank Financial Telecommunication (SWIFT) network, a network of over 10,000 banks and financial institutions in more than 200 countries, passing through various intermediary banks before finally landing at the recipient’s bank which then has its own processing delays. Often this processing is to avoid fraudulent transactions; refer to the paragraph above to see how blockchain can mitigate fraud. Once this money gets to the recipient’s account it very likely will need to go through further processing via an exchange into the local currency of the receiving party. This also takes time and typically incurs a fee at whatever is the current exchange rate. Compounding this is that different countries offer different lending interest rates. According to the World Bank the average interest rate for credit in 2019 was 19.82% in Ukraine, 67.26% in Argentina, 9.56% in Bangladesh, and 5.28% in the United States. Blockchain opens the opportunity for anyone around the world to get a loan in a reasonable time under a global interest rate and anyone, anywhere can contribute.</p><p>Now that we have developed a shared understanding of some of the ways in which blockchain can improve the lending process, let’s get to building something on the blockchain! We will build out solutions for the Ethereum blockchain where we can deploy smart contracts. The smart contracts will be written in the Solidity programming language. We will not be deploying to the production Ethereum blockchain. Instead, we will deploy to Ganache which created an instance of the Ethereum block on our local machine. The solution that we will build will enable a borrower to post a request for a loan that is backed by collateral in the form of a crypto asset. Any lender can then browse that request and choose to fund it. The borrower will then have access to that funding, and the lender will eventually be paid out the amount promised by the borrower. To achieve this, we will build two smart contracts: one to represent the loan request which will receive the funding and distribute the return and a second to represent the collateral backing the loan request.</p><p>To follow along, you can find the <a href="https://github.com/ckraczkowsky91/smb-loan-platform-ethereum">source code</a> on my GitHub.</p><h4>Building a smart contract on the Ethereum blockchain to represent a loan request</h4><p>I go over <a href="https://medium.com/swlh/applying-blockchain-to-on-time-payment-collection-for-small-business-owners-e7eebd2b058e">the basics of writing smart contracts</a> in a separate blog, so in this blog I dive right into the specifics of the code. To start, we set up our project and create a Solidity source file.</p><pre>$ mkdir smb-loan-platform-ethereum<br>$ cd smb-loan-platform-ethereum/<br>$ echo “{ \”name\”: \”smb-loan-platform-ethereum\”, \”version\”: \”1.0.0\”, \”description\”: \”A decentralized application (dapp) containing a smart contract deployed to the Ethereum blockchain via Alchemy.\” }” &gt;&gt; package.json<br>$ touch LoanPlatform.sol</pre><p>The LoanPlatform.sol file is going to hold the two smart contracts that we build in this blog.</p><p>Within the LoanPlatform.sol file, we write the contents of our smart contracts. The first part in our blockchain-enabled lending process requires the borrower to post a smart contract describing the requested loan amount, the amount that the lender will receive in return for funding this loan, and the amount of time that the borrower has to pay down this loan, i.e. four months from the deployment of the contract.</p><pre>contract SmartLoan {<br>  uint public loanAmount;<br>  uint public payableAmount;<br>  uint public timePeriod;<br>  address payable public borrower;<br>  uint public contractStart;<br>  <br>  constructor(uint _loanAmount, uint _payableAmount, uint _timePeriod) public {<br>    loanAmount = _loanAmount;<br>    payableAmount = _payableAmount;<br>    timePeriod = _timePeriod;<br>    contractStart = 0;<br>    borrower = msg.sender;<br>  }<br>...<br>}</pre><p>A contract is a special concept in Solidity that acts similarly to a class in an object-oriented programming language like JavaScript. Like a class, construction is the first stage in the lifecycle of a contract and likewise contains a constructor function. We use this function to initialize the variables that we defined earlier in the contract. Upon creation of a new instance of SmartLoan the smart contract expects to be provided a loanAmount, a payableAmount, and a timePeriod, which should be expressed in months. We create a variable to represent the start of the contract and initialize it to 0 as we do not want the clock to start until the lender sends the requested loan amount to the contract. Finally, we grab the address of the individual initiating the smart contract. These variables then get persisted by the smart contract in public variables accessible via the Ethereum blockchain for all parties to see.</p><h4>Building a smart contract on the Ethereum blockchain to hold collateral backing a loan request</h4><p>Now that we have enabled the borrower to create an instance of the SmartLoan smart contract to post a request for external financing, we assemble a mechanism for them to back this loan with some collateral. We achieve this through a second smart contract that will get its own address on the blockchain and be able to manage its value separately from that of the loan. In this step of the process, the borrower deploys the second smart contract and transfers into it the value of the collateral backing the loan. The collateral is in the form of a crypto asset that is untouchable by the borrower for a period of time if they don’t get the necessary money by the requested time.</p><pre>contract BorrowerCollateral {<br>  uint public collateralAmount;<br>  SmartLoan public loan;</pre><pre>  fallback() payable external {<br>    collateralAmount = msg.value;<br>  }</pre><pre>  function withdrawCollateral(address payable loanAddress) external {<br>    loan = SmartLoan(loanAddress);<br>    if(loan.contractStart() == 0){<br>      require(<br>        msg.sender == loan.borrower(),<br>        ‘REVERT: Only the borrower can withdraw the collateral before the contract starts!’<br>      );<br>      collateralAmount = 0;<br>      msg.sender.transfer(address(this).balance);<br>    } else if(block.timestamp &lt; loan.contractEnd()){<br>      require(<br>        loan.amountPaid() == true,<br>        ‘REVERT: Collateral can\’t be withdrawn until the payment is made!’<br>      );<br>      require(<br>        msg.sender == loan.borrower(),<br>        ‘REVERT: Only the borrower can withdraw the collateral before the contract ends!’<br>      );<br>      collateralAmount = 0;<br>      msg.sender.transfer(address(this).balance);<br>    } else {<br>      require(<br>        msg.sender == loan.lender(),<br>        ‘Payment is late; collateral forfeited to lender.’<br>      );<br>      collateralAmount = 0;<br>      msg.sender.transfer(address(this).balance);<br>    }<br>  }<br>}</pre><p>In our BorrowerCollateral smart contract we utilize the fallback() payable mechanism of Solidity to capture any payments made to this contract’s address. We then define a withdrawCollateral function to hold the somewhat complicated logic for how this smart contract will handle withdrawals. This function expects to be provided the address of an instance of a SmartLoan smart contract which we will use to reference that contract. The first clause in our if statement is to handle the requirement that only the borrower can withdraw the collateral before the contract starts. To achieve this, we use the reference to the contractStart variable in our instance of SmartLoan which, recall from above, we initialize to 0 when the smart contract is created but before it has received funding. In this case, an attempt from anyone other than borrower to withdraw the collateral will be reverted by the Ethereum Virtual Machine (EVM). The next clause is to handle the requirement that the collateral can only be withdrawn by borrower either once the contract has ended or once they have paid the amount promised. To achieve this, we compare the current block timestamp with the end of the duration of the loan which we get from SmartLoan. Any attempts to withdraw the collateral in this case will be reverted first if the loan has not yet been paid off, the transaction will be reverted and second if the request is being made by anyone other than by borrower. If the payment has been made then borrower will be able to withdraw the full amount stored in the smart contract using the transfer method provided by Solidity to send Ether, in units of wei, to the calling address. The else statement represents our final clause to handle the requirement that if the borrower defaults on the loan, i.e. doesn’t pay the lender the amount promised by the end of the contract, then the collateral is forfeited to lender. We achieve this by reverting all calls to our withdrawCollateral function unless they are made by lender which we get from SmartLoan. Next, the borrower posts BorrowerCollateral and transfers the collateral amount to the newly created address.</p><p>Once the collateral has been funded, the borrower adds the collateral to their loan so that all information is contained within the loan.</p><pre>contract SmartLoan {<br>  BorrowerCollateral public collateral;<br>  uint public collateralAmount;<br>...<br>  function addCollateral(address payable collateralAddress) public returns(uint) {<br>    collateral = BorrowerCollateral(collateralAddress);<br>    collateralAmount = collateral.collateralAmount();<br>  }<br>...<br>}</pre><p>To achieve this, we add a new addCollateral function to SmartLoan which accepts an address as a parameter. This address should be the address of an instance of BorrowerCollateral which we built above. We then create a new variable of the BorrowerCollateral type passing it the collected address to give us a reference to that specific instance. Finally, we use that reference to get the value of the collateral and store it in SmartLoan as the new collateralAmount variable.</p><h4>Receiving funding for our loan on the Ethereum blockchain</h4><p>In the next step of our lending process, a potential lender reviews the details of the deployed instance of SmartLoan and assesses the requested loan amount, the amount that they will receive in return, and the collateral attached to the loan request to decide whether or not to fund the loan.</p><pre>contract SmartLoan {<br>  uint public contractEnd;<br>...<br>  fallback() payable external {<br>    require(<br>      msg.value == loanAmount,<br>      ‘REVERT: Contribution should be the requested amount.’<br>    );<br>    lender = msg.sender;<br>    contractStart = block.timestamp;<br>    uint timePeriodUnix = timePeriod * 60 * 60 * 24 * 30;<br>    contractEnd = contractStart + timePeriodUnix;<br>  }<br>...<br>}</pre><p>Again we use the fallback() payable mechanism of Solidity to capture a payment from a lender. In the first line of this function, we insert a require function, a.k.a. a “convenience function”, provided by Solidity to assert that the payment made by the lender is the amount requested by the loan. Otherwise the transaction will be reverted. We then capture the address of the lender and store it in the lender variable for later use. We also start the clock on the loan now that it has received funding. Since the payment from lender will add a new block to the blockchain, we can access and store the timestamp of this block using block.timestamp which will reference the timestamp of the block that this transaction was included in as seconds since the Unix epoch, i.e. the time elapsed since 00:00:00 UTC January 1, 1970. That will represent the start of the contract. We now need to calculate the end of the contract. Recall from the <strong>Building a smart contract on the Ethereum blockchain to represent a loan request</strong> that we defined a timePeriod as a part of the construction of this smart contract to store the duration of the loan in months. As block.timestamp is returned in seconds, we perform a simple calculation to determine contractEnd as a function of timePeriod after that timestamp. For the purposes of this simple example, we are assuming that there are a standard 30 days per month. Now lender, contractStart, and contractEnd are persisted by the smart contract in public variables accessible via the Ethereum blockchain for all parties to see.</p><h4>Managing the lifecycle of the loan</h4><p>At this point in the lifecycle of our loan on the Ethereum blockchain, a borrower has posted a smart contract requesting financing for a loan as well as backed that request with collateral and a lender has been able to fund the loan. Now, we need to account for the various scenarios that could arise throughout that lifecycle until it terminates at the payment of the loan. For example, the borrower should be able to withdraw the financing at which point neither they nor the lender should have access to the collateral. In addition, the borrower should be able to repay the loan at which point the collateral should be available for them to reclaim. We implement these scenarios by coding additional functions and requirements into our smart contract.</p><pre>contract SmartLoan {<br>  bool public loanAmountWithdrawn = false;<br>  bool public amountPaid = false;<br>...<br>  function withdrawLoanAmount() payable external {<br>    if(!loanAmountWithdrawn) {<br>      require(<br>        msg.sender == borrower,<br>        ‘REVERT: Only the borrower can withdraw the loan amount!’<br>    );<br>      msg.sender.transfer(loanAmount);<br>      loanAmountWithdrawn = true;<br>    } else {<br>      revert(‘REVERT: Loan amount already withdrawn!’);<br>    };<br>  }<br>  <br>  function makeBorrowerPayment() payable external {<br>    require(<br>      msg.value == payableAmount,<br>      ‘REVERT: The payment should be the total amount payable!’<br>    );<br>    borrowerPayment = msg.value;<br>    amountPaid = true;<br>  }</pre><pre>  function withdrawBorrowerPayment() external {<br>    require(<br>      lender != address(0),<br>      ‘REVERT: Contract has not started, lender does not exist!’<br>    );<br>    require(<br>      msg.sender == lender,<br>     ‘REVERT: Only the lender can withdraw the payment!’<br>    );<br>    msg.sender.transfer(borrowerPayment);<br>  }<br>...<br>}</pre><p>We first enable the borrower to withdraw the financing by adding a withdrawLoanAmount function. This should only occur once, so we create the loanAmountWithdrawn variable of type bool to check for this. If the financing has not yet been withdrawn, we next check that the transfer request is coming from borrower. Recall from the <strong>Building a smart contract on the Ethereum blockchain to represent a loan request </strong>section above that we stored a reference to the address of the borrower in the construction of the smart contract which we use to perform this check. Having passed those requirements, the value of the smart contract is then moved to the requesting address using the transfer method provided by Solidity to send Ether, in units of wei, and withdrawLoanAmount is set to true to indicate that the financing has been withdrawn.</p><p>Next, we enable the borrower to make a payment on the loan by adding a makeBorrowerPayment function. For the purposes of this simple example, we require that the payment is the full amount promised at the construction of the smart contract. The makeBorrowerPayment function is of type payable making it available to receive transactions. I provide <a href="https://medium.com/swlh/building-a-decentralized-application-dapp-on-the-ethereum-blockchain-with-javascript-and-solidity-503065ccc23b">more information on the different types of functions in Solidity</a> in a separate blog, but essentially any calls to a function of this type must contain a value which we can access via msg.value and store. Upon execution of our makeBorrowerPayment function, SmartLoan will now also hold the value of the payment that the borrower made. We store recognition of this payment in the newly added amountPaid variable. Updating the amountPaid variable will also unlock the collateral in our BorrowerCollateral contract so that the value can be reclaimed by the borrower.</p><pre>contract BorrowerCollateral {<br>...<br>  require(<br>    loan.amountPaid() == true,<br>    ‘REVERT: Collateral can\’t be withdrawn until the payment is made!’<br>  );<br>...<br>}</pre><p>Finally, we enable the lender to withdraw a payment on the loan by adding a withdrawBorrowerPayment function. Because our smart contract can exist without having received any funding, we first check that the loan has actually started. We do this by checking that lender is holding an actual address which would indicate that the loan has been funded. Next, we check that only lender can withdraw the payment. Once these are both satisfied, we initiate the transfer. Since the lender only has claim to the payment promised by the borrower, we supply borrowerPayment as an augment to the transfer function so that only that amount will be transferred.</p><p>Success! We have written two smart contracts representing our lending process on the blockchain. There are obvious room for improvements like support for interest rates, support for multiple lenders, option without collateral, auto-generation the fixed rate of interests based on the profile of a borrower, but these are all the scenarios that we will cover in this example. As our process and requirements grow we would add new code to our smart contract to handle them. Once we have built a smart contract that we are happy with, we are ready to compile and deploy it to the blockchain.</p><h4>Deploying our solution to the Ethereum blockchain</h4><p>Now that we have written our smart contracts, we need to make it executable by deploying it to the Ethereum blockchain. The blockchain that we use is Ganache, a personal, in-memory Ethereum blockchain. We also want to interact with our smart contract. We will do so by running a local Node.js server and loading the web3.js library, a popular JavaScript API for Ethereum. I go over <a href="https://medium.com/swlh/building-a-decentralized-application-dapp-on-the-ethereum-blockchain-with-javascript-and-solidity-503065ccc23b">how to use Ganache and the web3.js library</a> in a separate blog, so I won’t dive into too much detail here.</p><p>We start by installing the dependencies.</p><pre>$ nvm use 12 &amp;&amp; npm install ganache-cli solc@0.6.4 web3</pre><p>In a terminal window, let’s launch Ganache CLI to see what has been installed.</p><pre>$ node_modules/.bin/ganache-cli</pre><pre>Ganache CLI v6.12.0 (ganache-core: 2.13.0)<br>Available Accounts<br>==================<br>(0) 0x19c22F9e151FAF0331cfc335DBc9d383EA6308F8 (100 ETH)<br>(1) 0x92cfe0156f08c1516aad3B38a0c03009E8e0166A (100 ETH)<br>(2) 0xeb5632df88440bE37bb07411ad1f31db837Aaf3d (100 ETH)(3) 0x386BeF8dfa26457077387Afb383e6765d1179779 (100 ETH)<br>(4) 0x719ff317a2796845F1202bf376e030E64cCA7464 (100 ETH)<br>(5) 0x1344990B4eE941e13224e2a3a806410EF5ec07Df (100 ETH)<br>(6) 0x5F4400D5967D2A24F46e9cd940085bA8f9e498E9 (100 ETH)<br>(7) 0xd9Bc118b5d7Cb8499ab05c74B4Ff58e53E86b419 (100 ETH)<br>(8) 0xC3d79097A32847e288497a767D19A247cEDb8277 (100 ETH)<br>(9) 0x8E72f2B921499e9A2d72Ba4CB007D62F50E24F78 (100 ETH)</pre><pre>Private Keys<br>==================<br>(0) 0x82ed56f35339d84a6c1f76dd84d4aa96fd9b5b729e8f13bf38a0288814c0d468<br>(1) 0x955e5adafe5a8132cb62206fec6414e4bb3ff0036e694afa30b4a9a50d04b128<br>(2) 0xb6b190249a26eea360006f2ba1b8e9523619d3ecc2bbac7217fa8bfe995bbff5<br>(3) 0xb4bbf216bd5981396d2cd10373aa4178fe1da66ec09f0ef06f746650951b2a93<br>(4) 0xb1257c40ef93fbfdaed6e51e061e1218630a58f7133259ba0b11329b6d1a2ce6<br>(5) 0x5435819e7797cbd7878026e04a883dca74630437e2a10b81c58315b79e3968ee<br>(6) 0xfabec80f35628de6fafb7e50700e319e1a020c92767a64e28f5fe65815917b6c<br>(7) 0x33da8361353f9b5624fffd8dfdd072c55708db7cb591f3448288dca9bae37fe8<br>(8) 0x683932c9b2576dd5ca9f685f4cf6f6f824044542955a5f11ca36956d5c55f06e<br>(9) 0x26ed5fc87d3de8f073c16abf2d99cfc06a963e7ac44a551d8f7acd40f509a7ab</pre><pre>HD Wallet<br>==================<br>Mnemonic: bamboo myself slender rally net cart firm crisp transfer organ impact spell<br>Base HD Path: m/44&#39;/60&#39;/0&#39;/0/{account_index}</pre><pre>Gas Price<br>==================<br>20000000000</pre><pre>Gas Limit<br>==================<br>6721975</pre><pre>Call Gas Limit<br>==================<br>9007199254740991</pre><pre>Listening on 127.0.0.1:8545</pre><p>Let’s arbitrarily pick one address to represent our fictional small business that is seeking external financing and a separate address to represent our fictional lender that is providing that financing.</p><pre>$ node<br>&gt; const borrower = ‘0x19c22F9e151FAF0331cfc335DBc9d383EA6308F8’;<br>&gt; const lender = ‘0x92cfe0156f08c1516aad3B38a0c03009E8e0166A’;</pre><p>We can view the details of our newly created accounts using the web3 library.</p><pre>&gt; Web3 = require(‘web3’);<br>&gt; web3 = new Web3(‘<a href="http://127.0.0.1:8545/">http://127.0.0.1:8545</a>&#39;);<br>&gt; web3.eth.getBalance(borrower).then(console.log);</pre><pre>100000000000000000000</pre><p>We see that each account came with 100,000,000,000,000,000,000 wei (100 Ether) preloaded, so we are ready to start executing some transactions on Ethereum! Our first transaction will be to get our smart contract deployed to the blockchain. In a separate window, we use the solcjs Solidity compiler that we installed earlier to compile our SmartInvoice source code into .bin and .abi files.</p><pre>$ node_modules/.bin/solcjs — bin — abi ‘LoanPlatform.sol’</pre><p>You will notice four new files appear in your project: the LoanPlatform_sol_BorrowerCollateral.abi file, the LoanPlatform_sol_BorrowerCollateral.bin file, the LoanPlatform_sol_SmartLoan.abi file, and the LoanPlatform_sol_SmartLoan.bin file. We need all of these files to deploy our smart contracts to Ethereum. We first deploy the SmartLoan contract from the borrower’s account. This example loan will request 2000 wei and promise 2200 wei in return after a period of 4 months.</p><pre>&gt; abi1 = JSON.parse(fs.readFileSync(‘LoanPlatform_sol_SmartLoan.abi’));<br>&gt; bytecode1 = fs.readFileSync(‘LoanPlatform_sol_SmartLoan.bin’).toString();<br>&gt; contract1 = new web3.eth.Contract(abi1);<br>&gt; contract1.deploy({data: bytecode1, arguments:[2000, 2200, 4]}).send({ from:borrower, gasPrice: web3.utils.toWei(‘0.000000098’, ‘ether’), gas: 1500000}).then((deployedContract) =&gt; { contract1.options.address = deployedContract.options.address; console.log(deployedContract.options.address);});</pre><pre>0x514F5F8b7c7e7B89c3313F287A2B659a2CDd227b</pre><p>We chose 0.000000098 as the gasPrice because, according to <a href="https://ethgasstation.info/">Eth Gas Station</a>, that is the recommended gas price to process a transaction at a standard rate as of the time of this blog. In Ganache CLI, we see the following output:</p><pre>Transaction: 0xd164e1cab2e58a1f4e88c809b793de8c85f970e46707053be869c965e7399a6d<br>Contract created: 0x514f5f8b7c7e7b89c3313f287a2b659a2cdd227b<br>Gas usage: 797662<br>Block Number: 1<br>Block Time: Tue Dec 01 2020 10:51:51 GMT-0500 (Eastern Standard Time)</pre><p>Let’s store the address of the contract in a new variable. We will need it later in this blog.</p><pre>&gt; const loanContractAddress = ‘0x514f5f8b7c7e7b89c3313f287a2b659a2cdd227b’;</pre><p>Using web3, we can also see the cost of executing this transaction to the small business owner’s account.</p><pre>&gt; web3.eth.getBalance(borrower).then(console.log);</pre><pre>99921829124000000000</pre><p>That transaction cost 78,170,876,000,000,000 wei (0.078170876 Ether) to process. We can verify this because 797,662 units of gas * 0.000000098 Ether per unit of gas = 0.078170876 Ether. At the time of this blog, 1 Ether cost $590.67 USD meaning that this transaction cost $46.17 USD to produce. With this one-time cost our smart contract now exists on the blockchain forever, or at least until we decide to modify it.</p><p>Next, we deploy the BorrowerCollateral contract.</p><pre>&gt; abi2 = JSON.parse(fs.readFileSync(‘LoanPlatform_sol_BorrowerCollateral.abi’));<br>&gt; bytecode2 = fs.readFileSync(‘LoanPlatform_sol_BorrowerCollateral.bin’).toString();<br>&gt; contract2 = new web3.eth.Contract(abi2);<br>&gt; contract2.deploy({data: bytecode2}).send({ from:borrower, gasPrice: web3.utils.toWei(‘0.000000098’, ‘ether’), gas: 1500000}).then((deployedContract) =&gt; { contract2.options.address = deployedContract.options.address; console.log(deployedContract.options.address);});</pre><pre>0x4d10a38B219CF4449Cc5d83C45caFF57Abb62c9D</pre><p>This transaction adds a new block to our Ethereuem blockchain.</p><pre>Transaction: 0x22b53cbee238e141781b8efc3f7e5fdce356c87987c76d3d4a3cec47596dd1d1<br>Contract created: 0x4d10a38b219cf4449cc5d83c45caff57abb62c9d<br>Gas usage: 497049<br>Block Number: 2<br>Block Time: Tue Dec 01 2020 11:06:38 GMT-0500 (Eastern Standard Time)</pre><p>Let’s store the address of this contract as well.</p><pre>&gt; const collateralContractAddress = ‘0x100Ac3e452f756b20C112275d78EAB7eCf144636’;</pre><p>We now have both of our smart contracts deployed to the Ethereum blockchain running on our local machine with Ganache! We can now test that all of the logic is functioning appropriately.</p><h4>Testing our solution with Ganache</h4><p>Let’s run through some test cases to ensure that our SmartLoan smart contract and BorrowerCollateral smart contract are functioning as expected.</p><blockquote><strong>Test Case: </strong>Our BorrowerCollateral smart contract is able to receive transfers.</blockquote><pre>&gt; web3.eth.sendTransaction({<br>  from: borrower,<br>  to: collateralContractAddress,<br>  value: 500<br>  });<br>&gt; web3.eth.getBalance(collateralContractAddress).then(console.log);</pre><pre>500</pre><blockquote><strong>Test Case:</strong> If the loan has not yet started, only the borrower should be able to withdraw the funds stored in our BorrowerCollateral smart contract.</blockquote><pre>&gt; contract1.methods.contractStart().call(console.log);</pre><pre><strong>null</strong> 0</pre><pre>&gt; contract2.methods.withdrawCollateral(loanContractAddress).send({from:lender});</pre><pre>(node:38831) UnhandledPromiseRejectionWarning: Error: Returned error: VM Exception while processing transaction: revert <strong>REVERT: Only the borrower can withdraw the collateral before the contract starts!</strong></pre><pre>&gt; contract2.methods.withdrawCollateral(loanContractAddress).send({from:borrower});<br>&gt; web3.eth.getBalance(collateralContractAddress).then(console.log);</pre><pre>0</pre><blockquote><strong>Test Case:</strong> The collateral can be added to our SmartLoan smart contract.</blockquote><pre>&gt; contract1.methods.addCollateral(collateralContractAddress).send({from:borrower});<br>&gt; contract1.methods.collateralAmount().call(console.log);</pre><pre><strong>null</strong> 500</pre><blockquote><strong>Test Case:</strong> Our SmartLoan smart contract is able to receive transfers only in the amount defined upon deployment of the contract. Upon receipt, the contract should be stamped with a start time and an end time.</blockquote><pre>&gt; contract1.methods.loanAmount().call(console.log);</pre><pre><strong>null</strong> 2000</pre><pre>&gt; contract1.methods.payableAmount().call(console.log);</pre><pre><strong>null</strong> 2200</pre><pre>&gt; contract1.methods.contractStart().call(console.log);</pre><pre><strong>null</strong> 0</pre><pre>&gt; contract1.methods.contractEnd().call(console.log);</pre><pre><strong>null</strong> 0</pre><pre>&gt; web3.eth.sendTransaction({<br>  from:lender,<br>  to: loanContractAddress,<br>  value: 50<br>  });</pre><pre>(node:38992) UnhandledPromiseRejectionWarning: Error: Returned error: VM Exception while processing transaction: revert <strong>REVERT: Contribution should be the requested amount.</strong></pre><pre>&gt; web3.eth.sendTransaction({<br>  from:lender,<br>  to: loanContractAddress,<br>  value: 2000<br>  });<br>&gt; contract1.methods.contractStart().call(console.log);</pre><pre><strong>null</strong> 1606841253</pre><pre>&gt; contract1.methods.contractEnd().call(console.log);</pre><pre><strong>null</strong> 1617209253</pre><pre>&gt; web3.eth.getBalance(loanContractAddress).then(console.log);</pre><pre>2000</pre><blockquote><strong>Test Case:</strong> Only the borrower can withdraw the loan amount.</blockquote><pre>&gt; contract1.methods.loanAmountWithdrawn().call(console.log);</pre><pre><strong>null</strong> false</pre><pre>&gt; contract1.methods.withdrawLoanAmount().send({from:lender});</pre><pre>(node:38992) UnhandledPromiseRejectionWarning: Error: Returned error: VM Exception while processing transaction: revert <strong>REVERT: Only the borrower can withdraw the loan amount!</strong></pre><pre>&gt; contract1.methods.withdrawLoanAmount().send({from:borrower});<br>&gt; web3.eth.getBalance(loanContractAddress).then(console.log);</pre><pre>0</pre><pre>&gt; contract1.methods.loanAmountWithdrawn().call(console.log);</pre><pre><strong>null</strong> true</pre><blockquote><strong>Test Case:</strong> Once the loan has been withdrawn, the borrower should not be able to withdraw the collateral unless the lender has been repaid.</blockquote><pre>&gt; contract1.methods.amountPaid().call(console.log);</pre><pre><strong>null</strong> false</pre><pre>&gt; contract2.methods.withdrawCollateral(loanContractAddress).send({from:borrower});</pre><pre>(node:38992) UnhandledPromiseRejectionWarning: Error: Returned error: VM Exception while processing transaction: revert <strong>REVERT: Collateral can’t be withdrawn until the payment is made!</strong></pre><blockquote><strong>Test Case: </strong>The borrower needs to make a repayment equal to the amount promised.</blockquote><pre>&gt; contract1.methods.amountPaid().call(console.log);</pre><pre><strong>null</strong> false</pre><pre>&gt; contract1.methods.makeBorrowerPayment().send({from:borrower, value:2000});</pre><pre>(node:38992) UnhandledPromiseRejectionWarning: Error: Returned error: VM Exception while processing transaction: revert <strong>REVERT: The payment should be the total amount payable!</strong></pre><pre>&gt; contract1.methods.amountPaid().call(console.log);</pre><pre><strong>null</strong> false</pre><pre>&gt; contract1.methods.makeBorrowerPayment().send({from:borrower, value:2200});<br>&gt; contract1.methods.amountPaid().call(console.log);</pre><pre><strong>null</strong> true</pre><pre>&gt; web3.eth.getBalance(loanContractAddress).then(console.log);</pre><pre>2200</pre><blockquote><strong>Test Case:</strong> Once the loan has been paid, only the lender should be able to withdraw the payment.</blockquote><pre>&gt; contract1.methods.withdrawBorrowerPayment().send({from:borrower});</pre><pre>(node:38992) UnhandledPromiseRejectionWarning: Error: Returned error: VM Exception while processing transaction: revert <strong>REVERT: Only the lender can withdraw the payment!</strong></pre><pre>&gt; contract1.methods.withdrawBorrowerPayment().send({from:lender});<br>&gt; web3.eth.getBalance(loanContractAddress).then(console.log);</pre><pre>0</pre><blockquote><strong>Test Case:</strong> Once the loan has been paid, only the borrower should be able to withdraw the collateral.</blockquote><pre>&gt; web3.eth.getBalance(collateralContractAddress).then(console.log);</pre><pre>500</pre><pre>&gt; contract1.methods.amountPaid().call(console.log);</pre><pre><strong>null</strong> true</pre><pre>&gt; contract2.methods.withdrawCollateral(loanContractAddress).send({from:lender});</pre><pre>(node:38992) UnhandledPromiseRejectionWarning: Error: Returned error: VM Exception while processing transaction: revert <strong>REVERT: Only the borrower can withdraw the collateral before the contract ends!</strong></pre><pre>&gt; contract2.methods.withdrawCollateral(loanContractAddress).send({from:borrower});<br>&gt; web3.eth.getBalance(collateralContractAddress).then(console.log);</pre><pre>0</pre><blockquote><strong>Test Case:</strong> If the borrower hasn’t made a payment by the time the contract has ended, only the lender may withdraw the collateral.</blockquote><pre>&gt; contract1.methods.contractStart().call(console.log);</pre><pre><strong>null</strong> 1606843164</pre><pre>&gt; contract1.methods.contractEnd().call(console.log);</pre><pre><strong>null</strong> 1606843164</pre><pre>&gt; contract1.methods.amountPaid().call(console.log);</pre><pre><strong>null</strong> false</pre><pre>&gt; contract2.methods.withdrawCollateral(loanContractAddress).send({from:borrower});</pre><pre>(node:39096) UnhandledPromiseRejectionWarning: Error: Returned error: VM Exception while processing transaction: revert <strong>REVERT: Payment is late; collateral forfeited to lender.</strong></pre><pre>&gt; contract2.methods.withdrawCollateral(loanContractAddress).send({from:lender});<br>&gt; web3.eth.getBalance(collateralContractAddress).then(console.log);</pre><pre>0</pre><p>Perfect, all of our test cases passed!</p><h4>Alternative options to traditional lending</h4><p>Over the past decade, the world has seen a number of new lending options appear as an alternative to traditional lending through banks. In fact, the solution that we built throughout this blog is what some would consider a “peer-to-peer lending” solution. Around 2005, we saw the evolution of peer-to-peer lending, often abbreviated as “P2P”, as another option for small businesses to acquire external financing. Traditionally small business owners sought external financing from banks. The owner would submit an application to the bank and the bank would review their credit score, history, and income to determine how much money to loan them and the interest rate for which they would qualify. Rather than using credit score and history, P2P lending services rely on their own algorithms to assess credit worthiness enabling them to accept more applications that banks would consider too risky. Manifestations of P2P lending today are online services that connect borrowers with lenders. Borrowers submit a request for a loan and their information. Based on their information, the service determines an interest rate that the borrower will pay on top of their principal. This online presence allows these services to process requests much more quickly than traditional external financing options. The service then posts the loan at which point lenders can discover that loan and contribute an amount towards the total amount requested by that borrower. The lenders then receive a monthly sum of principal payments and interest payments. If the borrower defaults on the loan then the lenders either lose whatever remains of their investment or sell their remaining investment at a loss to another risk-tolerant investor who believes that the some value can still be recouped. Popular P2P services today are <a href="https://medium.com/u/94a894192594">Funding Circle</a>, <a href="https://medium.com/u/b0c760993111">Upstart</a>, Prosper, and LendingClub.</p><p>According to <a href="https://medium.com/u/afad1a2d7ad4">MarketWatch</a>, the market for P2P lending was valued at approximately $68 billion USD in 2019 and anticipated to grow at a rate of more than 30% over the next seven years. They cite enhanced transparency and low operating cost as a large factor driving that growth. As we have seen throughout this blog, the emergence of blockchain has a massive impact on those same factors and therefore can be expected to be a game changer in the P2P landscape and revive it as a viable means for raising capital for small businesses. As an immutable, decentralized ledger, there is no need for an intermediary in blockchain. Lenders are directly linked to the small business borrower with full transparency and a real-time look at the lending process. There are also cost savings from the elimination of typical overhead costs like upfront fees (e.g. P2P services today generate revenue by collecting a one-time fee from borrowers on funded loans and a loan servicing fee from investors), underwriting fees and closing costs. In addition, blockchain can introduce these borrowers to the potential of borderless financing and open up doors to capital that was not previously accessible to them.</p><p>While ostensibly this seems like a great situation for small businesses, as with any new technology and product, there is uncertainty around whether users will choose to use it. This concept was best characterized as “value risk” by technology product management thought leader Marty Cagan in his book <em>INSPIRED</em>, a must read for product people. The <em>2019 Report on Employer Firms</em> introduced at the beginning of this blog shows a favorable trend towards reducing value risk. According to the report,<em> </em>trust in online lending has been rising among small business owners with 32% of respondents seeking funding from an online lender in 2018 up from only 19% in 2016. When pressed for the reasons for pursuing online lending, respondents largely credited the speed at which a decision on their application could be made as well as the likelihood that their application would be accepted. Vice versa, small businesses that pursued external financing from a traditional bank reported their existing relationship as the most significant factor in their decision. This is good news for the future of online lending and blockchain! If an existing relationship is the main reason why a small business owner would choose a lender and we are seeing a surge of small business owners establishing relationships with online lenders, then it is only a matter of time before online lending becomes a primary source of funding for small businesses. And, as we have discussed earlier in this section, the improvements that blockchain will enable for online lending will only reinforce the adoption of lending options running on a blockchain.</p><h4>What were we talking about, again?</h4><p>As we learned at the beginning of this blog, there is a problem in the lending market for small businesses. Small business owners want to expand their business, acquire business assets, and/or pay their operating expenses. To do so, they need capital which they turn to external financing to provide. The problem is that many small business owners are finding it difficult to get external financing via today’s channels with only 47% of applicants receiving the total amount sought. The reasons for this shortfall span both the lenders and the lending process. Big banks are reducing the number of accepted applications from small businesses. Simultaneously, small businesses are being denied for loans because of insufficient collateral or the right type of collateral, a low credit score or no credit history, they are already carrying a lot of debt, and/or they have inadequate cash flow.</p><p>To address this problem, we turned to blockchain which has the potential to open up new channels for external financing. Blockchain enables the lending process to be performed both quickly through decentralization of the process across a peer-to-peer network and securely through cryptography. This time-savings and reduction of intermediaries means that small business owners can receive funding more quickly and at a cheaper price. The entire lending experience can be simplified using smart contracts on the Ethereum blockchain which can be integrated with an intuitive web frontend limiting the number of applications that get denied due to clerical errors. This also opens a new channel of external financing for small business owners to supplement the shortfall in loans from other channels or to meet all of their lending needs.</p><p>Why should we care about this problem? Without access to external financing, small businesses will fail. We see this all the time. The Bureau of Labor Statistics within the United States Department of Labor reports that 20% of small businesses today will fail in their first year and 50% will fail by their fifth year. The owners of these small businesses are our friends and neighbors; especially those of us lucky enough to call New York City our home. According to an article in Small Business Trends published in 2019, New York City is home to the most small business owners with a total of 411K which is even greater than the combined totals of runners-up Los Angeles at 243K, San Francisco at 84K, and Boston at 81K small business owners. While small business owners are a minority compared to the working population, data shows that most of us actually want what these individuals have been brave enough to do. In fact, according to a survey run by the Organisation for Economic Co-operation and Development in 2015, 69% / 62% of adult men and 58% / 52% of adult women in the United States and Canada respectively want to build their own businesses. While this presents a clear economic opportunity, a convincing humanities argument could also be made to build solutions to problems that inhibit achievement of a dream so common across our fellow human beings.</p><p>But in order to enable small businesses to open and stay open, we need to open up new channels of external financing to small business owners!</p><p>If you are a small business owner and you’d like to get some hands on experience building smart contracts on Ethereum with Solidity and JavaScript, clone the <a href="https://github.com/ckraczkowsky91/smb-loan-platform-ethereum">source code</a> from my GitHub of the application that we built throughout this blog and run it on your local machine.</p><h4>About the author</h4><p>Colin Kraczkowsky is passionate about building solutions that solve people’s problems and loves to learn and share his thoughts on new technologies. His latest interest is in blockchain, specifically Ethereum development, and its applications to solving problems for small businesses including sole proprietors, the self-employed, and solopreneurs. Colin’s professional history includes working in both enterprise and startup environments to code web and mobile applications, launch new products, build mockups and prototypes, analyze metrics, and continuously innovate.</p><p>In his spare time, Colin can be found checking out an REI camp bundle for a weekend away in the woods, field testing the latest HOKAs, hunting fresh powder on the mountain, or surfing the Horror section on Netflix.</p><p>Connect with Colin — <a href="https://www.linkedin.com/in/colinkraczkowsky">https://www.linkedin.com/in/colinkraczkowsky</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fb0e0423ff1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/applying-blockchain-to-the-external-financing-needs-of-small-business-owners-6fb0e0423ff1">Applying Blockchain to the External Financing Needs of Small Business Owners</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>