Users can post directly onto other usersโ profiles for interactions like endorsements, community appreciation, or personal engagement. Posts support rich markdown content.Posting to User Profiles Using React Integration:
Copy
import { usePost } from '@sageprotocol/sdk/react';import { useWallet } from '@suiet/wallet-kit';function PostToUser({ targetSharedUserId, ownedUserId }) { const { postToUser } = usePost(); const { account, signAndExecuteTransaction } = useWallet(); async function handlePostToUser() { const result = await postToUser({ amounts: [0, 0], // Required protocol fee amounts appId: 'your-app-id', // Required application ID network: 'testnet', // 'testnet' or 'mainnet' sharedUserId: targetSharedUserId, // Target user's shared user object ID ownedUserId, // Poster's owned user object ID self: account.address, // Wallet address of the poster title: '๐ Professional Recommendation', // Post headline/title (markdown supported) description: 'Endorsement for exceptional work', // Brief summary (markdown supported) data: 'Your contributions to the project were outstanding!' // Main markdown content }); if (result.ok) { await signAndExecuteTransaction({ transaction: result.transaction }); console.log("Posted to user profile successfully!"); } else { console.error("Error posting to user profile:", result.err); } } return <button onClick={handlePostToUser}>Post to User</button>;}export default PostToUser;
Posting to User Profiles Using Direct JavaScript Integration
Copy
const postResult = await sageClient.postToUser({ amounts: [0, 0], // Required protocol fee amounts appId: 'your-app-id', // Required application ID network: 'testnet', // 'testnet' or 'mainnet' sharedUserId: 'target-user-shared-id', // Target user's shared user ID ownedUserId: 'your-owned-user-id', // Poster's owned user ID self: walletAddress, // Poster's wallet address title: '๐ Professional Recommendation', // Post title in markdown description: 'Endorsement for exceptional work',// Markdown summary data: 'Your contributions to the project were outstanding!' // Main markdown content});if (postResult.ok) { await signAndExecuteTransaction({ transaction: postResult.transaction }); console.log("Posted to user profile successfully!");} else { console.error('Error posting to user profile:', postResult.err);}