# Application of Blockchain Technologies in Verification of Software Metrics
## 3 Methodology
### Verification on Blockchain
#### 3.2.2 Smart Contracts  
Traditional verification approaches rely on centralized code analysis systems, where results are generated using tools such as SonarQube, PMD, Checkstyle, and similar static code analysis tools. These systems typically operate in three phases: (1) data collection from the code, (2) computation of software metrics, and (3) storage and verification of results in relational databases or local files. Although these mechanisms are widely adopted, the third phase reduces system reliability, as they depend on centralized databases, leaving the results susceptible to manipulation. To address this limitation, this paper proposes the use of Ethereum smart contracts for the automatic verification and storage of software metric results. This approach offers several advantages:  
1. Transparency: In practice, the conditions defined within a smart contract are clearly accessible to all participants in the blockchain network [33]. Once a contract is deployed, modifying it is not easily feasible. Every transaction executed under the contract is tracked and verified by other nodes in the network, enhancing transparency and reducing the risk of fraud [33]. Moreover, fraudulent practices in software metric verification are becoming increasingly common, highlighting the need for more robust and reliable methods;
2. Speed: Smart contracts operate independently of human intervention, with their execution monitored and validated by other nodes. Once the predefined conditions are met, the contract executes automatically [33]. This process is typically triggered by specific events, which activate the contract logic when certain criteria are fulfilled [33];
3. Security: Leveraging advanced cryptographic methods and the intrinsic properties of blockchain, such as immutability, smart contracts provide a high level of security [33]. The contents of a smart contract cannot be retroactively modified by any party, and execution occurs autonomously and deterministically [33]. As part of this research, a smart contract was created to verify software metrics on the blockchain. The smart contract was created in Solidity version 0.8.0 programming language. This contract is designed to store and verify software testing results in one place. To achieve this, as shown in code below, the smart contract uses a MetricsTest structure that contains the unique number of the test, the name of the software, the time the test was run, and an array containing the numeric values of the metrics. All tests recorded by a user on the blockchain network can be found quickly and efficiently as the smart contract maps the address to its list of tests. The main storeMetrics function records each new test. It first checks that the software name is not a null value and that the metric array is not empty, then it finds a free test number (if a unique test number value is used, +1 is added) and only then saves the data. If the recording is successful, the MetricsStored event is broadcasted, which enables external services to immediately see that a new result has arrived. To display the history of all tests of one user, the functions getMetrics, which returns all the data of one test, and getAllTestIds, which returns a list of all tests of the user, are used.