Kit
Type aliases

RpcTransportFromClusterUrl

RpcTransportFromClusterUrl<TClusterUrl> = TClusterUrl extends DevnetUrl ? RpcTransportDevnet : TClusterUrl extends TestnetUrl ? RpcTransportTestnet : TClusterUrl extends MainnetUrl ? RpcTransportMainnet : RpcTransport

Given a ClusterUrl, this utility type will resolve to as specific a RpcTransport as possible.

Type Parameters

Type Parameter
TClusterUrl extends ClusterUrl

Example

function createCustomTransport<TClusterUrl extends ClusterUrl>(
    clusterUrl: TClusterUrl,
): RpcTransportFromClusterUrl<TClusterUrl> {
    /* ... */
}
 
const transport = createCustomTransport(testnet('http://api.testnet.solana.com'));
transport satisfies RpcTransportTestnet; // OK

On this page