Fetching profile of an human avatar
This section is dedicated to handling/updating the profiles of an avatar.
Get a profile for the avatar
This function fetches the current profile associated with the avatar. If no profile exists, it will return undefined.
const profile = await inviteeAvatar.profile.get();
if (profile) {
console.log(profile.name, profile.description);
}Update profile of the avatar
This function pins JSON to the Profiles service and updates the metadata digest on-chain. Returns the new CID.
import type { Profile } from '@aboutcircles/sdk-types';
const newProfile: Profile = {
name: 'Avatar Name',
description: 'Updated description for the avatar.',
avatarUrl: 'ipfs://QmYourImageCIDHere', // optional
};
try {
const newCid = await inviteeAvatar.profile.update(newProfile);
console.log('Profile updated. New CID:', newCid);
} catch (err) {
console.error('Error updating profile:', err);
}If you already have your CID, you can use the function below to update the on-chain pointer:
Last updated
Was this helpful?