Composable Services & DeFi Legos

Kate Sills
4 min readMar 4, 2023

--

When people talk about composability, they’re usually talking about composable services. But what *are* composable services?

In the last few years, there’s been a lot of discussion about composability in smart contracts. But composability as a term has been hard to pin down. For some people, it means open source code that anyone can edit and reuse. For others, composability involves integration through standardized interfaces, such as ERC20 tokens. In DeFi especially, composability has been compared to “money legos” or building blocks that can be recombined in various ways.

Open source software and DeFi building blocks are truly groundbreaking, but there’s more to composability. We can divide composability into a few major categories:

  • composable services
  • composable access
  • composable goods

Many of these categories have been majorly overlooked by the industry. But before we go into the different types of composability, let’s start at the beginning.

Composable functions

Probably the simplest example of composition is the composition of two functions. In math and programming, if two functions are composed, then that means that the output of one function is the input of another function. In other words, it’s like two pieces of pipe being put together:

One really cool thing about composition is that when we compose two functions together, it’s as if we created a new function. And this function itself can be further composed with other things!

Composable services

This pattern is simple, but incredibly powerful. When people talk about money legos and DeFi building blocks, they’re often referring to this kind of composition, but with services. When we can compose services, we provide an input and get an output back, just like a function. But unlike a mathematical function, we can send real things with real value, like money, tokens, or other items.

For example, if I want to buy an NFT, but the owner of the NFT only wants to be paid in a token that I don’t own yet, then without composability I have to go through a laborious, multi-step process of exchanging tokens and then buying the NFT.

But, with composability, as long as there’s a decentralized exchange using the usual token standards, I can just plug that in and create an even better NFT storefront, one where you can buy an NFT with nearly any popular token, not just the one the seller accepts. This means that customers don’t need to care about how to pay, as long as they have something valuable to pay with.

So why does this work, and why weren’t we able to do this earlier? Unlike Web 2.0, the building blocks:

  • Don’t go away if a company dissolves or gets sold
  • Can’t be deleted or taken down, as long as the smart contract doesn’t allow it
  • Are publicly available to any caller and have public data
  • Are permissionless — you don’t need anyone’s approval to put them together

And importantly, unlike Web 2.0, we can finally “send money through the API”. In other words, for the first time, code can be a self-sustaining business. When customers make use of smart contracts on a blockchain, they have to pay upfront to cover the costs of the code executing. And on top of that, customers can pay tokens. This means that services can ask customers to cover the marginal cost of their usage, and opens up a number of new business models beyond the typical “pay monthly for rate-limited access.” In particular, customers don’t need to create new accounts for each service, if they immediately and directly pay for usage through tokens.

While this is truly revolutionary, money legos are only one type of composability: composable services that require standardized, transferable tokens. But what about cases where we don’t have or don’t want tokens? For example, what if I create a smart contract and I want to delegate my admin abilities to a friend while I go on vacation? (And what if I want to decentralize control completely by plugging in a DAO instead?) Let’s call this composable access.

In the next piece, I’ll provide some examples of composable access, and show how easy it is to do on Flow with something called capabilities!

-> Continue to Part 2

--

--

Kate Sills

past: engineering lead for Agoric’s smart contract framework