Analyzing Contracts with Slither
The analyze_with_slither tool runs Slither’s static security analysis over your Solidity sources and returns the findings grouped by severity. Run it before deploying anything, to catch problems while they are still cheap to fix.
Price: 0.02 USDC per call.
Input parameters
{
sources: {
[filename: string]: {
content: string
}
},
version?: string,
detectors?: Array<string>,
excludeLow?: boolean,
excludeInformational?: boolean
}
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
Object |
Yes |
Map of filename to source code content |
|
string |
Yes |
Solidity source code |
|
string |
No |
Solidity compiler version, for example |
|
Array<string> |
No |
Specific detectors to run |
|
boolean |
No |
Exclude low severity findings. Defaults to |
|
boolean |
No |
Exclude informational findings. Defaults to |
Common detectors
If you leave detectors empty, the full detector set runs. Some of the more commonly used ones are:
reentrancy-eth: reentrancy vulnerabilitiesarbitrary-send-eth: unprotected ETH sendsuicidal: unprotected self-destructuninitialized-state: uninitialized state variablesunchecked-transfer: unchecked return valuestx-origin: dangerous use oftx.origintimestamp: timestamp dependency
Output
{
success: boolean,
summary?: {
totalFindings: number,
high: number,
medium: number,
low: number,
informational: number,
optimization: number
},
findings?: Array<{
check: string,
impact: "High" | "Medium" | "Low" | "Informational" | "Optimization",
confidence: "High" | "Medium" | "Low",
description: string,
elements?: Array<{
type: string,
name: string,
source_mapping?: {
start: number,
length: number,
filename_relative: string,
lines: Array<number>
}
}>,
reference?: string,
id?: string
}>,
rawAnalysis?: string,
rawOutput?: Object,
compilerVersion?: string,
error?: string
}
Output fields
Field |
Type |
Description |
|---|---|---|
|
boolean |
Whether the analysis completed |
|
Object |
Counts by severity level |
|
Array |
The security findings |
|
string |
Detector that found the issue |
|
string |
Severity level of the finding |
|
string |
Confidence level of the finding |
|
string |
Human-readable description |
|
Array |
Code elements involved, where available |
|
string |
URL with more information |
|
string |
Raw Slither output text |
|
Object |
Complete Remix API response |
|
string |
Solidity version used for the analysis |
|
string |
Error message if the analysis failed |
Impact levels
High: critical vulnerabilities that should be fixed immediately
Medium: important issues that could lead to problems
Low: minor issues or code quality improvements
Informational: best practice suggestions
A finding also carries a confidence level. Treat a high impact, high confidence finding as a blocker; lower confidence findings are worth reading, but may not apply to your contract.
Example
This contract changes state after an external call, which is the classic reentrancy pattern:
const result = await client.callTool({
name: "analyze_with_slither",
arguments: {
sources: {
"Vulnerable.sol": {
content: `
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Vulnerable {
mapping(address => uint256) public balances;
function withdraw() public {
uint256 amount = balances[msg.sender];
(bool success, ) = msg.sender.call{value: amount}("");
require(success);
balances[msg.sender] = 0; // State change after external call!
}
}
`
}
},
excludeInformational: true
}
});
const output = JSON.parse(result.content[0].text);
console.log('Summary:', output.summary);
output.findings.forEach(finding => {
console.log(`[${finding.impact}] ${finding.check}: ${finding.description}`);
});