alchemy

1function alchemy(config): AlchemyTransport;

Defined in: account-kit/infra/dist/types/alchemyTransport.d.ts:80

Creates an Alchemy transport with the specified configuration options. When sending all traffic to Alchemy, you must pass in one of rpcUrl, apiKey, or jwt. If you want to send Bundler and Paymaster traffic to Alchemy and Node traffic to a different RPC, you must pass in alchemyConnection and nodeRpcUrl.

Example

Basic Example

If the chain you’re using is supported for both Bundler and Node RPCs, then you can do the following:

1import { alchemy } from "@account-kit/infra";
2
3const transport = alchemy({
4 // NOTE: you can also pass in an rpcUrl or jwt here or rpcUrl and jwt
5 apiKey: "your-api-key",
6});

AA Only Chains

For AA-only chains, you need to specify the alchemyConnection and nodeRpcUrl since Alchemy only handles the Bundler and Paymaster RPCs for these chains.

1import { alchemy } from "@account-kit/infra";
2
3const transport = alchemy({
4 alchemyConnection: {
5 apiKey: "your-api-key",
6 },
7 nodeRpcUrl: "https://zora.rpc.url",
8});

Parameters

ParameterTypeDescription

config

AlchemyTransportConfig

The configuration object for the Alchemy transport.

Returns

AlchemyTransport

The configured Alchemy transport object.