This is a simple example implementation for EIP-2535 Diamonds. To learn about other implementations go here: https://github.com/mudgen/diamond
The standard loupe functions have been gas-optimized in this implementation and can be called in on-chain transactions. However keep in mind that a diamond can have any number of functions and facets so it is still possible to get out-of-gas errors when calling loupe functions. Except for the facetAddress
loupe function which has a fixed gas cost.
The contracts/facets/LaunchPadProjectFacet.sol
file shows an launchpad contract with Diamond implementation.
The contracts/libraries/LibLaunchPadProjectStorage.sol
file shows how to implement Diamond Storage.
In order to call a function that exists in a diamond you need to use the ABI information of the facet that has the function.
- EIP-2535 Diamonds
- diamond-3-hardhat
- Introduction to EIP-2535 Diamonds
- Solidity Storage Layout For Proxy Contracts and Diamonds
- New Storage Layout For Proxy Contracts and Diamonds
- Diamond Setter
- Upgradeable smart contracts using the EIP-2535 Diamonds
- buidler-deploy supports diamonds
This implementation was written by Jenson.
Contact:
MIT license. See the license file. Anyone can use or modify this software for their purposes.