Towards seamless cross-platform smart-contract development

With the growing interest in blockchain technologies, smart-contract development has gained more and more traction in recent years. This is an exciting new field, which holds great potential in providing solutions for significant real-world problems.

The novelty of this field stems from the decentralised and trust-less nature of blockchain, which are attributes that other software solutions have lacked, to date. However, developing solutions within a new field often comes hand-in-hand with a lack of tools for developing the desired solutions in an efficient manner. Currently, a smart- contract developer is required to keep up with the rapid evolution of the related technologies, the technical differences of a multitude of platforms such as smart-contract language versions, and different blockchain platforms. Keeping up-to-date with all the technologies and their frequent updates tends to hinder the developer’s ability to approach the solution in a high-level manner and focus on the actual logic of the program. Moreover, the issue is exacerbated when developers would be required to write similar code split into multiple files in order to support different platforms.

This research set out to address the latter issue primarily by means of a framework that would allow developers to combine common code, which is shared between multiple platforms, with unique code for specific platforms, together in a single file. The developer would simply add annotations to the code in this file to specify to which platform the different blocks of code belong.

The use cases in this study focused primarily on the Solidity smart- contract language, and mainly targeted the issue of frequent changes being released across different Solidity versions. These changes would often result in older code not working as expected or even not compiling at all. The work being proposed also analyses situations where a smart-contract developer might want to deploy their Solidity smart contract onto multiple blockchain platforms. Traditionally, a developer would have to create different files containing duplicate code for all the targeted platforms. Using the proposed framework, the developer could instead create one file and specify for which platform each code-block would be intended. The framework would then automatically generate the necessary files with the deployable smart-contract code for all the different platforms.

A use-case study of a smart contract designed to be deployed across six different platforms confirmed that, when using the proposed approach, developers could generate the deployable smart-contract code for all the different platforms by feeding just one file into the framework. The single file would consist of less than half the lines of code needed in a more traditional approach. The significant reduction in lines of codes would also translate into less time and effort being required for maintaining code for different platforms and versions. This would also allow the developers to shift their focus towards high- level implementation.

The above results show that by using the proposed framework, developers would be able to write smart contracts intended for different platforms and versions in a seamless manner, allowing for developers to focus on the high-level logic.

Figure 1. Structure of a smart-contract source file
Student: Stefano Schembri
Course: B.Sc. IT (Hons.) Software Development
Supervisor: Dr Joshua Ellul