This guide explains how to integrate Certora specifications into a Solana smart contract project using the Certora Solana Spec Template.
This directory contains formal verification specifications and all supporting files needed to verify Solana programs using Certora's tools.
Navigate to your package's src directory and clone the Certora spec template repository under the name certora.
For example, if your package is in WORKSPACE_ROOT/programs/contract:
cd WORKSPACE_ROOT/programs/contract/src
git clone https://github.com/Certora/solana-spec-template certoraUse the provided setup script to configure the specifications for your workspace and package.
cd certora
python certora-setup.py --workspace WORKSPACE_ROOT --package-name contractIf everything looks good, re-run the setup script with the --execute flag to apply the changes:
python certora-setup.py --workspace WORKSPACE_ROOT --package-name contract --executeTo include the specifications in your Rust crate, add the following to your lib.rs:
pub mod certora;And add certora feature under [features] in Cargo.toml for the package
[features]
...
certora = ["no-entrypoint", "dep:cvlr", "dep:cvlr-solana"]This makes the Certora specification code available during compilation (when the certora feature is enabled).
- Make sure to enable the
certorafeature in yourCargo.tomlto include dependencies and settings necessary for formal verification. - Specification files are expected to be under
src/certora/specs. - Adjust
solana_inlining.txtandsolana_summaries.txtfiles in theenvsfolder to fine-tune inlining and function summaries for verification.