Can you use custom error data to provide context when a transaction reverts?

Responsive Ad Header

Question

Grade: Education Subject: Support
Can you use custom error data to provide context when a transaction reverts?
Asked by:
76 Viewed 76 Answers
Responsive Ad After Question

Answer (76)

Best Answer
(336)
Yes, named custom errors allow you to include data within the error definition. In the example `error InsufficientBalance(uint256 available, uint256 required);`, `available` and `required` are data fields. When the error is thrown, this data is included in the revert, providing valuable context for off-chain monitoring and debugging.