Why Composability Matters For Web3
Composability, built on open-source technology, is key to unlocking value for developers and users in Web3.
10 min read
Table of contents
- What Does Composability Mean?
- How Composability Unlocks Value in Web3
- Obstacles to Web3 Composability
- Final Thoughts
Many Web2 developers are familiar with composability—the idea of creating reusable software components that can be used to create distinct applications. Composability has roots in the open-source technology movement and was critical to the Internet's early growth.
Even though it improves on the Web2 Internet, Web3 needs composability to unlock value for users and foster innovation. This article outlines the principles of composability, the benefits of a composable system, and how it fits into the Web3 infrastructure.
What Does Composability Mean?
In application development, composability refers to the ability to combine existing components and reassemble them to create new products.
In a composable architecture, every component has a specific use case. Developers can then combine these components and add new functionality to build applications—without having to reinvent the wheel or build from scratch.
As explained earlier, composability was and is a feature of open-source technology. Anyone could create open-license software, which other developers can use in their products, without fear of litigation or patent infringement issues.
The early days of the Internet were built on this idea of collective access to technology. For instance, CERN famously released software for the World Wide Web.
However, Big Tech giants eroded composability to preserve company profits. Companies like Google, Facebook, and Amazon now protect software through overzealous patent protection, data protection, and deliberately engineering products using incompatible tech stacks.
Moreover, Web2 companies lock users into platforms and prevent usage of rival platforms by implementing high switching costs. The result is a fragmented system, where each component cannot be combined to create greater value.
Composability in Blockchain Technology
The explosion in decentralized technology (Web3) has triggered a new interest in software composability. As open-source technologies, blockchain applications are highly interoperable and can benefit from existing libraries to create new experiences for users.
In the context of Web3, composability is the ability of blockchain applications, like decentralized exchanges (DEXs), decentralized applications (dApps), and decentralized autonomous organizations (DAOs) to communicate and work with each other.
Specifically, composability in blockchain technology means developers can freely use and integrate code from other applications into their products. This is because smart contracts—which control application logic—are open-source and available to the public.
Composability in blockchain technology helps shorten the development cycle for decentralized applications (dApps). Previously, developers would've to develop every feature of an application from the ground up. But composability allows developers to modify code libraries from existing dApps to create new apps, reducing time spent on writing lines of code.
An area of blockchain technology that’s benefitted from composable software is decentralized finance (DeFi). For example, SushiSwap launched its decentralized exchange by copying Uniswap's codebase and adding extra features, such as a governance token and liquidity mining.
There are even more examples of composability in Web3, which I explore in the next section.
How Composability Unlocks Value in Web3
Composability is necessary for creating an interoperable system where disparate elements can connect seamlessly. Components of blockchain technology, such as dApps, DEXs, and DAOs, are composable by nature, allowing them to be reassembled, duplicated, or integrated into one another.
Blockchain composability typically occurs at either the smart contract or project level. This allows developers to combine powerful components to design new applications and unlock greater possibilities for users.
Syntactic composability denotes the implementation of several components, such that they can be connected to form entirely new systems. Syntactic composability thrives on three critical components:
Modularity: Each component in a composable infrastructure must solve a specific problem and do it well. This allows developers to assemble modular components into one product, with various elements handling different tasks.
Autonomy: Components in a composable architecture must be able to work independently without relying on other components for functionality. It also means each element can be modified without affecting the overall structure
Discoverability: Composability allows developers to harness repositories of reusable software frameworks and libraries. But these libraries and frameworks must be "discoverable" for others to use. In other words, code must be open-source and available for unrestrained modification and usage.
Ethereum is a classic example of how syntactic composability works in blockchain technology: smart contracts function as reusable elements anyone can use. This means development teams can re-use basic contract code and concentrate on building core infrastructure for dApps.
The Ethereum.org website puts it thus:
Smart contracts are public on Ethereum and can be thought of as open APIs. You don't need to write your own smart contract to become a dapp developer, you just need to know how to interact with them. For example, you can use the existing smart contracts of Uniswap, a decentralized exchange, to handle all the token swap logic in your app – you don't need to start from scratch.
Within the Ethereum ecosystem, smart contracts are building blocks that developers can apply to build even more complex applications. The SushiSwap-Uniswap example mentioned earlier shows how different projects can use similar codebases to achieve different objectives.
Other blockchain applications also benefit from syntactic composability. For example, a new DAO might find building a bespoke governance system costly and time-intensive. But it can simply use a library of governance tools, like Aragon Client, to bootstrap and scale a usable governance system.
"Atomicity" is a concept in blockchain technology that introduces the idea of combining multiple actions into one transaction. This transaction can be anything from a token swap between two individuals to smart contract calls.
The principle of atomicity maintains that every action in the transaction must be correct and possible for it to work. If a single part of the transaction fails, then the entire transaction fails as well.
Atomic composability—a combination of atomicity and composability—is, therefore, the idea that a single transaction can involve calls to different smart contracts. The failure of one part of the transaction causes the transaction to fail: the transaction either succeeds together or fails together.
Moreover, atomic composability is possible only if the parts involved in the transaction are hosted on a single same execution layer. It'd be impossible to conduct a complex transaction that involves using dApps running on different chains—say, Ethereum (Layer 1) and Polygon (Layer 2).
The best examples of atomic composability come from the DeFi ecosystem. Here are a few examples of atomic composability in action:
For those who haven't journeyed deep into the weeds of crypto and DeFi, a flash loan may seem like a futuristic concept. However, flash loans follow a simple pattern and work because of atomic composability:
The idea of a flash loan is simple: you borrow and pay back a loan within a single transaction. Flash loans operate on atomic principles, meaning lenders will get their money back if the transaction fails. This paves the way for uncollateralized loans since borrowers cannot (theoretically) default on repayments.
Atomic composability means a flash loan can involve different activities executed across different platforms (provided those actions generate enough tokens to repay the loan). Here's an example, taken from arbitrage trading, to explain the concept:
Say a token (MKR) is trading higher on one exchange (Uniswap) than on another exchange (Kyber). The arbitrage trader (Bob) lacks enough funds to buy MKR on Kyber and sell on Uniswap for profit, so he takes out a flash loan.
Here’s the fun part:
Bob can use the loan to buy MKR on Kyber, sell the MKR tokens on Uniswap, take out the profit, and return the initial capital to the lender. And all of these actions happen in a single transaction. If one part fails, then the entire deal falls through and the lender gets their capital.
Taking out a loan in the real world would involve a painful amount of paperwork and lots of time-wasting, hindering efficient arbitrage. Thanks to atomic composability, flash loans make it easier for arbitrage trading to benefit from higher liquidity and generate profits.
Automated Market Makers (AMMs)
Automated market makers (AMMs) are protocols that enable the trustless and automatic trading of crypto tokens. You can think of an AMM as a robotic "portfolio manager" that makes investment decisions based on an analysis of current market conditions.
Yearn is an example of a popular AMM among DeFi enthusiasts. The Yearn AMM can automatically scan different DeFi platforms and move your tokens to where you'll gain the most profit (by earning trading fees, for example).
However, Yearn can only work because of two reasons:
It can access data about token prices on different DeFi platforms. If each platform protected platform data, the Yearn algorithm wouldn’t be able to compare token prices.
Different components of the DeFi ecosystem can be combined quickly within the same transaction. For example, the Yearn trading bot can use ETH as collateral to borrow DAI stablecoins from MakerDAO, use DAI to earn CRV tokens on Curve, sell CRV for ETH, and return ETH to MakerDAO for collateral.
Decentralized Identity and Composability
Another application of composability in Web3 is identity management. Currently, identity frameworks are hardly composable since each platform must engineer its system for collecting and managing user identities.
One of Web3's biggest improvements is the ability of users to transfer their identity across dApps. Users can store identifiers in their wallets and grant read-only access to dApp authentication systems. This means you don't have to remember long passwords or provide the same details to dozens of applications.
This contrasts with the centralized Internet, where different providers cannot share identity information. That's why you have different account information for Facebook, Twitter, LinkedIn, and more—even if the information is, more or less, the same.
Obstacles to Web3 Composability
While composability is a noble idea, implementing it can be difficult for many reasons:
A big part of blockchain composability derives from the ability of smart contracts to call other contracts. This is what makes complex transactions involving different contracts possible.
However, calling external contracts isn't always the best idea. For instance, calling a malicious contract could lead to exploits, especially re-entrancy attacks.
For composability to become the standard, strengthening smart contract security is important. This makes it easier for developers to safely integrate logic from other contracts into their contracts.
Intellectual Property (IP) Protection
Up until now, blockchain technology has thrived off the ideals of open-source technology and codebases as "public goods". But there are signs this might change sooner than expected.
After the SushiSwap incident, Uniswap built a clause into the v3 release of its software to prevent unauthorized usage or forking. Although sensible, such moves may re-introduce the 'walled gardens' of Web2, where organizations prioritize self-preservation over collective growth and innovation.
If projects start to register smart contracts or prevent usage, then composability will die a slow death. As explained earlier, composability requires software to be open-source and available for usage and modification.
Composability in blockchain benefits from standards. For instance, Ethereum ensured interoperability by creating standards known as Ethereum Requests for Comments (ERCs) for smart contract interfaces.
The ERC-20 standard, for example, defines how a fungible token should operate. This makes sure it's compatible with other components of the Ethereum ecosystem, such as wallets, DEXs, dApps, and so on.
However, with the explosion of blockchains, it may be difficult to create standards that will ensure the composability and interoperability. It is important to agree on industry standards, lest Web3 becomes a collection of walled gardens itself.
Initially, I thought of naming this article, "What Do Orchestras And Web3 Have In Common?". Like an orchestra, Web3 benefits from having disparate but composable elements combine to create new results.
While this article has covered composability extensively, there are more applications of a composable infrastructure in Web3. With time, developers will find ways to adapt pre-existing components to fabricate new systems that provide exceptional functionality.
Whether Web3 will continue to encourage composability remains to be seen, though. Better smart contract security, greater collaboration between development teams, and higher standardization are necessary to create a truly composable Web3 ecosystem.
Cover Photo by Ryan Quintal on Unsplash