Glider Cheatsheet

This cheatsheet brings together a collection of Glider query code snippets, designed to help you write queries more effectively without starting from scratch.

Identify the function from an instruction

Problem:

I want to find the function an Instruction belongs to.

Solution:

def query():
    # If you have an instruction and want to find a function
    instruction = Instructions().exec(1)
    function = instruction.get_parent()

    return function

Check if a variable comes from a function argument

Problem

Given a VarValue, I want to see if the VarValue comes from a function argument.

This type of query is helpful when you want to see if a variable comes from user-input.

Solution

Check if require or assert statement is called inside a function

Problem #1

I need to know if a require or assert statement is made inside a function.

Solution #1

Problem #2

I want to know if the Instruction I'm working with is a require or assert statement.

Solution #2

Check if a function is called in another function

Problem

I need to find the functions that call a particular function, where the only information I have is the name of the function being called.

Solution

Filter out interface functions

Problem

I want to remove interface functions from my results.

Solution

Get all variables used in an instruction

Problem

I want to find all of the variables and components in a given Instruction.

Solution

Identify state variables in a contract

Problem

I want to find every state variable for a contract.

Solution

Identify instructions doing arithmetic

Problem

I want to know if a given Instruction contains math arthimetic.

Solution

Identify functions that receives or send ETH

Problem

I want to know if a function receives or sends ETH.

Solution

Find functions without a modifier

Problem

I want to find functions that don't call onlyOwner.

Solution

Check if a function has a given argument by type

Problem

I want to determine if a function has an argument type like address, uint256, etc.

Solution

Check for msg.sender validations

Problem

I want to check if a function has any msg.sender validations.

Solution

Check if an instruction could revert

Problem

I want to check if an instruction could revert either through a require or assert check or a direct call to a revert.

Solution

Last updated