> ## Documentation Index
> Fetch the complete documentation index at: https://developers.stellar.org/llms.txt
> Use this file to discover all available pages before exploring further.

# tx Commands

> Create stellar transactions using the Stellar CLI

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:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
stellar keys generate --fund alice --network testnet
stellar keys generate 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](https://developers.stellar.org/docs/networks.md#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.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
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`.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
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:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
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.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
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:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
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:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
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:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
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:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
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)
