Skip to content

Instantly share code, notes, and snippets.

@mudgen
Last active October 7, 2022 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mudgen/c2be756d8252f2eae6fab09cd28f5c96 to your computer and use it in GitHub Desktop.
Save mudgen/c2be756d8252f2eae6fab09cd28f5c96 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
DiamondStorage storage ds = diamondStorage();
bytes4 functionSelector = bytes4(keccak256("myFunction(uint256)"));
// get facet address of function
address facet = ds.selectorToFacet[functionSelector];
bytes memory myFunctionCall = abi.encodeWithSelector(functionSelector, 4);
(bool success, bytes memory result) = address(facet).delegatecall(myFunctionCall);
require(success, "myFunction failed");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment