Docs

Migration from SDK v4

Progressive migration

If you're currently using the @thirdweb-dev/sdk, you can progressively migrate to the new thirdweb unified SDK. Both SDKs can be used side by side and are interoperable with each other.

High level changes

  • All imports from @thirdweb-dev/* should be replaced with thirdweb unified SDK with sub-exports.
  • The unified SDK is function based rather than class based for better tree shaking and performance.
  • All contract call are now prepared using prepareContractCall and sent using the sendTransaction function.
  • Transactions are submitted without waiting for receipt by default. You can call the waitForReceipt function to wait for the transaction to be mined.

TypeScript Cheat sheet

Task@thirdweb-dev/sdkthirdweb unified SDK
Chainsimport { Sepolia } from "@thirdweb-dev/chains"import { sepolia } from "thirdweb/chains"
Walletsimport { MetaMaskWallet } from "@thirdweb-dev/wallets"import { metamaskWallet } from "thirdweb/wallets"
Initializenew ThirdwebSDK(...)createThirdwebClient({ ... })
Contractawait sdk.getContract(...)getContract(...) // no await
Readawait contract.call(...)await readContract(...)
Prepareawait contract.prepare(...)prepareContractCall(...) // no await
Sendawait contract.call(...)await sendTransaction(...)
Extensionsawait contract.erc721.getAll()await getNFTs(...)

React Cheat sheet

Task@thirdweb-dev/reactthirdweb unified SDK
Providerimport { ThirdwebProvider} from @thirdweb-dev/reactimport { ThirdwebProvider } from "thirdweb/react"
ContractuseContract(...)getContract(...) // not a hook
ReaduseContractRead(...)useReadContract(...)
WriteuseContractWrite(...)useSendTransaction()
ExtensionsuseNFTs(...)useReadContract(getNFTs, { ... })