toProvider

Converts a Thirdweb wallet into an EIP-1193 compatible provider.

This adapter allows you to use a Thirdweb wallet with any library or dApp that expects an EIP-1193 provider. The provider implements the standard EIP-1193 interface including request handling and event subscription.

Example

import { EIP1193 } from "thirdweb/wallets";
// Create an EIP-1193 provider from a Thirdweb wallet
const provider = EIP1193.toProvider({
wallet,
chain: ethereum,
client: createThirdwebClient({ clientId: "..." }),
});
// Use with any EIP-1193 compatible library
const accounts = await provider.request({
method: "eth_requestAccounts",
});
// Listen for events
provider.on("accountsChanged", (accounts) => {
console.log("Active accounts:", accounts);
});
function toProvider(

Parameters

Configuration options for creating the provider

Type

let options: {
chain: Chain;
client: ThirdwebClient;
connectOverride?: (wallet: Wallet) => Promise<Account>;
wallet: Wallet;
};

Returns

let returnType: {
request: (params: any) => Promise<any>;
on: (event: any, listener: (params: any) => any) => void;
removeListener: (
event: any,
listener: (params: any) => any,
) => void;
};

An EIP-1193 compatible provider that wraps the Thirdweb wallet