CARVIEW |
Select Language
HTTP/2 200
date: Fri, 25 Jul 2025 23:45:48 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"999bc895abaadf2dcea3a948af930260"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=Wtrc9RsEH%2FQG2wb%2Bm%2FtjDS3elKsN1YteRNZ67tgNTsPrsDY3Vc3IEeHvSmH2RJy75LZUhLN2Tsnc7vmlsRDUGT4R0GeeF9SlEPzik2tLUg8ZJZiuIUNkSyGIhB90KvRR7adDRcBhW9lbcPSFjFjAP9hyHfjbdKa%2BTacQsYup56GOhqrS%2BITcKA4FXca%2BjxxkUhQPTDhjUs4d8MkDPEUnU%2B6lmNIER3Oj2ChFgFxlZD%2BEslKptw9s09W2DWkkJMN4LfVCKsUoRsn0FMv2cEstaw%3D%3D--%2Bwo3j85Wu3wnTLf5--H6EoVttIWnB4PQ4XCizyNw%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1300467010.1753487148; Path=/; Domain=github.com; Expires=Sat, 25 Jul 2026 23:45:48 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sat, 25 Jul 2026 23:45:48 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 9568:1028D7:33581:51D3C:6884172C
Python API · crytic/slither Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 1k
Python API
Feist Josselin edited this page Feb 14, 2019
·
1 revision
Let's start with the smallest possible Slither script:
from slither.slither import Slither
slither = Slither('file.sol')
A Slither object has:
-
contracts (list(Contract)
: list of contracts -
contracts_derived (list(Contract)
: list of contracts that are not inherited by another contract (subset of contracts) -
get_contract_from_name (str)
: Return a contract from its name
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:
-
name (str)
: Name of the contract -
functions (list(Function))
: List of functions -
modifiers (list(Modifier))
: List of functions -
all_functions_called (list(Function/Modifier))
: List of all the internal functions reachable by the contract -
inheritance (list(Contract))
: List of inherited contracts -
get_function_from_signature (str)
: Return aFunction
from its signature -
get_modifier_from_signature (str)
: Return aModifier
from its signature -
get_state_variable_from_name (str)
: Return aStateVariable
from its name
A Function or a Modifier object has:
-
name (str)
: Name of the function -
nodes (list(Node))
: List of the nodes composing the CFG of the function/modifier -
entry_point (Node)
: Entry point of the CFG -
variables_read (list(Variable))
: List of variables read -
variables_written (list(Variable))
: List of variables written -
state_variables_read (list(StateVariable))
: List of state variables read (subset of variables`read) -
state_variables_written (list(StateVariable))
: List of state variables written (subset of variables`written)
Variables can be different types, such as StateVariable, or LocalVariable. All variables have:
-
name (str)
: Name of the variable -
initialized (boolean)
: True if the variable is initialized at declaration
A Node object has:
-
type (NodeType)
: The type of the node (ex: If a control flow node, RETURN is for the node containing the return statement). -
expression (Expression)
: Expression associated with the node (not all nodes contain an expression) -
variables_read (list(Variable))
: List of variables read -
variables_written (list(Variable))
: List of variables written -
state_variables_read (list(StateVariable))
: List of state variables read (subset of variables_read) -
state_variables_written (list(StateVariable))
: List of state variables written (subset of variables_written)
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:
-
functions_writing.py: Where the state variable
a
is written? -
variable_in_condition.py: Is the variable
a
used in a condition? -
functions_called.py: What are all the functions reached by a call to
entry_point()
? - slithIR.py: Print the SlithIR operations
You can’t perform that action at this time.