Last active
December 7, 2023 21:12
-
-
Save 0xalpharush/dc77c0beba3533bfea1c5457081222c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python3 external_calls.py . | |
# python3 external_calls.py file.sol | |
# python3 external_calls.py 0xdead | |
import sys | |
from slither import Slither | |
from slither.slithir.operations import HighLevelCall | |
sl = Slither(sys.argv[1]) | |
for contract in sl.contracts_derived: | |
for function in contract.functions_entry_points: # if you only want reentrant functions, use `function.is_reentrant` | |
for node in function.nodes: | |
for op in node.irs: | |
if isinstance(op, HighLevelCall): # if you want to exclude view calls, add `and isinstance(op.function, Function)` | |
print(f"External call: {node.source_mapping.content} {node.source_mapping}") | |
# Other useful APIs: | |
# Get functions reading from a variable: https://crytic.github.io/slither/slither/core/declarations/contract.html#Contract.get_functions_reading_from_variable | |
# Get functions writing to a variable: https://crytic.github.io/slither/slither/core/declarations/contract.html#Contract.get_functions_writing_to_variable | |
# Get state variables read or written in reentrant functions: https://crytic.github.io/slither/slither/core/declarations/contract.html#Contract.state_variables_used_in_reentrant_targets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment