Overview
Foundry is a blazing fast, portable, and modular toolkit for Ethereum application development written in Rust. While Tenderly CLI doesn’t have a dedicated Foundry provider like Hardhat or Truffle, you can still verify and monitor your Foundry contracts on Tenderly using the CLI’s verification commands.For the most up-to-date Foundry verification workflows, refer to the Foundry verification guide in the official Tenderly documentation.
Prerequisites
Before integrating Tenderly with your Foundry project:- Have Foundry installed (
forge,cast,anvil) - Install and authenticate Tenderly CLI
- Have an active Tenderly account
- Contracts deployed to a supported network
Installation
Install Tenderly CLI
Install the Tenderly CLI for your operating system:
- macOS
- Linux
- Windows
Using Homebrew:Or using cURL:
Authenticate with Tenderly
Log in to your Tenderly account:You can also authenticate using an access key:
Foundry Project Structure
A typical Foundry project structure:Foundry Configuration
Configure yourfoundry.toml with compiler settings:
foundry.toml
Contract Development Workflow
Build Your Contracts
Compile your contracts using Forge:This generates build artifacts in the
out/ directory.Verifying Contracts on Tenderly
Since Foundry doesn’t have direct CLI integration like Hardhat, verification requires manual setup:Method 1: Using Tenderly Dashboard
Verify via Dashboard
- Go to Tenderly Dashboard
- Navigate to your project
- Click “Contracts” → “Add Contract”
- Enter contract address and network
- Upload the flattened source code
- Provide compiler version and settings from
foundry.toml
Method 2: Using Tenderly API
For automated verification, use the Tenderly API directly:script/verify-tenderly.sh
Method 3: Export to Hardhat Format
Convert Foundry artifacts to Hardhat-compatible format:Tenderly Configuration
Yourtenderly.yaml configuration:
tenderly.yaml
Testing with Tenderly Forks
Use Tenderly forks for testing without deploying:test/MyToken.t.sol
Best Practices
Keep Artifacts
Don’t delete the
out/ directory - it contains essential build artifacts for verification.Use Environment Variables
Store sensitive data like private keys and API keys in
.env files, not in scripts.Verify on Multiple Platforms
Verify contracts on both Etherscan and Tenderly for maximum transparency.
Test Thoroughly
Use Forge’s comprehensive testing framework before deploying to mainnet.
Useful Forge Commands
Troubleshooting
Build Artifacts Not Found
If you encounter issues with missing artifacts:RPC Connection Issues
If deployment fails with RPC errors:- Check your RPC URL is correct
- Ensure you have sufficient ETH for gas
- Verify network connectivity
- Try increasing gas limit:
--gas-limit 5000000
Verification Fails
If manual verification fails:- Ensure compiler version matches exactly
- Check optimizer settings match
foundry.toml - Verify contract address is correct
- Confirm contract is deployed on the specified network
Next Steps
Foundry Book
Complete Foundry documentation and guides.
Tenderly Dashboard
Monitor and debug your contracts visually.
Contract Verification
Learn advanced verification techniques on Tenderly.
Testing Guide
Master Forge testing capabilities.