| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Let's start with the smallest possible Slither script:
from slither.slither import Slither
slither = Slither('file.sol') A Slither object has:
contracts_derived iterates over contracts that are not inherited. It is useful to prevent duplicate findings. If you find an issue in a derived contract, then one of its inherited contracts is likely to have the same issue.
A Contract object has:
A Function or a Modifier object has:
Variables can be different types, such as StateVariable, or LocalVariable. All variables have:
A Node object has:
An Expression is an AST-based representation of the code executed.
For example, the following code explores all the functions of all the contracts and prints what state variables are read or written:
from slither.slither import Slither
slither = Slither('file.sol')
for contract in slither.contracts:
print 'Contract: '+ contract.name
for function in contract.functions:
print('Function: {}'.format(function.name))
print('\tRead: {}'.format([v.name for v in function.state_variables_read]))
print('\tWritten {}'.format([v.name for v in function.state_variables_written]))You will find more Slither API examples here. For example:
| Back | FazBrowse Home | New Git URL |