> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getpara.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure RPC Endpoints with Solana Libraries

> Set up and configure Solana RPC endpoints and connections using Web3.js or Anchor

Configure custom RPC endpoints for Solana to optimize performance, use private nodes, or connect to different networks. This guide covers RPC setup for all supported libraries.

<Card title="Setup Solana Libraries First" description="Configure Solana libraries with Para SDK before using these operations" href="/v3/react-native/guides/web3-operations/solana/setup-libraries" horizontal />

<Tabs>
  <Tab title="@solana/kit">
    ```typescript theme={null}
    import { useParaSolanaSigner } from "@getpara/react-native-wallet/solana";
    import { createSolanaRpc } from '@solana/kit';

    const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");

    // You can create multiple RPC connections for different networks
    const mainnetRpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
    const devnetRpc = createSolanaRpc('https://api.devnet.solana.com');
    const customRpc = createSolanaRpc('https://your-custom-rpc-endpoint.com');

    function ConfigureRpc() {
      // Pass the desired rpc to the hook
      const { solanaSigner, isLoading } = useParaSolanaSigner({ rpc: mainnetRpc });

      const checkHealth = async () => {
        const health = await mainnetRpc.getHealth().send();
        const version = await mainnetRpc.getVersion().send();
        return { health, version };
      };

      return (
        <div>
          <p>Signer address: {solanaSigner?.address}</p>
          <button onClick={checkHealth}>Check RPC Health</button>
        </div>
      );
    }
    ```
  </Tab>

  <Tab title="@solana/web3.js">
    ```typescript theme={null}
    import { ParaSolanaWeb3Signer } from '@getpara/solana-web3.js-v1-integration';
    import { Connection, clusterApiUrl, Commitment } from '@solana/web3.js';
    import { para } from './para';

    function useCustomRPC() {
      // Using Solana public RPC endpoints
      const mainnetConnection = new Connection(
        clusterApiUrl('mainnet-beta'),
        'confirmed'
      );

      const devnetConnection = new Connection(
        clusterApiUrl('devnet'),
        'confirmed'
      );

      // Using custom RPC endpoint (e.g., QuickNode, Alchemy, Helius)
      const customConnection = new Connection(
        'https://your-custom-rpc-endpoint.com',
        {
          commitment: 'confirmed',
          wsEndpoint: 'wss://your-custom-websocket-endpoint.com',
          httpHeaders: {
            'Authorization': 'Bearer YOUR_API_KEY',
          },
          disableRetryOnRateLimit: false,
          confirmTransactionInitialTimeout: 30000,
        }
      );

      // Create signers with different connections
      const mainnetSigner = new ParaSolanaWeb3Signer(para, mainnetConnection);
      const devnetSigner = new ParaSolanaWeb3Signer(para, devnetConnection);
      const customSigner = new ParaSolanaWeb3Signer(para, customConnection);

      // Example: Get network performance metrics
      const checkPerformance = async () => {
        const start = Date.now();
        const slot = await customConnection.getSlot();
        const latency = Date.now() - start;

        console.log('Current slot:', slot);
        console.log('RPC latency:', latency, 'ms');

        const perfSamples = await customConnection.getRecentPerformanceSamples(5);
        console.log('Recent performance:', perfSamples);
      };

      return { mainnetSigner, devnetSigner, customSigner, checkPerformance };
    }
    ```
  </Tab>

  <Tab title="Anchor">
    ```typescript theme={null}
    import { ParaSolanaWeb3Signer } from '@getpara/solana-web3.js-v1-integration';
    import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js';
    import * as anchor from '@coral-xyz/anchor';
    import { para } from './para';

    function useCustomAnchorProvider() {
      // Configure connection with custom options
      const connection = new Connection(
        'https://your-custom-rpc-endpoint.com',
        {
          commitment: 'confirmed',
          wsEndpoint: 'wss://your-custom-websocket-endpoint.com',
          httpHeaders: {
            'Authorization': 'Bearer YOUR_API_KEY',
          },
        }
      );

      const signer = new ParaSolanaWeb3Signer(para, connection);

      // Create Anchor wallet adapter
      const wallet = {
        publicKey: signer.sender,
        signTransaction: async <T extends Transaction | VersionedTransaction>(tx: T): Promise<T> => {
          return await signer.signTransaction(tx);
        },
        signAllTransactions: async <T extends Transaction | VersionedTransaction>(txs: T[]): Promise<T[]> => {
          return await Promise.all(txs.map((tx) => signer.signTransaction(tx)));
        },
      };

      // Create provider with custom options
      const provider = new anchor.AnchorProvider(
        connection,
        wallet,
        {
          commitment: 'confirmed',
          preflightCommitment: 'confirmed',
          skipPreflight: false,
        }
      );

      // Set as default provider
      anchor.setProvider(provider);

      // Example: Test connection
      const testConnection = async () => {
        const blockHeight = await connection.getBlockHeight();
        console.log('Current block height:', blockHeight);

        const epoch = await connection.getEpochInfo();
        console.log('Epoch info:', epoch);

        const supply = await connection.getSupply();
        console.log('Total supply:', supply);
      };

      return { provider, testConnection };
    }
    ```
  </Tab>
</Tabs>

## Next Steps

<CardGroup cols={3}>
  <Card title="Execute Transactions" description="Send transactions with configured RPC" href="/v3/react-native/guides/web3-operations/solana/execute-transactions" icon="bolt" />

  <Card title="Get Transaction Status" description="Check confirmations via RPC" href="/v3/react-native/guides/web3-operations/solana/get-transaction-status" icon="clock" />

  <Card title="Query Balances" description="Fetch account data from RPC" href="/v3/react-native/guides/web3-operations/solana/query-balances" icon="wallet" />
</CardGroup>
