Overview
The Tenderly CLI integrates seamlessly with Hardhat projects through the@tenderly/hardhat-tenderly plugin. This integration enables automatic tracking of contract deployments, making them available for verification and monitoring in the Tenderly Dashboard.
For complete contract verification workflows, refer to the Hardhat verification guide in the official Tenderly documentation.
Prerequisites
Before integrating Tenderly with your Hardhat project, ensure you have:- A Hardhat project initialized
- Node.js and npm/yarn installed
- Tenderly CLI installed and authenticated
- An active Tenderly account
Installation
Install the Hardhat Tenderly Plugin
Install the
@tenderly/hardhat-tenderly package as a development dependency:Configure Your Hardhat Project
Add the plugin to your Hardhat configuration file:
- JavaScript
- TypeScript
Add this line to your
hardhat.config.js:hardhat.config.js
Usage in Deployment Scripts
Tracking Single Contract Deployments
When deploying contracts, use thepersistArtifacts method to track them in Tenderly:
scripts/deploy.js
Tracking Multiple Contract Deployments
ThepersistArtifacts method accepts variadic parameters, allowing you to track multiple contracts in a single call:
scripts/deploy-multiple.js
Complete Integration Workflow
Deploy and Track Contracts
Run your deployment script with the For testnet or mainnet deployments:
persistArtifacts calls:Project Structure
After integration, your project will include:Configuration File
Thetenderly.yaml file created by tenderly init contains your project configuration:
tenderly.yaml
Best Practices
Always Call persistArtifacts
Ensure you call
persistArtifacts after every contract deployment to maintain tracking consistency.Deploy Before Verification
The
deployments directory must exist before running verification commands. Always deploy first.Network-Specific Deployments
Use the
--network flag to track deployments on different networks separately.Version Control
Commit
tenderly.yaml to version control, but consider adding deployments/ to .gitignore for local testing.Troubleshooting
No deployments Directory
If you see errors about missing deployment artifacts:Check persistArtifacts Calls
Confirm that
hre.tenderly.persistArtifacts() is called in your deployment scripts.Verification Fails
If contract verification fails:- Ensure you’re authenticated:
tenderly login - Verify the project is initialized: check for
tenderly.yaml - Confirm contracts are deployed to supported networks
- Check that build artifacts are up to date
Next Steps
Verify Contracts
Learn how to verify contracts on Tenderly after deployment.
Push Contracts
Explore pushing contracts to multiple projects and networks.
Monitor Transactions
Set up transaction monitoring and alerts in the Tenderly Dashboard.
Hardhat Plugin Docs
View the complete hardhat-tenderly plugin documentation.