The main entry point for the thirdweb SDK

Hierarchy

  • RPCConnectionHandler
    • ThirdwebSDK

Constructors

  • Parameters

    • network: NetworkInput
    • options: undefined | {
          clientId?: string;
          gasSettings?: { maxPriceInGwei?: number | undefined; speed?: "standard" | "fast" | "fastest" | undefined; };
          gasless?: ({ openzeppelin: { relayerUrl: string; relayerForwarderAddress?: string | undefined; useEOAForwarder?: boolean | undefined; domainName?: string | undefined; domainVersion?: string | undefined; }; experimentalChainlessSupport?: boolean | undefined; }) | ({ biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number | undefined; }; }) | ({ engine: { relayerUrl: string; }; });
          gatewayUrls?: string[];
          readonlySettings?: { rpcUrl: string; chainId?: number | undefined; };
          secretKey?: string;
          supportedChains?: ({ rpc: string[]; chainId: number; nativeCurrency: { symbol: string; name: string; decimals: number; }; slug: string; })[];
      } = {}
    • Optional storage: IThirdwebStorage

    Returns ThirdwebSDK

Properties

New contract deployer

multiChainRegistry: MultichainRegistry

The registry of deployed contracts

network: NetworkInput
options: {
    clientId?: string;
    gasSettings: { maxPriceInGwei: number; speed: "standard" | "fast" | "fastest"; };
    gasless?: ({ openzeppelin: { relayerUrl: string; useEOAForwarder: boolean; domainName: string; domainVersion: string; relayerForwarderAddress?: string | undefined; }; experimentalChainlessSupport: boolean; }) | ({ biconomy: { apiId: string; apiKey: string; deadlineSeconds: number; }; }) | ({ engine: { relayerUrl: string; }; });
    gatewayUrls?: string[];
    readonlySettings?: { rpcUrl: string; chainId?: number | undefined; };
    secretKey?: string;
    supportedChains: ({ rpc: string[]; chainId: number; nativeCurrency: { symbol: string; name: string; decimals: number; }; slug: string; })[];
}

Type declaration

  • Optional clientId?: string
  • gasSettings: { maxPriceInGwei: number; speed: "standard" | "fast" | "fastest"; }
  • Optional gasless?: ({ openzeppelin: { relayerUrl: string; useEOAForwarder: boolean; domainName: string; domainVersion: string; relayerForwarderAddress?: string | undefined; }; experimentalChainlessSupport: boolean; }) | ({ biconomy: { apiId: string; apiKey: string; deadlineSeconds: number; }; }) | ({ engine: { relayerUrl: string; }; })
  • Optional gatewayUrls?: string[]
  • Optional readonlySettings?: { rpcUrl: string; chainId?: number | undefined; }
  • Optional secretKey?: string
  • supportedChains: ({ rpc: string[]; chainId: number; nativeCurrency: { symbol: string; name: string; decimals: number; }; slug: string; })[]
storage: ThirdwebStorage<IpfsUploadBatchOptions>

Upload and download files from IPFS or from your own storage service

storageHandler: ThirdwebStorage<IpfsUploadBatchOptions>

Internal handler for uploading and downloading files

verifier: ContractVerifier

Contract verifier

wallet: UserWallet

Interact with the connected wallet

Accessors

