🎉 ⏱ Ready to build? Get early access now!⏱ 🎉
Getting Started with thirdweb SDK
Last updated:
February 2, 2022
You're convinced. You want to start NOW. Say no more 👇
Developers assemble!
In a nutshell, our SDK integrates seamlessly on the frontend or backend, depending on your use case. We've written an article over here, where we go more in dept.
This is what we're going to cover here:
- Your design based on your use case
- Set up your dev environment
- Using the SDK
Dependencies
First make sure you install the dependencies.
If you're using JavaScript or TypeScript 👇
npm install @3rdweb/sdk ethers // packages below are for frontend components npm install @3rdweb/react @3rdweb/hooks
If you're using Python
pip install thirdweb-sdk
Your use case
Before we get to the fun part of coding, let's talk about design. Depending on your use case, you'd want to use our sdk in a specific way. To cater for your web3 needs, we built smart contracts on steroids, Modules
. Modules enable the feature you want inside your app.
For example, if you want a mint
functionality in your app, then you'd need the NFT Collection
module. Maybe you want to reward users with your own tokens when they complete a specific action, then you want to have a look at our Token
module. Auction your NFTs on your own Marketplace? We got you → the Marketplace
module is what you need.
Setting up a module is a matter of a few clicks! Click here to create and deploy your first module.

Overview of our modules
Based on your needs you can pick modules, which contain the functionalities and features that you want in your app.
Next up, setting up your dev environment.
Using our SDK - Setting up your dev environment
Ok, so you know what you want to build. You deployed the modules you need through the dashboard. Now it's time to integrate them into your own code!
General steps:
- Instantiate the SDK
- Pass the module address
- Use the methods inside a module
1. Read data from the blockchain
If you just want to read data from the blockchain, all you need is our @3rdweb/sdk
.
import { ThirdwebSDK } from "@3rdweb/sdk"; // This url indicates which chain you want to connect to const rpcUrl = "https://polygon-rpc.com/"; const sdk = new ThirdwebSDK(rpcUrl);
Side note, this is a public RPC. If you have your own dedicated RPC Alchemy or Infura, you can use that one instead.
Reading data from the blockchain with our sdk looks like this 👇
// Initialize market module by passing in the module address const marketplaceModuleAddress = "<MARKETPLACE_MODULE_ADDRESS>"; const marketplace = sdk.getMarketplaceModule(marketplaceModuleAddress); // Get all the listings marketplace.getAllListings();
2. Make things happen on the blockchain
When you buy an NFT or make anything happen on the blockchain, you're doing more than reading data from the blockchain. Every action that changes the data stored on the blockchain — like buying an NFT — is signed off by a wallet.
A provider is your connection to the blockchain.
To read data from the blockchain, a provider
needs an RPC url. To write data to the blockchain i.e. send a transaction to the blockchain, — it needs to be able to interface with a wallet.
The Signer
object is a clean interface to interact with a wallet.
Once you have a provider, you can use it to instantiate the SDK to write to the blockchain on behalf of a connected user.
// Follow our guides to get a signer (from a connected wallet or your private key) const sdk = new ThirdwebSDK(signer); // Get your marketplace module const marketplaceModuleAddress = "0xC06adC34097afa2085324D4192fbE9206059f8e0"; const marketplace = sdk.getMarketplaceModule(marketplaceModuleAddress); // Now you can buy from the connected signer marketplace.buyoutDirectListing({ listingId: 1, quantityDesired: 1, });
How do you get a signer
? Glad you asked.
To get a signer we need to connect the user's wallet to our app. Let's build a connect wallet
button. thirdweb has a component for this 👇
Check out this guide first to understand how the connect wallet
component works for frontend and this guide is highly encouraged to read, to understand how the wallet information is used to instantiate the sdk and methods.
Information like chain and type of wallet, will be used to instantiate the sdk, by getting the provider
from useWeb3()
.
With the sdk you can access your deployed modules to mint NFTs, transfer tokens or list NFTs on your marketplace.
3. Writing scripts
Warning: This method is not suitable for frontend.
The final way to initialise the sdk is to make use of your own wallet's private keys
.
This method should be used with extreme care on the backend, making sure not to expose your private keys. If you want to know more about this method, check out this guide.
Our SDK documentation
To find out more about our SDKs, check out our documentations 👇
Next