Verify Smart Contracts on your Saga Chainlet

Kyle
Sagaxyz
Published in
3 min readJul 10, 2024

Smart Contracts are the foundational element in blockchain technology, automating agreements and transactions without the need for intermediaries. These self-executing contracts, encoded directly onto the blockchain, promise unparalleled efficiency and transparency. However, with great power comes great responsibility. The immutability and autonomous nature of smart contracts make them both a revolutionary tool and a potential risk. This is why verifying smart contracts is not just important — it’s essential. Ensuring the security, correctness, and reliability of these digital agreements is critical to safeguarding assets, maintaining trust, and fostering the widespread adoption of blockchain technology. In this blog post, we will explore the key reasons why every smart contract needs to be thoroughly verified before deployment.

In this tutorial, we will:

  1. Locate the Smart Contract on the block explorer
  2. Generate Input JSON file
  3. Verify Smart Contract

Locating the Smart Contract on the block explorer

Once a smart contract is deployed, the transaction is generated on the block explorer. You can find your chainlet block explorer from the chainlet dashboard.

If you click on the transaction, the details page will open up showing the smart contract address.

Clicking on the contract address will open up the contract detail page. In the Contracts tab, you should see the Verify button.

Generating Input JSON file

Before we begin to verify the contract, we need to prepare the JSON input file. To create that, head over to foundry or hardhat directory of the contracts. Look for the following path:

Contracts -> artifacts -> build-info

Click on the JSON file associated with the smart contract.

From the JSON file, copy the text from the “input” field. Ensure to copy from the starting to the ending of the curly brace. Now paste this in an empty JSON file and save it. We now have everything we need to verify the smart contract.

Verifying the Smart Contracts

Now we head back to the Contract tab on the block explorer and click on “Verify”.

In the amrt Contract Verification page, select the preferred verification method. The block explorer offers solidity and vyper options, For this example, we will use the Solidity (Standard JSON input).

It will now ask for the compiler version. Ensure that you select the same version used in teh smart contract. You can include nightly builds, if required.

Finally, upload the saved Standard Input JSON file we created.

Hit “Verify & Publish”.

If everything went on well, you should see a green checkmark next to the Contract tab and the source code will be visible.

Your smart contract is now verified.

--

--