Thirdweb SDK
How to use Thirdweb CLI to deploy contracts and connect your dApps to Mantle Network
Mantle v2 Tectonic has been released, please move to the new documentation!
2023/12/04 Thirdweb released a report about recent security vulnerabilities in the commonly used open-source library for web3 smart contracts. All developers who have previously deployed contracts are advised to ensure that the contract is secure, see details here.
thirdweb is a complete web3 development framework that provides everything you need to connect your apps and games to decentralized networks like Mantle Network.
Visit the thirdweb docs to find more info and instructions on the thirdweb CLI
Installing Thirdweb CLI
You can install the thirdweb CLI globally on your machine using npm
by running the following command.
Creating a New Project
To create a new project with thirdweb installed and configured, run:
Deploying a Contract
See the section on deploying a contract Using Thirdweb CLI .
Connecting Your App
thirdweb offers SDKs for a range of programming languages, such as React, React Native, TypeScript, Python, Go, and Unity.
Creating a New App
Run the following command to start creating a new application:
Input your preferences for the command line prompts:
Give your project a name
Choose your network: We will choose EVM for Mantle Network
Choose your preferred framework: Next.js, CRA, Vite, React Native, Node.js, or Express
Choose your preferred language: JavaScript or TypeScript
To create a new application pre-configured with thirdweb’s SDKs, run the following command and choose your preferred configurations:
Install Into an Existing Project
You can install thirdweb into your existing project by running:
Initialize SDK on Mantle Network
Wrap your application in the ThirdwebProvider
component and change the activeChain
to Mantle Network.
Get Contract
To connect to your contract, use the SDK’s getContract
method.
Calling Contract Functions
For extension based functions, use the built-in supported hooks. The following is an example using the NFTs extension to access a list of NFTs owned by an address-
useOwnedNFTs
Complete reference available here: https://portal.thirdweb.com/react/react.usenft
Use the
useContractRead
hook to call any read functions on your contract by passing in the name of the function you want to use.
Complete reference available here: https://portal.thirdweb.com/react/react.usecontractread
Use the
useContractWrite
hook to call any write functions on your contract by passing in the name of the function you want to use.
Complete reference available here: https://portal.thirdweb.com/react/react.usecontractwrite
Connect Wallet
Create a custom connect wallet experience by declaring supported wallets passed to your provider.
Add in a connect wallet button to prompt end-users to log in with any of the above supported wallets.
Complete reference available here: https://portal.thirdweb.com/react/connecting-wallets
Deploying Your App
Use the following command to deploy your static web application on IPFS:
Upon running this command:
Your app is built for production and stored using thirdweb's Storage solution
The production build is uploaded to IPFS
A unique URL is generated for your application that serves as a permanent hosting location
Learn more here: https://blog.thirdweb.com/guides/how-to-host-your-web-app-on-ipfs/
Support
In case you have questions, or if you run into issues during deployment, feel free to reach out to us via Discord / Telegram, or get in touch with the thirdweb support at https://support.thirdweb.com.
Last updated