Python3 script to automatically create a Gas-Optimizations report for smart-contract audits
Like a lot of people, I started my smart-contract auditor journey by reporting gas-optimizations on Code4rena. Hence, I created this bot to automate the process and earn a few rewards easily. Now is time to open-source it, so you can use it in you audit competitions too (Code4rena, CodeHawks, Hats, Immunefi...).
This script works with advenced regular expressions to check the presence of common optimization issues. All the rules are in the Issues.py
file where you can add your own rules too.
Note that some of the findings may be false positives (especially issue G16
) so a bit of manuall review is required.
To get started you need to have python3 installed. If it is not the case you can download it here : https://www.python.org/downloads/
Make sure you've already git installed. Then you can run the following commands to get the scripts on your computer:
git clone https://github.com/MiniGlome/Gas-Optimizations-auto-report
cd Gas-Optimizations-auto-report
The script does not have any requirement, it only uses packages already installed with all versions of Python.
-
Create a directory with all the solidity files you want to analyse. This directory can be a direct copy of the
/src
of the project with nested folders.
See/Example
for example. -
Run the script with the folder name as parameter
python3 Auto-Report.py <Directory-with-all-the-source-files>
Example:
python3 Auto-Report.py Example
- The result will be in the
/output
directory. See /output/Example_gas_report.md for example
If you want to support my work, you can send 2 or 3 Bitcoins 🙃 to this address:
bc1q4nq8tjuezssy74d5amnrrq6ljvu7hd3l880m7l