Book Image

Learn Ethereum - Second Edition

By : Xun (Brian) Wu, Zhihong Zou, Dongying Song
Book Image

Learn Ethereum - Second Edition

By: Xun (Brian) Wu, Zhihong Zou, Dongying Song

Overview of this book

Ethereum is a blockchain-based, decentralized computing platform that allows you to run smart contracts. With this book, you’ll discover the latest Ethereum tools, frameworks, wallets, and layer 2, along with setting up and running decentralized applications for the complete, end-to-end development experience. Learn Ethereum, 2nd Edition is a comprehensive overview of the Ethereum ecosystem, exploring its concepts, mechanisms, and decentralized application development process. You’ll delve into Ethereum's internals, technologies, and tools, including Ethereum 2.0 and the Ethereum Virtual Machine (EVM), gas, and its account systems. You’ll also explore Ethereum's transition to proof of stake, L1/L2 scaling solutions, DeFi protocols, and the current marketplace. Additionally, you’ll learn about EVM-compatible blockchains, connectivity techniques, and advanced topics such as sharding, off-chain scaling, DAOs, Metaverse, and NFTs. By the end of this book, you’ll be well-equipped to write smart contracts and develop, test, and deploy DApps using various tools, wallets, and frameworks.
Table of Contents (24 chapters)
1
Part 1: Blockchain and Ethereum Basics
7
Part 2:Ethereum Development Fundamentals
11
Part 3: Ethereum Development Fundamentals
15
Part 4:Production and Deployment
20
Part 5:Conclusion

Overview of blockchain use cases in the industry and government

Since its invention in 2009, blockchain has garnered great interest across industry worldwide. It is considered a disruptive technology that has unsettled financial services, banking, and the payment industry and continues to fundamentally change the way business is conducted in all other industries. It has found great success in all traditional industries, as well as in governments around the world. As the world desperately searches for ways to get out of the tangled web of the Web2 world and explore unchartered paths on a voyage into the digital future, it is blockchain that ushers in the unknown metaverse and the world of Web3.

In this section, we will showcase a few successful use cases of blockchain technology in industry and government.

Financial services

Blockchain started as a peer-to-peer electronic payments solution, and quickly found broad success in the financial services, banking, and payment industries. Decentralized Finance (DeFi) is a collective term for financial instruments created on top of distributed ledger technology and blockchain, which replicate all traditional financial instruments in the digital world using cryptocurrencies and smart contracts. It created a world in the digital and crypto space parallel to the real, traditional world of financial services to which we have been accustomed for the last few hundred years – and it offered more. Today, DeFi products and services range from crypto asset management, lending and borrowing, and DeFi exchange, to sophisticated risk management products such as derivatives, insurance, and more. Bridges between traditional finance and DeFi are built to provide blockchain and smart contract solutions to traditional financial institutions to enable them to diversify and expose themselves to the crypto markets.

You will learn more about blockchain, smart contracts, and cryptocurrency throughout the rest of this book. In particular, we will delve into DeFi use cases and the leading protocols in Chapter 3, Decentralized Finance.

Payments

There are great opportunities in the payment market due to its size. According to the McKinsey on Payments in 2021 report, covering the trends and opportunities in the global payments space, more than three quarters of Americans are using some form of digital payments. Digital payments constitute 78% of all payments. McKinsey’s survey of executives from leading banks found that leveraging blockchain and distributed ledger technologies to support the digitization of supply chain financing is one of the technology trends they observed.

Blockchain-enabled models further support banks in offering frictionless real-time payments with lower costs. Ripple came into the picture as early as 2012 with the intention to make a dent in the inter-bank money transfer system. This space has traditionally been dominated by the Society for Worldwide Interbank Financial Telecommunication, better known by its acronym SWIFT. That year, Ripple Labs Inc. released a real-time gross settlement system, including a currency exchange and remittance network. RippleNet provides a service to send money globally by connecting banks, payment providers, and digital asset exchanges. To transfer funds between banks, RippleNet uses its native XRP tokens and guarantees fast and secure settlements. As of February 2023, this payment network involves 55 countries and hosts over 120 currency pairs. More than 100 financial institutions worldwide have joined its payment network.

