The purpose of this guide is to get you immersed in Web3 as quickly as possible so you have the context and basic understanding needed to start learning and start developing.
If you’re new to the space, it may not be clear what a “decentralized Internet” offers to a developer. Think of a public blockchain like Ethereum as defining a clear “state”—and source of truth—for everyone who takes part in it, accessible by anyone Internet-connected, a system that uses the the strength of the open source protocol and the redundancy of peer-to-peer networking to remain trustable and secure. Rather than requiring every app developer to create and maintain the entire state of their app on private servers, much can be stored on, and retrieved from, the public blockchain. A common, trusted, secure backend.
The reason this is possible is because of the unique characteristics of a blockchain database. It’s write-only: where a typical database can add and remove records, blockchain data exists forever and can’t be removed. The network of nodes maintain this database as a “distributed ledger” and have strict protocols around who has permission to write at a given time. One of the interesting aspects of the technology is how write permissions are distributed amongst nodes that may require no special permission to join. If you spun up your own public Ethereum node, you would have write access to the whole network: provided you completed the “proof of work” required to give you the privilege of writing a node before any other node did.
A prime and typical example of blockchain technology in action is the ease of sending and receiving cryptocurrency. The public Ethereum ledger allows a developer to implement payment gateways without banks, accounts, or other intermediaries.
A developer could create their own Ethereum token without having to create the infrastructure needed for users to trade them. An online gaming platform might tokenize in-game items, and users could purchase those tokens and trade them outside the platform and own them separately from the gaming platform itself. Beyond trading items for use in-game, digital collectibles have massive future potential. As e-sports grows in popularity, you might have a digitally tokenized equivalent of a “home run ball”.
With each user having their own public/private key pair, user authentication is made much simpler as apps need only verify that a user can sign transactions with their private key.
Smart contracts can be used to create programmable money. Consider a basic usage of a programmable smart contract to address the situation where two owners of an apartment want to split a tenant’s rent payments 50/50. Normally, either the renter would have to pay each owner separately, or would pay one owner or an agent, and the owner or agent would disburse the money. While this situation isn’t particularly problematic, consider the implicit trust required in one individual to provide the other with their share. Contrast this with a simple smart contract that programmatically splits any incoming funds and sends them to the address of each owner. The renter need only send their rent to that address and each owner will receive their share immediately. Because of the security and immutability of a blockchain like Ethereum each owner can be assured that the smart contract will operate as desired, and can audit its code.
Once we have the digital backbone of trust provided by blockchain, we can also apply the benefits of programming to important social problems. We can provide a banking service in a few lines of code. We can confirm identity with a few clicks. All with a protocol that can run on nearly any computer anywhere in the world.
As the space is new and developing, opportunity is rife for developers to build new kinds of tools, apps, and systems, and to come up with novel use cases for this technology.
A Solution in Search of a Problem?
A common refrain in criticisms of blockchain technology is that it’s a solution in search of a problem. It may be argued that digital currency was the first blockchain killer app, and Distributed Finance, or DeFi, is shaping up to be the next, the full extent of how this technology can be applied is currently unknown and is one of the primary reasons devs in the space find it exciting to be a part of. For over a decade, laser technology had no apparent use, until researchers, experimenters, and entrepreneurs were able to apply it in ways totally unexpected. While the same argument could be used for any new technology, the massive widespread adoption of digital currency and the over $350 billion currently contained on distributed, unmanaged, decentralized blockchains, is pretty remarkable.
Basic Distributed App Structure
A distributed app is, generally speaking, one that connects to a blockchain somewhere in its stack, and likely in some way that is fundamental to its operation. Distributed apps are a mix of the usual front and backend systems you’d find in a web app but will use a library like web3.js to connect to the Ethereum network. Some distributed apps are completely distributed: living entirely on distributed networks.
On the user end, MetaMask is a popular plugin that manages users’ Ethereum wallet. MetaMask provides an interface for a user to sign transactions and prove their “identity”.
A given distributed app may connect to the Ethereum blockchain and also to the users MetaMask wallet (or another wallet) for authentication.
Interfacing With Ethereum
Typically, to interact with Ethereum you would need to operate a node. A node is a fundamental part of a blockchain’s structure, the peer that connects to other peers to form the decentralized structure. The protocol is king on the public mainnet: there is no central server, no authority, and no limits on who can operate a node. There is only a common protocol for all participating nodes.
Many app developers would prefer not to run their own Ethereum node, so services like Infura exist to provide a gateway and API for Ethereum that developers can use instead.
While the Bitcoin network is one of the most well-known blockchains, Ethereum has a feature set that is more exciting to developers as it includes a Turing-complete virtual machine that can run small programs called smart contracts. As a result, Ethereum has the strongest and most active developer community among any of the blockchain ecosystems.
Smart contracts run on nodes and use transactions for their input and output. Smart contracts reside at addresses on the blockchain, the same way that a user’s account address does. To interact with a smart contract, you need only send a transaction to it along with input data.
Running a smart contract requires gas, a small cost which compensates node operators for the service of executing the smart contract, while also reducing the incidence of spam (by making spamming expensive) and preventing poorly coded smart contracts from looping infinitely and bogging down the network.
Mainnet, Testnets, Other Networks
A mainnet in blockchain parlance refers to the primary active network for a given protocol. In the case of Ethereum, mainnet is where real value is exchanged, and is considered the source of truth. But any group of nodes can form their own network. Testnets serve the developer community by offering much smaller networks where Eth and gas are free, so developers can test their projects and code without risk. The Ethereum testnets are named Ropsten, Kovan, Rinkeby, and Görli.
Ethereum networks are also used for enterprise applications: custom-made networks that operate on a permissioned basis (versus the permissionless mainnet and testnets) to facilitate transactions and other operations among a small group of organizations (for example). These networks have far fewer nodes and usually serve a specific purpose. Large banks, for example, might use a blockchain for interbank settlement.
Development in Ethereum
Development in Ethereum generally first takes place on local, home-spun blockchains. Developers are free to use something like geth, command line software that lets you create Ethereum networks. But this is like programming in a low-level language: making things easier, the Truffle suite serves many developer needs. Ganache, part of the suite, makes it much easier for devs to fire up a local blockchain network to test their apps, offering a “one click blockchain” for development purposes, along with command line tools. Drizzle helps with front-end development, and Truffle itself is a framework to make smart contract development and deployment easier.
Interacting with the blockchain itself requires the use of an API (such as web3.js) and access to a node; rather than operate their own nodes, many developers will use a service like Infura as an Ethereum API.
Smart Contract Languages
The Full Stack
As with all modern web development there are a lot of options for components to use at various levels of the stack. You can get more details in the always up to date blockchain stack.
A Simple Project Stack
Here’s a typical set of development tools you might use in a simple project:
Node package manager, part of node.js
A suite of tools to make development easier
From the Truffle framework, used to launch a private blockchain on your own machine
A blockchain user interface and gateway to Ethereum; it’s a browser plugin and mobile app that your app can connect to allowing users to sign transactions and perform other tasks.
A popular programming language for smart contracts
For your front-end
An Ethereum API library letting you connect and interact with the Ethereum network
An Ethereum API service that gives developers access to the Ethereum network without having to run their own node
If you’re ready to get started, our 3-step guide will go into more detail to get you up and running on the blockchain quickly with a walk through.