Skip to main content

Deploying a smart contract with thirdweb

thirdweb is an end-to-end framework for smart contract development and deployment.

It enables developers to deploy, standard contracts such as ERC-20, ERC-721, or ERC-1155, etc. without writing a line of code. More of this is discussed in the via thirdweb Explore section.

Furthermore, developers looking to develop and deploy custom smart contracts can use the Solidity SDK provided by thirdweb, among others such as TypeScript SDK and Unity SDK. However, for this guide, we will mainly talk about the thirdweb Explore and the Solidity SDK.


  • Explore: Ready to deploy pre-built contracts.
  • Build (Solidity SDK): Write custom smart contracts.
  • Deploy: Support for contract deployment built for any use case.
  • Publish: Publish your contracts onchain.
  • Interact: Interact with smart contracts and integrate smart contracts directly into your app.

Deploying pre-built contracts via thirdweb Explore

In case you want to deploy a pre-built contract without any customization, thirdweb offers a convenient way to do so with Explore. Check out the following video for a quick introduction to Explore:


Before you try out the following guides, please ensure that your wallet is connected to Lisk's Network and it has sufficient funds in it. For more information, see the Wallet funds section.

The following videos describe step-by-step, how to deploy different tokens with pre-built contracts on Lisk.

via Solidity SDK


Node.js v18+

Download and install Node v18+.

If you are using nvm to manage your node versions, you can just run nvm install 18.

Installing and Configuring thirdweb

To develop custom contracts, it is required to download and configure thirdweb.

  1. To install thirdweb run the following command:
    npm i -g thirdweb
  2. Set up your thirdweb API key.

Logging in with your API key

  1. The next step is to log in to thirdweb via CLI, so to do that type the following:
    thirdweb login
  2. Once, you execute the aforementioned command, the terminal will open a browser window where it will ask you to authenticate the device:

    💎 thirdweb v0.13.60 💎

    Automatically attempting to open a link to authenticate with our dashboard...

    If the browser doesn't open, please use this link to authenticate:

    ⠙ Waiting for a response from the dashboard
  3. Once you authenticate via the browser, the terminal will log the following message:
    Successfully linked your account to this device 
  4. You can verify your login status by re-running the thirdweb login command.
    💎 thirdweb v0.13.60 💎

Creating a project

The first step of deploying smart contracts to Lisk is to set up your development environment by creating a project. The thirdweb supports two of the most popular smart contracts development frameworks such as Foundry and Hardhat.

For this guide, we are using Foundry for smart contract development. However, you can use Hardhat if you are more comfortable with that. The project creation steps are similar for both Foundry and Hardhat.

  1. For Foundry, install its prerequisites on your system before proceeding with the creation of a thirdweb project.

  2. Once, the aforementioned is installed, proceed with the following:

    npx thirdweb create
  3. Choose Contract as the type of your project and give an appropriate name to your project.


    💎 thirdweb v0.13.60 💎

    ✔ What type of project do you want to create? › Contract
    ✔ What is your project named? … thirdweb-contracts
  4. Next, choose Forge as the framework, NFT as the name of the contract, ERC721 as the type of smart contract, and None for the extensions option.


    In case you want to use the Hardhat framework, choose Hardhat instead of Forge in the following dialogue.

    ✔ What framework do you want to use? › Forge
    ✔ What will be the name of your new smart contract? … NFT
    ✔ What type of contract do you want to start from? › ERC721
    ✔ What extensions do you want to add to your contract? › None
  5. thirdweb will install all the relevant dependencies and set up a contract project for you.

    Execution logs of the thirdweb contract project creation
    Creating a new thirdweb contracts project in /Users/XYZ/Lightcurve-Code/L2/thirdweb-contracts.

    Downloading files. This might take a moment.
    Installing packages. This might take a couple of minutes.

    yarn install v1.22.19
    warning ../../../package.json: No license field
    info No lockfile found.
    [1/4] 🔍 Resolving packages...
    [2/4] 🚚 Fetching packages...
    [3/4] 🔗 Linking dependencies...
    [4/4] 🔨 Building fresh packages...
    success Saved lockfile.
    ✨ Done in 9.73s.

    Initialized a git repository.

    Success! Created thirdweb-contracts at /Users/XYZ/Lightcurve-Code/L2/thirdweb-contracts

    Inside that directory, you can run several commands:

    yarn build
    Compiles your contracts and detects thirdweb extensions implemented on them.

    yarn deploy
    Deploys your contracts with the thirdweb deploy flow.

    yarn publish
    Publishes your contracts with the thirdweb publish flow.

    We suggest that you begin by typing:

    cd thirdweb-contracts
  6. Foundry applications created with thirdweb have a similar directory structure to the following:

    ├── .github
    ├── .cache
    ├── lib
    ├── node_modules
    ├── out
    ├── src
    │   └── NFT.sol
    ├── test
    │ └── Contract.t.sol
    ├── .gitignore
    ├── .gitmodules
    ├── foundry.toml

