A proxy contract that validates Cairo facts by calling isCairoFactValid on a target validator contract. The contract includes an owner-controlled mechanism to update the target validator address.
The main proxy contract with the following features:
- Owner-controlled: Only the owner can update the target contract address
- Public validation: Anyone can call
isValidto check fact validity - Ownership transfer: Owner can transfer ownership to another address
| Function | Access | Description |
|---|---|---|
isValid(bytes32 fact) |
Public | Check if a fact is valid (calls target with is_mocked=true) |
isValidWithMock(bytes32 fact, bool is_mocked) |
Public | Check fact validity with custom is_mocked parameter |
setTargetContract(address) |
Owner only | Update the target validator contract address |
transferOwnership(address) |
Owner only | Transfer contract ownership |
getTargetContract() |
Public | Get current target contract address |
owner() |
Public | Get current owner address |
targetContract() |
Public | Get current target contract address |
OwnershipTransferred(address indexed previousOwner, address indexed newOwner)TargetContractUpdated(address indexed previousTarget, address indexed newTarget)
forge installSet the following environment variables:
export RPC_URL="<your_rpc_url>"
export PRIVATE_KEY="<your_private_key>"
export TARGET_CONTRACT="<target_validator_address>"forge script script/FactValidityProxy.s.sol:FactValidityProxyScript \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--broadcastImportant: After deployment, update deployments.json with your deployment details.
forge script script/FactValidityProxy.s.sol:FactValidityProxyScript \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--broadcast \
--verify \
--etherscan-api-key $ETHERSCAN_API_KEYforge verify-contract <DEPLOYED_ADDRESS> \
src/FactValidityProxy.sol:FactValidityProxy \
--chain sepolia \
--constructor-args $(cast abi-encode "constructor(address)" $TARGET_CONTRACT) \
--etherscan-api-key $ETHERSCAN_API_KEYDeploys the FactValidityProxy contract.
forge script script/FactValidityProxy.s.sol:FactValidityProxyScript \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--broadcastChecks if a fact hash is valid (read-only, no gas required).
PROXY_ADDRESS=<deployed_proxy_address> \
FACT_HASH=<bytes32_fact_hash> \
forge script script/CheckFactValidity.s.sol:CheckFactValidityScript \
--rpc-url $RPC_URLUpdates the target validator contract address (owner only).
PROXY_ADDRESS=<deployed_proxy_address> \
NEW_TARGET=<new_target_address> \
forge script script/SetTargetContract.s.sol:SetTargetContractScript \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--broadcastTests multiple contract functions including isValid and optionally setTargetContract.
# Test isValid only (read-only)
PROXY_ADDRESS=<deployed_proxy_address> \
forge script script/TestFactValidityProxy.s.sol:TestFactValidityProxyScript \
--rpc-url $RPC_URL
# Test isValid + setTargetContract
PROXY_ADDRESS=<deployed_proxy_address> \
NEW_TARGET=<new_target_address> \
forge script script/TestFactValidityProxy.s.sol:TestFactValidityProxyScript \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--broadcastAll deployments must be recorded in deployments.json. After each deployment, add an entry:
{
"date": "YYYY-MM-DD",
"network": "sepolia",
"proxyAddress": "0x...",
"targetAddress": "0x...",
"ownerAddress": "0x...",
"deployer": "@github_username"
}verifier-proxy/
├── src/
│ └── FactValidityProxy.sol # Main proxy contract
├── script/
│ ├── FactValidityProxy.s.sol # Deploy script
│ ├── CheckFactValidity.s.sol # Check fact validity script
│ ├── SetTargetContract.s.sol # Set target contract script
│ └── TestFactValidityProxy.s.sol # Full test script
├── lib/
│ └── forge-std/ # Foundry standard library
├── deployments.json # Deployment tracker
├── foundry.toml # Foundry configuration
└── README.md
MIT