Verify Deployed Smart Contract

Verifying your smart contract creates transperancy, thus increasing trust.

Steps to verify your deployed contracts:

  1. 2.
    Input your contract address
  2. 3.
    Choose compiler type (single file is recommended)
  3. 4.
    Choose the compiler version (according to your contract)
  4. 5.
    Choose the open-source license
  5. 6.
    Click Continue
If you select a single file as compiler type, then you can use a library like sol-merger to flatten your contract. It creates a single file that contains all the imports.
Make sure there is only one line of '// SPDX-License-Identifier'. If there are multiple lines of this, remove them except the first one.
6. Choose yes for optimization (if you deployed your contract using Hardhat) .
7. Paste the source code.
8. If the contract has a constructor, then you need to create the ABI code for the values passed to the constructor. Use Copy the result and paste it to the Argument (Constructor) section.
9. Tick the box to indicate that you are not a robot.
10. Verify and publish.


Via Command Line and Script

You can verify your contracts via a Hardhat or Truffle command line. You need to get a scan API key from first. Register if you do not have an account and then create a scan API Key. Hover over your username and then choose API Keys. You then can create an API Key.
You then need to store the API Key in a .env file which is read by your configuration file, such as: API_KEY={your API Key}
Your Hardhat configuration hardhat.config.js may look like this:
Your Truffle configuration truffle-config.js may look like:
Below are two examples of command lines to verify your contract, one in Hardhat and the other in Truffle configuration. npx hardhat verify --contract contracts/YourContractFile.sol:YourContractName --constructor-args scripts/argument.js --network testnet {contract address} truffle run verify YourContract@{contract address} --network testnet In the above examples, it is assumed that you supplied some values to the constructor when you deployed the contract.
- Using the Hardhat command line: When verifying using the Hardhat command line, you need to specify the values in a JavaScript file. In the example above, it is assumed that the file is under the scripts folder. Please refer to
- Using the Truffle command line: however, you do not need to specify any value that you passed to the contract's constructor. Truffle records these when you deploy the contract.
If you use Hardhat, you can also use the verify:verify command in a script to verify your contract. You can include this script in your deployment script. Here is an example:
© 2024 Fantom Foundation