Configure SuiClient, SealClient, and WalrusClient step by step and verify your connection to the network.
The SuiClient is your gateway to the Sui blockchain. It handles reading objects, querying events, and submitting transactions. You create one by providing a fullnode URL. The SDK includes getFullnodeUrl() to get the correct URL for any network. Let's set it up and verify the connection:
Sui has four networks: devnet (experimental, resets often), testnet (stable testing with free faucet tokens), mainnet (live production with real assets), and localnet (local node for offline development). Start with testnet for learning โ it has free tokens and a stable environment. Match each network to its purpose:
SealClient handles threshold encryption. It connects to Seal key servers that split encryption keys across multiple validators โ at least t-of-n must cooperate to decrypt, so no single server can read your messages. To create one, you pass your SuiClient plus a server object ID that identifies which Seal deployment to use. The server ID differs between testnet and mainnet.
WalrusClient stores and retrieves encrypted message blobs. It connects to Walrus aggregator and publisher nodes. The simplest setup only needs a network name and your suiClient โ Walrus auto-discovers the correct endpoints. For production apps, you can specify custom URLs.
Now combine all three clients into a MessagingClient. The constructor takes all three plus the current user's wallet address. Once created, this single client provides the full API: createChannel, sendMessage, getMessages, addMember, and more. All encryption and storage happens automatically.
Follow these practices when configuring your messaging client: match the network across all clients, create client instances once and reuse them via React context, store network-specific constants in environment variables, and always handle connection errors. Here's a production-ready setup pattern:
In React apps, initialize clients once in a context provider so all components can access them. This avoids creating redundant connections and ensures consistent configuration. Here's how to expose the messaging client via React context: