fromProvider

Creates a Thirdweb wallet from an EIP-1193 compatible provider.

This adapter allows you to use any EIP-1193 provider (like MetaMask, WalletConnect, etc.) as a Thirdweb wallet. It handles all the necessary conversions between the EIP-1193 interface and Thirdweb's wallet interface.

Example

import { EIP1193 } from "thirdweb/wallets";
// Create a Thirdweb wallet from MetaMask's provider
const wallet = EIP1193.fromProvider({
provider: window.ethereum,
walletId: "io.metamask",
});
// Use like any other Thirdweb wallet
const account = await wallet.connect({
client: createThirdwebClient({ clientId: "..." }),
});
// Sign messages
await account.signMessage({ message: "Hello World" });
// Send transactions
await account.sendTransaction({
to: "0x...",
value: 1000000000000000000n,
});
function fromProvider(options: FromEip1193AdapterOptions): Wallet;

Parameters

Configuration options for creating the wallet adapter

Type

let options: {
provider: EIP1193Provider | (() => Promise<EIP1193Provider>);
walletId?: WalletId;
};

Returns

let returnType: {
getAdminAccount?: () => Account | undefined;
getConfig: () => CreateWalletArgs<TWalletId>[1];
id: TWalletId;
onConnectRequested?: () => Promise<void>;
subscribe: WalletEmitter<TWalletId>["subscribe"];
autoConnect: (
options: WalletAutoConnectionOption<TWalletId>,
) => Promise<Account>;
connect: (
options: WalletConnectionOption<TWalletId>,
) => Promise<Account>;
disconnect: () => Promise<void>;
getAccount: () => undefined | Account;
getChain: () =>
| undefined
| Readonly<ChainOptions & { rpc: string }>;
switchChain: (
chain: Readonly<ChainOptions & { rpc: string }>,
) => Promise<void>;
};

A Thirdweb wallet instance that wraps the EIP-1193 provider