# MDA-Based Approach for Blockchain Smart Contract Development
## 4 Application of the MDAsmartCD Method for Development of Hackathon Certificate Issuing Solution
### The Metrics of the Developed HackChain Models and the Generated Code
\begin{table}
\begin{tabular}{l l l l l} \hline \hline \multicolumn{5}{c}{_HackChain_ **Solidity Smart Contract**} \\ \hline
**Executed Function** & **NLOC** & **CCN** & **Token** & **Parameters** \\ \hline _createCertificate_ & 7 & 1 & 109 & 9 \\ _confirmEvaluationResults_ & 10 & 4 & 74 & 3 \\ \hline \multicolumn{5}{c}{_HackChain_ **Go Chaincode**} \\ \hline
**Executed Function** & **NLOC** & **CCN** & **Token** & **Parameters** \\ \hline _CreateCertificate_ & 16 & 3 & 154 & 10 \\ _ConfirmEvaluationResults_ & 24 & 7 & 142 & 4 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Smart contract code metrics for Ethereum and Hyperledger Fabric platforms. Figure 23: _HackChain.sol_ and _HackChain.go_ code complexity comparison. For evaluation purposes, the Solidity smart contract was hosted on the Goerli test network. The Go chaincode was deployed on a local Hyperledger Fabric network consisting of two peers. For hosting this network, a server having an Intel Xeon Silver 4114 CPU featuring 16 GB of RAM with data stored on the SSD storage was used. The server was running on an Ubuntu 18.04 operating system and using Docker containers as a Peer environment for Hyperledger Fabric 2.2 with CouchDB 2.3.1 as the state database. The deployed smart contracts were experimented upon by imitating the certificate issuing processes. For both the Ethereum and Hyperledger Fabric smart contracts, the same data set was used to execute smart contract functions in the same workflow and record the execution metrics. In both cases, 18 certificates were created (state machine state ISSUED) for hackathon participants. To cover all transitions specified in the state machine, three different situations were included in the workflow of the experiment:  
* Nine participant certificates were confirmed to have submitted valid solutions, the solution references were updated, and the certificates were updated to the ISSUED_FOR_SOLUTION state. * Six hackathon participant certificates were updated to the ISSUED_FOR_PARTICIPATION state, as they were determined to have submitted an invalid solution (the reference to a solution was also updated). * The remaining three participant certificates were updated to the ISSUED_FOR_PARTICIPATION state, as participants have not submitted a solution. Additionally, the Solidity of the smart contract execution costs were recorded once the smart contract was hosted on a Goerli testing network. The transaction fees were recorded (Table 5), which represent the total amount of ETH (Ethereum cryptocurrency) paid to the block producers for processing all transactions, the total amount of GAS usage per all transactions, and the average function GAS usage cost. When compared, the _createCertificate_ function execution costs are higher, as during the execution, a new _Certificate_ data record is created and an NFT token is minted, as opposed to the _confirmEvaluationResults_ when only the specific _Certificate_ data record values are updated. Similarly, the generated _HackChain_ chaincode was hosted on a Hyperledger Fabric network. For each Hyperledger Fabric chaincode function evaluated, a total execution time for all transactions was calculated (Table 5), which includes the duration of state validation, committing data to CouchDB storage and committing data to the blockchain. The difference between functions is marginal because both functions require multiple calls to the _TransactionContextInterface_, to which most of the execution time is attributed. Although the code execution metrics are too different to be compared directly, both _HackChain.sol_ and _HackChain.go_ were successfully compiled, deployed, and executed using the outlined workflow. In the Hyperledger Fabric, a total of 38 blocks (39 transactions) were created during the experiment, while in the Ethereum Goerli test network, a total of 37 blocks (37 transactions) were produced. The difference between the number of blocks can be attributed to the mechanism that the networks use to deploy smart contracts. In