Expand description
Circles SDK orchestrating RPC, profile service access, pathfinding, transfers, and optional contract execution.
This crate mirrors the high-level TypeScript SDK shape while keeping the Rust
implementation read-first: most reads work with Sdk::new(config, None), and
write paths are gated behind a ContractRunner.
§Quick Start
use alloy_primitives::address;
use circles_sdk::{Sdk, config};
let sdk = Sdk::new(config::gnosis_mainnet(), None)?;
let avatar = address!("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
let info = sdk.avatar_info(avatar).await?;
println!("avatar type: {:?}", info.avatar_type);
let typed = sdk.get_avatar(avatar).await?;
match typed {
circles_sdk::Avatar::Human(human) => {
let balances = human.balances(false, true).await?;
println!("balances: {}", balances.len());
}
circles_sdk::Avatar::Organisation(_) | circles_sdk::Avatar::Group(_) => {}
}§Usage Model
Sdkwires together RPC, profile lookups, pathfinding, transfers, and contract bindings.Avatargives you a typed wrapper after runtime avatar detection.ContractRunneris only required for write paths such as registrations, trust changes, and transfer submission.SafeContractRunnerandEoaContractRunnerare the built-in execution backends for existing single-owner Safe wallets and direct EOA execution, and now expose buffered batch, gas-estimation, and read-call helper surface on the runner itself.SafeExecutionBuilderis the browser/external-signature foundation for Safe-backed flows: it prepares the canonical Safe payload/hash without requiring a local private key.- The optional
wsfeature enables WebSocket subscriptions with retry/backoff and HTTP catch-up helpers.
§Recommended Entry Points
config::gnosis_mainnetfor the shared mainnet configuration.Sdk::avatar_infofor a fast read-only probe.Sdk::get_avatarwhen you want a typed avatar wrapper.EoaContractRunner::connectandSafeContractRunner::connectwhen you want built-in execution backends for existing wallets.SafeExecutionBuilder::connectwhen you need the TS-style Safe transaction-preparation seam before an external/browser signer submits the transaction.HumanAvatar::plan_transfer,OrganisationAvatar::plan_transfer, andBaseGroupAvatar::plan_transferfor pathfinding-based transaction planning.HumanAvatar::plan_direct_transfer,OrganisationAvatar::plan_direct_transfer, andBaseGroupAvatar::plan_direct_transferfor TS-style direct-send planning.HumanAvatar::plan_group_token_redeemandOrganisationAvatar::plan_group_token_redeemfor automatic group-token redeem planning.HumanAvatar::available_invitations,HumanAvatar::invitation_origin,HumanAvatar::proxy_inviters, andHumanAvatar::find_farm_invite_pathfor the current invitation/referral query surface.HumanAvatar::plan_inviteandHumanAvatar::invitefor TS-style direct invite planning/execution against existing Safe wallets.Sdk::referralsandHumanAvatar::list_referralsfor the optional referrals backend.HumanAvatar::plan_referral_codeandHumanAvatar::get_referral_codefor the TS-style single-referral planner used bygetReferralCode().HumanAvatar::plan_generate_referralsandHumanAvatar::generate_referralsfor invitation-farm batch referral planning/execution.
§Validation
- Unit tests:
cargo test -p circles-sdk - WS helpers:
cargo test -p circles-sdk --features ws - Live checks (ignored by default):
RUN_LIVE=1 LIVE_AVATAR=0x... cargo test -p circles-sdk -- --ignored
Modules§
- config
- registration
- Registration helpers (human/org/base group).
Structs§
- Base
Group Avatar - Top-level avatar enum variant: base group.
- EoaContract
Runner - EOA-backed contract runner using the same call-builder model as the Safe runner.
- Human
Avatar - Top-level avatar enum variant: human.
- Organisation
Avatar - Top-level avatar enum variant: organisation.
- Prepared
Safe Execution - Prepared Safe execution data for browser/external-signature workflows.
- Prepared
Transaction - Prepared transaction for a runner to submit. This is intentionally simple; we can swap to richer contract-specific types as we wire more flows.
- Referral
- Full private referral record from the authenticated backend view.
- Referral
Info - Referral info returned from the public retrieve endpoint.
- Referral
List - Paginated authenticated referral list.
- Referral
List Mine Options - Optional filters for authenticated
my-referralsqueries. - Referral
Preview - Public masked referral preview.
- Referral
Preview List - Paginated public referral preview list.
- Referral
Public List Options - Optional filters for public
list/{address}queries. - Referral
Session - Distribution-session metadata attached to private referrals.
- Referral
Store Input - One item in the batch store request body.
- Referrals
- Optional referrals backend client.
- Registration
Result - Generic registration outcome carrying submitted transactions and an optional avatar.
- Safe
Contract Runner - Safe-backed contract runner using
safe-rs. - Safe
Execution Builder - Read-only Safe execution builder for browser/external signing workflows.
- Sdk
- Top-level SDK orchestrator.
- Store
Batch Error - Error entry returned from the batch store endpoint.
- Store
Batch Result - Batch store result returned by the referrals backend.
- Submitted
Tx - Result stub for submitted transactions.
Enums§
- Avatar
- Top-level avatar enum (human, organisation, group).
- Referral
Status - Referral status lifecycle exposed by the referrals backend.
- Referral
Sync Status - Cache freshness metadata for public preview queries.
- Referrals
Error - Errors surfaced by the optional referrals backend client.
- Runner
Error - Errors surfaced by the runner.
- SdkError
- High-level SDK errors.
Traits§
- Batch
Run - Buffered batch helper mirroring the TypeScript
BatchRunconcept. - Contract
Runner - Trait that allows the SDK to send transactions (e.g., via a Safe or EOA backend).
Functions§
- call_
to_ tx - Helper to turn a SolCall into a prepared transaction.