Skip to main content

ThirdwebSDK.fromSigner

Instantiate the ThirdwebSDK in read-write mode using a Signer.

This is useful when using the SDK on the client-side, such as when using our React SDK.

Use the useSigner hook to get the currently connected wallets signer on the client.

The SDK will be instantiated on the chain that the signer is connected to.

Usage

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

// An example of a signer using the ethers library
import ethers from "ethers";
const signer = new ethers.Wallet("{{private_key}}");

const sdk = ThirdwebSDK.fromSigner(signer, {
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
});

Configuration

Client ID or Secret Key(required)

To use the Typescript SDK, you need to obtain either the clientId or secretKey from an API key which you can obtain from the Dashboard. You can instatiate the SDK in two ways:

  • Client-side: Use the SDK in the browser or mobile app. In this instance, you would use the clientId prop.
  • Server-side: Use the SDK in a server environment. In this instance, you would use the secretKey prop.

Signer (required)

The Signer is an object that represents an Ethereum account. It is used to sign transactions and messages. The SDK uses the Signer to sign transactions and messages.