This repository presents a way to build and deploy modular StarkNet contracts. It is heavily inspired by the Diamond Standard, but uses a different naming convention to avoid confusion.
You can use nile to compile the smart contracts:
nile compile
You can use pytest to runs the tests:
PYTHONPATH=. pytest tests
The idea is to deploy a main
contract and then add modules to it
to increase its functionality. Modules can be replaced to perform an
upgrade. The main
module automatically registers the ModuleRegistry
module on deployment. You can make a contract immutable by removing the
ModuleRegistry
.
ModuleRegistry
: provides a function to add, replace, and remove modules.ModuleIntrospection
: provides functions to inspect registered modules.
New modules are best implemented using the extensibility pattern proposed by Open Zeppelin.
Modules should never import functions from other modules, they should instead import functions from libraries. Importing from modules results in accidentally exporting the module's external functions.
Modules are like contracts, but they don't have a
constructor, initialization is provided by defining an @external
initializer
function.