function alchemyTransport<rpcSchema>(config): AlchemyTransport<rpcSchema>;Defined in: packages/common/src/transport/alchemy.ts:146
Creates an Alchemy HTTP transport for connecting to Alchemy's services.
| Type Parameter | Default type |
|---|---|
|
|
| Parameter | Type | Description |
|---|---|---|
| The configuration object for the Alchemy transport (extends viem's HttpTransportConfig) |
AlchemyTransport<rpcSchema>
The configured Alchemy transport function
Using API Key:
import { alchemyTransport } from "@alchemy/common";
const transport = alchemyTransport({ apiKey: "your-api-key" });Using JWT:
import { alchemyTransport } from "@alchemy/common";
const transport = alchemyTransport({ jwt: "your-jwt-token" });Using URL directly:
import { alchemyTransport } from "@alchemy/common";
const transport = alchemyTransport({
url: "https://eth-mainnet.g.alchemy.com/v2/your-key",
});Using custom URL with API key:
import { alchemyTransport } from "@alchemy/common";
const transport = alchemyTransport({
url: "https://custom-alchemy.com/v2",
apiKey: "your-api-key",
});Using custom URL with JWT:
import { alchemyTransport } from "@alchemy/common";
const transport = alchemyTransport({
url: "https://custom-alchemy.com/v2",
jwt: "your-jwt-token",
});Using HTTP debugging options:
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,
});