import type { Address, CirclesConfig, ContractRunner, Profile, TokenBalance } from '@aboutcircles/sdk-types'; import type { GroupTokenHolderRow } from '@aboutcircles/sdk-rpc'; import { Core } from '@aboutcircles/sdk-core'; import { CirclesRpc, PagedQuery } from '@aboutcircles/sdk-rpc'; import { HumanAvatar, OrganisationAvatar, BaseGroupAvatar } from './avatars/index.js'; import type { GroupType } from '@aboutcircles/sdk-types'; import type { CirclesData } from './types.js'; /** * Simplified Circles SDK * Provides a user-friendly API for non-crypto users with low entrance barrier * * @example * ```typescript * const sdk = new Sdk(); * * // Register as a human * const avatar = await sdk.register.asHuman('0xInviterAddress', { * name: 'Alice', * description: 'Developer' * }); * * // Get an avatar * const avatar = await sdk.getAvatar('0xAvatarAddress'); * * // Transfer tokens * await avatar.transfer.direct('0xRecipient', 100); * * // Mint personal tokens * await avatar.personalToken.mint(); * ``` */ export declare class Sdk { readonly circlesConfig: CirclesConfig; readonly contractRunner?: ContractRunner; readonly senderAddress?: Address; readonly core: Core; readonly rpc: CirclesRpc; private readonly profilesClient; private readonly referralsClient?; readonly data: CirclesData; /** * Create a new Sdk instance * * @param config Circles configuration (defaults to Gnosis Chain mainnet) * @param contractRunner Optional contract runner for executing transactions * @throws Error if contractRunner is provided but doesn't support sendTransaction or has no address */ constructor(config?: CirclesConfig, contractRunner?: ContractRunner); /** * Get an avatar by address * Automatically detects the avatar type and returns the appropriate avatar instance * * @param avatarAddress The address of the avatar to fetch * @param autoSubscribeEvents Whether to automatically subscribe to events for this avatar (default: false) * If true, waits for event subscription to complete before returning * @returns HumanAvatar, OrganisationAvatar, or BaseGroupAvatar depending on type */ getAvatar(avatarAddress: Address, autoSubscribeEvents?: boolean): Promise; /** * Registration methods for creating new Circles identities */ readonly register: { /** * Register as a human in the Circles ecosystem * * This function: * 1. Creates and uploads profile data to IPFS * 2. Registers the human with the profile CID * 3. Returns a HumanAvatar instance for the registered account * * Requirements: * - Contract runner must be configured to execute transactions * - An inviter address must be provided * * @param inviter Address of the inviting avatar * @param profile Profile data with name, description, etc. * @returns HumanAvatar instance for the newly registered human * * @example * ```typescript * const avatar = await sdk.register.asHuman('0xInviter', { * name: 'Alice', * description: 'Developer' * }); * ``` */ asHuman: (inviter: Address, profile: Profile | string) => Promise; /** * Register as an organization * Organizations can participate in Circles without minting personal tokens * and do not require invitations to register * * @param profile Profile data for the organization or CID string * @returns OrganisationAvatar instance for the newly registered organization * * @example * ```typescript * const orgAvatar = await sdk.register.asOrganization({ * name: 'My Organization', * description: 'A Circles organization' * }); * ``` */ asOrganization: (profile: Profile | string) => Promise; /** * Register a base group * Creates a new base group using the BaseGroupFactory and registers it in the Circles ecosystem * * @param owner The address that will own the newly created BaseGroup * @param service The address of the service for the new BaseGroup * @param feeCollection The address of the fee collection for the new BaseGroup * @param initialConditions An array of initial condition addresses * @param name The group name (must be 19 characters or fewer) * @param symbol The group symbol (e.g., 'MYG') * @param profile Profile data (name, description, images, etc.) or CID string * @returns BaseGroupAvatar instance for the newly registered group * * @example * ```typescript * const groupAvatar = await sdk.register.asGroup( * '0xOwnerAddress', * '0xServiceAddress', * '0xFeeCollectionAddress', * [], // initial conditions * 'My Group', // name * 'MYG', // symbol * { * name: 'My Group', * description: 'A Circles base group' * } * ); * ``` */ asGroup: (owner: Address, service: Address, feeCollection: Address, initialConditions: Address[], name: string, symbol: string, profile: Profile | string) => Promise; }; /** * Profile management methods */ readonly profiles: { /** * Create and pin a profile to IPFS * @param profile Profile data or CID string * @returns CID of the pinned profile */ create: (profile: Profile) => Promise; /** * Get a profile by CID * @param cid Content identifier * @returns Profile data or undefined if not found */ get: (cid: string) => Promise; }; /** * Referral/invitation management methods * * The referrals backend enables users to invite others via referral links. * Requires referralsServiceUrl to be configured in CirclesConfig. */ readonly referrals: { /** * Store a referral private key * * The private key is validated on-chain via ReferralsModule.accounts() to ensure * the account exists and has not been claimed. The inviter address is self-declared * for dashboard visibility only. * * @param privateKey - The referral private key (0x-prefixed, 64 hex chars) * @param inviter - Self-declared inviter address for dashboard visibility * @throws Error if referrals service not configured or validation fails */ store: (privateKey: string, inviter: Address) => Promise; /** * Retrieve referral info by private key * * This is a public endpoint - no authentication required. * Used by invitees to look up who invited them. * * @param privateKey - The referral private key * @returns Referral info including inviter and status * @throws Error if referrals service not configured or referral not found */ retrieve: (privateKey: string) => Promise; /** * List all referrals created by the authenticated user * * Requires authentication - must configure a token provider. * * @returns List of referrals with their status and metadata * @throws Error if referrals service not configured or not authenticated */ listMine: () => Promise; }; /** * Token utilities */ readonly tokens: { /** * Get an inflationary wrapper for a token * @param address Avatar address * @returns The ERC20 inflationary wrapper address, or zero address if not deployed */ getInflationaryWrapper: (address: Address) => Promise
; /** * Get a demurraged wrapper for a token * @param address Avatar address * @returns The ERC20 demurraged wrapper address, or zero address if not deployed */ getDemurragedWrapper: (address: Address) => Promise
; /** * Get token holders for a specific token address with pagination * @param tokenAddress The token address to query holders for * @param limit Maximum number of results per page (default: 100) * @param sortOrder Sort order for results (default: 'DESC' - highest balance first) * @returns PagedQuery instance for token holders * * @example * ```typescript * const holdersQuery = sdk.tokens.getHolders('0x42cedde51198d1773590311e2a340dc06b24cb37', 10); * * while (await holdersQuery.queryNextPage()) { * const page = holdersQuery.currentPage!; * console.log(`Found ${page.size} holders`); * page.results.forEach(holder => { * console.log(`${holder.account}: ${holder.demurragedTotalBalance}`); * }); * } * ``` */ getHolders: (tokenAddress: Address, limit?: number) => Promise>; }; /** * Group utilities */ readonly groups: { /** * Get the type of a group * @param avatar Group avatar address * @returns Group type or undefined if not a group */ getType: (avatar: Address) => Promise; /** * Get all members of a specific group using cursor-based pagination * * Returns a PagedQuery instance for iterating through members of the specified group, * including membership details such as expiry time and when the membership was created. * * @param groupAddress The address of the group to query members for * @param limit Number of members per page (default: 100) * @returns PagedQuery instance for iterating through group members * * @example * ```typescript * const query = sdk.groups.getMembers('0xGroupAddress...'); * * // Get first page * await query.queryNextPage(); * console.log(`${query.currentPage.size} members in the group`); * * // Iterate through all members * while (await query.queryNextPage()) { * query.currentPage.results.forEach(membership => { * console.log(`Member: ${membership.member}`); * console.log(`Expiry: ${new Date(membership.expiryTime * 1000).toLocaleDateString()}`); * }); * } * ``` */ getMembers: (groupAddress: Address, limit?: number) => Promise>; /** * Get collateral tokens in a group's treasury * * This convenience method fetches the treasury address of a group and returns * all token balances held in the treasury. * * @param groupAddress The address of the group * @returns Array of token balances in the treasury * * @example * ```typescript * // Get collateral tokens in a group treasury * const collateral = await sdk.groups.getCollateral('0xGroupAddress...'); * * collateral.forEach(balance => { * console.log(`Token: ${balance.tokenAddress}`); * console.log(`Balance: ${balance.circles} CRC`); * }); * ``` */ getCollateral: (groupAddress: Address) => Promise; /** * Get all holders of a group token using cursor-based pagination * * Returns all avatars that hold the specified group token, ordered by balance (highest first), * including balance amounts and ownership fractions. * * @param groupAddress The address of the group token * @param limit Maximum number of holders to return (default: 100) * @returns PagedQuery instance for iterating through group token holders * * @example * ```typescript * // Get all holders of a group token * const query = sdk.groups.getHolders('0xGroupAddress...'); * * // Get first page (ordered by balance DESC) * await query.queryNextPage(); * console.log(`${query.currentPage.size} holders of this group token`); * * // Iterate through all holders * while (await query.queryNextPage()) { * query.currentPage.results.forEach(holder => { * const balanceInCrc = Number(holder.totalBalance) / 1e18; * console.log(`Holder: ${holder.holder}`); * console.log(`Balance: ${balanceInCrc.toFixed(2)} CRC`); * console.log(`Ownership: ${(holder.fractionOwnership * 100).toFixed(2)}%`); * }); * } * ``` */ getHolders: (groupAddress: Address, limit?: number) => PagedQuery; }; } //# sourceMappingURL=Sdk.d.ts.map