Circles Documentation
  • Welcome to Circles
  • Overview
    • Understanding Personal and Group Currencies
      • Personal Currencies
      • Group Currencies
    • Why Build on Circles?
    • Circles Architecture
  • Developer Docs
    • The Circles Stack
    • Circles SDK Overview
    • Quickstart Guide for Circles SDK
    • Setting Circles Profiles
    • Building with different Circles Avatars
      • Personal / Human Avatars
        • Inviting and accepting human avatars
        • Mint personal tokens
        • Fetching profile of an human avatar
        • Manage trust connections
        • Get token balances of an avatar
        • Transfer personal Circles tokens to different avatar
      • Group Avatars
        • Create Base Groups for your community.
          • Vanilla groups with V2 hub
        • Mint group tokens
        • Managing group invites
        • Find groups and memberships
        • Getting total supply of group tokens available
      • Organization Avatars
        • Creation of Organizations
        • Managing trust connections via Org avatar account
  • Tutorials and Examples
    • Setting up Circles SDK with React
  • Querying Circles profiles and data
    • Query Circles Data
    • Subscribing to Avatar events
    • Utilising CirclesQuery Class
    • Query Circles profiles
  • Circles SDK Reference
    • Circles SDK interface
    • SDK Methods
    • Circles Data Methods
    • Circles Events Types
  • Developer Support
    • Glossary
    • Past Hackathon Projects on Circles
Powered by GitBook
On this page
  • Subscribe
  • Query past events
  • Event types

Was this helpful?

Export as PDF
  1. Querying Circles profiles and data

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:

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

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

export type CirclesEvent =

// CrcV1 Events

| CrcV1_HubTransfer
| CrcV1_Signup
| CrcV1_OrganizationSignup
| CrcV1_Trust
| CrcV1_Transfer

// CrcV2 Events

 | CrcV2_InviteHuman
 | CrcV2_PersonalMint
 | CrcV2_RegisterGroup
 | CrcV2_RegisterHuman
 | CrcV2_RegisterOrganization
 | CrcV2_Stopped
 | CrcV2_Trust
 | CrcV2_TransferSingle
 | CrcV2_Erc20WrapperTransfer
 | CrcV2_Erc20WrapperDeployed
 | CrcV2_URI
 | CrcV2_ApprovalForAll
 | CrcV2_TransferBatch
 | CrcV2_RegisterShortName
 | CrcV2_UpdateMetadataDigest
 | CrcV2_CidV0
 | CrcV2_StreamCompleted
 | CrcV2_CreateVault
 | CrcV2_GroupMintSingle
 | CrcV2_GroupMintBatch
 | CrcV2_GroupRedeem
 | CrcV2_GroupRedeemCollateralReturn
 | CrcV2_GroupRedeemCollateralBurn
 | CrcV2_DepositDemurraged
 | CrcV2_DepositInflationary
 | CrcV2_WithdrawDemurraged
 | CrcV2_WithdrawInflationary
PreviousQuery Circles DataNextUtilising CirclesQuery Class

Last updated 2 months ago

Was this helpful?

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

source code