[Paper Review] SIF: A Framework for Solidity Code Instrumentation and Analysis
SIF is a comprehensive C++-based framework for Solidity smart contract analysis, instrumentation, and code generation, enabling developers to query, transform, and generate Solidity code via its Abstract Syntax Tree (AST). It supports 7 practical tools for vulnerability detection, code analysis, and debugging, and was successfully evaluated on 1,838 real Ethereum contracts with high usability and automation, demonstrating its feasibility as a unified tooling infrastructure for smart contract development.
Solidity is an object-oriented and high-level language for writing smart contracts that are used to execute, verify and enforce credible transactions on permissionless blockchains. In the last few years, analysis of smart contracts has raised considerable interest and numerous techniques have been proposed to check the presence of vulnerabilities in them. Current techniques lack traceability in source code and have widely differing work flows. There is no single unifying framework for analysis, instrumentation, optimisation and code generation of Solidity contracts. In this paper, we present SIF, a comprehensive framework for Solidity contract analysis, query, instrumentation, and code generation. SIF provides support for Solidity contract developers and testers to build source level techniques for analysis, understanding, diagnostics, optimisations and code generation. We show feasibility and applicability of the framework by building practical tools on top of it and running them on 1838 real smart contracts deployed on the Ethereum network.
Motivation & Objective
- To address the lack of a unified framework for Solidity code analysis, instrumentation, and transformation, which currently relies on fragmented, low-level bytecode analysis or incomplete source-to-IR translation.
- To provide Solidity developers and testers with a high-level, reusable, and extensible framework similar to Clang LibTooling for C/C++.
- To enable end-to-end source-level program analysis, transformation, and code generation with strong traceability to original Solidity source code.
- To support the development of custom tools for security analysis, diagnostics, and testing through reusable helper functions and a simple C++ interface.
- To evaluate the framework’s usability, performance, and extensibility through real-world deployment on 1,838 Ethereum smart contracts.
Proposed method
- The framework uses a C++-based intermediate representation of the Solidity AST, exposing a clean and extensible interface for AST traversal and manipulation.
- It provides helper functions to query AST nodes, insert instrumentation (e.g., assertions), and perform code transformations such as renaming or bug seeding.
- Code generation is supported by reconstructing Solidity source code from the modified AST, with options to disable default code output for pure analysis tasks.
- The framework enables AST-level syntactic diffing, call graph and control flow graph generation, and vulnerability detection via static analysis of AST nodes.
- It supports both text-based and JSON-formatted AST inputs, with performance profiling identifying bottlenecks in JSON AST parsing.
- The framework is extensible: users can implement new tools using the provided interface, with built-in support for maintaining state across AST nodes via before/after visitor functions.
Experimental results
Research questions
- RQ1Can a unified, source-level framework be built for Solidity that supports instrumentation, analysis, and code generation with full traceability to source code?
- RQ2How usable and automatable is the framework for developers and testers in building and deploying custom analysis tools?
- RQ3What is the performance overhead of AST-based code generation and analysis on real-world smart contracts?
- RQ4How effective is the framework in supporting diverse use cases such as vulnerability detection, code transformation, and diagnostics?
- RQ5Can the framework be extended and adopted by the global developer community for practical smart contract tooling?
Key findings
- SIF successfully processed all 1,838 real-world Ethereum smart contracts, confirming the robustness and scalability of the framework.
- The 7 tools built on SIF—such as assertion analyzers, call graph generators, and fault seeders—produced correct outputs, as verified by all three user evaluators.
- Users rated the usability of the tools and framework highly, with an average ease-of-use rating of 3.7 out of 5, and found the tools nearly fully automatic.
- Code generation from AST was efficient for most contracts: under 4 seconds for contracts with fewer than 1,000 lines of code.
- For a large contract (6,183 lines), code generation took 85.6 seconds, primarily due to repeated root-level JSON AST queries; this bottleneck was identified and is being optimized.
- The framework has gained international traction post-release, with community feedback leading to critical fixes (e.g., uninitialized variable detection) and feature enhancements (e.g., optional code generation, detailed AST documentation).
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.