Installation & Setups
- All imports from
@thirdweb-dev/*
should be replaced withthirdweb
SDK with sub-exports. - The new SDK is
function
based rather thanclass
based for better tree shaking and performance. - All contract calls are now prepared using
prepareContractCall
and sent using theuseSendTransaction
function. - Transactions are submitted without waiting for receipt by default. You can call the
useSendAndConfirmTransaction
function to wait for the transaction to be mined.
Once you have installed the latest package (alongside the older version that you want to replace), you can start the migration process.
In the latest SDK, the ThirdwebProvider
no longer accepts any prop such as activeChain
, clientId
or any extra SDK options.
Instead, you only need to pass the clientId when necessary (we'll talk more about this in a few sections below).
If you're currently using the @thirdweb-dev/sdk
, you can progressively migrate to the new thirdweb
SDK. Both SDKs can be used side by side and are interoperable with each other.
In React, you can mix and match the v4 and v5 ThirdwebProvider
, that gives you access to the hooks and functionality of both SDKs.
This way, once you have moved away from all the v4 functionalities, you can finally remove the ThirdwebProviderV4
from your app.
Similar to v4's ConnectWallet
component, the latest version has the ConnectButton
component which has the same functionality.
However, unlike with v4 where the number of supported wallets is limited (about 20), and adding more wallets mean your app becomes heavier, the SDK v5 supports over 300 wallets with virtually no impact to your application.
Here's how you use the new ConnectButton
:
To learn more about the new ConnectButton
, head over to the Playground.
Notice how you are passing the thirdweb client to the component itself and not to the ThirdwebProvider
like in v4?
By not putting every config inside the context wrapper, we were able to make the SDK v5 much more lightweight since you only load what you need!
Tip: You can reuse the thirdweb client object by putting it in a file and export it.