For the complete documentation index, see llms.txt. This page is also available as Markdown.

Subscribing to Avatar events

The Circles SDK let's you subscribe to protocol events. Either filtered for an avatar or as a complete stream. There is also a way to query all past events in a block range.

Subscribe

To subscribe, you need an initialized CirclesData class.

const circlesRpc = new CirclesRpc("https://rpc.aboutcircles.com/");
const data = new CirclesData(circlesRpc);
const circlesRpc = new CirclesRpc("https://static.94.138.251.148.clients.your-server.de/rpc/");
const data = new CirclesData(circlesRpc);

Then call the subscribeToEvents() method and supply the address of the avatar to subscribe to:

const avatarEvents = await data.subscribeToEvents("0x...");
avatarEvents.subscribe(event => {
    console.log(event);
});

If you want to subscribe to all events, call it without parameter:

const avatarEvents = await data.subscribeToEvents("0x...");
avatarEvents.subscribe(event => {
    console.log(event);
});

Query past events

If your client missed some events, you can query all events for a specific avatar in a block range.

const avatarEvents = await data.getEvents("0x..", 9000000, 10000000);

You can omit the last parameter (toBlock) to query from fromBlock to the latest block:

Event types

The above methods yield CirclesEvents. All events have at least the following base properties:

  • $event: CirclesEventType One of the event types listed below

  • blockNumber: number In which block the event occurred

  • timestamp?: number When the event occurred

  • transactionIndex: number The index of the transaction in the block

  • logIndex: number The index of the log entry in the transaction

  • transactionHash?: string The transaction hash

Here's a list of all event types. Please refer to the source code for the event properties.

Last updated

Was this helpful?