Docs

Modular Contracts

Modular Contracts are contracts for which you can add, remove, or upgrade the exact parts you want.

Getting started

To get started, install the modular-contracts package in your existing Solidity project:

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

A modular contract is made up of [1] a Core and [2] Extension contracts. Learn more about these, below.

Follow this end-to-end guide to learn how to write, deploy and use your own custom modular contract.

Background

A modular contract is made up of two kinds of contracts:

  • Core contract: the foundational API that can be customized by installing Extensions.
  • Extension contract: implements a set of functionality that is enabled on a Core when it is installed.

Installing an Extension in a Core customizes the Core’s behaviour in two ways:

  • New functions become callable on the Core contract (via its fallback function).
  • Core contract’s fixed functions make callback function calls into the Extension.

You can read about the full technical design details of Modular Contracts in its design document.