Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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, uint 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