tx Commands
So far the examples of the CLI interacting with the blockchain have been through the contract
command. Uploading contracts, deploying contracts, and invoking them. Each of these are different types of transactions, which must be signed and submitted to the network (and in the case of contract related transactions simulated first).
Technically these three are different operations, of which a transaction can contain up to 100 operations. However, in the case of contract related operations a transaction is limited to just one.
So for all other transactions the CLI provides the tx
subcommands. These are:
new
sign
send
simulate
tx new
For the following examples we will use the following accounts:
stellar keys generate --fund alice --network testnet
stellar keys generate --no-fund bob
# You can add a public key to the keys
stellar keys add --public-key GBUG7QTBTT47XVDVE6RZYWRUZBPLOIO57INE6LYZDMIXMMDCREQRUQKI charlie
## and use testnet
stellar network use testnet
Create Account
Creates and funds a new Stellar account. Above alice
was funded by friendbot. However, bob
and charlie
were not. So we can use the create-account
command to fund them.
bob
will receive 10 XLM and charlie
will get 1 XLM.
stellar tx new create-account \
--source alice \
--destination bob \
--starting-balance 100_000_000
stellar tx new create-account \
--source alice \
--destination charlie \
--starting-balance 10_000_000
Notes:
--starting-balance
: Initial balance in stroops to fund the account with (1 XLM = 10,000,000 stroops)
Payment
bob
feels bad that charlie
only got 1 XLM, so they will send 4 more XLM to charlie
.
stellar tx new payment \
--source bob \
--destination charlie \
--asset native \
--amount 40_000_000
Notes:
--asset
: The asset to send - either "native" for XLM or "CODE:ISSUER" format for other assets
Bump Sequence
Bump an account's sequence number forward:
stellar tx new bump-sequence \
--source alice \
--bump-to 123450
Account Merge
Merge one account into another, transferring all XLM.
bob
decides to continue spreading the wealth and merges their account into charlie
's.
stellar tx new account-merge \
--source bob \
--account charlie
Notes:
--source
: The account to remove from the ledger, thus this is its final tranaction
Set Trustline Flags
Modify authorization flags on a trustline:
stellar tx new set-trustline-flags \
--source alice \
--asset USDC:GBUG7QTBTT47XVDVE6RZYWRUZBPLOIO57INE6LYZDMIXMMDCREQRUQKI \
--trustor charlie \
--set-authorize \
--set-authorize-to-maintain-liabilities \
--set-trustline-clawback-enabled
Arguments:
--source
: The issuing account setting the flags (must be the asset issuer)--asset
: The asset in CODE:ISSUER format--trustor
: The account whose trustline flags to modify--set-authorize
: Enable full authorization--set-authorize-to-maintain-liabilities
: Enable limited authorization--set-trustline-clawback-enabled
: Enable clawback for this trustline--clear-*
: Corresponding clear flags to remove each setting
Set Options
Configure account settings:
stellar tx new set-options \
--source alice \
--inflation-dest GBUG7QTBTT47XVDVE6RZYWRUZBPLOIO57INE6LYZDMIXMMDCREQRUQKI \
--home-domain "example.com" \
--master-weight 100 \
--med-threshold 100 \
--low-threshold 100 \
--high-threshold 100 \
--signer GBXSGN5GX4PZOSBHB4JJF67CEGSGT7DGBGGUGWXI4WOQMQEA4SFV2HTJ \
--signer-weight 1 \
--set-required \
--set-revocable \
--set-clawback-enabled \
--set-immutable
Notes:
--source
: Account to modify settings for--inflation-dest
: Set inflation destination account--home-domain
: Set home domain for federation/compliance--master-weight
: Weight of the account's master key (0-255)--low-threshold
: Weight threshold for low security operations--med-threshold
: Weight threshold for medium security operations--high-threshold
: Weight threshold for high security operations--signer
: Add a new signer public key--signer-weight
: Weight for the new signer (0 removes the signer)--set-required
: Enable requiring authorization for new trustlines--set-revocable
: Enable revoking of trustlines--set-clawback-enabled
: Enable clawback for asset issuing account--set-immutable
: Make account settings immutable--clear-*
: Corresponding clear flags to remove each setting
Change Trust
Create or modify a trustline:
stellar tx new change-trust \
--source alice \
--line USDC:ISSUER \
--limit 100000000
Arguments:
--source
: Account creating/modifying the trustline--line
: Asset to create trustline for in CODE:ISSUER format--limit
: Maximum amount that can be held (0 removes trustline)
Manage Data
Manage account data entries:
stellar tx new manage-data \
--source alice \
--data-name config \
--data-value 7465737476616c7565 # hex encoded
Notes:
--data-name
: Name of the data entry (up to 64 bytes)--data-value
: Hex encoded value to store (up to 64 bytes, omit to delete)
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