Ensuring security and reliability in smart contracts remains a paramount concern in the blockchain domain. While available research projects have utilized machine learning techniques, primarily static analysis, to detect vulnerabilities, these methods often fall short. They present limitations, such as insufficient labeled data, incomplete code analysis due to ineffective execution path navigation, and are computationally demanding.
To address these challenges, we introduce the Particle Gravitational Translearner (PGT). This novel approach is a fusion of semi-supervised optimization and transductive learning methodology. PGT delves deep into data preprocessing, transforming the textual smart contract source code into dense numerical vectors. This transformation is pivotal as it captures intricate semantic relationships between tokens, enhancing the feature selection process.
Our feature selection technique is underpinned by rigorous metaheuristic algorithms. These algorithms traverse the feature space with a balanced focus on exploration and exploitation, ensuring optimized feature extraction.
The PGT classification algorithm, built on a robust transductive learning approach leveraging labeled and unlabeled data, significantly boosts vulnerability detection accuracy during the classification stage.
PGT is evaluated comprehensively using a dataset of 47,398 real-world smart contracts. Our evaluations, benchmarked against state-of-the-art methods, revealed that PGT outperformed existing techniques regarding accuracy and computational efficiency.
Before you begin, ensure you have the following installed:
- R (version 3.6.0 or higher)
- RStudio (optional, but recommended for a better R coding experience)
- Git (for cloning the repository)
-
Clone the Repository
Open your terminal or command prompt and run:
git clone https://github.com/niirex1/PGT_Project
-
Navigate to the Project Directory
cd PGT_Project -
Install Required R Packages
Open R or RStudio and run:
install.packages(c("kernlab", "pso", "matrixStats", "tm", "tokenizers"))
-
Load the PGT Script
In R or RStudio, set your working directory to the project's location and source the main script:
setwd("/path_to_directory/PGT_Project") source("Data Preprocessing.R") source("Feature Selection.R") source("Classification.R")
-
Run the Algorithm
Assuming you have datasets
D_train,Y_train,D_test, andX_optprepared:result <- PGT_Classification(X_opt, D_train, Y_train, D_test) print(result)
- If you encounter package installation issues, ensure you have the latest version of R and try installing the packages individually.
- Ensure all datasets are correctly formatted and match the expected input for the PGT functions.
We welcome contributions from the community! Whether you're fixing bugs, improving documentation, or proposing new features, your efforts and expertise are appreciated. Here's how you can contribute:
Start by forking the [PGT repository(https://github.com/niirex1/PGT_Project)].
git clone https://github.com/your_username/PGT_Project.git
cd PGT_ProjectIt's best practice to create a new branch for each feature or fix:
git checkout -b feature/your_feature_nameor
git checkout -b fix/your_fix_name- Ensure your code adheres to the project's coding standards.
- If you're adding a feature, make sure to also add relevant tests and documentation.
- If you're fixing a bug, ensure the bug is reproducible with a test before you fix it.
Keep your commit messages clear and descriptive:
git add .
git commit -m "Add a brief description of your changes"git push origin feature/your_feature_nameGo to your fork on GitHub and click the "New pull request" button. Fill in the necessary details and submit.
Maintainers will review your PR. Address any comments or feedback they provide to ensure timely merging of your contributions.
- Issue First: For significant changes, it's best to open an issue for discussion before diving into coding.
- Stay Updated: Ensure your fork is always updated with the main branch to avoid merge conflicts.
- Documentation: Update the README or other documentation if necessary.
- Testing: Ensure your code passes all tests and doesn't introduce new bugs.
- Respect Code Style: Follow the coding style and conventions used throughout the project.
Thank you for contributing to PGT! Your efforts help improve the project for everyone.
The PGT project is licensed under the MIT License. This means that anyone is free to copy, modify, publish, use, compile, sell, or distribute the software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
- Commercial use: You can use the software for commercial purposes.
- Modification: You can make changes to the software.
- Distribution: You can distribute the software to others.
- Sublicense: You can grant/extend a license to others.
- Private use: You can use the software for private purposes.
However, there are some conditions:
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software.
- The software is provided "as is", without warranty of any kind.
For the full license text, you can refer to the LICENSE file in the repository or visit MIT License.
This section provides a brief overview of the MIT License for the PGT project. If you decide to use this license, you should include a LICENSE file in your repository with the full license text. If you prefer another license, please specify, and I can provide details on that.
For any questions, feedback, or suggestions regarding the PGT project, please reach out to the project maintainers:
- Rexford Sosu
- Email: rexfordsosu@outlook.com
- GitHub: @rexfordsosu
- LinkedIn: Rexford's LinkedIn