PhEvm
Title: PhEvm
Author: Phylax Systems
Precompile interface for accessing transaction state within assertions
This interface provides access to the Credible Layer's execution environment, allowing assertions to inspect transaction state, logs, call inputs, and storage changes. The precompile is available at a deterministic address during assertion execution.
Functions
forkPreTx
Fork to the state before the assertion-triggering transaction
Allows inspection of pre-transaction state for comparison
function forkPreTx() external;
forkPostTx
Fork to the state after the assertion-triggering transaction
Allows inspection of post-transaction state for validation
function forkPostTx() external;
forkPreCall
Fork to the state before a specific call execution
Useful for inspecting state at specific points during transaction execution
function forkPreCall(uint256 id) external;
Parameters
| Name | Type | Description |
|---|---|---|
id | uint256 | The call identifier from CallInputs.id |
forkPostCall
Fork to the state after a specific call execution
Useful for inspecting state changes from specific calls
function forkPostCall(uint256 id) external;
Parameters
| Name | Type | Description |
|---|---|---|
id | uint256 | The call identifier from CallInputs.id |
load
Load a storage slot value from any address
function load(address target, bytes32 slot) external view returns (bytes32 data);
Parameters
| Name | Type | Description |
|---|---|---|
target | address | The address to read storage from |
slot | bytes32 | The storage slot to read |
Returns
| Name | Type | Description |
|---|---|---|
data | bytes32 | The value stored at the slot |
getLogs
Get all logs emitted during the transaction
Returns logs in emission order
function getLogs() external returns (Log[] memory logs);
Returns
| Name | Type | Description |
|---|---|---|
logs | Log[] | Array of Log structs containing all emitted events |
getAllCallInputs
Get all call inputs for a target and selector (all call types)
Includes CALL, STATICCALL, DELEGATECALL, and CALLCODE
function getAllCallInputs(address target, bytes4 selector) external view returns (CallInputs[] memory calls);
Parameters
| Name | Type | Description |
|---|---|---|
target | address | The target contract address |
selector | bytes4 | The function selector to filter by |
Returns
| Name | Type | Description |
|---|---|---|
calls | CallInputs[] | Array of CallInputs matching the criteria |
getCallInputs
Get call inputs for regular CALL opcode only
function getCallInputs(address target, bytes4 selector) external view returns (CallInputs[] memory calls);
Parameters
| Name | Type | Description |
|---|---|---|
target | address | The target contract address |
selector | bytes4 | The function selector to filter by |
Returns
| Name | Type | Description |
|---|---|---|
calls | CallInputs[] | Array of CallInputs from CALL opcodes |
getStaticCallInputs
Get call inputs for STATICCALL opcode only
function getStaticCallInputs(address target, bytes4 selector) external view returns (CallInputs[] memory calls);
Parameters
| Name | Type | Description |
|---|---|---|
target | address | The target contract address |
selector | bytes4 | The function selector to filter by |
Returns
| Name | Type | Description |
|---|---|---|
calls | CallInputs[] | Array of CallInputs from STATICCALL opcodes |
getDelegateCallInputs
Get call inputs for DELEGATECALL opcode only
function getDelegateCallInputs(address target, bytes4 selector) external view returns (CallInputs[] memory calls);
Parameters
| Name | Type | Description |
|---|---|---|
target | address | The target/proxy contract address |
selector | bytes4 | The function selector to filter by |
Returns
| Name | Type | Description |
|---|---|---|
calls | CallInputs[] | Array of CallInputs from DELEGATECALL opcodes |
getCallCodeInputs
Get call inputs for CALLCODE opcode only
function getCallCodeInputs(address target, bytes4 selector) external view returns (CallInputs[] memory calls);
Parameters
| Name | Type | Description |
|---|---|---|
target | address | The target contract address |
selector | bytes4 | The function selector to filter by |
Returns
| Name | Type | Description |
|---|---|---|
calls | CallInputs[] | Array of CallInputs from CALLCODE opcodes |
getStateChanges
Get all state changes for a specific storage slot
Returns the sequence of values the slot held during transaction execution
function getStateChanges(address contractAddress, bytes32 slot)
external
view
returns (bytes32[] memory stateChanges);
Parameters
| Name | Type | Description |
|---|---|---|
contractAddress | address | The contract whose storage to inspect |
slot | bytes32 | The storage slot to get changes for |
Returns
| Name | Type | Description |
|---|---|---|
stateChanges | bytes32[] | Array of values the slot held (in order of changes) |
getAssertionAdopter
Get the assertion adopter address for the current transaction
The adopter is the contract that registered the assertion
function getAssertionAdopter() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the assertion adopter contract |
Structs
Log
Represents an Ethereum log emitted during transaction execution
Used by getLogs() to return transaction logs for inspection
struct Log {
/// @notice The topics of the log, including the event signature if any
bytes32[] topics;
/// @notice The raw ABI-encoded data of the log
bytes data;
/// @notice The address of the contract that emitted the log
address emitter;
}
CallInputs
Represents the inputs to a call made during transaction execution
Used by getCallInputs() and related functions to inspect call details
struct CallInputs {
/// @notice The calldata of the call
bytes input;
/// @notice The gas limit of the call
uint64 gas_limit;
/// @notice The address of the bytecode being executed (code address)
address bytecode_address;
/// @notice The target address whose storage may be modified
address target_address;
/// @notice The address that initiated this call
address caller;
/// @notice The ETH value sent with the call
uint256 value;
/// @notice Unique identifier for this call, used with forkPreCall/forkPostCall
uint256 id;
}