Learn how to configure custom RPC endpoints for different Cosmos-based chains when using CosmJS with Para.

Prerequisites

Setup CosmJS Libraries

Configure Chain-Specific RPC

import { useCosmosClient } from "./useCosmosClient";

const CHAIN_CONFIGS = {
  cosmos: {
    rpc: "https://rpc.cosmos.network",
    prefix: "cosmos"
  },
  osmosis: {
    rpc: "https://osmosis-rpc.polkachu.com",
    prefix: "osmo"
  },
  celestia: {
    rpc: "https://celestia-rpc.publicnode.com",
    prefix: "celestia"
  },
  dydx: {
    rpc: "https://dydx-dao-rpc.polkachu.com",
    prefix: "dydx"
  }
};

function MultiChainExample() {
  const cosmosClient = useCosmosClient(CHAIN_CONFIGS.cosmos.rpc, CHAIN_CONFIGS.cosmos.prefix);
  const osmosisClient = useCosmosClient(CHAIN_CONFIGS.osmosis.rpc, CHAIN_CONFIGS.osmosis.prefix);
  
  const checkChainStatus = async () => {
    if (!cosmosClient.publicClient || !osmosisClient.publicClient) return;
    
    const cosmosHeight = await cosmosClient.publicClient.getHeight();
    const osmosisHeight = await osmosisClient.publicClient.getHeight();
    
    console.log("Cosmos block height:", cosmosHeight);
    console.log("Osmosis block height:", osmosisHeight);
  };

  return (
    <button onClick={checkChainStatus}>Check Chain Status</button>
  );
}

Next Steps