Returns an RPC endpoint by defining a provider and a cluster type.
Current supported RPC providers are:
- Solana (opens in a new tab)
- Project Serum (opens in a new tab)
- GenesysGo (opens in a new tab)
- AllThatNode (opens in a new tab)
- Blockdaemon (opens in a new tab)
- Ankr (opens in a new tab)
- GetBlock (opens in a new tab)
- Alchemy (opens in a new tab)
- Syndica (opens in a new tab)
Solana RPC in mainnet.
import { getRpcEndpointUrl } from '@lndgalante/solutils';
const { rpcEndpointUrl: solanaMainnetRpc } = getRpcEndpointUrl('solana', 'mainnet');
console.log(solanaMainnetRpc); // "https://api.mainnet-beta.solana.com"
GenesysGo RPC in devnet.
import { getRpcEndpointUrl } from '@lndgalante/solutils';
const { rpcEndpointUrl: genesysGoRpc } = getRpcEndpointUrl('genesysgo', 'devnet');
console.log(genesysGoRpc); // "https://devnet.genesysgo.net"
Alchemy private RPC in mainnet.
import { getRpcEndpointUrl } from '@lndgalante/solutils';
const ALCHEMY_API_KEY = '3EUkBvPfNdHg3qsazLs1zqUVUQfz3ipRXM';
const { rpcEndpointUrl: alchemyRpc } = getRpcEndpointUrl('alchemy', 'mainnet', ALCHEMY_API_KEY);
console.log(alchemyRpc); // "https://solana-mainnet.g.alchemy.com/v2/3EUkBvPfNdHg3qsazLs1zqUVUQfz3ipRXM"
Syndica private RPC in mainnet.
import { getRpcEndpointUrl } from '@lndgalante/solutils';
const SYNDICA_ACCESS_TOKEN = 'GlGcaiydgQJI0zqkUDKC810LVYXWA1gxx2CtboDluHOp23o2UqkLaRdVZTuJsUvD';
const { rpcEndpointUrl: syndicaRpc } = getRpcEndpointUrl('syndica', 'mainnet', SYNDICA_ACCESS_TOKEN);
console.log(syndicaRpc); // "https://solana-api.syndica.io/access-token/GlGcaiydgQJI0zqkUDKC810LVYXWA1gxx2CtboDluHOp23o2UqkLaRdVZTuJsUvD/rpc"
⚠️
For production builds you probably want to get a paid RPC service due to service limitations.