Creating the smart contract

For ease and security, thirdweb already provides base contracts, which can be easily customized via code. Since we chose to create an ERC721 token earlier, an NFT.sol file will be present in the src/ folder. The NFT.sol will already have the base code required for an NFT contract.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@thirdweb-dev/contracts/base/ERC721Base.sol";

contract NFT is ERC721Base {
address _defaultAdmin,
string memory _name,
string memory _symbol,
address _royaltyRecipient,
uint128 _royaltyBps

Building the smart contract

Once the smart contract's code is ready, it must be built using thirdweb.

  1. To do that, simply run:
    npx thirdweb build
  2. If the smart contract doesn't have any errors, you will see the following output on the terminal:

    💎 thirdweb v0.13.62 💎

    ✔ Detected project type: foundry
    ✔ Compilation successful
    ✔ Choose which contracts to run detection on · NFT

    🔎 Detected extension on NFT
    ✔️ ERC721
    ✔️ ERC721Burnable
    ✔️ ERC721Supply
    ✔️ ERC721AQueryable
    ✔️ ERC721Mintable
    ✔️ ERC721BatchMintable
    ✔️ Royalty
    ✔️ ContractMetadata
    ✔️ Ownable
    ✔️ Fallback

    ℹ Suggested extensions
    - ERC721Enumerable -
    - ERC721LazyMintable -
    - ERC721SignatureMintV1 -
    - ERC721SignatureMintV2 -
    - ERC721TieredDrop -
    - ERC721ClaimCustom -
    - ERC721ClaimZora -
    - ERC721ClaimConditionsV1 -
    - ERC721ClaimConditionsV2 -
    - ERC721ClaimPhasesV1 -
    - ERC721ClaimPhasesV2 -
    - ERC721SharedMetadata -
    - ERC721LoyaltyCard -
    - ERC721UpdatableMetadata -
    - Permissions -

    ℹ Once you're done writing your contracts, you can run the following command to deploy them:

    yarn deploy

Deploying the smart contract

All checks passed, which means that the smart contract is ready to be deployed using thirdweb.

  1. To do that, simply run:

    npx thirdweb deploy
  2. If the smart contract doesn't have any errors, you will see the following output on the terminal:


    💎 thirdweb v0.13.60 💎

    ✔ Detected project type: foundry
    ✔ Compilation successful
    ✔ Choose which contract(s) to deploy · NFT
    ✔ Upload successful
    ✔ Open this link to deploy your contracts:
  3. The terminal will also open a browser window, directing towards a unique URL, as highlighted above.

  4. Fill out the form as suggested in the Fill Parameter section.

  5. Once you fill out the details of the ERC721 smart contract, click on the Deploy Now button and it will deploy the contract to the chosen network of your wallet.


If you want to test your Foundry-based contract, follow the steps mentioned in the Testing the Smart Contract guide.

Interacting with the Smart Contract

Once the contract is deployed, you can interact with it via Explore. The following videos describe step-by-step, how to interact with different token contracts on Lisk.