<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Bitcoin - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Bitcoin - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sat, 23 May 2026 22:21:15 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/bitcoin/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ This absurd rap battle summarizes the arguments for and against cryptocurrency ]]>
                </title>
                <description>
                    <![CDATA[ A rap battle group has resurrected Alexander Hamilton so he could square off against Satoshi Nakamoto. In a silly (and PG-rated) rap battle, Hamilton and Satoshi argue the merits behind centralized and decentralized currencies. Alexander Hamilton is ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/this-absurd-rap-battle-summarizes-the-arguments-for-and-against-cryptocurrency/</link>
                <guid isPermaLink="false">66b8d60e80f2fbfc1b20bc01</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ youtube ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Quincy Larson ]]>
                </dc:creator>
                <pubDate>Thu, 05 Sep 2019 20:47:43 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/09/maxresdefault--4--1.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>A rap battle group has resurrected Alexander Hamilton so he could square off against Satoshi Nakamoto.</p>
<p>In a silly (and PG-rated) rap battle, Hamilton and Satoshi argue the merits behind centralized and decentralized currencies.</p>
<p>Alexander Hamilton is one of America's Founding Fathers and served as our first Secretary of Treasury under George Washington. He was a lawyer, banker, and advocate of centralized control of fiscal and monetary policy.</p>
<p>And yes - he's the same Hamilton from the Broadway play.</p>
<p>Hamilton is played by EpicLloyd (of Epic Rap Battles of History fame.)</p>
<p>Satoshi Nakamoto is the creator of the Blockchain and of the Bitcoin cryptocurrency. Nobody knows what he looks like - or whether he's even a real person. (And yes - this is addressed in the rap battle).</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/09/printing_front_jpg-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>Satoshi Nakamoto's <a target="_blank" href="https://www.freecodecamp.org/news/shop">Programmer Playing Card</a>.</em></p>
<p>Nakamoto is portrayed by an unmasked TimothyDeLaGhetto.</p>
<p>In the 6-minute video, the rappers trade ideological blows with one another.</p>
<p>Hamilton brings up issues with Bitcoin's high transaction costs, scalability issues, and energy consumption.</p>
<p>Nakamoto raps about how untraceable cash can facilitate crime, and how the existence of giant banks can necessitate taxpayer bailouts.</p>
<p>Here's the full video:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/JaMJi1_1tkA" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>And here are the full lyrics in case you don't want to be seen at your desk watching Alexander Hamilton rap with a musket in hand. (But really - you should watch it.)</p>
<p>[Alexander Hamilton]<br>Before we begin, everyone do me a favor,<br>And read a little thing I wrote called the Federalist Papers.<br>I explain how a nation’s unlikely to survive<br>Without a strong central government to keep it alive,<br>When I launched the central bank, Jefferson called me ill,<br>Now you have my face to thank on every ten dollar-bill.<br>When America was cash-strapped, I pushed past that,<br>Now some sicko makes crypto and our nation backtracks?</p>
<p>[Satoshi Nakamoto]<br>Decentralized currency. Yes, I invented it.<br>I’m sure many governments wish they had prevented it<br>Their national cash is how they keep control,<br>But freedom to the people was my ultimate goal.<br>Am I a pseudonym? A group of men? It doesn’t even matter.<br>I invented Bitcoin cause fiat is a disaster.<br>A man from Japan or a damn hologram?<br>I’m the reason open season on crypto began.</p>
<p>[Alexander Hamilton]<br>Does anybody know what this crypto-thing means?<br>To me, sounds like the new Get Broke Quick scheme,<br>A bunch of fools from across the land<br>Investing in something they don’t even understand,<br>Buying Litecoin, Dash, Bitcoin Cash,<br>It’s all gonna crash, and be gone in a flash.<br>All this unsupported money’s an irrational prank,<br>And I’ll be laughing all the way to my National Bank.</p>
<p>[Satoshi Nakamoto]<br>Hahahahahah, yeah dude, super funny,<br>As if banks these days still helped people make money.<br>The rich get richer and we follow like we’re all sheep,<br>The banks serve Wall Street, crypto serves all streets,<br>The interest in crypto’s on rapid ascent<br>What’s your current interest? Half a percent?<br>I’m sorry, the bank’s gone past its peak<br>But I want info encrypted, not hacked and leaked.</p>
<p>[Alexander Hamilton]<br>If this crypto system will be our salvation,<br>It needs to be centralized, needs regulation.<br>If our central database gets… how you say, “hacked?”<br>Insurance will just make a case to get your money back.<br>‘Cause in fact, it’s tracked, and the money leaves a trail.<br>Central currency is strong, cryptocurrency is frail.<br>Untraceable money — wow, so clever.<br>One typo in your address? Now it’s gone forever.</p>
<p>[Satoshi Nakamoto]<br>Crypto is frail? That’s the essence of your lesson?<br>Your money leaves a trail? Yeah, a trail to a recession.<br>A buncha rich white guys made this system.<br>Why would they ever change this, when It’s made them rich men!<br>Movie moguls fought hard against the VCR.<br>Horse and buggy manufacturers all hated the car.<br>So why would I take my advice from the banks?<br>I don’t need a bailout to survive. Thanks.</p>
<p>[Satoshi Nakamoto's backup singer]<br>The system is so broken.<br>We need that crypto token.</p>
<p>[Alexander Hamilton's backup singer]<br>The system isn’t broken.<br>Can we trust crypto tokens?</p>
<p>[Alexander Hamilton]<br>It’s gotta be centralized!</p>
<p>[Satoshi Nakamoto]<br>Decentralized!</p>
<p>[Alexander Hamilton]<br>Centralized!</p>
<p>[Satoshi Nakamoto]<br>Decentralized!</p>
<p>[Alexander Hamilton]<br>We need control!</p>
<p>[Satoshi Nakamoto]<br>Free enterprise!</p>
<p>[Debate moderator]<br>Bring me the facts.<br>Please testify.</p>
<p>[Satoshi Nakamoto]<br>Fiat's the way a government controls the populace.</p>
<p>[Alexander Hamilton]<br>Government protects its people. All of this is obvious.<br>They keep the peace, and so they keep control.<br>You want us ruled by crypto-miners no one even knows.</p>
<p>[Satoshi Nakamoto]<br>Oh, it’s that "Strong Central Government" bit again.<br>They protect people, but only their citizens.<br>Crypto has no borders, it's a true global currency.<br>And censorship resistance for those who need it urgently.</p>
<p>[Alexander Hamilton]<br>Banks earn trust by assuming liability.<br>You know a key, we know the customer explicitly.<br>Will the real Satoshi please stand up?<br>Nope, you’ll still be hiding when crypto busts.</p>
<p>[Satoshi Nakamoto]<br>You don’t need to trust the people, you just need to trust the code.<br>Every record’s in the network, you’re just one node.<br>And when you find a flaw, there’s a software update.<br>Now try updating cash. Go ahead, I’ll wait.</p>
<p>[Alexander Hamilton]<br>Wait? Cash works! You immediately pay.<br>Crypto's a far worse medium of exchange.<br>Can’t bitcoin the dentist, can’t bitcoin my breakfast.<br>Can’t even use bitcoin at bitcoin conventions.</p>
<p>[Satoshi Nakamoto]<br>No currency starts with universal adoption.<br>It takes time for places to make it an option.<br>Plus billions of people don’t have bank accounts.<br>No savings, no interest, no checks to bounce.</p>
<p>[Alexander Hamilton]<br>You’re saving the world? But what’s the price you’re paying?<br>The only change you’re creating is climate change.<br>Power grids spiking all across the land.<br>Overheated, no one needs it, hope it all is banned.</p>
<p>[Satoshi Nakamoto]<br>From the king of paper currency, the hypocrisy!<br>For bills and forms in triplicates, you’re killing all the trees.<br>Don’t like my power usage? Stop targeting my rights.<br>I own my purchased power and the market sets the price.</p>
<p>[Alexander Hamilton]<br>It’s gonna get real dark if this is crypto’s night.<br>They use your currency for crimes, that’s your kryptonite.</p>
<p>[Satoshi Nakamoto]<br>Most crime is done with Benjamins, not the blockchain.<br>There’s a reason most dollars carry traces of cocaine.</p>
<p>[Alexander Hamilton]<br>Where’s your proof of work? That’s pure speculation.<br>Those darknet black markets need more regulation.</p>
<p>[Satoshi Nakamoto]<br>The world’s fulla currencies. And this one makes it worse?<br>1 hundred eighty now, Bitcoin’s a hundred-eighty-first.</p>
<p>[Alexander Hamilton]<br>It’s not the currency itself, it’s the method, man.<br>You can’t build things that last without a central plan.</p>
<p>[Satoshi Nakamoto]<br>Crypto is a balance to the centralized model.<br>Cause things fall apart. The center cannot hodl.</p>
<p>[Alexander Hamilton]<br>If you end up having problems, I’ll feel bad for you, son.</p>
<p>[Satoshi Nakamoto]<br>I’ve got 99 problems but a bit ain’t one.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How looking back can help us move forward: a retrospective on software gems and fads ]]>
                </title>
                <description>
                    <![CDATA[ By Pakal de Bonchamp Maybe one of the most important qualities of a developer is the ability to pick the right tool for the right job, without hopping onto bandwagons or reinventing the wheel. This might require a bit of technology analysis, but even... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/software-fads-and-gems/</link>
                <guid isPermaLink="false">66d460939f2bec37e2da0664</guid>
                
                    <category>
                        <![CDATA[ asyncio ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ formats ]]>
                    </category>
                
                    <category>
                        <![CDATA[ NoSQL ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 30 Aug 2019 18:30:49 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/08/hidden-gem.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Pakal de Bonchamp</p>
<p>Maybe one of the most important qualities of a developer is the ability to pick the right tool for the right job, without hopping onto bandwagons or <a target="_blank" href="https://en.wikipedia.org/wiki/Not_invented_here">reinventing the wheel</a>. This might require a bit of technology analysis, but even more, a touch of critical thinking.</p>
<p>Here is a review of a few exaggerated trends and underrated niceties, in different areas of the marvelous world of computer science: <strong>databases, asynchronicity, cryptocurrency, and data formats</strong>. I won't touch on the subject of REST webservices, which I already <a target="_blank" href="https://www.freecodecamp.org/news/rest-is-the-new-soap-97ff6c09896d/">ranted about at great length</a>. </p>
<p><em>As usual, your feedback is more than welcome if any factual errors slipped into this (not entirely unbiased) article.</em></p>
<h2 id="heading-databases-nosql-amp-zodb">Databases: NoSQL &amp; ZODB</h2>
<p>Few moments, in the history of computer science, were as ironically lit as the arrival of No-SQL databases, around 2009. A tidal wave struck the shores of backend development and system administration: SQL databases were too rigid, too slow, too hard to replicate. </p>
<p>So new projects massively ditched them in favor of key-value stores like Redis, document-oriented databases like MongoDB/CouchDB, or graph-oriented databases like Neo4j. And we must acknowledge one thing: these new databases shone in benchmarks; they shone about as much.... as would shine any SQL database dropping all its <a target="_blank" href="https://www.geeksforgeeks.org/acid-properties-in-dbms/">ACID constraints</a> and query language flexibility.</p>
<p>But the horizon was grim for numerous programmers. They learned, the hard way, that data persistence was not a minor concern. And that they needed, for example, to explicitly activate "Write Concerns" in MongoDB, to ensure that data would not get lost before reaching disk oxide. </p>
<p>They learned that "eventual consistency" was a pretty word for "temporary inconsistency", opening the door to nasty, silent, hard-to-reproduce bugs in production. And that transactions - and their implicit locking - were precious features, and that mimicking them by hand, with awkward flags stuffed into documents, was all but easy and robust. </p>
<p>And they learned that data schemas, and referential integrity, were more than welcome to prevent databases from becoming heaps of incoherent objects. And that the lack of advanced indexing capabilities (on multiple keys, on deep document fields) in key-value stores could become quite embarrassing.</p>
<p> Thus, people began reinventing SQL features on top of NoSQL databases, by mimicking data schemas, foreign keys, advanced aggregation, in language-specific "ORM" libraries (mongoengine, mongoid, mongomapper...). In this context, this "Object-Relational Mapper" acronym should have, by itself, been a hint that something had gone wild. </p>
<p>There was something surreal in watching NoSQL databases, which were honed for specific use cases (highly replicated or heterogeneous data, <a target="_blank" href="https://docs.mongodb.com/manual/core/capped-collections/">capped-size collections</a> or <a target="_blank" href="https://docs.mongodb.com/manual/tutorial/expire-data/">TTLs</a>, pub/sub systems...), be used just to store a bunch of same-shape objects in a single server instance. </p>
<p>A standard SQL database would completely have done the job, and offered many more tooling options and plugins (different storage engines, Percona toolkit scripts, IDEs like HeidiSql or Mysql Workbench, DB schema migration processes integrated into web frameworks...). Even if it meant stuffing extra unstructured data into a serialized Text Field (or, nowadays, dedicated <a target="_blank" href="https://www.postgresql.org/docs/current/datatype-json.html">PostgreSQL Json Fields</a>).</p>
<p>With time, NoSQL databases themselves improved a lot, among other things by borrowing features from the SQL world. But reinventing SQL is not an easy task. Relational databases deal with query language parsing, character sets and collations, data aggregation and conversion, transactions and isolation levels, views and query caches, triggers, embedded procedures, <a target="_blank" href="http://wiki.gis.com/wiki/index.php/Geographic_information_system">GIS</a>, fine-grained permissions, replication and clustering... complex and sensitive features, driven by hundreds of settings spread on multiple levels (per database, per table, per connection). </p>
<p>So despite their great progress (multi-document transactions, better data aggregation, stored JavaScript functions, pluggable storage, role-based access control in MongoDB), NoSQL DBs still have trouble challenging major SQL databases, purely feature-wise. </p>
<p>Luckily, most projects only need a tiny subset of these SQL database features: a few schema validations, a few proper indices, and business can get rolling; so for teams lacking SQL expertise, the relative simplicity of many NoSQL DBs could indeed be, to be honest, a relevant factor.</p>
<p>The wave seems to have faded by now, and projects seem more inclined to combine different databases according to actual needs. They thus separate user accounts, job queues and similar caches, logging and stats data... each into the most relevant storage.</p>
<p>All these cited NoSQL databases, and their countless alternatives, are shining in their intended use cases. But I'd like to mention a too-little-known, too-little-used gem of the Python ecosystem. Have you already wanted to persist your data in a really, reaaaalllly easy way? Then I forward you to the <a target="_blank" href="http://www.zodb.org/en/latest/">ZODB</a>. You open it like a dictionary, you push whatever data you want into it, you commit the transaction, and you're good to go. </p>
<p><em>Example of simple local ZODB instance:</em></p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> ZODB <span class="hljs-keyword">import</span> FileStorage, DB
<span class="hljs-keyword">import</span> transaction

storage = FileStorage.FileStorage(<span class="hljs-string">'mydatabase.fs'</span>)
root = DB(storage).open().root()
print(<span class="hljs-string">"ROOT:"</span>, root)
root[<span class="hljs-string">'employees'</span>] = [<span class="hljs-string">'Mary'</span>, <span class="hljs-string">'Jo'</span>, <span class="hljs-string">'Bob'</span>]
transaction.commit()
</code></pre>
<p>Graphs of data are handled gracefully (no recursion error), objects are lazily loaded on access, special "bucket tree" types are provided to browse huge amounts of data while keeping memory low, and several storage backends exist, including <a target="_blank" href="https://relstorage.readthedocs.io/en/latest/install.html">relstorage</a> which leverages the power of SQL databases. Perfect, isn't it?</p>
<p>Alright, I'm lying, there are a few gotchas. There is no built-in indexing system (one must use Zcatalog or the likes instead). Using dedicated "persistent" types is highly advised, to automatically detect and persist mutations of objects. The overall tooling is quite limited compared to mainstream databases. And the concurrency model based on "optimistic locking" might force you, under heavy load, to retry an operation several times until it manages to get applied. </p>
<p>The extreme amount of integration with the Python language has an additional drawback: if you introduce breaking changes into your data model, your database might not load anymore, so you must handle schema migrations carefully. </p>
<p>But context is everything: ZODB is not meant for long term and interoperable data persistence, but for effortless storage of (possibly very heterogeneous) python objects. It can make long-running scripts able to resume after interruption, it can store player data of online game sessions... if you really want to store blog articles or personal accounts in ZODB, you had better limit yourself to native python types, and implement your own sanity checks.  But whatever happens, do not use a very limited <a target="_blank" href="https://docs.python.org/3.7/library/shelve.html">stdlib shelf</a>, if you can have a nifty ZODB under the hand to store your work-in-progress data.</p>
<h2 id="heading-asynchronicity-asyncio-trio-and-green-threads">Asynchronicity: Asyncio, Trio and Green Threads</h2>
<p>There has been an immemorial challenge between synchronous and asynchronous programming models, in all IO-bound programs. Kernels have provided asynchronous modes for disk operations, with more or less success (<em>overlapped</em> non-blocking IO on Windows, limited _io<em>submit</em>() API on Linux...). </p>
<p>Networking code has made the issue still more acute, with the need for huge numbers of long-term connections, each performing only minor CPU operations. </p>
<p>Some languages, like Erland, confronted this by being asynchronous from the start, and letting different tasks communicate by message passing (a.k.a <a target="_blank" href="https://en.wikipedia.org/wiki/Actor_model">Actor Model</a>).</p>
<p>In other languages, several design patterns emerged to tackle the problem:</p>
<ul>
<li>callbacks</li>
<li>async/await syntax</li>
<li>lightweight threads</li>
</ul>
<p>Callbacks were previously the major solution in mainstream frameworks. For example in jQuery or Twisted, the developer would provide callables as arguments or as instance methods, and these would be called on IO completion/cancellation, in a pattern called <a target="_blank" href="https://en.wikipedia.org/wiki/Inversion_of_control">Inversion of Control</a>. It works, for sure, but it makes program flows quite hard to predict and debug, hence the term "callback soup" often used in this context.</p>
<p>For the last few years, the <a target="_blank" href="https://docs.python.org/3/library/asyncio-task.html">async/await</a> syntax has become highly trendy, especially in the Python world. But there is a problem: like Inversion of Control, it's a whole new way of programming, almost a new language. The vast amount of packages currently available, made of modules, classes and methods, just does NOT work with async/await. </p>
<p>Any IO, any expensive operation, hidden deep inside a subdependency, could ruin your day. So we're currently gazing at thousands of great modules being happily reimplemented, with a whole new world of bugs and missing features.</p>
<p>Is it all worth it? Python developers have massively jumped onto the train of the <a target="_blank" href="https://docs.python.org/3/library/asyncio.html">asyncio</a> package, which has become part of the stdlib. But this technology has scary issues, like the difficulty of socket backpressure, the fragile handling of exceptions and ctrl-C, the unsafe cancellation of (leaking) tasks, and the steep learning curve of an API full of gotchas and redundant concepts. Other frameworks like Trio/Curio, seemed <a target="_blank" href="https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/">much more careful on these subjects</a>. </p>
<p>If we have to recode tons of existing libraries, why base new versions on an engine that some developers have - not without arguments - called a <a target="_blank" href="https://veriny.tf/asyncio-a-dumpster-fire-of-bad-design/">dumpster fire of bad design</a>? But the <a target="_blank" href="https://en.wikipedia.org/wiki/Network_effect">network effect</a> is huge in such cases, and alternative async/await-based frameworks will have a hard time challenging the standard.</p>
<p>And what about the third pattern quoted above, lightweight threads? Long before this async/await trend, Python developers thought: we already have some perfectly fine synchronous business code, so let's change the way it is run, not the way it is written. Thus appeared lightweight threads, or "greenlets". They work like a bunch of tiny tasks scheduled on top of a few native threads, tasks which yield control to each other only when they block on IO or explicitly do so; and with much greater performance than native threads, in terms of memory usage and switching delay. </p>
<p>In the end, this system can quickly boost about any existing codebase so that it supports thousands of long-term concurrent tasks. And this is not an isolated mad experiment: Python lightweight threads have originally been used in Eve Online game (via Stackless Python), and have since successfully been ported to CPython (Gevent, Eventlet...) and PyPy. And they have actually <a target="_blank" href="https://en.wikipedia.org/wiki/Green_threads">existed for a long time</a> in lots of programming languages, under different names (green processes, green threads, fibers...).</p>
<p>The drawbacks of this system?</p>
<ul>
<li>Libraries must play nice with green threads, by yielding control instead of blocking on IOs, and launching green threads instead of native threads. In python, main libraries (socket, time.sleep(), threading) are forcibly made green-friendly via monkey-patching; but compiled extensions must be especially checked, since they can bypass these patches and block on their own system calls.</li>
<li>No heavy computation, or otherwise time-consuming tasks, must be performed, else all other tasks get impacted by the delay. For such needs, just delegate work to a pool of <a target="_blank" href="http://www.gevent.org/api/gevent.threadpool.html">native threads</a> (or a <a target="_blank" href="http://www.celeryproject.org/">celery</a>-like worker queue).</li>
</ul>
<p>As we see, these drawbacks are similar to those of async/await, except that you almost don't have to touch the original, synchronous code. An "except" which can mean months or years of work avoided ; your CTO and CEO should be highly pleased about this.</p>
<p>Now, you'll sometimes hear strange rationalizations from people who ditched lightweight threads in favor of a whole async/await reimplementation. Something in the lines of "<em>Explicit is better than implicit, and all these awaits show me exactly where my code could switch context, whereas green threads might switch discreetly if a third-party function performs any kind of IO or explicit switch</em>".</p>
<p>But the thing is...</p>
<p>FIRST, why do you need to know at which points exactly the program will switch to another task? For all the past years, with native (preemptive) thread, a switch could happen anywhere, anytime, even right in a middle of a simple increment. </p>
<p>But we learned to deal with this invisible threat properly, by protecting critical sections with locks and other synchronization primitives (Recursive Locks, Event, Condition, Semaphore...), keeping a proper order when nesting locks, and using thread-safe data structures (Queues and the likes) which handle concurrency for us. </p>
<p>Green threads are a middle ground between (implicit) preemptive threads and (explicit) async/await, but all of these technologies had better stick to the good old way of protecting concurrent operations. </p>
<p>Locks can be dangerous when misused (especially since most implementations stall, instead of detecting deadlock and reporting them as exceptions), but they are cheap and robust. What is the point of attempting to do lock-less concurrency, by checking the position of each potentially switch-triggering calls, when you could anytime have to add a new operation (even a simple logging output) in the middle of your carefully crafted lock-less sequence, and thus ruin its safety?</p>
<p><em>This naive code shows how a recently added call to log_counter_value() breaks an otherwise safe asynchronous code.</em></p>
<pre><code class="lang-python">
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">increment_counter</span>(<span class="hljs-params">counter</span>):</span>
     current = counter.current_value
     <span class="hljs-keyword">await</span> log_counter_value(current)  <span class="hljs-comment"># Unwanted context switch happens here</span>
     counter.current_value = current + <span class="hljs-number">1</span>
</code></pre>
<p>SECOND, do you really have to deal with synchronization? In the web world especially, where HTTP requests are not supposed to interact, we want parallelization, not concurrency. Persistent data (and transactions) are supposed to be handled by external databases and caches, not in process memory heap. </p>
<p>So usual thread-safety good practices (using thread-safe initialization of the process via locks, read-only structures for global data, and read-write data only local to stack frames) are enough to make the whole system "thread/greenlet/asynctask safe". </p>
<p>If one day you need to implement highly concurrent algorithms inside a process, you'll choose the best tool for that, but no need for hammer-building factories if all you have to do is thrust one nail.</p>
<h2 id="heading-money-bitcoins-amp-alternatives">Money: Bitcoins &amp; Alternatives</h2>
<p>Let's ponder for a moment. What are the biggest challenges of our 21st century? Climate change? Tax evasion? Legitimacy of state power? So candid minds could think that energetic sobriety, financial traceability, and (really) democratic organizations, would be goals to pursue.</p>
<p>But a group of smart hackers decided that current moneys were a major issue, and came up with Bitcoins: energy-devouring "proof of work" system, easy anonymity of money holders, and fuzzy (for the least) governance.</p>
<p>With such adequation between needs and demand, it's no wonder that Bitcoins became what they became: a product of (almost) pure speculation, praised by <a target="_blank" href="https://cointelegraph.com/news/research-suggests-russian-based-hackers-behind-ryuk-ransomwares-25-million-gains">ransomwares</a> and miscellaneous mafias, mass-mined by factories of graphics cards, with an especially high appetite for <a target="_blank" href="https://cryptosec.info/exchange-hacks/">being stolen</a> (or lost). </p>
<p>This money, and its soon-emerged siblings, have a history already full of bewildering moments, with accidental chain splits, <a target="_blank" href="https://en.bitcoin.it/wiki/Softfork">soft forks</a> blocked for <a target="_blank" href="https://en.bitcoin.it/wiki/Segregated_Witness">political reasons</a>, <a target="_blank" href="https://en.wikipedia.org/wiki/List_of_bitcoin_forks">hard forks</a> quite arbitrarily decided by miscellaneous people (or forced by <a target="_blank" href="https://news.bitcoin.com/verge-is-forced-to-fork-after-suffering-a-51-attack/">cyber attacks</a>), and endless battles between different currencies, or different versions of the same currency (Bitcoin Core, Cash, Gold, SV...). Algorithms (cryptography, consensus, transaction code...) were praised as the foundations of a bullet-proof and self-governing system, but some actors had to <a target="_blank" href="https://www.coindesk.com/crypto-developer-komodo-hacks-wallet-users-to-foil-13-million-hack">hack their own users</a> to protect them from theft, while even the so glorified "smart contracts" showed loads of <a target="_blank" href="https://blog.sigmaprime.io/solidity-security.html#">scary security weaknesses</a>, and <a target="_blank" href="https://www.coindesk.com/three-smart-contract-misconceptions">not as many use cases</a> as some expected.</p>
<p>Let's make it clear: the blockchain, a public ledger based on Merkle trees, is far from a bad idea. But when decisions are not based on the needs of society, and carefulness regarding bugs, but on ideology and greed, the outcome can be predicted. And the decline in hype is proportional to unduly invested hopes.</p>
<p>What is the "better" counterpart of Bitcoin, Ethereum, and the like? Lots of alternative cryptocurrencies exist, with lighter forms of authorization, with different crypto algorithms, with different privacy settings, with different adoption rates too... But if you ask me, what we would really need is "<strong>an easily traceable money for State finances and NGOs</strong>"; a public ledger designed so that any citizen could easily audit how public money is used, from the moment it's gathered via taxes and donations, to the moment it gets back into private circuits by paying goods or employee salaries. <em>Does anything like this exist yet, anyone? Couldn't find it...</em></p>
<p>One could also mention non-cryptographic but <em>local</em> moneys (ex. the "<a target="_blank" href="https://translate.google.com/translate?sl=fr&amp;tl=en&amp;u=http%3A%2F%2Fwww.lagonette.org%2F">Gonette</a>" in Lyon, France), kept on parity with national moneys, which have the advantage of favoring local businesses and thus lowering the collateral damages of international trade.</p>
<h2 id="heading-data-formats-text-and-binary">Data Formats: Text and Binary</h2>
<p>A witty passerby once defined XML as "<em>the readability of binary data with the efficiency of text</em>". Indeed XML parsers tend to be sluggish, and to clutter memory (when in DOM mode), compared to binary data loaders; and editing XML configurations and documents by hand is not the best user experience one might have.</p>
<p>We easily understand why XML, as a metalanguage allowing to create new tags and properties for all kinds of uses, needs to be so verbose. But why such enthusiasm for text-based formats, when the goal is to transmit information between servers using well-defined data types ?</p>
<p>Parsing HTTP payloads into an internal representation, and then parsing, for example, its JSON body, ends up adding significant overhead to webservice requests. For what gain ? Binary formats like <a target="_blank" href="http://bsonspec.org/">Bson</a> would make the serialization/deserialization much more performant; and semantically equivalent text formats could be used for debugging (auto-converted by web browser dev tools, Wireshark, CURL and the likes), and for manually crafting test payloads.</p>
<p>For sure, handling these dual representations of the same data would add a bit of complexity to the system, but in an era when startups love exposing webservices to thousands simultaneous clients, the performance boost can be real, with not so much effort. </p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>What's the moral of all this? Always the same, "<em>use the right tool for the right job, and beware of irrational fads</em>". It can take lots of reading before one has a sufficient depth of view, on a specific matter, to take educated decisions; but this investment quickly pays off. </p>
<p>Guessing how well a framework will be supported on the long-term, or which protocol/format will win a standardization war, is a different problem, but at least we can have our opinions firmly founded, when it comes to purely technical aspects, and this is Gold.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Four architecture pattern candidates for Blockchain-based decentralized applications ]]>
                </title>
                <description>
                    <![CDATA[ By Srinath Perera Blockchain has a diverse set of use cases, ranging from finance to a decentralized Internet. However, most blockchain use cases can be implemented using relatively few patterns. For example, A Pattern Collection for Blockchain-based... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/https-medium-com-srinathperera-blockchain-patterns-6cf58fdc2d9b/</link>
                <guid isPermaLink="false">66d4614b706b9fb1c166b9b1</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software architecture ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 23 Apr 2019 15:49:36 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*iCv3PnwJ3jvu2pDhEq3ZhQ.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Srinath Perera</p>
<p>Blockchain has a diverse set of use cases, ranging from finance to a decentralized Internet. However, most blockchain use cases can be implemented using relatively few patterns. For example, <a target="_blank" href="https://www.researchgate.net/publication/325439030_A_Pattern_Collection_for_Blockchain-based_Applications">A Pattern Collection for Blockchain-based Applications</a> provides a list of 15 Blockchain patterns.</p>
<p>Fine-grained patterns, such as described above, are useful. However, system design needs a much higher level of abstractions. It is useful also to have more coarse-grained macro patterns, which we call architecture patterns. This post describes four such architecture patterns.</p>
<p>Let’s get started. To describe patterns, I will use the template described in by Aleksandra Tešanovic in <a target="_blank" href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.123.1162&amp;rep=rep1&amp;type=pdf">What is a Pattern</a>?</p>
<h3 id="heading-architecture-pattern-for-iam">Architecture Pattern for IAM.</h3>
<p><strong>Context:</strong> IAM environments include many users and service providers. IAM systems give each user an account and set of capabilities enabling users to go to service providers, demonstrate their ownership of accounts, and then receive services based on their capabilities.</p>
<p><strong>Forces:</strong> Need to implement a decentralized IAM environment where a single rogue user or few users can’t significantly affect the system.</p>
<p><strong>Solution:</strong> Proposed pattern candidate uses World Wide Web Consortium (W3C) DID specification and W3C Verifiable Claims specification in the following manner.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/lUMFQa8e5GZRqE9PVExbKKUBq43VTd0LCauy" alt="Image" width="800" height="760" loading="lazy">
<em>Figure 1: Blockchain-based IAM Architecture Pattern</em></p>
<p>Let’s assume Alice needs an identity (DID, which is a unique identifier). As shown by the figure for creating a new DID, Alice creates an entry in the blockchain. This entry includes a randomly generated identifier, a link to the repository with her profile data, and a hash of the profile data. The user profile contains a public key and a set of verifiable claims. The generated random identifier now becomes Alice’s DID because only she owns the private key that corresponds to the public key.</p>
<p>Verifiable claims are delegation tokens signed by a competent authority. The creator also records them in a blockchain together with the hash of the claim in a manner similar to the DID.</p>
<p>Alice obtains the verifiable claims in the first place by going to authorities. For example, the department of personal registration or equivalent is the proper authority for verifiable claims of name, address, and date of birth. Assuming authorities issue verifiable claims, Alice first demonstrates her ownership of the DID uses a challenge-response-protocol. Then she submits requests for verifiable claims for her attributes, which may, for example, include her name, address, degree, and date of birth. To update her profile data, Alice will add a new entry to the blockchain with a new hash of the profile.</p>
<p>In the challenge-response-protocol, the validator generates a random seed, encrypts it using Alice’s public key, and then challenges Alice to demonstrate that she has the private key by decrypting the encrypted seed. Since Alice has the private key, she must be the owner of the DID.</p>
<p>A different user or an organization (authenticator), Bob, who wants to identify Alice, first receives the DID from Alice, read all entries related to that DID from the blockchain, retrieve Alice’s profile data, and verify them. Bob can verify the identity of Alice (identification) again using challenge-response-protocol. Then Bob can confirm the verifiable claims and be assured that the claims about Alice are true.</p>
<p>We can layer most IAM use cases on top of this architecture pattern. For example, we can achieve access control either by issuing verifiable claims for actions we want users to perform or by only accepting users who have certain properties (e.g., age, job description, group membership) in their verifiable claims. An implementation may choose to cache relevant subsets of the profile data in a database to improve performance.</p>
<h3 id="heading-architecture-pattern-for-auditable-history-or-workspace">Architecture Pattern for Auditable History or Workspace</h3>
<p><strong>Context:</strong> A two or more parties perform transactions or works together, and their activities need to be recorded in an indisputable manner.</p>
<p><strong>Forces:</strong> Need to implement a decentralized audit log or a workspace where a single rogue user or few users can’t significantly affect the system.</p>
<p><strong>Solution:</strong> The proposed system records activities and creates entries in the blockchain for those records. The entry contains the hash of activity records, and therefore, the records can’t be disputed later.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/iF-qjFAl8ERHYc8MkajFeVnIUK10RiWz2RVG" alt="Image" width="800" height="692" loading="lazy">
<em>Figure 2: Blockchain based Auditable History or Workspace Architecture Pattern</em></p>
<p>For example, let’s assume Alice wants to pay a tax. Tax Server accepts the payment application, creates a digital receipt, records its hash in the blockchain, and sends the receipt to Alice. Alice can verify the receipt by calculating the hash and checking against the value stored in the blockchain. After this, Bob can’t deny the receipt because the receipt hash and time are recorded in the blockchain.</p>
<p>If the activities are numerous, there may be a need to workaround blockchain performance limitations. Therefore, some implementations may record a hash of several activity records as a block instead of a single activity record.</p>
<h3 id="heading-architecture-pattern-for-registry-or-marketplace">Architecture Pattern for Registry or Marketplace</h3>
<p><strong>Context:</strong> A registry is a collection of data entries that can be searched and retrieved over the network. A market place is a registry that allows users to buy the services or products represented by data entries. For example, a registry may be a catalog of available APIs.</p>
<p><strong>Forces:</strong> Need to implement a decentralized environment where a single rogue user or few users can’t significantly affect the system.</p>
<p><strong>Solution:</strong> The proposed pattern works as follows.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/PxrO0b03JFpQ-JuWXHXtzkfq56xJHND3gesV" alt="Image" width="800" height="564" loading="lazy">
<em>Figure 3: Blockchain based Registry Architecture Pattern</em></p>
<p>Let’s first consider a registry. With the proposed architecture, when a user issues a registry update (to add or modify an entry), the client records the change in the blockchain. If data in the update is large, the blockchain record may contain a link to the data and a hash value of the data. If data stored in the registry needs to be amended, the registry client adds a new record to the blockchain with amended information.</p>
<p>In the diagram above, each user has a registry client running in the local machine (e.g., laptop or phone). Each registry client reads the update records from the blockchain, verifies the update data against the hash included in the records, and reconstructs the most current view of records from updates. For example, by reading blockchain records about APIs, their additions, amendments, and removals, the registry client can create a view that shows current APIs included in the registry. To avoid having to read and verify all records every time the registry is used, clients might store data in a database and index it. The client should periodically check the blockchain and update the registry.</p>
<p>Blockchain works well as a “service marketplace,” since the same service may be sold many times. However, due to performance limitations, blockchain-based marketplaces are not suitable for items that can be sold only once.</p>
<p>To illustrate, the functionality of a blockchain-based registry, let’s look at when Alice wants to subscribe to “weather news service” in the blockchain marketplace. When she submits her request, the registry creates credentials for the service and shares it with Alice. The payment may happen in one of several ways: using Bitcoins, via a smart contract where payments are made on a timely basis, or by some out-of-bound means.</p>
<h3 id="heading-architecture-pattern-for-smart-contracts-and-managed-things">Architecture Pattern for Smart Contracts and Managed Things</h3>
<p>Under this pattern, we consider two cases. First, we consider smart contracts, and as the second, we consider a common special case of smart contracts: “Managed Things.”</p>
<h4 id="heading-smart-contracts-pattern">Smart Contracts Pattern</h4>
<p><strong>Context:</strong> Multiple users want to abide by a contract, described as an executable program. Contract undergoes state transitions as per conditions defined in the contract, and at a given time, everyone can agree on the current status of the contract.</p>
<p><strong>Forces:</strong> need to implement an environment where a single rogue user or few users can’t significantly affect the system.</p>
<p><strong>Solution:</strong> Smart contacts are part of blockchain technologies and supported by blockchain implementations, such as Ethereum. A contract is described using a smart contract language and distributed to all participants. As conditions defined in the contract changes, each participant executes the contract and records the current status in the blockchain using the consensus algorithm.</p>
<h4 id="heading-managed-things-pattern">Managed Things Pattern</h4>
<p><strong>Context:</strong> We need to track the ownership of real-world smart things. Here smart things are real-world objects that are capable of running computing logic within them. The owner is allowed to control and perform actions on the real world things. Also, the owner may transfer his ownership to someone else.</p>
<p><strong>Forces:</strong> need to implement an environment where a single rogue user or few users can’t significantly affect the system.</p>
<p><strong>Solution:</strong> Following describes the implementation of the pattern using Car as the managed thing as an example.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/8je7rRiQV0zVRuuvCXjnHJHMNlnNjOrv29r4" alt="Image" width="800" height="470" loading="lazy">
<em>Figure 4: Blockchain based Managed Things Architecture Pattern</em></p>
<p>We can implement a blockchain for a managed thing, in this case, a car, in two steps. First, the manufacturer records the DID and the public key of the owner of the car. When ownership changes, the owner adds a new record in the blockchain specifying the new owner. Second, when checking for ownership, the car first retrieves all records in the blockchain and verifies that each record is added by the owner at that time. This is done by checking the public key of the user who wrote the record against the public key included in the previous ownership record. The last owner in this valid chain is the current owner.</p>
<p>After determining the owner, the car logs in the current owner, Alice, by retrieving her public key and carrying out a challenge-response-protocol-based login with Alice’s phone, which has Alice’s private key.</p>
<p>Such a system reduces the risks associated with remotely controlled artifacts. For example, in a non-blockchain implementation, someone with access can change the ownership of your car. However, with the blockchain-based model, to remotely control the car, a would-be attacker must change the ownership record in the blockchain, which is very hard to achieve without being the owner.</p>
<p>However, it is hard to stop someone who has access to the “thing” from physically changing the logic running inside (e.g., by replacing the firmware of the car). One solution to this problem is to build some form of self-destruct that triggers when tampering into the artifact is detected.</p>
<p>For example, Alice buys the car from Bob using a smart contract that pays Bob and updates the ownership of the vehicle. After the transaction, Alice walks to the car, which reads Alice’s DID from the phone, retrieves her public key, authenticates her using a challenge-response-protocol by communicating with the phone that has Alice’s private key, verifies her ownership, and unlocks the car.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>We discussed four blockchain based architecture patterns. The GitHub document, <a target="_blank" href="https://github.com/wso2/ETAC/blob/master/blockchain/blockchain-usecases.md">Blockchain-based Integration Use Cases</a>, shows these patterns in action, describing how 30-plus blockchain use cases can be implemented using these four patterns.</p>
<p>If you have opinions about the above patterns or know about other patterns, I would really like to hear about them.</p>
<p>I hope this was useful. If you like this, you might also like a detailed blockchain analysis in our recently published paper, “<a target="_blank" href="https://peerj.com/preprints/27529/">A use case centric survey of Blockchain: status quo and future directions</a>.”</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The most popular programming languages used in blockchain development ]]>
                </title>
                <description>
                    <![CDATA[ By Michael Draper We’re currently in the midst of a new burgeoning industry with blockchain development. Blockchain technology is very much in a nascent stage, however this disruptive technology has already managed to take the world by storm and has ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/the-most-popular-programming-languages-used-in-blockchain-development-5133a0a207dc/</link>
                <guid isPermaLink="false">66c361d10cede4e9b1329ce2</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 18 Jan 2019 16:36:39 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/0*NAV5EQqx0pxMr1tb" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Michael Draper</p>
<p>We’re currently in the midst of a new burgeoning industry with blockchain development.</p>
<p>Blockchain technology is very much in a nascent stage, however this disruptive technology has already managed to take the world by storm and has experienced a boom like no other in recent times.</p>
<p>With many well-funded projects now eager to build out their blockchain network and deploy decentralized applications on top of them, there’s a great shortage of capable, competent blockchain developers.</p>
<p>With billions having been funneled into this sector, the pay and demand for blockchain developers has escalated with projects bidding against each other to attract the best blockchain talent that is left on the market.</p>
<p>This gold rush may leave some developers wondering if they have what it takes to dive into this industry, and especially what programming languages are most sought after in this new industry. Almost all popular programming languages are used in the blockchain industry, however developers have to consider what type of development they would like to undertake as different languages are used for certain blockchain projects and applications.</p>
<p>Here’s a brief rundown of the different languages and projects that are utilizing them to serve as a basic understanding and foundation for those looking to dive deeper into this industry.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/RevQpoRAiseiZCE6uyQtPkt5fDB8HD8l8BvK" alt="Image" width="320" height="445" loading="lazy"></p>
<p><a target="_blank" href="https://solidity.readthedocs.io/en/v0.5.1/"><strong>Solidity</strong></a> — A new and simple programming language that is popular amongst Ethereum developers, as it is the language used for developing Ethereum smart contracts. <strong>Solidity</strong> is a contract-oriented Turing-complete programming language and <a target="_blank" href="https://www.trustnodes.com/2018/07/22/ethereums-ecosystem-estimated-200000-developers-truffle-seeing-80000-downloads-month">the number of developers is estimated at over 200,000</a>.</p>
<p>As Ethereum has taken the head start on smart contracts, many alternative blockchain platforms are ensuring that they are Solidity (or ERC-20) compatible, thus allowing smart contracts to be easily ported from Ethereum into their new blockchain networks.</p>
<p><a target="_blank" href="https://www.ethereum.org/"><strong>Ethereum</strong></a> <strong>—</strong> Technically Ethereum functions as an Ethereum Virtual Machine (EVM) as a “world computer”, and is made up of multiple languages including C++, Python, Ruby, Go, and Java. JavaScript serves as the backbone of Ethereum as it functions as a runtime environment with script execution.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/453Z55OmBXoA7bZWXbNMwXDKErgEWfjUzInx" alt="Image" width="256" height="256" loading="lazy"></p>
<p><strong>Java</strong> — A general-purpose programming language that is concurrent, object-oriented, and class-based is designed in such a way that Java has few implementation dependencies. Since its launch in 1995, Java has become one of the top 3 programming languages and rightly so with <a target="_blank" href="http://infomory.com/numbers/number-of-java-developers/">over 9 million developers</a>. <a target="_blank" href="https://nem.io/"><strong>NEM’s</strong></a> core blockchain network has been written solely in Java (soon to be C++).</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/bzwFfhuDu9UYcOnLazlQ9r4moMBEE5-MQ3Pw" alt="Image" width="300" height="288" loading="lazy"></p>
<p><strong>C#</strong> — An object-oriented language known to enable developers to build robust applications that run on the .NET Framework with at least <a target="_blank" href="https://blogs.msdn.microsoft.com/zxue/2016/10/24/how-many-developers-use-c-vs-c-vs-other-programming-languages/">2M developers worldwide</a>. C# was developed back in 2000. Since its inception, it has become a popular programming language used to build powerful cross platform code that works over multiple operating systems such as Windows, Mac, Linux, and Android. Blockchain projects written with C# include:</p>
<ul>
<li><a target="_blank" href="https://stratisplatform.com/"><strong>Stratis</strong></a> a Blockchain-as-a-Service provider backed by Microsoft, allows enterprises to build their own private blockchain systems.</li>
<li><a target="_blank" href="https://neo.org/"><strong>NEO</strong></a> was written in C#, however it also supports a variety of programming languages such as Javascript, Java, Python, and Go.</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/gA2Klhnw9OxLGs8tfY2nGb1Sw1QKVw0bzIdX" alt="Image" width="280" height="280" loading="lazy"></p>
<p><strong>Javascript —</strong> Often abbreviated as JS, this is a multi-paradigm language that supports event-driven, functional, and imperative (including object-oriented and prototype-based) programming styles. It is one of the most popular programming languages in the world used by at least <a target="_blank" href="https://appdevelopermagazine.com/9.7m-developers-use-javascript/">9.7M developers worldwide</a>.</p>
<p><a target="_blank" href="https://lisk.io/"><strong>Lisk’s</strong></a> SideChain Development Kit (SDK) is written in JavaScript and allows developers to build applications on top of Lisk’s blockchain platform.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/q0XCGHR7jwZtmBosEjQVxZBG2NTJKNt1bB-P" alt="Image" width="369" height="303" loading="lazy"></p>
<p><strong>SQL —</strong> Structured Query Language or ‘’Sequel’’ is a programming language developed by IBM used to communicate with databases that store, query, and manipulate data. There is an estimated <a target="_blank" href="https://blog.jetbrains.com/datagrip/2015/12/23/how-many-sql-developers-is-out-there-a-jetbrains-report/">7 million developers</a> for SQL today. Popular databases such as MySQL, PostgreSQL, SQL Server, DB2, Oracle and more all use SQL to develop applications. A blockchain project that incorporates SQL is:</p>
<ul>
<li><a target="_blank" href="https://www.aergo.io/"><strong>Aergo</strong></a> <strong>—</strong> An entreprise-ready blockchain solution developed by Blocko under their proprietary Coinstack technology utilizes SQL smart contracts. The <strong>Aergo</strong> chain features a <strong>SQL</strong>-based smart contract platform that will allow enterprise entities to create and execute advanced smart contracts in commercial business environments.</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/-7ltSXVwZ-2XGhF6mV9lRDJ7aawZBBuvUVMy" alt="Image" width="200" height="200" loading="lazy"></p>
<p><strong>C++</strong> — A general-purpose programming language with an estimated <a target="_blank" href="https://blog.jetbrains.com/clion/2015/07/infographics-cpp-facts-before-clion/">4.4 million developers</a>, it’s greatest strength lies in the capability to scale resource intensive applications and enable them to run smoothly, thus making it a very popular programming language for 3D games. Blockchain projects using C++ include:</p>
<ul>
<li><a target="_blank" href="https://eos.io/"><strong>EOS</strong></a> — C++ is the main programming language of EOS preferred for its flexibility to run extensive applications on top of the blockchain. EOS also supports any language that compiles into WebAssembly (WASM)</li>
</ul>
<blockquote>
<p><em>Random Fact: Bitcoin core’s network is programmed in C++.</em></p>
</blockquote>
<p><img src="https://cdn-media-1.freecodecamp.org/images/xDJHI4g0ZABEz-1rADp4Q7rWpRNmYdzjZeE-" alt="Image" width="607" height="318" loading="lazy"></p>
<p><a target="_blank" href="https://golang.org/"><strong>Golang</strong></a> — An open source general programming language loosely based on the syntax of the C programming language, Golang is easy for developers to learn, and for testers to understand. Currently there is an estimated <a target="_blank" href="https://research.swtch.com/gophercount">800,000+ developers</a> on the Golang language that is used by the consortium network:</p>
<ul>
<li><a target="_blank" href="https://hyperledger-fabric.readthedocs.io/en/release-1.3/"><strong>HyperLedger Fabric</strong></a> <strong>—</strong> Most of the chaincode (smart contracts built using HyperLedger Fabrics) is written in Golang. They also have a Java SDK for developing blockchain applications.</li>
</ul>
<p>Hopefully this has provided you with a basic overview of where to start and what to dig into further if the blockchain industry is something that interests you. There is little doubt that this industry will continue to further explode over the next decade or so as advancements are made and real-world adoption use cases emerge.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How does tokenization work, anyway? ]]>
                </title>
                <description>
                    <![CDATA[ By Albert Ho Not everything will be tokenized, but that which can be will be. 2017 saw the hype of utility tokens and ICOs. 2018 marks the hyped start of asset tokenization and the launch of securities tokens/platforms. This trend is notably huge in... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-does-tokenization-work-anyway-afb5fed1ac47/</link>
                <guid isPermaLink="false">66c34d124f7405e6476b01d8</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Ethereum ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Tokenization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 20 Oct 2018 13:06:04 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*7pMYW1axSFq7uO09x3UoqA.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Albert Ho</p>
<h4 id="heading-not-everything-will-be-tokenized-but-that-which-can-be-will-be"><strong>Not everything will be tokenized, but that which can be will be.</strong></h4>
<p><img src="https://cdn-media-1.freecodecamp.org/images/3S1xyeWzGYjjVeZp5EGSY1S6gFYFUEyYLl12" alt="Image" width="800" height="533" loading="lazy"></p>
<p>2017 saw the hype of utility tokens and ICOs. 2018 marks the hyped start of asset tokenization and the launch of securities tokens/platforms. This trend is notably huge in the U.S, given how A16z and GGV Capital invested in the likes of tokenization platforms like <a target="_blank" href="https://blog.trusttoken.com/trusttoken-raises-20-million-usd-in-strategic-round-88912d1dbc71">TrustToken</a>, <a target="_blank" href="https://techcrunch.com/2018/04/17/harbor-securities-tokenization/">Harbor</a>, and <a target="_blank" href="https://www.businessinsider.sg/a-startup-raised-59-million-in-a-token-sale-to-usher-in-the-next-generation-of-crypto-2018-2/?r=US&amp;IR=T">Polymath</a>.</p>
<p>In Asia, the trend is starting to pick up too. For instance, <a target="_blank" href="https://rate3.network">Rate3 Network</a> was funded by various notable Asian VCs that include Matrix Partners China and Fenbushi Capital.</p>
<p>Conceptually, tokenization <em>might seem</em> easy: Issue an ERC-20 token (or any other blockchain tokens), imbue legal rights and ownership rights in the tokens, and you can trade them easily. However, this warrants a much deeper look: how do you distinguish claim rights and ownership rights? What are the differences in tokenization between different asset classes? What is impeding tokenization from adoption?</p>
<p>Thinking comprehensively about tokenization requires an understanding of blockchains and smart contracts, legal, finance, and economics. There has already been in-depth research on each of these components.</p>
<p>In this piece, I want to give a comprehensive introduction to tokenization through using real estate as a primary example. Here’s what we’ll discuss:</p>
<ul>
<li><a class="post-section-overview" href="#8381">What <em>exactly</em> is Tokenization?</a> <em>(Is it not just securitization?)</em></li>
<li><a class="post-section-overview" href="#ccc3">What are the <em>real</em> benefits of tokenization?</a> <em>(Why do we even bother?)</em></li>
<li><a class="post-section-overview" href="#9264">What are some of the <em>tougher</em> issues to think about?</a> <em>(How do we ask the right questions?)</em></li>
<li><a class="post-section-overview" href="#57ff">What are the <em>challenges</em> for tokenization?</a> <em>(What’s stopping adoption?)</em></li>
<li><a class="post-section-overview" href="#789d">How will the tokenized <em>future</em> be?</a> <em>(What are some elements?)</em></li>
</ul>
<p><strong>Let’s get started!</strong></p>
<h3 id="heading-what-is-tokenization">What is Tokenization?</h3>
<h4 id="heading-isnt-tokenization-just-securitization">Isn’t Tokenization just securitization?</h4>
<p>For structured finance professionals, tokenization <em>might</em> seem like securitization. In summary, securitization consists of a few steps:</p>
<ol>
<li>Originator (owner of the assets) collects the assets in a pool and transfers the pool to a legal entity (usually a special purpose vehicle). Through this legal structure, assets are not exposed to counter-party risks or risk of bankruptcy of the originator bank</li>
<li>The SPV structures the assets within the pool into several tranches, according to different risk levels and characteristics usually. Securities are issued, and backed by the cash flows generated by the underlying assets.</li>
<li>After issuing the securities, the SPV sells the securities to investors, whilst transferring the proceeds to the originator afterwards.</li>
</ol>
<h4 id="heading-securitization-has-various-flaws"><strong>Securitization</strong> has various flaws.</h4>
<p>The classic <strong>securitization</strong> process is extremely costly and takes up a lot of time. The entire process might cost up to millions of dollars and takes up to a year. The securitization process requires agreements with various parties under conditions of asymmetric information, as well as a heterogeneous structure of asset data.</p>
<p>Furthermore, there might be a lack of full transparency in the various stages of securitization, all of which hinder auditing and rating of the underlying assets. In the sub-prime mortgage crisis, there is no transparency on the credit pool nor the audit process that lead to defaults on the bonds issued.</p>
<h4 id="heading-clearly-tokenization-securitization">Clearly, tokenization =/= securitization</h4>
<p>Tokenization — in its simplest definition — refers to converting an asset into a digital token on the blockchain system. The biggest difference between tokenization and securitization, is how programmability is introduced into the tokenized asset. This way, business logic can be introduced, reducing the need for manual settlements. Smart contracts can have functions for automatic transactions, formulas for calculating asset prices and other specific features.</p>
<h3 id="heading-what-are-the-real-benefits-of-tokenization-then">What are the real benefits of Tokenization then?</h3>
<p><img src="https://cdn-media-1.freecodecamp.org/images/-W6AlP3OdocdH7XlQG3vxR6Ki2ifpbdwyCfS" alt="Image" width="800" height="532" loading="lazy">
<em>Photo by @sanfrancisco, Unsplash</em></p>
<p>Numerous research pieces have talked about various benefits of tokenization, but these various benefits can be categorized into three core principles: 1) <strong>liquidity</strong>, 2) <strong>programmability</strong> and 3) <strong>immutable proof of ownership</strong>.</p>
<h4 id="heading-key-principle-1-liquidity">Key Principle 1: Liquidity</h4>
<p><a target="_blank" href="http://www3.weforum.org/docs/WEF_GAC15_Technological_Tipping_Points_report_2015.pdf">World Economic Forum</a> predicts that over the next ten years, 10% of the world’s GDP will be stored in crypto assets, amounting to $10 trillion. This is primarily due to increased fractional ownership, and unlocking of liquidity premiums.</p>
<p>Assuming no legal and regulatory barriers, tokenization allows for increased fractional ownership. Most tokens can be broken into 18 decimals, as compared to fiat which can be broken down to $0.01 only. Fractional ownership lowers the barriers of entry for new investors. For instance, instead of paying $1 million for a new apartment, I can pay $50,000 for a tokenized fraction of the real estate. For investors, fractional ownership and lower barriers help them to increase portfolio diversification and construct a “truer” market portfolio.</p>
<p>The increase in liquidity helps unlock value for markets through liquidity premiums. When illiquid assets become more liquid, a <a target="_blank" href="http://people.stern.nyu.edu/adamodar/pdfiles/country/illiquidity.pdf">liquidity premium</a> of approximately ~20–30% is unlocked. One example is real estate: Even a fractional improvement in the sales price of such investments could result in trillions of dollars of new value for issuers and resellers.</p>
<h4 id="heading-key-principle-2-programmability-built-into-tokens">Key Principle 2: Programmability built into tokens</h4>
<p>Programmability refers to the ability to introduce <em>certain</em> business logic into smart contracts, allowing for automated events to occur. Tokenization can also lead to easier management of investors and their rights. Secondary transactions can be easily tracked by collaborating with third-party exchanges, allowing investors to receive distributions and exercise their other rights (e.g., voting) through the blockchain.</p>
<p>Programmability is especially useful in increasing the speed of settlements. In traditional finance, settlements refer to the process of documentation of the transfer of asset ownership before the ownership of assets actually changes hands. Compliance can be programmed into the tokens, if all participants have a digital identity that has gone through the relevant compliance/KYC/AML checks.</p>
<h4 id="heading-key-principle-3-immutable-proof-of-ownership">Key Principle 3: Immutable proof of ownership</h4>
<p>Blockchains are immutable and keep a public trace of every transfer, and owner. This digital trace of transactions not only proves the history of ownership but also helps to ensure less fraud. The immutable structure makes it impossible for a token-holder to “double-sell” a token — accepting a transfer for the same token to two different sources. This helps assure investors that no one can falsify transactions after the transaction has happened.</p>
<h3 id="heading-lets-dive-deeper-into-tokenization">Let’s dive deeper into tokenization.</h3>
<p><em>Tokenization is the process of digitally storing the property rights to a thing of value (asset) on a blockchain or distributed ledger, so that ownership can be transferred via the blockchain’s protocol. What are the other challenges?</em></p>
<h4 id="heading-issue-1-what-are-the-requirements-for-tokenization-to-take-place">Issue #1: What are the requirements for tokenization to take place?</h4>
<p>There are 3 fundamental requirements:</p>
<ol>
<li><strong>The rights to an asset can be stored digitally on a blockchain</strong></li>
</ol>
<p>Let’s go back to the real estate example. If I want to tokenize my house, I must be able to record my ownership of my house on a token itself. This means that to regulatory authorities, holding a token represents an ownership right or claim right on the house itself. <em>(We will go into these rights in a bit.)</em></p>
<p><strong>2. These rights can be legally transferred via blockchains</strong></p>
<p>Whilst I can document my rights to my house in a legally-recognized way, I should be able to transfer these rights to anyone I want and that person will have legal ownership of my house, assuming my tokens are imbued with ownership rights.</p>
<p><strong>3. Tokens can be easily exchanged for value, giving the assets “value”</strong></p>
<p>Lastly, like any security, I must be able to exchange my real estate token for value easily — so I can subscribe value to the asset.</p>
<h4 id="heading-issue-2-what-are-the-other-legal-issues-to-consider">Issue #2: What are the other legal issues to consider?</h4>
<p>Apart from the 3 requirements, what is more crucial to take note is the exact asset you are tokenizing: Does the token represent a claim on the asset or does the token represent actual ownership of the asset itself? Investors and token issuers must think carefully about what exactly a token represents.</p>
<p><strong>The truth is: it depends on what you want to tokenize. Tokenization is flexible.</strong> Using real estate as an example again, what can be tokenized could be direct ownership in the real estate (being a partial equity owner), right to rental income, or even the right to use an asset (renting the apartment).</p>
<p>Hence, a token could represent <em>ownership</em> of the underlying real asset, an <em>interest in a debt</em> secured by the asset, an <em>equity interest</em> in a legal entity that owns that asset, or a <em>right to the cash flow</em> from the asset.</p>
<h3 id="heading-there-are-3-basic-categories-of-rights-to-understand">There are 3 basic categories of rights to understand.</h3>
<p>The rights bestowed by tokenized securities (or security token) can be very complex to understand. However, tokenized securities can include claims to the assets (and usually the resulting cash flows), direct ownership rights, governance rights or a combination of all.</p>
<ol>
<li><strong>Claim rights:</strong> Claims to only certain specific uses (and claims) of the asset</li>
<li><strong>Ownership rights:</strong> Equity ownership and control of the asset</li>
<li><strong>Governance:</strong> System by which a group of people can come to unified decisions</li>
</ol>
<h4 id="heading-lets-illustrate-this-with-real-estate-again-with-a-few-examples-on-the-token-holders-rights">Let’s illustrate this with real estate again, with a few examples on the token holders’ rights:</h4>
<ol>
<li><strong>Claim rights, but no ownership rights</strong>: Token holders are entitled to cash flows from ongoing leases, but they have no ‘equity’ and ‘ownership’ of the underlying real estate</li>
<li><strong>Claim rights, AND ownership rights</strong>: Token holders are the ‘owners’ of the underlying real estate with claims to the cash flows. They can make decisions directly: how much to charge for rent, investments made to maintain the real estate, hiring staff and given the proceeds from the sale of the real estate.</li>
<li><strong>Only ownership rights:</strong> This example is rarely the case, but it means that token holders are now the ‘equity owners’ of the real estate.</li>
</ol>
<h4 id="heading-what-are-the-challenges-that-arise-from-these-different-rights">What are the challenges that arise from these different rights?</h4>
<p>It is possible that there is a separation of claim rights and ownership rights, and this creates misaligned incentives between both parties.</p>
<p><strong>What if… the tokens have ownership rights for token holders?</strong> How do 1,000 token holders make decisions collectively for the best of the assets? Is there a need for delegated voting or decision making?</p>
<p><strong>What if… the tokens only imbue claim rights for token holders?</strong> The token issuers (owners) can reduce profits and cash flows to the token holders, by re-investing the profits. This will be to the detriment of token holders who originally look towards the future cash flow.</p>
<p>The smart contract geek might ask: <em>can’t one automate all these logic in smart contracts?</em></p>
<h3 id="heading-no-smart-contracts-cannot-solve-all-these-issues">No, smart contracts cannot solve all these issues.</h3>
<p><img src="https://cdn-media-1.freecodecamp.org/images/lP3pwrUqO9p3X0gH66HrJVmelSsIPHUmAh18" alt="Image" width="800" height="458" loading="lazy"></p>
<p>Contracts and smart contracts are <strong><em>incomplete:</em></strong></p>
<ol>
<li><em>Contracts are only enforceable when events and actions can be verified by a third party</em></li>
</ol>
<p>This is the long-standing problem of “<strong><em>oracles</em></strong>” in tokenization. There are some events that can be captured in code, but near impossible for any arbiter to determine if they really happened.</p>
<p>For instance, I issued out real estate tokens to holders so they can receive a portion of the rental income. However, it is possible that I do not document down all the rental agreements so token holders do not know what the real amount of rental income is. If this cannot be enforced effectively, there is no rational reason for parties to abide by the smart contract.</p>
<p><em>2. It is near impossible to write a contract that contains all possible conditions and events, hence achieving “completeness”</em></p>
<p>The problem with contracts is not what is in them, it is what is not in them. It is very costly and operationally challenging to write down every condition and event. Furthermore, events and conditions change in real life — and contracts have to adapt to these real-life changes.</p>
<p>Given the limitations of smart contracts as inherently incomplete, certain asset types should not be tokenized.</p>
<h3 id="heading-what-should-not-be-tokenized">What should not be tokenized?</h3>
<ol>
<li><strong>When the blockchain cannot fully capture the change of ownership of assets</strong></li>
</ol>
<p>There are some assets in markets where I can sell the physical asset outside of the protocol directly, despite it being tokenized. For instance, I can tokenize real estate and transfer the token (with ownership rights) to you, but it is possible I can also legally sell the same real estate to another.</p>
<p>There are also other cases when I can trade tokens, but have no guarantees that I can verify the authenticity of the underlying asset. In the case of real estate, it is easier to verify, but other examples include gold bars. If it takes a lot of costs and resources to verify the authenticity, tokenization might not be a viable solution.</p>
<p><strong>2. When the use of prices impede the protocol from achieving its objectives</strong></p>
<p>There are some situations in which we don’t <em>want</em> prices to determine who gets what. Sometimes, prices do not capture external societal benefits and costs, and might not be the most equitable way to allocate resources. Examples include social goods, for instance.</p>
<p><strong>3. Sometimes, we just <em>do not want</em> to tokenize some ‘assets’ and rights</strong></p>
<p>For instance, rights to birth certificates or educational records should not be tokenized since they represent a <em>unique</em> right. We do not, and should not tokenize these ‘assets’.</p>
<p>Clearly, there are some asset classes that _should no_t be tokenized, given real-life limitations.</p>
<h3 id="heading-how-do-you-really-tokenize">How do you really tokenize?</h3>
<p>We have walked through the <em>what</em> and <em>why of tokenization,</em> now let’s talk a little about the <em>how</em> of tokenization.</p>
<p>There are a few categories of assets that have been tokenized:</p>
<ul>
<li><strong>Fiat currencies</strong></li>
</ul>
<p>The tokenization of fiat currencies gave rise to stablecoins. <a target="_blank" href="https://tether.to">Tether</a> is the first example, creating USDT. However, there are inherent challenges with Tether. For a good, updated summary on stablecoins, I suggest this:</p>
<p><a target="_blank" href="https://blog.goodaudience.com/stablecoins-are-now-officially-in-vogue-again-131383ab8db9"><strong>Stablecoins are now officially in vogue again</strong></a><br><a target="_blank" href="https://blog.goodaudience.com/stablecoins-are-now-officially-in-vogue-again-131383ab8db9">_With seemingly one new project unveiling multi-million-dollar funding every other week, no one will blame you for…_blog.goodaudience.com</a></p>
<ul>
<li><strong>Gold</strong></li>
</ul>
<p>An example of a gold tokenization project is <a target="_blank" href="https://digix.global/dgx/">Digix</a>.</p>
<p>Each DGX token is 1:1 gold-backed, and 1 token represent 1 gram of 99.99% gold from London Bullion Market Association-certified refiners, with gold stored in The Safehouse vault. Purchasing 1 DGX token is equivalent to purchasing actual gold itself.</p>
<ul>
<li><strong>Real Estate</strong></li>
</ul>
<p>My primary interest lies in real estate, given the analogy between REITs and tokenized real estate. A few interesting examples are <a target="_blank" href="https://www.forbes.com/sites/rachelwolfson/2018/10/03/a-first-for-manhattan-30m-real-estate-property-tokenized-with-blockchain/#537f78784895">how a Manhattan real estate property was most recently tokenized</a>, or <a target="_blank" href="https://venturebeat.com/2018/10/09/elevated-returns-gets-18-million-for-st-regis-aspen-resort-tokenized-real-estate/">how a portion of the St. Regis Aspen is tokenized</a>. In the case of St. Regis Aspen, each Aspen token represents an indirect ownership interest in a common stock of the St. Regis Aspen REIT. According to Elevated Returns, the “REIT provides tax efficient structure while the blockchain provides peer-to-peer investing and cross-border transaction made simpler for investors.”</p>
<h3 id="heading-clearly-there-are-many-challenges-associated-with-tokenization">Clearly, there are many challenges associated with tokenization.</h3>
<h4 id="heading-1-lack-of-tokenization-standards-and-legal-infrastructure">1. Lack of tokenization standards and legal infrastructure</h4>
<p>Tokenization is not simply the creation of a token — any Solidity developer can do it. Instead, it’s about the design of the whole system, including understanding the various rights and issues we’ve talked about previously.</p>
<p>How do tokenization standards cater for these issues:</p>
<ul>
<li>Incentives (claim rights, ownership rights, governance)</li>
<li>Privileges of users and system admins (who operate the token contracts)</li>
<li>Life-cycle management of an asset (issuance, payouts, withdrawal)</li>
<li>Security management</li>
<li>Integration of KYC/AML requirements across different jurisdictions</li>
<li>Integration with exchanges</li>
<li>Interoperability between different public chains</li>
</ul>
<p>In the case of cross-chain interoperability, we do see different chains with different nascent characteristics. For instance, Ethereum has scalability issues but provides for more complex Turing-complete smart contracts. How about other public blockchain networks like Stellar or IOST or Zilliqa?</p>
<p><em>How can tokenized assets (in the form of tokens) be interoperable across these different chains?</em></p>
<h4 id="heading-2-digital-identity-thats-globally-and-legally-recognized">2. Digital identity that’s globally and legally-recognized</h4>
<p>From a regulatory point of view, it is a regulatory nightmare for assets to be issued and transferred across citizens of different legal jurisdictions.</p>
<p>Suppose I am an EU resident looking to tokenize my real estate and the token only imbues claim rights. How do I transfer this token to U.S persons, whilst taking into account their identity, KYC/AML issues, U.S regulations, taxes and all the other issues?</p>
<p><em>How can I reasonably and easily deal with a verified, attested U.S person in a legally-compliant way for both our national jurisdictions?</em></p>
<h4 id="heading-3-tokenization-does-not-mean-instant-liquidity">3. Tokenization does not mean instant liquidity</h4>
<p>Liquidity is the biggest challenge in the security token space and it does not happen organically. History has given us various examples of financial markets and instruments that have not yet achieved significant levels of liquidity. Helping to create liquidity through allowing institutional investors or accredited retail investors — through custodian solutions will be key. Of course, the underlying asset must be useful.</p>
<p><em>How do we introduce long-term, sustainable solutions for large institutional investors — the market makers — to create and maintain liquidity?</em></p>
<h3 id="heading-what-does-a-tokenized-future-look-like">What does a tokenized future look like?</h3>
<p><img src="https://cdn-media-1.freecodecamp.org/images/VROVXufGdaPXFsGlBxX3mnk1zyqtHrnrX0Wi" alt="Image" width="800" height="519" loading="lazy"></p>
<p>I’m generally bullish on a tokenized future: a fairer, more equitable world with lower barrier to entry and capital requirements for individuals or businesses.</p>
<p>Through capturing value in tokenized assets, we can re-create all the sophistication of the existing financial and operational world we live in, with far less operational costs and complexities. When combining tokenization with reasonably complex business logic enabled by smart contracts, we can represent complex business interactions faithfully and more efficiently.</p>
<h4 id="heading-there-will-be-interoperability-through-standardization">There will be interoperability, through standardization</h4>
<p><strong>ERC 20 for token standards, as an example</strong></p>
<p>If the ecosystem for global assets becomes interoperable, it means we can hold ownership claims to a commercial building, early-stage equity, corporate bonds, a T-bill, a single-family residence, and a decentralized network on the same platform.</p>
<p>Different assets can reference each other contractually and interact in an automated way. It means an increased liquidity for all (tokenized) asset classes.</p>
<p><strong>ERC 725 for Identity, as another</strong></p>
<p><a target="_blank" href="https://twitter.com/feindura?lang=en">Fabian Vogelstellar</a> — creator of the ERC 20 standard — is leading the front for a unique decentralized identity for “humans, groups, objects and machines”. Quoting directly from the ERC 725 Github itself, “ This identity can hold keys to sign actions (transactions, documents, logins, access, etc), and claims, which are attested from third parties (issuers) and self-attested (<a target="_blank" href="https://github.com/ethereum/EIPs/issues/735">#ERC735</a>), as well as a proxy function to act directly on the blockchain”.</p>
<p>You can read more here about <em>ERC 725</em> here:</p>
<p><a target="_blank" href="https://github.com/ethereum/EIPs/issues/725"><strong>ERC: Identity · Issue #725 · ethereum/EIPs</strong></a><br><a target="_blank" href="https://github.com/ethereum/EIPs/issues/725">_eip: title: ERC-725 Identity author: Fabian Vogelsteller (@frozeman) discussions-to…_github.com</a></p>
<p>There are notable projects that have been working on implementing ERC 725 identity contracts. A few examples are: <a target="_blank" href="https://www.originprotocol.com/en">Origin Protocol</a> and <a target="_blank" href="https://rate3.network">Rate3 Network</a>.</p>
<p><a target="_blank" href="https://medium.com/originprotocol/managing-identity-with-a-ui-for-erc-725-5c7422b38c09"><strong>Managing Identity with a UI for ERC 725</strong></a><br><a target="_blank" href="https://medium.com/originprotocol/managing-identity-with-a-ui-for-erc-725-5c7422b38c09">_At Origin, we’re building a platform for decentralized, peer-to-peer marketplaces. You can imagine a future Airbnb-like…_medium.com</a><a target="_blank" href="https://medium.com/official-rate3/rate3-cross-chain-identity-protocol-identity-and-claims-erc-725-erc735-c6e51f422e7b"><strong>Rate3 Cross-Chain Identity Protocol — Identity and Claims (ERC 725, ERC735)</strong></a><br><a target="_blank" href="https://medium.com/official-rate3/rate3-cross-chain-identity-protocol-identity-and-claims-erc-725-erc735-c6e51f422e7b">_At Rate3, we initially wanted to build a blockchain-based settlement and clearance network for businesses. We…_medium.com</a></p>
<h3 id="heading-the-future-of-tokenization-is-not-here-yet-but-it-will-be-sooner-than-we-know">The future of tokenization is not here (yet), but it will be sooner than we know</h3>
<p>We are optimistic and bullish for the future of tokenization and tokenized securities. There are many elements of the envisioned tokenized future that we observe today:</p>
<ol>
<li><strong>Governments are increasingly partnering with private companies to create infrastructural solutions</strong></li>
</ol>
<p>One such example is the collaboration between <em>NASDAQ</em>, <em>Monetary Authority of Singapore</em> (Singapore’s Central Bank) and <em>Singapore Exchange</em> (Singapore’s main stock exchange) to develop Delivery versus Payment capabilities for settlement of tokenized assets across different blockchain platforms to improve operational efficiency and reduce settlement risks.</p>
<p><a target="_blank" href="http://www.mas.gov.sg/News-and-Publications/Media-Releases/2018/MAS-and-SGX-partner-Anquan-Deloitte-and-Nasdaq-to-harness-blockchain-technology.aspx"><strong>MAS and SGX partner Anquan Deloitte and Nasdaq to harness blockchain technology</strong></a><br><a target="_blank" href="http://www.mas.gov.sg/News-and-Publications/Media-Releases/2018/MAS-and-SGX-partner-Anquan-Deloitte-and-Nasdaq-to-harness-blockchain-technology.aspx">_Singapore, 24 August 2018… The Monetary Authority of Singapore (MAS) and Singapore Exchange (SGX) today announced a…_www.mas.gov.sg</a></p>
<ol start="2">
<li><strong>Projects have recognized the need for compliance, and are creating solutions that target automated compliance and AML/KYC</strong></li>
</ol>
<p>We have touched about the need to meld real-world legal requirements into the blockchain space. There are various projects that have been doing these globally:</p>
<ol>
<li><a target="_blank" href="https://harbor.com/"><strong>Harbor</strong></a>: <em>A compliance platform and protocol to ensure tokenized securities comply with existing securities laws at issuance and on every trade, everywhere across the globe.</em></li>
<li><a target="_blank" href="https://rate3.network"><strong>Rate3 Network</strong></a>: <em>A protocol that handles asset-tokenization and identity management across both Ethereum and Stellar blockchains.</em></li>
<li><a target="_blank" href="https://polymath.network/"><strong>Polymath:</strong></a> <em>A security token platform on which regulatory-compliant tokens can be built</em></li>
</ol>
<p>I do notice more blockchain projects building tokenization solutions targeted at different asset classes, different ways of modeling structured finance through issuing both debt and equity tokens, for instance. More importantly, these solutions know that working directly with regulatory authorities, collaborating with central banks and other projects will help to improve the overall ecosystem.</p>
<p>Ensuring the legally-compliant design of the whole system is key.</p>
<p><strong>3. “Paths of least resistance” will help everyone relate existing real examples to upcoming tokenization projects</strong></p>
<p>Real estate have always been quoted as an example for tokenization projects. This is due to the structure of real estate investment trusts (REITs), that one could relate more easily to tokenized structures.</p>
<p>Tokenized real estate is <em>not</em> REITs, but there are various principles we can use to help us understand, relate and think better: property rights, economics for REITs for instance.</p>
<p><em>Not everything will be tokenized, but those that can be will be.</em></p>
<p><em>Disclosure: I work at <a target="_blank" href="https://www.rate3.network/">Rate3 Network</a>, a dual-protocol that handles asset-tokenization and identity management across both Ethereum and Stellar blockchains.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Satoshi Nakamoto’s Bitcoin Whitepaper: A thorough and straightforward walk-through ]]>
                </title>
                <description>
                    <![CDATA[ By Valentijn v/den Hout When I first read the original bitcoin whitepaper published by Satoshi Nakamoto (2008), it clarified a lot of fundamental questions I had regarding the cryptocurrency and blockchains in general. The paper, as many well-read bl... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/satoshi-nakamotos-bitcoin-whitepaper-a-walk-through-3e9e1dee71ce/</link>
                <guid isPermaLink="false">66c35e3de9895571912a0d0a</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 12 Sep 2018 19:48:13 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*cZrXuxTThqjN_H-py_RbTw.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Valentijn v/den Hout</p>
<p>When I first read the original bitcoin whitepaper published by Satoshi Nakamoto (2008), it clarified a lot of fundamental questions I had regarding the cryptocurrency and blockchains in general. The paper, as many well-read blockchain and crypto professionals will confirm, is a fantastic starting point for anybody looking to learn more about the technology.</p>
<p>The goal of this post is to walk you through the whitepaper while making it as digestible as possible for anybody that is new to the field. I will aim to simplify some parts while maintaining the accuracy of the content.</p>
<p>Let’s stall no longer and dive right in. 🙌</p>
<p>PDF: <a target="_blank" href="https://bitcoin.org/bitcoin.pdf">Bitcoin: A peer-to-peer electronic cash system.</a></p>
<h3 id="heading-before-we-start">Before we start…</h3>
<p>A blockchain is a ledger or database. It is distributed across and maintained by a large number of nodes (computers) in contrast to it being held by a single authority or party. The goal of the technology behind cryptocurrencies such as Bitcoin is to make it possible to reach an agreement (consensus) on the validity of the data in the database and that of data to be added to the database 🤝. Data, in this case, refers mainly to online transaction data that determines ownership of digital assets such as cryptocurrencies or tokens.</p>
<p>The entire distributed ledger is kept up to date and verified, and all participants in the network agree on its validity. Without immediately diving into the technical workings, blockchain protocols such as the one underlying Bitcoin, allow this agreement and validation to be achieved without the need for a third-party intermediary, such as a bank 🏦.</p>
<p>In the past, such a party was necessary in order to verify ownership of money (i.e., can this person spend this money). The party also made sure that an online payment was only spent once. (i.e., that particular money is not used in another transaction). The latter issue is what is referred to as the <strong>double-spend problem</strong>.</p>
<p>This has always been a major issue for transacting digital assets. It is possible to duplicate the code that makes up the asset and use it in multiple transactions.</p>
<p>The name “blockchain” comes from the way the data is stored. Data are collected in blocks 📦 which are added to a chain ⛓️ of previously validated blocks. With this as an introduction, let us get straight to it and dive into the ever famous whitepaper.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/LPRtCW--yLwGP5QKh5Z1uwmysOOlu56uKgJ9" alt="Image" width="800" height="280" loading="lazy">
<em>by Mike Alonzo via Unsplash</em></p>
<h3 id="heading-abstract">Abstract</h3>
<p>The abstract of the whitepaper goes quite deep right of the bet and serves as a small summary of the paper. Do not worry if this goes over your head initially 🙆‍‍. We already covered most of what you need to know and will add to this in the next section.</p>
<p>The only takeaway here should be that the paper proposes a peer-to-peer electronic cash system. The system allows us to make online payments directly to each other. There is no need for a bank to solve the problems of ownership and double-spending. 💁 → 💵 → 🙋‍ and ❌🏦?</p>
<blockquote>
<p>“A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution.”</p>
</blockquote>
<h3 id="heading-introduction">Introduction</h3>
<blockquote>
<p>“Commerce on the Internet has come to rely almost exclusively on financial institutions serving as trusted third parties to process electronic payments.”</p>
</blockquote>
<p>At the time of writing of the Bitcoin whitepaper, financial institutions were necessary to verify ownership and eliminate the double spend problem. This, together with the need for transactions to be reversible (financial institutions have to deal with mediation disputes), increases the costs associated with a transaction. This means that there is a minimum transaction size necessary for these financial institutions to execute on it. Their fee needs to cover the transaction costs at least otherwise it does not make any sense. If it has not been clear before: banks really enjoy making money 💸.</p>
<blockquote>
<p>“… limiting the minimum practical transaction size and cutting off the possibility for small casual transactions.”</p>
</blockquote>
<p>This eliminates the option for a vast amount of transaction opportunities that theoretically exist but are practically not feasible. An amazing application that is not possible due to this minimum transaction size is the micro-consumption of online content, whether these are web articles, videos, music, and so forth. Instead of having to pay a monthly subscription, which may or may not be worth it depending on the usage by the consumer, micro-transactions would allow for a user to make incredibly small automated payments as the content is being consumed.</p>
<p>This would radically change the way we use the internet. Paying for Medium articles per word, YouTube videos per second, Spotify music per minute, or even consuming internet bandwidth per megabyte.</p>
<p>Another possible application would be to realize micro-payments directly between Internet-of-Things devices. A simple example here would be a parked car paying for its parking spot by the minute. There are countless micro-consumption/transaction applications, many of which will only become more apparent in the future. This is simply not possible if we need a third-party intermediary.</p>
<blockquote>
<p>“With the possibility of reversal, the need for trust spreads. Merchants must be wary of their customers, hassling them for more information than they would otherwise need.”</p>
</blockquote>
<p><img src="https://cdn-media-1.freecodecamp.org/images/YCo5BQ0vTov-f0qtxaUlHVNCk1KT3UTEOxkQ" alt="Image" width="800" height="233" loading="lazy">
<em>by Rawpixel via Unsplash</em></p>
<p>Another reason why the need for trust is not ideal when making online transactions is that in order to obtain said trust, personal information has to be collected, whether this is by the banks or by the merchants via which payments are made. This information is stored by these organizations (often on a single server), giving them control over the personal data and making the data prone to leakage or hacking 👾.</p>
<p>Incredible data hacks have taken place over the last decade — think of Yahoo and Equifax — and they are becoming more prominent by the day. What Bitcoin aims to accomplish is to, in some way, replicate the simplicity of an in-person transaction in an online environment.</p>
<p>If Andy hands Brenda a $10 note 💵, Brenda does not have to know anything about Andy (such as personal information, credit scores, net worth, etc.). The only thing she has to know is that the $10 went from being in Andy’s possession to be in her possession and that the $10 did not magically duplicate itself (💵 → 🧙‍ → 💵💵) and Andy has another (exact) replica to spend.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/3H2aKl5PWQEdz3Bn7k3lfRXYz1h-kapsRM0G" alt="Image" width="800" height="190" loading="lazy">
<em>by Sharon McCutcheon via Unsplash</em></p>
<blockquote>
<p>“In this paper, we propose a solution to the double-spending problem using a peer-to-peer distributed timestamp server to generate computational proof of the chronological order of transactions.”</p>
</blockquote>
<p>In order to make this possible, the person (or people, or thing) under the name Satoshi Nakamoto presents an electronic payment system that uses cryptographic proof 👨‍🏫 that allows its members to reach an agreement (consensus) without the need for a third-party intermediary.</p>
<h3 id="heading-2-transactions">2. Transactions</h3>
<blockquote>
<p>“Each owner transfers the coin to the next by digitally signing a hash of the previous transaction and the public key.”</p>
</blockquote>
<p>In the world of Bitcoin, those that own Bitcoins have what is called a “wallet”. This functions somewhat similar to a classic wallet in that it “holds” your Bitcoin. Associated with the wallet is a <strong>public key</strong>. This is an address that can be used to send Bitcoin to, just like somebody has an email address or a bank account number.</p>
<p>Also, there is another (VERY important) key that is associated with a wallet that is called a <strong>private key</strong> 🔐, which sort of functions as its password. Signing with this private key is the only way somebody can prove their ownership of the wallet, and it is what enables them to send the Bitcoins in that wallet. You lose this key (and depending on the type of wallet, your seed words), you lose your BTC 🙈.</p>
<p>Note that the order actually goes as follows:</p>
<ul>
<li>When a wallet is set up, that wallet generates a random private key.</li>
<li>From that private key (using an Elliptic Curve Digital Signature Algorithm) a public key is generated (note that it is not possible to convert this back to its private key; it’s a one-way algorithm).</li>
<li>From that public key (something we will discuss in the Privacy section) a wallet address is generated.</li>
</ul>
<p>Owning Bitcoins does not mean you actually have coins sitting in your wallet. A Bitcoin is not a piece of code you own or that is stored somewhere. The value of the BTC associated with a wallet (let’s call it ABC123) is based on how many transactions on the blockchain say “Address EXAMPLE890… sends x amount of BTC to address ABC123” as well as how many say “Address ABC123… sends x amount of BTC to address EXAMPLE453”.</p>
<p>In other words, the Bitcoin blockchain stores an incredible amount of data that specifies who sent how much to what address 📒. This data (who sends, what amount, who receives) is stored in individual transactions. The ownership of Bitcoin is calculated by looking at all the transactions coming into to an address and those that go out.</p>
<p>Now, if address ABC123 wants to spend the BTC that has been received from another address, it has to prove it is allowed to do so by <strong>signing the transaction with its private key</strong> 🔑 (that conditional data — you can only use it if signed with the correct private key — can be found in the previous transaction that is called upon). A new transaction is generated, the BTC is sent, and we start again. K<em>eep in mind that this is a simplified version; some details will be added later.</em></p>
<p><strong>Core takeaway:</strong> Bitcoins are not actual coins, they are just a combination of transactions that prove you have BTC to spend. Private keys are used to sign transactions and verify ownership.</p>
<blockquote>
<p>“The problem of course it that the payee can’t verify that one of the owners did not double-spend the coin.”</p>
<p>“The only way to confirm the absence of a transaction is to be aware of all transactions.”</p>
</blockquote>
<p>Confirming the absence of a transaction is done by broadcasting each transaction to the entire network 📡 and creating a shared history of all previous transactions (chronologically).</p>
<h3 id="heading-3-timestamp-server">3. Timestamp Server</h3>
<blockquote>
<p>“A timestamp server works by taking a hash of a block of items to be timestamped and widely publishing the hash…”</p>
</blockquote>
<p>The idea here is to collect the transactions that have been publicly broadcast into blocks, timestamp them (adding a time value 🕔), adding some more relevant data (we’ll get to this later) and then running it through a SHA256 hashing algorithm ⏩.</p>
<p>What this basically does is it converts the block and its data into a string of characters that can be used to uniquely identify that block (only that combination of data will get you that hash value). Each new block (before being added and run through a SHA256) can now refer back to the hash of the previous block in the chain, creating a chain of blocks in chronological order. This way, everybody can see which blocks (and its transactions) have taken place in the past and in what order.</p>
<p>This chain of blocks that are linked via their hash value is what makes up the actual blockchain (“blockchain” is often used to refer to entire protocols and systems but really it is the actual chain of blocks itself; the actual database).</p>
<h3 id="heading-4-proof-of-work-amp-5-network">4. Proof-of-Work &amp; 5. Network</h3>
<p>All right. Seems great! Though, how do we make sure the data that is added to the chain is actually correct? Can anybody just add blocks with transactions that do not exist? 🤔</p>
<blockquote>
<p>“To implement a distributed timestamp server on a peer-to-peer basis, we will need to use a proof-of-work system…”</p>
</blockquote>
<p>What is needed is a system that demands some work to be done before being able to add or suggest a new block to the blockchain. Just like the infamous CAPTCHA on the web, the goal is to create a barrier where it becomes harder (and infeasible) to spam the system (or in Bitcoins case, suggest false data). Bitcoin does this as follows.</p>
<p>I mentioned above that transactions are broadcast to the entire network. At this point, they are not yet added to the chain. Miners (those that are going to perform the “work” to add the block to the chain) are going to perform the previously mentioned hashing. They collect these transactions and put them in a block (as Merkle Root, we’ll discuss that later) together with the aforementioned timestamp, previous block hash, and some other relevant data like block height (what block # in the chain), and more.</p>
<p>Having collected all this data in a block, they run it through the SHA256 hashing algorithm. Again, what this basically does is it converts all that data into a string of characters that uniquely identifies that block and its data. Change a tiny thing in the block’s data and the entire hash changes (there is no known pattern for this but it is not random; change it back and you will get exactly the same hash).</p>
<p>Look at how the hash changes when I add the number “1” to the string of characters.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/Iez8yV275ZOaShY6KPVBAFxIDlCHjNhrFiYM" alt="Image" width="761" height="399" loading="lazy">
_Hashing the original title. [Xorbin SHA256 Hash Calculator](https://www.xorbin.com/tools/sha256-hash-calculator" rel="noopener" target="<em>blank" title=")</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/XmId6NlenYbSR8TGkbHb5SORgpfuccfh8FJq" alt="Image" width="761" height="403" loading="lazy">
_Adding “1” to the title. [Xorbin SHA256 Hash Calculator](https://www.xorbin.com/tools/sha256-hash-calculator" rel="noopener" target="<em>blank" title=")</em></p>
<p>The Bitcoin blockchain does not demand just a hash; it wants a hash that starts with (at the moment of writing) seventeen 0’s 😲.</p>
<blockquote>
<p>For example: 000000000000000006fb217d70740a895ce4966e2826325e31061bc433d7b186</p>
</blockquote>
<p>How do miners get that hash? They need to add a number to the block’s data which is called a ‘nonce’ (they add it just like I added the “1”). Nobody knows what number is needed to find the correct hash 🤷‍‍. The only way to find it is through trial-and-error: guessing.</p>
<blockquote>
<p>“… we implement the proof-of-work by incrementing a nonce in the block until a value is found that gives the block’s hash the required zero bits.”</p>
</blockquote>
<p>This process, guessing the right nonce, is what is referred to as ‘mining’ ⛏️. The miners with the largest CPU resources (most computational power) have the highest chance of being the first to find that correct nonce.</p>
<p>As long as more than 51% of the CPU power is in the hands of honest nodes, it will be impossible for a malicious miner to consistently win the mining process and add false data to the chain. The longest chain is always the chain that is taken as the truthful chain.</p>
<blockquote>
<p>“… the proof of work difficulty is determined by a moving average targeting an average number of blocks per hour. If they’re generated to fast, the difficulty increases.”</p>
</blockquote>
<p>This process of adding a new block to the blockchain happens every 10 minutes or so. This is kept stable by the protocol adjusting the mining difficulty (# of starting 0’s) — also called “difficulty bomb” 💣 — accordingly as computational power grows over time.</p>
<h3 id="heading-6-incentive">6. Incentive</h3>
<p>Why would miners go through all that effort and pay a lot of money to obtain the computational power to mine?</p>
<p>Once the block is agreed upon, an extra transaction is added to the beginning of the block (often referred to as the ‘coinbase transaction’) which allocates newly created BTC to the winning miner’s wallet address, rewarding them for the work put in and providing a way to distribute coins into circulation 💰. On top of that, each transaction in the block has a small — at least that was the goal — transaction fee associated with it which also goes to the winning miner.</p>
<blockquote>
<p>“Once a predetermined number of coins have entered the circulation, the incentive can transition entirely on transaction fees and be completely inflation free.”</p>
</blockquote>
<p>We are going to skip over part 7 (Reclaiming Disk Space) and part 8 (Simplified Payment Verification) and will briefly discuss these sections at the end. Although they are an important part of how Bitcoin operates, for the sake of understanding the core of the paper, they are less so.</p>
<h3 id="heading-9-combining-and-splitting-value">9. Combining and Splitting Value</h3>
<blockquote>
<p>“To allow value to be split and combined, transactions contain multiple inputs and outputs. Normally, there will be either a single input from a larger previous transaction or multiple inputs combining smaller amounts, and at most two outputs: one for the payment, and one returning the change, if any, back to the sender.”</p>
</blockquote>
<p>Something we already touched upon a bit earlier is how transactions are made up and how address value is calculated.</p>
<p>The BTC value held in an address is basically the sum of all its potential input transactions (i.e., the value of all the transactions towards that address <strong>that have not been spent</strong>). When the address holder wants to spend its BTC, they cannot just take exactly that amount and send it. They have to use their input transactions as whole pieces to do so (kind of like how you need to pay with an entire dollar note and can’t cut it in pieces to pay with). So what does that mean in the practical sense?</p>
<p>Andy is back 👋 but now he has a wallet with 0.5BTC. This value comes from three unspent transaction outputs (UTXO) (or future input transactions; the UTXO function as a reference for the input transaction for a new transaction):<br>a) 0.15BTC<br>b) 0.27BTC<br>c) 0.08BTC</p>
<p>Andy wants to send 0.38BTC to Brenda (lucky Brenda… 🙅). When he generates this transaction, the Bitcoin protocol will take the needed inputs that together are equal to or higher than (≥) the payment to Brenda and will use those as whole pieces to generate two output transactions.</p>
<p>In our example, the input transactions <strong>a</strong> and <strong>b</strong> are used (0.15 + 0.27 = 0.42) to generate the payment output transaction of 0.38BTC to Brenda, as well as another output transaction to Andy’s own address which returns the change (0.42–0.38 = 0.04). Both these output transactions can function as new input transactions for future payments by the address holders.</p>
<p><em>Note: There is also a miner/transaction fee involved that is taken out of the equation. So, the change that is returned is a bit less.</em></p>
<p><strong>Core takeaway</strong>: Output transactions require whole input transactions that together are at least equal to or more than the output value. Any excess (Inputs -(payment+miners fee)) is returned as change and can be used as a new input transaction.</p>
<h3 id="heading-10-privacy">10. Privacy</h3>
<p>We already discussed the existence and usage of wallets, public keys, and private keys earlier. In the situation where a third-party stores our information (like a bank), privacy is obtained by limiting the access to that information by handling permissions and securing the servers on which it is stored.</p>
<p>However, as mentioned before, these provide a single point of failure and attack, making it prone to loss and hacking. So, how does the Bitcoin go about providing privacy if all transactions are openly broadcast to the entire network? 🙃</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/5rszGA0p0dub9d8aWPvkHrcgoVBDMW3Edj2X" alt="Image" width="800" height="253" loading="lazy">
<em>by Ryan Born via Unsplash</em></p>
<blockquote>
<p>“The necessity to announce all transactions publicly precludes this method, but privacy can still be maintained by breaking the flow of information in another place: by keeping public keys anonymous.”</p>
</blockquote>
<p>The idea here is to keep the public key anonymous 🕵️. As long as people cannot associate a public key with a particular person, there is no way to reveal its identity.</p>
<p>A way of doing this that is currently used in the protocol is via the generation of wallet addresses, with a wallet being able to hold multiple addresses. Instead of showing public keys in the transaction data, wallet addresses are used. Just like public keys are created based on private keys using a one-way algorithm, the same is done to generate a wallet address from a public key (using the SHA256 followed by a RIPEMD160). What we are left with (after running it through a BASE58CHECK to make it more readable) is a wallet address that is used in the transaction data.</p>
<blockquote>
<p>“As an additional firewall, a new key pair should be used for each transaction to keep them from being linked to a common owner.”</p>
</blockquote>
<p>Without diving into to much detail, multiple addresses can be generated from a single private key by implementing a counter and adding an incrementing value in order to create sub-private keys (which can be used to create public keys that in its turn can be used to generate wallet addresses). This way, a single private key can give access to a wallet that has transactions going in and out of multiple addresses (this is referred to as a deterministic wallet).</p>
<p>Many Bitcoin software and services handle this auto-creation of wallet addresses when executing a transaction, making it nearly impossible to reveal the identities behind a publicly broadcast transaction.</p>
<p>We will briefly walk through the leftover pieces of the whitepaper, and then wrap it up.</p>
<h3 id="heading-7-reclaiming-disk-space">7. Reclaiming Disk Space</h3>
<blockquote>
<p>“Once the latest transaction in a coin is buried under enough blocks, the spent transactions before it can be discarded to save disk space.”</p>
</blockquote>
<p>When a transaction is buried under enough blocks, meaning it has been thoroughly validated by the system, it does not necessarily need to keep storing all the transaction data in the block. This is possible without breaking the hash by including only the Merkle Root of all transactions in the block’s hash, and not the individual transaction data. For more information on Merkle Trees 🌲, check out W<a target="_blank" href="https://en.wikipedia.org/wiki/Merkle_tree">ikipedia.</a></p>
<p>In short, all transactions are hashed and those hashes are paired before being hashed again, and so forth until you reach the parent hash of all transactions, called the Merkle Root.</p>
<h3 id="heading-8-simplified-payment-verification">8. Simplified Payment Verification</h3>
<p>In order to verify a payment, a user only needs to be able to link the transaction to a place in the chain by querying the longest chain of blocks and pulling the Merkle branch in which the transaction exists. If that user can do so, they can trust that the transaction has been valid given that the network has included it and further blocks have been build on it.</p>
<h3 id="heading-11-calculations">11. Calculations</h3>
<p>This dives into the more mathematical background of why the network will be secure when more than half of the network consists of honest nodes.</p>
<p>Basically, as long as there are more honest nodes than malicious nodes, as the chain grows it becomes harder and harder for an attacker to generate an alternate chain that allows them to take back payments they have made. The more blocks that are added on top of a particular transaction, the lower the probability becomes that an attacker can catch up with an alternate chain.</p>
<p>That is why we often see the number 6 when talking about (block) confirmations, which basically refers to 6 blocks that are added after the transaction was included, and functions as the complete confirmation threshold.</p>
<h3 id="heading-done">Done</h3>
<p>There we are! 👏 We have covered pretty much the entire original Bitcoin whitepaper. This paper has functioned as the genesis of the blockchain technologies that we see today. Getting a better grasp of its contents will definitely help you understand the current ecosystem of the industry.</p>
<p>I really hope this article has helped you out. If so, claps would be greatly appreciated and do let me know in the comment section below what your thoughts are on the piece. I would love to hear what you think. Any suggestions, corrections, or feedback is all greatly appreciated.</p>
<p>All the best,</p>
<p>Valentijn | <a target="_blank" href="https://twitter.com/vvdhout">@vvdhout</a></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/-FPGy30PsLYQpav4OrIcTvFMtjW5CM4r-r-s" alt="Image" width="800" height="304" loading="lazy"></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Hands On: Get Started With Infura and the IPFS on Ethereum ]]>
                </title>
                <description>
                    <![CDATA[ By Niharika Singh Why Infura? There are a lot of pain points being faced by blockchain which may be solved by Infura and/or the InterPlanetary File System (IPFS), to some extent. These are the main challenges: It’s expensive to store data on the Eth... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/hands-on-get-started-with-infura-and-ipfs-on-ethereum-b63635142af0/</link>
                <guid isPermaLink="false">66c34c165ced6d98e4bd3301</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 28 Jul 2018 17:14:14 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*cQNpUgQlMS2Almmpav-_Xg.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Niharika Singh</p>
<h3 id="heading-why-infura">Why Infura?</h3>
<p>There are a lot of pain points being faced by blockchain which may be solved by Infura and/or the InterPlanetary File System (IPFS), to some extent. These are the main challenges:</p>
<ol>
<li>It’s expensive to store data on the Ethereum blockchain</li>
<li>It’s tough to configure an Ethereum geth client</li>
<li>It’s tough to scale the infrastructure</li>
</ol>
<p>If you use Infura, access to the Ethereum network and the IPFS becomes a lot faster. It no longer takes hours to sync up the geth client which uses up a huge chunk of memory and bandwidth while the entire blockchain gets downloaded.</p>
<p>Here are some other advantages that come with using Infura:</p>
<ul>
<li>Huge amounts of data can be stored on the IPFS, and just the hash of the file can be stored on Ethereum.</li>
<li>Infura provides secure, reliable, scalable, and easy to use APIs to access the Ethereum network and the IPFS. Developers do not have to worry about the infrastructure of an Ethereum node or an IPFS node. That is taken care of by Infura.</li>
<li>Infura provides TLS enabled public endpoints.</li>
<li>The code is portable on Ethereum’s interface using JSON RPC, Web3.</li>
<li>Infura is practically a developer’s Swiss Army knife, and also saves the deployment team from the hell of scalability issues.</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/y8iwhXpRkRt2PGMowxrJ7p8UY8PXSdhy-Sjc" alt="Image" width="800" height="266" loading="lazy"></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/GS-bzDc0-YSK4Ut4mryw7AjVcYL3UUF2IJB5" alt="Image" width="800" height="360" loading="lazy"></p>
<ul>
<li>And finally, Infura is trusted:</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/nWAllpEFkm1FUmv0KIYZAPEW9sEanL0oQbvB" alt="Image" width="800" height="307" loading="lazy"></p>
<h3 id="heading-dapp-description">dApp Description</h3>
<p>Our dApp will take a file as input from a user and upload it to the IPFS by invoking an Ethereum contract. The hash of the file will be stored on Ethereum.</p>
<p>This is the process we’ll go through:</p>
<ol>
<li>Take file as an input</li>
<li>Convert file to buffer</li>
<li>Upload buffer to IPFS</li>
<li>Store hash of file returned by IPFS</li>
<li>Get user’s Metamask Ethereum address</li>
<li>User confirms transaction to Ethereum via Metamask</li>
<li>IPFS hash is written on Ethereum</li>
</ol>
<p><img src="https://cdn-media-1.freecodecamp.org/images/iO9rRzyMkmjnJABUKCkFMbVvByzCUh7HWPXZ" alt="Image" width="800" height="679" loading="lazy">
<em>dApp Architecture</em></p>
<h3 id="heading-tech-stack-involved">Tech Stack Involved</h3>
<ul>
<li><a target="_blank" href="https://reactjs.org/">React</a> — Front end library</li>
<li><a target="_blank" href="https://solidity.readthedocs.io/en/develop/">Solidity</a> — The language used to build smart contracts that runs on Ethereum</li>
<li><a target="_blank" href="https://ipfs.io/">IPFS</a> — Decentralized storage</li>
<li><a target="_blank" href="https://infura.io">Infura</a> —API access to Ethereum network and IPFS</li>
</ul>
<h3 id="heading-lets-code">Let’s Code!</h3>
<blockquote>
<p><em>Make sure you already have Metamask downloaded. If not, download it from <a target="_blank" href="https://metamask.io/">here</a>.</em></p>
<p><em>Also, keep your Node and NPM up to date.</em></p>
</blockquote>
<h4 id="heading-install-the-following-dependencies"><strong>Install the following dependencies:</strong></h4>
<pre><code>$ npm i -g create-react-app$ npm install react-bootstrap$ npm install fs-extra$ npm install ipfs-api$ npm install web3
</code></pre><p>After you’re done, run the following command on your CLI to create a sample React project. I’ll name my project <strong>ipfs</strong>.</p>
<pre><code>$ create-react-app ipfs
</code></pre><h4 id="heading-deploy-the-smart-contract-on-ropsten-testnet"><strong>Deploy the Smart Contract on Ropsten Testnet</strong></h4>
<p>.Make sure you’re on Ropsten testnet on metamask.</p>
<p>To deploy the smart contract, we need ether. To get ether for Ropsten testnet, go to <a target="_blank" href="https://faucet.metamask.io/">https://faucet.metamask.io/</a>.</p>
<p>To deploy the smart contract, go to <a target="_blank" href="https://remix.ethereum.org">https://remix.ethereum.org</a>.</p>
<pre><code>pragma solidity ^<span class="hljs-number">0.4</span><span class="hljs-number">.17</span>;
</code></pre><pre><code>contract Contract { string ipfsHash;  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">setHash</span>(<span class="hljs-params">string x</span>) <span class="hljs-title">public</span> </span>{   ipfsHash = x; } <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getHash</span>(<span class="hljs-params"></span>) <span class="hljs-title">public</span> <span class="hljs-title">view</span> <span class="hljs-title">returns</span> (<span class="hljs-params">string x</span>) </span>{   <span class="hljs-keyword">return</span> ipfsHash; }
</code></pre><pre><code>}
</code></pre><p><img src="https://cdn-media-1.freecodecamp.org/images/agAOGfoOvoQfYAqSDGqH94y4Lw1KoYHdrF4d" alt="Image" width="800" height="447" loading="lazy"></p>
<p>Save the address of smart contract. Mine is: 0x610DD75057738B73e3F17A9D607dB16A44f962F1</p>
<p>Also, save the Application Binary Interface (ABI) in JSON. It can be found in the ‘compile’ tab, under ‘details’.</p>
<p>Mine is the following:</p>
<pre><code>[ {  <span class="hljs-string">"constant"</span>: <span class="hljs-literal">false</span>,  <span class="hljs-string">"inputs"</span>: [   {    <span class="hljs-string">"name"</span>: <span class="hljs-string">"x"</span>,    <span class="hljs-string">"type"</span>: <span class="hljs-string">"string"</span>   }  ],  <span class="hljs-string">"name"</span>: <span class="hljs-string">"sendHash"</span>,  <span class="hljs-string">"outputs"</span>: [],  <span class="hljs-string">"payable"</span>: <span class="hljs-literal">false</span>,  <span class="hljs-string">"stateMutability"</span>: <span class="hljs-string">"nonpayable"</span>,  <span class="hljs-string">"type"</span>: <span class="hljs-string">"function"</span> }, {  <span class="hljs-string">"constant"</span>: <span class="hljs-literal">true</span>,  <span class="hljs-string">"inputs"</span>: [],  <span class="hljs-string">"name"</span>: <span class="hljs-string">"getHash"</span>,  <span class="hljs-string">"outputs"</span>: [   {    <span class="hljs-string">"name"</span>: <span class="hljs-string">"x"</span>,    <span class="hljs-string">"type"</span>: <span class="hljs-string">"string"</span>   }  ],  <span class="hljs-string">"payable"</span>: <span class="hljs-literal">false</span>,  <span class="hljs-string">"stateMutability"</span>: <span class="hljs-string">"view"</span>,  <span class="hljs-string">"type"</span>: <span class="hljs-string">"function"</span> }]
</code></pre><p>In the “ipfs/src” directory, create the following files: <strong>web3.js</strong>, <strong>ipfs.js</strong>, and <strong>storehash.js</strong>.</p>
<h4 id="heading-file-1-web3js">File 1 — Web3.js</h4>
<pre><code><span class="hljs-keyword">import</span> Web3 <span class="hljs-keyword">from</span> <span class="hljs-string">'web3'</span>;
</code></pre><pre><code><span class="hljs-keyword">const</span> web3 = <span class="hljs-keyword">new</span> Web3(<span class="hljs-built_in">window</span>.web3.currentProvider);
</code></pre><pre><code><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> web3;
</code></pre><h4 id="heading-file-2-storehashjs">File 2 — Storehash.js</h4>
<pre><code><span class="hljs-keyword">import</span> web3 <span class="hljs-keyword">from</span> <span class="hljs-string">'./web3'</span>;
</code></pre><pre><code><span class="hljs-comment">//Your contract addressconst address = '0x610dd75057738b73e3f17a9d607db16a44f962f1';</span>
</code></pre><pre><code><span class="hljs-comment">//Your contract ABIconst abi = [ {  "constant": false,  "inputs": [   {    "name": "x",    "type": "string"   }  ],  "name": "sendHash",  "outputs": [],  "payable": false,  "stateMutability": "nonpayable",  "type": "function" }, {  "constant": true,  "inputs": [],  "name": "getHash",  "outputs": [   {    "name": "x",    "type": "string"   }  ],  "payable": false,  "stateMutability": "view",  "type": "function" }]</span>
</code></pre><pre><code><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-keyword">new</span> web3.eth.Contract(abi, address);
</code></pre><h4 id="heading-file-3-ipfsjs">File 3 — Ipfs.js</h4>
<pre><code><span class="hljs-keyword">const</span> IPFS = <span class="hljs-built_in">require</span>(<span class="hljs-string">'ipfs-api'</span>);<span class="hljs-keyword">const</span> ipfs = <span class="hljs-keyword">new</span> IPFS({ <span class="hljs-attr">host</span>: <span class="hljs-string">'ipfs.infura.io'</span>, <span class="hljs-attr">port</span>: <span class="hljs-number">5001</span>, <span class="hljs-attr">protocol</span>: <span class="hljs-string">'https'</span> });
</code></pre><pre><code><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> ipfs;
</code></pre><h4 id="heading-edit-indexjs">Edit — Index.js</h4>
<pre><code><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;<span class="hljs-keyword">import</span> ReactDOM <span class="hljs-keyword">from</span> <span class="hljs-string">'react-dom'</span>;<span class="hljs-keyword">import</span> <span class="hljs-string">'./index.css'</span>;<span class="hljs-keyword">import</span> App <span class="hljs-keyword">from</span> <span class="hljs-string">'./App'</span>;<span class="hljs-keyword">import</span> registerServiceWorker <span class="hljs-keyword">from</span> <span class="hljs-string">'./registerServiceWorker'</span>;<span class="hljs-keyword">import</span> <span class="hljs-string">'bootstrap/dist/css/bootstrap.min.css'</span>;
</code></pre><pre><code>ReactDOM.render(<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">App</span> /&gt;</span></span>, <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'root'</span>));registerServiceWorker();
</code></pre><h4 id="heading-file-4-appjs">File 4 — App.js</h4>
<pre><code><span class="hljs-keyword">import</span> React, { Component } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;<span class="hljs-keyword">import</span> web3 <span class="hljs-keyword">from</span> <span class="hljs-string">'./web3'</span>;<span class="hljs-keyword">import</span> ipfs <span class="hljs-keyword">from</span> <span class="hljs-string">'./ipfs'</span>;<span class="hljs-keyword">import</span> storehash <span class="hljs-keyword">from</span> <span class="hljs-string">'./storehash'</span>;<span class="hljs-keyword">import</span> { Button } <span class="hljs-keyword">from</span> <span class="hljs-string">'reactstrap'</span>;
</code></pre><pre><code><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">App</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Component</span> </span>{
</code></pre><pre><code>state = {      <span class="hljs-attr">ipfsHash</span>:<span class="hljs-literal">null</span>,      <span class="hljs-attr">buffer</span>:<span class="hljs-string">''</span>,      <span class="hljs-attr">ethAddress</span>:<span class="hljs-string">''</span>,      <span class="hljs-attr">transactionHash</span>:<span class="hljs-string">''</span>,      <span class="hljs-attr">txReceipt</span>: <span class="hljs-string">''</span>    };
</code></pre><pre><code><span class="hljs-comment">//Take file input from usercaptureFile =(event) =&gt; {        event.stopPropagation()        event.preventDefault()        const file = event.target.files[0]        let reader = new window.FileReader()        reader.readAsArrayBuffer(file)        reader.onloadend = () =&gt; this.convertToBuffer(reader)      };</span>
</code></pre><pre><code><span class="hljs-comment">//Convert the file to buffer to store on IPFS convertToBuffer = async(reader) =&gt; {      //file is converted to a buffer for upload to IPFS        const buffer = await Buffer.from(reader.result);      //set this buffer-using es6 syntax        this.setState({buffer});    };</span>
</code></pre><pre><code><span class="hljs-comment">//ES6 async functiononClick = async () =&gt; {try{        this.setState({blockNumber:"waiting.."});        this.setState({gasUsed:"waiting..."});</span>
</code></pre><pre><code><span class="hljs-keyword">await</span> web3.eth.getTransactionReceipt(<span class="hljs-built_in">this</span>.state.transactionHash, <span class="hljs-function">(<span class="hljs-params">err, txReceipt</span>)=&gt;</span>{          <span class="hljs-built_in">console</span>.log(err,txReceipt);          <span class="hljs-built_in">this</span>.setState({txReceipt});        });      }<span class="hljs-keyword">catch</span>(error){      <span class="hljs-built_in">console</span>.log(error);    }}
</code></pre><pre><code>onSubmit = <span class="hljs-keyword">async</span> (event) =&gt; {      event.preventDefault();
</code></pre><pre><code><span class="hljs-comment">//bring in user's metamask account address      const accounts = await web3.eth.getAccounts();    //obtain contract address from storehash.js      const ethAddress= await storehash.options.address;      this.setState({ethAddress});    //save document to IPFS,return its hash#, and set hash# to state      await ipfs.add(this.state.buffer, (err, ipfsHash) =&gt; {        console.log(err,ipfsHash);        //setState by setting ipfsHash to ipfsHash[0].hash        this.setState({ ipfsHash:ipfsHash[0].hash });        // call Ethereum contract method "sendHash" and .send IPFS hash to etheruem contract        //return the transaction hash from the ethereum contract        storehash.methods.sendHash(this.state.ipfsHash).send({          from: accounts[0]        }, (error, transactionHash) =&gt; {          console.log(transactionHash);          this.setState({transactionHash});        });      })    };</span>
</code></pre><pre><code>render() {
</code></pre><pre><code><span class="hljs-keyword">return</span> (        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"App"</span>&gt;</span>          <span class="hljs-tag">&lt;<span class="hljs-name">header</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"App-header"</span>&gt;</span>            <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Ethereum and IPFS using Infura<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>          <span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span></span>
</code></pre><pre><code>&lt;hr/&gt;&lt;grid&gt;          &lt;h3&gt; Choose file to send to IPFS &lt;/h3&gt;          &lt;form onSubmit={this.onSubmit}&gt;            &lt;input              type = "file"              onChange = {this.captureFile}            /&gt;             &lt;Button             bsStyle="primary"             type="submit"&gt;             Send it             &lt;/Button&gt;          &lt;/form&gt;&lt;hr/&gt; &lt;Button onClick = {this.onClick}&gt; Get Transaction Receipt &lt;/Button&gt; &lt;hr/&gt;  &lt;table bordered responsive&gt;                &lt;thead&gt;                  &lt;tr&gt;                    &lt;th&gt;Tx Receipt Category&lt;/th&gt;                    &lt;th&gt; &lt;/th&gt;                    &lt;th&gt;Values&lt;/th&gt;                  &lt;/tr&gt;                &lt;/thead&gt;
</code></pre><pre><code>&lt;tbody&gt;                  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>                    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>IPFS Hash stored on Ethereum<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>                    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span> : <span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>                    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>{this.state.ipfsHash}<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>                  <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span></span>                  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>                    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>Ethereum Contract Address<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>                    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span> : <span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>                    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>{this.state.ethAddress}<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>                  <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span></span>                  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>                    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>Tx # <span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>                    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span> : <span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>                    <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>{this.state.transactionHash}<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>                  <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span></span>                &lt;<span class="hljs-regexp">/tbody&gt;            &lt;/</span>table&gt;        &lt;<span class="hljs-regexp">/grid&gt;     &lt;/</span>div&gt;      );    }}<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> App;
</code></pre><p><strong>And that is all!</strong></p>
<p>Access your dApp at localhost:3000. Upload a file and you will see a hash generated. To make sure your file is uploaded, access it via the IPFS gateway. Make sure you accept the Metamask requests.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/gsZvutm3tRljA5j6vS4MygjSlmfnQ072vBO6" alt="Image" width="800" height="381" loading="lazy"></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/4KoRXxzXfal5sHgZyDbbP8pZ8xodGPSMeaK6" alt="Image" width="800" height="406" loading="lazy"></p>
<p>Access your file at: https://gateway.ipfs.io/ipfs/your IPFS hash</p>
<p>Mine is at: <a target="_blank" href="https://gateway.ipfs.io/ipfs/QmbyizSHLirDfZhms75tdrrdiVkaxKvbcLpXzjB5k34a31">https://gateway.ipfs.io/ipfs/QmbyizSHLirDfZhms75tdrrdiVkaxKvbcLpXzjB5k34a31</a></p>
<p>To know more about IPFS, see my other articles:</p>
<p><a target="_blank" href="https://medium.freecodecamp.org/ipfs-101-understand-by-doing-it-9f5622c4d4ed"><strong>Learn by doing: a nice and easy intro to the Inter Planetary File System</strong></a><br><a target="_blank" href="https://medium.freecodecamp.org/ipfs-101-understand-by-doing-it-9f5622c4d4ed">_Primer on IPFS_medium.freecodecamp.org</a><a target="_blank" href="https://hackernoon.com/ipfs-and-merkle-forest-a6b7f15f3537"><strong>IPFS ? and Merkle Forest?</strong></a><br><a target="_blank" href="https://hackernoon.com/ipfs-and-merkle-forest-a6b7f15f3537"><strong>W</strong>h_at is IPFS?ha_ckernoon.com</a></p>
<h4 id="heading-thank-you-for-reading-if-you-liked-this-please-clap-follow-me-on-twitter-httpswwwfreecodecamporgnewshands-on-get-started-with-infura-and-ipfs-on-ethereum-b63635142af0undefinedniharika3297">Thank you for reading. If you liked this, please clap! Follow me on Twitter <a target="_blank" href="https://www.freecodecamp.org/news/hands-on-get-started-with-infura-and-ipfs-on-ethereum-b63635142af0/undefined">@</a>Niharika3297</h4>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to create a Bitcoin wallet address from a private key ]]>
                </title>
                <description>
                    <![CDATA[ By Timur Badretdinov In the previous article, we looked at different methods to generate a private key. Whatever method you choose, you’ll end up with 32 bytes of data. Here’s the one that we got at the end of that article: 60cf347dbc59d31c1358c8e5cf... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-create-a-bitcoin-wallet-address-from-a-private-key-eca3ddd9c05f/</link>
                <guid isPermaLink="false">66d45e013dce891ac3a967c4</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 16 Jul 2018 15:35:36 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*yrGW1KubP_JKLR1CVg074g.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Timur Badretdinov</p>
<p>In <a target="_blank" href="https://www.freecodecamp.org/news/how-to-generate-your-very-own-bitcoin-private-key-7ad0f4936e6c/">the previous article</a>, we looked at different methods to generate a private key. Whatever method you choose, you’ll end up with 32 bytes of data. Here’s the one that we got at the end of that article:</p>
<p><code>60cf347dbc59d31c1358c8e5cf5e45b822ab85b79cb32a9f3d98184779a9efc2</code></p>
<p>We’ll use this private key throughout the article to derive both a public key and the address for the Bitcoin wallet.</p>
<p>What we want to do is to apply a series of conversions to the private key to get a public key and then a wallet address. Most of these conversions are called hash functions. These hash functions are one-way conversions that can’t be reversed. We won’t go to the mechanics of the functions themselves — there are plenty of great articles that cover that. Instead, we will look at how using these functions in the correct order can lead you to the Bitcoin wallet address that you can use.</p>
<h3 id="heading-elliptic-curve-cryptography">Elliptic Curve Cryptography</h3>
<p>The first thing we need to do is to apply the ECDSA or Elliptic Curve Digital Signature Algorithm to our private key. An elliptic curve is a curve defined by the equation <code>y² = x³ + ax + b</code> with a chosen <code>a</code> and <code>b</code>. There is a whole family of such curves that are widely known and used. Bitcoin uses the <strong>secp256k1</strong> curve. If you want to learn more about Elliptic Curve Cryptography, I’ll refer you to <a target="_blank" href="https://hackernoon.com/what-is-the-math-behind-elliptic-curve-cryptography-f61b25253da3">this article</a>.</p>
<p>By applying the ECDSA to the private key, we get a 64-byte integer. This consists of two 32-byte integers that represent the X and Y of the point on the elliptic curve, concatenated together.</p>
<p>For our example, we got: <code>1e7bcc70c72770dbb72fea022e8a6d07f814d2ebe4de9ae3f7af75bf706902a7b73ff919898c836396a6b0c96812c3213b99372050853bd1678da0ead14487d7</code>.</p>
<p>In Python, it would look like this:</p>
<pre><code class="lang-python">public_key_bytes = codecs.decode(public_key, ‘hex’)
<span class="hljs-comment"># Run SHA-256 for the public key</span>
sha256_bpk = hashlib.sha256(public_key_bytes)
sha256_bpk_digest = sha256_bpk.digest()
<span class="hljs-comment"># Run RIPEMD-160 for the SHA-256</span>
ripemd160_bpk = hashlib.new(‘ripemd160’)
ripemd160_bpk.update(sha256_bpk_digest)
ripemd160_bpk_digest = ripemd160_bpk.digest()
ripemd160_bpk_hex = codecs.encode(ripemd160_bpk_digest, ‘hex’)
</code></pre>
<p>Note: as you can see from the code, before I used a method from the <code>ecdsa</code> module, I decoded the private key using <code>codecs</code>. This is relevant more to the Python and less to the algorithm itself, but I will explain what are we doing here to remove possible confusion.</p>
<p>In Python, there are at least two classes that can keep the private and public keys: “str” and “bytes”. The first is a string and the second is a byte array. Cryptographic methods in Python work with a “bytes” class, taking it as input and returning it as the result.</p>
<p>Now, there’s a little catch: a string, say, <code>4f3c</code> does not equal the byte array <code>4f3c</code>, it equals the byte array with two elements, <code>O&amp;</code>lt;. And that’s wh<code>at codecs.dec</code>ode method does: it converts a string into a byte array. That will be the same for all cryptographic manipulations that we’ll do in this article.</p>
<h3 id="heading-public-key">Public key</h3>
<p>Once we’re done with the ECDSA, all we need to do is to add the bytes <code>0x04</code> at the start of our public key. The result is a Bitcoin full public key, which is equal to: <code>041e7bcc70c72770dbb72fea022e8a6d07f814d2ebe4de9ae3f7af75bf706902a7b73ff919898c836396a6b0c96812c3213b99372050853bd1678da0ead14487d7</code> for us.</p>
<h3 id="heading-compressed-public-key">Compressed public key</h3>
<p>But we can do better. As you might remember, the public key is some point (X, Y) on the curve. We know the curve, and for each X there are only two Ys that define the point which lies on that curve. So why keep Y? Instead, let’s keep X and the sign of Y. Later, we can derive Y from that if needed.</p>
<p>The specifics are as follows: we take X from the ECDSA public key. Now, we add the <code>0x02</code> if the last byte of Y is even, and the byte <code>0x03</code> if the last byte is odd.</p>
<p>In our case, the last byte is odd, so we add <code>0x03</code> to get the compressed public key: <code>031e7bcc70c72770dbb72fea022e8a6d07f814d2ebe4de9ae3f7af75bf706902a7</code>. This key contains the same information, but it’s almost twice as short as the uncompressed key. Cool!</p>
<p>Previously, wallet software used long, full versions of public keys, but now most of it has switched to compressed keys.</p>
<h3 id="heading-encrypting-the-public-key">Encrypting the public key</h3>
<p>From now on, we need to make a wallet address. Whatever method of getting the public key you choose, it goes through the same procedure. Obviously, the addresses will differ. In this article, we will go with the compressed version.</p>
<p>What we need to do here is to apply SHA-256 to the public key, and then apply RIPEMD-160 to the result. The order is important.</p>
<p>SHA-256 and RIPEMD-160 are two hash functions, and again, we won’t go into the details of how they work. What matters is that now we have 160-bit integer, which will be used for further modifications. Let’s call that an encrypted public key. For our example, the encrypted public key is <code>453233600a96384bb8d73d400984117ac84d7e8b</code>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/9Fj7FyUVc7zLwLodE7JvoHXfY81g6DndArUd" alt="Image" width="800" height="80" loading="lazy"></p>
<p>Here’s how we encrypt the public key in Python:</p>
<pre><code>public_key_bytes = codecs.decode(public_key, ‘hex’)# Run SHA<span class="hljs-number">-256</span> <span class="hljs-keyword">for</span> the public keysha256_bpk = hashlib.sha256(public_key_bytes)sha256_bpk_digest = sha256_bpk.digest()# Run RIPEMD<span class="hljs-number">-160</span> <span class="hljs-keyword">for</span> the SHA<span class="hljs-number">-256</span>ripemd160_bpk = hashlib.new(‘ripemd160’)ripemd160_bpk.update(sha256_bpk_digest)ripemd160_bpk_digest = ripemd160_bpk.digest()ripemd160_bpk_hex = codecs.encode(ripemd160_bpk_digest, ‘hex’)
</code></pre><h3 id="heading-adding-the-network-byte">Adding the network byte</h3>
<p>The Bitcoin has two networks, main and test. The main network is the network that all people use to transfer the coins. The test network was created — you guessed it — to test new features and software.</p>
<p>We want to generate an address to use it on the mainnet, so we need to add <code>0x00</code> bytes to the encrypted public key. The result is <code>00453233600a96384bb8d73d400984117ac84d7e8b</code>. For the testnet, that would be <code>0x6f</code> bytes.</p>
<h3 id="heading-checksum">Checksum</h3>
<p>Now we need to calculate the checksum of our mainnet key. The idea of checksum is to make sure that the data (in our case, the key) wasn’t corrupted during transmission. The wallet software should look at the checksum and mark the address as invalid if the checksum mismatches.</p>
<p>To calculate the checksum of the key, we need to apply SHA-256 twice and then take first 4 bytes of the result. For our example, the double SHA-256 is <code>512f43c48517a75e58a7ec4c554ecd1a8f9603c891b46325006abf39c5c6b995</code> and therefore the checksum is <code>512f43c4</code> (note that 4 bytes is 8 hex digits).</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/rcb40Z2plVojizglRqDG3Y4fIxy1m77Gsnnu" alt="Image" width="800" height="120" loading="lazy"></p>
<p>The code to calculate an address checksum is the following:</p>
<pre><code class="lang-python"><span class="hljs-comment"># Double SHA256 to get checksum</span>
sha256_nbpk = hashlib.sha256(network_bitcoin_public_key_bytes)
sha256_nbpk_digest = sha256_nbpk.digest()
sha256_2_nbpk = hashlib.sha256(sha256_nbpk_digest)
sha256_2_nbpk_digest = sha256_2_nbpk.digest()
sha256_2_hex = codecs.encode(sha256_2_nbpk_digest, ‘hex’)
checksum = sha256_2_hex[:<span class="hljs-number">8</span>]
</code></pre>
<h3 id="heading-getting-the-address">Getting the address</h3>
<p>Finally, to make an address, we just concatenate the mainnet key and the checksum. That makes it <code>00453233600a96384bb8d73d400984117ac84d7e8b512f43c4</code> for our example.</p>
<p>That’s it! That’s the wallet address for the private key at the start of the article.</p>
<p>But you may notice that something is off. You’ve probably seen a handful of Bitcoin addresses and they didn’t look like that. Well, the reason is that they are encoded with <a target="_blank" href="https://en.wikipedia.org/wiki/Base58">Base58</a>. It’s a little bit odd.</p>
<p>Here’s the algorithm to convert a hex address to the Base58 address:</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">base58</span>(<span class="hljs-params">address_hex</span>):</span>
    alphabet = ‘<span class="hljs-number">123456789</span>ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz’
    b58_string = ‘’
    <span class="hljs-comment"># Get the number of leading zeros</span>
    leading_zeros = len(address_hex) — len(address_hex.lstrip(‘<span class="hljs-number">0</span>’))
    <span class="hljs-comment"># Convert hex to decimal</span>
    address_int = int(address_hex, <span class="hljs-number">16</span>)
    <span class="hljs-comment"># Append digits to the start of string</span>
    <span class="hljs-keyword">while</span> address_int &gt; <span class="hljs-number">0</span>:
        digit = address_int % <span class="hljs-number">58</span>
        digit_char = alphabet[digit]
        b58_string = digit_char + b58_string
        address_int //= <span class="hljs-number">58</span>
    <span class="hljs-comment"># Add ‘1’ for each 2 leading zeros</span>
    ones = leading_zeros // <span class="hljs-number">2</span>
    <span class="hljs-keyword">for</span> one <span class="hljs-keyword">in</span> range(ones):
        b58_string = ‘<span class="hljs-number">1</span>’ + b58_string
    <span class="hljs-keyword">return</span> b58_string
</code></pre>
<p>What we get is <code>17JsmEygbbEUEpvt4PFtYaTeSqfb9ki1F1</code>, a compressed Bitcoin wallet address.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/saUvqNSzw5b7ATtpSh3RUMS3WwEeBFVNU9m8" alt="Image" width="800" height="120" loading="lazy"></p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>The wallet key generation process can be split into four steps:</p>
<ul>
<li>creating a public key with ECDSA</li>
<li>encrypting the key with SHA-256 and RIPEMD-160</li>
<li>calculating the checksum with double SHA-256</li>
<li>encoding the key with Base58.</li>
</ul>
<p>Depending on the form of public key (full or compressed), we get different addresses, but both are perfectly valid.</p>
<p>Here’s the full algorithm for the uncompressed public key:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/r1G799LERTJzPvyfibbkVdRpJDzMbgPRbmmu" alt="Image" width="800" height="320" loading="lazy"></p>
<p>If you want to play with the code, I published it to the <a target="_blank" href="https://github.com/Destiner/blocksmith">Github repository</a>.</p>
<p>I am making a course on cryptocurrencies here on freeCodeCamp News. The <a target="_blank" href="https://medium.com/longcaller/blockchain-explained-2b26b28657ca">first part</a> is a detailed description of the blockchain.</p>
<p>I also post random thoughts about crypto on <a target="_blank" href="https://twitter.com/DestinerX">Twitter</a>, so you might want to check it out.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to generate your very own Bitcoin private key ]]>
                </title>
                <description>
                    <![CDATA[ By Timur Badretdinov In cryptocurrencies, a private key allows a user to gain access to their wallet. The person who holds the private key fully controls the coins in that wallet. For this reason, you should keep it secret. And if you really want to ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-generate-your-very-own-bitcoin-private-key-7ad0f4936e6c/</link>
                <guid isPermaLink="false">66d45e05d1ffc3d3eb89ddb7</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 29 Jun 2018 00:40:27 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*6pWGbFF9kCmlGSra6Kmh-w.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Timur Badretdinov</p>
<p>In cryptocurrencies, a private key allows a user to gain access to their wallet. The person who holds the private key fully controls the coins in that wallet. For this reason, you should keep it secret. And if you really want to generate the key yourself, it makes sense to generate it in a secure way.</p>
<p>Here, I will provide an introduction to private keys and show you how you can generate your own key using various cryptographic functions. I will provide a description of the algorithm and the code in Python.</p>
<h3 id="heading-do-i-need-to-generate-a-private-key">Do I need to generate a private key?</h3>
<p>Most of the time you don’t. For example, if you use a web wallet like Coinbase or Blockchain.info, they create and manage the private key for you. It’s the same for exchanges.</p>
<p>Mobile and desktop wallets usually also generate a private key for you, although they might have the option to create a wallet from your own private key.</p>
<p>So why generate it anyway? Here are the reasons that I have:</p>
<ul>
<li>You want to make sure that no one knows the key</li>
<li>You just want to learn more about cryptography and random number generation (RNG)</li>
</ul>
<h3 id="heading-what-exactly-is-a-private-key">What exactly is a private key?</h3>
<p>Formally, a private key for Bitcoin (and many other cryptocurrencies) is a series of 32 bytes. Now, there are many ways to record these bytes. It can be a string of 256 ones and zeros (32 * 8 = 256) or 100 dice rolls. It can be a binary string, Base64 string, a <a target="_blank" href="https://en.bitcoin.it/wiki/Wallet_import_format">WIF key</a>, <a target="_blank" href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">mnemonic phrase</a>, or finally, a hex string. For our purposes, we will use a 64 character long hex string.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/lyrhBKkIKdFsCCrBdSXnaRYJrwj67NUaMXNy" alt="Image" width="800" height="320" loading="lazy">
<em>The same private key, written in different formats.</em></p>
<p>Why exactly 32 bytes? Great question! You see, to create a public key from a private one, Bitcoin uses the <strong>ECDSA</strong>, or Elliptic Curve Digital Signature Algorithm. More specifically, it uses one particular curve called <strong>secp256k1</strong>.</p>
<p>Now, this curve has an order of 256 bits, takes 256 bits as input, and outputs 256-bit integers. And 256 bits is exactly 32 bytes. So, to put it another way, we need 32 bytes of data to feed to this curve algorithm.</p>
<p>There is an additional requirement for the private key. Because we use ECDSA, the key should be positive and should be less than the order of the curve. The order of secp256k1 is <code>FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141</code>, which is pretty big: almost any 32-byte number will be smaller than it.</p>
<h3 id="heading-naive-method">Naive method</h3>
<p>So, how do we generate a 32-byte integer? The first thing that comes to mind is to just use an RNG library in your language of choice. Python even provides a cute way of generating just enough bits:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> random
bits = random.getrandbits(<span class="hljs-number">256</span>)
<span class="hljs-comment"># 30848827712021293731208415302456569301499384654877289245795786476741155372082</span>
bits_hex = hex(bits)
<span class="hljs-comment"># 0x4433d156e8c53bf5b50af07aa95a29436f29a94e0ccc5d58df8e57bdc8583c32</span>
private_key = bits_hex[<span class="hljs-number">2</span>:]
<span class="hljs-comment"># 4433d156e8c53bf5b50af07aa95a29436f29a94e0ccc5d58df8e57bdc8583c32</span>
</code></pre>
<p>Looks good, but actually, it’s not. You see, normal RNG libraries are not intended for cryptography, as they are not very secure. They generate numbers based on a seed, and by default, the seed is the current time. That way, if you know approximately when I generated the bits above, all you need to do is brute-force a few variants.</p>
<p>When you generate a private key, you want to be extremely secure. Remember, if anyone learns the private key, they can easily steal all the coins from the corresponding wallet, and you have no chance of ever getting them back.</p>
<p>So let’s try to do it more securely.</p>
<h3 id="heading-cryptographically-strong-rng">Cryptographically strong RNG</h3>
<p>Along with a standard RNG method, programming languages usually provide a RNG specifically designed for cryptographic operations. This method is usually much more secure, because it draws entropy straight from the operating system. The result of such RNG is much harder to reproduce. You can’t do it by knowing the time of generation or having the seed, because there is no seed. Well, at least the user doesn’t enter a seed — rather, it’s created by the program.</p>
<p>In Python, cryptographically strong RNG is implemented in the <code>secrets</code> module. Let’s modify the code above to make the private key generation secure!</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> secrets
bits = secrets.randbits(<span class="hljs-number">256</span>)
<span class="hljs-comment"># 46518555179467323509970270980993648640987722172281263586388328188640792550961</span>
bits_hex = hex(bits)
<span class="hljs-comment"># 0x66d891b5ed7f51e5044be6a7ebe4e2eae32b960f5aa0883f7cc0ce4fd6921e31</span>
private_key = bits_hex[<span class="hljs-number">2</span>:]
<span class="hljs-comment"># 66d891b5ed7f51e5044be6a7ebe4e2eae32b960f5aa0883f7cc0ce4fd6921e31</span>
</code></pre>
<p>That is amazing. I bet you wouldn’t be able to reproduce this, even with access to my PC. But can we go deeper?</p>
<h3 id="heading-specialized-sites">Specialized sites</h3>
<p>There are sites that generate random numbers for you. We will consider just two here. One is <a target="_blank" href="https://random.org">random.org</a>, a well-known general purpose random number generator. Another one is <a target="_blank" href="https://bitaddress.org">bitaddress.org</a>, which is designed specifically for Bitcoin private key generation.</p>
<p>Can <a target="_blank" href="https://random.org">random.org</a> help us generate a key? Definitely, as they have <a target="_blank" href="https://www.random.org/bytes">service</a> for generating random bytes. But two problems arise here. <a target="_blank" href="https://random.org">Random.org</a> claims to be a truly random generator, but can you trust it? Can you be sure that it is indeed random? Can you be sure that the owner doesn’t record all generation results, especially ones that look like private keys? The answer is up to you. Oh, and you can’t run it locally, which is an additional problem. This method is not 100% secure.</p>
<p>Now, <a target="_blank" href="https://bitaddress.org">bitaddress.org</a> is a whole different story. It’s open source, so you can see what’s under its hood. It’s client-side, so you can download it and run it locally, even without an Internet connection.</p>
<p>So how does it work? It uses you — yes, you — as a source of entropy. It asks you to move your mouse or press random keys. You do it long enough to make it infeasible to reproduce the results.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/y5eDywvm3A2NMywdEk2u6pQYUORSP42gtWr2" alt="Image" width="862" height="540" loading="lazy">
<em>The process of generation an entropy by randomly moving the mouse. The large chunk of symbols shows the pool.</em></p>
<p>Are you interested to see how <a target="_blank" href="https://bitaddress.org">bitaddress.org</a> works? For educational purposes, we will look at its code and try to reproduce it in Python.</p>
<blockquote>
<p>_Quick note: bitaddress.org gives you the private key in a compressed WIF format, which is close to the <a target="_blank" href="https://en.bitcoin.it/wiki/Wallet_import_format">WIF format</a> that we discussed before. For our purposes, we will make the algorithm return a hex string so that we can use it later for a public key generation._</p>
</blockquote>
<h3 id="heading-bitaddress-the-specifics">Bitaddress: the specifics</h3>
<p>Bitaddress creates the entropy in two forms: by mouse movement and by key pressure. We’ll talk about both, but we’ll focus on the key presses, as it’s hard to implement mouse tracking in the Python lib. We’ll expect the end user to type buttons until we have enough entropy, and then we’ll generate a key.</p>
<p>Bitaddress does three things. It initializes byte array, trying to get as much entropy as possible from your computer, it fills the array with the user input, and then it generates a private key.</p>
<p>Bitaddress uses the 256-byte array to store entropy. This array is rewritten in cycles, so when the array is filled for the first time, the pointer goes to zero, and the process of filling starts again.</p>
<p>The program initiates an array with 256 bytes from <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Window/crypto">window.crypto</a>. Then, it writes a timestamp to get an additional 4 bytes of entropy. Finally, it gets such data as the size of the screen, your time zone, information about browser plugins, your locale, and more. That gives it another 6 bytes.</p>
<p>After the initialization, the program continually waits for user input to rewrite initial bytes. When the user moves the cursor, the program writes the position of the cursor. When the user presses buttons, the program writes the char code of the button pressed.</p>
<p>Finally, bitaddress uses accumulated entropy to generate a private key. It needs to generate 32 bytes. For this task, bitaddress uses an RNG algorithm called ARC4. The program initializes ARC4 with the current time and collected entropy, then gets bytes one by one 32 times.</p>
<p>This is all an oversimplification of how the program works, but I hope that you get the idea. You can check out the algorithm in full detail on <a target="_blank" href="https://github.com/pointbiz/bitaddress.org">Github</a>.</p>
<h3 id="heading-doing-it-yourself">Doing it yourself</h3>
<p>For our purposes, we’ll build a simpler version of bitaddress. First, we won’t collect data about the user’s machine and location. Second, we will input entropy only via text, as it’s quite challenging to continually receive mouse position with a Python script (check <a target="_blank" href="https://github.com/asweigart/pyautogui">PyAutoGUI</a> if you want to do that).</p>
<p>That brings us to the formal specification of our generator library. First, it will initialize a byte array with cryptographic RNG, then it will fill the timestamp, and finally it will fill the user-created string. After the seed pool is filled, the library will let the developer create a key. Actually, they will be able to create as many private keys as they want, all secured by the collected entropy.</p>
<h4 id="heading-initializing-the-pool">Initializing the pool</h4>
<p>Here we put some bytes from cryptographic RNG and a timestamp. <code>__seed_int</code> and <code>__seed_byte</code> are two helper methods that insert the entropy into our pool array. Notice that we use <code>secrets</code>.</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init_pool</span>(<span class="hljs-params">self</span>):</span>
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(self.POOL_SIZE):
        random_byte = secrets.randbits(<span class="hljs-number">8</span>)
        self.__seed_byte(random_byte)
    time_int = int(time.time())
    self.__seed_int(time_int)
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__seed_int</span>(<span class="hljs-params">self, n</span>):</span>
    self.__seed_byte(n)
    self.__seed_byte(n &gt;&gt; <span class="hljs-number">8</span>)
    self.__seed_byte(n &gt;&gt; <span class="hljs-number">16</span>)
    self.__seed_byte(n &gt;&gt; <span class="hljs-number">24</span>)
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__seed_byte</span>(<span class="hljs-params">self, n</span>):</span>
    self.pool[self.pool_pointer] ^= n &amp; <span class="hljs-number">255</span>
    self.pool_pointer += <span class="hljs-number">1</span>
    <span class="hljs-keyword">if</span> self.pool_pointer &gt;= self.POOL_SIZE:
        self.pool_pointer = <span class="hljs-number">0</span>
</code></pre>
<h4 id="heading-seeding-with-input">Seeding with input</h4>
<p>Here we first put a timestamp and then the input string, character by character.</p>
<pre><code>def seed_input(self, str_input):
    time_int = int(time.time())
    self.__seed_int(time_int)
    <span class="hljs-keyword">for</span> char <span class="hljs-keyword">in</span> str_input:
        char_code = ord(char)
        self.__seed_byte(char_code)
</code></pre><h4 id="heading-generating-the-private-key">Generating the private key</h4>
<p>This part might look hard, but it’s actually very simple.</p>
<p>First, we need to generate 32-byte number using our pool. Unfortunately, we can’t just create our own <code>random</code> object and use it only for the key generation. Instead, there is a shared object that is used by any code that is running in one script.</p>
<p>What does that mean for us? It means that at each moment, anywhere in the code, one simple <code>random.seed(0)</code> can destroy all our collected entropy. We don’t want that. Thankfully, Python provides <code>getstate</code> and <code>setstate</code> methods. So, to save our entropy each time we generate a key, we remember the state we stopped at and set it next time we want to make a key.</p>
<p>Second, we just make sure that our key is in range (1, <code>CURVE_ORDER</code>). This is a requirement for all ECDSA private keys. The <code>CURVE_ORDER</code> is the order of the secp256k1 curve, which is <code>FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141</code>.</p>
<p>Finally, for convenience, we convert to hex, and strip the ‘0x’ part.</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">generate_key</span>(<span class="hljs-params">self</span>):</span>
    big_int = self.__generate_big_int()
    big_int = big_int % (self.CURVE_ORDER — <span class="hljs-number">1</span>) <span class="hljs-comment"># key &lt; curve order</span>
    big_int = big_int + <span class="hljs-number">1</span> <span class="hljs-comment"># key &gt; 0</span>
    key = hex(big_int)[<span class="hljs-number">2</span>:]
    <span class="hljs-keyword">return</span> key
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__generate_big_int</span>(<span class="hljs-params">self</span>):</span>
    <span class="hljs-keyword">if</span> self.prng_state <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
    seed = int.from_bytes(self.pool, byteorder=’big’, signed=<span class="hljs-literal">False</span>)
    random.seed(seed)
    self.prng_state = random.getstate()
    random.setstate(self.prng_state)
    big_int = random.getrandbits(self.KEY_BYTES * <span class="hljs-number">8</span>)
    self.prng_state = random.getstate()
    <span class="hljs-keyword">return</span> big_int
</code></pre>
<h4 id="heading-in-action">In action</h4>
<p>Let’s try to use the library. Actually, it’s really simple: you can generate a private key in three lines of code!</p>
<pre><code>kg = KeyGenerator()
kg.seed_input(‘Truly random string. I rolled a dice and got <span class="hljs-number">4.</span>’)
kg.generate_key()
# <span class="hljs-number">60</span>cf347dbc59d31c1358c8e5cf5e45b822ab85b79cb32a9f3d98184779a9efc2
</code></pre><p>You can see it yourself. The key is random and totally valid. Moreover, each time you run this code, you get different results.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>As you can see, there are a lot of ways to generate private keys. They differ in simplicity and security.</p>
<p>Generating a private key is only a first step. The next step is extracting a public key and a wallet address that you can use to receive payments. The process of generating a wallet differs for Bitcoin and Ethereum, and I plan to write two more articles on that topic.</p>
<p>If you want to play with the code, I published it to this <a target="_blank" href="https://github.com/Destiner/blocksmith">Github repository</a>.</p>
<p><em>I am making a course on cryptocurrencies here on freeCodeCamp News. The <a target="_blank" href="https://medium.com/longcaller/blockchain-explained-2b26b28657ca">first part</a> is a detailed description of the blockchain.</em></p>
<p><em>I also post random thoughts about crypto on <a target="_blank" href="https://twitter.com/DestinerX">Twitter</a>, so you might want to check it out.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How Bitcoin mining really works ]]>
                </title>
                <description>
                    <![CDATA[ By Subhan Nadeem As Bitcoin approaches mainstream adoption and recognition, its fundamental security model, characterized as mining, is being put under the spotlight and scrutinized more and more everyday. People are increasingly concerned about and ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-bitcoin-mining-really-works-38563ec38c87/</link>
                <guid isPermaLink="false">66c34cdd0f58901a6209179d</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 31 May 2018 17:10:07 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/0*A8uxgOGZV8XlHg8s.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Subhan Nadeem</p>
<p>As Bitcoin approaches mainstream adoption and recognition, its fundamental security model, characterized as mining, is being put under the spotlight and scrutinized more and more everyday.</p>
<p>People are increasingly concerned about and interested in the environmental impact of Bitcoin mining, the security and degree of decentralization of the underlying model, and even the potential impact of a quantum computing breakthrough on the future of Bitcoin and other cryptocurrencies.</p>
<p>Often times, proof-of-work is described as a “cryptographic puzzle,” but what is that puzzle, really?</p>
<p>In order to truly understand these questions (and any possible answers), you need to have a fundamental understanding Bitcoin mining itself and its evolution.</p>
<p>This article will explore all the technical components and moving parts of proof-of-work, and how they seamlessly synchronize with one another to allow Bitcoin to be the decentralized platform it is today.</p>
<h3 id="heading-why-mining-works-cryptographic-one-way-hashing">Why Mining Works: Cryptographic One-Way Hashing</h3>
<p>The Bitcoin blockchain is often described as a database that is cryptographically secure and, subsequently, immutable. The underlying technology that powers this immutability and security is <strong>cryptographic hashing.</strong></p>
<p>A cryptographic hash function is a mathematical function that, simply put, takes any input and maps it to a fixed-size string.</p>
<p>However, there are four special properties of these functions that make them invaluable to the Bitcoin network. They are:</p>
<ol>
<li><strong>Deterministic —</strong> for any input into the cryptographic hash function, the resulting output will always be the same.</li>
<li><strong>Fast</strong> — Computing the output of the hash function, given any input, is a relatively fast process (doesn’t need heavy computation)</li>
<li><strong>Unique —</strong> Every input into the function should result in a completely random and unique output (in other words, no two inputs result in the same output)</li>
<li><strong>Irreversible —</strong> Given an output of a hash function, the original input is unable to be obtained</li>
</ol>
<p>These rules provide the foundation that enables Bitcoin mining to secure the network.</p>
<p>In particular, the creator of the Bitcoin protocol, Satoshi Nakomoto, chose to use the <a target="_blank" href="https://en.wikipedia.org/wiki/SHA-2">SHA-256 hash function</a> as the basis for Bitcoin mining. This is a specific cryptographic hash function that has been mathematically proven to hold the above properties. It always outputs a <strong>256 bit number</strong> (the most basic unit of computation), which is usually represented in the hexadecimal number system with 64 characters for human-readability.</p>
<p>The output of the SHA-256 function is usually referred to as the <strong>hash</strong> of its input.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1iObT23KZMg-OPHVKyPW3Fp-12cFhc2oaMdI" alt="Image" width="800" height="541" loading="lazy">
<em>A hash function’s input results in a completely unique output</em></p>
<p>Here is an example of a SHA-256 function input and output (you can try it out yourself <a target="_blank" href="http://www.xorbin.com/tools/sha256-hash-calculator">here</a>):</p>
<pre><code>Input to SHA<span class="hljs-number">-256</span>:
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Bitcoin</span> <span class="hljs-attr">Transaction</span>&gt;</span>
Output to SHA-256:
77077b1f4c3ad44c83dc0bdb8d937e9b71c0ef07a35c2664bb7da85be738eacf</span>
</code></pre><p>Interestingly enough, in the majority of places where hashing is used in the Bitcoin protocol, <strong>double hashing</strong> is used. This means that the output of the original SHA-256 function is then put right back into the SHA-256 function to obtain another output. Here is what that process looks like:</p>
<pre><code>Input to SHA<span class="hljs-number">-256</span>(first round):
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Bitcoin</span> <span class="hljs-attr">Transaction</span>&gt;</span>
Output (first round):
77077b1f4c3ad44c83dc0bdb8d937e9b71c0ef07a35c2664bb7da85be738eacf

Input to SHA-256 (second round):
77077b1f4c3ad44c83dc0bdb8d937e9b71c0ef07a35c2664bb7da85be738eacf
Output (second round and final result):
3c6c55b0e4b607b672b50f04e028a6951aed6dc97b91e103fb0f348c3f1dfa00</span>
</code></pre><p>Double hashing is used to safeguard against birthday attacks. A birthday attack is a scenario where an attacker is able to produce the same hash as another input by using a completely different input (called a <strong>collision</strong>). This breaks the third property of <strong>uniqueness.</strong> Without it, two completely different Bitcoin blocks may be represented by the exact same hash, allowing attackers to potentially switch out blocks.</p>
<p>With the SHA-256 function, the probability of this attack happening is infinitely small. If it wasn’t close to impossible, SHA-256 would be considered broken.</p>
<p>However, other hash functions have been “broken” in the past. In order to safeguard against this happening to SHA-256 in the future (and effectively breaking the security model of Bitcoin) it’s best to <strong>hash the hash</strong>. This halves the probability of a collision occurring, making the protocol that much more secure.</p>
<p>At a very high level, Bitcoin mining is a system in which all Bitcoin transactions are sent to Bitcoin miners. Miners select one megabyte worth of transactions, bundle them as an input into the SHA-256 function, and attempt to find a specific output the network accepts. The first miner to find this output and publish the block to the network receives a reward in the form of transaction fees and the creation of new Bitcoin.</p>
<p>Let’s take things a step further and dive into the Bitcoin blockchain itself to see what exactly it is that miners do to make the network secure.</p>
<h3 id="heading-bitcoin-mining-a-technical-introduction">Bitcoin Mining: A Technical Introduction</h3>
<p>Mining was introduced as the solution to the double-spend problem. If I have 1 Bitcoin and I send it to Bob, and then try sending that same Bitcoin to Alice, the network ensures that only one transaction will be accepted. It does this through the well-known process called mining.</p>
<p>Before diving into the technical details, its important to understand why mining is necessary to secure the network. As <a target="_blank" href="https://www.investopedia.com/terms/f/fiatmoney.asp">fiat currency</a> exists now, the currency we hold is created and validated by a federal reserve. Because Bitcoin operates under the rigid assumption of decentralization and consensus, no central authority can exist that validates and time-stamps the issuance of that currency and validation of any transactions that occur with that currency.</p>
<p>Satoshi Nakamoto proposed the only known solution at the time to solving this validation problem in a consensus-oriented system. Titled in the Bitcoin whitepaper as <strong>proof-of-work</strong>, this scheme elegantly justifies that transactions are validated by those who are willing to expend enough physical computational energy and time to do so, while simultaneously introducing an incentive to induce market competition. This competition enables the property of decentralization to emerge and thrive organically within the ecosystem.</p>
<h3 id="heading-a-look-inside-a-block">A Look Inside a Block</h3>
<p>A Bitcoin block consists primarily of two components:</p>
<h4 id="heading-1-transactions-in-the-form-of-a-merkle-tree">1. Transactions, in the form of a <strong>merkle tree</strong></h4>
<p>Mining computers collect enough transactions to fill a block and bundle them into a merkle tree.</p>
<p>A merkle tree is a relatively simple concept: transactions lie at the bottom of the tree as leaves and are hashed using the SHA-256 function. The combination of two leaf transactions are hashed again using the SHA-256 function to form a parent of the leaves. This parent is continuously hashed upwards in combination with other parents of hashed transactions, until a single <strong>root</strong> is created. The hash of this root is effectively a unique representation of the transactions that are underneath it.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/3Y5SmuCwRz8GnPlpMVo9SUG0n3mg95o4fwoP" alt="Image" width="800" height="397" loading="lazy">
<em>A visualization of how a merkle tree is built — the leaves at the very bottom of the tree are transactions</em></p>
<p>The root of the merkle tree is a combination of the hashes of every transaction in the tree.</p>
<p>Recall that for any any input to a hash function, the output is entirely <strong>unique.</strong> Therefore, once most nodes on the network receive a mined block, the root of the merkle tree hash acts as an unchangeable summary of all the transactions in that given block.</p>
<p>If a malicious actor were to try and change the contents of a transaction in a block, its hash would be changed. This change of a hash would be propagated up the transaction’s merkle tree until the hash of the root is changed. Any node can then quickly catch this malicious act by comparing the root of the changed block’s merkle tree to that of a valid block’s merkle tree.</p>
<h4 id="heading-2-the-block-header">2. The block header</h4>
<p>The block header is a summary of the contents of the block itself. It contains the following <strong>six components</strong>:</p>
<ul>
<li>The version of software the Bitcoin client is running</li>
<li>The timestamp of the block</li>
<li>The root of its containing transactions' merkle tree</li>
<li>The hash of the block before it</li>
<li>A <strong>nonce</strong></li>
<li>The <strong>target</strong></li>
</ul>
<p>Remember that the root of the transaction merkle tree acts as an effective summary of every transaction in the block without having to look at each transaction.</p>
<p>The hash of the previous block before it allows the network to properly place the block in chronological order. This is where the term <strong>blockchain</strong> is derived from — each block is chained to a previous block.</p>
<p>The <strong>nonce</strong> and <strong>target</strong> are what make mining tick. They are the basis for solving the SHA-256 puzzle that miners need to solve.</p>
<p>Please note that all of this data in the block header is compressed into 80 bytes using a notation called <a target="_blank" href="https://bitcoin.stackexchange.com/questions/2063/why-does-the-bitcoin-protocol-use-the-little-endian-notation">little-endian</a>, making the transfer of block headers between nodes a trivially efficient process. For the purposes of this explanation, we’ll ignore this compression and assume data is in its original form.</p>
<h3 id="heading-explaining-the-mining-problem">Explaining the Mining Problem</h3>
<p>The <strong>target</strong> stored in the block header is simply a numeric value stored in bits. In traditional base 10 notation, this target ranges anywhere between 0 to somewhere in the range of 2²²⁴ (a <strong>67+ digit</strong> number), depending on how many miners are competing to solve this problem at the same time.</p>
<p>Recall that the output of SHA-256 is just a number. The goal of a miner is to take the current block’s header, add a random number to it called the <strong>nonce</strong>, and calculate its hash. This numeric value of the hash must be smaller than the target value.</p>
<p>That’s all there is to it. But it’s much easier said than done.</p>
<p>Recall the first property of SHA-256: an input into a hash function will always result in the same output. Therefore, if the miner took the block header, hashed it, and realized that the hash value wasn’t less than the target, they would have to change the input somehow in order to try finding a hash below the target value.</p>
<p>This is where the <strong>nonce</strong> comes in.</p>
<p>The miner adds a number (starting from 0), called the <strong>nonce</strong>, to the block header, and hashes that value. If the hash value isn’t less than the target, the miner will increment the nonce by 1, add it again to the block header, and hash that changed value. This process is repeated continuously until a hash less than the target value is found.</p>
<h4 id="heading-a-mining-example">A Mining Example</h4>
<p>Here’s a rough approximation of what made up the first block header:</p>
<ul>
<li>The merkle root of the transaction in the Genesis block:</li>
</ul>
<pre><code>Merkle Root:
<span class="hljs-number">4</span>a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
</code></pre><ul>
<li>The first known Bitcoin version: <code>0.1.0</code></li>
<li>The timestamp of the block: <code>2009–01–03 18:15:05</code></li>
<li>The target (this is also the highest the target will ever be):</li>
</ul>
<pre><code>Target:
<span class="hljs-number">0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</span>
</code></pre><ul>
<li>No previous block hash — this was the first block, and so this is a unique case</li>
</ul>
<p>The final block header after adding its components together:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/RgFYX1FSetNk-EJF91HSNTcVhqIYyDziZJkD" alt="Image" width="767" height="672" loading="lazy">
_The Genesis block data (this includes the nonce, but lets pretend it doesn’t), source: [bitcointalk](https://bitcointalk.org/index.php?topic=52706" rel="noopener" target="<em>blank" title=")</em></p>
<p>Let’s take this large header and compute the double-hash:</p>
<pre><code>SHA<span class="hljs-number">-256</span> <span class="hljs-keyword">of</span> header:
<span class="hljs-number">7</span>d80bd12dfdccbdde2c41c9f406edfc05afb3320f5affc4f510b05a3394e1c91

SHA<span class="hljs-number">-256</span> <span class="hljs-keyword">of</span> the previous result (final result):
c5aa3150f61b752c8fb39525f911981e2f9982c8b9bc907c73914585ad2ef12b
</code></pre><p>Both the target and the output hash are incredibly large numbers when converted to base 10 (remember, over 67 digits long). Instead of trying to demonstrate the comparison of the two here, the following Python function handles the comparison instead:</p>
<pre><code>def isBlockHashLessThanTarget(blockHash, target):
    <span class="hljs-keyword">return</span> int(blockHash, <span class="hljs-number">16</span>) &lt; int(target, <span class="hljs-number">16</span>)
</code></pre><p>True is returned if the hash is less than the target, false otherwise.</p>
<p>Here is the result with our target and block hash:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/mI97AvtxoLFh08Qy99YmpOesirwiyS3a6iLj" alt="Image" width="800" height="158" loading="lazy"></p>
<p>Now we take the original block hexadecimal value and add 1 to it. Here is the following result:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/M7hXm9TXd9CFp3vmZ4sOUHxyvuzMHowjTifh" alt="Image" width="752" height="662" loading="lazy">
<em>Notice how the very last digit is now 1, due to the addition of the nonce</em></p>
<p>We then run the same hashing algorithm and comparison on this changed data. If its not below the target, keep repeating.</p>
<p>Once a successful hash is found, the latest nonce used to find this solution is saved within the block.</p>
<p><a target="_blank" href="https://blockchain.info/block-index/14849">The listed nonce on the Genesis block</a> is 2,083,236,893.</p>
<p>This means Satoshi Nakomoto iterated through this process over 2 billion times before he found a hash that was acceptable.</p>
<p>I’ve written a small Python implementation of this Genesis block mining process that can be found on my <a target="_blank" href="http://github.com/subhan-nadeem/bitcoin-mining-python">GitHub</a>.</p>
<p><a target="_blank" href="http://github.com/subhan-nadeem/bitcoin-mining-python"><strong>subhan-nadeem/bitcoin-mining-python</strong></a><br><a target="_blank" href="http://github.com/subhan-nadeem/bitcoin-mining-python"><em>bitcoin-mining-python - A Python implementation of the Bitcoin mining algorithm</em></a><br><a target="_blank" href="http://github.com/subhan-nadeem/bitcoin-mining-python">github.com</a></p>
<p>See how long it would take for you to successfully mine the Genesis block!</p>
<h4 id="heading-a-caveat-extranonce">A Caveat: <code>extraNonce</code></h4>
<p>The nonce value in a block header is stored as a 32-bit number. This means that the highest nonce anybody is able to achieve is <strong>2³²</strong> (approximately 4 billion). After 4 billion iterations, the nonce is exhausted, and if a solution is not found, miners are once again stuck.</p>
<p>The solution to this is to add a field to the <strong>coinbase</strong> (the transaction contents of a block, stored as the merkle tree) called the <strong>extraNonce.</strong> The size of this extraNonce is only limited by the size of block itself, and so it can be as large as miners wish as long as the block size is within protocol limits.</p>
<p>If all 4 billion possible values of the nonce are exhausted, the <strong>extraNonce</strong> is added and incremented to the <strong>coinbase.</strong> A new merkle root and subsequently new block header are calculated, and the <strong>nonce</strong> is iterated over once again. This process is repeated until a sufficient hash is found.</p>
<p>It’s best to avoid adding the <strong>extraNonce</strong> until the <strong>nonce</strong> is exhausted, because any change to the extraNonce changes the merkle tree. This requires extra computation in order to propagate the change upwards until a new root of the merkle tree is calculated.</p>
<h4 id="heading-the-miner-reward">The Miner Reward</h4>
<p>A miner who successfully publishes a block the fastest is rewarded brand new Bitcoin, created out of thin air. That reward <a target="_blank" href="http://www.bitcoinblockhalf.com/">currently stands</a> at 12.5 BTC. Just how do these Bitcoins come into existence?</p>
<p>Each miner simply adds a new output transaction to their block that attributes 12.5 Bitcoins to themselves before beginning to mine the block. The network protocol will accept this special transaction as valid upon receiving a newly validated block. This special transaction is called a <strong>generation transaction.</strong></p>
<p>Its the miner’s responsibility to add this transaction into the block before mining it. There has been <a target="_blank" href="https://www.reddit.com/r/Bitcoin/comments/7n1ie5/someone_destroyed_125_newly_mined_bitcoins/">at least one case</a> where miners forgot to add the reward to the transaction before mining a block, effectively destroying 12.5 BTC!</p>
<h3 id="heading-validating-proof-of-work">Validating Proof-of-Work</h3>
<p>Let’s say our miner has found a hash that is less than the target. All this miner has to do is publish the mined block with the original six components to any connected nodes.</p>
<p>This node receiving the block will first verify the transaction set, ensuring all transactions are valid (for example, all transactions are appropriately signed, and coins aren’t being double-spent and/or being created out of thin air).</p>
<p>It will then simply <strong>double-hash</strong> the block header and ensure the value is below the block’s included target value. Once the block is deemed valid, the new node will continue to propagate this block across the network until every node has an up-to-date ledger.</p>
<p>As you can see, newly published blocks can easily be verified by any given node. However, publishing a valid block to the network requires an incredibly large amount of computational power (thus, electricity and time). This asymmetry is what allows the network to be secured while simultaneously allowing individuals who wish to conduct economic activity on the network to do so in a relatively seamless manner.</p>
<h3 id="heading-the-block-time-and-adjusting-the-target">The Block Time and Adjusting the Target</h3>
<p>As the first miners began mining, they each monitored the <strong>block time</strong>. Each Bitcoin block has a set block time of 10 minutes. What this means is that given the current level of computing power (<strong>network</strong> <strong>hashrate</strong>) on the network, nodes will always expect newly validated blocks to be produced every 10 minutes on average.</p>
<p>We can reasonably expect blocks to be produced within 10 minutes because the probability of finding a block, given the network hashrate, is known.</p>
<p>For example, let’s take the easiest target that’s ever existed in Bitcoin: the genesis block. The probability of any single hash being less than the easiest target is 1 in 2³². That’s one in over four billion. Therefore, we can reasonably expect somebody to run 2³² iterations of the mining problem in order to find a proper hash. Nodes on the network expected four billion of these iterations to be run across <strong>all</strong> miners on the network every 10 minutes.</p>
<p>If, over a large sample size of blocks, blocks start appearing faster than 10 minutes, this is a pretty clear indication that nodes on the network are iterating through four billion hashes much faster than 10 minutes. This situation prompts every node to adjust the target proportionally based on the increase (or decrease) in network power to ensure blocks continue to be produced every 10 minutes.</p>
<p>In actuality, nodes on the network monitor the block time across <strong>2016</strong> blocks, which comes out to exactly two weeks. Every two weeks, the total block time is compared to the expected block time (which is 20160 minutes).</p>
<p>To obtain the new target, simply multiply the existing target by the ratio of the total actual block time over the last two weeks to get the expected block time. This will adjust the target proportionally to the amount of entering or exiting computing power on the network.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/M3-52KmmkeyZCRECDfzfdACTrILXpveYlDn5" alt="Image" width="800" height="91" loading="lazy">
<em>The formula to calculate the new target, run every 20160 minutes (two weeks) by each Bitcoin node</em></p>
<p>The block time and the ability to easily calculate the probability of finding a valid block lets nodes easily monitor and determine the total hashpower on the network and adjust the network. No matter how much computing power is added to the network or how quickly its added, on average the block time will always remain at 10 minutes.</p>
<p>The current total hash rate on the network is 28.27 exahash per second. That’s <strong><em>28.27 x 10¹⁸</em></strong> hashes run every second across all computers on the network.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/d9dUC5kBAfoDhYFAhuUIF-49pjPT-risoGxB" alt="Image" width="800" height="450" loading="lazy"></p>
<h3 id="heading-in-summary">In summary</h3>
<p>We have now comprehensively covered the following:</p>
<ul>
<li>Why cryptographic one way hashing is vital to proof-of-work</li>
<li>A breakdown of the construction of a Bitcoin block</li>
<li>The actual mining process and iteration itself</li>
<li>How nodes can easily validate other blocks</li>
<li>How the network manages to maintain the algorithm and competitiveness by monitoring the block time and adjusting the target</li>
</ul>
<p>You should now be able to understand and explain how proof-of-work actually functions and why it is considered to be an entirely secure algorithm that enables decentralization and consensus!</p>
<p><strong>Follow me on <a target="_blank" href="https://twitter.com/SubhanNadeem19">Twitter</a> and Medium if you’re interested in more in-depth and informative write-ups like these in the future!</strong></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Blockchain explained by trying to pass a high school math class ]]>
                </title>
                <description>
                    <![CDATA[ By Kevin Kononenko If you have ever struggled through a high school math class, then you will be able to understand the principles of blockchain technology, which makes Bitcoin possible. Have you ever tried to learn the basics of Blockchain by readin... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/blockchain-explained-by-trying-to-pass-a-high-school-math-class-2322c01ece48/</link>
                <guid isPermaLink="false">66c34620622ca5970af83301</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ privacy ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 18 Apr 2018 04:35:30 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*x2gUD6BhNjkF7ac4UEwg5Q.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Kevin Kononenko</p>
<p>If you have ever struggled through a high school math class, then you will be able to understand the principles of blockchain technology, which makes Bitcoin possible.</p>
<p>Have you ever tried to learn the basics of Blockchain by reading random blog posts and wikis, or watching YouTube videos?</p>
<p>It gets technical <strong>very</strong> quickly. You are quickly presented with concepts like:</p>
<p><em>Distributed ledger</em></p>
<p><em>Cryptographic hash</em></p>
<p><em>Digital signatures</em></p>
<p>Although you can certainly persevere through the initial confusion, you need to understand a series of new technical concepts before you understand the whole system.</p>
<h4 id="heading-heres-why-this-is-so-hard"><strong>Here’s why this is so hard</strong></h4>
<p>Bitcoin (and blockchain) are based on a distributed and decentralized paradigm. We are used to centralized, trustworthy authorities, like banks, healthcare providers, and corporations (yes, we even trust most of them).</p>
<p>Each one of those institutions has complicated systems in place to maintain high quality. In order to maintain these same standards for vital products <em>without</em> the centralized authority…we need new, complicated rules to keep decentralized systems running, too.</p>
<p>So, in this article, I am going to create a new high school called “Distributed High School” that operates using the principles of blockchain. We are going to create a new way to grade assignments from math class using a distributed system. Students will be able to maintain the grading system on their own, without teach involvement.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*Rj_2EXsXSvtjIL8x." alt="Image" width="300" height="211" loading="lazy"></p>
<p><strong>One last note:</strong> Although Bitcoin is probably the most popular application for blockchain technology in 2018, many other industries will likely begin to adopt blockchain over the next five years.</p>
<p>This explanation will translate most directly to Bitcoin, but it will also apply to other types of blockchains. For example, healthcare providers could use a blockchain to securely store individual medical histories.</p>
<p>If you are looking for a more technical explanation, this <a target="_blank" href="https://www.youtube.com/watch?v=Lx9zgZCMqXE">20 minute animated YouTube video</a> on Bitcoin is probably my favorite.</p>
<h3 id="heading-the-centralized-way-to-manage-a-high-school">The centralized way to manage a high school</h3>
<p>Imagine that you are a freshman in high school, and you are taking the algebra class for all 9th graders. In order to pass the class, you need to get a sufficient score on homework assignments, quizzes, and tests. There are 30 total students in your class.</p>
<p>All of this is managed by one centralized authority: the teacher. This one person will grade all your assignments, deliver your report cards each quarter, and make sure that nobody is cheating on tests (which would ruin the integrity of the class).</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*UaeN6iaCD0UUJ6-t." alt="Image" width="730" height="356" loading="lazy"></p>
<p>Although this is the system that we are all accustomed to, it actually has some inherent flaws.</p>
<ol>
<li><strong>It can be inefficient:</strong> when you give 30 tests to a teacher all at once, they can sometimes take a week to get them back to you — because it takes forever to grade 30 tests!</li>
<li><strong>Sometimes it’s risky:</strong> sometimes a teacher might loses a student’s test. Or paper tests can get ruined by floods or other natural disasters. These things happen. And teachers handle so many assignments that there will probably be some errors along the way.</li>
<li><strong>Corruptible:</strong> Have you ever been the troublemaker in the class? When the teacher sits down to grade your test, they may take one look at the name on the top of the test, and become instantly biased while grading the test. Sometimes this is hard to avoid (human nature and all that jazz).</li>
<li><strong>Costly:</strong> All that time spent grading tests is time that could be spent doing other, more productive things. This is also probably the teacher’s least favorite part of the job. They probably became a teacher so they could help students learn, not spend all their “free” time grading tests. Instead, your parents’ taxpayer dollars are going towards an activity that could be much improved.</li>
</ol>
<p>You can see similar issues with other centralized systems. For example, although we trust banks with our hard-earned money, the banking industry helped cause the <a target="_blank" href="https://en.wikipedia.org/wiki/Financial_crisis_of_2007%E2%80%932008">2008 financial crisis</a> through risky practices that required a massive taxpayer-funded bailout.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*-Jp5sc1d8PL_JreA." alt="Image" width="730" height="298" loading="lazy"></p>
<p>Although we trust doctors, <a target="_blank" href="https://www.usnews.com/news/articles/2016-05-03/medical-errors-are-third-leading-cause-of-death-in-the-us">medical error is the third-leading cause of death in the United States</a>, behind heart disease and cancer. Many of those errors might be caused by important medical data being inaccessible to doctors.</p>
<p>So, back to high school math class. You might be wondering… how the heck are we going to solve all these problems by removing the influence of the teacher, the one person with the most expertise in this system? How would we prevent it from becoming anarchy?</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*BmLmZP9UAVLDbv49.gif" alt="Image" width="500" height="375" loading="lazy"></p>
<p>That is where the blockchain concept comes in. Before I get into the specific way we will use blockchain to create a new way to run Distributed High School, you should know that each blockchain has specific rules that are instituted by its creator.</p>
<p>In Bitcoin’s example, that would be “<a target="_blank" href="https://en.wikipedia.org/wiki/Satoshi_Nakamoto">Satoshi Nakamoto</a>” who wrote the original white paper and created the rules (algorithms) that allow it to operate without human intervention.</p>
<p>In our school example, we are going to have an exceptionally forward-thinking principal that has changed the rules.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*4p657mzLzJjE13V-." alt="Image" width="300" height="300" loading="lazy"></p>
<h3 id="heading-creating-a-blockchain-for-distributed-high-school">Creating a blockchain for distributed high school</h3>
<p>While a teacher grades tests and manages grades in private, a blockchain makes all transactions public. So, blockchain doesn’t rely on any central authority aside from the person who created it.</p>
<p>If you haven’t already guessed it, that means that in Distributed High School, we are going to start by having the 9th-grade students grade each other’s tests!</p>
<p>Let’s say it is test day, and the class period is an hour long. Students neatly stack their tests on top of the teacher’s desk when they finish.</p>
<p>But, instead of taking all of the tests home for grading, the teacher jumbles all of them into a big pile, and asks each student to take a random test and grade it with an answer key.</p>
<p>This is known as a <strong>transaction</strong>. This is the fundamental unit that makes up a blockchain. Let’s say that one student, Andy, gave another student, Alice, a grade of 84. In this case, Andy is the <strong>sender</strong> and Alice is the <strong>recipient</strong>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*t2VhNUww6r7ioUsE." alt="Image" width="730" height="382" loading="lazy"></p>
<p>In Bitcoin terms, this would not be random: you know where you are sending money!</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*QRWwpy7J6et9kjFV." alt="Image" width="730" height="381" loading="lazy"></p>
<p>So far, we have solved the speed and cost problems. Teachers no longer need to spend time on grading, and each student can grade one other test pretty quickly. But, there is a huge potential for fraud. This is pretty close to anarchy. There needs to be a network of responsible people that will keep all participants honest.</p>
<p>Here’s where the principal’s policies come in. The principal controls the one thing that everyone cares about: the grading system. At Distributed High School, the principal decides to allow seniors (12th graders) to run this blockchain system in exchange for a reward.</p>
<p>If a senior reviews 20 of these graded tests in 1 day, they can enter into a competition to get <strong>10 points added to one of their own tests</strong>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*1SnDo-1Zf1wigpvx." alt="Image" width="730" height="321" loading="lazy"></p>
<p>That set of 20 transactions is known as a <strong>block</strong>, and we will eventually show how all blocks work together to form a <strong>blockchain</strong>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*AKHGsWEryV33QBrV." alt="Image" width="730" height="344" loading="lazy"></p>
<p>So why can only seniors do this? And why must it be a competition?</p>
<p>It must be seniors, because the principal needs participants who are going to be able to handle the workload of grading tests every day (if they want to). If the system slows down, then nobody would have their tests validated and logged, which would be a complete failure.</p>
<p>And it must be a competition so that the point system is not completely devalued. Imagine if every senior reviewed their 20 tests and received 10 points on their own test? Grade inflation would be rampant, similar to the way that currency inflation increases when the government prints more money. There must be a competition for a scarce number of points. I’ll share the terms of the competition later.</p>
<p>The principal is not forcing any senior to participate, but there is a strong incentive for them to do so.</p>
<p>In Bitcoin, each block has a limit of 1 megabyte (MB) of data. As of late 2017, the average transaction included about 500 bytes of data, so a block typically contained about 2000 transactions (<a target="_blank" href="https://arstechnica.com/tech-policy/2017/12/bitcoin-fees-are-skyrocketing/">source</a>).</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*S2XeukezziEmbTz-." alt="Image" width="730" height="362" loading="lazy"></p>
<h3 id="heading-an-introduction-to-the-distributed-ledger">An introduction to the distributed ledger</h3>
<p>Now we know how one test gets graded (a transaction) and the incentives in place for the seniors to maintain the system with integrity: they get more points by reviewing and validating more tests. But we are still missing the entire distributed infrastructure for how this work actually gets done.</p>
<p>Let’s say that 10 seniors took the principal up on his offer. They want to be part of this competition to earn more points on their own tests. Another set of 10 seniors decides to volunteer to help maintain the system, but not participate in the competition. This is simply out of support for the distributed system, and part of the spirit of the movement towards open-source grading.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*2aTv7QNJDk-Z1VVC." alt="Image" width="730" height="393" loading="lazy"></p>
<p>Each one of those seniors is a <a target="_blank" href="https://bitcoin.org/en/full-node"><strong>full node</strong></a> in the network. They communicate in real-time about new transactions and blocks.</p>
<p>The 10 seniors that decided to participate in the competition are called <strong>miners</strong>. They build blocks with transactions available in the <strong>mempool</strong>, the reservoir of unconfirmed transactions.</p>
<p>When a student, like Andy, finishes grading a test, the student broadcasts an <strong>unvalidated transaction</strong> to the network of seniors. Each full node shares it around with everyone else, like a rumor. It becomes part of the mempool.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*oRwV9z9DSPTj0oeH." alt="Image" width="730" height="408" loading="lazy"></p>
<p>Every node must <strong>validate</strong> the transaction first. In other words, they determine whether it was possible or not. In this example, validation could mean confirming that the grader actually graded the test correctly by punching in all the final answers into your calculator. We will get into the other part of validation in a little bit.</p>
<p>After validation, each miner has the opportunity to build their own block out of 20 tests, or transactions.</p>
<p>But wait! On test days, 30 new transactions should be added to the network, since there are 30 students in the class. How do the miners choose the transactions to add to their block?</p>
<p>The answer is a <strong>transaction fee</strong>. Each <strong>sender</strong> must attach a transaction fee to their transaction to compensate the miners for their work. So, the miners usually just choose to put all the transactions with the highest fees into their blocks immediately. Since this operates on supply and demand, they can include the transactions with lower fees on days when there are fewer tests to validate.</p>
<p>In our school example, this transaction fee could be a point off the sender’s test to donate to the miner. It would not come off of Alice’s (the recipient’s) test. In Bitcoin, it would be a small fraction of a Bitcoin, like 0.000003 BTC. The sender pays the fee since that is the easiest way to handle the logistics.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*G4LLKTQ0ZbDOUa2z." alt="Image" width="730" height="532" loading="lazy"></p>
<p>At this point, each miner has their block of 20 validated transactions that they would like to add to the blockchain. Now, it is time for the competition to see which of the 10 miners will get their blocks accepted and be awarded the points from the principal.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*llDVmllWBaTLR4U3." alt="Image" width="730" height="388" loading="lazy"></p>
<p>One last thing. You are starting to see the amount of <em>redundancy</em>, or repeated work. Each proposed block will have many transactions (tests) in common. That is a security measure necessary for running a distributed system. If all the nodes are validating transactions separately, that makes it much harder to cheat the system.</p>
<h3 id="heading-the-race-for-proof-of-work">The race for proof of work</h3>
<p>Imagine that after all this work to create a block of 20 transactions, the principal then shared a 12th-grade level math problem to every miner. The person that solved the problem first was awarded all the points and had their block confirmed.</p>
<p>This would mean that the “rich get richer,” and it would skew the incentives for the whole system.</p>
<p>Every day, the top math students would have an excellent chance at winning the competition, and the rest of the seniors would have little to no chance. Soon, most miners/seniors would stop participating since they would never receive any points.</p>
<p>So, instead, our principal is going to set up a scavenger hunt in the school every night. Importantly, the scavenger hunt has <strong>nothing</strong> to do with a miner’s math ability. This encourages everyone to continue to mine.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*Qr4WFhLdSP25-2cA." alt="Image" width="730" height="730" loading="lazy"></p>
<p>The principal will hide a trophy somewhere in the school. The students must race around until they find it, and then yell so that the rest of the students throughout the school can confirm that they found it and go home. Since this principal has some magical foresight abilities, he hides the trophy in a perfect place so that it will take r<strong>oughly an hour to find each night.</strong></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*KInaCht6IDVdOhgP." alt="Image" width="730" height="818" loading="lazy"></p>
<p>Does this sound arbitrary? In other words, does it feel like it came out of nowhere?</p>
<p>Well, it must be unrelated to the test-validation so that it can level the playing field. This is known as “<a target="_blank" href="https://en.bitcoin.it/wiki/Proof_of_work">proof of work</a>” in Bitcoin. It is an algorithm that is difficult to solve, but easy for the other nodes to confirm once it is solved. Each Bitcoin miner must guess numbers until they choose the right one that solves the puzzle. In Bitcoin, a new block is confirmed every 10 minutes, on average.</p>
<p>Keep in mind, Bitcoin miners are really massive computers that look like this:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*-l7_x9hWb_TnXykS." alt="Image" width="730" height="548" loading="lazy">
_[Image credit](https://medium.com/@lopp/the-future-of-bitcoin-mining-ac9c3dc39c60" rel="noopener" target="<em>blank" title=").</em></p>
<p>The algorithm also gets gradually more difficult over time as more miners join the network. If there are more miners, that means there will be more guesses, so the challenge must get more difficult if Bitcoin wants to continue to confirm a block every 10 minutes.</p>
<p>This example demonstrates how Bitcoin (and our school example) force every miner to compete against the rest of the network. Once a miner solves the puzzle, they share their answer with the rest of the network, which can be quickly confirmed. After the nodes reach a <strong>consensus</strong>, or over 50% agree that the block is <strong>confirmed</strong>, it can be added to the blockchain.</p>
<p>This has motivated some miners to form <strong>guilds</strong>. In our school example, this means that a few of the students would agree to split the points once one of them finds the trophy. It simply increases the probability that the first one to find the trophy will be a member of their team.</p>
<p>In Bitcoin, the total computing power that is working on solving this “proof of work puzzle” is called the <a target="_blank" href="https://bitcoin.org/en/vocabulary#hash-rate"><strong>hash rate</strong></a>. The largest Bitcoin guilds control about 10% of the hash rate, which still gives the rest of the miners a good chance to solve the puzzle. If a guild contained 50% of the hash rate, there would be less incentive for others to continue to mine.</p>
<p>Once a block is confirmed, the miner receives the prize (10 points on a test) and all the transaction fees from the confirmed transactions. Transactions that were not part of the block then return to the <strong>mempool</strong> to be included in a future block.</p>
<h3 id="heading-building-a-blockchain">Building a blockchain</h3>
<p>So far, we have covered most of the steps that go into adding one more block to the blockchain. But, we have not covered the whole point of building a blockchain itself.</p>
<p>A blockchain has a simple three-level structure. A series of transactions make up a block. And a series of blocks make up a blockchain.</p>
<p>Although you can certainly divide a blockchain into pieces based on timing, usually, each individual node (senior) will maintain the full history of the blockchain, or the <strong>ledger</strong>.</p>
<p>In our high school example, we are looking at a 9th-grade class. So, the full history of the class could be all of the grades from all of the students in the entire class, from kindergarten until today. Since we are adding blocks at a 1-day interval, and there are approximately 180 days in the school year, that would mean that the blockchain contains about 1700 blocks.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*YdtjX9-71kre2aca." alt="Image" width="730" height="223" loading="lazy"></p>
<p>Each block has a unique ID, which, due to a “<a target="_blank" href="https://www.coindesk.com/information/how-do-bitcoin-transactions-work/">hash function</a>”, depends on the block ID of the previous block. That is what secures the blockchain: there is no such thing as block substitution, or rewriting history, because it will change the block ID of every subsequent block.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*IDnKIxaCaRxsE8RU." alt="Image" width="730" height="410" loading="lazy"></p>
<p>Since our education example uses one-day intervals, you might think, <em>“Oh, it should be easy to create a unique ID for each block, since each date only occurs once!”</em></p>
<p>But, that would introduce a security vulnerability. If a miner was able to introduce a new block somewhere in the middle of the chain, it would not break the pattern! The deviant miner would easily be able to replicate the block ID, and none of the following blocks would change their value, since dates follow a dependable pattern that can be easily replicated.</p>
<p>Here is a <a target="_blank" href="http://www.miraclesalad.com/webtools/sha256.php">hash generator that you can play around with</a>. I wish there was some wonderful analogy I could give you for the block order, but unfortunately, that is the point of the hash function. It makes it very, very hard to imitate and replace blocks (impossible, as far as we know). So, I will add some random strings to show what is going on.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*c9DDWVUYJU9Gf_lL." alt="Image" width="730" height="276" loading="lazy"></p>
<p>We are going to cover privacy in the next section, because right now, it looks like every 12th grader can see the entire grade history of each 9th grader. That is not what we want!</p>
<p>But, on the plus side, the distributed ledger allows each individual senior to ensure the validity of the graded tests as they circulate around the network.</p>
<p>This ordering system is <strong>relative</strong>, rather than absolute. The order of the blocks matters much more than the times that they were added to the chain. Timestamps, as we discussed above, are too easy to copy and imitate.</p>
<p>Let’s give an example of what is known as a <strong>double spend attack</strong>. Let’s say that one of your classmates takes a math test on a Monday, and knows that she did poorly. One of your classmates grades that version of the test and then broadcasts it to the nodes, per usual.</p>
<p>Your classmate who did poorly studies like crazy that night, and then shows up the next day to take the same test with another class. Maybe the teacher didn’t notice her there the day before — so she is able to convince the teacher that she was not present on the previous day. Remember, the teacher has no role in grading tests, so the teacher cannot quickly reference the previous day’s exams. The student is allowed to take the test again, and submits it with the rest of the class.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*PEQrhnTmZhPyNDwZ." alt="Image" width="730" height="411" loading="lazy"></p>
<p>Here are the latest options for blocks from the blockchain, with Alice’s attempt to override her previous grade.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*YEn6fQq_eZvWuSyl." alt="Image" width="730" height="678" loading="lazy"></p>
<p>Oh, by the way, Alice will now need to become a miner on the network and participate in the scavenger hunt. She is now the 11th miner on this network.</p>
<p>The rule is that the “longest chain wins.” That means that on Day 11, the rest of the network may be working on adding a new block with the latest set of transactions. But Alice will be working on “<strong>forking</strong>” the chain, and adding a new set of transactions for day 10 with 19 transactions in common, and her new test score as a replacement for the old test score.</p>
<p>Forking means that she is attempting to build a new longest chain, as opposed to the chain that the rest of the network assumes is the longest.</p>
<p>If she can win the scavenger hunt that day, and then come back the next day and win it again, she would have the longest chain.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*ssSrX9xeV-rGw8D7." alt="Image" width="730" height="518" loading="lazy"></p>
<p>This is part of the value of the “proof of work” system. Since Alice is one of 11 miners on the network, she has an approximately 1% chance of solving two blocks in a row. There is a 99% chance that she will put in all that work just to get nothing. Not a great incentive.</p>
<p>This is also why the block IDs and previous block IDs are a better labeling scheme than a specific date. If Alice wins the race on the day that she secretly takes the test a second time, all the new tests from that day will still be eventually stored in the blockchain. They will just need to wait one more day.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*_P5KrKwCU2FuXkYG." alt="Image" width="730" height="489" loading="lazy"></p>
<h3 id="heading-introducing-public-and-private-keys">Introducing public and private keys</h3>
<p>So far, we have covered all the mechanics that will allow the students of Distributed High School to manage their own grades. We are missing just one major thing: privacy!</p>
<p>Right now, the grades of each individual student are exposed forever on the blockchain. If this were a currency, it would be easy to figure out how much money each person had. That is not what we want.</p>
<p>At the same time, the transparency is a great way to keep individual people accountable for unfair grading and other fraudulent practices.</p>
<p>This is why Bitcoin uses a cryptographic system with <strong>public and private keys</strong>. In high school, you are probably used to the lockers that line pretty much every hallway.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*lWOuvJJs7uvVxzK4." alt="Image" width="300" height="300" loading="lazy"></p>
<p>Well, in Bitcoin, there are an (essentially) unlimited number of private-public key combinations. So instead, imagine that this high school’s walls are lined with the little mailboxes that you see in an apartment building.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*SaCRqoGbn9LGrNZw." alt="Image" width="730" height="190" loading="lazy"></p>
<p>And they cover every wall in this whole dang school. And, since there are an unlimited total number of lockers, each student in the school can own an unlimited number of lockers. In math terms:</p>
<p><em>Unlimited/30 students = Unlimited</em></p>
<p>Have you seen <a target="_blank" href="https://en.wikipedia.org/wiki/Harry_Potter_and_the_Order_of_the_Phoenix_(film)">Harry Potter and the Order of the Phoenix</a>?</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*lhLjy4ByrTRhb22J." alt="Image" width="730" height="435" loading="lazy"></p>
<p>It’s like the scenes from the “<a target="_blank" href="http://harrypotter.wikia.com/wiki/Hall_of_Prophecy">Hall of Prophecy</a>” — seemingly limitless.</p>
<p>But anyway…</p>
<p>For the sake of simplicity, let’s assume that each student gets 1 mailbox for each grade in school (9th-12th) during which they took tests. If a student is in 9th grade, that means they are using their 9th grade locker.</p>
<p>Let’s return to our transaction, where Andy grades Alice’s test.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*Pz1ZwzVBr9c_TYNt." alt="Image" width="730" height="532" loading="lazy"></p>
<p>Our <strong>full nodes</strong>, the wonderful seniors, must first evaluate whether Andy is qualified to be grading 9th grade math tests. Andy needs to prove himself.</p>
<p>Here’s an issue: if Andy happily announces to the network that he has graded Alice’s assignment, he risks exposing Alice. What if she got a failing grade? She doesn’t want the whole world to know that, forever!</p>
<p>So, he must broadcast while keeping both of them anonymous. He can randomly slip a note to one of the nodes…just like most rumors in 1980's high school movies start!</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*t4cxM7jDV10lZAZQ.gif" alt="Image" width="480" height="270" loading="lazy"></p>
<p>Then the full node would share this rumor with the rest of the network.</p>
<p>This is where our <strong>public keys</strong> come into play. When Andy slips a note about his graded test to the network, he is really saying:</p>
<ul>
<li>My current mailbox address is 126900trl.</li>
<li>In order to prove that I was there on test day, here is the answer key that the teacher gave me to grade this specific test (<strong>digital signature</strong>).</li>
<li>Also, in order to prove that I am indeed a 9th grader in algebra class, here are the final exam scores from math class each year from grades 1–8, and the answer key for each of those tests (<strong>transaction chain</strong>).</li>
<li>I am going to be delivering the test to mailbox 856734pok</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*EgJPXleu1fqn6T4N." alt="Image" width="730" height="381" loading="lazy"></p>
<p>This is answering two key questions:</p>
<ol>
<li>Is the sender the actual person that he/she claims to be?</li>
<li>Is the sender qualified to be the sender (grade the test)?</li>
</ol>
<p>In order to answer the first question, Bitcoin uses a <strong>digital signature</strong>. The digital signature is unique to every transaction and is formed with a hash of the transaction ID and private key. In this case, that is kind of like the test key: you can only own it if you were there on the specific test day and the teacher gave it to you.</p>
<p>For the second question, remember that in Bitcoin there is no concept of an “account” or “account balance.” If there was, Andy could just share an ID number that proved he was qualified.</p>
<p>In order to prove that this particular public key (Andy’s public key) has the sufficient approval, he must share a test history that every full node can validate. That way, everyone can validate that he completed 1st-8th grade. Andy must also provide the answer key for each of those tests to prove that he was in the room at that time. This is called the <strong>transaction chain.</strong> I will not cover it here, but it is an important part of validation.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*_CQr2_5Bm1-pJBYh." alt="Image" width="197" height="300" loading="lazy"></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*TuGPI64sSgjzdV5O." alt="Image" width="730" height="455" loading="lazy">
_[Image credit](https://www.cryptocompare.com/wallets/guides/how-do-digital-signatures-in-bitcoin-work/" rel="noopener" target="<em>blank" title=").</em></p>
<p>After Andy’s transaction is <strong>validated</strong> and then included in a block that has been <strong>confirmed</strong>, he can go drop the test off in Alice’s mailbox without public knowledge.</p>
<p>As you noticed in the transaction above, Andy had to access tests from the last 8 years! This locker system only allows Andy to access his tests.</p>
<p>Andy has a set of 8 <strong>private keys</strong>. Every time he started a new year, he opened another locker and put his grades from that year in the locker.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0*3PLQPo9mhRE477b0." alt="Image" width="730" height="375" loading="lazy"></p>
<p>Others can slide his latest test results into his locker, but only he can then retrieve the results.</p>
<p>Bitcoin software like <a target="_blank" href="http://coinbase.com/">Coinbase</a> allows you to create many public/private key combinations within your wallet. This improves security. You never want to give away your private keys, which are the only way to access the Bitcoins that have been transferred to you. Unlike a traditional bank, there is nobody to turn to if you forget or lose a private key. The Bitcoin will be locked up.</p>
<h3 id="heading-final-thoughts">Final Thoughts</h3>
<p>To recap, we have:</p>
<ul>
<li>Tests (Transactions)</li>
<li>Answer keys (Digital signatures)</li>
<li>9th graders (senders and recipients)</li>
<li>12th graders (full nodes)</li>
<li>Principal (blockchain creator)</li>
<li>Unlimited mailboxes (public/private keys)</li>
<li>No teachers grading tests (centralized authority)</li>
<li>No report cards (Accounts/account balances)</li>
</ul>
<p>Much of this system revolves around the concept of being “trustless,” as you have probably seen by the careful checks and balances and incentive structures. In the traditional playbook for administrating banking or public education, trust in a central authority plays a huge role. In order to give that control back to individual people, there must be a huge amount of redundancy from the nodes to prevent fraud, as well careful security protocols to prevent hackers from infiltrating the system.</p>
<p>But, this distributed system could revolutionize the way that many industries handle their data, and could help prevent industrial accidents, medical malpractice, and financial ruin.</p>
<p>If you haven’t already noticed, there is a huge amount of duplicated work across all the full nodes. Between validating and confirming transactions, as well as guessing answers to the “proof of work” as quickly as possible, the system consumes plenty of energy. <a target="_blank" href="https://arstechnica.com/tech-policy/2017/12/bitcoins-insane-energy-consumption-explained/">According to one estimate</a>, the Bitcoin network consumes as much energy as the country of Denmark! But, this is also necessary to form a consensus and maintain the integrity of mining.</p>
<h3 id="heading-get-more-visual-explanations">Get More Visual Explanations</h3>
<p>Did you enjoy this tutorial? Give it a clap, leave a comment, or sign up here to get my latest technical explanations:</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ You might have misconceptions about Blockchain. Let me help you fix them. ]]>
                </title>
                <description>
                    <![CDATA[ By Syed Fazle Rahman The internet is going crazy about this new buzzword called “Blockchain.” I am sure you have heard about it too, from your friends, investors, users or team members. As a technology, blockchain is so new and popular that people do... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/misconceptions-about-blockchain-8553262e8ff0/</link>
                <guid isPermaLink="false">66c35b611bbad699e42799fc</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ICO ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 17 Apr 2018 12:08:17 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*ZZe6aLUCv8Qe6wxcl0ZTQA.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Syed Fazle Rahman</p>
<p>The internet is going crazy about this new buzzword called “Blockchain.” I am sure you have heard about it too, from your friends, investors, users or team members. As a technology, blockchain is so new and popular that people don’t have a proper idea about it and its applications.</p>
<p>In this article, let me help you correct the ten misconceptions about blockchain on a superficial level.</p>
<h3 id="heading-1-cryptocurrency-is-the-only-application-of-blockchain">1. Cryptocurrency is the only application of blockchain</h3>
<p>Creating a cryptocurrency seems like the most popular and viable application of blockchain today. This is also an easy way of making money by launching an ICO (Initial Coin Offerings) where investors buy your virtual coins with fiat currency or other coins like ETH, BTC, and so on.</p>
<p>Starting an ICO and making money quickly definitely looks tempting and is one of the reasons why it became massively popular. Take a look at the top 99 cryptocurrencies in the market right now and their current value, <a target="_blank" href="http://99coins.co/">99coins</a>.</p>
<p>On a side note, the ease of launching an ICO opened doors to many scams like the “Vietnamese Modern Tech” scam, where <a target="_blank" href="http://fortune.com/2018/04/12/icos-cryptocurrency-scam-vietnam/">a fake company raised $658M</a> by promising to build tech internet giants in the country.</p>
<p>But in reality, there are multiple real-world applications of blockchain, and cryptocurrency is just one of them. Here are a few of them:</p>
<ol>
<li><strong>Healthcare:</strong> Blockchain can help us keep health records securely with proper timestamps, so they don’t get lost. The current health care systems have a massive amount of data, and they aren’t managed and connected to the internet properly.</li>
<li><strong>Banking:</strong> Blockchain can help in cutting costs of settling transactions involving bonds or other financial instruments. It can help in sending money to countries where banking facilities aren’t a viable option.</li>
<li><strong>Distributed Cloud Storage:</strong> Today, the photos and documents we upload to the cloud (Google Drive, iCloud, and so on.) are all centralized and, and everything is controlled by an organization. With blockchain, we can take full control of our data, encrypt and store them, and access them securely.</li>
</ol>
<blockquote>
<p><strong><em>Tip: ? I</em></strong>f you want to launch your own ICO in a few minutes without any coding, check out T<a target="_blank" href="https://tokenlauncher.co/">okenLauncher,</a> created by S<a target="_blank" href="https://www.freecodecamp.org/news/misconceptions-about-blockchain-8553262e8ff0/undefined">andeep</a> and me.</p>
</blockquote>
<h3 id="heading-2-the-blockchain-is-the-solution-to-all-the-problems-under-the-sun">2. The blockchain is the solution to all the problems under the sun!!</h3>
<blockquote>
<p>“If all you have is a <strong>hammer</strong>, everything looks like a <strong>nail.</strong>”</p>
</blockquote>
<p>Just like the above quote, all the applications in the world needn’t involve blockchain. Blockchain comes with the concept of keeping the data or transactions decentralized. This means all your data is recorded forever in a network of computers. Data, once sent to a blockchain network, cannot be deleted or removed from all the systems. So, if you are thinking to build a decentralized network, think again!</p>
<h3 id="heading-3-bitcoin-is-blockchain">3. Bitcoin is Blockchain</h3>
<p><strong>The blockchain is the technology that powers Bitcoin</strong>. Bitcoin is also one of the first applications of blockchain that went popular. Therefore, many people assume that Bitcoin is blockchain.</p>
<p>Bitcoin was initially created as an alternative, decentralized payment method. However, as the supply of Bitcoin is limited, the value has increased drastically in recent times. Today, Bitcoin is considered digital gold and people treat it as an asset rather than a mode of payment.</p>
<h3 id="heading-4-smart-contracts-are-legal-documents">4. Smart contracts are legal documents!</h3>
<p><strong>No, they are not!</strong> The smart contract helps eliminate the need to pay intermediaries (Middlemen) and saves time and complexity. Think of them as self-executing code blocks that reside on the blockchain that no one can tamper with. However, smart contracts cannot be served as a legal document like Bonds, and so on.</p>
<h3 id="heading-5-blockchains-are-always-public">5. Blockchains are always public</h3>
<p>A public blockchain is open-source and accessible to all, and no one is in charge. Anyone can be part of the consensus in a public blockchain. However, all blockchains need not be public. You can make or create a private blockchain for your closed group of people.</p>
<p>In a private blockchain, the owner is a single entity or an enterprise and can delete/override commands on a blockchain, if needed. The private blockchain is also faster, cheaper, and requires less energy to operate.</p>
<h3 id="heading-6-blockchains-cannot-be-linked-together">6. Blockchains cannot be linked together</h3>
<p>Most of us assume that blockchains cannot communicate with each other. Well, it’s not our fault. That’s how blockchain was implemented, initially.</p>
<p>However, it’s entirely possible to send data between blockchains. <a target="_blank" href="https://cosmos.network/"><strong>Cosmos</strong></a>, a company which is building the future <em>Internet of Blockchain</em>, is trying to bridge the gap between multiple blockchains by enabling them to exchange data easily.</p>
<h3 id="heading-7-proof-of-work-is-the-only-way-of-achieving-consensus">7. Proof of work is the only way of achieving consensus</h3>
<p>As a group of people/nodes run blockchain, they need a way to agree before committing a transaction in the network. In simple terms, the consensus is a dynamic way of reaching agreement in a group.</p>
<p>The most common form of consensus is “<a target="_blank" href="https://hashnode.com/post/back-to-basics-why-proof-of-work-cjfc9pbxa003uo5s1vqbclz81"><strong>Proof of work</strong></a><strong>,</strong>” where every miner has to solve a difficult problem. The reward is given to the first miner who solves each block problem. However, it’s extremely expensive and requires a lot of power to run. Hence, people invented other types of consensus. Read about various types of consensus protocols <a target="_blank" href="https://blockgeeks.com/guides/blockchain-consensus/">here</a>.</p>
<p>Two popular alternatives to POW are:</p>
<ul>
<li><strong>Proof of stake:</strong> a node/person can mine or validate block transactions according to how many coins they hold. Which means the more coins owned by a miner, the more mining power they have. Example: <a target="_blank" href="https://neo.org/">Neo</a></li>
<li><strong>Delegated Proof Of Stake:</strong> people in the blockchain vote for witnesses who are paid for their services. The top witnesses even earn a monthly salary. The amount of stake a person has determines the power of each vote. This means people who have more tokens will influence the network more than people who have very few tokens. Any witness who’s not doing their job is thrown out and replaced with another witness. Example: <a target="_blank" href="https://steem.io/">Steem</a>, <a target="_blank" href="https://lisk.io/">Lisk</a>, and so on.</li>
</ul>
<h3 id="heading-8-the-blockchain-network-can-shut-down-if-the-creator-is-no-longer-interested">8. The Blockchain network can shut down if the creator is no longer interested</h3>
<p>A public blockchain network cannot shut down easily. Since a blockchain is decentralized and no single authority controls it, it’s very difficult to shut it down unless all the participants in the network stop working. In most cases, it’s nearly to impossible to shut down a public blockchain.</p>
<h3 id="heading-9-mentioning-blockchain-in-your-pitch-deck-guarantees-funding">9. Mentioning “Blockchain” in your pitch deck guarantees funding</h3>
<p>Many people around the world want to jump into the hype train and make money out of it. We see this trend every year with new buzzwords. In 2016 and 2017, it was ML and AI. In 2018, it’s Blockchain. ?</p>
<p>If you are raising money without thinking deeper, the product is destined to die as the market stabilizes itself. So, beware! An investor wants a return! ?</p>
<h3 id="heading-10-only-geeks-and-nerds-can-use-blockchain">10. Only geeks and nerds can use Blockchain</h3>
<p>Even my cat can use Blockchain!</p>
<p>You don’t have to be a nerd to use blockchain. For example, to send or receive Bitcoin, all you need is a wallet that supports Bitcoin transactions, a public address, and a private key! Make sure to keep your private key secret. It takes a few seconds to create a new Bitcoin wallet. Get your wallet <a target="_blank" href="https://bitcoin.org/en/choose-your-wallet">here</a>.</p>
<h4 id="heading-bonus"><em>(Bonus)</em></h4>
<h3 id="heading-blockchain-dlt-distributed-ledger-technology">Blockchain === DLT (Distributed Ledger Technology)</h3>
<p>Many believe that blockchain and DLT are the same. However, this is not true. DLT is an umbrella term used to refer to technologies that distribute information among multiple nodes. By this logic, we can say blockchain is a fully functional Distributed Ledger Technology.</p>
<p>Other protocols such as HashGraph, Nano, IOTA (Tangle Network) and so on are also DLTs, but they are not blockchain.</p>
<p>So, blockchain and DLT may be synonymous, but they aren’t the same. Rather, blockchain is a type of DLT.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>I hope I was able to clear any misconceptions you might have had about the blockchain. If I left any out, please leave your comments below.</p>
<p>PS: I am not associated with any blockchain products that I have mentioned in my article.</p>
<p>PPS: My team and I are building a friendly community for developers called <a target="_blank" href="https://hashnode.com">Hashnode</a>. More than half a million developers hang out and discuss programming every month. Make sure to <a target="_blank" href="https://hashnode.com/communities?tab=blockchain">follow popular crypto communities</a> to stay in the loop.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to build a Cryptocurrency price list app using Flutter SDK ]]>
                </title>
                <description>
                    <![CDATA[ By Elvis Chidera Flutter is Google’s new open-source toolkit for helping developers build iOS and Android apps with just one codebase. Flutter apps are written in the Dart programming language and compile to native code, so the performance is really,... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-build-a-cryptocurrency-price-list-app-using-flutter-sdk-1c75998e1a58/</link>
                <guid isPermaLink="false">66d45e3f264384a65d5a9514</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ education ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 08 Mar 2018 05:50:18 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*0umkh4edvLRBJgxiuoVDcA.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Elvis Chidera</p>
<p><a target="_blank" href="https://flutter.io">Flutter</a> is Google’s new <strong>open-source</strong> toolkit for helping developers build iOS and Android apps with just <strong>one codebase</strong>. Flutter apps are written in the <a target="_blank" href="http://dartlang.org">Dart</a> programming language and compile to <strong>native</strong> code, so the performance is really, really great.</p>
<p>In this tutorial, I will show you how to use Flutter to build an app that shows the current price of different cryptocurrencies. I will walk you through the fundamentals of Flutter and Dart.</p>
<p>Before we start, <a target="_blank" href="https://flutter.io/get-started/install/">install Flutter</a> and the <a target="_blank" href="https://flutter.io/get-started/editor/">Flutter editor plugin</a> if you haven’t done so already. The installation should be straight-forward, but if you bump into issues you can leave a comment on this post and I will be glad to help out.</p>
<p>For this tutorial, I will be using <a target="_blank" href="https://developer.android.com/studio/index.html">Android Studio</a>, but you can also use <a target="_blank" href="https://www.jetbrains.com/idea/">IntelliJ</a> or <a target="_blank" href="https://code.visualstudio.com/">Visual Studio Code</a>.</p>
<p>Also, some object-oriented programming (OOP) experience is required. Relax! You don’t need years of experience — if you know what <a target="_blank" href="https://www.techrepublic.com/article/intro-to-oop-understanding-classes-and-objects/">classes and objects</a> are, you should be fine.</p>
<h4 id="heading-lets-get-started">Let’s get started</h4>
<p>On Android Studio or IntelliJ, click on the <strong>File</strong> menu -&amp;g<strong>t;</strong> New <strong>-&gt; New Flutter P</strong>roject. If you don’t se<strong>e the New Flutter P</strong>roject option, ensure you have installe<a target="_blank" href="https://flutter.io/get-started/editor/">d the Flutter</a> plugin. If you are using Visual Studio Code, follow the <a target="_blank" href="https://flutter.io/get-started/test-drive/">step</a>s here to create a new project.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*oE6SlcmuRJwR-tHRJzpZvA.png" alt="Image" width="800" height="377" loading="lazy"></p>
<p>When the page opens, select <strong>Flutter Application</strong> and click on the <strong>Next</strong> button.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*SM_ttARLHyGXP38TaxMngA.png" alt="Image" width="800" height="377" loading="lazy"></p>
<p>The next page lets you configure the project. You can use a similar configuration like the image below. Just ensure that the Flutter SDK path points to the directory where you downloaded Flutter.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*uEgNPColbpe8DQTqc5EE5g.png" alt="Image" width="800" height="380" loading="lazy"></p>
<p>The last page lets you configure your company domain name, and you can set it to any domain name. After that, click on the Finish button.</p>
<p>The project creation should begin after clicking the finish button, which usually takes a few minutes.</p>
<p>When it’s done, your project should look like this.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*SOKlN4-dxCw4X-CAN1_ZAA.png" alt="Image" width="800" height="352" loading="lazy"></p>
<p>A file called <code>main.dart</code> was created in the <code>lib</code> folder. It contains code for a demo app. Since we will be building our app from scratch, open up the <code>main.dart</code> file and delete/clear all the code in it.</p>
<p>If your project includes a <code>test</code> directory that contains the file <code>widget_test.dart</code>, delete this file before continuing. It contains tests for the code we just deleted.</p>
<p>Flutter apps are written in the Dart programming language. The <code>main.dart</code> file is a Dart source file (<code>.dart</code> extension). The Dart convention is to name source files using <code>lowercase_with_underscores</code>.</p>
<p>Let’s start writing some Dart code. We will begin with the programming tradition: printing “Hello World!”</p>
<p>To do that we will have to create something called the <code>main</code> function. The <code>main</code> function is a top-level function that every Flutter app has that serves as the entry point into your app. Think of it like the entrance to a house.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*hC831nn9aLYCdcGaYkDQGw.png" alt="Image" width="800" height="450" loading="lazy"></p>
<p>When you run your app on a device, execution will start from the main function. Let’s create a simple <code>main</code> function, so enter the following code into your <code>main.dart</code> file.</p>
<p>As you can see, creating the <code>main</code> function is easy. The second line contains the <code>main</code> function declaration: its return type(<code>void</code>) and name (<code>main</code>). The main function returns <code>void</code> meaning it returns nothing.</p>
<p>The third line does the printing to the console. We call the <code>print</code> function and pass a string argument to it. Note that in Dart, you can use single quotes (<code>‘string’</code>) or double quotes (<code>“string”</code>) when declaring a string literal.</p>
<p>To run the code, click on the green run (play) button at the top of Android Studio or IntelliJ. Ensure you have an actual device connected or you have an <a target="_blank" href="https://flutter.io/setup-windows/">emulator running</a>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*3TYytoIBY2UvLR-VOdR_Cw.png" alt="Image" width="747" height="131" loading="lazy"></p>
<p>After the app successfully starts, you should see “Hello World!” printed on the console.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*smn4mdtI8SzSkRH0c0I3Ew.png" alt="Image" width="800" height="170" loading="lazy"></p>
<p>But if you check your device or emulator, you will see something disappointing.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*NXFISzRQgevj7BjxiAtIPw.png" alt="Image" width="279" height="500" loading="lazy">
<em>A blank screen</em></p>
<p>Well, this was expected, as we are currently only printing to the console. There was nothing added to the app UI, and that is why it is blank.</p>
<p>So let’s fix this by adding some elements to the app UI. Our app will be using material design, so let’s add a package to the <code>main.dart</code> file to help with that.</p>
<pre><code><span class="hljs-keyword">import</span> <span class="hljs-string">'package:flutter/material.dart'</span>;
</code></pre><p>Just like any modern programming language, you can import a library/package to use in your code. Here we are importing the <code>material.dart</code> package. This package contains code that helps us create a material styled app.</p>
<p>The <code>material.dart</code> package has a function called <code>runApp</code>. The <code>runApp</code> takes a widget and attaches it to the screen. Well, what is a widget?</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*NK6qwYtoWPzPrUptqheOnQ.jpeg" alt="Image" width="750" height="361" loading="lazy">
<em>Widgets</em></p>
<p>You can think of widgets as views or UI elements. They are the things you see (and some you don’t see) when you run your app on a device. In Flutter, you will be using widgets a lot, because the main idea is that your app UI is made entirely out of widgets.</p>
<p>Flutter already comes with a suite of powerful widgets like text and images. The <code>material.dart</code> package we just imported has several material design widgets that we will be using shortly.</p>
<p>Let’s use the <code>runApp</code> method now to show “Hello World!” at the center of the device screen. Replace the content of the <code>main</code> function with the code below.</p>
<pre><code class="lang-dart"><span class="hljs-keyword">void</span> main() {
  <span class="hljs-built_in">print</span>(<span class="hljs-string">'Hello World!'</span>);

  <span class="hljs-comment">// Runs the MaterialApp widget</span>
  runApp(<span class="hljs-keyword">new</span> MaterialApp(
    <span class="hljs-comment">// This is the widget that is displayed first when the application is started normally</span>
    home: <span class="hljs-keyword">new</span> Center(
      <span class="hljs-comment">// The Text widget is wrapped in a center widget to center it on the screen</span>
      child: <span class="hljs-keyword">new</span> Text(<span class="hljs-string">'Hello World!'</span>),
    ),
  ));
}
</code></pre>
<p>Let me explain some ofthe new stuff in the code above</p>
<ol>
<li><code>new</code>: To create an object, you usually use the <code>new</code> keyword with a <em>constructor</em> for a class. (OOP)</li>
<li><code>new MaterialApp()</code>: Here we are creating a new widget object called <code>MaterialApp</code>. The <code>MaterialApp</code> widget creates a number of useful things needed by a material design app.</li>
<li><code>home:</code>: In Dart, we can clearly state the name of each parameter within the function/constructor call. The widget passed in as the <code>home</code> parameter is displayed first when the app is started normally.</li>
<li><code>new Center(child: new Text('Hello World!'))</code> : We wrap the Text widget inside a Center widget so that the text gets centered on the screen. The Text widget is a child of the Center widget. Yes, widgets can be nested.</li>
</ol>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*Z79-bHQP9bhwSh9IYlaMTA.png" alt="Image" width="800" height="450" loading="lazy"></p>
<p>If you run the code again and open up your device, you should get a slightly better screen now.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*Gnn1V4u5ClUok_kAeOnl4g.png" alt="Image" width="279" height="500" loading="lazy"></p>
<p>Cool! We were able to show an ugly looking text centered on the device screen.</p>
<h4 id="heading-the-next-steps">The next steps</h4>
<p>Let’s take a few steps forward now. We will be getting the cryptocurrency prices from the <a target="_blank" href="https://api.coinmarketcap.com/v1/ticker/">CoinMarketCap API</a>. The API returns a JSON array. Here is a sample response from the API:</p>
<pre><code>[
    {
        <span class="hljs-string">"name"</span>: <span class="hljs-string">"Bitcoin"</span>, 
        <span class="hljs-string">"price_usd"</span>: <span class="hljs-string">"11525.7"</span>, 
        <span class="hljs-string">"percent_change_1h"</span>: <span class="hljs-string">"-0.18"</span>,
        ...
    },
    ...
]
</code></pre><p>We will be making a request to the CoinMarketCap API and decoding the JSON from the app. We will have to include a couple of new packages to the <code>main.dart</code> file.</p>
<pre><code><span class="hljs-keyword">import</span> <span class="hljs-string">'dart:async'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'dart:convert'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'package:http/http.dart'</span> <span class="hljs-keyword">as</span> http;
</code></pre><p>Here’s an overview of the new packages:</p>
<ol>
<li><code>dart:async</code>: Provides the <code>Future</code> class, which I will talk more about below.</li>
<li><code>dart:convert</code>: Provides the <code>json</code> variable we will use to decode the JSON string response.</li>
<li><code>package:http/http.dart</code>: Provides the function we will use to make HTTP GET requests.</li>
</ol>
<p>Let’s add a new function to the <code>main.dart</code> file that makes a request to the CoinMarketCap API.</p>
<pre><code>
Future&lt;List&gt; getCurrencies() <span class="hljs-keyword">async</span> {
  <span class="hljs-built_in">String</span> apiUrl = <span class="hljs-string">'https://api.coinmarketcap.com/v1/ticker/?limit=50'</span>;
  <span class="hljs-comment">// Make a HTTP GET request to the CoinMarketCap API.</span>
  <span class="hljs-comment">// Await basically pauses execution until the get() function returns a Response</span>
  http.Response response = <span class="hljs-keyword">await</span> http.get(apiUrl);
  <span class="hljs-comment">// Using the JSON class to decode the JSON String</span>
  <span class="hljs-keyword">return</span> <span class="hljs-built_in">JSON</span>.decode(response.body);
}
</code></pre><p>Let’s walk through the new code</p>
<p>→ <code>Future&lt;List&gt;</code> : We are basically saying that the <code>getCurrencies()</code> function will return a <code>List</code> sometime in the future. It will make an HTTP request to the CoinMarketCap API and return a <code>List</code> of currencies when done.</p>
<p>The <code>getCurrencies()</code> function is asynchronous. If you have some JavaScript experience, you can think of <code>Futures</code> as <code>Promises</code>. I created the images below to help you understand <code>Futures</code> in Dart.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*YrTpSezcRdjSQl5M6R33IA.png" alt="Image" width="800" height="450" loading="lazy">
<em>Bob calls the asynchronous function askKateForBalloons() which returns a Future&lt;Balloons&gt;</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*dyGmD3Z6t0uEFYthWVUq0A.png" alt="Image" width="800" height="450" loading="lazy">
<em>Bob can keep the Future&lt;Balloons&gt;</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*fj18OGjh4wfy42q5XXTwWg.png" alt="Image" width="800" height="450" loading="lazy">
<em>Bob can know when the Future completes</em></p>
<p>→ <code>async and await</code> :</p>
<p><code>Await</code> expressions let you write asynchronous code almost as if it were synchronous. The <code>http.get(url)</code> function is asynchronous, returning a <code>Future&lt;Respon</code>se&gt; immediately when it’s called. We want to wait fo<code>r the Re</code>sponse so we can decode the JSON string, but we also don’t want to use ugly callbacks.</p>
<p>The <code>await</code> expression evaluates <code>http.get(url)</code>, and then suspends the currently running function (<code>getCurrencies()</code>) until the result is ready — that is, until the Future has completed.</p>
<p>To use <code>await</code>, the code must be in a function marked as asynchronous. An <code>async</code> function is a function whose body is marked with an <code>async</code> modifier. When you call an <code>async</code> function, it immediately returns a Future. The body of the function is scheduled for execution later.</p>
<p>You can read more about <code>async</code> and <code>await</code> in Dart <a target="_blank" href="https://www.dartlang.org/articles/language/await-async">here</a>.</p>
<p>→ <code>http.get(url)</code> : Makes a HTTP GET request to the CoinMarketCap API. This function is asynchronous and returns a Future immediately.</p>
<ol>
<li><code>JSON.decode(response.body)</code> : Decodes the JSON string response.</li>
</ol>
<p>Let’s test the <code>getCurrencies()</code> function we just created. We do that by making a call to it in our <code>main</code> function and printing the returned value to the console.</p>
<pre><code><span class="hljs-comment">// Since we are using await within the main function, we have to make it asynchronous too</span>
<span class="hljs-keyword">void</span> main() <span class="hljs-keyword">async</span> {
  <span class="hljs-comment">// Testing the getCurrencies function</span>
  <span class="hljs-comment">// We wait for the currency data to arrive</span>
  List currencies = <span class="hljs-keyword">await</span> getCurrencies();
  <span class="hljs-comment">// Before printing it to the Console</span>
  print(currencies);

  runApp(<span class="hljs-keyword">new</span> MaterialApp(
    home: <span class="hljs-keyword">new</span> Center(
      child: <span class="hljs-keyword">new</span> Text(<span class="hljs-string">'Hello World!'</span>),
    ),
  ));
</code></pre><p>If you run the code above, you should see the API response printed to the console.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*asbOqbSU3_M12wYvbe4vSw.png" alt="Image" width="800" height="176" loading="lazy"></p>
<p>Well, in the real world bad things can happen. For example, you might not be connected to the internet, so the request to the CoinMarketCap API will fail. For this tutorial, we will assume we are in <a target="_blank" href="https://en.wikipedia.org/wiki/Wakanda_(comics)">Wakanda</a>.</p>
<p>In a production app, you will have to handle network failure. You do that by putting the HTTP call in a <code>[try…catch](https://www.dartlang.org/guides/libraries/futures-error-handling)</code> block.</p>
<h4 id="heading-building-out-the-ui">Building out the UI</h4>
<p>Now that we have a list of currencies, let’s go ahead to build the UI to show that list.</p>
<p>When writing Flutter apps, you’ll usually create new widget classes. A widget’s main job is to implement a <code>build</code> function, which describes the widget in terms of other, lower-level widgets.</p>
<p>Let’s create a new Widget called CryptoListWidget. Add the code below to the bottom of your <code>main.dart</code> file.</p>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">CryptoListWidget</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">StatelessWidget</span> </span>{

  <span class="hljs-comment">// This is a list of material colors. Feel free to add more colors, it won't break the code</span>
  <span class="hljs-keyword">final</span> <span class="hljs-built_in">List</span>&lt;MaterialColor&gt; _colors = [Colors.blue, Colors.indigo, Colors.red];
  <span class="hljs-comment">// The underscore before a variable name marks it as a private variable</span>
  <span class="hljs-keyword">final</span> <span class="hljs-built_in">List</span> _currencies;

  <span class="hljs-comment">// This is a constructor in Dart. We are assigning the value passed to the constructor</span>
  <span class="hljs-comment">// to the _currencies variable</span>
  CryptoListWidget(<span class="hljs-keyword">this</span>._currencies);

  <span class="hljs-meta">@override</span>
  Widget build(BuildContext context) {
    <span class="hljs-comment">// Build describes the widget in terms of other, lower-level widgets.</span>
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Text(<span class="hljs-string">'Hello World!'</span>);
  }

}
</code></pre>
<p>Let’s walk through the new code above:</p>
<ol>
<li><code>StatelessWidget</code> : You will usually create Widgets that are subclasses of either <code>[StatelessWidget](https://stackoverflow.com/questions/47501710/stateful-vs-stateless-widgets-in-flutter)</code> <a target="_blank" href="https://stackoverflow.com/questions/47501710/stateful-vs-stateless-widgets-in-flutter">or <code>StatefulWidget</code></a>, depending on whether your widget manages any state. We are using <code>StatelessWidget</code> because we have our data already and we won’t be updating it in this tutorial.</li>
<li><code>final List&lt;MaterialColor&gt; _</code>colors : Variables <code>in a Stateless</code>Widget shou<code>ld be</code> final (meaning they are constant or do not change). Here we are declar<code>ing a</code> final variable that holds a li<code>st of Materia</code>lColors. The unders<code>c</code>ore (_) before the variable name makes it private (inaccessible from other classes).</li>
<li><code>CryptoListWidget(this._currencies)</code> : This is the constructor for our widget. It assigns the list of currencies we pass into the constructor to the <code>_currencies</code> variable.</li>
<li><code>build</code> function: The build method returns a lower-level Widget (<code>Text</code>) that describes how it will look.</li>
</ol>
<p>Let’s replace the Text widget in the <code>build</code> function above with a new widget called <code>Scaffold</code>. The <code>Scaffold</code> widget implements the basic material design visual layout structure. Replace the <code>build</code> function above with the one below.</p>
<pre><code class="lang-dart"><span class="hljs-meta">@override</span>
  Widget build(BuildContext context) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Scaffold(
      body: _buildBody(),
      backgroundColor: Colors.blue,
    );
  }
</code></pre>
<p>The Scaffold class provides APIs for showing drawers, floating an action button, bottom bar, snack bar, and so on. We will be adding a floating action button later.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*PsoStgOHjRfZ2C2saoPQEw.png" alt="Image" width="800" height="450" loading="lazy"></p>
<p>You should get a warning that <code>_buildBody()</code> isn’t defined for the class <code>CryptoListWidget</code>. Let’s go ahead to create <code>_buildBody()</code> function inside of the <code>CryptoListWidget</code> class.</p>
<pre><code class="lang-dart">Widget _buildBody() {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Container(
      <span class="hljs-comment">// A top margin of 56.0. A left and right margin of 8.0. And a bottom margin of 0.0.</span>
      margin: <span class="hljs-keyword">const</span> EdgeInsets.fromLTRB(<span class="hljs-number">8.0</span>, <span class="hljs-number">56.0</span>, <span class="hljs-number">8.0</span>, <span class="hljs-number">0.0</span>),
      child: <span class="hljs-keyword">new</span> Column(
        <span class="hljs-comment">// A column widget can have several widgets that are placed in a top down fashion</span>
        children: &lt;Widget&gt;[
          _getAppTitleWidget(),
          _getListViewWidget()
        ],
      ),
    );
  }
</code></pre>
<p>The syntax here should be familiar. We are using two new Widgets:</p>
<ol>
<li><code>Container</code> widget: A <code>[Container](https://docs.flutter.io/flutter/widgets/Container-class.html)</code> widget is just a container :) (for other widgets).</li>
<li>Column widget: A <code>[Column](https://docs.flutter.io/flutter/widgets/Column-class.html)</code> widget layouts a list of child widgets in the vertical direction. It has a parameter called <code>children</code> that takes a list of widgets.</li>
</ol>
<p>Let’s create the two functions we called in the <code>_buildBody()</code> function. The first one is <code>_getAppTitleWidget()</code> .</p>
<pre><code class="lang-dart">Widget _getAppTitleWidget() {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Text(
      <span class="hljs-string">'Cryptocurrencies'</span>,
      style: <span class="hljs-keyword">new</span> TextStyle(
          color: Colors.white,
          fontWeight: FontWeight.bold,
          fontSize: <span class="hljs-number">24.0</span>),
    );
  }
</code></pre>
<p>This function returns a regular <code>Text</code> widget with a style that makes it bold and white with a font size of 24.0.</p>
<p>The text is going to look like this when we run the app.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*fAbESNYbWMV900x1Fq84CA.png" alt="Image" width="800" height="222" loading="lazy"></p>
<p>We can’t run the app yet because we haven’t created the other function called <code>_getListViewWidget()</code>. Let’s quickly create it using the code below.</p>
<pre><code class="lang-dart">Widget _getListViewWidget() {
    <span class="hljs-comment">// We want the ListView to have the flexibility to expand to fill the</span>
    <span class="hljs-comment">// available space in the vertical axis</span>
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Flexible(
        child: <span class="hljs-keyword">new</span> ListView.builder(
            <span class="hljs-comment">// The number of items to show</span>
            itemCount: _currencies.length,
            <span class="hljs-comment">// Callback that should return ListView children</span>
            <span class="hljs-comment">// The index parameter = 0...(itemCount-1)</span>
            itemBuilder: (context, index) {
              <span class="hljs-comment">// Get the currency at this position</span>
              <span class="hljs-keyword">final</span> <span class="hljs-built_in">Map</span> currency = _currencies[index];

              <span class="hljs-comment">// Get the icon color. Since x mod y, will always be less than y,</span>
              <span class="hljs-comment">// this will be within bounds</span>
              <span class="hljs-keyword">final</span> MaterialColor color = _colors[index % _colors.length];

              <span class="hljs-keyword">return</span> _getListItemWidget(currency, color);
            }));
  }
</code></pre>
<p>The <code>_getListViewWidget()</code> returns a <code>ListView</code> widget that is wrapped in a <code>Flexible</code> widget. We use the <code>ListView.builder</code> to easily create the list. We pass in an <code>itemCount</code> which tells the builder how many currencies to show.</p>
<p>The <code>itemBuilder</code> callback will be called for each item and you have to return a new widget. In the code above we are calling a function called <code>_getListItemWidget()</code> that returns a Widget.</p>
<pre><code class="lang-dart">CircleAvatar _getLeadingWidget(<span class="hljs-built_in">String</span> currencyName, MaterialColor color) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> CircleAvatar(
      backgroundColor: color,
      child: <span class="hljs-keyword">new</span> Text(currencyName[<span class="hljs-number">0</span>]),
    );
  }
</code></pre>
<p>Before we create the <code>_getListItemWidget()</code> function, let’s quickly create the individual elements for the ListView item widget. We want each item in the ListView to look like this:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*O3HD57q2Ovl5MPUyndgWUw.png" alt="Image" width="800" height="175" loading="lazy"></p>
<p>So, we have three main widgets:</p>
<ol>
<li>A round icon widget with the currency name’s first character</li>
<li>A text widget with the currency name</li>
<li>A text widget with the price and percent change in 1 hour.</li>
</ol>
<pre><code class="lang-dart">Text _getTitleWidget(<span class="hljs-built_in">String</span> currencyName) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Text(
      currencyName,
      style: <span class="hljs-keyword">new</span> TextStyle(fontWeight: FontWeight.bold),
    );
  }

  Text _getSubtitleWidget(<span class="hljs-built_in">String</span> priceUsd, <span class="hljs-built_in">String</span> percentChange1h) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Text(<span class="hljs-string">'\$<span class="hljs-subst">$priceUsd</span>\n1 hour: <span class="hljs-subst">$percentChange1h</span>%'</span>);
  }
</code></pre>
<p>Let’s create the widgets. For simplicity sake, I created a function for each of them. The first function called <code>_getLeadingWidget()</code> returns the round icon with the text.</p>
<p>The widget will look like this:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*QkD7n2hBzTXCL5yiANx2Xg.png" alt="Image" width="250" height="304" loading="lazy"></p>
<p>The second function called <code>_getTitleWidget</code> returns the <code>Text</code> widget for the currency name.</p>
<p>The third function called _getSubtitleWidget() returns the <code>Text</code> widget for the currency current price and percent change in 1 hour.</p>
<p>Both of these widgets should look like this:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*hIF928PlzKa_tOi3CPE0mg.png" alt="Image" width="800" height="208" loading="lazy"></p>
<p>Let’s wrap all three widgets in something called a <code>ListTile</code> widget. The <code>ListTile</code> widget is based on the <a target="_blank" href="https://material.io/guidelines/components/lists.html">Material Design List</a> documentation. It shows all three widgets in this style.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*O3HD57q2Ovl5MPUyndgWUw.png" alt="Image" width="800" height="175" loading="lazy"></p>
<p>We will create a new function called <code>_getListTile</code> that returns a <code>ListTile</code> widget.</p>
<pre><code class="lang-dart">ListTile _getListTile(<span class="hljs-built_in">Map</span> currency, MaterialColor color) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> ListTile(
      leading: _getLeadingWidget(currency[<span class="hljs-string">'name'</span>], color),
      title: _getTitleWidget(currency[<span class="hljs-string">'name'</span>]),
      subtitle: _getSubtitleWidget(
          currency[<span class="hljs-string">'price_usd'</span>], currency[<span class="hljs-string">'percent_change_1h'</span>]),
      isThreeLine: <span class="hljs-keyword">true</span>,
    );
  }
</code></pre>
<p>Finally, let’s create the <code>_getListItemWidget()</code> . It is going to return a <code>Container</code> widget that has a top padding of 5.0 and has a <code>Card</code> widget child. The card widget has the <code>ListTile</code> returned by <code>_getListTile</code> as it’s child.</p>
<pre><code class="lang-dart">Container _getListItemWidget(<span class="hljs-built_in">Map</span> currency, MaterialColor color) {
    <span class="hljs-comment">// Returns a container widget that has a card child and a top margin of 5.0</span>
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Container(
      margin: <span class="hljs-keyword">const</span> EdgeInsets.only(top: <span class="hljs-number">5.0</span>),
      child: <span class="hljs-keyword">new</span> Card(
        child: _getListTile(currency, color),
      ),
    );
  }
</code></pre>
<p>The widget will look like this.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*SFq5wfAj25va2RZkaWX3Kg.png" alt="Image" width="800" height="210" loading="lazy"></p>
<p>We have successfully completed our <code>CryptoListWidget</code>. But we have to update the <code>main</code> function to show the newly created widget instead of the <code>Text</code> widget.</p>
<pre><code class="lang-dart"><span class="hljs-keyword">void</span> main() <span class="hljs-keyword">async</span> {
  <span class="hljs-comment">// Bad practice alert :). You should ideally show the UI, and probably a progress view,</span>
  <span class="hljs-comment">// then when the requests completes, update the UI to show the data.</span>
  <span class="hljs-built_in">List</span> currencies = <span class="hljs-keyword">await</span> getCurrencies();
  <span class="hljs-built_in">print</span>(currencies);

  runApp(<span class="hljs-keyword">new</span> MaterialApp(
    home: <span class="hljs-keyword">new</span> CryptoListWidget(currencies),
  ));
}
</code></pre>
<p>That’s it. You can hit the run button again. If everything works well and you are connected to the internet, you should a screen that looks like this.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*5UqjvSl_Q9SEJESOoXSJHw.png" alt="Image" width="800" height="801" loading="lazy"></p>
<p>Really cool right?</p>
<p>The app you see will be slightly different from the screenshot above:</p>
<ol>
<li>It does not have a floating action button at the bottom right.</li>
<li>The text color of the percent change in 1 hour is black.</li>
</ol>
<p>I decided not to include them in the tutorial. But you can check the project <a target="_blank" href="https://github.com/Elvis10ten/FlutterCryptocurrencyListApp">Github repository</a> to see how I was able to achieve it.</p>
<p>The completed app can be downloaded <a target="_blank" href="https://drive.google.com/file/d/1awcyZCsbeM3qiNHgBb_Jx-On2N3lEh9F/view?usp=sharing">here</a>.</p>
<p>Thanks for reading and hope you enjoy Flutter as much as I do. Feel free to leave a comment below if you have any issues, suggestions, etc.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to get GitLab to do periodic jobs for you in under a minute ]]>
                </title>
                <description>
                    <![CDATA[ By Moe Ibrahim What would technology be without a computer doing periodic work? Whether it’s your phone constantly checking your inbox for you, or getting timely alerts for weather or flight delays. What about a bitcoin vs Canadian dollar price servi... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/56-seconds-to-get-gitlab-to-do-periodic-jobs-for-you-6a731b977559/</link>
                <guid isPermaLink="false">66c34191160da468ed76f0f6</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GitLab ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 06 Mar 2018 00:15:49 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*HHVkCUSmaGkFPTx06jjZKw.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Moe Ibrahim</p>
<p>What would technology be without a computer doing periodic work?</p>
<p>Whether it’s your phone constantly checking your inbox for you, or getting timely alerts for weather or flight delays.</p>
<p>What about a bitcoin vs Canadian dollar price service, in just 56 seconds? No <em>IFTTT</em>, no <em>Zapier</em>, but no programming languages either — and no frameworks, no server or docker configuration, no Raspberry Pi, no AWS and no tests!</p>
<p>To make the example as universal as possible, we will only use 2 command lines:</p>
<ul>
<li>one to GET the bitcoin price from an API</li>
<li>and another to POST it to another service.</li>
</ul>
<p>Of course you can make this more useful by posting the price to Twitter, Twilio, Telegram, Slack and so on. But here we will simply post it to putsreq.com so we can inspect the POST request.</p>
<p>Then we will use GitLab-CI to schedule it to run everyday.</p>
<blockquote>
<p><strong>Level</strong> : All levels</p>
<p><strong>Requirements</strong> : Any web browser</p>
</blockquote>
<p>Let’s get you started :</p>
<ol>
<li><p><strong>Create a free account</strong> at <a target="_blank" href="https://gitlab.com/users/sign_in">gitlab.com</a> (20 seconds)</p>
</li>
<li><p><strong>Create a new Project :</strong> Click on the <strong><em>New Project</em></strong> button to create a new repo, and in the name field type <em>periodic-job</em> or any other name. (9 seconds)</p>
</li>
</ol>
<p><img src="https://cdn-media-1.freecodecamp.org/images/erHlPeiJTmeTnQ4GoFSMtoYLR5V0zseO60H8" alt="Image" width="800" height="521" loading="lazy"></p>
<p>Then save it by clicking on <strong><em>Create Project</em></strong> (1 second).</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/bzyB3KG6wmQ9Jc01n1FhAdyF6BBhCjC9pATv" alt="Image" width="800" height="536" loading="lazy"></p>
<ol start="3">
<li><strong>Create a .gitlab-ci.yml file in this new project:</strong> Click on <strong><em>New File</em></strong>, copy and paste the following snippet into the .gitlab-ci.yml file, then click save (5 seconds)</li>
</ol>
<p><img src="https://cdn-media-1.freecodecamp.org/images/ojeKxdcQUHLAGUO0y8g517nuss9rsKANxpt-" alt="Image" width="800" height="538" loading="lazy"></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/sFPB53USK5EYEvXza-ZyruSj0c9Qp3fx5-1R" alt="Image" width="800" height="532" loading="lazy"></p>
<pre><code>test:
</code></pre><pre><code> script:
</code></pre><pre><code> - btc=$(curl https:<span class="hljs-comment">//min-api.cryptocompare.com/data/price?fsym=BTC\&amp;tsyms=CAD)</span>
</code></pre><pre><code>- curl -i -X POST https:<span class="hljs-comment">//putsreq.com/wkDdMQWhaOyalisaIe49 — data ‘price=CA$ ‘“${btc//[0-9\.]/}”</span>
</code></pre><p>These are basically two simple commands. Here we can go further and add</p>
<p><a target="_blank" href="https://hackernoon.com/71-seconds-to-build-your-free-custom-webhook-illustrated-step-by-step-7a09b9e240ba"><em>if [ $btc -ge 15000 -a $btc -lt 7000 ]; then</em></a></p>
<p>conditions, or even run a full bash script file, but let’s keep it simple.</p>
<p>Click on the <strong><em>Commit changes</em></strong> button, and this will trigger it to build and run.</p>
<ol start="4">
<li><strong>Schedule it to run everyday:</strong> click on the CI/CD icon to expand the menu, and select Schedules to set up a name and a timer for your periodic job to trigger. (11 seconds)</li>
</ol>
<p><img src="https://cdn-media-1.freecodecamp.org/images/LPe0diYgDp3FtDob-daYQgz9yQp3NIbpcaB8" alt="Image" width="800" height="491" loading="lazy"></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/myy9E9YueotL6uCnQzIj64S7WvNZgH0nSvI9" alt="Image" width="800" height="529" loading="lazy">
<em>click on <strong>New schedule</strong> button</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/hORLN61TKEGqsCLm4Dus6l0mC0hEp1kDxc7i" alt="Image" width="800" height="550" loading="lazy">
<em>Type in a name for the new schedule <strong>daily-bitcoin-price-job</strong>, select to run it daily then click <strong>Save</strong></em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/2dK2LU1YHfEwHK3Mhzs82VpHdR3uXncbyG-L" alt="Image" width="800" height="541" loading="lazy">
<em>Your scheduled job has been saved</em></p>
<ol start="5">
<li>Congrats! You’re done. Go to to <a target="_blank" href="https://putsreq.com/wkDdMQWhaOyalisaIe49/inspect">this link in putsreq.com</a> to see it in action. (10 seconds)</li>
</ol>
<p><img src="https://cdn-media-1.freecodecamp.org/images/Yhx54rH7S8jocMDTd8NB0F6-RwySKIoDLT5Y" alt="Image" width="800" height="533" loading="lazy"></p>
<p>This job will run everyday as long as your free 2000/month build minutes do not run out.</p>
<p>We haven’t even scratched the surface of what we can do with GitLab-CI — just think of all the possibilities of using it to create webhooks or <a target="_blank" href="https://medium.com/@YYC_Ninja/99-seconds-to-make-bitcoin-call-your-phone-number-a8cbd9740f76">connecting it to IFTTT</a> and Zapier, which in turn would connect it to hundreds of services.</p>
<p>In <a target="_blank" href="https://medium.com/@YYC_Ninja/71-seconds-to-build-your-free-custom-webhook-illustrated-step-by-step-7a09b9e240ba">the next article</a> we will go through what we have just done, and how we can take it up a notch and create a webhook and use it to post to social media.</p>
<p>You can find the <a target="_blank" href="https://gitlab.com/ninjayoto/my-periodic-jobs/tree/master">sample code here</a>, and you can read the <a target="_blank" href="https://gitlab.com/ninjayoto/my-periodic-jobs/-/jobs">build logs here</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Dapps: Why Blockchain is here to stay (and Bitcoin might not be) ]]>
                </title>
                <description>
                    <![CDATA[ By James Hsu If you’re not already a cryptocurrency investor, you’ve probably at least heard a thing or two about blockchain, Bitcoin, or both. Let’s be clear: these are indeed technologies to be taken seriously, even as they’re written off by tradit... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/why-blockchain-is-here-to-stay-and-bitcoin-might-not-be-e117c4386af7/</link>
                <guid isPermaLink="false">66c3667f21ae2d74bb7009e8</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Ethereum ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 13 Feb 2018 08:10:00 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*2-chg0RiznhaFRvBOEUF_Q.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By James Hsu</p>
<p>If you’re not already a cryptocurrency investor, you’ve probably at least heard a thing or two about blockchain, Bitcoin, or both.</p>
<p>Let’s be clear: these are indeed technologies to be taken seriously, even as they’re written off by traditionalists like Warren Buffet and <a target="_blank" href="https://www.cnbc.com/2017/10/13/jamie-dimon-says-people-who-buy-bitcoin-are-stupid.html">Jamie Dimon</a> (who perhaps, not coincidentally, have massive investments in traditional financial institutions).</p>
<p>To recap, <strong>Bitcoin (BTC)</strong> is the first decentralized <a target="_blank" href="https://en.wikipedia.org/wiki/Cryptocurrency">cryptocurrency</a> (created in 2009) and currently the largest of <a target="_blank" href="https://coinmarketcap.com/all/views/all/">more than 1,000</a> known cryptocurrencies. It has a market cap of about $140B USD as of the beginning of February, 2018. That represents more than a third of the nearly $400B total market cap of all cryptocurrencies tracked by <a target="_blank" href="https://coinmarketcap.com/">CoinMarketCap</a>.</p>
<p><strong>Blockchain</strong>, on the other hand, is the technology that Bitcoin and many (but not all) of the other newer cryptocurrencies vying for a piece of the crypto-craze are built on.</p>
<p>Blockchain works by recording peer-to-peer transactions onto “blocks” which are subsequently written permanently onto an open and distributed ledger (the blockchain) through a consensus-based mining process. The blockchain ledger, by its open nature, is verifiable by anyone, and is resistant to modification because it’s distributed and encrypted.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/nVKfbbyeZMS0z9g98RaMTapud1ITqt9pOk-b" alt="Image" width="768" height="448" loading="lazy">
_How blockchain transactions are processed (credit: <a target="_blank" href="http://blockchain.open.ac.uk/">http://blockchain.open.ac.uk/)</a>" rel="noopener" target="<em>blank" title=")</em></p>
<p>Importantly, blockchain’s design eliminates the need for “trusted” middlemen such as banks, offering a number of significant advantages over our current trust-based systems. For example, transactions on a blockchain can happen much quicker (as they are processed within minutes, automatically), more reliably, and more efficiently than traditional transactions using fiat currency like US dollars.</p>
<p>One important benefit from the increased efficiency is significantly reduced transaction costs. As an example, McKinsey and Company estimates that revenue from cross-border payments (transaction fees) worldwide will total <a target="_blank" href="https://www.mckinsey.com/industries/financial-services/our-insights/global-payments-2017-amid-rapid-change-an-upward-trajectory">$2.2 trillion USD by 2021</a>, illustrating just how expensive it is to move money across borders (never mind the typical 3–5 day settlement times).</p>
<p>That’s a lot of potential cost savings to be had if the companies that provide these payment services adopt blockchain-based systems.</p>
<p>Cross-border payments are just one of the more obvious use cases for blockchain technology. Beyond cross-border payments and even peer-to-peer (P2P) payments, there are even more interesting use cases for blockchain, which we’ll discuss later in this story.</p>
<h3 id="heading-why-blockchain-is-here-to-stay-and-bitcoin-might-not-be">Why Blockchain is here to stay (and Bitcoin might not be)</h3>
<p>In an <a target="_blank" href="https://www.linkedin.com/feed/update/urn:li:activity:6356177307601821696">automobile analogy</a> (credit: Jason Schenker), you might think of Bitcoin as the first car to use an internal combustion engine and blockchain as the internal combustion engine technology itself.</p>
<p>While Bitcoin is the first and currently largest cryptocurrency to use blockchain technology and has excellent people behind it, many new blockchain projects are emerging that are also intriguing from a technology perspective. And yes, even Kodak (the film company) <a target="_blank" href="https://www.theverge.com/2018/1/9/16869998/kodak-kodakcoin-blockchain-platform-ethereum-ledger-stock-price">entered the blockchain fray in 2018</a>.</p>
<p>Who could be next? Tech giants like <a target="_blank" href="https://azure.microsoft.com/en-us/solutions/blockchain/">Microsoft</a> and <a target="_blank" href="https://www.oracle.com/cloud/blockchain/index.html">Oracle</a> are now incorporating blockchain into their product and service portfolios, though neither has stated any intention of creating its own cryptocurrency just yet.</p>
<p>Therefore, given the rapid influx of innovation and talent flowing into the global cryptocurrency community, it’s anybody’s guess whether Bitcoin will remain on top five, 10, or 20+ years from now.</p>
<p>It does need to be stated, however, that Bitcoin maintains a strong advantage in <a target="_blank" href="https://en.wikipedia.org/wiki/Network_effect">network effect</a>. Bitcoin currently plays a sort of “safe haven” role as the largest and most traded cryptocurrency (thus providing the most liquidity), with less volatility (price fluctuations) than most other cryptocurrencies.</p>
<p>So, Bitcoin has a significant leg up on its competition right now. But things could change rapidly depending on how other cryptocurrency projects evolve.</p>
<p>While Bitcoin’s future prospects are anyone’s guess, <em>blockchain</em>, on the other hand, is almost certain to gain mainstream relevance in the future. A foundational approach to building decentralized systems, blockchain offers significant gains for just about every business across just about every industry.</p>
<p>The only significant question mark is just how long it will take for this promising technology to be widely implemented.</p>
<h3 id="heading-the-early-days-saw-limited-differentiation">The early days saw limited differentiation</h3>
<p>The early wave of cryptocurrencies inspired by Bitcoin’s emergence in 2009 provided limited product differentiation beyond the original peer-to-peer (P2P) payments focus.</p>
<p><a target="_blank" href="https://litecoin.org/"><strong>Litecoin</strong></a> <strong>(LTC)</strong>, founded in 2011 and currently #6 in global market cap, is essentially Bitcoin with more frequent block creation to allow faster transactions, for example. According to Litecoin founder Charlie Lee, Litecoin is intended to be “the silver to Bitcoin’s gold.”</p>
<p>Litecoin also positions itself on its website as complementary to Bitcoin. This suggests that there is room in the future of P2P payments for a coin whose transactions settle in just 2.5 minutes, compared to Bitcoin’s process which takes 10 minutes.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/lmQJMt1RTBUW2d4bt4QarRFz1UOFEqmBfBc3" alt="Image" width="800" height="337" loading="lazy">
<em>Litecoin founder Charlie Lee’s twitter profile exemplifies the complementary relationship between Bitcoin and Litecoin.</em></p>
<p>In 2012, <a target="_blank" href="https://ripple.com/">Ripple</a> (whose native cryptocurrency is <strong>XRP</strong>), another project that catapulted in popularity last year (and is currently #3 in market cap among cryptocurrencies), also began to offer its own take on decentralized payments.</p>
<p>Unlike Bitcoin and Litecoin, Ripple’s payments systems verify transactions by consensus from a much smaller number of trusted gateways, instead of its predecessors’ blockchain-based approach that requires vast amounts of computing power and electricity (to mine).</p>
<p>Ripple’s approach has several benefits over Bitcoin (at the cost of less decentralization): much faster transaction speeds (just seconds) and potentially lower transaction costs. Ripple has <a target="_blank" href="https://ripple.com/press-center/#press">had success over the last year launching partnerships</a> to facilitate “frictionless” cross-border payments using its payments systems.</p>
<p>Although both Litecoin and Ripple brought innovation to the crypto space, at the end of the day, they (and a few others) have generally been content to focus on P2P payments use cases.</p>
<h3 id="heading-ethereum-broadens-the-horizon">Ethereum Broadens the Horizon</h3>
<p>In late 2013, the crypto paradigm changed forever when Vitalik Buterin introduced the world to <a target="_blank" href="https://www.ethereum.org/"><strong>Ethereum</strong></a> (whose token is <strong>ETH</strong>). The emergence of Ethereum in subsequent years, particularly in 2017 when its market cap grew to nearly $100B (2nd only to Bitcoin), has validated the value of projects that unlock new use cases beyond P2P payments.</p>
<p>Here’s why.</p>
<p>Unlike Bitcoin and Litecoin, Ethereum was not designed primarily for payments. Instead, Ethereum was built to facilitate blockchain-based custom “smart contracts” and applications. Central to the Ethereum platform are mechanisms for scripting custom smart contracts that can be recorded onto the Ethereum blockchain.</p>
<p>This means that Ether (the token used on the Ethereum platform) can be used for all kinds of smart contracts, including but not limited to smart property rentals (think “rental economy” with AirBnB, ridesharing, etc.), financial transactions, commodity pricing, online gambling, video games, content licensing, virtual gifting, and even the creation and management of new cryptocurrency projects and initial coin offerings (ICOs).</p>
<p>Smart contracts on a platform like Ethereum can run the gamut from complex business arrangements to simple consumer transactions.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/QffCYff0FCexJcRaeDCJvHDMBLmGDP1QZ9fq" alt="Image" width="800" height="331" loading="lazy">
<em>Ethereum lets you build “unstoppable applications,” according to the Ethereum Foundation website.</em></p>
<h3 id="heading-the-future-of-differentiated-dapps">The future of differentiated dapps</h3>
<p>Ethereum’s meteoric rise in 2017, among other developments, has facilitated a recent surge of new decentralized apps (dapps) that use blockchain technology.</p>
<p>Some of the most prominent dapps are themselves new cryptocurrency projects, many of which are <a target="_blank" href="https://theethereum.wiki/w/index.php/ERC20_Token_Standard">ERC20</a> tokens — built on the Ethereum network, but adding customizations to either the technology or application focus.</p>
<p>Here are just a few of the top coin or token projects competing for attention in the exploding cryptocurrency market, in order of market share according to CoinMarketCap, as of February 7th, 2018.</p>
<ol>
<li><strong>Bitcoin</strong></li>
<li><strong>Ethereum</strong></li>
<li><strong>Ripple</strong></li>
<li><strong>Bitcoin Cash</strong></li>
<li><strong>Cardano</strong></li>
<li><strong>Litecoin</strong></li>
<li><strong>Stellar</strong></li>
<li><strong>NEO</strong></li>
<li><strong>EOS</strong></li>
<li><strong>NEM</strong></li>
</ol>
<p>What’s interesting to note is the degree to which each project on the list attempts to distinguish itself from its peers. For example, a quick look at publicly available resources for each project suggests the following primary focuses for each of the currencies on the list above:</p>
<ol>
<li><strong>Bitcoin</strong> — secure P2P payments</li>
<li><strong>Ethereum</strong> — flexible smart contracts platform</li>
<li><strong>Ripple</strong> — global payments with trusted gateways</li>
<li><strong>Bitcoin Cash</strong> — P2P cash</li>
<li><strong>Cardano</strong> — smart contracts that can be regulated for compliance</li>
<li><strong>Litecoin</strong> — fast, efficient P2P payments</li>
<li><strong>Stellar</strong> — global payments</li>
<li><strong>NEO</strong> — smart contracts, pays a “dividend”</li>
<li><strong>EOS</strong> — decentralized operating system (OS)</li>
<li><strong>NEM</strong> — smart assets</li>
</ol>
<p>It would appear that nobody on this list is doing the <em>exact</em> same thing.</p>
<p>Could there be room in the global economy for several or more of these projects to coexist in the future? (If so, can we stop thinking about the cryptocurrency market as an ultra-risky, winner-takes-all contest?)</p>
<p>And, when you consider the thousands of dapps being built that don’t even qualify as a cryptocurrency, you start to see the makings of a whole universe of distinct opportunities for enterprising entrepreneurs.</p>
<h3 id="heading-how-can-dapps-improve-real-business-performance">How can dapps improve real business performance?</h3>
<p>For businesses that aren’t looking to enter the much-hyped ICO or cryptocurrency markets, there are still many reasons to build dapps.</p>
<p>Here are just some practical benefits that building on a blockchain can offer businesses of all sizes:</p>
<ul>
<li>Ability to settle transactions and close deals automatically anytime, not just during business hours (even weekends).</li>
<li>Improved security (in terms of immutability) of data and applications stored on the blockchain.</li>
<li>Increased business (more customers and transaction volume) due to improved operational performance (faster and more reliable transactions)</li>
<li>Reduced overhead costs (such as personnel and facilities) for accounting and contracting (contract lawyers and contract management staff), and fraud prevention (for ecommerce companies, for example).</li>
<li>Significantly lower average transaction costs, due to both the reduced overhead and variable costs associated with blockchain-based verification and processing.</li>
</ul>
<h3 id="heading-decentralized-apps-are-surprisingly-accessible">Decentralized apps are surprisingly accessible</h3>
<p>Next, consider that many of these leading projects (Ethereum, for example) are ecosystems or platforms, intended to attract the support of business partners and applications that will each put down their own roots on one or more of these platforms.</p>
<p>Much like app marketplaces like the Google Play Store, Salesforce AppExchange, or WordPress Plugin Directory who must minimize barriers for app developers that want to launch on their platforms, these blockchain platforms also need to make it easy for app developers and businesses to create and support dapps on their platforms.</p>
<p>It’s precisely this opportunity — to build dapps on <em>existing</em> dapp platforms (like Ethereum) — that is attracting companies of all sizes to the virtues of decentralization.</p>
<p>“Blockchain technology is interesting to many of the businesses we talk to because it can unlock tremendous operational improvements in their existing business,” explains Harry Lee, CEO of <a target="_blank" href="https://citrusbits.com/">CitrusBits</a>, a Los Angeles and San Francisco-based mobile app agency that offers <a target="_blank" href="https://citrusbits.com/blockchain-dapp-development/">blockchain development services</a>. “For these businesses, building a ‘dapp’ isn’t just about capitalizing on investor interest in anything associated with blockchain. They’re actually out to realize the substantial ROI building decentralized apps on a blockchain can provide.”</p>
<blockquote>
<p>“The bottom line is this: you don’t need to have crypto geniuses or blockchain inventors on your staff in order to tap into blockchain’s potential. With the right experts or app agency supporting you, you can now begin building your own specialized decentralized apps on an existing dapp platform — essentially piggybacking on the openness and innovation of blockchain pioneers throughout the world.”</p>
</blockquote>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