Ripple is not the only blockchain-based payment service. Mastercard and the blockchain company R3 announced a partnership to produce a cross-border payment solution in September 2019. China Construction Bank also developed a blockchain solution enabling supply-chain financing for cross-border payments with the aim of reducing settlement time.

We expect that companies with objectives such as financial inclusion, consumer protection, and regulatory compliance will continue to leverage blockchain and other emerging technologies, and work together towards the same goal, a noble goal of offering a global currency and robust, secure infrastructure to empower the lives of people all over the world.

Audit and assurance

During an audit, an organization’s financial statements are evaluated to determine their accuracy and fairness. If all the transactions are recorded in an immutable blockchain as indelible marks, audits will become redundant. However, there is still the chance that blockchain transactions could be logged in the wrong sections of financial statements, or a transaction itself may be illegal if, say, it’s sent and received between parties that might not comply with regulations. In some cases, it can even be sent as an off-chain agreement.

Internationally, the audit market is dominated by big players such as Price Waterhouse Coopers (PwC), KPMG, Ernst & Young (EY), and Deloitte. All of them are bringing in blockchain innovations.

PwC announced a blockchain auditing service in March 2018. PwC France and Francophone Africa brought together experts specialized in cybersecurity, big data, and audits in its blockchain lab, located in Paris. The lab collaborated with Request Network, which is a project that’s building a decentralized payment system for the Ethereum network.

KPMG, partnered with Microsoft, has expanded its blockchain strategy for audits. Microsoft Azure’s hybrid cloud capabilities, security at an enterprise level, and extensive compliance certification portfolio were combined by KPMG to break down complex business workflows. The first joint blockchain nodes opened in Frankfurt and Singapore as early as February 2017.

By April 2018, EY had announced its blockchain analyzer to make the lives of audit teams easier in sourcing all transaction data across an organization from multiple ledgers on the blockchain. May 2022 saw the production release of the third generation of EY Blockchain Analyzer: Reconciler, being made available for the first time to non-audit clients. It enables the auditors and non-audit users to do the following:

  • Import enterprise records
  • Reconcile off-chain enterprise records with on-chain transactions
  • Track wallet balances

In 2017, Deloitte released 90,000 certificates on the private blockchain, with an international accredited registrar DNV GL. How does this work? As soon as a new certificate is issued, it will be digitized and stored in a private blockchain. In this private network, each certificate is tagged uniquely and can be traced. Simply scanning a QR code makes it possible for anyone to verify that a company is certified.

Blockchain technology also brings new challenges to auditing and assurance. The chaos from Initial Coin Offerings (ICOs) and Initial Token Offerings (ITOs), which we will talk in Chapter 3, Decentralized Finance, as well as the security and audit issues in smart contracts, will make auditing and assurance of DeFi companies and the transparency and accountability of cryptocurrency much harder to achieve. The dramatic crash of Terra/Luna demonstrates that it requires a different level of expertise that audit and assurance firms have to build. Lack of regulatory clarity on how crypto assets are audited will ultimately only hurt the average Joe.

Healthcare

Healthcare is another industry that has strived to find ways to maintain health quality and lower overall costs. Blockchain has the potential to disrupt the entire industry.

COVID-19 contact tracing

The COVID-19 pandemic is an ongoing global pandemic of a coronavirus disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). Since early 2020, it has overwhelmed healthcare systems and disrupted people’s lives around the world. Beyond vaccines, the best way to slow down the rate of infection is social distancing and contact tracing.

IBM developed a digital health pass using blockchain, like a health passport, to track and selectively share individual COVID-19 status so that it can help to control the spread of the disease. It allows organizations to verify the health credentials of those they have interacted with or do business with. With privacy built into the tools, it enables individuals to manage their health information through an encrypted digital wallet on their smartphones and maintain control of who it is shared with and for what purpose.

