Applicable on struct
and enum
definitions.
It derives traits necessary for encoding/decoding a custom type as revert error data.
The following traits are derived depending on the ABI mode:
- In "ink" and "all" ABI mode:
scale::Encode
andscale::Decode
for encoding/decoding ink! revert error datascale_info::TypeInfo
for generating ink! contract metadata (gated behind thestd
feature)
- In "sol" and "all" ABI mode:
SolErrorEncode
andSolErrorDecode
for encoding/decoding custom types as Solidity custom errorsSolErrorMetadata
for generating Solidity ABI metadata (gated behind thestd
feature)
Example
#[ink::error]
struct UnitError;
#[ink::error]
enum MultipleErrors {
UnitError,
ErrorWithParams(bool, u8, String),
ErrorWithNamedParams {
status: bool,
count: u8,
reason: String,
}
}
note
See our Solidity ABI compatibility docs for more details about handling Solidity ABI encoded revert error data.