Methods

  • Get the native balance of a given address (wallet or contract)

    Parameters

    • address: string

      the address to check the balance for

    Returns Promise<{
        decimals: number;
        displayValue: string;
        name: string;
        symbol: string;
        value: BigNumber;
    }>

    Example

    const balance = await sdk.getBalance("0x...");
    console.log(balance.displayValue);
  • Get an instance of a Custom ThirdwebContract

    Type Parameters

    • TContractAddress extends string

    Parameters

    • address: TContractAddress

      the address of the deployed contract

    Returns Promise<TContractAddress extends never
        ? SmartContract<BaseContractForAddress<TContractAddress>>
        : SmartContract<BaseContract>>

    the contract

    Example

    const contract = await sdk.getContract("{{contract_address}}");
    
  • Get an instance of a Custom ThirdwebContract

    Type Parameters

    • TContractType extends "custom" | "pack" | "token" | "edition" | "split" | "vote" | "edition-drop" | "marketplace" | "marketplace-v3" | "multiwrap" | "nft-collection" | "nft-drop" | "signature-drop" | "token-drop"

    Parameters

    • address: string

      the address of the deployed contract

    • contractType: TContractType

      the ContractType of the contract to load

    Returns Promise<TContractType extends "pack" | "token" | "edition" | "split" | "vote" | "edition-drop" | "marketplace" | "marketplace-v3" | "multiwrap" | "nft-collection" | "nft-drop" | "signature-drop" | "token-drop"
        ? ContractForPrebuiltContractType<TContractType>
        : SmartContract<BaseContract>>

    the contract

    Example

    const contract = await sdk.getContract("{{contract_address}}", "nft-drop");
    
  • Get an instance of a Custom ThirdwebContract

    Parameters

    • address: string

      the address of the deployed contract

    • abi: ContractInterface

      the ABI (ContractInterface) of the contract to load

    Returns Promise<SmartContract<BaseContract>>

    the contract

    Example

    const contract = await sdk.getContract("{{contract_address}}", ABI);
    
  • Beta

    Get an instance of a Custom contract from a json ABI

    Parameters

    • address: string

      the address of the deployed contract

    • abi: ContractInterface

      the JSON abi

    Returns Promise<SmartContract<BaseContract>>

    the contract

    Example

    // Import your ABI from a JSON file
    import myABI from "./path/to/myABI.json";

    const contract = sdk.getContractFromAbi(
    "{{contract_address}}",
    // Pass in the "abi" field from the JSON file
    myABI.abi
    );
  • Get an instance of a Edition contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<Edition>

    Deprecated

    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 Drop contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<EditionDrop>

    Deprecated

    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 Marketplace contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<Marketplace>

    Deprecated

    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

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<MarketplaceV3>

    Deprecated

    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 Pack contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<Multiwrap>

    Deprecated

    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 NFT Collection Drop contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<NFTCollection>

    Deprecated

    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 Drop contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<NFTDrop>

    Deprecated

    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 Pack contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<Pack>

    Deprecated

    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 Signature Drop contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<SignatureDrop>

    Deprecated

    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 Split contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<Split>

    Deprecated

    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 Token contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<Token>

    Deprecated

    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 Drop contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<TokenDrop>

    Deprecated

    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 Vote contract

    Parameters

    • contractAddress: string

      the address of the deployed contract

    Returns Promise<Vote>

    Deprecated

    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");
  • Parameters

    • contractAddress: string

      the address of the contract to attempt to resolve the contract type for

    Returns Promise<"custom" | "pack" | "token" | "edition" | "split" | "vote" | "edition-drop" | "marketplace" | "marketplace-v3" | "multiwrap" | "nft-collection" | "nft-drop" | "signature-drop" | "token-drop">

    the ContractType for the given contract address

  • Update the active signer or provider for all contracts

    Parameters

    Returns void

  • Get an instance of the thirdweb SDK based on a private key.

    Parameters

    • privateKey: string

      the private key - DO NOT EXPOSE THIS TO THE PUBLIC

    • network: ChainOrRpcUrl

      the network (chain) to connect to (e.g. "mainnet", "rinkeby", "polygon", "mumbai"...) or a fully formed RPC url

    • options: undefined | {
          clientId?: string;
          gasSettings?: { maxPriceInGwei?: number | undefined; speed?: "standard" | "fast" | "fastest" | undefined; };
          gasless?: ({ openzeppelin: { relayerUrl: string; relayerForwarderAddress?: string | undefined; useEOAForwarder?: boolean | undefined; domainName?: string | undefined; domainVersion?: string | undefined; }; experimentalChainlessSupport?: boolean | undefined; }) | ({ biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number | undefined; }; }) | ({ engine: { relayerUrl: string; }; });
          gatewayUrls?: string[];
          readonlySettings?: { rpcUrl: string; chainId?: number | undefined; };
          secretKey?: string;
          supportedChains?: ({ rpc: string[]; chainId: number; nativeCurrency: { symbol: string; name: string; decimals: number; }; slug: string; })[];
      } = {}

      the SDK options to use

    • Optional storage: ThirdwebStorage<IpfsUploadBatchOptions>

      optional storage implementation to use

    Returns ThirdwebSDK

    an instance of the SDK

    Remarks

    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.

    Example

    const sdk = ThirdwebSDK.fromPrivateKey("SecretPrivateKey", "mainnet");
    
  • Beta

    Get an instance of the thirdweb SDK based on an existing ethers signer

    Parameters

    • signer: Signer

      a ethers Signer to be used for transactions

    • Optional network: ChainOrRpcUrl

      the network (chain) to connect to (e.g. "mainnet", "rinkeby", "polygon", "mumbai"...) or a fully formed RPC url

    • options: undefined | {
          clientId?: string;
          gasSettings?: { maxPriceInGwei?: number | undefined; speed?: "standard" | "fast" | "fastest" | undefined; };
          gasless?: ({ openzeppelin: { relayerUrl: string; relayerForwarderAddress?: string | undefined; useEOAForwarder?: boolean | undefined; domainName?: string | undefined; domainVersion?: string | undefined; }; experimentalChainlessSupport?: boolean | undefined; }) | ({ biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number | undefined; }; }) | ({ engine: { relayerUrl: string; }; });
          gatewayUrls?: string[];
          readonlySettings?: { rpcUrl: string; chainId?: number | undefined; };
          secretKey?: string;
          supportedChains?: ({ rpc: string[]; chainId: number; nativeCurrency: { symbol: string; name: string; decimals: number; }; slug: string; })[];
      } = {}

      the SDK options to use

    • Optional storage: ThirdwebStorage<IpfsUploadBatchOptions>

      optional storage implementation to use

    Returns ThirdwebSDK

    an instance of the SDK

    Example

    // 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 setup
    const sdk = ThirdwebSDK.fromSigner(signer, "mainnet");
  • Beta

    Get an instance of the thirdweb SDK based on an AbstractWallet

    Parameters

    • wallet: {
          getSigner: (() => Promise<Signer>);
      }

      the implementation of the AbstractWallet class to use for signing

      • getSigner: (() => Promise<Signer>)
          • (): Promise<Signer>
          • Returns Promise<Signer>

    • network: ChainOrRpcUrl

      the network (chain) to connect to (e.g. "mainnet", "rinkeby", "polygon", "mumbai"...) or a fully formed RPC url

    • options: undefined | {
          clientId?: string;
          gasSettings?: { maxPriceInGwei?: number | undefined; speed?: "standard" | "fast" | "fastest" | undefined; };
          gasless?: ({ openzeppelin: { relayerUrl: string; relayerForwarderAddress?: string | undefined; useEOAForwarder?: boolean | undefined; domainName?: string | undefined; domainVersion?: string | undefined; }; experimentalChainlessSupport?: boolean | undefined; }) | ({ biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number | undefined; }; }) | ({ engine: { relayerUrl: string; }; });
          gatewayUrls?: string[];
          readonlySettings?: { rpcUrl: string; chainId?: number | undefined; };
          secretKey?: string;
          supportedChains?: ({ rpc: string[]; chainId: number; nativeCurrency: { symbol: string; name: string; decimals: number; }; slug: string; })[];
      } = {}

      the SDK options to use

    • Optional storage: ThirdwebStorage<IpfsUploadBatchOptions>

      optional storage implementation to use

    Returns Promise<ThirdwebSDK>

    an instance of the SDK

    Example

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

    const wallet = new AbstractWalletImplementation();
    const sdk = await ThirdwebSDK.fromWallet(wallet, "mainnet");

Generated using TypeDoc