# Stellar

Source: https://developers.bitgo.com/docs/stellar

## Stellar

Stellar can be accessed with the following coin types:

| Environment        | Coin Type | Faucet                                                                                                                                                                           |
| :----------------- | :-------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Stellar Production | xlm       |                                                                                                                                                                                  |
| Stellar Testnet    | txlm      | <a href="https://www.stellar.org/laboratory/#account-creator?network=test" target="_blank" rel="noreferrer">https://www.stellar.org/laboratory/#account-creator?network=test</a> |

### Explorer
<a href="https://stellarchain.io/" target="_blank" rel="noreferrer">https://stellarchain.io/</a>


### Generating wallets

```javascript
bitgo
  .coin('txlm')
  .wallets()
  .generateWallet({
    label: 'My Test Wallet',
    passphrase: 'secretpassphrase1a5df8380e0e30',
  })
  .then(function (wallet) {
    // print the new wallet
    console.dir(wallet);
  });
```
```shell
LABEL="My Test Wallet"
PASSPHRASE="secretpassphrase1a5df8380e0e30"

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d "{ \"label\": \"$LABEL\", \"passphrase\": \"$PASSPHRASE\" }" \
http://$BITGO_EXPRESS_HOST/api/v2/txlm/wallet/generate
```

Before you can use a Stellar wallet, you must initialize it on the Stellar blockchain. You must first send a funding
transaction to the wallet address. When BitGo detects this funding transaction, it automatically sends another
initialization transaction to set up the signers and the home domain of the account.

Until the network confirms the initialization transaction, the wallet is _not_ ready for use, and the API does _not_
expose the receive address. This is to protect users from losing assets by sending to a wallet that does not exist on the
network.

> 🚧 **Warning:** Do not use a Stellar wallet while it initializes or you may lose assets.

Stellar accounts must maintain a minimum balance. See [Stellar Balances](#xlm-balances).

### Required reserve

```shell
curl -X GET \
-H "Authorization: Bearer $ACCESS_TOKEN" \
https://app.bitgo-test.com/api/v2/txlm/requiredReserve
```

Fetch information about reserve requirements for an account. See [Stellar Balances](#xlm-balances).

#### HTTP Request

`GET /api/v2/:coin/requiredReserve`

#### HTTP Response

| Field          | Description                                                     |
| :------------- | :-------------------------------------------------------------- |
| baseFee        | base fee used in transaction fees.                              |
| baseReserve    | base reserve used in minimum account balances.                  |
| height         | the height of the block that provides the base values.          |
| minimumFunding | minimum funding balance, calculated using reserve and base fee. |
| reserve        | minimum account balance, calculated using base reserve.         |

### Creating addresses

```javascript
bitgo
  .coin('txlm')
  .wallets()
  .getWallet({ id: '585c51a5df8380e0e3082e46' })
  .then(function (wallet) {
    return wallet.createAddress();
  })
  .then(function (newAddress) {
    // print new address details
    console.dir(newAddress);
  });
```
```shell
WALLET=585c51a5df8380e0e3082e46

curl -X POST \
-H "Authorization: Bearer $ACCESS_TOKEN" \
https://app.bitgo-test.com/api/v2/txlm/wallet/$WALLET/address
```

The BIP-32 standard does not apply here, and hence generated XLM addresses differ only in their sequentially
incrementing <a href="https://developers.stellar.org/docs/learn/encyclopedia/memos" target="_blank" rel="noreferrer">memo</a> id components. The memo type used by BitGo is `MEMO_ID`: a 64-bit unsigned numeric string. Whenever you create a new address, the address `coinSpecific` property contains the incremented `memoId` and the `rootAddress`.

### Balances

Lumen (XLM) is the native asset of the Stellar blockchain. The base unit of Lumen is stroop:

- 1 stroop is <code>10<sup> </sup>-7</code> or 0.0000001 Lumen.
- 1 Lumen is <code>10<sup> </sup>7</code> or 10000000 stroop (10 million).

The API supports balances in string format: `balanceString`, `confirmedBalanceString`, `spendableBalanceString`, and `seqIdString`.

**_NOTE:_**  If you provide a `memoId` on the address, balances only return `seqIdString`.

All Stellar accounts must maintain a <a href="https://developers.stellar.org/docs/learn/fundamentals/lumens#minimum-balance" target="_blank" rel="noreferrer">minimum balance</a> of
lumens. The base reserve, which is currently 0.5 XLM, determines the minimum balance. The absolute minimum
balance for an account is 1 XLM, which is equal to (2 + 0 entries) \* 0.5 base reserve. Each additional entry reserves
an additional 0.5 XLM.

### Base fee

Stellar has a <a href="https://developers.stellar.org/docs/learn/fundamentals/lumens#transaction-fees" target="_blank" rel="noreferrer">base fee</a> that a VCG auction
determines dynamically. When you submit a transaction to the network, you specify the maximum base
fee you’re willing to pay per operation, but Stellar charges you the lowest possible fee based on network activity.

When network activity is below capacity, you pay the network minimum, which is currently 100 stroops (0.00001 XLM) per
operation.

### Transactions

Stellar uses an account-based model, similar to XRP. Additionally, due to the use of memo, Stellar transactions only
support one input and one output.

BitGo's XLM multisig contract currently only supports one sender and one recipient so the `sendMany` is not supported.

### Federation

BitGo supports the Stellar federation protocol
that matches Stellar addresses to Stellar accounts. Additionally, the BitGo federation server provides the next memo id
for the wallet. Stellar accounts can be looked up by their Stellar address or their account ID.

Users can create email-like usernames for their Stellar wallets. A Stellar address consists of the Stellar username and the account <a href="https://developers.stellar.org/docs/learn/glossary#home-domain" target="_blank" rel="noreferrer">home domain</a> (for example, `test*bitgo.com`).

Stellar usernames are unique, and only accept lower-case letters, numbers, and the characters: `-_.+@`. BitGo automatically
sets the home domain to `bitgo.com`. A Stellar username can only be set once the wallet initializes, and it
cannot be changed. See [Update Wallet](/reference/v2walletupdate).
