# Hedera Hashgraph

Source: https://developers.bitgo.com/docs/hedera-hashgraph

## Hedera Hashgraph

Hedera (HBAR) can be accessed with the following coin types:

| Environment       | Coin Type | Faucet                                                                                                               |
| :---------------- | :-------- | :------------------------------------------------------------------------------------------------------------------- |
| Hedera Production | hbar      | <a href="https://portal.hedera.com/register" target="_blank" rel="noreferrer">https://portal.hedera.com/register</a> |
| Hedera Testnet    | thbar     | <a href="https://portal.hedera.com/register" target="_blank" rel="noreferrer">https://portal.hedera.com/register</a> |

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


### Generating wallets

To create a HBAR wallet using BitGoJS:

```javascript
bitgo
  .coin('thbar')
  .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.baseAddress);
  });
```

Enterprise customers can create HBAR wallets. In production, there is limit of 100 wallets total per
enterprise. In testnet, there is no limit.

> 📘 **Note:** To inquire about increasing your limit, contact BitGo at support@bitgo.com.

Before you can use an HBAR wallet, it must be initialized on the Hedera blockchain. A funding transaction must first be
sent 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. Creating HBAR wallets incurs a fee that BitGo covers for the user.

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 an HBAR wallet while initialization is in progress or you may lose assets.

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

### Creating addresses

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

HBAR receive addresses use a memo which can be attached to a transaction. For each BitGo wallet, an
incrementing string number value is used as the memo. Whenever you create a new address, the response returns the incremented `memoId` in the `coinSpecific` property of the address. HBAR supports alphanumeric `memoId`.

### Balances

HBAR (HBAR) is the native asset of the Hedera blockchain. The base unit of HBAR is tinybar:

- 1 tinybar is (<code>10<sup>-8</sup></code>) or 0.00000001 HBAR.
- 1 HBAR is (<code>10<sup>8</sup></code>) or 100000000 tinybars (100 million).

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