Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Circles is a decentralized protocol designed to create and distribute fair and social money through personal currencies. At the core of the Circles project lies a simple yet powerful principle:
"Every person receives one Circle every hour, unconditionally."
Circles uses smart contracts, deployed on Gnosis Chain, for creation of personal and group Avatars and their currencies (CRC). Circles as a network works via trust connection. To join Circles 2.0, you would require an invitation from a human/personal avatar. The pathfinder service is deployed to find the optimal path between trust connections to exchange personal and group currencies. Circles smart contracts are based on ERC1155 multi-token standard for both personal avatars and group avatars.
Every person receives 1 CRC every hour, hence 24 CRC per single day. Circles undergo daily demurrage at a rate equivalent to 7% per year. Issuance for past days accounts for this demurrage, ensuring fair distribution over time.
This documentation will guide developers in understanding Avatars and using the Circles SDK.
In addition to individual CRC currencies, Circles has introduced the concept of Group Avatars and Currencies. The idea behind Group currencies is to social-economic value amongst groups, without the geographical bounds of where groups are generated or created. Group avatar tokens can't be minted based on time, rather depends on personal collateral.
If you want to become a part of group, you would require to be invited to the group itself by the group admin. Invitation to groups would be that you are simply trusting a human avatar. Now, in order to mint the group tokens, as a group member (human avatar in the group) you would require to trust the group address so that you can start accepting the tokens. When you are trusting a human, you are also trusting their personal tokens. You can currently mint group tokens based on the quantity of total personal tokens (CRC).
The current mint policy allows you to mint group tokens based on your total personal CRC tokens quantity that you hold as a human. In other words, your personal tokens would be swapped for your group tokens.
Developers Hub for building with Circles.
Our developer documentation portal provides comprehensive guide to build using Circles SDK, SDK references, contract addresses, and code examples to help you integrate Circles into your applications and build upon our ecosystem.
If you want to develop a server or client application that utilizes Circles, and allow you to utilize trust connection and personal/group currencies, then Circles SDK would be your entry point. Based on your need, you can pick to develop any avatar post initialization of SDK.
Circles relies on hub contracts for V1 and V2 that you can utilize directly within applications. These deployed contracts exist on Gnosis Chain and are required by the SDK for configuration and initialization.
Here are the deployed addresses for V1 hub and V2 hub that you should consider for configuration or building tools on Circles protocol:
V1 hub contract
0x29b9a7fbb8995b2423a71cc17cf9810798f6c543
V2 hub contract
0xc12C1E50ABB450d6205Ea2C3Fa861b3B834d13e8
Name registry
0xA27566fD89162cC3D40Cb59c87AAaA49B85F3474
Migration contract
0xD44B8dcFBaDfC78EA64c55B705BFc68199B56376
Base mint policy
0xcCa27c26CF7BAC2a9928f42201d48220F0e3a549
If you want to skip directly to setting up Circles SDK in your application, you can jump to the SDK Configuration Guide which covers all the setup parameters.
To collaborate with fellow developers, ask questions, and share your insights, join our technical community channels on Discord, GitHub, and other platforms.
Join Telegram Group as a Hacker or a Developer.
Pathfinder
Finds liquid paths between two accounts in the trust network. These paths are used as input for the contract's transfer methods.
Circles Nethermind Plug-in
Provides access to the Gnosis Chain and indexes Circles events for a seamless experience.
Circles V1 contract source code
Review the codebase for Circles Contracts V1, including all core features and specifications related to Hub Contract and minting.
Circles V2 contract source code
Review the codebase for Circles contracts V2 which follows ERC1155 standard, and manages personal, group and organisation avatars.
Circles V2 Reference docs
Explore the latest updates and functionalities of Circles v2.0 Contracts with detailed documentation.
The Circles SDK is a TypeScript library that allows you to integrate Circles protocol into your dApp to implement trust connections and offering the users of network to get socio-economic value.
As a developer, you can start from installing the SDK and supported packages.
Manage Signers: Use a contract runner (like MetaMask) to sign transactions.
Circles Configuration: Set up Circles-specific configuration (contract addresses, RPC endpoints).
Access Circles Data: Query data through the Circles RPC Query API, including balances, trust relations, and transaction histories.
Support for Circles V1 and V2 Hubs: Interact with both V1 and V2 of Circles protocol hubs for contract-related operations,
Pathfinder Client: Use the V1 and V2 Pathfinder for finding liquid paths in trust networks to facilitate transfers.
Profile Management: Store and retrieve profiles (human, group, organization) via the Circles profile service.
Avatar Management:
Retrieve avatars by their address.
Register human, group, and organization avatars in Circles V1 and V2.
Invitation Handling: Accept invitations to join the Circles network by specifying an inviter and providing profile data.
@circles-sdk/abi-v1
Provides the ABI for Circles V1 contracts.
Interact with Circles V1 smart contracts for transfers, minting, and managing trust relations.
@circles-sdk/abi-v2
Provides the ABI for Circles V2 contracts.
Interact with Circles V2 smart contracts for advanced features like group avatars, inflationary/demurrage tokens.
@circles-sdk/data
Wrapper around the Circles RPC Query API.
Query Circles-related data (balances, trust relationships, transaction histories) without direct contract interaction.
@circles-sdk/profiles
Manages Circles avatar profiles (human, group, organization).
Retrieve and store avatar profiles, manage trust relations, and handle identity in the Circles ecosystem.
@circles-sdk/adapter-ethers
Adapter to connect Circles SDK with Ethers.js.
Leverage Ethers.js for signing and sending transactions, connecting to wallets, and interacting with contracts.
ethers
Library for interacting with Ethereum-based blockchains.
Simplify blockchain interactions like sending transactions, querying data, and working with smart contracts. We would be using ethers v6 version for Circles SDK.
multihashes
Handles multihash algorithms for decentralized file storage.
Ensure compatibility with IPFS and manage content-addressable storage for file integrity in decentralized systems.
Circles is a decentralized protocol with a social and economic value for humans, communities and groups. Circles is not a crypto startup or product in general, but a collective effort to bring a fair distribution model for the money created, owned and shared by people.
Explore our developer documentation, and join us in our mission to create a fair and sustainable economy for all.
Each user generates tokens continuously at a rate of one Circle (CRC) per hour, ensuring equal opportunity regardless of when they join. This promotes fairness as everyone has a chance to accumulate Circles.
Circles operates on a trust-based model, forming a social graph where users trust each other's CRC tokens. Trusted tokens become fungible, creating a dynamic economy backed by genuine social connections.
Circles integrates a demurrage mechanism, applying a 7% annual fee on held tokens. This keeps the currency circulating, benefiting the overall economy and promoting continuous engagement within the community. For most human users, the fee is offset by the steady income of 1 CRC per hour. Organizations always have to pay the fee.
By decentralising the verification process and leveraging human judgment for trust, Circles addresses the issue of fake accounts. This fosters a secure and resilient ecosystem, where the authenticity of each user is ensured by their social connections rather than centralised authorities or algorithms.
Circles v2 allows for the creation of group currencies, enabling communities to share a currency that's backed by their members' personal tokens. This reduces risk, simplifies payments, and enhances market creation by aggregating individual tokens into a more stable group currency that's easy to integrate into existing protocols.
By joining the Circles developer community, you can play a crucial role in building a more equitable and inclusive financial system. You can build applications, support developers, and invite more people to join your trust network.
Circles is all about creating a fairer money system. Our current monetary system and most cryptocurrencies tend to benefit those with established wealth and market positions, making it challenging for newcomers to catch up. Wealth grows disproportionately for those already in the market, as time in the market often beats time to market.
Circles aims to solve this by ensuring equal opportunity for all. Each user continuously generates tokens at a rate of one Circle (CRC) per hour, regardless of when they join. Additionally, existing Circles incur a demurrage fee of 7% per year. By tying the issuance of tokens to time, a resource everyone has, Circles promotes fairness by giving everyone a chance to accumulate tokens and encouraging the active circulation of currency.
Circles employs a unique token issuance mechanism where each user generates their own currency (CRC) at a steady rate of one token per hour. The minting rules are encoded in the so-called Hub, a token factory from which all individual Circles tokens are created.
All tokens are automatically demurred at a rate of 7% per year.
For human users, the demurrage is offset by the steady income of new CRC. Only after minting for 80 years (roughly a human lifespan) or through economic activity can a person become negatively affected by demurrage. Once the person dies, no new tokens are minted and all of the person's tokens are subjected to demurrage.
The following graph visualizes the balance of an account over time, assuming no economic activity and continuous minting of all CRC.
If understood as a tax, then the tax would be negative at first (you get money), but once your balance reaches the threshold of 125.000 Circles, it turns positive (you loose money).
Circles v1 tokens adhere to the ERC20 token standard with added functionality for personal minting and a built-in allowance like mechanism for the Hub contract which is necessary to enable the path transfer functionality.
Circles v2 is built on the ERC1155 token standard. Here, the Hub uses a standard allowance to facilitate path transfers. The token metadata mimics as profile.
Circles v1 tokens have a built-in "dead man's switch" that permanently disables the minting of new tokens after 90 days of inactivity. This proved problematic, so in Circles v2, the mechanism was replaced by a limit that allows a maximum minting amount of 14 days' worth of Circles.
In both versions, minting can be stopped manually. This feature is used, for example, to ensure that users who migrate from v1 to v2 cannot mint in v1 before they are allowed to mint in v2.
Hub V2 Contract
An ERC-1155 standard contract for registeration of
human,
groups and
organisation avatars.
Manages trust relations, minting of personal CRC tokens, group currencies and demurrage.
Migration Contract
Allows transition from Legacy V1 hub avatars to V2 hub. Migration will lock V1 CRC tokens, stop minting V1 tokens and convert into V2 tokens.
Name Registry
NameRegistry contract manages names, symbols and metadata for avatars (humans, groups, and organizations).
The name would be of 12 characters with a base58 encoding and store metadata for avatar profiles.
Base Mint Policy
Base mint policy is standard contract is utilized group registration. Once registered the policy address is immutable for the group address. This is a reference implementation for minting, burning and redeeming the group currencies and developers can build their own custom policies as well.
Vaults
Vaults is a factor contract that holds the personal CRC collateral against the group currencies. Every group, there is single vault to query balance. This contract is deployed by Standard treasury and is utilized during redemption of group circles token.
Standard Treasury
The Standard Treasury handles minting and redemption of group Circles by managing collateral transfers. It ensures collateral is forwarded to the correct vault based on structured data from the Hub contract. Additionally, it verifies data during redemption to release or burn collateral as specified by the group's mint policy.
An avatar represents a Circles user.
Personal / Human Avatars
ERC-1155 standard avatars, which allows you to mint your personal Circles token (CRC) every hour, accumulating 24 CRC per day with an applied demurrage of 7%.
Group Avatars
Created by an owner, these avatars allow groups to trust human avatars within the group. Group tokens are utilized by collateralizing personal tokens, following the ERC-1155 standard.
Organization Avatars
As an organization, you are an avatar without any minting of new tokens. With your name and metadata file, which will be used for identification and can trust other avatars to receive Circles, with all owned Circles earned by avatars rather than minted.
This guide will help you get started with the Circles SDK. It shows how to use the Circles SDK with MetaMask.
Metamask Plugin installed in browser
Setup Gnosis Chain (Mainnet) and/or Chiado Chain (Testnet). Check out Gnosis Chain docs here.
If you have all prerequisites in place, start by installing the Circles SDK package and ethers v6 in your project using npm.
Then, import the necessary interfaces from the Circles SDK and Ethers.
CirclesConfig
for SDKCirclesConfig
defines the configuration settings needed to set up the SDK. You provide an object that follows this structure when initializing the SDK.
Circles is available on Gnosis Chain and Chiado Testnet. You need to specify the correct contract addresses and service endpoints for each environment.
v2PathfinderUrl?
The URL for the V2 Pathfinder service (if using V2).
pathfinderUrl?
The URL for the Pathfinder service (used in V1).
circlesRpcUrl
The URL for the Circles RPC service
profileServiceUrl?
The URL for the profile service that manages user profiles in Circles.
v1HubAddress
The contract address for the Circles V1 Hub.
v2HubAddress?
The contract address for the Circles V2 Hub.
nameRegistryAddress?
The address of the name registry contract.
migrationAddress?
The address used for migrating avatars and tokens from V1 to V2.
baseGroupMintPolicy?
The address of the minting policy used for group avatars in Circles.
Circles contracts are deployed on Gnosis Chain mainnet. The below config is for applications that would be built in production environment.
RINGS is a sandbox version of Circles protocol. If you are a builder or developer who is building on Circles for fun and want to see how the overall mechanics work - then this would be your place to begin.
To setup provider and signer, we would utilize the Circles Adapter that is built to support transactions via ethers. Once you have already imported the BrowserProviderContractRunner
, you would need to initialize it.
To initialize the CirclesSDK, we will pass on the CirclesConfig
and Adapter
to SDK instance.
Once you have successfully created a SDK instance, you are all set to use Circles in your dApp. Let's learn more about the Circles SDK features and how you can use them on the next pages.\
Personal / Human Avatars
ERC-1155 standard avatars, which allows you to mint your personal Circles token (CRC) every hour, accumulating 24 CRC per day with an applied demurrage of 7%.
Group Avatars
Created by an owner, these avatars allow groups to trust human avatars within the group. Group tokens are utilized by collateralizing personal tokens, following the ERC-1155 standard.
Organization Avatars
As an organization, you are an avatar without any minting of new tokens. With your name and metadata file, which will be used for identification and can trust other avatars to receive Circles, with all owned Circles earned by avatars rather than minted.
Circles is built around the ERC1155 token standard which allows tokens to have metadata. Since Circles is all about personal currency, it makes sense to utilize this metadata as a profile.
The profile data is stored in IPFS and the Circles avatar references the CIDv0 of the profile on-chain.
The schema is very simple and only has one required attribute:
You can include a profile picture in the profile document (the previewImageUrl
). If you choose to do so, make sure the picture you are using has the following properties:
Format: The image must be in PNG, JPEG, or GIF format.
Dimensions: The image must be exactly 256x256 pixels.
File size: The image must not exceed 150KB.
Encoding: The image must be base64 encoded and included as a data URL in the previewImageUrl
field.
These requirements are enforced by the server to ensure consistency and performance across the platform.
Here is a code example (Browser; TypeScript) that shows how you can prepare the previewImageUrl.
Profiles that don't adhere to the spec aren't considered and won't be served by Circles' profile service.
Circles v2.0 will allow you to join the network as a human with a token ERC 1155 standard. You would have a profile and would require to be invited to join the network and start minting personal CRC tokens.
The V2 Hub contract is the main smart contract that a user would interact. You would need a profile CID as well.
Incase, you don't have CID, you can use the Profile
object and implicitly use the Circles pinning service to pin it:
If you have the address of an existing avatar, you can get an instance by calling sdk.getAvatar(address)
. It returns either an AvatarInterface
instance or throws an error if the avatar can't be found.
Circles v2.0 allows you to join the network as a human with an ERC-1155 standard token. You would have a profile and would require to be invited to join the network and start minting personal CRC tokens.
The V2 Hub contract is the main smart contract that a user would interact. You would need a profile CID as well.
Incase, you don't have CID, you can use the Profile
object and implicitly use the Circles pinning service to pin it:
This function will allow you to get maximum amount of CRC tokens that are available to mint at that point of time. Human avatars can mint only upto 24 personal Circles per day.
This function will allow you to mint your personal CRC tokens
In Circles, money is generated collectively by many individuals over time rather than by a central authority at specific events.
When you become part of the Circles network, every person has their own personal Circles token and receives one Circle (CRC) per hour, unconditionally.
The trust network forms a social graph where each trust relationship acts as a link, allowing tokens to flow between individuals through these connections. This ensures that the value of Circles is supported by genuine social relationships, fostering a community-driven economy.
At the same time, this mechanism is an effective soft sybil protection, as it decentralises the verification process and relies on human judgment for trust, preventing fake accounts from compromising the network. Since the connections between Circles accounts have a limited capacity (defined by their balances of fungible tokens), this limits the impact of fake accounts that manage to get trusted by a credible member of the network to their direct surroundings.
Personal Currencies and Trust Path
Personal currencies are unique and require trust to be transferred to others. To send tokens, other users must first trust your personal currency. When someone trusts your tokens, they become fungible with their own tokens.
This fungibility allows for the transfer of tokens along a trust path, enabling transactions even between people who do not directly trust each other.
Group Currencies
Additionally, Circles v2 introduces support for group currencies, allowing communities to share a currency backed by their members' personal tokens.
This collective currency reduces risk, simplifies payments, and enhances market creation by aggregating individual tokens into a more stable and fungible group currency. Group currencies make it easier to integrate Circles into existing economic structures and protocols, further promoting a robust and interconnected community economy.
This function allows an avatar to trust another avatar or multiple avatars. Trusting an avatar means you are willing to accept Circles that have been issued by them. Once trusted, Circles transfers from the trusted avatar are allowed.
This function revokes trust from another avatar or multiple avatars. Once trust is revoked, the avatar will no longer accept Circles issued by the untrusted avatar. However, this will not impact Circles that were already received from the untrusted avatar.
This function checks if the current avatar is trusted by another avatar. It can be used to verify whether another avatar is willing to accept Circles issued by the current avatar.
This function retrieves all trust relationships of the current avatar. It returns an array of trust relations indicating which avatars are trusted, which avatars trust the current avatar, and which relationships are mutual.
This function fetches the total Circles balance of the avatar. It checks the balance from either the v1 or v2 versions of Circles, depending on which version the avatar is using.
This function retrieves the avatar's token balances. Before calling this function, ensure that the system is initialized. It returns a promise that resolves to an array of TokenBalanceRow
objects, each representing the balances for different tokens associated with the avatar in the current context.
This section is dedicated to handling the profiles of an avatar
This function fetches the current profile associated with the avatar. If no profile exists, it will return undefined
.
This function updates the avatar's metadata by uploading a new content identifier (CID) to IPFS. The CID represents the new metadata for the avatar.
This function updates the avatar’s profile and returns the IPFS CID of the newly updated profile.
Utilizes the pathfinder to find the maximum Circles amount that can be transferred from this Avatar to the specified avatar. The address of the avatar passed would be the one to which the Circles will be transferred.
This function will allow you to transfer CRC tokens to the avatars with a valid trust path. The maximum transferable amount can be lower than the avatar's balance depending on its trust relations and token holdings.
You would be requiring to initialize the Circles data property to find groups and get memberships.
Otherwise you can create an instance like this:
Functionality: This method allows you to fetch a list of groups from the Circles system, with options for pagination and filtering. This is useful for applications that need to display groups or for querying specific groups based on certain criteria.
Parameters:
pageSize
: A number specifying how many groups should be returned in the response.
params
: An optional parameter that can include various filters for the query, such as group types or statuses.
This method is designed to fetch all group memberships associated with a specific avatar. This is useful for applications that want to display or manage the groups that a user belongs to.
Parameters:
avatar
: A string representing the address of the avatar for which group memberships are being requested.
pageSize
: A number that specifies the maximum number of group memberships to return.
To create a group following the ERC1155 standard, which allows you to utilize personal tokens as a collateral and mint group tokens, you would require to call the following function.
Your wallet should not have been signed up as a different avatar and once connected to SDK would be registered as s a group avatar in Circles v2.
To invite group members, you need to trust them. Trusting them would simply mean that you are inviting them to join group and would be accepting their personal token as collateral. Now, once invited, a group member will require to trust the group avatar address so that they can mint the group tokens.
This method allows a group to mint new Group Circles using trusted collateral tokens. The group specifies which collateral to use and the corresponding amounts.
To access the entire codebase for building frontend applications using React and Circles SDK, check out the Github repo here.
This method retrieves the total amount of Circles associated with the avatar, which can be either Personal Circles or Group Circles, depending on the calling context.
Organizations are different from groups as you can't mint an organization token, use profiles and trust other avatars to receive tokens from them.
Retrieve user profile data using the Profiles Nethermind plugin. You can:
Create new user profiles
Search existing profiles using parameters such as:
Name
CID (Content Identifier)
Description
Wallet Address
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.
To subscribe, you need an initialized CirclesData class.
Then call the subscribeToEvents()
method and supply the address of the avatar to subscribe to:
If you want to subscribe to all events, call it without parameter:
If your client missed some events, you can query all events for a specific avatar in a block range.
You can omit the last parameter (toBlock
) to query from fromBlock
to the latest block:
The above methods yield CirclesEvent
s. 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.
The CirclesData class provides an easy-to-use selection of common queries that are suitable for most use cases.
Most of the previously shown avatar methods internally use the CirclesData
class with filters for the current avatar address. If you already have a configured Sdk
instance, you can use the sdk.data
property to access the class:
Otherwise you can create an instance like this:
The getAvatarInfo(avatar: string): Promise<AvatarRow | undefined>
method finds basic information about an avatar. This includes the signup timestamp, circles version, avatar type (human, organization or group), and token address/id as well as it's profile CID (if any).
This method is useful to check if an avatar exists before using .
The getTokenInfo(tokenId: string): Promise<TokenInfoRow | undefined>
methods finds basic information about a Circles token. This includes the creation timestamp, circles version, token type (human or group) and the address of the avatar that created the token.
The total Circles balance of an avatar is the sum of all it's personalized and group token holdings. It can be queried with the getTotalBalance(avatar:string): Promise<string>
method. There is a separate method for each Circles version.
In contrast to the above method, the getTokenBalances(avatar: string): Promise<TokenBalanceRow[]>
method gives a detailed overview of an avatar's Circles holdings. As with the method above, this one also exists for both versions of the Circles protocol.
The result row contains the token
, balance
and the tokenOwner
.
The getTransactionHistory(avatar: string, pageSize: number): CirclesQuery<TransactionHistoryRow>
method can be used to query all incoming and outgoing Circles transfers from and to an avatar. This includes minting and transfers of personal and group Circles for v1 and v2.
The result rows have the following properties:
timestamp
When the transaction happened
transactionHash
version
If the transaction happened in Circles v1 or v2
operator
(the operator that facilitated the transaction - v2 only)
from
the sender address
to
the receiver address
id
in v1: the token address, in v2: the token id
value
the transferred raw value for the given version (bigint)
timeCircles
a floating point number representation of the value
for display purposes
tokenAddress
an address representation of the numeric tokenid (v2) or the actual erc20 token address of a v1 personal token
The results are ordered in descending order.
The getTrustRelations(avatar: string, pageSize: number): CirclesQuery<TrustListRow>
method can be used to query the effective trust events for an avatar. Already expired or removed trust relations are omitted from the results.
In contrast to the above method, this method queries all relevant trust events and groups mutual trust events into a single row instead of one for each direction.
The result rows have the following properties:
subjectAvatar
The acting avatar
relation
The relation between the acting avatar and the one it's related to
objectAvatar
The other avatar
The possible relations are: trusts
, trustedBy
, mutuallyTrusts
, and selfTrusts
. The last one (selfTrusts
) exists because, in Circles, every avatar trusts itself.
Circles groups have a name and symbol that's stored on-chain. You can use the findGroups(pageSize: number, params: GroupQueryParams): CirclesQuery<GroupRow>
method to find groups by name or symbol.
The params
parameter can be used to filter and order the result set by the name
and symbol
of a group.
Use the method as following:
You can query the group memberships of an avatar using the getGroupMemberships(avatar: string, pageSize: number): CirclesQuery<GroupMembershipRow>
method to get a list of all groups an avatar is a member of.
The result rows contain the following properties: group
, member
, expiryTime
.
Avatars can invite others to join Circles. The getInvitations(avatar: string, pageSize: number): CirclesQuery<InvitationRow>
method returns a list of invitations sent by the specified avatar.
Th e result rows contain the follwing properties: timestamp
, transactionHash
, inviter
, invited
.
You can query who invited an other avatar by calling getInvitedBy(avatar:string): Promise<string|undefined>
. If the avatar wasn't invited, the method returns undefined.
The CirclesQuery class allows you to execute custom queries against the Circles RPC api.
The previously shown CirclesData
class returns CirclesQuery<T>
objects for all paged query results. You can execute custom queries against all tables in the Circles index and filter with them.
First you'll need to define a query. The basic structure of a query is the same as for a basic SQL select. It has the following fields:
namespace
: Used to distinguish between tables and views as well and to tell the tables of the two Circles version apart from each other.
table
: The name of the table you want to query.
columns
: A list of column names you want to select.
filter
: A list of filter conditions that must be met.
sortOrder
: Can be 'asc' or 'desc'.
limit
: How many rows to return (max: 1000).
Here is a query that reads all avatars with type group
. Other avatar types you can try are human
and organization
.
If you want to be able to load the next page (queryNextPage()
) you must always include the following fields in your query:blockNumber
, transactionIndex,
logIndex.
You can define a type for the rows of your query, or just go with any
if the type doesn't matter.
If you want to specify a custom type, it must extend the EventRow
type. The EventRow
type contains the blockNumber
, transactionIndex
and logIndex
fields which are required for pagination.
To execute the query definition, you'll need a CirclesRpc
instance. Create one and pass the Circles rpc url to the constructor.
Then create a CirclesQuery<MyGroupType>
instance.
Call getNextPage()
to retrieve the first page of the result set. You can then access the results through the currentPage
property. This property includes the results
themselves, along with firstCursor
, lastCursor
, limit
, size
, and sortOrder
.
You can extend the CirclesQuery with computed columns. Computed columns are defined by a callback that takes in the row and returns a new value. Here we convert the value of the previously queried cidV0Digest
field (which is originally a hex-string) to a CID in Qm..
format.
The new column should be added to the custom type.
Then you can execute the query just like you did before. The calculated column function will be executed for each row in a page.
Check out the documentation of the for a list of tables.
Gets an avatar instance by its address.
Parameters:
avatarAddress
: The avatar’s wallet address.
subscribe
: Optional, whether to subscribe to avatar events.
Returns: A Promise
that resolves to an Avatar
instance.
Usage Example:
Accepts an invitation to join Circles using either CID or Profile.
Parameters:
inviter
: The address of the inviting avatar.
cidV0
: The CIDv0 of the avatar’s metadata (or profile
data).
Returns: A Promise
resolving to an AvatarInterface
.
Usage Example:
Registers the connected wallet as a human avatar in Circles V1.
Returns: A Promise
resolving to an AvatarInterface
, representing the registered human avatar.
Usage Example:
Registers the connected wallet as an organization avatar in Circles V1.
Returns: A Promise
resolving to an AvatarInterface
for the organization avatar.
Usage Example:
Registers the connected wallet as an organization avatar in Circles V2 with profile data.
Parameters:
profile
: A Profile
object representing the organization’s profile.
Returns: A Promise
resolving to an AvatarInterface
.
Usage Example:
Registers the connected wallet as a group avatar in Circles V2 with profile data.
Parameters:
mint
: Address of the minting policy contract.
profile
: A GroupProfile
object containing group information.
Returns: A Promise
resolving to an AvatarInterface
.
Usage Example:
Migrates a V1 avatar and its Circles holdings to V2.
Parameters:
avatar
: The address of the avatar to migrate.
profile
: Profile data of the avatar.
trustRelations
: Optional, a list of trust relations to migrate.
Returns: A Promise
resolving to void
.
Usage Example:
Creates or updates a user profile in Circles.
Parameters:
profile
: A Profile
object or a CID string pointing to the profile.
Returns: A Promise
that resolves to a ContractTransactionReceipt
.
Usage Example:
Migrates all V1 token holdings of an avatar to V2.
Parameters:
avatar
: The avatar whose tokens need to be migrated.
tokens
: Optional list of token addresses.
Returns: A Promise
resolving to void
.
Usage Example:
Gets an inflationary wrapper for managing tokens.
Parameters:
wrapperAddress
: Address of the inflationary wrapper contract.
Returns: A Promise
resolving to InflationaryCircles
.
Usage Example:
This function retrieves a demurrage wrapper, which is used to manage tokens that decrease in value over time (demurrage).
wrapperAddress
: The address of the demurrage wrapper contract.
Returns : A Promise
that resolves to an instance of DemurrageCircles
.
Usage Example:
CirclesBaseEvent
This is the base type for all Circles events. It contains common metadata for all events.
$event: CirclesEventType
— The event type, defining which event occurred.
blockNumber: number
— The block number in which the event was logged.
timestamp: number
(optional) — The timestamp when the event occurred.
transactionIndex: number
— Index of the transaction in the block.
logIndex: number
— Index of the log within the transaction.
transactionHash: string
(optional) — The hash of the transaction that emitted this event.
CrcV1_HubTransfer
Triggered when a transfer of Circles tokens happens via the Circles Hub.
$event: 'CrcV1_HubTransfer'
from: string
(optional) — Address sending the tokens.
to: string
(optional) — Address receiving the tokens.
amount: bigint
(optional) — Amount of tokens transferred.
CrcV1_Signup
Triggered when a new user signs up in the Circles system.
$event: 'CrcV1_Signup'
user: string
(optional) — Address of the new user.
token: string
(optional) — The token assigned to the user.
CrcV1_OrganizationSignup
Triggered when an organization signs up.
$event: 'CrcV1_OrganizationSignup'
organization: string
(optional) — Address of the organization.
CrcV1_Trust
Emitted when a trust relationship is created.
$event: 'CrcV1_Trust'
canSendTo: string
(optional) — The address that can receive tokens from the user.
user: string
(optional) — The user creating the trust.
limit: bigint
(optional) — The limit up to which the user can send tokens.
CrcV1_Transfer
Triggered when a token transfer occurs in the Circles V1 system.
$event: 'CrcV1_Transfer'
tokenAddress: string
(optional) — Address of the token.
from: string
(optional) — Address sending the tokens.
to: string
(optional) — Address receiving the tokens.
amount: bigint
(optional) — Amount of tokens transferred.
CrcV2_InviteHuman
Triggered when a human is invited to Circles.
$event: 'CrcV2_InviteHuman'
inviter: string
(optional) — Address of the inviter.
invited: string
(optional) — Address of the invited human.
CrcV2_PersonalMint
Triggered when a personal minting event occurs.
$event: 'CrcV2_PersonalMint'
human: string
(optional) — Address of the human minting tokens.
amount: bigint
(optional) — Amount of tokens minted.
startPeriod: bigint
(optional) — Start of the minting period.
endPeriod: bigint
(optional) — End of the minting period.
CrcV2_RegisterGroup
Triggered when a group is registered.
$event: 'CrcV2_RegisterGroup'
group: string
(optional) — Address of the group.
mint: string
(optional) — Address of the mint.
treasury: string
(optional) — Address of the treasury.
name: string
(optional) — Name of the group.
symbol: string
(optional) — Symbol for the group.
CrcV2_RegisterHuman
Triggered when a human registers in Circles.
$event: 'CrcV2_RegisterHuman'
avatar: string
(optional) — Avatar of the registered human.
inviter: string
(optional) — Address of the inviter.
CrcV2_RegisterOrganization
Triggered when an organization is registered.
$event: 'CrcV2_RegisterOrganization'
organization: string
(optional) — Address of the organization.
name: string
(optional) — Name of the organization.
CrcV2_Stopped
Triggered when an avatar stops its activity.
$event: 'CrcV2_Stopped'
avatar: string
(optional) — Avatar that stopped.
CrcV2_Trust
Triggered when a trust relationship is established in Circles V2.
$event: 'CrcV2_Trust'
truster: string
(optional) — The address of the truster.
trustee: string
(optional) — The address of the trustee.
expiryTime: bigint
(optional) — Expiry time of the trust relationship.
CrcV2_TransferSingle
Triggered during a single token transfer in Circles V2.
$event: 'CrcV2_TransferSingle'
operator: string
(optional) — Address of the operator.
from: string
(optional) — Address sending the token.
to: string
(optional) — Address receiving the token.
id: bigint
(optional) — ID of the token being transferred.
value: bigint
(optional) — Value of the token transferred.
CrcV2_URI
Triggered when a token's URI is updated.
$event: 'CrcV2_URI'
value: string
(optional) — The new URI value.
id: bigint
(optional) — ID of the token with the updated URI.
CrcV2_ApprovalForAll
Triggered when an account gives or revokes permission to an operator.
$event: 'CrcV2_ApprovalForAll'
account: string
(optional) — The account giving or revoking permission.
operator: string
(optional) — The operator being granted or revoked permission.
approved: boolean
(optional) — Whether the approval was granted (true
) or revoked (false
).
CrcV2_TransferBatch
Triggered during a batch transfer in Circles V2.
$event: 'CrcV2_TransferBatch'
batchIndex: number
— Index of the batch.
operator: string
(optional) — Address of the operator.
from: string
(optional) — Address sending the tokens.
to: string
(optional) — Address receiving the tokens.
id: bigint
(optional) — ID of the token being transferred.
value: bigint
(optional) — Value of the tokens transferred.
CrcV2_RegisterShortName
Triggered when a short name is registered to an avatar.
$event: 'CrcV2_RegisterShortName'
avatar: string
(optional) — Avatar registering the short name.
shortName: bigint
(optional) — The registered short name.
nonce: bigint
(optional) — The nonce of the registration.
CrcV2_UpdateMetadataDigest
Triggered when an avatar's metadata digest is updated.
$event: 'CrcV2_UpdateMetadataDigest'
avatar: string
(optional) — Avatar updating the metadata.
metadataDigest: Uint8Array
(optional) — The new metadata digest.
CrcV2_CidV0
Triggered when an avatar's CID (Content Identifier) for metadata is updated.
$event: 'CrcV2_CidV0'
avatar: string
(optional) — Avatar updating the CID.
cidV0Digest: Uint8Array
(optional) — The new CID v0 digest.
CrcV2_StreamCompleted
Triggered when a streaming payment or data transfer is completed.
$event: 'CrcV2_StreamCompleted'
operator: string
(optional) — Address of the operator.
from: string
(optional) — Address sending the streamed payment.
to: string
(optional) — Address receiving the streamed payment.
id: bigint
(optional) — ID of the streamed token.
amount: bigint
(optional) — Total amount streamed.
CrcV2_CreateVault
Triggered when a vault is created.
$event: 'CrcV2_CreateVault'
vault: string
(optional) — Address of the vault.
token: string
(optional) — Address of the token stored in the vault.
Circles Data class provides various methods to query and interact with Circles' data, such as balances, transaction history, trust relations, group memberships, and avatar information. It is built around the Circles RPC to facilitate communication with the blockchain and retrieve relevant data. The CirclesData
class exposes methods for both CRCv1 and CRCv2 tokens, trust events, and group information, as well as subscriptions to events.
getTotalBalance
Gets the total CRC V1 balance of an address.
Parameters:
avatar
: The address to get the CRC balance for.
asTimeCircles
(optional): Return the balance as TimeCircles or not (default is true
).
Returns:
A Promise<string>
representing the total balance.
Usage Example:
getTotalBalanceV2
Gets the total CRC V2 balance of an address.
Parameters:
avatar
: The address to get the CRC balance for.
asTimeCircles
(optional): Return the balance as TimeCircles or not (default is true
).
Returns:
A Promise<string>
representing the total balance.
Usage Example:
getTokenBalances
Gets the detailed token balances of an address.
Parameters:
avatar
: The address to get the token balances for.
Returns:
A Promise<TokenBalanceRow[]>
containing the token balances.
Usage Example:
getTransactionHistory
Gets the transaction history of an address (incoming/outgoing transactions and CRC minting).
Parameters:
avatar
: The address to get the transaction history for.
pageSize
: The maximum number of transactions per page.
Returns:
A CirclesQuery<TransactionHistoryRow>
object.
Usage Example:
getTrustRelations
Gets the current incoming and outgoing trust relations of an address.
Parameters:
avatar
: The address to get the trust list for.
pageSize
: The maximum number of trust relations per page.
Returns:
A CirclesQuery<TrustListRow>
object.
Usage Example:
getAggregatedTrustRelations
Gets all trust relations of an avatar and groups mutual trust relations together.
Parameters:
avatarAddress
: The address to get the trust relations for.
Returns:
A Promise<TrustRelationRow[]>
representing the trust relations.
Usage Example:
getAvatarInfo
Gets basic information about an avatar.
Parameters:
avatar
: The address to check.
Returns:
A Promise<AvatarRow | undefined>
with the avatar info or undefined
if not found.
Usage Example:
getAvatarInfos
Gets basic information about multiple avatars.
Parameters:
avatars
: The addresses to check.
Returns:
A Promise<AvatarRow[]>
containing avatar information.
Usage Example:
getTokenInfo
Gets the token info for a given token address.
Parameters:
address
: The address of the token.
Returns:
A Promise<TokenInfoRow | undefined>
with the token info or undefined
if not found.
Usage Example:
subscribeToEvents
Subscribes to Circles events.
Parameters:
avatar
(optional): The avatar to subscribe to. If not provided, all events are subscribed to.
Returns:
A Promise<Observable<CirclesEvent>>
representing the event stream.
Usage Example:
getEvents
Gets the events for a given avatar in a block range.
Parameters:
avatar
(optional): The avatar to get the events for.
fromBlock
(optional): The starting block number.
toBlock
(optional): The ending block number.
eventTypes
(optional): Types of events to filter.
filters
(optional): Additional filter criteria.
sortAscending
(optional): Whether to sort events in ascending order.
Returns:
A Promise<CirclesEvent[]>
representing the events.
Usage Example:
getInvitations
Gets the invitations sent by an avatar.
Parameters:
avatar
: The avatar to get the invitations for.
pageSize
: The maximum number of invitations per page.
Returns:
A CirclesQuery<InvitationRow>
object.
Usage Example:
getInvitedBy
Gets the avatar that invited the given avatar.
Parameters:
avatar
: The address of the invited avatar.
Returns:
A Promise<string | undefined>
with the address of the inviting avatar or undefined
if not found.
Usage Example:
findGroups
Gets the list of groups.
Parameters:
pageSize
: The maximum number of groups per page.
params
(optional): Query parameters to filter groups.
Returns:
A CirclesQuery<GroupRow>
object.
Usage Example:
getGroupMemberships
Gets the group memberships of an avatar.
Parameters:
avatar
: The avatar to get the group memberships for.
pageSize
: The maximum number of group memberships per page.
Returns:
A CirclesQuery<GroupMembershipRow>
object.
Usage Example:
getMetadataCidForAddress
Gets the metadata CID for an address.
Parameters:
address
: The address to get the metadata CID for.
Returns:
A Promise<string | undefined>
with the CID or undefined
if not found.
Usage Example:
Here are some of the past hackathon projects built with Circles. You can use these as a reference or to get inspiration of what kind of applications to build.
BraceBuddy allows to onboard easily and in a fun way people to the Circles ecosystem with NFC!
Woleth is an easy to use EVM wallet embed into Telegram designed to build a Social Graph utilizing Circle's invite mechanism.
Famjam is a dapp that uses Circles to create a family currency to incentivize kids for good behaviour.
Voting with UBI is a dapp which implements a voting mechanism for DAOs by utilizing Circles group tokens.
This glossary contains terms and definitions used throughout the Circles documentation.
ERC-1155 is an Ethereum token standard that enables the efficient transfer and bundling of multiple fungible and non-fungible tokens in a single transaction. This multi-token standard allows for the creation of complex token systems, such as those used in gaming or supply chain management, where different types of tokens need to be managed simultaneously.
The standard introduces a new set of functions, including safeTransferFrom
, safeBatchTransferFrom
, and balanceOfBatch
, which allow for the transfer and querying of multiple token balances in a single call. This reduces gas costs and simplifies token management compared to using multiple ERC-20 or ERC-721 contracts.
ERC-1155 tokens are identified by a unique combination of an address and an ID, allowing for the creation of an unlimited number of token types within a single contract. The standard also includes an optional metadata extension, enabling developers to associate additional information, such as images or descriptions, with each token type.
See also:
An externally-owned account (also known as EOA) is one of the two types of Ethereum accounts. A private key controls it; it has no code, and users can send messages by creating and signing Ethereum transactions.
See also:
See also:
A blockchain network is a collection of interconnected computers that utilize a blockchain protocol for communication. Decentralized networks allow users to send transactions, that are processed on a distributed ledger with a consensus mechanism ensuring the batching, verification, and acceptance of data into blocks. This structure enables the development of applications without the need for a central authority or server.
See also:
See also:
See also:
Safe is a smart contract wallet that requires a minimum number of people to approve a transaction before it can occur (M-of-N). If for example you have 3 main stakeholders in your business, you are able to set up the wallet to require approval from 2 out of 3 (2/3) or all 3 people before the transaction is sent. This assures that no single person could compromise the funds.
See also:
Some common features that smart accounts offer to their users are:
Multi-signature scheme
Transaction batching
Account recovery
Safe is one of the most trusted implementations of a smart account.
See also:
The threshold of a Safe account is a crucial configuration element that enables using Safe as a multi-signature smart account. It defines the number of required confirmations from the Safe owners a (Safe) transaction must have to be executable.
See also:
A wallet is an interface or application that gives users control over their blockchain account. Wallets allow users to sign in to applications, read their account balance, send transactions, and verify their identity.
See also:
The Circles SDK provides a high-level interface for interacting with the Circles protocol, focusing on features like user profiles, avatars, token transfers, and contract interactions. It integrates with Circles V1 and V2 hubs, and enables registration, migration, and management of avatars and profiles.
Sdk
This class implements the SdkInterface
, which provides core functionality to interact with the Circles protocol.
The Sdk
class implements the following interface:
Parameters:
contractRunner
: An instance of SdkContractRunner
, which is responsible for signing transactions.
config
: Optional, an instance of CirclesConfig
, containing chain-specific configurations (addresses and endpoints).
Avatar
: Represents the Circles avatar with methods for interacting with its state.
CirclesConfig
: Holds chain-specific configurations such as contract addresses and RPC endpoints.
Pathfinder
: Provides routing for token transfers on the Circles network.
Profiles
: Manages avatar profiles within Circles.
ContractTransactionReceipt
: Used to manage transactions and their receipts on the Ethereum blockchain.
on ethereum.org
on ethereum.org
Gasless transactions (also known as meta-transactions) are Ethereum transactions that are executed by a third party called on behalf of a to abstract the use of gas. Users must sign a message (instead of the transaction itself) with information about the transaction they want to execute. A relayer will create the Ethereum transaction, sign and execute it, and pay for the gas costs. The main benefit is that users can interact with the blockchain without holding the native token in their account.
on docs.safe.global
on ethereum.org
A Safe owner is one of the accounts that control a given Safe. Only owners can manage the configuration of a Safe and approve transactions. They can be either or . The of a Safe defines how many owners need to approve a Safe transaction to make it executable.
on github.com
A relayer is a third-party service acting as an intermediary between users' accounts and . It executes transactions on behalf of users and covers the associated execution costs, which may or may not be claimed.
on docs.gelato.network
A smart account (also known as a smart contract account) leverages the programmability of smart contracts to extend its functionality and improve its security in comparison with . Smart accounts are controlled by one or multiple externally-owned accounts or other smart accounts, and all transactions have to be initiated by one of those.
A transaction is an action initiated by an to update the state of the EVM network. Transaction objects must be signed using the sender's private key, require a fee, and be included in a validated block.
A Safe transaction is a transaction sent to a Safe Proxy contract calling the method.
on ethereum.org
and of a Safe with the Safe{Core} SDK on docs.safe.global
on ethereum.org