-
Notifications
You must be signed in to change notification settings - Fork 973
Printer documentation
Slither allows printing contracts information through its printers.
slither file.sol --printer contract-summary
Output a quick summary of the contract.
$ slither examples/printers/quick_summary.sol --printer contract-summary
slither file.sol --printer function-summary
Output a summary of the contract showing for each function:
- What are the visibility and the modifiers
- What are the state variables read or written
- What are the calls
$ slither tests/backdoor.sol --printer function-summary
[...]
Contract C
Contract vars: []
Inheritances:: []
+-----------------+------------+-----------+----------------+-------+---------------------------+----------------+
| Function | Visibility | Modifiers | Read | Write | Internal Calls | External Calls |
+-----------------+------------+-----------+----------------+-------+---------------------------+----------------+
| i_am_a_backdoor | public | [] | ['msg.sender'] | [] | ['selfdestruct(address)'] | [] |
+-----------------+------------+-----------+----------------+-------+---------------------------+----------------+
+-----------+------------+------+-------+----------------+----------------+
| Modifiers | Visibility | Read | Write | Internal Calls | External Calls |
+-----------+------------+------+-------+----------------+----------------+
+-----------+------------+------+-------+----------------+----------------+
slither file.sol --printer inheritance-graph
Output a graph showing the inheritance interaction between the contracts.
This printer requires xdot installed for vizualization:
sudo apt install xdot
$ slither examples/printers/inheritances.sol --printer inheritance-graph
[...]
INFO:PrinterInheritance:Inheritance Graph: examples/DAO.sol.dot
The output format is dot. To vizualize the graph:
xdot examples/printers/inheritances.sol.dot
To convert the file to svg:
dot examples/printers/inheritances.sol.dot -Tsvg -o examples/printers/inheritances.sol.png
Functions in orange override a parent's functions. If a variable points to another contract, the contract type is written in blue.
slither file.sol --printer vars-and-auth
Print the variables written and the check on msg.sender
of each function.
...
$ slither examples/printers/authorization.sol --printer vars-and-auth
[..]
INFO:Printers:
Contract MyContract
+-------------+-------------------------+----------------------------------------+
| Function | State variables written | Conditions on msg.sender |
+-------------+-------------------------+----------------------------------------+
| constructor | ['owner'] | [] |
| mint | ['balances'] | ['require(bool)(msg.sender == owner)'] |
+-------------+-------------------------+----------------------------------------+
slither file.sol --printer slithir
Print the IR for every function
$ slither examples/printers/slihtir.sol --printer slithir
Contract UnsafeMath
Function add(uint256,uint256)
Expression: a + b
IRs:
TMP_0(uint256) = a + b
RETURN TMP_0
Function min(uint256,uint256)
Expression: a - b
IRs:
TMP_0(uint256) = a - b
RETURN TMP_0
Contract MyContract
Function transfer(address,uint256)
Expression: balances[msg.sender] = balances[msg.sender].min(val)
IRs:
REF_3(uint256) -> balances[msg.sender]
REF_1(uint256) -> balances[msg.sender]
TMP_1(uint256) = LIBRARY_CALL, dest:UnsafeMath, function:min, arguments:['REF_1', 'val']
REF_3 := TMP_1
Expression: balances[to] = balances[to].add(val)
IRs:
REF_3(uint256) -> balances[to]
REF_1(uint256) -> balances[to]
TMP_1(uint256) = LIBRARY_CALL, dest:UnsafeMath, function:add, arguments:['REF_1', 'val']
REF_3 := TMP_1