Skip to content

Inviting and Accepting Human Avatars

The Rust SDK now covers both sides of the current invite flow, but the API is split across the inviter avatar and the top-level registration helpers.

Current split:

  • inviter side:
    • HumanAvatar::plan_invite
    • HumanAvatar::invite
    • query helpers such as available_invitations, accepted_invitees, pending_invitees, proxy_inviters, find_invite_path, and find_farm_invite_path
  • invitee / registration side:
    • Sdk::register_human(inviter, profile)

register_human pins the profile, redeems a pending invitation if one exists in the invitation escrow, and then submits registerHuman.

Example: register a human avatar with an inviter

use std::sync::Arc;
 
use alloy_primitives::address;
use circles_sdk::{EoaContractRunner, Sdk, config};
use circles_types::Profile;
 
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let runner = Arc::new(
        EoaContractRunner::connect(
            "https://rpc.aboutcircles.com/",
            "0xYOUR_PRIVATE_KEY",
        )
        .await?,
    );
    let sdk = Sdk::new(config::gnosis_mainnet(), Some(runner))?;
    let inviter = address!("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    let profile = Profile {
        name: "Alice".into(),
        description: Some("New Circles member".into()),
        preview_image_url: None,
        image_url: None,
        location: Some("Berlin".into()),
        geo_location: None,
        extensions: None,
    };
 
    let registered = sdk.register_human(inviter, &profile).await?;
    println!("submitted {} tx(s)", registered.txs.len());
 
    Ok(())
}