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 bob
s 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:
ποΈ Contract Lifecycle
Manage the lifecycle of a Stellar smart contract using the CLI
ποΈ Deploy a contract from installed Wasm bytecode
Deploy an instance of a compiled contract that is already installed on the network
ποΈ Deploy the Stellar Asset Contract for a Stellar asset
Deploy an SAC for a Stellar asset so that it can interact with smart contracts
ποΈ Extend a deployed contract instance's TTL
Use the CLI to extend the time to live (TTL) of a contract instance
ποΈ Extend a deployed contract's storage entry TTL
Use the CLI to extend the time to live (TTL) of a contract's persistent storage entry
ποΈ Extend a deployed contract's Wasm code TTL
Use Stellar CLI to extend contract's Wasm bytecode TTL, with or without local binary
ποΈ Install and deploy a smart contract
Combine the install and deploy commands in the Stellar CLI to accomplish both tasks
ποΈ Install Wasm bytecode
Use the Stellar CLI to install a compiled smart contract on the ledger
ποΈ Payments and Assets
Send XLM, stellar classic, or a soroban asset using the Stellar CLI
ποΈ Restore an archived contract using the Stellar CLI
Restore an archived contract instance using the Stellar CLI
ποΈ Restore archived contract data using the Stellar CLI
Restore archived contract storage entries using Stellar CLI
ποΈ tx Commands
Create stellar transactions using the Stellar CLI
ποΈ tx op add
Create stellar transactions using the Stellar CLI
ποΈ tx sign and tx send
Create stellar transactions using the Stellar CLI