πŸ‘ΎUsing avatars

An avatar represents a Circles user.

The SDK is built around the concept of avatars. An avatar is a Circles user and is used to interact with other Avatars aka Circles users.

You can get an avatar in two ways:

  • Registering a new wallet at Circles via Sign Up,

  • Loading an existing avatar by it's address.

Create a new avatar

You will need a new Metamask account with some xDAI to be able to interact with contracts and follow along the steps. Make sure you configured MetaMask with the correct ChainID (Gnosis Chain or Chiado) before you continue.

To register a new Human

You can call registerHuman() method to sign the connected MetaMask account up for Circles and get your avatar address.

const avatar = await sdk.registerHuman();
console.log(avatar.avatarInfo);

There are different types of avatars within Circles. A human avatar is the most common and suitable for any person. It differentiates itself from all other avatar types in that it can mint 24 new personal Circles per day.

Get an existing avatar

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.

const avatar = await sdk.getAvatar(avatarAddress);
console.log(avatar.avatarInfo);

You can supply any avatar address to the function, even if you don't have the key for it. However, if you just want to query the data with the @circles-sdk/data package you can refer to this part of documentation.

Different Avatar types

Apart from Human Avatar you can also create Group and Orangization Avatar types. The technical details of same will be mentioned in later sections of docs. But here's how you can sign up as Group or Organization Avatar.

One account can only sign up as one avatar. E.g. if an account is already signed up as human then it can't sign-up as organization.

Organizations can be used e.g. by shop owners to receive payments in Circles. They are available in Circles v1 and v2. Organizations can't mint new Circles.

// v1:
const avatar = await sdk.registerOrganization();
// v2:
const avatar = await sdk.registerOrganizationV2();

Next steps

The next page will show you how to use the avatar instance to query essential data like the avatar's Circles balance, it's trust relations and transaction history. On the page after, we'll use it to interact with other avatars.

Full example

For a complete example that registers a human or organization account, check out the Circles SDK Svelte Examples on GitHub. Specifically the Using avatars route.

Last updated