solidity-fcg-tool
solidity-fcg-tool packages a Solidity static analysis workflow that extracts module/function source code and call graph data. The first release uses Slither under the hood, while keeping the analysis engine pluggable so Tree-sitter, Solar, or other backends can be added later.
Features
- Engine abstraction –
core.engine_base.AnalysisEnginedefines the contract for all engines and allows hot-swapping implementations. - Rich data model – function source, parameters, state variable access, locations, and call relationships.
- Service layer –
services.query.QueryServiceexposes Python APIs plus a JSON-emitting CLI for downstream tooling (e.g., AI assistants). - Extensible registry – register additional engines without touching higher-level services.
Installation
Once published, install via pip:
pip install solidity-fcg-tool
For local development:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .[dev]
A compatible
solcbinary is required. Install withpy-solc-xor reuse an existing compiler on your system.
CLI Usage
Function source lookup
python -m solidity_fcg_tool \
--project samples/SimpleToken.sol \
--engine slither \
query \
--contract SimpleToken \
--function "transfer(address,uint256)"
Example (truncated) response:
{
"contract": "SimpleToken",
"function": "transfer(address,uint256)",
"source": " function transfer(address to, uint256 amount) external returns (bool) {\n _performTransfer(msg.sender, to, amount);\n return true;\n }\n",
"location": {
"file": "/absolute/path/to/solidity-fcg-tool/samples/SimpleToken.sol",
"start_line": 17,
"end_line": 20
},
"parameter": [
{ "name": "to", "type": "address" },
{ "name": "amount", "type": "uint256" }
],
"calls": [
{
"file": "/absolute/path/to/solidity-fcg-tool/samples/SimpleToken.sol",
"module": "SimpleToken",
"function": "_performTransfer(address,address,uint256)"
}
]
}
Call graph extraction
python -m solidity_fcg_tool \
--project samples/SimpleToken.sol \
call-graph \
--contract SimpleToken
Sample output:
{
"edges": [
{
"caller": "SimpleToken.transfer(address,uint256)",
"callee": "SimpleToken._performTransfer(address,address,uint256)"
}
],
"metadata": {
"engine": "slither"
}
}
Python API
from solidity_fcg_tool.services.query import get_function_source
result = get_function_source(
project_path="samples/SimpleToken.sol",
contract="SimpleToken",
function_signature="transfer(address,uint256)",
)
print(result["source"])
For repeated queries, keep the service instance alive:
from solidity_fcg_tool.services.query import create_service
service = create_service("samples/SimpleToken.sol")
info = service.get_function_source("SimpleToken", "transfer(address,uint256)")
edges = service.get_call_graph(caller_contract="SimpleToken")
Project Layout
solidity_fcg_tool/core– engine abstractions and shared models.solidity_fcg_tool/engines– registry and the Slither-backed engine.solidity_fcg_tool/services– public query service and helpers.samples/– example Solidity contracts.tests/– pytest-based regression suite.
Extending Engines
- Implement
AnalysisEngine, filling inload()and (optionally)_iter_call_graph_impl(). - Populate
ProjectModel/ContractInfo/FunctionInfowith the new engine’s data. - Register the engine via
register_engine("my-engine", MyEngineClass). - Use it through
--engine my-engine(CLI) orcreate_service(..., engine_name="my-engine").
Release Notes
See the CHANGELOG for a detailed history of updates.
Development & Tests
pytest
If Slither or
solcis missing, API/CLI tests will be skipped with an informative message.
For more details in Chinese, please read README_zh.md.
Publishing
To build and upload a release:
pip install -e .[dev]
python -m build
python -m twine check dist/*
python -m twine upload dist/*
Metadata
Release files for solidity-fcg-tool 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| solidity_fcg_tool-0.1.0.tar.gz | 20.5 kB | Without provenance | Details for solidity_fcg_tool-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| solidity_fcg_tool-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for solidity_fcg_tool-0.1.0-py3-none-any.whl |
Total release size: 35.8 kB
Release files / solidity_fcg_tool-0.1.0.tar.gz
| Download URL | solidity_fcg_tool-0.1.0.tar.gz |
|---|---|
| Size | 20.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
594fb8ca128eb323be3043b6be02246e89331627c74f15be8396596389c344f7
|
|
BLAKE2b-256 checksum How to use checksums |
0848c59d81ad5294efe7d70b688e3cdebbc6379ca6eed8c3596f3e88e67085a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Release files / solidity_fcg_tool-0.1.0-py3-none-any.whl
| Download URL | solidity_fcg_tool-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
af25598aac88ecf4fa67aa59a4538a45d20fef61ca39c84352d6faf8a82fdc33
|
|
BLAKE2b-256 checksum How to use checksums |
6c0fecb7b9296da0665f50be536349fa084ca67ba2cfbaae44cdcf46550b1e69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Security for solidity-fcg-tool 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.