Skip to content

Instantly share code, notes, and snippets.

@mudgen
Last active December 15, 2025 17:10
Show Gist options
  • Select an option

  • Save mudgen/34aefd1abedfbf41ab8c4909530eacb5 to your computer and use it in GitHub Desktop.

Select an option

Save mudgen/34aefd1abedfbf41ab8c4909530eacb5 to your computer and use it in GitHub Desktop.
import "../DiamondMod.sol" as DiamondMod;
contract ExampleDiamond {
/**
* @notice Struct to hold a facet address and its function selectors.
* struct FacetFunctions {
* address facet;
* bytes4[] selectors;
* }
*/
/**
* @notice Initializes the diamond contract with facets.
* @dev Adds all provided facet functions to the diamond's function/selector mapping.
* @param _facetFunctions Array of facet addresses and their corresponding function selectors to add to the diamond.
*/
constructor(DiamondMod.FacetFunctions[] memory _facetFunctions) {
/**
* Here we add all the ERC20 functions from the ERC20Facet.
* Here we add the diamondUpgrade function.
*/
DiamondMod.addFacetFunctions(facetFunctions);
}
fallback() external payable {
DiamondMod.diamondFallback();
}
receive() external payable {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment