# MDA-Based Approach for Blockchain Smart Contract Development
## 4 Application of the MDAsmartCD Method for Development of Hackathon Certificate Issuing Solution
### Blockchain PIM for HackChain  
The M2M Blockchain CIM to Blockchain PIM transformation result is outlined in Figure 16. During the transformation, a created _SmartContract_ class was appended with two operations (_createCertificate_ and _confirmEvaluationResults_) based on the CIM use cases _Create Certificate_ and _Confirm Evaluation Results_ that were associated with the <<blockchain>> actor. Furthermore, the specified Blockchain CIM domain model classes were analysed, based on which the _SmartContract_ class was appended with a contained _Certificate_ class, representing the data structure. The _Certificate_ class also includes all properties from Blockchain CIM that had the <<on-chain>> stereotype applied. Additionally, the _Certificate_ class also includes the properties based on the Blockchain CIM <<on-chain>> association ends; these properties are outlined as references to the Blockchain CIM _Hackathon_, _Participant_, and _Solution_ classes' unique identifiers, and are of _Integer_ type.  
Figure 16: Blockchain CIM to Blockchain PIM transformation result: class diagram.  
Figure 15: Blockchain CIM _HackChain_ domain model: class diagram.  
After the transformation was complete, as supported by the method, the _SmartContract_ class was manually updated. Specifically, the operations had their parameters specified, because this specification step requires additional input from the developer and cannot be fully automated. Furthermore, two class properties _tokenCounter_ and _certificates_ were created, as well as the _Certificate_ class properties _owner_ and _tokenID_, to better keep track of unique certificate records and the certificate token ownership. Additionally, changes to improve readability were made to the naming of elements of the <<SmartContract> class: the _SmartContract_ class was renamed to _HackChain_; the _Certificate_ properties _title_ and _valid_ were renamed to _hackathon_ and _solutionValid_, since before the transformation, these properties belonged to _Solution_ and _Hackathon_ classes, respectively. The resulting extended Blockchain PIM class diagram is presented in Figure 17. Furthermore, a behaviour was outlined for the _Certificate_ class using the state machine diagram (Figure 18). The behaviour specification is based on the _Issue certificate_ and _Evaluate submitted solutions_ business processes specified in the Blockchain CIM. As outlined in the state machine (Figure 18), the _Certificate_ is created in an _Issued_ state, denoting that the _Certificate_ was issued to a participant, and can later transition to the _Issued for participation_ state or _Issued for a solution_ state. As the naming implies, the _Issued for participation Certificate_ is awarded to a participant for joining the hackathon but not having a solution submitted during the hackathon or having submitted an invalid solution, and the _Issued for a solution Certificate_ is awarded to a participant who submitted a valid solution.  
Figure 17: The extended _HackChain_ Blockchain PIM: class diagram.  
Figure 18: The extended _HackChain_ Blockchain PIM: state machine diagram.