I am using Foundry, and I need to calculate the 4-byte selector of a custom error. How can I do this with the cast CLI?

1 Answer 1


You can use cast sig for this, which takes a single input in the form of NAME(type1,type2,...).

Here's an example:

$ cast sig "transfer(address,uint256)"

Will output:


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.