Fetching Profile of a Human Avatar
Profile reads work without a runner. Human avatars also expose write helpers for
update_profile, update_profile_metadata, and register_short_name.
Read example 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(())
}For writes, prefer the typed HumanAvatar methods so the profile is pinned and
the metadata digest update is submitted in the expected order.