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

Separate tx build from simulate/sign/send #1265

Closed
leighmcculloch opened this issue Mar 20, 2024 · 4 comments · Fixed by #1267
Closed

Separate tx build from simulate/sign/send #1265

leighmcculloch opened this issue Mar 20, 2024 · 4 comments · Fixed by #1267
Assignees

Comments

@leighmcculloch
Copy link
Member

leighmcculloch commented Mar 20, 2024

I'm splitting this component of #1180 into its own issue, because I think it needs to be prioritised separately.

What

Add support for the ability to not sign and send transactions to the network and instead output their transaction XDR as base64 to stdout.

Why

The CLI signs every transactions it submits to the network. It also has the option to simulate only.

Users who wish to build a transaction and submit it at a later date or sign it on another machine need a way to perform all the operations that the CLI supports today without doing those final two steps of signing and sending. These users need the CLI to output the transaction XDR rather than performing those steps.

How

Add a --build-only option wherever the --source option exists.

When --build-only is present, commands do not simulate, sign, or send the transaction to the network. Instead the base64 encoded transaction XDR is outputted to stdout.

Stdout is intentional so that the output can be piped to other programs.

Example

For example, today the following command will simulate a deploy, then build a transaction that performs the deploy, the sign the transaction with the source, then send it to the network.

$ soroban contract asset deploy \
    --asset CDE:GCYLVLL2FC7VGFHNU4MCSQ4GP3LFVK5NPSGH5HVMLHBBWJ56WOAVSIPY \
    --source me
CAFRE77725EPX4ISTZHEDVMGHASMLBM35PURHMQXRDOWWDJLSND76NS6

For example, with this change it will be possible to build the tx without signing and submitting:

$ soroban contract asset deploy \
    --asset CDE:GCYLVLL2FC7VGFHNU4MCSQ4GP3LFVK5NPSGH5HVMLHBBWJ56WOAVSIPY \
    --source me \
    --build-only
AAAAAgAAAACUdJTjk6FaYdoQ/LNQtVN9VXKdysiWyB+6ZwjPaxxxgQDfXAwACRCAAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAYAAAAAQAAAAEAAAABQ0RFAAAAAACwuq16KL9TFO2nGClDhn7WWqutfIx+nqxZwhsnvrOBWQAAAAEAAAAAAAAAAAAAAAA=

For example, after #1180 is also complete we'd have a composable set of commands:

$ soroban contract asset deploy \
    --asset CDE:GCYLVLL2FC7VGFHNU4MCSQ4GP3LFVK5NPSGH5HVMLHBBWJ56WOAVSIPY \
    --source me \
    --build-only \
  | soroban tx simulate \
  | soroban tx sign --signer me \
  | soroban tx send
CAFRE77725EPX4ISTZHEDVMGHASMLBM35PURHMQXRDOWWDJLSND76NS6

Related

This issue is similar and related to #1264.

@github-project-automation github-project-automation bot moved this to Backlog in DevX Mar 20, 2024
@leighmcculloch leighmcculloch changed the title soroban-cli: separate tx build from send Separate tx build from send Mar 20, 2024
@tomerweller
Copy link

tomerweller commented Mar 20, 2024

What if instead of --no-sign we would call it --build-only (or ... a better name) and then introduce 3 new commands: simulate, sign and send, which will give the user more fine grained control over the tx pipeline?

@leighmcculloch
Copy link
Member Author

That's a good point. I've updated the issue above and example to reflect that it only builds a tx, no simulation, signing, or sending.

@leighmcculloch leighmcculloch changed the title Separate tx build from send Separate tx build from simulate/sign/send Mar 20, 2024
@willemneal
Copy link
Member

willemneal commented Mar 20, 2024

This makes a lot of sense. There is already fee:Arg which has fee, cost, instructions, however, this could become txn::Arg which would include all txn related args. This way all the other commands that end up creating transactions will share the implementation.

@leighmcculloch
Copy link
Member Author

leighmcculloch commented Mar 20, 2024

There is already fee:Arg which has fee, cost, instructions, however, this could become txn::Arg which would include all txn related args.

We have non-fee txn args in the config::Args already, for example the network option which impacts which network passphrase to use, and the --source-account option which is also for the txn.

Maybe both of these needs merging together, or maybe fees should be kept fees since fees is a reasonably complex-on-its-own set of options that benefit from bucketing together.

@janewang janewang moved this from Backlog to Todo in DevX Apr 1, 2024
@janewang janewang moved this from Todo to In Progress in DevX Apr 16, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in DevX May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants