Derive Macro ethers_contract_derive::EthEvent
source · #[derive(EthEvent)]
{
// Attributes available to this derive:
#[ethevent]
}
Expand description
Derives the EthEvent
and Tokenizeable
trait for the labeled type.
Additional arguments can be specified using the #[ethevent(...)]
attribute:
For the struct:
name
,name = "..."
: Overrides the generatedEthEvent
name, default is the struct’s name.signature
,signature = "..."
: The signature as hex string to override the event’s signature.abi
,abi = "..."
: The ABI signature for the event this event’s data corresponds to. Theabi
should be solidity event definition or a tuple of the event’s types in case the event has non elementary (otherEthAbiType
) types as membersanonymous
: A flag to mark this as an anonymous event
For fields:
indexed
: flag to mark a field as an indexed event inputname
: override the name of an indexed event input, default is the rust field name
Example
ⓘ
use ethers_contract::EthCall;
use ethers_core::types::Address;
#[derive(Debug, EthAbiType)]
struct Inner {
inner: Address,
msg: String,
}
#[derive(Debug, EthEvent)]
#[ethevent(abi = "ValueChangedEvent((address,string),string)")]
struct ValueChangedEvent {
#[ethevent(indexed, name = "_target")]
target: Address,
msg: String,
inner: Inner,
}