Derive Macro ethers_contract_derive::EthError

source ·
#[derive(EthError)]
{
    // Attributes available to this derive:
    #[etherror]
}
Expand description

Derives the EthError and Tokenizeable trait for the labeled type.

Additional arguments can be specified using the #[etherror(...)] attribute:

For the struct:

  • name, name = "...": Overrides the generated EthCall function name, default is the struct’s name.
  • abi, abi = "...": The ABI signature for the function this call’s data corresponds to.

NOTE: in order to successfully parse the abi (<name>(<args>,...)) the <name> must match either the struct name or the name attribute: #[ethcall(name ="<name>"]

Example

use ethers_contract::EthError;

#[derive(Debug, Clone, EthError)]
#[etherror(name ="my_error")]
struct MyError {
    addr: Address,
    old_value: String,
    new_value: String,
}
assert_eq!(
    MyCall::abi_signature().as_ref(),
    "my_error(address,string,string)"
);