# MDA-Based Approach for Blockchain Smart Contract Development
## 3 MDA-Based Smart Contract Development Method  
According to the MDA principles, the MDAsmartCD method outlines three different models: Blockchain CIM, Blockchain PIM, and Blockchain PSM. The process of transitioning between these models is defined in our method, along with the definitions of metamodels (extended using UML profiles), input and output models, and algorithms for transformations. The general process of the proposed method is presented in Figure 1, where the main development steps of each model and the final step of the development of the smart contract code are defined. The proposed method utilises UML as a basis for the definition of all proposed models (CIM, PIM, and PSM). In some respects, the UML is used as is, particularly during the specification of the smart contract behaviour. However, the structure specification is supported by additional UML metamodel extensions, which include blockchain-specific stereotypes and datatypes. In each upcoming section, the metamodels of each model of the MDAsmartCD method are presented, encompassing the elements of UML metamodel and their extensions. For each model, the model definition steps and model transformation algorithms are also presented. The MDAsmartCD method (Figure 1) starts with the Blockchain CIM definition which is supported by the provided UML profile for Blockchain CIM. In Blockchain CIM, a developer outlines business processes and uses the defined information for the specification of the use case and domain class model. Once the specification is completed, the model is validated using the Object Constraint Language (OCL) validation rules. The validation rules check model conformance to the Blockchain CIM requirements (usage of stereotypes and elements, model structure and composition). The final Blockchain CIM is used as an input for the definition of Blockchain PIM. The Blockchain PIM definition starts with a model-to-model (M2M) transformation of Blockchain CIM to Blockchain PIM. The transformation creates Blockchain PIM elements based on Blockchain CIM elements and applies specific Blockchain PIM stereotypes according to the outlined ATL rules. The Blockchain PIM then can be extended by the developer via augmentation of the model (e.g., developer can specify additional state machine behaviours and smart contract structural features based on business processes). The Blockchain PIM is also validated using the defined OCL rules in the Blockchain PIM profile: if the model is correctly defined (a class for smart contract exists, smart contract has defined operations, opaque behaviors, state machines); if Blockchain CIM stereotypes are correctly applied; if state machines are correctly specified (e.g., transition triggers correspond to smart contract operations). The validated Blockchain PIM is further used as an input for the definition of Blockchain PSM. The Blockchain PSM definition begins with the M2M transformation implemented using ATL rules. For a selected platform, the M2M algorithm transforms Blockchain PIM elements to Blockchain PSM elements, applies Blockchain PSM stereotypes, and, based on the specified state machine behaviours, creates new platform-specific structural features. The developer once again can augment the model, this time by utilising the provided opaque behavior library elements or outlining the behaviour using sequence diagrams. Lastly, the produced model is validated using OCL rules by checking the conformance to the specifics of the selected blockchain platform, especially the correct stereotype usage, model conformance to expected structure, and appropriate specifications of behavioural elements. In the final step of the MDAsmartCD method, the development of the smart contract starts with the model to text (M2T) transformation, during which the validated Blockchain PSM is used as an input. In this transformation, MOFM2T templates are used to define the mappings of Blockchain PSM metamodel elements to implementation language concepts in order to generate platform-specific smart contract code.