Derive Macro ethers_contract_derive::EthEvent

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

Derives the EthEvent and Tokenizable traits for the labeled type.

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

For the struct:

  • name = "...": Overrides the generated event name. Defaults to the struct’s name;
  • signature = "...": The signature as hex string to override the event’s signature;
  • abi = "...": The ABI signature of the event. The abi should be a Solidity event definition or a tuple of the event’s types in case the event has non elementary (other EthAbiType) types as members;
  • anonymous: A flag to mark this as an anonymous event.

For fields:

  • indexed: flag to mark a field as an indexed event input;
  • name = "...": override the name of an indexed event input, default is the rust field name.

§Examples

use ethers_contract_derive::{EthAbiType, EthEvent};
use ethers_core::types::Address;

#[derive(EthAbiType)]
struct Inner {
    inner: Address,
    msg: String,
}

#[derive(EthEvent)]
#[ethevent(abi = "ValueChangedEvent(address,string,(address,string))")]
struct ValueChangedEvent {
    #[ethevent(indexed, name = "_target")]
    target: Address,
    msg: String,
    inner: Inner,
}