Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] - Balance existing transaction #867

Open
ch1bo opened this issue Aug 20, 2024 · 7 comments
Open

[FR] - Balance existing transaction #867

ch1bo opened this issue Aug 20, 2024 · 7 comments
Labels
enhancement New feature or request Stale

Comments

@ch1bo
Copy link
Contributor

ch1bo commented Aug 20, 2024

Internal (anyone could benefit though)

Area
Transaction building

Describe the feature you'd like

I would like to use the cardano-cli to balance a transaction that was drafted by another application. Assuming we have a transaction already built with body and witnesses (redeemers) by a DApp in a transaction envelope tx.json and some signing key wallet.sk which owns ADA to pay fees:

 cardano-cli transaction balance \
   --socket-path ... \ #
   --testnet-magic 2 \
   --unbalanced-tx tx.json \
   --cardano-signing-key wallet.sk \
   --out-file tx.json

Would connect to the cardano-node as usual to fetch various information (utxo owned by user, protocol parameters, system start and era history) and balance the transaction. That is:

  • (Re-)calculate script costs using redeemers from the tx
  • Estimate fees
  • Find and add input to cover fees
  • Add a change output
  • Write the balanced transaction to disk (or stdout)

Alternative with slightly smaller scope: Take only an input to use for paying fees and change address, very much like transaction build.

Describe alternatives you've considered
Obvious alternative is to do all this in the DApp itself, but balancing a transaction is a generic process and not application-specific. Also, this would tie the transaction creating code very much to the "source" of where UTxO, protocol parameters etc. are fetched from. Having it in the cardano-cli, a dedicated client to the cardano-node, would keep it separated from e.g. an alternative workflow that uses blockfrost.

Additional context / screenshots
We encountered this while designing a command line tool to create certain smart contract transactions in the Hydra protocol. More details here: cardano-scaling/hydra#1574

@ch1bo
Copy link
Contributor Author

ch1bo commented Aug 20, 2024

BTW I could contribute this directly and this feature request is also to test waters whether this would be appreciated?

@CarlosLopezDeLara
Copy link
Contributor

@ch1bo This is a very interesting use case and is very much appreciated. If you can submit the PR it would be awesome, if not, just let us know and we will find it a place on the TODO list.

@CarlosLopezDeLara CarlosLopezDeLara added the enhancement New feature or request label Sep 4, 2024
@CarlosLopezDeLara
Copy link
Contributor

This would enable a more standalone operation of some of hydra tools,

@smelc
Copy link
Contributor

smelc commented Sep 13, 2024

If we were to do this, it would be useful for https://github.com/tweag/cooked-validators too, right @mmontin?

@CarlosLopezDeLara
Copy link
Contributor

Adding example files I got from https://github.com/v0d1ch

commit-utxo.json
deposit.json

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

@github-actions github-actions bot added the Stale label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Stale
Projects
None yet
Development

No branches or pull requests

4 participants