# 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  
The model-to-model transformation results are presented in Table 2, where the quantitative model metrics and the differences between the Blockchain CIM, the transformed Blockchain PIM, and the extended Blockchain PIM are outlined. For each model, the UML model element counts that were directly utilised during the transformation or are a result of the transformation are presented. Based on the two use cases in the Blockchain CIM use case model, the generated Blockchain PIM for _HackChain_ has a single <<SmartContract>> class with two operations. Fur \begin{table}
\begin{tabular}{l c} \hline \hline
**Element** & **Element Count** \\ \hline \multicolumn{3}{c}{**BlockchainCIM**} \\ \hline Business process (activity) & 2 \\ Actor & 2 \\ \textless{}blockchain>> actor & 1 \\ \textless{} use case & 2 \\ Association between actor and use case & 4 \\ Class & 6 \\ Property & 13 \\ \textless{}on-chain>> property & 6 \\ Association between classes & 8 \\ \textless{}on-chain>> association member end & 4 \\ \hline \multicolumn{3}{c}{**Blockchain PIM (Transformation Result)**} \\ \hline Class & 2 \\ \textless{}SmartContract> class & 1 \\ Operation & 2 \\ Operation parameter & 0 \\ Property & 9 \\ \hline \multicolumn{3}{c}{**BlockchainPIM (after Extension)**} \\ \hline Class & 2 \\ \textless{}SmartContract> class & 1 \\ Operation & 2 \\ Operation parameter & 12 \\ Property & 13 \\ State & 3 \\ Transition & 4 \\ Effect & 1 \\ Guard & 2 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: _HackChain_ Blockchain CIM to Blockchains PIM transformation metrics. Figure 22: _HackChain_ Hyperledger Fabric PSM: state machine diagram. thermore, there is a single contained class in Blockchain PIM that encompasses in total nine properties based on six <<on-chain>> properties and three <<on-chain>> association member end properties defined in the Blockchain CIM domain class model. After the transformation to the Blockchain PIM, this model was manually extended with additional 16 model elements, the majority of which (12) were operation parameters. When considering the main structural model elements (classes, properties, and operations), 14 out of 18 Blockchain PIM elements were automatically transformed from Blockchain CIM; thus, PIM was extended with four additional elements, all of them being properties. In contrast to structure specification, the behaviour in PIM was specified manually; therefore, the state machine elements are present only in extended Blockchain PIM. The operations of the <<SmartContract>> class were used in the specification of the smart contract behaviour, represented using the state machine diagram, the logic of which was based on the Blockchain CIM business processes. The resulting Blockchain PIM was used during the transformations to the Ethereum PSM and Hyperledger Fabric PSM and the quantitative metrics of both PSMs are presented in Table 3. The differences between the metrics of the two Blockchain PSMs are directly related to the supported Solidity and Go metamodel concepts. The produced Blockchain PSMs differ in terms of the smart contract structure: due to the platform specifics, the Ethereum PSM has an additional mapping property, while the Hyperledger Fabric does not need it; based on the PIM state machine transition effect, the Ethereum PSM has an additional <<event>> operation, while the Hyperledger Fabric PSM has a _CertificateCreated_ <<structure>> class; for denoting the certificate state, the Ethereum PSM has _state_ <<member>> property and <<enum>> _CertificateState_ with literals, while Hyperledger Fabric PSM has a _state_ <<field>> string property. Additionally, for implementing the NFT standard functionality (minting of tokens), both Blockchain PSMs were specified to inherit the ERC 721 standard implementations from the OpaqueBehavior library: Ethereum PSM <<contract>> _HackChain_ inherits in total 36 elements and the Hyperledger Fabric <<chaincode>> _HackChain_ inherits 26 additional elements.