What Makes Up Web3?
There is a lot of talk these days about “crypto” and “web3” and “blockchain” – So I wanted to de-mystify what “web3” actually means – what it is – and what is required from a development standpoint.
The Web3 Dev tools stack
Storing Data On The Blockchain
Developing for Security & Maintainability
Web3 means an application that interacts with the blockchain
It could also be called a “Decentralized Application” or “Dapp”. It has a client interface and then it interacts with the blockchain of choice through API calls. So what’s the confusion?
Is a smart contract considered Web3? Nope. A smart contract is a program that runs on the blockchain where it’s deployed (i.e. Ethereum, Solana, Terra, Cardano, etc). Smart contracts can be called via the appropriate API by Web3 Applications, but aren’t considered “Web3”.
A Web3 Application interacts with deployed programs (smart contracts, etc) on a blockchain.
So what, then, is the Web3 Stack (what’s used to build web3 apps)?
Web3 Applications have a web-based client (or could be a browser based and/or a mobile application) – and that application allows users to interact with it. In the DeFi space, we’ve seen things like Decentralized Exchanges (DEX) such as Uniswap, the Metamask, or Phantom wallets, and lending & farming apps like SushiSwap. Then there are also games, and NFT marketplaces — all Web3 Applications.
Behind the scenes, based upon user actions, the application might make API calls to one or more blockchains, and invoke an API call to a smart contract on the chain, or to an operation that is available on that blockchain, and communicate the results to the application user.
You’ll also want an integrated development environment (ide) that will allow you to easily build and deploy your web3 applications. The Truffle Framework has an integrated set of tools that make developing Ethereum smart contracts pretty straightforward.
If you want easier dev, that enforces strong typing – which will catch errors early, and reduce the bugs you produce like as you code – super important, especially in blockchain applications – , you’ll want to consider Typescript. It has gained in popularity and for good reason! Just from a maintainability, code consistency and support for future browser version are enough to make it a standard in your web3 development.
Build the backend for scalability
If you don’t have this layer, then you’ll have to leave your users to install some sort of browser extension to interact directly with the blockchain. Using Node.JS within your application, allows you to take care of this and not rely on users having to install a browser extension to utilize your application.
Node.js is perfectly suited for developing web3 apps that require communication with the blockchain – as it has a scalable model and can run both client and server side in your application. The construct it has been built around allows for continuous communication and calls – rather than locking up the app for a specific call. It’s built-in asynchronous process, has Node rotate through the event queue until there are no more events to process. Then it sleeps. It’s lightweight, efficient, and a great fit for applications with real-time processing needs.
The innovation of Node.js is that both the client and the server can initiate communication – where in the web2 world, only the client could initiate communication. That changes things dramatically – and is exactly what’s needed for web3 development. This allows for callbacks to be triggered when an event finishes – and allows your application to continue processing other things in the meantime.
Where is data stored?
If you’re familiar with Web2 applications, or application development, you’re likely familiar with database technologies – Oracle, SQL SERVER, or MySQL, etc. With Web3, data is stored on the blockchain, and not in a database engine at all. That would be “centralization” and blockchain likes to claim the “decentralized” mantel, where there is no centralized process or storage or single point of control or failure. But that’s a topic for a different post.
Briefly – a blockchain network is made up of chains and chains are comprised of a series of blocks. Through the process of mining, new blocks are created in the chain. Nodes refers to computers in the blockchain, and blockchains have many nodes. The data is stored across ALL of the nodes, which is what makes blockchain immutable – because these chains can be run by many different people and entities. Every node contains a full copy of the data within the blockchain.
However, a big issue that must be considered when developing web3 applications is how to effectively query the data that resides in the blockchain. Because even though blockchain has the transparent, immutable, and decentralized qualities that has allowed it to gain traction, those very qualities create huge obstacles when it comes time to query the data contained within the blockchain.
Querying the blockchain data has been a bottleneck and creates both performance and scalability issues with blockchain applications. Sadly, the lack of a standardized query language (sql) for blockchain data and metadata – something easily done within an RDBMS, makes getting data out of the blockchain a code-heavy process.
While it’s great that we can store data in a distributed, immutable, and transparent manner, if we can’t access that data easily…. Well, growth isn’t going to follow as that is a HUGE limitation.
Enter the Graph Protocol. Developed to solve the blockchain data query problem, it has indexed the blockchain and made the data available through GraphQL queries. The Graph Protocol enables high-performance querying, and is open source. Run your own Graph node, or “rent” a hosted service provided by The Graph.
We can debate it’s decentralized vs. centralized qualities – but it solves the query problem, and allows software developers building the Web3 app to create “subgraphs” that is the data that is needed to be queried, utilizing the standard GraphQL JSON query format, which removes the code-heavy reality that faced web3 app developers prior to the development of the Graph Protocol. In fact, if you check The Graph Explorer, there may be a subgraph that you can utilize that has already been developed. And that will save you time on your development.
What’s in a Node?
Distinct from Node.js, web3’s also need access to the blockchain for dev and testing. As you develop, you will need to run through your application and get it working – you will need a blockchain Node to access for testing.
On the Ethereum (or any EVM) blockchain, there are companies that you can essentially “rent” nodes from (like Quicknode or Infura). Other blockchains, like Solana also have companies that provide nodes for development (i.e. Quicknode and Chainstack) – so you can do your development without having to set up and run your own full node. As you develop, you may also want to explore whether a personal blockchain node tool is available, similar to Ganache, which is a personal blockchain instance that you can use for developing Ethereum-specific applications. It is part of the Truffle Suite of tools – all designed around Ethereum app development.
One of the benefits of using a personal blockchain like Ganache for developing your app, is that it allows you to see exactly what is happening on the blockchain through the calls you make – and gives you the flexibility to inspect state while controlling how the blockchain operates. As chains develop, we’ll likely see more tools like these on other chains as well.
With other blockchains, you may have to deploy your own node to accomplish this. It always works to go through the developer site for the chain your Dapp will interact with and find out what libraries are available and what specific dev/testing process is available.
How can I do testing before deploying a web3 app?
And can I say that testing is one of the BIGGEST challenges?! … in ANY development project, not just Web3 or Blockchain – but any software development process – and the lack of really solid testing practices is one of the leading causes of the crypto theft and exploits that have occurred – so pay attention to security for sure!
Functional Testing (Unit and System Testing)
So back to testing – yep, it’s critical – and there are different ways you can accomplish this. We’ve got a tutorial that outlines how to use Hardhat to run your testing. So you can set up a framework for testing, and then be sure to develop rigorous tests of EVERY possible condition and logic flow that could occur (even those you think are highly unlikely to ever occur) – and be sure that your application works as expected in each of those scenarios.
One thing we know, is that if setting up tests isn’t easy, it’s not going to be thoroughly done on a regular basis.
Performance & Scalability Testing
Another critical area that must be tested is the performance under load of your application. Will it scale and handle the load that it might see? We’ve seen with Solana, the challenges inherent in performance testing – as we have seen multiple times when under stress, the Solana system goes down, sometimes for hours – and that is NOT what you want your users to experience after you launch your application.
Catching performance issues PRIOR to launch allows you to make the necessary tweaks and adjustments so you don’t get caught trying to duct tape a system that went down under heavy load during critical market movements.
Having developers thoroughly understand, develop, and test your web3 application can be a tall order. There are a lot of moving parts – and depending upon whether you’re building a DEX, a wallet, an AMM trading app, a game, training, or an NFT marketplace – these are all Dapps, and will likely use the mainstays of web3 development.
That includes the standards of React and Typescript on the front end. The appropriate coding libraries for your blockchain of choice, and NodeJS on the backend to interact with the blockchain data, so you can add data to the blockchain, and query the blockchain data as required for your application.
Smart contract programs that will likely also be part of your application – those are deployed to the blockchain, utilize whatever programming language that chain supports – Solidity for Ethereum and EVM compatible blockchains, and Rust is a language that is gaining traction.
For sure there is a LOT of learning to continuously factor in as blockchain development becomes more and more mature – the tools will mature as well.