Skip to content

A proposal for modular, upgradeable StarkNet contracts. Inspired by the Diamond Standard.

Notifications You must be signed in to change notification settings

apibara/starknet-modular-contracts-standard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StarkNet Modular Contracts (SMC) Standard

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.

Running

You can use nile to compile the smart contracts:

nile compile

You can use pytest to runs the tests:

PYTHONPATH=. pytest tests

Modular Contracts

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.

Built-ins modules

  • ModuleRegistry: provides a function to add, replace, and remove modules.
  • ModuleIntrospection: provides functions to inspect registered modules.

Authoring 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.

About

A proposal for modular, upgradeable StarkNet contracts. Inspired by the Diamond Standard.

Topics

Resources

Stars

Watchers

Forks