Develop a batched transaction generator that generates signed transactions which can be directly submitted to the Cardano blockchain even when there are multiple assets and recipient addresses involved.
Batching transactions is a pertinent use case as it has a direct impact on transaction fees that are paid. At present teams devise their own approaches to batch transactions when using the cardano-cli. This project will create a well designed open source repository that can be used by teams for batching transactions easily by just configuration of properties.
We implemented a batched transaction (manually prepared) in testnet to observe the reduction in transaction fee. To test, we sent a native token to 150 different receive addresses in one transaction. The total transaction fees turned out to be just ~ 0.73 ADA whereas if the transactions were not batched, the total cost would have been 150 x ~0.17 = ~ 25.5 ADA.
Here is the test transaction on cardanoscan: <https://testnet.cardanoscan.io/transaction/af31b5852987d350a089684e6ccc9189c8a86b0014a88d3de296803bf988aa41>
A reduction in fees by 35 times as seen in the above example is why we think it is worth the effort to develop this into an open source solution.
Projects which employ batching of transactions today in their dApps and projects use their own approaches. There is a lack of scalable solutions which dApp developers can use out of the box. We will develop an open source repository with the code for this solution, a working example on testnet and video walkthrough for using the solution.
How the components of this solution will work:
- The transaction generator (haskell component) will receive data from the data source integration service about receiving addresses as well as the native assets and their amounts that need to be transferred.
- The generator will read the configuration properties and generate commands that perform a create a batched transaction, signs and submits it to the Cardano blockchain. The configuration among other parameters will include the signing keys for the address/wallet being used with the CLI.
- Shell scripts will be used to orchestrate the various steps that need to occur sequentially.
A schematic diagram of the components can be found here.
Benefits of this open source solution
- Teams do not have to invest time and effort in developing batching mechanisms when using cardano-cli.
- Reduction in cost when transferring native assets to multiple addresses.
- Configurability of data source will allow this code base to cater to various project teams and scenarios.
- Automated approach to building batched transactions. It is possible to manually create batched transactions using the cardano-cli’s transaction build command. But the manual approach is not scalable and this provides a programmable way for creating batched txs.
- Demonstration of this solution will highlight the advantage that Cardano EUTXO model has over other blockchains in terms of fees. Cardano's low tx fees is widely quoted. This solution of batching will allow development teams to readily harness it.
Use cases:
- NFT drops : NFT drops require native assets to be sent to multiple addresses as part of the drop.
- Token sales by companies : During various stages tokens purchased have to be distributed to multiple recipients.
- Token faucets: Faucets depending on cardano-cli can make use of the repository.
Design considerations:
- The generator will be coded in Haskell to take advantage of Haskell’s type safety and immutability. These are significant as the accuracy of the correctness of the generated transaction depends on the accuracy of the generator code.
- The datasource integration module will be developed as a micro service decoupled from the tx generator itself. Adapter design pattern will be used for interfacing data sources in a plug and play model.
- Batch size that can be accommodated into a transaction (which is capped at 16KB today) depends on the type of asset that is being sent. So the batch size (besides other properties) should be a parameter that teams that use this solution can configure.
Configurability
- The generator will be configuration driven so that users of the repository can set properties like maximum and minimum batch size, policy ids for exclusion and inclusion etc.
- The datasource integration being designed as a micro service will allow modifications independent of the generator component. Additional data sources can be added in as plug and play.
Future scope:
Pipelining mechanisms for this system so that it can be interfaced into live applications through APIs. This is part of future scope as interfacing with application pipelines rather than using as a standalone repository requires extensive work.
As described in the challenge details, the OSDE challenge aims to promote open source projects, open-source frameworks, and accessible knowledge. This project aligns with the guiding questions by ensuring benefits for future teams from this work, by sharing our knowledge and work through an open source repository. This proposal is for developing a common tool.
This open source solution aligns with all the key metrics of this challenge by
- adding to the number and the quality of Cardano Open Source projects
- Increase the number of contributors by way of our team's contribution.
- adding one more open source tool for the community to use.
Health challenges like Covid can reduce availability of human resources and delay our delivery timeline.