Skip to main content

Connect Wallets with the Wallet SDK in TypeScript

To get started, install the required dependencie(s) into your TypeScript project.

npm install @thirdweb-dev/wallets

Optionally, install the TypeScript SDK to use the wallet with the SDK.

npm install @thirdweb-dev/sdk

Connect Wallets in TypeScript

You can use the Wallet SDK directly in any environment that supports TypeScript. The Wallet SDK enables you to connect and create wallets which you can then use in your app to sign transactions as you usually would. There are two main instances in which you would use the Wallet SDK directly:

  1. Connecting wallets in a back-end environment such as Node.js script to sign transactions without passing a private key. Instead, a browser popup would be initiated to sign the transaction.

  2. In projects where you need low-level control of the wallet

  • Example: Needing to pass custom configuration options such as specifying a custom execute method for smartWallet e.g. in this template.

Get started connecting wallets with the Wallet SDK in TypeScript by following the steps below. You can also then use the wallet to instantiate the TypeScript SDK:

import { MetaMaskWallet } from "@thirdweb-dev/wallets";
import { ThirdwebSDK } from "@thirdweb-dev/sdk";

// Instantiate the wallet you want to use
const wallet = new MetaMaskWallet();

// connect wallet
await wallet.connect();

// Instantiate the SDK using the wallet
const sdk = ThirdwebSDK.fromWallet(wallet, "ethereum", {
clientId: "YOUR_CLIENT_ID", // Use client id if using on the client side, get it from dashboard settings
secretKey: "YOUR_SECRET_KEY", // Use secret key if using on the server, get it from dashboard settings
});

// sdk is now ready to use

View the supported wallets in the wallet SDK.