metacontract/mc
Meta-contract
The meta contract is a highly abstract framework based on ERC-7546 UC (Upgradeable Clone) that enables Solidity smart contract development with minimal overhead.
Overview
This framework aims to seamlessly solve challenges associated with the initial development and operation of real-world Dapps. For example, it automatically generates integration handlers for indexers, minimizes indexer maintenance costs, reduces the implementation cost of upgrade mechanisms, and minimizes operational overhead. One of the issues that is difficult to articulate but definitely exists in actual smart contract development is that "as smart contracts become more complex, high technical skills are required to continue safe and efficient development." The framework carefully selects and implements the necessary requirements to free many developers from this burden. As a result, developers only need to focus on the "data schema and function set" of their own protocol. Upgradeability, clone factories, indexers, and other features are hidden behind the framework, allowing developers to concentrate their thinking resources solely on the business domain they are trying to solve. Furthermore, this design pattern is compatible with the mental models of LLMs (Large Language Models), and GPTs are being developed to efficiently assist with design and implementation. Highly reusable schemas and functions are suggested through LLMs, ensuring an unprecedented development experience.
Details
Structure
Meta-contracts are essentially bundles of smart contract functions that adhere to the ERC-7546 UCS. They are designed to operate within the constraints of the Ethereum Virtual Machine (EVM), optimizing for both efficiency and functionality. Each bundle can contain various functions that, when combined, fulfill a broader set of contract responsibilities.
Storage Schema
They utilize a structured and efficient way to manage contract state through a central storage layout, often detailed in a Schema library. This approach ensures that state variables are well-organized and accessible, reducing complexity and the potential for errors.
Upgradeability and Scalability
By employing the clone function methodology, meta-contracts allow for the creation of new contract instances (clones) that can utilize the same underlying logic without redeploying the entire codebase. This feature significantly enhances both upgradeability and scalability, allowing for adjustments and expansions to be made with minimal cost and effort.
Features
Modularity
Each metacontract can be seen as a modular piece of a larger puzzle. Developers can mix and match different functions or bundles to create customized contract solutions that fit their specific needs.
Efficient Development and Testing
The structured approach to contract design simplifies both development and testing processes. Since meta-contracts encourage unit-test maximalism, developers can quickly test individual functions in isolation, speeding up the development cycle.
Reduced Deployment Cost
The ability to clone contracts allows for significant gas savings, as the underlying logic does not need to be redeployed for each new instance. Only the state-changing transactions associated with initializing or interacting with these clones incur gas costs.
Enhanced Organizational Structure
The use of libraries like StorageScheme.sol to centralize storage information helps in maintaining a tidy and organized codebase. This structure is beneficial for both ongoing development and future audits.
Pros of Meta-contracts
Upgradeability
Meta-contracts facilitate easy and efficient upgrades. Modifications or improvements can be made to the contract logic without necessitating the redeployment of the entire contract, thus preserving the contract's address and state.
Cost-Efficiency
The cloning feature inherent to meta-contracts significantly reduces the cost associated with deploying new contract instances, making it a cost-effective solution for scalable projects.
Developer Friendliness
The modular nature and structured storage approach make meta-contracts particularly appealing to developers, offering ease of development, testing, and maintenance.
Flexibility
Developers can customize and extend the functionality of their contracts by adding, modifying, or removing function bundles as needed, without compromising the system's integrity or incurring excessive costs.