alchemy
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.
Import
import { alchemy } from "@account-kit/infra";
Usage
Basic Example
If the chain you're using is supported for both Bundler and Node RPCs, then you can do the following:
import { alchemy } from "@account-kit/infra";
const transport = alchemy({
// NOTE: you can also pass in an rpcUrl or jwt here or rpcUrl and jwt
apiKey: "your-api-key",
});
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.
import { alchemy } from "@account-kit/infra";
const transport = alchemy({
alchemyConnection: {
apiKey: "your-api-key",
},
nodeRpcUrl: "https://zora.rpc.url",
});
Parameters
config
AlchemyTransportConfig
The configuration object for the Alchemy transport.
config.retryDelay
number
Optional The delay between retries, in milliseconds.
config.retryCount
number
Optional The number of retry attempts.
config.alchemyConnection
string
Optional Alchemy connection configuration (if this is passed in, nodeRpcUrl is required).
config.fetchOptions
string
Optional fetch options for HTTP requests.
config.nodeRpcUrl
string
Optional RPC URL for node (if this is passed in, alchemyConnection is required).
config.rpcUrl
string
Optional RPC URL.
config.apiKey
string
Optional API key for Alchemy.
config.jwt
string
Optional JSON Web Token for authorization.
Returns
AlchemyTransport
The configured Alchemy transport object.