Skip to content

split

The split transport allows you to provide overrides for specific RPC methods. This is useful, for example, if you want to send bundler traffic to one provider and node traffic to another.

Import

ts
import { split } from "@alchemy/aa-core";

Usage

ts
import { createSmartAccountClient, sepolia, split } from "@alchemy/aa-core";
import { http } from "viem";

const bundlerMethods = [
  "eth_sendUserOperation",
  "eth_estimateUserOperationGas",
  "eth_getUserOperationReceipt",
  "eth_getUserOperationByHash",
  "eth_supportedEntryPoints",
];

const splitTransport = split({
  overrides: [
    {
      methods: bundlerMethods,
      transport: http("BUNDLER_RPC_URL"),
    },
  ],
  fallback: http("OTHER_RPC_URL"),
});

export const client = createSmartAccountClient({
  chain: sepolia,
  transport: splitTransport,
});

Parameters

ts
import { type SplitTransportProps } from "@alchemy/aa-core";

overrides

{transport: Transport, methods: string[]}[]

The overrides param is an array of objects containing a transport param of type Transport from viem (eg. http) and an array of methods that this transport should handle

fallback

Transport

This is the Transport to use for all other methods

Return Type

ts
import { type CustomTransport } from "viem";

Returns a CustomTransport that can be passed to any compatible viem Client. This includes any SmartAccountClient instance.