docs/solidity-guides/foundry/README.md
This section will guide you through writing and testing FHEVM smart contracts in Solidity using Foundry.
To write FHEVM smart contracts in Foundry, the recommended approach is to use forge-fhevm — a Foundry-native testing library for FHEVM confidential smart contracts.
forge-fhevm deploys the FHEVM host contracts (FHEVMExecutor, ACL, InputVerifier, KMSVerifier) into Foundry's test EVM, so your contract runs the same on-chain code paths as production — input verification, ACL enforcement, and handle lifecycle all execute exactly as they would on mainnet. The FHE coprocessor computation itself is simulated, with plaintext values tracked locally so you can assertEq on decrypted results directly.
It gives you, out of the box:
encryptBool, encryptUint8 … encryptUint256, encryptAddress)decrypt(), publicDecrypt(), and userDecrypt()signUserDecrypt, buildDecryptionProof)FhevmTest base contract with all infrastructure deployed in setUp(){% hint style="info" %} The only deviation from mainnet is the use of mock private keys for the input signer and KMS signer, enabling deterministic EIP-712 proof generation in tests. {% endhint %}
The fastest way to start is the FHEVM Foundry Template — a ready-to-clone Foundry project preconfigured with forge-fhevm, an example FHECounter contract, deployment scripts for local Anvil and Sepolia, and tests demonstrating the full encrypt → execute → decrypt flow.
🟨 Go to Setup Foundry to create a Foundry project from the template.
🟨 Go to Write FHEVM tests in Foundry for details on writing tests with forge-fhevm.
🟨 Go to Deploy FHEVM contracts with Foundry to learn how to deploy to a local Anvil node or to Sepolia.
🟨 Go to forge-fhevm API reference for the full list of FhevmTest helpers.