Skip to content

createAlchemyPublicRpcClient

Creates an Alchemy public RPC client with the provided chain, connection configuration, and optional fetch options. The client has alchemy methods and can dynamically update HTTP headers.

Import

import { createAlchemyPublicRpcClient } from "@account-kit/infra";

Usage

import { createAlchemyPublicRpcClient, alchemy } from "@account-kit/infra";
import { sepolia } from "@account-kit/infra";
 
const client = createAlchemyPublicRpcClient({
  transport: alchemy({
    apiKey: "ALCHEMY_API_KEY",
  }),
  chain: sepolia,
});

Parameters

params

{connectionConfig: ConnectionConfig,chain: Chain,fetchOptions?: NoUndefined<HttpTransportConfig["fetchOptions"]>} The parameters for creating the Alchemy public RPC client

params.connectionConfig

ConnectionConfig The connection configuration containing the RPC URL and API key

params.chain

Chain The blockchain chain configuration

params.fetchOptions

NoUndefined<HttpTransportConfig["fetchOptions"]> Optional fetch configuration for HTTP transport

Returns

ClientWithAlchemyMethods A client object tailored with Alchemy methods and capabilities to interact with the blockchain