ThirdwebSDK
The main entry point for the thirdweb SDK
class ThirdwebSDK extends RPCConnectionHandler {}
function constructor( options: | undefined | { clientId?: string; gasless?: | { experimentalChainlessSupport?: boolean; openzeppelin: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; useEOAForwarder?: boolean; }; } | { biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number; }; } | { engine: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; }; experimentalChainlessSupport?: boolean; }; gasSettings?: { maxPriceInGwei?: number; speed?: "standard" | "fast" | "fastest"; }; gatewayUrls?: Array<string>; readonlySettings?: { chainId?: number; rpcUrl: string }; rpcBatchSettings?: { sizeLimit?: number; timeLimit?: number }; secretKey?: string; supportedChains?: Array<{ chainId: number; nativeCurrency: { decimals: number; name: string; symbol: string; }; rpc: Array<string>; slug: string; }>; },
let options: | undefined | { clientId?: string; gasless?: | { experimentalChainlessSupport?: boolean; openzeppelin: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; useEOAForwarder?: boolean; }; } | { biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number; }; } | { engine: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; }; experimentalChainlessSupport?: boolean; }; gasSettings?: { maxPriceInGwei?: number; speed?: "standard" | "fast" | "fastest"; }; gatewayUrls?: Array<string>; readonlySettings?: { chainId?: number; rpcUrl: string }; rpcBatchSettings?: { sizeLimit?: number; timeLimit?: number }; secretKey?: string; supportedChains?: Array<{ chainId: number; nativeCurrency: { decimals: number; name: string; symbol: string; }; rpc: Array<string>; slug: string; }>; };
Get the native balance of a given address (wallet or contract)
const balance = await sdk.getBalance("0x...");console.log(balance.displayValue);
function getBalance( address: string,): Promise<{ decimals: number; displayValue: string; name: string; symbol: string; value: BigNumber;}>;
Get an instance of a Custom ThirdwebContract
const contract = await sdk.getContract("{{contract_address}}");
function getContract( address: TContractAddress,): Promise< TContractAddress extends never >>;
let returnType: Promise< TContractAddress extends never >>;
The contract
Get an instance of a Custom ThirdwebContract
const contract = await sdk.getContract( "{{contract_address}}", "nft-drop",);
function getContract( address: string, contractType: TContractType,): Promise< TContractType extends | "split" | "pack" | "token" | "edition" | "vote" | "edition-drop" | "marketplace" | "marketplace-v3" | "multiwrap" | "nft-collection" | "nft-drop" | "signature-drop" | "token-drop" ? ContractForPrebuiltContractType<TContractType<TContractType>>>;
let returnType: Promise< TContractType extends | "split" | "pack" | "token" | "edition" | "vote" | "edition-drop" | "marketplace" | "marketplace-v3" | "multiwrap" | "nft-collection" | "nft-drop" | "signature-drop" | "token-drop" ? ContractForPrebuiltContractType<TContractType<TContractType>>>;
The contract
Get an instance of a Custom ThirdwebContract
const contract = await sdk.getContract("{{contract_address}}", ABI);
function getContract( address: string, abi: ContractInterface,
The contract
Get an instance of a Custom contract from a json ABI
// Import your ABI from a JSON fileimport myABI from "./path/to/myABI.json"; const contract = sdk.getContractFromAbi( "{{contract_address}}", // Pass in the "abi" field from the JSON file myABI.abi,);
function getContractFromAbi( address: string, abi: ContractInterface,
The contract
Return all the contracts deployed by the specified address
const contracts = sdk.getContractList("{{wallet_address}}");
function getContractList( walletAddress: string,
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const edition = await sdk.getEdition("0x1234...");+ const edition = await sdk.getContract("0x1234...", "edition");
Get an instance of a Edition contract
function getEdition(contractAddress: string): Promise<Edition>;
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const editionDrop = await sdk.getEditionDrop("0x1234...");+ const editionDrop = await sdk.getContract("0x1234...", "edition-drop");
Get an instance of a Edition Drop contract
function getEditionDrop( contractAddress: string,): Promise<EditionDrop>;
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const marketplace = await sdk.getMarketplace("0x1234...");+ const marketplace = await sdk.getContract("0x1234...", "marketplace");
Get an instance of a Marketplace contract
function getMarketplace( contractAddress: string,): Promise<Marketplace>;
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const marketplace = await sdk.getMarketplaceV3("0x1234...");+ const marketplace = await sdk.getContract("0x1234...", "marketplace-v3");
Get an instance of a Marketplace contract
function getMarketplaceV3( contractAddress: string,): Promise<MarketplaceV3>;
function getMultichainContractList( walletAddress: string, chains: Array<Chain>,
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const multiWrap = await sdk.getMultiwrap("0x1234...");+ const multiWrap = await sdk.getContract("0x1234...", "multiwrap");
Get an instance of a Pack contract
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const signatureDrop = await sdk.getNFTCollection("0x1234...");+ const signatureDrop = await sdk.getContract("0x1234...", "nft-collection");
Get an instance of a NFT Collection Drop contract
function getNFTCollection( contractAddress: string,): Promise<NFTCollection>;
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const dropContract = await sdk.getDropContract("0x1234...");+ const dropContract = await sdk.getContract("0x1234...", "nft-drop");
Get an instance of a NFT Drop contract
function getNFTDrop(contractAddress: string): Promise<NFTDrop>;
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const pack = await sdk.getPack("0x1234...");+ const pack = await sdk.getContract("0x1234...", "pack");
Get an instance of a Pack contract
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const signatureDrop = await sdk.getSignatureDrop("0x1234...");+ const signatureDrop = await sdk.getContract("0x1234...", "signature-drop");
Get an instance of a Signature Drop contract
function getSignatureDrop( contractAddress: string,): Promise<SignatureDrop>;
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const split = await sdk.getSplit("0x1234...");+ const split = await sdk.getContract("0x1234...", "split");
Get an instance of a Split contract
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const token = await sdk.getToken("0x1234...");+ const token = await sdk.getContract("0x1234...", "token");
Get an instance of a Token contract
function getToken(contractAddress: string): Promise<Token>;
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const tokenDrop = await sdk.getTokenDrop("0x1234...");+ const tokenDrop = await sdk.getContract("0x1234...", "token-drop");
Get an instance of a Token Drop contract
function getTokenDrop(contractAddress: string): Promise<TokenDrop>;
This method is deprecated and will be removed in a future major version. You should use getContract instead.
- const vote = await sdk.getVote("0x1234...");+ const vote = await sdk.getContract("0x1234...", "vote");
Get an instance of a Vote contract
function resolveContractType( contractAddress: string,): Promise< | "custom" | "split" | "pack" | "token" | "edition" | "vote" | "edition-drop" | "marketplace" | "marketplace-v3" | "multiwrap" | "nft-collection" | "nft-drop" | "signature-drop" | "token-drop">;
Update the active signer or provider for all contracts
Get an instance of the thirdweb SDK based on a private key.
This should only be used for backend services or scripts, with the private key stored in a secure way. NEVER expose your private key to the public in any way.
const sdk = ThirdwebSDK.fromPrivateKey("SecretPrivateKey", "mainnet");
function fromPrivateKey( privateKey: string, options: | undefined | { clientId?: string; gasless?: | { experimentalChainlessSupport?: boolean; openzeppelin: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; useEOAForwarder?: boolean; }; } | { biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number; }; } | { engine: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; }; experimentalChainlessSupport?: boolean; }; gasSettings?: { maxPriceInGwei?: number; speed?: "standard" | "fast" | "fastest"; }; gatewayUrls?: Array<string>; readonlySettings?: { chainId?: number; rpcUrl: string }; rpcBatchSettings?: { sizeLimit?: number; timeLimit?: number }; secretKey?: string; supportedChains?: Array<{ chainId: number; nativeCurrency: { decimals: number; name: string; symbol: string; }; rpc: Array<string>; slug: string; }>; },
the network (chain) to connect to (e.g. "mainnet", "rinkeby", "polygon", "mumbai"...) or a fully formed RPC url
the SDK options to use
let options: | undefined | { clientId?: string; gasless?: | { experimentalChainlessSupport?: boolean; openzeppelin: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; useEOAForwarder?: boolean; }; } | { biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number; }; } | { engine: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; }; experimentalChainlessSupport?: boolean; }; gasSettings?: { maxPriceInGwei?: number; speed?: "standard" | "fast" | "fastest"; }; gatewayUrls?: Array<string>; readonlySettings?: { chainId?: number; rpcUrl: string }; rpcBatchSettings?: { sizeLimit?: number; timeLimit?: number }; secretKey?: string; supportedChains?: Array<{ chainId: number; nativeCurrency: { decimals: number; name: string; symbol: string; }; rpc: Array<string>; slug: string; }>; };
An instance of the SDK
Get an instance of the thirdweb SDK based on an existing ethers signer
// get a signer from somewhere (createRandom is being used purely for example purposes)const signer = Wallet.createRandom(); // get an instance of the SDK with the signer already setupconst sdk = ThirdwebSDK.fromSigner(signer, "mainnet");
function fromSigner( signer: Signer, options: | undefined | { clientId?: string; gasless?: | { experimentalChainlessSupport?: boolean; openzeppelin: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; useEOAForwarder?: boolean; }; } | { biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number; }; } | { engine: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; }; experimentalChainlessSupport?: boolean; }; gasSettings?: { maxPriceInGwei?: number; speed?: "standard" | "fast" | "fastest"; }; gatewayUrls?: Array<string>; readonlySettings?: { chainId?: number; rpcUrl: string }; rpcBatchSettings?: { sizeLimit?: number; timeLimit?: number }; secretKey?: string; supportedChains?: Array<{ chainId: number; nativeCurrency: { decimals: number; name: string; symbol: string; }; rpc: Array<string>; slug: string; }>; },
the network (chain) to connect to (e.g. "mainnet", "rinkeby", "polygon", "mumbai"...) or a fully formed RPC url
the SDK options to use
let options: | undefined | { clientId?: string; gasless?: | { experimentalChainlessSupport?: boolean; openzeppelin: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; useEOAForwarder?: boolean; }; } | { biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number; }; } | { engine: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; }; experimentalChainlessSupport?: boolean; }; gasSettings?: { maxPriceInGwei?: number; speed?: "standard" | "fast" | "fastest"; }; gatewayUrls?: Array<string>; readonlySettings?: { chainId?: number; rpcUrl: string }; rpcBatchSettings?: { sizeLimit?: number; timeLimit?: number }; secretKey?: string; supportedChains?: Array<{ chainId: number; nativeCurrency: { decimals: number; name: string; symbol: string; }; rpc: Array<string>; slug: string; }>; };
An instance of the SDK
Get an instance of the thirdweb SDK based on an AbstractWallet
import { ThirdwebSDK } from "@thirdweb-dev/sdk"; const wallet = new AbstractWalletImplementation();const sdk = await ThirdwebSDK.fromWallet(wallet, "mainnet");
function fromWallet( wallet: { getSigner: () => Promise<Signer> }, options: | undefined | { clientId?: string; gasless?: | { experimentalChainlessSupport?: boolean; openzeppelin: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; useEOAForwarder?: boolean; }; } | { biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number; }; } | { engine: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; }; experimentalChainlessSupport?: boolean; }; gasSettings?: { maxPriceInGwei?: number; speed?: "standard" | "fast" | "fastest"; }; gatewayUrls?: Array<string>; readonlySettings?: { chainId?: number; rpcUrl: string }; rpcBatchSettings?: { sizeLimit?: number; timeLimit?: number }; secretKey?: string; supportedChains?: Array<{ chainId: number; nativeCurrency: { decimals: number; name: string; symbol: string; }; rpc: Array<string>; slug: string; }>; },
the network (chain) to connect to (e.g. "mainnet", "rinkeby", "polygon", "mumbai"...) or a fully formed RPC url
the SDK options to use
let options: | undefined | { clientId?: string; gasless?: | { experimentalChainlessSupport?: boolean; openzeppelin: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; useEOAForwarder?: boolean; }; } | { biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number; }; } | { engine: { domainName?: string; domainSeparatorVersion?: string; domainVersion?: string; relayerForwarderAddress?: string; relayerUrl: string; }; experimentalChainlessSupport?: boolean; }; gasSettings?: { maxPriceInGwei?: number; speed?: "standard" | "fast" | "fastest"; }; gatewayUrls?: Array<string>; readonlySettings?: { chainId?: number; rpcUrl: string }; rpcBatchSettings?: { sizeLimit?: number; timeLimit?: number }; secretKey?: string; supportedChains?: Array<{ chainId: number; nativeCurrency: { decimals: number; name: string; symbol: string; }; rpc: Array<string>; slug: string; }>; };
An instance of the SDK
RPCConnectionHandler.getProvider
Explicitly get the active provider.
function getProvider(): Provider;
RPCConnectionHandler.getSigner
Explicitly get the active signer.
function getSigner(): undefined | Signer;
RPCConnectionHandler.getSignerOrProvider
function getSignerOrProvider(): Signer | Provider;
RPCConnectionHandler.isReadOnly
function isReadOnly(): boolean;
RPCConnectionHandler.removeListener
Remove the listeners of a given event.
function removeListener( event: T, fn?: (...args: Array<any>) => void, context?: any, once?: boolean,): this;
let options: { clientId?: string; gasless?: | { experimentalChainlessSupport: boolean; openzeppelin: { domainName: string; domainSeparatorVersion: string; domainVersion: string; relayerForwarderAddress?: string; relayerUrl: string; useEOAForwarder: boolean; }; } | { biconomy: { apiId: string; apiKey: string; deadlineSeconds: number; }; } | { engine: { domainName: string; domainSeparatorVersion: string; domainVersion: string; relayerForwarderAddress?: string; relayerUrl: string; }; experimentalChainlessSupport: boolean; }; gasSettings: { maxPriceInGwei: number; speed: "standard" | "fast" | "fastest"; }; gatewayUrls?: Array<string>; readonlySettings?: { chainId?: number; rpcUrl: string }; rpcBatchSettings?: { sizeLimit: number; timeLimit: number }; secretKey?: string; supportedChains: Array<{ chainId: number; nativeCurrency: { decimals: number; name: string; symbol: string; }; rpc: Array<string>; slug: string; }>;};
type clientId = string;
type gasless = | { experimentalChainlessSupport: boolean; openzeppelin: { domainName: string; domainSeparatorVersion: string; domainVersion: string; relayerForwarderAddress?: string; relayerUrl: string; useEOAForwarder: boolean; }; } | { biconomy: { apiId: string; apiKey: string; deadlineSeconds: number; }; } | { engine: { domainName: string; domainSeparatorVersion: string; domainVersion: string; relayerForwarderAddress?: string; relayerUrl: string; }; experimentalChainlessSupport: boolean; };
type gasSettings = { maxPriceInGwei: number; speed: "standard" | "fast" | "fastest";};
type gatewayUrls = Array<string>;
type readonlySettings = { chainId?: number; rpcUrl: string };
type rpcBatchSettings = { sizeLimit: number; timeLimit: number };
type secretKey = string;
type supportedChains = Array<{ chainId: number; nativeCurrency: { decimals: number; name: string; symbol: string }; rpc: Array<string>; slug: string;}>;
Upload and download files from IPFS or from your own storage service
let prefixed: string | boolean;
let auth: void;