Bytecode Verification
Overview
Basic Setup
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Test} from "forge-std/Test.sol";
import {KontrolCheats} from "kontrol-cheatcodes/KontrolCheats.sol";
// Define the interface for the contract you want to verify
interface IUnknownContract {
function someFunction(uint256) external returns (bool);
}
contract BytecodeVerificationTest is Test, KontrolCheats {
IUnknownContract public unknownContract;
address constant UNKNOWN_CONTRACT_ADDRESS = address(0x1234);
function setUp() public {
// Get the bytecode (this would typically come from on-chain or other sources)
bytes memory bytecode = hex"608060405234801561001057600080fd5b506004361061002b5760003560e01c8063..."; // truncated for example
// Deploy the bytecode at the specified address
vm.etch(UNKNOWN_CONTRACT_ADDRESS, bytecode);
// Initialize the interface
unknownContract = IUnknownContract(UNKNOWN_CONTRACT_ADDRESS);
}
function testFuzz_SomeFunction(uint256 x) public {
// Make the storage symbolic
vm.setArbitraryStorage(UNKNOWN_CONTRACT_ADDRESS);
// Call the function and verify properties
bool result = unknownContract.someFunction(x);
// Add your verification properties here
}
}Getting Bytecode
Best Practices
Additional Resources
Last updated
Was this helpful?