Social Profiles
Managing Social Profiles with the VitalEarth SDK
The VitalEarth SDK provides powerful tools for creating and managing social profiles for your users. These profiles store valuable metadata about user activities, loyalty, and rewards, ensuring a consistent and engaging experience across all applications using the SDK.
Prerequisites
Before you can start managing social profiles, make sure you have completed the installation and initialization of the VitalEarth SDK, as explained in the previous steps.
Fetching User Profiles
To retrieve a user's profile based on their address, use the following code:
Explanation of the code:
Import the
profileClient
module from the VitalEarth SDK.Initialize the
client
object for profile management.Specify the user's address in the
userAddress
variable. Replace"0x123456789abcdef"
with the actual user's Ethereum address.Use
await client.getProfile(userAddress);
to fetch the user's profile based on their address.Check if the profile exists, and if it does, you can access and use the user's profile data as needed.
Creating User Profiles
If a user's profile does not exist, you can create one using the following code:
Explanation of the code:
Import the
profileClient
module from the VitalEarth SDK.Initialize the
client
object for profile management.Specify the user's address in the
userAddress
variable. Replace"0x123456789abcdef"
with the actual user's Ethereum address.Use
await client.createProfile(userAddress);
to create the user's profile if it does not exist.
By implementing these profile management functions in your application, you ensure that user profiles are created and accessible consistently across all apps using the Vitalearth SDK. This fosters a seamless and interconnected experience for users as they engage with various sustainability-focused applications.
Last updated