SolanaRpcApiFromClusterUrl

type SolanaRpcApiFromClusterUrl<TClusterUrl> = SolanaRpcApiFromTransport<RpcTransportFromClusterUrl<TClusterUrl>>;

Given a ClusterUrl this utility type will resolve to a union of all the methods of the Solana RPC API supported by the URL's cluster.

Type Parameters

Type Parameter
TClusterUrl extends ClusterUrl

Example

function createSolanaRpcFromClusterUrl<TClusterUrl extends ClusterUrl>(
    clusterUrl: TClusterUrl,
): Rpc<SolanaRpcApiFromClusterUrl<TClusterUrl>, RpcTransportFromClusterUrl<TClusterUrl>> {
    /* ... */
}
const rpc = createSolanaRpcFromClusterUrl(mainnet('http://rpc.company'));
rpc satisfies Rpc<SolanaRpcApiMainnet>; // OK

On this page