createWalletAdapter

Creates a wallet from the given account.

You can use this to:

  • convert a third party library wallet (wagmi, viem, ethers) into a thirdweb wallet.

  • connect with a private key (for automated tests)

Available wallet adatpers:

Example

import { createWalletAdapter } from "thirdweb";
const wallet = createWalletAdapter({
client,
adaptedAccount,
chain,
onDisconnect: () => {
// disconnect logic
},
switchChain: async (chain) => {
// switch chain logic
},
});
function createWalletAdapter(
): Wallet<"adapter">;

Parameters

The options for the adapter wallet.

Type

let options: {
adaptedAccount: Account;
chain: Chain;
client: ThirdwebClient;
onDisconnect: () => Promise<void> | void;
switchChain: (chain: Chain) => Promise<void> | void;
};

Returns

let returnType: Wallet<"adapter">;

a wallet instance.