Skip to main content
Works on: Virtual Environments and public networks (mainnets and testnets). The same plugin handles both; point it at the right network in hardhat.config.ts.
The Tenderly-Hardhat plugin verifies contracts deployed from Hardhat against Virtual Environments or public networks. Use automatic verification to verify on every deploy, or manual verification to call tenderly.verify() explicitly from your scripts.
On public networks, the plugin verifies publicly by default. To verify privately (visible only inside your project/organization), set privateVerification: true in hardhat.config.ts. See Configure authentication and verification visibility.

Versions and compatibility

Depending on the Ethers version you’re using with Hardhat, you need to download the corresponding version of the Tenderly-Hardhat plugin.
It’s highly recommended to switch to Ethers 6 and use the latest version of the Tenderly-Hardhat plugin for security and performance reasons, as well as additional features.

Verification methods

The Tenderly-Hardhat plugin supports three methods for contract verification.
  • Automatic verification (recommended): Simply import and set up the plugin. This method is ideal for verification during deployment because the process is fully automated. Automatic verification works with plain hardhat deployment setup, as well as using hardhat-ignition. Control automatic verification by using the TENDERLY_AUTOMATIC_VERIFICATION environment variable.
  • Manual verification (low-code): Offers an explicit verification step within your code, which is useful for scenarios like post-deployment verification, conditional verification (e.g. only after a failing test), or verifying factory contracts’ instances.
  • Verbose manual verification (high-code): Provides detailed control over the verification process, specifying library addresses, source codes, and compiler configurations. This is necessary for verifying multiple contracts with varying compiler versions or settings.

Examples

The best way to explore the automatic verification process is to go through an example that you can in our GitHub repo. All the examples use the sample Greeter contract. Browse the example projects directly:

Tenderly-Hardhat plugin setup

Follow the steps below to install and initialize the Tenderly-Hardhat plugin.
In the following sections, you’ll learn how to verify contracts using the different verification methods.

Automatic verification

Automatic verification occurs seamlessly when you deploy a contract using Ethers.js. The automatic verification approach will perform the verification automatically after collecting the compiler settings, the deployed contract’s address, and the source code. To enable or disable automatic verification, use the TENDERLY_AUTOMATIC_VERIFICATION environment variable recognized by the plugin. The Tenderly-Hardhat plugin will verify contracts when it detects that the contract has been deployed, and Ethers has received the receipt of the deployment transaction. To enable this, you need to await for deployment when you deploy contracts using Ethers’ helper methods ethers.deployContract() and ethers.getContractFactory(), by calling waitForDeployment() or deployed() on the contract instance, respectively.
You need to capture the reference to the contract object returned by the waitForDeployment() (Ethers 6) and deployed() (Ethers 5) if you intend to interact with that contract.

Verifying proxy contracts

Automatic verification of proxy contracts deployed and upgraded with hardhat-upgrades is possible with the following versions of @tenderly/hardhat-tenderly package:
  • >= 1.10.0
  • >= 2.1.0
For versions 1.x.x < 1.10.0 and 2.x.x < 2.1.0 follow the proxy verification guide.

Manual verification

Low-code verification through tenderly.verify() allows you to be explicit about the exact point of verification within a deployment script or a Hardhat test. This method is particularly beneficial for:
  • Verifying previously deployed contracts through custom scripts.
  • Verifying instances created by factory contracts.
  • Enhancing test runs by selectively verifying contracts at the end of a failing suite (after), which speeds up execution.
To manually control the verification, disable automatic verification by changing the TENDERLY_AUTOMATIC_VERIFICATION to false when running scripts.

The verify function

The verify() function takes an object where you must provide the:
  • name of the contract
  • address where the contract is deployed
  • libraries (optional) used by the contract
The Tenderly-Hardhat plugin will pick up the existing compiler configuration and contract source code to perform the verification of the contracts you’ve specified.
It’s necessary to invoke verify() after the contract has been deployed.If you’re performing a verification alongside to deployment, you have to await for waitForDeployment() in the case of Ethers 6, and deployed() in the case of Ethers 5.
If you’re verifying multiple contracts, the function has variadic arguments:

Verbose manual verification

The method verifyMultiCompilerAPI() gives you full control over the verification process, allowing you to specify every detail of the verification process. This is rarely recommended but can be useful if you’re verifying contracts compiled with different compiler versions or configurations. The fully controlled verification method allows you to explicitly:
  • Specify the source code of the contracts (sources)
  • Set compilation arguments (compiler)
  • Set linked libraries (libraries)
The following example demonstrates how to perform a fully controlled verification.

Verification arguments

The verifyMultiCompilerAPI() method takes one argument — an array of contract objects. Each contract object consists of the following: