Solidity Dialect
This documentation page is still a work-in-progress and may be subject to change.
This page contains reference documentation for the Solidity dialect of PAQL, describing every Object type available, and the properties and iterators of each Object type.
Contracts and Functions
Contract
Represents a smart contract of any kind (contract, interface, or library).
Properties
name: the name of the contractfilepath: the virtual file path of the contract, as computed by the Solidity compiler.kind: one ofcontract,interface, orlibraryisContract,isInterface,isLibrary: boolean values indicating whether the contract is of the specific kind, respectively.superClasses: an object that may be iterated over to obtain the superclasses (asContractobjects) of this contract.
Iterators
Function: the functions that this contract has. Note that this includes inherited functions, as well as internal library functions that are included in the Contract's bytecode.- Any
StatementorExpression: all of the corresponding Statements or Expressions that occur in the functions of this contract. StorageVar: the storage variables that this contract has. Note that this includes inherited storage variables.
Examples
The following query finds all of the functions defined by interface contracts
that are in the src folder:
FIND
Contract contract,
Function function IN contract
WHERE
contract.kind == "interface",
regexMatch(contract.filepath, "src/.*"),
Function
Represents a function.
Properties
name: The name of the function, such astransfer.signature: The full name and type signature of the function, such astransfer(address,uint256).selector: The selector of this function as a string without a0xprefix, such as1234abcd. Empty string if the function is not externally callable, or if it is a fallback, receive, or constructor function.isExternallyCallable: a boolean value indicating whether this function may be invoked directly using an external call.visibility: the visibility of this function, such asexternal,public,internal, andprivate.mutability: the mutability of this function, such asnonpayable,payable,view, andpure.contract: the Contract that has this function. Note that this is not necessarily the same as the contract that defined this function; for example, ifAinheritsffromB, then theFunctionobject forA.fwill haveAas itscontractproperty, notB.reachable: an object that may be iterated to get "reachable" objects. Supports iteration overFunctions, expressions, and statements, to get all functions/expressions/statements (respectively) that are reachable from thisFunction.
Iterators
Argument: the parameters of this function. Currently, this object only supports theforwardSlices/backwardSlicesproperties that are similar to the ones defined onExpressionandStatement.StorageRead: the storage reads that may occur specifically within this function (i.e., does not include those in nested internal calls).StorageWrite: the storage writes that may occur specifically within this function (i.e., does not include those in nested internal calls).- Every
ExpressionandStatement
Documentation coming soon
Examples
Find all internal calls to _updateInterest() in functions named deposit:
FIND
Function f,
InternalCall c IN f
WHERE
f.name == "deposit",
c.callee.name == "_updateInterest",
Find all storage writes that may be performed as a result of calling an external function:
FIND
Function extFun,
StorageWrite w IN extFun.reachable,
WHERE
extFun.isExternallyCallable
StorageVar
Represents a storage variable. This does not include immutable variables or constants.
Properties
name: The name of this storage variable.contract: TheContractthat this storage variable has been inherited into.declaringContract: TheContractthat declared this storage variable.getterSignature: The signature of the getter function of this variable as a string, or empty string if this has no getter function.slot: The (base) storage slot of this varible.offset: The (base) offset of this variable.
Expressions and Statements
The Expression and Statement classes describe a family of PAQL objects that
cover Solidity expressions and control structures, respectively.
Common Properties
after: an object that may be iterated to get allExpressionorStatementthat may be executed after this one.before: an object that may be iterated to get allExpressionorStatementthat may be executed before this one.forwardSlices: an object that may be iterated to get allExpressionorStatementthat are influenced by the results of thisExpression/Statement.backwardSlices: an object that may be iterated to get allExpressionorStatementthat are influenced by the operands of thisExpression/Statement.
Common Iterators
StorageRead,StorageWrite: the storage accesses that are performed by thisExpression/Statement.
Expression: ExternalCall
Represents an external call.
Properties
signature(string): the signature of the function that is invoked by this call. Empty string if the function target cannot be determined.name(string): the name of the function that is invoked by this call. Empty string if the function target cannot be determined.selector(string): the selector of the call target. Empty string if not known, or if the target is a fallback or receive.callees: an object that may be iterated to get all of the external functions that may be targets of this call.isLowLevelCall: whether this is a low-level call, such as in the Solidity codemsg.sender.call("").isSend, (bool)kind(string): indicates the type of EVM call opcode of this call, one ofcall,staticcall, ordelegatecall.isCall,isStaticcall,isDelegatecall(bool): indicates whether the call is the corresponding kind
Expression: InternalCall
Represents an internal call (within the same contract).
Properties
callee(Function): the function that is called.
Arithmetic Expressions
These expressions represent arithmetic operations, and they include:
DivideExpressionMultiplyExpression
Statement: RequireLike
Represents a pattern of expressions/statements that are similar to a
require(...) statement.
This currently includes the following:
require(condition, "withOrWithoutMessage");in Solidityif (!condition) revert WithOrWithoutError();in Solidity- Any similar patterns to the above that are automatically inserted by the Solidity compiler, such as for checking success status of function calls on contracts
Properties
condition(Expression): the boolean expression used as a condition to the require-like structure.
Statement: Revert
Represents any statement that is similar to a revert, including the following:
revert("withOrWithoutmessage")in Solidityrevert Error(...)in Solidity- Any
reverts or panics automatically inserted by the Solidity compiler
Storage Accesses
To allow reasoning about storage variable reads and writes, the Solidity
dialect provides two classes StorageRead and StorageWrite, which represent a
specific read from or write to (respectively) a specific storage variable.
Common Properties
location: a string representation of the storage variable location that was written, or empty string if unknown. For scalar variables, this is just the name of the variable. For aggregate data structures, such asstructormappings, this may also include fields or indexes.variable: theStorageVarthat was read or written.
The .variable property will currently cause Vanguard to crash for reads/writes
whose target locations are not known to Vanguard.