API
Write queries, describe code scenarios and find matching contract code
Last updated
Write queries, describe code scenarios and find matching contract code
Last updated
Before diving deep into the API classes and methods, let's see an example of how the Glider engine "understands" or represents the contract code.
Let's look at the :
For everything in the contract code (except comment sections), there is at least one entity that represents it in the Glider engine and allows the filtering and analysis of that data.
There are special flags and methods to distinguish or filter them.
In USDT the TetherToken will have a contract object for:
Contract objects can be used to obtain full information about the contract, such as the deployed address, compiler versions/pragmas, state variables, base and derived contracts, etc.
That said, the libraries, interfaces, and base contracts used in USDT code will also have a Contract object representing them:
As one address (one main contract) can have multiple interfaces, libraries, contracts declared or even derived, built in a complex folder structure, Glider will generate Contract objects for all of them, though the address will be the same, and only one contract will be considered to be the main.
Contracts contain references to other entities that belong to those contracts:
Glider treats functions and modifiers as callable objects.
E.g transfer function in the TetherToken contract
Or any other function, for example mul, div, sub, add
functions in the SafeMath library:
E.g the onlyOwner
modifier in Ownable
contract:
Or onlyPayloadSize
in BasicToken
contract:
And whenNotPaused
and whenPaused
modifiers in Pauable:
Functions have references to the modifiers that are being used in the function and vice versa.
An easy way to think of an instruction is anything that ends with a semicolon ';' in the code. However, this is not always the case, as with some instructions like if-statements, don't use semicolons.
E.g in the function transfer:
The instructions will be:
Here the whenNotPaused
modifier's instructions will be:
The constructors are also considered functions; special methods can be used to query and check that a function is a constructor.
An instruction on its own usually consists of different parts, for example:
This instruction consists of a require()
call, a boolean expression !paused
E.g. in the instruction
The Argument and Arguments object are mainly used in context of functions and modifiers (as they are the ones having arguments).
E.g for the function setParams
in TetherToken:
The newBasisPoints
and newMaxFee
are arguments of the function, and an Argument object will be used to represent each of them.
The contracts also have state (storage) variables defined; Glider allows the users to query, filter and analyze them as well.
E.g in the contract TetherToken:
or in BasicToken:
These state variables will be represented by a StateVariable object each or a StateVariables object for a set (or whole database).
E.g. in BasicToken.transfer()
function:
The uint fee
and uint sendAmount
will be the local variables defined in the function.
In Glider, every contract, interface, and library is represented by the class.
A set of contracts is represented by class.
For the contract that is "main", meaning that its functions are being executed if a transaction is called, the engine marks this contract as "main" to distinguish it from others on the same address; see .
While the class is used to obtain information about a single contract, the class is used to query and/or filter contracts from a set or the whole database.
(), (), , , , .
Nonetheless, Glider has and classes that both derive from
Each function in the contract code is represented by a object.
The set of functions is represented by the object.
Each modifier is represented by a object.
The set of modifiers is represented by a object.
and objects can be used to obtain data about a specific object, while and objects are used to query and/or filter functions/modifiers by specific properties from a set or the whole database.
See methods: and for a single function/modifier instance
Also: and for the set
One of the most important references that functions/modifiers have is their reference to their .
As the Modifier is also a , it also has instructions:
See methods: , ,
As with other entities, the object is used to obtain data and analyze one specific instruction, and the object is used to query/filter instructions in a set or in a whole database.
In Glider, the "parts" of the instruction are called .
The Value object represents a "part" of the instruction. Value by itself is a base class for different types of values such as , , etc.
The "part" representing the require call, will be of type (class derived from Value), and the value paused
will be of type (class derived from Value) as it represents a variable.
The class is used to represent a single argument of the function/modifier (callable), while the class is used to represent a set of arguments.
The local variables of functions/modifiers are represented by and classes.