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.
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.
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 {}
Clone the repo:
git clone https://github.com/thirdweb-dev/modular-contracts.git
Install dependencies:
# Install dependecies
forge install
If you have any feedback, please create an issue or reach out to us at [email protected].