Please describe your proposed solution.
Problem
There are no language-agnostic mechanisms for specifying the types of information and values used in Cardano DApps, a detrimental fact to productivity and cross-language environment interoperability. A significant percentage of DApp development effort is spent on dealing with serialization/deserialization issues between on-chain code types, off-chain/frontend, and analytics/databases. This major source of delay in project timelines could be eliminated if types would be language agnostically defined once per DApp; with serialization/deserialization code for multiple targets generated automatically from the agnostic definition.
Currently, type definitions for a typical Cardano DApp must be specified in the Haskell programming language. Together with the <u>PlutusTx</u> or <u>Plutarch</u> libraries, Haskell is the de-facto main tool for writing Plutus programs.
The lack of language-agnostic tools for specifying Cardano DApps data types (e.g. datums, redeemers, etc.) has a negative effect on productivity. Furthermore, it constitutes a fundamental hurdle to cross-language environment interoperability and proliferation of generic tooling to enable rich interaction with DApps (e.g., database explorers).
The mentioned issue of language-tied typing has become more severe with the proliferation of different PAB platforms, each written in different languages. PAB platforms enable developers to build software that give users the ability to interact with Cardano DApps from a variety of platforms (e.g., server, desktop, browser, mobile etc.). Examples of such platforms include <u>Bot Plutus Interface</u> (Haskell), <u>Cardano Transaction Lib</u> (Purescript), and <u>Lucid</u> (Javascript).
To make Cardano DApps available across all the aforementioned platforms, structured information needs to be effectively shared in a language-agnostic manner and made available to different language/PAB environments. Furthermore, blockchain analytics applications, DApp aggregators, and DApp interoperability will require light DApp-type schemas that are decoupled from the DApp’s implementation code - it is not very practical to have to import a DApp’s codebase in order to interpret its datums, redeemers, and other on-chain data.
We want to consolidate the solution to this issue into a single project that takes type definitions out of a language-specific environment and into a configuration language that can be then fed to a reliable code generation tool that targets a number of different language/PAB environments.
The intent behind this project is to align the Cardano tech environment with modern best practices that facilitate building robust, technology stack agnostic Cardano DApps.
Solution
We propose a configuration language for specifying DApp schemas. The language makes use of code-generation tooling, which using the schemas produces ‘type libraries’ (aka. typelibs) for different language/PAB environments. Each typelib is generated alongside supporting libraries for handling encoding, serialization and other essential operations. All the mentioned processes are automated, maintaining correctness and compatibility between different language/PAB environments.
Cardano DApp Schemas serve as a language-neutral, extensible mechanism for specifying type definitions and code-generating different language environments library implementations.
Market
Developers building Cardano DApps and extended tooling and infrastructure.
Features
- Configuration language for specifying data types aligned with the Plutus data model.
- Support for sum, record/product and polymorphic types.
- Automated production of type libraries from configuration-based specifications.
- Integration with build systems associated with the target language/PAB environments (e.g., Cabal, Spago, Node, Nix etc.).
- Standardized data type associated operations, including JSON encodings, Plutus data encodings, Plutarch instances, Pretty printers, Arbitrary instances and more.
Related work
For the reader’s reference, the following standards and technologies have solved a similar problem in traditional software sectors:
- <u>ASN.1</u> - adopted by widely used cryptographic standards (see X.509),
- <u>Google Protobuf</u> - used by major tech companies as the foundation for RPC and microservice-based architectures,
- <u>Apache Thrift</u> - used by major tech companies as the foundation for RPC and microservice-based architectures,
- <u>Apache Avro</u> - configuration-based schema definition mechanism used across different Apache projects,
- <u>CDDL</u> - used by Cardano itself at the network/transport level, fairly complicated standard with little supporting tooling available,
- <u>XDR</u> - used for RPC in Linux-based enterprise networks,
- <u>Microsoft IDL</u> - used by Microsoft DCE/MS-RPC protocols and a foundational technology for MS Windows-based enterprise networks,
- ADL <u>https://github.com/timbod7/adl</u>
- Data specification technology inspired by and built for functional programming language environments.
Please describe how your proposed solution will address the Challenge that you have submitted it in.
Typical Cardano DApp projects involve a very diverse team. For instance, a frontend team working with Javascript/Typescript, contract writers using Purescript and the <u>Cardano Transaction Lib</u>, an analytics team reporting on the DApp’s state and statistics with SQL/GraphQL using relational databases, and a Haskell team writing Plutus programs and building server/desktop automation using <u>Bot Plutus Interface</u>.
We hope this proposal will make such diverse teams work together more effectively by consolidating all data type definitions in a single place, and reusing them reliably across their respective technological environments.
The successful adoption of this project would radically increase developer productivity, while decreasing the amount of unnecessary, tedious, error-prone and boilerplate code that needs to be manually written and curated. Type definitions would serve as documentation for the project, as well, and could very well be foundational to proliferation of generic tools and infrastructure that can interact with schema-enabled Cardano DApp projects.
What are the main risks that could prevent you from delivering the project successfully and please explain how you will mitigate each risk?
This project will generate code that integrates closely with target language/PAB environments, concretely <u>Cardano Transaction Lib</u>, <u>Plutarch</u>, <u>Lucid</u> and <u>Postgres</u>, to name a few. Given that some of these projects are currently under active development, we anticipate that API breakages will be a common occurrence and we intend to bring respective development teams into a common social circle in order to organize for mutual evolution and growth.
We don’t anticipate any significant technological hurdles. Encouraged by our experience successfully building and using <u>Purescript Bridge/CTL</u>, we are confident in our ability to deliver such a project.