Sage Protocol supports two primary types of social relationships, which you can manage seamlessly using the provided React hooks:

Following Users (One-Way)

A one-way connection similar to platforms like X (Twitter), enabling you to follow other users: Following a User Using React Integration:
import { useUser } from '@sageprotocol/sdk/react';
import { useWallet } from '@suiet/wallet-kit';

function FollowUser({ ownedUserId, targetSharedUserId }) {
  const { follow } = useUser();
  const { account, signAndExecuteTransaction } = useWallet();

  const handleFollow = async () => {
    const result = await follow({
      amounts: [0, 0],                             // Required protocol fees (default: [0,0])
      followSharedUserId: targetSharedUserId,      // Target user's shared user object ID
      ownedUserId,                                 // Your owned user object ID
      self: account.address                        // Your wallet address
    });

    if (result.ok) {
      await signAndExecuteTransaction({ transaction: result.transaction });
      console.log("Successfully followed the user!");
    } else {
      console.error("Error following user:", result.err);
    }
  };

  return (
    <button onClick={handleFollow}>
      Follow User
    </button>
  );
}

export default FollowUser;

Friendships (Two-Way)

A mutual connection, akin to friend relationships on platforms like Facebook. You can initiate a friendship or accept incoming friend requests: Friending a User Using React Integration:
import { useUser } from '@sageprotocol/sdk/react';
import { useWallet } from '@suiet/wallet-kit';

function FriendUser({ sharedUserId, friendSharedUserId }) {
  const { friend } = useUser();
  const { account, signAndExecuteTransaction } = useWallet();

  const handleFriendRequest = async () => {
    const result = await friend({
      amounts: [0, 0],                              // Required protocol fees (default: [0,0])
      friendSharedUserId,                           // Target user's shared user object ID
      sharedUserId,                                 // Your shared user object ID
      self: account.address                         // Your wallet address
    });

    if (result.ok) {
      await signAndExecuteTransaction({ transaction: result.transaction });
      console.log("Friend request successful!");
    } else {
      console.error("Error sending friend request:", result.err);
    }
  };

  return (
    <button onClick={handleFriendRequest}>
      Send Friend Request
    </button>
  );
}

export default FriendUser;

Important Notes:

  • Protocol Fees: Currently defaulted to [0, 0] for all operations.
  • Transaction Handling: All actions require explicitly signing and executing transactions via connected user wallets.
  • IDs: Clearly distinguish between “owned” and “shared” user object IDs as per the SDK.