# Tezos

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

## Tezos

Tezos (xtz) can be accessed with the following coin types:

| Environment            | Coin Type | Faucet                                                                                                 |
| :--------------------- | :-------- | :----------------------------------------------------------------------------------------------------- |
| Tezos Production       | xtz       | <a href="https://faucet.tezos.com/" target="_blank" rel="noreferrer">https://faucet.tezos.com/</a>     |
| Tezos Testnet          | txtz      | <a href="https://teztnets.com/" target="_blank" rel="noreferrer">https://teztnets.com/</a> |

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


### Enterprise fee address

```shell
ENTERPRISEID=585c51a5df8380e0e3082e46

curl -X POST \
-H "Authorization: Bearer $ACCESS_TOKEN" \
https://app.bitgo-test.com/api/v2/txtz/enterprise/$ENTERPRISEID/feeAddressBalance
```

Each enterprise has a fee address which is used to pay for transaction fees on every Tezos wallet in such
enterprise. The BitGo website dashboard displays the fee address, and you must fund it before creating a
wallet, address, or sending assets. Unlike in Bitcoin (where the sending wallet also pays the transaction fees) the BitGo
Tezos wallet contract requires a separate account to initiate the transaction and pay the fees. If the enterprise fee
address runs out of assets, you cannot create new wallets, addresses, or send transactions until you fund
the fee address. You cannot use one of your own Tezos wallets to fund the fee address if the fee address is
too low (because you cannot send transactions from your wallet). Create and fund a non-BitGo Tezos account
to fund your BitGo enterprise fee address. Any open source Tezos wallet or
exchange can be used to create an account.

> 📘 **Note:** The fee address is a single-signature account and BitGo creates and owns the private key, so you cannot
send assets out of the fee address once you have sent them in.

There is a 'feeAddress' field under the 'CoinSpecific' key for Tezos wallets. Use this address to pay the
fees for creating transactions and addresses.

### Generating wallets

To create a Tezos wallet using BitGoJS:

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

    // print the new wallets address to send to
    console.dir(wallet.coinSpecific.rootAddress);
  });
```

It currently costs 1.33964 ꜩ to create a new Tezos wallet. The fee account pays this amount, which consists of
0.04764 ꜩ in baker fees, 1.035 ꜩ storage fees, and 0.257 ꜩ for allocation fees.

To create a Tezos wallet using the platform API:

```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/txtz/wallet/generate
```

A similar operation needs to be provided to the resultant rootAddress.

### Creating addresses

```javascript
bitgo
  .coin('txtz')
  .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/txtz/wallet/$WALLET/address
```

The creation of receive addresses for Tezos wallets results in additional accounts associated with the main wallet. When
a user receives assets on a receive address, those assets need to be consolidated in the base address of the wallet first
to be spent. See [Consolidate account](/reference/v2walletconsolidateaccountbuild).

### Sending

Funds can only be sent out from the wallet base address. If your wallet has sufficient assets but you are unable to
send, you may need to consolidate the assets from the receive addresses into the base address by calling
[Consolidate account](/reference/v2walletconsolidateaccountbuild) first. The fee address pays fees of transactions sent from the base
wallet address, while fees of consolidation transactions taken from the receive address
itself. The public key of every Tezos receive address must be revealed to the network before it can send transactions.
The address' first consolidation transaction includes the reveal operation. The baker fee for a reveal operation
is 0.00142 ꜩ and for a consolidation transaction is 0.04764 ꜩ.

### Balances

tez (ꜩ) (XTZ) is the native asset of the Tezos blockchain. The base unit of tez is micro tez (or "mutez"):

- 1 micro tez is (<code>10<sup>-6</sup></code>) or 0.000001 tez.
- 1 tez is (<code>10<sup>6</sup></code>) or 1000000 micro tez (1 million).

BitGo supports balances in string format: `balanceString`, `confirmedBalanceString`, and `spendableBalanceString`.

Tezos counts funds stored in the base address of a wallet as "spendable balance". The sum of the balances of the
base address and the receive addresses is the wallet "confirmed balance".

### Transactions

The BitGo Tezos (XTZ) multisig contract currently only supports one sender and one recipient so the `sendMany` is not supported.