As published on HealthIT.gov in the middle of 2020, Villanova University developed a blockchain solution to help medical facilities track coronavirus cases globally. The system enables medical facilities around the world to publish coronavirus test results between doctors on a blockchain. Assisted by technologies such as the Internet of Things (IoT) and Artificial Intelligence (AI), the system triggers alerts about potential surges of COVID-19 cases based on high-risk gatherings and public space surveys. These alerts enable healthcare providers to make data-driven decisions in allocating medical staff and equipment already in short supply.

Tech Mahindra developed a vaccine ledger using blockchain technology to track COVID-19 vaccines from manufacturers to the recipients, with the intention of preventing counterfeits. As a result, vaccine distribution becomes safer and more reliable, especially during initial outbreaks, where the scarcity of authentic vaccines may drive price gauging and the spread of counterfeits. Similarly, Novartis, a global health company, has been exploring the potential of blockchain for pharmaceutics and developing drug tracking systems using blockchain to combat counterfeits and black-market medicine.

Electronic medical records

Blockchain in healthcare can help improve medical record access and sharing. Anthem, the largest health plan in the BlueCross BlueShield system and the second largest health insurer in the United States, is using blockchain technology to allow secure data access and sharing of its members’ medical records. It started as a pilot in 2019 and expects to roll out this feature to all 40 million members.

Medical claim adjudication and payment

Several leading healthcare payor and provider organizations are working together to explore the potential of taking advantage of blockchain to improve the efficiency of administrative processes with the goal of bending curve in the administrative cost in healthcare ecosystem. Anthem, together with Health Care Service Corporation (HCSC), another of the largest insurers in the BlueCross BlueShield system, shared other party liability information over blockchain and made it to all parties, which in turn removes friction and the possibility of erroneous manual processing from coordination of benefit during the claim adjudication.

A group of top healthcare heavyweights, including Anthem, HCSC, and Aetna, together with IBM, initiated a blockchain healthcare network with the intention to tackle various healthcare industry challenges, including efficiency and end-to-end visibility in claims processing and payments, as well as provider data accuracy. Not coincidently, United Healthcare, Humana, and Change Healthcare are also piloting blockchain solutions with another group of health organizations, initially focusing on addressing provider data quality issues using distributed ledger technology. Provider data accuracy and quality are prevailing industry challenges that cost the healthcare industry billions of dollars in administrative expenses each year.

Providence St. Joseph Health, one of the leading not-for-profit healthcare systems, is focusing on building an integrated provider-payer system on a blockchain platform to streamline claims processing and interoperability among all parties, and improve revenue cycle efficiency. One of the successful use cases is to utilize blockchain technology and shared ledgers to improve prior authorization processes, a complex process that often infuriates providers and doctors due to erroneous denials of medical services, increasing friction between providers and healthcare payors.

Blockchain use cases led by government

Governments around the world have leveraged blockchain technology to improve service provision to citizens in their countries. In this section, we will discuss some of the prominent blockchain use cases implemented in the public sector.

Food safety initiatives

Believe it or not, the food industry is leading the blockchain adoption. The FDA is taking a new approach to food safety. In the New Era of Smarter Food Safety blueprint, announced in July 2020, the FDA laid out its technology heavy approaches for creating a safer, more digital and traceable food system, including tech-enable traceability and smarter tools for prevention and outbreak response. In its blueprint, it plans to tap into new technologies, like blockchain and Internet of Things (IoT), for maintaining records and tracking events from growing to the food on the table.

In fact, there are many such food safety tracking implementations already on blockchain. Walmart, partnering with IBM and Nestle, implemented a supply chain food tracking system using Hyperledger, a permissioned blockchain, as early as 2018. It tracks the journey of fresh produce from farms to grocery stores. Agricultural conglomerate Cargill Inc. is leveraging blockchain technology to track its Thanksgiving turkeys from the store they were sold in back to the farm that raised them. In a similar way, Nestle, the Swiss multinational food and drink processing conglomerate, is harnessing blockchain technology for baby food safety. It allows the consumer to simply scan a QR code to track items such as organic infant formula, baby food, and instant mashed potatoes from the manufacturer to the grocery store shelf.

