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.
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 ;
Following a User Using Direct JavaScript Integration
const result = await sageClient . followUser ({
amounts: [ 0 , 0 ], // Required protocol fees (default: [0,0])
appId: 'your-app-id' , // Required application ID
network: 'testnet' , // 'testnet' or 'mainnet', required
followSharedUserId: 'target-user-shared-id' , // Target user's shared user ID
ownedUserId: 'your-owned-user-id' , // Your owned user object ID
self: walletAddress // 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 );
}
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 ;
Friending a User using Direct Javascript Integration
const friendResult = await sageClient . friendUser ({
amounts: [ 0 , 0 ], // Required protocol fees (default: [0,0])
appId: 'your-app-id' , // Required application ID
network: 'testnet' , // 'testnet' or 'mainnet', required
friendSharedUserId: 'friend-user-shared-id' , // Target user's shared user object ID
sharedUserId: 'your-shared-user-id' , // Your shared user object ID
self: walletAddress // Your wallet address
});
if ( friendResult . ok ) {
await signAndExecuteTransaction ({ transaction: friendResult . transaction });
console . log ( "Friend request successful!" );
} else {
console . error ( "Error sending friend request:" , friendResult . err );
}
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.