Connect Wallets with the Wallet SDK 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:
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.
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 forsmartWallet
e.g. in this template.
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