Is it possible in Solidity to check if a function selector exists in an external contract without attempting to invoke said function?


1 Answer 1


To my knowledge no.

If you want to check for a view function it may be possible to use staticcall(abi.encodeWithSelector(selector))

statticcall() ensures that an external function calls will not write to the contract while interacting with a function, in case of success it returns a boolean and the data and reverts if the call try to write to storage.



The other method used, which isn't function specific is to use the IERC165, to see if a contract implements an interface containing a set of precise function headers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.