Skip to content

A framework for writing highly composable smart contracts for which you can add, remove, upgrade or switch out the exact parts you want.

Notifications You must be signed in to change notification settings

thirdweb-dev/modular-contracts

Repository files navigation



Modular Contracts

Write smart contracts for which you can add, remove, upgrade or switch out the exact parts you want.


A Modular Contract is built of two kinds of parts: a Modular Core and its Modular Modules.

modular-contracts-analogy

A developer writes a Core smart contract as the foundation that can be customized by adding new parts and updating or removing these parts over time. These ‘parts’ are Module smart contracts which any third-party developer can independently develop with reference to the Core smart contract as the known foundation to build around.

Install and Use

This project can currently be installed as a dependency in foundry projects. To install, run:

forge install https://github.com/thirdweb-dev/modular-contracts

Add the following in a remappings.txt file:

@modular-contracts/=lib/modular-contracts/src/

Import Core inherit to build a Modular Core contract (e.g. ERC-721 Core):

import {Core} from "@modular-contracts/Core.sol";
import {ERC721A} from "@erc721a/extensions/ERC721AQueryable.sol";

contract ModularNFTCollection is ERC721A, Core {}

Import Module to create an Module for your Core contract (e.g. Soulbound):

import {Module} from "@modular-contracts/Module.sol";

contract SoulboundERC721 is Module {}

Run this repo

Clone the repo:

git clone https://github.com/thirdweb-dev/modular-contracts.git

Install dependencies:

# Install dependecies
forge install

Feedback

If you have any feedback, please create an issue or reach out to us at support@thirdweb.com.

Authors

License

Apache 2.0

About

A framework for writing highly composable smart contracts for which you can add, remove, upgrade or switch out the exact parts you want.

Resources

Stars

Watchers

Forks