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

Folders and files

NameName
Last commit message
Last commit date
Jul 19, 2024
May 15, 2024
Aug 21, 2024
Nov 7, 2024
Nov 29, 2024
Nov 19, 2024
Sep 4, 2024
May 17, 2024
Aug 21, 2024
Aug 28, 2024
Aug 21, 2024
Aug 28, 2024
Aug 21, 2024
Mar 4, 2024
Aug 21, 2024

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 [email protected].

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