# Celo

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

## Celo

Celo can be accessed with the following coin types:

| Environment     | Coin Type | Faucet                                                                                                               |
| :-------------- | :-------- | :------------------------------------------------------------------------------------------------------------------- |
| Celo Production | celo      |                                                                                                                      |
| Celo Testnet    | tcelo     | <a href="https://faucet.celo.org/celo-sepolia" target="_blank" rel="noreferrer">https://faucet.celo.org/celo-sepolia</a> |

### Explorer
<a href="https://explorer.celo.org/mainnet/" target="_blank" rel="noreferrer">https://explorer.celo.org/mainnet/</a>


### Enterprise fee address

```shell
ENTERPRISEID=585c51a5df8380e0e3082e46

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

Celo uses the same fee address structure as Ethereum. Each enterprise has a fee address that is used to pay for
transaction fees on all Celo wallets in that enterprise. The BitGo website dashboard displays the fee address,
and you must fund it before creating a wallet, address, or sending a transaction.

If the enterprise fee address has an insufficient balance, you cannot create new wallets or addresses, and cannot send
transactions until you fund the fee address. If the balance of your fee address gets too low, you cannot
fund it with one of your own Celo wallets (because you cannot send transactions from your Celo wallet).
BitGo recommends that you create and fund a non-BitGo Celo account, so you can use it to fund your BitGo enterprise fee
address. Any open source Celo wallet can be used to create an account.

> 📘 **Note:** A best practice is to create and fund a non-BitGo Celo account to fund your BitGo enterprise fee address.

> 📘 **Note:** The fee address is a single-signature account, and BitGo creates and owns the private key. 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 Celo wallets. Use this address to pay the fees for creating transactions and addresses.

### Generating wallets

```javascript
bitgo
  .coin('tcelo')
  .wallets()
  .generateWallet({
    label: 'My Test Wallet',
    passphrase: 'secretpassphrase1a5df8380e0e30',
    enterprise: '5612c2beeecf83610b621b90964448cd',
  })
  .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/tcelo/wallet/generate
```

Before you can use a Celo wallet, it must be initialized on the Celo 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.

Until the network confirms the initialization transaction, the wallet is _not_ ready for use, and the receive address is _not_
exposed in the API. 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 Celo wallet while it is initializing or you may lose assets.

### Creating addresses

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

As with Celo wallets, Celo address must be initialized on the Celo blockchain before they can be used.

To deploy a receive address contract, BitGo sends a transaction on the Celo network. Remember that you _must fund_ the
fee address. Like wallet creation process, a Celo address is not immediately usable and so the caller of this function
must wait for the network to confirm the initialization transaction before attempting to fetch, or send to, the address.

> 🚧 **Warning:** Do not use a Celo address while it is initializing or you may lose assets.

### Balances

CELO (CELO) is the native asset of the Celo blockchain. The base unit of CELO is wei:

- 1 wei is (<code>10<sup>-18</sup></code>) or 0.000000000000000001 CELO.
- 1 CELO is (<code>10<sup>18</sup></code>) or 1000000000000000000 wei (1 quintillion).

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

### Transactions

The BitGo Celo multisig contract currently only supports one sender and one recipient so the `sendMany` is not supported.
