Skip to content

Contract Verification

Introduction

Verifying smart contracts on a block explorer improves the transparency and security of deployed smart contracts on the blockchain. Users can view the source code for verified contracts and, in some cases, interact directly with the contract's public methods through the block explorer's interface.

This guide will outline the steps for verifying Solidity smart contracts on Polkadot Hub, through the Subscan block explorer, explicitly focusing on the Westend Hub for testing purposes.

Deploying the Contract

To verify a smart contract on the Subscan explorer, the contract must first be deployed on the target network. For further guidance about this process, you can check the Deploy a NFT or Deploy an ERC-20 tutorials.

You can deploy your Solidity smart contract using various development tools compatible with the Polkadot Hub, such as Remix, Hardhat, or other preferred tools that connect to the Polkadot network.

This guide uses a simple incrementer contract as an example. The Solidity code is the following:

Incrementer.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

contract Incrementer {
    uint256 public number;

    constructor(uint256 _initialNumber) {
        number = _initialNumber;
    }

    function increment(uint256 _value) public {
        number = number + _value;
    }

    function reset() public {
        number = 0;
    }
}

Collecting Information for Contract Verification

You will need to collect some information related to the contract's compiler and deployment to verify it successfully:

  1. Take note of the name of the contract (in this example, Incrementer)
  2. Take note of the Solidity compiler version used to compile the contract (in this example, v0.8.28+commit.7893614a)

  3. If optimization is enabled during compilation, take note of the optimization runs parameter

  4. After deployment, take note of the deployed contract address. This can be found in the console output of your deployment tool or the interface of tools like Remix

Verify the Contract

Follow these steps to verify your contract on Westend Hub Subscan:

  1. Navigate to the Subscan explorer for Westend Hub
  2. Open the Tools dropdown and select Contract Verification Tool

  3. Fill in the contract's information in the verification form:

    • Contract address
    • Select the compiler type. For this Incrementer.sol example, select Solidity (Single file)
    • Fill in the contract name (e.g., Incrementer)
    • Select the compiler version used to compile the contract (e.g., v0.8.28+commit.7893614a)
    • Add the Solidity source code of the contract

  4. Click the Verify and Publish button to verify the contract

Verification Results

After a successful verification, you should be redirected to a new page (for this example, you can check the following contract page). The contract page on Subscan will now display:

  • Contract information
  • Contract ABI
  • Contract's source code
  • Contract bytecode

This verified contract status gives users confidence that the contract's source code matches the deployed bytecode on the blockchain.

Conclusion

Verifying your Solidity smart contracts on Subscan enhances transparency and trust in your decentralized applications on Polkadot Hub. Users can inspect the source code and interact with your contracts directly through the explorer interface, which is crucial for building community trust and facilitating the adoption of your project.

Remember that verification is a one-time process for each deployed contract. Once your contract is verified, its source code will remain accessible on the blockchain explorer for as long as the explorer maintains its database.

Last update: May 29, 2025
| Created: May 29, 2025