Using Thirdweb

thirdwebarrow-up-right is a development framework that allows you to easily build Web3 functionality into your applications. It provides tools to create, deploy, and interact with smart contracts using a unified developer workflow.

In this guide, you will learn how to use the thirdweb CLIarrow-up-right to deploy a smart contract to the CelesChain Testnet.


Objectives

By the end of this guide, you will be able to:

  • Create a project with a smart contract using thirdweb

  • Deploy smart contracts to CelesChain using the thirdweb CLIarrow-up-right

  • Interact with deployed smart contracts using the thirdweb SDK


Prerequisites

The interactive thirdweb command line interfacearrow-up-right has everything needed to create, build, and deploy smart contracts and applications to CelesChain.

Install the CLI globally:

npm i -g @thirdweb-dev/cli

Or use npx to always run the latest version:

npx thirdweb

Creating a Project

You can use the thirdweb CLI arrow-up-rightto create a new project that includes a smart contract. Alternatively, you can deploy prebuilt NFT, Token, or Marketplace contracts directly from the thirdweb Explorearrow-up-right page.

To create a new smart contract project:

This will trigger an interactive setup:

  • Enter a project name

  • Select Hardhat

  • Select a base contract such as ERC721

  • Select None for optional extensionsarrow-up-right, unless needed


Exploring the Project

Open the newly created folder in your editor. Inside the contracts directory, you will find a Contract.sol file.

The contract typically inherits from a thirdweb base contract. Example:

The code imports ERC721Base, inherits it, and implements any required methods.arrow-up-right This pattern allows you to add custom logic on top of audited base contract implementations.


Deploying the Contract

You can deploy your contract to CelesChain Testnet using the CLIarrow-up-right.

From your project root, run:

This command will:

  • Compile your contracts

  • Let you select which contract to deploy

  • Upload ABI and source code to IPFS

  • Open the deployment interface in the dashboard

In the dashboard, enter your constructorarrow-up-right parameters:

  • _name

  • _symbol

  • _royaltyRecipient

  • _royaltyBps

Then select:

➡️ CelesChain Testnet as your deployment network.

Click Deploy Now.

After deployment, you will be redirected to the thirdweb dashboard for contract management.


Interacting With Your Contract

thirdweb provides SDKs for:

To build a frontend application that interacts with your deployed contract, you can scaffold a Web3-enabled React app.

Create a thirdweb React project:

Interactive steps:


Project Structure

Open the generated folder. In src/index.tsxarrow-up-right, you will see the app wrapped with ThirdwebProviderarrow-up-right.

This wrapper configures the active chain, allowing the SDK to connect to contracts deployed on CelesChain.

Since we deployed to CelesChain Testnet, set the active chain to CelesChain Testnet:


Interacting With the Contract in the App

Use the contract address from the thirdweb dashboardarrow-up-right.

To read contract data:

To write transactions:

thirdweb also provides hooks for ERC20, ERC721, and other supported interfaces.

For more information, see the official thirdweb SDK documentation.arrow-up-right


Deploying the Web Application

You can deploy your app to IPFS using:

This will:

  • Build your application

  • Upload the build to IPFS

  • Generate a permanent link hosted on decentralized storagearrow-up-right

Your application is now live and fully connected to smart contracts deployed on CelesChain Testnet.

Last updated