Use this file to discover all available pages before exploring further.
Users must follow channels to actively participate in them—such as posting, commenting, and liking content. Following establishes public membership within the community.React Hook Example for Following Channels:
import { useChannel } from '@sageprotocol/sdk/react';import { useWallet } from '@suiet/wallet-kit';function FollowChannel({ channelId, ownedUserId }) { const { follow } = useChannel(); const { account, signAndExecuteTransaction } = useWallet(); async function handleFollow() { const result = await follow({ amounts: [0, 0], // Required, typically [0, 0] appId: 'your-app-id', // Required application ID network: 'testnet', // 'testnet' or 'mainnet' channelId, // Channel ID to follow ownedUserId, // Follower's owned user object ID self: account.address // Follower's wallet address }); if (result.ok) { await signAndExecuteTransaction({ transaction: result.transaction }); console.log("Channel followed successfully!"); } else { console.error("Error following channel:", result.err); } } return <button onClick={handleFollow}>Follow Channel</button>;}export default FollowChannel;
Direct JavaScript Example for Following Channels
import { SageClient } from '@sageprotocol/sdk';const sageClient = new SageClient({ appId: 'your-app-id', // Required application ID channelRegistryId: 'your-registry-id', // Required channel registry ID network: 'testnet' // 'testnet' or 'mainnet'});await sageClient.initialize();async function followChannel(channelId, ownedUserId, walletAddress) { const result = await sageClient.followChannel({ amounts: [0, 0], // Required, typically [0, 0] channelId, // Channel ID to follow ownedUserId, // Follower's owned user object ID self: walletAddress // Follower's wallet address }); if (result.ok) { await signAndExecuteTransaction({ transaction: result.transaction }); console.log("Channel followed successfully!"); } else { console.error("Error following channel:", result.err); }}followChannel('your-channel-id', 'your-owned-user-id', walletAddress);