Reusable Smart Contracts
You might be wondering: How can I create a new project without deploying new smart contracts?
How does Compose make it possible to build new systems from existing onchain contracts?
The answer lies in Compose's smart contract architecture, which is based on diamond contracts.
A diamond contract is a simple, tiny contract that uses the code of other onchain contracts called facets. Each diamond uses the code of other contracts (facets) to create and maintain its storage data.
When you use Compose, you do deploy new contracts—but only the small diamond contract that ties together existing onchain facets.
Let's look at a simple example.
Suppose you want to create a new ERC-20 token that supports gasless approvals (permit) and cross-chain bridging.
With Compose, you can:
- Select the facets you need – for example,
ERC20Facet,ERC20PermitFacet, andERC20BridgableFacet. - Provide initialization data – such as the token name, symbol, and total supply.
- Deploy your diamond – which initializes your ERC-20 token and connects it to the chosen facets.
Many diamond contracts can be deployed that reuse the same onchain facets.