Wallets
Third party library adapters
The thirdweb SDK can work side by side with:
- any library that supports EIP1193 (wagmi, privy, etc.)
- ethers.js v5 & v6
- viem
- older versions of the @thirdweb-dev/sdk (using the ethers.js v5 adapter)
Adapters allow you to use contracts, providers and wallets from these libraries with the thirdweb SDK and vice versa.
View the demo repo for using thirdweb in-app / smart wallets with wagmi:
You can use thirdweb's in-app, ecosystem and smart wallets in your wagmi application by using the @thirdweb-dev/wagmi-adapter package.
Make sure you're running wagmi 2.14.1 or above.
You probably already have a wagmi config with some connectors, simply add the inAppWalletConnector to the list, along with the desired options.
You can use the thirdweb react connection components and hooks like ConnectButton, ConnectEmbed, useConnectModal, etc, but still keep using wagmi for the rest of the application.
To do so, you will need to connect the inAppWalletConnector connector from the @thirdweb-dev/wagmi-adapter package with the connected thirdweb wallet.
You can do this at any time after connecting the thirdweb wallet, a convenient place to do this is in the onConnect callback of the ConnectButton or ConnectEmbed.
Make sure your app is wrapped in a <ThirdwebProvider> as well as a <WagmiProvider> since both contexts will be used here. From there, the wallet state will be in sync between the 2 libraries.
Note: the ConnectButton and ConnectEmbed handle reconnecting automatically on page reload. If not using those components (ie. useConnectModal or useConnect hooks directly), you will need to handle reconnecting by explicitely calling useAutoConnect(), and doing the same wagmi connection from the onConnect callback.
You can also use the inAppWalletConnector connector directly in your application to connect to the thirdweb wallet without needing a <ThirdwebProvider> at all.
You can also use the thirdweb SDK within a wagmi application by setting the wagmi connected account as the thirdweb 'active wallet'. After that, you can use all of the react components and hooks normally, including BuyWidget, TransactionButton, etc.
You can view a fully functioning wagmi + thirdweb app in this github repository.
Similarly, you can use the thirdweb SDK with privy by setting the privy wallet as the thirdweb 'active wallet'. After that, you can use all of the react components, functions and hooks normally, including BuyWidget, TransactionButton, etc.
You can use any wallet that supports EIP1193 with the thirdweb SDK by converting it using EIP1193.fromProvider:
You can also convert a thirdweb account to an EIP1193 provider using EIP1193.toProvider, which can then be used with other libraries:
You can use an existing wallet client from viem with the thirdweb SDK by converting it using the viemAdapter:
You can also convert viem public clients and contracts from and to the thirdweb SDK.
View the viemAdapter reference for more details.
You can use an existing ethers.js v6 Signer with the thirdweb SDK by converting it using the ethers6Adapter:
Similarly, you can use any wallets created with the thirdweb SDK with ethers.js v6 by converting them using the ethers6Adapter:
You can also convert ethers.js providers and contracts from and to the thirdweb SDK.
View the ethers6Adapter reference for more details.
You can use an existing ethers.js v5 Signer with the thirdweb SDK by converting it using the ethers5Adapter:
You can also convert ethers.js providers and contracts from and to the thirdweb SDK.
View the ethers5Adapter reference for more details.