import { type Chain, type EIP1193RequestFn, type HttpTransportConfig, type RpcSchema, type Transport } from "viem"; /** * Configuration options for the Alchemy transport. * Extends viem's HttpTransportConfig with Alchemy-specific options while omitting * options that are not relevant or supported by Alchemy. */ export interface AlchemyTransportConfig extends Omit { /** API key for Alchemy authentication */ apiKey?: string; /** JWT token for authentication */ jwt?: string; /** Custom RPC URL (optional - defaults to chain's Alchemy URL, but can be used to override the chain's Alchemy URL) */ url?: string; } type AlchemyTransportBase = Transport<"alchemyHttp", { alchemyRpcUrl: string; fetchOptions: AlchemyTransportConfig["fetchOptions"]; config: AlchemyTransportConfig; }, EIP1193RequestFn>; export type AlchemyTransport = AlchemyTransportBase & { updateHeaders(newHeaders: HeadersInit): void; }; /** * A type guard for the transport to determine if it is an Alchemy transport. * Used in cases where we would like to do switching depending on the transport. * * @param {Transport} transport The transport to check * @param {Chain} chain Chain for the transport to run its function to return the transport config * @returns {boolean} `true` if the transport is an Alchemy transport, otherwise `false` */ export declare function isAlchemyTransport(transport: Transport, chain: Chain): transport is AlchemyTransport; /** * Creates an Alchemy HTTP transport for connecting to Alchemy's services. * * @example * Using API Key: * ```ts * import { alchemyTransport } from "@alchemy/common"; * * const transport = alchemyTransport({ apiKey: "your-api-key" }); * ``` * * @example * Using JWT: * ```ts * import { alchemyTransport } from "@alchemy/common"; * * const transport = alchemyTransport({ jwt: "your-jwt-token" }); * ``` * * @example * Using URL directly: * ```ts * import { alchemyTransport } from "@alchemy/common"; * * const transport = alchemyTransport({ url: "https://eth-mainnet.g.alchemy.com/v2/your-key" }); * ``` * * @example * Using custom URL with API key: * ```ts * import { alchemyTransport } from "@alchemy/common"; * * const transport = alchemyTransport({ * url: "https://custom-alchemy.com/v2", * apiKey: "your-api-key" * }); * ``` * * @example * Using custom URL with JWT: * ```ts * import { alchemyTransport } from "@alchemy/common"; * * const transport = alchemyTransport({ * url: "https://custom-alchemy.com/v2", * jwt: "your-jwt-token" * }); * ``` * * @example * Using HTTP debugging options: * ```ts * import { alchemyTransport } from "@alchemy/common"; * * const transport = alchemyTransport({ * apiKey: "your-api-key", * onFetchRequest: (request) => console.log("Request:", request), * onFetchResponse: (response) => console.log("Response:", response), * timeout: 30000, * retryCount: 3, * retryDelay: 1000 * }); * ``` * * @param {AlchemyTransportConfig} config - The configuration object for the Alchemy transport (extends viem's HttpTransportConfig) * @param {string} [config.apiKey] - API key for Alchemy authentication * @param {string} [config.jwt] - JWT token for authentication * @param {string} [config.url] - Direct URL to Alchemy endpoint or a proxy URL * @param {Function} [config.onFetchRequest] - Callback for debugging outgoing requests * @param {Function} [config.onFetchResponse] - Callback for debugging responses * @param {number} [config.timeout] - Request timeout in milliseconds * @param {number} [config.retryCount] - The number of retry attempts * @param {number} [config.retryDelay] - The delay between retries, in milliseconds * @param {object} [config.fetchOptions] - Optional fetch options for HTTP requests * @param {object} [config.httpOptions] - HTTP transport options for debugging (onFetchRequest, onFetchResponse, timeout, batch) * @returns {AlchemyTransport} The configured Alchemy transport function */ export declare function alchemyTransport(config: AlchemyTransportConfig): AlchemyTransport; export {}; //# sourceMappingURL=alchemy.d.ts.map