getRpcClient

Returns an RPC request that can be used to make JSON-RPC requests.

Example

import { createThirdwebClient } from "thirdweb";
import { getRpcClient } from "thirdweb/rpc";
import { ethereum } from "thirdweb/chains";
const client = createThirdwebClient({ clientId: "..." });
const rpcRequest = getRpcClient({ client, chain: ethereum });
const blockNumber = await rpcRequest({
method: "eth_blockNumber",
});
function getRpcClient(
options: Readonly<{
chain: Readonly<ChainOptions & { rpc: string }>;
client: ThirdwebClient;
config?: {
batchTimeoutMs?: number;
maxBatchSize?: number;
requestTimeoutMs?: number;
};
}>,
): EIP1193RequestFn<EIP1474Methods>;

Parameters

The RPC options.

Type

let options: Readonly<{
chain: Readonly<ChainOptions & { rpc: string }>;
client: ThirdwebClient;
config?: {
batchTimeoutMs?: number;
maxBatchSize?: number;
requestTimeoutMs?: number;
};
}>;

Returns

let returnType: EIP1193RequestFn<EIP1474Methods>;

The RPC request function.