As I mentioned in the previous lesson about smart contracts, Ethereum is a computing platform that allows you to create and run smart contracts.

A smart contract is a pre-programmed piece of software code (“computer program”) where once specified conditions are met, the code is automatically executed.

Most developers who create smart contracts are actually doing so as part of a decentralized app or “dApp” that they’re building.

But what are dApps? And why do they matter?

dApp

What is a decentralized application (dApp)?

A decentralized application, also known as a “dApp”, “Dapp” or”dapp”,  is a software application that operates autonomously using smart contracts.

Since smart contracts are just computer programs that self-execute according to predetermined conditions explicitly written in code, this is what allows dApps to operate autonomously, without any human involvement.

 

dApps” are pretty similar to web or mobile apps except that dApps are built using smart contracts and run on a blockchain.

In the simplest sense, a dApp is a smart contract and a web user interface (UI).

dApp = frontend + smart contract backend

In other words, it combines a frontend user interface (UI) that looks just like your good ol’ smartphone or web app with the functionality of smart contracts running on the backend.

The frontend of an app refers to the portion of the app that is displayed on the user’s screen or graphical user interface (GUI). The  bakend of an app refers to the portion of the app that is not displayed on the user’s screen (“frontend”).

dApps enable two parties to make a transaction or agreement in code without needing an intermediary or central authority to follow through. They can simply trust the code to ensure that the contract is fulfilled.

dApps are also open-source, which means that the source code is out there for anyone to see. This makes dApps easier to trust since the source code can be inspected and any malicious intent can (theoretically) be spotted.

Because tech companies keep their code under lock and key, we don’t really know how Google’s top-secret search algorithm works or if Alexa is actually listening in on our conversations.

With smart contracts and dApps, we can see if everything checks out under the hood.

 

dApps are also censorship-resistant. This means that governments or big corporations have no way of blocking any content or banning users.

Now, this can be a good AND bad thing, depending on how it’s used (or abused). Censorship on social media, for instance, has been a topic of debate since platforms like Facebook can ban users for their political views or spread fake news.

If a dApp is programmed to do something and the smart contract is executed, there is nothing anyone can do to stop or reverse the code. No such thing as “Felt cute, might delete later.” here.

Lastly, one of the big benefits of dApps is that they are difficult to take offline.

dApps run on a network of decentralized computers (which could be in the hundreds or thousands depending on the blockchain) all over the world.

Decentralized app (dApp)

Even if a few (or a few hundred) go offline, the rest of the network keeps running the blockchain to ensure virtually zero downtime.

That’s all well and good, but it’s worth noting that there are still some drawbacks to dApps, particularly on the developers’ side of things.

Because code and data published on the blockchain are harder to modify, it can be extra challenging for developers to make dApp updates once deployed. This means fixing bugs in older versions or introducing new features can be a pain in the a… pp.

Also, the benefits of running on the Ethereum network (i.e. security, transparency, decentralization, and reliability) come at a high overhead cost.

Ethereum’s current consensus mechanism (PoW) takes some time plus every node has to run and store each transaction, which adds up to higher computational demands.

Even if dApps essentially don’t go completely offline, network congestion can still happen and cause the runtime to slow down.

These tradeoffs make it hard for dApps to scale, but future upgrades to Ethereum promise to address some of these issues such as shifting to the proof-of-stake (PoS) consensus mechanism.

What’s an example of a dApp?

To have a better idea of how dApps work in the real world, let’s look at Uniswap as an example.

Built on the Ethereum blockchain, Uniswap is a decentralized exchange (DEX).

It provides an app that allows users to easily exchange or “swap” crypto assets.

Here’s how the app’s user interface looks like:

Uniswap

Unlike traditional exchanges that use centralized order books to manage liquidity and set prices, the Uniswap DEX runs on AMM technology.

AMM” stands for “automated market maker,” which is just a fancy term for a smart contract that relies on a liquidity pool instead of an order book and uses a mathematical formula to determine buy and sell prices.

In effect, Uniswap does not hold any of the crypto assets on the exchange nor does it take the opposite side of trades in order to create liquidity.

Instead, trades happen between you and a smart contract. Within the smart contract, there is a mathematical formula that determines what price you can buy or sell a crypto asset.

Where do the crypto assets come from? For example, if I want to swap some of my ETH for BAT, who will I get the BAT from if the AMM is handling the transaction?

This is where “liquidy pools” come into play. Other users deposit their crypto assets to provide liquidity and are compensated with a share of the trading fee.

Since the Uniswap DEX runs on open-source software, users can be able to check the source code if there’s anything shady going on.

The protocol is public and permissionless, which means that anyone can use the dApp if they want to buy or sell crypto assets. No need to register an account or request access. All you need to do is connect your crypto wallet.