You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compose is a general purpose smart contract library. It helps you create smart contract systems.
13
14
@@ -30,28 +31,29 @@ So Compose is a general purpose **onchain** smart contract library.
30
31
31
32
## Reusable Smart Contracts
32
33
33
-
If you want to create a new project you might wonder how to do that without deploying new smart contracts. How does Compose enable people
34
-
to create new smart contract systems without deploying contracts?
34
+
If you want to create a new project you might wonder how to do that without deploying new smart contracts. How does Compose enable people to create new smart contract systems using existing onchain contracts?
35
35
36
36
This is where Compose's smart contract architecture comes in. Compose uses [diamond contracts](https://eips.ethereum.org/EIPS/eip-2535)
37
37
to organize smart contracts and make them reusable.
38
38
39
39
A diamond contract is a simple, small contract that uses the code of other onchain contracts.
40
40
41
41
A diamond contract creates and maintains its own storage data using code from other contracts. These other "contracts" are called facets.
42
-
```mermaid
43
-
flowchart TD
44
-
45
-
A{"Diamond Contract"} --> B[Facet 1]
46
-
A --> C[Facet 2]
47
-
A --> D[Facet N]
48
-
```
49
-
<br />
50
-
Let's look at a simple example of how this works. Let's say that you want to create a new ERC20 token that uses the gasless "permit" function and can be bridged to other blockchains.
Using Compose you do actually deploy new contracts. Specifically you deploy a small diamond contract that uses existing onchain facets.
46
+
47
+
Let's look at a simple example of how this works. Let's say that you want to create a new ERC20 token that uses the gasless "permit" function and can be bridged to other blockchains. Use Compose to:
48
+
49
+
1. Choose the onchain facets you need. In this case you need `ERC20Facet`, `ERC20PermitFacet` and `ERC20BridgableFacet`.
50
+
2. Setup initialization information such as the name of your ERC20 token, its total supply, etc.
51
+
3. Deploy a diamond which initializes your ERC20 token and uses the onchain facets in step 1.
52
+
53
+
## Composable Contracts
54
+
55
+
The word "composable" means capable of being combined with other parts or elements to form a whole. As much as possible Compose facets are designed to be composable. Facets are designed to work with other facets. Facets are the building blocks of Compose.
0 commit comments