The immutable and auditable nature of blockchain transaction records make it best suited for supply chain tracking. From the top 50 blockchain use cases reported by Forbes in the last 3 years, it is no wonder that supply chain tracking using blockchain has been applied in almost every industry. For example, AP Moller Maersk, a Danish shipping company, is using Hyperledger to track shipping containers during ocean and inland freight transportation. Breitling, the luxury watchmaker, has built a Ethereum-based blockchain system to track and prove the authenticity of its products. De Beers, the diamond producer, and LVMH, the world leader in high-quality luxury products, are also using blockchain technology to track products, prove authenticity, and fight counterfeiting.

Blockchain finds its way in driving positive changes in Environment, Social, and Governance (ESG) issues and supporting ESG’s mission for a sustainable future too. Mining giant BHP developed blockchain solutions to document emission data and trace its carbon footprint. Other use cases have been implemented by Industrial and Commercial Bank of China (ICBC) to track and incentivize energy-efficient vehicle usage by connecting ICBC customer wallets to government transportation data via blockchain.

Smart city ambitions

The smart city concept is not new. A smart city is a technologically modern physical infrastructure that integrates and leverages information, communication, and network technology to optimize city operations and services for its residences. With the advent of blockchain, 5G, IoT, and AI/Machine Learning (ML), interpretations of the smart city concept have expanded. Modern smart cities use different types of IoT devices and sensors to collect specific data from citizens, devices, buildings, assets, and every element of city operations, and leverage 5G networks to efficiently transmit and share this data. AI/ML technology is used to gain insights and drive efficiency in managing assets, resources, and services, improving operations across the city. Blockchain is expected to be used as an immutable and shared ledger to facilitate frictionless data exchange.

One such ambition is Saudi Arabia’s $500 billion smart city project, NEOM, which intends to build a cognitive city and hyperconnected infrastructure from scratch. Advanced technology plays a key role in ensuring efficient and smart operations in cities. Blockchain and smart contracts will be used to manage instantaneous transactions and financial payments. It will enable network participants to exchange data with a high degree of reliability and transparency. If this has gotten you interested, you can check https://www.neom.com/en-us for any new developments.

Central bank-issued digital currency

A central bank-issued digital currency (CBDC) is a digital form of central bank money that is widely available to the public. It is also viewed as the digital form of fiat money. Although the US has not decided whether or when it will issue a CDBC yet, the Federal Reserve has recognized the benefits of CDBCs and is exploring the implications and options for issuing a US CDBC, sometimes also called a digital dollar. In its Money and Payments: The U.S. Dollar in the Age of Digital Transformation report published in January 2022, the Federal Reserve made it clear that it considers CDBCs to be a digitized version of fiat currency, and an expansion to the existing fiat currency, not intended to reduce or replace it.

Due to the widespread use of Bitcoin and other cryptocurrencies, central banks around the globe face the same dilemma. As tracked by the Atlantic Council’s Geoeconomics Center, 9 out 91 countries on the tracking list have launched their own CDBCs, including the Bahamas, Nigeria, and seven eastern Caribbean countries. 15 countries are piloting CDBCs, including China, Singapore, Russia, and South Korea. 16 countries are in the development stage of their own CDBCs. The US is one of 40 countries still in the research stage.

China’s Central Bank released a pilot version of its digital yuan wallet in April 2021 and has expanded the pilot to more than 11 regions as of February 2023. Although the US is behind the other top central banks, including the EU, UK, and Japan, a number of technological experiments related to digital currencies have already been conducted in the US, including a hypothetical CBDC and the use of distributed ledger technology for wholesale payments. Research on economic and policy, stakeholder engagement and outreach activities, and international collaboration are underway to help the Fed reach a decision about the appropriateness of issuing a US CBDC.

Powering many blockchain implementations of the use cases in the preceding subsections are a set of newer blockchain technologies and smart contracts. In the next section, we will introduce you to Ethereum, a smart contract-enabled blockchain network.