Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sageprotocol.xyz/llms.txt

Use this file to discover all available pages before exploring further.

Users can clearly express their identities by updating their profiles. Profile updates support markdown formatting and media asset references. All fields must be explicitly provided—if a field is intended to remain unchanged, pass its current value. Updating User Profiles using React Integration:
import { useUser } from '@sageprotocol/sdk/react';
import { useWallet } from '@suiet/wallet-kit';

function UpdateProfile({ ownedUserId, currentProfile }) {
  const { update } = useUser();
  const { account, signAndExecuteTransaction } = useWallet();

  const handleUpdateProfile = async () => {
    const result = await update({
      amounts: [0, 0],                             // Required, typically [0, 0]
      avatar: currentProfile.avatar,               // Blob ID for avatar (existing or new ID)
      banner: currentProfile.banner,               // Blob ID for banner (existing or new ID)
      description: "Blockchain enthusiast and Web3 developer",  // Markdown-supported description
      name: currentProfile.name,                   // Username casing updates only
      ownedUserId,                                 // User's owned object ID
      self: account.address                        // User's wallet address
    });

    if (result.ok) {
      await signAndExecuteTransaction({ transaction: result.transaction });
      console.log("Profile updated successfully!");
    } else {
      console.error("Profile update error:", result.err);
    }
  };

  return (
    <button onClick={handleUpdateProfile}>
      Update Profile
    </button>
  );
}

export default UpdateProfile;
const updateUserResult = await sageClient.updateUser({
  amounts: [0, 0],                                   // Required, typically [0, 0]
  avatar: currentProfile.avatar,                     // Existing or new avatar blob ID
  banner: currentProfile.banner,                     // Existing or new banner blob ID
  description: "Blockchain enthusiast and Web3 developer", // Markdown-supported description
  name: currentProfile.name,                         // Username casing updates only
  ownedUserId: 'your-owned-user-id',                 // User's owned user object ID
  self: walletAddress                                // User's wallet address
});

if (updateUserResult.ok) {
  await signAndExecuteTransaction({ transaction: updateUserResult.transaction });
  console.log("Profile updated successfully!");
} else {
  console.error("Profile update error:", updateUserResult.err);
}

Important Notes:

  • Complete Replacement: All fields must be provided explicitly for every update. Any field left out or mistakenly changed could unintentionally overwrite existing valuessage_sdk.
  • Username Casing Only: Username updates are limited strictly to casing changes (e.g., “john-doe” to “John-Doe”). New usernames cannot be assigned through updatessage_sdk.
  • Blob IDs for Media: Avatar and banner images must use Walrus blob IDs (numeric IDs), not URLssage_sdk.