2020-05-26 11:00:56 +00:00
|
|
|
use anyhow::Result;
|
2020-05-25 09:23:50 +00:00
|
|
|
use ethers::{
|
2020-05-31 16:01:34 +00:00
|
|
|
core::types::{Address, Filter},
|
2020-05-27 15:43:43 +00:00
|
|
|
providers::{networks::Any, HttpProvider},
|
2020-05-25 09:23:50 +00:00
|
|
|
};
|
|
|
|
use std::convert::TryFrom;
|
|
|
|
|
|
|
|
#[tokio::main]
|
2020-05-26 11:00:56 +00:00
|
|
|
async fn main() -> Result<()> {
|
2020-05-25 09:23:50 +00:00
|
|
|
// connect to the network
|
2020-05-27 15:43:43 +00:00
|
|
|
let provider = HttpProvider::<Any>::try_from("http://localhost:8545")?;
|
2020-05-25 09:23:50 +00:00
|
|
|
|
|
|
|
let filter = Filter::new()
|
|
|
|
.address_str("f817796F60D268A36a57b8D2dF1B97B14C0D0E1d")?
|
|
|
|
.event("ValueChanged(address,string,string)") // event name
|
2020-05-30 14:11:51 +00:00
|
|
|
.topic0("9729a6fbefefc8f6005933898b13dc45c3a2c8b7".parse::<Address>()?); // indexed param
|
2020-05-25 09:23:50 +00:00
|
|
|
|
|
|
|
let logs = provider.get_logs(&filter).await?;
|
|
|
|
println!("Got logs: {}", serde_json::to_string(&logs).unwrap());
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|