Last updated a week ago
CIP-30 in-browser wallet interface is unnecessarily low-level and does not include a query layer to fetch blockchain data. This leads to suboptimal dApp architecture.
We propose creating a new CIP that extends CIP-30 with new query methods and which allows for abstraction from the CBOR encoding of data.
This is the total amount allocated to MLabs - Re-think CIP-30 wallet interface standard. 3 out of 5 milestones are completed.
1/5
Organising the initiative
Cost: ₳ 40,714
Delivery: Month 1 - Nov 2023
2/5
Develop a JSON-schema CIP
Cost: ₳ 81,429
Delivery: Month 7 - May 2024
3/5
Develop a standardised Query Layer CIP
Cost: ₳ 27,143
Delivery: Month 8 - Jun 2024
4/5
Develop a CIP for the wallet connector API
Cost: ₳ 81,429
Delivery: Month 10 - Aug 2024
5/5
Addressing Feedback and Promoting the CIPs
Cost: ₳ 40,715
Delivery: Month 12 - Oct 2024
Vladimir Kalnitsky (@klntsky)
Dzmitry Shuiski
Success of this project depends on the willingness of major wallet developers and other parties to collaborate on a better in-browser wallet standard (CIP).
Project will be fully open source.
Problem
CIP-30 is a universally accepted web-based wallet standard for Cardano. It provides a minimalistic interface that, in principle, can be used to build almost any kind of Cardano dApp. However, the way dApp<->wallet interaction is defined leads to suboptimal dApp architecture due to CIP-30 limits.
Consider the following problems:
Use of CBOR representations
CIP-30 standard uses CBOR encoding for all data passed from the wallet, e.g. addresses and UTxOs. Interpreting this data within the app requires CBOR decoding functionality that is tedious to implement manually, and so users resort to using cardano-serialization-lib or its close alternative, cardano-multiplatform-lib, which both require loading a WebAssembly blob of >1M size.
For comparison, to start a new Web3 app on Ethereum there is no need to use a library for data serialization. It’s possible to interact with the provider object that is given by the wallet directly, although there are libraries to further simplify this. Using CBOR looks unnecessary, given that JSON is a de-facto standard for web data serialization.
Manual Transaction Building
When comparing developer experience for Cardano dApps and Web3 apps on Ethereum, the thing that is usually noticed first is that Ethereum developers operate on a higher level of abstraction than Cardano wallets.
On Ethereum, a smart contract transaction can be triggered by a simple function call on a Contract object, but when CIP-30 is used, the whole process of constructing transactions is delegated to the developer. This process includes:
The complexity of this process vastly exceeds that of the Ethereum analogue.
Limits of available queries
Most dApps require interacting with scripts, which implies the need to query for available UTxOs locked at script addresses. CIP-30 does not contain a query call that allows that - the only UTxOs that are visible are those owned by the wallet itself.
Some other useful queries, like getting delegation and reward info, stake pool info, transaction metadata or contents, and epoch data, are also outside of scope.
As a result, dApp developers are forced to implement their own query layers on the backend side - which leads to one more problem - inconsistency between states of multiple query layers:
Query Layer State Inconsistency
On Cardano, every running node has its own opinion on the set of currently unspent transaction outputs. Only eventual consistency is guaranteed.
Any dApp that interacts with a CIP-30 wallet has to deal with the inconsistency between the local cardano-node-based query layer and the light wallet query layer, especially when dApp workflow involves sending multiple transactions with the wallet in quick succession.
Thus, the goal of the developers is to ensure that the set of UTxOs available to the wallet and the set of UTxOs the backend cardano-node knows about are synchronized enough to not cause errors when a wallet or backend operations are performed. To give a few examples of potential issues, consider the following scenarios:
Solution
We propose creating an extension standard on top of CIP-30 that addresses all these problems.
Use of JSON instead of CBOR representations
The standard should specify a new set of API methods, or a non-breaking extension of CIP-30 methods, that would allow specifying a preference for human-readable JSON format instead of CBOR for all CIP-30 data types.
To address the well-known Cardano-related CBOR definite-length vs. indefinite-length problem, the standard should refer to CIP-21 (https://cips.cardano.org/cips/cip21/) and require the implementations to follow it.
Automatic Transaction Building
Another set of API calls should be specified, with the goal of abstracting away tedious parts of transaction building.
Declarative transaction building is hard, but we have some experience we can apply. At MLabs, we created a library named cardano-transaction-lib (CTL) (https://github.com/Plutonomicon/cardano-transaction-lib/) (thanks to Catalyst Funds 8 & 9) that facilitates transaction building in JavaScript environments. The main feature of the library is a declarative constraints interface similar to that of plutus-tx-constraints package (https://input-output-hk.github.io/plutus-apps/main/plutus-tx-constraints/html/index.html).
We could standardize an interface similar conceptually, but using JSON instead of PureScript function calls.
For example, to spend a certain UTxO, the client would just call:
walletAPI.buildTransaction({
mustSpend: [{ utxo: “0x123467890ABCDEF…….12345#0”, redeemer: 42 }]
})
The result would be a JSON-serialized transaction built by the wallet, containing the provided UTxO as one of its inputs.
The transaction could later be modified manually before signing, but we can assume most dApps would not need to do that.
Adding new queries
The wallet query layer should be extended with new methods. We propose making a combination of existing query layer implementations into a standard with minimal changes.
We could take these specs as inspiration:
The goal is to make it possible to retrieve the following data without the need to deploy own cardano-node:
Market
All dApp developers targeting browsers could benefit from this proposal.
Challenge statement: Development & Infrastructure. What research, tools or software can improve the developer ecosystem or infrastructure to make it easier to build and scale on the Cardano blockchain?
Current wallet API usability on Cardano is limited in comparison to Ethereum due to the aforementioned problems. Resolving these problems could significantly reduce the time-to-market metric for new Cardano projects and cut development costs, while also providing a way to build more lightweight dApps.
What does this proposal entail?
This proposal entails creating a new CIP with the aim to get new APIs standardized.
However, it does not necessarily follow that wallet developers will agree to adopt and implement the new standard.
In the best-case scenario, the CIP will revolutionize Cardano dApp development. In the worst case, it will be left unnoticed by wallet developers.
Success can be measured subjectively: by perceived approval of the new CIP.
The goal of this project is to get the CIP adopted by wallet developers, which is the ultimate indicator of success.
MLabs maintains a social presence on Twitter and in Plutonomicon Discord, where updates could be posted. Additionally, the release could be announced on IOG technical Discord.
MLabs has proven itself as a company employing dozens of Haskell and PureScript software developers and delivering a number of Catalyst-funded projects in the past.
The main goal of the project is to create a new CIP for in-browser wallet interface that is approved and adopted by wallet developers, as an extension of CIP-30.
Feasibility of our approaches to achieve the goal will be evaluated by project managers and technical leadership of the project, based on time and budget constraints.
1st-2nd month
3rd-4th month
5th-12th month
1st-2nd month
A new CIP pull request that attempts to address the problems should be made available
3rd-4th month
Attract a considerable amount of contributions to the CIP from other participants. Cover the entire API surface with specifications
5th-12th month
Facilitate creating a working prototype for the canonical implementation.
Subtotal: 600 hours @95/hour = $57,000 USD
Total (@ rate $0.21 USD / ADA): 271430 ADA
**In the interest of full transparency, please note we have applied a conservative USD/ADA exchange rate in pricing this proposal. This is to ensure our operations remain stable regardless of market conditions. Although we firmly believe the future of Cardano is bright, we recognize the price of ADA and all cryptocurrencies is inherently volatile. Our financial obligations are denominated in fiat. Most importantly, this includes the salary of our engineers whose hard work makes projects like this possible.
In the unlikely scenario of severe negative price movement beyond our forecasted rate, it is possible that MLabs may need to temporarily suspend work on this proposal until the market recovers. Rest assured, this decision would be made solely to protect our business's long-term viability and never taken lightly.
We appreciate your understanding and support, and we are excited to see what we can achieve together.
This project, if successful, could bring a lot of value to practically everyone in the Cardano ecosystem:
dApp developers would receive the following benefits:
dApp users:
NB: Monthly reporting was deprecated from January 2024 and replaced fully by the Milestones Program framework. Learn more here
MLabs
MLabs has quickly become one of the premier development firms in the Cardano Ecosystem. We are an IOG Plutus Partner and work regularly with IOG to develop the Cardano blockchain and ecosystem. Our team is composed of talented developers who have helped build community projects such as:
Through our work with early-stage projects, we have one of the largest groups of Haskell/Plutus developers in the community.
Website: https://mlabs.city/
The team
Vladimir Kalnitsky - developer
Vladimir is a software developer with a number of contributions to the PureScript ecosystem and solid experience with Haskell. During his undergraduate years, Vladimir focused on functional programming and type theory. Vladimir is more of a 'hacker' than a scientist, but he still values formal reasoning about code and well-founded software development practices.
Dzmitry Shuiski - developer
Dzmitry is an experienced software engineer, currently developing solutions using functional programming techniques, mostly using PureScript and Haskell. Coming from a background in iOS App Development, he is well-versed in various aspects of developing robust and user-centric systems. Dzmitry has made considerable contributions to CTL in the past and is now primarily focused on Cardano dApp development. He is currently pursuing a degree in Software Engineering and Management at the Graz University of Technology to deepen his knowledge in more fundamental disciplines.