Open imokoi opened 2 years ago
logic of topic filter
let log = receipt
.logs
.iter()
.find(|log| {
log.topics
.iter()
.find(|topic| {
**topic
== H256::from_str(
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
)
.unwrap()
})
.is_some()
})
.unwrap();
I got it.
I need to define my event like below
#[derive(Debug, Default, EthEvent, PartialEq, Eq)]
#[ethevent(name = "Transfer", abi = "Transfer(address,address,uint256)")]
pub struct Erc20TransferEvent {
#[ethevent(indexed)]
pub from: Address,
#[ethevent(indexed)]
pub to: Address,
pub value: U256,
}
parse the log
let event = <Erc20TransferEvent as EthLogDecode>::decode_log(ðers::abi::RawLog {
topics,
data,
})
yes, the indexed fields are required.
do you want to add an erc20 event parsing example?
yes, the indexed fields are required.
do you want to add an erc20 event parsing example?
sure, I will post a PR later
Sorry to ask this question, but I didn't find any example of parsing the log in tx receipt.
what I have tried:
config a ERC20TransferEvent
it failed.
then I tried another way
it succeeds. but I want to how to use the way 1.
so is there any example about paring log?