Fetching Profile of a Human Avatar
Read-only profile lookup using circles_query.
use circles_rpc::QueryMethods;
use circles_types::{Address, FilterPredicate, OrderBy, QueryParams};
use reqwest::Url;
#[derive(Debug, Clone, serde::Deserialize)]
struct ProfileRow {
avatar: Address,
name: Option<String>,
description: Option<String>,
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = circles_rpc::RpcClient::http(Url::parse("https://rpc.aboutcircles.com/")?);
let queries = QueryMethods::new(client);
let params = QueryParams {
namespace: "circles".into(),
table: "profiles".into(),
columns: vec!["avatar".into(), "name".into(), "description".into()],
filter: vec![FilterPredicate::equals(
"avatar".into(),
"0x1234567890123456789012345678901234567890",
)
.into()],
order: vec![OrderBy::desc("blockNumber".into())],
limit: Some(1),
};
let rows: Vec<ProfileRow> = queries.circles_query(params).await?;
if let Some(row) = rows.first() {
println!("profile: {:?}", row);
} else {
println!("no profile found");
}
Ok(())
}Profile updates are runner-dependent and will be added once write support is available.