Circles RPC (Rust)
Async JSON-RPC client for the Circles protocol, mirroring the TS @rpc package while leaning on Alloy transports and shared Circles types.
Features
- Thin
CirclesRpcfacade with method groups (balance,token,trust,avatar,profile,query,events,invitation,pathfinder,group,tables,health,network,search). - HTTP constructor helpers (
try_from_http,TryFrom<&str>); WS subscriptions behind thewsfeature with best-efforteth_unsubscribeon drop. circles_queryhelpers with cursor extraction plusPagedQuery/paged_streamconvenience;paged_queryis validated against livecircles_query.- Normalized token holder balances (
TokenHolderNormalized), invitation-origin / combined-invitation lookups, inviter-outbound invitation queries, and the legacy invitation-balance batching helper. - WS parsing tolerates heartbeats (
[]), flattens batch frames, and maps unknown event types toCrcUnknownEvent.
Quickstart
use CirclesRpc;
use Address;
async
Paged queries
use CirclesRpc;
use ;
async
Events
HTTP fetch:
let events = rpc
.events
.circles_events
.await?;
WebSocket subscription (enable the ws feature):
WS behavior notes
- Public endpoints (
wss://rpc.aboutcircles.com/ws,wss://rpc.helsinki.aboutcircles.com/ws) emit periodic empty arrays; these are dropped. - Event frames can arrive batched (array-of-arrays); they are flattened before parsing.
- Unknown event types are surfaced as
CrcUnknownEvent. We have observedCrcV2_TransferSinglebatches and an unknownCrcV2_TransferSummarytype; schema validation on a busier node is still pending. - Reconnect/backoff is not automatic; see the SDK crate for retry/catch-up helpers if you need them.
Examples
paged_and_ws: fetch one page of avatars viacircles_queryand, with thewsfeature, subscribe to Circles events. Tolerates heartbeats/batches and logs unknown events without panicking.
CIRCLES_RPC_URL=https://rpc.aboutcircles.com/ \
CIRCLES_RPC_WS_URL=wss://rpc.aboutcircles.com/ws \
Status / TODO
- Subscription resilience (reconnect/backoff) is best-effort only.
- Pagination helpers could gain table-aware defaults and richer ergonomics.
- Transaction sending is intentionally omitted; transfers are handled by a separate crate in this workspace.