Skip to main content

tx sign and tx send

The previous examples of using tx new showed how to create transactions. However, these transactions were immediately ready to be signed and submitted to the network.

To avoid this each of the subcommands has the --build-only argument, which as the name suggests only builds the transaction and prints the transaction envelope.

tx sign​

Let's return to the first example of creating bobs account:

stellar tx new create-account \
--source alice \
--destination bob \
--starting-balance 100_000_000 \
--build-only

would output something like:

AAAAAgAAAADwSUp9CwmVlPN40mKX1I1j39y6DmYc36QS1aK2x6eYVQAAAGQAEcMsAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAACTMkzn1TwPo8SIhnKvnyuv9K2/aWjpX9NTYfyiA7vXaAAAAAAX14QAAAAAAAAAAAA==

You can inspect it with stellar lab! Where you can also sign and send the transaction.

However, you can also sign the transaction with the tx sign command. To do this you can pipe the output of the tx new command to the tx sign command:

stellar tx new create-account \
--source alice \
--destination bob \
--starting-balance 100_000_000 \
--build-only \
| stellar tx sign --sign-with-key alice

This should output something like:

AAAAAgAAAAAebE8Ewg9uzvHRAl+UmvP0kixsyp238kkz0zOy+91FeQAAAGQAFJk4AAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAPpiy8qfSw4pLYG/Bav78FfrFWlte7YQfiHX41DQ+nGWAAAAAAX14QAAAAAAAAAAAfvdRXkAAABA4kjz9Yeub/IrzogjMr57U4nYwCmSJAXxIW+7Xyjan/UweIByF7uEhVS4gEl1N138uq07njVxZwRMtugWyMleCg==

You can again view it in lab and see that there is now a signature attached to the transaction envelope.

::tip Or sign with lab! Though currently you must send it from lab and cannot return to the CLI (a work in progress!).

stellar tx new create-account \
--source alice \
--destination bob \
--starting-balance 100_000_000 \
--build-only \
| stellar tx sign --sign-with-lab

:::

tx send​

Finally, to submit the transaction to the network you can use the tx send command. This command will submit the transaction to the network.

stellar tx new create-account \
--source alice \
--destination bob \
--starting-balance 100_000_000 \
--build-only \
| stellar tx sign --sign-with-key alice \
| stellar tx send

Guides in this category: