Register Your Contracts Using Release

Register Your Contracts Using Release

In this tutorial, we will learn how you can register your smart contracts, making them shareable, verifiable, and deployable by anyone.

Release registers your smart contract onto our on-chain registry where anybody can view the source code, metadata, license (and more!) of your contract, as well as deploy a copy of it to any of our supported networks using the dashboard.

So without wasting any time, let's create a release.

To create a release, you'll need a smart contract!

So let's set up our hardhat environment.

Step 1 Create a folder:

Open up a terminal and execute these commands

mkdir twrelease
cd twrelease

In the same directory where you installed Hardhat, run:

npx thirdweb create --contract

thirdweb will give you a few options after the command executes.

  • You will also be asked about the framework you want to use, Choose either hardhat or forge it really doesn't matter.
  • We will use a custom contract here so choose the Empty Contract option.

Now you will have your project ready to go!

Step 2 Create your solidity file:
Inside the contracts folder, you will already have a Contract.sol file ready for you to start off with, let's go ahead and write our contract over there.

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

contract moodDiary{
	string mood;
    
    // create a function that writes a mood to the smart contract
    function setMood(string memory _mood) public {
    	mood = _mood;
    }
    
    //create a function the reads the mood from the smart contract
    function getMood() public view returns (string memory) {
		return mood;
    }
}

Step 3  Register your contract:

Now that you have your smart contract, it's time to register it. The following command will help you register and release your contract and generate a dashboard link, So go ahead and execute this command in the same directory.

npx thirdweb release

Here's what your terminal should look like:

Now click on the link in the terminal, which will redirect to the dashboard. Fill in the necessary information.

After you have filled in the description, about section, and the release version, go ahead and click on the Create Release button to release your contract.

This action will trigger a gasless transaction which you have to confirm.

After the transaction is successful, the process will take you to the dashboard, which will look something like this:

You can see all the read and write functions, including your contract ABI and smart contract code file in the Sources section.

You can now deploy your smart contract by clicking on the Deploy Now button.

This action will again trigger two transactions and ask for the chain you want to deploy your contract and the required parameters in your smart contract if there are any.

Now you can interact with your functions and use the dashboard to use all the functionalities thirdweb deploy offers.

Congratulations 🎉🥳! You just registered your smart contract, which is now associated with your wallet.

Feel free to check out the contract from this guide and deploy it.